wrong-notebook 2026.11.9-3 → 2026.11.9-4

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 (155) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +1 -0
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/routes-manifest.json +6 -0
  6. package/.next/server/app/_global-error.html +1 -1
  7. package/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  12. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/.next/server/app/admin/page.js.nft.json +1 -1
  14. package/.next/server/app/admin/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/admin/user/[id]/page.js.nft.json +1 -1
  16. package/.next/server/app/admin/user/[id]/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/analyze/route.js.nft.json +1 -1
  18. package/.next/server/app/api/error-items/[id]/figure/route.js.nft.json +1 -1
  19. package/.next/server/app/api/error-items/[id]/fix-latex/route.js.nft.json +1 -1
  20. package/.next/server/app/api/error-items/[id]/geogebra/route.js.nft.json +1 -1
  21. package/.next/server/app/api/error-items/[id]/notes/route.js.nft.json +1 -1
  22. package/.next/server/app/api/error-items/[id]/reanswer/route.js.nft.json +1 -1
  23. package/.next/server/app/api/error-items/[id]/retag/route.js.nft.json +1 -1
  24. package/.next/server/app/api/error-items/[id]/route.js.nft.json +1 -1
  25. package/.next/server/app/api/error-items/[id]/svg-animation/narration/route.js.nft.json +1 -1
  26. package/.next/server/app/api/error-items/[id]/svg-animation/route.js.nft.json +1 -1
  27. package/.next/server/app/api/error-items/batch-delete/route.js.nft.json +1 -1
  28. package/.next/server/app/api/error-items/batch-move/route/app-paths-manifest.json +3 -0
  29. package/.next/server/app/api/error-items/batch-move/route/build-manifest.json +12 -0
  30. package/.next/server/app/api/error-items/batch-move/route/server-reference-manifest.json +4 -0
  31. package/.next/server/app/api/error-items/batch-move/route.js +18 -0
  32. package/.next/server/app/api/error-items/batch-move/route.js.map +5 -0
  33. package/.next/server/app/api/error-items/batch-move/route.js.nft.json +1 -0
  34. package/.next/server/app/api/error-items/batch-move/route_client-reference-manifest.js +3 -0
  35. package/.next/server/app/api/error-items/route.js.nft.json +1 -1
  36. package/.next/server/app/api/exams/[id]/questions/[questionId]/regenerate/route.js.nft.json +1 -1
  37. package/.next/server/app/api/exams/[id]/results/route.js.nft.json +1 -1
  38. package/.next/server/app/api/exams/[id]/retry/route.js.nft.json +1 -1
  39. package/.next/server/app/api/exams/[id]/route.js.nft.json +1 -1
  40. package/.next/server/app/api/exams/route.js.nft.json +1 -1
  41. package/.next/server/app/api/geogebra-analyze/route.js.nft.json +1 -1
  42. package/.next/server/app/api/import/route.js.nft.json +1 -1
  43. package/.next/server/app/api/import-batches/[id]/confirm-all/route.js.nft.json +1 -1
  44. package/.next/server/app/api/import-batches/[id]/fix-text/route.js.nft.json +1 -1
  45. package/.next/server/app/api/import-batches/[id]/read/route.js.nft.json +1 -1
  46. package/.next/server/app/api/import-batches/[id]/retry/route.js.nft.json +1 -1
  47. package/.next/server/app/api/import-batches/[id]/route.js.nft.json +1 -1
  48. package/.next/server/app/api/import-batches/[id]/start/route.js.nft.json +1 -1
  49. package/.next/server/app/api/import-batches/route.js.nft.json +1 -1
  50. package/.next/server/app/api/import-tasks/[id]/confirm/route.js.nft.json +1 -1
  51. package/.next/server/app/api/import-tasks/[id]/read/route.js.nft.json +1 -1
  52. package/.next/server/app/api/import-tasks/[id]/retry/route.js.nft.json +1 -1
  53. package/.next/server/app/api/import-tasks/[id]/route.js.nft.json +1 -1
  54. package/.next/server/app/api/import-tasks/route.js.nft.json +1 -1
  55. package/.next/server/app/api/notebooks/[id]/retag/route.js.nft.json +1 -1
  56. package/.next/server/app/api/openclaw/batch-upload/route.js.nft.json +1 -1
  57. package/.next/server/app/api/practice/generate/route.js.nft.json +1 -1
  58. package/.next/server/app/api/reanswer/route.js.nft.json +1 -1
  59. package/.next/server/app/api/tasks/route.js.nft.json +1 -1
  60. package/.next/server/app/api/tts/batch/route.js.nft.json +1 -1
  61. package/.next/server/app/error-items/[id]/page.js.nft.json +1 -1
  62. package/.next/server/app/error-items/[id]/page_client-reference-manifest.js +1 -1
  63. package/.next/server/app/eula/page.js.nft.json +1 -1
  64. package/.next/server/app/eula/page_client-reference-manifest.js +1 -1
  65. package/.next/server/app/exams/[id]/page.js.nft.json +1 -1
  66. package/.next/server/app/exams/[id]/page_client-reference-manifest.js +1 -1
  67. package/.next/server/app/exams/[id]/print/page.js.nft.json +1 -1
  68. package/.next/server/app/exams/[id]/print/page_client-reference-manifest.js +1 -1
  69. package/.next/server/app/exams/page.js.nft.json +1 -1
  70. package/.next/server/app/exams/page_client-reference-manifest.js +1 -1
  71. package/.next/server/app/import-batches/[id]/page.js.nft.json +1 -1
  72. package/.next/server/app/import-batches/[id]/page_client-reference-manifest.js +1 -1
  73. package/.next/server/app/import-tasks/[id]/page.js.nft.json +1 -1
  74. package/.next/server/app/import-tasks/[id]/page_client-reference-manifest.js +1 -1
  75. package/.next/server/app/import-tasks/page.js.nft.json +1 -1
  76. package/.next/server/app/import-tasks/page_client-reference-manifest.js +1 -1
  77. package/.next/server/app/initialize/page.js.nft.json +1 -1
  78. package/.next/server/app/initialize/page_client-reference-manifest.js +1 -1
  79. package/.next/server/app/login/page.js.nft.json +1 -1
  80. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  81. package/.next/server/app/notebooks/[id]/add/page.js.nft.json +1 -1
  82. package/.next/server/app/notebooks/[id]/add/page_client-reference-manifest.js +1 -1
  83. package/.next/server/app/notebooks/[id]/page.js.nft.json +1 -1
  84. package/.next/server/app/notebooks/[id]/page_client-reference-manifest.js +1 -1
  85. package/.next/server/app/notebooks/page.js.nft.json +1 -1
  86. package/.next/server/app/notebooks/page_client-reference-manifest.js +1 -1
  87. package/.next/server/app/page.js.nft.json +1 -1
  88. package/.next/server/app/page_client-reference-manifest.js +1 -1
  89. package/.next/server/app/practice/page.js.nft.json +1 -1
  90. package/.next/server/app/practice/page_client-reference-manifest.js +1 -1
  91. package/.next/server/app/print-preview/page.js.nft.json +1 -1
  92. package/.next/server/app/print-preview/page_client-reference-manifest.js +1 -1
  93. package/.next/server/app/register/page.js.nft.json +1 -1
  94. package/.next/server/app/register/page_client-reference-manifest.js +1 -1
  95. package/.next/server/app/review/page.js.nft.json +1 -1
  96. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  97. package/.next/server/app/setup/page.js.nft.json +1 -1
  98. package/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  99. package/.next/server/app/stats/page.js.nft.json +1 -1
  100. package/.next/server/app/stats/page_client-reference-manifest.js +1 -1
  101. package/.next/server/app/tags/page.js.nft.json +1 -1
  102. package/.next/server/app/tags/page_client-reference-manifest.js +1 -1
  103. package/.next/server/app-paths-manifest.json +1 -0
  104. package/.next/server/chunks/_007ypexktdy5h._.js +3 -0
  105. package/.next/server/chunks/_0431fxnqiloso._.js +1 -1
  106. package/.next/server/chunks/_0kreo-8xn80hb._.js +1 -1
  107. package/.next/server/chunks/_0tktp4y6lb9uv._.js +3 -0
  108. package/.next/server/chunks/_12xi_xqvtrn3k._.js +1 -1
  109. package/.next/server/chunks/_1cydcmia78z15._.js +1 -1
  110. package/.next/server/chunks/_next-internal_server_app_api_error-items_batch-move_route_actions_1usg70f6cukl0.js +3 -0
  111. package/.next/server/chunks/src_lib_question_question-deduplication_ts_0gumctesi3szc._.js +1 -1
  112. package/.next/server/chunks/src_lib_schemas_error-items_ts_0vdof4417rd3y._.js +1 -1
  113. package/.next/server/chunks/ssr/[root-of-the-server]__0l0hz47yn1ku_._.js +3 -0
  114. package/.next/server/chunks/ssr/_02_avk2sj3zf5._.js +3 -0
  115. package/.next/server/chunks/ssr/_07igsu8xjloky._.js +3 -0
  116. package/.next/server/chunks/ssr/{_0mvuvawj5-r--._.js → _0qiirfq71m0ty._.js} +2 -2
  117. package/.next/server/chunks/ssr/_12x0l20ysatxn._.js +3 -0
  118. package/.next/server/chunks/ssr/{_19hxsrrruepym._.js → _1m7f_7kfoqzo_._.js} +2 -2
  119. package/.next/server/chunks/ssr/_1m8y_pv3jak70._.js +3 -0
  120. package/.next/server/chunks/ssr/{node_modules_16_s8zyr3620u._.js → node_modules_0nslyotwav52f._.js} +1 -1
  121. package/.next/server/chunks/ssr/{_0t-venqf7b-4q._.js → node_modules_lucide-react_dist_esm_icons_0mg8mlclupjv-._.js} +2 -2
  122. package/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_1qsyz9_vm6jfk._.js +3 -0
  123. package/.next/server/chunks/ssr/src_app_notebooks_[id]_page_tsx_08njm-5-txm8_._.js +1 -1
  124. package/.next/server/chunks/ssr/src_components_providers_tsx_09kw-mv3nb6xs._.js +2 -2
  125. package/.next/server/chunks/ssr/src_contexts_LanguageContext_tsx_0r6xucmeu1k5z._.js +1 -1
  126. package/.next/server/chunks/ssr/src_lib_i18n_en_ts_08zkpwnoqey5s._.js +1 -1
  127. package/.next/server/middleware-build-manifest.js +3 -3
  128. package/.next/server/pages/500.html +1 -1
  129. package/.next/server/preview-props.json +3 -3
  130. package/.next/server/server-reference-manifest.js +1 -1
  131. package/.next/server/server-reference-manifest.json +1 -1
  132. package/.next/static/chunks/{334z2x2rojgkd.js → 032xzuhi_gy7t.js} +1 -1
  133. package/.next/static/chunks/{0_cnc6gz9gqm8.js → 0ocb49htmlhl5.js} +3 -3
  134. package/.next/static/chunks/{0bufg6cl_1x2h.js → 142ggarrxy3ku.js} +1 -1
  135. package/.next/static/chunks/{1ziwji7xw98fj.js → 1_lxyr04qvsxk.js} +1 -1
  136. package/.next/static/chunks/{05f13kdl-5r-c.js → 1ey5h3_143nwz.js} +2 -2
  137. package/.next/static/chunks/1v01oqugf1j5g.js +1 -0
  138. package/.next/static/chunks/2secy011jtksr.js +1 -0
  139. package/.next/static/chunks/{19a04m6wxadzm.js → 321kq8xr7a6_r.js} +1 -1
  140. package/.next/static/chunks/3hft-37m4c_s4.js +1 -0
  141. package/package.json +1 -1
  142. package/prisma/seed.db +0 -0
  143. package/.next/server/chunks/ssr/[root-of-the-server]__0x4us8rfvt68s._.js +0 -3
  144. package/.next/server/chunks/ssr/[root-of-the-server]__124rb-z-nm7o5._.js +0 -3
  145. package/.next/server/chunks/ssr/[root-of-the-server]__1yhcc4i7ps6s5._.js +0 -3
  146. package/.next/server/chunks/ssr/_0ethdphoh7xqp._.js +0 -3
  147. package/.next/server/chunks/ssr/_0qbp5_0h-b69q._.js +0 -3
  148. package/.next/server/chunks/ssr/_1s3gqrczubor-._.js +0 -3
  149. package/.next/server/chunks/ssr/_1wt7hpzajqoju._.js +0 -3
  150. package/.next/static/chunks/11jjfyt0-zwcn.js +0 -1
  151. package/.next/static/chunks/209odxnq_2nok.js +0 -1
  152. package/.next/static/chunks/2hl62fuxy23ky.js +0 -1
  153. /package/.next/static/{rECWSmgzryfRL_QGfDMQL → SksTfjOW_RawBbtAQNssc}/_buildManifest.js +0 -0
  154. /package/.next/static/{rECWSmgzryfRL_QGfDMQL → SksTfjOW_RawBbtAQNssc}/_clientMiddlewareManifest.js +0 -0
  155. /package/.next/static/{rECWSmgzryfRL_QGfDMQL → SksTfjOW_RawBbtAQNssc}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- module.exports=[418175,a=>{"use strict";var b=a.i(187924),c=a.i(572131),d=a.i(550194),e=a.i(875003),f=a.i(291938),g=a.i(960927),h=a.i(630534);let i=["system","light","dark"],j="system",k="app-theme";function l(a){return"string"==typeof a&&i.includes(a)}let m=(0,c.createContext)({preference:j,theme:"light",setPreference:()=>void 0}),n="(prefers-color-scheme: dark)",o=new Set;function p(a){return o.add(a),window.addEventListener("storage",a),()=>{o.delete(a),window.removeEventListener("storage",a)}}function q(){try{let a=localStorage.getItem(k);return l(a)?a:j}catch{return j}}function r(a){try{localStorage.setItem(k,a)}catch{}o.forEach(a=>a())}function s(a){let b=window.matchMedia(n);return b.addEventListener("change",a),()=>b.removeEventListener("change",a)}let t=()=>window.matchMedia(n).matches;function u({children:a}){let{data:d,status:i}=(0,e.useSession)(),k="authenticated"===i,n=d?.user?.email,o=(0,c.useSyncExternalStore)(p,q,()=>j),v=(0,c.useSyncExternalStore)(s,t,()=>!1),w="system"===o?v?"dark":"light":o;(0,c.useEffect)(()=>{let a=document.documentElement,b=b=>{a.classList.toggle("dark","dark"===b),a.style.colorScheme=b};b(w);let c=()=>b("light"),d=()=>b(w);return window.addEventListener("beforeprint",c),window.addEventListener("afterprint",d),()=>{window.removeEventListener("beforeprint",c),window.removeEventListener("afterprint",d)}},[w]),(0,c.useEffect)(()=>{if(!k||!n)return;let a=!1;return f.k.get("/api/user").then(b=>{!a&&l(b.themePreference)&&b.themePreference!==q()&&r(b.themePreference)}).catch(a=>{h.V.warn("[Theme]","Failed to load theme preference",{error:(0,g.Z)(a)})}),()=>{a=!0}},[k,n]);let x=(0,c.useCallback)(a=>{r(a),k&&f.k.patch("/api/user",{themePreference:a}).catch(a=>{h.V.warn("[Theme]","Failed to save theme preference",{error:(0,g.Z)(a)})})},[k]),y=(0,c.useMemo)(()=>({preference:o,theme:w,setPreference:x}),[o,w,x]);return(0,b.jsx)(m.Provider,{value:y,children:a})}var v=a.i(529759),w=a.i(50944),x=a.i(875160),y=a.i(699570),z=a.i(814574),A=a.i(510606),B=a.i(283248),C=a.i(118688),D=a.i(895605),E=a.i(483138),F=a.i(164831);let G={name:"circle-plus",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],aliases:["plus-circle"]};G.node;let H=(0,F.f)(G),I=[/^\/login/,/^\/register/,/^\/setup/,/^\/print-preview/,/^\/exams\/[^/]+\/print/],J=[{key:"home",href:"/",icon:H,match:a=>"/"===a},{key:"notebooks",href:"/notebooks",icon:C.f,match:a=>a.startsWith("/notebooks")||a.startsWith("/error-items")||a.startsWith("/practice")},{key:"review",href:"/review",icon:D.f,match:a=>a.startsWith("/review")},{key:"stats",href:"/stats",icon:B.f,match:a=>a.startsWith("/stats")||a.startsWith("/tags")},{key:"exams",href:"/exams",icon:E.f,match:a=>a.startsWith("/exams")}];function K(a){return I.some(b=>b.test(a))}var L=a.i(710302);let M="ai-consent-dismissed:";function N(){let{t:a,language:g}=(0,d.b)(),i=a.aiConsent,{data:j,status:k}=(0,e.useSession)(),l=(0,w.usePathname)()||"/",m="authenticated"===k?j?.user?.email??null:null,[n,o]=(0,c.useState)(null),[p,q]=(0,c.useState)(null),[r,s]=(0,c.useState)(!1);(0,c.useEffect)(()=>(0,A.y)(a=>o(b=>b??a)),[]);let t=K(l);(0,c.useEffect)(()=>{if(!m||t||function(a){try{return"1"===sessionStorage.getItem(a)}catch{return!1}}(M+m))return;let a=!1;return f.k.get("/api/user").then(b=>{a||!b||b.aiDataConsentAt||o(a=>a??"prompt")}).catch(a=>h.V.error("[AiConsentDialog]","load consent failed",{error:a})),()=>{a=!0}},[m,t]);let u=null!==n&&!!m;(0,c.useEffect)(()=>{if(!u)return;let a=!1;return f.k.get("/api/settings").then(b=>{a||q(b?.aiProvider??null)}).catch(()=>void 0),()=>{a=!0}},[u]);let v=()=>{o(null),s(!1)},B=async()=>{s(!0);try{await f.k.post("/api/user/ai-consent",{}),L.c.success("blocked"===n?i.agreedRetry:i.agreed),v()}catch(a){h.V.error("[AiConsentDialog]","save consent failed",{error:a}),L.c.error(i.failed),s(!1)}},C=()=>{m&&function(a){try{sessionStorage.setItem(a,"1")}catch{}}(M+m),L.c.info(i.declined),v()},D=(0,A.K)(p,g);return(0,b.jsx)(z.N,{open:u,onOpenChange:a=>{a||r||C()},children:(0,b.jsxs)(z.d,{className:"sm:max-w-lg",children:[(0,b.jsxs)(z.s,{children:[(0,b.jsx)(z.F,{children:i.title}),(0,b.jsx)(z.C,{children:"blocked"===n?i.blocked:i.intro})]}),(0,b.jsxs)("div",{className:"space-y-3 text-sm",children:["blocked"===n&&(0,b.jsx)("p",{children:i.intro}),(0,b.jsx)("ul",{className:"list-disc space-y-1 pl-5",children:i.items.map(a=>(0,b.jsx)("li",{children:a},a))}),(0,b.jsx)("p",{children:D?i.providerKnown.replace("{provider}",D):i.providerUnknown}),(0,b.jsxs)("p",{children:[i.policy,"en"===g?" ":"",(0,b.jsx)("a",{className:"underline underline-offset-2",href:(0,A.L)(g),target:"_blank",rel:"noopener noreferrer",children:i.policyLink}),"en"===g?".":"。"]}),(0,b.jsx)("p",{className:"text-muted-foreground",children:i.declineNote})]}),(0,b.jsxs)(z.c,{className:"gap-2",children:[(0,b.jsx)(y.f,{type:"button",variant:"outline",onClick:C,disabled:r,children:i.decline}),(0,b.jsxs)(y.f,{type:"button",onClick:B,disabled:r,children:[r&&(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}),i.agree]})]})]})})}var O=a.i(16644),P=a.i(238246),Q=a.i(557230);let R={name:"shield",size:24,node:[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]};R.node;let S=(0,F.f)(R);var T=a.i(303324);function U({status:a,onAccept:f}){let{t:g,language:i}=(0,d.b)(),[j,k]=(0,c.useState)(!1),l="en"===i?a.changes.en:a.changes.zh,m=async()=>{k(!0);try{await f()}catch(a){h.V.error("[EulaGate]","Failed to accept EULA",{error:a}),L.c.error(g.eula.acceptFailed)}finally{k(!1)}};return(0,b.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/60 p-4",role:"dialog","aria-modal":"true","aria-labelledby":"eula-upgrade-title",children:(0,b.jsxs)("div",{className:"max-h-[90vh] w-full max-w-lg space-y-4 overflow-y-auto rounded-lg border bg-background p-5 shadow-lg",children:[(0,b.jsx)("h2",{id:"eula-upgrade-title",className:"text-lg font-semibold",children:g.eula.upgradeTitle}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:g.eula.upgradeDesc.replace("{accepted}",a.accepted??"-").replace("{current}",a.current)}),l.length>0&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-sm font-medium",children:g.eula.changesTitle}),(0,b.jsx)("ul",{className:"list-disc space-y-1 pl-5 text-sm",children:l.map(a=>(0,b.jsx)("li",{children:a},a))})]}),(0,b.jsx)(T.f,{}),(0,b.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[(0,b.jsx)(y.f,{variant:"outline",onClick:()=>(0,e.signOut)({callbackUrl:"/login"}),disabled:j,children:g.eula.logout}),(0,b.jsxs)(y.f,{onClick:m,disabled:j,children:[j&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),g.eula.accept]})]})]})})}var V=a.i(780767),W=a.i(682338),X=a.i(368114);function Y({className:a}){let{t:e}=(0,d.b)(),{data:f}=(0,W.b)(),g=(0,c.useRef)(null);if((0,c.useEffect)(()=>{if(!f)return;let a=new Set([...f.tasks.filter(a=>"analyzing"===a.status||"saving"===a.status).map(a=>a.id),...(f.batches??[]).filter(a=>"splitting"===a.phase||"processing"===a.phase).map(a=>`batch:${a.id}`)]),b=new Set([...f.tasks.filter(a=>a.unread).map(a=>a.id),...(f.batches??[]).filter(a=>a.unread).map(a=>`batch:${a.id}`)]),c=g.current;c&&[...c].some(c=>!a.has(c)&&b.has(c))&&L.c.info(e.importTasks.finishedToast),g.current=a},[f,e.importTasks.finishedToast]),!f||0===f.tasks.length&&!f.batches?.length)return null;let{activeCount:h,unreadCount:i}=f,j=h>0?e.importTasks.entryActive.replace("{count}",String(h)):e.importTasks.entry;return(0,b.jsxs)(P.default,{href:"/import-tasks",className:(0,X.f)("relative flex h-9 items-center gap-1.5 rounded-full border px-3 text-sm font-medium transition-colors hover:bg-muted",i>0?"border-primary/50 text-primary":"text-muted-foreground",a),"data-testid":"import-tasks-entry","aria-label":i>0?`${j} \xb7 ${e.importTasks.entryUnread.replace("{count}",String(i))}`:j,children:[h>0?(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}):(0,b.jsx)(V.f,{className:"h-4 w-4"}),(0,b.jsx)("span",{className:"whitespace-nowrap",children:j}),i>0&&(0,b.jsx)("span",{className:"flex h-5 min-w-5 items-center justify-center rounded-full bg-destructive px-1 text-xs text-white","data-testid":"import-tasks-unread",children:i})]})}var Z=a.i(390702);let $={name:"bot",size:24,node:[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]};$.node;let _=(0,F.f)($),aa={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};aa.node;let ab=(0,F.f)(aa);var ac=a.i(357204);let ad={name:"message-square-text",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]};ad.node;let ae=(0,F.f)(ad),af={name:"settings",size:24,node:[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]};af.node;let ag=(0,F.f)(af);var ah=a.i(344451),ai=a.i(930363),aj=a.i(875083),ak=a.i(986705),al=a.i(786304),am=a.i(563658),an=a.i(866718),ao=a.i(870430);let ap=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("div",{className:"relative w-full overflow-auto",children:(0,b.jsx)("table",{ref:d,className:(0,X.f)("w-full caption-bottom text-sm",a),...c})}));ap.displayName="Table";let aq=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("thead",{ref:d,className:(0,X.f)("[&_tr]:border-b",a),...c}));aq.displayName="TableHeader";let ar=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("tbody",{ref:d,className:(0,X.f)("[&_tr:last-child]:border-0",a),...c}));ar.displayName="TableBody",(c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("tfoot",{ref:d,className:(0,X.f)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...c}))).displayName="TableFooter";let as=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("tr",{ref:d,className:(0,X.f)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",a),...c}));as.displayName="TableRow";let at=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("th",{ref:d,className:(0,X.f)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",a),...c}));at.displayName="TableHead";let au=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("td",{ref:d,className:(0,X.f)("p-4 align-middle [&:has([role=checkbox])]:pr-0",a),...c}));au.displayName="TableCell",(c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("caption",{ref:d,className:(0,X.f)("mt-4 text-sm text-muted-foreground",a),...c}))).displayName="TableCaption";var av=a.i(951675);let aw={name:"ban",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]};aw.node;let ax=(0,F.f)(aw);var ay=a.i(79362);function az(){var a;let{t:e}=(0,d.b)(),[g,i]=(0,c.useState)(String(5)),[j,k]=(0,c.useState)(!1),l=(0,c.useCallback)(async()=>{try{let a=await f.k.get("/api/settings");i(String(a.aiConcurrencyLimit??5))}catch(a){h.V.error("[AiConcurrencyLimitSetting]","Failed to fetch config",{error:a})}},[]);(0,c.useEffect)(()=>{l()},[l]);let m=Number(g),n=""!==g.trim()&&"number"==typeof(a=m)&&Number.isInteger(a)&&a>=1&&a<=100,o=async()=>{if(n){k(!0);try{await f.k.post("/api/settings",{aiConcurrencyLimit:m}),L.c.success(e.admin.aiConcurrencyLimitSaved)}catch(a){h.V.error("[AiConcurrencyLimitSetting]","Failed to update AI concurrency limit",{error:a}),L.c.error(e.common.error)}finally{k(!1)}}};return(0,b.jsxs)("div",{className:"flex flex-col gap-3 p-4 border rounded-lg bg-muted/30 sm:flex-row sm:items-center sm:justify-between",children:[(0,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)(ao.f,{htmlFor:"ai-concurrency-limit",className:"text-base",children:e.admin.aiConcurrencyLimit}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:e.admin.aiConcurrencyLimitDesc})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(an.f,{id:"ai-concurrency-limit",type:"number",min:1,max:100,step:1,inputMode:"numeric",value:g,onChange:a=>i(a.target.value),"aria-invalid":!n,className:"w-24"}),(0,b.jsxs)(y.f,{size:"sm",onClick:o,disabled:j||!n,children:[j&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.common.save]})]})]})}function aA(a,b){return new Intl.NumberFormat("zh"===b?"zh-CN":"en-US",{notation:"compact",maximumFractionDigits:1}).format(Math.max(0,a))}function aB({user:a}){let{t:c,language:e}=(0,d.b)(),f=c.admin.aiTokensDetail.replace("{input}",aA(a.aiTokensToday.input,e)).replace("{output}",aA(a.aiTokensToday.output,e));return(0,b.jsxs)(b.Fragment,{children:[c.admin.aiUsageToday,": ",a.aiUsageToday," | ",c.admin.aiTokensToday,": ",f]})}function aC(){let{timeZone:a}=(0,v.M)(),{data:i}=(0,e.useSession)(),{t:j}=(0,d.b)(),[k,l]=(0,c.useState)([]),[m,n]=(0,c.useState)(!0),[o,p]=(0,c.useState)(!1),[q,r]=(0,c.useState)(!1),[s,t]=(0,c.useState)("0"),[u,w]=(0,c.useState)(!1),z=(0,c.useCallback)(async()=>{n(!0);try{let a=await f.k.get("/api/admin/users");l(a)}catch(a){h.V.error("[UserManagement]","Failed to fetch users",{error:a})}finally{n(!1)}},[]),A=(0,c.useCallback)(async()=>{try{let a=await f.k.get("/api/settings");p(!0===a.allowRegistration),t(String(a.aiDailyLimit??0))}catch(a){h.V.error("[UserManagement]","Failed to fetch config",{error:a})}},[]);(0,c.useEffect)(()=>{z(),A()},[z,A]);let B=async a=>{r(!0);try{await f.k.post("/api/settings",{allowRegistration:a}),p(a)}catch(a){h.V.error("[UserManagement]","Failed to update registration setting",{error:a}),L.c.error(j.common.error)}finally{r(!1)}},C=Number(s),D=""!==s.trim()&&Number.isInteger(C)&&C>=0,E=async()=>{if(D){w(!0);try{await f.k.post("/api/settings",{aiDailyLimit:C}),L.c.success(j.admin.aiDailyLimitSaved)}catch(a){h.V.error("[UserManagement]","Failed to update AI daily limit",{error:a}),L.c.error(j.common.error)}finally{w(!1)}}},F=async a=>{let b=a.isActive?j.admin.confirmDisable:j.admin.confirmEnable;if(await (0,L.u)(b))try{await f.k.patch(`/api/admin/users/${a.id}`,{isActive:!a.isActive}),z()}catch(a){h.V.error("[UserManagement]","Failed to update user status",{error:a}),L.c.error(j.common.error)}},G=async a=>{if(await (0,L.u)(j.admin.confirmDelete,{destructive:!0}))try{await f.k.delete(`/api/admin/users/${a.id}`),z()}catch(b){h.V.error("[UserManagement]","Failed to delete user",{error:b});let a=(0,g.d)(b)||j.common.error;L.c.error(a)}};return m?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(x.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[(0,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)(ao.f,{className:"text-base",children:j.admin?.allowRegistration||"Allow New Registrations"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:j.admin?.allowRegistrationDesc||"When disabled, new users cannot register"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[q&&(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}),(0,b.jsx)(am.f,{checked:o,onCheckedChange:B,disabled:q})]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-3 p-4 border rounded-lg bg-muted/30 sm:flex-row sm:items-center sm:justify-between",children:[(0,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)(ao.f,{htmlFor:"ai-daily-limit",className:"text-base",children:j.admin.aiDailyLimit}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:j.admin.aiDailyLimitDesc})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(an.f,{id:"ai-daily-limit",type:"number",min:0,step:1,inputMode:"numeric",value:s,onChange:a=>t(a.target.value),"aria-invalid":!D,className:"w-24"}),(0,b.jsxs)(y.f,{size:"sm",onClick:E,disabled:u||!D,children:[u&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),j.common.save]})]})]}),(0,b.jsx)(az,{}),(0,b.jsx)("div",{className:"sm:hidden space-y-3",children:k.map(c=>(0,b.jsxs)("div",{className:"border rounded-lg p-4 bg-card space-y-3",children:[(0,b.jsxs)("div",{className:"flex justify-between items-start",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"font-medium",children:c.name||"N/A"}),(0,b.jsx)("div",{className:"text-sm text-muted-foreground",children:c.email})]}),(0,b.jsx)(al.f,{variant:"admin"===c.role?"default":"secondary",children:"admin"===c.role?j.admin.admin:j.admin.user})]}),(0,b.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,b.jsxs)("div",{className:"text-muted-foreground",children:[j.admin.errors,": ",c._count.errorItems," | ",j.admin.practiceCount,": ",c._count.practiceRecords," | ",(0,b.jsx)(aB,{user:c})]}),(0,b.jsx)(al.f,{variant:c.isActive?"default":"destructive",className:"text-xs",children:c.isActive?j.admin.active:j.admin.disabled})]}),(0,b.jsxs)("div",{className:"flex justify-between items-center pt-2 border-t",children:[(0,b.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,ak.r)(c.createdAt,"yyyy-MM-dd",a)}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:()=>F(c),disabled:c.id===i?.user?.id,children:c.isActive?(0,b.jsx)(ax,{className:"h-4 w-4 text-orange-500"}):(0,b.jsx)(ay.f,{className:"h-4 w-4 text-green-500"})}),(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:()=>G(c),disabled:c.id===i?.user?.id,children:(0,b.jsx)(av.f,{className:"h-4 w-4 text-destructive"})})]})]})]},c.id))}),(0,b.jsx)("div",{className:"hidden sm:block border rounded-lg overflow-hidden",children:(0,b.jsxs)(ap,{children:[(0,b.jsx)(aq,{children:(0,b.jsxs)(as,{children:[(0,b.jsx)(at,{children:j.admin.nameEmail}),(0,b.jsx)(at,{children:j.admin.role}),(0,b.jsx)(at,{children:j.admin.stats}),(0,b.jsx)(at,{children:j.admin.createdAt}),(0,b.jsx)(at,{children:j.admin.status}),(0,b.jsx)(at,{className:"text-right",children:j.admin.actions})]})}),(0,b.jsx)(ar,{children:k.map(c=>(0,b.jsxs)(as,{children:[(0,b.jsxs)(au,{children:[(0,b.jsx)("div",{className:"font-medium",children:c.name||"N/A"}),(0,b.jsx)("div",{className:"text-sm text-muted-foreground",children:c.email})]}),(0,b.jsx)(au,{children:(0,b.jsx)(al.f,{variant:"admin"===c.role?"default":"secondary",children:"admin"===c.role?j.admin.admin:j.admin.user})}),(0,b.jsxs)(au,{children:[(0,b.jsxs)("div",{className:"text-sm",children:[j.admin.errors,": ",c._count.errorItems]}),(0,b.jsxs)("div",{className:"text-sm",children:[j.admin.practiceCount,": ",c._count.practiceRecords]}),(0,b.jsx)("div",{className:"text-sm",children:(0,b.jsx)(aB,{user:c})})]}),(0,b.jsx)(au,{children:(0,ak.r)(c.createdAt,"yyyy-MM-dd",a)}),(0,b.jsx)(au,{children:(0,b.jsx)(al.f,{variant:c.isActive?"default":"destructive",children:c.isActive?j.admin.active:j.admin.disabled})}),(0,b.jsxs)(au,{className:"text-right space-x-2",children:[(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:()=>F(c),disabled:c.id===i?.user?.id,title:c.isActive?j.admin.disable:j.admin.enable,children:c.isActive?(0,b.jsx)(ax,{className:"h-4 w-4 text-orange-500"}):(0,b.jsx)(ay.f,{className:"h-4 w-4 text-green-500"})}),(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:()=>G(c),disabled:c.id===i?.user?.id,title:j.admin.delete,children:(0,b.jsx)(av.f,{className:"h-4 w-4 text-destructive"})})]})]},c.id))})]})})]})}var aD=a.i(168370);let aE={name:"scroll-text",size:24,node:[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]};aE.node;let aF=(0,F.f)(aE);function aG(a){return(0,b.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a,children:[(0,b.jsx)("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),(0,b.jsx)("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}let aH={name:"server",size:24,node:[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]};aH.node;let aI=(0,F.f)(aH);var aJ=a.i(540553);let aK=()=>()=>void 0;function aL(){let{t:a}=(0,d.b)(),e=(0,c.useSyncExternalStore)(aK,aJ.f,()=>null);return e?e.isStandalone?.()?(0,b.jsx)("p",{className:"text-center text-sm text-muted-foreground",children:a.settings?.about?.androidStandalone||"Running on this device. Data is stored only on this device."}):(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[(0,b.jsxs)("span",{className:"break-all",children:[a.settings?.about?.androidServer||"Server",": ",e.getServerUrl()]}),(0,b.jsxs)(y.f,{variant:"outline",className:"gap-2",onClick:()=>e.changeServer(),children:[(0,b.jsx)(aI,{className:"h-4 w-4"}),a.settings?.about?.changeServer||"Change server"]})]}):null}var aM=a.i(424235);function aN(){let{t:a}=(0,d.b)(),[e,f]=(0,c.useState)("");(0,c.useEffect)(()=>{fetch("/api/version").then(a=>a.json()).then(a=>f(a.version)).catch(()=>{})},[]);let g=[{href:aM.f,icon:aG,label:a.settings?.about?.github||"GitHub Repository"},{href:`${aM.f}/releases`,icon:aF,label:a.settings?.about?.releaseNotes||"Release Notes"},{href:`${aM.f}/issues`,icon:ae,label:a.settings?.about?.feedback||"Feedback"}];return(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-6 py-8 text-center bg-muted/30 rounded-lg border",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-2xl font-bold",children:a.app?.title||"Smart Error Notebook"}),(0,b.jsx)("p",{className:"text-muted-foreground",children:a.settings?.about?.desc||"AI-powered learning assistant"})]}),(0,b.jsxs)("div",{className:"flex items-center space-x-2 text-sm text-muted-foreground border px-4 py-2 rounded-full bg-background",children:[(0,b.jsx)(ab,{className:"h-4 w-4"}),(0,b.jsxs)("span",{children:[a.settings?.about?.version||"Version",": v",e||"unknown"]})]}),(0,b.jsx)(aL,{}),(0,b.jsx)("div",{className:"flex flex-col sm:flex-row flex-wrap justify-center gap-4 w-full sm:w-auto px-4 sm:px-0",children:g.map(({href:a,icon:c,label:d})=>(0,b.jsx)(y.f,{variant:"outline",asChild:!0,className:"gap-2 w-full sm:w-auto",children:(0,b.jsxs)("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[(0,b.jsx)(c,{className:"h-4 w-4"}),d,(0,b.jsx)(aD.f,{className:"h-3 w-3 ml-1 opacity-50"})]})},a))}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-8",children:a.settings?.about?.copyright||"© 2026 margrop · Based on wttwins/wrong-notebook · MIT License"})]})}var aO=a.i(152679),aP=a.i(580701),aQ=a.i(348966);let aR={name:"",email:"",educationStage:"",enrollmentYear:"",currentGrade:"",currentSemester:"",password:""};function aS(){let{t:a}=(0,d.b)(),[e,i]=(0,c.useState)(aR),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(!0),[n,o]=(0,c.useState)(!1),p=(0,c.useCallback)(async()=>{try{let a=await f.k.get("/api/user"),b=a.fixedGradeSemester?(0,aQ.p)(a.fixedGradeSemester):null;i({name:a.name||"",email:a.email||"",educationStage:a.educationStage||"",enrollmentYear:a.enrollmentYear||"",currentGrade:b?.grade||"",currentSemester:b?.semester||"",password:""})}catch(a){h.V.error("[AccountSettings]","Failed to fetch profile",{error:a})}finally{m(!1)}},[]);(0,c.useEffect)(()=>{p()},[p]);let q=async()=>{if(e.password&&e.password!==j)return void L.c.error(a.settings?.messages?.passwordMismatch||"Passwords do not match");o(!0);try{let b={name:e.name,email:e.email,educationStage:e.educationStage};e.enrollmentYear&&(b.enrollmentYear=parseInt(e.enrollmentYear.toString())),e.password&&(b.password=e.password),e.currentGrade&&e.currentSemester?b.fixedGradeSemester=`${e.currentGrade}${e.currentSemester}`:e.currentGrade||(b.fixedGradeSemester=null),await f.k.patch("/api/user",b),L.c.success(a.settings?.messages?.profileUpdated||"Profile updated"),i(a=>({...a,password:""})),k(""),window.location.reload()}catch(b){h.V.error("[AccountSettings]","Failed to update profile",{error:(0,g.d)(b)??(0,g.Z)(b)}),L.c.error((0,g.d)(b)||a.settings?.messages?.updateFailed||"Update failed")}finally{o(!1)}};return l?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(x.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,b.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.auth?.name||"Name"}),(0,b.jsx)(an.f,{value:e.name||"",onChange:a=>i({...e,name:a.target.value})})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.auth?.email||"Email"}),(0,b.jsx)(an.f,{value:e.email||"",onChange:a=>i({...e,email:a.target.value}),type:"email"})]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.auth?.educationStage||"Education Stage"}),(0,b.jsxs)(aP.d,{value:e.educationStage||"",onValueChange:a=>i({...e,educationStage:a,currentGrade:(0,aQ.c)(a).includes(e.currentGrade)?e.currentGrade:"",currentSemester:(0,aQ.c)(a).includes(e.currentGrade)?e.currentSemester:""}),children:[(0,b.jsx)(aP.P,{children:(0,b.jsx)(aP.U,{placeholder:a.auth?.selectStage||"Select Stage"})}),(0,b.jsxs)(aP.r,{children:[(0,b.jsx)(aP.T,{value:"primary",children:a.auth?.primary||"Primary School"}),(0,b.jsx)(aP.T,{value:"junior_high",children:a.auth?.juniorHigh||"Junior High"}),(0,b.jsx)(aP.T,{value:"senior_high",children:a.auth?.seniorHigh||"Senior High"}),(0,b.jsx)(aP.T,{value:"university",children:a.auth?.university||"University"})]})]})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.auth?.enrollmentYear||"Enrollment Year"}),(0,b.jsx)(an.f,{type:"number",value:e.enrollmentYear||"",onChange:a=>i({...e,enrollmentYear:a.target.value}),placeholder:"YYYY"})]})]}),e.educationStage&&(0,aQ.c)(e.educationStage).length>0&&(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.settings?.account?.currentGrade||"Current Grade & Semester"}),(0,b.jsxs)(aP.d,{value:e.currentGrade||"",onValueChange:a=>i({...e,currentGrade:a,currentSemester:a?e.currentSemester||"上":""}),children:[(0,b.jsx)(aP.P,{children:(0,b.jsx)(aP.U,{placeholder:a.settings?.account?.selectGrade||"Select Grade"})}),(0,b.jsx)(aP.r,{children:(0,aQ.c)(e.educationStage).map(a=>(0,b.jsx)(aP.T,{value:a,children:a},a))})]})]}),e.currentGrade&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.settings?.account?.selectSemester||"Select Semester"}),(0,b.jsxs)(aP.d,{value:e.currentSemester||"",onValueChange:a=>i({...e,currentSemester:a}),children:[(0,b.jsx)(aP.P,{children:(0,b.jsx)(aP.U,{placeholder:a.settings?.account?.selectSemester||"Select Semester"})}),(0,b.jsxs)(aP.r,{children:[(0,b.jsx)(aP.T,{value:"上",children:a.settings?.account?.firstSemester||"1st Semester"}),(0,b.jsx)(aP.T,{value:"下",children:a.settings?.account?.secondSemester||"2nd Semester"})]})]})]})]}),e.currentGrade&&e.currentSemester&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground -mt-2",children:a.settings?.account?.gradeAppliedHint||"New questions will default to this grade. You can also configure AI grade recognition in General Settings."}),(0,b.jsxs)("div",{className:"space-y-3 pt-2 border-t",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.settings?.account?.changePassword||"Change Password (Leave empty to keep)"}),(0,b.jsx)(aO.f,{value:e.password,onChange:a=>i({...e,password:a.target.value}),placeholder:"******",minLength:6})]}),e.password&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.auth?.confirmPassword||"Confirm Password"}),(0,b.jsx)(aO.f,{value:j,onChange:a=>k(a.target.value),placeholder:"******",minLength:6})]})]}),(0,b.jsxs)(y.f,{onClick:q,disabled:n,className:"w-full",children:[n&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.settings?.account?.update||"Update Profile"]})]})}var aT=a.i(151304),aU=a.i(201661),aV=a.i(246059),aW=a.i(998868),aX=a.i(332485),aY=a.i(861954);let aZ="https://github.com/xiaoyang111222/cn-math-taxonomy",a$="https://raw.githubusercontent.com/xiaoyang111222/cn-math-taxonomy/HEAD/data/topics.json",a_=aV.z.object({id:aW.z.string().optional(),name:aW.z.string().trim().min(1),subject:aW.z.string().nullish(),grade:aX.z.number().int(),semester:aW.z.string().nullish(),chapter:aW.z.string().nullish()}).passthrough();aY.z.array(a_).min(1);let a0="/api/admin/cnm-tags";function a1(){let{t:a}=(0,d.b)(),e=a.admin.cnmTags,[g,i]=(0,c.useState)(null),[j,k]=(0,c.useState)(!1),l=(0,c.useRef)(null),m=(0,c.useCallback)(async()=>{try{i(await f.k.get(a0))}catch(a){h.V.warn("[CnmTagImportSettings]","Failed to load status",{error:a})}},[]);(0,c.useEffect)(()=>{m()},[m]);let n=async a=>{if(a){k(!0);try{let b;try{b=JSON.parse(await a.text())}catch{L.c.error(e.invalidFile);return}let c=await f.k.post(a0,{topics:b},{timeout:3e5});i(c.status),L.c.success(e.imported.replace("{created}",String(c.result.created)).replace("{skipped}",String(c.result.skipped)))}catch(b){h.V.error("[CnmTagImportSettings]","Import failed",{error:b});let a=b instanceof f.a&&400===b.status;L.c.error(a?e.invalidFile:e.failed)}finally{k(!1),l.current&&(l.current.value="")}}},o=g?.knowledgePoints??0;return(0,b.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("p",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,b.jsx)(C.f,{className:"h-4 w-4"}),e.title]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:e.desc})]}),(0,b.jsxs)("div",{className:"space-y-1 rounded-md bg-muted/50 p-3 text-xs text-muted-foreground",children:[(0,b.jsx)("p",{children:e.downloadHint}),(0,b.jsx)("a",{href:a$,target:"_blank",rel:"noopener noreferrer",className:"block break-all text-primary underline",children:a$}),(0,b.jsxs)("p",{children:[e.sourceLabel," ",(0,b.jsx)("a",{href:aZ,target:"_blank",rel:"noopener noreferrer",className:"break-all text-primary underline",children:aZ})]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g?o>0?e.status.replace("{count}",String(o)):e.notImported:""}),(0,b.jsx)("input",{ref:l,type:"file",accept:".json,application/json",className:"hidden",onChange:a=>n(a.target.files?.[0]),disabled:j}),(0,b.jsxs)(y.f,{variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:()=>l.current?.click(),disabled:j,children:[j?(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,b.jsx)(aU.f,{className:"mr-2 h-4 w-4"}),j?e.importing:e.select]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:e.note})]})}var a2=a.i(519783);let a3={info:{card:"border-blue-200 dark:border-blue-900 bg-blue-50 dark:bg-blue-950/40",title:"text-blue-900 dark:text-blue-200 font-bold",desc:"text-blue-800 dark:text-blue-200 font-medium",button:"bg-blue-100 dark:bg-blue-900/40 hover:bg-blue-200 dark:hover:bg-blue-900/60 text-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-800"},danger:{card:"border-red-200 dark:border-red-900 bg-red-50 dark:bg-red-950/40",title:"text-red-700 dark:text-red-300 font-medium",desc:"text-red-600 dark:text-red-400",button:""},critical:{card:"border-red-600/50 bg-red-100/50 dark:bg-red-900/40",title:"text-red-900 dark:text-red-200 font-bold",desc:"text-red-800 dark:text-red-200 font-medium",button:"bg-red-700 hover:bg-red-800"}};function a4({title:a,description:c,tone:d,busy:e,icon:f,onClick:g}){let h=a3[d];return(0,b.jsxs)("div",{className:`p-4 border rounded-lg ${h.card}`,children:[(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsx)("span",{className:`text-sm flex items-center gap-2 ${h.title}`,children:a}),(0,b.jsx)(y.f,{variant:"info"===d?"outline":"destructive",size:"sm",onClick:g,disabled:e,className:h.button,children:e?(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}):f})]}),(0,b.jsx)("p",{className:`text-xs mt-2 ${h.desc}`,children:c})]})}function a5({isAdmin:a}){let{t:e}=(0,d.b)(),[g,i]=(0,c.useState)(null),j=async(a,b,c,d)=>{i(a);try{L.c.success(await b()),d&&window.location.reload()}catch(b){h.V.error("[DangerZoneSettings]",`${a} failed`,{error:b}),L.c.error(c)}finally{i(null)}},k=e.settings?.clearSuccess||"Success",l=e.settings?.clearError||"Failed",m=async()=>{await (0,L.u)(e.settings?.migrateTagsConfirm||"This will reset system tags. Confirm?",{destructive:!0})&&await j("migrateTags",async()=>{let a=await f.k.post("/api/admin/migrate-tags",{});return`${k}: ${a.count||0} tags migrated.`},e.settings?.clearError||"Failed to migrate tags",!1)},n=async()=>{await (0,L.u)(e.settings?.clearDataConfirm||"Are you sure?",{destructive:!0})&&await j("clearPractice",async()=>(await f.k.delete("/api/stats/practice/clear"),k),l,!0)},o=async()=>{await (0,L.u)(e.settings?.clearErrorDataConfirm||"Are you sure?",{destructive:!0})&&await j("clearErrors",async()=>(await f.k.delete("/api/error-items/clear"),k),l,!0)},p=async()=>{if(!await (0,L.u)(e.settings?.systemResetConfirm||"WARNING: Deleting ALL data. Undoing is impossible. Are you sure?",{destructive:!0}))return;let a=prompt(e.settings?.systemResetPrompt||"Type 'RESET' to confirm system initialization:","");if("RESET"!==a){null!==a&&L.c.error(e.common?.error||"Confirmation failed");return}await j("systemReset",async()=>(await f.k.post("/api/admin/system-reset",{}),e.settings?.clearSuccess||"Success - System Reset Complete"),e.settings?.clearError||"Failed to reset system",!0)};return(0,b.jsxs)(b.Fragment,{children:[a&&(0,b.jsx)(a4,{tone:"info",title:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a2.f,{className:"h-4 w-4"}),e.settings?.migrateTags||"Migrate Tags"]}),description:e.settings?.migrateTagsDesc||"Re-populates standard tags from file",busy:"migrateTags"===g,icon:(0,b.jsx)(a2.f,{className:"h-4 w-4"}),onClick:m}),(0,b.jsx)(a4,{tone:"danger",title:e.settings?.clearData||"Clear Practice Data",description:e.settings?.clearDataDesc||"This will permanently delete all practice history. Irreversible.",busy:"clearPractice"===g,icon:(0,b.jsx)(av.f,{className:"h-4 w-4"}),onClick:n}),(0,b.jsx)(a4,{tone:"danger",title:e.settings?.clearErrorData||"Clear Error Data",description:e.settings?.clearErrorDataDesc||"This will permanently delete all error items. Irreversible.",busy:"clearErrors"===g,icon:(0,b.jsx)(av.f,{className:"h-4 w-4"}),onClick:o}),a&&(0,b.jsx)(a4,{tone:"critical",title:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Z.f,{className:"h-4 w-4"}),e.settings?.systemReset||"System Initialization"]}),description:e.settings?.systemResetDesc||"Resets the system to factory state. Deletes ALL data.",busy:"systemReset"===g,icon:(0,b.jsx)(av.f,{className:"h-4 w-4"}),onClick:p})]})}let a6={name:"user-x",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]};a6.node;let a7=(0,F.f)(a6);function a8({isAdmin:a}){let{t:g}=(0,d.b)(),i=g.settings.deleteAccount,[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(""),[n,o]=(0,c.useState)(!1),p=a=>{!n&&(k(a),a||m(""))},q=async a=>{if(a.preventDefault(),l){o(!0);try{await f.k.delete("/api/user",{body:JSON.stringify({password:l})}),L.c.success(i.success),await (0,e.signOut)({callbackUrl:"/login"})}catch(b){let a=b instanceof f.a&&400===b.status;a||h.V.error("[DeleteAccountSettings]","delete account failed",{error:b}),L.c.error(a?i.wrongPassword:i.failed),o(!1)}}};return(0,b.jsxs)("div",{className:"p-4 border rounded-lg border-red-600/50 bg-red-100/50 dark:bg-red-900/40",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsxs)("span",{className:"text-sm flex items-center gap-2 text-red-900 dark:text-red-200 font-bold",children:[(0,b.jsx)(a7,{className:"h-4 w-4"}),i.title]}),(0,b.jsx)(y.f,{variant:"destructive",size:"sm",className:"bg-red-700 hover:bg-red-800",disabled:a,onClick:()=>k(!0),"aria-label":i.title,children:(0,b.jsx)(a7,{className:"h-4 w-4"})})]}),(0,b.jsx)("p",{className:"text-xs mt-2 text-red-800 dark:text-red-200 font-medium",children:a?i.adminDisabled:i.desc}),(0,b.jsx)(z.N,{open:j,onOpenChange:p,children:(0,b.jsx)(z.d,{className:"sm:max-w-md",children:(0,b.jsxs)("form",{onSubmit:q,className:"space-y-4",children:[(0,b.jsxs)(z.s,{children:[(0,b.jsx)(z.F,{children:i.confirmTitle}),(0,b.jsx)(z.C,{children:i.confirmDesc})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{htmlFor:"delete-account-password",children:i.passwordLabel}),(0,b.jsx)(aO.f,{id:"delete-account-password",autoComplete:"current-password",value:l,onChange:a=>m(a.target.value),disabled:n})]}),(0,b.jsxs)(z.c,{className:"gap-2",children:[(0,b.jsx)(y.f,{type:"button",variant:"outline",onClick:()=>p(!1),disabled:n,children:i.cancel}),(0,b.jsxs)(y.f,{type:"submit",variant:"destructive",disabled:!l||n,children:[n&&(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}),i.confirm]})]})]})})})]})}let a9={name:"shield-check",size:24,node:[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]};a9.node;let ba=(0,F.f)(a9);function bb(){let{t:a,language:e}=(0,d.b)(),g=a.aiConsent,[i,j]=(0,c.useState)(void 0),[k,l]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let a=!1;return f.k.get("/api/user").then(b=>{a||j(b?.aiDataConsentAt??null)}).catch(a=>h.V.error("[AiConsentSetting]","load consent failed",{error:a})),()=>{a=!0}},[]);let m=async a=>{if(a||await (0,L.u)(g.revokeConfirm,{destructive:!0})){l(!0);try{let b=a?await f.k.post("/api/user/ai-consent",{}):await f.k.delete("/api/user/ai-consent");j(b.aiDataConsentAt),L.c.success(a?g.agreed:g.revoked)}catch(a){h.V.error("[AiConsentSetting]","update consent failed",{error:a}),L.c.error(g.failed)}finally{l(!1)}}};if(void 0===i)return null;let n=null!==i,o=n?new Date(i).toLocaleDateString("en"===e?"en-US":"zh-CN"):"";return(0,b.jsxs)("div",{className:"space-y-2 rounded-lg border p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,b.jsx)(ba,{className:"h-4 w-4"}),g.settingTitle]}),(0,b.jsxs)(y.f,{type:"button",size:"sm",variant:n?"outline":"default",onClick:()=>m(!n),disabled:k,children:[k&&(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}),n?g.revoke:g.grant]})]}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:[n?g.settingGranted.replace("{date}",o):g.settingNotGranted," ",(0,b.jsx)("a",{className:"underline underline-offset-2",href:(0,A.L)(e),target:"_blank",rel:"noopener noreferrer",children:g.policyLink})]})]})}var bc=a.i(613412),bd=a.i(536670),be=a.i(64332);async function bf(a,b){let c=await fetch(a);if(!c.ok)throw Error((await c.json().catch(()=>({}))).message||"Download failed");let d=await c.blob(),e=window.URL.createObjectURL(d),f=document.createElement("a");f.href=e;let g=c.headers.get("Content-Disposition")?.match(/filename="(.+)"/);f.download=g?g[1]:b,document.body.appendChild(f),f.click(),document.body.removeChild(f),window.URL.revokeObjectURL(e)}function bg({isAdmin:a,userId:e}){let{t:g}=(0,d.b)(),[i,j]=(0,c.useState)(!1),[k,l]=(0,c.useState)(!1),[m,n]=(0,c.useState)(null),o=`user:${e}:data-import`,{running:p,refresh:q}=(0,be.f)(o),r=(0,c.useRef)(!1);(0,c.useEffect)(()=>{if(p){r.current=!0;return}r.current&&(r.current=!1,window.location.reload())},[p]);let s=async a=>{if(!a||await (0,L.u)(g.settings?.exportAllConfirm||"Export all users' data? This may take a while.")){j(!0);try{await bf(a?"/api/export?all=true":"/api/export",a?"wrong-notebook-export-all.json":"wrong-notebook-export.json"),L.c.success(g.settings?.exportSuccess||"Export successful")}catch(b){h.V.error("[DataBackupSettings]",a?"Export all failed":"Export failed",{error:b}),L.c.error(g.settings?.exportFailed||"Export failed")}finally{j(!1)}}},t=async a=>{if(!m)return;let b=a?g.settings?.importAllConfirm||"Import all users' data? This will restore data for all users from the export file.":g.settings?.importConfirm||"Are you sure you want to import?";if(await (0,L.u)(b)){l(!0);try{let b=JSON.parse(await m.text()),{stats:c}=await f.k.post(a?"/api/import?all=true":"/api/import",b);L.c.success((g.settings?.importResultDesc||"Imported {subjects} notebooks, {tags} tags, {items} error items, {schedules} review schedules, {records} practice records, {papers} exam papers and {voices} cloud voice clips.").replace("{subjects}",String(c.subjectsCreated)).replace("{tags}",String(c.tagsCreated)).replace("{items}",String(c.errorItemsCreated)).replace("{schedules}",String(c.reviewSchedulesCreated)).replace("{records}",String(c.practiceRecordsCreated)).replace("{papers}",String(c.examPapersCreated??0)).replace("{voices}",String(c.ttsSpeechesImported??0)).replace("{duplicates}",String(c.duplicateErrorItems??0))),n(null),window.location.reload()}catch(b){b instanceof f.a&&409===b.status&&b.data?.code==="TASK_ALREADY_RUNNING"?(L.c.info(g.errors.TASK_ALREADY_RUNNING),await q()):(h.V.error("[DataBackupSettings]",a?"Import all failed":"Import failed",{error:b}),L.c.error(g.settings?.importFailed||"Import failed"))}finally{l(!1)}}},u=(a,c)=>a?(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}):c,v=k||!!p;return(0,b.jsxs)("div",{className:"p-4 border border-blue-200 dark:border-blue-900 rounded-lg bg-blue-50 dark:bg-blue-950/40",children:[(0,b.jsx)("h4",{className:"text-sm font-bold text-blue-900 dark:text-blue-200 mb-3",children:g.settings?.dataManagement||"Data Management"}),(0,b.jsxs)("div",{className:"mb-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,b.jsx)("span",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium",children:g.settings?.exportData||"Export Data"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>s(!1),disabled:i,className:"bg-blue-100 dark:bg-blue-900/40 hover:bg-blue-200 dark:hover:bg-blue-900/60 text-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-800",children:[u(i,(0,b.jsx)(bd.f,{className:"mr-2 h-4 w-4"})),g.settings?.exportData||"Export"]}),a&&(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>s(!0),disabled:i,className:"bg-orange-100 dark:bg-orange-900/40 hover:bg-orange-200 dark:hover:bg-orange-900/60 text-orange-900 dark:text-orange-200 border-orange-300 dark:border-orange-800",children:[u(i,(0,b.jsx)(bd.f,{className:"mr-2 h-4 w-4"})),g.settings?.exportAllData||"Export All"]})]})]}),(0,b.jsx)("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:g.settings?.exportDataDesc||"Export all data as JSON file."})]}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,b.jsx)("span",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium",children:g.settings?.importData||"Import Data"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("input",{type:"file",accept:".json",onChange:a=>n(a.target.files?.[0]??m),className:"hidden",id:"import-file-input",disabled:v}),(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>document.getElementById("import-file-input")?.click(),disabled:v,className:"bg-blue-100 dark:bg-blue-900/40 hover:bg-blue-200 dark:hover:bg-blue-900/60 text-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-800",children:[u(v,(0,b.jsx)(aU.f,{className:"mr-2 h-4 w-4"})),m?.name||g.settings?.selectFile||"Select File"]}),m&&(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>t(!1),disabled:v,className:"bg-green-100 dark:bg-green-900/40 hover:bg-green-200 dark:hover:bg-green-900/60 text-green-900 dark:text-green-200 border-green-300 dark:border-green-800",children:[u(v,(0,b.jsx)(bc.f,{className:"mr-2 h-4 w-4"})),g.settings?.importData||"Import"]}),m&&a&&(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>t(!0),disabled:v,className:"bg-orange-100 dark:bg-orange-900/40 hover:bg-orange-200 dark:hover:bg-orange-900/60 text-orange-900 dark:text-orange-200 border-orange-300 dark:border-orange-800",children:[u(v,(0,b.jsx)(bc.f,{className:"mr-2 h-4 w-4"})),g.settings?.importAllData||"Import All"]})]})]}),(0,b.jsx)("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:g.settings?.importDataDesc||"Import data from JSON file. Existing data will be skipped."})]})]})}let bh={name:"bug",size:24,node:[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]]};bh.node;let bi=(0,F.f)(bh),bj="/api/admin/debug-logs";function bk(){let{t:a}=(0,d.b)(),{timeZone:e}=(0,v.M)(),g=a.admin.debugLog,[i,j]=(0,c.useState)(null),[k,l]=(0,c.useState)(!1),m=(0,c.useCallback)(async()=>{try{j(await f.k.get(bj))}catch(a){h.V.warn("[DebugLogSettings]","Failed to load debug status",{error:a})}},[]);(0,c.useEffect)(()=>{m()},[m]),(0,c.useEffect)(()=>{if(!i?.enabled)return;let a=setInterval(m,5e3);return()=>clearInterval(a)},[i?.enabled,m]);let n=async(a,b)=>{l(!0);try{await a(),L.c.success(b)}catch(a){h.V.error("[DebugLogSettings]","Debug log action failed",{error:a}),L.c.error(g.failed)}finally{l(!1)}},o=a=>a?(0,ak.r)(a,"yyyy-MM-dd HH:mm",e):"",p=i?.enabled?g.enabledHint.replace("{since}",o(i.enabledAt)).replace("{until}",o(i.expiresAt)):g.disabledHint,q=(i?.entryCount??0)>0;return(0,b.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)(ao.f,{htmlFor:"debug-mode-switch",className:"flex items-center gap-2 font-medium",children:[(0,b.jsx)(bi,{className:"h-4 w-4"}),g.title]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g.desc})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)("span",{className:"text-sm text-muted-foreground",children:g.enable}),(0,b.jsx)(am.f,{id:"debug-mode-switch",checked:!!i?.enabled,onCheckedChange:a=>n(async()=>{j(await f.k.post(bj,{enabled:a}))},a?g.enabled:g.disabled),disabled:k||!i})]})]}),(0,b.jsxs)("p",{className:`text-xs ${i?.enabled?"text-orange-600":"text-muted-foreground"}`,children:[p,i&&(0,b.jsxs)(b.Fragment,{children:[" ",g.entries.replace("{count}",String(i.entryCount)),i.droppedCount>0&&g.dropped.replace("{count}",String(i.droppedCount))]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>n(async()=>{await bf(`${bj}/export`,"wrong-notebook-debug.json"),await m()},g.exported),disabled:k||!q,className:"sm:flex-1",children:[k?(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,b.jsx)(bd.f,{className:"mr-2 h-4 w-4"}),g.export]}),(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>n(async()=>{j(await f.k.delete(bj))},g.cleared),disabled:k||!q,children:[(0,b.jsx)(av.f,{className:"mr-2 h-4 w-4"}),g.clear]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g.privacyNote})]})}var bl=a.i(225949);function bm({field:a,label:e,description:g}){let{t:i}=(0,d.b)(),[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(!1),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(null),r=`preference-${a}`;(0,c.useEffect)(()=>{f.k.get("/api/user").then(b=>k(!!b[a])).catch(()=>void 0).finally(()=>m(!0))},[a]);let s=async b=>{k(b),o(!0);try{await f.k.patch("/api/user",{[a]:b}),q(i.importFlow.preferenceSaved)}catch(c){k(!b),q(i.importFlow.preferenceSaveFailed),h.V.error("[Settings]","Failed to save user preference",{field:a,error:c instanceof Error?c.message:String(c)})}finally{o(!1)}};return(0,b.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,b.jsx)(ao.f,{htmlFor:r,children:e}),(0,b.jsx)(am.f,{id:r,checked:j,onCheckedChange:s,disabled:!l||n})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g}),p&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:p})]})}function bn(){let{t:a}=(0,d.b)();return(0,b.jsx)(bm,{field:"enableGeogebra",label:a.importFlow.enableGeogebra,description:a.importFlow.enableGeogebraDesc})}function bo(){let{t:a}=(0,d.b)();return(0,b.jsx)(bm,{field:"confirmBeforeImport",label:a.importFlow.confirmBeforeImport,description:a.importFlow.confirmBeforeImportDesc})}var bp=a.i(249479);function bq(){let{t:a}=(0,d.b)(),[e,g]=(0,c.useState)(String(bp.z)),[i,j]=(0,c.useState)(null),[k,l]=(0,c.useState)(!0),[m,n]=(0,c.useState)(!1),[o,p]=(0,c.useState)(null),q=Number(e),r=""!==e.trim()&&Number.isInteger(q)&&q>=bp.P&&q<=bp.o,s=(0,c.useCallback)(async()=>{l(!0),p(null);try{let a=(await f.k.get("/api/user")).masteryThreshold??bp.z;g(String(a)),j(a)}catch(b){p(a.mastery.thresholdLoadFailed),h.V.error("[Settings]","加载已掌握阈值失败",{error:b instanceof Error?b.message:String(b)})}finally{l(!1)}},[a.mastery.thresholdLoadFailed]);(0,c.useEffect)(()=>{s()},[s]);let t=async()=>{if(r&&null!==i){n(!0),p(null);try{let b=(await f.k.patch("/api/user",{masteryThreshold:q})).masteryThreshold??q;j(b),g(String(b)),p(a.importFlow.preferenceSaved)}catch(b){p(a.importFlow.preferenceSaveFailed),h.V.error("[Settings]","保存已掌握阈值失败",{error:b instanceof Error?b.message:String(b)})}finally{n(!1)}}};return(0,b.jsxs)("div",{className:"space-y-2 border-t pt-4",children:[(0,b.jsx)(ao.f,{htmlFor:"mastery-threshold",children:a.mastery.thresholdLabel}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)(an.f,{id:"mastery-threshold",type:"number",min:bp.P,max:bp.o,step:1,value:e,onChange:a=>{g(a.target.value),p(null)},disabled:k||m||null===i,className:"w-28","aria-describedby":"mastery-threshold-hint"}),(0,b.jsx)("span",{"aria-hidden":"true",children:"%"}),(0,b.jsxs)(y.f,{type:"button",size:"sm",variant:"outline",onClick:t,disabled:k||m||null===i||!r||q===i,children:[(k||m)&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.importFlow.saveThreshold]}),!k&&null===i&&(0,b.jsx)(y.f,{type:"button",size:"sm",variant:"outline",onClick:s,children:a.importFlow.retryLoad})]}),(0,b.jsx)("p",{id:"mastery-threshold-hint",className:"text-xs text-muted-foreground",children:a.mastery.thresholdDescription}),null!==i&&!r&&(0,b.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:a.mastery.thresholdInvalid}),o&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:o})]})}var br=a.i(393045);function bs(){let{t:a}=(0,d.b)(),[e,i]=(0,c.useState)({gradeRecognitionMode:"fixed",fixedGradeSemester:null}),[j,k]=(0,c.useState)(null),[l,m]=(0,c.useState)(!0),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(null),r=(0,c.useRef)(0),s=(0,c.useCallback)(async()=>{let b=++r.current;m(!0),q(null);try{let a=await f.k.get("/api/user");if(b!==r.current)return;let c={gradeRecognitionMode:a.gradeRecognitionMode??"fixed",fixedGradeSemester:a.fixedGradeSemester??null};i(c),k(c)}catch(c){if(b!==r.current)return;q(a.questionGrade.loadFailed),h.V.error("[QuestionGradeSetting]","加载录入年级规则失败",{error:(0,g.Z)(c)})}finally{b===r.current&&m(!1)}},[a.questionGrade.loadFailed]);(0,c.useEffect)(()=>{s()},[s]);let t=async()=>{o(!0),q(null);try{let b=await f.k.patch("/api/user",e),c={gradeRecognitionMode:b.gradeRecognitionMode??e.gradeRecognitionMode,fixedGradeSemester:b.fixedGradeSemester??null};i(c),k(c),q(a.importFlow.preferenceSaved)}catch(b){q(a.importFlow.preferenceSaveFailed),h.V.error("[QuestionGradeSetting]","保存录入年级规则失败",{error:(0,g.Z)(b)})}finally{o(!1)}},u=l||n||null===j,v=j?.gradeRecognitionMode===e.gradeRecognitionMode&&j?.fixedGradeSemester===e.fixedGradeSemester;return(0,b.jsxs)("div",{className:"space-y-3 border-t pt-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{htmlFor:"question-grade-mode",children:a.questionGrade.label}),(0,b.jsxs)("select",{id:"question-grade-mode",value:e.gradeRecognitionMode,disabled:u,onChange:a=>{i({...e,gradeRecognitionMode:a.target.value}),q(null)},className:"h-10 w-full rounded-md border border-input bg-background px-3 text-sm disabled:opacity-50",children:[(0,b.jsx)("option",{value:"fixed",children:a.questionGrade.fixed}),(0,b.jsx)("option",{value:"ai",children:a.questionGrade.ai})]})]}),"fixed"===e.gradeRecognitionMode&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{htmlFor:"question-fixed-grade",children:a.editor.gradeSemester}),(0,b.jsx)(br.f,{id:"question-fixed-grade",value:e.fixedGradeSemester??"",disabled:u,onChange:a=>{i({...e,fixedGradeSemester:a||null}),q(null)}})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"fixed"===e.gradeRecognitionMode?a.questionGrade.fixedDescription:a.questionGrade.aiDescription}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:a.questionGrade.description}),(0,b.jsxs)(y.f,{type:"button",variant:"outline",size:"sm",disabled:u||v,onClick:t,children:[(l||n)&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.questionGrade.save]}),!l&&null===j&&(0,b.jsx)(y.f,{type:"button",variant:"outline",size:"sm",onClick:s,children:a.importFlow.retryLoad}),p&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:p})]})}function bt(){let{t:a}=(0,d.b)();return(0,b.jsx)(bm,{field:"enableSvgAnimation",label:a.importFlow.enableSvgAnimation,description:a.importFlow.enableSvgAnimationDesc})}function bu({value:a,onChange:c,disabled:e}){let{t:f}=(0,d.b)();return(0,b.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,b.jsx)(ao.f,{htmlFor:"app-time-zone",children:f.settings.general.timeZoneLabel}),(0,b.jsx)(an.f,{id:"app-time-zone",value:a,onChange:a=>c(a.target.value),disabled:e,list:"app-time-zones",placeholder:"Asia/Shanghai"}),(0,b.jsx)("datalist",{id:"app-time-zones",children:["Asia/Shanghai","Asia/Hong_Kong","Asia/Tokyo","Asia/Singapore","Europe/London","America/New_York","America/Los_Angeles","UTC"].map(a=>(0,b.jsx)("option",{value:a},a))}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:f.settings.general.timeZoneDesc})]})}function bv({config:a,setConfig:c,isAdmin:e,disabled:f}){let{t:g,language:h,setLanguage:i}=(0,d.b)(),{timeZone:j}=(0,v.M)(),k=a=>c(b=>({...b,timeouts:{...b.timeouts,analyze:1e3*a}}));return(0,b.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:g.settings?.language||"Language"}),(0,b.jsxs)(aP.d,{value:h,onValueChange:a=>i(a),children:[(0,b.jsx)(aP.P,{children:(0,b.jsx)(aP.U,{})}),(0,b.jsxs)(aP.r,{children:[(0,b.jsx)(aP.T,{value:"zh",children:"中文 (Chinese)"}),(0,b.jsx)(aP.T,{value:"en",children:"English"})]})]})]}),(0,b.jsx)(bu,{value:a.timeZone??j,onChange:a=>c(b=>({...b,timeZone:a})),disabled:!e||f}),e&&(0,b.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,b.jsx)(ao.f,{children:g.settings?.general?.timeoutLabel||"AI Analysis Timeout (Seconds)"}),(0,b.jsx)(an.f,{type:"number",value:a.timeouts?.analyze?a.timeouts.analyze/1e3:"",onChange:a=>{let b=""===a.target.value?0:parseInt(a.target.value);k(isNaN(b)?0:b)},onBlur:()=>{let b=(a.timeouts?.analyze||0)/1e3,c=Math.min(600,Math.max(120,b));c!==b&&k(c)},min:120,max:600}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g.settings?.general?.timeoutDesc||"Increase this value if you experience frequent timeouts during AI analysis."})]}),(0,b.jsx)(bo,{}),(0,b.jsx)(bs,{}),(0,b.jsx)(bt,{}),(0,b.jsx)(bn,{}),(0,b.jsx)(bl.f,{}),(0,b.jsx)(bq,{})]})}var bw=a.i(403512),bx=a.i(591119),by=a.i(481132);function bz(){let{t:a}=(0,d.b)(),{groups:e,loading:g,refetch:i}=(0,by.f)(),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(!1),n=async()=>{let b=j.trim();if(b){m(!0);try{await f.k.post("/api/paper-groups",{name:b}),k(""),L.c.success(a.common?.messages?.saveSuccess||"Saved"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to add group",{error:b}),L.c.error(a.common?.messages?.saveFailed||"Failed to save")}finally{m(!1)}}},o=async(b,c)=>{let d=window.prompt(a.settings?.paperGroups?.renamePrompt||"Rename group",c);if(d&&d.trim()!==c)try{await f.k.patch(`/api/paper-groups/${b}`,{name:d.trim()}),L.c.success(a.common?.messages?.saveSuccess||"Saved"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to rename group",{error:b}),L.c.error(a.common?.messages?.saveFailed||"Failed to save")}},p=async(b,c)=>{try{await f.k.patch(`/api/paper-groups/${b}`,{isActive:!c}),L.c.success(a.common?.messages?.saveSuccess||"Saved"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to toggle group",{error:b}),L.c.error(a.common?.messages?.saveFailed||"Failed to save")}},q=async(b,c,d)=>{if(d>0){let e=(a.settings?.paperGroups?.deleteConfirmWithItems||'Group "{name}" has {count} questions. Deleting will clear their group assignment. Continue?').replace("{name}",c).replace("{count}",String(d));if(!await (0,L.u)(e,{destructive:!0}))return;try{await f.k.delete(`/api/paper-groups/${b}?clear=true`),L.c.success(a.common?.messages?.deleteSuccess||"Deleted"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to delete group",{error:b}),L.c.error(a.common?.messages?.deleteFailed||"Delete failed")}return}let e=(a.settings?.paperGroups?.deleteConfirm||'Delete group "{name}"?').replace("{name}",c);if(await (0,L.u)(e,{destructive:!0}))try{await f.k.delete(`/api/paper-groups/${b}`),L.c.success(a.common?.messages?.deleteSuccess||"Deleted"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to delete group",{error:b}),L.c.error(a.common?.messages?.deleteFailed||"Delete failed")}};return g?(0,b.jsx)(bx.N,{children:(0,b.jsx)(bx.O,{className:"py-12 flex items-center justify-center",children:(0,b.jsx)(x.f,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):(0,b.jsxs)(bx.N,{children:[(0,b.jsxs)(bx.Y,{children:[(0,b.jsxs)(bx.v,{className:"flex items-center gap-2 text-lg",children:[(0,b.jsx)(E.f,{className:"h-5 w-5"}),a.settings?.paperGroups?.title||"Paper Groups"]}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:a.settings?.paperGroups?.desc||"Customize paper groups like Unit Test, Midterm, Final. Default groups A/B/Other can be renamed but not deleted."})]}),(0,b.jsxs)(bx.O,{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)(an.f,{value:j,onChange:a=>k(a.target.value),placeholder:a.settings?.paperGroups?.addPlaceholder||"e.g. Unit Test",onKeyDown:a=>{"Enter"===a.key&&n()}}),(0,b.jsxs)(y.f,{onClick:n,disabled:l||!j.trim(),children:[l?(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}):(0,b.jsx)(bw.f,{className:"h-4 w-4 mr-1"}),a.common?.add||"Add"]})]}),(0,b.jsx)("div",{className:"space-y-2",children:e.map(c=>(0,b.jsxs)("div",{className:`flex items-center justify-between rounded-lg border p-3 ${!c.isActive?"opacity-50":""}`,children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("span",{className:"font-medium",children:c.name}),c.key&&(0,b.jsx)(al.f,{variant:"secondary",className:"text-xs",children:a.settings?.paperGroups?.systemBadge||"Default"}),!c.isActive&&(0,b.jsx)(al.f,{variant:"outline",className:"text-xs",children:a.common?.inactive||"Inactive"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:()=>o(c.id,c.name),children:a.common?.rename||"Rename"}),(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:()=>p(c.id,c.isActive),children:c.isActive?a.common?.deactivate||"Deactivate":a.common?.activate||"Activate"}),!c.key&&(0,b.jsx)(y.f,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>q(c.id,c.name,c._count?.errorItems||0),children:(0,b.jsx)(av.f,{className:"h-4 w-4"})})]})]},c.id))})]})]})}var bA=a.i(489970),bB=a.i(585650),bC=a.i(533838),bD=a.i(986708),bE=a.i(429246);async function bF(a,b){try{return await navigator.clipboard.writeText(a),!0}catch{return b(a),!1}}async function bG(){try{return await navigator.clipboard.readText()}catch{return null}}function bH({value:a,defaultValue:e,onChange:f,onReset:g,title:h,variables:i}){let{t:j}=(0,d.b)(),[k,l]=(0,c.useState)(!1),m=(0,c.useMemo)(()=>{let b=new Set(Array.from(new Set(Array.from(a.matchAll(/\{\{(\w+)\}\}/g),a=>a[1]))));return i.filter(a=>!b.has(a.name))},[a,i]),n=async()=>{await bF(a,a=>window.prompt(j.settings?.prompts?.copyManual||"Copy the template manually:",a))&&(l(!0),setTimeout(()=>l(!1),1500),L.c.success(j.settings?.prompts?.copied||"Template copied"))},o=async()=>{let b=await bG();null===b?L.c.error(j.settings?.prompts?.pasteFailed||"Cannot read the clipboard. Paste into the box manually."):b.trim()?(!a.trim()||await (0,L.u)(j.settings?.prompts?.pasteConfirm||"Replace the current template with the clipboard content?",{destructive:!0}))&&(f(b),L.c.success(j.settings?.prompts?.pasted||"Template replaced from the clipboard")):L.c.error(j.settings?.prompts?.pasteEmpty||"The clipboard is empty")},p=async()=>{await (0,L.u)(j.settings?.prompts?.resetConfirm||"Are you sure you want to reset to default?",{destructive:!0})&&g()};return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,b.jsx)(ao.f,{className:"text-base font-semibold",children:h}),(0,b.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:n,children:[(0,b.jsx)(bB.f,{className:"w-4 h-4 mr-2"}),k?j.settings?.prompts?.copied||"Copied":j.settings?.prompts?.copy||"Copy"]}),(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:o,children:[(0,b.jsx)(bA.f,{className:"w-4 h-4 mr-2"}),j.settings?.prompts?.pasteReplace||"Replace with clipboard"]}),(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:p,children:[(0,b.jsx)(bC.f,{className:"w-4 h-4 mr-2"}),j.settings?.prompts?.reset||"Reset Default"]})]})]}),(0,b.jsxs)("div",{className:"bg-amber-50 dark:bg-amber-950/40 border border-amber-200 dark:border-amber-900 rounded-md p-3 flex items-start gap-3 text-amber-900 dark:text-amber-200 text-sm",children:[(0,b.jsx)(bD.f,{className:"w-4 h-4 mt-0.5 shrink-0"}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"font-medium",children:j.settings?.prompts?.customizeTitle||"Tailor the prompt to your child"}),(0,b.jsx)("p",{children:j.settings?.prompts?.customizeBody||"Copy the default template, rewrite the role, tone and analysis steps to fit your child's grade, weak points and learning habits, then paste it back. Keep the {{variables}}: they are filled with each question's data."})]})]}),(0,b.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,b.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,b.jsx)(ab,{className:"h-3.5 w-3.5"}),j.settings?.prompts?.variables||"Available Variables"]}),(0,b.jsx)("div",{className:"space-y-1.5",children:i.map(a=>(0,b.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-2 text-xs py-1",children:[(0,b.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] shrink-0",children:`{{${a.name}}}`}),(0,b.jsx)("span",{className:"text-muted-foreground",children:a.description})]},a.name))}),m.length>0&&(0,b.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300 pt-1",children:(j.settings?.prompts?.missingVariables||"Not referenced in this template: {names}. The app still adds the matching rules, but the data will not reach the model.").replace("{names}",m.map(a=>`{{${a.name}}}`).join("、"))})]}),(0,b.jsx)(bE.f,{value:a,onChange:a=>f(a.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:e,"aria-label":h})]})}let bI="[REDACTED]",bJ=/api[-_]?key|password|passwd|secret|authorization|cookie|credential|private[-_]?key|^(access|refresh|id|auth|api|bearer|session|csrf|setup)?[-_]?token$/i,bK=Symbol.for("wrong-notebook.debug-log");function bL(){let a=globalThis,b=a[bK];return b||(b={enabledAt:null,entries:[],totalSize:0,dropped:0},a[bK]=b),b}function bM(a){let b=a.replace(/data:([\w.+-]+\/[\w.+-]+);base64,[A-Za-z0-9+/=]+/g,(a,b)=>`[data:${b}, ${a.length} chars]`).replace(/(Bearer\s+)[\w\-.~+/]+=*/gi,`$1${bI}`).replace(/\bsk-[A-Za-z0-9_-]{8,}/g,bI).replace(/([?&](?:key|api_key|apikey|token|access_token)=)[^&\s"']+/gi,`$1${bI}`);return b.length>1e4&&(b=`${b.slice(0,1e4)}…[truncated ${b.length-1e4} chars]`),b}function bN(a,b,c,d=new Date){if(function(a=Date.now()){let b=bL();return null!==b.enabledAt&&(!(a-b.enabledAt>=864e5)||(b.enabledAt=null,!1))}(d.getTime()))try{let e={...function a(b,c=0,d=new WeakSet){if(null==b)return b;if("string"==typeof b)return bM(b);if("number"==typeof b||"boolean"==typeof b)return b;if("bigint"==typeof b)return b.toString();if("function"==typeof b||"symbol"==typeof b)return String(b);if(b instanceof Date)return b.toISOString();if(b instanceof Error){let e={name:b.name,message:bM(b.message)};return b.stack&&(e.stack=bM(b.stack)),void 0!==b.code&&(e.code=a(b.code,c+1,d)),void 0!==b.status&&(e.status=a(b.status,c+1,d)),void 0!==b.cause&&c<8&&(e.cause=a(b.cause,c+1,d)),e}if("object"!=typeof b)return String(b);if(d.has(b))return"[Circular]";if(c>=8)return"[Object]";if(d.add(b),Array.isArray(b)){let e=b.slice(0,100).map(b=>a(b,c+1,d));return b.length>100&&e.push(`…[${b.length-100} more items]`),e}return ArrayBuffer.isView(b)||b instanceof ArrayBuffer?`[Binary ${b.byteLength} bytes]`:Object.fromEntries(Object.entries(b).map(([b,e])=>[b,bJ.test(b)&&null!=e&&""!==e?bI:a(e,c+1,d)]))}(b),time:d.toISOString(),level:a,msg:bM(c)},f=JSON.stringify(e).length,g=bL();for(g.entries.push({entry:e,size:f}),g.totalSize+=f;g.entries.length>5e3||g.totalSize>0x1400000&&g.entries.length>1;){let a=g.entries.shift();if(!a)break;g.totalSize-=a.size,g.dropped+=1}}catch{}}let bO={trace:10,debug:20,info:30,warn:40,error:50,fatal:60};function bP(a,b={}){let c,d=bO[a],e=(c=process.env.LOG_LEVEL?.toLowerCase())&&void 0!==bO[c]?bO[c]:bO.info;return(c,f)=>{let g,h,i=new Date;if("string"==typeof c?(g={},h=c):(g=c,h=f||""),bN(a,{...b,...g},h,i),!(d<e)){let c=JSON.stringify({level:a,time:i.toISOString(),...b,...g,msg:h});switch(a){case"error":case"fatal":console.error(c);break;case"warn":console.warn(c);break;default:console.log(c)}}}}(function a(b={}){return b.module,{trace:bP("trace",b),debug:bP("debug",b),info:bP("info",b),warn:bP("warn",b),error:bP("error",b),fatal:bP("fatal",b),child:c=>a({...b,...c}),box:(a,c,d="📋")=>{bN("info",{...b,..."string"==typeof c?{content:c}:c},a);{let d="string"==typeof c?{content:c}:c||{};console.log(JSON.stringify({level:"info",time:new Date().toISOString(),...b,title:a,...d,msg:a}));return}},divider:(a="-")=>{}}})({env:"production"}).child({module:"ai:prompts"});let bQ=`填写题目类型,只能是以下 key 之一:single_choice(单选题)、multiple_choice(多选题)、true_false(判断题)、fill_blank(填空题)、calculation(计算题)、solution(解答题)、reading(阅读理解)、cloze(完形填空)、writing(写作)、other(其他)。
1
+ module.exports=[418175,a=>{"use strict";var b=a.i(187924),c=a.i(572131),d=a.i(550194),e=a.i(875003),f=a.i(291938),g=a.i(960927),h=a.i(630534);let i=["system","light","dark"],j="system",k="app-theme";function l(a){return"string"==typeof a&&i.includes(a)}let m=(0,c.createContext)({preference:j,theme:"light",setPreference:()=>void 0}),n="(prefers-color-scheme: dark)",o=new Set;function p(a){return o.add(a),window.addEventListener("storage",a),()=>{o.delete(a),window.removeEventListener("storage",a)}}function q(){try{let a=localStorage.getItem(k);return l(a)?a:j}catch{return j}}function r(a){try{localStorage.setItem(k,a)}catch{}o.forEach(a=>a())}function s(a){let b=window.matchMedia(n);return b.addEventListener("change",a),()=>b.removeEventListener("change",a)}let t=()=>window.matchMedia(n).matches;function u({children:a}){let{data:d,status:i}=(0,e.useSession)(),k="authenticated"===i,n=d?.user?.email,o=(0,c.useSyncExternalStore)(p,q,()=>j),v=(0,c.useSyncExternalStore)(s,t,()=>!1),w="system"===o?v?"dark":"light":o;(0,c.useEffect)(()=>{let a=document.documentElement,b=b=>{a.classList.toggle("dark","dark"===b),a.style.colorScheme=b};b(w);let c=()=>b("light"),d=()=>b(w);return window.addEventListener("beforeprint",c),window.addEventListener("afterprint",d),()=>{window.removeEventListener("beforeprint",c),window.removeEventListener("afterprint",d)}},[w]),(0,c.useEffect)(()=>{if(!k||!n)return;let a=!1;return f.k.get("/api/user").then(b=>{!a&&l(b.themePreference)&&b.themePreference!==q()&&r(b.themePreference)}).catch(a=>{h.V.warn("[Theme]","Failed to load theme preference",{error:(0,g.Z)(a)})}),()=>{a=!0}},[k,n]);let x=(0,c.useCallback)(a=>{r(a),k&&f.k.patch("/api/user",{themePreference:a}).catch(a=>{h.V.warn("[Theme]","Failed to save theme preference",{error:(0,g.Z)(a)})})},[k]),y=(0,c.useMemo)(()=>({preference:o,theme:w,setPreference:x}),[o,w,x]);return(0,b.jsx)(m.Provider,{value:y,children:a})}var v=a.i(529759),w=a.i(50944),x=a.i(875160),y=a.i(699570),z=a.i(814574),A=a.i(510606),B=a.i(283248),C=a.i(118688),D=a.i(895605),E=a.i(483138),F=a.i(164831);let G={name:"circle-plus",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],aliases:["plus-circle"]};G.node;let H=(0,F.f)(G),I=[/^\/login/,/^\/register/,/^\/setup/,/^\/print-preview/,/^\/exams\/[^/]+\/print/],J=[{key:"home",href:"/",icon:H,match:a=>"/"===a},{key:"notebooks",href:"/notebooks",icon:C.f,match:a=>a.startsWith("/notebooks")||a.startsWith("/error-items")||a.startsWith("/practice")},{key:"review",href:"/review",icon:D.f,match:a=>a.startsWith("/review")},{key:"stats",href:"/stats",icon:B.f,match:a=>a.startsWith("/stats")||a.startsWith("/tags")},{key:"exams",href:"/exams",icon:E.f,match:a=>a.startsWith("/exams")}];function K(a){return I.some(b=>b.test(a))}var L=a.i(710302);let M="ai-consent-dismissed:";function N(){let{t:a,language:g}=(0,d.b)(),i=a.aiConsent,{data:j,status:k}=(0,e.useSession)(),l=(0,w.usePathname)()||"/",m="authenticated"===k?j?.user?.email??null:null,[n,o]=(0,c.useState)(null),[p,q]=(0,c.useState)(null),[r,s]=(0,c.useState)(!1);(0,c.useEffect)(()=>(0,A.y)(a=>o(b=>b??a)),[]);let t=K(l);(0,c.useEffect)(()=>{if(!m||t||function(a){try{return"1"===sessionStorage.getItem(a)}catch{return!1}}(M+m))return;let a=!1;return f.k.get("/api/user").then(b=>{a||!b||b.aiDataConsentAt||o(a=>a??"prompt")}).catch(a=>h.V.error("[AiConsentDialog]","load consent failed",{error:a})),()=>{a=!0}},[m,t]);let u=null!==n&&!!m;(0,c.useEffect)(()=>{if(!u)return;let a=!1;return f.k.get("/api/settings").then(b=>{a||q(b?.aiProvider??null)}).catch(()=>void 0),()=>{a=!0}},[u]);let v=()=>{o(null),s(!1)},B=async()=>{s(!0);try{await f.k.post("/api/user/ai-consent",{}),L.c.success("blocked"===n?i.agreedRetry:i.agreed),v()}catch(a){h.V.error("[AiConsentDialog]","save consent failed",{error:a}),L.c.error(i.failed),s(!1)}},C=()=>{m&&function(a){try{sessionStorage.setItem(a,"1")}catch{}}(M+m),L.c.info(i.declined),v()},D=(0,A.K)(p,g);return(0,b.jsx)(z.N,{open:u,onOpenChange:a=>{a||r||C()},children:(0,b.jsxs)(z.d,{className:"sm:max-w-lg",children:[(0,b.jsxs)(z.s,{children:[(0,b.jsx)(z.F,{children:i.title}),(0,b.jsx)(z.C,{children:"blocked"===n?i.blocked:i.intro})]}),(0,b.jsxs)("div",{className:"space-y-3 text-sm",children:["blocked"===n&&(0,b.jsx)("p",{children:i.intro}),(0,b.jsx)("ul",{className:"list-disc space-y-1 pl-5",children:i.items.map(a=>(0,b.jsx)("li",{children:a},a))}),(0,b.jsx)("p",{children:D?i.providerKnown.replace("{provider}",D):i.providerUnknown}),(0,b.jsxs)("p",{children:[i.policy,"en"===g?" ":"",(0,b.jsx)("a",{className:"underline underline-offset-2",href:(0,A.L)(g),target:"_blank",rel:"noopener noreferrer",children:i.policyLink}),"en"===g?".":"。"]}),(0,b.jsx)("p",{className:"text-muted-foreground",children:i.declineNote})]}),(0,b.jsxs)(z.c,{className:"gap-2",children:[(0,b.jsx)(y.f,{type:"button",variant:"outline",onClick:C,disabled:r,children:i.decline}),(0,b.jsxs)(y.f,{type:"button",onClick:B,disabled:r,children:[r&&(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}),i.agree]})]})]})})}var O=a.i(16644),P=a.i(238246),Q=a.i(557230);let R={name:"shield",size:24,node:[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]};R.node;let S=(0,F.f)(R);var T=a.i(303324);function U({status:a,onAccept:f}){let{t:g,language:i}=(0,d.b)(),[j,k]=(0,c.useState)(!1),l="en"===i?a.changes.en:a.changes.zh,m=async()=>{k(!0);try{await f()}catch(a){h.V.error("[EulaGate]","Failed to accept EULA",{error:a}),L.c.error(g.eula.acceptFailed)}finally{k(!1)}};return(0,b.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/60 p-4",role:"dialog","aria-modal":"true","aria-labelledby":"eula-upgrade-title",children:(0,b.jsxs)("div",{className:"max-h-[90vh] w-full max-w-lg space-y-4 overflow-y-auto rounded-lg border bg-background p-5 shadow-lg",children:[(0,b.jsx)("h2",{id:"eula-upgrade-title",className:"text-lg font-semibold",children:g.eula.upgradeTitle}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:g.eula.upgradeDesc.replace("{accepted}",a.accepted??"-").replace("{current}",a.current)}),l.length>0&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-sm font-medium",children:g.eula.changesTitle}),(0,b.jsx)("ul",{className:"list-disc space-y-1 pl-5 text-sm",children:l.map(a=>(0,b.jsx)("li",{children:a},a))})]}),(0,b.jsx)(T.f,{}),(0,b.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[(0,b.jsx)(y.f,{variant:"outline",onClick:()=>(0,e.signOut)({callbackUrl:"/login"}),disabled:j,children:g.eula.logout}),(0,b.jsxs)(y.f,{onClick:m,disabled:j,children:[j&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),g.eula.accept]})]})]})})}var V=a.i(780767),W=a.i(682338),X=a.i(368114);function Y({className:a}){let{t:e}=(0,d.b)(),{data:f}=(0,W.b)(),g=(0,c.useRef)(null);if((0,c.useEffect)(()=>{if(!f)return;let a=new Set([...f.tasks.filter(a=>"analyzing"===a.status||"saving"===a.status).map(a=>a.id),...(f.batches??[]).filter(a=>"splitting"===a.phase||"processing"===a.phase).map(a=>`batch:${a.id}`)]),b=new Set([...f.tasks.filter(a=>a.unread).map(a=>a.id),...(f.batches??[]).filter(a=>a.unread).map(a=>`batch:${a.id}`)]),c=g.current;c&&[...c].some(c=>!a.has(c)&&b.has(c))&&L.c.info(e.importTasks.finishedToast),g.current=a},[f,e.importTasks.finishedToast]),!f||0===f.tasks.length&&!f.batches?.length)return null;let{activeCount:h,unreadCount:i}=f,j=h>0?e.importTasks.entryActive.replace("{count}",String(h)):e.importTasks.entry;return(0,b.jsxs)(P.default,{href:"/import-tasks",className:(0,X.f)("relative flex h-9 items-center gap-1.5 rounded-full border px-3 text-sm font-medium transition-colors hover:bg-muted",i>0?"border-primary/50 text-primary":"text-muted-foreground",a),"data-testid":"import-tasks-entry","aria-label":i>0?`${j} \xb7 ${e.importTasks.entryUnread.replace("{count}",String(i))}`:j,children:[h>0?(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}):(0,b.jsx)(V.f,{className:"h-4 w-4"}),(0,b.jsx)("span",{className:"whitespace-nowrap",children:j}),i>0&&(0,b.jsx)("span",{className:"flex h-5 min-w-5 items-center justify-center rounded-full bg-destructive px-1 text-xs text-white","data-testid":"import-tasks-unread",children:i})]})}var Z=a.i(390702);let $={name:"bot",size:24,node:[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]};$.node;let _=(0,F.f)($),aa={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};aa.node;let ab=(0,F.f)(aa);var ac=a.i(357204);let ad={name:"message-square-text",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]};ad.node;let ae=(0,F.f)(ad),af={name:"settings",size:24,node:[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]};af.node;let ag=(0,F.f)(af);var ah=a.i(344451),ai=a.i(930363),aj=a.i(875083),ak=a.i(986705),al=a.i(786304),am=a.i(563658),an=a.i(866718),ao=a.i(870430);let ap=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("div",{className:"relative w-full overflow-auto",children:(0,b.jsx)("table",{ref:d,className:(0,X.f)("w-full caption-bottom text-sm",a),...c})}));ap.displayName="Table";let aq=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("thead",{ref:d,className:(0,X.f)("[&_tr]:border-b",a),...c}));aq.displayName="TableHeader";let ar=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("tbody",{ref:d,className:(0,X.f)("[&_tr:last-child]:border-0",a),...c}));ar.displayName="TableBody",(c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("tfoot",{ref:d,className:(0,X.f)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...c}))).displayName="TableFooter";let as=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("tr",{ref:d,className:(0,X.f)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",a),...c}));as.displayName="TableRow";let at=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("th",{ref:d,className:(0,X.f)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",a),...c}));at.displayName="TableHead";let au=c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("td",{ref:d,className:(0,X.f)("p-4 align-middle [&:has([role=checkbox])]:pr-0",a),...c}));au.displayName="TableCell",(c.forwardRef(({className:a,...c},d)=>(0,b.jsx)("caption",{ref:d,className:(0,X.f)("mt-4 text-sm text-muted-foreground",a),...c}))).displayName="TableCaption";var av=a.i(951675);let aw={name:"ban",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]};aw.node;let ax=(0,F.f)(aw);var ay=a.i(79362);function az(){var a;let{t:e}=(0,d.b)(),[g,i]=(0,c.useState)(String(5)),[j,k]=(0,c.useState)(!1),l=(0,c.useCallback)(async()=>{try{let a=await f.k.get("/api/settings");i(String(a.aiConcurrencyLimit??5))}catch(a){h.V.error("[AiConcurrencyLimitSetting]","Failed to fetch config",{error:a})}},[]);(0,c.useEffect)(()=>{l()},[l]);let m=Number(g),n=""!==g.trim()&&"number"==typeof(a=m)&&Number.isInteger(a)&&a>=1&&a<=100,o=async()=>{if(n){k(!0);try{await f.k.post("/api/settings",{aiConcurrencyLimit:m}),L.c.success(e.admin.aiConcurrencyLimitSaved)}catch(a){h.V.error("[AiConcurrencyLimitSetting]","Failed to update AI concurrency limit",{error:a}),L.c.error(e.common.error)}finally{k(!1)}}};return(0,b.jsxs)("div",{className:"flex flex-col gap-3 p-4 border rounded-lg bg-muted/30 sm:flex-row sm:items-center sm:justify-between",children:[(0,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)(ao.f,{htmlFor:"ai-concurrency-limit",className:"text-base",children:e.admin.aiConcurrencyLimit}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:e.admin.aiConcurrencyLimitDesc})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(an.f,{id:"ai-concurrency-limit",type:"number",min:1,max:100,step:1,inputMode:"numeric",value:g,onChange:a=>i(a.target.value),"aria-invalid":!n,className:"w-24"}),(0,b.jsxs)(y.f,{size:"sm",onClick:o,disabled:j||!n,children:[j&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),e.common.save]})]})]})}function aA(a,b){return new Intl.NumberFormat("zh"===b?"zh-CN":"en-US",{notation:"compact",maximumFractionDigits:1}).format(Math.max(0,a))}function aB({user:a}){let{t:c,language:e}=(0,d.b)(),f=c.admin.aiTokensDetail.replace("{input}",aA(a.aiTokensToday.input,e)).replace("{output}",aA(a.aiTokensToday.output,e));return(0,b.jsxs)(b.Fragment,{children:[c.admin.aiUsageToday,": ",a.aiUsageToday," | ",c.admin.aiTokensToday,": ",f]})}function aC(){let{timeZone:a}=(0,v.M)(),{data:i}=(0,e.useSession)(),{t:j}=(0,d.b)(),[k,l]=(0,c.useState)([]),[m,n]=(0,c.useState)(!0),[o,p]=(0,c.useState)(!1),[q,r]=(0,c.useState)(!1),[s,t]=(0,c.useState)("0"),[u,w]=(0,c.useState)(!1),z=(0,c.useCallback)(async()=>{n(!0);try{let a=await f.k.get("/api/admin/users");l(a)}catch(a){h.V.error("[UserManagement]","Failed to fetch users",{error:a})}finally{n(!1)}},[]),A=(0,c.useCallback)(async()=>{try{let a=await f.k.get("/api/settings");p(!0===a.allowRegistration),t(String(a.aiDailyLimit??0))}catch(a){h.V.error("[UserManagement]","Failed to fetch config",{error:a})}},[]);(0,c.useEffect)(()=>{z(),A()},[z,A]);let B=async a=>{r(!0);try{await f.k.post("/api/settings",{allowRegistration:a}),p(a)}catch(a){h.V.error("[UserManagement]","Failed to update registration setting",{error:a}),L.c.error(j.common.error)}finally{r(!1)}},C=Number(s),D=""!==s.trim()&&Number.isInteger(C)&&C>=0,E=async()=>{if(D){w(!0);try{await f.k.post("/api/settings",{aiDailyLimit:C}),L.c.success(j.admin.aiDailyLimitSaved)}catch(a){h.V.error("[UserManagement]","Failed to update AI daily limit",{error:a}),L.c.error(j.common.error)}finally{w(!1)}}},F=async a=>{let b=a.isActive?j.admin.confirmDisable:j.admin.confirmEnable;if(await (0,L.u)(b))try{await f.k.patch(`/api/admin/users/${a.id}`,{isActive:!a.isActive}),z()}catch(a){h.V.error("[UserManagement]","Failed to update user status",{error:a}),L.c.error(j.common.error)}},G=async a=>{if(await (0,L.u)(j.admin.confirmDelete,{destructive:!0}))try{await f.k.delete(`/api/admin/users/${a.id}`),z()}catch(b){h.V.error("[UserManagement]","Failed to delete user",{error:b});let a=(0,g.d)(b)||j.common.error;L.c.error(a)}};return m?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(x.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/30",children:[(0,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)(ao.f,{className:"text-base",children:j.admin?.allowRegistration||"Allow New Registrations"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:j.admin?.allowRegistrationDesc||"When disabled, new users cannot register"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[q&&(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}),(0,b.jsx)(am.f,{checked:o,onCheckedChange:B,disabled:q})]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-3 p-4 border rounded-lg bg-muted/30 sm:flex-row sm:items-center sm:justify-between",children:[(0,b.jsxs)("div",{className:"space-y-0.5",children:[(0,b.jsx)(ao.f,{htmlFor:"ai-daily-limit",className:"text-base",children:j.admin.aiDailyLimit}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:j.admin.aiDailyLimitDesc})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(an.f,{id:"ai-daily-limit",type:"number",min:0,step:1,inputMode:"numeric",value:s,onChange:a=>t(a.target.value),"aria-invalid":!D,className:"w-24"}),(0,b.jsxs)(y.f,{size:"sm",onClick:E,disabled:u||!D,children:[u&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),j.common.save]})]})]}),(0,b.jsx)(az,{}),(0,b.jsx)("div",{className:"sm:hidden space-y-3",children:k.map(c=>(0,b.jsxs)("div",{className:"border rounded-lg p-4 bg-card space-y-3",children:[(0,b.jsxs)("div",{className:"flex justify-between items-start",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"font-medium",children:c.name||"N/A"}),(0,b.jsx)("div",{className:"text-sm text-muted-foreground",children:c.email})]}),(0,b.jsx)(al.f,{variant:"admin"===c.role?"default":"secondary",children:"admin"===c.role?j.admin.admin:j.admin.user})]}),(0,b.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,b.jsxs)("div",{className:"text-muted-foreground",children:[j.admin.errors,": ",c._count.errorItems," | ",j.admin.practiceCount,": ",c._count.practiceRecords," | ",(0,b.jsx)(aB,{user:c})]}),(0,b.jsx)(al.f,{variant:c.isActive?"default":"destructive",className:"text-xs",children:c.isActive?j.admin.active:j.admin.disabled})]}),(0,b.jsxs)("div",{className:"flex justify-between items-center pt-2 border-t",children:[(0,b.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,ak.r)(c.createdAt,"yyyy-MM-dd",a)}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:()=>F(c),disabled:c.id===i?.user?.id,children:c.isActive?(0,b.jsx)(ax,{className:"h-4 w-4 text-orange-500"}):(0,b.jsx)(ay.f,{className:"h-4 w-4 text-green-500"})}),(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:()=>G(c),disabled:c.id===i?.user?.id,children:(0,b.jsx)(av.f,{className:"h-4 w-4 text-destructive"})})]})]})]},c.id))}),(0,b.jsx)("div",{className:"hidden sm:block border rounded-lg overflow-hidden",children:(0,b.jsxs)(ap,{children:[(0,b.jsx)(aq,{children:(0,b.jsxs)(as,{children:[(0,b.jsx)(at,{children:j.admin.nameEmail}),(0,b.jsx)(at,{children:j.admin.role}),(0,b.jsx)(at,{children:j.admin.stats}),(0,b.jsx)(at,{children:j.admin.createdAt}),(0,b.jsx)(at,{children:j.admin.status}),(0,b.jsx)(at,{className:"text-right",children:j.admin.actions})]})}),(0,b.jsx)(ar,{children:k.map(c=>(0,b.jsxs)(as,{children:[(0,b.jsxs)(au,{children:[(0,b.jsx)("div",{className:"font-medium",children:c.name||"N/A"}),(0,b.jsx)("div",{className:"text-sm text-muted-foreground",children:c.email})]}),(0,b.jsx)(au,{children:(0,b.jsx)(al.f,{variant:"admin"===c.role?"default":"secondary",children:"admin"===c.role?j.admin.admin:j.admin.user})}),(0,b.jsxs)(au,{children:[(0,b.jsxs)("div",{className:"text-sm",children:[j.admin.errors,": ",c._count.errorItems]}),(0,b.jsxs)("div",{className:"text-sm",children:[j.admin.practiceCount,": ",c._count.practiceRecords]}),(0,b.jsx)("div",{className:"text-sm",children:(0,b.jsx)(aB,{user:c})})]}),(0,b.jsx)(au,{children:(0,ak.r)(c.createdAt,"yyyy-MM-dd",a)}),(0,b.jsx)(au,{children:(0,b.jsx)(al.f,{variant:c.isActive?"default":"destructive",children:c.isActive?j.admin.active:j.admin.disabled})}),(0,b.jsxs)(au,{className:"text-right space-x-2",children:[(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:()=>F(c),disabled:c.id===i?.user?.id,title:c.isActive?j.admin.disable:j.admin.enable,children:c.isActive?(0,b.jsx)(ax,{className:"h-4 w-4 text-orange-500"}):(0,b.jsx)(ay.f,{className:"h-4 w-4 text-green-500"})}),(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:()=>G(c),disabled:c.id===i?.user?.id,title:j.admin.delete,children:(0,b.jsx)(av.f,{className:"h-4 w-4 text-destructive"})})]})]},c.id))})]})})]})}var aD=a.i(168370);let aE={name:"scroll-text",size:24,node:[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]};aE.node;let aF=(0,F.f)(aE);function aG(a){return(0,b.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a,children:[(0,b.jsx)("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),(0,b.jsx)("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}let aH={name:"server",size:24,node:[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]};aH.node;let aI=(0,F.f)(aH);var aJ=a.i(540553);let aK=()=>()=>void 0;function aL(){let{t:a}=(0,d.b)(),e=(0,c.useSyncExternalStore)(aK,aJ.f,()=>null);return e?e.isStandalone?.()?(0,b.jsx)("p",{className:"text-center text-sm text-muted-foreground",children:a.settings?.about?.androidStandalone||"Running on this device. Data is stored only on this device."}):(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[(0,b.jsxs)("span",{className:"break-all",children:[a.settings?.about?.androidServer||"Server",": ",e.getServerUrl()]}),(0,b.jsxs)(y.f,{variant:"outline",className:"gap-2",onClick:()=>e.changeServer(),children:[(0,b.jsx)(aI,{className:"h-4 w-4"}),a.settings?.about?.changeServer||"Change server"]})]}):null}var aM=a.i(424235);function aN(){let{t:a}=(0,d.b)(),[e,f]=(0,c.useState)("");(0,c.useEffect)(()=>{fetch("/api/version").then(a=>a.json()).then(a=>f(a.version)).catch(()=>{})},[]);let g=[{href:aM.f,icon:aG,label:a.settings?.about?.github||"GitHub Repository"},{href:`${aM.f}/releases`,icon:aF,label:a.settings?.about?.releaseNotes||"Release Notes"},{href:`${aM.f}/issues`,icon:ae,label:a.settings?.about?.feedback||"Feedback"}];return(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-6 py-8 text-center bg-muted/30 rounded-lg border",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-2xl font-bold",children:a.app?.title||"Smart Error Notebook"}),(0,b.jsx)("p",{className:"text-muted-foreground",children:a.settings?.about?.desc||"AI-powered learning assistant"})]}),(0,b.jsxs)("div",{className:"flex items-center space-x-2 text-sm text-muted-foreground border px-4 py-2 rounded-full bg-background",children:[(0,b.jsx)(ab,{className:"h-4 w-4"}),(0,b.jsxs)("span",{children:[a.settings?.about?.version||"Version",": v",e||"unknown"]})]}),(0,b.jsx)(aL,{}),(0,b.jsx)("div",{className:"flex flex-col sm:flex-row flex-wrap justify-center gap-4 w-full sm:w-auto px-4 sm:px-0",children:g.map(({href:a,icon:c,label:d})=>(0,b.jsx)(y.f,{variant:"outline",asChild:!0,className:"gap-2 w-full sm:w-auto",children:(0,b.jsxs)("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[(0,b.jsx)(c,{className:"h-4 w-4"}),d,(0,b.jsx)(aD.f,{className:"h-3 w-3 ml-1 opacity-50"})]})},a))}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-8",children:a.settings?.about?.copyright||"© 2026 margrop · Based on wttwins/wrong-notebook · MIT License"})]})}var aO=a.i(152679),aP=a.i(580701),aQ=a.i(348966);let aR={name:"",email:"",educationStage:"",enrollmentYear:"",currentGrade:"",currentSemester:"",password:""};function aS(){let{t:a}=(0,d.b)(),[e,i]=(0,c.useState)(aR),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(!0),[n,o]=(0,c.useState)(!1),p=(0,c.useCallback)(async()=>{try{let a=await f.k.get("/api/user"),b=a.fixedGradeSemester?(0,aQ.p)(a.fixedGradeSemester):null;i({name:a.name||"",email:a.email||"",educationStage:a.educationStage||"",enrollmentYear:a.enrollmentYear||"",currentGrade:b?.grade||"",currentSemester:b?.semester||"",password:""})}catch(a){h.V.error("[AccountSettings]","Failed to fetch profile",{error:a})}finally{m(!1)}},[]);(0,c.useEffect)(()=>{p()},[p]);let q=async()=>{if(e.password&&e.password!==j)return void L.c.error(a.settings?.messages?.passwordMismatch||"Passwords do not match");o(!0);try{let b={name:e.name,email:e.email,educationStage:e.educationStage};e.enrollmentYear&&(b.enrollmentYear=parseInt(e.enrollmentYear.toString())),e.password&&(b.password=e.password),e.currentGrade&&e.currentSemester?b.fixedGradeSemester=`${e.currentGrade}${e.currentSemester}`:e.currentGrade||(b.fixedGradeSemester=null),await f.k.patch("/api/user",b),L.c.success(a.settings?.messages?.profileUpdated||"Profile updated"),i(a=>({...a,password:""})),k(""),window.location.reload()}catch(b){h.V.error("[AccountSettings]","Failed to update profile",{error:(0,g.d)(b)??(0,g.Z)(b)}),L.c.error((0,g.d)(b)||a.settings?.messages?.updateFailed||"Update failed")}finally{o(!1)}};return l?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(x.f,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,b.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.auth?.name||"Name"}),(0,b.jsx)(an.f,{value:e.name||"",onChange:a=>i({...e,name:a.target.value})})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.auth?.email||"Email"}),(0,b.jsx)(an.f,{value:e.email||"",onChange:a=>i({...e,email:a.target.value}),type:"email"})]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.auth?.educationStage||"Education Stage"}),(0,b.jsxs)(aP.d,{value:e.educationStage||"",onValueChange:a=>i({...e,educationStage:a,currentGrade:(0,aQ.c)(a).includes(e.currentGrade)?e.currentGrade:"",currentSemester:(0,aQ.c)(a).includes(e.currentGrade)?e.currentSemester:""}),children:[(0,b.jsx)(aP.P,{children:(0,b.jsx)(aP.U,{placeholder:a.auth?.selectStage||"Select Stage"})}),(0,b.jsxs)(aP.r,{children:[(0,b.jsx)(aP.T,{value:"primary",children:a.auth?.primary||"Primary School"}),(0,b.jsx)(aP.T,{value:"junior_high",children:a.auth?.juniorHigh||"Junior High"}),(0,b.jsx)(aP.T,{value:"senior_high",children:a.auth?.seniorHigh||"Senior High"}),(0,b.jsx)(aP.T,{value:"university",children:a.auth?.university||"University"})]})]})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.auth?.enrollmentYear||"Enrollment Year"}),(0,b.jsx)(an.f,{type:"number",value:e.enrollmentYear||"",onChange:a=>i({...e,enrollmentYear:a.target.value}),placeholder:"YYYY"})]})]}),e.educationStage&&(0,aQ.c)(e.educationStage).length>0&&(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.settings?.account?.currentGrade||"Current Grade & Semester"}),(0,b.jsxs)(aP.d,{value:e.currentGrade||"",onValueChange:a=>i({...e,currentGrade:a,currentSemester:a?e.currentSemester||"上":""}),children:[(0,b.jsx)(aP.P,{children:(0,b.jsx)(aP.U,{placeholder:a.settings?.account?.selectGrade||"Select Grade"})}),(0,b.jsx)(aP.r,{children:(0,aQ.c)(e.educationStage).map(a=>(0,b.jsx)(aP.T,{value:a,children:a},a))})]})]}),e.currentGrade&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.settings?.account?.selectSemester||"Select Semester"}),(0,b.jsxs)(aP.d,{value:e.currentSemester||"",onValueChange:a=>i({...e,currentSemester:a}),children:[(0,b.jsx)(aP.P,{children:(0,b.jsx)(aP.U,{placeholder:a.settings?.account?.selectSemester||"Select Semester"})}),(0,b.jsxs)(aP.r,{children:[(0,b.jsx)(aP.T,{value:"上",children:a.settings?.account?.firstSemester||"1st Semester"}),(0,b.jsx)(aP.T,{value:"下",children:a.settings?.account?.secondSemester||"2nd Semester"})]})]})]})]}),e.currentGrade&&e.currentSemester&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground -mt-2",children:a.settings?.account?.gradeAppliedHint||"New questions will default to this grade. You can also configure AI grade recognition in General Settings."}),(0,b.jsxs)("div",{className:"space-y-3 pt-2 border-t",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.settings?.account?.changePassword||"Change Password (Leave empty to keep)"}),(0,b.jsx)(aO.f,{value:e.password,onChange:a=>i({...e,password:a.target.value}),placeholder:"******",minLength:6})]}),e.password&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:a.auth?.confirmPassword||"Confirm Password"}),(0,b.jsx)(aO.f,{value:j,onChange:a=>k(a.target.value),placeholder:"******",minLength:6})]})]}),(0,b.jsxs)(y.f,{onClick:q,disabled:n,className:"w-full",children:[n&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.settings?.account?.update||"Update Profile"]})]})}var aT=a.i(151304),aU=a.i(201661),aV=a.i(246059),aW=a.i(998868),aX=a.i(332485),aY=a.i(861954);let aZ="https://github.com/xiaoyang111222/cn-math-taxonomy",a$="https://raw.githubusercontent.com/xiaoyang111222/cn-math-taxonomy/HEAD/data/topics.json",a_=aV.z.object({id:aW.z.string().optional(),name:aW.z.string().trim().min(1),subject:aW.z.string().nullish(),grade:aX.z.number().int(),semester:aW.z.string().nullish(),chapter:aW.z.string().nullish()}).passthrough();aY.z.array(a_).min(1);let a0="/api/admin/cnm-tags";function a1(){let{t:a}=(0,d.b)(),e=a.admin.cnmTags,[g,i]=(0,c.useState)(null),[j,k]=(0,c.useState)(!1),l=(0,c.useRef)(null),m=(0,c.useCallback)(async()=>{try{i(await f.k.get(a0))}catch(a){h.V.warn("[CnmTagImportSettings]","Failed to load status",{error:a})}},[]);(0,c.useEffect)(()=>{m()},[m]);let n=async a=>{if(a){k(!0);try{let b;try{b=JSON.parse(await a.text())}catch{L.c.error(e.invalidFile);return}let c=await f.k.post(a0,{topics:b},{timeout:3e5});i(c.status),L.c.success(e.imported.replace("{created}",String(c.result.created)).replace("{skipped}",String(c.result.skipped)))}catch(b){h.V.error("[CnmTagImportSettings]","Import failed",{error:b});let a=b instanceof f.a&&400===b.status;L.c.error(a?e.invalidFile:e.failed)}finally{k(!1),l.current&&(l.current.value="")}}},o=g?.knowledgePoints??0;return(0,b.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("p",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,b.jsx)(C.f,{className:"h-4 w-4"}),e.title]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:e.desc})]}),(0,b.jsxs)("div",{className:"space-y-1 rounded-md bg-muted/50 p-3 text-xs text-muted-foreground",children:[(0,b.jsx)("p",{children:e.downloadHint}),(0,b.jsx)("a",{href:a$,target:"_blank",rel:"noopener noreferrer",className:"block break-all text-primary underline",children:a$}),(0,b.jsxs)("p",{children:[e.sourceLabel," ",(0,b.jsx)("a",{href:aZ,target:"_blank",rel:"noopener noreferrer",className:"break-all text-primary underline",children:aZ})]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g?o>0?e.status.replace("{count}",String(o)):e.notImported:""}),(0,b.jsx)("input",{ref:l,type:"file",accept:".json,application/json",className:"hidden",onChange:a=>n(a.target.files?.[0]),disabled:j}),(0,b.jsxs)(y.f,{variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:()=>l.current?.click(),disabled:j,children:[j?(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,b.jsx)(aU.f,{className:"mr-2 h-4 w-4"}),j?e.importing:e.select]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:e.note})]})}var a2=a.i(519783);let a3={info:{card:"border-blue-200 dark:border-blue-900 bg-blue-50 dark:bg-blue-950/40",title:"text-blue-900 dark:text-blue-200 font-bold",desc:"text-blue-800 dark:text-blue-200 font-medium",button:"bg-blue-100 dark:bg-blue-900/40 hover:bg-blue-200 dark:hover:bg-blue-900/60 text-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-800"},danger:{card:"border-red-200 dark:border-red-900 bg-red-50 dark:bg-red-950/40",title:"text-red-700 dark:text-red-300 font-medium",desc:"text-red-600 dark:text-red-400",button:""},critical:{card:"border-red-600/50 bg-red-100/50 dark:bg-red-900/40",title:"text-red-900 dark:text-red-200 font-bold",desc:"text-red-800 dark:text-red-200 font-medium",button:"bg-red-700 hover:bg-red-800"}};function a4({title:a,description:c,tone:d,busy:e,icon:f,onClick:g}){let h=a3[d];return(0,b.jsxs)("div",{className:`p-4 border rounded-lg ${h.card}`,children:[(0,b.jsxs)("div",{className:"flex items-center justify-between",children:[(0,b.jsx)("span",{className:`text-sm flex items-center gap-2 ${h.title}`,children:a}),(0,b.jsx)(y.f,{variant:"info"===d?"outline":"destructive",size:"sm",onClick:g,disabled:e,className:h.button,children:e?(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}):f})]}),(0,b.jsx)("p",{className:`text-xs mt-2 ${h.desc}`,children:c})]})}function a5({isAdmin:a}){let{t:e}=(0,d.b)(),[g,i]=(0,c.useState)(null),j=async(a,b,c,d)=>{i(a);try{L.c.success(await b()),d&&window.location.reload()}catch(b){h.V.error("[DangerZoneSettings]",`${a} failed`,{error:b}),L.c.error(c)}finally{i(null)}},k=e.settings?.clearSuccess||"Success",l=e.settings?.clearError||"Failed",m=async()=>{await (0,L.u)(e.settings?.migrateTagsConfirm||"This will reset system tags. Confirm?",{destructive:!0})&&await j("migrateTags",async()=>{let a=await f.k.post("/api/admin/migrate-tags",{});return`${k}: ${a.count||0} tags migrated.`},e.settings?.clearError||"Failed to migrate tags",!1)},n=async()=>{await (0,L.u)(e.settings?.clearDataConfirm||"Are you sure?",{destructive:!0})&&await j("clearPractice",async()=>(await f.k.delete("/api/stats/practice/clear"),k),l,!0)},o=async()=>{await (0,L.u)(e.settings?.clearErrorDataConfirm||"Are you sure?",{destructive:!0})&&await j("clearErrors",async()=>(await f.k.delete("/api/error-items/clear"),k),l,!0)},p=async()=>{if(!await (0,L.u)(e.settings?.systemResetConfirm||"WARNING: Deleting ALL data. Undoing is impossible. Are you sure?",{destructive:!0}))return;let a=prompt(e.settings?.systemResetPrompt||"Type 'RESET' to confirm system initialization:","");if("RESET"!==a){null!==a&&L.c.error(e.common?.error||"Confirmation failed");return}await j("systemReset",async()=>(await f.k.post("/api/admin/system-reset",{}),e.settings?.clearSuccess||"Success - System Reset Complete"),e.settings?.clearError||"Failed to reset system",!0)};return(0,b.jsxs)(b.Fragment,{children:[a&&(0,b.jsx)(a4,{tone:"info",title:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a2.f,{className:"h-4 w-4"}),e.settings?.migrateTags||"Migrate Tags"]}),description:e.settings?.migrateTagsDesc||"Re-populates standard tags from file",busy:"migrateTags"===g,icon:(0,b.jsx)(a2.f,{className:"h-4 w-4"}),onClick:m}),(0,b.jsx)(a4,{tone:"danger",title:e.settings?.clearData||"Clear Practice Data",description:e.settings?.clearDataDesc||"This will permanently delete all practice history. Irreversible.",busy:"clearPractice"===g,icon:(0,b.jsx)(av.f,{className:"h-4 w-4"}),onClick:n}),(0,b.jsx)(a4,{tone:"danger",title:e.settings?.clearErrorData||"Clear Error Data",description:e.settings?.clearErrorDataDesc||"This will permanently delete all error items. Irreversible.",busy:"clearErrors"===g,icon:(0,b.jsx)(av.f,{className:"h-4 w-4"}),onClick:o}),a&&(0,b.jsx)(a4,{tone:"critical",title:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Z.f,{className:"h-4 w-4"}),e.settings?.systemReset||"System Initialization"]}),description:e.settings?.systemResetDesc||"Resets the system to factory state. Deletes ALL data.",busy:"systemReset"===g,icon:(0,b.jsx)(av.f,{className:"h-4 w-4"}),onClick:p})]})}let a6={name:"user-x",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]};a6.node;let a7=(0,F.f)(a6);function a8({isAdmin:a}){let{t:g}=(0,d.b)(),i=g.settings.deleteAccount,[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(""),[n,o]=(0,c.useState)(!1),p=a=>{!n&&(k(a),a||m(""))},q=async a=>{if(a.preventDefault(),l){o(!0);try{await f.k.delete("/api/user",{body:JSON.stringify({password:l})}),L.c.success(i.success),await (0,e.signOut)({callbackUrl:"/login"})}catch(b){let a=b instanceof f.a&&400===b.status;a||h.V.error("[DeleteAccountSettings]","delete account failed",{error:b}),L.c.error(a?i.wrongPassword:i.failed),o(!1)}}};return(0,b.jsxs)("div",{className:"p-4 border rounded-lg border-red-600/50 bg-red-100/50 dark:bg-red-900/40",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsxs)("span",{className:"text-sm flex items-center gap-2 text-red-900 dark:text-red-200 font-bold",children:[(0,b.jsx)(a7,{className:"h-4 w-4"}),i.title]}),(0,b.jsx)(y.f,{variant:"destructive",size:"sm",className:"bg-red-700 hover:bg-red-800",disabled:a,onClick:()=>k(!0),"aria-label":i.title,children:(0,b.jsx)(a7,{className:"h-4 w-4"})})]}),(0,b.jsx)("p",{className:"text-xs mt-2 text-red-800 dark:text-red-200 font-medium",children:a?i.adminDisabled:i.desc}),(0,b.jsx)(z.N,{open:j,onOpenChange:p,children:(0,b.jsx)(z.d,{className:"sm:max-w-md",children:(0,b.jsxs)("form",{onSubmit:q,className:"space-y-4",children:[(0,b.jsxs)(z.s,{children:[(0,b.jsx)(z.F,{children:i.confirmTitle}),(0,b.jsx)(z.C,{children:i.confirmDesc})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{htmlFor:"delete-account-password",children:i.passwordLabel}),(0,b.jsx)(aO.f,{id:"delete-account-password",autoComplete:"current-password",value:l,onChange:a=>m(a.target.value),disabled:n})]}),(0,b.jsxs)(z.c,{className:"gap-2",children:[(0,b.jsx)(y.f,{type:"button",variant:"outline",onClick:()=>p(!1),disabled:n,children:i.cancel}),(0,b.jsxs)(y.f,{type:"submit",variant:"destructive",disabled:!l||n,children:[n&&(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}),i.confirm]})]})]})})})]})}let a9={name:"shield-check",size:24,node:[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]};a9.node;let ba=(0,F.f)(a9);function bb(){let{t:a,language:e}=(0,d.b)(),g=a.aiConsent,[i,j]=(0,c.useState)(void 0),[k,l]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let a=!1;return f.k.get("/api/user").then(b=>{a||j(b?.aiDataConsentAt??null)}).catch(a=>h.V.error("[AiConsentSetting]","load consent failed",{error:a})),()=>{a=!0}},[]);let m=async a=>{if(a||await (0,L.u)(g.revokeConfirm,{destructive:!0})){l(!0);try{let b=a?await f.k.post("/api/user/ai-consent",{}):await f.k.delete("/api/user/ai-consent");j(b.aiDataConsentAt),L.c.success(a?g.agreed:g.revoked)}catch(a){h.V.error("[AiConsentSetting]","update consent failed",{error:a}),L.c.error(g.failed)}finally{l(!1)}}};if(void 0===i)return null;let n=null!==i,o=n?new Date(i).toLocaleDateString("en"===e?"en-US":"zh-CN"):"";return(0,b.jsxs)("div",{className:"space-y-2 rounded-lg border p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,b.jsx)(ba,{className:"h-4 w-4"}),g.settingTitle]}),(0,b.jsxs)(y.f,{type:"button",size:"sm",variant:n?"outline":"default",onClick:()=>m(!n),disabled:k,children:[k&&(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}),n?g.revoke:g.grant]})]}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:[n?g.settingGranted.replace("{date}",o):g.settingNotGranted," ",(0,b.jsx)("a",{className:"underline underline-offset-2",href:(0,A.L)(e),target:"_blank",rel:"noopener noreferrer",children:g.policyLink})]})]})}var bc=a.i(613412),bd=a.i(536670),be=a.i(64332);async function bf(a,b){let c=await fetch(a);if(!c.ok)throw Error((await c.json().catch(()=>({}))).message||"Download failed");let d=await c.blob(),e=window.URL.createObjectURL(d),f=document.createElement("a");f.href=e;let g=c.headers.get("Content-Disposition")?.match(/filename="(.+)"/);f.download=g?g[1]:b,document.body.appendChild(f),f.click(),document.body.removeChild(f),window.URL.revokeObjectURL(e)}function bg({isAdmin:a,userId:e,userEmail:g}){let{t:i}=(0,d.b)(),[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(!1),[n,o]=(0,c.useState)(null),p=`user:${e}:data-import`,{running:q,refresh:r}=(0,be.f)(p),s=(0,c.useRef)(!1);(0,c.useEffect)(()=>{if(q){s.current=!0;return}s.current&&(s.current=!1,window.location.reload())},[q]);let t=async a=>{if(!a||await (0,L.u)(i.settings?.exportAllConfirm||"Export all users' data? This may take a while.")){k(!0);try{await bf(a?"/api/export?all=true":"/api/export",a?"wrong-notebook-export-all.json":"wrong-notebook-export.json"),L.c.success(i.settings?.exportSuccess||"Export successful")}catch(b){h.V.error("[DataBackupSettings]",a?"Export all failed":"Export failed",{error:b}),L.c.error(i.settings?.exportFailed||"Export failed")}finally{k(!1)}}},u=async a=>{let b;if(!n)return;try{b=JSON.parse(await n.text())}catch(a){h.V.error("[DataBackupSettings]","Import file is not valid JSON",{error:a}),L.c.error(i.settings?.importFailed||"Import failed");return}let c="object"==typeof b&&null!==b&&"user"in b?b.user:void 0,d="object"==typeof c&&null!==c&&"email"in c&&"string"==typeof c.email?c.email:null,e=!a&&!!d&&!!g&&d!==g,j=a?i.settings?.importAllConfirm||"Import all users' data? This will restore data for all users from the export file.":e?(i.settings?.importOtherAccountConfirm||"This backup belongs to {email}. Importing merges it into the current account without restoring that account's preferences. Continue?").replace("{email}",d??""):i.settings?.importConfirm||"Are you sure you want to import?";if(await (0,L.u)(j)){m(!0);try{let{stats:c}=await f.k.post(a?"/api/import?all=true":e?"/api/import?merge=true":"/api/import",b);L.c.success((i.settings?.importResultDesc||"Imported {subjects} notebooks, {tags} tags, {items} error items, {schedules} review schedules, {records} practice records, {papers} exam papers and {voices} cloud voice clips.").replace("{subjects}",String(c.subjectsCreated)).replace("{tags}",String(c.tagsCreated)).replace("{items}",String(c.errorItemsCreated)).replace("{schedules}",String(c.reviewSchedulesCreated)).replace("{records}",String(c.practiceRecordsCreated)).replace("{papers}",String(c.examPapersCreated??0)).replace("{voices}",String(c.ttsSpeechesImported??0)).replace("{duplicates}",String(c.duplicateErrorItems??0))),o(null),window.location.reload()}catch(b){b instanceof f.a&&409===b.status&&b.data?.code==="TASK_ALREADY_RUNNING"?(L.c.info(i.errors.TASK_ALREADY_RUNNING),await r()):(h.V.error("[DataBackupSettings]",a?"Import all failed":e?"Merge import failed":"Import failed",{error:b}),L.c.error(i.settings?.importFailed||"Import failed"))}finally{m(!1)}}},v=(a,c)=>a?(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}):c,w=l||!!q;return(0,b.jsxs)("div",{className:"p-4 border border-blue-200 dark:border-blue-900 rounded-lg bg-blue-50 dark:bg-blue-950/40",children:[(0,b.jsx)("h4",{className:"text-sm font-bold text-blue-900 dark:text-blue-200 mb-3",children:i.settings?.dataManagement||"Data Management"}),(0,b.jsxs)("div",{className:"mb-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,b.jsx)("span",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium",children:i.settings?.exportData||"Export Data"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>t(!1),disabled:j,className:"bg-blue-100 dark:bg-blue-900/40 hover:bg-blue-200 dark:hover:bg-blue-900/60 text-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-800",children:[v(j,(0,b.jsx)(bd.f,{className:"mr-2 h-4 w-4"})),i.settings?.exportData||"Export"]}),a&&(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>t(!0),disabled:j,className:"bg-orange-100 dark:bg-orange-900/40 hover:bg-orange-200 dark:hover:bg-orange-900/60 text-orange-900 dark:text-orange-200 border-orange-300 dark:border-orange-800",children:[v(j,(0,b.jsx)(bd.f,{className:"mr-2 h-4 w-4"})),i.settings?.exportAllData||"Export All"]})]})]}),(0,b.jsx)("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:i.settings?.exportDataDesc||"Export all data as JSON file."})]}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,b.jsx)("span",{className:"text-sm text-blue-800 dark:text-blue-200 font-medium",children:i.settings?.importData||"Import Data"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("input",{type:"file",accept:".json",onChange:a=>o(a.target.files?.[0]??n),className:"hidden",id:"import-file-input",disabled:w}),(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>document.getElementById("import-file-input")?.click(),disabled:w,className:"bg-blue-100 dark:bg-blue-900/40 hover:bg-blue-200 dark:hover:bg-blue-900/60 text-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-800",children:[v(w,(0,b.jsx)(aU.f,{className:"mr-2 h-4 w-4"})),n?.name||i.settings?.selectFile||"Select File"]}),n&&(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>u(!1),disabled:w,className:"bg-green-100 dark:bg-green-900/40 hover:bg-green-200 dark:hover:bg-green-900/60 text-green-900 dark:text-green-200 border-green-300 dark:border-green-800",children:[v(w,(0,b.jsx)(bc.f,{className:"mr-2 h-4 w-4"})),i.settings?.importData||"Import"]}),n&&a&&(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>u(!0),disabled:w,className:"bg-orange-100 dark:bg-orange-900/40 hover:bg-orange-200 dark:hover:bg-orange-900/60 text-orange-900 dark:text-orange-200 border-orange-300 dark:border-orange-800",children:[v(w,(0,b.jsx)(bc.f,{className:"mr-2 h-4 w-4"})),i.settings?.importAllData||"Import All"]})]})]}),(0,b.jsx)("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:i.settings?.importDataDesc||"Import data from JSON file. Existing data will be skipped."})]})]})}let bh={name:"bug",size:24,node:[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]]};bh.node;let bi=(0,F.f)(bh),bj="/api/admin/debug-logs";function bk(){let{t:a}=(0,d.b)(),{timeZone:e}=(0,v.M)(),g=a.admin.debugLog,[i,j]=(0,c.useState)(null),[k,l]=(0,c.useState)(!1),m=(0,c.useCallback)(async()=>{try{j(await f.k.get(bj))}catch(a){h.V.warn("[DebugLogSettings]","Failed to load debug status",{error:a})}},[]);(0,c.useEffect)(()=>{m()},[m]),(0,c.useEffect)(()=>{if(!i?.enabled)return;let a=setInterval(m,5e3);return()=>clearInterval(a)},[i?.enabled,m]);let n=async(a,b)=>{l(!0);try{await a(),L.c.success(b)}catch(a){h.V.error("[DebugLogSettings]","Debug log action failed",{error:a}),L.c.error(g.failed)}finally{l(!1)}},o=a=>a?(0,ak.r)(a,"yyyy-MM-dd HH:mm",e):"",p=i?.enabled?g.enabledHint.replace("{since}",o(i.enabledAt)).replace("{until}",o(i.expiresAt)):g.disabledHint,q=(i?.entryCount??0)>0;return(0,b.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)(ao.f,{htmlFor:"debug-mode-switch",className:"flex items-center gap-2 font-medium",children:[(0,b.jsx)(bi,{className:"h-4 w-4"}),g.title]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g.desc})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)("span",{className:"text-sm text-muted-foreground",children:g.enable}),(0,b.jsx)(am.f,{id:"debug-mode-switch",checked:!!i?.enabled,onCheckedChange:a=>n(async()=>{j(await f.k.post(bj,{enabled:a}))},a?g.enabled:g.disabled),disabled:k||!i})]})]}),(0,b.jsxs)("p",{className:`text-xs ${i?.enabled?"text-orange-600":"text-muted-foreground"}`,children:[p,i&&(0,b.jsxs)(b.Fragment,{children:[" ",g.entries.replace("{count}",String(i.entryCount)),i.droppedCount>0&&g.dropped.replace("{count}",String(i.droppedCount))]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>n(async()=>{await bf(`${bj}/export`,"wrong-notebook-debug.json"),await m()},g.exported),disabled:k||!q,className:"sm:flex-1",children:[k?(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,b.jsx)(bd.f,{className:"mr-2 h-4 w-4"}),g.export]}),(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:()=>n(async()=>{j(await f.k.delete(bj))},g.cleared),disabled:k||!q,children:[(0,b.jsx)(av.f,{className:"mr-2 h-4 w-4"}),g.clear]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g.privacyNote})]})}var bl=a.i(225949);function bm({field:a,label:e,description:g}){let{t:i}=(0,d.b)(),[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(!1),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(null),r=`preference-${a}`;(0,c.useEffect)(()=>{f.k.get("/api/user").then(b=>k(!!b[a])).catch(()=>void 0).finally(()=>m(!0))},[a]);let s=async b=>{k(b),o(!0);try{await f.k.patch("/api/user",{[a]:b}),q(i.importFlow.preferenceSaved)}catch(c){k(!b),q(i.importFlow.preferenceSaveFailed),h.V.error("[Settings]","Failed to save user preference",{field:a,error:c instanceof Error?c.message:String(c)})}finally{o(!1)}};return(0,b.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,b.jsx)(ao.f,{htmlFor:r,children:e}),(0,b.jsx)(am.f,{id:r,checked:j,onCheckedChange:s,disabled:!l||n})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g}),p&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:p})]})}function bn(){let{t:a}=(0,d.b)();return(0,b.jsx)(bm,{field:"enableGeogebra",label:a.importFlow.enableGeogebra,description:a.importFlow.enableGeogebraDesc})}function bo(){let{t:a}=(0,d.b)();return(0,b.jsx)(bm,{field:"confirmBeforeImport",label:a.importFlow.confirmBeforeImport,description:a.importFlow.confirmBeforeImportDesc})}var bp=a.i(249479);function bq(){let{t:a}=(0,d.b)(),[e,g]=(0,c.useState)(String(bp.z)),[i,j]=(0,c.useState)(null),[k,l]=(0,c.useState)(!0),[m,n]=(0,c.useState)(!1),[o,p]=(0,c.useState)(null),q=Number(e),r=""!==e.trim()&&Number.isInteger(q)&&q>=bp.P&&q<=bp.o,s=(0,c.useCallback)(async()=>{l(!0),p(null);try{let a=(await f.k.get("/api/user")).masteryThreshold??bp.z;g(String(a)),j(a)}catch(b){p(a.mastery.thresholdLoadFailed),h.V.error("[Settings]","加载已掌握阈值失败",{error:b instanceof Error?b.message:String(b)})}finally{l(!1)}},[a.mastery.thresholdLoadFailed]);(0,c.useEffect)(()=>{s()},[s]);let t=async()=>{if(r&&null!==i){n(!0),p(null);try{let b=(await f.k.patch("/api/user",{masteryThreshold:q})).masteryThreshold??q;j(b),g(String(b)),p(a.importFlow.preferenceSaved)}catch(b){p(a.importFlow.preferenceSaveFailed),h.V.error("[Settings]","保存已掌握阈值失败",{error:b instanceof Error?b.message:String(b)})}finally{n(!1)}}};return(0,b.jsxs)("div",{className:"space-y-2 border-t pt-4",children:[(0,b.jsx)(ao.f,{htmlFor:"mastery-threshold",children:a.mastery.thresholdLabel}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)(an.f,{id:"mastery-threshold",type:"number",min:bp.P,max:bp.o,step:1,value:e,onChange:a=>{g(a.target.value),p(null)},disabled:k||m||null===i,className:"w-28","aria-describedby":"mastery-threshold-hint"}),(0,b.jsx)("span",{"aria-hidden":"true",children:"%"}),(0,b.jsxs)(y.f,{type:"button",size:"sm",variant:"outline",onClick:t,disabled:k||m||null===i||!r||q===i,children:[(k||m)&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.importFlow.saveThreshold]}),!k&&null===i&&(0,b.jsx)(y.f,{type:"button",size:"sm",variant:"outline",onClick:s,children:a.importFlow.retryLoad})]}),(0,b.jsx)("p",{id:"mastery-threshold-hint",className:"text-xs text-muted-foreground",children:a.mastery.thresholdDescription}),null!==i&&!r&&(0,b.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:a.mastery.thresholdInvalid}),o&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:o})]})}var br=a.i(393045);function bs(){let{t:a}=(0,d.b)(),[e,i]=(0,c.useState)({gradeRecognitionMode:"fixed",fixedGradeSemester:null}),[j,k]=(0,c.useState)(null),[l,m]=(0,c.useState)(!0),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(null),r=(0,c.useRef)(0),s=(0,c.useCallback)(async()=>{let b=++r.current;m(!0),q(null);try{let a=await f.k.get("/api/user");if(b!==r.current)return;let c={gradeRecognitionMode:a.gradeRecognitionMode??"fixed",fixedGradeSemester:a.fixedGradeSemester??null};i(c),k(c)}catch(c){if(b!==r.current)return;q(a.questionGrade.loadFailed),h.V.error("[QuestionGradeSetting]","加载录入年级规则失败",{error:(0,g.Z)(c)})}finally{b===r.current&&m(!1)}},[a.questionGrade.loadFailed]);(0,c.useEffect)(()=>{s()},[s]);let t=async()=>{o(!0),q(null);try{let b=await f.k.patch("/api/user",e),c={gradeRecognitionMode:b.gradeRecognitionMode??e.gradeRecognitionMode,fixedGradeSemester:b.fixedGradeSemester??null};i(c),k(c),q(a.importFlow.preferenceSaved)}catch(b){q(a.importFlow.preferenceSaveFailed),h.V.error("[QuestionGradeSetting]","保存录入年级规则失败",{error:(0,g.Z)(b)})}finally{o(!1)}},u=l||n||null===j,v=j?.gradeRecognitionMode===e.gradeRecognitionMode&&j?.fixedGradeSemester===e.fixedGradeSemester;return(0,b.jsxs)("div",{className:"space-y-3 border-t pt-4",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{htmlFor:"question-grade-mode",children:a.questionGrade.label}),(0,b.jsxs)("select",{id:"question-grade-mode",value:e.gradeRecognitionMode,disabled:u,onChange:a=>{i({...e,gradeRecognitionMode:a.target.value}),q(null)},className:"h-10 w-full rounded-md border border-input bg-background px-3 text-sm disabled:opacity-50",children:[(0,b.jsx)("option",{value:"fixed",children:a.questionGrade.fixed}),(0,b.jsx)("option",{value:"ai",children:a.questionGrade.ai})]})]}),"fixed"===e.gradeRecognitionMode&&(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{htmlFor:"question-fixed-grade",children:a.editor.gradeSemester}),(0,b.jsx)(br.f,{id:"question-fixed-grade",value:e.fixedGradeSemester??"",disabled:u,onChange:a=>{i({...e,fixedGradeSemester:a||null}),q(null)}})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"fixed"===e.gradeRecognitionMode?a.questionGrade.fixedDescription:a.questionGrade.aiDescription}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:a.questionGrade.description}),(0,b.jsxs)(y.f,{type:"button",variant:"outline",size:"sm",disabled:u||v,onClick:t,children:[(l||n)&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),a.questionGrade.save]}),!l&&null===j&&(0,b.jsx)(y.f,{type:"button",variant:"outline",size:"sm",onClick:s,children:a.importFlow.retryLoad}),p&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",role:"status",children:p})]})}function bt(){let{t:a}=(0,d.b)();return(0,b.jsx)(bm,{field:"enableSvgAnimation",label:a.importFlow.enableSvgAnimation,description:a.importFlow.enableSvgAnimationDesc})}function bu({value:a,onChange:c,disabled:e}){let{t:f}=(0,d.b)();return(0,b.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,b.jsx)(ao.f,{htmlFor:"app-time-zone",children:f.settings.general.timeZoneLabel}),(0,b.jsx)(an.f,{id:"app-time-zone",value:a,onChange:a=>c(a.target.value),disabled:e,list:"app-time-zones",placeholder:"Asia/Shanghai"}),(0,b.jsx)("datalist",{id:"app-time-zones",children:["Asia/Shanghai","Asia/Hong_Kong","Asia/Tokyo","Asia/Singapore","Europe/London","America/New_York","America/Los_Angeles","UTC"].map(a=>(0,b.jsx)("option",{value:a},a))}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:f.settings.general.timeZoneDesc})]})}function bv({config:a,setConfig:c,isAdmin:e,disabled:f}){let{t:g,language:h,setLanguage:i}=(0,d.b)(),{timeZone:j}=(0,v.M)(),k=a=>c(b=>({...b,timeouts:{...b.timeouts,analyze:1e3*a}}));return(0,b.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:g.settings?.language||"Language"}),(0,b.jsxs)(aP.d,{value:h,onValueChange:a=>i(a),children:[(0,b.jsx)(aP.P,{children:(0,b.jsx)(aP.U,{})}),(0,b.jsxs)(aP.r,{children:[(0,b.jsx)(aP.T,{value:"zh",children:"中文 (Chinese)"}),(0,b.jsx)(aP.T,{value:"en",children:"English"})]})]})]}),(0,b.jsx)(bu,{value:a.timeZone??j,onChange:a=>c(b=>({...b,timeZone:a})),disabled:!e||f}),e&&(0,b.jsxs)("div",{className:"space-y-2 pt-4 border-t",children:[(0,b.jsx)(ao.f,{children:g.settings?.general?.timeoutLabel||"AI Analysis Timeout (Seconds)"}),(0,b.jsx)(an.f,{type:"number",value:a.timeouts?.analyze?a.timeouts.analyze/1e3:"",onChange:a=>{let b=""===a.target.value?0:parseInt(a.target.value);k(isNaN(b)?0:b)},onBlur:()=>{let b=(a.timeouts?.analyze||0)/1e3,c=Math.min(600,Math.max(120,b));c!==b&&k(c)},min:120,max:600}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:g.settings?.general?.timeoutDesc||"Increase this value if you experience frequent timeouts during AI analysis."})]}),(0,b.jsx)(bo,{}),(0,b.jsx)(bs,{}),(0,b.jsx)(bt,{}),(0,b.jsx)(bn,{}),(0,b.jsx)(bl.f,{}),(0,b.jsx)(bq,{})]})}var bw=a.i(403512),bx=a.i(591119),by=a.i(481132);function bz(){let{t:a}=(0,d.b)(),{groups:e,loading:g,refetch:i}=(0,by.f)(),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(!1),n=async()=>{let b=j.trim();if(b){m(!0);try{await f.k.post("/api/paper-groups",{name:b}),k(""),L.c.success(a.common?.messages?.saveSuccess||"Saved"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to add group",{error:b}),L.c.error(a.common?.messages?.saveFailed||"Failed to save")}finally{m(!1)}}},o=async(b,c)=>{let d=window.prompt(a.settings?.paperGroups?.renamePrompt||"Rename group",c);if(d&&d.trim()!==c)try{await f.k.patch(`/api/paper-groups/${b}`,{name:d.trim()}),L.c.success(a.common?.messages?.saveSuccess||"Saved"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to rename group",{error:b}),L.c.error(a.common?.messages?.saveFailed||"Failed to save")}},p=async(b,c)=>{try{await f.k.patch(`/api/paper-groups/${b}`,{isActive:!c}),L.c.success(a.common?.messages?.saveSuccess||"Saved"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to toggle group",{error:b}),L.c.error(a.common?.messages?.saveFailed||"Failed to save")}},q=async(b,c,d)=>{if(d>0){let e=(a.settings?.paperGroups?.deleteConfirmWithItems||'Group "{name}" has {count} questions. Deleting will clear their group assignment. Continue?').replace("{name}",c).replace("{count}",String(d));if(!await (0,L.u)(e,{destructive:!0}))return;try{await f.k.delete(`/api/paper-groups/${b}?clear=true`),L.c.success(a.common?.messages?.deleteSuccess||"Deleted"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to delete group",{error:b}),L.c.error(a.common?.messages?.deleteFailed||"Delete failed")}return}let e=(a.settings?.paperGroups?.deleteConfirm||'Delete group "{name}"?').replace("{name}",c);if(await (0,L.u)(e,{destructive:!0}))try{await f.k.delete(`/api/paper-groups/${b}`),L.c.success(a.common?.messages?.deleteSuccess||"Deleted"),i()}catch(b){h.V.error("[PaperGroupSettings]","Failed to delete group",{error:b}),L.c.error(a.common?.messages?.deleteFailed||"Delete failed")}};return g?(0,b.jsx)(bx.N,{children:(0,b.jsx)(bx.O,{className:"py-12 flex items-center justify-center",children:(0,b.jsx)(x.f,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):(0,b.jsxs)(bx.N,{children:[(0,b.jsxs)(bx.Y,{children:[(0,b.jsxs)(bx.v,{className:"flex items-center gap-2 text-lg",children:[(0,b.jsx)(E.f,{className:"h-5 w-5"}),a.settings?.paperGroups?.title||"Paper Groups"]}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:a.settings?.paperGroups?.desc||"Customize paper groups like Unit Test, Midterm, Final. Default groups A/B/Other can be renamed but not deleted."})]}),(0,b.jsxs)(bx.O,{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)(an.f,{value:j,onChange:a=>k(a.target.value),placeholder:a.settings?.paperGroups?.addPlaceholder||"e.g. Unit Test",onKeyDown:a=>{"Enter"===a.key&&n()}}),(0,b.jsxs)(y.f,{onClick:n,disabled:l||!j.trim(),children:[l?(0,b.jsx)(x.f,{className:"h-4 w-4 animate-spin"}):(0,b.jsx)(bw.f,{className:"h-4 w-4 mr-1"}),a.common?.add||"Add"]})]}),(0,b.jsx)("div",{className:"space-y-2",children:e.map(c=>(0,b.jsxs)("div",{className:`flex items-center justify-between rounded-lg border p-3 ${!c.isActive?"opacity-50":""}`,children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("span",{className:"font-medium",children:c.name}),c.key&&(0,b.jsx)(al.f,{variant:"secondary",className:"text-xs",children:a.settings?.paperGroups?.systemBadge||"Default"}),!c.isActive&&(0,b.jsx)(al.f,{variant:"outline",className:"text-xs",children:a.common?.inactive||"Inactive"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:()=>o(c.id,c.name),children:a.common?.rename||"Rename"}),(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:()=>p(c.id,c.isActive),children:c.isActive?a.common?.deactivate||"Deactivate":a.common?.activate||"Activate"}),!c.key&&(0,b.jsx)(y.f,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>q(c.id,c.name,c._count?.errorItems||0),children:(0,b.jsx)(av.f,{className:"h-4 w-4"})})]})]},c.id))})]})]})}var bA=a.i(489970),bB=a.i(585650),bC=a.i(533838),bD=a.i(986708),bE=a.i(429246);async function bF(a,b){try{return await navigator.clipboard.writeText(a),!0}catch{return b(a),!1}}async function bG(){try{return await navigator.clipboard.readText()}catch{return null}}function bH({value:a,defaultValue:e,onChange:f,onReset:g,title:h,variables:i}){let{t:j}=(0,d.b)(),[k,l]=(0,c.useState)(!1),m=(0,c.useMemo)(()=>{let b=new Set(Array.from(new Set(Array.from(a.matchAll(/\{\{(\w+)\}\}/g),a=>a[1]))));return i.filter(a=>!b.has(a.name))},[a,i]),n=async()=>{await bF(a,a=>window.prompt(j.settings?.prompts?.copyManual||"Copy the template manually:",a))&&(l(!0),setTimeout(()=>l(!1),1500),L.c.success(j.settings?.prompts?.copied||"Template copied"))},o=async()=>{let b=await bG();null===b?L.c.error(j.settings?.prompts?.pasteFailed||"Cannot read the clipboard. Paste into the box manually."):b.trim()?(!a.trim()||await (0,L.u)(j.settings?.prompts?.pasteConfirm||"Replace the current template with the clipboard content?",{destructive:!0}))&&(f(b),L.c.success(j.settings?.prompts?.pasted||"Template replaced from the clipboard")):L.c.error(j.settings?.prompts?.pasteEmpty||"The clipboard is empty")},p=async()=>{await (0,L.u)(j.settings?.prompts?.resetConfirm||"Are you sure you want to reset to default?",{destructive:!0})&&g()};return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,b.jsx)(ao.f,{className:"text-base font-semibold",children:h}),(0,b.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:n,children:[(0,b.jsx)(bB.f,{className:"w-4 h-4 mr-2"}),k?j.settings?.prompts?.copied||"Copied":j.settings?.prompts?.copy||"Copy"]}),(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:o,children:[(0,b.jsx)(bA.f,{className:"w-4 h-4 mr-2"}),j.settings?.prompts?.pasteReplace||"Replace with clipboard"]}),(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:p,children:[(0,b.jsx)(bC.f,{className:"w-4 h-4 mr-2"}),j.settings?.prompts?.reset||"Reset Default"]})]})]}),(0,b.jsxs)("div",{className:"bg-amber-50 dark:bg-amber-950/40 border border-amber-200 dark:border-amber-900 rounded-md p-3 flex items-start gap-3 text-amber-900 dark:text-amber-200 text-sm",children:[(0,b.jsx)(bD.f,{className:"w-4 h-4 mt-0.5 shrink-0"}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"font-medium",children:j.settings?.prompts?.customizeTitle||"Tailor the prompt to your child"}),(0,b.jsx)("p",{children:j.settings?.prompts?.customizeBody||"Copy the default template, rewrite the role, tone and analysis steps to fit your child's grade, weak points and learning habits, then paste it back. Keep the {{variables}}: they are filled with each question's data."})]})]}),(0,b.jsxs)("div",{className:"space-y-2 border rounded-md p-3 bg-background",children:[(0,b.jsxs)("h4",{className:"text-xs font-medium flex items-center gap-1.5 mb-2",children:[(0,b.jsx)(ab,{className:"h-3.5 w-3.5"}),j.settings?.prompts?.variables||"Available Variables"]}),(0,b.jsx)("div",{className:"space-y-1.5",children:i.map(a=>(0,b.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-2 text-xs py-1",children:[(0,b.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] shrink-0",children:`{{${a.name}}}`}),(0,b.jsx)("span",{className:"text-muted-foreground",children:a.description})]},a.name))}),m.length>0&&(0,b.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300 pt-1",children:(j.settings?.prompts?.missingVariables||"Not referenced in this template: {names}. The app still adds the matching rules, but the data will not reach the model.").replace("{names}",m.map(a=>`{{${a.name}}}`).join("、"))})]}),(0,b.jsx)(bE.f,{value:a,onChange:a=>f(a.target.value),className:"font-mono text-xs min-h-[400px]",placeholder:e,"aria-label":h})]})}let bI="[REDACTED]",bJ=/api[-_]?key|password|passwd|secret|authorization|cookie|credential|private[-_]?key|^(access|refresh|id|auth|api|bearer|session|csrf|setup)?[-_]?token$/i,bK=Symbol.for("wrong-notebook.debug-log");function bL(){let a=globalThis,b=a[bK];return b||(b={enabledAt:null,entries:[],totalSize:0,dropped:0},a[bK]=b),b}function bM(a){let b=a.replace(/data:([\w.+-]+\/[\w.+-]+);base64,[A-Za-z0-9+/=]+/g,(a,b)=>`[data:${b}, ${a.length} chars]`).replace(/(Bearer\s+)[\w\-.~+/]+=*/gi,`$1${bI}`).replace(/\bsk-[A-Za-z0-9_-]{8,}/g,bI).replace(/([?&](?:key|api_key|apikey|token|access_token)=)[^&\s"']+/gi,`$1${bI}`);return b.length>1e4&&(b=`${b.slice(0,1e4)}…[truncated ${b.length-1e4} chars]`),b}function bN(a,b,c,d=new Date){if(function(a=Date.now()){let b=bL();return null!==b.enabledAt&&(!(a-b.enabledAt>=864e5)||(b.enabledAt=null,!1))}(d.getTime()))try{let e={...function a(b,c=0,d=new WeakSet){if(null==b)return b;if("string"==typeof b)return bM(b);if("number"==typeof b||"boolean"==typeof b)return b;if("bigint"==typeof b)return b.toString();if("function"==typeof b||"symbol"==typeof b)return String(b);if(b instanceof Date)return b.toISOString();if(b instanceof Error){let e={name:b.name,message:bM(b.message)};return b.stack&&(e.stack=bM(b.stack)),void 0!==b.code&&(e.code=a(b.code,c+1,d)),void 0!==b.status&&(e.status=a(b.status,c+1,d)),void 0!==b.cause&&c<8&&(e.cause=a(b.cause,c+1,d)),e}if("object"!=typeof b)return String(b);if(d.has(b))return"[Circular]";if(c>=8)return"[Object]";if(d.add(b),Array.isArray(b)){let e=b.slice(0,100).map(b=>a(b,c+1,d));return b.length>100&&e.push(`…[${b.length-100} more items]`),e}return ArrayBuffer.isView(b)||b instanceof ArrayBuffer?`[Binary ${b.byteLength} bytes]`:Object.fromEntries(Object.entries(b).map(([b,e])=>[b,bJ.test(b)&&null!=e&&""!==e?bI:a(e,c+1,d)]))}(b),time:d.toISOString(),level:a,msg:bM(c)},f=JSON.stringify(e).length,g=bL();for(g.entries.push({entry:e,size:f}),g.totalSize+=f;g.entries.length>5e3||g.totalSize>0x1400000&&g.entries.length>1;){let a=g.entries.shift();if(!a)break;g.totalSize-=a.size,g.dropped+=1}}catch{}}let bO={trace:10,debug:20,info:30,warn:40,error:50,fatal:60};function bP(a,b={}){let c,d=bO[a],e=(c=process.env.LOG_LEVEL?.toLowerCase())&&void 0!==bO[c]?bO[c]:bO.info;return(c,f)=>{let g,h,i=new Date;if("string"==typeof c?(g={},h=c):(g=c,h=f||""),bN(a,{...b,...g},h,i),!(d<e)){let c=JSON.stringify({level:a,time:i.toISOString(),...b,...g,msg:h});switch(a){case"error":case"fatal":console.error(c);break;case"warn":console.warn(c);break;default:console.log(c)}}}}(function a(b={}){return b.module,{trace:bP("trace",b),debug:bP("debug",b),info:bP("info",b),warn:bP("warn",b),error:bP("error",b),fatal:bP("fatal",b),child:c=>a({...b,...c}),box:(a,c,d="📋")=>{bN("info",{...b,..."string"==typeof c?{content:c}:c},a);{let d="string"==typeof c?{content:c}:c||{};console.log(JSON.stringify({level:"info",time:new Date().toISOString(),...b,title:a,...d,msg:a}));return}},divider:(a="-")=>{}}})({env:"production"}).child({module:"ai:prompts"});let bQ=`填写题目类型,只能是以下 key 之一:single_choice(单选题)、multiple_choice(多选题)、true_false(判断题)、fill_blank(填空题)、calculation(计算题)、solution(解答题)、reading(阅读理解)、cloze(完形填空)、writing(写作)、other(其他)。
2
2
  若题型不明确,填 other。`,bR=`请参考《高思学校竞赛数学导引》(每讲分兴趣篇、拓展篇、超越篇,题目左侧标 1~5 颗星)的星级标准,结合题目所在年级评定难度:
