lookatstudy-mobile 0.36.0 → 0.37.1

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 (145) hide show
  1. package/package.json +1 -1
  2. package/server.cjs +10 -4
  3. package/web/assets/{CanvasStage-2yeV4nPH.js → CanvasStage-DWa6BPww.js} +1 -1
  4. package/web/assets/{CommandPalette-BFX8tcFC.js → CommandPalette-DiD-q1kY.js} +1 -1
  5. package/web/assets/{CompanionBotLab-DTlObSeR.js → CompanionBotLab-Uh7Iurz6.js} +1 -1
  6. package/web/assets/{CourseSearchPanel-DiuZkUSE.js → CourseSearchPanel-BDg7IVGf.js} +1 -1
  7. package/web/assets/{ExamView-fx7mUx8Q.js → ExamView-BCAqFLj-.js} +1 -1
  8. package/web/assets/MermaidArtifact-pvwMTDsC.js +9 -0
  9. package/web/assets/{PersonalProfileModal-CivNUd4y.js → PersonalProfileModal-Cp2sd0r5.js} +1 -1
  10. package/web/assets/{ReviewPanel-CdgUqKuF.js → ReviewPanel-BKloT7C_.js} +1 -1
  11. package/web/assets/SettingsView-DlAIL4xo.js +20 -0
  12. package/web/assets/{VoicePanel-Cyopy3sr.js → VoicePanel-Blijw_xQ.js} +1 -1
  13. package/web/assets/{abnfDiagram-VCTEODGH-Dn5J4BZu.js → abnfDiagram-VCTEODGH-B4Pws_nv.js} +1 -1
  14. package/web/assets/{abnfDiagram-VCTEODGH-ODA7YWAP-6WuG0Nt3.js → abnfDiagram-VCTEODGH-ODA7YWAP-D-Sdh0h-.js} +1 -1
  15. package/web/assets/{architectureDiagram-5GKGNRK7-C4PU3XN7-BtKh8197.js → architectureDiagram-5GKGNRK7-C4PU3XN7-Bkd1gLHS.js} +1 -1
  16. package/web/assets/{architectureDiagram-5GKGNRK7-jrCKwrXL.js → architectureDiagram-5GKGNRK7-DLKfj4RZ.js} +1 -1
  17. package/web/assets/{blockDiagram-I7D4REHJ-CWtkTOLG.js → blockDiagram-I7D4REHJ-CcU7UGAT.js} +1 -1
  18. package/web/assets/{blockDiagram-NRAW4CY4-UMJ6PMQQ-DHl4tIPo.js → blockDiagram-NRAW4CY4-UMJ6PMQQ-C4bMYcFo.js} +1 -1
  19. package/web/assets/{c4Diagram-7LVT6UL2-DvgOYbmL.js → c4Diagram-7LVT6UL2-DTM1UxNS.js} +1 -1
  20. package/web/assets/{c4Diagram-UCG6FXSJ-75X3U2P3-8t5uU1V0.js → c4Diagram-UCG6FXSJ-75X3U2P3-B1cVRXCm.js} +1 -1
  21. package/web/assets/channel-Bd-gObO1.js +1 -0
  22. package/web/assets/{chunk-2Q5K7J3B-D-MRkRaW.js → chunk-2Q5K7J3B-CK1sHHcq.js} +1 -1
  23. package/web/assets/{chunk-5VM5RSS4-DgMwQtQx.js → chunk-5VM5RSS4-CtN85jHB.js} +1 -1
  24. package/web/assets/{chunk-7XDTSPCN-C6CLiznJ.js → chunk-7XDTSPCN-DL3gFm2O.js} +1 -1
  25. package/web/assets/{chunk-CTNIYPP6-CM1Z69qf.js → chunk-CTNIYPP6-34jcHYzx.js} +1 -1
  26. package/web/assets/{chunk-CXNFBKHE-B6ieqKBL.js → chunk-CXNFBKHE-Ajw5fhAt.js} +1 -1
  27. package/web/assets/{chunk-F27PBJKO-AboV3MjF.js → chunk-F27PBJKO-CeTL5oEt.js} +1 -1
  28. package/web/assets/{chunk-IMKFNOWR-BRfxTcG3.js → chunk-IMKFNOWR-BXpLlPze.js} +1 -1
  29. package/web/assets/{chunk-ISA7TJRJ-BA6VnLlf.js → chunk-ISA7TJRJ-CkTr2ChC.js} +1 -1
  30. package/web/assets/{chunk-JWPE2WC7-CM5DFf0Z.js → chunk-JWPE2WC7-DSacNhA4.js} +1 -1
  31. package/web/assets/{chunk-LV3HUYFY-DtT0YyqZ.js → chunk-LV3HUYFY-BDvEK9u6.js} +1 -1
  32. package/web/assets/{chunk-M3IUQBOH-DGSTxKRB.js → chunk-M3IUQBOH-iJMK0j9N.js} +1 -1
  33. package/web/assets/{chunk-NDIOYS4C-BDCIN1Cv.js → chunk-NDIOYS4C-cxrwwBVm.js} +1 -1
  34. package/web/assets/{chunk-POPQ4Y6H-CRs1ouKF.js → chunk-POPQ4Y6H-DNyVIlsa.js} +1 -1
  35. package/web/assets/{chunk-RE4WF27V-CPwQc2vn.js → chunk-RE4WF27V-DOxrYV0W.js} +1 -1
  36. package/web/assets/{chunk-SVP7TREG-Cbw7rxkD.js → chunk-SVP7TREG-DbnWkZ8h.js} +1 -1
  37. package/web/assets/{chunk-TICWLB2K-CJpuBU6m.js → chunk-TICWLB2K-Ba3f7lw5.js} +1 -1
  38. package/web/assets/{chunk-VII2H2IX-udiwuRgE.js → chunk-VII2H2IX-Dbzz_on1.js} +1 -1
  39. package/web/assets/{chunk-X5GNSKZ3-DvVFKhTQ.js → chunk-X5GNSKZ3-zngMbi6F.js} +1 -1
  40. package/web/assets/{chunk-XCWWM2C3-EFZq_oj4.js → chunk-XCWWM2C3-3NMcdDFX.js} +1 -1
  41. package/web/assets/{chunk-XXDRQBXY-BCxGit2x.js → chunk-XXDRQBXY-DacZhf2D.js} +1 -1
  42. package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-59033U8k.js +1 -0
  43. package/web/assets/classDiagram-ZZMXUADV-DM-KS5hV.js +1 -0
  44. package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-59033U8k.js +1 -0
  45. package/web/assets/classDiagram-v2-VYDZK3BY-DM-KS5hV.js +1 -0
  46. package/web/assets/{core-CTdCef6f.js → core-iuOIACGb.js} +1 -1
  47. package/web/assets/{cose-bilkent-JH36ORCC-Dfkex2fo.js → cose-bilkent-JH36ORCC-Dq-Q8BZJ.js} +1 -1
  48. package/web/assets/{cose-bilkent-JH36ORCC-OB24KH3T-CE0-pZTl.js → cose-bilkent-JH36ORCC-OB24KH3T-CPgU6fjd.js} +1 -1
  49. package/web/assets/{cynefin-OW5HDTMX-DeRfvx8D.js → cynefin-OW5HDTMX-BpkRUbag.js} +1 -1
  50. package/web/assets/{cynefin-OW5HDTMX-GVF3BKWE-WBE1vO13.js → cynefin-OW5HDTMX-GVF3BKWE-BhhUo0ca.js} +1 -1
  51. package/web/assets/{cynefinDiagram-5FMLGOSQ-Bh5b3wB1.js → cynefinDiagram-5FMLGOSQ-CbT5J2AS.js} +1 -1
  52. package/web/assets/{cynefinDiagram-5FMLGOSQ-H3WIRU3N-BJvz82EQ.js → cynefinDiagram-5FMLGOSQ-H3WIRU3N-DjzZZfXh.js} +1 -1
  53. package/web/assets/{dagre-3AP2YEHR-DCERTXHT-XAHjclga.js → dagre-3AP2YEHR-DCERTXHT-DmYKg1uA.js} +1 -1
  54. package/web/assets/{dagre-GXQ25YYZ-DrM7-QVm.js → dagre-GXQ25YYZ-DaFjM1tp.js} +1 -1
  55. package/web/assets/{diagram-S7CK7UJ4-DuzIHkVE.js → diagram-S7CK7UJ4-BuDFhDGD.js} +1 -1
  56. package/web/assets/{diagram-S7CK7UJ4-MULGZGEL-DPqhnzpl.js → diagram-S7CK7UJ4-MULGZGEL-CCFqnfoE.js} +1 -1
  57. package/web/assets/{diagram-UQ7AKVKN-DhVHhLx3.js → diagram-UQ7AKVKN-BEZkD-tG.js} +1 -1
  58. package/web/assets/{diagram-UQ7AKVKN-YQBY353J-CtxlSSGF.js → diagram-UQ7AKVKN-YQBY353J-Dchh3ymU.js} +1 -1
  59. package/web/assets/{diagram-VSXAHHWV-KRouqsun.js → diagram-VSXAHHWV-LcyvOZyA.js} +1 -1
  60. package/web/assets/{diagram-VSXAHHWV-WLNH2ELY-CIR4bpme.js → diagram-VSXAHHWV-WLNH2ELY-UVsHRiao.js} +1 -1
  61. package/web/assets/{diagram-VX7I27RA-CTJ3vljk.js → diagram-VX7I27RA-TfCoRqjg.js} +1 -1
  62. package/web/assets/{diagram-VX7I27RA-XW6YQV5G-BpP1BFMf.js → diagram-VX7I27RA-XW6YQV5G-BSieiGEG.js} +1 -1
  63. package/web/assets/{diagram-Z3DM3KII-D5hgo2N9.js → diagram-Z3DM3KII-D81rsk1w.js} +1 -1
  64. package/web/assets/{diagram-Z3DM3KII-HG7RF65D-BYiYU7xi.js → diagram-Z3DM3KII-HG7RF65D-Rbjpm9hG.js} +1 -1
  65. package/web/assets/{ebnfDiagram-PWID7BFC-DamZ_7Vh.js → ebnfDiagram-PWID7BFC-D1tfiTa_.js} +1 -1
  66. package/web/assets/{ebnfDiagram-PWID7BFC-OKY4VHYD-yPy84C7F.js → ebnfDiagram-PWID7BFC-OKY4VHYD-DJFrRkqu.js} +1 -1
  67. package/web/assets/{elk.bundled-Bnb7YbCz.js → elk.bundled-Zj2eepJ0.js} +1 -1
  68. package/web/assets/{erDiagram-RLTQ6QDP-DXutINWC.js → erDiagram-RLTQ6QDP-OU6RwfWr.js} +1 -1
  69. package/web/assets/{erDiagram-SSCWMZ5O-PIPKOIK7-ZtlmPRSG.js → erDiagram-SSCWMZ5O-PIPKOIK7-XR2szNAv.js} +1 -1
  70. package/web/assets/{flowDiagram-A5DVABFB-2Z4AVO5R-RWiTsxAA.js → flowDiagram-A5DVABFB-2Z4AVO5R-DAB9UlGL.js} +1 -1
  71. package/web/assets/{flowDiagram-HODETNUW-C0v4xgVs.js → flowDiagram-HODETNUW-Bj5XhSEr.js} +1 -1
  72. package/web/assets/{ganttDiagram-EL5Y4UJY-C10Pxkpf.js → ganttDiagram-EL5Y4UJY-DYYnYoH2.js} +1 -1
  73. package/web/assets/{ganttDiagram-EL5Y4UJY-JZNG7GOG-C3JHepgy.js → ganttDiagram-EL5Y4UJY-JZNG7GOG-DFEJViIL.js} +1 -1
  74. package/web/assets/{gitGraphDiagram-WWUBYQGX-DMWMLL3G-Dvo5dray.js → gitGraphDiagram-WWUBYQGX-DMWMLL3G-C4Pimd0G.js} +1 -1
  75. package/web/assets/{gitGraphDiagram-WWUBYQGX-DnhwejId.js → gitGraphDiagram-WWUBYQGX-_Z0hgx0B.js} +1 -1
  76. package/web/assets/{index-D5O6zEt9.js → index-Bp9UucY6.js} +1 -1
  77. package/web/assets/{index-C06x750C.js → index-BqH7RtMm.js} +1 -1
  78. package/web/assets/index-CVsNhplX.js +14 -0
  79. package/web/assets/index-DFeHjpII.js +53 -0
  80. package/web/assets/index-EInfxfl9.css +1 -0
  81. package/web/assets/{infoDiagram-27XIBGKW-BCK0GNZi.js → infoDiagram-27XIBGKW-BbzbmS5U.js} +1 -1
  82. package/web/assets/{infoDiagram-RXCK75RN-HANS5KVC-DnIuK4Ld.js → infoDiagram-RXCK75RN-HANS5KVC-BTP5MSJx.js} +1 -1
  83. package/web/assets/{ishikawaDiagram-5VMMS53U-7GCIT7WU-D7H0PvCT.js → ishikawaDiagram-5VMMS53U-7GCIT7WU-CcMY5L6M.js} +1 -1
  84. package/web/assets/{ishikawaDiagram-5VMMS53U-CwfpIEur.js → ishikawaDiagram-5VMMS53U-Biav4sA5.js} +1 -1
  85. package/web/assets/{journeyDiagram-3NMN7TZE-D7yc5_ha.js → journeyDiagram-3NMN7TZE-wLoy0nOR.js} +1 -1
  86. package/web/assets/{journeyDiagram-EYS64GPL-OAPELBT7-BxN0kQu5.js → journeyDiagram-EYS64GPL-OAPELBT7-yWvaQfBz.js} +1 -1
  87. package/web/assets/{kanban-definition-3QL26DDD-I7RKWQQY-4n8YjWaH.js → kanban-definition-3QL26DDD-I7RKWQQY--EREHjsb.js} +1 -1
  88. package/web/assets/{kanban-definition-UXKFOSKX-jCn6YBMx.js → kanban-definition-UXKFOSKX-B_4rU47Y.js} +1 -1
  89. package/web/assets/{katex-N6JRN4PM-Dsye9nhm.js → katex-N6JRN4PM-D2c3WCAB.js} +1 -1
  90. package/web/assets/{layout-BGHeGqee.js → layout-28aDa-kS.js} +1 -1
  91. package/web/assets/{main-D7WqSbOt.js → main-Q55C34or.js} +117 -117
  92. package/web/assets/{mermaid-layout-elk.core-DTUF3xdW.js → mermaid-layout-elk.core-BtEZ1o-e.js} +2 -2
  93. package/web/assets/{mermaid.core-C-NqYAhX.js → mermaid.core-DnOBsKcF.js} +5 -5
  94. package/web/assets/{mindmap-definition-FBJOCRG2-KIYZG64Y-DfNqXTK3.js → mindmap-definition-FBJOCRG2-KIYZG64Y-CAgYj6yn.js} +1 -1
  95. package/web/assets/{mindmap-definition-YA3MSWOX-D3sKf06e.js → mindmap-definition-YA3MSWOX-fDXRUwwB.js} +1 -1
  96. package/web/assets/{pegDiagram-XKGWAZYB-CVKDjCVA.js → pegDiagram-XKGWAZYB-Ddka_qjr.js} +1 -1
  97. package/web/assets/{pegDiagram-XKGWAZYB-OIP57N6J-DS2aCbPH.js → pegDiagram-XKGWAZYB-OIP57N6J-DDSZmF9B.js} +1 -1
  98. package/web/assets/{pet-Du-sCSbe.js → pet-BEkzd4ze.js} +1 -1
  99. package/web/assets/{pieDiagram-E7YTZNPT-2UOTW327-yjF7mWxr.js → pieDiagram-E7YTZNPT-2UOTW327-ox59cMau.js} +1 -1
  100. package/web/assets/{pieDiagram-E7YTZNPT-Bv5akhT4.js → pieDiagram-E7YTZNPT-D9oat8I8.js} +1 -1
  101. package/web/assets/{quadrantDiagram-AXDQQJYC-O95BF4oR.js → quadrantDiagram-AXDQQJYC-MrrLJtbc.js} +1 -1
  102. package/web/assets/{quadrantDiagram-AXDQQJYC-SN3ASJJK-BLrtldcO.js → quadrantDiagram-AXDQQJYC-SN3ASJJK-ChSnrtGL.js} +1 -1
  103. package/web/assets/{railroadDiagram-O6MQD6OU-34742W6X-D8Re17Lm.js → railroadDiagram-O6MQD6OU-34742W6X-DpAy_neF.js} +1 -1
  104. package/web/assets/{railroadDiagram-O6MQD6OU-C4dT_AHN.js → railroadDiagram-O6MQD6OU-DsQMMR2g.js} +1 -1
  105. package/web/assets/{render-O7CIS3YK-C1LKCRfk.js → render-O7CIS3YK-uyJB6lwg.js} +7 -7
  106. package/web/assets/{requirementDiagram-BXWQKSXE-DRoAJ0A4.js → requirementDiagram-BXWQKSXE-Cg450wQf.js} +1 -1
  107. package/web/assets/{requirementDiagram-EFPCY7ZU-NGAFFSMB-BRpdn_yZ.js → requirementDiagram-EFPCY7ZU-NGAFFSMB-mh7_uzgF.js} +1 -1
  108. package/web/assets/{rotate-ccw-BS0Lg3XV.js → rotate-ccw-BOEgpxYS.js} +1 -1
  109. package/web/assets/{sankeyDiagram-P5KCCOFB-3D3M4XPB-U2MyqhHx.js → sankeyDiagram-P5KCCOFB-3D3M4XPB-DUQwTphe.js} +1 -1
  110. package/web/assets/{sankeyDiagram-P5KCCOFB-DhLHY7NO.js → sankeyDiagram-P5KCCOFB-BwzEBa47.js} +1 -1
  111. package/web/assets/{sequenceDiagram-WJ2MYXX4-C5QbVOkW.js → sequenceDiagram-WJ2MYXX4-BI3YNUx6.js} +1 -1
  112. package/web/assets/{sequenceDiagram-WJ2MYXX4-Q2IOPB4R-C3se4pTd.js → sequenceDiagram-WJ2MYXX4-Q2IOPB4R-CgNGGShc.js} +1 -1
  113. package/web/assets/{sizeCapture-INFHLROL-Ds6O28WR.js → sizeCapture-INFHLROL-BkVRwlBC.js} +1 -1
  114. package/web/assets/{sizeCapture-X5ZJPWSS-PSGVOMYM-Dalg_GSB.js → sizeCapture-X5ZJPWSS-PSGVOMYM-DMoR5_G_.js} +1 -1
  115. package/web/assets/{stateDiagram-D77RDMKH-C4Loqn2S.js → stateDiagram-D77RDMKH-DomT165i.js} +1 -1
  116. package/web/assets/{stateDiagram-HBIQ2CUA-4M2S6MAN-CYg9tFmx.js → stateDiagram-HBIQ2CUA-4M2S6MAN-BjwnPs-t.js} +1 -1
  117. package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-CYpZRXYS.js +1 -0
  118. package/web/assets/stateDiagram-v2-MP3YSRHH-Bu-0oSj-.js +1 -0
  119. package/web/assets/{swimlanes-42K2YHIH-B95g1myb.js → swimlanes-42K2YHIH-CzbjyNdC.js} +1 -1
  120. package/web/assets/{swimlanes-XN3QIQJK-N6N2CCQ6-BVCO5pth.js → swimlanes-XN3QIQJK-N6N2CCQ6-C4xMnbVh.js} +1 -1
  121. package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-CaXDcqd7.js +8 -0
  122. package/web/assets/swimlanesDiagram-VR7AAH4N-BU5GIrS3.js +8 -0
  123. package/web/assets/{timeline-definition-24CTP7MA-DfbDTQSt.js → timeline-definition-24CTP7MA-CTIJns6D.js} +1 -1
  124. package/web/assets/{timeline-definition-24CTP7MA-KN7RSRVM-Ba1F1ajL.js → timeline-definition-24CTP7MA-KN7RSRVM-BOjiMd8Q.js} +1 -1
  125. package/web/assets/{vennDiagram-4TSXK5OY-AKJ7LXAN-B9Nx1RWB.js → vennDiagram-4TSXK5OY-AKJ7LXAN-4hLVPR4S.js} +1 -1
  126. package/web/assets/{vennDiagram-4TSXK5OY-B-uAb-fo.js → vennDiagram-4TSXK5OY-A_Q4N3Be.js} +1 -1
  127. package/web/assets/{wardleyDiagram-VM6X3IG4-3B6A3BN5-v-icjHpd.js → wardleyDiagram-VM6X3IG4-3B6A3BN5-BMnLic23.js} +1 -1
  128. package/web/assets/{wardleyDiagram-VM6X3IG4-Cr0_wFiw.js → wardleyDiagram-VM6X3IG4-BjEyKJ7j.js} +1 -1
  129. package/web/assets/{xychartDiagram-S5SC5T6Z-DwsgX-jd.js → xychartDiagram-S5SC5T6Z-1YiCzgCj.js} +1 -1
  130. package/web/assets/{xychartDiagram-S5SC5T6Z-OBDNV6WG-BX7F_LDu.js → xychartDiagram-S5SC5T6Z-OBDNV6WG-BGnMnf5M.js} +1 -1
  131. package/web/index.html +3 -3
  132. package/web/pet.html +3 -3
  133. package/web/assets/SettingsView-pzj-Jlrz.js +0 -20
  134. package/web/assets/channel-CSAHJ2BV.js +0 -1
  135. package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-4hLnkbwM.js +0 -1
  136. package/web/assets/classDiagram-ZZMXUADV-CMAUnrA5.js +0 -1
  137. package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-4hLnkbwM.js +0 -1
  138. package/web/assets/classDiagram-v2-VYDZK3BY-CMAUnrA5.js +0 -1
  139. package/web/assets/index-BeI-qOIb.js +0 -21
  140. package/web/assets/index-By7sA5iY.css +0 -1
  141. package/web/assets/index-C8cLLejx.js +0 -53
  142. package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-CMhstoHU.js +0 -1
  143. package/web/assets/stateDiagram-v2-MP3YSRHH-CcPVgXyv.js +0 -1
  144. package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-CqJNI91T.js +0 -8
  145. package/web/assets/swimlanesDiagram-VR7AAH4N-BrEEiqe7.js +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lookatstudy-mobile",
3
- "version": "0.36.0",
3
+ "version": "0.37.1",
4
4
  "description": "LookatStudy Termux portable bundle (server.cjs + web frontend)",
