lookatstudy-mobile 0.33.2 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/install-termux.sh +169 -25
  2. package/package.json +1 -1
  3. package/server.cjs +2136 -5675
  4. package/web/assets/{CanvasStage-Gd9IcpRA.js → CanvasStage-C72HaOiw.js} +1 -1
  5. package/web/assets/{CommandPalette-DAynMTxU.js → CommandPalette-cB6g-mzh.js} +1 -1
  6. package/web/assets/{CompanionBotLab-ZoBUVdSh.js → CompanionBotLab-Ch7CGv7f.js} +1 -1
  7. package/web/assets/{CourseSearchPanel-D1VejiyW.js → CourseSearchPanel-C4Kh0qi3.js} +1 -1
  8. package/web/assets/{ExamView-B2Ps3sl8.js → ExamView-dpph-olw.js} +1 -1
  9. package/web/assets/{ReviewPanel-CQVX2nYz.js → ReviewPanel-DynCNoAR.js} +1 -1
  10. package/web/assets/SettingsView-CislD6Xj.js +20 -0
  11. package/web/assets/{VoicePanel-hA4wtfPr.js → VoicePanel-BgdvFoyX.js} +1 -1
  12. package/web/assets/{abnfDiagram-VCTEODGH-D6Hk3Y7l.js → abnfDiagram-VCTEODGH-CMtB3HOl.js} +1 -1
  13. package/web/assets/{abnfDiagram-VCTEODGH-ODA7YWAP-BvyMBGPN.js → abnfDiagram-VCTEODGH-ODA7YWAP-BvhKfjaY.js} +1 -1
  14. package/web/assets/api-web-Dwfo27My.js +1 -0
  15. package/web/assets/{architectureDiagram-5GKGNRK7-C4PU3XN7-Bew1e_oO.js → architectureDiagram-5GKGNRK7-C4PU3XN7-CSMXYZiY.js} +1 -1
  16. package/web/assets/{architectureDiagram-5GKGNRK7-C7Kp_VCT.js → architectureDiagram-5GKGNRK7-CHnFIH9b.js} +1 -1
  17. package/web/assets/{arrow-right-rT190nhw.js → arrow-right-TM3y6L-Y.js} +1 -1
  18. package/web/assets/{blockDiagram-I7D4REHJ-Z33I9bv_.js → blockDiagram-I7D4REHJ-VdzqHZvv.js} +1 -1
  19. package/web/assets/{blockDiagram-NRAW4CY4-UMJ6PMQQ-BH4SHysg.js → blockDiagram-NRAW4CY4-UMJ6PMQQ-D7kvNED-.js} +1 -1
  20. package/web/assets/{c4Diagram-7LVT6UL2-UvW7IuNF.js → c4Diagram-7LVT6UL2-CgznJmUi.js} +1 -1
  21. package/web/assets/{c4Diagram-UCG6FXSJ-75X3U2P3-IAl07Y5s.js → c4Diagram-UCG6FXSJ-75X3U2P3-B9xFuSPH.js} +1 -1
  22. package/web/assets/channel-Df7Ybeyp.js +1 -0
  23. package/web/assets/{chunk-2Q5K7J3B-CarLXuZT.js → chunk-2Q5K7J3B-CAns8y8j.js} +1 -1
  24. package/web/assets/{chunk-5VM5RSS4-DwCCLy6d.js → chunk-5VM5RSS4-C2nhzqYi.js} +1 -1
  25. package/web/assets/{chunk-7XDTSPCN-A-CYYjR9.js → chunk-7XDTSPCN-Du4JZkXG.js} +1 -1
  26. package/web/assets/{chunk-CTNIYPP6-CF37J8Wl.js → chunk-CTNIYPP6-B7lfk-YJ.js} +1 -1
  27. package/web/assets/{chunk-CXNFBKHE-Dol1xkx9.js → chunk-CXNFBKHE-BC4UXdAm.js} +1 -1
  28. package/web/assets/{chunk-F27PBJKO-CCKF34J6.js → chunk-F27PBJKO-LQpoAT6J.js} +1 -1
  29. package/web/assets/{chunk-IMKFNOWR-ChnROkLb.js → chunk-IMKFNOWR-Ctz3Z-uw.js} +1 -1
  30. package/web/assets/{chunk-ISA7TJRJ-xSTEZzVx.js → chunk-ISA7TJRJ-CxiQRkRL.js} +1 -1
  31. package/web/assets/{chunk-JWPE2WC7-omYL3Obe.js → chunk-JWPE2WC7-yepkRAwM.js} +1 -1
  32. package/web/assets/{chunk-LV3HUYFY-Bk9nvQV-.js → chunk-LV3HUYFY-CIjD4C-e.js} +1 -1
  33. package/web/assets/{chunk-M3IUQBOH-CAVmNM6v.js → chunk-M3IUQBOH-B_b1jC1d.js} +1 -1
  34. package/web/assets/{chunk-NDIOYS4C-DGwQ1S-J.js → chunk-NDIOYS4C-Dnzhfg9r.js} +1 -1
  35. package/web/assets/{chunk-POPQ4Y6H-C0Zgm0cx.js → chunk-POPQ4Y6H-fHcz0X8j.js} +1 -1
  36. package/web/assets/{chunk-RE4WF27V-Br7-3LIe.js → chunk-RE4WF27V-CxX4BnEj.js} +1 -1
  37. package/web/assets/{chunk-SVP7TREG-IZUpDCWY.js → chunk-SVP7TREG-BnltLrM-.js} +1 -1
  38. package/web/assets/{chunk-TICWLB2K-FxWFH9Jf.js → chunk-TICWLB2K-D12wpFc6.js} +1 -1
  39. package/web/assets/{chunk-VII2H2IX-CSYYAPr-.js → chunk-VII2H2IX-Twcv7Nfl.js} +1 -1
  40. package/web/assets/{chunk-X5GNSKZ3-Dchniejs.js → chunk-X5GNSKZ3-BL1R0B0m.js} +1 -1
  41. package/web/assets/{chunk-XCWWM2C3-CkB_7V6A.js → chunk-XCWWM2C3-Tg4IR0n8.js} +1 -1
  42. package/web/assets/{chunk-XXDRQBXY-mXFfWdd4.js → chunk-XXDRQBXY-DJoPR1YB.js} +1 -1
  43. package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-B6JY0Amc.js +1 -0
  44. package/web/assets/classDiagram-ZZMXUADV-CW-v2a7Q.js +1 -0
  45. package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-B6JY0Amc.js +1 -0
  46. package/web/assets/classDiagram-v2-VYDZK3BY-CW-v2a7Q.js +1 -0
  47. package/web/assets/{core-C__jCKLW.js → core-CInUNwIn.js} +1 -1
  48. package/web/assets/{cose-bilkent-JH36ORCC-pqa9xs1w.js → cose-bilkent-JH36ORCC-Bs86DA0h.js} +1 -1
  49. package/web/assets/{cose-bilkent-JH36ORCC-OB24KH3T-CZMlLgoQ.js → cose-bilkent-JH36ORCC-OB24KH3T-Dq3mWE76.js} +1 -1
  50. package/web/assets/{cynefin-OW5HDTMX-Bzlfkn3M.js → cynefin-OW5HDTMX-D6ZQlGMQ.js} +1 -1
  51. package/web/assets/{cynefin-OW5HDTMX-GVF3BKWE-Bd4Ot2ae.js → cynefin-OW5HDTMX-GVF3BKWE-Dnl8JJFM.js} +1 -1
  52. package/web/assets/{cynefinDiagram-5FMLGOSQ-C0bSmN09.js → cynefinDiagram-5FMLGOSQ-CCC-03k6.js} +1 -1
  53. package/web/assets/{cynefinDiagram-5FMLGOSQ-H3WIRU3N-Q5MnkiSc.js → cynefinDiagram-5FMLGOSQ-H3WIRU3N-Dt1RAnjs.js} +1 -1
  54. package/web/assets/{dagre-3AP2YEHR-DCERTXHT-CJZg19fe.js → dagre-3AP2YEHR-DCERTXHT-B0t8ElJV.js} +1 -1
  55. package/web/assets/{dagre-GXQ25YYZ-JmpF3dnx.js → dagre-GXQ25YYZ-CgU7yrVy.js} +1 -1
  56. package/web/assets/{diagram-S7CK7UJ4-Du2A_-O-.js → diagram-S7CK7UJ4-DTR2y6UT.js} +1 -1
  57. package/web/assets/{diagram-S7CK7UJ4-MULGZGEL-3I2Tacmz.js → diagram-S7CK7UJ4-MULGZGEL-DwX9tj_E.js} +1 -1
  58. package/web/assets/{diagram-UQ7AKVKN-C7idBPLC.js → diagram-UQ7AKVKN-D2CVN862.js} +1 -1
  59. package/web/assets/{diagram-UQ7AKVKN-YQBY353J-Bd-LRcw1.js → diagram-UQ7AKVKN-YQBY353J-LgNf4bhC.js} +1 -1
  60. package/web/assets/{diagram-VSXAHHWV-BKZF79gO.js → diagram-VSXAHHWV-CYQLixjs.js} +1 -1
  61. package/web/assets/{diagram-VSXAHHWV-WLNH2ELY-DSymPCZL.js → diagram-VSXAHHWV-WLNH2ELY-C2Plr2sR.js} +1 -1
  62. package/web/assets/{diagram-VX7I27RA-Dhw4qEcD.js → diagram-VX7I27RA-BJQtFm-G.js} +1 -1
  63. package/web/assets/{diagram-VX7I27RA-XW6YQV5G-BWEKbFNG.js → diagram-VX7I27RA-XW6YQV5G-BkfQh4Mv.js} +1 -1
  64. package/web/assets/{diagram-Z3DM3KII-HG7RF65D-WDQq7tAf.js → diagram-Z3DM3KII-HG7RF65D-BsWePKJ6.js} +1 -1
  65. package/web/assets/{diagram-Z3DM3KII-CkQJvuAa.js → diagram-Z3DM3KII-arIh_Ydh.js} +1 -1
  66. package/web/assets/{ebnfDiagram-PWID7BFC-OKY4VHYD-Bpih3QFv.js → ebnfDiagram-PWID7BFC-OKY4VHYD-CSDN-ES2.js} +1 -1
  67. package/web/assets/{ebnfDiagram-PWID7BFC-BdXZV32p.js → ebnfDiagram-PWID7BFC-efb9oxoq.js} +1 -1
  68. package/web/assets/{elk.bundled-SZmCpI5p.js → elk.bundled-B1HkkibK.js} +1 -1
  69. package/web/assets/{erDiagram-RLTQ6QDP-jpRq-UGG.js → erDiagram-RLTQ6QDP-BM3e1Eha.js} +1 -1
  70. package/web/assets/{erDiagram-SSCWMZ5O-PIPKOIK7-D0mRljF8.js → erDiagram-SSCWMZ5O-PIPKOIK7-BkRkgiEn.js} +1 -1
  71. package/web/assets/{flowDiagram-A5DVABFB-2Z4AVO5R-BJE_0PFG.js → flowDiagram-A5DVABFB-2Z4AVO5R-CNrxNr1X.js} +1 -1
  72. package/web/assets/{flowDiagram-HODETNUW-CuyRnAfK.js → flowDiagram-HODETNUW-tIdWY3-u.js} +1 -1
  73. package/web/assets/{ganttDiagram-EL5Y4UJY-TunEgpI8.js → ganttDiagram-EL5Y4UJY-CcbO-KDD.js} +1 -1
  74. package/web/assets/{ganttDiagram-EL5Y4UJY-JZNG7GOG-yFTfjUwE.js → ganttDiagram-EL5Y4UJY-JZNG7GOG-BZZl4cGf.js} +1 -1
  75. package/web/assets/{gitGraphDiagram-WWUBYQGX-DMWMLL3G-uGNiKmaN.js → gitGraphDiagram-WWUBYQGX-DMWMLL3G-BXh7EB8a.js} +1 -1
  76. package/web/assets/{gitGraphDiagram-WWUBYQGX-BgzYKWnb.js → gitGraphDiagram-WWUBYQGX-mUHSo0oW.js} +1 -1
  77. package/web/assets/{index-BNvqgHhT.js → index-B9KSAI26.js} +1 -1
  78. package/web/assets/{index-CFVpnh5A.js → index-BzdORPhC.js} +1 -1
  79. package/web/assets/{index-T8vA0XV2.js → index-CtcKtEMF.js} +4 -4
  80. package/web/assets/index-DpPK19Iz.css +1 -0
  81. package/web/assets/index-DpUqsNSC.js +53 -0
  82. package/web/assets/{infoDiagram-27XIBGKW-B8l9g0jD.js → infoDiagram-27XIBGKW-6zuJOkud.js} +1 -1
  83. package/web/assets/{infoDiagram-RXCK75RN-HANS5KVC-BBl7fKsQ.js → infoDiagram-RXCK75RN-HANS5KVC-DgNsPCDB.js} +1 -1
  84. package/web/assets/{ishikawaDiagram-5VMMS53U-7GCIT7WU-Bt-TE7vw.js → ishikawaDiagram-5VMMS53U-7GCIT7WU-C1aCi21z.js} +1 -1
  85. package/web/assets/{ishikawaDiagram-5VMMS53U-CzwJL0NU.js → ishikawaDiagram-5VMMS53U-CfBlX7z8.js} +1 -1
  86. package/web/assets/{journeyDiagram-3NMN7TZE-B8wTvg0T.js → journeyDiagram-3NMN7TZE-CsVwn0uz.js} +1 -1
  87. package/web/assets/{journeyDiagram-EYS64GPL-OAPELBT7-A4dOTrJK.js → journeyDiagram-EYS64GPL-OAPELBT7-GmOyjRKs.js} +1 -1
  88. package/web/assets/{kanban-definition-3QL26DDD-I7RKWQQY-fVSx48Ir.js → kanban-definition-3QL26DDD-I7RKWQQY-DYO1LivP.js} +1 -1
  89. package/web/assets/{kanban-definition-UXKFOSKX-Ba0UYhk_.js → kanban-definition-UXKFOSKX-BGaJOKpZ.js} +1 -1
  90. package/web/assets/{katex-N6JRN4PM-CHwboYl9.js → katex-N6JRN4PM-CCO3fQlh.js} +1 -1
  91. package/web/assets/{layout-Dw29D4oc.js → layout-DxwbGgTi.js} +1 -1
  92. package/web/assets/{main-DrJVBtna.js → main-CSS_lFDP.js} +113 -113
  93. package/web/assets/{mermaid-layout-elk.core-CicnJpM7.js → mermaid-layout-elk.core-D9OOh4D_.js} +2 -2
  94. package/web/assets/{mermaid.core-CkjogKiM.js → mermaid.core-BEhN9Nie.js} +5 -5
  95. package/web/assets/{mindmap-definition-FBJOCRG2-KIYZG64Y-xsFUfLdH.js → mindmap-definition-FBJOCRG2-KIYZG64Y-ZPfoLqVV.js} +1 -1
  96. package/web/assets/{mindmap-definition-YA3MSWOX-CILBhFg_.js → mindmap-definition-YA3MSWOX-D-0q8D0x.js} +1 -1
  97. package/web/assets/{pegDiagram-XKGWAZYB-C-d4b8Dk.js → pegDiagram-XKGWAZYB-BV_8eJIL.js} +1 -1
  98. package/web/assets/{pegDiagram-XKGWAZYB-OIP57N6J-Bnh4Krz5.js → pegDiagram-XKGWAZYB-OIP57N6J-DqRF2GbT.js} +1 -1
  99. package/web/assets/{pet-C2gtNZEs.js → pet-DCzJVVt6.js} +1 -1
  100. package/web/assets/{pieDiagram-E7YTZNPT-2UOTW327-CQuNMHQ1.js → pieDiagram-E7YTZNPT-2UOTW327-Cr4fAU8o.js} +1 -1
  101. package/web/assets/{pieDiagram-E7YTZNPT-__8_Z3l_.js → pieDiagram-E7YTZNPT-nB-_CLeT.js} +1 -1
  102. package/web/assets/{quadrantDiagram-AXDQQJYC-JT_Oydow.js → quadrantDiagram-AXDQQJYC-BNAlPSkj.js} +1 -1
  103. package/web/assets/{quadrantDiagram-AXDQQJYC-SN3ASJJK-BHmr4hy8.js → quadrantDiagram-AXDQQJYC-SN3ASJJK-Cf5G05Po.js} +1 -1
  104. package/web/assets/{railroadDiagram-O6MQD6OU-34742W6X-BuzOX6qM.js → railroadDiagram-O6MQD6OU-34742W6X-CFH7Z2dw.js} +1 -1
  105. package/web/assets/{railroadDiagram-O6MQD6OU-BL4fzNdr.js → railroadDiagram-O6MQD6OU-FF9J40BN.js} +1 -1
  106. package/web/assets/{render-O7CIS3YK-lZh9RHoM.js → render-O7CIS3YK-CFk-qve4.js} +7 -7
  107. package/web/assets/{requirementDiagram-BXWQKSXE-BX4Og0gc.js → requirementDiagram-BXWQKSXE-BMV8VnvW.js} +1 -1
  108. package/web/assets/{requirementDiagram-EFPCY7ZU-NGAFFSMB-Be_4b6Ca.js → requirementDiagram-EFPCY7ZU-NGAFFSMB-Dgr3205x.js} +1 -1
  109. package/web/assets/{rotate-ccw-jAam_EWy.js → rotate-ccw-DZxkibR5.js} +1 -1
  110. package/web/assets/{sankeyDiagram-P5KCCOFB-3D3M4XPB-DQyfvfY9.js → sankeyDiagram-P5KCCOFB-3D3M4XPB-CN03neoX.js} +1 -1
  111. package/web/assets/{sankeyDiagram-P5KCCOFB-CsMuk8xO.js → sankeyDiagram-P5KCCOFB-yPJIv_Ow.js} +1 -1
  112. package/web/assets/{sequenceDiagram-WJ2MYXX4-CqLVTAiQ.js → sequenceDiagram-WJ2MYXX4-BaWlvXkm.js} +1 -1
  113. package/web/assets/{sequenceDiagram-WJ2MYXX4-Q2IOPB4R-CKxbF_KH.js → sequenceDiagram-WJ2MYXX4-Q2IOPB4R-GEXmhp2H.js} +1 -1
  114. package/web/assets/{sizeCapture-INFHLROL-B_yzF7FU.js → sizeCapture-INFHLROL-DvbiIbXq.js} +1 -1
  115. package/web/assets/{sizeCapture-X5ZJPWSS-PSGVOMYM-DdyuBiOR.js → sizeCapture-X5ZJPWSS-PSGVOMYM-CLmCvgE-.js} +1 -1
  116. package/web/assets/{stateDiagram-D77RDMKH-BW1HJ7hN.js → stateDiagram-D77RDMKH-v3JAq8H4.js} +1 -1
  117. package/web/assets/{stateDiagram-HBIQ2CUA-4M2S6MAN-DYW1Q86F.js → stateDiagram-HBIQ2CUA-4M2S6MAN-Bk6n0C4h.js} +1 -1
  118. package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-CSGIWpWK.js +1 -0
  119. package/web/assets/stateDiagram-v2-MP3YSRHH-Bw5j-FVB.js +1 -0
  120. package/web/assets/{swimlanes-42K2YHIH-CSEPYP51.js → swimlanes-42K2YHIH-DHz1p7KG.js} +1 -1
  121. package/web/assets/{swimlanes-XN3QIQJK-N6N2CCQ6-DK5asoC3.js → swimlanes-XN3QIQJK-N6N2CCQ6-HxeNMmfZ.js} +1 -1
  122. package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-BcGn1eC6.js +8 -0
  123. package/web/assets/swimlanesDiagram-VR7AAH4N-BORev-1v.js +8 -0
  124. package/web/assets/{timeline-definition-24CTP7MA-CNV-7RF0.js → timeline-definition-24CTP7MA-Dn1hyaRN.js} +1 -1
  125. package/web/assets/{timeline-definition-24CTP7MA-KN7RSRVM-WJCyYFqv.js → timeline-definition-24CTP7MA-KN7RSRVM-DVlLI_ni.js} +1 -1
  126. package/web/assets/{vennDiagram-4TSXK5OY-AKJ7LXAN-D7P4RYfo.js → vennDiagram-4TSXK5OY-AKJ7LXAN-W1H4YhrJ.js} +1 -1
  127. package/web/assets/{vennDiagram-4TSXK5OY-DnO_E0gl.js → vennDiagram-4TSXK5OY-Dxezw6vn.js} +1 -1
  128. package/web/assets/{wardleyDiagram-VM6X3IG4-3B6A3BN5-BDz-qu7A.js → wardleyDiagram-VM6X3IG4-3B6A3BN5-y4QqLWww.js} +1 -1
  129. package/web/assets/{wardleyDiagram-VM6X3IG4-DriPUoP9.js → wardleyDiagram-VM6X3IG4-BJzvdena.js} +1 -1
  130. package/web/assets/{xychartDiagram-S5SC5T6Z-dsrWxH2R.js → xychartDiagram-S5SC5T6Z-DePRnwoY.js} +1 -1
  131. package/web/assets/{xychartDiagram-S5SC5T6Z-OBDNV6WG-D6KLvT_R.js → xychartDiagram-S5SC5T6Z-OBDNV6WG-CCeTp4-Y.js} +1 -1
  132. package/web/fouc.js +18 -0
  133. package/web/index.html +7 -23
  134. package/web/pet.html +4 -4
  135. package/web/assets/SettingsView-D2LV8vux.js +0 -10
  136. package/web/assets/api-web-BCzlfr07.js +0 -1
  137. package/web/assets/channel-Br11ibHK.js +0 -1
  138. package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-vwLxJ0gZ.js +0 -1
  139. package/web/assets/classDiagram-ZZMXUADV-B-kQs3FT.js +0 -1
  140. package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-vwLxJ0gZ.js +0 -1
  141. package/web/assets/classDiagram-v2-VYDZK3BY-B-kQs3FT.js +0 -1
  142. package/web/assets/index-3R9G44mo.js +0 -53
  143. package/web/assets/index-DPow_Z3A.css +0 -1
  144. package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-BlV86LYk.js +0 -1
  145. package/web/assets/stateDiagram-v2-MP3YSRHH-DlFDcdin.js +0 -1
  146. package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-CxQIfxrF.js +0 -8
  147. package/web/assets/swimlanesDiagram-VR7AAH4N-CTm10_mn.js +0 -8