3
3
  - 1 星:课本基础题,直接套用概念、公式或简单计算即可(相当于兴趣篇前几题)。
4
4
  - 2 星:校内拔高题,需要两三步推理或简单综合(相当于兴趣篇后几题)。
@@ -261,6 +261,6 @@ ${bQ}
261
261
  ${bT}
262
262
 
263
263
  {{grade_instruction}}
264
- {{provider_hints}}`;var bX=a.i(62832);function bY({config:a,onUpdate:c}){let{t:e}=(0,d.b)(),f=a.prompts?.analyze||bU,g=a.prompts?.similar||bV,h=a.prompts?.reanswer||bW,i=e.settings?.prompts?.vars,j=[{name:"language_instruction",description:i?.languageInstruction||"Language instructions."},{name:"knowledge_points_list",description:i?.knowledgePointsList||"Knowledge point tags for the subject."},{name:"grade_instruction",description:i?.gradeInstruction||"Grade and semester guidance."},{name:"provider_hints",description:i?.providerHints||"Provider compatibility hints."}],k=[{name:"original_question",description:i?.originalQuestion||"The full text of the original question."},{name:"knowledge_points",description:i?.knowledgePoints||"List of knowledge points to test."},{name:"difficulty_level",description:i?.difficultyLevel||"Target difficulty level."},{name:"difficulty_instruction",description:i?.difficultyInstruction||"Specific writing instructions for the target difficulty."},{name:"language_instruction",description:i?.languageInstructionShort||"Language formatting instructions."},{name:"figure_instruction",description:i?.figureInstruction||"Instructions for redrawing the original figure."},{name:"grade_instruction",description:i?.gradeInstruction||"Grade and semester guidance."}],l=[{name:"question_text",description:i?.questionText||"The corrected question text."},{name:"subject_hint",description:i?.subjectHint||"Subject of the question."},{name:"knowledge_points_rule",description:i?.knowledgePointsRule||"Candidate knowledge points to choose from."},{name:"language_instruction",description:i?.languageInstruction||"Language instructions."},{name:"grade_instruction",description:i?.gradeInstruction||"Grade and semester guidance."},{name:"provider_hints",description:i?.providerHints||"Provider compatibility hints."}];return(0,b.jsx)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:(0,b.jsxs)(aj.i,{defaultValue:"analyze",className:"w-full",children:[(0,b.jsxs)(aj.U,{className:"grid w-full grid-cols-3",children:[(0,b.jsx)(aj.k,{value:"analyze",className:"text-xs sm:text-sm",children:e.settings?.prompts?.analysisTab||"Analysis Prompt"}),(0,b.jsx)(aj.k,{value:"reanswer",className:"text-xs sm:text-sm",children:e.settings?.prompts?.reanswerTab||"Solving Prompt"}),(0,b.jsx)(aj.k,{value:"similar",className:"text-xs sm:text-sm",children:e.settings?.prompts?.similarTab||"Similar Question Prompt"})]}),(0,b.jsx)(aj.S,{value:"analyze",className:"py-4",children:(0,b.jsx)(bH,{value:f,defaultValue:bU,onChange:a=>c("analyze",a),onReset:()=>c("analyze",bU),title:e.settings?.prompts?.customAnalysis||"Custom Analysis Template",variables:j})}),(0,b.jsx)(aj.S,{value:"reanswer",className:"py-4",children:(0,b.jsx)(bH,{value:h,defaultValue:bW,onChange:a=>c("reanswer",a),onReset:()=>c("reanswer",bW),title:e.settings?.prompts?.customReanswer||"Custom Solving Template",variables:l})}),(0,b.jsx)(aj.S,{value:"similar",className:"py-4",children:(0,b.jsx)(bH,{value:g,defaultValue:bV,onChange:a=>c("similar",a),onReset:()=>c("similar",bV),title:e.settings?.prompts?.customSimilar||"Custom Similar Question Template",variables:k})})]})})}bX.I.join("、"),bX.r.join("、");var bZ=a.i(867147);function b$({open:a,onOpenChange:e,onConfirm:f}){let{t:g}=(0,d.b)(),[h,i]=(0,c.useState)(!1),[j,k]=(0,c.useState)(!1),l=async()=>{k(!0);try{await f(),i(!1),e(!1)}catch{}finally{k(!1)}};return(0,b.jsx)(z.N,{open:a,onOpenChange:a=>!j&&e(a),children:(0,b.jsxs)(z.d,{className:"w-[calc(100vw-2rem)] sm:max-w-lg",children:[(0,b.jsxs)(z.s,{children:[(0,b.jsx)(z.F,{children:g.eula.dialogTitle}),(0,b.jsx)(z.C,{children:g.eula.dialogDesc})]}),(0,b.jsx)(bZ.f,{checked:h,onCheckedChange:i,disabled:j}),(0,b.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[(0,b.jsx)(y.f,{variant:"outline",onClick:()=>e(!1),disabled:j,children:g.eula.cancel}),(0,b.jsxs)(y.f,{onClick:l,disabled:!h||j,children:[j&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),g.eula.accept]})]})]})})}function b_({endpoint:a,retentionDays:e,disabled:f,onSave:g}){let{t:h}=(0,d.b)(),i=h.telemetrySettings,[j,k]=(0,c.useState)(""!==a),[l,m]=(0,c.useState)(a),[n,o]=(0,c.useState)(String(e)),p=Number(n),q=Number.isInteger(p)&&p>=1&&p<=365;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(ao.f,{htmlFor:"telemetry-endpoint",children:i.endpoint}),j?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(an.f,{id:"telemetry-endpoint",value:l,placeholder:i.endpointPlaceholder,disabled:f,onChange:a=>m(a.target.value)}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:i.endpointHint})]}):(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:i.endpointDefault}),(0,b.jsx)(y.f,{variant:"link",size:"sm",className:"h-auto p-0",disabled:f,onClick:()=>k(!0),children:i.endpointCustomize})]})]}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(ao.f,{htmlFor:"telemetry-retention",children:i.retentionDays}),(0,b.jsx)(an.f,{id:"telemetry-retention",type:"number",min:1,max:365,className:"w-32",value:n,disabled:f,onChange:a=>o(a.target.value)})]}),(0,b.jsx)(y.f,{size:"sm",variant:"outline",disabled:f||!q,onClick:()=>g({endpoint:l.trim(),retentionDays:p}),children:i.save})]})}function b0({events:a,errors:c,disabled:e,onClear:f}){let{t:g}=(0,d.b)(),{timeZone:h}=(0,v.M)(),i=g.telemetrySettings,j=a=>(0,ak.r)(a,"MM-dd HH:mm",h),k=a=>a?i.forwarded:i.notForwarded,l=0===a.length&&0===c.length;return(0,b.jsxs)("details",{className:"rounded-md border p-3 text-sm",children:[(0,b.jsx)("summary",{className:"cursor-pointer font-medium",children:i.recentTitle}),(0,b.jsxs)("div",{className:"mt-3 space-y-3",children:[l&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:i.recentEmpty}),a.length>0&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:i.recentEvents}),(0,b.jsx)("ul",{className:"space-y-1 font-mono text-xs",children:a.map(a=>(0,b.jsxs)("li",{className:"break-all",children:[j(a.createdAt)," ",a.name," ",a.payload??""," · ",k(a.forwardedAt)]},a.id))})]}),c.length>0&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:i.recentErrors}),(0,b.jsx)("ul",{className:"space-y-1 font-mono text-xs",children:c.map(a=>(0,b.jsxs)("li",{className:"break-all",children:[j(a.createdAt)," ",a.kind," ",a.scope," ",a.name," #",a.fingerprint,a.path?` ${a.path}`:"",a.message?` — ${a.message}`:""," · ",k(a.forwardedAt)]},a.id))})]}),(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:f,disabled:e||l,children:[(0,b.jsx)(av.f,{className:"mr-2 h-4 w-4"}),i.clear]})]})]})}function b1({id:a,label:c,description:d,checked:e,disabled:f,onCheckedChange:g}){return(0,b.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(ao.f,{htmlFor:a,className:"font-medium",children:c}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d})]}),(0,b.jsx)(am.f,{id:a,checked:e,disabled:f,onCheckedChange:g,className:"shrink-0"})]})}let b2="/api/admin/telemetry";async function b3(a){return await f.k.post("/api/admin/eula/accept",{version:a}),f.k.post(b2,{forwarding:!0})}function b4(a){return f.k.post(b2,a)}var b5=a.i(585982);function b6(){let{t:a}=(0,d.b)(),{timeZone:e}=(0,v.M)(),i=a.telemetrySettings,{data:j,update:k,enableWithConsent:l,clear:m}=function(){let[a,b]=(0,c.useState)(null),d=(0,c.useCallback)(async()=>{try{b(await f.k.get(b2))}catch(a){h.V.warn("[TelemetrySettings]","Failed to load telemetry status",{error:a})}},[]);return(0,c.useEffect)(()=>{d()},[d]),{data:a,update:async a=>b(await b4(a)),enableWithConsent:async a=>b(await b3(a)),clear:async()=>b(await f.k.delete(b2))}}(),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(!1),r=async(a,b)=>{o(!0);try{await a(),L.c.success(b)}catch(a){throw h.V.error("[TelemetrySettings]","Telemetry action failed",{error:a}),L.c.error("INVALID_TELEMETRY_ENDPOINT"===(0,g.d)(a)?i.invalidEndpoint:i.failed),a}finally{o(!1)}},s=a=>r(async()=>{await k(a),(0,b5.z)("settings_changed",{section:"telemetry"})},i.saved).catch(()=>void 0);if(!j)return null;let t=j.lockedByEnv,u=n||t,w=a=>(0,ak.r)(a,"yyyy-MM-dd HH:mm",e),x=async()=>{await (0,L.u)(i.clearConfirm)&&r(m,i.cleared).catch(()=>void 0)},y=j.lastFlushAt?i.lastFlush.replace("{time}",w(j.lastFlushAt)):i.neverFlushed;return j.lastAttempt?.status==="failed"&&(y=i.lastAttemptFailed.replace("{status}",String(j.lastAttempt.httpStatus??"network"))),j.lastAttempt?.status==="stopped"&&(y=i.lastAttemptStopped),(0,b.jsxs)("div",{className:"space-y-4 rounded-lg border p-4",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("p",{className:"flex items-center gap-2 font-medium",children:[(0,b.jsx)(ba,{className:"h-4 w-4"}),i.title]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:i.desc})]}),t&&(0,b.jsx)("p",{className:"text-xs text-orange-600",children:i.lockedByEnv}),j.consentPending&&(0,b.jsx)("p",{className:"text-xs text-orange-600",children:i.consentPending}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:[j.eula.acceptedVersion?i.eulaStatus.replace("{version}",j.eula.acceptedVersion).replace("{time}",j.eula.acceptedAt?w(j.eula.acceptedAt):"-"):i.eulaNotAccepted," ",(0,b.jsx)("a",{href:"/eula",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:i.viewEula})]}),(0,b.jsx)(b1,{id:"telemetry-forwarding",label:i.forwarding,description:i.forwardingDesc,checked:j.forwarding,disabled:u,onCheckedChange:a=>{a&&(!j.eula.acceptedVersion||j.consentPending)?q(!0):s({forwarding:a})}}),j.forwarding&&(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:[i.pending.replace("{count}",String(j.pending))," · ",y]}),(0,b.jsx)(b1,{id:"telemetry-recording",label:i.recording,description:i.recordingDesc,checked:j.recording,disabled:u,onCheckedChange:a=>s({recording:a})}),(0,b.jsx)(b1,{id:"telemetry-errors",label:i.errors,description:i.errorsDesc,checked:j.errors,disabled:u,onCheckedChange:a=>s({errors:a})}),(0,b.jsx)(b_,{endpoint:j.endpoint,retentionDays:j.retentionDays,disabled:u,onSave:s}),(0,b.jsx)(b0,{events:j.events,errors:j.errorRecords,disabled:n,onClear:x}),(0,b.jsx)(b$,{open:p,onOpenChange:q,onConfirm:()=>r(()=>l(j.eula.current),i.enabled)})]})}var b7=a.i(738835),b8=a.i(676330),b9=a.i(206194),ca=a.i(190622),cb=a.i(975484),cc=a.i(294655);function cd({config:a,setConfig:e,saving:i,onSave:j}){let{t:k,language:l}=(0,d.b)(),m=k.settings.tts,[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(null),r=a.tts?.mode??"browser",s=(0,cc.y)(r)?r:null,t=s?a.tts?.[s]:void 0,u=(a,b)=>{s&&e(c=>({...c,tts:{...c.tts,[s]:{...c.tts?.[s],[a]:b}}}))},v=!!s&&(0,cc.S)(s),w=s?(0,cc.L)(a,s):void 0,z=v?t?.apiKey:w?.apiKey,A=async()=>{(0,cb.p)(),o(!0),q(null);try{await j();let{id:a,version:b}=await f.k.post("/api/tts",{text:m.previewText,language:l},{timeout:12e4,recoverable:!0}),c=(0,cb.l)();if(!c)return;c.src=`/api/tts/${a}?v=${b}`,c.playbackRate=1,await c.play()}catch(b){h.V.error("[TtsSettings]","Preview failed",{error:b});let a=(0,g.d)(b);L.c.error("TTS_NOT_CONFIGURED"===a?m.notConfigured:"TTS_PROVIDER_ERROR"===a?m.providerError:m.previewFailed),q((0,g.L)(b)??null)}finally{o(!1)}};return(0,b.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:m.title}),(0,b.jsxs)(aP.d,{value:r,onValueChange:a=>e(b=>({...b,tts:{...b.tts,mode:a}})),children:[(0,b.jsx)(aP.P,{children:(0,b.jsx)(aP.U,{})}),(0,b.jsx)(aP.r,{children:cc.l.map(a=>(0,b.jsx)(aP.T,{value:a,children:m.modes[a]},a))})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:s?m.cloudHint:m.browserHint})]}),s&&(0,b.jsxs)("div",{className:"space-y-3 animate-in fade-in slide-in-from-top-2",children:[cc.D[s]&&(0,b.jsxs)("div",{className:"rounded-md border border-green-200 bg-green-50 p-3 text-xs text-green-800 dark:border-green-900 dark:bg-green-950/40 dark:text-green-300",children:[m.freeTrial," ",(0,b.jsx)("a",{href:cc.D[s],target:"_blank",rel:"noopener noreferrer",className:"underline",children:m.freeTrialLink})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(b8.f,{label:"openai"===s?"OpenAI API Key":v?m.speechApiKey:`${(0,ca.z)(s,l)} API Key`,href:cc.r[s].apiKey,linkText:k.settings.ai.docLinks.apiKey}),(0,b.jsx)(aO.f,{value:z||"",onChange:a=>{var b;return b=a.target.value,void(s&&(v?u("apiKey",b):e(a=>({...a,[s]:{...a[s],apiKey:b}}))))},placeholder:"qwen"===s?"sk-sp-...":v?"":"sk-..."}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:m.apiKeyHint[s]})]}),(0,b.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(b8.f,{label:m.model,href:cc.r[s].model,linkText:m.docs}),(0,b.jsx)(an.f,{value:t?.model||"",onChange:a=>u("model",a.target.value),placeholder:cc.C[s].model})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(b8.f,{label:m.voice,href:cc.r[s].voice,linkText:m.voiceList}),(0,b.jsx)(an.f,{value:t?.voice||"",onChange:a=>u("voice",a.target.value),placeholder:cc.C[s].voice})]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:m.voiceHint[s]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(b8.f,{label:m.endpoint,href:cc.r[s].endpoint,linkText:m.docs}),(0,b.jsx)(an.f,{value:t?.endpoint||"",onChange:a=>u("endpoint",a.target.value),placeholder:(0,cc.E)(s,w)}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:m.endpointHint})]})]},s),(0,b.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[s&&(0,b.jsxs)(y.f,{variant:"outline",onClick:A,disabled:i||n,className:"sm:w-auto",children:[n?(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,b.jsx)(b7.f,{className:"mr-2 h-4 w-4"}),m.preview]}),(0,b.jsxs)(y.f,{onClick:()=>void j(),disabled:i||n,className:"flex-1",children:[i&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),m.save]})]}),s&&p&&(0,b.jsx)("div",{className:"rounded-md border border-red-200 bg-red-50 p-2 dark:border-red-900 dark:bg-red-950/40",children:(0,b.jsx)(b9.f,{detail:p})})]})}var ce=a.i(439830);function cf({value:a,icon:c,label:d}){return(0,b.jsxs)(aj.k,{value:a,className:"px-2 sm:px-3",children:[c,(0,b.jsx)("span",{className:"hidden sm:inline",children:d})]})}function cg(){let{setTimeZone:a}=(0,v.M)(),{data:g}=(0,e.useSession)(),i=g?.user?.role==="admin",j=g?.user?.id??"",{t:k}=(0,d.b)(),l=(0,w.useRouter)(),[m,n]=(0,c.useState)(!1),o=(0,c.useRef)(null),[p,q]=(0,c.useState)(!1),[r,s]=(0,c.useState)(!1),[t,u]=(0,c.useState)({aiProvider:"minimax"}),A=(0,c.useCallback)(async()=>{s(!0);try{u(await f.k.get("/api/settings"))}catch(a){h.V.error("[SettingsDialog]","Failed to fetch settings",{error:a})}finally{s(!1)}},[]);(0,c.useEffect)(()=>{m&&A()},[m,A]);let C=async b=>{let c=(0,ce.f)(t,k);if(c)return void L.c.error(c);q(!0);try{let c=await f.k.post("/api/settings",t);u(c),a(c.timeZone||ak.J),L.c.success(k.settings?.messages?.saved||"Settings saved"),(0,b5.z)("settings_changed",{section:b}),o.current?.scrollTo({top:0,behavior:"smooth"})}catch(a){h.V.error("[SettingsDialog]","Failed to save settings",{error:a}),L.c.error(k.settings?.messages?.saveFailed||"Failed to save")}finally{q(!1)}},D=(a,c)=>(0,b.jsxs)(y.f,{onClick:()=>C(c),disabled:p,className:"w-full",children:[p&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),a]});return(0,b.jsxs)(z.N,{open:m,onOpenChange:n,children:[(0,b.jsx)(z.a,{asChild:!0,children:(0,b.jsxs)(y.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,b.jsx)(ag,{className:"h-5 w-5"}),(0,b.jsx)("span",{className:"sr-only",children:k.settings?.title||"Settings"})]})}),(0,b.jsxs)(z.d,{ref:o,className:"w-[calc(100vw-2rem)] sm:max-w-[900px] max-h-[85vh] overflow-y-auto",children:[(0,b.jsxs)(z.s,{children:[(0,b.jsx)(z.F,{children:k.settings?.title||"Settings"}),(0,b.jsx)(z.C,{children:k.settings?.desc||"Manage your preferences and data."})]}),(0,b.jsxs)(aj.i,{defaultValue:"general",className:"w-full",children:[(0,b.jsxs)(aj.U,{className:`grid w-full grid-cols-4 ${i?"sm:grid-cols-7":"sm:grid-cols-4"} gap-1 h-auto`,children:[(0,b.jsx)(cf,{value:"general",icon:(0,b.jsx)(ac.f,{className:"h-4 w-4 sm:mr-2"}),label:k.settings?.tabs?.general||"General"}),(0,b.jsx)(cf,{value:"account",icon:(0,b.jsx)(ah.f,{className:"h-4 w-4 sm:mr-2"}),label:k.settings?.tabs?.account||"Account"}),i&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(cf,{value:"ai",icon:(0,b.jsx)(_,{className:"h-4 w-4 sm:mr-2"}),label:k.settings?.tabs?.ai||"AI Provider"}),(0,b.jsx)(cf,{value:"prompts",icon:(0,b.jsx)(ae,{className:"h-4 w-4 sm:mr-2"}),label:k.settings?.tabs?.prompts||"Prompts"}),(0,b.jsx)(cf,{value:"admin",icon:(0,b.jsx)(S,{className:"h-4 w-4 sm:mr-2"}),label:k.settings?.tabs?.admin||"User Management"})]}),(0,b.jsx)(cf,{value:"danger",icon:(0,b.jsx)(Z.f,{className:"h-4 w-4 sm:mr-2"}),label:k.settings?.tabs?.danger||"Danger"}),(0,b.jsx)(cf,{value:"about",icon:(0,b.jsx)(ab,{className:"h-4 w-4 sm:mr-2"}),label:k.settings?.tabs?.about||"About"})]}),(0,b.jsxs)(aj.S,{value:"general",className:"space-y-4 py-4",children:[(0,b.jsx)(bv,{config:t,setConfig:u,isAdmin:i,disabled:r||p}),(0,b.jsx)(bz,{}),i&&D(k.settings?.save||"Save Settings","general")]}),(0,b.jsxs)(aj.S,{value:"account",className:"space-y-4 py-4",children:[(0,b.jsx)(aS,{}),(0,b.jsx)(bb,{})]}),(0,b.jsxs)(aj.S,{value:"ai",className:"space-y-4 py-4",children:[(0,b.jsx)(aT.f,{config:t,setConfig:u,loading:r,saving:p,onSave:()=>C("ai")}),!r&&(0,b.jsx)(cd,{config:t,setConfig:u,saving:p,onSave:()=>C("tts")})]}),(0,b.jsxs)(aj.S,{value:"prompts",className:"space-y-4 py-4",children:[(0,b.jsx)(bY,{config:t,onUpdate:(a,b)=>u(c=>({...c,prompts:{...c.prompts,[a]:b}}))}),D(k.settings?.prompts?.save||"Save Prompt Settings","prompts")]}),i&&(0,b.jsxs)(aj.S,{value:"admin",className:"space-y-4 py-4",children:[(0,b.jsxs)(y.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{n(!1),l.push("/admin")},children:[(0,b.jsx)(B.f,{className:"h-4 w-4"}),k.admin?.dashboard?.title||"Admin Dashboard"]}),(0,b.jsxs)(y.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{n(!1),l.push("/setup")},children:[(0,b.jsx)(ai.f,{className:"h-4 w-4"}),k.setup.rerun]}),(0,b.jsx)(b6,{}),(0,b.jsx)(bk,{}),(0,b.jsx)(a1,{}),(0,b.jsx)("div",{className:"border-t pt-4",children:(0,b.jsx)(aC,{})})]}),(0,b.jsx)(aj.S,{value:"danger",className:"space-y-4 py-4",children:(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsx)(bg,{isAdmin:i,userId:j}),(0,b.jsx)(a5,{isAdmin:i}),(0,b.jsx)(a8,{isAdmin:i})]})}),(0,b.jsx)(aj.S,{value:"about",className:"space-y-4 py-4",children:(0,b.jsx)(aN,{})})]})]})]})}var ch=a.i(474215);function ci({enabled:a}){let{t:e}=(0,d.b)(),g=e.telemetrySettings,[i,j]=(0,c.useState)(!1),[k,l]=(0,c.useState)(""),[m,n]=(0,c.useState)(!1);if((0,c.useEffect)(()=>{if(!a)return;let b=!1;return f.k.get(`${b2}?view=notice`).then(a=>{b||(l(a.eula.current),j(a.showNotice))}).catch(a=>h.V.warn("[TelemetryNotice]","Failed to load telemetry notice",{error:a})),()=>{b=!0}},[a]),!a||!i)return null;let o=async()=>{try{await b3(k),j(!1),L.c.success(g.enabled)}catch(a){throw h.V.error("[TelemetryNotice]","Failed to enable forwarding",{error:a}),L.c.error(g.failed),a}};return(0,b.jsxs)("div",{className:"border-b bg-primary/5 print:hidden",children:[(0,b.jsxs)("div",{className:"mx-auto flex max-w-6xl flex-col gap-2 px-4 py-2 text-sm sm:flex-row sm:items-center md:px-8",children:[(0,b.jsx)("p",{className:"flex-1 text-muted-foreground",children:g.noticeText}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(y.f,{size:"sm",onClick:()=>n(!0),children:g.noticeEnable}),(0,b.jsxs)(y.f,{size:"sm",variant:"ghost",onClick:()=>{j(!1),b4({noticeDismissed:!0}).catch(a=>h.V.warn("[TelemetryNotice]","Failed to dismiss notice",{error:a}))},children:[(0,b.jsx)(ch.X,{className:"mr-1 h-4 w-4"}),g.noticeDismiss]})]})]}),(0,b.jsx)(b$,{open:m,onOpenChange:n,onConfirm:o})]})}var cj=a.i(505004);let ck={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]};ck.node;let cl=(0,F.f)(ck),cm={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]};cm.node;let cn=(0,F.f)(cm);var co=a.i(335732);let cp={system:cj.f,light:cn,dark:cl};function cq(){let{t:a}=(0,d.b)(),{preference:e,setPreference:f}=(0,c.useContext)(m),g=cp[e],h=`${a.theme.toggle}: ${a.theme[e]}`;return(0,b.jsxs)(co.G,{children:[(0,b.jsx)(co.X,{asChild:!0,children:(0,b.jsx)(y.f,{variant:"ghost",size:"icon",className:"rounded-full",title:h,"aria-label":h,children:(0,b.jsx)(g,{className:"h-5 w-5"})})}),(0,b.jsx)(co.L,{align:"end",children:(0,b.jsx)(co.O,{value:e,onValueChange:a=>{l(a)&&f(a)},children:i.map(c=>{let d=cp[c];return(0,b.jsxs)(co.T,{value:c,className:"gap-2",children:[(0,b.jsx)(d,{className:"h-4 w-4"}),a.theme[c]]},c)})})})]})}var cr=a.i(445233),cs=a.i(694796),ct=a.i(57441),ct=ct;let cu=["gemini","openai","azure","anthropic","minimax-code",...ca.U],cv=["1","2-5","6-20",">20"],cw=["0","1-50","51-500",">500"],cx=cr.z.enum(cu),cy=cs.z.boolean();Object.keys({app_installed:ct.strictObject({method:cr.z.enum(["setup-token","preset-admin"])}),eula_accepted:ct.strictObject({version:aW.z.string().regex(/^v\d{1,4}$/),trigger:cr.z.enum(["install","upgrade","settings"])}),instance_alive:ct.strictObject({platform:cr.z.enum(["docker","npm","desktop","fnos","android","other"]),aiConfigured:cs.z.boolean()}),app_opened:ct.strictObject({client:cr.z.enum(["browser","pwa","desktop","android"])}),page_viewed:ct.strictObject({page:cr.z.enum(["home","notebooks","error_detail","practice","review","stats","tags","exams","settings","admin","other"])}),ai_analyze_started:ct.strictObject({provider:cx}),ai_analyze_result:ct.strictObject({ok:cy,provider:cx,duration:cr.z.enum(["<3s","3-10s","10-30s",">30s"])}),ai_reanswer:ct.strictObject({ok:cy,provider:cx}),ai_practice_grading:ct.strictObject({ok:cy,count:cr.z.enum(cv)}),exam_paper_generation:ct.strictObject({ok:cy,count:cr.z.enum(cv)}),data_exported:ct.strictObject({scope:cr.z.enum(["user","all"]),rows:cr.z.enum(cw)}),data_imported:ct.strictObject({rows:cr.z.enum(cw)}),tts_used:ct.strictObject({mode:cr.z.enum(cc.l)}),settings_changed:ct.strictObject({section:cr.z.enum(["general","ai","tts","prompts","telemetry"])})});let cz=[[/^\/$/,"home"],[/^\/notebooks?(\/|$)/,"notebooks"],[/^\/error-items?\/[^/]+/,"error_detail"],[/^\/practice(\/|$)/,"practice"],[/^\/review(\/|$)/,"review"],[/^\/stats(\/|$)/,"stats"],[/^\/tags(\/|$)/,"tags"],[/^\/exams?(\/|$)/,"exams"],[/^\/(settings|setup)(\/|$)/,"settings"],[/^\/admin(\/|$)/,"admin"]];function cA({children:a}){var g,i;let j,k,l,m=(0,w.usePathname)()||"/",{t:n}=(0,d.b)(),{data:o,status:p}=(0,e.useSession)(),q=o?.user?.role==="admin",r=K(m);g=q&&!r,j=(0,w.useRouter)(),k=(0,c.useRef)(!1),(0,c.useEffect)(()=>{g&&!k.current&&(k.current=!0,f.k.get("/api/setup").then(a=>{a.needsSetup&&j.replace("/setup")}).catch(a=>h.V.warn("[Setup]","Failed to check setup status",{error:a})))},[g,j]),i="authenticated"===p,l=(0,c.useRef)(null),(0,c.useEffect)(()=>{(0,b5.J)()},[]),(0,c.useEffect)(()=>{let a;if(!i)return;let b=(a=m.split(/[?#]/)[0]||"/",cz.find(([b])=>b.test(a))?.[1]??"other");b!==l.current&&(l.current=b,(0,b5.z)("page_viewed",{page:b}))},[m,i]);let s=function(a){let[b,d]=(0,c.useState)(null);(0,c.useEffect)(()=>{if(!a)return;let b=!1;return f.k.get("/api/eula/status").then(a=>{b||d(a)}).catch(a=>h.V.warn("[EulaGate]","Failed to check EULA status",{error:a})),()=>{b=!0}},[a]);let e=(0,c.useCallback)(async()=>{b&&d(await f.k.post("/api/admin/eula/accept",{version:b.current}))},[b]);return{pending:a&&!!b?.pending,status:b,accept:e}}(q&&"authenticated"===p),t=s.pending&&s.status?(0,b.jsx)(U,{status:s.status,onAccept:s.accept}):null;if(r||"unauthenticated"===p)return(0,b.jsxs)(b.Fragment,{children:[a,t]});let u=o?.user?.name||o?.user?.email||"";return(0,b.jsxs)("div",{className:"min-h-screen",children:[(0,b.jsx)("header",{className:"sticky top-0 z-40 border-b bg-card/80 backdrop-blur-md supports-[backdrop-filter]:bg-card/70 print:hidden",children:(0,b.jsxs)("div",{className:"mx-auto flex h-14 max-w-6xl items-center gap-3 px-4 md:h-16 md:px-8",children:[(0,b.jsxs)(P.default,{href:"/",className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(O.default,{src:"/icons/icon.png",alt:"",width:32,height:32,className:"rounded-lg",priority:!0,unoptimized:!0}),(0,b.jsx)("span",{className:"hidden text-base font-semibold tracking-tight sm:inline",children:n.pageTitle.base})]}),(0,b.jsx)("nav",{className:"ml-4 hidden items-center gap-1 md:flex",children:J.map(a=>{let c=a.match(m),d=a.icon;return(0,b.jsxs)(P.default,{href:a.href,className:(0,X.f)("flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors",c?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),"aria-current":c?"page":void 0,children:[(0,b.jsx)(d,{className:"h-4 w-4"}),n.nav[a.key]]},a.key)})}),(0,b.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[u&&(0,b.jsxs)("span",{className:"mr-2 hidden max-w-40 items-center gap-2 truncate text-sm text-muted-foreground lg:flex",children:[(0,b.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:u.slice(0,1).toUpperCase()}),(0,b.jsx)("span",{className:"truncate",children:u})]}),q&&(0,b.jsx)(P.default,{href:"/admin",title:n.nav.admin,children:(0,b.jsxs)(y.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,b.jsx)(S,{className:"h-5 w-5"}),(0,b.jsx)("span",{className:"sr-only",children:n.nav.admin})]})}),(0,b.jsx)(Y,{className:"mr-1"}),(0,b.jsx)(cq,{}),(0,b.jsx)(cg,{}),(0,b.jsx)(y.f,{variant:"ghost",size:"icon",className:"rounded-full text-muted-foreground hover:text-destructive",onClick:()=>(0,e.signOut)({callbackUrl:"/login"}),title:n.app.logout,children:(0,b.jsx)(Q.f,{className:"h-5 w-5"})})]})]})}),(0,b.jsx)(ci,{enabled:q&&"authenticated"===p&&!s.pending}),(0,b.jsx)("div",{className:"pb-20 md:pb-0",children:a}),t,(0,b.jsx)("nav",{className:"pb-safe fixed inset-x-0 bottom-0 z-40 border-t bg-card/90 backdrop-blur-md md:hidden print:hidden",children:(0,b.jsx)("div",{className:"grid h-16",style:{gridTemplateColumns:`repeat(${J.length}, minmax(0, 1fr))`},children:J.map(a=>{let c=a.match(m),d=a.icon;return(0,b.jsxs)(P.default,{href:a.href,className:(0,X.f)("flex flex-col items-center justify-center gap-1 text-[11px] font-medium transition-colors",c?"text-primary":"text-muted-foreground"),"aria-current":c?"page":void 0,children:[(0,b.jsx)("span",{className:(0,X.f)("flex h-7 w-12 items-center justify-center rounded-full transition-colors",c&&"bg-accent"),children:(0,b.jsx)(d,{className:"h-5 w-5"})}),n.nav[a.key]]},a.key)})})})]})}let cB={name:"list-todo",size:24,node:[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]};cB.node;let cC=(0,F.f)(cB);var cD=a.i(211134),cE=a.i(374161);let cF=[/^\/login/,/^\/register/,/^\/print-preview/,/^\/exams\/[^/]+\/print/];function cG(){let{t:a}=(0,d.b)(),{timeZone:g}=(0,v.M)(),{status:h}=(0,e.useSession)(),i=(0,w.usePathname)(),[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(()=>cE.f.getSnapshot()),[n,o]=(0,c.useState)(()=>Date.now()),p="authenticated"!==h||cF.some(a=>a.test(i||""));if((0,c.useEffect)(()=>{if(!p)return cE.f.subscribe(a=>{m(a),o(Date.now())})},[p]),p)return null;let q=l.filter(a=>"running"===a.status).length,r=l.some(a=>"running"!==a.status),s=async()=>{try{await f.k.delete("/api/tasks"),await cE.f.refresh()}catch{}};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(y.f,{variant:"outline",size:"icon",className:"fixed bottom-20 right-4 z-40 h-11 w-11 rounded-full shadow-lg md:bottom-6 md:right-6 print:hidden",onClick:()=>k(!0),"aria-label":a.backgroundTasks.title,title:a.backgroundTasks.title,children:[q>0?(0,b.jsx)(x.f,{className:"h-5 w-5 animate-spin"}):(0,b.jsx)(cC,{className:"h-5 w-5"}),q>0&&(0,b.jsx)("span",{className:"absolute -right-1 -top-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-xs text-primary-foreground",children:q})]}),(0,b.jsx)(z.N,{open:j,onOpenChange:k,children:(0,b.jsxs)(z.d,{className:"max-h-[85vh] overflow-y-auto sm:max-w-lg",children:[(0,b.jsxs)(z.s,{children:[(0,b.jsx)(z.F,{children:a.backgroundTasks.title}),(0,b.jsx)(z.C,{children:a.backgroundTasks.description})]}),0===l.length?(0,b.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:a.backgroundTasks.empty}):(0,b.jsx)("ul",{className:"space-y-2",children:l.map(c=>{var d,e;let f;return(0,b.jsx)("li",{className:"rounded-md border p-3 text-sm",children:(0,b.jsxs)("div",{className:"flex items-start gap-2",children:["running"===c.status&&(0,b.jsx)(x.f,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),"succeeded"===c.status&&(0,b.jsx)(bc.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-600"}),"failed"===c.status&&(0,b.jsx)(cD.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,b.jsxs)("div",{className:"font-medium",children:[a.backgroundTasks.kinds[c.kind],(0,b.jsxs)("span",{className:"font-normal text-muted-foreground",children:[" · ",a.backgroundTasks.status[c.status]]})]}),c.subject&&(0,b.jsx)("div",{className:"break-words text-muted-foreground",children:c.subject}),c.progress&&c.progress.total>0&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("div",{className:"h-1.5 overflow-hidden rounded bg-muted",children:(0,b.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.round(c.progress.done/c.progress.total*100)}%`}})}),(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:[a.backgroundTasks.progress.replace("{done}",String(c.progress.done)).replace("{total}",String(c.progress.total)),c.progress.failed>0&&` \xb7 ${a.backgroundTasks.failedCount.replace("{count}",String(c.progress.failed))}`]})]}),c.error&&(0,b.jsx)("div",{className:"text-xs text-destructive",children:(b=>{if(!b)return null;let c=a.backgroundTasks.errors[b]??a.errors[b];return"string"==typeof c?c:b})(c.error)}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground",children:[(0,b.jsx)("span",{children:a.backgroundTasks.startedAt.replace("{time}",(0,ak.r)(c.startedAt,"HH:mm:ss",g))}),(0,b.jsx)("span",{children:a.backgroundTasks.elapsed.replace("{time}",(d=c.startedAt,e=c.finishedAt,f=Math.max(0,Math.round(((e?Date.parse(e):n)-Date.parse(d))/1e3)),`${Math.floor(f/60)}:${String(f%60).padStart(2,"0")}`))}),c.link&&(0,b.jsx)(P.default,{href:c.link,className:"text-primary hover:underline",onClick:()=>k(!1),children:a.backgroundTasks.view})]})]})]})},c.id)})}),(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:a.backgroundTasks.retentionHint}),r&&(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:s,children:a.backgroundTasks.clearFinished})]})]})})]})}var cH=a.i(131900);function cI(){let{t:a}=(0,d.b)(),e=(0,cH.f)(),[f,g]=(0,c.useState)(!1),h=e?function(a){let b=/\bChrome\/(\d+)\./.exec(a);if(!b)return null;let c=Number(b[1]);return c>=111?null:{kind:/; wv\)/.test(a)||a.includes("WrongNotebookAndroid/")?"webview":"browser",version:c}}(navigator.userAgent):null;if(!h||f)return null;let i="webview"===h.kind?a.browserSupport.outdatedWebView:a.browserSupport.outdatedBrowser;return(0,b.jsxs)("div",{role:"alert","data-testid":"outdated-browser-notice",className:"flex items-start gap-3 border-b border-amber-300 bg-amber-100 px-4 py-2 text-sm text-amber-900",children:[(0,b.jsx)("p",{className:"flex-1",children:i.replace("{version}",String(h.version))}),(0,b.jsx)("button",{type:"button",onClick:()=>g(!0),className:"shrink-0 font-medium underline",children:a.common.close})]})}let cJ={success:{icon:bc.f,className:"text-success"},error:{icon:cD.f,className:"text-destructive"},warning:{icon:Z.f,className:"text-warning"},info:{icon:ab,className:"text-primary"}};function cK(){let{t:a}=(0,d.b)(),[e,f]=(0,c.useState)([]),[g,h]=(0,c.useState)(null);return(0,c.useEffect)(()=>(0,L.M)(a=>{f(a.toasts),h(a.confirm)}),[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"pointer-events-none fixed inset-x-0 top-3 z-[100] flex flex-col items-center gap-2 px-4 print:hidden",role:"status","aria-live":"polite",children:e.map(c=>{let{icon:d,className:e}=cJ[c.type];return(0,b.jsxs)("div",{className:"pointer-events-auto flex w-full max-w-sm items-start gap-3 rounded-xl border bg-card/95 px-4 py-3 text-sm shadow-lg backdrop-blur animate-in fade-in slide-in-from-top-2 duration-200",children:[(0,b.jsx)(d,{className:(0,X.f)("mt-0.5 h-4 w-4 shrink-0",e)}),(0,b.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed",children:c.message}),(0,b.jsx)("button",{type:"button",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",onClick:()=>(0,L.p)(c.id),"aria-label":a.common.close,children:(0,b.jsx)(ch.X,{className:"h-3.5 w-3.5"})})]},c.id)})}),(0,b.jsx)(z.N,{open:!!g,onOpenChange:a=>{a||g?.resolve(!1)},children:(0,b.jsxs)(z.d,{className:"sm:max-w-md",children:[(0,b.jsxs)(z.s,{children:[(0,b.jsxs)(z.F,{className:"flex items-center gap-2",children:[g?.destructive&&(0,b.jsx)(Z.f,{className:"h-5 w-5 text-destructive"}),g?.title||a.common.confirmTitle]}),(0,b.jsx)(z.C,{className:"whitespace-pre-line pt-1 text-left leading-relaxed",children:g?.message})]}),(0,b.jsxs)(z.c,{className:"gap-2",children:[(0,b.jsx)(y.f,{variant:"outline",onClick:()=>g?.resolve(!1),children:g?.cancelText||a.common.cancel}),(0,b.jsx)(y.f,{variant:g?.destructive?"destructive":"default",onClick:()=>g?.resolve(!0),autoFocus:!0,children:g?.confirmText||a.common.confirm})]})]})})]})}function cL(){return(0,c.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(a=>{h.V.warn("[PWA]","Service worker registration failed",{error:String(a)})})},[]),null}a.s(["Providers",0,function({children:a,timeZone:f}){return(0,c.useEffect)(()=>(0,h.m)(),[]),(0,b.jsx)(e.SessionProvider,{children:(0,b.jsx)(u,{children:(0,b.jsx)(d.w,{children:(0,b.jsxs)(v.n,{initialTimeZone:f,children:[(0,b.jsx)(cI,{}),(0,b.jsx)(cA,{children:a}),(0,b.jsx)(cG,{}),(0,b.jsx)(N,{}),(0,b.jsx)(cK,{}),(0,b.jsx)(cL,{})]})})})})}],418175)}];
264
+ {{provider_hints}}`;var bX=a.i(62832);function bY({config:a,onUpdate:c}){let{t:e}=(0,d.b)(),f=a.prompts?.analyze||bU,g=a.prompts?.similar||bV,h=a.prompts?.reanswer||bW,i=e.settings?.prompts?.vars,j=[{name:"language_instruction",description:i?.languageInstruction||"Language instructions."},{name:"knowledge_points_list",description:i?.knowledgePointsList||"Knowledge point tags for the subject."},{name:"grade_instruction",description:i?.gradeInstruction||"Grade and semester guidance."},{name:"provider_hints",description:i?.providerHints||"Provider compatibility hints."}],k=[{name:"original_question",description:i?.originalQuestion||"The full text of the original question."},{name:"knowledge_points",description:i?.knowledgePoints||"List of knowledge points to test."},{name:"difficulty_level",description:i?.difficultyLevel||"Target difficulty level."},{name:"difficulty_instruction",description:i?.difficultyInstruction||"Specific writing instructions for the target difficulty."},{name:"language_instruction",description:i?.languageInstructionShort||"Language formatting instructions."},{name:"figure_instruction",description:i?.figureInstruction||"Instructions for redrawing the original figure."},{name:"grade_instruction",description:i?.gradeInstruction||"Grade and semester guidance."}],l=[{name:"question_text",description:i?.questionText||"The corrected question text."},{name:"subject_hint",description:i?.subjectHint||"Subject of the question."},{name:"knowledge_points_rule",description:i?.knowledgePointsRule||"Candidate knowledge points to choose from."},{name:"language_instruction",description:i?.languageInstruction||"Language instructions."},{name:"grade_instruction",description:i?.gradeInstruction||"Grade and semester guidance."},{name:"provider_hints",description:i?.providerHints||"Provider compatibility hints."}];return(0,b.jsx)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:(0,b.jsxs)(aj.i,{defaultValue:"analyze",className:"w-full",children:[(0,b.jsxs)(aj.U,{className:"grid w-full grid-cols-3",children:[(0,b.jsx)(aj.k,{value:"analyze",className:"text-xs sm:text-sm",children:e.settings?.prompts?.analysisTab||"Analysis Prompt"}),(0,b.jsx)(aj.k,{value:"reanswer",className:"text-xs sm:text-sm",children:e.settings?.prompts?.reanswerTab||"Solving Prompt"}),(0,b.jsx)(aj.k,{value:"similar",className:"text-xs sm:text-sm",children:e.settings?.prompts?.similarTab||"Similar Question Prompt"})]}),(0,b.jsx)(aj.S,{value:"analyze",className:"py-4",children:(0,b.jsx)(bH,{value:f,defaultValue:bU,onChange:a=>c("analyze",a),onReset:()=>c("analyze",bU),title:e.settings?.prompts?.customAnalysis||"Custom Analysis Template",variables:j})}),(0,b.jsx)(aj.S,{value:"reanswer",className:"py-4",children:(0,b.jsx)(bH,{value:h,defaultValue:bW,onChange:a=>c("reanswer",a),onReset:()=>c("reanswer",bW),title:e.settings?.prompts?.customReanswer||"Custom Solving Template",variables:l})}),(0,b.jsx)(aj.S,{value:"similar",className:"py-4",children:(0,b.jsx)(bH,{value:g,defaultValue:bV,onChange:a=>c("similar",a),onReset:()=>c("similar",bV),title:e.settings?.prompts?.customSimilar||"Custom Similar Question Template",variables:k})})]})})}bX.I.join("、"),bX.r.join("、");var bZ=a.i(867147);function b$({open:a,onOpenChange:e,onConfirm:f}){let{t:g}=(0,d.b)(),[h,i]=(0,c.useState)(!1),[j,k]=(0,c.useState)(!1),l=async()=>{k(!0);try{await f(),i(!1),e(!1)}catch{}finally{k(!1)}};return(0,b.jsx)(z.N,{open:a,onOpenChange:a=>!j&&e(a),children:(0,b.jsxs)(z.d,{className:"w-[calc(100vw-2rem)] sm:max-w-lg",children:[(0,b.jsxs)(z.s,{children:[(0,b.jsx)(z.F,{children:g.eula.dialogTitle}),(0,b.jsx)(z.C,{children:g.eula.dialogDesc})]}),(0,b.jsx)(bZ.f,{checked:h,onCheckedChange:i,disabled:j}),(0,b.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[(0,b.jsx)(y.f,{variant:"outline",onClick:()=>e(!1),disabled:j,children:g.eula.cancel}),(0,b.jsxs)(y.f,{onClick:l,disabled:!h||j,children:[j&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),g.eula.accept]})]})]})})}function b_({endpoint:a,retentionDays:e,disabled:f,onSave:g}){let{t:h}=(0,d.b)(),i=h.telemetrySettings,[j,k]=(0,c.useState)(""!==a),[l,m]=(0,c.useState)(a),[n,o]=(0,c.useState)(String(e)),p=Number(n),q=Number.isInteger(p)&&p>=1&&p<=365;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(ao.f,{htmlFor:"telemetry-endpoint",children:i.endpoint}),j?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(an.f,{id:"telemetry-endpoint",value:l,placeholder:i.endpointPlaceholder,disabled:f,onChange:a=>m(a.target.value)}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:i.endpointHint})]}):(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:i.endpointDefault}),(0,b.jsx)(y.f,{variant:"link",size:"sm",className:"h-auto p-0",disabled:f,onClick:()=>k(!0),children:i.endpointCustomize})]})]}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(ao.f,{htmlFor:"telemetry-retention",children:i.retentionDays}),(0,b.jsx)(an.f,{id:"telemetry-retention",type:"number",min:1,max:365,className:"w-32",value:n,disabled:f,onChange:a=>o(a.target.value)})]}),(0,b.jsx)(y.f,{size:"sm",variant:"outline",disabled:f||!q,onClick:()=>g({endpoint:l.trim(),retentionDays:p}),children:i.save})]})}function b0({events:a,errors:c,disabled:e,onClear:f}){let{t:g}=(0,d.b)(),{timeZone:h}=(0,v.M)(),i=g.telemetrySettings,j=a=>(0,ak.r)(a,"MM-dd HH:mm",h),k=a=>a?i.forwarded:i.notForwarded,l=0===a.length&&0===c.length;return(0,b.jsxs)("details",{className:"rounded-md border p-3 text-sm",children:[(0,b.jsx)("summary",{className:"cursor-pointer font-medium",children:i.recentTitle}),(0,b.jsxs)("div",{className:"mt-3 space-y-3",children:[l&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:i.recentEmpty}),a.length>0&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:i.recentEvents}),(0,b.jsx)("ul",{className:"space-y-1 font-mono text-xs",children:a.map(a=>(0,b.jsxs)("li",{className:"break-all",children:[j(a.createdAt)," ",a.name," ",a.payload??""," · ",k(a.forwardedAt)]},a.id))})]}),c.length>0&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:i.recentErrors}),(0,b.jsx)("ul",{className:"space-y-1 font-mono text-xs",children:c.map(a=>(0,b.jsxs)("li",{className:"break-all",children:[j(a.createdAt)," ",a.kind," ",a.scope," ",a.name," #",a.fingerprint,a.path?` ${a.path}`:"",a.message?` — ${a.message}`:""," · ",k(a.forwardedAt)]},a.id))})]}),(0,b.jsxs)(y.f,{variant:"outline",size:"sm",onClick:f,disabled:e||l,children:[(0,b.jsx)(av.f,{className:"mr-2 h-4 w-4"}),i.clear]})]})]})}function b1({id:a,label:c,description:d,checked:e,disabled:f,onCheckedChange:g}){return(0,b.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)(ao.f,{htmlFor:a,className:"font-medium",children:c}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d})]}),(0,b.jsx)(am.f,{id:a,checked:e,disabled:f,onCheckedChange:g,className:"shrink-0"})]})}let b2="/api/admin/telemetry";async function b3(a){return await f.k.post("/api/admin/eula/accept",{version:a}),f.k.post(b2,{forwarding:!0})}function b4(a){return f.k.post(b2,a)}var b5=a.i(585982);function b6(){let{t:a}=(0,d.b)(),{timeZone:e}=(0,v.M)(),i=a.telemetrySettings,{data:j,update:k,enableWithConsent:l,clear:m}=function(){let[a,b]=(0,c.useState)(null),d=(0,c.useCallback)(async()=>{try{b(await f.k.get(b2))}catch(a){h.V.warn("[TelemetrySettings]","Failed to load telemetry status",{error:a})}},[]);return(0,c.useEffect)(()=>{d()},[d]),{data:a,update:async a=>b(await b4(a)),enableWithConsent:async a=>b(await b3(a)),clear:async()=>b(await f.k.delete(b2))}}(),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(!1),r=async(a,b)=>{o(!0);try{await a(),L.c.success(b)}catch(a){throw h.V.error("[TelemetrySettings]","Telemetry action failed",{error:a}),L.c.error("INVALID_TELEMETRY_ENDPOINT"===(0,g.d)(a)?i.invalidEndpoint:i.failed),a}finally{o(!1)}},s=a=>r(async()=>{await k(a),(0,b5.z)("settings_changed",{section:"telemetry"})},i.saved).catch(()=>void 0);if(!j)return null;let t=j.lockedByEnv,u=n||t,w=a=>(0,ak.r)(a,"yyyy-MM-dd HH:mm",e),x=async()=>{await (0,L.u)(i.clearConfirm)&&r(m,i.cleared).catch(()=>void 0)},y=j.lastFlushAt?i.lastFlush.replace("{time}",w(j.lastFlushAt)):i.neverFlushed;return j.lastAttempt?.status==="failed"&&(y=i.lastAttemptFailed.replace("{status}",String(j.lastAttempt.httpStatus??"network"))),j.lastAttempt?.status==="stopped"&&(y=i.lastAttemptStopped),(0,b.jsxs)("div",{className:"space-y-4 rounded-lg border p-4",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("p",{className:"flex items-center gap-2 font-medium",children:[(0,b.jsx)(ba,{className:"h-4 w-4"}),i.title]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:i.desc})]}),t&&(0,b.jsx)("p",{className:"text-xs text-orange-600",children:i.lockedByEnv}),j.consentPending&&(0,b.jsx)("p",{className:"text-xs text-orange-600",children:i.consentPending}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:[j.eula.acceptedVersion?i.eulaStatus.replace("{version}",j.eula.acceptedVersion).replace("{time}",j.eula.acceptedAt?w(j.eula.acceptedAt):"-"):i.eulaNotAccepted," ",(0,b.jsx)("a",{href:"/eula",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:i.viewEula})]}),(0,b.jsx)(b1,{id:"telemetry-forwarding",label:i.forwarding,description:i.forwardingDesc,checked:j.forwarding,disabled:u,onCheckedChange:a=>{a&&(!j.eula.acceptedVersion||j.consentPending)?q(!0):s({forwarding:a})}}),j.forwarding&&(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:[i.pending.replace("{count}",String(j.pending))," · ",y]}),(0,b.jsx)(b1,{id:"telemetry-recording",label:i.recording,description:i.recordingDesc,checked:j.recording,disabled:u,onCheckedChange:a=>s({recording:a})}),(0,b.jsx)(b1,{id:"telemetry-errors",label:i.errors,description:i.errorsDesc,checked:j.errors,disabled:u,onCheckedChange:a=>s({errors:a})}),(0,b.jsx)(b_,{endpoint:j.endpoint,retentionDays:j.retentionDays,disabled:u,onSave:s}),(0,b.jsx)(b0,{events:j.events,errors:j.errorRecords,disabled:n,onClear:x}),(0,b.jsx)(b$,{open:p,onOpenChange:q,onConfirm:()=>r(()=>l(j.eula.current),i.enabled)})]})}var b7=a.i(738835),b8=a.i(676330),b9=a.i(206194),ca=a.i(190622),cb=a.i(975484),cc=a.i(294655);function cd({config:a,setConfig:e,saving:i,onSave:j}){let{t:k,language:l}=(0,d.b)(),m=k.settings.tts,[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(null),r=a.tts?.mode??"browser",s=(0,cc.y)(r)?r:null,t=s?a.tts?.[s]:void 0,u=(a,b)=>{s&&e(c=>({...c,tts:{...c.tts,[s]:{...c.tts?.[s],[a]:b}}}))},v=!!s&&(0,cc.S)(s),w=s?(0,cc.L)(a,s):void 0,z=v?t?.apiKey:w?.apiKey,A=async()=>{(0,cb.p)(),o(!0),q(null);try{await j();let{id:a,version:b}=await f.k.post("/api/tts",{text:m.previewText,language:l},{timeout:12e4,recoverable:!0}),c=(0,cb.l)();if(!c)return;c.src=`/api/tts/${a}?v=${b}`,c.playbackRate=1,await c.play()}catch(b){h.V.error("[TtsSettings]","Preview failed",{error:b});let a=(0,g.d)(b);L.c.error("TTS_NOT_CONFIGURED"===a?m.notConfigured:"TTS_PROVIDER_ERROR"===a?m.providerError:m.previewFailed),q((0,g.L)(b)??null)}finally{o(!1)}};return(0,b.jsxs)("div",{className:"space-y-4 border rounded-lg p-4 bg-muted/30",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(ao.f,{children:m.title}),(0,b.jsxs)(aP.d,{value:r,onValueChange:a=>e(b=>({...b,tts:{...b.tts,mode:a}})),children:[(0,b.jsx)(aP.P,{children:(0,b.jsx)(aP.U,{})}),(0,b.jsx)(aP.r,{children:cc.l.map(a=>(0,b.jsx)(aP.T,{value:a,children:m.modes[a]},a))})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:s?m.cloudHint:m.browserHint})]}),s&&(0,b.jsxs)("div",{className:"space-y-3 animate-in fade-in slide-in-from-top-2",children:[cc.D[s]&&(0,b.jsxs)("div",{className:"rounded-md border border-green-200 bg-green-50 p-3 text-xs text-green-800 dark:border-green-900 dark:bg-green-950/40 dark:text-green-300",children:[m.freeTrial," ",(0,b.jsx)("a",{href:cc.D[s],target:"_blank",rel:"noopener noreferrer",className:"underline",children:m.freeTrialLink})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(b8.f,{label:"openai"===s?"OpenAI API Key":v?m.speechApiKey:`${(0,ca.z)(s,l)} API Key`,href:cc.r[s].apiKey,linkText:k.settings.ai.docLinks.apiKey}),(0,b.jsx)(aO.f,{value:z||"",onChange:a=>{var b;return b=a.target.value,void(s&&(v?u("apiKey",b):e(a=>({...a,[s]:{...a[s],apiKey:b}}))))},placeholder:"qwen"===s?"sk-sp-...":v?"":"sk-..."}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:m.apiKeyHint[s]})]}),(0,b.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(b8.f,{label:m.model,href:cc.r[s].model,linkText:m.docs}),(0,b.jsx)(an.f,{value:t?.model||"",onChange:a=>u("model",a.target.value),placeholder:cc.C[s].model})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(b8.f,{label:m.voice,href:cc.r[s].voice,linkText:m.voiceList}),(0,b.jsx)(an.f,{value:t?.voice||"",onChange:a=>u("voice",a.target.value),placeholder:cc.C[s].voice})]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:m.voiceHint[s]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(b8.f,{label:m.endpoint,href:cc.r[s].endpoint,linkText:m.docs}),(0,b.jsx)(an.f,{value:t?.endpoint||"",onChange:a=>u("endpoint",a.target.value),placeholder:(0,cc.E)(s,w)}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:m.endpointHint})]})]},s),(0,b.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[s&&(0,b.jsxs)(y.f,{variant:"outline",onClick:A,disabled:i||n,className:"sm:w-auto",children:[n?(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}):(0,b.jsx)(b7.f,{className:"mr-2 h-4 w-4"}),m.preview]}),(0,b.jsxs)(y.f,{onClick:()=>void j(),disabled:i||n,className:"flex-1",children:[i&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),m.save]})]}),s&&p&&(0,b.jsx)("div",{className:"rounded-md border border-red-200 bg-red-50 p-2 dark:border-red-900 dark:bg-red-950/40",children:(0,b.jsx)(b9.f,{detail:p})})]})}var ce=a.i(439830);function cf({value:a,icon:c,label:d}){return(0,b.jsxs)(aj.k,{value:a,className:"px-2 sm:px-3",children:[c,(0,b.jsx)("span",{className:"hidden sm:inline",children:d})]})}function cg(){let{setTimeZone:a}=(0,v.M)(),{data:g}=(0,e.useSession)(),i=g?.user?.role==="admin",j=g?.user?.id??"",k=g?.user?.email??"",{t:l}=(0,d.b)(),m=(0,w.useRouter)(),[n,o]=(0,c.useState)(!1),p=(0,c.useRef)(null),[q,r]=(0,c.useState)(!1),[s,t]=(0,c.useState)(!1),[u,A]=(0,c.useState)({aiProvider:"minimax"}),C=(0,c.useCallback)(async()=>{t(!0);try{A(await f.k.get("/api/settings"))}catch(a){h.V.error("[SettingsDialog]","Failed to fetch settings",{error:a})}finally{t(!1)}},[]);(0,c.useEffect)(()=>{n&&C()},[n,C]);let D=async b=>{let c=(0,ce.f)(u,l);if(c)return void L.c.error(c);r(!0);try{let c=await f.k.post("/api/settings",u);A(c),a(c.timeZone||ak.J),L.c.success(l.settings?.messages?.saved||"Settings saved"),(0,b5.z)("settings_changed",{section:b}),p.current?.scrollTo({top:0,behavior:"smooth"})}catch(a){h.V.error("[SettingsDialog]","Failed to save settings",{error:a}),L.c.error(l.settings?.messages?.saveFailed||"Failed to save")}finally{r(!1)}},E=(a,c)=>(0,b.jsxs)(y.f,{onClick:()=>D(c),disabled:q,className:"w-full",children:[q&&(0,b.jsx)(x.f,{className:"mr-2 h-4 w-4 animate-spin"}),a]});return(0,b.jsxs)(z.N,{open:n,onOpenChange:o,children:[(0,b.jsx)(z.a,{asChild:!0,children:(0,b.jsxs)(y.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,b.jsx)(ag,{className:"h-5 w-5"}),(0,b.jsx)("span",{className:"sr-only",children:l.settings?.title||"Settings"})]})}),(0,b.jsxs)(z.d,{ref:p,className:"w-[calc(100vw-2rem)] sm:max-w-[900px] max-h-[85vh] overflow-y-auto",children:[(0,b.jsxs)(z.s,{children:[(0,b.jsx)(z.F,{children:l.settings?.title||"Settings"}),(0,b.jsx)(z.C,{children:l.settings?.desc||"Manage your preferences and data."})]}),(0,b.jsxs)(aj.i,{defaultValue:"general",className:"w-full",children:[(0,b.jsxs)(aj.U,{className:`grid w-full grid-cols-4 ${i?"sm:grid-cols-7":"sm:grid-cols-4"} gap-1 h-auto`,children:[(0,b.jsx)(cf,{value:"general",icon:(0,b.jsx)(ac.f,{className:"h-4 w-4 sm:mr-2"}),label:l.settings?.tabs?.general||"General"}),(0,b.jsx)(cf,{value:"account",icon:(0,b.jsx)(ah.f,{className:"h-4 w-4 sm:mr-2"}),label:l.settings?.tabs?.account||"Account"}),i&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(cf,{value:"ai",icon:(0,b.jsx)(_,{className:"h-4 w-4 sm:mr-2"}),label:l.settings?.tabs?.ai||"AI Provider"}),(0,b.jsx)(cf,{value:"prompts",icon:(0,b.jsx)(ae,{className:"h-4 w-4 sm:mr-2"}),label:l.settings?.tabs?.prompts||"Prompts"}),(0,b.jsx)(cf,{value:"admin",icon:(0,b.jsx)(S,{className:"h-4 w-4 sm:mr-2"}),label:l.settings?.tabs?.admin||"User Management"})]}),(0,b.jsx)(cf,{value:"danger",icon:(0,b.jsx)(Z.f,{className:"h-4 w-4 sm:mr-2"}),label:l.settings?.tabs?.danger||"Danger"}),(0,b.jsx)(cf,{value:"about",icon:(0,b.jsx)(ab,{className:"h-4 w-4 sm:mr-2"}),label:l.settings?.tabs?.about||"About"})]}),(0,b.jsxs)(aj.S,{value:"general",className:"space-y-4 py-4",children:[(0,b.jsx)(bv,{config:u,setConfig:A,isAdmin:i,disabled:s||q}),(0,b.jsx)(bz,{}),i&&E(l.settings?.save||"Save Settings","general")]}),(0,b.jsxs)(aj.S,{value:"account",className:"space-y-4 py-4",children:[(0,b.jsx)(aS,{}),(0,b.jsx)(bb,{})]}),(0,b.jsxs)(aj.S,{value:"ai",className:"space-y-4 py-4",children:[(0,b.jsx)(aT.f,{config:u,setConfig:A,loading:s,saving:q,onSave:()=>D("ai")}),!s&&(0,b.jsx)(cd,{config:u,setConfig:A,saving:q,onSave:()=>D("tts")})]}),(0,b.jsxs)(aj.S,{value:"prompts",className:"space-y-4 py-4",children:[(0,b.jsx)(bY,{config:u,onUpdate:(a,b)=>A(c=>({...c,prompts:{...c.prompts,[a]:b}}))}),E(l.settings?.prompts?.save||"Save Prompt Settings","prompts")]}),i&&(0,b.jsxs)(aj.S,{value:"admin",className:"space-y-4 py-4",children:[(0,b.jsxs)(y.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{o(!1),m.push("/admin")},children:[(0,b.jsx)(B.f,{className:"h-4 w-4"}),l.admin?.dashboard?.title||"Admin Dashboard"]}),(0,b.jsxs)(y.f,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{o(!1),m.push("/setup")},children:[(0,b.jsx)(ai.f,{className:"h-4 w-4"}),l.setup.rerun]}),(0,b.jsx)(b6,{}),(0,b.jsx)(bk,{}),(0,b.jsx)(a1,{}),(0,b.jsx)("div",{className:"border-t pt-4",children:(0,b.jsx)(aC,{})})]}),(0,b.jsx)(aj.S,{value:"danger",className:"space-y-4 py-4",children:(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsx)(bg,{isAdmin:i,userId:j,userEmail:k}),(0,b.jsx)(a5,{isAdmin:i}),(0,b.jsx)(a8,{isAdmin:i})]})}),(0,b.jsx)(aj.S,{value:"about",className:"space-y-4 py-4",children:(0,b.jsx)(aN,{})})]})]})]})}var ch=a.i(474215);function ci({enabled:a}){let{t:e}=(0,d.b)(),g=e.telemetrySettings,[i,j]=(0,c.useState)(!1),[k,l]=(0,c.useState)(""),[m,n]=(0,c.useState)(!1);if((0,c.useEffect)(()=>{if(!a)return;let b=!1;return f.k.get(`${b2}?view=notice`).then(a=>{b||(l(a.eula.current),j(a.showNotice))}).catch(a=>h.V.warn("[TelemetryNotice]","Failed to load telemetry notice",{error:a})),()=>{b=!0}},[a]),!a||!i)return null;let o=async()=>{try{await b3(k),j(!1),L.c.success(g.enabled)}catch(a){throw h.V.error("[TelemetryNotice]","Failed to enable forwarding",{error:a}),L.c.error(g.failed),a}};return(0,b.jsxs)("div",{className:"border-b bg-primary/5 print:hidden",children:[(0,b.jsxs)("div",{className:"mx-auto flex max-w-6xl flex-col gap-2 px-4 py-2 text-sm sm:flex-row sm:items-center md:px-8",children:[(0,b.jsx)("p",{className:"flex-1 text-muted-foreground",children:g.noticeText}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(y.f,{size:"sm",onClick:()=>n(!0),children:g.noticeEnable}),(0,b.jsxs)(y.f,{size:"sm",variant:"ghost",onClick:()=>{j(!1),b4({noticeDismissed:!0}).catch(a=>h.V.warn("[TelemetryNotice]","Failed to dismiss notice",{error:a}))},children:[(0,b.jsx)(ch.X,{className:"mr-1 h-4 w-4"}),g.noticeDismiss]})]})]}),(0,b.jsx)(b$,{open:m,onOpenChange:n,onConfirm:o})]})}var cj=a.i(505004);let ck={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]};ck.node;let cl=(0,F.f)(ck),cm={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]};cm.node;let cn=(0,F.f)(cm);var co=a.i(335732);let cp={system:cj.f,light:cn,dark:cl};function cq(){let{t:a}=(0,d.b)(),{preference:e,setPreference:f}=(0,c.useContext)(m),g=cp[e],h=`${a.theme.toggle}: ${a.theme[e]}`;return(0,b.jsxs)(co.G,{children:[(0,b.jsx)(co.X,{asChild:!0,children:(0,b.jsx)(y.f,{variant:"ghost",size:"icon",className:"rounded-full",title:h,"aria-label":h,children:(0,b.jsx)(g,{className:"h-5 w-5"})})}),(0,b.jsx)(co.L,{align:"end",children:(0,b.jsx)(co.O,{value:e,onValueChange:a=>{l(a)&&f(a)},children:i.map(c=>{let d=cp[c];return(0,b.jsxs)(co.T,{value:c,className:"gap-2",children:[(0,b.jsx)(d,{className:"h-4 w-4"}),a.theme[c]]},c)})})})]})}var cr=a.i(445233),cs=a.i(694796),ct=a.i(57441),ct=ct;let cu=["gemini","openai","azure","anthropic","minimax-code",...ca.U],cv=["1","2-5","6-20",">20"],cw=["0","1-50","51-500",">500"],cx=cr.z.enum(cu),cy=cs.z.boolean();Object.keys({app_installed:ct.strictObject({method:cr.z.enum(["setup-token","preset-admin"])}),eula_accepted:ct.strictObject({version:aW.z.string().regex(/^v\d{1,4}$/),trigger:cr.z.enum(["install","upgrade","settings"])}),instance_alive:ct.strictObject({platform:cr.z.enum(["docker","npm","desktop","fnos","android","other"]),aiConfigured:cs.z.boolean()}),app_opened:ct.strictObject({client:cr.z.enum(["browser","pwa","desktop","android"])}),page_viewed:ct.strictObject({page:cr.z.enum(["home","notebooks","error_detail","practice","review","stats","tags","exams","settings","admin","other"])}),ai_analyze_started:ct.strictObject({provider:cx}),ai_analyze_result:ct.strictObject({ok:cy,provider:cx,duration:cr.z.enum(["<3s","3-10s","10-30s",">30s"])}),ai_reanswer:ct.strictObject({ok:cy,provider:cx}),ai_practice_grading:ct.strictObject({ok:cy,count:cr.z.enum(cv)}),exam_paper_generation:ct.strictObject({ok:cy,count:cr.z.enum(cv)}),data_exported:ct.strictObject({scope:cr.z.enum(["user","all"]),rows:cr.z.enum(cw)}),data_imported:ct.strictObject({rows:cr.z.enum(cw)}),tts_used:ct.strictObject({mode:cr.z.enum(cc.l)}),settings_changed:ct.strictObject({section:cr.z.enum(["general","ai","tts","prompts","telemetry"])})});let cz=[[/^\/$/,"home"],[/^\/notebooks?(\/|$)/,"notebooks"],[/^\/error-items?\/[^/]+/,"error_detail"],[/^\/practice(\/|$)/,"practice"],[/^\/review(\/|$)/,"review"],[/^\/stats(\/|$)/,"stats"],[/^\/tags(\/|$)/,"tags"],[/^\/exams?(\/|$)/,"exams"],[/^\/(settings|setup)(\/|$)/,"settings"],[/^\/admin(\/|$)/,"admin"]];function cA({children:a}){var g,i;let j,k,l,m=(0,w.usePathname)()||"/",{t:n}=(0,d.b)(),{data:o,status:p}=(0,e.useSession)(),q=o?.user?.role==="admin",r=K(m);g=q&&!r,j=(0,w.useRouter)(),k=(0,c.useRef)(!1),(0,c.useEffect)(()=>{g&&!k.current&&(k.current=!0,f.k.get("/api/setup").then(a=>{a.needsSetup&&j.replace("/setup")}).catch(a=>h.V.warn("[Setup]","Failed to check setup status",{error:a})))},[g,j]),i="authenticated"===p,l=(0,c.useRef)(null),(0,c.useEffect)(()=>{(0,b5.J)()},[]),(0,c.useEffect)(()=>{let a;if(!i)return;let b=(a=m.split(/[?#]/)[0]||"/",cz.find(([b])=>b.test(a))?.[1]??"other");b!==l.current&&(l.current=b,(0,b5.z)("page_viewed",{page:b}))},[m,i]);let s=function(a){let[b,d]=(0,c.useState)(null);(0,c.useEffect)(()=>{if(!a)return;let b=!1;return f.k.get("/api/eula/status").then(a=>{b||d(a)}).catch(a=>h.V.warn("[EulaGate]","Failed to check EULA status",{error:a})),()=>{b=!0}},[a]);let e=(0,c.useCallback)(async()=>{b&&d(await f.k.post("/api/admin/eula/accept",{version:b.current}))},[b]);return{pending:a&&!!b?.pending,status:b,accept:e}}(q&&"authenticated"===p),t=s.pending&&s.status?(0,b.jsx)(U,{status:s.status,onAccept:s.accept}):null;if(r||"unauthenticated"===p)return(0,b.jsxs)(b.Fragment,{children:[a,t]});let u=o?.user?.name||o?.user?.email||"";return(0,b.jsxs)("div",{className:"min-h-screen",children:[(0,b.jsx)("header",{className:"sticky top-0 z-40 border-b bg-card/80 backdrop-blur-md supports-[backdrop-filter]:bg-card/70 print:hidden",children:(0,b.jsxs)("div",{className:"mx-auto flex h-14 max-w-6xl items-center gap-3 px-4 md:h-16 md:px-8",children:[(0,b.jsxs)(P.default,{href:"/",className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(O.default,{src:"/icons/icon.png",alt:"",width:32,height:32,className:"rounded-lg",priority:!0,unoptimized:!0}),(0,b.jsx)("span",{className:"hidden text-base font-semibold tracking-tight sm:inline",children:n.pageTitle.base})]}),(0,b.jsx)("nav",{className:"ml-4 hidden items-center gap-1 md:flex",children:J.map(a=>{let c=a.match(m),d=a.icon;return(0,b.jsxs)(P.default,{href:a.href,className:(0,X.f)("flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors",c?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),"aria-current":c?"page":void 0,children:[(0,b.jsx)(d,{className:"h-4 w-4"}),n.nav[a.key]]},a.key)})}),(0,b.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[u&&(0,b.jsxs)("span",{className:"mr-2 hidden max-w-40 items-center gap-2 truncate text-sm text-muted-foreground lg:flex",children:[(0,b.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:u.slice(0,1).toUpperCase()}),(0,b.jsx)("span",{className:"truncate",children:u})]}),q&&(0,b.jsx)(P.default,{href:"/admin",title:n.nav.admin,children:(0,b.jsxs)(y.f,{variant:"ghost",size:"icon",className:"rounded-full",children:[(0,b.jsx)(S,{className:"h-5 w-5"}),(0,b.jsx)("span",{className:"sr-only",children:n.nav.admin})]})}),(0,b.jsx)(Y,{className:"mr-1"}),(0,b.jsx)(cq,{}),(0,b.jsx)(cg,{}),(0,b.jsx)(y.f,{variant:"ghost",size:"icon",className:"rounded-full text-muted-foreground hover:text-destructive",onClick:()=>(0,e.signOut)({callbackUrl:"/login"}),title:n.app.logout,children:(0,b.jsx)(Q.f,{className:"h-5 w-5"})})]})]})}),(0,b.jsx)(ci,{enabled:q&&"authenticated"===p&&!s.pending}),(0,b.jsx)("div",{className:"pb-20 md:pb-0",children:a}),t,(0,b.jsx)("nav",{className:"pb-safe fixed inset-x-0 bottom-0 z-40 border-t bg-card/90 backdrop-blur-md md:hidden print:hidden",children:(0,b.jsx)("div",{className:"grid h-16",style:{gridTemplateColumns:`repeat(${J.length}, minmax(0, 1fr))`},children:J.map(a=>{let c=a.match(m),d=a.icon;return(0,b.jsxs)(P.default,{href:a.href,className:(0,X.f)("flex flex-col items-center justify-center gap-1 text-[11px] font-medium transition-colors",c?"text-primary":"text-muted-foreground"),"aria-current":c?"page":void 0,children:[(0,b.jsx)("span",{className:(0,X.f)("flex h-7 w-12 items-center justify-center rounded-full transition-colors",c&&"bg-accent"),children:(0,b.jsx)(d,{className:"h-5 w-5"})}),n.nav[a.key]]},a.key)})})})]})}let cB={name:"list-todo",size:24,node:[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]};cB.node;let cC=(0,F.f)(cB);var cD=a.i(211134),cE=a.i(374161);let cF=[/^\/login/,/^\/register/,/^\/print-preview/,/^\/exams\/[^/]+\/print/];function cG(){let{t:a}=(0,d.b)(),{timeZone:g}=(0,v.M)(),{status:h}=(0,e.useSession)(),i=(0,w.usePathname)(),[j,k]=(0,c.useState)(!1),[l,m]=(0,c.useState)(()=>cE.f.getSnapshot()),[n,o]=(0,c.useState)(()=>Date.now()),p="authenticated"!==h||cF.some(a=>a.test(i||""));if((0,c.useEffect)(()=>{if(!p)return cE.f.subscribe(a=>{m(a),o(Date.now())})},[p]),p)return null;let q=l.filter(a=>"running"===a.status).length,r=l.some(a=>"running"!==a.status),s=async()=>{try{await f.k.delete("/api/tasks"),await cE.f.refresh()}catch{}};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(y.f,{variant:"outline",size:"icon",className:"fixed bottom-20 right-4 z-40 h-11 w-11 rounded-full shadow-lg md:bottom-6 md:right-6 print:hidden",onClick:()=>k(!0),"aria-label":a.backgroundTasks.title,title:a.backgroundTasks.title,children:[q>0?(0,b.jsx)(x.f,{className:"h-5 w-5 animate-spin"}):(0,b.jsx)(cC,{className:"h-5 w-5"}),q>0&&(0,b.jsx)("span",{className:"absolute -right-1 -top-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-xs text-primary-foreground",children:q})]}),(0,b.jsx)(z.N,{open:j,onOpenChange:k,children:(0,b.jsxs)(z.d,{className:"max-h-[85vh] overflow-y-auto sm:max-w-lg",children:[(0,b.jsxs)(z.s,{children:[(0,b.jsx)(z.F,{children:a.backgroundTasks.title}),(0,b.jsx)(z.C,{children:a.backgroundTasks.description})]}),0===l.length?(0,b.jsx)("p",{className:"py-6 text-center text-sm text-muted-foreground",children:a.backgroundTasks.empty}):(0,b.jsx)("ul",{className:"space-y-2",children:l.map(c=>{var d,e;let f;return(0,b.jsx)("li",{className:"rounded-md border p-3 text-sm",children:(0,b.jsxs)("div",{className:"flex items-start gap-2",children:["running"===c.status&&(0,b.jsx)(x.f,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),"succeeded"===c.status&&(0,b.jsx)(bc.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-green-600"}),"failed"===c.status&&(0,b.jsx)(cD.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,b.jsxs)("div",{className:"font-medium",children:[a.backgroundTasks.kinds[c.kind],(0,b.jsxs)("span",{className:"font-normal text-muted-foreground",children:[" · ",a.backgroundTasks.status[c.status]]})]}),c.subject&&(0,b.jsx)("div",{className:"break-words text-muted-foreground",children:c.subject}),c.progress&&c.progress.total>0&&(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("div",{className:"h-1.5 overflow-hidden rounded bg-muted",children:(0,b.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.round(c.progress.done/c.progress.total*100)}%`}})}),(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:[a.backgroundTasks.progress.replace("{done}",String(c.progress.done)).replace("{total}",String(c.progress.total)),c.progress.failed>0&&` \xb7 ${a.backgroundTasks.failedCount.replace("{count}",String(c.progress.failed))}`]})]}),c.error&&(0,b.jsx)("div",{className:"text-xs text-destructive",children:(b=>{if(!b)return null;let c=a.backgroundTasks.errors[b]??a.errors[b];return"string"==typeof c?c:b})(c.error)}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground",children:[(0,b.jsx)("span",{children:a.backgroundTasks.startedAt.replace("{time}",(0,ak.r)(c.startedAt,"HH:mm:ss",g))}),(0,b.jsx)("span",{children:a.backgroundTasks.elapsed.replace("{time}",(d=c.startedAt,e=c.finishedAt,f=Math.max(0,Math.round(((e?Date.parse(e):n)-Date.parse(d))/1e3)),`${Math.floor(f/60)}:${String(f%60).padStart(2,"0")}`))}),c.link&&(0,b.jsx)(P.default,{href:c.link,className:"text-primary hover:underline",onClick:()=>k(!1),children:a.backgroundTasks.view})]})]})]})},c.id)})}),(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 pt-1",children:[(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:a.backgroundTasks.retentionHint}),r&&(0,b.jsx)(y.f,{variant:"ghost",size:"sm",onClick:s,children:a.backgroundTasks.clearFinished})]})]})})]})}var cH=a.i(131900);function cI(){let{t:a}=(0,d.b)(),e=(0,cH.f)(),[f,g]=(0,c.useState)(!1),h=e?function(a){let b=/\bChrome\/(\d+)\./.exec(a);if(!b)return null;let c=Number(b[1]);return c>=111?null:{kind:/; wv\)/.test(a)||a.includes("WrongNotebookAndroid/")?"webview":"browser",version:c}}(navigator.userAgent):null;if(!h||f)return null;let i="webview"===h.kind?a.browserSupport.outdatedWebView:a.browserSupport.outdatedBrowser;return(0,b.jsxs)("div",{role:"alert","data-testid":"outdated-browser-notice",className:"flex items-start gap-3 border-b border-amber-300 bg-amber-100 px-4 py-2 text-sm text-amber-900",children:[(0,b.jsx)("p",{className:"flex-1",children:i.replace("{version}",String(h.version))}),(0,b.jsx)("button",{type:"button",onClick:()=>g(!0),className:"shrink-0 font-medium underline",children:a.common.close})]})}let cJ={success:{icon:bc.f,className:"text-success"},error:{icon:cD.f,className:"text-destructive"},warning:{icon:Z.f,className:"text-warning"},info:{icon:ab,className:"text-primary"}};function cK(){let{t:a}=(0,d.b)(),[e,f]=(0,c.useState)([]),[g,h]=(0,c.useState)(null);return(0,c.useEffect)(()=>(0,L.M)(a=>{f(a.toasts),h(a.confirm)}),[]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"pointer-events-none fixed inset-x-0 top-3 z-[100] flex flex-col items-center gap-2 px-4 print:hidden",role:"status","aria-live":"polite",children:e.map(c=>{let{icon:d,className:e}=cJ[c.type];return(0,b.jsxs)("div",{className:"pointer-events-auto flex w-full max-w-sm items-start gap-3 rounded-xl border bg-card/95 px-4 py-3 text-sm shadow-lg backdrop-blur animate-in fade-in slide-in-from-top-2 duration-200",children:[(0,b.jsx)(d,{className:(0,X.f)("mt-0.5 h-4 w-4 shrink-0",e)}),(0,b.jsx)("p",{className:"min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed",children:c.message}),(0,b.jsx)("button",{type:"button",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",onClick:()=>(0,L.p)(c.id),"aria-label":a.common.close,children:(0,b.jsx)(ch.X,{className:"h-3.5 w-3.5"})})]},c.id)})}),(0,b.jsx)(z.N,{open:!!g,onOpenChange:a=>{a||g?.resolve(!1)},children:(0,b.jsxs)(z.d,{className:"sm:max-w-md",children:[(0,b.jsxs)(z.s,{children:[(0,b.jsxs)(z.F,{className:"flex items-center gap-2",children:[g?.destructive&&(0,b.jsx)(Z.f,{className:"h-5 w-5 text-destructive"}),g?.title||a.common.confirmTitle]}),(0,b.jsx)(z.C,{className:"whitespace-pre-line pt-1 text-left leading-relaxed",children:g?.message})]}),(0,b.jsxs)(z.c,{className:"gap-2",children:[(0,b.jsx)(y.f,{variant:"outline",onClick:()=>g?.resolve(!1),children:g?.cancelText||a.common.cancel}),(0,b.jsx)(y.f,{variant:g?.destructive?"destructive":"default",onClick:()=>g?.resolve(!0),autoFocus:!0,children:g?.confirmText||a.common.confirm})]})]})})]})}function cL(){return(0,c.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(a=>{h.V.warn("[PWA]","Service worker registration failed",{error:String(a)})})},[]),null}a.s(["Providers",0,function({children:a,timeZone:f}){return(0,c.useEffect)(()=>(0,h.m)(),[]),(0,b.jsx)(e.SessionProvider,{children:(0,b.jsx)(u,{children:(0,b.jsx)(d.w,{children:(0,b.jsxs)(v.n,{initialTimeZone:f,children:[(0,b.jsx)(cI,{}),(0,b.jsx)(cA,{children:a}),(0,b.jsx)(cG,{}),(0,b.jsx)(N,{}),(0,b.jsx)(cK,{}),(0,b.jsx)(cL,{})]})})})})}],418175)}];
265
265
 
266
266
  //# sourceMappingURL=src_components_providers_tsx_09kw-mv3nb6xs._.js.map