5
5
  "repository": {
6
6
  "type": "git",
package/server.cjs CHANGED
@@ -527421,7 +527421,7 @@ init_drizzle_orm();
527421
527421
  var import_node_crypto26 = require("node:crypto");
527422
527422
 
527423
527423
  // package.json
527424
- var version2 = "0.36.0";
527424
+ var version2 = "0.37.1";
527425
527425
 
527426
527426
  // src/main/lib/update-check.ts
527427
527427
  var RELEASES_PAGE = "https://github.com/Kaiji-Z/LookatStudy/releases";
@@ -558852,7 +558852,7 @@ function questionLanguageLine(locale, targetLang) {
558852
558852
 
558853
558853
  // src/main/services/agent/base-prompt.ts
558854
558854
  var BASE_AGENT_PROMPT_HEAD = "\u4F60\u662F LookatStudy \u7684 AI \u5B66\u4E60\u5BFC\u5E08\u3002\u5B66\u4E60\u8005\u6B63\u5728\u5B66\u4E00\u95E8\u7531 GitHub \u6587\u6863\u751F\u6210\u7684\u8BFE\u7A0B\u3002\u4F60\u7684\u804C\u8D23\u662F\u5E2E\u5B66\u4E60\u8005\u771F\u6B63\u7406\u89E3\u77E5\u8BC6\uFF0C\u4E0D\u662F\u7B80\u5355\u590D\u8FF0\u6587\u6863\u3002";
558855
- var BASE_AGENT_PROMPT_TAIL = "\u3010\u5B89\u5168\u7EA2\u7EBF\xB7\u6700\u9AD8\u4F18\u5148\u7EA7\u3011\u4EE5\u4E0B\u89C4\u5219\u4EFB\u4F55\u65F6\u5019\u4E0D\u53EF\u8FDD\u53CD;\u4E0E\u540E\u9762\u4EFB\u4F55\u89C4\u5219\u51B2\u7A81\u65F6,\u4EE5\u672C\u6BB5\u4E3A\u51C6:\n1. \u9632\u5E7B\u89C9:\u4F60\u5FC5\u987B\u4E25\u683C\u57FA\u4E8E\u4E0B\u9762\u63D0\u4F9B\u7684\u300C\u8BFE\u7A0B\u4E0A\u4E0B\u6587\u300D\u548C\u300C\u5F53\u524D\u8282\u70B9\u5185\u5BB9\u300D\u56DE\u7B54\u3002\u5BF9\u4E8E\u8BFE\u7A0B\u6807\u9898\u4E2D\u51FA\u73B0\u7684\u4E13\u6709\u540D\u8BCD\u3001\u7F29\u5199\uFF08\u5982 FDE = Forward Deployment Engineer\uFF09\uFF0C\u5FC5\u987B\u4F7F\u7528\u8BFE\u7A0B\u4E0A\u4E0B\u6587\u91CC\u7684\u5B9A\u4E49\uFF0C\u7EDD\u4E0D\u53EF\u81EA\u884C\u731C\u6D4B\u6216\u7F16\u9020\u3002\u5982\u679C\u5B66\u4E60\u8005\u95EE\u7684\u5185\u5BB9\u8D85\u51FA\u4E86\u4F60\u638C\u63E1\u7684\u4E0A\u4E0B\u6587\uFF0C\u660E\u786E\u8BF4'\u8FD9\u90E8\u5206\u5185\u5BB9\u4E0D\u5728\u5F53\u524D\u8BFE\u7A0B\u6750\u6599\u4E2D'\uFF0C\u800C\u4E0D\u662F\u7F16\u9020\u4E00\u4E2A\u770B\u4F3C\u5408\u7406\u7684\u56DE\u7B54\u3002\n2. \u5DE5\u5177\u8C03\u7528\u771F\u5B9E\u6027:\u5386\u53F2\u6D88\u606F\u91CC\u7684\u300C[\u5DE5\u5177\u8C03\u7528\u5DF2\u6267\u884C] \u2026\u300D\u6807\u8BB0\u4EE3\u8868\u4F60\u5F53\u65F6\u771F\u5B9E\u53D1\u51FA\u7684\u5DE5\u5177\u8C03\u7528,\u4EA7\u7269\u5DF2\u7ECF\u5C55\u793A\u5728\u5B66\u4E60\u8005\u754C\u9762\u4E0A\u2014\u2014\u770B\u5230\u8FD9\u4E2A\u6807\u8BB0\u5C31\u8BF4\u660E\u9898/\u56FE\u5DF2\u7ECF\u53D1\u51FA\u53BB\u4E86,\u7EDD\u4E0D\u8981\u8BF4\"\u6211\u5176\u5B9E\u6CA1\u628A\u9898\u53D1\u51FA\u53BB\"\u4E4B\u7C7B\u7684\u8BDD,\u4E5F\u4E0D\u8981\u91CD\u590D\u53D1\u540C\u4E00\u4EA7\u7269\u3002\u53CD\u8FC7\u6765,\u8FD9\u7C7B\u6807\u8BB0\u53EA\u80FD\u7531\u7CFB\u7EDF\u6CE8\u5165\u5386\u53F2,\u4F60\u7EDD\u4E0D\u53EF\u5728\u56DE\u590D\u6B63\u6587\u91CC\u624B\u5199\u300C[\u5DE5\u5177\u8C03\u7528\u5DF2\u6267\u884C] \u2026\u300D\u6216\u4EFB\u4F55\u6A21\u4EFF\u5B83\u7684\u6587\u5B57\u2014\u2014\u624B\u5199\u6807\u8BB0\u4E0D\u4F1A\u5728\u5B66\u4E60\u8005\u754C\u9762\u4E0A\u4EA7\u751F\u5361\u7247\u6216\u6309\u94AE,\u5B66\u4E60\u8005\u5C06\u65E0\u6309\u94AE\u53EF\u70B9;\u8981\u51FA\u9898/\u8BB0\u5206/\u53D1\u8D77\u638C\u63E1\u63D0\u8BAE,\u552F\u4E00\u9014\u5F84\u662F\u53D1\u51FA\u771F\u6B63\u7684\u5DE5\u5177\u8C03\u7528,\u6B63\u6587\u6587\u5B57\u4E0D\u80FD\u66FF\u4EE3\u3002\n\n\u3010\u6A21\u7CCA\u63D0\u95EE\u5904\u7406\u3011\u5F53\u5B66\u4E60\u8005\u8BF4'\u6211\u4E0D\u61C2''\u4E0D\u592A\u7406\u89E3'\u4F46\u6CA1\u8BF4\u5177\u4F53\u4E0D\u61C2\u4EC0\u4E48\u65F6\uFF0C\u4E0D\u8981\u5047\u8BBE\u4F60\u77E5\u9053\u4ED6\u54EA\u91CC\u4E0D\u61C2\u7136\u540E\u957F\u7BC7\u5927\u8BBA\u3002\u5148\u53CD\u95EE'\u4F60\u5177\u4F53\u662F\u54EA\u4E2A\u6982\u5FF5\u4E0D\u592A\u6E05\u695A\uFF1F'\uFF0C\u6216\u8005\u5217\u51FA\u8FD9\u8BFE\u6D89\u53CA\u7684 2-3 \u4E2A\u6838\u5FC3\u6982\u5FF5\u8BA9\u4ED6\u9009\u3002\u53EA\u8BB2\u89E3\u5B66\u4E60\u8005\u660E\u786E\u95EE\u5230\u7684\u90E8\u5206\uFF0C\u4E0D\u8981\u4E3B\u52A8\u6269\u5C55\u5230\u8BFE\u7A0B\u5185\u5BB9\u4E4B\u5916\u7684\u9886\u57DF\u77E5\u8BC6\u3002\n\n\u3010\u6559\u5B66\u5DE5\u5177\u4F7F\u7528\u3011\u4F60\u6709\u51E0\u4E2A\u80FD\u751F\u6210\u53EF\u89C6\u5316\u5B66\u4E60\u4EA7\u7269\u3001\u8BB0\u5F55\u5B66\u4E60\u72B6\u6001\u7684\u5DE5\u5177\uFF0C\u9002\u65F6\u4F7F\u7528\u80FD\u5927\u5E45\u63D0\u5347\u7406\u89E3\uFF1A- show_concept_map:\u7406\u6E05\u6982\u5FF5\u95F4\u5173\u7CFB(\u67B6\u6784/\u4F9D\u8D56/\u5206\u7C7B),\u5B66\u4E60\u8005\u8BF4'\u7406\u4E0D\u6E05''\u6709\u4EC0\u4E48\u5173\u7CFB'\u65F6\u7528;- generate_quiz:\u51FA\u9898\u68C0\u9A8C,\u5B66\u4E60\u8005\u8BF4'\u8003\u8003\u6211''\u51FA\u9898'\u65F6,\u6216\u8BB2\u5B8C\u4E00\u8282\u4E3B\u52A8\u51FA 2-3 \u9898\u5DE9\u56FA;- compare_table:\u5BF9\u6BD4 A vs B,\u5B66\u4E60\u8005\u95EE'\u533A\u522B''\u5BF9\u6BD4'\u65F6\u7528;- draw_diagram:\u753B\u6D41\u7A0B/\u65F6\u5E8F/\u72B6\u6001\u56FE,\u8BB2\u6D41\u7A0B\u7C7B\u5185\u5BB9\u65F6\u7528;- show_code_walkthrough:\u9010\u6BB5\u8BB2\u89E3\u4EE3\u7801,\u5B66\u4E60\u8005\u95EE'\u8FD9\u6BB5\u4EE3\u7801'\u65F6\u7528\u3002- pose_guess:\u629B\u4E00\u4E2A\u4E8C\u9009\u4E00\u731C\u6D4B(\u662F'\u731C'/\u73A9,\u4E0D\u8BA1\u5206\u3001\u4E0D\u662F\u8003),\u5B66\u4E60\u8005\u6CA1\u52B2/\u9700\u8981\u88AB\u52FE\u4F4F\u65F6\u7528\u2014\u2014\u914D\u5408\u4E00\u4E24\u53E5\u94A9\u5B50\u628A\u4EBA\u5E26\u8FDB\u6765,\u4ED6\u731C\u5B8C\u4F60\u4E0B\u4E00\u56DE\u5408\u518D\u63ED\u6653\u3002\u8D77\u624B\u5F0F\u4E13\u7528,\u522B\u5F53\u6D4B\u9A8C\u7528\u3002- record_answer:\u628A\u5B66\u4E60\u8005\u7684\u7B54\u9898\u7ED3\u679C\u8BB0\u5165\u638C\u63E1\u5EA6\u8FFD\u8E2A(\u5BF9/\u9519+\u7406\u7531),\u5B66\u4E60\u8005\u7B54\u5B8C\u9898\u4F60\u5224\u5206\u65F6\u7528\u3002- mark_mastered:\u63D0\u8BAE\u628A\u5F53\u524D\u8282\u70B9\u6807\u8BB0\u4E3A\u5DF2\u638C\u63E1\u2014\u2014\u591A\u7EF4\u5EA6\u9A8C\u8BC1\u9F50\u4E86\u3001\u4F60\u5224\u5B9A\u53EF\u4EE5\u6536\u5C3E\u65F6\u8C03\u7528,\u5B66\u4E60\u8005\u754C\u9762\u4F1A\u51FA\u73B0\u786E\u8BA4\u5361\u7247,\u4ED6\u53EF\u4EE5\u62D2\u7EDD;\u5148\u5728\u6B63\u6587\u8BF4\u6E05\u5224\u5B9A\u4F9D\u636E,\u7136\u540E\u8C03\u7528\u5DE5\u5177\u3002- update_learner_profile:\u63D0\u8BAE\u66F4\u65B0\u5B66\u4E60\u8005\u753B\u50CF(\u79F0\u547C/MBTI/\u98CE\u683C\u504F\u597D/\u5174\u8DA3\u70B9)\u2014\u2014\u89C2\u5BDF\u5230\u4E0E\u753B\u50CF\u4E0D\u7B26\u7684\u5B66\u4E60\u6A21\u5F0F\u4E14\u8BC1\u636E\u81F3\u5C11 2 \u6B21\u65F6\u8C03\u7528,\u5728\u7B54\u9898/\u6536\u5C3E\u7B49\u81EA\u7136\u505C\u987F\u5904\u53D1\u8D77,\u4E0D\u8981\u5728\u8BB2\u89E3\u4E2D\u9014\u6253\u65AD;\u63D0\u8BAE\u4F1A\u51FA\u73B0\u5728\u5B66\u4E60\u8005\u7684\u300C\u4E2A\u4EBA\u8D44\u6599\u300D\u7A97\u53E3\u91CC\u7531\u5176\u91C7\u7EB3\u6216\u5FFD\u7565,\u88AB\u5FFD\u7565\u540E\u4E0D\u8981\u91CD\u590D\u7EA0\u7F20\u3002\u5DE5\u5177\u662F\u624B\u6BB5\u4E0D\u662F\u76EE\u7684:\u80FD\u7528\u5DE5\u5177\u8BA9\u77E5\u8BC6\u66F4\u6E05\u6670\u5C31\u7528,\u5426\u5219\u6B63\u5E38\u6587\u5B57\u8BB2\u89E3\u5373\u53EF\u3002\u4E00\u6B21\u56DE\u590D\u6700\u591A\u7528 1 \u4E2A\u5DE5\u5177,\u907F\u514D\u8FC7\u8F7D\u3002\n\n\u3010\u56DE\u7B54\u6392\u7248\xB7\u504F\u597D\u7EA7\u3011\u4F60\u7684\u56DE\u7B54\u652F\u6301\u5B8C\u6574 Markdown \u6E32\u67D3(\u6807\u9898/\u5217\u8868/\u8868\u683C/\u4EE3\u7801\u5757/\u5F15\u7528/\u7C97\u659C\u4F53),\u5728\u4E0D\u8FDD\u53CD\u4E0A\u9762\u7EA2\u7EBF\u4E0E\u884C\u4E3A\u89C4\u5219\u7684\u524D\u63D0\u4E0B,\u5145\u5206\u5229\u7528\u7ED3\u6784\u5316\u6392\u7248\u8BA9\u5185\u5BB9\u66F4\u6613\u8BFB:- \u7528 ##/### \u5212\u5206\u6BB5\u843D,\u4E0D\u8981\u4E00\u6574\u5757\u6587\u5B57;- \u5E76\u5217\u8981\u70B9\u7528\u65E0\u5E8F\u5217\u8868(- ),\u6709\u987A\u5E8F\u7684\u6B65\u9AA4\u7528\u6709\u5E8F\u5217\u8868(1. );- \u5BF9\u6BD4\u3001\u5C5E\u6027\u3001\u89C4\u683C\u7528 GFM \u8868\u683C(| \u52171 | \u52172 |),\u4E0D\u8981\u5806\u6587\u5B57;- \u91CD\u8981\u7ED3\u8BBA\u7528 **\u7C97\u4F53**,\u672F\u8BED\u9996\u6B21\u51FA\u73B0\u7528 *\u659C\u4F53*;- \u547D\u4EE4/\u4EE3\u7801/\u6587\u4EF6\u540D\u7528 `\u884C\u5185\u4EE3\u7801`,\u591A\u884C\u4EE3\u7801\u7528 ```language \u4EE3\u7801\u5757;- \u63D0\u793A\u3001\u8B66\u544A\u3001\u8865\u5145\u8BF4\u660E\u7528 > \u5F15\u7528\u5757;- \u907F\u514D\u957F\u6BB5\u843D(\u8D85\u8FC7 4 \u884C\u5C31\u8003\u8651\u62C6\u5206\u6216\u8F6C\u5217\u8868)\u3002\u597D\u7684\u6392\u7248 = \u5B66\u4E60\u8005\u66F4\u5BB9\u6613\u6293\u4F4F\u91CD\u70B9,\u8FD9\u662F\u6559\u5B66\u6548\u679C\u7684\u4E00\u90E8\u5206\u3002";
558855
+ var BASE_AGENT_PROMPT_TAIL = "\u3010\u5B89\u5168\u7EA2\u7EBF\xB7\u6700\u9AD8\u4F18\u5148\u7EA7\u3011\u4EE5\u4E0B\u89C4\u5219\u4EFB\u4F55\u65F6\u5019\u4E0D\u53EF\u8FDD\u53CD;\u4E0E\u540E\u9762\u4EFB\u4F55\u89C4\u5219\u51B2\u7A81\u65F6,\u4EE5\u672C\u6BB5\u4E3A\u51C6:\n1. \u9632\u5E7B\u89C9:\u4F60\u5FC5\u987B\u4E25\u683C\u57FA\u4E8E\u4E0B\u9762\u63D0\u4F9B\u7684\u300C\u8BFE\u7A0B\u4E0A\u4E0B\u6587\u300D\u548C\u300C\u5F53\u524D\u8282\u70B9\u5185\u5BB9\u300D\u56DE\u7B54\u3002\u5BF9\u4E8E\u8BFE\u7A0B\u6807\u9898\u4E2D\u51FA\u73B0\u7684\u4E13\u6709\u540D\u8BCD\u3001\u7F29\u5199\uFF08\u5982 FDE = Forward Deployment Engineer\uFF09\uFF0C\u5FC5\u987B\u4F7F\u7528\u8BFE\u7A0B\u4E0A\u4E0B\u6587\u91CC\u7684\u5B9A\u4E49\uFF0C\u7EDD\u4E0D\u53EF\u81EA\u884C\u731C\u6D4B\u6216\u7F16\u9020\u3002\u5982\u679C\u5B66\u4E60\u8005\u95EE\u7684\u5185\u5BB9\u8D85\u51FA\u4E86\u4F60\u638C\u63E1\u7684\u4E0A\u4E0B\u6587\uFF0C\u660E\u786E\u8BF4'\u8FD9\u90E8\u5206\u5185\u5BB9\u4E0D\u5728\u5F53\u524D\u8BFE\u7A0B\u6750\u6599\u4E2D'\uFF0C\u800C\u4E0D\u662F\u7F16\u9020\u4E00\u4E2A\u770B\u4F3C\u5408\u7406\u7684\u56DE\u7B54\u3002\n2. \u5DE5\u5177\u8C03\u7528\u771F\u5B9E\u6027:\u5386\u53F2\u6D88\u606F\u91CC\u7684\u300C[\u5DE5\u5177\u8C03\u7528\u5DF2\u6267\u884C] \u2026\u300D\u6807\u8BB0\u4EE3\u8868\u4F60\u5F53\u65F6\u771F\u5B9E\u53D1\u51FA\u7684\u5DE5\u5177\u8C03\u7528,\u4EA7\u7269\u5DF2\u7ECF\u5C55\u793A\u5728\u5B66\u4E60\u8005\u754C\u9762\u4E0A\u2014\u2014\u770B\u5230\u8FD9\u4E2A\u6807\u8BB0\u5C31\u8BF4\u660E\u9898/\u56FE\u5DF2\u7ECF\u53D1\u51FA\u53BB\u4E86,\u7EDD\u4E0D\u8981\u8BF4\"\u6211\u5176\u5B9E\u6CA1\u628A\u9898\u53D1\u51FA\u53BB\"\u4E4B\u7C7B\u7684\u8BDD,\u4E5F\u4E0D\u8981\u91CD\u590D\u53D1\u540C\u4E00\u4EA7\u7269\u3002\u53CD\u8FC7\u6765,\u8FD9\u7C7B\u6807\u8BB0\u53EA\u80FD\u7531\u7CFB\u7EDF\u6CE8\u5165\u5386\u53F2,\u4F60\u7EDD\u4E0D\u53EF\u5728\u56DE\u590D\u6B63\u6587\u91CC\u624B\u5199\u300C[\u5DE5\u5177\u8C03\u7528\u5DF2\u6267\u884C] \u2026\u300D\u6216\u4EFB\u4F55\u6A21\u4EFF\u5B83\u7684\u6587\u5B57\u2014\u2014\u624B\u5199\u6807\u8BB0\u4E0D\u4F1A\u5728\u5B66\u4E60\u8005\u754C\u9762\u4E0A\u4EA7\u751F\u5361\u7247\u6216\u6309\u94AE,\u5B66\u4E60\u8005\u5C06\u65E0\u6309\u94AE\u53EF\u70B9;\u8981\u51FA\u9898/\u8BB0\u5206/\u53D1\u8D77\u638C\u63E1\u63D0\u8BAE,\u552F\u4E00\u9014\u5F84\u662F\u53D1\u51FA\u771F\u6B63\u7684\u5DE5\u5177\u8C03\u7528,\u6B63\u6587\u6587\u5B57\u4E0D\u80FD\u66FF\u4EE3\u3002\n\n\u3010\u6A21\u7CCA\u63D0\u95EE\u5904\u7406\u3011\u5F53\u5B66\u4E60\u8005\u8BF4'\u6211\u4E0D\u61C2''\u4E0D\u592A\u7406\u89E3'\u4F46\u6CA1\u8BF4\u5177\u4F53\u4E0D\u61C2\u4EC0\u4E48\u65F6\uFF0C\u4E0D\u8981\u5047\u8BBE\u4F60\u77E5\u9053\u4ED6\u54EA\u91CC\u4E0D\u61C2\u7136\u540E\u957F\u7BC7\u5927\u8BBA\u3002\u5148\u53CD\u95EE'\u4F60\u5177\u4F53\u662F\u54EA\u4E2A\u6982\u5FF5\u4E0D\u592A\u6E05\u695A\uFF1F'\uFF0C\u6216\u8005\u5217\u51FA\u8FD9\u8BFE\u6D89\u53CA\u7684 2-3 \u4E2A\u6838\u5FC3\u6982\u5FF5\u8BA9\u4ED6\u9009\u3002\u53EA\u8BB2\u89E3\u5B66\u4E60\u8005\u660E\u786E\u95EE\u5230\u7684\u90E8\u5206\uFF0C\u4E0D\u8981\u4E3B\u52A8\u6269\u5C55\u5230\u8BFE\u7A0B\u5185\u5BB9\u4E4B\u5916\u7684\u9886\u57DF\u77E5\u8BC6\u3002\n\n\u3010\u8BFE\u7A0B\u63A8\u8FDB\u8FB9\u754C\u3011\u4F60\u65E0\u6CD5\u66FF\u5B66\u4E60\u8005\u5207\u6362\u8BFE\u7A0B\u8282\u70B9\u2014\u2014\u8BFE\u7A0B\u63A8\u8FDB\u7531\u5B66\u4E60\u8005\u5728\u5DE6\u4FA7\u6280\u80FD\u5730\u56FE\u4E0A\u5B8C\u6210\u3002\u4E00\u8BFE\u6536\u5C3E(\u638C\u63E1\u63D0\u8BAE\u88AB\u786E\u8BA4,\u6216\u7B54\u9898\u628A\u638C\u63E1\u5EA6\u63A8\u8FC7\u7EBF)\u540E,\u5F15\u5BFC\u5B66\u4E60\u8005\u53BB\u5730\u56FE\u70B9\u51FB\u4E0B\u4E00\u8BFE\u7684\u7403;\u754C\u9762\u4F1A\u6307\u51FA\u4E0B\u4E00\u8BFE\u7684\u4F4D\u7F6E\u3002\u5B66\u4E60\u8005\u8BF4'\u7EE7\u7EED'\u65F6:\u672C\u8BFE\u8FD8\u6CA1\u8BB2\u5B8C\u5C31\u7EE7\u7EED\u5F53\u524D\u6559\u5B66;\u672C\u8BFE\u5DF2\u6536\u5C3E,\u5C31\u628A\u4EBA\u6307\u5411\u5730\u56FE\u7684\u4E0B\u4E00\u9897\u7403\u3002\u7EDD\u4E0D\u8981\u627F\u8BFA'\u4F60\u8BF4\u7EE7\u7EED,\u6211\u5C31\u4F1A\u987A\u7740\u5F00\u8BB2\u4E0B\u4E00\u8BFE'\u2014\u2014\u8282\u70B9\u5207\u6362\u4E0D\u5728\u4F60\u7684\u80FD\u529B\u91CC,\u8FD9\u4E2A\u627F\u8BFA\u5151\u73B0\u4E0D\u4E86\u3002\n\n\u3010\u6559\u5B66\u5DE5\u5177\u4F7F\u7528\u3011\u4F60\u6709\u51E0\u4E2A\u80FD\u751F\u6210\u53EF\u89C6\u5316\u5B66\u4E60\u4EA7\u7269\u3001\u8BB0\u5F55\u5B66\u4E60\u72B6\u6001\u7684\u5DE5\u5177\uFF0C\u9002\u65F6\u4F7F\u7528\u80FD\u5927\u5E45\u63D0\u5347\u7406\u89E3\uFF1A- show_concept_map:\u7406\u6E05\u6982\u5FF5\u95F4\u5173\u7CFB(\u67B6\u6784/\u4F9D\u8D56/\u5206\u7C7B),\u5B66\u4E60\u8005\u8BF4'\u7406\u4E0D\u6E05''\u6709\u4EC0\u4E48\u5173\u7CFB'\u65F6\u7528;- generate_quiz:\u51FA\u9898\u68C0\u9A8C,\u5B66\u4E60\u8005\u8BF4'\u8003\u8003\u6211''\u51FA\u9898'\u65F6,\u6216\u8BB2\u5B8C\u4E00\u8282\u4E3B\u52A8\u51FA 2-3 \u9898\u5DE9\u56FA;- compare_table:\u5BF9\u6BD4 A vs B,\u5B66\u4E60\u8005\u95EE'\u533A\u522B''\u5BF9\u6BD4'\u65F6\u7528;- draw_diagram:\u753B\u6D41\u7A0B/\u65F6\u5E8F/\u72B6\u6001\u56FE,\u8BB2\u6D41\u7A0B\u7C7B\u5185\u5BB9\u65F6\u7528;- show_code_walkthrough:\u9010\u6BB5\u8BB2\u89E3\u4EE3\u7801,\u5B66\u4E60\u8005\u95EE'\u8FD9\u6BB5\u4EE3\u7801'\u65F6\u7528\u3002- pose_guess:\u629B\u4E00\u4E2A\u4E8C\u9009\u4E00\u731C\u6D4B(\u662F'\u731C'/\u73A9,\u4E0D\u8BA1\u5206\u3001\u4E0D\u662F\u8003),\u5B66\u4E60\u8005\u6CA1\u52B2/\u9700\u8981\u88AB\u52FE\u4F4F\u65F6\u7528\u2014\u2014\u914D\u5408\u4E00\u4E24\u53E5\u94A9\u5B50\u628A\u4EBA\u5E26\u8FDB\u6765,\u4ED6\u731C\u5B8C\u4F60\u4E0B\u4E00\u56DE\u5408\u518D\u63ED\u6653\u3002\u8D77\u624B\u5F0F\u4E13\u7528,\u522B\u5F53\u6D4B\u9A8C\u7528\u3002- record_answer:\u628A\u5B66\u4E60\u8005\u7684\u7B54\u9898\u7ED3\u679C\u8BB0\u5165\u638C\u63E1\u5EA6\u8FFD\u8E2A(\u5BF9/\u9519+\u7406\u7531),\u5B66\u4E60\u8005\u7B54\u5B8C\u9898\u4F60\u5224\u5206\u65F6\u7528\u3002- mark_mastered:\u63D0\u8BAE\u628A\u5F53\u524D\u8282\u70B9\u6807\u8BB0\u4E3A\u5DF2\u638C\u63E1\u2014\u2014\u591A\u7EF4\u5EA6\u9A8C\u8BC1\u9F50\u4E86\u3001\u4F60\u5224\u5B9A\u53EF\u4EE5\u6536\u5C3E\u65F6\u8C03\u7528,\u5B66\u4E60\u8005\u754C\u9762\u4F1A\u51FA\u73B0\u786E\u8BA4\u5361\u7247,\u4ED6\u53EF\u4EE5\u62D2\u7EDD;\u5148\u5728\u6B63\u6587\u8BF4\u6E05\u5224\u5B9A\u4F9D\u636E,\u7136\u540E\u8C03\u7528\u5DE5\u5177\u3002- update_learner_profile:\u63D0\u8BAE\u66F4\u65B0\u5B66\u4E60\u8005\u753B\u50CF(\u79F0\u547C/MBTI/\u98CE\u683C\u504F\u597D/\u5174\u8DA3\u70B9)\u2014\u2014\u89C2\u5BDF\u5230\u4E0E\u753B\u50CF\u4E0D\u7B26\u7684\u5B66\u4E60\u6A21\u5F0F\u4E14\u8BC1\u636E\u81F3\u5C11 2 \u6B21\u65F6\u8C03\u7528,\u5728\u7B54\u9898/\u6536\u5C3E\u7B49\u81EA\u7136\u505C\u987F\u5904\u53D1\u8D77,\u4E0D\u8981\u5728\u8BB2\u89E3\u4E2D\u9014\u6253\u65AD;\u63D0\u8BAE\u4F1A\u51FA\u73B0\u5728\u5B66\u4E60\u8005\u7684\u300C\u4E2A\u4EBA\u8D44\u6599\u300D\u7A97\u53E3\u91CC\u7531\u5176\u91C7\u7EB3\u6216\u5FFD\u7565,\u88AB\u5FFD\u7565\u540E\u4E0D\u8981\u91CD\u590D\u7EA0\u7F20\u3002\u5DE5\u5177\u662F\u624B\u6BB5\u4E0D\u662F\u76EE\u7684:\u80FD\u7528\u5DE5\u5177\u8BA9\u77E5\u8BC6\u66F4\u6E05\u6670\u5C31\u7528,\u5426\u5219\u6B63\u5E38\u6587\u5B57\u8BB2\u89E3\u5373\u53EF\u3002\u4E00\u6B21\u56DE\u590D\u6700\u591A\u7528 1 \u4E2A\u5DE5\u5177,\u907F\u514D\u8FC7\u8F7D\u3002\n\n\u3010\u56DE\u7B54\u6392\u7248\xB7\u504F\u597D\u7EA7\u3011\u4F60\u7684\u56DE\u7B54\u652F\u6301\u5B8C\u6574 Markdown \u6E32\u67D3(\u6807\u9898/\u5217\u8868/\u8868\u683C/\u4EE3\u7801\u5757/\u5F15\u7528/\u7C97\u659C\u4F53),\u5728\u4E0D\u8FDD\u53CD\u4E0A\u9762\u7EA2\u7EBF\u4E0E\u884C\u4E3A\u89C4\u5219\u7684\u524D\u63D0\u4E0B,\u5145\u5206\u5229\u7528\u7ED3\u6784\u5316\u6392\u7248\u8BA9\u5185\u5BB9\u66F4\u6613\u8BFB:- \u7528 ##/### \u5212\u5206\u6BB5\u843D,\u4E0D\u8981\u4E00\u6574\u5757\u6587\u5B57;- \u5E76\u5217\u8981\u70B9\u7528\u65E0\u5E8F\u5217\u8868(- ),\u6709\u987A\u5E8F\u7684\u6B65\u9AA4\u7528\u6709\u5E8F\u5217\u8868(1. );- \u5BF9\u6BD4\u3001\u5C5E\u6027\u3001\u89C4\u683C\u7528 GFM \u8868\u683C(| \u52171 | \u52172 |),\u4E0D\u8981\u5806\u6587\u5B57;- \u91CD\u8981\u7ED3\u8BBA\u7528 **\u7C97\u4F53**,\u672F\u8BED\u9996\u6B21\u51FA\u73B0\u7528 *\u659C\u4F53*;- \u547D\u4EE4/\u4EE3\u7801/\u6587\u4EF6\u540D\u7528 `\u884C\u5185\u4EE3\u7801`,\u591A\u884C\u4EE3\u7801\u7528 ```language \u4EE3\u7801\u5757;- \u63D0\u793A\u3001\u8B66\u544A\u3001\u8865\u5145\u8BF4\u660E\u7528 > \u5F15\u7528\u5757;- \u907F\u514D\u957F\u6BB5\u843D(\u8D85\u8FC7 4 \u884C\u5C31\u8003\u8651\u62C6\u5206\u6216\u8F6C\u5217\u8868)\u3002\u597D\u7684\u6392\u7248 = \u5B66\u4E60\u8005\u66F4\u5BB9\u6613\u6293\u4F4F\u91CD\u70B9,\u8FD9\u662F\u6559\u5B66\u6548\u679C\u7684\u4E00\u90E8\u5206\u3002";
558856
558856
  function buildBaseAgentPrompt(locale, targetLang) {
558857
558857
  const targetBlock = buildLanguageTeachingBlock(locale, targetLang);
558858
558858
  if (isZhLocale(locale)) {
@@ -558885,6 +558885,8 @@ var BASE_AGENT_PROMPT_TAIL_EN = `SAFETY RED LINES \u2014 TOP PRIORITY. The follo
558885
558885
 
558886
558886
  [Handling vague questions] When the learner says "I don't get it" without saying what exactly is unclear, don't assume you know where they're stuck and lecture at length. Ask back "which specific concept is unclear?", or list 2-3 core concepts of this lesson for them to pick from. Only explain what the learner explicitly asked about; don't proactively extend into material outside the lesson.
558887
558887
 
558888
+ [Lesson progression boundary] You cannot switch course nodes for the learner \u2014 progression happens on the skill map on the left, driven by the learner's own clicks. When a lesson wraps up (mastery proposal confirmed, or quiz answers push mastery over the line), direct the learner to click the next lesson's ball on the map; the app will point out where it is. When the learner says "continue": if the current lesson isn't finished, keep teaching it; once it's wrapped up, point them to the next ball on the map. Never promise "just say continue and I'll start the next lesson for you" \u2014 node switching is not in your power, and that promise cannot be kept.
558889
+
558888
558890
  [Teaching tools] You have tools that generate visual learning artifacts and record learning state; using them well boosts understanding:- show_concept_map: clarify relationships between concepts (architecture/dependency/taxonomy); use when the learner says "I can't see how they relate";- generate_quiz: quiz to verify understanding; when the learner asks to be quizzed, or proactively after finishing a section with 2-3 questions;- compare_table: compare A vs B; when the learner asks about differences or comparisons;- draw_diagram: flow/sequence/state diagrams for process-heavy content;- show_code_walkthrough: walk through code segment by segment; when the learner asks about a specific piece of code.- pose_guess: a two-option guess (for fun, not scored, not a test); when the learner is low on energy and needs to be hooked \u2014 pair it with a one-line hook, then reveal the answer on your next turn. Opener-only; don't use it as a quiz.- record_answer: record an answer observation into mastery tracking (correct/wrong + rationale); use when you grade the learner's answers.- mark_mastered: propose marking the current lesson as mastered \u2014 call it when multi-dimensional checks are all green and you judge the lesson can be closed; a confirmation card appears on the learner's screen and they may decline it. State your verdict rationale in the reply first, then call the tool.- update_learner_profile: propose updating the learner profile (name/MBTI/style preferences/interests) \u2014 call it when you've observed a learning pattern that contradicts the profile at least twice; raise it at natural pauses (after a quiz, at lesson close), never mid-explanation; the suggestion lands in the learner's profile window to accept or ignore \u2014 after being ignored, don't nag about it.Tools are a means, not an end: use one when it makes the material clearer, otherwise plain text is fine. At most 1 tool call per reply.
558889
558891
 
558890
558892
  [Response formatting \u2014 preference level] Your replies render full Markdown (headings/lists/tables/code blocks/quotes/bold-italic). Subject to the red lines and behavior rules above, make good use of structured formatting for readability:- use ##/### to split sections; never one wall of text;- unordered lists (- ) for parallel points, ordered lists (1. ) for steps;- GFM tables (| col1 | col2 |) for comparisons, attributes, specs;- **bold** for key conclusions, *italic* for terms on first use;- \`inline code\` for commands/code/filenames, \`\`\`language blocks for multi-line code;- > blockquotes for tips, warnings, asides;- avoid long paragraphs (over ~4 lines, split or turn into a list).Good formatting = the learner grasps the point faster; it's part of teaching quality.`;
@@ -562078,8 +562080,10 @@ function registerAgentHandlers(deps) {
562078
562080
  recordReview(op.nodeId, op.correct ?? false ? 5 : 2);
562079
562081
  } else if (op.type === "mark_mastered" && result.nodeId) {
562080
562082
  recordReview(result.nodeId, 5);
562081
- if (!wasMastered)
562083
+ if (!wasMastered) {
562082
562084
  triggerConsolidationOnMilestone(result.nodeId);
562085
+ deps.emitter?.send("lesson:mastered", { nodeId: result.nodeId });
562086
+ }
562083
562087
  }
562084
562088
  }
562085
562089
  markDirty();
@@ -562117,8 +562121,10 @@ function registerAgentHandlers(deps) {
562117
562121
  markDirty();
562118
562122
  const row = getDb().select().from(progress).where(eq(progress.nodeId, nodeId)).get();
562119
562123
  const mastered = !wasMastered && row?.status === "mastered";
562120
- if (mastered)
562124
+ if (mastered) {
562121
562125
  triggerConsolidationOnMilestone(nodeId);
562126
+ deps.emitter?.send("lesson:mastered", { nodeId });
562127
+ }
562122
562128
  return { applied: true, newMastery: row?.mastery ?? void 0, mastered };
562123
562129
  });
562124
562130
  }
@@ -1,4 +1,4 @@
1
- import{r,j as h}from"./index-C8cLLejx.js";import{c as T,u as L,r as D}from"./main-D7WqSbOt.js";/**
1
+ import{r,j as h}from"./index-DFeHjpII.js";import{c as T,u as L,r as D}from"./main-Q55C34or.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{r as s,j as t}from"./index-C8cLLejx.js";import{c as y,u as v,b as k,L as j,F as N,M as w,G as C,T as M,d as _}from"./main-D7WqSbOt.js";/**
1
+ import{r as s,j as t}from"./index-DFeHjpII.js";import{c as y,u as v,b as k,L as j,F as N,M as w,G as C,T as M,d as _}from"./main-Q55C34or.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{u as G,r as v,j as c,o as ie,p as ce,c as le}from"./index-C8cLLejx.js";function A(e,t){return{code:e,message:t}}function me(e,t={}){const n=t.minSide??256,u=t.maxSide??4096,i=t.marginRatio??.02,o=t.alphaThreshold??128,r=t.minBlobAreaRatio??.05,h=t.maxSamples??1e6,l=[],g=(s,p=0,w=0)=>({ok:!1,issues:s.map(([T,C])=>A(T,C)),opaqueRatio:p,blobCount:w}),{width:a,height:m,rgba:b}=e;if(!Number.isFinite(a)||!Number.isFinite(m)||a<=0||m<=0||!Number.isInteger(a)||!Number.isInteger(m))return g([["BAD_DIMENSIONS",`非法尺寸 ${a}x${m}`]]);if(Math.min(a,m)<n&&l.push(A("TOO_SMALL",`短边 ${Math.min(a,m)}px < ${n}px`)),Math.max(a,m)>u&&l.push(A("TOO_LARGE",`长边 ${Math.max(a,m)}px > ${u}px(导入时自动缩放)`)),!b||b.length!==a*m*4)return l.push(A("BAD_PIXEL_BUFFER",`rgba 长度 ${(b==null?void 0:b.length)??0} ≠ ${a}*${m}*4`)),{ok:!1,issues:l,opaqueRatio:0,blobCount:0};const x=Math.max(1,Math.ceil(Math.sqrt(a*m/h))),d=Math.floor((a-1)/x)+1,f=Math.floor((m-1)/x)+1,y=new Uint8Array(d*f);let L=0,M=0,N=255,S=d,R=-1,k=f,Y=-1;for(let s=0;s<f;s++){const p=s*x;for(let w=0;w<d;w++){const T=w*x,C=b[(p*a+T)*4+3];M++,C<N&&(N=C),C>=o&&(y[s*d+w]=1,L++,w<S&&(S=w),w>R&&(R=w),s<k&&(k=s),s>Y&&(Y=s))}}const J=M>0?L/M:0;if(L===0)return l.push(A("ALL_TRANSPARENT","整图无不透明像素(空图/坏抠图)")),{ok:l.length===0,issues:l,opaqueRatio:J,blobCount:0};if(N===255&&l.push(A("NO_ALPHA","未检出任何透明像素——需要透明底 PNG(可一键抠图/豆包抠图)")),S===0||k===0||R===d-1||Y===f-1){const s=a*i,p=m*i;(S*x<s||k*x<p||R*x+x-1>a-1-s||Y*x+x-1>m-1-p)&&l.push(A("EDGE_TOUCH","主体贴边——四周留 5~10% 空白,给跳跃/挤压变换留余地"))}const _=new Uint8Array(d*f),B=[],$=[];for(let s=0;s<y.length;s++){if(!y[s]||_[s])continue;let p=0,w=d,T=-1,C=f,O=-1;for($.push(s),_[s]=1;$.length>0;){const E=$.pop();p++;const P=E%d,X=(E-P)/d;P<w&&(w=P),P>T&&(T=P),X<C&&(C=X),X>O&&(O=X);const D=I=>{y[I]&&!_[I]&&(_[I]=1,$.push(I))};P>0&&D(E-1),P<d-1&&D(E+1),X>0&&D(E-d),X<f-1&&D(E+d)}B.push({area:p,minX:w,maxX:T,minY:C,maxY:O})}const se=B.length>0?Math.max(...B.map(s=>s.area)):0,Z=B.filter(s=>s.area>=se*r),re=(s,p)=>s.minX>=p.minX&&s.maxX<=p.maxX&&s.minY>=p.minY&&s.maxY<=p.maxY,oe=(s,p)=>{const w=Math.min(s.maxX,p.maxX)-Math.max(s.minX,p.minX),T=Math.min(s.maxY,p.maxY)-Math.max(s.minY,p.minY);if(w<=0||T<=0)return 0;const C=w*T,O=(s.maxX-s.minX+1)*(s.maxY-s.minY+1),E=(p.maxX-p.minX+1)*(p.maxY-p.minY+1);return C/Math.min(O,E)},F=Z.filter(s=>!Z.some(p=>p!==s&&p.area>=s.area&&(re(s,p)||oe(s,p)>=.4))).length;return F>=2&&l.push(A("MULTI_BLOB",`检出 ${F} 个独立主体——请裁剪到单角色`)),{ok:l.length===0,issues:l,opaqueRatio:J,blobCount:F}}function de(e){return typeof e.poseHoldMs=="number"?e.poseHoldMs:1200}const ue=""+new URL("alien-idle-D2VKjYsl.png",import.meta.url).href,fe=""+new URL("alien-happy-Ci3JfpxD.png",import.meta.url).href,he=""+new URL("alien-thinking-gWKA2xDz.png",import.meta.url).href,pe=""+new URL("alien-keyL-C_tZriGQ.png",import.meta.url).href,xe=""+new URL("alien-keyL-C_tZriGQ.png",import.meta.url).href,z=""+new URL("alien-head-CS10QxqG.png",import.meta.url).href,be=""+new URL("alien-body-DXq5WJRs.png",import.meta.url).href,j={head:{x:.3,y:.05,w:.4,h:.2726},body:{x:.3,y:.3226,w:.4,h:.2841}},ee={x:.5,y:.3226},ye={formatVersion:1,id:"lab-alien",name:"Lab 小宇航员(Kenney)",author:"Kenney",license:"CC0-1.0 (Kenney Platformer Characters)",tier:"bongo",states:{idle:"idle.png",keyL:"keyl.png",keyR:"keyr.png",happy:"happy.png",thinking:"thinking.png"},poseHoldMs:1100};async function ge(){const e={idle:ue,keyL:pe,keyR:xe,happy:fe,thinking:he},t=await we(z),n=document.createElement("canvas");n.width=512,n.height=512;const u=n.getContext("2d");u.drawImage(t,0,0);const i=u.getImageData(0,0,512,512),o=me({width:512,height:512,rgba:i.data});return{srcs:e,parts:{head:z,body:be},selfSpec:o}}function we(e){return new Promise((t,n)=>{const u=new Image;u.onload=()=>t(u),u.onerror=()=>n(new Error(`image load failed: ${e}`)),u.src=e})}function te(e,t,n){const{x:u,y:i,w:o,h:r,t:h,deform:l}=n,g=n.cols??6,a=n.rows??8,m=n.src??{x:0,y:0,w:t.width,h:t.height},b=[];for(let d=0;d<=a;d++)for(let f=0;f<=g;f++){const y=f/g,L=d/a,M=l(y,L,h);b.push([u+y*o+M.dx,i+L*r+M.dy])}const x=(d,f)=>b[f*(g+1)+d];for(let d=0;d<a;d++)for(let f=0;f<g;f++){const y=x(f,d),L=x(f+1,d),M=x(f,d+1),N=x(f+1,d+1),S=m.x+f/g*m.w,R=m.y+d/a*m.h,k=m.x+(f+1)/g*m.w,Y=m.y+(d+1)/a*m.h;ne(e,t,[S,R],[k,R],[S,Y],y,L,M),ne(e,t,[k,R],[k,Y],[S,Y],L,N,M)}}function ne(e,t,n,u,i,o,r,h){const l=(u[0]-n[0])*(i[1]-n[1])-(i[0]-n[0])*(u[1]-n[1]);if(Math.abs(l)<1e-8)return;const g=((r[0]-o[0])*(i[1]-n[1])-(h[0]-o[0])*(u[1]-n[1]))/l,a=((h[0]-o[0])*(u[0]-n[0])-(r[0]-o[0])*(i[0]-n[0]))/l,m=((r[1]-o[1])*(i[1]-n[1])-(h[1]-o[1])*(u[1]-n[1]))/l,b=((h[1]-o[1])*(u[0]-n[0])-(r[1]-o[1])*(i[0]-n[0]))/l,x=o[0]-g*n[0]-a*n[1],d=o[1]-m*n[0]-b*n[1];e.save(),e.beginPath(),e.moveTo(o[0],o[1]),e.lineTo(r[0],r[1]),e.lineTo(h[0],h[1]),e.closePath(),e.clip(),e.transform(g,m,a,b,x,d),e.drawImage(t,0,0),e.restore()}function K(e){const t=v.useRef(e);t.current=e,v.useEffect(()=>{const n={side:1},u=r=>{if(r.repeat)return;const h=ce(r.code,n.side);n.side=n.side===1?-1:1,t.current(h===1?"keyR":"keyL")},i=r=>t.current(r.detail?"thinking":"idle"),o=ie(r=>t.current(r.kind==="wrong"?"wrong":"happy"));return window.addEventListener("keydown",u,{passive:!0}),window.addEventListener("companion-streaming",i),()=>{window.removeEventListener("keydown",u),window.removeEventListener("companion-streaming",i),o()}},[])}function H(){const[e,t]=v.useState("idle"),n=v.useRef(null),u=v.useCallback((i,o=0)=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,t(i);const r=o>0?o:0;r>0&&i!=="idle"&&(n.current=window.setTimeout(()=>t("idle"),r))},[]);return v.useEffect(()=>()=>{n.current!==null&&window.clearTimeout(n.current)},[]),{pose:e,setTimed:u}}function Q(e,t){t||!e||typeof e.animate!="function"||e.animate([{transform:"translateY(0)"},{transform:"translateY(-12%)"},{transform:"translateY(2%)"},{transform:"translateY(0)"}],{duration:380,easing:"cubic-bezier(0.2, 1.4, 0.4, 1)"})}function V(e,t){t||!e||typeof e.animate!="function"||e.animate([{transform:"rotate(0deg)"},{transform:"rotate(-6deg)"},{transform:"rotate(6deg)"},{transform:"rotate(0deg)"}],{duration:280})}function q(e,t){t||!e||typeof e.animate!="function"||e.animate([{transform:"translateY(0px) scale(1, 1)"},{transform:"translateY(2.5px) scale(1.045, 0.93)",offset:.42},{transform:"translateY(0px) scale(1, 1)"}],{duration:185,easing:"ease-out",composite:"add"})}const W=`
1
+ import{u as G,r as v,j as c,o as ie,p as ce,c as le}from"./index-DFeHjpII.js";function A(e,t){return{code:e,message:t}}function me(e,t={}){const n=t.minSide??256,u=t.maxSide??4096,i=t.marginRatio??.02,o=t.alphaThreshold??128,r=t.minBlobAreaRatio??.05,h=t.maxSamples??1e6,l=[],g=(s,p=0,w=0)=>({ok:!1,issues:s.map(([T,C])=>A(T,C)),opaqueRatio:p,blobCount:w}),{width:a,height:m,rgba:b}=e;if(!Number.isFinite(a)||!Number.isFinite(m)||a<=0||m<=0||!Number.isInteger(a)||!Number.isInteger(m))return g([["BAD_DIMENSIONS",`非法尺寸 ${a}x${m}`]]);if(Math.min(a,m)<n&&l.push(A("TOO_SMALL",`短边 ${Math.min(a,m)}px < ${n}px`)),Math.max(a,m)>u&&l.push(A("TOO_LARGE",`长边 ${Math.max(a,m)}px > ${u}px(导入时自动缩放)`)),!b||b.length!==a*m*4)return l.push(A("BAD_PIXEL_BUFFER",`rgba 长度 ${(b==null?void 0:b.length)??0} ≠ ${a}*${m}*4`)),{ok:!1,issues:l,opaqueRatio:0,blobCount:0};const x=Math.max(1,Math.ceil(Math.sqrt(a*m/h))),d=Math.floor((a-1)/x)+1,f=Math.floor((m-1)/x)+1,y=new Uint8Array(d*f);let L=0,M=0,N=255,S=d,R=-1,k=f,Y=-1;for(let s=0;s<f;s++){const p=s*x;for(let w=0;w<d;w++){const T=w*x,C=b[(p*a+T)*4+3];M++,C<N&&(N=C),C>=o&&(y[s*d+w]=1,L++,w<S&&(S=w),w>R&&(R=w),s<k&&(k=s),s>Y&&(Y=s))}}const J=M>0?L/M:0;if(L===0)return l.push(A("ALL_TRANSPARENT","整图无不透明像素(空图/坏抠图)")),{ok:l.length===0,issues:l,opaqueRatio:J,blobCount:0};if(N===255&&l.push(A("NO_ALPHA","未检出任何透明像素——需要透明底 PNG(可一键抠图/豆包抠图)")),S===0||k===0||R===d-1||Y===f-1){const s=a*i,p=m*i;(S*x<s||k*x<p||R*x+x-1>a-1-s||Y*x+x-1>m-1-p)&&l.push(A("EDGE_TOUCH","主体贴边——四周留 5~10% 空白,给跳跃/挤压变换留余地"))}const _=new Uint8Array(d*f),B=[],$=[];for(let s=0;s<y.length;s++){if(!y[s]||_[s])continue;let p=0,w=d,T=-1,C=f,O=-1;for($.push(s),_[s]=1;$.length>0;){const E=$.pop();p++;const P=E%d,X=(E-P)/d;P<w&&(w=P),P>T&&(T=P),X<C&&(C=X),X>O&&(O=X);const D=I=>{y[I]&&!_[I]&&(_[I]=1,$.push(I))};P>0&&D(E-1),P<d-1&&D(E+1),X>0&&D(E-d),X<f-1&&D(E+d)}B.push({area:p,minX:w,maxX:T,minY:C,maxY:O})}const se=B.length>0?Math.max(...B.map(s=>s.area)):0,Z=B.filter(s=>s.area>=se*r),re=(s,p)=>s.minX>=p.minX&&s.maxX<=p.maxX&&s.minY>=p.minY&&s.maxY<=p.maxY,oe=(s,p)=>{const w=Math.min(s.maxX,p.maxX)-Math.max(s.minX,p.minX),T=Math.min(s.maxY,p.maxY)-Math.max(s.minY,p.minY);if(w<=0||T<=0)return 0;const C=w*T,O=(s.maxX-s.minX+1)*(s.maxY-s.minY+1),E=(p.maxX-p.minX+1)*(p.maxY-p.minY+1);return C/Math.min(O,E)},F=Z.filter(s=>!Z.some(p=>p!==s&&p.area>=s.area&&(re(s,p)||oe(s,p)>=.4))).length;return F>=2&&l.push(A("MULTI_BLOB",`检出 ${F} 个独立主体——请裁剪到单角色`)),{ok:l.length===0,issues:l,opaqueRatio:J,blobCount:F}}function de(e){return typeof e.poseHoldMs=="number"?e.poseHoldMs:1200}const ue=""+new URL("alien-idle-D2VKjYsl.png",import.meta.url).href,fe=""+new URL("alien-happy-Ci3JfpxD.png",import.meta.url).href,he=""+new URL("alien-thinking-gWKA2xDz.png",import.meta.url).href,pe=""+new URL("alien-keyL-C_tZriGQ.png",import.meta.url).href,xe=""+new URL("alien-keyL-C_tZriGQ.png",import.meta.url).href,z=""+new URL("alien-head-CS10QxqG.png",import.meta.url).href,be=""+new URL("alien-body-DXq5WJRs.png",import.meta.url).href,j={head:{x:.3,y:.05,w:.4,h:.2726},body:{x:.3,y:.3226,w:.4,h:.2841}},ee={x:.5,y:.3226},ye={formatVersion:1,id:"lab-alien",name:"Lab 小宇航员(Kenney)",author:"Kenney",license:"CC0-1.0 (Kenney Platformer Characters)",tier:"bongo",states:{idle:"idle.png",keyL:"keyl.png",keyR:"keyr.png",happy:"happy.png",thinking:"thinking.png"},poseHoldMs:1100};async function ge(){const e={idle:ue,keyL:pe,keyR:xe,happy:fe,thinking:he},t=await we(z),n=document.createElement("canvas");n.width=512,n.height=512;const u=n.getContext("2d");u.drawImage(t,0,0);const i=u.getImageData(0,0,512,512),o=me({width:512,height:512,rgba:i.data});return{srcs:e,parts:{head:z,body:be},selfSpec:o}}function we(e){return new Promise((t,n)=>{const u=new Image;u.onload=()=>t(u),u.onerror=()=>n(new Error(`image load failed: ${e}`)),u.src=e})}function te(e,t,n){const{x:u,y:i,w:o,h:r,t:h,deform:l}=n,g=n.cols??6,a=n.rows??8,m=n.src??{x:0,y:0,w:t.width,h:t.height},b=[];for(let d=0;d<=a;d++)for(let f=0;f<=g;f++){const y=f/g,L=d/a,M=l(y,L,h);b.push([u+y*o+M.dx,i+L*r+M.dy])}const x=(d,f)=>b[f*(g+1)+d];for(let d=0;d<a;d++)for(let f=0;f<g;f++){const y=x(f,d),L=x(f+1,d),M=x(f,d+1),N=x(f+1,d+1),S=m.x+f/g*m.w,R=m.y+d/a*m.h,k=m.x+(f+1)/g*m.w,Y=m.y+(d+1)/a*m.h;ne(e,t,[S,R],[k,R],[S,Y],y,L,M),ne(e,t,[k,R],[k,Y],[S,Y],L,N,M)}}function ne(e,t,n,u,i,o,r,h){const l=(u[0]-n[0])*(i[1]-n[1])-(i[0]-n[0])*(u[1]-n[1]);if(Math.abs(l)<1e-8)return;const g=((r[0]-o[0])*(i[1]-n[1])-(h[0]-o[0])*(u[1]-n[1]))/l,a=((h[0]-o[0])*(u[0]-n[0])-(r[0]-o[0])*(i[0]-n[0]))/l,m=((r[1]-o[1])*(i[1]-n[1])-(h[1]-o[1])*(u[1]-n[1]))/l,b=((h[1]-o[1])*(u[0]-n[0])-(r[1]-o[1])*(i[0]-n[0]))/l,x=o[0]-g*n[0]-a*n[1],d=o[1]-m*n[0]-b*n[1];e.save(),e.beginPath(),e.moveTo(o[0],o[1]),e.lineTo(r[0],r[1]),e.lineTo(h[0],h[1]),e.closePath(),e.clip(),e.transform(g,m,a,b,x,d),e.drawImage(t,0,0),e.restore()}function K(e){const t=v.useRef(e);t.current=e,v.useEffect(()=>{const n={side:1},u=r=>{if(r.repeat)return;const h=ce(r.code,n.side);n.side=n.side===1?-1:1,t.current(h===1?"keyR":"keyL")},i=r=>t.current(r.detail?"thinking":"idle"),o=ie(r=>t.current(r.kind==="wrong"?"wrong":"happy"));return window.addEventListener("keydown",u,{passive:!0}),window.addEventListener("companion-streaming",i),()=>{window.removeEventListener("keydown",u),window.removeEventListener("companion-streaming",i),o()}},[])}function H(){const[e,t]=v.useState("idle"),n=v.useRef(null),u=v.useCallback((i,o=0)=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,t(i);const r=o>0?o:0;r>0&&i!=="idle"&&(n.current=window.setTimeout(()=>t("idle"),r))},[]);return v.useEffect(()=>()=>{n.current!==null&&window.clearTimeout(n.current)},[]),{pose:e,setTimed:u}}function Q(e,t){t||!e||typeof e.animate!="function"||e.animate([{transform:"translateY(0)"},{transform:"translateY(-12%)"},{transform:"translateY(2%)"},{transform:"translateY(0)"}],{duration:380,easing:"cubic-bezier(0.2, 1.4, 0.4, 1)"})}function V(e,t){t||!e||typeof e.animate!="function"||e.animate([{transform:"rotate(0deg)"},{transform:"rotate(-6deg)"},{transform:"rotate(6deg)"},{transform:"rotate(0deg)"}],{duration:280})}function q(e,t){t||!e||typeof e.animate!="function"||e.animate([{transform:"translateY(0px) scale(1, 1)"},{transform:"translateY(2.5px) scale(1.045, 0.93)",offset:.42},{transform:"translateY(0px) scale(1, 1)"}],{duration:185,easing:"ease-out",composite:"add"})}const W=`
2
2
  .cbot { position: relative; display: inline-block; line-height: 0;
3
3
  animation: cbot-breath 3.4s ease-in-out infinite; transform-origin: 50% 62%; }
4
4
  .cbot img, .cbot canvas { display: block; user-select: none; }
@@ -1,4 +1,4 @@
1
- import{r as u,j as t}from"./index-C8cLLejx.js";import{c as C,U as I,u as y,a as L,d as S,X as N,B as M,T as E,C as R}from"./main-D7WqSbOt.js";/**
1
+ import{r as u,j as t}from"./index-DFeHjpII.js";import{c as C,U as I,u as y,a as L,d as S,X as N,B as M,T as E,C as R}from"./main-Q55C34or.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{r as o,h as U,j as e,c as ie}from"./index-C8cLLejx.js";import{c as te,u as ce,a as j,m as de,T as z,p as Y,A as q,L as V,q as oe,X as xe}from"./main-D7WqSbOt.js";import{R as G}from"./rotate-ccw-BS0Lg3XV.js";/**
1
+ import{r as o,h as U,j as e,c as ie}from"./index-DFeHjpII.js";import{c as te,u as ce,a as j,m as de,T as z,p as Y,A as q,L as V,q as oe,X as xe}from"./main-Q55C34or.js";import{R as G}from"./rotate-ccw-BOEgpxYS.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,9 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-DnOBsKcF.js","./main-Q55C34or.js","./index-DFeHjpII.js","./index-EInfxfl9.css","./main-D9IB7N5p.css","./transform-Bd_a5eGM.js","./mermaid-layout-elk.core-BtEZ1o-e.js"])))=>i.map(i=>d[i]);
2
+ import{r as o,j as t}from"./index-DFeHjpII.js";import{c as K,_ as B,u as O,b as H,y as U,X,z as L}from"./main-Q55C34or.js";import{M as Y,C as G}from"./CanvasStage-DWa6BPww.js";/**
3
+ * @license lucide-react v0.468.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const J=K("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);function Q(e){const i=e.split(`
8
+ `);for(let r=0;r<i.length;r++){const a=i[r]??"",s=a.trim();if(!(!s||s.startsWith("%%")))return/^flowchart-elk\b/i.test(s)?e:/^(flowchart|graph)\b/i.test(s)?(i[r]=a.replace(/^(\s*)(flowchart|graph)\b/i,"$1flowchart-elk"),i.join(`
9
+ `)):e}return e}let p=null;function ee(){return p||(p=B(()=>import("./mermaid.core-DnOBsKcF.js").then(e=>e.bI),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(async e=>{const i=e.default,{default:r}=await B(async()=>{const{default:a}=await import("./mermaid-layout-elk.core-BtEZ1o-e.js").then(s=>s.m);return{default:a}},__vite__mapDeps([6,1,2,3,4]),import.meta.url);return i.registerLayoutLoaders(r),i.initialize({startOnLoad:!1,theme:"base",securityLevel:"strict",themeVariables:te(),flowchart:{useMaxWidth:!0,htmlLabels:!0,curve:"basis",nodeSpacing:42,rankSpacing:54,padding:10},sequence:{useMaxWidth:!0,boxMargin:8,noteMargin:8,messageMargin:32}}),i})),p}function te(){const e=(r,a)=>{if(typeof document>"u")return a;const s=getComputedStyle(document.documentElement).getPropertyValue(r).trim();return s?`rgb(${s})`:a};return{background:"transparent",fontFamily:typeof document<"u"&&getComputedStyle(document.body).fontFamily||"ui-sans-serif, system-ui, sans-serif",fontSize:"14px",primaryColor:e("--surface-3-rgb","rgb(42 43 46)"),primaryBorderColor:e("--border-rgb","rgb(37 38 41)"),primaryTextColor:e("--ink-strong-rgb","rgb(250 250 250)"),secondaryColor:e("--surface-2-rgb","rgb(32 33 36)"),secondaryBorderColor:e("--border-faint-rgb","rgb(26 26 29)"),secondaryTextColor:e("--ink-rgb","rgb(245 245 250)"),tertiaryColor:e("--surface-1-rgb","rgb(24 25 27)"),tertiaryBorderColor:e("--border-faint-rgb","rgb(26 26 29)"),tertiaryTextColor:e("--ink-rgb","rgb(245 245 250)"),lineColor:e("--ink-faint-rgb","rgb(117 117 126)"),textColor:e("--ink-rgb","rgb(245 245 250)"),edgeLabelBackground:e("--surface-0-rgb","rgb(12 13 15)"),clusterBkg:e("--surface-1-rgb","rgb(24 25 27)"),clusterBorder:e("--border-faint-rgb","rgb(26 26 29)"),nodeBorder:e("--border-rgb","rgb(37 38 41)"),mainBkg:e("--surface-3-rgb","rgb(42 43 46)"),nodeTextColor:e("--ink-rgb","rgb(245 245 250)"),arrowheadColor:e("--ink-faint-rgb","rgb(117 117 126)"),actorBkg:e("--surface-3-rgb","rgb(42 43 46)"),actorBorder:e("--border-rgb","rgb(37 38 41)"),actorTextColor:e("--ink-strong-rgb","rgb(250 250 250)"),activationBkgColor:e("--surface-3-rgb","rgb(42 43 46)"),activationBorderColor:e("--border-rgb","rgb(37 38 41)"),signalColor:e("--ink-rgb","rgb(245 245 250)"),signalTextColor:e("--ink-rgb","rgb(245 245 250)"),labelBoxBkgColor:e("--surface-2-rgb","rgb(32 33 36)"),labelBoxBorderColor:e("--border-rgb","rgb(37 38 41)"),labelTextColor:e("--ink-rgb","rgb(245 245 250)"),loopTextColor:e("--ink-strong-rgb","rgb(250 250 250)"),noteBkgColor:"rgb(255 200 0 / 0.12)",noteBorderColor:"rgb(255 200 0 / 0.4)",noteTextColor:e("--ink-rgb","rgb(245 245 250)")}}typeof window<"u"&&window.addEventListener("theme-changed",()=>{p=null});async function re(e,i){const r=await ee(),a=Q(i);try{await r.parse(a)}catch(c){throw new Error(`mermaid 语法校验失败: ${c instanceof Error?c.message:String(c)}`)}const{svg:s}=await r.render(e,a);if(s.includes('aria-roledescription="error"')||s.includes('class="error-text"')||s.includes("Syntax error"))throw new Error("mermaid 渲染失败(语法错误或节点 label 含未转义特殊字符)");return s}function ae({title:e,onClose:i,children:r}){const a=O(),s=o.useRef(null);return H(s,!0),o.useEffect(()=>{const c=d=>{d.key==="Escape"&&i()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[i]),U.createPortal(t.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/80","data-testid":"diagram-viewer-modal","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":e,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 shrink-0",onClick:c=>c.stopPropagation(),children:[t.jsx("h3",{className:"text-body font-bold text-white truncate",children:e}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[t.jsx("span",{className:"text-caption text-white/50 hidden sm:inline",children:a("artifact.viewer.hint")}),t.jsx("button",{onClick:i,"data-testid":"diagram-viewer-close","aria-label":a("action.close"),"data-tooltip":a("action.close"),className:"text-white/70 hover:text-white w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white/10 transition-colors",children:t.jsx(X,{className:"w-5 h-5"})})]})]}),t.jsx("div",{className:"flex-1 min-h-0 px-2 pb-2",onClick:i,children:t.jsx("div",{ref:s,className:"h-full w-full",onClick:c=>c.stopPropagation(),children:r})})]}),document.body)}function z(e){let i=5381;for(let r=0;r<e.length;r++)i=(i<<5)+i+e.charCodeAt(r)>>>0;return i.toString(36)}const v=.3,k=3,x=.2;function I({data:e,variant:i="card"}){const r=e,a=O(),s={flowchart:a("artifact.diagram.flowchart"),sequence:a("artifact.diagram.sequence"),state:a("artifact.diagram.state")},c=o.useId().replace(/[:]/g,"_"),[d,w]=o.useState({status:"loading"}),[u,A]=o.useState(()=>{try{return sessionStorage.getItem(`mmdfix:${r.mermaid.length}:${z(r.mermaid)}`)??r.mermaid}catch{return r.mermaid}}),[j,P]=o.useState(!1),[C,N]=o.useState(!1),[R,$]=o.useState(0);o.useEffect(()=>{const n=()=>$(l=>l+1);return window.addEventListener("theme-changed",n),()=>window.removeEventListener("theme-changed",n)},[]);const[m,M]=o.useState(null),[g,b]=o.useState(1),[F,y]=o.useState(!1);o.useEffect(()=>{let n=!1;return w({status:"loading"}),M(null),re(`mmd-${c}`,u).then(l=>{if(!n&&(w({status:"rendered",svg:l}),u!==r.mermaid))try{sessionStorage.setItem(`mmdfix:${r.mermaid.length}:${z(r.mermaid)}`,u)}catch{}}).catch(l=>{n||(console.error("[MermaidArtifact] render failed:",l),w({status:"error",message:l instanceof Error?l.message:String(l)}))}),()=>{n=!0}},[u,c,R,r.mermaid]),o.useEffect(()=>{var n;d.status!=="error"||j||(P(!0),u===r.mermaid&&(n=window.api)!=null&&n.repairMermaidDiagram&&(N(!0),window.api.repairMermaidDiagram({mermaid:u,errorMessage:d.message,diagramType:r.diagramType}).then(l=>{l.ok&&l.mermaid.trim()&&A(l.mermaid)}).catch(()=>{}).finally(()=>N(!1))))},[d,j,u,r.mermaid,r.diagramType]);const D=`https://mermaid.live/edit#${encodeURIComponent(u)}`,V=o.useCallback(()=>b(n=>Math.min(k,+(n+x).toFixed(2))),[]),W=o.useCallback(()=>b(n=>Math.max(v,+(n-x).toFixed(2))),[]),q=o.useCallback(()=>b(1),[]),Z=o.useCallback(n=>{if(!n.ctrlKey&&!n.metaKey)return;n.preventDefault();const l=n.deltaY>0?-x:x;b(h=>Math.min(k,Math.max(v,+(h+l).toFixed(2))))},[]),E=d.status==="rendered"?t.jsx("div",{ref:n=>{var l;if(n&&!m){const h=n.querySelector("svg");if(h){const S=h.getBoundingClientRect(),f=(l=h.viewBox)==null?void 0:l.baseVal,T=f&&f.width?f.width:S.width,_=f&&f.height?f.height:S.height;T>0&&_>0&&M({width:T,height:_})}}},style:{width:(m==null?void 0:m.width)??void 0,height:(m==null?void 0:m.height)??void 0},dangerouslySetInnerHTML:{__html:d.svg},"data-testid":"mermaid-svg"}):null;return i==="canvas"?t.jsx("div",{"data-testid":"mermaid-canvas-content",children:E}):t.jsxs("div",{className:"surface-card p-4","data-testid":"artifact-mermaid",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3 gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.jsx(J,{className:"w-4 h-4 text-ink-muted shrink-0"}),t.jsx("h3",{className:"text-body font-bold text-ink truncate",children:r.title}),t.jsx("span",{className:"text-caption font-bold px-1.5 py-0.5 rounded bg-accent/15 text-accent shrink-0",children:s[r.diagramType]??r.diagramType})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[d.status==="rendered"&&t.jsxs("div",{className:"flex items-center gap-1","data-testid":"mermaid-zoom-controls",children:[t.jsx("button",{onClick:W,disabled:g<=v,className:"w-6 h-6 rounded border border-[var(--border)] text-ink-muted hover:bg-surface-1 hover:bg-surface-3 disabled:opacity-30 text-label font-bold flex items-center justify-center",title:a("artifact.zoomOut"),"data-testid":"mermaid-zoom-out",children:"−"}),t.jsxs("button",{onClick:q,className:"px-1.5 h-6 rounded border border-[var(--border)] text-ink-muted hover:bg-surface-1 hover:bg-surface-3 text-caption font-bold tabular-nums",title:a("artifact.zoomReset"),"data-testid":"mermaid-zoom-reset",children:[Math.round(g*100),"%"]}),t.jsx("button",{onClick:V,disabled:g>=k,className:"w-6 h-6 rounded border border-[var(--border)] text-ink-muted hover:bg-surface-1 hover:bg-surface-3 disabled:opacity-30 text-label font-bold flex items-center justify-center",title:a("artifact.zoomIn"),"data-testid":"mermaid-zoom-in",children:"+"})]}),d.status==="rendered"&&t.jsx("button",{onClick:()=>y(!0),"data-testid":"mermaid-expand","aria-label":a("artifact.viewer.open"),"data-tooltip":a("artifact.viewer.open"),className:"w-6 h-6 rounded border border-[var(--border)] text-ink-muted hover:bg-surface-3 flex items-center justify-center",children:t.jsx(Y,{className:"w-3.5 h-3.5"})})]}),t.jsx("button",{onClick:()=>window.open(D,"_blank"),className:"text-caption text-accent hover:underline font-bold shrink-0","data-testid":"mermaid-open-live",title:a("artifact.mermaid.openLive"),children:"mermaid.live ↗"})]}),t.jsxs("div",{onClick:()=>{d.status==="rendered"&&y(!0)},onWheel:Z,className:"bg-surface-0/40 rounded-lg p-3 overflow-auto min-h-[120px] max-h-[500px] select-none",style:{touchAction:"pan-x pan-y"},"data-testid":"mermaid-render-area","data-noswipe":"",children:[d.status==="loading"&&t.jsxs("div",{className:"flex items-center gap-2 text-body text-ink-muted my-8 justify-center","data-testid":"mermaid-loading",children:[t.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-accent rounded-full inline-block"}),t.jsx("span",{children:a("artifact.mermaid.rendering")})]}),d.status==="rendered"&&t.jsx("div",{style:{width:m?m.width*g:"auto",height:m?m.height*g:"auto",margin:"0 auto"},children:t.jsx("div",{style:{transform:`scale(${g})`,transformOrigin:"top left"},children:E})}),d.status==="error"&&C&&t.jsxs("div",{className:"flex items-center gap-2 text-body text-ink-muted my-8 justify-center","data-testid":"mermaid-repairing",children:[t.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-accent rounded-full inline-block"}),t.jsx("span",{children:a("artifact.mermaid.repairing")})]}),d.status==="error"&&!C&&t.jsxs("div",{className:"w-full text-center my-4","data-testid":"mermaid-fallback",children:[t.jsxs("div",{className:"text-body text-warning mb-2 flex items-center justify-center gap-1.5",children:[t.jsx(L,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{children:a("artifact.mermaid.renderFailed")})]}),t.jsx("pre",{className:"text-label bg-surface-1/60 rounded p-2 overflow-x-auto text-ink-muted font-mono text-left",children:u}),t.jsx("div",{className:"text-caption text-ink-muted mt-2",children:a("artifact.mermaid.errorPrefix",{msg:d.message})})]})]}),d.status==="rendered"&&t.jsx("div",{className:"mt-1.5 text-caption text-ink-muted flex items-center gap-2",children:t.jsx("span",{children:a("artifact.mermaid.hint")})}),F&&d.status==="rendered"&&t.jsx(ae,{title:r.title,onClose:()=>y(!1),children:t.jsx("div",{className:"h-full w-full rounded-xl overflow-hidden bg-surface-0/60",children:t.jsx(G,{testid:"mermaid-modal-stage",children:t.jsx(I,{data:e,variant:"canvas"})})})}),r.warnings&&r.warnings.length>0&&t.jsxs("div",{className:"mt-2 text-caption text-warning flex items-start gap-1","data-testid":"artifact-warnings",children:[t.jsx(L,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),t.jsx("span",{children:r.warnings.join("; ")})]})]})}const oe=Object.freeze(Object.defineProperty({__proto__:null,MermaidArtifact:I},Symbol.toStringTag,{value:"Module"}));export{ae as D,I as M,oe as a};
@@ -1,4 +1,4 @@
1
- import{r as n,j as e}from"./index-C8cLLejx.js";import{c as L,u as I,g as T,b as G,h as F,a as c,i as H,X as q,j as K,P as O,L as V,A as X,k as J,l as Q,m as U,n as W,s as Y,o as Z}from"./main-D7WqSbOt.js";/**
1
+ import{r as n,j as e}from"./index-DFeHjpII.js";import{c as L,u as I,g as T,b as G,h as F,a as c,i as H,X as q,j as K,P as O,L as V,A as X,k as J,l as Q,m as U,n as W,s as Y,o as Z}from"./main-Q55C34or.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as a,j as e,c as S}from"./index-C8cLLejx.js";import{u as j,a as N,S as M}from"./main-D7WqSbOt.js";function A({tree:c,onReviewNode:d,progressMap:o}){const s=j(),[l,f]=a.useState([]),[b,h]=a.useState(!0),[n,x]=a.useState(null);a.useEffect(()=>{N.getAllSrsItems().then(t=>f(t)).catch(()=>f([])).finally(()=>h(!1))},[]);const p=a.useMemo(()=>new Map(c.map(t=>[t.id,t])),[c]),g=a.useMemo(()=>new Set(l.filter(t=>t.overdue).map(t=>t.nodeId)),[l]),i=a.useMemo(()=>{const t=c.filter(u=>{var y;const m=(y=o[u.id])==null?void 0:y.status;return u.type==="lesson"&&(m==="in_progress"||m==="mastered")}),r=new Map;for(const u of t){const m=u.parentId??"(root)";r.has(m)||r.set(m,[]),r.get(m).push(u)}return r},[c,o]),w=a.useMemo(()=>Array.from(i.values()).flat().filter(t=>g.has(t.id)).length,[i,g]),v=a.useMemo(()=>Array.from(i.values()).flat(),[i]);if(a.useEffect(()=>{if(i.size>0&&(!n||!i.has(n))){const t=i.keys().next().value;t&&x(t)}},[i,n]),b)return e.jsxs("div",{className:"text-center py-12 text-body text-ink-muted flex items-center justify-center gap-2",children:[e.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),s("review.loading")]});if(v.length===0)return e.jsxs("div",{className:"text-center py-16","data-testid":"review-empty",children:[e.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),e.jsx("div",{className:"text-body text-ink-muted",children:s("review.empty.title")}),e.jsx("div",{className:"text-label text-ink-faint mt-1",children:s("review.empty.desc")})]});const k=t=>{var r;return((r=p.get(t))==null?void 0:r.title)??t};return e.jsxs("div",{className:"p-5 max-w-2xl mx-auto","data-testid":"review-panel",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-title font-extrabold text-ink-strong",children:s("review.title")}),w>0&&e.jsxs("span",{className:"text-label font-bold text-review","data-testid":"review-due-count",children:[w," ",s("review.due.count")]})]}),e.jsxs("button",{onClick:()=>{const t=v[Math.floor(Math.random()*v.length)];t&&d(t.id)},"data-testid":"review-interleave",className:"btn-3d-neutral w-full py-2.5 text-body mb-5 flex items-center justify-center gap-1.5",children:[e.jsx(M,{className:"w-4 h-4"}),s("review.interleave")]}),e.jsx("div",{className:"text-label font-bold text-ink-muted mb-2",children:s("review.selectSection")}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:Array.from(i.entries()).map(([t,r])=>e.jsxs("button",{onClick:()=>x(t),className:`px-2.5 py-1 rounded-full text-label font-bold transition-colors ${n===t?"bg-brand/15 text-brand ring-1 ring-brand/30":"bg-surface-3 text-ink-muted hover:text-ink-strong"}`,children:[k(t),e.jsxs("span",{className:"ml-1 opacity-60",children:["(",r.length,")"]})]},t))}),n&&i.has(n)&&e.jsx("div",{className:"space-y-1.5","data-testid":"review-lesson-list",children:i.get(n).map(t=>{const r=g.has(t.id);return e.jsxs("div",{className:`flex items-center justify-between gap-2 p-2.5 rounded-lg transition-colors ${r?"bg-review/8 ring-1 ring-review/20":"bg-surface-3 hover:bg-surface-3/80"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 truncate flex-1",children:[r&&e.jsx("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full bg-review"}),e.jsx("span",{className:"text-body text-ink-strong truncate",children:t.title})]}),e.jsx("button",{onClick:()=>d(t.id),"data-testid":`review-lesson-${t.id.slice(0,8)}`,className:"shrink-0 px-3 py-1 rounded-lg bg-brand/15 text-brand text-label font-bold hover:bg-brand/25 transition-colors",children:s("review.reviewLesson")})]},t.id)})})]})}function E({nodeId:c,onRated:d}){const o=a.useRef(null),s=j(),[l,f]=a.useState(!1),[b,h]=a.useState(!1),n=async x=>{if(!(l||b)){f(!0);try{await N.recordReview(c,x),h(!0),d==null||d(),S(x>=4?"correct":"wrong",{origin:x>=4&&o.current?(()=>{const p=o.current.getBoundingClientRect();return{x:p.right-48,y:p.top+24}})():void 0})}catch{}finally{f(!1)}}};return b?e.jsx("div",{className:"text-center text-body text-brand py-2","data-testid":"self-rated",children:s("review.selfrated")}):e.jsxs("div",{ref:o,className:"border-t border-[var(--border-faint)] pt-3 mt-3","data-testid":"self-rating",children:[e.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2 text-center",children:s("review.selfrate.title")}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:()=>n(1),disabled:l,"data-testid":"rate-again",className:"py-2 rounded-lg border border-warning/40 text-warning hover:bg-warning/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:s("review.selfrate.again")}),e.jsx("span",{className:"text-caption opacity-70",children:s("review.selfrate.again.hint")})]}),e.jsxs("button",{onClick:()=>n(4),disabled:l,"data-testid":"rate-remembered",className:"py-2 rounded-lg border border-accent/40 text-accent hover:bg-accent/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:s("review.selfrate.remembered")}),e.jsx("span",{className:"text-caption opacity-70",children:s("review.selfrate.remembered.hint")})]}),e.jsxs("button",{onClick:()=>n(5),disabled:l,"data-testid":"rate-mastered",className:"py-2 rounded-lg border border-brand/40 text-brand hover:bg-brand/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:s("review.selfrate.mastered")}),e.jsx("span",{className:"text-caption opacity-70",children:s("review.selfrate.mastered.hint")})]})]})]})}export{A as ReviewPanel,E as SelfRatingCard};
1
+ import{r as a,j as e,c as S}from"./index-DFeHjpII.js";import{u as j,a as N,S as M}from"./main-Q55C34or.js";function A({tree:c,onReviewNode:d,progressMap:o}){const s=j(),[l,f]=a.useState([]),[b,h]=a.useState(!0),[n,x]=a.useState(null);a.useEffect(()=>{N.getAllSrsItems().then(t=>f(t)).catch(()=>f([])).finally(()=>h(!1))},[]);const p=a.useMemo(()=>new Map(c.map(t=>[t.id,t])),[c]),g=a.useMemo(()=>new Set(l.filter(t=>t.overdue).map(t=>t.nodeId)),[l]),i=a.useMemo(()=>{const t=c.filter(u=>{var y;const m=(y=o[u.id])==null?void 0:y.status;return u.type==="lesson"&&(m==="in_progress"||m==="mastered")}),r=new Map;for(const u of t){const m=u.parentId??"(root)";r.has(m)||r.set(m,[]),r.get(m).push(u)}return r},[c,o]),w=a.useMemo(()=>Array.from(i.values()).flat().filter(t=>g.has(t.id)).length,[i,g]),v=a.useMemo(()=>Array.from(i.values()).flat(),[i]);if(a.useEffect(()=>{if(i.size>0&&(!n||!i.has(n))){const t=i.keys().next().value;t&&x(t)}},[i,n]),b)return e.jsxs("div",{className:"text-center py-12 text-body text-ink-muted flex items-center justify-center gap-2",children:[e.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),s("review.loading")]});if(v.length===0)return e.jsxs("div",{className:"text-center py-16","data-testid":"review-empty",children:[e.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),e.jsx("div",{className:"text-body text-ink-muted",children:s("review.empty.title")}),e.jsx("div",{className:"text-label text-ink-faint mt-1",children:s("review.empty.desc")})]});const k=t=>{var r;return((r=p.get(t))==null?void 0:r.title)??t};return e.jsxs("div",{className:"p-5 max-w-2xl mx-auto","data-testid":"review-panel",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-title font-extrabold text-ink-strong",children:s("review.title")}),w>0&&e.jsxs("span",{className:"text-label font-bold text-review","data-testid":"review-due-count",children:[w," ",s("review.due.count")]})]}),e.jsxs("button",{onClick:()=>{const t=v[Math.floor(Math.random()*v.length)];t&&d(t.id)},"data-testid":"review-interleave",className:"btn-3d-neutral w-full py-2.5 text-body mb-5 flex items-center justify-center gap-1.5",children:[e.jsx(M,{className:"w-4 h-4"}),s("review.interleave")]}),e.jsx("div",{className:"text-label font-bold text-ink-muted mb-2",children:s("review.selectSection")}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:Array.from(i.entries()).map(([t,r])=>e.jsxs("button",{onClick:()=>x(t),className:`px-2.5 py-1 rounded-full text-label font-bold transition-colors ${n===t?"bg-brand/15 text-brand ring-1 ring-brand/30":"bg-surface-3 text-ink-muted hover:text-ink-strong"}`,children:[k(t),e.jsxs("span",{className:"ml-1 opacity-60",children:["(",r.length,")"]})]},t))}),n&&i.has(n)&&e.jsx("div",{className:"space-y-1.5","data-testid":"review-lesson-list",children:i.get(n).map(t=>{const r=g.has(t.id);return e.jsxs("div",{className:`flex items-center justify-between gap-2 p-2.5 rounded-lg transition-colors ${r?"bg-review/8 ring-1 ring-review/20":"bg-surface-3 hover:bg-surface-3/80"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 truncate flex-1",children:[r&&e.jsx("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full bg-review"}),e.jsx("span",{className:"text-body text-ink-strong truncate",children:t.title})]}),e.jsx("button",{onClick:()=>d(t.id),"data-testid":`review-lesson-${t.id.slice(0,8)}`,className:"shrink-0 px-3 py-1 rounded-lg bg-brand/15 text-brand text-label font-bold hover:bg-brand/25 transition-colors",children:s("review.reviewLesson")})]},t.id)})})]})}function E({nodeId:c,onRated:d}){const o=a.useRef(null),s=j(),[l,f]=a.useState(!1),[b,h]=a.useState(!1),n=async x=>{if(!(l||b)){f(!0);try{await N.recordReview(c,x),h(!0),d==null||d(),S(x>=4?"correct":"wrong",{origin:x>=4&&o.current?(()=>{const p=o.current.getBoundingClientRect();return{x:p.right-48,y:p.top+24}})():void 0})}catch{}finally{f(!1)}}};return b?e.jsx("div",{className:"text-center text-body text-brand py-2","data-testid":"self-rated",children:s("review.selfrated")}):e.jsxs("div",{ref:o,className:"border-t border-[var(--border-faint)] pt-3 mt-3","data-testid":"self-rating",children:[e.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2 text-center",children:s("review.selfrate.title")}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:()=>n(1),disabled:l,"data-testid":"rate-again",className:"py-2 rounded-lg border border-warning/40 text-warning hover:bg-warning/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:s("review.selfrate.again")}),e.jsx("span",{className:"text-caption opacity-70",children:s("review.selfrate.again.hint")})]}),e.jsxs("button",{onClick:()=>n(4),disabled:l,"data-testid":"rate-remembered",className:"py-2 rounded-lg border border-accent/40 text-accent hover:bg-accent/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:s("review.selfrate.remembered")}),e.jsx("span",{className:"text-caption opacity-70",children:s("review.selfrate.remembered.hint")})]}),e.jsxs("button",{onClick:()=>n(5),disabled:l,"data-testid":"rate-mastered",className:"py-2 rounded-lg border border-brand/40 text-brand hover:bg-brand/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:s("review.selfrate.mastered")}),e.jsx("span",{className:"text-caption opacity-70",children:s("review.selfrate.mastered.hint")})]})]})]})}export{A as ReviewPanel,E as SelfRatingCard};
@@ -0,0 +1,20 @@
1
+ import{r as n,j as e,V as Te,k as be,l as Me,m as Ce,s as ot,n as rt,C as ct,M as dt}from"./index-DFeHjpII.js";import{c as We,u as ce,b as Oe,y as mt,X as ve,f as ut,k as xe,N as je,a as r,W as Le,r as Ue,O as De,Q as xt,q as ht,m as _e,R as pt,V as gt,Y as ft}from"./main-Q55C34or.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const bt=We("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const vt=We("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),jt={vision:"companion.custom.routeVision",geometric:"companion.custom.routeGeometric",l1:"companion.custom.routeL1"};function wt(t){let x="";for(let b=0;b<t.length;b+=32768)x+=String.fromCharCode(...t.subarray(b,b+32768));return btoa(x)}async function kt(t){try{return await navigator.clipboard.writeText(t),!0}catch{}const x=document.createElement("textarea");x.value=t,x.style.position="fixed",x.style.opacity="0",document.body.appendChild(x),x.focus(),x.select();let o=!1;try{o=document.execCommand("copy")}catch{o=!1}return x.remove(),o}function Nt({onClose:t,onSaved:x}){const o=ce(),[b,N]=n.useState(!1),[l,c]=n.useState(!1),[v,p]=n.useState(0),[g,S]=n.useState(null),[j,T]=n.useState(null),[$,h]=n.useState(""),[f,z]=n.useState(""),[y,A]=n.useState("ember"),R=n.useRef(null),M=n.useRef(null);Oe(M,!0),n.useEffect(()=>{if(!l)return;p(0);const m=Date.now(),E=window.setInterval(()=>p(Math.floor((Date.now()-m)/1e3)),500);return()=>window.clearInterval(E)},[l]);const q=async()=>{const m=await kt(o("companion.wizard.prompt"));N(m),m?setTimeout(()=>N(!1),2400):T(o("companion.wizard.copyFail"))},V=async m=>{if(m){c(!0),T(null),S(null),h(m.name.replace(/\.png$/i,""));try{const E=wt(new Uint8Array(await m.arrayBuffer())),_=await window.api.companionPackCutFromImage({pngBase64:E});S(_),_.visionError?T(`${o("companion.custom.visionFallback")} · ${_.visionError}`):T(`${o("companion.custom.cutDone")} · ${o(jt[_.route]??"companion.custom.routeL1")}`)}catch(E){T(`${o("companion.custom.fail")}: ${String(E)}`)}finally{c(!1)}}},B=async()=>{if(g){c(!0);try{await window.api.companionPackApplyPack({name:f.trim()||$||"My Bot",manifest:{...g.manifest,vehicle:y},parts:g.parts.map(m=>({name:m.name,pngBase64:m.pngBase64}))}),await Me(),await window.api.setSetting("companion_form","custom"),window.dispatchEvent(new Event("companion-config-changed")),x()}catch(m){T(`${o("companion.custom.fail")}: ${String(m)}`)}finally{c(!1)}}};return mt.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":o("companion.wizard.title"),onClick:t,children:e.jsxs("div",{ref:M,onClick:m=>m.stopPropagation(),className:"w-full max-w-xl max-h-[86vh] overflow-y-auto rounded-2xl bg-surface-1 shadow-pop p-4","data-testid":"companion-wizard",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-body font-bold text-ink-strong",children:o("companion.wizard.title")}),e.jsx("button",{onClick:t,"aria-label":o("action.close"),className:"text-ink-muted hover:text-ink-strong w-8 h-8 flex items-center justify-center rounded-lg hover:bg-surface-2",children:e.jsx(ve,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"rounded-xl border border-[var(--border-faint)] p-3 mb-2",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1",children:o("companion.wizard.s1")}),e.jsx("p",{className:"text-caption text-ink-muted leading-relaxed",children:o("companion.wizard.s1body")})]}),e.jsxs("div",{className:"rounded-xl border border-[var(--border-faint)] p-3 mb-2",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1",children:o("companion.wizard.s2")}),e.jsx("p",{className:"text-caption text-ink-muted leading-relaxed mb-2",children:o("companion.wizard.s2body")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("a",{href:"https://www.doubao.com/chat/",target:"_blank",rel:"noreferrer",className:"rounded-lg border border-[var(--border-faint)] px-3 py-1.5 text-label hover:bg-surface-2",children:o("companion.wizard.s2doubao")}),e.jsx("a",{href:"https://jimeng.jianying.com/",target:"_blank",rel:"noreferrer",className:"rounded-lg border border-[var(--border-faint)] px-3 py-1.5 text-label hover:bg-surface-2",children:o("companion.wizard.s2jimeng")}),e.jsx("a",{href:"https://chatgpt.com/",target:"_blank",rel:"noreferrer",className:"rounded-lg border border-[var(--border-faint)] px-3 py-1.5 text-label hover:bg-surface-2",children:o("companion.wizard.s2chatgpt")}),e.jsx("button",{type:"button",onClick:()=>void q(),"data-testid":"companion-wizard-copy",className:"rounded-lg bg-accent px-3 py-1.5 text-label text-white hover:opacity-90",children:o(b?"companion.wizard.copied":"companion.wizard.copy")})]}),e.jsx("textarea",{readOnly:!0,value:o("companion.wizard.prompt"),rows:6,className:"w-full rounded-lg bg-surface-2 border border-[var(--border-faint)] p-2 text-caption text-ink-muted font-mono resize-y select-all",onFocus:m=>m.currentTarget.select()})]}),e.jsxs("div",{className:"rounded-xl border border-[var(--border-faint)] p-3",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1",children:o("companion.wizard.s3")}),e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-caption text-ink-muted mb-1",children:o("companion.wizard.vehicle")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",role:"radiogroup","aria-label":o("companion.wizard.vehicle"),children:Te.map(m=>{const E=y===m;return e.jsxs("button",{type:"button",role:"radio","aria-checked":E,"data-testid":`companion-wizard-veh-${m}`,onClick:()=>A(m),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-label motion-safe:transition-colors
12
+ ${E?"border-[var(--accent)] bg-surface-2 text-ink-strong font-medium":"border-[var(--border-faint)] hover:bg-surface-2 text-ink-muted"}`,children:[e.jsx("span",{"aria-hidden":"true",className:"w-3 h-3 rounded-full border border-black/20",style:{background:be[m].dot}}),o(`companion.form.${m}.name`)]},m)})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("input",{ref:R,type:"file",accept:"image/png",className:"hidden","data-testid":"companion-custom-file",onChange:m=>{var E;return void V((E=m.target.files)==null?void 0:E[0])}}),e.jsx("button",{type:"button",disabled:l,onClick:()=>{var m;return(m=R.current)==null?void 0:m.click()},"data-testid":"companion-wizard-pick",className:"rounded-lg border border-[var(--border-faint)] px-3 py-1.5 text-label hover:bg-surface-2 disabled:opacity-50",children:o("companion.wizard.pick")}),l&&e.jsxs("span",{className:"flex items-center gap-1.5 text-label text-ink-muted","data-testid":"companion-custom-busy",children:[e.jsx(ut,{size:14,className:"animate-spin"}),o(g?"companion.custom.applying":"companion.custom.locating"),e.jsxs("span",{className:"tabular-nums",children:[v,"s"]})]}),j&&e.jsx("span",{className:"text-caption text-ink-muted","data-testid":"companion-custom-msg",children:j})]}),g&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"companion-custom-preview",children:[g.parts.map(m=>e.jsx("img",{src:`data:image/png;base64,${m.pngBase64}`,alt:m.name,title:m.name,className:"h-14 w-14 object-contain rounded-lg bg-surface-2"},m.name)),e.jsx("input",{value:f,onChange:m=>z(m.target.value),placeholder:o("companion.wizard.namePh"),"data-testid":"companion-wizard-name",className:"rounded-lg border border-[var(--border-faint)] bg-surface-0 px-2.5 py-1.5 text-label text-ink-strong placeholder:text-ink-muted w-36"}),e.jsx("button",{type:"button",disabled:l,onClick:()=>void B(),"data-testid":"companion-custom-apply",className:"rounded-lg bg-brand px-3 py-1.5 text-label text-white hover:opacity-90 disabled:opacity-50",children:o("companion.wizard.save")})]})]})]})}),document.body)}const yt=[{id:"shimejiorg",label:"shimeji.org",url:"https://shimeji.org/"},{id:"shimejisxyz",label:"shimejis.xyz",url:"https://shimejis.xyz/"},{id:"cachomon",label:"Cachomon",url:"https://cachomon.com/"},{id:"deviantart",label:"DeviantArt",url:"https://www.deviantart.com/search?q=shimeji"}];function St({onClose:t,onImported:x}){const o=ce(),b=n.useRef(null),N=n.useRef(null);Oe(b,!0);const[l,c]=n.useState(!1),[v,p]=n.useState(null),[g,S]=n.useState(null),j=async h=>{var z;const f=(z=h.target.files)==null?void 0:z[0];if(h.target.value="",!!f){c(!0),p(null);try{const y=new Uint8Array(await f.arrayBuffer());let A="";for(let M=0;M<y.length;M+=32768)A+=String.fromCharCode(...y.subarray(M,M+32768));const R=await window.api.shimejiImportZip({zipBase64:btoa(A)});S({importId:R.importId,characters:R.characters,selected:new Set(R.characters.map(M=>M.ref))})}catch(y){p(String(y.message??y).slice(0,160))}finally{c(!1)}}},T=h=>{S(f=>{if(!f)return f;const z=new Set(f.selected);return z.has(h)?z.delete(h):z.add(h),{...f,selected:z}})},$=async()=>{if(g){c(!0);try{await window.api.shimejiConfirmImport({importId:g.importId,characterRefs:[...g.selected]}),S(null),await Ce(),await x(),t()}catch(h){p(String(h.message??h).slice(0,160))}finally{c(!1)}}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":o("settings.shimeji.dialog.title"),onClick:t,children:e.jsxs("div",{ref:b,onClick:h=>h.stopPropagation(),className:"relative w-full max-w-md max-h-[85dvh] flex flex-col rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4","data-testid":"shimeji-dialog",children:[e.jsx("button",{type:"button","aria-label":o("action.close"),"data-testid":"shimeji-dialog-close",onClick:t,className:"absolute top-2.5 right-2.5 w-7 h-7 rounded-lg flex items-center justify-center text-ink-muted hover:text-ink-strong hover:bg-surface-2",children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsxs("div",{className:"min-h-0 overflow-y-auto",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong mb-1",children:o("settings.shimeji.dialog.title")}),e.jsx("p",{className:"text-label text-ink-muted mb-3",children:o("settings.shimeji.desc")}),!g&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button","data-testid":"shimeji-import",disabled:l,onClick:()=>{var h;return(h=N.current)==null?void 0:h.click()},className:"w-full rounded-xl border border-dashed border-[var(--border)] py-6 flex flex-col items-center gap-1.5 text-ink-faint hover:text-ink-muted hover:bg-surface-2 disabled:opacity-50",children:[e.jsx("span",{className:"text-label font-medium",children:o(l?"settings.shimeji.importing":"settings.shimeji.import")}),e.jsx("span",{className:"text-caption",children:o("settings.shimeji.guide")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2","data-testid":"shimeji-download-links",children:yt.map(h=>e.jsxs("a",{href:h.url,target:"_blank",rel:"noopener noreferrer","data-testid":`shimeji-link-${h.id}`,className:"inline-flex items-center gap-1 rounded-lg border border-[var(--border-faint)] px-2 py-1 text-caption text-ink-muted hover:text-ink-strong hover:bg-surface-2 motion-safe:transition-colors",children:[e.jsx(bt,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),h.label]},h.id))})]}),e.jsx("input",{ref:N,type:"file",accept:".zip",className:"hidden",onChange:h=>void j(h)}),v&&e.jsx("p",{className:"text-caption text-warning mt-2",role:"alert",children:v}),g&&e.jsxs("div",{className:"rounded-xl border border-[var(--border)] bg-surface-1 p-3","data-testid":"shimeji-character-picker",children:[e.jsx("div",{className:"text-body text-ink-strong mb-2",children:o("settings.shimeji.pick.title")}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:g.characters.map(h=>{const f=g.selected.has(h.ref);return e.jsxs("button",{type:"button","aria-pressed":f,onClick:()=>T(h.ref),className:`flex items-center gap-2 rounded-xl border p-2 text-left ${f?"border-[var(--accent)] bg-surface-2":"border-[var(--border-faint)]"}`,children:[h.iconBase64?e.jsx("img",{src:`data:image/png;base64,${h.iconBase64}`,alt:"",className:"w-9 h-9 rounded-lg object-contain bg-surface-2"}):e.jsx("div",{className:"w-9 h-9 rounded-lg bg-surface-2"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-body text-ink-strong",children:h.name}),e.jsxs("span",{className:"text-caption text-ink-muted",children:[h.format," · ",h.frameCount,"f · ",h.actionCount]})]})]},h.ref)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button","data-testid":"shimeji-confirm-import",className:"btn-3d-brand px-3 py-1.5 text-label",disabled:l||g.selected.size===0,onClick:()=>void $(),children:o("settings.shimeji.pick.confirm",{count:g.selected.size})}),e.jsx("button",{type:"button",className:"btn-3d-neutral px-3 py-1.5 text-label",onClick:t,children:o("action.cancel")})]})]})]})]})})}const fe="bg-ink/[0.04] text-ink-strong text-label rounded-lg border border-transparent focus:border-accent focus:bg-ink/[0.06] transition-colors placeholder:text-ink-faint";function $e({kind:t,showProtocol:x=!0,testPrefix:o="custom",titleKey:b="settings.custom.form_title",modelPhKey:N="settings.custom.model_ph",testOverride:l,onSaved:c,onCancel:v}){const p=ce(),[g,S]=n.useState(""),[j,T]=n.useState("openai-compatible"),[$,h]=n.useState(""),[f,z]=n.useState(""),[y,A]=n.useState(""),[R,M]=n.useState(!1),[q,V]=n.useState(!1),[B,m]=n.useState(null),E=async()=>{if(!(!$.trim()||!y.trim()||q)){V(!0),m(null);try{const w=l?await l({baseUrl:$.trim(),apiKey:f.trim(),model:y.trim()}):await r.testCustomProvider({label:g||p("settings.custom.test_label"),protocol:j,baseUrl:$.trim(),apiKey:f.trim()||void 0,defaultModel:y.trim()});m({ok:w.ok,detail:w.detail})}catch(w){m({ok:!1,detail:w instanceof Error?w.message:String(w)})}finally{V(!1)}}},_=async()=>{if(!(!g.trim()||!$.trim()||!y.trim()))try{const w=await r.createCustomProvider({label:g.trim(),kind:t,protocol:x?j:"openai-compatible",baseUrl:$.trim(),apiKey:f.trim()||void 0,defaultModel:y.trim(),vision:t==="llm"?R:void 0});c(w)}catch{}};return e.jsxs("div",{className:"space-y-2.5","data-testid":`${o}-provider-form`,children:[e.jsx("div",{className:"text-label font-bold text-ink-strong",children:p(b)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:g,onChange:w=>S(w.target.value),placeholder:p("settings.custom.label_ph"),"data-testid":`${o}-label`,className:`${fe} min-w-0 flex-1 px-2.5 py-1.5`}),x&&e.jsxs("select",{value:j,onChange:w=>T(w.target.value),"data-testid":`${o}-protocol`,className:`${fe} px-2 py-1.5`,children:[e.jsx("option",{value:"openai-compatible",children:p("settings.proto.openai")}),e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"google",children:"Google"})]})]}),e.jsx("input",{type:"text",value:$,onChange:w=>h(w.target.value),placeholder:p("settings.custom.baseurl_ph"),"data-testid":`${o}-baseurl`,className:`${fe} w-full px-2.5 py-1.5 font-mono`}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:y,onChange:w=>A(w.target.value),placeholder:p(N),"data-testid":`${o}-model`,className:`${fe} min-w-0 flex-1 px-2.5 py-1.5 font-mono`}),e.jsx("input",{type:"password",value:f,onChange:w=>z(w.target.value),placeholder:p("settings.custom.apikey_ph"),"data-testid":`${o}-apikey`,className:`${fe} min-w-0 flex-1 px-2.5 py-1.5`})]}),t==="llm"&&e.jsxs("label",{className:"inline-flex items-center gap-2 text-label cursor-pointer select-none","data-testid":`${o}-vision`,children:[e.jsx("input",{type:"checkbox",checked:R,onChange:w=>M(w.target.checked),className:"w-4 h-4 rounded accent-brand"}),e.jsx("span",{className:"text-ink-strong",children:p("settings.custom.vision")}),e.jsx("span",{className:"text-ink-faint",children:p("settings.custom.visionHint")})]}),B&&e.jsxs("div",{className:`text-label rounded p-2 inline-flex items-start gap-1.5 ${B.ok?"bg-brand/10 text-brand":"bg-warning/10 text-warning"}`,children:[B.ok?e.jsx(xe,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"break-words",children:B.detail})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>void E(),disabled:!$.trim()||!y.trim()||q,"data-testid":`${o}-test`,className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:p(q?"settings.testing":"settings.test")}),e.jsx("button",{onClick:()=>void _(),disabled:!g.trim()||!$.trim()||!y.trim(),"data-testid":`${o}-save`,className:"btn-3d-brand px-3 py-1.5 text-label disabled:opacity-40",children:p("settings.custom.save")}),v&&e.jsx("button",{onClick:v,className:"text-label text-ink-muted hover:text-ink-strong px-3 py-1.5 transition-colors",children:p("action.cancel")})]})]})}const He="lookatstudy-theme",Ke="auto",qe="(prefers-color-scheme: dark)";function Pe(){return typeof window>"u"||window.matchMedia(qe).matches?"dark":"light"}function Ct(){if(typeof localStorage>"u")return Ke;const t=localStorage.getItem(He);return t==="auto"||t==="light"||t==="dark"?t:Ke}function ze(t){const x=document.documentElement;x.classList.remove("dark","light"),x.classList.add(t),window.dispatchEvent(new CustomEvent("theme-changed",{detail:{resolved:t}}))}function _t(){const[t,x]=n.useState(()=>Ct()),[o,b]=n.useState(()=>t==="auto"?Pe():t),N=n.useCallback(l=>{x(l),localStorage.setItem(He,l);const c=l==="auto"?Pe():l;b(c),ze(c)},[]);return n.useEffect(()=>{if(t!=="auto")return;const l=window.matchMedia(qe),c=v=>{const p=v.matches?"dark":"light";b(p),ze(p)};return l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[t]),n.useEffect(()=>{const l=t==="auto"?Pe():t;b(l),ze(l)},[t]),{mode:t,resolved:o,setMode:N}}const $t="0.37.1",Et={version:$t};function Se(){window.dispatchEvent(new Event(ft))}const ie="bg-surface-1 text-ink text-body rounded-lg border border-[var(--border)] focus:border-brand focus:outline-none transition-colors placeholder:text-ink-faint",ee="bg-surface-3 text-ink-muted hover:bg-surface-3 hover:bg-surface-3 hover:text-ink-strong",te="bg-brand text-white shadow-sm";function P(t){return t?"px-4 py-3.5 border-t border-[var(--border-faint)]":"px-4 py-3.5"}function Bt(){const t=ce(),[x,o]=n.useState([]),[b,N]=n.useState([]),[l,c]=n.useState("glm"),[v,p]=n.useState(""),[g,S]=n.useState(""),[j,T]=n.useState(null),[$,h]=n.useState(!1),[f,z]=n.useState(null),[y,A]=n.useState(!1),[R,M]=n.useState(!1),[q,V]=n.useState([]),[B,m]=n.useState(!1),[E,_]=n.useState(null),[w,O]=n.useState(null),[W,G]=n.useState(""),[d,X]=n.useState(!1),U=_t(),se=async i=>{if(I)try{await r.updateCustomProvider(I.id,{vision:i}),await H()}catch{}},ae=async()=>{m(!0),_(null);try{const i=await r.discoverModels();i.ok&&i.models?V(i.models):_(i.error||t("settings.discover_failed"))}catch(i){_(i instanceof Error?i.message:String(i))}finally{m(!1)}},H=n.useCallback(async()=>{try{const[i,C,K,Z]=await Promise.all([r.getProviderPresets(),r.listCustomProviders(),r.getSetting("active_provider"),r.getSetting("active_model")]);o(i),N(C);const F=K??"glm";if(c(F),F.startsWith("custom-")){const s=C.find(u=>u.id===F);T(s!=null&&s.hasApiKey?t("settings.key.configured"):null)}else{const s=i.find(u=>u.id===F);if(s){const u=await r.hasSetting(s.apiKeySetting);T(u?t("settings.key.configured"):null)}}if(F.startsWith("custom-")){const s=C.find(u=>u.id===F);p(Z??(s==null?void 0:s.defaultModel)??"")}else{const s=i.find(u=>u.id===F);p(Z??(s==null?void 0:s.defaultModel)??"")}}catch(i){console.error("[SettingsView] load() failed:",i)}},[t]);n.useEffect(()=>{H()},[H]);const le=async i=>{c(i),z(null),S("");const C=x.find(K=>K.id===i);if(C){const K=await r.hasSetting(C.apiKeySetting);T(K?t("settings.key.configured"):null),p(v||C.defaultModel)}},me=async()=>{A(!1);try{if(await r.setSetting("active_provider",l),await r.setSetting("active_model",v),g.trim()){const i=x.find(C=>C.id===l);i&&(await r.setSetting(i.apiKeySetting,g.trim()),T(`${g.trim().slice(0,4)}…${g.trim().slice(-4)}`),S(""))}A(!0),setTimeout(()=>A(!1),2e3),window.dispatchEvent(new Event("llm-config-changed"))}catch{}},D=async()=>{h(!0),z(null);try{const i=await r.testLlmConnection();z(i)}catch(i){z({ok:!1,detail:i instanceof Error?i.message:String(i),errorKind:"unknown"})}finally{h(!1)}},Y=async i=>{await r.setSetting("active_provider",i.id),await r.setSetting("active_model",i.defaultModel),c(i.id),p(i.defaultModel),M(!1),await H(),window.dispatchEvent(new Event("llm-config-changed"))},oe=async i=>{try{await r.deleteCustomProvider(i),l===i&&(await r.setSetting("active_provider","glm"),c("glm")),await H()}catch{}},I=l.startsWith("custom-")?b.find(i=>i.id===l):null;n.useEffect(()=>{if(!I)return;const i=I.models.find(C=>C.id===v);G(i!=null&&i.contextWindow?String(i.contextWindow):"")},[I,v]);const pe=async()=>{var F,s;if(!I)return;const i=W.trim().replace(/[,\s_]/g,""),C=/^(\d+)([km]?)$/i.exec(i);if(i!==""&&!C)return;const K=((F=C==null?void 0:C[2])==null?void 0:F.toLowerCase())==="k"?1e3:((s=C==null?void 0:C[2])==null?void 0:s.toLowerCase())==="m"?1e6:1,Z=i===""||!C?null:Math.max(1,Math.round(parseInt(C[1],10)*K));X(!0);try{const u=I.models.map(L=>L.id===v?{...L,contextWindow:Z}:L);await r.updateCustomProvider(I.id,{models:u}),await H(),window.dispatchEvent(new Event("llm-config-changed"))}catch{}finally{X(!1)}},ne=l.startsWith("custom-")?null:x.find(i=>i.id===l);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-5 pt-5 space-y-6",children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.ai")}),e.jsxs("div",{className:"surface-card overflow-hidden",children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.provider")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5","data-testid":"provider-grid",children:[x.map(i=>e.jsx("button",{onClick:()=>le(i.id),"data-testid":`provider-card-${i.id}`,"aria-pressed":l===i.id,className:`px-3 py-1.5 rounded-lg text-label font-medium whitespace-nowrap transition-colors ${l===i.id?te:ee}`,children:i.label},i.id)),b.filter(i=>i.kind==="llm").map(i=>e.jsxs("button",{onClick:()=>le(i.id),"data-testid":`provider-card-${i.id}`,"aria-pressed":l===i.id,className:`px-3 py-1.5 rounded-lg text-label font-medium whitespace-nowrap transition-colors inline-flex items-center gap-1 ${l===i.id?te:ee}`,children:[e.jsx(Le,{className:"w-3.5 h-3.5","aria-hidden":"true"}),i.label]},i.id)),e.jsxs("button",{onClick:()=>M(i=>!i),"data-testid":"add-custom-provider",className:"px-3 py-1.5 rounded-lg text-label whitespace-nowrap inline-flex items-center gap-1 border border-dashed border-[var(--border)] text-ink-muted hover:border-ink-muted hover:text-ink-strong transition-colors",children:[e.jsx(Ue,{className:"w-3.5 h-3.5","aria-hidden":"true"}),t("settings.add_custom")]})]})]}),R&&e.jsx("div",{className:"px-4 py-3.5 bg-surface-1 border-t border-[var(--border-faint)]",children:e.jsx($e,{kind:"llm",testPrefix:"custom",onSaved:i=>void Y(i),onCancel:()=>M(!1)})}),b.length>0&&l.startsWith("custom-")&&e.jsx("div",{className:P(!0),children:e.jsx("button",{onClick:i=>{const C=i.currentTarget.getBoundingClientRect(),K=b.find(Z=>Z.id===l);K&&O({id:K.id,label:K.label,rect:C})},className:"text-label text-warning hover:underline",children:t("settings.delete_custom")})}),ne&&e.jsxs(e.Fragment,{children:[ne.baseUrl&&e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:"Base URL"}),e.jsx("code",{className:"text-label text-ink-faint font-mono break-all",children:ne.baseUrl})]}),e.jsxs("div",{className:P(!0),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.model")}),e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[e.jsxs("select",{value:v,onChange:i=>p(i.target.value),"data-testid":"model-select",className:`${ie} flex-1 px-2.5 py-1.5`,children:[ne.models.map(i=>e.jsx("option",{value:i.id,children:i.id},i.id)),l==="openrouter"&&q.map(i=>e.jsx("option",{value:i.id,children:i.id},i.id))]}),l==="openrouter"&&e.jsxs("button",{onClick:ae,disabled:B,"data-testid":"discover-models-btn",className:"text-label text-accent hover:underline disabled:opacity-40 whitespace-nowrap inline-flex items-center gap-1",children:[e.jsx(vt,{className:`w-3.5 h-3.5 ${B?"animate-spin":""}`,"aria-hidden":"true"}),t(B?"settings.discovering":"settings.refresh")]})]})]}),E&&e.jsx("div",{className:"text-label text-warning mt-1.5 ml-[68px]",children:E})]}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.apikey")}),e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[j&&e.jsxs("span",{className:"text-label text-brand shrink-0 inline-flex items-center gap-1",children:[e.jsx(xe,{className:"w-3.5 h-3.5","aria-hidden":"true"}),j]}),e.jsx("input",{type:"password",value:g,onChange:i=>S(i.target.value),placeholder:t(j?"settings.key.overwrite_ph":"settings.key.paste_ph"),"data-testid":"settings-key-input",className:`${ie} flex-1 px-2.5 py-1.5`}),e.jsx("a",{href:ne.keyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-label text-brand hover:underline whitespace-nowrap",children:t("settings.key.get")})]})]})}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 min-w-0",children:[e.jsx("button",{onClick:D,disabled:$,"data-testid":"test-connection-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:t($?"settings.testing":"settings.test")}),f&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 min-w-0 break-words ${f.ok?"text-brand":"text-warning"}`,children:[f.ok?e.jsx(xe,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}),f.detail]})]})})]}),I&&!ne&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:"Base URL"}),e.jsx("code",{className:"text-label text-ink-faint font-mono break-all",children:I.baseUrl})]}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.model")}),I.models.length>1?e.jsx("select",{value:v,onChange:i=>p(i.target.value),"data-testid":"model-select-custom",className:`${ie} flex-1 px-2.5 py-1.5`,children:I.models.map(i=>e.jsx("option",{value:i.id,children:i.id},i.id))}):e.jsx("input",{type:"text",value:v,onChange:i=>p(i.target.value),placeholder:t("settings.custom.model_ph"),"data-testid":"model-input-custom",className:`${ie} flex-1 px-2.5 py-1.5 font-mono`})]})}),e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.custom.windowLabel")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",inputMode:"numeric",value:W,onChange:i=>G(i.target.value),placeholder:t("settings.custom.windowPh"),"data-testid":"context-window-input",className:`${ie} flex-1 px-2.5 py-1.5 font-mono tabular-nums`}),e.jsx("button",{onClick:pe,disabled:d,"data-testid":"context-window-save",className:"btn-3d-neutral px-3 py-1.5 text-label shrink-0 disabled:opacity-40",children:t("settings.custom.save")})]}),e.jsx("div",{className:"text-caption text-ink-faint mt-1",children:t("settings.custom.windowHint")})]}),e.jsx("div",{className:P(!0),children:e.jsxs("label",{className:"inline-flex items-center gap-2 text-label cursor-pointer select-none","data-testid":"custom-vision-toggle",children:[e.jsx("input",{type:"checkbox",checked:I.vision,onChange:i=>void se(i.target.checked),className:"w-4 h-4 rounded accent-brand"}),e.jsx("span",{className:"text-ink-strong",children:t("settings.custom.vision")}),e.jsx("span",{className:"text-ink-faint",children:t("settings.custom.visionHint")})]})}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 min-w-0",children:[e.jsx("button",{onClick:D,disabled:$,"data-testid":"test-connection-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:t($?"settings.testing":"settings.test")}),f&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 min-w-0 break-words ${f.ok?"text-brand":"text-warning"}`,children:[f.ok?e.jsx(xe,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}),f.detail]})]})})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.vision")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(zt,{activeProvider:l,activeModel:v,presets:x,customProviders:b,onProvidersChanged:()=>void H()})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.speech")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(At,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.memory")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(Tt,{})})]}),e.jsxs("section",{id:"settings-section-companion",children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.companion")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(Mt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.appearance")}),e.jsxs("div",{className:"surface-card overflow-hidden",children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.theme")}),e.jsx("div",{className:"flex gap-2",children:[{mode:"auto",label:t("settings.theme.auto")},{mode:"light",label:t("settings.theme.light")},{mode:"dark",label:t("settings.theme.dark")}].map(({mode:i,label:C})=>e.jsx("button",{onClick:()=>U.setMode(i),"data-testid":`theme-${i}`,"aria-pressed":U.mode===i,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${U.mode===i?te:ee}`,children:C},i))}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:U.mode==="auto"?t("settings.theme.following",{mode:t(`settings.theme.${U.resolved}`)}):null})]}),e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.interface_lang")}),e.jsx("div",{className:"flex gap-2",children:["zh-CN","en"].map(i=>e.jsx("button",{onClick:()=>xt(i),"data-testid":`lang-${i}`,"aria-pressed":De()===i,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${De()===i?te:ee}`,children:i==="zh-CN"?"中文":"English"},i))})]}),e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.import_lang")}),e.jsx(Pt,{})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.data")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(It,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.about")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsxs("div",{className:P(!1),children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:t("settings.row.version")}),e.jsxs("a",{href:"https://github.com/Kaiji-Z/LookatStudy/releases",target:"_blank",rel:"noopener noreferrer",className:"text-label font-mono text-brand hover:underline","data-testid":"settings-version",children:["v",Et.version]})]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.version.hint")})]})})]})]}),e.jsxs("div",{className:"sticky bottom-0 px-5 py-3 bg-surface-0 border-t border-[var(--border)] flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-label text-ink-muted",children:t("settings.footer.hint")}),e.jsxs("button",{onClick:me,"data-testid":"settings-save",className:"btn-3d-brand px-5 py-2 text-body inline-flex items-center gap-1.5",children:[y&&e.jsx(ht,{className:"w-4 h-4","aria-hidden":"true"}),t(y?"settings.saved_text":"settings.footer.save")]})]}),w&&e.jsx(_e,{anchorRect:w.rect,message:t("settings.delete_custom_confirm",{name:w.label}),danger:!0,confirmLabel:t("action.delete"),testid:"custom-provider-delete-confirm",onConfirm:()=>{oe(w.id),O(null)},onCancel:()=>O(null)})]})}function Pt(){const[t,x]=n.useState("en"),[o,b]=n.useState(!1);n.useEffect(()=>{r.getSetting("pref_lang").then(c=>{c&&x(c),b(!0)})},[]);const N=async c=>{x(c),await r.setSetting("pref_lang",c)},l=[{code:"en",label:"English"},{code:"zh-CN",label:"简体中文"},{code:"zh-TW",label:"繁體中文"}];return o?e.jsx("div",{className:"flex gap-2","data-testid":"pref-lang-options",children:l.map(c=>e.jsx("button",{onClick:()=>N(c.code),"data-testid":`pref-lang-${c.code}`,"aria-pressed":t===c.code,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${t===c.code?te:ee}`,children:c.label},c.code))}):null}function zt({activeProvider:t,activeModel:x,presets:o,customProviders:b,onProvidersChanged:N}){const l=ce(),[c,v]=n.useState(!1),[p,g]=n.useState(!1),[S,j]=n.useState(""),[T,$]=n.useState(!1),[h,f]=n.useState(!1),[z,y]=n.useState(null),[A,R]=n.useState(!1);n.useEffect(()=>{Promise.all([r.getSetting("flag_multimodal_import"),r.getSetting("vision_provider_override"),r.getSetting("vision_model_override"),r.getSetting("flag_math_vision")]).then(([d,X,U])=>{v(d==="true"),j(X??""),R(U==="true"),g(!0)})},[]);const M=async()=>{const d=!c;v(d),await r.setSetting("flag_multimodal_import",String(d))},q=async()=>{const d=!A;R(d),await r.setSetting("flag_math_vision",String(d))},V=async d=>{await r.setSetting("vision_provider_override",d.id),await r.setSetting("vision_model_override",d.defaultModel),j(d.id),$(!1)},B=async()=>{await r.setSetting("vision_provider_override",""),await r.setSetting("vision_model_override",""),j(""),$(!1)},[m,E]=n.useState(null),_=async d=>{try{S===d&&(await r.setSetting("vision_provider_override",""),await r.setSetting("vision_model_override",""),j("")),await r.deleteCustomProvider(d)}catch{}finally{N==null||N()}},w=async()=>{if(!h){f(!0),y(null);try{const d=await r.testLlmConnection({vision:!0});y({ok:d.ok,detail:d.detail})}catch(d){y({ok:!1,detail:d instanceof Error?d.message:String(d)})}finally{f(!1)}}},O=b.filter(d=>d.kind==="vision"),W=S.startsWith("custom-")?b.find(d=>d.id===S):null,G=S&&!S.startsWith("custom-")?o.find(d=>d.id===S):null;return p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(he,{checked:c,onChange:M,label:l("settings.multimodal.toggle"),testid:"multimodal-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:l("settings.multimodal.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:l("settings.multimodal.toggle.desc")})]})]}),e.jsxs("div",{className:"px-4 py-3.5 border-t border-[var(--border-faint)] space-y-3",children:[e.jsxs("div",{className:"text-label text-ink-muted bg-ink/5 rounded-lg p-3",children:[e.jsx("div",{className:"font-medium mb-1",children:l("settings.multimodal.current_model",{model:x||l("settings.multimodal.not_selected")})}),e.jsx("div",{children:t.startsWith("custom-")?l("settings.multimodal.hint_custom"):l("settings.multimodal.hint_preset")})]}),e.jsxs("div",{className:"bg-ink/5 rounded-lg p-3",children:[e.jsx("div",{className:"text-label font-medium text-ink-muted mb-2",children:l("settings.multimodal.override_title")}),e.jsx("div",{className:"text-caption text-ink-muted mb-2",children:l("settings.multimodal.override_bridge_hint")}),e.jsxs("div",{className:"space-y-3 mt-1",children:[W&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx(Le,{className:"w-3.5 h-3.5 text-ink-faint shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium text-ink-strong",children:W.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:W.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:W.baseUrl})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{onClick:()=>void w(),disabled:h,"data-testid":"vision-override-test",className:"btn-3d-neutral px-4 py-1.5 text-label disabled:opacity-50",children:l(h?"settings.testing":"settings.multimodal.test_override")}),e.jsx("button",{onClick:()=>$(d=>!d),className:"text-label text-accent hover:underline",children:l("settings.multimodal.replace_custom")}),e.jsx("button",{onClick:()=>void B(),className:"text-label text-ink-muted hover:text-ink-strong",children:l("settings.multimodal.stop_override")}),e.jsx("button",{onClick:d=>{d.stopPropagation(),E({id:W.id,label:W.label,rect:d.currentTarget.getBoundingClientRect()})},"data-testid":`vision-delete-${W.id}`,className:"text-label text-ink-muted hover:text-warning",children:l("action.delete")}),z&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${z.ok?"text-brand":"text-warning"}`,children:[z.ok?e.jsx(xe,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4","aria-hidden":"true"}),z.detail]})]})]}),G&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx("span",{className:"text-ink-muted",children:l("settings.multimodal.legacy_preset",{label:G.label})}),e.jsx("button",{onClick:()=>void B(),className:"text-label text-ink-muted hover:text-ink-strong underline",children:l("settings.multimodal.stop_override")})]}),!W&&!G&&e.jsxs(e.Fragment,{children:[O.map(d=>e.jsxs("span",{className:"relative block",children:[e.jsxs("button",{onClick:()=>void V(d),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`vision-pick-${d.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:d.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:d.defaultModel})]}),e.jsx("button",{type:"button","aria-label":l("action.delete"),"data-tooltip":l("action.delete"),"data-testid":`vision-delete-${d.id}`,onClick:X=>{X.stopPropagation(),E({id:d.id,label:d.label,rect:X.currentTarget.getBoundingClientRect()})},className:"absolute top-1.5 right-1.5 w-6 h-6 rounded-full text-ink-muted hover:text-warning flex items-center justify-center hover:bg-surface-2",children:e.jsx(ve,{className:"w-3.5 h-3.5"})})]},d.id)),(T||O.length===0)&&e.jsx($e,{kind:"vision",testPrefix:"vision-custom",titleKey:"settings.custom.form_title_vision",modelPhKey:"settings.custom.model_ph_vision",onSaved:d=>void V(d),onCancel:()=>$(!1)}),O.length>0&&e.jsx("button",{onClick:()=>$(d=>!d),className:"text-label text-accent hover:underline",children:l(T?"action.cancel":"settings.custom.new")})]})]})]}),e.jsxs("div",{className:"bg-ink/5 rounded-lg p-3 flex items-center gap-3",children:[e.jsx(he,{checked:A,onChange:q,label:l("settings.mathvision.toggle"),testid:"math-vision-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:l("settings.mathvision.toggle")}),e.jsx("div",{className:"text-caption text-ink-muted",children:l("settings.mathvision.desc")})]})]})]}),m&&e.jsx(_e,{anchorRect:m.rect,message:l("settings.delete_custom_confirm",{name:m.label}),danger:!0,confirmLabel:l("action.delete"),testid:"vision-provider-delete-confirm",onConfirm:()=>{_(m.id),E(null)},onCancel:()=>E(null)})]}):null}function Tt(){const t=ce(),[x,o]=n.useState(!1),[b,N]=n.useState(!1);n.useEffect(()=>{r.getSetting("flag_memory_system").then(c=>{o(c==="true"),N(!0)})},[]);const l=async()=>{const c=!x;o(c),await r.setSetting("flag_memory_system",String(c))};return b?e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(he,{checked:x,onChange:l,label:t("settings.memory.toggle"),testid:"memory-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.memory.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.memory.toggle.desc")})]})]}):null}function Mt(){var K,Z,F;const t=ce(),[x,o]=n.useState(!0),[b,N]=n.useState(!1),l=n.useSyncExternalStore(ot,rt),[c,v]=n.useState(!0),[p,g]=n.useState(!1),S=typeof window<"u"&&!!window.__lookatstudyWeb;n.useEffect(()=>{r.getSetting("companion_enabled").then(s=>{o(s!=="false"&&s!=="0"),N(!0)}),r.getSetting("companion_sfx").then(s=>{v(s!=="false"&&s!=="0")}),r.getSetting("companion_pet_mode").then(s=>{g(s==="1")})},[]);const j=async()=>{const s=!x;o(s),await r.setSetting("companion_enabled",String(s)),window.dispatchEvent(new Event("companion-config-changed"))},T=async()=>{const s=!c;v(s),await r.setSetting("companion_sfx",String(s)),window.dispatchEvent(new Event("companion-config-changed"))},$=async()=>{const s=!p;g(s),await r.setSetting("companion_pet_mode",s?"1":"0"),window.dispatchEvent(new Event("companion-config-changed"))},h=async s=>{s!==l.form&&(await r.setSetting("companion_form",s),window.dispatchEvent(new Event("companion-config-changed")))},[f,z]=n.useState([]),[y,A]=n.useState(!1),[R,M]=n.useState(null),[q,V]=n.useState(!1),[B,m]=n.useState(!1),[E,_]=n.useState(!1),[w,O]=n.useState(null),[W,G]=n.useState(!1),[d,X]=n.useState([]),[U,se]=n.useState(null),[ae,H]=n.useState(null),[le,me]=n.useState(null),D=n.useCallback(async()=>{try{z((await window.api.companionPackList()).packs)}catch{}},[]),Y=n.useCallback(async()=>{try{X((await window.api.shimejiList()).packs)}catch{}},[]);n.useEffect(()=>{D(),Y();const s=()=>{D(),Y()};return window.addEventListener("companion-config-changed",s),()=>window.removeEventListener("companion-config-changed",s)},[D,Y]);const oe=async s=>{await r.shimejiActivate({id:s}),l.form!=="shimeji"&&await r.setSetting("companion_form","shimeji"),window.dispatchEvent(new Event("companion-config-changed")),await Y(),await Ce()},I=async(s,u)=>{await window.api.shimejiSetVehicle({id:s,vehicle:u}),await Y(),await Ce()},pe=async s=>{await window.api.shimejiDelete({id:s}),se(null),await Y(),await Ce()},ne=async s=>{await window.api.companionPackActivate({id:s}),l.form!=="custom"&&await r.setSetting("companion_form","custom"),await Me(),window.dispatchEvent(new Event("companion-config-changed"))},i=async s=>{(await window.api.companionPackDelete({id:s})).formReset&&window.dispatchEvent(new Event("companion-config-changed")),M(null),me(null),D()},C=async(s,u)=>{var L;await window.api.companionPackSetVehicle({id:s,vehicle:u}),await D(),(L=f.find(Q=>Q.id===s))!=null&&L.active&&(await Me(),window.dispatchEvent(new Event("companion-config-changed")))};return b?e.jsxs("div",{className:"px-4 py-3.5 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{checked:x,onChange:j,label:t("settings.companion.toggle"),testid:"companion-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.companion.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.companion.toggle.desc")})]})]}),x&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{checked:c,onChange:T,label:t("settings.companion.sfx"),testid:"companion-sfx-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.companion.sfx")}),e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.companion.sfx.desc")})]})]}),!S&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{checked:p,onChange:$,label:t("settings.companion.pet"),testid:"companion-pet-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.companion.pet")}),e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.companion.pet.desc")})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-label text-ink-muted mb-2",children:t("settings.companion.form")}),e.jsxs("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":t("settings.companion.form"),children:[ct.filter(s=>s!=="custom"&&s!=="shimeji").map(s=>{const u=l.form===s;return e.jsxs("button",{type:"button",role:"radio","aria-checked":u,"data-testid":`companion-form-${s}`,onClick:()=>{h(s)},className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
13
+ ${u?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,title:t(`companion.form.${s}.desc`),children:[e.jsx(dt,{form:s,expression:"happy",pose:"float",size:64}),e.jsx("span",{className:`text-label ${u?"text-ink-strong font-medium":"text-ink-muted"}`,children:t(`companion.form.${s}.name`)})]},s)}),e.jsxs("button",{type:"button",role:"radio","aria-checked":l.form==="custom"&&f.some(s=>s.active),"data-testid":"companion-card-custom",onClick:()=>m(!0),title:t("companion.pick.custom.title"),className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
14
+ ${l.form==="custom"&&f.some(s=>s.active)?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[(()=>{const s=f.find(u=>u.active);return s!=null&&s.thumb?e.jsx("img",{src:s.thumb,alt:"",className:"h-14 w-14 object-contain"}):e.jsx("span",{className:"h-14 w-14 flex items-center justify-center",children:e.jsx("span",{className:"h-9 w-9 rounded-full bg-[#c8a06e]"})})})(),e.jsx("span",{className:`text-label max-w-20 truncate ${l.form==="custom"&&f.some(s=>s.active)?"text-ink-strong font-medium":"text-ink-muted"}`,children:((K=f.find(s=>s.active))==null?void 0:K.name)??t("companion.create.self.name")})]}),e.jsxs("button",{type:"button",role:"radio","aria-checked":l.form==="shimeji"&&d.some(s=>s.active),"data-testid":"companion-card-shimeji",onClick:()=>_(!0),title:t("companion.pick.shimeji.title"),className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
15
+ ${l.form==="shimeji"&&d.some(s=>s.active)?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[(()=>{const s=d.find(u=>u.active);return s!=null&&s.iconBase64?e.jsx("img",{src:`data:image/png;base64,${s.iconBase64}`,alt:"",className:"h-14 w-14 object-contain"}):e.jsx("span",{className:"h-14 w-14 flex items-center justify-center text-caption text-ink-muted",children:"Shimeji"})})(),e.jsx("span",{className:`text-label max-w-20 truncate ${l.form==="shimeji"&&d.some(s=>s.active)?"text-ink-strong font-medium":"text-ink-muted"}`,children:((Z=d.find(s=>s.active))==null?void 0:Z.name)??"Shimeji"})]}),e.jsxs("button",{type:"button",role:"radio","aria-checked":!1,"data-testid":"companion-form-add","aria-label":t("companion.bots.add"),onClick:()=>V(!0),className:"flex flex-col items-center gap-0.5 rounded-xl p-1.5 border border-dashed border-[var(--border-faint)] hover:bg-surface-2",children:[e.jsx("span",{className:"h-14 w-14 flex items-center justify-center text-ink-muted",children:e.jsx(Ue,{className:"w-6 h-6"})}),e.jsx("span",{className:"text-label text-ink-muted",children:t("companion.bots.add")})]})]}),R&&e.jsx(_e,{anchorRect:R.rect,message:t("companion.bots.deleteConfirm"),danger:!0,testid:"companion-pack-delete-confirm",onConfirm:()=>void i(R.id),onCancel:()=>M(null)}),B&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":t("companion.pick.custom.title"),onClick:()=>m(!1),children:e.jsxs("div",{className:"relative w-full max-w-md max-h-[85dvh] flex flex-col rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4","data-testid":"custom-pack-list",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"text-body font-medium text-ink-strong mb-3",children:t("companion.pick.custom.title")}),e.jsxs("div",{className:"min-h-0 overflow-y-auto",children:[f.length===0?e.jsx("p",{className:"text-label text-ink-muted py-4 text-center",children:t("companion.pick.empty.custom")}):e.jsx("div",{className:"flex flex-col gap-1.5",children:f.map(s=>e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button","data-testid":`custom-pack-option-${s.id}`,onClick:()=>{ne(s.id),m(!1)},className:`w-full flex items-center gap-2.5 rounded-xl border p-2 text-left motion-safe:transition-colors
16
+ ${s.active&&l.form==="custom"?"border-[var(--accent)] bg-surface-2":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[s.thumb?e.jsx("img",{src:s.thumb,alt:"",className:"w-10 h-10 rounded-lg object-contain bg-surface-2"}):e.jsx("span",{className:"w-10 h-10 rounded-lg bg-surface-2 inline-block"}),e.jsx("span",{className:"text-body text-ink-strong flex-1 truncate",children:s.name}),s.active&&l.form==="custom"&&e.jsx("span",{className:"text-caption text-brand font-medium",children:t("settings.shimeji.active")})]}),e.jsx("button",{type:"button","aria-label":t("companion.bots.veh"),"data-tooltip":t("companion.bots.veh"),"data-testid":`companion-pack-veh-${s.id}`,onClick:u=>{u.stopPropagation(),me(L=>L===s.id?null:s.id)},className:"absolute top-1.5 -left-1.5 w-5 h-5 rounded-full border border-black/25 shadow-card hover:scale-110 motion-safe:transition-transform",style:{background:be[s.vehicle??"silver"].dot}}),e.jsx("button",{type:"button","aria-label":t("companion.custom.delete"),onClick:u=>{u.stopPropagation(),M({id:s.id,rect:u.currentTarget.getBoundingClientRect()})},className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full flex items-center justify-center text-ink-faint hover:text-warning",children:e.jsx(ve,{className:"w-3.5 h-3.5"})})]},s.id))}),le&&e.jsxs("div",{className:"mt-2.5 rounded-xl border border-[var(--border-faint)] bg-surface-0 p-2.5","data-testid":"companion-veh-picker",children:[e.jsx("div",{className:"text-caption text-ink-muted mb-1.5",children:t("companion.wizard.vehicle")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5",role:"radiogroup","aria-label":t("companion.wizard.vehicle"),children:["silver",...Te].map(s=>{var L;const u=(((L=f.find(Q=>Q.id===le))==null?void 0:L.vehicle)??"silver")===s;return e.jsxs("button",{type:"button",role:"radio","aria-checked":u,"data-testid":`companion-veh-pick-${s}`,onClick:()=>void C(le,s),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-label motion-safe:transition-colors
17
+ ${u?"border-[var(--accent)] bg-surface-2 text-ink-strong font-medium":"border-[var(--border-faint)] hover:bg-surface-2 text-ink-muted"}`,children:[e.jsx("span",{"aria-hidden":"true",className:"w-3 h-3 rounded-full border border-black/20",style:{background:be[s].dot}}),t(s==="silver"?"companion.veh.silver":`companion.form.${s}.name`)]},s)})})]})]})]})}),E&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":t("companion.pick.shimeji.title"),onClick:()=>_(!1),children:e.jsxs("div",{className:"relative w-full max-w-md max-h-[85dvh] flex flex-col rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4","data-testid":"shimeji-pack-list",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"text-body font-medium text-ink-strong mb-3",children:t("companion.pick.shimeji.title")}),e.jsxs("div",{className:"min-h-0 overflow-y-auto",children:[d.length===0?e.jsx("p",{className:"text-label text-ink-muted py-4 text-center",children:t("companion.pick.empty.shimeji")}):e.jsx("div",{className:"flex flex-col gap-1.5",children:d.map(s=>e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button","data-testid":`shimeji-pack-option-${s.id}`,onClick:()=>{oe(s.id),_(!1)},className:`w-full flex items-center gap-2.5 rounded-xl border p-2 text-left motion-safe:transition-colors
18
+ ${s.active&&l.form==="shimeji"?"border-[var(--accent)] bg-surface-2":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[s.iconBase64?e.jsx("img",{src:`data:image/png;base64,${s.iconBase64}`,alt:"",className:"w-10 h-10 rounded-lg object-contain bg-surface-2"}):e.jsx("span",{className:"w-10 h-10 rounded-lg bg-surface-2 inline-block"}),e.jsxs("span",{className:"flex flex-col flex-1 min-w-0",children:[e.jsx("span",{className:"text-body text-ink-strong truncate",children:s.name}),e.jsxs("span",{className:"text-caption text-ink-muted",children:[s.format," · ",s.frameCount,"f · ",s.actionCount]})]}),s.active&&l.form==="shimeji"&&e.jsx("span",{className:"text-caption text-brand font-medium",children:t("settings.shimeji.active")})]}),e.jsx("button",{type:"button","aria-label":t("companion.bots.veh"),"data-tooltip":t("companion.bots.veh"),"data-testid":`shimeji-pack-veh-${s.id}`,onClick:u=>{u.stopPropagation(),H(L=>L===s.id?null:s.id)},className:"absolute top-1.5 -left-1.5 w-5 h-5 rounded-full border border-black/25 shadow-card hover:scale-110 motion-safe:transition-transform",style:{background:be[s.vehicle??"silver"].dot}}),e.jsx("button",{type:"button","aria-label":t("settings.shimeji.delete"),onClick:u=>{u.stopPropagation(),se({id:s.id,rect:u.currentTarget.getBoundingClientRect()})},className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full flex items-center justify-center text-ink-faint hover:text-warning",children:e.jsx(ve,{className:"w-3.5 h-3.5"})})]},s.id))}),ae&&e.jsxs("div",{className:"mt-2.5 rounded-xl border border-[var(--border-faint)] bg-surface-0 p-2.5","data-testid":"shimeji-veh-picker",children:[e.jsx("div",{className:"text-caption text-ink-muted mb-1.5",children:t("companion.wizard.vehicle")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5",role:"radiogroup","aria-label":t("companion.wizard.vehicle"),children:["silver",...Te].map(s=>{var L;const u=(((L=d.find(Q=>Q.id===ae))==null?void 0:L.vehicle)??"silver")===s;return e.jsxs("button",{type:"button",role:"radio","aria-checked":u,"data-testid":`shimeji-veh-pick-${s}`,onClick:()=>void I(ae,s),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-label motion-safe:transition-colors
19
+ ${u?"border-[var(--accent)] bg-surface-2 text-ink-strong font-medium":"border-[var(--border-faint)] hover:bg-surface-2 text-ink-muted"}`,children:[e.jsx("span",{"aria-hidden":"true",className:"w-3 h-3 rounded-full border border-black/20",style:{background:be[s].dot}}),t(s==="silver"?"companion.veh.silver":`companion.form.${s}.name`)]},s)})})]})]})]})}),q&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":t("companion.create.title"),onClick:()=>V(!1),children:e.jsxs("div",{className:"relative w-full max-w-md rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"text-body font-medium text-ink-strong mb-3",children:t("companion.create.title")}),e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:[{key:"self",testid:"companion-create-self",name:t("companion.create.self.name"),hover:t("companion.create.self.hover"),open:()=>{V(!1),A(!0)}},{key:"shimeji",testid:"companion-create-shimeji",name:t("companion.create.shimeji.name"),hover:t("companion.create.shimeji.hover"),open:()=>{V(!1),G(!0)}}].map(s=>e.jsxs("button",{type:"button","data-testid":s.testid,onMouseEnter:()=>O(s.key),onMouseLeave:()=>O(u=>u===s.key?null:u),onFocus:()=>O(s.key),onBlur:()=>O(u=>u===s.key?null:u),onClick:s.open,className:`flex flex-col items-center gap-1.5 rounded-xl border p-4 motion-safe:transition-colors
20
+ ${w===s.key?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[e.jsx("span",{className:"text-body font-medium text-ink-strong",children:s.name}),e.jsx("span",{className:`text-caption text-ink-muted text-center leading-snug ${w===s.key?"":"opacity-0 h-0 overflow-hidden"} motion-safe:transition-all`,children:s.hover})]},s.key))}),e.jsx("p",{className:"text-caption text-ink-faint mt-3 text-center",children:t("companion.create.hint")})]})}),W&&e.jsx(St,{onClose:()=>G(!1),onImported:async()=>{await Y()}}),U&&e.jsx(_e,{anchorRect:U.rect,message:t("settings.shimeji.deleteConfirm",{name:((F=d.find(s=>s.id===U.id))==null?void 0:F.name)??""}),danger:!0,testid:"shimeji-delete-confirm",onConfirm:()=>void pe(U.id),onCancel:()=>se(null)}),y&&e.jsx(Nt,{onClose:()=>A(!1),onSaved:()=>{A(!1),D()}})]})]})]}):null}function he({checked:t,onChange:x,label:o,testid:b}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":o,onClick:x,"data-testid":b,className:`relative w-12 h-6 rounded-full transition-colors shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/60 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface-2)] ${t?"bg-brand":"bg-ink/20 hover:bg-ink/25"}`,children:e.jsx("span",{className:`absolute left-0.5 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full bg-white shadow transition-transform ${t?"translate-x-6":""}`})})}const Lt=[{id:"zh-CN-XiaoxiaoNeural",label:"zh-CN · 晓晓(女)"},{id:"zh-CN-XiaoyiNeural",label:"zh-CN · 晓伊(女)"},{id:"zh-CN-YunxiNeural",label:"zh-CN · 云希(男)"},{id:"zh-CN-YunyangNeural",label:"zh-CN · 云扬(男·新闻)"},{id:"zh-CN-liaoning-XiaobeiNeural",label:"zh-CN · 晓北(女·东北)"},{id:"zh-CN-shaanxi-XiaoniNeural",label:"zh-CN · 晓妮(女·陕西)"},{id:"en-US-AriaNeural",label:"en-US · Aria(女)"},{id:"en-US-GuyNeural",label:"en-US · Guy(男)"},{id:"en-US-JennyNeural",label:"en-US · Jenny(女)"}],Rt=[{sid:"45",label:"zf_xiaobei(女)"},{sid:"46",label:"zf_xiaoni(女)"},{sid:"47",label:"zf_xiaoxiao(女)"},{sid:"48",label:"zf_xiaoyi(女·默认)"},{sid:"49",label:"zm_yunjian(男)"},{sid:"50",label:"zm_yunxi(男)"},{sid:"51",label:"zm_yunxia(男)"},{sid:"52",label:"zm_yunyang(男)"}];function At(){const t=ce(),[x,o]=n.useState([]),[b,N]=n.useState(null),[l,c]=n.useState(null),[v,p]=n.useState(null),[g,S]=n.useState(null),[j,T]=n.useState("edge"),[$,h]=n.useState("zh-CN-XiaoxiaoNeural"),[f,z]=n.useState("48"),[y,A]=n.useState("1.0"),[R,M]=n.useState(""),[q,V]=n.useState(""),[B,m]=n.useState([]),E=typeof window<"u"&&"speechSynthesis"in window,[_,w]=n.useState("local"),[O,W]=n.useState("asr-whisper-turbo"),[G,d]=n.useState(!0),[X,U]=n.useState([]),[se,ae]=n.useState(!1),[H,le]=n.useState(!1),[me,D]=n.useState(!1),[Y,oe]=n.useState(!1),[I,pe]=n.useState(!1),[ne,i]=n.useState(null),[C,K]=n.useState(!1),[Z,F]=n.useState(null),[s,u]=n.useState(null),L=n.useCallback(()=>{r.listCustomProviders().then(a=>U(a.filter(k=>k.kind==="tts"||k.kind==="asr"))).catch(()=>{})},[]);n.useEffect(()=>{Promise.all([r.getSetting("tts_engine"),r.getSetting("tts_voice_edge"),r.getSetting("tts_sid_local"),r.getSetting("tts_speed"),r.getSetting("tts_custom_voice"),r.getSetting("tts_system_voice"),r.getSetting("asr_engine"),r.getSetting("asr_local_model"),r.getSetting("asr_auto_stop")]).then(([a,k,J,re,ye,Ve,Be,Ee,lt])=>{a&&T(a),k&&h(k),J&&z(J),re&&A(re),ye&&M(ye),Ve&&V(Ve),Be&&w(Be),(Ee==="asr-whisper-turbo"||Ee==="asr-whisper-small")&&W(Ee),d(lt!=="0")}),L()},[L]),n.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const a=()=>m(gt(window.speechSynthesis.getVoices()));return a(),window.speechSynthesis.addEventListener("voiceschanged",a),()=>window.speechSynthesis.removeEventListener("voiceschanged",a)},[]);const Q=n.useCallback(()=>{window.api.getSpeechModelStatus().then(a=>o(a)).catch(()=>{})},[]);n.useEffect(()=>(Q(),window.api.on("speech:modelProgress",k=>{p({id:k.id,pct:Math.floor(k.progress*100),label:k.currentFile?k.currentFile.split("/").pop()??"":""})})),[Q]);const Ge=a=>{c(null),N(a),p({id:a,pct:0,label:""}),window.api.ensureSpeechModel(a).then(()=>{N(null),p(null),Q()}).catch(k=>{N(null),p(null),c(k instanceof Error?k.message:String(k)),Q()})},Xe=a=>{N(a),S(null),window.api.deleteSpeechModel(a).then(Q).catch(k=>c(k instanceof Error?k.message:String(k))).finally(()=>N(null))},Ye=a=>t(a==="tts-kokoro"?"settings.speech.model.tts":a==="asr-whisper-turbo"?"settings.speech.model.asr_turbo":"settings.speech.model.asr_small"),Je=a=>t(a==="asr-whisper-turbo"?"settings.speech.model.turbo_short":"settings.speech.model.small_short"),Ze=a=>a.startsWith("asr-whisper")?t("settings.speech.license_mit"):t("settings.speech.license"),Re=a=>t(a==="ready"?"settings.speech.state.ready":a==="error"?"settings.speech.state.error":"settings.speech.state.absent"),Ae=a=>{var k;return((k=x.find(J=>J.id===a))==null?void 0:k.state)??"absent"},ge=a=>{T(a),i(null),r.setSetting("tts_engine",a),Se()},Qe=a=>{V(a),r.setSetting("tts_system_voice",a),Se()},we=a=>{w(a),F(null),r.setSetting("asr_engine",a)},ke=X.filter(a=>a.kind==="tts"),Ne=X.filter(a=>a.kind==="asr"),de=j.startsWith("custom-")?ke.find(a=>a.id===j)??null:null,ue=_.startsWith("custom-")?Ne.find(a=>a.id===_)??null:null,et=j==="azure",tt=_==="groq",st=_==="azure",at=async()=>{if(!(!de||I)){pe(!0),i(null);try{i(await r.testCustomTts({providerId:de.id}))}catch(a){i({ok:!1,detail:a instanceof Error?a.message:String(a)})}finally{pe(!1)}}},nt=async()=>{if(!(!ue||C)){K(!0),F(null);try{F(await r.testCustomAsr({providerId:ue.id}))}catch(a){F({ok:!1,detail:a instanceof Error?a.message:String(a)})}finally{K(!1)}}},it=async(a,k)=>{u(null);try{await r.deleteCustomProvider(a),k==="tts"&&j===a&&ge("edge"),k==="asr"&&_===a&&we("local"),L()}catch{}},Ie=a=>{const k=x.find(re=>re.id===a),J=(k==null?void 0:k.state)??"absent";return e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong truncate",children:Ye(a)}),e.jsxs("div",{className:"text-caption text-ink-muted",children:[Re(J)," · ",Ze(a)]}),b===a&&(v==null?void 0:v.id)===a&&e.jsx("div",{className:"mt-1.5 h-1.5 rounded-full bg-ink/[0.08] overflow-hidden","data-testid":`speech-dl-bar-${a}`,children:e.jsx("div",{className:"h-full bg-brand transition-all",style:{width:`${v.pct}%`}})}),b===a&&(v==null?void 0:v.id)===a&&e.jsxs("div",{className:"text-caption text-ink-faint mt-0.5","data-testid":`speech-dl-pct-${a}`,children:[v.pct,"%",v.label?` · ${v.label}`:""]})]}),J==="ready"?g===a?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-caption text-warning",children:t("settings.speech.confirm_del")}),e.jsx("button",{onClick:()=>Xe(a),className:"text-label text-warning hover:underline","data-testid":`speech-del-confirm-${a}`,children:t("settings.speech.delete")}),e.jsx("button",{onClick:()=>S(null),className:"text-label text-ink-muted hover:text-ink-strong",children:t("action.cancel")})]}):e.jsx("button",{onClick:()=>S(a),disabled:b===a,className:"text-label text-ink-muted hover:text-warning disabled:opacity-40","data-testid":`speech-del-${a}`,children:t("settings.speech.delete")}):e.jsx("button",{onClick:()=>Ge(a),disabled:b!=null||J==="downloading",className:"btn-3d-brand px-3 py-1 text-label disabled:opacity-40","data-testid":`speech-dl-${a}`,children:t(b===a||J==="downloading"?"settings.speech.downloading":"settings.speech.download")})]},a)},Fe=(a,k,J,re,ye)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx(Le,{className:"w-3.5 h-3.5 text-ink-faint shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium text-ink-strong",children:a.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:a.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:a.baseUrl}),a.hasApiKey&&e.jsxs("span",{className:"text-brand shrink-0 inline-flex items-center gap-0.5",children:[e.jsx(xe,{className:"w-3.5 h-3.5","aria-hidden":"true"}),t("settings.speech.key_saved")]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:()=>void ye(),disabled:J,className:"btn-3d-neutral px-3 py-1 text-label disabled:opacity-40","data-testid":`${k}-custom-test`,children:t(J?"settings.testing":"settings.test")}),s===a.id?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-caption text-warning",children:t("settings.speech.confirm_del_custom")}),e.jsx("button",{onClick:()=>void it(a.id,k),className:"text-label text-warning hover:underline","data-testid":`${k}-custom-del-confirm`,children:t("settings.speech.delete")}),e.jsx("button",{onClick:()=>u(null),className:"text-label text-ink-muted hover:text-ink-strong",children:t("action.cancel")})]}):e.jsx("button",{onClick:()=>u(a.id),className:"text-label text-ink-muted hover:text-warning","data-testid":`${k}-custom-del`,children:t("settings.speech.delete")}),re&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${re.ok?"text-brand":"text-warning"}`,children:[re.ok?e.jsx(xe,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4","aria-hidden":"true"}),re.detail]})]})]});return e.jsxs("div",{"data-testid":"settings-speech",children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.speech.tts_title")}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>{ge("edge"),ae(!1),D(!1)},"data-testid":"tts-engine-edge","aria-pressed":j==="edge",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${j==="edge"?te:ee}`,children:t("settings.speech.engine.edge")}),e.jsxs("button",{onClick:()=>{ge("local"),ae(!1),D(!1)},"data-testid":"tts-engine-local","aria-pressed":j==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${j==="local"?te:ee}`,children:[t("settings.speech.engine.local"),Ae("tts-kokoro")!=="ready"?` · ${t("settings.speech.state.absent")}`:""]}),e.jsx("button",{onClick:()=>{ge("system"),ae(!1),D(!1)},disabled:!E,"data-testid":"tts-engine-system","aria-pressed":j==="system",title:E?void 0:t("settings.speech.engine.system_unavailable"),className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${j==="system"?te:ee} ${E?"":"opacity-40 cursor-not-allowed"}`,children:t("settings.speech.engine.system")}),e.jsx("button",{onClick:()=>{ae(a=>!a),se||D(!1)},"data-testid":"tts-engine-custom","aria-pressed":j.startsWith("custom-")||se,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${j.startsWith("custom-")||se?te:ee}`,children:t("settings.speech.engine.custom")}),et&&e.jsxs("button",{disabled:!0,"data-testid":"tts-engine-azure",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Azure · ",t("settings.speech.legacy")]})]}),j==="edge"&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.engine.edge_note")})]}),j==="edge"&&e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsx("select",{value:$,onChange:a=>{h(a.target.value),r.setSetting("tts_voice_edge",a.target.value)},"data-testid":"tts-voice-select",className:`${ie} w-full min-w-0 px-2.5 py-1.5`,children:Lt.map(a=>e.jsx("option",{value:a.id,children:a.label},a.id))})]}),j==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsx("select",{value:f,onChange:a=>{z(a.target.value),r.setSetting("tts_sid_local",a.target.value)},"data-testid":"tts-sid-select",className:`${ie} w-full min-w-0 px-2.5 py-1.5`,children:Rt.map(a=>e.jsx("option",{value:a.sid,children:a.label},a.sid))})]}),e.jsx("div",{className:P(!1),children:Ie("tts-kokoro")})]}),j==="system"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsxs("select",{value:q,onChange:a=>Qe(a.target.value),"data-testid":"tts-system-voice-select",className:`${ie} w-full min-w-0 px-2.5 py-1.5`,children:[e.jsx("option",{value:"",children:t("settings.speech.voice_auto")}),B.map(a=>e.jsx("option",{value:a.name,children:pt(a)},a.voiceURI))]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.engine.system_note")})]})}),se&&e.jsx("div",{className:P(!1),children:e.jsxs("div",{className:"space-y-3",children:[de&&Fe(de,"tts",I,ne,at),de&&e.jsxs("div",{children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsx("input",{type:"text",value:R,onChange:a=>M(a.target.value),onBlur:()=>void r.setSetting("tts_custom_voice",R.trim()),placeholder:t("settings.speech.custom_voice_ph"),"data-testid":"tts-custom-voice",className:`${ie} w-full min-w-0 px-2.5 py-1.5 font-mono`})]}),!de&&ke.map(a=>e.jsxs("button",{onClick:()=>ge(a.id),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`tts-pick-${a.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:a.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:a.defaultModel})]},a.id)),(me||!de&&ke.length===0)&&e.jsx($e,{kind:"tts",showProtocol:!1,testPrefix:"tts-custom",titleKey:"settings.custom.form_title_tts",modelPhKey:"settings.custom.model_ph_tts",testOverride:a=>r.testCustomTts({baseUrl:a.baseUrl,apiKey:a.apiKey||void 0,model:a.model}),onSaved:a=>{ge(a.id),D(!1),L()},onCancel:()=>D(!1)}),(de||ke.length>0)&&e.jsx("button",{onClick:()=>D(a=>!a),className:"text-label text-accent hover:underline",children:t(me?"action.cancel":"settings.custom.new")})]})}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.speech.speed")}),e.jsx("input",{type:"range",min:"0.5",max:"2",step:"0.05",value:y,onChange:a=>A(a.target.value),onPointerUp:()=>{r.setSetting("tts_speed",y),Se()},onKeyUp:()=>{r.setSetting("tts_speed",y),Se()},"data-testid":"tts-speed-range",className:"flex-1 min-w-0 accent-[var(--brand)]"}),e.jsxs("span",{className:"text-label text-ink-muted tabular-nums w-10 text-right","data-testid":"tts-speed-value",children:[Number(y).toFixed(2),"x"]})]})}),e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.speech.asr_title")}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>{we("local"),le(!1),oe(!1)},"data-testid":"asr-engine-local","aria-pressed":_==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${_==="local"?te:ee}`,children:t("settings.speech.asr_engine.local")}),e.jsx("button",{onClick:()=>{le(a=>!a),H||oe(!1)},"data-testid":"asr-engine-custom","aria-pressed":_.startsWith("custom-")||H,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${_.startsWith("custom-")||H?te:ee}`,children:t("settings.speech.engine.custom")}),tt&&e.jsxs("button",{disabled:!0,"data-testid":"asr-engine-groq",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Groq · ",t("settings.speech.legacy")]}),st&&e.jsxs("button",{disabled:!0,"data-testid":"asr-engine-azure",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Azure · ",t("settings.speech.legacy")]})]}),_==="local"?e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_engine.local_note")}):_.startsWith("custom-")&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_engine.custom_note")})]}),_==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.model")}),e.jsx("select",{value:O,onChange:a=>{W(a.target.value),r.setSetting("asr_local_model",a.target.value)},"data-testid":"asr-model-select",className:`${ie} w-full min-w-0 px-2.5 py-1.5`,children:["asr-whisper-turbo","asr-whisper-small"].map(a=>e.jsxs("option",{value:a,children:[Je(a)," · ",Re(Ae(a))]},a))})]}),e.jsx("div",{className:P(!1),children:Ie(O)})]}),H&&e.jsx("div",{className:P(!1),children:e.jsxs("div",{className:"space-y-3",children:[ue&&Fe(ue,"asr",C,Z,nt),!ue&&Ne.map(a=>e.jsxs("button",{onClick:()=>we(a.id),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`asr-pick-${a.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:a.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:a.defaultModel})]},a.id)),(Y||!ue&&Ne.length===0)&&e.jsx($e,{kind:"asr",showProtocol:!1,testPrefix:"asr-custom",titleKey:"settings.custom.form_title_asr",modelPhKey:"settings.custom.model_ph_asr",testOverride:a=>r.testCustomAsr({baseUrl:a.baseUrl,apiKey:a.apiKey||void 0,model:a.model}),onSaved:a=>{we(a.id),oe(!1),L()},onCancel:()=>oe(!1)}),(ue||Ne.length>0)&&e.jsx("button",{onClick:()=>oe(a=>!a),className:"text-label text-accent hover:underline",children:t(Y?"action.cancel":"settings.custom.new")})]})}),e.jsxs("div",{className:P(!0),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{checked:G,onChange:()=>{const a=!G;d(a),r.setSetting("asr_auto_stop",a?"1":"0")},label:t("settings.speech.asr_auto_stop"),testid:"asr-auto-stop-toggle"}),e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.speech.asr_auto_stop")})]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_ux_note")})]}),l&&e.jsx("div",{className:"px-4 py-3 text-label text-warning break-all",role:"alert",children:l==="engine-unavailable"?t("chat.speech.engine_unavailable"):l})]})}function It(){const t=ce(),x=n.useRef(null),[o,b]=n.useState(null),[N,l]=n.useState(!1),[c,v]=n.useState(null);n.useEffect(()=>{r.dshImportDetect().then(b).catch(()=>b({found:!1,path:null,version:null}))},[]);const p=g=>{l(!0),v(null),g.then(v).catch(S=>v({ok:!1,error:String(S)})).finally(()=>l(!1))};return e.jsxs("div",{className:"p-4 space-y-3","data-testid":"settings-dsh-import",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:t("settings.dsh.title")}),e.jsx("p",{className:"text-label text-ink-muted leading-relaxed",children:t("settings.dsh.desc")}),o==null?null:o.found?e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"settings-dsh-detected",children:[e.jsx("span",{className:"text-label text-ink-strong",children:t("settings.dsh.detectFound",{v:o.version??"?"})}),e.jsx("button",{onClick:()=>p(r.dshImportFromPath(o.path??"")),disabled:N,"data-testid":"settings-dsh-import-btn",className:"px-3 py-1.5 rounded-xl text-label font-bold btn-3d-brand disabled:opacity-50",children:t(N?"settings.dsh.importing":"settings.dsh.import")})]}):e.jsx("div",{className:"text-label text-ink-muted","data-testid":"settings-dsh-none",children:t("settings.dsh.detectNone")}),e.jsxs("div",{children:[e.jsx("input",{ref:x,type:"file",accept:".json,application/json",className:"hidden","data-testid":"settings-dsh-file-input",onChange:g=>{var j;const S=(j=g.target.files)==null?void 0:j[0];S&&(S.text().then(T=>p(r.dshImportFromText(T))),g.target.value="")}}),e.jsx("button",{onClick:()=>{var g;return(g=x.current)==null?void 0:g.click()},disabled:N,className:"px-3 py-1.5 rounded-xl text-label font-bold btn-3d-neutral disabled:opacity-50",children:t("settings.dsh.pickFile")})]}),N&&!c?e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.dsh.importing")}):null,c!=null&&c.ok?e.jsxs("div",{className:"text-label text-brand leading-relaxed break-all",role:"status","data-testid":"settings-dsh-result",children:[t("settings.dsh.done",{courses:c.coursesCreated+c.coursesMapped+c.coursesRefreshed,nodes:c.nodes,progress:c.progressRows,srs:c.srsRows,xp:c.xpDelta}),c.skippedCourses.length>0?` · ${t("settings.dsh.skipped",{n:c.skippedCourses.length})}`:""]}):c?e.jsxs("div",{className:"text-label text-warning break-all",role:"alert","data-testid":"settings-dsh-error",children:[t("settings.dsh.failed"),": ",c.error??"unknown"]}):null]})}export{Bt as SettingsView};
@@ -1,4 +1,4 @@
1
- import{r as n,j as e}from"./index-C8cLLejx.js";import{c as f,u as h,e as b,f as g}from"./main-D7WqSbOt.js";import{R as j}from"./rotate-ccw-BS0Lg3XV.js";/**
1
+ import{r as n,j as e}from"./index-DFeHjpII.js";import{c as f,u as h,e as b,f as g}from"./main-Q55C34or.js";import{R as j}from"./rotate-ccw-BOEgpxYS.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-SVP7TREG-Cbw7rxkD.js";import{p as f}from"./chunk-JWPE2WC7-CM5DFf0Z.js";import{_ as n,l as o}from"./mermaid.core-C-NqYAhX.js";import"./transform-Bd_a5eGM.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-DeRfvx8D.js";import"./main-D7WqSbOt.js";import"./index-C8cLLejx.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},I={parser:R,db:a,renderer:u,styles:p};export{I as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-SVP7TREG-DbnWkZ8h.js";import{p as f}from"./chunk-JWPE2WC7-DSacNhA4.js";import{_ as n,l as o}from"./mermaid.core-DnOBsKcF.js";import"./transform-Bd_a5eGM.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-BpkRUbag.js";import"./main-Q55C34or.js";import"./index-DFeHjpII.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},I={parser:R,db:a,renderer:u,styles:p};export{I as diagram};
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-XCWWM2C3-EFZq_oj4.js";import{p as f}from"./chunk-VII2H2IX-udiwuRgE.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-GVF3BKWE-WBE1vO13.js";import{_ as n,l as o}from"./render-O7CIS3YK-C1LKCRfk.js";import"./transform-Bd_a5eGM.js";import"./mermaid-layout-elk.core-DTUF3xdW.js";import"./main-D7WqSbOt.js";import"./index-C8cLLejx.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),m=t?parseInt(t,10):0,l=s?parseInt(s,10):1/0;return{min:m,max:l}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},D={parser:R,db:a,renderer:u,styles:p};export{D as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-XCWWM2C3-3NMcdDFX.js";import{p as f}from"./chunk-VII2H2IX-Dbzz_on1.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-GVF3BKWE-BhhUo0ca.js";import{_ as n,l as o}from"./render-O7CIS3YK-uyJB6lwg.js";import"./transform-Bd_a5eGM.js";import"./mermaid-layout-elk.core-BtEZ1o-e.js";import"./main-Q55C34or.js";import"./index-DFeHjpII.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),m=t?parseInt(t,10):0,l=s?parseInt(s,10):1/0;return{min:m,max:l}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},D={parser:R,db:a,renderer:u,styles:p};export{D as diagram};