@@ -1,4 +1,4 @@
1
- import{s as mi,g as yi,o as li,n as bi,a as Ai,b as Ci,_ as n,l as ci,G as wi,d as Si,p as Ri,A as Mt,h as _i,C as gi,D as ki,I as Ti,J as Di}from"./render-O7CIS3YK-lZh9RHoM.js";import{_ as r}from"./mermaid-layout-elk.core-CicnJpM7.js";import{l as ai}from"./transform-Bd_a5eGM.js";import{b as ni}from"./band-dPffDWoQ.js";import{l as oi}from"./linear-CZIIlCMp.js";import"./main-DrJVBtna.js";import"./index-3R9G44mo.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./init-Gi6I4Gst.js";import"./ordinal-Cboi1Yqb.js";import"./defaultLocale-5voVPcsN.js";var It=(function(){var e=n(function(F,l,u,x){for(u=u||{},x=F.length;x--;u[F[x]]=l);return u},"o"),t=[1,10,12,14,16,18,19,21,23],i=[2,6],s=[1,3],a=[1,5],h=[1,6],c=[1,7],b=[1,5,10,12,14,16,18,19,21,23,36,37,38],p=[1,25],m=[1,26],k=[1,28],T=[1,29],L=[1,30],W=[1,31],X=[1,32],E=[1,33],B=[1,34],A=[1,35],D=[1,36],g=[1,37],M=[1,43],V=[1,42],Y=[1,47],N=[1,50],R=[1,10,12,14,16,18,19,21,23,36,37,38],U=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38],C=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38,42,43,44,45,46,47,48,49,50,51],w=[1,65],z=[26,28],_={trace:n(r(function(){},"trace"),"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,dataPoints:25,SQUARE_BRACES_END:26,dataPoint:27,COMMA:28,NUMBER_WITH_DECIMAL:29,STR:30,xAxisData:31,bandData:32,ARROW_DELIMITER:33,commaSeparatedTexts:34,yAxisData:35,NEWLINE:36,SEMI:37,EOF:38,alphaNum:39,MD_STR:40,alphaNumToken:41,AMP:42,NUM:43,ALPHA:44,PLUS:45,EQUALS:46,MULT:47,DOT:48,BRKT:49,MINUS:50,UNDERSCORE:51,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",28:"COMMA",29:"NUMBER_WITH_DECIMAL",30:"STR",33:"ARROW_DELIMITER",36:"NEWLINE",37:"SEMI",38:"EOF",40:"MD_STR",42:"AMP",43:"NUM",44:"ALPHA",45:"PLUS",46:"EQUALS",47:"MULT",48:"DOT",49:"BRKT",50:"MINUS",51:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[27,2],[27,1],[13,1],[13,2],[13,1],[31,1],[31,3],[32,3],[34,3],[34,1],[15,1],[15,2],[15,1],[35,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[39,1],[39,2],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1]],performAction:n(r(function(l,u,x,d,S,o,ct){var f=o.length-1;switch(S){case 5:d.setOrientation(o[f]);break;case 9:d.setDiagramTitle(o[f].text.trim());break;case 12:d.setLineData({text:"",type:"text"},o[f]);break;case 13:d.setLineData(o[f-1],o[f]);break;case 14:d.setBarData({text:"",type:"text"},o[f]);break;case 15:d.setBarData(o[f-1],o[f]);break;case 16:this.$=o[f].trim(),d.setAccTitle(this.$);break;case 17:case 18:this.$=o[f].trim(),d.setAccDescription(this.$);break;case 19:this.$=o[f-1];break;case 20:case 30:this.$=[o[f-2],...o[f]];break;case 21:case 31:this.$=[o[f]];break;case 22:this.$={value:Number(o[f-1]),label:o[f]};break;case 23:this.$={value:Number(o[f]),label:""};break;case 24:d.setXAxisTitle(o[f]);break;case 25:d.setXAxisTitle(o[f-1]);break;case 26:d.setXAxisTitle({type:"text",text:""});break;case 27:d.setXAxisBand(o[f]);break;case 28:d.setXAxisRangeData(Number(o[f-2]),Number(o[f]));break;case 29:this.$=o[f-1];break;case 32:d.setYAxisTitle(o[f]);break;case 33:d.setYAxisTitle(o[f-1]);break;case 34:d.setYAxisTitle({type:"text",text:""});break;case 35:d.setYAxisRangeData(Number(o[f-2]),Number(o[f]));break;case 39:this.$={text:o[f],type:"text"};break;case 40:this.$={text:o[f],type:"text"};break;case 41:this.$={text:o[f],type:"markdown"};break;case 42:this.$=o[f];break;case 43:this.$=o[f-1]+""+o[f];break}},"anonymous"),"anonymous"),table:[e(t,i,{3:1,4:2,7:4,5:s,36:a,37:h,38:c}),{1:[3]},e(t,i,{4:2,7:4,3:8,5:s,36:a,37:h,38:c}),e(t,i,{4:2,7:4,6:9,3:10,5:s,8:[1,11],36:a,37:h,38:c}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(b,[2,36]),e(b,[2,37]),e(b,[2,38]),{1:[2,1]},e(t,i,{4:2,7:4,3:21,5:s,36:a,37:h,38:c}),{1:[2,3]},e(b,[2,5]),e(t,[2,7],{4:22,36:a,37:h,38:c}),{11:23,30:p,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},{11:39,13:38,24:M,29:V,30:p,31:40,32:41,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},{11:45,15:44,29:Y,30:p,35:46,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},{11:49,17:48,24:N,30:p,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},{11:52,17:51,24:N,30:p,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},{20:[1,53]},{22:[1,54]},e(R,[2,18]),{1:[2,2]},e(R,[2,8]),e(R,[2,9]),e(U,[2,39],{41:55,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g}),e(U,[2,40]),e(U,[2,41]),e(C,[2,42]),e(C,[2,44]),e(C,[2,45]),e(C,[2,46]),e(C,[2,47]),e(C,[2,48]),e(C,[2,49]),e(C,[2,50]),e(C,[2,51]),e(C,[2,52]),e(C,[2,53]),e(R,[2,10]),e(R,[2,24],{32:41,31:56,24:M,29:V}),e(R,[2,26]),e(R,[2,27]),{33:[1,57]},{11:59,30:p,34:58,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},e(R,[2,11]),e(R,[2,32],{35:60,29:Y}),e(R,[2,34]),{33:[1,61]},e(R,[2,12]),{17:62,24:N},{25:63,27:64,29:w},e(R,[2,14]),{17:66,24:N},e(R,[2,16]),e(R,[2,17]),e(C,[2,43]),e(R,[2,25]),{29:[1,67]},{26:[1,68]},{26:[2,31],28:[1,69]},e(R,[2,33]),{29:[1,70]},e(R,[2,13]),{26:[1,71]},{26:[2,21],28:[1,72]},e(z,[2,23],{30:[1,73]}),e(R,[2,15]),e(R,[2,28]),e(R,[2,29]),{11:59,30:p,34:74,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},e(R,[2,35]),e(R,[2,19]),{25:75,27:64,29:w},e(z,[2,22]),{26:[2,30]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],74:[2,30],75:[2,20]},parseError:n(r(function(l,u){if(u.recoverable)this.trace(l);else{var x=new Error(l);throw x.hash=u,x}},"parseError"),"parseError"),parse:n(r(function(l){var u=this,x=[0],d=[],S=[null],o=[],ct=this.table,f="",ft=0,ti=0,di=2,ii=1,pi=o.slice.call(arguments,1),P=Object.create(this.lexer),q={yy:{}};for(var Dt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,Dt)&&(q.yy[Dt]=this.yy[Dt]);P.setInput(l,q.yy),q.yy.lexer=P,q.yy.parser=this,typeof P.yylloc>"u"&&(P.yylloc={});var Pt=P.yylloc;o.push(Pt);var fi=P.options&&P.options.ranges;typeof q.yy.parseError=="function"?this.parseError=q.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ei(I){x.length=x.length-2*I,S.length=S.length-I,o.length=o.length-I}r(ei,"popStack"),n(ei,"popStack");function Lt(){var I;return I=d.pop()||P.lex()||ii,typeof I!="number"&&(I instanceof Array&&(d=I,I=d.pop()),I=u.symbols_[I]||I),I}r(Lt,"lex"),n(Lt,"lex");for(var v,j,O,vt,rt={},mt,H,si,yt;;){if(j=x[x.length-1],this.defaultActions[j]?O=this.defaultActions[j]:((v===null||typeof v>"u")&&(v=Lt()),O=ct[j]&&ct[j][v]),typeof O>"u"||!O.length||!O[0]){var Et="";yt=[];for(mt in ct[j])this.terminals_[mt]&&mt>di&&yt.push("'"+this.terminals_[mt]+"'");P.showPosition?Et="Parse error on line "+(ft+1)+`:
1
+ import{s as mi,g as yi,o as li,n as bi,a as Ai,b as Ci,_ as n,l as ci,G as wi,d as Si,p as Ri,A as Mt,h as _i,C as gi,D as ki,I as Ti,J as Di}from"./render-O7CIS3YK-CFk-qve4.js";import{_ as r}from"./mermaid-layout-elk.core-D9OOh4D_.js";import{l as ai}from"./transform-Bd_a5eGM.js";import{b as ni}from"./band-dPffDWoQ.js";import{l as oi}from"./linear-CZIIlCMp.js";import"./main-CSS_lFDP.js";import"./index-DpUqsNSC.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./init-Gi6I4Gst.js";import"./ordinal-Cboi1Yqb.js";import"./defaultLocale-5voVPcsN.js";var It=(function(){var e=n(function(F,l,u,x){for(u=u||{},x=F.length;x--;u[F[x]]=l);return u},"o"),t=[1,10,12,14,16,18,19,21,23],i=[2,6],s=[1,3],a=[1,5],h=[1,6],c=[1,7],b=[1,5,10,12,14,16,18,19,21,23,36,37,38],p=[1,25],m=[1,26],k=[1,28],T=[1,29],L=[1,30],W=[1,31],X=[1,32],E=[1,33],B=[1,34],A=[1,35],D=[1,36],g=[1,37],M=[1,43],V=[1,42],Y=[1,47],N=[1,50],R=[1,10,12,14,16,18,19,21,23,36,37,38],U=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38],C=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38,42,43,44,45,46,47,48,49,50,51],w=[1,65],z=[26,28],_={trace:n(r(function(){},"trace"),"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,dataPoints:25,SQUARE_BRACES_END:26,dataPoint:27,COMMA:28,NUMBER_WITH_DECIMAL:29,STR:30,xAxisData:31,bandData:32,ARROW_DELIMITER:33,commaSeparatedTexts:34,yAxisData:35,NEWLINE:36,SEMI:37,EOF:38,alphaNum:39,MD_STR:40,alphaNumToken:41,AMP:42,NUM:43,ALPHA:44,PLUS:45,EQUALS:46,MULT:47,DOT:48,BRKT:49,MINUS:50,UNDERSCORE:51,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",28:"COMMA",29:"NUMBER_WITH_DECIMAL",30:"STR",33:"ARROW_DELIMITER",36:"NEWLINE",37:"SEMI",38:"EOF",40:"MD_STR",42:"AMP",43:"NUM",44:"ALPHA",45:"PLUS",46:"EQUALS",47:"MULT",48:"DOT",49:"BRKT",50:"MINUS",51:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[27,2],[27,1],[13,1],[13,2],[13,1],[31,1],[31,3],[32,3],[34,3],[34,1],[15,1],[15,2],[15,1],[35,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[39,1],[39,2],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1]],performAction:n(r(function(l,u,x,d,S,o,ct){var f=o.length-1;switch(S){case 5:d.setOrientation(o[f]);break;case 9:d.setDiagramTitle(o[f].text.trim());break;case 12:d.setLineData({text:"",type:"text"},o[f]);break;case 13:d.setLineData(o[f-1],o[f]);break;case 14:d.setBarData({text:"",type:"text"},o[f]);break;case 15:d.setBarData(o[f-1],o[f]);break;case 16:this.$=o[f].trim(),d.setAccTitle(this.$);break;case 17:case 18:this.$=o[f].trim(),d.setAccDescription(this.$);break;case 19:this.$=o[f-1];break;case 20:case 30:this.$=[o[f-2],...o[f]];break;case 21:case 31:this.$=[o[f]];break;case 22:this.$={value:Number(o[f-1]),label:o[f]};break;case 23:this.$={value:Number(o[f]),label:""};break;case 24:d.setXAxisTitle(o[f]);break;case 25:d.setXAxisTitle(o[f-1]);break;case 26:d.setXAxisTitle({type:"text",text:""});break;case 27:d.setXAxisBand(o[f]);break;case 28:d.setXAxisRangeData(Number(o[f-2]),Number(o[f]));break;case 29:this.$=o[f-1];break;case 32:d.setYAxisTitle(o[f]);break;case 33:d.setYAxisTitle(o[f-1]);break;case 34:d.setYAxisTitle({type:"text",text:""});break;case 35:d.setYAxisRangeData(Number(o[f-2]),Number(o[f]));break;case 39:this.$={text:o[f],type:"text"};break;case 40:this.$={text:o[f],type:"text"};break;case 41:this.$={text:o[f],type:"markdown"};break;case 42:this.$=o[f];break;case 43:this.$=o[f-1]+""+o[f];break}},"anonymous"),"anonymous"),table:[e(t,i,{3:1,4:2,7:4,5:s,36:a,37:h,38:c}),{1:[3]},e(t,i,{4:2,7:4,3:8,5:s,36:a,37:h,38:c}),e(t,i,{4:2,7:4,6:9,3:10,5:s,8:[1,11],36:a,37:h,38:c}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(b,[2,36]),e(b,[2,37]),e(b,[2,38]),{1:[2,1]},e(t,i,{4:2,7:4,3:21,5:s,36:a,37:h,38:c}),{1:[2,3]},e(b,[2,5]),e(t,[2,7],{4:22,36:a,37:h,38:c}),{11:23,30:p,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},{11:39,13:38,24:M,29:V,30:p,31:40,32:41,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},{11:45,15:44,29:Y,30:p,35:46,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},{11:49,17:48,24:N,30:p,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},{11:52,17:51,24:N,30:p,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},{20:[1,53]},{22:[1,54]},e(R,[2,18]),{1:[2,2]},e(R,[2,8]),e(R,[2,9]),e(U,[2,39],{41:55,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g}),e(U,[2,40]),e(U,[2,41]),e(C,[2,42]),e(C,[2,44]),e(C,[2,45]),e(C,[2,46]),e(C,[2,47]),e(C,[2,48]),e(C,[2,49]),e(C,[2,50]),e(C,[2,51]),e(C,[2,52]),e(C,[2,53]),e(R,[2,10]),e(R,[2,24],{32:41,31:56,24:M,29:V}),e(R,[2,26]),e(R,[2,27]),{33:[1,57]},{11:59,30:p,34:58,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},e(R,[2,11]),e(R,[2,32],{35:60,29:Y}),e(R,[2,34]),{33:[1,61]},e(R,[2,12]),{17:62,24:N},{25:63,27:64,29:w},e(R,[2,14]),{17:66,24:N},e(R,[2,16]),e(R,[2,17]),e(C,[2,43]),e(R,[2,25]),{29:[1,67]},{26:[1,68]},{26:[2,31],28:[1,69]},e(R,[2,33]),{29:[1,70]},e(R,[2,13]),{26:[1,71]},{26:[2,21],28:[1,72]},e(z,[2,23],{30:[1,73]}),e(R,[2,15]),e(R,[2,28]),e(R,[2,29]),{11:59,30:p,34:74,39:24,40:m,41:27,42:k,43:T,44:L,45:W,46:X,47:E,48:B,49:A,50:D,51:g},e(R,[2,35]),e(R,[2,19]),{25:75,27:64,29:w},e(z,[2,22]),{26:[2,30]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],74:[2,30],75:[2,20]},parseError:n(r(function(l,u){if(u.recoverable)this.trace(l);else{var x=new Error(l);throw x.hash=u,x}},"parseError"),"parseError"),parse:n(r(function(l){var u=this,x=[0],d=[],S=[null],o=[],ct=this.table,f="",ft=0,ti=0,di=2,ii=1,pi=o.slice.call(arguments,1),P=Object.create(this.lexer),q={yy:{}};for(var Dt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,Dt)&&(q.yy[Dt]=this.yy[Dt]);P.setInput(l,q.yy),q.yy.lexer=P,q.yy.parser=this,typeof P.yylloc>"u"&&(P.yylloc={});var Pt=P.yylloc;o.push(Pt);var fi=P.options&&P.options.ranges;typeof q.yy.parseError=="function"?this.parseError=q.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ei(I){x.length=x.length-2*I,S.length=S.length-I,o.length=o.length-I}r(ei,"popStack"),n(ei,"popStack");function Lt(){var I;return I=d.pop()||P.lex()||ii,typeof I!="number"&&(I instanceof Array&&(d=I,I=d.pop()),I=u.symbols_[I]||I),I}r(Lt,"lex"),n(Lt,"lex");for(var v,j,O,vt,rt={},mt,H,si,yt;;){if(j=x[x.length-1],this.defaultActions[j]?O=this.defaultActions[j]:((v===null||typeof v>"u")&&(v=Lt()),O=ct[j]&&ct[j][v]),typeof O>"u"||!O.length||!O[0]){var Et="";yt=[];for(mt in ct[j])this.terminals_[mt]&&mt>di&&yt.push("'"+this.terminals_[mt]+"'");P.showPosition?Et="Parse error on line "+(ft+1)+`:
2
2
  `+P.showPosition()+`
3
3
  Expecting `+yt.join(", ")+", got '"+(this.terminals_[v]||v)+"'":Et="Parse error on line "+(ft+1)+": Unexpected "+(v==ii?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(Et,{text:P.match,token:this.terminals_[v]||v,line:P.yylineno,loc:Pt,expected:yt})}if(O[0]instanceof Array&&O.length>1)throw new Error("Parse Error: multiple actions possible at state: "+j+", token: "+v);switch(O[0]){case 1:x.push(v),S.push(P.yytext),o.push(P.yylloc),x.push(O[1]),v=null,ti=P.yyleng,f=P.yytext,ft=P.yylineno,Pt=P.yylloc;break;case 2:if(H=this.productions_[O[1]][1],rt.$=S[S.length-H],rt._$={first_line:o[o.length-(H||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(H||1)].first_column,last_column:o[o.length-1].last_column},fi&&(rt._$.range=[o[o.length-(H||1)].range[0],o[o.length-1].range[1]]),vt=this.performAction.apply(rt,[f,ti,ft,q.yy,O[1],S,o].concat(pi)),typeof vt<"u")return vt;H&&(x=x.slice(0,-1*H*2),S=S.slice(0,-1*H),o=o.slice(0,-1*H)),x.push(this.productions_[O[1]][0]),S.push(rt.$),o.push(rt._$),si=ct[x[x.length-2]][x[x.length-1]],x.push(si);break;case 3:return!0}}return!0},"parse"),"parse")},lt=(function(){var F={EOF:1,parseError:n(r(function(u,x){if(this.yy.parser)this.yy.parser.parseError(u,x);else throw new Error(u)},"parseError"),"parseError"),setInput:n(function(l,u){return this.yy=u||this.yy||{},this._input=l,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:n(function(){var l=this._input[0];this.yytext+=l,this.yyleng++,this.offset++,this.match+=l,this.matched+=l;var u=l.match(/(?:\r\n?|\n).*/g);return u?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),l},"input"),unput:n(function(l){var u=l.length,x=l.split(/(?:\r\n?|\n)/g);this._input=l+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-u),this.offset-=u;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),x.length-1&&(this.yylineno-=x.length-1);var S=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:x?(x.length===d.length?this.yylloc.first_column:0)+d[d.length-x.length].length-x[0].length:this.yylloc.first_column-u},this.options.ranges&&(this.yylloc.range=[S[0],S[0]+this.yyleng-u]),this.yyleng=this.yytext.length,this},"unput"),more:n(function(){return this._more=!0,this},"more"),reject:n(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:n(function(l){this.unput(this.match.slice(l))},"less"),pastInput:n(function(){var l=this.matched.substr(0,this.matched.length-this.match.length);return(l.length>20?"...":"")+l.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:n(function(){var l=this.match;return l.length<20&&(l+=this._input.substr(0,20-l.length)),(l.substr(0,20)+(l.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:n(function(){var l=this.pastInput(),u=new Array(l.length+1).join("-");return l+this.upcomingInput()+`
package/web/fouc.js ADDED
@@ -0,0 +1,18 @@
1
+ // 防主题闪烁(FOUC):在 React mount 前就读 localStorage 设 <html> class。
2
+ // useTheme hook mount 时会再同步一次,这里只是消除首帧的默认(无 class)闪烁。
3
+ // 外联化以配合 CSP 去掉 script-src 'unsafe-inline'(2026-09-13 审计):
4
+ // head 内同步经典脚本,首帧前执行,'self' 放行。
5
+ (function () {
6
+ try {
7
+ var mode = localStorage.getItem("lookatstudy-theme") || "auto";
8
+ var resolved =
9
+ mode === "auto"
10
+ ? window.matchMedia("(prefers-color-scheme: dark)").matches
11
+ ? "dark"
12
+ : "light"
13
+ : mode;
14
+ document.documentElement.classList.add(resolved);
15
+ } catch (e) {
16
+ document.documentElement.classList.add("dark"); // 兜底:无法读 localStorage 时用深色
17
+ }
18
+ })();
package/web/index.html CHANGED
@@ -10,31 +10,15 @@
10
10
  <link rel="icon" type="image/png" sizes="192x192" href="./icon-192.png" />
11
11
  <meta
12
12
  http-equiv="Content-Security-Policy"
13
- content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; font-src 'self' data:; connect-src 'self' http://localhost:5173 ws://localhost:5173"
13
+ content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; font-src 'self' data:; connect-src 'self' http://localhost:5173 ws://localhost:5173; base-uri 'none'; form-action 'none'"
14
14
  />
15
15
  <title>LookatStudy</title>
16
- <script>
17
- // 防主题闪烁(FOUC):在 React mount 前就读 localStorage 设 <html> class。
18
- // useTheme hook mount 时会再同步一次,这里只是消除首帧的默认(无 class)闪烁。
19
- // CSP 允许 'unsafe-inline' 脚本(见上 meta),所以这段能跑。
20
- (function () {
21
- try {
22
- var mode = localStorage.getItem("lookatstudy-theme") || "auto";
23
- var resolved =
24
- mode === "auto"
25
- ? window.matchMedia("(prefers-color-scheme: dark)").matches
26
- ? "dark"
27
- : "light"
28
- : mode;
29
- document.documentElement.classList.add(resolved);
30
- } catch (e) {
31
- document.documentElement.classList.add("dark"); // 兜底:无法读 localStorage 时用深色
32
- }
33
- })();
34
- </script>
35
- <script type="module" crossorigin src="./assets/main-DrJVBtna.js"></script>
36
- <link rel="modulepreload" crossorigin href="./assets/index-3R9G44mo.js">
37
- <link rel="stylesheet" crossorigin href="./assets/index-DPow_Z3A.css">
16
+ <!-- FOUC 脚本外联化:script-src 已去掉 'unsafe-inline'(2026-09-13 审计,
17
+ 该指令曾把任何 HTML 注入点直接升级为脚本执行) -->
18
+ <script src="./fouc.js"></script>
19
+ <script type="module" crossorigin src="./assets/main-CSS_lFDP.js"></script>
20
+ <link rel="modulepreload" crossorigin href="./assets/index-DpUqsNSC.js">
21
+ <link rel="stylesheet" crossorigin href="./assets/index-DpPK19Iz.css">
38
22
  <link rel="stylesheet" crossorigin href="./assets/main-D9IB7N5p.css">
39
23
  </head>
40
24
  <body>
package/web/pet.html CHANGED
@@ -5,12 +5,12 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <meta
7
7
  http-equiv="Content-Security-Policy"
8
- content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self' http://localhost:5173 ws://localhost:5173"
8
+ content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self' http://localhost:5173 ws://localhost:5173; base-uri 'none'; form-action 'none'"
9
9
  />
10
10
  <title>LookatStudy Pet</title>
11
- <script type="module" crossorigin src="./assets/pet-C2gtNZEs.js"></script>
12
- <link rel="modulepreload" crossorigin href="./assets/index-3R9G44mo.js">
13
- <link rel="stylesheet" crossorigin href="./assets/index-DPow_Z3A.css">
11
+ <script type="module" crossorigin src="./assets/pet-DCzJVVt6.js"></script>
12
+ <link rel="modulepreload" crossorigin href="./assets/index-DpUqsNSC.js">
13
+ <link rel="stylesheet" crossorigin href="./assets/index-DpPK19Iz.css">
14
14
  <link rel="stylesheet" crossorigin href="./assets/pet-CTf4hJTR.css">
15
15
  </head>
16
16
  <body>
@@ -1,10 +0,0 @@
1
- import{r as n,j as e,V as De,k as $e,l as Ee,s as nt,m as it,C as lt,M as ot}from"./index-3R9G44mo.js";import{c as rt,u as ne,b as ct,r as dt,X as Te,f as mt,k as oe,n as pe,a as o,W as ze,P as Ue,p as Ke,s as ut,i as xt,g as Pe,q as ht,t as pt,v as gt}from"./main-DrJVBtna.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 ft=rt("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"}]]),bt={vision:"companion.custom.routeVision",geometric:"companion.custom.routeGeometric",l1:"companion.custom.routeL1"};function vt(t){let u="";for(let h=0;h<t.length;h+=32768)u+=String.fromCharCode(...t.subarray(h,h+32768));return btoa(u)}async function jt(t){try{return await navigator.clipboard.writeText(t),!0}catch{}const u=document.createElement("textarea");u.value=t,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.focus(),u.select();let r=!1;try{r=document.execCommand("copy")}catch{r=!1}return u.remove(),r}function wt({onClose:t,onSaved:u}){const r=ne(),[h,v]=n.useState(!1),[l,c]=n.useState(!1),[p,x]=n.useState(0),[f,y]=n.useState(null),[g,T]=n.useState(null),[S,W]=n.useState(""),[C,M]=n.useState(""),[_,L]=n.useState("ember"),R=n.useRef(null),A=n.useRef(null);ct(A,!0),n.useEffect(()=>{if(!l)return;x(0);const d=Date.now(),w=window.setInterval(()=>x(Math.floor((Date.now()-d)/1e3)),500);return()=>window.clearInterval(w)},[l]);const D=async()=>{const d=await jt(r("companion.wizard.prompt"));v(d),d?setTimeout(()=>v(!1),2400):T(r("companion.wizard.copyFail"))},U=async d=>{if(d){c(!0),T(null),y(null),W(d.name.replace(/\.png$/i,""));try{const w=vt(new Uint8Array(await d.arrayBuffer())),k=await window.api.companionPackCutFromImage({pngBase64:w});y(k),k.visionError?T(`${r("companion.custom.visionFallback")} · ${k.visionError}`):T(`${r("companion.custom.cutDone")} · ${r(bt[k.route]??"companion.custom.routeL1")}`)}catch(w){T(`${r("companion.custom.fail")}: ${String(w)}`)}finally{c(!1)}}},z=async()=>{if(f){c(!0);try{await window.api.companionPackApplyPack({name:C.trim()||S||"My Bot",manifest:{...f.manifest,vehicle:_},parts:f.parts.map(d=>({name:d.name,pngBase64:d.pngBase64}))}),await Ee(),await window.api.setSetting("companion_form","custom"),window.dispatchEvent(new Event("companion-config-changed")),u()}catch(d){T(`${r("companion.custom.fail")}: ${String(d)}`)}finally{c(!1)}}};return dt.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":r("companion.wizard.title"),onClick:t,children:e.jsxs("div",{ref:A,onClick:d=>d.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:r("companion.wizard.title")}),e.jsx("button",{onClick:t,"aria-label":r("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(Te,{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:r("companion.wizard.s1")}),e.jsx("p",{className:"text-caption text-ink-muted leading-relaxed",children:r("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:r("companion.wizard.s2")}),e.jsx("p",{className:"text-caption text-ink-muted leading-relaxed mb-2",children:r("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:r("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:r("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:r("companion.wizard.s2chatgpt")}),e.jsx("button",{type:"button",onClick:()=>void D(),"data-testid":"companion-wizard-copy",className:"rounded-lg bg-accent px-3 py-1.5 text-label text-white hover:opacity-90",children:r(h?"companion.wizard.copied":"companion.wizard.copy")})]}),e.jsx("textarea",{readOnly:!0,value:r("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:d=>d.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:r("companion.wizard.s3")}),e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-caption text-ink-muted mb-1",children:r("companion.wizard.vehicle")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",role:"radiogroup","aria-label":r("companion.wizard.vehicle"),children:De.map(d=>{const w=_===d;return e.jsxs("button",{type:"button",role:"radio","aria-checked":w,"data-testid":`companion-wizard-veh-${d}`,onClick:()=>L(d),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-label motion-safe:transition-colors
7
- ${w?"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:$e[d].dot}}),r(`companion.form.${d}.name`)]},d)})})]}),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:d=>{var w;return void U((w=d.target.files)==null?void 0:w[0])}}),e.jsx("button",{type:"button",disabled:l,onClick:()=>{var d;return(d=R.current)==null?void 0:d.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:r("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(mt,{size:14,className:"animate-spin"}),r(f?"companion.custom.applying":"companion.custom.locating"),e.jsxs("span",{className:"tabular-nums",children:[p,"s"]})]}),g&&e.jsx("span",{className:"text-caption text-ink-muted","data-testid":"companion-custom-msg",children:g})]}),f&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"companion-custom-preview",children:[f.parts.map(d=>e.jsx("img",{src:`data:image/png;base64,${d.pngBase64}`,alt:d.name,title:d.name,className:"h-14 w-14 object-contain rounded-lg bg-surface-2"},d.name)),e.jsx("input",{value:C,onChange:d=>M(d.target.value),placeholder:r("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 z(),"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:r("companion.wizard.save")})]})]})]})}),document.body)}const he="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 ye({kind:t,showProtocol:u=!0,testPrefix:r="custom",titleKey:h="settings.custom.form_title",modelPhKey:v="settings.custom.model_ph",testOverride:l,onSaved:c,onCancel:p}){const x=ne(),[f,y]=n.useState(""),[g,T]=n.useState("openai-compatible"),[S,W]=n.useState(""),[C,M]=n.useState(""),[_,L]=n.useState(""),[R,A]=n.useState(!1),[D,U]=n.useState(!1),[z,d]=n.useState(null),w=async()=>{if(!(!S.trim()||!_.trim()||D)){U(!0),d(null);try{const i=l?await l({baseUrl:S.trim(),apiKey:C.trim(),model:_.trim()}):await o.testCustomProvider({label:f||x("settings.custom.test_label"),protocol:g,baseUrl:S.trim(),apiKey:C.trim()||void 0,defaultModel:_.trim()});d({ok:i.ok,detail:i.detail})}catch(i){d({ok:!1,detail:i instanceof Error?i.message:String(i)})}finally{U(!1)}}},k=async()=>{if(!(!f.trim()||!S.trim()||!_.trim()))try{const i=await o.createCustomProvider({label:f.trim(),kind:t,protocol:u?g:"openai-compatible",baseUrl:S.trim(),apiKey:C.trim()||void 0,defaultModel:_.trim(),vision:t==="llm"?R:void 0});c(i)}catch{}};return e.jsxs("div",{className:"space-y-2.5","data-testid":`${r}-provider-form`,children:[e.jsx("div",{className:"text-label font-bold text-ink-strong",children:x(h)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:f,onChange:i=>y(i.target.value),placeholder:x("settings.custom.label_ph"),"data-testid":`${r}-label`,className:`${he} min-w-0 flex-1 px-2.5 py-1.5`}),u&&e.jsxs("select",{value:g,onChange:i=>T(i.target.value),"data-testid":`${r}-protocol`,className:`${he} px-2 py-1.5`,children:[e.jsx("option",{value:"openai-compatible",children:x("settings.proto.openai")}),e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"google",children:"Google"})]})]}),e.jsx("input",{type:"text",value:S,onChange:i=>W(i.target.value),placeholder:x("settings.custom.baseurl_ph"),"data-testid":`${r}-baseurl`,className:`${he} w-full px-2.5 py-1.5 font-mono`}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:_,onChange:i=>L(i.target.value),placeholder:x(v),"data-testid":`${r}-model`,className:`${he} min-w-0 flex-1 px-2.5 py-1.5 font-mono`}),e.jsx("input",{type:"password",value:C,onChange:i=>M(i.target.value),placeholder:x("settings.custom.apikey_ph"),"data-testid":`${r}-apikey`,className:`${he} 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":`${r}-vision`,children:[e.jsx("input",{type:"checkbox",checked:R,onChange:i=>A(i.target.checked),className:"w-4 h-4 rounded accent-brand"}),e.jsx("span",{className:"text-ink-strong",children:x("settings.custom.vision")}),e.jsx("span",{className:"text-ink-faint",children:x("settings.custom.visionHint")})]}),z&&e.jsxs("div",{className:`text-label rounded p-2 inline-flex items-start gap-1.5 ${z.ok?"bg-brand/10 text-brand":"bg-warning/10 text-warning"}`,children:[z.ok?e.jsx(oe,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}):e.jsx(pe,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"break-words",children:z.detail})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>void w(),disabled:!S.trim()||!_.trim()||D,"data-testid":`${r}-test`,className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:x(D?"settings.testing":"settings.test")}),e.jsx("button",{onClick:()=>void k(),disabled:!f.trim()||!S.trim()||!_.trim(),"data-testid":`${r}-save`,className:"btn-3d-brand px-3 py-1.5 text-label disabled:opacity-40",children:x("settings.custom.save")}),p&&e.jsx("button",{onClick:p,className:"text-label text-ink-muted hover:text-ink-strong px-3 py-1.5 transition-colors",children:x("action.cancel")})]})]})}const Ie="lookatstudy-theme",We="auto",Be="(prefers-color-scheme: dark)";function Ce(){return typeof window>"u"||window.matchMedia(Be).matches?"dark":"light"}function kt(){if(typeof localStorage>"u")return We;const t=localStorage.getItem(Ie);return t==="auto"||t==="light"||t==="dark"?t:We}function _e(t){const u=document.documentElement;u.classList.remove("dark","light"),u.classList.add(t),window.dispatchEvent(new CustomEvent("theme-changed",{detail:{resolved:t}}))}function Nt(){const[t,u]=n.useState(()=>kt()),[r,h]=n.useState(()=>t==="auto"?Ce():t),v=n.useCallback(l=>{u(l),localStorage.setItem(Ie,l);const c=l==="auto"?Ce():l;h(c),_e(c)},[]);return n.useEffect(()=>{if(t!=="auto")return;const l=window.matchMedia(Be),c=p=>{const x=p.matches?"dark":"light";h(x),_e(x)};return l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[t]),n.useEffect(()=>{const l=t==="auto"?Ce():t;h(l),_e(l)},[t]),{mode:t,resolved:r,setMode:v}}const yt="0.33.2",St={version:yt};function Ne(){window.dispatchEvent(new Event(gt))}const J="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",H="bg-surface-3 text-ink-muted hover:bg-surface-3 hover:bg-surface-3 hover:text-ink-strong",q="bg-brand text-white shadow-sm";function N(t){return t?"px-4 py-3.5 border-t border-[var(--border-faint)]":"px-4 py-3.5"}function At(){const t=ne(),[u,r]=n.useState([]),[h,v]=n.useState([]),[l,c]=n.useState("glm"),[p,x]=n.useState(""),[f,y]=n.useState(""),[g,T]=n.useState(null),[S,W]=n.useState(!1),[C,M]=n.useState(null),[_,L]=n.useState(!1),[R,A]=n.useState(!1),[D,U]=n.useState([]),[z,d]=n.useState(!1),[w,k]=n.useState(null),[i,E]=n.useState(null),[$,I]=n.useState(""),[m,X]=n.useState(!1),Z=Nt(),ce=async a=>{if(V)try{await o.updateCustomProvider(V.id,{vision:a}),await O()}catch{}},de=async()=>{d(!0),k(null);try{const a=await o.discoverModels();a.ok&&a.models?U(a.models):k(a.error||t("settings.discover_failed"))}catch(a){k(a instanceof Error?a.message:String(a))}finally{d(!1)}},O=n.useCallback(async()=>{try{const[a,j,K,se]=await Promise.all([o.getProviderPresets(),o.listCustomProviders(),o.getSetting("active_provider"),o.getSetting("active_model")]);r(a),v(j);const B=K??"glm";if(c(B),B.startsWith("custom-")){const P=j.find(F=>F.id===B);T(P!=null&&P.hasApiKey?t("settings.key.configured"):null)}else{const P=a.find(F=>F.id===B);if(P){const F=await o.getSetting(P.apiKeySetting);T(F?`${F.slice(0,4)}…${F.slice(-4)}`:null)}}if(B.startsWith("custom-")){const P=j.find(F=>F.id===B);x(se??(P==null?void 0:P.defaultModel)??"")}else{const P=a.find(F=>F.id===B);x(se??(P==null?void 0:P.defaultModel)??"")}}catch(a){console.error("[SettingsView] load() failed:",a)}},[t]);n.useEffect(()=>{O()},[O]);const ue=async a=>{c(a),M(null),y("");const j=u.find(K=>K.id===a);if(j){const K=await o.getSetting(j.apiKeySetting);T(K?`${K.slice(0,4)}…${K.slice(-4)}`:null),x(p||j.defaultModel)}},ge=async()=>{L(!1);try{if(await o.setSetting("active_provider",l),await o.setSetting("active_model",p),f.trim()){const a=u.find(j=>j.id===l);a&&(await o.setSetting(a.apiKeySetting,f.trim()),T(`${f.trim().slice(0,4)}…${f.trim().slice(-4)}`),y(""))}L(!0),setTimeout(()=>L(!1),2e3),window.dispatchEvent(new Event("llm-config-changed"))}catch{}},Y=async()=>{W(!0),M(null);try{const a=await o.testLlmConnection();M(a)}catch(a){M({ok:!1,detail:a instanceof Error?a.message:String(a),errorKind:"unknown"})}finally{W(!1)}},fe=async a=>{await o.setSetting("active_provider",a.id),await o.setSetting("active_model",a.defaultModel),c(a.id),x(a.defaultModel),A(!1),await O(),window.dispatchEvent(new Event("llm-config-changed"))},ie=async a=>{try{await o.deleteCustomProvider(a),l===a&&(await o.setSetting("active_provider","glm"),c("glm")),await O()}catch{}},V=l.startsWith("custom-")?h.find(a=>a.id===l):null;n.useEffect(()=>{if(!V)return;const a=V.models.find(j=>j.id===p);I(a!=null&&a.contextWindow?String(a.contextWindow):"")},[V,p]);const be=async()=>{var B,P;if(!V)return;const a=$.trim().replace(/[,\s_]/g,""),j=/^(\d+)([km]?)$/i.exec(a);if(a!==""&&!j)return;const K=((B=j==null?void 0:j[2])==null?void 0:B.toLowerCase())==="k"?1e3:((P=j==null?void 0:j[2])==null?void 0:P.toLowerCase())==="m"?1e6:1,se=a===""||!j?null:Math.max(1,Math.round(parseInt(j[1],10)*K));X(!0);try{const F=V.models.map(Q=>Q.id===p?{...Q,contextWindow:se}:Q);await o.updateCustomProvider(V.id,{models:F}),await O(),window.dispatchEvent(new Event("llm-config-changed"))}catch{}finally{X(!1)}},te=l.startsWith("custom-")?null:u.find(a=>a.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:N(!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:[u.map(a=>e.jsx("button",{onClick:()=>ue(a.id),"data-testid":`provider-card-${a.id}`,"aria-pressed":l===a.id,className:`px-3 py-1.5 rounded-lg text-label font-medium whitespace-nowrap transition-colors ${l===a.id?q:H}`,children:a.label},a.id)),h.filter(a=>a.kind==="llm").map(a=>e.jsxs("button",{onClick:()=>ue(a.id),"data-testid":`provider-card-${a.id}`,"aria-pressed":l===a.id,className:`px-3 py-1.5 rounded-lg text-label font-medium whitespace-nowrap transition-colors inline-flex items-center gap-1 ${l===a.id?q:H}`,children:[e.jsx(ze,{className:"w-3.5 h-3.5","aria-hidden":"true"}),a.label]},a.id)),e.jsxs("button",{onClick:()=>A(a=>!a),"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(ye,{kind:"llm",testPrefix:"custom",onSaved:a=>void fe(a),onCancel:()=>A(!1)})}),h.length>0&&l.startsWith("custom-")&&e.jsx("div",{className:N(!0),children:e.jsx("button",{onClick:a=>{const j=a.currentTarget.getBoundingClientRect(),K=h.find(se=>se.id===l);K&&E({id:K.id,label:K.label,rect:j})},className:"text-label text-warning hover:underline",children:t("settings.delete_custom")})}),te&&e.jsxs(e.Fragment,{children:[te.baseUrl&&e.jsxs("div",{className:N(!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:te.baseUrl})]}),e.jsxs("div",{className:N(!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:p,onChange:a=>x(a.target.value),"data-testid":"model-select",className:`${J} flex-1 px-2.5 py-1.5`,children:[te.models.map(a=>e.jsx("option",{value:a.id,children:a.id},a.id)),l==="openrouter"&&D.map(a=>e.jsx("option",{value:a.id,children:a.id},a.id))]}),l==="openrouter"&&e.jsxs("button",{onClick:de,disabled:z,"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(ft,{className:`w-3.5 h-3.5 ${z?"animate-spin":""}`,"aria-hidden":"true"}),t(z?"settings.discovering":"settings.refresh")]})]})]}),w&&e.jsx("div",{className:"text-label text-warning mt-1.5 ml-[68px]",children:w})]}),e.jsx("div",{className:N(!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:[g&&e.jsxs("span",{className:"text-label text-brand shrink-0 inline-flex items-center gap-1",children:[e.jsx(oe,{className:"w-3.5 h-3.5","aria-hidden":"true"}),g]}),e.jsx("input",{type:"password",value:f,onChange:a=>y(a.target.value),placeholder:t(g?"settings.key.overwrite_ph":"settings.key.paste_ph"),"data-testid":"settings-key-input",className:`${J} flex-1 px-2.5 py-1.5`}),e.jsx("a",{href:te.keyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-label text-brand hover:underline whitespace-nowrap",children:t("settings.key.get")})]})]})}),e.jsx("div",{className:N(!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:Y,disabled:S,"data-testid":"test-connection-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:t(S?"settings.testing":"settings.test")}),C&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 min-w-0 break-words ${C.ok?"text-brand":"text-warning"}`,children:[C.ok?e.jsx(oe,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}):e.jsx(pe,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}),C.detail]})]})})]}),V&&!te&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:N(!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:V.baseUrl})]}),e.jsx("div",{className:N(!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")}),V.models.length>1?e.jsx("select",{value:p,onChange:a=>x(a.target.value),"data-testid":"model-select-custom",className:`${J} flex-1 px-2.5 py-1.5`,children:V.models.map(a=>e.jsx("option",{value:a.id,children:a.id},a.id))}):e.jsx("input",{type:"text",value:p,onChange:a=>x(a.target.value),placeholder:t("settings.custom.model_ph"),"data-testid":"model-input-custom",className:`${J} flex-1 px-2.5 py-1.5 font-mono`})]})}),e.jsxs("div",{className:N(!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:$,onChange:a=>I(a.target.value),placeholder:t("settings.custom.windowPh"),"data-testid":"context-window-input",className:`${J} flex-1 px-2.5 py-1.5 font-mono tabular-nums`}),e.jsx("button",{onClick:be,disabled:m,"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:N(!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:V.vision,onChange:a=>void ce(a.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:N(!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:Y,disabled:S,"data-testid":"test-connection-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:t(S?"settings.testing":"settings.test")}),C&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 min-w-0 break-words ${C.ok?"text-brand":"text-warning"}`,children:[C.ok?e.jsx(oe,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}):e.jsx(pe,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}),C.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(_t,{activeProvider:l,activeModel:p,presets:u,customProviders:h,onProvidersChanged:()=>void O()})})]}),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(Pt,{})})]}),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($t,{})})]}),e.jsxs("section",{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(Et,{})})]}),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:N(!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:a,label:j})=>e.jsx("button",{onClick:()=>Z.setMode(a),"data-testid":`theme-${a}`,"aria-pressed":Z.mode===a,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${Z.mode===a?q:H}`,children:j},a))}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:Z.mode==="auto"?t("settings.theme.following",{mode:t(`settings.theme.${Z.resolved}`)}):null})]}),e.jsxs("div",{className:N(!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(a=>e.jsx("button",{onClick:()=>ut(a),"data-testid":`lang-${a}`,"aria-pressed":Ke()===a,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${Ke()===a?q:H}`,children:a==="zh-CN"?"中文":"English"},a))})]}),e.jsxs("div",{className:N(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.import_lang")}),e.jsx(Ct,{})]})]})]}),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(Mt,{})})]}),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:N(!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",St.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:ge,"data-testid":"settings-save",className:"btn-3d-brand px-5 py-2 text-body inline-flex items-center gap-1.5",children:[_&&e.jsx(xt,{className:"w-4 h-4","aria-hidden":"true"}),t(_?"settings.saved_text":"settings.footer.save")]})]}),i&&e.jsx(Pe,{anchorRect:i.rect,message:t("settings.delete_custom_confirm",{name:i.label}),danger:!0,confirmLabel:t("action.delete"),testid:"custom-provider-delete-confirm",onConfirm:()=>{ie(i.id),E(null)},onCancel:()=>E(null)})]})}function Ct(){const[t,u]=n.useState("en"),[r,h]=n.useState(!1);n.useEffect(()=>{o.getSetting("pref_lang").then(c=>{c&&u(c),h(!0)})},[]);const v=async c=>{u(c),await o.setSetting("pref_lang",c)},l=[{code:"en",label:"English"},{code:"zh-CN",label:"简体中文"},{code:"zh-TW",label:"繁體中文"}];return r?e.jsx("div",{className:"flex gap-2","data-testid":"pref-lang-options",children:l.map(c=>e.jsx("button",{onClick:()=>v(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?q:H}`,children:c.label},c.code))}):null}function _t({activeProvider:t,activeModel:u,presets:r,customProviders:h,onProvidersChanged:v}){const l=ne(),[c,p]=n.useState(!1),[x,f]=n.useState(!1),[y,g]=n.useState(""),[T,S]=n.useState(!1),[W,C]=n.useState(!1),[M,_]=n.useState(null),[L,R]=n.useState(!1);n.useEffect(()=>{Promise.all([o.getSetting("flag_multimodal_import"),o.getSetting("vision_provider_override"),o.getSetting("vision_model_override"),o.getSetting("flag_math_vision")]).then(([m,X,Z])=>{p(m==="true"),g(X??""),R(Z==="true"),f(!0)})},[]);const A=async()=>{const m=!c;p(m),await o.setSetting("flag_multimodal_import",String(m))},D=async()=>{const m=!L;R(m),await o.setSetting("flag_math_vision",String(m))},U=async m=>{await o.setSetting("vision_provider_override",m.id),await o.setSetting("vision_model_override",m.defaultModel),g(m.id),S(!1)},z=async()=>{await o.setSetting("vision_provider_override",""),await o.setSetting("vision_model_override",""),g(""),S(!1)},[d,w]=n.useState(null),k=async m=>{try{y===m&&(await o.setSetting("vision_provider_override",""),await o.setSetting("vision_model_override",""),g("")),await o.deleteCustomProvider(m)}catch{}finally{v==null||v()}},i=async()=>{if(!W){C(!0),_(null);try{const m=await o.testLlmConnection({vision:!0});_({ok:m.ok,detail:m.detail})}catch(m){_({ok:!1,detail:m instanceof Error?m.message:String(m)})}finally{C(!1)}}},E=h.filter(m=>m.kind==="vision"),$=y.startsWith("custom-")?h.find(m=>m.id===y):null,I=y&&!y.startsWith("custom-")?r.find(m=>m.id===y):null;return x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(re,{checked:c,onChange:A,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:u||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:[$&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx(ze,{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:$.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:$.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:$.baseUrl})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{onClick:()=>void i(),disabled:W,"data-testid":"vision-override-test",className:"btn-3d-neutral px-4 py-1.5 text-label disabled:opacity-50",children:l(W?"settings.testing":"settings.multimodal.test_override")}),e.jsx("button",{onClick:()=>S(m=>!m),className:"text-label text-accent hover:underline",children:l("settings.multimodal.replace_custom")}),e.jsx("button",{onClick:()=>void z(),className:"text-label text-ink-muted hover:text-ink-strong",children:l("settings.multimodal.stop_override")}),e.jsx("button",{onClick:m=>{m.stopPropagation(),w({id:$.id,label:$.label,rect:m.currentTarget.getBoundingClientRect()})},"data-testid":`vision-delete-${$.id}`,className:"text-label text-ink-muted hover:text-warning",children:l("action.delete")}),M&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${M.ok?"text-brand":"text-warning"}`,children:[M.ok?e.jsx(oe,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(pe,{className:"w-4 h-4","aria-hidden":"true"}),M.detail]})]})]}),I&&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:I.label})}),e.jsx("button",{onClick:()=>void z(),className:"text-label text-ink-muted hover:text-ink-strong underline",children:l("settings.multimodal.stop_override")})]}),!$&&!I&&e.jsxs(e.Fragment,{children:[E.map(m=>e.jsxs("span",{className:"relative block",children:[e.jsxs("button",{onClick:()=>void U(m),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`vision-pick-${m.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:m.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:m.defaultModel})]}),e.jsx("button",{type:"button","aria-label":l("action.delete"),"data-tooltip":l("action.delete"),"data-testid":`vision-delete-${m.id}`,onClick:X=>{X.stopPropagation(),w({id:m.id,label:m.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(Te,{className:"w-3.5 h-3.5"})})]},m.id)),(T||E.length===0)&&e.jsx(ye,{kind:"vision",testPrefix:"vision-custom",titleKey:"settings.custom.form_title_vision",modelPhKey:"settings.custom.model_ph_vision",onSaved:m=>void U(m),onCancel:()=>S(!1)}),E.length>0&&e.jsx("button",{onClick:()=>S(m=>!m),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(re,{checked:L,onChange:D,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")})]})]})]}),d&&e.jsx(Pe,{anchorRect:d.rect,message:l("settings.delete_custom_confirm",{name:d.label}),danger:!0,confirmLabel:l("action.delete"),testid:"vision-provider-delete-confirm",onConfirm:()=>{k(d.id),w(null)},onCancel:()=>w(null)})]}):null}function $t(){const t=ne(),[u,r]=n.useState(!1),[h,v]=n.useState(!1);n.useEffect(()=>{o.getSetting("flag_memory_system").then(c=>{r(c==="true"),v(!0)})},[]);const l=async()=>{const c=!u;r(c),await o.setSetting("flag_memory_system",String(c))};return h?e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(re,{checked:u,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 Et(){const t=ne(),[u,r]=n.useState(!0),[h,v]=n.useState(!1),l=n.useSyncExternalStore(nt,it),[c,p]=n.useState(!0),[x,f]=n.useState(!1),y=typeof window<"u"&&!!window.__lookatstudyWeb;n.useEffect(()=>{o.getSetting("companion_enabled").then(i=>{r(i!=="false"&&i!=="0"),v(!0)}),o.getSetting("companion_sfx").then(i=>{p(i!=="false"&&i!=="0")}),o.getSetting("companion_pet_mode").then(i=>{f(i==="1")})},[]);const g=async()=>{const i=!u;r(i),await o.setSetting("companion_enabled",String(i)),window.dispatchEvent(new Event("companion-config-changed"))},T=async()=>{const i=!c;p(i),await o.setSetting("companion_sfx",String(i)),window.dispatchEvent(new Event("companion-config-changed"))},S=async()=>{const i=!x;f(i),await o.setSetting("companion_pet_mode",i?"1":"0"),window.dispatchEvent(new Event("companion-config-changed"))},W=async i=>{i!==l.form&&(await o.setSetting("companion_form",i),window.dispatchEvent(new Event("companion-config-changed")))},[C,M]=n.useState([]),[_,L]=n.useState(!1),[R,A]=n.useState(null),[D,U]=n.useState(null),z=n.useCallback(async()=>{try{M((await window.api.companionPackList()).packs)}catch{}},[]);n.useEffect(()=>{z();const i=()=>void z();return window.addEventListener("companion-config-changed",i),()=>window.removeEventListener("companion-config-changed",i)},[z]);const d=async i=>{await window.api.companionPackActivate({id:i}),l.form!=="custom"&&await o.setSetting("companion_form","custom"),await Ee(),window.dispatchEvent(new Event("companion-config-changed"))},w=async i=>{(await window.api.companionPackDelete({id:i})).formReset&&window.dispatchEvent(new Event("companion-config-changed")),A(null),U(null),z()},k=async(i,E)=>{var $;await window.api.companionPackSetVehicle({id:i,vehicle:E}),await z(),($=C.find(I=>I.id===i))!=null&&$.active&&(await Ee(),window.dispatchEvent(new Event("companion-config-changed")))};return h?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(re,{checked:u,onChange:g,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")})]})]}),u&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(re,{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")})]})]}),!y&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(re,{checked:x,onChange:S,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:[lt.filter(i=>i!=="custom").map(i=>{const E=l.form===i;return e.jsxs("button",{type:"button",role:"radio","aria-checked":E,"data-testid":`companion-form-${i}`,onClick:()=>{W(i)},className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
8
- ${E?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,title:t(`companion.form.${i}.desc`),children:[e.jsx(ot,{form:i,expression:"happy",pose:"float",size:64}),e.jsx("span",{className:`text-label ${E?"text-ink-strong font-medium":"text-ink-muted"}`,children:t(`companion.form.${i}.name`)})]},i)}),C.map(i=>{const E=l.form==="custom"&&i.active;return e.jsxs("span",{className:"relative inline-block",children:[e.jsxs("button",{type:"button",role:"radio","aria-checked":E,"data-testid":`companion-form-pack-${i.id}`,onClick:()=>{d(i.id)},title:i.name,className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
9
- ${E?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[i.thumb?e.jsx("img",{src:i.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 ${E?"text-ink-strong font-medium":"text-ink-muted"}`,children:i.name})]}),e.jsx("button",{type:"button","aria-label":t("companion.bots.veh"),"data-tooltip":t("companion.bots.veh"),"data-testid":`companion-pack-veh-${i.id}`,onClick:$=>{$.stopPropagation(),U(I=>I===i.id?null:i.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:$e[i.vehicle??"silver"].dot}}),e.jsx("button",{type:"button","aria-label":t("companion.custom.delete"),"data-tooltip":t("companion.custom.delete"),onClick:$=>{$.stopPropagation(),A({id:i.id,rect:$.currentTarget.getBoundingClientRect()})},className:"absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-surface-1 border border-[var(--border-faint)] text-ink-muted hover:text-warning flex items-center justify-center",children:e.jsx(Te,{className:"w-3 h-3"})})]},i.id)}),e.jsxs("button",{type:"button",role:"radio","aria-checked":!1,"data-testid":"companion-form-add","aria-label":t("companion.bots.add"),onClick:()=>L(!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")})]})]}),D&&e.jsxs("div",{className:"mt-2 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:"flex flex-wrap gap-1.5",role:"radiogroup","aria-label":t("companion.wizard.vehicle"),children:["silver",...De].map(i=>{var $;const E=((($=C.find(I=>I.id===D))==null?void 0:$.vehicle)??"silver")===i;return e.jsxs("button",{type:"button",role:"radio","aria-checked":E,"data-testid":`companion-veh-pick-${i}`,onClick:()=>void k(D,i),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-label motion-safe:transition-colors
10
- ${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:$e[i].dot}}),t(i==="silver"?"companion.veh.silver":`companion.form.${i}.name`)]},i)})})]}),R&&e.jsx(Pe,{anchorRect:R.rect,message:t("companion.bots.deleteConfirm"),danger:!0,testid:"companion-pack-delete-confirm",onConfirm:()=>void w(R.id),onCancel:()=>A(null)}),_&&e.jsx(wt,{onClose:()=>L(!1),onSaved:()=>{L(!1),z()}})]})]})]}):null}function re({checked:t,onChange:u,label:r,testid:h}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":r,onClick:u,"data-testid":h,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 Tt=[{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(女)"}],zt=[{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 Pt(){const t=ne(),[u,r]=n.useState([]),[h,v]=n.useState(null),[l,c]=n.useState(null),[p,x]=n.useState(null),[f,y]=n.useState(null),[g,T]=n.useState("edge"),[S,W]=n.useState("zh-CN-XiaoxiaoNeural"),[C,M]=n.useState("48"),[_,L]=n.useState("1.0"),[R,A]=n.useState(""),[D,U]=n.useState(""),[z,d]=n.useState([]),w=typeof window<"u"&&"speechSynthesis"in window,[k,i]=n.useState("local"),[E,$]=n.useState("asr-whisper-turbo"),[I,m]=n.useState(!0),[X,Z]=n.useState([]),[ce,de]=n.useState(!1),[O,ue]=n.useState(!1),[ge,Y]=n.useState(!1),[fe,ie]=n.useState(!1),[V,be]=n.useState(!1),[te,a]=n.useState(null),[j,K]=n.useState(!1),[se,B]=n.useState(null),[P,F]=n.useState(null),Q=n.useCallback(()=>{o.listCustomProviders().then(s=>Z(s.filter(b=>b.kind==="tts"||b.kind==="asr"))).catch(()=>{})},[]);n.useEffect(()=>{Promise.all([o.getSetting("tts_engine"),o.getSetting("tts_voice_edge"),o.getSetting("tts_sid_local"),o.getSetting("tts_speed"),o.getSetting("tts_custom_voice"),o.getSetting("tts_system_voice"),o.getSetting("asr_engine"),o.getSetting("asr_local_model"),o.getSetting("asr_auto_stop")]).then(([s,b,G,ee,ke,Fe,Ve,Se,at])=>{s&&T(s),b&&W(b),G&&M(G),ee&&L(ee),ke&&A(ke),Fe&&U(Fe),Ve&&i(Ve),(Se==="asr-whisper-turbo"||Se==="asr-whisper-small")&&$(Se),m(at!=="0")}),Q()},[Q]),n.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const s=()=>d(pt(window.speechSynthesis.getVoices()));return s(),window.speechSynthesis.addEventListener("voiceschanged",s),()=>window.speechSynthesis.removeEventListener("voiceschanged",s)},[]);const xe=n.useCallback(()=>{window.api.getSpeechModelStatus().then(s=>r(s)).catch(()=>{})},[]);n.useEffect(()=>(xe(),window.api.on("speech:modelProgress",b=>{x({id:b.id,pct:Math.floor(b.progress*100),label:b.currentFile?b.currentFile.split("/").pop()??"":""})})),[xe]);const Oe=s=>{c(null),v(s),x({id:s,pct:0,label:""}),window.api.ensureSpeechModel(s).then(()=>{v(null),x(null),xe()}).catch(b=>{v(null),x(null),c(b instanceof Error?b.message:String(b)),xe()})},Ge=s=>{v(s),y(null),window.api.deleteSpeechModel(s).then(xe).catch(b=>c(b instanceof Error?b.message:String(b))).finally(()=>v(null))},He=s=>t(s==="tts-kokoro"?"settings.speech.model.tts":s==="asr-whisper-turbo"?"settings.speech.model.asr_turbo":"settings.speech.model.asr_small"),qe=s=>t(s==="asr-whisper-turbo"?"settings.speech.model.turbo_short":"settings.speech.model.small_short"),Xe=s=>s.startsWith("asr-whisper")?t("settings.speech.license_mit"):t("settings.speech.license"),Me=s=>t(s==="ready"?"settings.speech.state.ready":s==="error"?"settings.speech.state.error":"settings.speech.state.absent"),Le=s=>{var b;return((b=u.find(G=>G.id===s))==null?void 0:b.state)??"absent"},me=s=>{T(s),a(null),o.setSetting("tts_engine",s),Ne()},Ye=s=>{U(s),o.setSetting("tts_system_voice",s),Ne()},ve=s=>{i(s),B(null),o.setSetting("asr_engine",s)},je=X.filter(s=>s.kind==="tts"),we=X.filter(s=>s.kind==="asr"),ae=g.startsWith("custom-")?je.find(s=>s.id===g)??null:null,le=k.startsWith("custom-")?we.find(s=>s.id===k)??null:null,Je=g==="azure",Ze=k==="groq",Qe=k==="azure",et=async()=>{if(!(!ae||V)){be(!0),a(null);try{a(await o.testCustomTts({providerId:ae.id}))}catch(s){a({ok:!1,detail:s instanceof Error?s.message:String(s)})}finally{be(!1)}}},tt=async()=>{if(!(!le||j)){K(!0),B(null);try{B(await o.testCustomAsr({providerId:le.id}))}catch(s){B({ok:!1,detail:s instanceof Error?s.message:String(s)})}finally{K(!1)}}},st=async(s,b)=>{F(null);try{await o.deleteCustomProvider(s),b==="tts"&&g===s&&me("edge"),b==="asr"&&k===s&&ve("local"),Q()}catch{}},Re=s=>{const b=u.find(ee=>ee.id===s),G=(b==null?void 0:b.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:He(s)}),e.jsxs("div",{className:"text-caption text-ink-muted",children:[Me(G)," · ",Xe(s)]}),h===s&&(p==null?void 0:p.id)===s&&e.jsx("div",{className:"mt-1.5 h-1.5 rounded-full bg-ink/[0.08] overflow-hidden","data-testid":`speech-dl-bar-${s}`,children:e.jsx("div",{className:"h-full bg-brand transition-all",style:{width:`${p.pct}%`}})}),h===s&&(p==null?void 0:p.id)===s&&e.jsxs("div",{className:"text-caption text-ink-faint mt-0.5","data-testid":`speech-dl-pct-${s}`,children:[p.pct,"%",p.label?` · ${p.label}`:""]})]}),G==="ready"?f===s?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:()=>Ge(s),className:"text-label text-warning hover:underline","data-testid":`speech-del-confirm-${s}`,children:t("settings.speech.delete")}),e.jsx("button",{onClick:()=>y(null),className:"text-label text-ink-muted hover:text-ink-strong",children:t("action.cancel")})]}):e.jsx("button",{onClick:()=>y(s),disabled:h===s,className:"text-label text-ink-muted hover:text-warning disabled:opacity-40","data-testid":`speech-del-${s}`,children:t("settings.speech.delete")}):e.jsx("button",{onClick:()=>Oe(s),disabled:h!=null||G==="downloading",className:"btn-3d-brand px-3 py-1 text-label disabled:opacity-40","data-testid":`speech-dl-${s}`,children:t(h===s||G==="downloading"?"settings.speech.downloading":"settings.speech.download")})]},s)},Ae=(s,b,G,ee,ke)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx(ze,{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:s.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:s.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:s.baseUrl}),s.hasApiKey&&e.jsxs("span",{className:"text-brand shrink-0 inline-flex items-center gap-0.5",children:[e.jsx(oe,{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 ke(),disabled:G,className:"btn-3d-neutral px-3 py-1 text-label disabled:opacity-40","data-testid":`${b}-custom-test`,children:t(G?"settings.testing":"settings.test")}),P===s.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 st(s.id,b),className:"text-label text-warning hover:underline","data-testid":`${b}-custom-del-confirm`,children:t("settings.speech.delete")}),e.jsx("button",{onClick:()=>F(null),className:"text-label text-ink-muted hover:text-ink-strong",children:t("action.cancel")})]}):e.jsx("button",{onClick:()=>F(s.id),className:"text-label text-ink-muted hover:text-warning","data-testid":`${b}-custom-del`,children:t("settings.speech.delete")}),ee&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${ee.ok?"text-brand":"text-warning"}`,children:[ee.ok?e.jsx(oe,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(pe,{className:"w-4 h-4","aria-hidden":"true"}),ee.detail]})]})]});return e.jsxs("div",{"data-testid":"settings-speech",children:[e.jsxs("div",{className:N(!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:()=>{me("edge"),de(!1),Y(!1)},"data-testid":"tts-engine-edge","aria-pressed":g==="edge",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${g==="edge"?q:H}`,children:t("settings.speech.engine.edge")}),e.jsxs("button",{onClick:()=>{me("local"),de(!1),Y(!1)},"data-testid":"tts-engine-local","aria-pressed":g==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${g==="local"?q:H}`,children:[t("settings.speech.engine.local"),Le("tts-kokoro")!=="ready"?` · ${t("settings.speech.state.absent")}`:""]}),e.jsx("button",{onClick:()=>{me("system"),de(!1),Y(!1)},disabled:!w,"data-testid":"tts-engine-system","aria-pressed":g==="system",title:w?void 0:t("settings.speech.engine.system_unavailable"),className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${g==="system"?q:H} ${w?"":"opacity-40 cursor-not-allowed"}`,children:t("settings.speech.engine.system")}),e.jsx("button",{onClick:()=>{de(s=>!s),ce||Y(!1)},"data-testid":"tts-engine-custom","aria-pressed":g.startsWith("custom-")||ce,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${g.startsWith("custom-")||ce?q:H}`,children:t("settings.speech.engine.custom")}),Je&&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")]})]}),g==="edge"&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.engine.edge_note")})]}),g==="edge"&&e.jsxs("div",{className:N(!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:S,onChange:s=>{W(s.target.value),o.setSetting("tts_voice_edge",s.target.value)},"data-testid":"tts-voice-select",className:`${J} w-full min-w-0 px-2.5 py-1.5`,children:Tt.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))})]}),g==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:N(!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:C,onChange:s=>{M(s.target.value),o.setSetting("tts_sid_local",s.target.value)},"data-testid":"tts-sid-select",className:`${J} w-full min-w-0 px-2.5 py-1.5`,children:zt.map(s=>e.jsx("option",{value:s.sid,children:s.label},s.sid))})]}),e.jsx("div",{className:N(!1),children:Re("tts-kokoro")})]}),g==="system"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:N(!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:D,onChange:s=>Ye(s.target.value),"data-testid":"tts-system-voice-select",className:`${J} w-full min-w-0 px-2.5 py-1.5`,children:[e.jsx("option",{value:"",children:t("settings.speech.voice_auto")}),z.map(s=>e.jsx("option",{value:s.name,children:ht(s)},s.voiceURI))]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.engine.system_note")})]})}),ce&&e.jsx("div",{className:N(!1),children:e.jsxs("div",{className:"space-y-3",children:[ae&&Ae(ae,"tts",V,te,et),ae&&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:s=>A(s.target.value),onBlur:()=>void o.setSetting("tts_custom_voice",R.trim()),placeholder:t("settings.speech.custom_voice_ph"),"data-testid":"tts-custom-voice",className:`${J} w-full min-w-0 px-2.5 py-1.5 font-mono`})]}),!ae&&je.map(s=>e.jsxs("button",{onClick:()=>me(s.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-${s.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:s.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:s.defaultModel})]},s.id)),(ge||!ae&&je.length===0)&&e.jsx(ye,{kind:"tts",showProtocol:!1,testPrefix:"tts-custom",titleKey:"settings.custom.form_title_tts",modelPhKey:"settings.custom.model_ph_tts",testOverride:s=>o.testCustomTts({baseUrl:s.baseUrl,apiKey:s.apiKey||void 0,model:s.model}),onSaved:s=>{me(s.id),Y(!1),Q()},onCancel:()=>Y(!1)}),(ae||je.length>0)&&e.jsx("button",{onClick:()=>Y(s=>!s),className:"text-label text-accent hover:underline",children:t(ge?"action.cancel":"settings.custom.new")})]})}),e.jsx("div",{className:N(!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:_,onChange:s=>L(s.target.value),onPointerUp:()=>{o.setSetting("tts_speed",_),Ne()},onKeyUp:()=>{o.setSetting("tts_speed",_),Ne()},"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(_).toFixed(2),"x"]})]})}),e.jsxs("div",{className:N(!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:()=>{ve("local"),ue(!1),ie(!1)},"data-testid":"asr-engine-local","aria-pressed":k==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${k==="local"?q:H}`,children:t("settings.speech.asr_engine.local")}),e.jsx("button",{onClick:()=>{ue(s=>!s),O||ie(!1)},"data-testid":"asr-engine-custom","aria-pressed":k.startsWith("custom-")||O,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${k.startsWith("custom-")||O?q:H}`,children:t("settings.speech.engine.custom")}),Ze&&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")]}),Qe&&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")]})]}),k==="local"?e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_engine.local_note")}):k.startsWith("custom-")&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_engine.custom_note")})]}),k==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:N(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.model")}),e.jsx("select",{value:E,onChange:s=>{$(s.target.value),o.setSetting("asr_local_model",s.target.value)},"data-testid":"asr-model-select",className:`${J} w-full min-w-0 px-2.5 py-1.5`,children:["asr-whisper-turbo","asr-whisper-small"].map(s=>e.jsxs("option",{value:s,children:[qe(s)," · ",Me(Le(s))]},s))})]}),e.jsx("div",{className:N(!1),children:Re(E)})]}),O&&e.jsx("div",{className:N(!1),children:e.jsxs("div",{className:"space-y-3",children:[le&&Ae(le,"asr",j,se,tt),!le&&we.map(s=>e.jsxs("button",{onClick:()=>ve(s.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-${s.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:s.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:s.defaultModel})]},s.id)),(fe||!le&&we.length===0)&&e.jsx(ye,{kind:"asr",showProtocol:!1,testPrefix:"asr-custom",titleKey:"settings.custom.form_title_asr",modelPhKey:"settings.custom.model_ph_asr",testOverride:s=>o.testCustomAsr({baseUrl:s.baseUrl,apiKey:s.apiKey||void 0,model:s.model}),onSaved:s=>{ve(s.id),ie(!1),Q()},onCancel:()=>ie(!1)}),(le||we.length>0)&&e.jsx("button",{onClick:()=>ie(s=>!s),className:"text-label text-accent hover:underline",children:t(fe?"action.cancel":"settings.custom.new")})]})}),e.jsxs("div",{className:N(!0),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(re,{checked:I,onChange:()=>{const s=!I;m(s),o.setSetting("asr_auto_stop",s?"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 Mt(){const t=ne(),u=n.useRef(null),[r,h]=n.useState(null),[v,l]=n.useState(!1),[c,p]=n.useState(null);n.useEffect(()=>{o.dshImportDetect().then(h).catch(()=>h({found:!1,path:null,version:null}))},[]);const x=f=>{l(!0),p(null),f.then(p).catch(y=>p({ok:!1,error:String(y)})).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")}),r==null?null:r.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:r.version??"?"})}),e.jsx("button",{onClick:()=>x(o.dshImportFromPath(r.path??"")),disabled:v,"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(v?"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:u,type:"file",accept:".json,application/json",className:"hidden","data-testid":"settings-dsh-file-input",onChange:f=>{var g;const y=(g=f.target.files)==null?void 0:g[0];y&&(y.text().then(T=>x(o.dshImportFromText(T))),f.target.value="")}}),e.jsx("button",{onClick:()=>{var f;return(f=u.current)==null?void 0:f.click()},disabled:v,className:"px-3 py-1.5 rounded-xl text-label font-bold btn-3d-neutral disabled:opacity-50",children:t("settings.dsh.pickFile")})]}),v&&!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{At as SettingsView};
@@ -1 +0,0 @@
1
- var v=Object.defineProperty;var f=(o,e,t)=>e in o?v(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var m=(o,e,t)=>f(o,typeof e!="symbol"?e+"":e,t);const y={listCourses:"course:list",getCourseTree:"course:getTree",importCourseFromRepo:"course:importFromRepo",detectLanguages:"course:detectLanguages",getCourseLanguages:"course:getLanguages",setCourseLanguage:"course:setLanguage",getCourseLanguage:"course:getLanguage",analyzeRepo:"course:analyzeRepo",importAnalyzed:"course:importAnalyzed",importLocalFolder:"import:localFolder",importGithub:"import:github",importUrl:"import:url",importText:"import:text",importEpub:"import:epub",importAudio:"import:audio",importCancel:"import:cancel",importResume:"import:resume",importPack:"import:importPack",exportPack:"import:exportPack",generateCourseFromMarkdown:"course:generateFromMarkdown",deleteCourse:"course:delete",restructureCourse:"course:restructure",generateSummaries:"course:generateSummaries",getStarterPrompts:"course:getStarterPrompts",getNodeContent:"course:getNodeContent",getNodeSummary:"course:getNodeSummary",getPracticeForLesson:"course:getPracticeForLesson",getLessonForPractice:"course:getLessonForPractice",listAssetsByNode:"asset:listByNode",listAssetsByCourse:"asset:listByCourse",getAssetDataUrl:"asset:getDataUrl",repairMermaidDiagram:"artifact:repairMermaid",getProgress:"progress:get",updateProgress:"progress:update",markNodeAttempted:"progress:markAttempted",generateExercise:"exercise:generate",listExercises:"exercise:list",submitExerciseAnswer:"exercise:submit",examPrepare:"exam:prepare",examRegenerate:"exam:regenerate",examGetStatus:"exam:getStatus",examStartAttempt:"exam:startAttempt",examRecordAnswer:"exam:recordAnswer",examSubmitAttempt:"exam:submitAttempt",getDueReviews:"srs:getDue",getAllSrsItems:"srs:getAll",recordReview:"srs:record",getStreak:"streak:get",touchStreakToday:"streak:touchToday",listSouls:"soul:list",getSoul:"soul:get",createSoul:"soul:create",setActiveSoul:"soul:setActive",getActiveSoul:"soul:getActive",agentChat:"agent:chat",abortAgentChat:"agent:abort",getChatHistory:"agent:getHistory",clearChatHistory:"agent:clearHistory",agentChatThread:"agent:chatThread",abortAgentChatThread:"agent:abortThread",getContextUsage:"agent:getContextUsage",getSpeechModelStatus:"speech:getModelStatus",ensureSpeechModel:"speech:ensureModel",deleteSpeechModel:"speech:deleteModel",ttsSpeak:"speech:ttsSpeak",ttsStop:"speech:ttsStop",asrTranscribe:"speech:asrTranscribe",testCustomTts:"speech:testCustomTts",testCustomAsr:"speech:testCustomAsr",getAttachmentDataUrl:"attachment:getDataUrl",isAgentReady:"agent:isReady",getProviderPresets:"agent:getProviderPresets",testLlmConnection:"agent:testConnection",testCustomProvider:"agent:testCustomProvider",discoverModels:"agent:discoverModels",discoverProviderModels:"agent:discoverProviderModels",listCustomProviders:"customProvider:list",createCustomProvider:"customProvider:create",updateCustomProvider:"customProvider:update",deleteCustomProvider:"customProvider:delete",listPendingProposals:"proposal:listPending",applyProposal:"proposal:apply",rejectProposal:"proposal:reject",recordQuizAnswer:"quiz:recordAnswer",logFriction:"friction:log",getDashboard:"dashboard:get",searchContent:"search:content",updateMemory:"memory:update",getMemory:"memory:get",consolidateMemory:"consolidate:run",getSetting:"settings:get",setSetting:"settings:set",companionPetSetClickThrough:"companionPet:setClickThrough",dshImportDetect:"dsh:detect",dshImportFromPath:"dsh:importFromPath",dshImportFromText:"dsh:importFromText",companionPackCutFromImage:"companionPack:cutFromImage",companionPackApplyPack:"companionPack:applyPack",companionPackGetActive:"companionPack:getActive",companionPackList:"companionPack:list",companionPackActivate:"companionPack:activate",companionPackDelete:"companionPack:delete",companionPackSetVehicle:"companionPack:setVehicle",getXpStatus:"xp:getStatus",exportCourse:"course:export",canvasList:"canvas:list",canvasSave:"canvas:save",canvasDelete:"canvas:delete",canvasTogglePin:"canvas:togglePin",canvasSaveUserNote:"canvas:saveUserNote",canvasRecordQuizResult:"canvas:recordQuizResult",canvasUpdateUserNoteComment:"canvas:updateUserNoteComment",threadList:"thread:list",threadCreate:"thread:create",threadUpdate:"thread:update",threadDelete:"thread:delete",threadGetMessages:"thread:getMessages",threadFindRecentByNode:"thread:findRecentByNode"},h=1,p="ls-serve-token";function S(){const o=new URLSearchParams(window.location.search).get("token");if(o){try{window.localStorage.setItem(p,o)}catch{}return o}try{return window.localStorage.getItem(p)??""}catch{return""}}class g{constructor(){m(this,"ws",null);m(this,"everOpened",!1);m(this,"pending",new Map);m(this,"listeners",new Map);m(this,"connectPromise",null)}connect(){return this.ws&&this.ws.readyState===WebSocket.OPEN?Promise.resolve(this.ws):this.connectPromise?this.connectPromise:(this.connectPromise=new Promise((e,t)=>{const c=window.location.protocol==="https:"?"wss:":"ws:",s=S(),a=`${c}//${window.location.host}/?token=${encodeURIComponent(s)}`;let i=!1;const d=new WebSocket(a);this.ws=d;const l=window.setTimeout(()=>{i||(i=!0,this.connectPromise=null,t(new Error("连接学习服务超时(serve 未启动?)")))},5e3);d.addEventListener("open",()=>{this.everOpened=!0,window.clearTimeout(l),i||(i=!0,this.connectPromise=null,e(d))}),d.addEventListener("message",u=>{let r=null;try{r=JSON.parse(String(u.data))}catch{return}if(!(!r||r.v!==h)){if(r.type==="res"){const n=this.pending.get(r.id);if(!n)return;this.pending.delete(r.id),window.clearTimeout(n.timer),r.ok?n.resolve(r.result):n.reject(new Error(r.error))}else if(r.type==="event"){const n=this.listeners.get(r.channel);if(n)for(const P of n)P(...r.args)}}}),d.addEventListener("close",u=>{if(this.connectPromise=null,this.ws===d&&(this.ws=null),!i){i=!0,window.clearTimeout(l),t(new Error(C(u)));return}const r=u.code===4001?"学习服务拒绝了连接(token 无效)——请用启动时打印的带 token 链接打开":"与服务端的连接已断开";for(const[,n]of this.pending)window.clearTimeout(n.timer),n.reject(new Error(r));if(u.code===4001&&(this.everOpened=!1),this.pending.clear(),u.code===4001){window.dispatchEvent(new CustomEvent(k));return}this.everOpened&&window.setTimeout(()=>void this.connect().catch(()=>{}),2e3)}),d.addEventListener("error",()=>{})}),this.connectPromise)}static bytesToB64(e){const t=new Uint8Array(e);let c="";const s=32768;for(let a=0;a<t.length;a+=s)c+=String.fromCharCode(...t.subarray(a,a+s));return btoa(c)}async invoke(e,...t){var a,i;const c=await this.connect(),s=((i=(a=globalThis.crypto)==null?void 0:a.randomUUID)==null?void 0:i.call(a))??String(Math.random()).slice(2);return new Promise((d,l)=>{const u=window.setTimeout(()=>{this.pending.delete(s),l(new Error(`调用 ${e} 超时`))},3e5);this.pending.set(s,{resolve:d,reject:l,timer:u});const r=e==="speech:asrTranscribe"&&t[0]instanceof ArrayBuffer?[g.bytesToB64(t[0]),...t.slice(1)]:t;c.send(JSON.stringify({v:h,type:"req",id:s,channel:e,args:r}))})}on(e,t){const c=e==="speech:ttsAudio"?(...a)=>{const i=a[0];if(i&&typeof i.wavBase64=="string"){const d=atob(i.wavBase64),l=new Uint8Array(d.length);for(let n=0;n<d.length;n++)l[n]=d.charCodeAt(n);const{wavBase64:u,...r}=i;t({...r,wavBytes:l.buffer})}else t(...a)}:t;let s=this.listeners.get(e);return s||(s=new Set,this.listeners.set(e,s)),s.add(c),this.connect().catch(()=>{}),()=>{s.delete(c)}}}function T(){if(typeof window>"u")return!1;if(new URLSearchParams(window.location.search).get("token"))return!0;try{return!!window.localStorage.getItem(p)}catch{return!1}}function b(o){try{window.localStorage.setItem(p,o)}catch{}const e=new URL(window.location.href);e.searchParams.set("token",o),window.location.replace(e.toString())}const k="ls-web-token-rejected";function C(o){return o.code===4001?"学习服务拒绝了连接(token 无效)——请用启动时打印的带 token 链接打开":"无法连接学习服务(serve 未启动?)"}let w=!1;async function x(){if(w||window.api)return;w=!0;const o=new g,e={};for(const[t,c]of Object.entries(y))e[t]=(...s)=>o.invoke(c,...s);e.on=(t,c)=>o.on(t,c),window.api=e,window.__lookatstudyWeb=!0}function E(){return new g}export{k as TOKEN_REJECTED_EVENT,E as createWebTransportForTest,T as hasWebToken,x as installWebApi,b as setWebToken};
@@ -1 +0,0 @@
1
- import{U as a,C as n}from"./mermaid.core-CkjogKiM.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as t,C as e}from"./chunk-X5GNSKZ3-Dchniejs.js";import{_ as i}from"./render-O7CIS3YK-lZh9RHoM.js";import"./transform-Bd_a5eGM.js";import"./chunk-LV3HUYFY-Bk9nvQV-.js";import"./chunk-CXNFBKHE-Dol1xkx9.js";import"./chunk-NDIOYS4C-DGwQ1S-J.js";import"./chunk-ISA7TJRJ-xSTEZzVx.js";import"./mermaid-layout-elk.core-CicnJpM7.js";import"./main-DrJVBtna.js";import"./index-3R9G44mo.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";var g={parser:t,get db(){return new e},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{g as diagram};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as e,C as t}from"./chunk-TICWLB2K-FxWFH9Jf.js";import{_ as i}from"./mermaid.core-CkjogKiM.js";import"./transform-Bd_a5eGM.js";import"./chunk-5VM5RSS4-DwCCLy6d.js";import"./chunk-XXDRQBXY-mXFfWdd4.js";import"./chunk-POPQ4Y6H-C0Zgm0cx.js";import"./chunk-F27PBJKO-CCKF34J6.js";import"./main-DrJVBtna.js";import"./index-3R9G44mo.js";var b={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{b as diagram};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as t,C as e}from"./chunk-X5GNSKZ3-Dchniejs.js";import{_ as i}from"./render-O7CIS3YK-lZh9RHoM.js";import"./transform-Bd_a5eGM.js";import"./chunk-LV3HUYFY-Bk9nvQV-.js";import"./chunk-CXNFBKHE-Dol1xkx9.js";import"./chunk-NDIOYS4C-DGwQ1S-J.js";import"./chunk-ISA7TJRJ-xSTEZzVx.js";import"./mermaid-layout-elk.core-CicnJpM7.js";import"./main-DrJVBtna.js";import"./index-3R9G44mo.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";var g={parser:t,get db(){return new e},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{g as diagram};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as e,C as t}from"./chunk-TICWLB2K-FxWFH9Jf.js";import{_ as i}from"./mermaid.core-CkjogKiM.js";import"./transform-Bd_a5eGM.js";import"./chunk-5VM5RSS4-DwCCLy6d.js";import"./chunk-XXDRQBXY-mXFfWdd4.js";import"./chunk-POPQ4Y6H-C0Zgm0cx.js";import"./chunk-F27PBJKO-CCKF34J6.js";import"./main-DrJVBtna.js";import"./index-3R9G44mo.js";var b={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{b as diagram};