wrong-notebook 2026.11.8-1 → 2026.11.9-2

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 (147) 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/_not-found/page.js.nft.json +1 -1
  10. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  11. package/.next/server/app/admin/page.js.nft.json +1 -1
  12. package/.next/server/app/admin/page_client-reference-manifest.js +1 -1
  13. package/.next/server/app/admin/user/[id]/page.js.nft.json +1 -1
  14. package/.next/server/app/admin/user/[id]/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/api/analyze/route.js.nft.json +1 -1
  16. package/.next/server/app/api/error-items/[id]/figure/route.js.nft.json +1 -1
  17. package/.next/server/app/api/error-items/[id]/fix-latex/route.js.nft.json +1 -1
  18. package/.next/server/app/api/error-items/[id]/geogebra/route.js.nft.json +1 -1
  19. package/.next/server/app/api/error-items/[id]/reanswer/route.js.nft.json +1 -1
  20. package/.next/server/app/api/error-items/[id]/retag/route.js.nft.json +1 -1
  21. package/.next/server/app/api/error-items/[id]/svg-animation/narration/route.js.nft.json +1 -1
  22. package/.next/server/app/api/error-items/[id]/svg-animation/route.js.nft.json +1 -1
  23. package/.next/server/app/api/error-items/route.js.nft.json +1 -1
  24. package/.next/server/app/api/exams/[id]/questions/[questionId]/regenerate/route.js.nft.json +1 -1
  25. package/.next/server/app/api/exams/[id]/results/route.js.nft.json +1 -1
  26. package/.next/server/app/api/exams/[id]/retry/route.js.nft.json +1 -1
  27. package/.next/server/app/api/exams/[id]/route.js.nft.json +1 -1
  28. package/.next/server/app/api/exams/route.js.nft.json +1 -1
  29. package/.next/server/app/api/geogebra-analyze/route.js.nft.json +1 -1
  30. package/.next/server/app/api/import/route.js.nft.json +1 -1
  31. package/.next/server/app/api/import-batches/[id]/confirm-all/route.js.nft.json +1 -1
  32. package/.next/server/app/api/import-batches/[id]/fix-text/route.js.nft.json +1 -1
  33. package/.next/server/app/api/import-batches/[id]/read/route.js.nft.json +1 -1
  34. package/.next/server/app/api/import-batches/[id]/retry/route.js.nft.json +1 -1
  35. package/.next/server/app/api/import-batches/[id]/route.js.nft.json +1 -1
  36. package/.next/server/app/api/import-batches/[id]/start/route.js.nft.json +1 -1
  37. package/.next/server/app/api/import-batches/route.js.nft.json +1 -1
  38. package/.next/server/app/api/import-tasks/[id]/confirm/route.js.nft.json +1 -1
  39. package/.next/server/app/api/import-tasks/[id]/read/route.js.nft.json +1 -1
  40. package/.next/server/app/api/import-tasks/[id]/retry/route.js.nft.json +1 -1
  41. package/.next/server/app/api/import-tasks/[id]/route.js.nft.json +1 -1
  42. package/.next/server/app/api/import-tasks/route.js.nft.json +1 -1
  43. package/.next/server/app/api/notebooks/[id]/retag/route.js.nft.json +1 -1
  44. package/.next/server/app/api/openclaw/batch-upload/route.js.nft.json +1 -1
  45. package/.next/server/app/api/practice/generate/route.js.nft.json +1 -1
  46. package/.next/server/app/api/reanswer/route.js.nft.json +1 -1
  47. package/.next/server/app/api/tasks/route.js.nft.json +1 -1
  48. package/.next/server/app/api/tts/batch/route.js.nft.json +1 -1
  49. package/.next/server/app/error-items/[id]/page.js.nft.json +1 -1
  50. package/.next/server/app/error-items/[id]/page_client-reference-manifest.js +1 -1
  51. package/.next/server/app/eula/page.js.nft.json +1 -1
  52. package/.next/server/app/eula/page_client-reference-manifest.js +1 -1
  53. package/.next/server/app/exams/[id]/page.js.nft.json +1 -1
  54. package/.next/server/app/exams/[id]/page_client-reference-manifest.js +1 -1
  55. package/.next/server/app/exams/[id]/print/page.js.nft.json +1 -1
  56. package/.next/server/app/exams/[id]/print/page_client-reference-manifest.js +1 -1
  57. package/.next/server/app/exams/page.js.nft.json +1 -1
  58. package/.next/server/app/exams/page_client-reference-manifest.js +1 -1
  59. package/.next/server/app/import-batches/[id]/page.js.nft.json +1 -1
  60. package/.next/server/app/import-batches/[id]/page_client-reference-manifest.js +1 -1
  61. package/.next/server/app/import-tasks/[id]/page.js.nft.json +1 -1
  62. package/.next/server/app/import-tasks/[id]/page_client-reference-manifest.js +1 -1
  63. package/.next/server/app/import-tasks/page.js.nft.json +1 -1
  64. package/.next/server/app/import-tasks/page_client-reference-manifest.js +1 -1
  65. package/.next/server/app/initialize/page.js.nft.json +1 -1
  66. package/.next/server/app/initialize/page_client-reference-manifest.js +1 -1
  67. package/.next/server/app/login/page.js.nft.json +1 -1
  68. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  69. package/.next/server/app/notebooks/[id]/add/page.js.nft.json +1 -1
  70. package/.next/server/app/notebooks/[id]/add/page_client-reference-manifest.js +1 -1
  71. package/.next/server/app/notebooks/[id]/page.js.nft.json +1 -1
  72. package/.next/server/app/notebooks/[id]/page_client-reference-manifest.js +1 -1
  73. package/.next/server/app/notebooks/page.js.nft.json +1 -1
  74. package/.next/server/app/notebooks/page_client-reference-manifest.js +1 -1
  75. package/.next/server/app/page.js.nft.json +1 -1
  76. package/.next/server/app/page_client-reference-manifest.js +1 -1
  77. package/.next/server/app/practice/page.js.nft.json +1 -1
  78. package/.next/server/app/practice/page_client-reference-manifest.js +1 -1
  79. package/.next/server/app/print-preview/page.js.nft.json +1 -1
  80. package/.next/server/app/print-preview/page_client-reference-manifest.js +1 -1
  81. package/.next/server/app/register/page.js.nft.json +1 -1
  82. package/.next/server/app/register/page_client-reference-manifest.js +1 -1
  83. package/.next/server/app/review/page.js.nft.json +1 -1
  84. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  85. package/.next/server/app/setup/page.js.nft.json +1 -1
  86. package/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  87. package/.next/server/app/stats/page.js.nft.json +1 -1
  88. package/.next/server/app/stats/page_client-reference-manifest.js +1 -1
  89. package/.next/server/app/tags/page.js.nft.json +1 -1
  90. package/.next/server/app/tags/page_client-reference-manifest.js +1 -1
  91. package/.next/server/chunks/src_lib_import_import-batches_ts_0nq3mn0v5uj28._.js +2 -2
  92. package/.next/server/chunks/src_lib_question_question-deduplication_ts_0gumctesi3szc._.js +1 -1
  93. package/.next/server/chunks/ssr/{_12ho9vlz1_nzo._.js → _0ethdphoh7xqp._.js} +1 -1
  94. package/.next/server/chunks/ssr/_0p3bqrojxwfs0._.js +3 -0
  95. package/.next/server/chunks/ssr/_0r_8p9g00106y._.js +3 -0
  96. package/.next/server/chunks/ssr/_1ctycpq4tb8xw._.js +3 -0
  97. package/.next/server/chunks/ssr/_1dl7pg0vhu_7m._.js +3 -0
  98. package/.next/server/chunks/ssr/{node_modules_133xkxfckw9tf._.js → node_modules_0r81ft4mt93or._.js} +1 -1
  99. package/.next/server/chunks/ssr/{node_modules_heic-to_dist_csp_heic-to_1brtdb7tndxid.js → node_modules_heic-to_dist_csp_heic-to_03m-1das3a4fz.js} +1 -1
  100. package/.next/server/chunks/ssr/src_app_error-items_[id]_page_tsx_04xwwdmyh7_9q._.js +1 -1
  101. package/.next/server/chunks/ssr/src_app_import-batches_[id]_page_tsx_0mhg_vriwmkkw._.js +1 -1
  102. package/.next/server/chunks/ssr/src_app_page_tsx_1chiuahujsxm1._.js +2 -2
  103. package/.next/server/chunks/ssr/src_components_image-cropper_tsx_0pcp8-ifruyx-._.js +1 -1
  104. package/.next/server/chunks/ssr/src_contexts_LanguageContext_tsx_0r6xucmeu1k5z._.js +1 -1
  105. package/.next/server/chunks/ssr/src_lib_i18n_en_ts_08zkpwnoqey5s._.js +1 -1
  106. package/.next/server/middleware-build-manifest.js +3 -3
  107. package/.next/server/pages/500.html +1 -1
  108. package/.next/server/preview-props.json +3 -3
  109. package/.next/server/server-reference-manifest.js +1 -1
  110. package/.next/server/server-reference-manifest.json +1 -1
  111. package/.next/static/chunks/0-3d2l_vcliz4.js +6 -0
  112. package/.next/static/chunks/0b_bdug9u1cxw.js +1 -0
  113. package/.next/static/chunks/0xo3qpipk_k3u.js +1 -0
  114. package/.next/static/chunks/11jjfyt0-zwcn.js +1 -0
  115. package/.next/static/chunks/135mrn0ll7pgh.js +1 -0
  116. package/.next/static/chunks/13oi1micj1ewp.js +1 -0
  117. package/.next/static/chunks/172dko4hv3xbk.js +13 -0
  118. package/.next/static/chunks/{1kzmqap7asc46.js → 19a04m6wxadzm.js} +1 -1
  119. package/.next/static/chunks/2-9lp8_rdefk8.js +9 -0
  120. package/.next/static/chunks/209odxnq_2nok.js +1 -0
  121. package/.next/static/chunks/23h7edvgzvaoi.js +8 -0
  122. package/.next/static/chunks/32hvb4b-e4jpa.js +1 -0
  123. package/.next/static/chunks/334z2x2rojgkd.js +1 -0
  124. package/.next/static/chunks/3lsj4waqfw7eq.js +1 -0
  125. package/.next/static/chunks/3m_jfkz23whuc.js +1 -0
  126. package/package.json +1 -1
  127. package/prisma/seed.db +0 -0
  128. package/.next/server/chunks/ssr/_0a0h6yv1_61zn._.js +0 -3
  129. package/.next/server/chunks/ssr/_0m1jjbrzk71io._.js +0 -3
  130. package/.next/server/chunks/ssr/_14h_732sdmo6b._.js +0 -3
  131. package/.next/server/chunks/ssr/_1hp3fw-gk2r-3._.js +0 -3
  132. package/.next/static/chunks/0a_jerp9yv-om.js +0 -2
  133. package/.next/static/chunks/0cpyqet_sqmdp.js +0 -1
  134. package/.next/static/chunks/0jyyrmsnlj04i.js +0 -13
  135. package/.next/static/chunks/0l8auoibmum0r.js +0 -1
  136. package/.next/static/chunks/0wn8i_n7wpzhy.js +0 -8
  137. package/.next/static/chunks/16qwioc_q7wfz.js +0 -8
  138. package/.next/static/chunks/1ti8akix3yalf.js +0 -1
  139. package/.next/static/chunks/1u6m54j807_cw.js +0 -1
  140. package/.next/static/chunks/2hlvwtql2eiqy.js +0 -1
  141. package/.next/static/chunks/3-gt5s84owxj2.js +0 -1
  142. package/.next/static/chunks/3_wki8y0qb28v.js +0 -1
  143. package/.next/static/chunks/3ios-g8cm_1vz.js +0 -6
  144. package/.next/static/chunks/3mnblmrqi_tcr.js +0 -1
  145. /package/.next/static/{8txIetq9muxlc0OqsgaeI → I4Rw8GasSc6yR7HSWfSnC}/_buildManifest.js +0 -0
  146. /package/.next/static/{8txIetq9muxlc0OqsgaeI → I4Rw8GasSc6yR7HSWfSnC}/_clientMiddlewareManifest.js +0 -0
  147. /package/.next/static/{8txIetq9muxlc0OqsgaeI → I4Rw8GasSc6yR7HSWfSnC}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,864272,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(522016),s=e.i(618566),i=e.i(13285),n=e.i(853138),l=e.i(632781),c=e.i(77071),o=e.i(456420);let d={name:"undo-2",size:24,node:[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]};d.node;let m=(0,o.f)(d),u={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};u.node;let h=(0,o.f)(u);var x=e.i(111110);function p({inputProps:e,created:a}){let{t:s}=(0,x.b)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{type:"file",accept:"image/*",className:"hidden","data-testid":"continuation-input",...e}),a.length>0&&(0,t.jsx)("ul",{className:"space-y-1 rounded-lg border border-primary/40 bg-primary/5 p-3 text-sm","data-testid":"continuation-notice",children:a.map((e,a)=>(0,t.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(i.f,{className:"h-4 w-4 text-primary"}),s.importBatch.continuation.notice.replace("{n}",String(a+2))]}),(0,t.jsxs)(r.default,{href:`/import-batches/${e}`,className:"flex items-center gap-1 text-primary underline-offset-2 hover:underline",children:[s.importBatch.continuation.open,(0,t.jsx)(h,{className:"h-3 w-3"})]})]},e))})]})}let f={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};f.node;let g=(0,o.f)(f),y={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};y.node;let b=(0,o.f)(y);var j=e.i(716327),w=e.i(456539),v=e.i(508734);let k={name:"crop",size:24,node:[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]]};k.node;let N=(0,o.f)(k),B={name:"file-plus-corner",size:24,node:[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]],aliases:["file-plus-2"]};B.node;let S=(0,o.f)(B),C={name:"merge",size:24,node:[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]};C.node;let z=(0,o.f)(C),T={name:"scissors",size:24,node:[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]};T.node;let I=(0,o.f)(T);var A=e.i(328623),R=e.i(759659),$=e.i(263676),M=e.i(793479),E=e.i(110204),q=e.i(967489),F=e.i(624687),P=e.i(411382),D=e.i(978056),U=e.i(54105),_=e.i(772325),O=e.i(213056),H=e.i(282492),L=e.i(825624);let V=P.z.object({x:D.z.number().min(0).max(1),y:D.z.number().min(0).max(1),width:D.z.number().min(.01).max(1),height:D.z.number().min(.01).max(1)}).refine(e=>e.x+e.width<=1.0001&&e.y+e.height<=1.0001,{message:"REGION_OUT_OF_BOUNDS"}),K=["unclear","partial","unlocated"],G=U.z.string().max(1572864,"DRAFT_IMAGE_TOO_LARGE").regex(/^data:image\/(?:jpeg|png|webp);base64,[A-Za-z0-9+/]+=*$/,"DRAFT_IMAGE_INVALID"),Q=P.z.object({original:U.z.string().max(2e4),text:U.z.string().max(2e4),uncertain:_.z.array(U.z.string().max(200)).max(20)}),Y=P.z.object({key:U.z.string().regex(/^[A-Za-z0-9_-]{1,40}$/),label:U.z.string().max(20).nullable(),text:U.z.string().max(2e4),material:U.z.string().max(2e4).nullable(),section:U.z.string().max(500).nullable(),selected:O.z.boolean(),regions:_.z.array(V).max(4),hasFigure:O.z.boolean(),flags:_.z.array(H.z.enum(K)).max(K.length),fix:Q.nullish(),answer:U.z.string().max(2e4).nullish(),analysis:U.z.string().max(2e4).nullish(),knowledgePoints:_.z.array(U.z.string().max(200)).max(100).optional(),difficultyStars:D.z.number().int().min(1).max(5).nullish(),questionType:U.z.string().max(200).nullish(),wrongAnswer:U.z.string().max(2e4).nullish(),image:G.nullish()}),J=["blurry","partial","truncated","tooMany"];function W(e=[]){let t=new Set(e);for(;;){let e=`q${Math.random().toString(36).slice(2,10)}`;if(!t.has(e))return e}}function X(e,t){return"image"===t?e.regions.length>0:e.text.trim().length>0}function Z(e,t){return e.items.filter(e=>e.selected&&X(e,t))}function ee(e,t){return{...e,items:t}}function et(e,t){return e.items.findIndex(e=>e.key===t)}function ea(e,t,a){return ee(e,e.items.map(e=>{if(e.key!==t)return e;let r={...e,...a};return void 0!==a.text&&(r.text=a.text.slice(0,2e4),r.text!==e.text&&(r.fix=null)),void 0!==a.answer&&(r.answer=a.answer?.slice(0,2e4)??null),void 0!==a.analysis&&(r.analysis=a.analysis?.slice(0,2e4)??null),void 0!==a.knowledgePoints&&(r.knowledgePoints=a.knowledgePoints.slice(0,100).map(e=>e.slice(0,200))),void 0!==a.difficultyStars&&(r.difficultyStars=a.difficultyStars),void 0!==a.questionType&&(r.questionType=a.questionType),void 0!==a.wrongAnswer&&(r.wrongAnswer=a.wrongAnswer?.slice(0,2e4)??null),void 0!==a.regions&&(r.regions=a.regions.slice(0,4),r.flags=r.regions.length>0?e.flags.filter(e=>"unlocated"!==e):[...new Set([...e.flags,"unlocated"])]),r}))}function er(e,t){return ee(e,e.items.filter(e=>e.key!==t))}function es(e,t,a){let r=et(e,t),s=r+a;if(r<0||s<0||s>=e.items.length)return e;let i=[...e.items];return[i[r],i[s]]=[i[s],i[r]],ee(e,i)}function ei(e,t){return[e,t].filter(e=>e?.trim()).join("\n").trim()||null}function en(e,t){let a=t?new Set(t):null,r=!1,s=e.items.map(e=>e.fix&&(!a||a.has(e.key))?(r=!0,e.fix.original===e.text?{...e,text:e.fix.text,fix:null}:{...e,fix:null}):e);return r?ee(e,s):e}P.z.object({items:_.z.array(Y).max(L.S),ignored:_.z.array(U.z.string().max(2e4)).max(200),warnings:_.z.array(H.z.enum(J)).max(J.length)}).superRefine((e,t)=>{let a=new Set;for(let r of e.items)a.has(r.key)&&t.addIssue({code:"custom",message:"DUPLICATE_ITEM_KEY"}),a.add(r.key)});var el=e.i(401280);let ec=[1,2,3,4,5],eo=[el.O,...el.V];function ed({item:e,onEdit:r}){let{t:s}=(0,x.b)(),[i,n]=(0,a.useState)(!1),l=!!(e.answer?.trim()||e.analysis?.trim()||e.knowledgePoints?.length||null!=e.difficultyStars||e.wrongAnswer?.trim());return(0,t.jsxs)("div",{className:"rounded-lg border border-dashed p-2",children:[(0,t.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between text-xs font-medium text-muted-foreground",onClick:()=>n(e=>!e),"aria-expanded":i,children:[(0,t.jsx)("span",{children:s.importBatch.fields.title}),i?(0,t.jsx)(w.f,{className:"h-3.5 w-3.5"}):(0,t.jsx)(j.f,{className:"h-3.5 w-3.5"})]}),i&&(0,t.jsxs)("div",{className:"mt-2 space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(E.f,{htmlFor:`${e.key}-type`,className:"text-xs",children:s.questionType.label}),(0,t.jsxs)(q.d,{value:e.questionType??el.O,onValueChange:t=>r(a=>ea(a,e.key,{questionType:t===el.O?null:(0,el.P)(t)})),children:[(0,t.jsx)(q.P,{className:"h-8 w-full text-sm","aria-label":s.questionType.label,children:(0,t.jsx)(q.U,{})}),(0,t.jsx)(q.r,{children:eo.map(e=>(0,t.jsx)(q.T,{value:e,children:e===el.O?s.questionType.notSet:s.questionType.names[e]},e))})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(E.f,{htmlFor:`${e.key}-answer`,className:"text-xs",children:s.importBatch.fields.answer}),(0,t.jsx)(F.f,{id:`${e.key}-answer`,value:e.answer??"",onChange:t=>r(a=>ea(a,e.key,{answer:t.target.value})),className:"min-h-16 text-sm",placeholder:s.importBatch.fields.answerPlaceholder})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(E.f,{htmlFor:`${e.key}-analysis`,className:"text-xs",children:s.importBatch.fields.analysis}),(0,t.jsx)(F.f,{id:`${e.key}-analysis`,value:e.analysis??"",onChange:t=>r(a=>ea(a,e.key,{analysis:t.target.value})),className:"min-h-20 text-sm",placeholder:s.importBatch.fields.analysisPlaceholder})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(E.f,{htmlFor:`${e.key}-knowledge`,className:"text-xs",children:s.importBatch.fields.knowledgePoints}),(0,t.jsx)(M.f,{id:`${e.key}-knowledge`,value:(e.knowledgePoints??[]).join(", "),onChange:t=>r(a=>ea(a,e.key,{knowledgePoints:t.target.value.split(/[,,、]/).map(e=>e.trim()).filter(Boolean)})),className:"text-sm",placeholder:s.importBatch.fields.knowledgePlaceholder})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(E.f,{className:"text-xs",children:s.importBatch.fields.difficulty}),(0,t.jsxs)(q.d,{value:null!=e.difficultyStars?String(e.difficultyStars):"none",onValueChange:t=>r(a=>ea(a,e.key,{difficultyStars:"none"===t?null:Number(t)})),children:[(0,t.jsx)(q.P,{className:"h-8 w-full text-sm","aria-label":s.importBatch.fields.difficulty,children:(0,t.jsx)(q.U,{})}),(0,t.jsxs)(q.r,{children:[(0,t.jsx)(q.T,{value:"none",children:s.importBatch.fields.difficultyNone}),ec.map(e=>(0,t.jsx)(q.T,{value:String(e),children:"★".repeat(e)},e))]})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(E.f,{htmlFor:`${e.key}-wrong`,className:"text-xs",children:s.importBatch.fields.wrongAnswer}),(0,t.jsx)(F.f,{id:`${e.key}-wrong`,value:e.wrongAnswer??"",onChange:t=>r(a=>ea(a,e.key,{wrongAnswer:t.target.value})),className:"min-h-16 text-sm",placeholder:s.importBatch.fields.wrongAnswerPlaceholder})]})]}),!i&&l&&(0,t.jsx)("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:[e.answer?.trim()&&s.importBatch.fields.answer,e.analysis?.trim()&&s.importBatch.fields.analysis,e.knowledgePoints?.length&&`${s.importBatch.fields.knowledgePoints}(${e.knowledgePoints.length})`,null!=e.difficultyStars&&"★".repeat(e.difficultyStars),e.wrongAnswer?.trim()&&s.importBatch.fields.wrongAnswer].filter(Boolean).join(" · ")})]})}var em=e.i(975157);function eu({imageUrl:e,imageSize:a,regions:r,className:s}){let i=function(e){if(0===e.length)return null;let t=Math.min(...e.map(e=>e.x)),a=Math.min(...e.map(e=>e.y));return{x:t,y:a,width:Math.max(...e.map(e=>e.x+e.width))-t,height:Math.max(...e.map(e=>e.y+e.height))-a}}(r);if(!i)return null;let n=i.width*a.width/Math.max(1,i.height*a.height);return(0,t.jsx)("div",{className:(0,em.f)("relative w-full overflow-hidden rounded-md border bg-white",s),style:{aspectRatio:String(Math.max(.25,Math.min(8,n)))},"aria-hidden":!0,children:(0,t.jsx)("img",{src:e,alt:"",className:"absolute max-w-none select-none",draggable:!1,style:{width:`${100/i.width}%`,height:`${100/i.height}%`,left:`${-i.x/i.width*100}%`,top:`${-i.y/i.height*100}%`}})})}var eh=e.i(689664),ex=e.i(519455);function ep(e,t,a){if(!a)return;let r=e[e.length-1];r&&r.type===t?r.text+=a:e.push({type:t,text:a})}function ef({fix:e,onAccept:r,onReject:s}){let{t:i}=(0,x.b)(),n=(0,a.useMemo)(()=>(function(e,t){let a=Array.from(e),r=Array.from(t),s=0;for(;s<a.length&&s<r.length&&a[s]===r[s];)s++;let i=a.length,n=r.length;for(;i>s&&n>s&&a[i-1]===r[n-1];)i--,n--;let l=[];ep(l,"same",a.slice(0,s).join(""));let c=a.slice(s,i),o=r.slice(s,n),d=c.length,m=o.length;if(d*m>2e6)ep(l,"removed",c.join("")),ep(l,"added",o.join(""));else{let e=m+1,t=new Uint32Array((d+1)*e);for(let a=d-1;a>=0;a--)for(let r=m-1;r>=0;r--)t[a*e+r]=c[a]===o[r]?t[(a+1)*e+r+1]+1:Math.max(t[(a+1)*e+r],t[a*e+r+1]);let a=0,r=0;for(;a<d&&r<m;)c[a]===o[r]?(ep(l,"same",c[a]),a++,r++):t[(a+1)*e+r]>=t[a*e+r+1]?ep(l,"removed",c[a++]):ep(l,"added",o[r++]);ep(l,"removed",c.slice(a).join("")),ep(l,"added",o.slice(r).join(""))}return ep(l,"same",a.slice(i).join("")),l})(e.original,e.text),[e.original,e.text]);return(0,t.jsxs)("div",{className:"space-y-2 rounded-lg border border-violet-300 bg-violet-50/60 p-2 text-sm dark:border-violet-800 dark:bg-violet-950/30","data-testid":"text-fix-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-1",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1 text-xs font-medium text-violet-700 dark:text-violet-300",children:[(0,t.jsx)(A.f,{className:"h-3 w-3"}),i.importBatch.fixText.title]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i.importBatch.fixText.legend})]}),(0,t.jsx)("p",{className:"whitespace-pre-wrap break-words font-mono text-sm","data-testid":"text-fix-diff",children:n.map((e,a)=>"same"===e.type?(0,t.jsx)("span",{children:e.text},a):"removed"===e.type?(0,t.jsx)("del",{className:"bg-red-100 text-red-700 decoration-red-500 dark:bg-red-950/50 dark:text-red-300",children:e.text},a):(0,t.jsx)("ins",{className:"bg-emerald-100 text-emerald-800 no-underline dark:bg-emerald-950/50 dark:text-emerald-300",children:e.text},a))}),e.uncertain.length>0&&(0,t.jsxs)("div",{className:"text-xs text-amber-800 dark:text-amber-300",children:[(0,t.jsx)("span",{children:i.importBatch.fixText.uncertain}),(0,t.jsx)("ul",{className:"mt-0.5 list-inside list-disc",children:e.uncertain.map((e,a)=>(0,t.jsx)("li",{className:"break-words",children:e},a))})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxs)(ex.f,{type:"button",size:"sm",onClick:r,children:[(0,t.jsx)(eh.f,{className:"mr-1 h-4 w-4"}),i.importBatch.fixText.accept]}),(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"ghost",onClick:s,children:[(0,t.jsx)($.X,{className:"mr-1 h-4 w-4"}),i.importBatch.fixText.reject]})]})]})}var eg=e.i(487486),ey=e.i(257428);function eb({image:e,alt:r,onRemove:s}){let[i,n]=(0,a.useState)(!1);return(0,t.jsxs)("div",{className:"relative inline-block",children:[(0,t.jsx)("button",{type:"button",onClick:()=>n(!0),className:"block overflow-hidden rounded-lg border","aria-label":r,children:(0,t.jsx)("img",{src:e,alt:r,className:"max-h-32 w-auto object-contain"})}),(0,t.jsx)(ex.f,{type:"button",size:"icon",variant:"ghost",className:"absolute -right-2 -top-2 h-6 w-6 rounded-full bg-background border shadow-sm",onClick:s,"aria-label":"删除图片",children:(0,t.jsx)($.X,{className:"h-3 w-3"})}),i&&(0,t.jsx)("button",{type:"button",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",onClick:()=>n(!1),"aria-label":"关闭大图",children:(0,t.jsx)("img",{src:e,alt:r,className:"max-h-full max-w-full object-contain"})})]})}function ej({item:e,index:r,total:s,source:i,expanded:c,onToggleExpand:o,onEdit:d,image:m,onAdjustRegion:u,highlighted:h,onFixText:p,fixing:f,fixBusy:y,onContinue:k,continuing:B}){let{t:C}=(0,x.b)(),T=(0,a.useRef)(null),$=X(e,i),M=`draft-item-${e.key}`,E=e.fix&&e.fix.original===e.text?e.fix:null;return(0,t.jsxs)("li",{id:M,className:(0,em.f)("rounded-xl border bg-card p-3 transition-colors",!e.selected&&"opacity-70",h&&"border-primary ring-2 ring-primary/30"),"data-testid":"draft-item","data-selected":e.selected,"data-fix-pending":E?"true":void 0,children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(ey.f,{className:"mt-1 h-5 w-5",checked:e.selected,disabled:!$,onCheckedChange:t=>d(a=>{var r,s;return r=e.key,s=!0===t,ee(a,a.items.map(e=>e.key===r?{...e,selected:s}:e))}),"aria-label":C.importBatch.question.replace("{index}",String(r+1))}),(0,t.jsxs)("button",{type:"button",className:"min-w-0 flex-1 text-left",onClick:o,"aria-expanded":c,"aria-controls":`${M}-body`,children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,t.jsx)("span",{className:"font-semibold",children:C.importBatch.question.replace("{index}",String(r+1))}),e.label&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:C.importBatch.originalLabel.replace("{label}",e.label)}),e.material&&(0,t.jsx)(eg.f,{variant:"secondary",children:C.importBatch.material}),e.hasFigure&&(0,t.jsx)(eg.f,{variant:"outline",children:C.importBatch.hasFigure}),E&&(0,t.jsx)(eg.f,{className:"bg-violet-600 text-white hover:bg-violet-600",children:C.importBatch.fixText.pending}),e.section&&(0,t.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:e.section.split("\n")[0]})]}),!c&&!E&&e.text&&(0,t.jsx)("p",{className:"mt-1 line-clamp-3 whitespace-pre-line break-words text-sm text-muted-foreground",children:e.text}),e.flags.length>0&&(0,t.jsx)("ul",{className:"mt-1 space-y-0.5",children:e.flags.map(e=>(0,t.jsxs)("li",{className:"flex items-center gap-1 text-xs text-amber-700 dark:text-amber-300",children:[(0,t.jsx)(n.f,{className:"h-3 w-3 shrink-0"}),C.importBatch.flags[e]]},e))})]}),(0,t.jsx)(ex.f,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 shrink-0",onClick:o,"aria-label":c?C.importBatch.collapse:C.importBatch.edit,children:c?(0,t.jsx)(w.f,{className:"h-4 w-4"}):(0,t.jsx)(j.f,{className:"h-4 w-4"})})]}),m&&e.regions.length>0&&(0,t.jsx)("button",{type:"button",className:"mt-2 block w-full max-w-md pl-8",onClick:u,"aria-label":C.importBatch.adjustRegion,children:(0,t.jsx)(eu,{imageUrl:m.url,imageSize:m,regions:e.regions,className:"max-h-48"})}),k&&(0,t.jsx)("div",{className:"mt-2 pl-8",children:(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:k,disabled:B,"data-testid":"draft-continue",children:[B?(0,t.jsx)(l.f,{className:"mr-1 h-4 w-4 animate-spin"}):(0,t.jsx)(S,{className:"mr-1 h-4 w-4"}),B?C.importBatch.continuation.working:C.importBatch.continuation.button]})}),E&&(0,t.jsx)("div",{className:"mt-2 pl-8",children:(0,t.jsx)(ef,{fix:E,onAccept:()=>d(t=>en(t,[e.key])),onReject:()=>d(t=>{var a;return a=e.key,ee(t,t.items.map(e=>e.key===a&&e.fix?{...e,fix:null}:e))})})}),c&&(0,t.jsxs)("div",{id:`${M}-body`,className:"mt-3 space-y-3 pl-8",children:[e.material&&(0,t.jsxs)("div",{className:"rounded-lg bg-muted/60 p-2 text-sm",children:[(0,t.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2",children:[(0,t.jsxs)("span",{className:"text-xs font-medium",children:[C.importBatch.material," · ",C.importBatch.materialHint]}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>d(t=>ea(t,e.key,{material:null})),children:C.importBatch.removeMaterial})]}),(0,t.jsx)("p",{className:"line-clamp-6 whitespace-pre-line break-words text-muted-foreground",children:e.material})]}),"text"===i?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(F.f,{ref:T,"aria-label":C.importBatch.questionText,value:e.text,onChange:t=>d(a=>ea(a,e.key,{text:t.target.value}),`text-${e.key}`),className:"min-h-28 font-mono text-sm"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:C.importBatch.splitHint}),e.image&&(0,t.jsx)(eb,{image:e.image,alt:C.importBatch.questionImage,onRemove:()=>d(t=>ea(t,e.key,{image:null}))}),(0,t.jsx)(ed,{item:e,onEdit:e=>d(e)})]}):(0,t.jsxs)(t.Fragment,{children:[e.text&&(0,t.jsx)("p",{className:"whitespace-pre-line break-words text-sm text-muted-foreground",children:e.text}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:C.importBatch.imageTextHint})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:["text"===i?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:()=>{let t=T.current?.selectionStart??0;d(a=>(function(e,t,a){let r=et(e,t);if(r<0||e.items.length>=L.S)return e;let s=e.items[r],i=s.text.slice(0,a).replace(/\s+$/,""),n=s.text.slice(a).replace(/^\s+/,"");if(!i||!n)return e;let l={...s,key:W(e.items.map(e=>e.key)),label:null,text:n,regions:[],flags:s.regions.length>0?["unlocated"]:[],selected:!(s.regions.length>0)&&s.selected,answer:null,analysis:null,knowledgePoints:void 0,difficultyStars:null,questionType:null,wrongAnswer:null,fix:null},c=[...e.items];return c.splice(r,1,{...s,text:i,fix:null},l),ee(e,c)})(a,e.key,t))},children:[(0,t.jsx)(I,{className:"mr-1 h-4 w-4"}),C.importBatch.splitHere]}),p&&(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:p,disabled:y||!e.text.trim(),children:[f?(0,t.jsx)(l.f,{className:"mr-1 h-4 w-4 animate-spin"}):(0,t.jsx)(A.f,{className:"mr-1 h-4 w-4"}),f?C.importBatch.fixText.running:C.importBatch.fixText.one]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:u,children:[(0,t.jsx)(N,{className:"mr-1 h-4 w-4"}),e.regions.length?C.importBatch.adjustRegion:C.importBatch.locate]}),(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:()=>d(t=>(function(e,t){let a=et(e,t);if(a<0||e.items.length>=L.S)return e;let r=e.items[a],s={...r,key:W(e.items.map(e=>e.key)),label:null,regions:r.regions.map(e=>({...e}))},i=[...e.items];return i.splice(a+1,0,s),ee(e,i)})(t,e.key)),children:[(0,t.jsx)(v.f,{className:"mr-1 h-4 w-4"}),C.importBatch.duplicate]})]}),(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",disabled:0===r,onClick:()=>d(t=>(function(e,t){let a=et(e,t);if(a<=0)return e;let r=e.items[a-1],s=e.items[a],i={...r,text:[r.text,s.text].filter(e=>e.trim()).join("\n").slice(0,2e4),material:r.material??s.material,selected:r.selected||s.selected,regions:[...r.regions,...s.regions].slice(0,4),hasFigure:r.hasFigure||s.hasFigure,flags:[...new Set([...r.flags,...s.flags])].filter(e=>"unlocated"!==e||r.regions.length+s.regions.length===0),answer:ei(r.answer,s.answer)?.slice(0,2e4)??null,analysis:ei(r.analysis,s.analysis)?.slice(0,2e4)??null,knowledgePoints:[...new Set([...r.knowledgePoints??[],...s.knowledgePoints??[]])].slice(0,100),difficultyStars:r.difficultyStars??s.difficultyStars,questionType:r.questionType??s.questionType,wrongAnswer:ei(r.wrongAnswer,s.wrongAnswer)?.slice(0,2e4)??null,fix:null},n=[...e.items];return n.splice(a-1,2,i),ee(e,n)})(t,e.key)),children:[(0,t.jsx)(z,{className:"mr-1 h-4 w-4"}),C.importBatch.mergeUp]}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",disabled:0===r,onClick:()=>d(t=>es(t,e.key,-1)),"aria-label":C.importBatch.moveUp,children:(0,t.jsx)(b,{className:"h-4 w-4"})}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",disabled:r===s-1,onClick:()=>d(t=>es(t,e.key,1)),"aria-label":C.importBatch.moveDown,children:(0,t.jsx)(g,{className:"h-4 w-4"})}),(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>d(t=>er(t,e.key)),children:[(0,t.jsx)(R.f,{className:"mr-1 h-4 w-4"}),C.importBatch.delete]})]})]})]})}function ew({count:e,missingRegions:a,pendingFixes:r=0,imageQuestions:s=0,confirmBeforeImport:i,starting:n,onStart:c,onDiscard:o,source:d,analysisMode:m,onAnalysisModeChange:u,hasTargetNotebook:h}){let{t:p}=(0,x.b)(),f="none"===m,g="tags"===m,y=f?(i?p.importBatch.startNoneReview:p.importBatch.startNoneAuto).replace("{count}",String(e)):g?(i?p.importBatch.startTagsReview:p.importBatch.startTagsAuto).replace("{count}",String(e)):(i?p.importBatch.startReview:p.importBatch.startAuto).replace("{count}",String(e)),b=0===e?p.importBatch.nothingSelected:a>0?p.importBatch.needsRegion.replace("{count}",String(a)):f?p.importBatch.startHintNone:g?p.importBatch.startHintTags:r>0?p.importBatch.fixText.pendingHint.replace("{count}",String(r)):s>0?p.importBatch.startHintAiWithImage:i?p.importBatch.startHintReview:p.importBatch.startHintAuto,j=(f||g)&&!h,w=j?p.importBatch.startNoneNoTarget:void 0;return(0,t.jsx)("div",{className:"fixed inset-x-0 bottom-[calc(4rem+env(safe-area-inset-bottom))] z-30 border-t bg-background/95 py-3 pl-4 pr-16 shadow-[0_-4px_12px_rgba(0,0,0,0.06)] backdrop-blur md:sticky md:bottom-4 md:rounded-xl md:border md:px-4","data-testid":"draft-start-bar",children:(0,t.jsxs)("div",{className:"mx-auto flex max-w-4xl flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:["text"===d&&(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",role:"radiogroup","aria-label":p.importBatch.analysisModeLabel,children:[(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":"ai"===m,disabled:!!n,onClick:()=>u("ai"),className:`rounded-full border px-2.5 py-1 transition-colors ${"ai"===m?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:border-primary/40"}`,"data-testid":"draft-analysis-ai",children:p.importBatch.analysisAi}),(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":g,disabled:!!n||j,onClick:()=>u("tags"),title:w,className:`rounded-full border px-2.5 py-1 transition-colors ${g?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:border-primary/40"} disabled:cursor-not-allowed disabled:opacity-50`,"data-testid":"draft-analysis-tags",children:p.importBatch.analysisTags}),(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":f,disabled:!!n||j,onClick:()=>u("none"),title:w,className:`rounded-full border px-2.5 py-1 transition-colors ${f?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:border-primary/40"} disabled:cursor-not-allowed disabled:opacity-50`,"data-testid":"draft-analysis-none",children:p.importBatch.analysisNone})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground md:max-w-md","data-testid":"draft-start-hint",children:n??b})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(ex.f,{type:"button",variant:"ghost",onClick:o,disabled:!!n,className:"shrink-0",children:p.importBatch.discard}),(0,t.jsxs)(ex.f,{type:"button",onClick:c,disabled:0===e||!!n,className:"min-w-0 flex-1 md:flex-none","data-testid":"draft-start",children:[n?(0,t.jsx)(l.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(A.f,{className:"mr-2 h-4 w-4"}),(0,t.jsx)("span",{className:"truncate",children:y})]})]})]})})}function ev({ignored:e,onRestore:r}){let{t:s}=(0,x.b)(),[i,n]=(0,a.useState)(!1);return 0===e.length?null:(0,t.jsxs)("section",{className:"rounded-xl border p-3",children:[(0,t.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between text-left text-sm font-medium",onClick:()=>n(e=>!e),"aria-expanded":i,children:[s.importBatch.ignoredTitle.replace("{count}",String(e.length)),i?(0,t.jsx)(w.f,{className:"h-4 w-4"}):(0,t.jsx)(j.f,{className:"h-4 w-4"})]}),i&&(0,t.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:s.importBatch.ignoredHint}),(0,t.jsx)("ul",{className:"space-y-2",children:e.map((e,a)=>(0,t.jsxs)("li",{className:"flex items-start gap-2 rounded-lg bg-muted/50 p-2 text-sm",children:[(0,t.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words text-muted-foreground",children:e}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"outline",className:"h-7 shrink-0",onClick:()=>r(a),children:s.importBatch.addAsQuestion})]},`${a}-${e.slice(0,20)}`))})]})]})}function ek({imageUrl:e,items:r,onSelectItem:s,highlightedKey:i}){let{t:n}=(0,x.b)(),[l,c]=(0,a.useState)(!0);return(0,t.jsxs)("section",{className:"rounded-xl border bg-card p-3","data-testid":"page-image-overview",children:[(0,t.jsxs)(ex.f,{type:"button",variant:"ghost",size:"sm",className:"mb-2 h-8 px-2 md:hidden",onClick:()=>c(e=>!e),"aria-expanded":l,children:[l?(0,t.jsx)(w.f,{className:"mr-1 h-4 w-4"}):(0,t.jsx)(j.f,{className:"mr-1 h-4 w-4"}),l?n.importBatch.hideImage:n.importBatch.showImage]}),(0,t.jsxs)("div",{className:(0,em.f)("relative mx-auto w-fit max-w-full",!l&&"hidden md:block"),children:[(0,t.jsx)("img",{src:e,alt:"",className:"block max-h-[70vh] max-w-full select-none rounded-md",draggable:!1}),r.map((e,a)=>e.regions.map((r,l)=>(0,t.jsx)("button",{type:"button",onClick:()=>s(e.key),className:(0,em.f)("absolute rounded-sm border-2 transition-colors",e.selected?"border-primary bg-primary/10":"border-dashed border-muted-foreground/70 bg-transparent",i===e.key&&"border-amber-500 bg-amber-400/20"),style:{left:`${100*r.x}%`,top:`${100*r.y}%`,width:`${100*r.width}%`,height:`${100*r.height}%`},"aria-label":n.importBatch.question.replace("{index}",String(a+1)),children:0===l&&(0,t.jsx)("span",{className:(0,em.f)("absolute -left-0.5 -top-0.5 rounded-br-md px-1.5 text-xs font-semibold text-white",e.selected?"bg-primary":"bg-muted-foreground"),children:a+1})},`${e.key}-${l}`)))]})]})}var eN=e.i(232660),eB=e.i(776639);let eS={x:.1,y:.1,width:.8,height:.3};function eC(e){return{unit:"%",x:100*e.x,y:100*e.y,width:100*e.width,height:100*e.height}}function ez(e){let t={x:e.x/100,y:e.y/100,width:e.width/100,height:e.height/100};return t.width>=.01&&t.height>=.01?t:null}function eT({open:e,imageUrl:r,regions:s,onClose:i,onSave:n}){let{t:l}=(0,x.b)(),[o,d]=(0,a.useState)(()=>(s.length?s:[eS]).map(eC)),[m,u]=(0,a.useState)(0),h=o[Math.min(m,o.length-1)];return(0,t.jsx)(eB.N,{open:e,onOpenChange:e=>!e&&i(),children:(0,t.jsxs)(eB.d,{className:"flex h-[90vh] max-w-3xl flex-col gap-0 p-0",children:[(0,t.jsxs)(eB.s,{className:"shrink-0 border-b p-4",children:[(0,t.jsx)(eB.F,{children:l.importBatch.regionDialogTitle}),(0,t.jsx)(eB.C,{children:l.importBatch.regionDialogHint})]}),(0,t.jsx)("div",{className:"min-h-0 flex-1 overflow-auto bg-black p-3",children:(0,t.jsx)("div",{className:"mx-auto w-fit",children:(0,t.jsx)(eN.f,{crop:h,onChange:(e,t)=>d(e=>e.map((e,a)=>a===m?t:e)),children:(0,t.jsx)("img",{src:r,alt:"",className:"block max-h-[65vh] max-w-full",draggable:!1})})})}),(0,t.jsxs)("div",{className:"shrink-0 space-y-3 border-t p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[o.map((e,a)=>(0,t.jsx)("button",{type:"button",onClick:()=>u(a),className:(0,em.f)("rounded-md border px-3 py-1 text-sm",a===m?"border-primary bg-primary/10 font-medium":"text-muted-foreground"),children:l.importBatch.regionTab.replace("{index}",String(a+1))},a)),o.length<4&&(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"ghost",onClick:()=>{d(e=>[...e,eC(eS)]),u(o.length)},children:[(0,t.jsx)(c.f,{className:"mr-1 h-4 w-4"}),l.importBatch.addRegion]}),o.length>1&&(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>{d(e=>e.filter((e,t)=>t!==m)),u(0)},children:[(0,t.jsx)(R.f,{className:"mr-1 h-4 w-4"}),l.importBatch.removeRegion]})]}),(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(ex.f,{type:"button",variant:"outline",onClick:i,children:l.common.cancel}),(0,t.jsx)(ex.f,{type:"button",onClick:()=>{let e=o.map(ez).filter(e=>null!==e);e.length&&n(e)},children:l.importBatch.saveRegion})]})]})]})})}let eI={name:"check-check",size:24,node:[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]};eI.node;let eA=(0,o.f)(eI);function eR({targetCount:e,pendingCount:a,fixing:r,onFix:s,onAcceptAll:i}){let{t:n}=(0,x.b)();return(0,t.jsxs)("div",{className:"space-y-1 rounded-lg border border-dashed p-3","data-testid":"text-fix-toolbar",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:s,disabled:r||0===e,children:[r?(0,t.jsx)(l.f,{className:"mr-1 h-4 w-4 animate-spin"}):(0,t.jsx)(A.f,{className:"mr-1 h-4 w-4"}),r?n.importBatch.fixText.running:n.importBatch.fixText.selected.replace("{count}",String(e))]}),a>0&&(0,t.jsxs)(ex.f,{type:"button",size:"sm",onClick:i,children:[(0,t.jsx)(eA,{className:"mr-1 h-4 w-4"}),n.importBatch.fixText.acceptAll.replace("{count}",String(a))]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:n.importBatch.fixText.hint})]})}var e$=e.i(767077),eM=e.i(499930),eE=e.i(294114),eq=e.i(201276),eF=e.i(119472),eP=e.i(213761),eD=e.i(132411),eU=e.i(41931);function e_(e){return`import-batch-text-fix:${e}`}function eO(e){try{sessionStorage.removeItem(e_(e))}catch{}}function eH({batch:e,draft:r,onEdit:s,onUndo:i,canUndo:o,saveState:d,image:u,confirmBeforeImport:h,starting:f,onStart:g,onDiscard:y,analysisMode:b,onAnalysisModeChange:j,hasConflictCopy:w,onRestoreConflict:v,onDismissConflict:k}){let{t:N}=(0,x.b)(),B=e.source,[S,C]=(0,a.useState)(null),[z,T]=(0,a.useState)(null),[I,A]=(0,a.useState)(null),R=r.items.filter(e=>e.selected&&X(e,B)),$=r.items.length>0&&r.items.every(e=>e.selected||!X(e,B)),M=r.items.filter(e=>e.selected&&!X(e,B)).length,E=function(e,t,r){let{t:s}=(0,x.b)(),[i,n]=(0,a.useState)([]),l=`import-batch:${e}:fix-text`,{running:c,refresh:o}=(0,eD.f)(l),d=(0,a.useRef)(!1),m=(0,a.useRef)(!1),u=(0,a.useRef)(!1),h=(0,a.useCallback)(e=>{e.fixes.length>0&&r(t=>{let a,r,s;return a=new Map(e.fixes.map(e=>[e.key,e])),r=!1,s=t.items.map(e=>{let t=a.get(e.key);return t&&e.text===t.original&&t.text!==t.original?(r=!0,{...e,fix:{original:t.original,text:t.text,uncertain:t.uncertain}}):e}),r?ee(t,s):t});let t=[e.fixes.length>0?s.importBatch.fixText.done.replace("{count}",String(e.fixes.length)):null,e.unchanged.length>0?s.importBatch.fixText.unchanged.replace("{count}",String(e.unchanged.length)):null,e.failed.length>0?s.importBatch.fixText.failed.replace("{count}",String(e.failed.length)):null].filter(Boolean).join(" ");e.failed.length>0?eE.c.warning(t):eE.c.success(t)},[r,s]),p=(0,a.useCallback)(async a=>{let r=t.items.filter(e=>a.includes(e.key)&&e.text.trim()).map(e=>({key:e.key,text:e.text}));if(0===r.length)return;let i=(0,eU.j)();var l={requestId:i,keys:r.map(e=>e.key)};try{sessionStorage.setItem(e_(e),JSON.stringify(l))}catch{}n(r.map(e=>e.key)),d.current=!0;try{let t=await (0,eF.$)(e,r,i);h(t)}catch(e){e instanceof eU.a&&409===e.status&&e.data?.code==="TASK_ALREADY_RUNNING"?(eE.c.info(s.errors.TASK_ALREADY_RUNNING),await o()):(eq.V.error("[ImportBatch]","Text fix failed",{error:e}),eE.c.error((0,e$.f)(e,s)))}finally{n([])}},[e,t,h,o,s]);(0,a.useEffect)(()=>{if(!c)return;let t=function(e){try{let t=sessionStorage.getItem(e_(e));return t?JSON.parse(t):null}catch{return null}}(e);if(t?.requestId&&!d.current){let a=Date.now()+6e5;(0,eU.u)(t.requestId,a,Error("REQUEST_NOT_FOUND")).then(t=>{u.current=!0,h(t),eO(e)}).catch(e=>{eq.V.warn("[ImportBatch]","Text fix recovery failed",{error:e})})}},[c,e,h]);let f=(0,a.useRef)(!1);return(0,a.useEffect)(()=>{if(c){f.current=!0,m.current=!1;return}f.current&&(f.current=!1,eO(e),d.current||u.current||m.current||(m.current=!0,eE.c.info(s.importBatch.fixText.waitingOtherDevice)),d.current=!1,u.current=!1)},[c,e,s]),{fix:p,fixingKeys:i,fixing:i.length>0||!!c}}(e.id,r,s),q=function(e,t,r,s){let{t:i,language:n}=(0,x.b)(),l=(0,a.useRef)(null),c=(0,a.useRef)(null),[o,d]=(0,a.useState)(null),[m,u]=(0,a.useState)([]),h=async a=>{let l=a.target.files?.[0];a.target.value="";let o=r.items.find(e=>e.key===c.current);if(l&&o&&t){d(o.key);try{let a=await (0,eP.p)(l);try{let r=await (0,eM.y)(t),l=await (0,eM.k)(r,o.regions,a),c={...(0,eP.N)(a,l),sourceType:"continuation"},d=await (0,eF.v)({source:"image",imageBase64:l.dataUrl,imageInfo:c,language:n,subjectId:e.subjectId,targetSubjectId:e.targetSubjectId,paperLevel:e.paperLevel});s(e=>er(e,o.key)),u(e=>[...e,d.id]),eq.V.info("[ImportBatch]","Continuation batch created",{batchId:d.id,...c}),eE.c.success(i.importBatch.continuation.created)}finally{a.dispose()}}catch(e){eq.V.error("[ImportBatch]","Continuation failed",{error:e}),eE.c.error(e instanceof eP.o?i.upload.decodeErrors[e.code].replace("{format}",e.format.toUpperCase()):(0,e$.f)(e,i))}finally{d(null)}}};return{pick:e=>{c.current=e,l.current?.click()},busyKey:o,created:m,inputProps:{ref:l,onChange:e=>void h(e)}}}(e,u?.url??null,r,s),F="text"===B?r.items.filter(e=>e.fix&&e.fix.original===e.text).length:0,P="text"===B?R.filter(e=>!(e.fix&&e.fix.original===e.text)).map(e=>e.key):[];return(0,t.jsxs)("div",{className:"space-y-4 pb-36 md:pb-24",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("p",{className:"text-base font-semibold","data-testid":"draft-summary",children:[N.importBatch.detected.replace("{count}",String(r.items.length)),(0,t.jsx)("span",{className:"mx-2 text-muted-foreground",children:"·"}),N.importBatch.selected.replace("{count}",String(R.length))]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsxs)("span",{className:"mr-2 flex items-center gap-1 text-xs text-muted-foreground","aria-live":"polite","data-testid":"draft-save-state","data-state":d,children:["saving"===d&&(0,t.jsx)(l.f,{className:"h-3 w-3 animate-spin"}),N.importBatch.save[d]]}),(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"ghost",disabled:!o,onClick:i,children:[(0,t.jsx)(m,{className:"mr-1 h-4 w-4"}),N.importBatch.undo]}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",onClick:()=>s(e=>(function(e,t,a=()=>!0){return ee(e,e.items.map(e=>({...e,selected:t&&a(e)})))})(e,!$,e=>X(e,B))),children:$?N.importBatch.selectNone:N.importBatch.selectAll})]})]}),w&&(0,t.jsxs)("div",{className:"space-y-2 rounded-lg border border-primary/40 bg-primary/5 p-3 text-sm",role:"status","data-testid":"draft-conflict",children:[(0,t.jsx)("p",{children:N.importBatch.conflictKept}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(ex.f,{type:"button",size:"sm",onClick:v,children:N.importBatch.restoreMine}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",onClick:k,children:N.importBatch.discardMine})]})]}),"text"===B&&r.items.length>0&&(0,t.jsx)(eR,{targetCount:P.length,pendingCount:F,fixing:E.fixing,onFix:()=>void E.fix(P),onAcceptAll:()=>s(e=>en(e))}),r.warnings.length>0&&(0,t.jsx)("ul",{className:"space-y-1 rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200",children:r.warnings.map(e=>(0,t.jsxs)("li",{className:"flex items-start gap-2",children:[(0,t.jsx)(n.f,{className:"mt-0.5 h-4 w-4 shrink-0"}),N.importBatch.warnings[e]]},e))}),(0,t.jsx)(p,{inputProps:q.inputProps,created:q.created}),u&&(0,t.jsx)(ek,{imageUrl:u.url,items:r.items,onSelectItem:e=>{T(e),C(e),document.getElementById(`draft-item-${e}`)?.scrollIntoView({behavior:"smooth",block:"center"})},highlightedKey:z}),0===r.items.length?(0,t.jsx)("p",{className:"rounded-xl border border-dashed p-6 text-center text-sm text-muted-foreground",children:N.importBatch.emptyDraft}):(0,t.jsx)("ol",{className:"space-y-3",children:r.items.map((e,a)=>{var i;return(0,t.jsx)(ej,{item:e,index:a,total:r.items.length,source:B,expanded:S===e.key,onToggleExpand:()=>C(t=>t===e.key?null:e.key),onEdit:s,image:u,onAdjustRegion:()=>A({key:e.key,regions:e.regions}),highlighted:z===e.key,onFixText:"text"===B?()=>void E.fix([e.key]):void 0,fixing:E.fixingKeys.includes(e.key),fixBusy:E.fixing,onContinue:u&&(i=r.items.length,e.regions.length>0&&(e.flags.includes("partial")||a===i-1))?()=>q.pick(e.key):void 0,continuing:q.busyKey===e.key},e.key)})}),u&&(0,t.jsxs)(ex.f,{type:"button",variant:"outline",size:"sm",onClick:()=>A({key:null,regions:[]}),children:[(0,t.jsx)(c.f,{className:"mr-1 h-4 w-4"}),N.importBatch.addQuestion]}),(0,t.jsx)(ev,{ignored:r.ignored,onRestore:e=>s(t=>(function(e,t){let a=e.ignored[t];if(void 0===a||e.items.length>=L.S)return e;let r={key:W(e.items.map(e=>e.key)),label:null,text:a,material:null,section:null,selected:!0,regions:[],hasFigure:!1,flags:[]};return{...e,items:[...e.items,r],ignored:e.ignored.filter((e,a)=>a!==t)}})(t,e))}),(0,t.jsx)(ew,{count:R.length,missingRegions:M,pendingFixes:F,imageQuestions:R.filter(e=>!!e.image).length,confirmBeforeImport:h,starting:f,onStart:g,onDiscard:y,source:B,analysisMode:b,onAnalysisModeChange:j,hasTargetNotebook:!!e.targetSubjectId||!!e.subjectId}),u&&I&&(0,t.jsx)(eT,{open:!0,imageUrl:u.url,regions:I.regions,onClose:()=>A(null),onSave:e=>{let t=I.key;s(a=>t?ea(a,t,{regions:e,selected:!0}):function(e,t){if(e.items.length>=L.S)return e;let a={key:W(e.items.map(e=>e.key)),label:null,text:"",material:null,section:null,selected:!0,regions:[t],hasFigure:!1,flags:[]};return{...e,items:[...e.items,a]}}(a,e[0])),A(null)}})]})}var eL=e.i(399847),eV=e.i(395925);function eK({batch:e,busy:a,onRetry:r,onDiscard:s}){let{t:i}=(0,x.b)(),n=i.errors,c=e.error?"string"==typeof n[e.error]?n[e.error]:e.error:null;return"splitting"===e.phase?(0,t.jsxs)("section",{className:"flex items-start gap-3 rounded-xl border bg-card p-4",role:"status","data-testid":"batch-splitting",children:[(0,t.jsx)(l.f,{className:"mt-0.5 h-5 w-5 shrink-0 animate-spin text-primary"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,t.jsx)("p",{className:"font-medium",children:i.importBatch.phase.splitting}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i.importBatch.splittingHint}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",onClick:s,children:i.importBatch.discard})]})]}):(0,t.jsxs)("section",{className:"flex items-start gap-3 rounded-xl border border-destructive/40 bg-card p-4","data-testid":"batch-failed",children:[(0,t.jsx)(eL.f,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,t.jsx)("p",{className:"font-medium",children:i.importBatch.phase.failed}),c&&(0,t.jsx)("p",{className:"text-sm text-destructive",children:c}),"image"===e.source&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i.importBatch.manualFallback}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxs)(ex.f,{type:"button",size:"sm",onClick:r,disabled:a,children:[(0,t.jsx)(eV.f,{className:"mr-1 h-4 w-4"}),i.importBatch.retrySplit]}),(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"ghost",onClick:s,children:i.importBatch.discard})]})]})]})}var eG=e.i(551757),eQ=e.i(615568),eY=e.i(168148);let eJ={analyzing:.5,saving:.9,review:1,saved:1,failed:1};function eW({task:e}){let{t:a}=(0,x.b)(),r=a.importBatch.itemStatus;if("saved"===e.status){let a=e.errorItemId?e.duplicate?r.duplicate:r.saved:r.deleted;return(0,t.jsxs)("span",{className:"flex items-center gap-1 text-green-700 dark:text-green-300",children:[(0,t.jsx)(eG.f,{className:"h-4 w-4"}),a]})}return"failed"===e.status?(0,t.jsxs)("span",{className:"flex items-center gap-1 text-destructive",children:[(0,t.jsx)(eL.f,{className:"h-4 w-4"}),r.failed]}):"review"===e.status?(0,t.jsxs)("span",{className:"flex items-center gap-1 text-primary",children:[(0,t.jsx)(eQ.f,{className:"h-4 w-4"}),r.review]}):(0,t.jsxs)("span",{className:"flex items-center gap-1 text-muted-foreground",children:[(0,t.jsx)(l.f,{className:"h-4 w-4 animate-spin"}),r[e.status]]})}function eX({batch:e,image:a,busy:s,onRetryFailed:i,onRetryOne:n,onConfirmAll:l}){let{t:c}=(0,x.b)(),{counts:o}=e,d=o.total-o.active,m=o.total?Math.round(e.tasks.reduce((e,t)=>e+eJ[t.status],0)/o.total*100):0,u=new Map((e.draft?.items??[]).map((e,t)=>[e.key,{item:e,index:t}])),h=c.errors;return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("section",{className:"space-y-3 rounded-xl border bg-card p-4","data-testid":"batch-progress","data-phase":e.phase,children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[(0,t.jsx)("p",{className:"text-base font-semibold",children:c.importBatch.progress.replace("{done}",String(d)).replace("{total}",String(o.total))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c.importTasks.stageEstimate})]}),(0,t.jsx)(eY.f,{value:m,"aria-label":c.importTasks.stageEstimate,"aria-valuetext":c.common.progress.estimated.replace("{percent}",String(m)),className:"h-2"}),(0,t.jsxs)("ul",{className:"flex flex-wrap gap-x-4 gap-y-1 text-sm","data-testid":"batch-counts",children:[(0,t.jsx)("li",{className:"text-green-700 dark:text-green-300",children:c.importBatch.counts.saved.replace("{count}",String(o.saved-o.duplicate))}),o.duplicate>0&&(0,t.jsx)("li",{className:"text-muted-foreground",children:c.importBatch.counts.duplicate.replace("{count}",String(o.duplicate))}),o.review>0&&(0,t.jsx)("li",{className:"text-primary",children:c.importBatch.counts.review.replace("{count}",String(o.review))}),o.failed>0&&(0,t.jsx)("li",{className:"text-destructive",children:c.importBatch.counts.failed.replace("{count}",String(o.failed))}),o.active>0&&(0,t.jsx)("li",{className:"text-muted-foreground",children:c.importBatch.counts.active.replace("{count}",String(o.active))})]}),o.active>0&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c.importBatch.leaveHint}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[o.failed>0&&(0,t.jsxs)(ex.f,{type:"button",size:"sm",onClick:i,disabled:s,children:[(0,t.jsx)(eV.f,{className:"mr-1 h-4 w-4"}),c.importBatch.retryFailed.replace("{count}",String(o.failed))]}),o.review>0&&(0,t.jsx)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:l,disabled:s,children:c.importBatch.confirmAll.replace("{count}",String(o.review))})]})]}),(0,t.jsx)("ol",{className:"space-y-3",children:e.tasks.map(e=>{let i=u.get(e.batchItemKey??""),l=e.error?"string"==typeof h[e.error]?h[e.error]:e.error:null;return(0,t.jsxs)("li",{className:(0,em.f)("flex gap-3 rounded-xl border bg-card p-3 text-sm",e.unread&&"review"===e.status&&"border-primary/50"),"data-testid":"batch-task","data-status":e.status,children:[a&&i&&i.item.regions.length>0&&(0,t.jsx)(eu,{imageUrl:a.url,imageSize:a,regions:i.item.regions,className:"w-20 shrink-0 self-start sm:w-28"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"font-medium",children:c.importBatch.question.replace("{index}",String((i?.index??0)+1))}),(0,t.jsx)(eW,{task:e})]}),(0,t.jsx)("p",{className:"line-clamp-2 break-words text-muted-foreground",children:e.excerpt||i?.item.text}),"saved"===e.status&&e.errorItemId&&!e.duplicate&&e.notebookName&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:c.importTasks.savedTo.replace("{notebook}",e.notebookName).replace("{id}",e.errorItemShortId||"-")}),l&&"failed"===e.status&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:l}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2 pt-1",children:["review"===e.status&&(0,t.jsx)(ex.f,{asChild:!0,size:"sm",children:(0,t.jsx)(r.default,{href:`/import-tasks/${e.id}`,children:c.importBatch.review})}),"saved"===e.status&&e.errorItemId&&(0,t.jsx)(ex.f,{asChild:!0,size:"sm",variant:"outline",children:(0,t.jsx)(r.default,{href:`/error-items/${e.errorItemId}`,children:c.importBatch.viewItem})}),"failed"===e.status&&(0,t.jsxs)(ex.f,{type:"button",size:"sm",variant:"outline",onClick:()=>n(e),disabled:s,children:[(0,t.jsx)(eV.f,{className:"mr-1 h-3 w-3"}),c.importTasks.retry]})]})]})]},e.id)})})]})}var eZ=e.i(912505),e0=e.i(393842),e1=e.i(86963),e2=e.i(127175),e4=e.i(35209),e5=e.i(25197);e.s(["default",0,function(){let e=(0,s.useParams)(),n=(0,s.useRouter)(),l=e.id,{t:c}=(0,x.b)();(0,e4.f)(c.importBatch.title);let o=function(e,t={}){let[r,s]=(0,a.useState)(null),[i,n]=(0,a.useState)(!1),[l,c]=(0,a.useState)(null),[o,d]=(0,a.useState)("saved"),m=(0,a.useRef)([]),[u,h]=(0,a.useState)(!1),x=(0,a.useRef)(0),p=(0,a.useRef)(0),f=(0,a.useRef)(0),g=(0,a.useRef)(null),y=(0,a.useRef)(null),b=(0,a.useRef)(null),j=(0,a.useRef)(async()=>!0),[w,v]=(0,a.useState)(null),k=(0,a.useRef)(t.onConflict);(0,a.useEffect)(()=>{k.current=t.onConflict},[t.onConflict]);let N=(0,a.useCallback)((e,t=!1)=>{s(t=>t&&!e.imageData&&t.imageData&&t.id===e.id?{...e,imageData:t.imageData}:e);let a=p.current!==f.current;(t||!a||"draft"!==e.status)&&(null!==g.current&&e.version!==x.current&&(m.current=[],h(!1)),x.current=e.version,g.current=e.draft,c(e.draft),f.current=p.current,d("saved"))},[]),B=(0,a.useCallback)(async()=>{if("u"<typeof document||"hidden"!==document.visibilityState)try{N(await (0,eF.w)(e)),n(!1)}catch(e){e?.status===404&&n(!0)}},[e,N]);(0,a.useEffect)(()=>{let t=!1;(0,eF.w)(e,{image:!0}).then(e=>{t||N(e,!0)}).catch(e=>{t||e?.status!==404||n(!0)});let a=(0,e2.E)(()=>void B());return()=>{t=!0,a()}},[e,N,B]);let S=r?.phase==="splitting"||r?.phase==="processing";(0,a.useEffect)(()=>{if(!S)return;let e=setInterval(()=>void B(),2500);return()=>clearInterval(e)},[S,B]);let C=(0,a.useCallback)(async()=>{let t=p.current;d("saving");try{let a=await (0,eF.S)(e,x.current,g.current);return x.current=a.version,f.current=t,s(e=>e?{...a,imageData:e.imageData}:a),d(p.current===t?"saved":"dirty"),"ok"}catch(t){let e=(0,eF.n)(t);if(e){let t=g.current;return"draft"===e.status&&t&&v(t),N(e,!0),k.current?.(),"conflict"}return d("error"),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>void j.current(),5e3),"error"}},[e,N]),z=(0,a.useCallback)(async()=>{for(b.current&&(clearTimeout(b.current),b.current=null);;){let e=y.current??(y.current=(async()=>{try{for(;p.current!==f.current&&g.current;)if(await C()!=="ok")return!1;return!0}finally{y.current=null}})());if(!await e)return!1;if(p.current===f.current)return!0}},[C]);(0,a.useEffect)(()=>{j.current=z},[z]),(0,a.useEffect)(()=>{let e=()=>{"hidden"===document.visibilityState&&p.current!==f.current&&z()};return document.addEventListener("visibilitychange",e),window.addEventListener("pagehide",e),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("pagehide",e)}},[z]),(0,a.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]);let T=(0,a.useCallback)(e=>{g.current=e,c(e),p.current+=1,d("dirty"),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>void z(),800)},[z]),I=(0,a.useRef)(null),A=(0,a.useCallback)((e,t)=>{let a=g.current;if(!a)return;let r=e(a);if(r===a)return;let s=Date.now(),i=t&&I.current?.group===t&&s-I.current.at<1500;I.current=t?{group:t,at:s}:null,i||(m.current=[...m.current.slice(-29),a],h(!0)),T(r)},[T]),R=(0,a.useCallback)(()=>{let e=m.current.pop();I.current=null,h(m.current.length>0),e&&T(e)},[T]),$=(0,a.useCallback)(()=>{v(null),w&&A(()=>w)},[w,A]);return{batch:r,draft:l,notFound:i,saveState:o,refresh:B,save:z,edit:A,undo:R,canUndo:u,conflictCopy:w,restoreConflictCopy:$,dismissConflictCopy:()=>v(null),version:()=>x.current,replace:e=>N(e,!0)}}(l,{onConflict:()=>eE.c.info(c.importBatch.conflict)}),{batch:d,draft:m,notFound:u}=o,h=function(e){let[t,r]=(0,a.useState)(null);return(0,a.useEffect)(()=>{if(!e)return;let t=!1,a=new Image;return a.onload=()=>{t||r({url:e,width:a.naturalWidth,height:a.naturalHeight})},a.src=e,()=>{t=!0}},[e]),t&&t.url===e?t:null}(d?.source==="image"?d.imageData:null),[p,f]=(0,a.useState)(null),[g,y]=(0,a.useState)(null),[b,j]=(0,a.useState)(!1),[w,v]=(0,a.useState)("ai"),k=(0,a.useRef)(null),[N,B]=(0,a.useState)(null);if(m!==N&&(B(m),m&&d?.source==="text")){let e=Z(m,"text");v(e.length>0&&e.every(e=>e.answer?.trim())?"tags":"ai")}if((0,a.useEffect)(()=>{(0,e5.x)().then(f)},[]),(0,a.useEffect)(()=>{d?.unread&&k.current!==`${d.id}:${d.phase}:${d.counts.active}`&&(k.current=`${d.id}:${d.phase}:${d.counts.active}`,(0,eF.f)(d.id).catch(e=>eq.V.warn("[ImportBatch]","Mark read failed",{error:e})))},[d]),u)return(0,t.jsx)("main",{className:"mx-auto max-w-3xl px-4 py-6 md:px-8 md:py-8",children:(0,t.jsx)(eZ.f,{icon:i.f,title:c.importBatch.notFound,action:(0,t.jsx)(r.default,{href:"/import-tasks",children:(0,t.jsx)(ex.f,{children:c.importTasks.viewTasks})})})});if(!d||null===p||"image"===d.source&&"draft"===d.status&&!h)return(0,t.jsx)(e1.f,{});let S=async e=>{j(!0);try{await e()}catch(t){let e=(0,eF.n)(t);e?(o.replace(e),eE.c.info(c.importBatch.conflict)):eE.c.error((0,e$.f)(t,c))}finally{j(!1)}},C=async()=>{if(m){y(c.importBatch.submitting);try{let e;if(!await o.save())return;if("image"===d.source){if(!d.imageData)throw Error("IMAGE_EMPTY");let t=await (0,eM.y)(d.imageData),a=Z(m,"image");e=[];let r=0;for(let s of a){y(c.importBatch.cropping.replace("{done}",String(e.length+1)).replace("{total}",String(a.length)));let i=await (0,eM.M)(t,s.regions);r+=i.bytes,e.push({key:s.key,imageBase64:i.dataUrl,imageInfo:{outputWidth:i.width,outputHeight:i.height,outputBytes:i.bytes,quality:i.quality}})}if(e.reduce((e,t)=>e+t.imageBase64.length,0)>0x3c00000)return void eE.c.error(c.errors.IMPORT_BATCH_TOO_LARGE);y(c.importBatch.uploadingImages.replace("{count}",String(e.length)).replace("{size}",`${(r/1024/1024).toFixed(1)}MB`))}o.replace(await (0,eF.g)(d.id,o.version(),e,w)),window.scrollTo({top:0})}catch(t){eq.V.error("[ImportBatch]","Start failed",{error:t});let e=(0,eF.n)(t);e?(o.replace(e),eE.c.info(c.importBatch.conflict)):eE.c.error((0,e$.f)(t,c))}finally{y(null)}}},z=async()=>{await (0,eE.u)(c.importBatch.discardConfirm)&&await S(async()=>{await (0,eF.o)(d.id),eE.c.success(c.importBatch.discarded),n.push("/import-tasks")})},T=()=>S(async()=>{o.replace(await (0,eF.s)(d.id)),eE.c.info(c.importTasks.retried)}),I=`${c.importBatch.source[d.source]} \xb7 ${c.importBatch.phase[d.phase]}`;return(0,t.jsxs)("main",{className:"mx-auto max-w-4xl space-y-4 px-4 py-6 md:px-8 md:py-8",children:[(0,t.jsx)(e0.f,{backHref:"/import-tasks",title:c.importBatch.title,description:I}),"splitting"===d.phase||"failed"===d.phase?(0,t.jsx)(eK,{batch:d,busy:b,onRetry:T,onDiscard:z}):"draft"===d.status&&m?(0,t.jsx)(eH,{batch:d,draft:m,onEdit:o.edit,onUndo:o.undo,canUndo:o.canUndo,saveState:o.saveState,image:h,confirmBeforeImport:p,starting:g,onStart:C,onDiscard:z,analysisMode:w,onAnalysisModeChange:v,hasConflictCopy:!!o.conflictCopy,onRestoreConflict:o.restoreConflictCopy,onDismissConflict:o.dismissConflictCopy}):(0,t.jsx)(eX,{batch:d,image:h,busy:b,onRetryFailed:T,onRetryOne:e=>S(async()=>{await (0,e2.R)(e.id),eE.c.info(c.importTasks.retried),await o.refresh()}),onConfirmAll:()=>S(async()=>{let e=await (0,eF.J)(d.id);o.replace(e.batch),eE.c.success(c.importBatch.confirmAllDone.replace("{count}",String(e.saved)))})})]})}],864272)}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,204573,e=>{"use strict";var t=e.i(843476),a=e.i(271645),s=e.i(522016),r=e.i(618566),n=e.i(711241),i=e.i(456420);let l={name:"file-question-mark",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]],aliases:["file-question"]};l.node;let o=(0,i.f)(l);var c=e.i(741120),u=e.i(759659),d=e.i(469937),m=e.i(314381),g=e.i(632781),f=e.i(3198),h=e.i(519455),x=e.i(111110),p=e.i(41931),v=e.i(303163),j=e.i(201276),y=e.i(294114),b=e.i(132411);function N({errorItemId:e,commands:s,onUpdate:r}){let{t:n}=(0,x.b)(),[i,l]=(0,a.useState)(!1),[o,c]=(0,a.useState)(null),u=`error-item:${e}:geogebra`,{running:d,refresh:w}=(0,b.f)(u),k=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(d){k.current=!0;return}k.current&&(k.current=!1,p.k.get(`/api/error-items/${e}`).then(e=>{e.geogebraCommands&&r({geogebraCommands:e.geogebraCommands})}).catch(e=>j.V.warn("[ErrorDetail]","Failed to reload GeoGebra commands",{error:e})))},[d,e,r]);let A=async()=>{l(!0),c(null);try{let t=await p.k.post(`/api/error-items/${e}/geogebra`,{},{recoverable:!0});t.suitable&&t.commands.length>0?r({geogebraCommands:JSON.stringify(t.commands)}):c(t.description||n.geogebra.notSuitable)}catch(e){if(e instanceof p.a&&409===e.status&&e.data?.code==="TASK_ALREADY_RUNNING")y.c.info(n.errors.TASK_ALREADY_RUNNING),await w();else{j.V.error("[ErrorDetail]","GeoGebra analysis failed",{error:e});let t=(0,v.d)(e)||(0,v.Z)(e);t.includes("AI_AUTH_ERROR")?c(n.geogebra.authFailed):t.includes("AI_CONNECTION")?c(n.geogebra.connectionFailed):c(n.geogebra.analyzeFailed)}}finally{l(!1)}},S=async t=>{await p.k.put(`/api/error-items/${e}`,{geogebraCommands:t}),r({geogebraCommands:t})},C=async()=>{await p.k.delete(`/api/error-items/${e}/geogebra`),r({geogebraCommands:null})};if(s)return(0,t.jsx)(f.f,{commands:s,height:700,showToolBar:!0,showAlgebraInput:!1,showMenuBar:!1,onRegenerate:A,onSaveCommands:S,onDelete:C});let I=i||!!d;return(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)(m.f,{className:"h-4 w-4"}),(0,t.jsx)("span",{children:n.geogebra.title})]}),(0,t.jsx)(h.f,{variant:"outline",size:"sm",onClick:A,disabled:I,children:I?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(g.f,{className:"mr-2 h-4 w-4 animate-spin"}),n.geogebra.analyzing]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m.f,{className:"mr-2 h-4 w-4"}),n.geogebra.generate]})})]}),o&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:o}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:n.geogebra.hint})]})}function w({src:e,onClose:a}){let{t:s}=(0,x.b)();return e?(0,t.jsx)("div",{className:"fixed inset-0 z-50 bg-black/90 flex items-center justify-center p-4",onClick:a,children:(0,t.jsxs)("div",{className:"relative max-w-7xl max-h-full",children:[(0,t.jsx)("button",{className:"absolute -top-12 right-0 text-white hover:text-gray-300 text-lg font-semibold bg-black/50 px-4 py-2 rounded",onClick:a,children:s.detail?.close||"✕ Close"}),(0,t.jsx)("img",{src:e,alt:"Full size",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:e=>e.stopPropagation()}),(0,t.jsx)("p",{className:"text-center text-white/70 text-sm mt-4",children:s.detail?.clickOutside||"Click outside to close"})]})}):null}var k=e.i(141176),A=e.i(511445),S=e.i(515288);let C={name:"square-pen",size:24,node:[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],aliases:["pen-box","edit","pen-square"]};C.node;let I=(0,i.f)(C);var E=e.i(856522),T=e.i(263676);function R({onClick:e,label:a}){let{t:s}=(0,x.b)();return(0,t.jsxs)(h.f,{variant:"ghost",size:"sm",onClick:e,children:[(0,t.jsx)(I,{className:"h-4 w-4 mr-1"}),a||s.common?.edit||"Edit"]})}function L({onSave:e,onCancel:a,children:s}){let{t:r}=(0,x.b)();return(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxs)(h.f,{size:"sm",onClick:e,children:[(0,t.jsx)(E.f,{className:"h-4 w-4 mr-1"}),r.common?.save||"Save"]}),(0,t.jsxs)(h.f,{size:"sm",variant:"outline",onClick:a,children:[(0,t.jsx)(T.X,{className:"h-4 w-4 mr-1"}),r.common?.cancel||"Cancel"]}),s]})}function F({title:e,actions:a}){return(0,t.jsxs)("div",{className:"flex justify-between items-center",children:[e,a]})}function M({read:e,save:t,logLabel:s,successMessage:r,failureMessage:n}){let{t:i}=(0,x.b)(),[l,o]=(0,a.useState)(!1),[c,u]=(0,a.useState)(e),d=async()=>{try{await t(c),o(!1),y.c.success(r||i.common?.messages?.saveSuccess||"Saved successfully")}catch(e){j.V.error("[ErrorDetail]",`Failed to save ${s}`,{error:e}),y.c.error(n||i.common?.messages?.saveFailed||"Save failed")}};return{editing:l,value:c,setValue:u,start:()=>{u(e()),o(!0)},cancel:()=>o(!1),submit:d}}function $({title:e,value:a,onSave:s,logLabel:r,rows:n,placeholder:i,editorLabel:l,emptyText:o,cardClassName:c,titleClassName:u,contentClassName:d,headerActions:m,children:g}){let f=M({read:()=>a||"",save:s,logLabel:r}),h=(0,t.jsx)(k.f,{value:f.value,onChange:f.setValue,placeholder:i,rows:n,className:"w-full font-mono text-sm"});return(0,t.jsxs)(S.N,{className:c,children:[(0,t.jsx)(S.Y,{children:(0,t.jsx)(F,{title:(0,t.jsx)(S.v,{className:u,children:e}),actions:!f.editing&&(0,t.jsxs)("div",{className:"flex flex-wrap justify-end",children:[m,(0,t.jsx)(R,{onClick:f.start})]})})}),(0,t.jsxs)(S.O,{className:"space-y-4",children:[f.editing?(0,t.jsxs)("div",{className:"space-y-3",children:[l?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:l}),h]}):h,(0,t.jsx)(L,{onSave:f.submit,onCancel:f.cancel})]}):!a&&o?(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:o}):(0,t.jsx)(A.f,{content:a,className:d}),g]})]})}var z=e.i(624687);function _({item:e,onUpdate:a}){let{t:s}=(0,x.b)(),r=M({read:()=>e.userNotes||"",save:async t=>{await p.k.patch(`/api/error-items/${e.id}/notes`,{userNotes:t}),a({userNotes:t})},logLabel:"notes",successMessage:s.common?.messages?.noteSaveSuccess||"Notes saved successfully"});return(0,t.jsxs)(S.N,{children:[(0,t.jsx)(S.Y,{children:(0,t.jsx)(F,{title:(0,t.jsx)(S.v,{children:s.detail.yourNotes}),actions:!r.editing&&(0,t.jsx)(R,{onClick:r.start,label:s.detail.editNotes})})}),(0,t.jsx)(S.O,{children:r.editing?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(z.f,{value:r.value,onChange:e=>r.setValue(e.target.value),placeholder:s.detail.notesPlaceholder||"Enter your notes...",rows:5,className:"w-full"}),(0,t.jsx)(L,{onSave:r.submit,onCancel:r.cancel})]}):(0,t.jsx)("div",{className:"whitespace-pre-wrap",children:e.userNotes?(0,t.jsx)("p",{className:"text-foreground",children:e.userNotes}):(0,t.jsx)("p",{className:"text-muted-foreground italic",children:s.detail.noNotes})})})]})}let D={name:"shapes",size:24,node:[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]};D.node;let U=(0,i.f)(D);function V({errorItemId:e,onDone:s}){let{t:r}=(0,x.b)(),[n,i]=(0,a.useState)(!1),l=`error-item:${e}:figure`,{running:o,refresh:c}=(0,b.f)(l),u=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(o){u.current=!0;return}u.current&&(u.current=!1,p.k.get(`/api/error-items/${e}`).then(e=>s({hasFigure:e.hasFigure,figureSvg:e.figureSvg})).catch(e=>j.V.warn("[RegenerateFigure]","Failed to reload figure",{error:e})))},[o,e,s]);let d=async()=>{i(!0);try{let t=await p.k.post(`/api/error-items/${e}/figure`,{},{recoverable:!0});s(t),t.figureSvg||y.c.warning(r.figure.noFigure)}catch(e){if(e instanceof p.a&&409===e.status&&e.data?.code==="TASK_ALREADY_RUNNING")y.c.info(r.errors.TASK_ALREADY_RUNNING),await c();else{let t=e?.data?.message||"",a=r.errors[t];j.V.error("[RegenerateFigure]","Failed to regenerate figure",{code:t}),y.c.error("NO_ORIGINAL_IMAGE"===t?r.figure.noImage:"string"==typeof a?a:r.figure.failed)}}finally{i(!1)}},m=n||!!o;return(0,t.jsxs)(h.f,{variant:"outline",size:"sm",onClick:d,disabled:m,className:"flex items-center gap-2",children:[m?(0,t.jsx)(g.f,{className:"h-4 w-4 animate-spin"}):(0,t.jsx)(U,{className:"h-4 w-4"}),m?r.figure.regenerating:r.figure.regenerate]})}let q={name:"image-plus",size:24,node:[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]};q.node;let O=(0,i.f)(q);var G=e.i(12130),K=e.i(213761);function Y({errorItemId:e,hasImage:s,onDone:r}){let{t:n}=(0,x.b)(),i=(0,a.useRef)(null),[l,o]=(0,a.useState)(!1),[c,u]=(0,a.useState)(null);(0,a.useEffect)(()=>()=>c?.dispose(),[c]);let d=async()=>{(!s||await (0,y.u)(n.replaceImage.confirm))&&i.current?.click()},m=async e=>{if(e){o(!0);try{u(await (0,K.p)(e))}catch(e){y.c.error(e instanceof K.o?n.upload.decodeErrors[e.code].replace("{format}",e.format.toUpperCase()):n.replaceImage.invalid)}finally{o(!1)}}},f=async t=>{if(c&&0!==t.length){o(!0);try{let{dataUrl:a}=await (0,K.X)(c,t[0]);u(null);let s=await p.k.put(`/api/error-items/${e}/image`,{imageDataUrl:a});r(s.originalImageUrl),y.c.success(n.replaceImage.done)}catch(t){let e=t?.data?.message||"";j.V.error("[ReplaceImage]","Failed to replace original image",{code:e}),y.c.error("INVALID_IMAGE"===e?n.replaceImage.invalid:n.replaceImage.failed)}finally{o(!1)}}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:i,type:"file",accept:"image/*,.heic,.heif",className:"hidden",onChange:e=>{m(e.target.files?.[0]),e.target.value=""}}),c&&(0,t.jsx)(G.f,{imageSrc:c.previewUrl,open:!l,onClose:()=>u(null),allowMulti:!1,onRegionsSelected:e=>void f(e)}),(0,t.jsxs)(h.f,{variant:"outline",size:"sm",onClick:d,disabled:l,className:"flex items-center gap-2",children:[l?(0,t.jsx)(g.f,{className:"h-4 w-4 animate-spin"}):(0,t.jsx)(O,{className:"h-4 w-4"}),l?n.replaceImage.uploading:s?n.replaceImage.replace:n.replaceImage.add]})]})}var H=e.i(520732),P=e.i(438465),B=e.i(28342),X=e.i(674166),Q=e.i(967489),W=e.i(401280),Z=e.i(470279);function J({item:e,onChanged:a}){var s;let{t:r}=(0,x.b)(),n=r.common?.notSet||"Not set",{groups:i}=(0,Z.f)(),l=M({read:()=>({subjectId:e.subjectId||null,gradeSemester:e.gradeSemester||"",paperLevel:e.paperLevel||"",questionType:e.questionType||""}),save:async t=>{let{subjectId:s,paperLevel:r,questionType:n,...i}=t;await p.k.put(`/api/error-items/${e.id}`,{...i,...r!==(e.paperLevel||"")?{paperLevel:r||null}:{},...s!==(e.subjectId||null)?{subjectId:s}:{},...n!==(e.questionType||"")?{questionType:n||null}:{}}),await a()},logLabel:"metadata",successMessage:r.common?.messages?.metaUpdateSuccess||"Metadata updated successfully!",failureMessage:r.common?.messages?.updateFailed||"Update failed"}),o=e=>l.setValue({...l.value,...e});return(0,t.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,t.jsx)(F,{title:(0,t.jsx)("h4",{className:"text-sm font-semibold",children:r.detail?.questionInfo||"Question Info"}),actions:!l.editing&&(0,t.jsx)(R,{onClick:l.start})}),l.editing?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:r.notebooks?.title||"Notebook"}),(0,t.jsx)(P.f,{value:l.value.subjectId||void 0,onChange:e=>o({subjectId:e})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:r.questionType.label||"Question Type"}),(0,t.jsxs)(Q.d,{value:l.value.questionType,onValueChange:e=>o({questionType:e===W.O?"":e}),children:[(0,t.jsx)(Q.P,{children:(0,t.jsx)(Q.U,{placeholder:r.questionType.notSet||"Not set"})}),(0,t.jsxs)(Q.r,{children:[(0,t.jsx)(Q.T,{value:W.O,children:r.questionType.clear||"Clear"}),W.V.map(e=>(0,t.jsx)(Q.T,{value:e,children:r.questionType.names?.[e]||e},e))]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{htmlFor:"detail-grade-semester",className:"text-sm text-muted-foreground",children:r.editor.gradeSemester}),(0,t.jsx)(B.f,{id:"detail-grade-semester",value:l.value.gradeSemester,onChange:e=>o({gradeSemester:e})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:r.filter.paperLevel}),(0,t.jsx)(X.f,{value:l.value.paperLevel,onChange:e=>o({paperLevel:e})})]}),(0,t.jsx)(L,{onSave:l.submit,onCancel:l.cancel})]}):(0,t.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsxs)("span",{className:"text-muted-foreground",children:[r.notebooks?.title||"Notebook",":"]}),(0,t.jsx)("span",{className:"font-medium",children:e.subject?.name||n})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsxs)("span",{className:"text-muted-foreground",children:[r.questionType.label||"Question Type",":"]}),(0,t.jsx)("span",{className:"font-medium",children:(s=e.questionType)?r.questionType.names?.[s]||s:n})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsxs)("span",{className:"text-muted-foreground",children:[r.editor.gradeSemester,":"]}),(0,t.jsx)("span",{className:"font-medium",children:e.gradeSemester||n})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsxs)("span",{className:"text-muted-foreground",children:[r.filter.paperLevel,":"]}),(0,t.jsx)("span",{className:"font-medium",children:(e=>{if(!e)return n;let t=i.find(t=>t.id===e);return t?.name||e})(e.paperLevel)})]})]})]})}var ee=e.i(487486),et=e.i(328623);function ea({errorItemId:e,onDone:s,onSuggested:r,onReload:n}){let{t:i}=(0,x.b)(),[l,o]=(0,a.useState)(!1),c=`error-item:${e}:retag`,{running:u,refresh:d}=(0,b.f)(c),m=(0,a.useRef)(!1),f=(0,a.useRef)(!1),v=async()=>{o(!0),m.current=!0;try{if(r){let t=await p.k.post(`/api/error-items/${e}/retag`,{preview:!0},{recoverable:!0});r(t.tags)}else await p.k.post(`/api/error-items/${e}/retag`,{},{recoverable:!0}),s?.()}catch(e){if(e instanceof p.a&&409===e.status&&e.data?.code==="TASK_ALREADY_RUNNING")y.c.info(i.errors.TASK_ALREADY_RUNNING),m.current=!1,await d();else{let t=e?.data?.message||"",a=i.errors[t];j.V.error("[RetagItem]","Failed to regenerate tags",{code:t}),y.c.error("NO_TAGS_SELECTED"===t?i.retag.noTags:"string"==typeof a?a:i.retag.itemFailed)}}finally{o(!1)}};(0,a.useEffect)(()=>{if(u){f.current=!0;return}f.current&&!m.current&&n?.(),f.current=!1,m.current=!1},[u,n]);let N=l||!!u;return(0,t.jsxs)(h.f,{variant:"ghost",size:"sm",onClick:v,disabled:N,children:[N?(0,t.jsx)(g.f,{className:"h-4 w-4 mr-1 animate-spin"}):(0,t.jsx)(et.f,{className:"h-4 w-4 mr-1"}),r?N?i.retag.suggestRunning:i.retag.suggestButton:N?i.retag.itemRunning:i.retag.itemButton]})}var es=e.i(574041),er=e.i(597138),en=e.i(428602);function ei({item:e,educationStage:a,onChanged:s}){let{t:r}=(0,x.b)(),n=(0,en.f)(e),i=M({read:()=>(0,en.f)(e),save:async t=>{await p.k.put(`/api/error-items/${e.id}`,{knowledgePoints:t}),await s()},logLabel:"tags",successMessage:r.common?.messages?.tagUpdateSuccess||"Tags updated successfully!",failureMessage:r.common?.messages?.updateFailed||"Update failed"});return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(F,{title:(0,t.jsx)("h4",{className:"text-sm font-semibold",children:r.editor?.tags||"Knowledge Tags"}),actions:!i.editing&&(0,t.jsxs)("div",{className:"flex",children:[(0,t.jsx)(ea,{errorItemId:e.id,onDone:s,onReload:s}),(0,t.jsx)(R,{onClick:i.start})]})}),i.editing?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(es.f,{value:i.value,onChange:i.setValue,placeholder:r.editor?.tagsPlaceholder||"Enter or select knowledge tags...",subject:(0,er.f)(e.subject?.name||null)||void 0,gradeStage:a}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:r.editor?.tagsHint||"Select from standard or custom tags"}),(0,t.jsx)(L,{onSave:i.submit,onCancel:i.cancel,children:(0,t.jsx)(ea,{errorItemId:e.id,onSuggested:i.setValue})})]}):(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:n.map(e=>(0,t.jsx)(ee.f,{variant:"secondary",children:e},e))})]})}var el=e.i(580860);let eo={name:"image",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]};eo.node;let ec=(0,i.f)(eo);function eu({src:e,alt:a,showLabel:s,hideLabel:r,visible:n,onVisibleChange:i,onEnlarge:l,variant:o="ghost",actions:c}){let{t:u}=(0,x.b)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[e&&(0,t.jsx)(h.f,{variant:o,size:"sm",onClick:()=>i(!n),className:`flex items-center gap-2 ${"ghost"===o?"text-muted-foreground":""}`,children:n?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(el.f,{className:"h-4 w-4"}),r]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ec,{className:"h-4 w-4"}),s]})}),c]}),e&&n&&(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("img",{src:e,alt:a,className:"w-full rounded-lg border cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>l(e)}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1 text-center",children:u.detail?.clickToEnlarge||"Click to enlarge"})]})]})}function ed({item:e,educationStage:s,saveFields:r,onUpdate:n,reload:i,onEnlarge:l}){let{t:o}=(0,x.b)(),[c,u]=(0,a.useState)(!1),d=M({read:()=>e.questionText,save:e=>r({questionText:e}),logLabel:"question"});return(0,t.jsxs)(S.N,{children:[(0,t.jsx)(S.Y,{children:(0,t.jsx)(F,{title:(0,t.jsx)(S.v,{children:o.detail.question}),actions:!d.editing&&(0,t.jsx)(R,{onClick:d.start})})}),(0,t.jsxs)(S.O,{className:"space-y-4",children:[d.editing?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(k.f,{value:d.value,onChange:d.setValue,placeholder:"Enter question text...",rows:8,className:"w-full font-mono text-sm"}),(0,t.jsx)(L,{onSave:d.submit,onCancel:d.cancel})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(A.f,{content:e.questionText}),(0,t.jsx)(H.f,{svg:e.figureSvg,scale:e.figureScale,align:e.figureAlign,onSave:(e,t)=>r({figureScale:e,figureAlign:t})},`${e.id}-${e.figureScale??100}-${e.figureAlign??"center"}`)]}),(0,t.jsx)(ei,{item:e,educationStage:s,onChanged:i}),(0,t.jsx)(J,{item:e,onChanged:i}),(0,t.jsx)("div",{className:"pt-3",children:(0,t.jsx)(eu,{src:e.originalImageUrl,alt:o.detail.originalProblem||"Original Problem",showLabel:o.replaceImage?.view||"View original image",hideLabel:o.replaceImage?.hide||"Hide original image",variant:"outline",visible:c,onVisibleChange:u,onEnlarge:l,actions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y,{errorItemId:e.id,hasImage:!!e.originalImageUrl,onDone:e=>{n({originalImageUrl:e}),u(!0)}}),e.originalImageUrl&&(0,t.jsx)(V,{errorItemId:e.id,onDone:n})]})})})]})]})}var em=e.i(991722);function eg({item:e,saveFields:s,onEnlarge:r}){let{t:n,language:i}=(0,x.b)(),[l,o]=(0,a.useState)(!1),c=M({read:()=>({text:e.wrongAnswerText||"",status:e.mistakeStatus||"unknown"}),save:({text:e,status:t})=>s({wrongAnswerText:e,mistakeStatus:(0,em.x)(t,e)}),logLabel:"wrong answer"});return(0,t.jsxs)(S.N,{children:[(0,t.jsx)(S.Y,{children:(0,t.jsx)(F,{title:(0,t.jsx)(S.v,{children:n.editor?.wrongAnswerText||"Wrong Answer / Work"}),actions:!c.editing&&(0,t.jsx)(R,{onClick:c.start})})}),(0,t.jsx)(S.O,{className:"space-y-4",children:c.editing?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:n.editor?.mistakeStatus||"Attempt Status"}),(0,t.jsxs)(Q.d,{value:c.value.status,onValueChange:e=>c.setValue({...c.value,status:e}),children:[(0,t.jsx)(Q.P,{children:(0,t.jsx)(Q.U,{})}),(0,t.jsxs)(Q.r,{children:[(0,t.jsx)(Q.T,{value:"not_attempted",children:n.editor?.mistakeStatuses?.notAttempted||"Not attempted"}),(0,t.jsx)(Q.T,{value:"wrong_attempt",children:n.editor?.mistakeStatuses?.wrongAttempt||"Wrong attempt"}),(0,t.jsx)(Q.T,{value:"unknown",children:n.editor?.mistakeStatuses?.unknown||"Unknown"})]})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:n.editor?.wrongAnswerText||"Wrong Answer / Work"}),(0,t.jsx)(k.f,{value:c.value.text,onChange:e=>c.setValue({text:e,status:e.trim()?"wrong_attempt":c.value.status}),rows:5,className:"w-full font-mono text-sm"})]}),(0,t.jsx)(L,{onSave:c.submit,onCancel:c.cancel})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(ee.f,{variant:"secondary",children:(0,em.i)(e.mistakeStatus,i)}),e.wrongAnswerText?(0,t.jsx)(A.f,{content:e.wrongAnswerText}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:n.detail?.noMistakeAnalysis||"No mistake analysis yet."}),e.wrongAnswerImageUrl&&(0,t.jsx)("div",{className:"pt-3",children:(0,t.jsx)(eu,{src:e.wrongAnswerImageUrl,alt:n.detail.wrongAnswerImageAlt,showLabel:n.detail.viewImage,hideLabel:n.detail.hideImage,visible:l,onVisibleChange:o,onEnlarge:r})})]})})]})}let ef={name:"square-function",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]],aliases:["function-square"]};ef.node;let eh=(0,i.f)(ef);var ex=e.i(716400),ep=e.i(369939);let ev=new Set(["ne","neq","nabla","nu","not","notin","ni","nexists","ngeq","nleq","nmid","nparallel","nsubseteq"]);function ej(e){return e.length>80?`${e.slice(0,80)}…`:e}let ey=["questionText","answerText","analysis","wrongAnswerText","mistakeAnalysis"];function eb({errorItemId:e,fields:s,onDone:r,onReload:n}){let{t:i}=(0,x.b)(),[l,o]=(0,a.useState)(!1),c=`error-item:${e}:fix-latex`,{running:u,refresh:d}=(0,b.f)(c),m=(0,a.useRef)(!1),f=(0,a.useRef)(!1),v=(0,a.useMemo)(()=>Object.values(function(e){let t={};for(let a of ey){let s=function(e){if(!e?.trim())return[];let{masked:t,segments:a}=(0,ep.F)(e),s=[];for(let e of a)try{ex.f.renderToString(e.tex,{displayMode:e.displayMode,throwOnError:!0,strict:"ignore"})}catch(a){let t=a instanceof Error?a.message.replace(/^KaTeX parse error:\s*/,""):String(a);s.push({snippet:ej(e.source),message:t})}let r=t.replace(/@@MATH\d+@@/g," "),n=r.replace(/\\\$/g,"").match(/\$/g);n&&s.push({snippet:"$",message:`有 ${n.length} 个未配对的 $ 定界符`});let i=r.match(/\\[()[\]]/g);i&&s.push({snippet:i.join(" "),message:"有未配对的 \\( \\) 或 \\[ \\] 定界符"});let l=[...new Set(r.match(/\\[a-zA-Z]{2,}/g)||[])].filter(e=>!e.startsWith("\\n")||ev.has(e.slice(1)));return l.length>0&&s.push({snippet:ej(l.join(" ")),message:"LaTeX 命令没有放在 $…$ 中,会原样显示"}),s}(e[a]);s.length>0&&(t[a]=s)}return t}(s)).reduce((e,t)=>e+(t?.length??0),0),[s]),N=async()=>{o(!0),m.current=!0;try{let t=await p.k.post(`/api/error-items/${e}/fix-latex`,{},{timeout:3e5,recoverable:!0});r(t.updated);let a=t.fixedFields.map(e=>i.fixLatex.fields[e]).join(i.common.listSeparator);y.c.info(0===t.issuesBefore?i.fixLatex.noIssues:0===t.fixedFields.length?i.fixLatex.notFixed:0===t.issuesAfter?i.fixLatex.fixedAll.replace("{fields}",a):i.fixLatex.fixedPartly.replace("{fields}",a).replace("{count}",String(t.issuesAfter)))}catch(e){if(e instanceof p.a&&409===e.status&&e.data?.code==="TASK_ALREADY_RUNNING")y.c.info(i.errors.TASK_ALREADY_RUNNING),m.current=!1,await d();else{let t=e?.data?.message||"",a=i.errors[t];j.V.error("[FixLatex]","Failed to fix LaTeX",{code:t}),y.c.error("string"==typeof a?a:i.fixLatex.failed)}}finally{o(!1)}};(0,a.useEffect)(()=>{if(u){f.current=!0;return}f.current&&!m.current&&n?.(),f.current=!1,m.current=!1},[u,n]);let w=l||!!u;return 0!==v||w?(0,t.jsxs)(h.f,{variant:"outline",size:"sm",onClick:N,disabled:w,className:"border-amber-500 text-amber-700 dark:text-amber-400",title:i.fixLatex.issuesFound.replace("{count}",String(v)),children:[w?(0,t.jsx)(g.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(eh,{className:"mr-2 h-4 w-4"}),w?i.fixLatex.running:i.fixLatex.button,!w&&v>0&&(0,t.jsxs)("span",{className:"ml-1",children:["(",v,")"]})]}):null}var eN=e.i(991686),ew=e.i(846968),ek=e.i(931454);function eA({errorItemId:e,onDone:s,onReload:r}){let{t:n,language:i}=(0,x.b)(),[l,o]=(0,a.useState)(!1),c=`error-item:${e}:reanswer`,{running:u,refresh:d}=(0,b.f)(c),m=(0,a.useRef)(!1),f=(0,a.useRef)(!1),v=async()=>{if(await (0,y.u)(n.reanswerItem.confirm)){o(!0),m.current=!0;try{let t=await p.k.post(`/api/error-items/${e}/reanswer`,{language:i},{timeout:6e5,recoverable:!0});s(t)}catch(e){if(e instanceof p.a&&409===e.status&&e.data?.code==="TASK_ALREADY_RUNNING")y.c.info(n.errors.TASK_ALREADY_RUNNING),m.current=!1,await d();else{let t=e?.data?.message||"",a=n.errors[t];j.V.error("[RegenerateAnswer]","Failed to regenerate answer",{code:t}),y.c.error("NO_QUESTION_TEXT"===t?n.reanswerItem.noQuestionText:"string"==typeof a?a:n.reanswerItem.failed)}}finally{o(!1)}}};(0,a.useEffect)(()=>{if(u){f.current=!0;return}f.current&&!m.current&&r?.(),f.current=!1,m.current=!1},[u,r]);let N=l||!!u;return(0,t.jsxs)(h.f,{variant:"ghost",size:"sm",onClick:v,disabled:N,children:[N?(0,t.jsx)(g.f,{className:"h-4 w-4 mr-1 animate-spin"}):(0,t.jsx)(ek.f,{className:"h-4 w-4 mr-1"}),N?n.reanswerItem.running:n.reanswerItem.button]})}var eS=e.i(689664),eC=e.i(508734);function eI({shortId:e,className:s=""}){let{t:r}=(0,x.b)(),[n,i]=(0,a.useState)(!1);if(!e)return null;let l=async t=>{t.preventDefault(),t.stopPropagation();try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{window.prompt(r.shortId.copy,e)}};return(0,t.jsxs)("button",{type:"button",onClick:l,title:n?r.shortId.copied:r.shortId.copy,className:`inline-flex items-center gap-1 rounded-md border bg-muted/50 px-2 py-0.5 font-mono text-xs text-muted-foreground hover:text-foreground transition-colors ${s}`,children:[(0,t.jsx)("span",{children:r.shortId.label}),(0,t.jsx)("span",{className:"font-semibold text-foreground",children:e}),n?(0,t.jsx)(eS.f,{className:"h-3 w-3 text-green-600"}):(0,t.jsx)(eC.f,{className:"h-3 w-3"})]})}let eE={name:"audio-lines",size:24,node:[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]};eE.node;let eT=(0,i.f)(eE),eR={name:"clapperboard",size:24,node:[["path",{d:"m12.296 3.464 3.02 3.956",key:"qash78"}],["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z",key:"1h7j8b"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"4lm6w1"}],["path",{d:"m6.18 5.276 3.1 3.899",key:"zjj9t3"}]]};eR.node;let eL=(0,i.f)(eR),eF={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]};eF.node;let eM=(0,i.f)(eF),e$={name:"minimize",size:24,node:[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]};e$.node;let ez=(0,i.f)(e$),e_={name:"pause",size:24,node:[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]};e_.node;let eD=(0,i.f)(e_);var eU=e.i(21357),eV=e.i(395925);let eq={name:"volume-2",size:24,node:[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]};eq.node;let eO=(0,i.f)(eq),eG={name:"volume-x",size:24,node:[["path",{d:"M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z",key:"1p7khw"}],["path",{d:"m16.5 14.5 5-5",key:"cul3yw"}],["path",{d:"m16.5 9.5 5 5",key:"1akey5"}]]};eG.node;let eK=(0,i.f)(eG);var eY=e.i(975157);function eH({supported:e,enabled:a,rate:s,fullscreen:r,onToggle:n,onCycleRate:i}){let{t:l}=(0,x.b)(),o=(0,eY.f)("h-8 shrink-0",r&&"text-white hover:bg-white/20 hover:text-white"),c=e?a?l.svgAnimation.voiceOff:l.svgAnimation.voiceOn:l.svgAnimation.voiceUnsupported;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{title:c,className:"shrink-0",children:(0,t.jsx)(h.f,{variant:"ghost",size:"sm",className:(0,eY.f)(o,"w-8 p-0",a&&e&&!r&&"text-primary"),onClick:n,disabled:!e,"aria-label":c,"aria-pressed":a&&e,children:a&&e?(0,t.jsx)(eO,{className:"h-4 w-4"}):(0,t.jsx)(eK,{className:"h-4 w-4"})})}),a&&e&&(0,t.jsxs)(h.f,{variant:"ghost",size:"sm",className:(0,eY.f)(o,"px-1.5 text-xs tabular-nums"),onClick:i,"aria-label":l.svgAnimation.voiceRate,title:l.svgAnimation.voiceRate,children:[s,"×"]})]})}let eP=/<metadata\b[^>]*\bid\s*=\s*["']narration["'][^>]*>([\s\S]*?)<\/metadata\s*>/gi,eB={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};function eX(e){let t=e;if("string"==typeof t){let e=t.indexOf("["),a=t.lastIndexOf("]");if(-1===e||a<e)return null;try{t=JSON.parse(t.slice(e,a+1))}catch{return null}}if(!Array.isArray(t))return null;let a=[];for(let e of t){if(!e||"object"!=typeof e)continue;let{begin:t,text:s}=e,r="number"==typeof t?t:"string"==typeof t?eJ(t):null;if(null===r||!Number.isFinite(r)||r<0||"string"!=typeof s)continue;let n=s.replace(/\s+/g," ").trim();n&&a.push({begin:Math.round(100*r)/100,text:n})}a.sort((e,t)=>e.begin-t.begin);let s=[];for(let e of a){let t=s[s.length-1];t&&t.begin===e.begin?t.text=`${t.text} ${e.text}`:s.push({...e})}let r=s.slice(0,20).map(e=>({...e,text:e.text.slice(0,300)}));return r.length>0?r:null}function eQ(e){for(let t of e.matchAll(eP)){let e=eX(t[1].replace(/&(#x[0-9a-f]+|#\d+|lt|gt|amp|quot|apos);/gi,(e,t)=>{if("#"!==t[0])return eB[t.toLowerCase()];let a="x"===t[1]||"X"===t[1]?parseInt(t.slice(2),16):Number(t.slice(1));return Number.isFinite(a)&&a<=1114111?String.fromCodePoint(a):e}));if(e)return e}return null}let eW=/<(?:animate|animateTransform|animateMotion|set)\b[^>]*>/gi;function eZ(e,t){let a=e.match(RegExp(`\\s${t}\\s*=\\s*("([^"]*)"|'([^']*)')`,"i"));return a?(a[2]??a[3]??"").trim():null}function eJ(e){if(!e)return null;let t=e.trim(),a=t.match(/^(?:(\d+):)?(\d+):(\d+(?:\.\d+)?)$/);if(a)return 3600*Number(a[1]??0)+60*Number(a[2])+Number(a[3]);let s=t.match(/^(\d+(?:\.\d+)?)(h|min|s|ms)?$/);if(!s)return null;let r={h:3600,min:60,s:1,ms:.001}[s[2]??"s"]??1;return Number(s[1])*r}let e0=new Set(["opacity","visibility","display","fill-opacity"]);function e1(e){let t=e.getAttribute("viewBox")?.split(/[\s,]+/).map(Number),a=t?.length===4&&t[3]>0?t[1]+t[3]:parseFloat(e.getAttribute("height")??"");if(!(a>0))return null;let s=t?.length===4?t[1]+.78*t[3]:.78*a,r=[];for(let t of Array.from(e.querySelectorAll("text"))){if(t.closest("defs, metadata"))continue;let a=parseFloat(t.getAttribute("y")??t.querySelector("tspan[y]")?.getAttribute("y")??"");if(!(a>=s))continue;let n=Array.from(t.querySelectorAll("tspan")),i=(n.length>0?n.map(e=>e.textContent??"").join(" "):t.textContent??"").replace(/\s+/g," ").trim(),l=function(e,t){for(let a=e;a&&a!==t;a=a.parentElement)for(let e of Array.from(a.children)){let t=e.localName;if("set"!==t&&"animate"!==t)continue;let a=e.getAttribute("attributeName")??"";if(e0.has(a)&&!function(e,t){if(null===t)return!1;let a=t.trim();return"visibility"===e?"hidden"===a:"display"===e?"none"===a:0===Number(a)}(a,e.getAttribute("to")??e.getAttribute("values")?.split(";").pop()??null))return eJ((e.getAttribute("begin")??"0").split(";")[0])}return 0}(t,e);i&&null!==l&&r.push({begin:l,y:a,text:i})}return r.sort((e,t)=>e.begin-t.begin||e.y-t.y),eX(r.map(({begin:e,text:t})=>({begin:e,text:t})))}var e2=e.i(79058);let e4={zh:["zh","cmn"],en:["en"]};function e3(){return"speechSynthesis"in window&&"u">typeof SpeechSynthesisUtterance?window.speechSynthesis:null}let e5=!1;function e8(){let e=e3();if(!e||e5)return;e5=!0;let t=new SpeechSynthesisUtterance(" ");t.volume=0,e.speak(t)}let e6=[1,1.25,1.5,.75],e7="svg-narration-enabled",e9="svg-narration-rate";function te(e){try{return localStorage.getItem(e)}catch{return null}}function tt(e,t){try{localStorage.setItem(e,t)}catch{}}function ta(e,t){return Math.max(8e3,400*e.length/t+5e3)}function ts(e,t){let a=-1;for(let s=0;s<e.length&&e[s].begin<=t+.05;s++)a=s;return a}function tr(e){let t=Math.max(0,Math.floor(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function tn({svg:e,errorItemId:s}){let{t:r,language:n}=(0,x.b)(),i=(0,a.useRef)(null),l=(0,a.useRef)(null),o=(0,a.useRef)(null),[c,u]=(0,a.useState)(null),[d,m]=(0,a.useState)(!1),[g,f]=(0,a.useState)(0),[p,v]=(0,a.useState)(!1),[j,y]=(0,a.useState)(!1),b=p||j,N=(0,a.useMemo)(()=>(function(e){let t=0;for(let a of e.match(eW)||[]){let e=eZ(a,"begin"),s=null===e?0:eJ(e.split(";")[0]);if(null===s)continue;let r=eZ(a,"repeatCount");if("indefinite"!==r&&"indefinite"!==eZ(a,"repeatDur"))t=Math.max(t,s+(eJ(eZ(a,"dur"))??0)*(r&&Number.isFinite(Number(r))?Number(r):1))}return t})(e),[e]),w=(0,a.useMemo)(()=>(function(e){let t=e.match(/<svg\b[^>]*>/i)?.[0]??"",a=eZ(t,"viewBox")?.split(/[\s,]+/).map(Number);if(a?.length===4&&a[2]>0&&a[3]>0)return a[2]/a[3];let s=parseFloat(eZ(t,"width")??""),r=parseFloat(eZ(t,"height")??"");return s>0&&r>0?s/r:1.6})(e),[e]),k=(0,a.useMemo)(()=>`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:"><style>html,body{margin:0;height:100%;background:#fff;overflow:hidden}svg{display:block;width:100%;height:100%}</style></head><body>${e}</body></html>`,[e]),A=(0,a.useMemo)(()=>eQ(e),[e]),[S,C]=(0,a.useState)(null),I=A??S,E=(0,a.useCallback)(()=>{let e=l.current?.contentDocument;return"function"==typeof e?.getAnimations?e.getAnimations():[]},[]),T=function({segments:e,language:t,errorItemId:s,holdAnimation:r}){let{supported:n,mode:i,modeRef:l,voiceRef:o}=function(e){let[t,s]=(0,a.useState)(!1),[r,n]=(0,a.useState)("browser"),i=(0,a.useRef)(void 0),l=(0,a.useRef)("browser");return(0,a.useEffect)(()=>{let e=!0;return(0,e2.v)().then(t=>{e&&(l.current=t,n(t))}),()=>{e=!1}},[]),(0,a.useEffect)(()=>{let t=e3();if(!t)return;let a=()=>{let a,r,n,l=t.getVoices();a=e4[e],r=l.filter(e=>a.some(t=>e.lang.toLowerCase().startsWith(t))),n="zh"===e?/^(zh|cmn)[-_](cn|hans)/i:/^en[-_]us/i,i.current=r.find(e=>n.test(e.lang)&&e.localService)??r.find(e=>n.test(e.lang))??r[0],s(0===l.length||!!i.current)};return a(),t.addEventListener?.("voiceschanged",a),()=>t.removeEventListener?.("voiceschanged",a)},[e]),{supported:t,mode:r,modeRef:l,voiceRef:i}}(t),[c,u]=(0,a.useState)(!1),[d,m]=(0,a.useState)(1),[g,f]=(0,a.useState)(!1),[h,x]=(0,a.useState)(!1),p=(0,a.useRef)(!1),v=(0,a.useRef)(!1),j=(0,a.useRef)(1),y=(0,a.useRef)(r);(0,a.useEffect)(()=>{y.current=r},[r]),(0,a.useEffect)(()=>{g&&(0,e2.E)()},[g]),(0,a.useEffect)(()=>{v.current="1"===te(e7),u(v.current);let e=Number(te(e9));e6.includes(e)&&(j.current=e,m(e))},[]);let b=(0,a.useRef)(null);(0,a.useEffect)(()=>{let a=b.current;a&&(a.deps.segments=e,a.deps.language=t,a.deps.enabled=v.current,a.deps.mode=l.current,a.deps.voice=o.current,a.deps.rate=j.current)}),(0,a.useEffect)(()=>{let a={segments:e,language:t,enabled:v.current,mode:l.current,voice:o.current,rate:j.current,setSpeaking:f,setHolding:x,hold:e=>{y.current(e)}},s=function(e){let t=-1,a=!1,s=null,r=0,n=null,i=!1,l=!1;function o(){i&&(i=!1,null===s&&(e.setHolding(!1),e.hold(!1)))}function c(t,r){r(),t()&&(n=null,a=!1,e.setSpeaking(!1),o(),null!==s&&(s=null,e.setHolding(!1),e.hold(!1)))}function u(t,a,s,r){if(!t()||l)return;l=!0,o();let n=e3();if(!n)return void c(t,s);let i=new SpeechSynthesisUtterance(a.text);i.lang=e.voice?.lang??("en"===e.language?"en-US":"zh-CN"),e.voice&&(i.voice=e.voice),i.rate=e.rate,i.onend=()=>c(t,s),i.onerror=()=>c(t,s),i.onstart=()=>r(ta(a.text,i.rate)),r(2500),n.speak(i)}return{update:function(d){let m=e.segments;if(!e.enabled||!m?.length||null!==s)return;if(a){let a=t+1;if(a>=m.length)return;let r=a>0?m[a].begin-m[a-1].begin:m[a].begin;if(d<m[a].begin-Math.min(.8,r/2))return;s=a,e.setHolding(!0),e.hold(!0);return}let g=ts(m,d);g<=t||(t=g,function(t){let d,m=e.segments,g=m?.[t];if(!g)return;let f=r,h={},x=()=>r===f&&n===h,p=()=>clearTimeout(d),v=e=>{clearTimeout(d),d=setTimeout(()=>c(x,p),e)};if(l=!1,n=h,a=!0,e.setSpeaking(!0),"cloud"!==e.mode)return u(x,g,p,v);let j=e.language,y=m?.[t+1];y&&(0,e2.U)(y.text,j).catch(()=>void 0);let b=setTimeout(()=>{x()&&null===s&&(i=!0,e.setHolding(!0),e.hold(!0))},300);(0,e2.U)(g.text,j).then(t=>{let a=(0,e2.l)();if(!x())return;if(!a){clearTimeout(b),u(x,g,p,v);return}let s=e=>()=>{x()&&!l&&e()};a.onplaying=s(()=>{clearTimeout(b),o(),v(ta(g.text,a.playbackRate))}),a.onended=s(()=>c(x,p)),a.onerror=s(()=>u(x,g,p,v)),a.src=t,a.playbackRate=e.rate,v(8e3),a.play().catch(s(()=>{clearTimeout(b),u(x,g,p,v)}))},()=>{clearTimeout(b),u(x,g,p,v)})}(g))},stop:function(l){r++,n=null,a=!1,e.setSpeaking(!1),(null!==s||i)&&(s=null,i=!1,e.setHolding(!1),e.hold(!1)),t=e.segments?ts(e.segments,l)-1:-1,e3()?.cancel(),"cloud"===e.mode&&(0,e2.l)()?.pause()},dispose:function(){r++,e3()?.cancel(),"cloud"===e.mode&&(0,e2.l)()?.pause()}}}(a);return b.current={playback:s,deps:a},()=>{s.dispose(),b.current=null}},[]);let N=(0,a.useCallback)(()=>b.current?.playback??null,[]);(0,a.useEffect)(()=>()=>{N()?.dispose()},[e,N]);let w=(0,a.useCallback)(e=>{N()?.stop(e)},[N]),k=(0,a.useCallback)(e=>{N()?.update(e)},[N]),A=(0,a.useCallback)(()=>{v.current&&(e8(),"cloud"===l.current&&(0,e2.p)())},[l]),S=(0,a.useCallback)((e,t)=>{p.current=!0,N()?.stop(t),v.current=e,u(e),tt(e7,e?"1":"0"),A()},[N,A]),C=(0,a.useCallback)(()=>{var e;let t,a=(e=j.current,t=e6.indexOf(e),e6[(t+1)%e6.length]);if(j.current=a,m(a),"cloud"===l.current){let e=(0,e2.l)();e&&(e.playbackRate=a)}tt(e9,String(a))},[l]);return(0,a.useEffect)(()=>{let e="cloud"===i&&!(0,e2.h)();if(!c||(e5||!e3())&&!e)return;let t=()=>{e8(),e&&(0,e2.p)()};return document.addEventListener("click",t,{capture:!0,once:!0}),document.addEventListener("touchend",t,{capture:!0,once:!0}),()=>{document.removeEventListener("click",t,{capture:!0}),document.removeEventListener("touchend",t,{capture:!0})}},[c,i]),(0,a.useEffect)(()=>{c&&"cloud"===i&&e?.length&&(0,e2.w)(e.map(e=>e.text),t,s).catch(()=>void 0)},[c,i,e,t,s]),(0,a.useEffect)(()=>{if("cloud"!==i||!e?.length||v.current)return;let a=!0;return(0,e2.z)(e.map(e=>e.text),t).then(e=>{a&&e&&!v.current&&!p.current&&(v.current=!0,u(!0))}),()=>{a=!1}},[i,e,t]),{supported:n||"cloud"===i,enabled:c,rate:d,speaking:g,holding:h,setEnabled:S,cycleRate:C,update:k,stop:w,prime:A}}({segments:I,language:n,errorItemId:s,holdAnimation:(0,a.useCallback)(e=>{e?o.current?.pauseAnimations():o.current?.unpauseAnimations(),E().forEach(t=>e?t.pause():t.play())},[E])}),R=T.enabled&&(T.holding||!d&&T.speaking),{stop:L,update:F,prime:M}=T,$=(0,a.useCallback)(()=>{o.current?.pauseAnimations(),E().forEach(e=>e.pause()),m(!1)},[E]),z=(0,a.useCallback)(()=>{L(o.current?.getCurrentTime()??0),$()},[$,L]),_=(0,a.useCallback)(e=>{o.current?.setCurrentTime(e),E().forEach(t=>{t.currentTime=1e3*e}),f(e),L(e)},[E,L]),D=(0,a.useCallback)(()=>{let e=o.current;e&&(N>0&&e.getCurrentTime()>=N&&_(0),e.unpauseAnimations(),E().forEach(e=>e.play()),m(!0),M())},[E,N,_,M]),U=async()=>{if(j)return void y(!1);if(document.fullscreenElement)return void await document.exitFullscreen().catch(()=>void 0);let e=i.current;if(e&&"function"==typeof e.requestFullscreen)try{await e.requestFullscreen();return}catch{}y(!0)};return(0,a.useEffect)(()=>{let e=()=>v(document.fullscreenElement===i.current);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),(0,a.useEffect)(()=>{if(!j)return;let e=e=>{"Escape"===e.key&&y(!1)},t=document.body.style.overflow;return document.body.style.overflow="hidden",document.addEventListener("keydown",e),()=>{document.body.style.overflow=t,document.removeEventListener("keydown",e)}},[j]),(0,a.useEffect)(()=>{if(!d)return;let e=0,t=()=>{let a=o.current?.getCurrentTime()??0;if(F(a),N>0&&a>=N){o.current?.setCurrentTime(N),$(),f(N);return}f(a),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[d,N,$,F]),(0,t.jsxs)("div",{ref:i,className:(0,eY.f)("space-y-2",b&&"flex flex-col items-center justify-center bg-black p-4",j&&"fixed inset-0 z-50"),children:[(0,t.jsx)("iframe",{ref:l,srcDoc:k,sandbox:"allow-same-origin",title:r.svgAnimation.alt,onLoad:()=>{o.current=l.current?.contentDocument?.querySelector("svg")??null,L(0),$(),o.current?.setCurrentTime(0),E().forEach(e=>{e.currentTime=0}),C(o.current?e1(o.current):null),f(0),u(o.current?e:null)},className:(0,eY.f)("mx-auto block rounded border bg-white transition-shadow",!b&&"w-full max-w-3xl",R&&"border-primary ring-2 ring-primary/40"),style:{visibility:c===e?"visible":"hidden",...b?{aspectRatio:w,width:`min(100%, calc((100dvh - 96px) * ${w}))`}:{aspectRatio:w}}}),(0,t.jsxs)("div",{className:(0,eY.f)("mx-auto flex w-full items-center gap-2",b?"max-w-5xl text-white":"max-w-3xl"),children:[(0,t.jsx)(h.f,{variant:"outline",size:"sm",className:"h-8 w-8 shrink-0 p-0 text-foreground",onClick:d?z:D,disabled:c!==e,"aria-label":d?r.svgAnimation.pause:r.svgAnimation.play,title:d?r.svgAnimation.pause:r.svgAnimation.play,children:d?(0,t.jsx)(eD,{className:"h-4 w-4"}):(0,t.jsx)(eU.f,{className:"h-4 w-4"})}),(0,t.jsx)(h.f,{variant:"ghost",size:"sm",className:(0,eY.f)("h-8 w-8 shrink-0 p-0",b&&"text-white hover:bg-white/20 hover:text-white"),onClick:()=>{_(0),D()},disabled:c!==e,"aria-label":r.svgAnimation.replay,title:r.svgAnimation.replay,children:(0,t.jsx)(eV.f,{className:"h-4 w-4"})}),N>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{type:"range",min:0,max:N,step:.1,value:Math.min(g,N),onChange:e=>_(Number(e.target.value)),"aria-label":r.svgAnimation.progress,className:"h-2 min-w-0 flex-1 cursor-pointer accent-primary"}),(0,t.jsxs)("span",{className:(0,eY.f)("shrink-0 text-xs tabular-nums",b?"text-white/80":"text-muted-foreground"),children:[tr(g)," / ",tr(N)]})]}),(0,t.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[!!I?.length&&(0,t.jsx)(eH,{supported:T.supported,enabled:T.enabled,rate:T.rate,fullscreen:b,onToggle:()=>T.setEnabled(!T.enabled,o.current?.getCurrentTime()??0),onCycleRate:T.cycleRate}),(0,t.jsx)(h.f,{variant:"ghost",size:"sm",className:(0,eY.f)("h-8 w-8 shrink-0 p-0",b&&"text-white hover:bg-white/20 hover:text-white"),onClick:U,"aria-label":b?r.svgAnimation.exitFullscreen:r.svgAnimation.fullscreen,title:b?r.svgAnimation.exitFullscreen:r.svgAnimation.fullscreen,children:b?(0,t.jsx)(ez,{className:"h-4 w-4"}):(0,t.jsx)(eM,{className:"h-4 w-4"})})]})]})]})}function ti({svg:e,errorItemId:s,disabled:r,onBusyChange:n}){let{t:i,language:l}=(0,x.b)(),[o,c]=(0,a.useState)(!1),[u,d]=(0,a.useState)(!1),m=(0,a.useMemo)(()=>(function(e){let t=eQ(e);if(t)return t;try{let t=new DOMParser().parseFromString(e,"image/svg+xml").documentElement;return"svg"===t.nodeName?e1(t):null}catch{return null}})(e),[e]),f=s?`error-item:${s}:tts-voice:${l}`:null,{running:N,refresh:w}=(0,b.f)(f);if((0,a.useEffect)(()=>{let e=!0;return(0,e2.v)().then(t=>{e&&c("cloud"===t)}),()=>{e=!1}},[]),!o||!m?.length)return null;let k=async()=>{d(!0),n(!0);try{await (0,e2.H)(m.map(e=>e.text),l,s),y.c.success(i.svgAnimation.voiceRegenerateDone)}catch(e){if(e instanceof p.a&&409===e.status&&e.data?.code==="TASK_ALREADY_RUNNING")y.c.info(i.errors.TASK_ALREADY_RUNNING),await w();else{let t=(0,v.d)(e)||"";j.V.error("[SvgAnimation]","Failed to regenerate cloud voice",{code:t,error:(0,v.Z)(e)});let a=(0,v.L)(e),s="TTS_DISABLED"===t?i.svgAnimation.voiceRegenerateDisabled:i.svgAnimation.voiceRegenerateFailed;y.c.error(a?`${s} (${a})`:s)}}finally{d(!1),n(!1)}},A=u||!!N;return(0,t.jsxs)(h.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1",onClick:k,disabled:r||A,title:i.svgAnimation.voiceRegenerateHint,children:[A?(0,t.jsx)(g.f,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(eV.f,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:A?i.svgAnimation.voiceRegenerating:i.svgAnimation.voiceRegenerate})]})}function tl({errorItemId:e,svgAnimation:s,hasOtherLanguage:r,onChange:n}){let{t:i,language:l}=(0,x.b)(),[o,d]=(0,a.useState)(!1),[m,f]=(0,a.useState)(!1),[N,w]=(0,a.useState)(!1),[k,A]=(0,a.useState)(!1),[S,C]=(0,a.useState)(null),I=(0,a.useMemo)(()=>!!s&&!!eQ(s),[s]),E=`error-item:${e}:svg-animation:${l}`,T=`error-item:${e}:svg-narration:${l}`,{running:R,refresh:L}=(0,b.f)(E),{running:F,refresh:M}=(0,b.f)(T),$=(0,a.useRef)(!1),z=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(R){$.current=!0;return}$.current&&($.current=!1,p.k.get(`/api/error-items/${e}`).then(e=>n(l,"en"===l?e.svgAnimationEn??null:e.svgAnimation??null)).catch(e=>j.V.warn("[SvgAnimation]","Failed to reload animation",{error:e})))},[R,e,l,n]),(0,a.useEffect)(()=>{if(F){z.current=!0;return}z.current&&(z.current=!1,p.k.get(`/api/error-items/${e}`).then(e=>n(l,"en"===l?e.svgAnimationEn??null:e.svgAnimation??null)).catch(e=>j.V.warn("[SvgAnimation]","Failed to reload narration",{error:e})))},[F,e,l,n]);let _=(e,t)=>{let a=i.errors[e];return"string"==typeof a?a:t},D=async()=>{d(!0),C(null);try{let t=await p.k.post(`/api/error-items/${e}/svg-animation`,{language:l},{timeout:6e5,recoverable:!0});n(l,t.svgAnimation)}catch(e){if(e instanceof p.a&&409===e.status&&e.data?.code==="TASK_ALREADY_RUNNING")y.c.info(i.errors.TASK_ALREADY_RUNNING),await L();else{let t=(0,v.d)(e)||"";j.V.error("[SvgAnimation]","Failed to generate SVG animation",{code:t,error:(0,v.Z)(e)}),C("NO_QUESTION_TEXT"===t?i.svgAnimation.noQuestionText:"NO_VALID_ANIMATION"===t?i.svgAnimation.invalid:_(t,i.svgAnimation.failed))}}finally{d(!1)}},U=async()=>{w(!0),C(null);try{let t=await p.k.post(`/api/error-items/${e}/svg-animation/narration`,{language:l},{timeout:3e5,recoverable:!0});n(l,t.svgAnimation),y.c.success(i.svgAnimation.narrationDone)}catch(e){if(e instanceof p.a&&409===e.status&&e.data?.code==="TASK_ALREADY_RUNNING")y.c.info(i.errors.TASK_ALREADY_RUNNING),await M();else{let t=(0,v.d)(e)||"";j.V.error("[SvgAnimation]","Failed to generate SVG narration",{code:t,error:(0,v.Z)(e)}),C("NO_VALID_NARRATION"===t?i.svgAnimation.narrationInvalid:_(t,i.svgAnimation.narrationFailed))}}finally{w(!1)}},V=async()=>{if(await (0,y.u)(i.svgAnimation.confirmDelete,{destructive:!0})){f(!0);try{await p.k.delete(`/api/error-items/${e}/svg-animation?language=${l}`),n(l,null),C(null)}catch(e){j.V.error("[SvgAnimation]","Failed to delete SVG animation",{error:e instanceof Error?e.message:String(e)}),y.c.error(i.svgAnimation.deleteFailed)}finally{f(!1)}}};if(!s)return(0,t.jsxs)("div",{className:"rounded-lg border border-dashed p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(eL,{className:"h-4 w-4"}),(0,t.jsx)("span",{children:i.svgAnimation.title})]}),(0,t.jsxs)(h.f,{variant:"outline",size:"sm",onClick:D,disabled:o||!!R,children:[o||R?(0,t.jsx)(g.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,t.jsx)(eL,{className:"mr-2 h-4 w-4"}),o||R?i.svgAnimation.generating:i.svgAnimation.generate]})]}),S&&(0,t.jsx)("p",{className:"text-xs text-destructive mt-2",children:S}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:r?i.svgAnimation.otherLanguageAvailable:i.svgAnimation.hint})]});let q=o||!!R||m||N||!!F||k;return(0,t.jsxs)("div",{className:"rounded-lg border bg-card",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 border-b bg-muted/30",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:i.svgAnimation.title}),q&&(0,t.jsx)(g.f,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,t.jsxs)(h.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1",onClick:U,disabled:q,title:i.svgAnimation.narrationHint,children:[N||F?(0,t.jsx)(g.f,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(eT,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:N||F?i.svgAnimation.narrationGenerating:I?i.svgAnimation.narrationRegenerate:i.svgAnimation.narrationGenerate})]}),(0,t.jsx)(ti,{svg:s,errorItemId:e,disabled:q,onBusyChange:A}),(0,t.jsxs)(h.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1",onClick:D,disabled:q,children:[o||R?(0,t.jsx)(g.f,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(c.f,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:o||R?i.svgAnimation.generating:i.svgAnimation.regenerate})]}),(0,t.jsxs)(h.f,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1 text-destructive hover:text-destructive",onClick:V,disabled:q,children:[(0,t.jsx)(u.f,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:i.svgAnimation.delete})]})]})]}),S&&(0,t.jsx)("p",{className:"px-3 pt-2 text-xs text-destructive",children:S}),(0,t.jsx)("div",{className:"p-2 sm:p-3",children:(0,t.jsx)(tn,{svg:s,errorItemId:e})})]})}var to=e.i(912505),tc=e.i(86963),tu=e.i(35209);e.s(["default",0,function(){let e=(0,r.useParams)(),i=(0,r.useRouter)(),{t:l,language:m}=(0,x.b)(),[g,f]=(0,a.useState)(null);(0,tu.f)(l.detail.title,g?.subject?.name,g?.shortId);let[v,b]=(0,a.useState)(!0),[k,A]=(0,a.useState)(null),[S,C]=(0,a.useState)(!1),[I,E]=(0,a.useState)(void 0),[T,R]=(0,a.useState)(!1),[L,F]=(0,a.useState)(!0),[M,z]=(0,a.useState)(null),[D,U]=(0,a.useState)(!1),V=(0,a.useCallback)(async e=>{try{let t=await p.k.get(`/api/error-items/${e}`);f(t)}catch(e){j.V.error("[ErrorDetail]","Failed to fetch error item",{error:e}),y.c.error(l.common?.messages?.loadFailed||"Failed to load item"),i.push("/notebooks")}finally{b(!1)}},[i,l]);(0,a.useEffect)(()=>{p.k.get("/api/user").then(e=>{e&&e.educationStage&&E(e.educationStage),R(!!e?.enableGeogebra),F(e?.enableSvgAnimation!==!1)}).catch(e=>j.V.error("[ErrorDetail]","Failed to fetch user info",{error:e})),e.id&&V(e.id)},[e.id,V]);let q=(0,a.useCallback)(e=>{f(t=>t&&{...t,...e})},[]),O=async e=>{g&&(await p.k.put(`/api/error-items/${g.id}`,e),q(e))},G=async()=>{g&&await V(g.id)},K=async e=>{if(!g)return;let t=g.difficultyStars??null;q({difficultyStars:e}),U(!0);try{let t=await p.k.put(`/api/error-items/${g.id}`,{difficultyStars:e});q({paperLevel:t.paperLevel})}catch(e){q({difficultyStars:t}),j.V.error("[ErrorDetail]","Failed to save difficulty",{error:e}),y.c.error(l.difficulty.saveFailed)}finally{U(!1)}},Y=(0,a.useCallback)((e,t)=>{q({["en"===e?"svgAnimationEn":"svgAnimation"]:t})},[q]),H=async()=>{if(g&&await (0,y.u)(l.common?.messages?.confirmDelete||"Are you sure you want to delete this error item?",{destructive:!0}))try{await p.k.delete(`/api/error-items/${g.id}/delete`),y.c.success(l.common?.messages?.deleteSuccess||"Deleted successfully"),i.push(g.subjectId?`/notebooks/${g.subjectId}`:"/notebooks")}catch(e){j.V.error("[ErrorDetail]","Failed to delete error item",{error:e}),y.c.error(l.common?.messages?.deleteFailed||"Delete failed")}};return v?(0,t.jsx)(tc.f,{label:l.common.loading}):g?(0,t.jsxs)("main",{className:"min-h-screen",children:[(0,t.jsxs)("div",{className:"mx-auto max-w-6xl space-y-6 px-4 py-6 md:px-8 md:py-8",children:[(0,t.jsxs)("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,t.jsx)(s.default,{href:g.subjectId?`/notebooks/${g.subjectId}`:"/notebooks",children:(0,t.jsx)(h.f,{variant:"ghost",size:"icon",className:"-ml-2",children:(0,t.jsx)(n.f,{className:"h-5 w-5"})})}),(0,t.jsx)("h1",{className:"text-2xl font-bold tracking-tight",children:l.detail.title}),(0,t.jsx)(eI,{shortId:g.shortId}),(0,t.jsx)(d.f,{size:"md",value:g.difficultyStars,onChange:K,disabled:D})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(eb,{errorItemId:g.id,fields:g,onDone:q,onReload:G}),(0,t.jsx)(s.default,{href:`/practice?id=${g.id}`,children:(0,t.jsxs)(h.f,{variant:"outline",size:"sm",children:[(0,t.jsx)(c.f,{className:"mr-2 h-4 w-4"}),l.detail.practice]})}),M&&(0,t.jsx)(ew.x,{status:M,className:"h-8 self-center px-3"}),(0,t.jsxs)(h.f,{variant:"ghost",size:"sm",onClick:H,className:"text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 hover:bg-red-50 dark:hover:bg-red-950/40",children:[(0,t.jsx)(u.f,{className:"mr-2 h-4 w-4"}),l.detail.delete||"Delete"]})]})]}),(0,t.jsx)(ed,{item:g,educationStage:I,saveFields:O,onUpdate:q,reload:G,onEnlarge:A}),(0,t.jsx)(eN.K,{errorItemId:g.id,onMasteryStatusChange:z}),(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-2",children:[(0,t.jsx)($,{title:l.detail.correctAnswer,value:g.answerText,onSave:e=>O({answerText:e}),logLabel:"answer",rows:5,placeholder:"Enter answer...",cardClassName:"border-primary/20",titleClassName:"text-primary",contentClassName:"font-semibold",headerActions:(0,t.jsx)(eA,{errorItemId:g.id,onDone:e=>q({answerText:e.answerText??"",analysis:e.analysis??""}),onReload:G}),children:g.referenceImageUrl&&(0,t.jsx)("div",{className:"pt-3",children:(0,t.jsx)(eu,{src:g.referenceImageUrl,alt:l.detail.referenceImageAlt,showLabel:l.detail.viewImage,hideLabel:l.detail.hideImage,visible:S,onVisibleChange:C,onEnlarge:A})})}),(0,t.jsx)(eg,{item:g,saveFields:O,onEnlarge:A})]}),(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-2",children:[(0,t.jsx)($,{title:l.detail.analysis,value:g.analysis,onSave:e=>O({analysis:e}),logLabel:"analysis",rows:12,placeholder:"Enter analysis..."}),(0,t.jsx)($,{title:l.detail?.mistakeAnalysis||"Mistake Analysis",value:g.mistakeAnalysis,onSave:e=>O({mistakeAnalysis:e}),logLabel:"mistake analysis",rows:8,editorLabel:l.editor?.mistakeAnalysis||"Mistake Cause Analysis",emptyText:l.detail?.noMistakeAnalysis||"No mistake analysis yet."})]}),(0,t.jsxs)("div",{className:"space-y-6",children:[L&&(0,t.jsx)(tl,{errorItemId:g.id,svgAnimation:"en"===m?g.svgAnimationEn:g.svgAnimation,hasOtherLanguage:!!("en"===m?g.svgAnimation:g.svgAnimationEn),onChange:Y},m),T&&(0,t.jsx)(N,{errorItemId:g.id,commands:g.geogebraCommands,onUpdate:q}),(0,t.jsx)(_,{item:g,onUpdate:q})]})]}),(0,t.jsx)(w,{src:k,onClose:()=>A(null)})]}):(0,t.jsx)(to.f,{icon:o,title:l.detail.notFound||"Item not found",className:"m-4 md:m-8"})}],204573)}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,[711241,e=>{var s=e.i(456420);let t={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};t.node;let a=(0,s.f)(t);e.s(["f",0,a],711241)},576248,e=>{var s=e.i(456420);let t={name:"circle-question-mark",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["help-circle","circle-help"]};t.node;let a=(0,s.f)(t);e.s(["f",0,a],576248)},474544,e=>{var s=e.i(456420);let t={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};t.node;let a=(0,s.f)(t);e.s(["f",0,a],474544)},520732,e=>{var s=e.i(843476),t=e.i(271645),a=e.i(149704),r=e.i(519455),i=e.i(793479),l=e.i(111110),n=e.i(294114),d=e.i(184110),c=e.i(201276);e.s(["f",0,function({svg:e,scale:m,align:o,previewScaleOverride:u,previewAlignOverride:x,onSave:f}){let{t:h}=(0,l.b)(),g=(0,t.useId)(),b=(0,d.V)(m),p=(0,d.o)(o),[y,j]=(0,t.useState)(null),[v,N]=(0,t.useState)(null),[w,k]=(0,t.useState)(!1),S=y??String(b),C=""!==S.trim()&&(0,d.x)(Number(S)),T=C?Number(S):b,$=v??p,A=u??T,z=x??$,M=null!==y&&(!C||Number(S)!==b)||null!==v&&v!==p;if(!e)return null;let R=async e=>{if(e.preventDefault(),C&&M&&!w){k(!0);try{await f(T,$),j(null),N(null),n.c.success(h.common.messages.saveSuccess)}catch(e){c.V.error("[FigureScale]","保存配图比例失败",{error:e}),n.c.error(h.common.messages.saveFailed)}finally{k(!1)}}};return(0,s.jsxs)("div",{children:[(0,s.jsx)(a.f,{svg:e,scale:A,align:z}),(0,s.jsxs)("form",{onSubmit:R,className:"figure-scale-editor-controls space-y-2 rounded-md border p-3 print:hidden",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,s.jsx)("label",{htmlFor:g,children:h.figure.scale}),(0,s.jsx)(i.f,{id:g,type:"number",min:d._,max:d.a,step:1,value:S,disabled:w,"aria-describedby":`${g}-hint`,"aria-invalid":!C,onChange:e=>j(e.target.value),className:"h-8 w-20"}),(0,s.jsx)("span",{children:"%"}),(0,s.jsx)(r.f,{type:"button",variant:"outline",size:"sm",disabled:w||C&&T===d.n,onClick:()=>j(String(d.n)),children:h.figure.resetScale}),(0,s.jsxs)("div",{role:"group","aria-label":h.figure.align,className:"inline-flex items-center gap-1",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:h.figure.align}),d.j.map(e=>(0,s.jsx)(r.f,{type:"button",variant:$===e?"default":"outline",size:"sm",disabled:w,"aria-pressed":$===e,onClick:()=>N(e===p?null:e),children:h.figure.aligns[e]},e))]}),(0,s.jsx)(r.f,{type:"submit",size:"sm",disabled:w||!M||!C,children:w?h.common.progress.saving:h.common.save}),M&&(0,s.jsx)(r.f,{type:"button",variant:"ghost",size:"sm",disabled:w,onClick:()=>{j(null),N(null)},children:h.common.cancel})]}),(0,s.jsx)("input",{type:"range",min:d._,max:d.a,step:1,value:T,disabled:w,"aria-label":h.figure.scaleSlider,"aria-describedby":`${g}-hint`,onChange:e=>j(e.target.value),className:"block h-6 w-full max-w-sm accent-primary"}),(0,s.jsx)("p",{id:`${g}-hint`,className:"text-xs text-muted-foreground",children:h.figure.scaleHint})]})]})}])},991686,931454,e=>{var s=e.i(843476),t=e.i(271645),a=e.i(522016),r=e.i(215519),i=e.i(306831),l=e.i(716327),n=e.i(456539),d=e.i(632781),c=e.i(77071),m=e.i(328623),o=e.i(759659),u=e.i(487486),x=e.i(519455),f=e.i(515288),h=e.i(511445),g=e.i(856522),b=e.i(793479),p=e.i(393733),y=e.i(111110),j=e.i(41931);function v({errorItemId:e,onSaved:a,onCancel:l}){let{t:n}=(0,y.b)(),{timeZone:c}=(0,r.M)(),m=(0,i.r)(new Date,"yyyy-MM-dd",c),[o,u]=(0,t.useState)(null),[f,h]=(0,t.useState)(m),[N,w]=(0,t.useState)(!1),[k,S]=(0,t.useState)(null),C=async()=>{if(o&&f){w(!0),S(null);try{await j.k.post("/api/practice/record",{errorItemId:e,result:o,source:"manual",takenAt:(0,i.$)(f,c)}),a()}catch{S(n.mastery.resultSaveFailed)}finally{w(!1)}}};return(0,s.jsxs)("div",{className:"space-y-3 rounded-md border bg-muted/30 p-3",children:[(0,s.jsx)(p.f,{value:o,onChange:u,disabled:N}),(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2",children:[(0,s.jsx)("label",{htmlFor:`practice-date-${e}`,className:"text-sm font-medium",children:n.mastery.recordDate}),(0,s.jsx)(b.f,{id:`practice-date-${e}`,type:"date",value:f,max:m,onChange:e=>h(e.target.value),className:"sm:w-48"}),(0,s.jsxs)("div",{className:"flex gap-2 sm:ml-auto",children:[(0,s.jsx)(x.f,{variant:"outline",size:"sm",onClick:l,disabled:N,className:"flex-1 sm:flex-none",children:n.exam.cancel}),(0,s.jsxs)(x.f,{size:"sm",onClick:C,disabled:N||!o||!f,className:"flex-1 sm:flex-none",children:[N?(0,s.jsx)(d.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(g.f,{className:"mr-2 h-4 w-4"}),n.mastery.saveResult]})]})]}),k&&(0,s.jsx)("p",{className:"text-sm text-destructive",children:k})]})}var N=e.i(149704),w=e.i(294114),k=e.i(905110);let S={correct:"bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300 border-green-200 dark:border-green-900",wrong:"bg-red-100 dark:bg-red-900/40 text-red-700 dark:text-red-300 border-red-200 dark:border-red-900",not_attempted:"bg-amber-100 dark:bg-amber-900/40 text-amber-700 dark:text-amber-300 border-amber-200 dark:border-amber-900"};e.s(["K",0,function({errorItemId:e,onMasteryStatusChange:g}){let{timeZone:b}=(0,r.M)(),{t:p}=(0,y.b)(),[C,T]=(0,t.useState)(null),[$,A]=(0,t.useState)(null),[z,M]=(0,t.useState)(0),[R,E]=(0,t.useState)(!1),F=(0,t.useCallback)(()=>{j.k.get(`/api/error-items/${e}/practice-records`).then(e=>{T(e),g?.(e.masteryStatus)}).catch(()=>void 0)},[e,g]);(0,t.useEffect)(F,[F]);let H=()=>{M(0),F()},I=async e=>{if(await (0,w.u)(p.mastery.deleteRecordConfirm,{destructive:!0}))try{await j.k.delete(`/api/practice/record/${e}`),H()}catch{w.c.error(p.mastery.deleteRecordFailed)}},P=C?.records[0],D=!!P&&(!C?.masteryEvaluatedAt||new Date(P.createdAt)>new Date(C.masteryEvaluatedAt));if((0,t.useEffect)(()=>{if(!D||z>=20)return;let e=setTimeout(()=>{M(e=>e+1),F()},4e3);return()=>clearTimeout(e)},[D,z,F]),!C)return null;let q=C.masteryProbability,O=null===q?null:Math.round(100*q),U=null===O?"":(0,k.m)(q,C.masteryThreshold)?"bg-green-500":O>=30?"bg-amber-500":"bg-red-500",_=p.practice.difficulty;return(0,s.jsxs)(f.N,{children:[(0,s.jsx)(f.Y,{children:(0,s.jsxs)(f.v,{className:"flex items-center gap-2 text-base",children:[(0,s.jsx)(m.f,{className:"h-4 w-4 text-primary"}),p.mastery.probability]})}),(0,s.jsxs)(f.O,{className:"space-y-4",children:[null===O?(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:D?p.mastery.pending:p.mastery.notEvaluated}):(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,s.jsxs)("span",{className:"text-3xl font-bold",children:[O,"%"]}),(0,s.jsxs)("span",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[D&&(0,s.jsx)(d.f,{className:"h-3 w-3 animate-spin"}),(0,s.jsx)(u.f,{variant:"outline",children:"ai"===C.masterySource?p.mastery.aiEvaluated:p.mastery.estimated})]})]}),(0,s.jsx)("div",{className:"h-2 w-full rounded-full bg-muted overflow-hidden",children:(0,s.jsx)("div",{className:`h-full ${U} transition-all`,style:{width:`${O}%`}})}),C.masteryReason&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:C.masteryReason}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:p.mastery.thresholdHint.replace("{threshold}",String(C.masteryThreshold))})]}),(0,s.jsxs)("div",{className:"space-y-2 border-t pt-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("h4",{className:"text-sm font-semibold",children:p.mastery.history}),!R&&(0,s.jsxs)(x.f,{variant:"outline",size:"sm",onClick:()=>E(!0),children:[(0,s.jsx)(c.f,{className:"mr-1 h-4 w-4"}),p.mastery.addRecord]})]}),R&&(0,s.jsx)(v,{errorItemId:e,onCancel:()=>E(!1),onSaved:()=>{E(!1),H()}}),0===C.records.length?(0,s.jsx)("p",{className:"text-sm text-muted-foreground italic",children:p.mastery.noHistory}):(0,s.jsx)("ul",{className:"divide-y rounded-md border",children:C.records.map(e=>(0,s.jsxs)("li",{className:"p-3 text-sm space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsxs)("button",{type:"button",className:"flex min-w-0 flex-1 flex-wrap items-center gap-2 text-left",onClick:()=>A($===e.id?null:e.id),children:[(0,s.jsx)("span",{className:"text-muted-foreground tabular-nums",children:(0,i.r)(e.createdAt,"yyyy-MM-dd HH:mm",b)}),(0,s.jsx)(u.f,{variant:"outline",className:S[e.result]||"",children:p.mastery.results[e.result]||e.result}),e.difficulty&&(0,s.jsx)(u.f,{variant:"secondary",children:_[e.difficulty]||e.difficulty}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:e.exam?`${p.mastery.sources.exam} \xb7 ${e.exam.title}`:p.mastery.sources[e.source]||p.mastery.sources.practice}),e.questionText&&(0,s.jsx)("span",{className:"ml-auto text-muted-foreground",children:$===e.id?(0,s.jsx)(n.f,{className:"h-4 w-4"}):(0,s.jsx)(l.f,{className:"h-4 w-4"})})]}),(0,s.jsx)("button",{type:"button","aria-label":p.mastery.deleteRecord,title:p.mastery.deleteRecord,className:"shrink-0 rounded p-1 text-muted-foreground hover:bg-red-50 dark:hover:bg-red-950/40 hover:text-red-600 dark:hover:text-red-400",onClick:()=>I(e.id),children:(0,s.jsx)(o.f,{className:"h-4 w-4"})})]}),$===e.id&&e.questionText&&(0,s.jsxs)("div",{className:"space-y-2 rounded-md bg-muted/40 p-3",children:[(0,s.jsx)(h.f,{content:e.questionText}),(0,s.jsx)(N.f,{svg:e.figureSvg}),e.wrongAnswerText&&(0,s.jsxs)("div",{className:"border-t pt-2",children:[(0,s.jsx)("p",{className:"mb-1 font-medium",children:p.editor.wrongAnswerText}),(0,s.jsx)(h.f,{content:e.wrongAnswerText})]}),e.mistakeAnalysis&&(0,s.jsxs)("div",{className:"border-t pt-2",children:[(0,s.jsx)("p",{className:"mb-1 font-medium",children:p.editor.mistakeAnalysis}),(0,s.jsx)(h.f,{content:e.mistakeAnalysis})]}),e.originalImageUrl&&(0,s.jsx)("img",{src:e.originalImageUrl,alt:p.editor.wrongAnswerText,className:"max-h-96 max-w-full rounded object-contain"}),e.answerText&&(0,s.jsx)("div",{className:"border-t pt-2",children:(0,s.jsx)(h.f,{content:e.answerText,className:"font-semibold"})}),e.exam&&(0,s.jsx)(a.default,{href:`/exams/${e.exam.paperId}`,className:"text-xs text-primary hover:underline",children:e.exam.title})]})]},e.id))})]})]})]})},"x",0,S],991686);var C=e.i(534693);e.s(["f",()=>C.f],931454)},846968,e=>{var s=e.i(843476),t=e.i(548161),a=e.i(474544),r=e.i(741120),i=e.i(487486),l=e.i(111110);let n={new:{className:"bg-warning/15 text-amber-700 dark:text-warning",icon:a.f},reviewing:{className:"bg-primary/10 text-primary",icon:r.f},mastered:{className:"bg-success/15 text-success",icon:t.f}};e.s(["o",0,{new:"border-l-warning/70",reviewing:"border-l-primary/60",mastered:"border-l-success/70"},"x",0,function({status:e,className:t=""}){let{t:a}=(0,l.b)(),{className:r,icon:d}=n[e],c="mastered"===e?a.notebook.mastered:"reviewing"===e?a.notebook.reviewing:a.notebook.review;return(0,s.jsx)(i.f,{variant:"secondary",className:`${r} ${t}`,children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)(d,{className:"h-3 w-3"})," ",c]})})}])},393733,e=>{var s=e.i(843476),t=e.i(548161),a=e.i(576248),r=e.i(583967),i=e.i(111110);let l=[{value:"correct",icon:t.f,active:"border-green-600 bg-green-50 dark:bg-green-950/40 text-green-700 dark:text-green-300"},{value:"wrong",icon:r.f,active:"border-red-600 bg-red-50 dark:bg-red-950/40 text-red-700 dark:text-red-300"},{value:"not_attempted",icon:a.f,active:"border-amber-600 bg-amber-50 dark:bg-amber-950/40 text-amber-700 dark:text-amber-300"}];e.s(["f",0,function({value:e,onChange:t,disabled:a,size:r="md"}){let{t:n}=(0,i.b)(),d="sm"===r?"px-2 py-1 text-xs":"px-3 py-2 text-sm";return(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2",role:"radiogroup",children:l.map(({value:i,icon:l,active:c})=>(0,s.jsxs)("button",{type:"button",role:"radio","aria-checked":e===i,disabled:a,onClick:()=>t(i),className:`flex items-center justify-center gap-1 rounded-md border font-medium transition-colors disabled:opacity-60 ${d} ${e===i?c:"border-input hover:bg-muted"}`,children:[(0,s.jsx)(l,{className:"sm"===r?"h-3 w-3":"h-4 w-4"}),n.mastery.results[i]]},i))})}])},912505,e=>{var s=e.i(843476),t=e.i(975157);e.s(["f",0,function({icon:e,title:a,description:r,action:i,className:l}){return(0,s.jsxs)("div",{className:(0,t.f)("flex flex-col items-center justify-center rounded-2xl border border-dashed bg-card/50 px-6 py-14 text-center",l),children:[(0,s.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-accent text-accent-foreground",children:(0,s.jsx)(e,{className:"h-7 w-7"})}),(0,s.jsx)("p",{className:"font-medium",children:a}),r&&(0,s.jsx)("p",{className:"mt-1 max-w-sm text-sm text-muted-foreground",children:r}),i&&(0,s.jsx)("div",{className:"mt-5",children:i})]})}])},86963,e=>{var s=e.i(843476),t=e.i(632781);e.s(["f",0,function({label:e}){return(0,s.jsxs)("div",{className:"flex min-h-[50vh] flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,s.jsx)(t.f,{className:"h-7 w-7 animate-spin text-primary"}),e&&(0,s.jsx)("p",{className:"text-sm",children:e})]})}])},35209,e=>{var s=e.i(271645),t=e.i(111110);e.s(["f",0,function(...e){let{t:a}=(0,t.b)(),r=[a.pageTitle.base,...e.map(e=>"string"==typeof e?e.trim():"").filter(e=>e.length>0)].join("-");(0,s.useEffect)(()=>{document.title=r},[r])}])},428602,e=>{e.s(["f",0,function(e){if(e.tags&&e.tags.length>0)return e.tags.map(e=>e.name);if(!e.knowledgePoints)return[];try{let s=JSON.parse(e.knowledgePoints);return Array.isArray(s)?s.filter(e=>"string"==typeof e):[]}catch{return[]}}])}],462684,e=>{e.v(s=>Promise.all(["static/chunks/2hh64gi4pmlk2.js"].map(s=>e.l(s))).then(()=>s(506175)))}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,[711241,e=>{var s=e.i(456420);let t={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};t.node;let i=(0,s.f)(t);e.s(["f",0,i],711241)},590546,e=>{var s=e.i(843476),t=e.i(618566),i=e.i(519455),a=e.i(711241);e.s(["f",0,function({fallbackUrl:e,className:l}){let n=(0,t.useRouter)();return(0,s.jsx)(i.f,{variant:"ghost",size:"icon",onClick:()=>{n.push(e)},className:l,children:(0,s.jsx)(a.f,{className:"h-5 w-5"})})}])},912505,e=>{var s=e.i(843476),t=e.i(975157);e.s(["f",0,function({icon:e,title:i,description:a,action:l,className:n}){return(0,s.jsxs)("div",{className:(0,t.f)("flex flex-col items-center justify-center rounded-2xl border border-dashed bg-card/50 px-6 py-14 text-center",n),children:[(0,s.jsx)("div",{className:"mb-4 flex h-14 w-14 items-center justify-center rounded-2xl bg-accent text-accent-foreground",children:(0,s.jsx)(e,{className:"h-7 w-7"})}),(0,s.jsx)("p",{className:"font-medium",children:i}),a&&(0,s.jsx)("p",{className:"mt-1 max-w-sm text-sm text-muted-foreground",children:a}),l&&(0,s.jsx)("div",{className:"mt-5",children:l})]})}])},393842,e=>{var s=e.i(843476),t=e.i(590546),i=e.i(975157);e.s(["f",0,function({title:e,description:a,backHref:l,actions:n,titleAddon:r,className:c}){return(0,s.jsxs)("div",{className:(0,i.f)("flex items-start gap-3",c),children:[l&&(0,s.jsx)(t.f,{fallbackUrl:l,className:"-ml-2 shrink-0"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("h1",{className:"truncate text-2xl font-bold tracking-tight sm:text-3xl",children:e}),r]}),a&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground sm:text-base",children:a})]}),n&&(0,s.jsx)("div",{className:"flex shrink-0 items-center gap-2",children:n})]})}])},86963,e=>{var s=e.i(843476),t=e.i(632781);e.s(["f",0,function({label:e}){return(0,s.jsxs)("div",{className:"flex min-h-[50vh] flex-col items-center justify-center gap-3 text-muted-foreground",children:[(0,s.jsx)(t.f,{className:"h-7 w-7 animate-spin text-primary"}),e&&(0,s.jsx)("p",{className:"text-sm",children:e})]})}])},35209,e=>{var s=e.i(271645),t=e.i(111110);e.s(["f",0,function(...e){let{t:i}=(0,t.b)(),a=[i.pageTitle.base,...e.map(e=>"string"==typeof e?e.trim():"").filter(e=>e.length>0)].join("-");(0,s.useEffect)(()=>{document.title=a},[a])}])}],462684,e=>{e.v(s=>Promise.all(["static/chunks/2hh64gi4pmlk2.js"].map(s=>e.l(s))).then(()=>s(506175)))}]);
@@ -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),k=e.i(41931),v=e.i(201276),y=e.i(35209),b=e.i(598053),I=e.i(315092),N=e.i(804536),S=e.i(271945);e.s(["default",0,function(){let e=(0,t.useParams)(),T=(0,t.useRouter)(),w=e.id,{t:P}=(0,j.b)(),[C,z]=(0,s.useState)(null);(0,y.f)(P.notebooks.title,C?.name,P.pageTitle.addError);let[A,B]=(0,N.y)(S.c,S.k,"image"),R=(0,b.f)({logPrefix:"[AddErrorItem]",analyzeSubjectId:w,importSubjectId:w,textNotebook:{id:w,name:C?.name||""},fixedSubjectId:w});return((0,s.useEffect)(()=>{k.k.get(`/api/notebooks/${w}`).then(e=>z(e)).catch(e=>{v.V.error("[AddErrorItem]","Failed to fetch notebook",{error:e}),T.push("/notebooks")})},[w,T]),C)?(0,a.jsxs)("main",{className:"min-h-screen",children:[(0,a.jsx)(h.f,{status:R.analysisStep,completed:R.completedStages}),(0,a.jsxs)("div",{className:`mx-auto space-y-6 px-4 py-6 md:px-8 md:py-8 ${"review"===R.step?"max-w-6xl":"max-w-4xl"}`,children:[(0,a.jsx)(p.f,{message:R.saveError,onDismiss:R.dismissSaveError}),(0,a.jsx)(x.f,{backHref:`/notebooks/${w}`,title:P.app.addError,description:C.name}),"upload"===R.step&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(g.f,{options:[{value:"image",icon:i.f,label:P.app?.uploadImage||"Take Photo"},{value:"text",icon:n.f,label:P.app?.manualInput||"Manual Input"}],value:A,onChange:B}),R.pendingTask&&(0,a.jsx)(d.f,{task:R.pendingTask,onRefresh:R.refreshPendingTask,onDismiss:R.dismissPendingTask}),R.lastImported&&(0,a.jsx)(c.f,{imported:R.lastImported,onDismiss:R.dismissImported}),R.batchImages?(0,a.jsx)(l.f,{images:R.batchImages,subjectId:w,onClose:R.closeBatch}):"image"===A?(0,a.jsxs)(a.Fragment,{children:[R.parts.length>0&&(0,a.jsx)(m.f,{parts:R.parts.map(e=>e.dataUrl),busy:R.isBusy,onFinish:()=>void R.finishParts(),onDiscard:R.discardParts}),(0,a.jsx)(f.f,{onImageSelect:R.selectImage,isAnalyzing:R.isBusy})]}):(0,a.jsx)(u.f,{onSubmit:R.submitText,isAnalyzing:R.isBusy,defaultNotebookName:C.name,onCreateBatch:R.createTextBatch,creatingBatch:R.creatingBatch})]}),"review"===R.step&&R.parsedData&&(0,a.jsx)(r.f,{initialData:R.parsedData,imagePreview:R.currentImage,onSave:R.saveReviewed,onCancel:R.cancelReview,initialSubjectId:w,aiTimeout:R.aiTimeout})]}),(0,a.jsx)(o.f,{imageSrc:R.croppingImage||"",open:R.isCropperOpen,onClose:R.closeCropper,onRegionsSelected:R.cropRegions,allowMulti:0===R.parts.length,onAutoSplit:0===R.parts.length?R.autoSplitImage:void 0,onAddPart:R.parts.length<I.u-1?R.addPart:void 0,partCount:R.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:P.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)))}]);