lookatstudy-mobile 0.38.0 → 0.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/package.json +1 -1
  2. package/server.cjs +1 -1
  3. package/web/assets/{CanvasStage-vallbGco.js → CanvasStage-BjmEt0UY.js} +1 -1
  4. package/web/assets/{CommandPalette-Kyu6mhyt.js → CommandPalette-DTNMFUea.js} +1 -1
  5. package/web/assets/{CourseSearchPanel-CrpFIaU8.js → CourseSearchPanel-Dh3wEDsH.js} +1 -1
  6. package/web/assets/{ExamView-BBwDRS1g.js → ExamView-Ce_t9n9N.js} +1 -1
  7. package/web/assets/{MermaidArtifact-x5kLLb52.js → MermaidArtifact-CyXaq4AR.js} +3 -3
  8. package/web/assets/{ModelManagerModal-CHz1i5v2.js → ModelManagerModal-C0b-oOcn.js} +1 -1
  9. package/web/assets/{PersonalProfileModal-DJdHOMH9.js → PersonalProfileModal-CCUuVq38.js} +1 -1
  10. package/web/assets/{ReviewPanel-BJhoJAOK.js → ReviewPanel-N-e3bkWC.js} +1 -1
  11. package/web/assets/{SettingsView-COw_GSOo.js → SettingsView-CZWKuAOS.js} +2 -2
  12. package/web/assets/{Toggle-Bkokw_WS.js → Toggle-fMmuR4RN.js} +1 -1
  13. package/web/assets/{VoicePanel-DPrlBZ48.js → VoicePanel-BhZjkbBn.js} +1 -1
  14. package/web/assets/{abnfDiagram-VCTEODGH-DXAHXtdM.js → abnfDiagram-VCTEODGH-DJZ92IQG.js} +1 -1
  15. package/web/assets/{abnfDiagram-VCTEODGH-ODA7YWAP-BdHlSP1w.js → abnfDiagram-VCTEODGH-ODA7YWAP-CnOz9_ts.js} +1 -1
  16. package/web/assets/{architectureDiagram-5GKGNRK7-C4PU3XN7-B4RCVI81.js → architectureDiagram-5GKGNRK7-C4PU3XN7-Up7UX1_6.js} +1 -1
  17. package/web/assets/{architectureDiagram-5GKGNRK7-DViQRgRS.js → architectureDiagram-5GKGNRK7-DDFiDp0N.js} +1 -1
  18. package/web/assets/{blockDiagram-I7D4REHJ-Bm4Jv7XO.js → blockDiagram-I7D4REHJ-CvG84uPF.js} +1 -1
  19. package/web/assets/{blockDiagram-NRAW4CY4-UMJ6PMQQ-dOUZFc-F.js → blockDiagram-NRAW4CY4-UMJ6PMQQ-ByS9GD6j.js} +1 -1
  20. package/web/assets/{c4Diagram-7LVT6UL2-Cn_bbm4P.js → c4Diagram-7LVT6UL2-Z4oqjV_s.js} +1 -1
  21. package/web/assets/{c4Diagram-UCG6FXSJ-75X3U2P3-DgytixUD.js → c4Diagram-UCG6FXSJ-75X3U2P3-JqYGaud4.js} +1 -1
  22. package/web/assets/channel-BVgQi2SB.js +1 -0
  23. package/web/assets/{chunk-2Q5K7J3B-hNQuZg4_.js → chunk-2Q5K7J3B-Bk7vR2OO.js} +1 -1
  24. package/web/assets/{chunk-5VM5RSS4-DwAMOseZ.js → chunk-5VM5RSS4-CWyB6Ag5.js} +1 -1
  25. package/web/assets/{chunk-7XDTSPCN-COFFwjaS.js → chunk-7XDTSPCN-D6Yc_Buh.js} +1 -1
  26. package/web/assets/{chunk-CTNIYPP6-B3zyRQW8.js → chunk-CTNIYPP6-Bkfc0YPS.js} +1 -1
  27. package/web/assets/{chunk-CXNFBKHE-C91q6lvg.js → chunk-CXNFBKHE-DlVSTamJ.js} +1 -1
  28. package/web/assets/{chunk-F27PBJKO-ia4EagnF.js → chunk-F27PBJKO-BVcD43e_.js} +1 -1
  29. package/web/assets/{chunk-IMKFNOWR-vd22BhM5.js → chunk-IMKFNOWR-Zxym8xKJ.js} +1 -1
  30. package/web/assets/{chunk-ISA7TJRJ-BReqmCMw.js → chunk-ISA7TJRJ-qHFg5Itc.js} +1 -1
  31. package/web/assets/{chunk-JWPE2WC7-Cjsal04r.js → chunk-JWPE2WC7-DdTAe5_k.js} +1 -1
  32. package/web/assets/{chunk-LV3HUYFY-D2A9VNi8.js → chunk-LV3HUYFY-ChgpGbar.js} +1 -1
  33. package/web/assets/{chunk-M3IUQBOH-DZWUYlu1.js → chunk-M3IUQBOH-CtheRxQX.js} +1 -1
  34. package/web/assets/{chunk-NDIOYS4C-Cg_gB3IQ.js → chunk-NDIOYS4C-B27IOxo1.js} +1 -1
  35. package/web/assets/{chunk-POPQ4Y6H-CpFBYm4R.js → chunk-POPQ4Y6H-_s5H9Hu1.js} +1 -1
  36. package/web/assets/{chunk-RE4WF27V-DJhALSJZ.js → chunk-RE4WF27V-uEsraMf5.js} +1 -1
  37. package/web/assets/{chunk-SVP7TREG-CLk3nYlu.js → chunk-SVP7TREG-S8N2_Tii.js} +1 -1
  38. package/web/assets/{chunk-TICWLB2K-CAAm7rEI.js → chunk-TICWLB2K-DxCRITn1.js} +1 -1
  39. package/web/assets/{chunk-VII2H2IX-D9ZFtXPz.js → chunk-VII2H2IX-qahGaA3g.js} +1 -1
  40. package/web/assets/{chunk-X5GNSKZ3-BRpQXOuk.js → chunk-X5GNSKZ3-CRsLzrmL.js} +1 -1
  41. package/web/assets/{chunk-XCWWM2C3-CGZOunzF.js → chunk-XCWWM2C3-gAY--_6y.js} +1 -1
  42. package/web/assets/{chunk-XXDRQBXY-IwMJhHxA.js → chunk-XXDRQBXY-Dlodiy7w.js} +1 -1
  43. package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-BfnNr1df.js +1 -0
  44. package/web/assets/classDiagram-ZZMXUADV-A7yMYr-v.js +1 -0
  45. package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-BfnNr1df.js +1 -0
  46. package/web/assets/classDiagram-v2-VYDZK3BY-A7yMYr-v.js +1 -0
  47. package/web/assets/{core-KfkXlXB0.js → core-Ctwl1_u6.js} +1 -1
  48. package/web/assets/{cose-bilkent-JH36ORCC-CvvDvDJy.js → cose-bilkent-JH36ORCC-CPuRsyhX.js} +1 -1
  49. package/web/assets/{cose-bilkent-JH36ORCC-OB24KH3T-C0vuvt-a.js → cose-bilkent-JH36ORCC-OB24KH3T-DEty9Vjh.js} +1 -1
  50. package/web/assets/{cynefin-OW5HDTMX-BnU7sKRp.js → cynefin-OW5HDTMX-BkB-LB8l.js} +1 -1
  51. package/web/assets/{cynefin-OW5HDTMX-GVF3BKWE-C0Fp61PQ.js → cynefin-OW5HDTMX-GVF3BKWE-D0wGTJgs.js} +1 -1
  52. package/web/assets/{cynefinDiagram-5FMLGOSQ-Ci7ijXRa.js → cynefinDiagram-5FMLGOSQ-DNV9WdAS.js} +1 -1
  53. package/web/assets/{cynefinDiagram-5FMLGOSQ-H3WIRU3N-BG1dQkD8.js → cynefinDiagram-5FMLGOSQ-H3WIRU3N-D3Ij3Tc1.js} +1 -1
  54. package/web/assets/{dagre-3AP2YEHR-DCERTXHT-SRdJ45ZG.js → dagre-3AP2YEHR-DCERTXHT-DtOlsda2.js} +1 -1
  55. package/web/assets/{dagre-GXQ25YYZ-a6zLLMCL.js → dagre-GXQ25YYZ-B0krUCV-.js} +1 -1
  56. package/web/assets/{diagram-S7CK7UJ4-DwGQoHs5.js → diagram-S7CK7UJ4-CJPq3UX3.js} +1 -1
  57. package/web/assets/{diagram-S7CK7UJ4-MULGZGEL-DFbcMEGe.js → diagram-S7CK7UJ4-MULGZGEL--apiqMq_.js} +1 -1
  58. package/web/assets/{diagram-UQ7AKVKN-DObuhRvP.js → diagram-UQ7AKVKN-DN2fvIcQ.js} +1 -1
  59. package/web/assets/{diagram-UQ7AKVKN-YQBY353J-f7iJnEEP.js → diagram-UQ7AKVKN-YQBY353J-Dedl3cQE.js} +1 -1
  60. package/web/assets/{diagram-VSXAHHWV-Ctso7LL9.js → diagram-VSXAHHWV-B_3615az.js} +1 -1
  61. package/web/assets/{diagram-VSXAHHWV-WLNH2ELY-DwsW9ccQ.js → diagram-VSXAHHWV-WLNH2ELY-qPd_xBpx.js} +1 -1
  62. package/web/assets/{diagram-VX7I27RA-B1-W9xu6.js → diagram-VX7I27RA-BBdDfxTE.js} +1 -1
  63. package/web/assets/{diagram-VX7I27RA-XW6YQV5G-DckTcRvE.js → diagram-VX7I27RA-XW6YQV5G-2NQmjTWZ.js} +1 -1
  64. package/web/assets/{diagram-Z3DM3KII-CvmndeRP.js → diagram-Z3DM3KII-4-iFyExq.js} +1 -1
  65. package/web/assets/{diagram-Z3DM3KII-HG7RF65D-Cg1XNNOC.js → diagram-Z3DM3KII-HG7RF65D-BdtXesk5.js} +1 -1
  66. package/web/assets/{ebnfDiagram-PWID7BFC-Cs9GSL14.js → ebnfDiagram-PWID7BFC-DCkQga-4.js} +1 -1
  67. package/web/assets/{ebnfDiagram-PWID7BFC-OKY4VHYD-C0q6BGVW.js → ebnfDiagram-PWID7BFC-OKY4VHYD-BJhXk1ud.js} +1 -1
  68. package/web/assets/{erDiagram-RLTQ6QDP-CvYV5Bmu.js → erDiagram-RLTQ6QDP-Cr9QaJ1v.js} +1 -1
  69. package/web/assets/{erDiagram-SSCWMZ5O-PIPKOIK7-Di0McTkf.js → erDiagram-SSCWMZ5O-PIPKOIK7-CCpUhFOK.js} +1 -1
  70. package/web/assets/{flowDiagram-A5DVABFB-2Z4AVO5R-C_7fHJVS.js → flowDiagram-A5DVABFB-2Z4AVO5R-D9DlpmgO.js} +1 -1
  71. package/web/assets/{flowDiagram-HODETNUW-CEwpjqJR.js → flowDiagram-HODETNUW-Wol63Kv-.js} +1 -1
  72. package/web/assets/{ganttDiagram-EL5Y4UJY-Bjj2P85p.js → ganttDiagram-EL5Y4UJY-CrNG_cdW.js} +1 -1
  73. package/web/assets/{ganttDiagram-EL5Y4UJY-JZNG7GOG-BWxHKrFA.js → ganttDiagram-EL5Y4UJY-JZNG7GOG-DD6wgz29.js} +1 -1
  74. package/web/assets/{gitGraphDiagram-WWUBYQGX-DMWMLL3G-D4hn_rGb.js → gitGraphDiagram-WWUBYQGX-DMWMLL3G-DWe7BJRj.js} +1 -1
  75. package/web/assets/{gitGraphDiagram-WWUBYQGX-DhH7fsJW.js → gitGraphDiagram-WWUBYQGX-IMvPkTdS.js} +1 -1
  76. package/web/assets/index-B7WF2qJW.js +14 -0
  77. package/web/assets/{index-DcWGv1Ix.js → index-CIZh7RMQ.js} +1 -1
  78. package/web/assets/{index-nwyPdk23.js → index-T02kICsr.js} +1 -1
  79. package/web/assets/{infoDiagram-27XIBGKW-DDm2aahL.js → infoDiagram-27XIBGKW-BG6Y7L1i.js} +1 -1
  80. package/web/assets/{infoDiagram-RXCK75RN-HANS5KVC-CwBcehVD.js → infoDiagram-RXCK75RN-HANS5KVC-CQgucjmb.js} +1 -1
  81. package/web/assets/{ishikawaDiagram-5VMMS53U-7GCIT7WU-CBAcnlnt.js → ishikawaDiagram-5VMMS53U-7GCIT7WU-XjEpfVKy.js} +1 -1
  82. package/web/assets/{ishikawaDiagram-5VMMS53U-BViel9G3.js → ishikawaDiagram-5VMMS53U-DZqDGKJg.js} +1 -1
  83. package/web/assets/{journeyDiagram-3NMN7TZE-CO3lCO75.js → journeyDiagram-3NMN7TZE-CRs3_-1Y.js} +1 -1
  84. package/web/assets/{journeyDiagram-EYS64GPL-OAPELBT7-sBJrBBzK.js → journeyDiagram-EYS64GPL-OAPELBT7-Dw7bUcjI.js} +1 -1
  85. package/web/assets/{kanban-definition-3QL26DDD-I7RKWQQY-hit6oZsH.js → kanban-definition-3QL26DDD-I7RKWQQY-BUnF1mWS.js} +1 -1
  86. package/web/assets/{kanban-definition-UXKFOSKX-CKgCw87L.js → kanban-definition-UXKFOSKX-hGGkPiRw.js} +1 -1
  87. package/web/assets/{katex-N6JRN4PM-D81co42V.js → katex-N6JRN4PM-C6a-kx0O.js} +1 -1
  88. package/web/assets/{layout-Gnf9u57J.js → layout-BUbLYu8b.js} +1 -1
  89. package/web/assets/{main-C7vIrKEC.js → main-Bwe-ngM3.js} +6 -6
  90. package/web/assets/{mermaid-layout-elk.core-DfOj66Qv.js → mermaid-layout-elk.core-B4Ud-kMJ.js} +2 -2
  91. package/web/assets/{mermaid.core-B8uFE6gu.js → mermaid.core-DfcXYaBE.js} +5 -5
  92. package/web/assets/{mindmap-definition-FBJOCRG2-KIYZG64Y-DdU7WsWK.js → mindmap-definition-FBJOCRG2-KIYZG64Y-Bj-zHJUj.js} +1 -1
  93. package/web/assets/{mindmap-definition-YA3MSWOX-Dlr3j6bz.js → mindmap-definition-YA3MSWOX-6CCGXEnY.js} +1 -1
  94. package/web/assets/{pegDiagram-XKGWAZYB-DUukoOjY.js → pegDiagram-XKGWAZYB-CMNrdc9G.js} +1 -1
  95. package/web/assets/{pegDiagram-XKGWAZYB-OIP57N6J-ClyIfOjy.js → pegDiagram-XKGWAZYB-OIP57N6J-nEVXV8wL.js} +1 -1
  96. package/web/assets/{pieDiagram-E7YTZNPT-2UOTW327-CXr_-LKy.js → pieDiagram-E7YTZNPT-2UOTW327-CVTkOJWh.js} +1 -1
  97. package/web/assets/{pieDiagram-E7YTZNPT-BoX73GVV.js → pieDiagram-E7YTZNPT-D5EMeJ7m.js} +1 -1
  98. package/web/assets/{quadrantDiagram-AXDQQJYC-fWVY4hSA.js → quadrantDiagram-AXDQQJYC-DzCvG7yn.js} +1 -1
  99. package/web/assets/{quadrantDiagram-AXDQQJYC-SN3ASJJK-BfJPVLX8.js → quadrantDiagram-AXDQQJYC-SN3ASJJK-C6_UC8pF.js} +1 -1
  100. package/web/assets/{railroadDiagram-O6MQD6OU-34742W6X-LEvRYv_-.js → railroadDiagram-O6MQD6OU-34742W6X-no51XOTx.js} +1 -1
  101. package/web/assets/{railroadDiagram-O6MQD6OU-BtJHgxH_.js → railroadDiagram-O6MQD6OU-Dm_fovg0.js} +1 -1
  102. package/web/assets/{render-O7CIS3YK-DU3B_ERD.js → render-O7CIS3YK-BjDBnwGB.js} +7 -7
  103. package/web/assets/{requirementDiagram-BXWQKSXE-DeBI9tYJ.js → requirementDiagram-BXWQKSXE-BfDo8qe9.js} +1 -1
  104. package/web/assets/{requirementDiagram-EFPCY7ZU-NGAFFSMB-DDu5KaVc.js → requirementDiagram-EFPCY7ZU-NGAFFSMB-9m84sd56.js} +1 -1
  105. package/web/assets/{rotate-ccw-DHjeGlQd.js → rotate-ccw-DjLv5683.js} +1 -1
  106. package/web/assets/{sankeyDiagram-P5KCCOFB-3D3M4XPB-CuAwPvR9.js → sankeyDiagram-P5KCCOFB-3D3M4XPB-CTdzZoDY.js} +1 -1
  107. package/web/assets/{sankeyDiagram-P5KCCOFB-Cn7EgJJg.js → sankeyDiagram-P5KCCOFB-B4ZNqFX0.js} +1 -1
  108. package/web/assets/{sequenceDiagram-WJ2MYXX4-Cc4unhAQ.js → sequenceDiagram-WJ2MYXX4-CE8SOZmY.js} +1 -1
  109. package/web/assets/{sequenceDiagram-WJ2MYXX4-Q2IOPB4R-Bhw9XiPP.js → sequenceDiagram-WJ2MYXX4-Q2IOPB4R-D0hSM0Rf.js} +1 -1
  110. package/web/assets/{sizeCapture-INFHLROL-D5ATuvis.js → sizeCapture-INFHLROL-BoK_snCd.js} +1 -1
  111. package/web/assets/{sizeCapture-X5ZJPWSS-PSGVOMYM-pk47pQ9r.js → sizeCapture-X5ZJPWSS-PSGVOMYM-DHFL989w.js} +1 -1
  112. package/web/assets/{stateDiagram-D77RDMKH-CQSVKJos.js → stateDiagram-D77RDMKH-DewCbTYT.js} +1 -1
  113. package/web/assets/{stateDiagram-HBIQ2CUA-4M2S6MAN-CtK20myG.js → stateDiagram-HBIQ2CUA-4M2S6MAN-1Iq-0t_T.js} +1 -1
  114. package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-BtlmMFv0.js +1 -0
  115. package/web/assets/stateDiagram-v2-MP3YSRHH-B81KSXVj.js +1 -0
  116. package/web/assets/{swimlanes-42K2YHIH-C_TtTWTU.js → swimlanes-42K2YHIH-B_ZemasQ.js} +1 -1
  117. package/web/assets/{swimlanes-XN3QIQJK-N6N2CCQ6-BcUMswQj.js → swimlanes-XN3QIQJK-N6N2CCQ6-D7IZVohV.js} +1 -1
  118. package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-wm4Xp0xX.js +8 -0
  119. package/web/assets/swimlanesDiagram-VR7AAH4N-Dqjnb-t1.js +8 -0
  120. package/web/assets/{timeline-definition-24CTP7MA-DUWrxPBR.js → timeline-definition-24CTP7MA-Dl-MZgJm.js} +1 -1
  121. package/web/assets/{timeline-definition-24CTP7MA-KN7RSRVM-guNGP5k9.js → timeline-definition-24CTP7MA-KN7RSRVM-DKGhla1L.js} +1 -1
  122. package/web/assets/{vennDiagram-4TSXK5OY-AKJ7LXAN-CqrpJGZz.js → vennDiagram-4TSXK5OY-AKJ7LXAN-DJGD_zp2.js} +1 -1
  123. package/web/assets/{vennDiagram-4TSXK5OY-DpAMU-X3.js → vennDiagram-4TSXK5OY-BNIMMkc8.js} +1 -1
  124. package/web/assets/{wardleyDiagram-VM6X3IG4-3B6A3BN5-CvLFmNdB.js → wardleyDiagram-VM6X3IG4-3B6A3BN5-BWY4hoNl.js} +1 -1
  125. package/web/assets/{wardleyDiagram-VM6X3IG4-CwLky2tH.js → wardleyDiagram-VM6X3IG4-C5iQnCkI.js} +1 -1
  126. package/web/assets/{xychartDiagram-S5SC5T6Z-C0uS7jlH.js → xychartDiagram-S5SC5T6Z-KRAufNo2.js} +1 -1
  127. package/web/assets/{xychartDiagram-S5SC5T6Z-OBDNV6WG-DUua3NqS.js → xychartDiagram-S5SC5T6Z-OBDNV6WG-Bw4UIStv.js} +1 -1
  128. package/web/index.html +1 -1
  129. package/web/assets/channel-D_-re5YU.js +0 -1
  130. package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-DsXVuA3q.js +0 -1
  131. package/web/assets/classDiagram-ZZMXUADV-mIT3v2vU.js +0 -1
  132. package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-DsXVuA3q.js +0 -1
  133. package/web/assets/classDiagram-v2-VYDZK3BY-mIT3v2vU.js +0 -1
  134. package/web/assets/index-eHVYJyBS.js +0 -14
  135. package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-z3Zfnb5n.js +0 -1
  136. package/web/assets/stateDiagram-v2-MP3YSRHH-BEw4hFwV.js +0 -1
  137. package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-D6SdGCA2.js +0 -8
  138. package/web/assets/swimlanesDiagram-VR7AAH4N-BCgYwpZp.js +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lookatstudy-mobile",
3
- "version": "0.38.0",
3
+ "version": "0.38.1",
4
4
  "description": "LookatStudy Termux portable bundle (server.cjs + web frontend)",
5
5
  "repository": {
6
6
  "type": "git",
package/server.cjs CHANGED
@@ -527707,7 +527707,7 @@ init_drizzle_orm();
527707
527707
  var import_node_crypto26 = require("node:crypto");
527708
527708
 
527709
527709
  // package.json
527710
- var version2 = "0.38.0";
527710
+ var version2 = "0.38.1";
527711
527711
 
527712
527712
  // src/main/lib/update-check.ts
527713
527713
  var RELEASES_PAGE = "https://github.com/Kaiji-Z/LookatStudy/releases";
@@ -1,4 +1,4 @@
1
- import{r,j as h}from"./index-jKxnKPxh.js";import{c as T,u as L,t as D}from"./main-C7vIrKEC.js";/**
1
+ import{r,j as h}from"./index-jKxnKPxh.js";import{c as T,u as L,t as D}from"./main-Bwe-ngM3.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{r as s,j as t}from"./index-jKxnKPxh.js";import{c as y,u as v,d as k,L as j,F as N,M as w,G as C,T as M,e as _}from"./main-C7vIrKEC.js";/**
1
+ import{r as s,j as t}from"./index-jKxnKPxh.js";import{c as y,u as v,d as k,L as j,F as N,M as w,G as C,T as M,e as _}from"./main-Bwe-ngM3.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{r as u,j as t}from"./index-jKxnKPxh.js";import{c as I,U as C,u as y,a as L,e as S,X as N,B as M,T as E,h as R}from"./main-C7vIrKEC.js";/**
1
+ import{r as u,j as t}from"./index-jKxnKPxh.js";import{c as I,U as C,u as y,a as L,e as S,X as N,B as M,T as E,h as R}from"./main-Bwe-ngM3.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{r as o,h as U,j as e,c as ie}from"./index-jKxnKPxh.js";import{c as te,u as ce,a as j,n as de,T as z,q as Y,A as q,L as V,r as oe,X as xe}from"./main-C7vIrKEC.js";import{R as G}from"./rotate-ccw-DHjeGlQd.js";/**
1
+ import{r as o,h as U,j as e,c as ie}from"./index-jKxnKPxh.js";import{c as te,u as ce,a as j,n as de,T as z,q as Y,A as q,L as V,r as oe,X as xe}from"./main-Bwe-ngM3.js";import{R as G}from"./rotate-ccw-DjLv5683.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,9 +1,9 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-B8uFE6gu.js","./main-C7vIrKEC.js","./index-jKxnKPxh.js","./index-CS4Wtfwl.css","./main-D9IB7N5p.css","./transform-Bd_a5eGM.js","./mermaid-layout-elk.core-DfOj66Qv.js"])))=>i.map(i=>d[i]);
2
- import{r as o,j as t}from"./index-jKxnKPxh.js";import{c as K,_ as B,u as O,d as H,D as U,X,E as L}from"./main-C7vIrKEC.js";import{M as Y,C as G}from"./CanvasStage-vallbGco.js";/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-DfcXYaBE.js","./main-Bwe-ngM3.js","./index-jKxnKPxh.js","./index-CS4Wtfwl.css","./main-D9IB7N5p.css","./transform-Bd_a5eGM.js","./mermaid-layout-elk.core-B4Ud-kMJ.js"])))=>i.map(i=>d[i]);
2
+ import{r as o,j as t}from"./index-jKxnKPxh.js";import{c as K,_ as B,u as O,d as H,D as U,X,E as L}from"./main-Bwe-ngM3.js";import{M as Y,C as G}from"./CanvasStage-BjmEt0UY.js";/**
3
3
  * @license lucide-react v0.468.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
6
6
  * See the LICENSE file in the root directory of this source tree.
7
7
  */const J=K("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);function Q(e){const i=e.split(`
8
8
  `);for(let r=0;r<i.length;r++){const a=i[r]??"",s=a.trim();if(!(!s||s.startsWith("%%")))return/^flowchart-elk\b/i.test(s)?e:/^(flowchart|graph)\b/i.test(s)?(i[r]=a.replace(/^(\s*)(flowchart|graph)\b/i,"$1flowchart-elk"),i.join(`
9
- `)):e}return e}let p=null;function ee(){return p||(p=B(()=>import("./mermaid.core-B8uFE6gu.js").then(e=>e.bI),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(async e=>{const i=e.default,{default:r}=await B(async()=>{const{default:a}=await import("./mermaid-layout-elk.core-DfOj66Qv.js").then(s=>s.m);return{default:a}},__vite__mapDeps([6,1,2,3,4]),import.meta.url);return i.registerLayoutLoaders(r),i.initialize({startOnLoad:!1,theme:"base",securityLevel:"strict",themeVariables:te(),flowchart:{useMaxWidth:!0,htmlLabels:!0,curve:"basis",nodeSpacing:42,rankSpacing:54,padding:10},sequence:{useMaxWidth:!0,boxMargin:8,noteMargin:8,messageMargin:32}}),i})),p}function te(){const e=(r,a)=>{if(typeof document>"u")return a;const s=getComputedStyle(document.documentElement).getPropertyValue(r).trim();return s?`rgb(${s})`:a};return{background:"transparent",fontFamily:typeof document<"u"&&getComputedStyle(document.body).fontFamily||"ui-sans-serif, system-ui, sans-serif",fontSize:"14px",primaryColor:e("--surface-3-rgb","rgb(42 43 46)"),primaryBorderColor:e("--border-rgb","rgb(37 38 41)"),primaryTextColor:e("--ink-strong-rgb","rgb(250 250 250)"),secondaryColor:e("--surface-2-rgb","rgb(32 33 36)"),secondaryBorderColor:e("--border-faint-rgb","rgb(26 26 29)"),secondaryTextColor:e("--ink-rgb","rgb(245 245 250)"),tertiaryColor:e("--surface-1-rgb","rgb(24 25 27)"),tertiaryBorderColor:e("--border-faint-rgb","rgb(26 26 29)"),tertiaryTextColor:e("--ink-rgb","rgb(245 245 250)"),lineColor:e("--ink-faint-rgb","rgb(117 117 126)"),textColor:e("--ink-rgb","rgb(245 245 250)"),edgeLabelBackground:e("--surface-0-rgb","rgb(12 13 15)"),clusterBkg:e("--surface-1-rgb","rgb(24 25 27)"),clusterBorder:e("--border-faint-rgb","rgb(26 26 29)"),nodeBorder:e("--border-rgb","rgb(37 38 41)"),mainBkg:e("--surface-3-rgb","rgb(42 43 46)"),nodeTextColor:e("--ink-rgb","rgb(245 245 250)"),arrowheadColor:e("--ink-faint-rgb","rgb(117 117 126)"),actorBkg:e("--surface-3-rgb","rgb(42 43 46)"),actorBorder:e("--border-rgb","rgb(37 38 41)"),actorTextColor:e("--ink-strong-rgb","rgb(250 250 250)"),activationBkgColor:e("--surface-3-rgb","rgb(42 43 46)"),activationBorderColor:e("--border-rgb","rgb(37 38 41)"),signalColor:e("--ink-rgb","rgb(245 245 250)"),signalTextColor:e("--ink-rgb","rgb(245 245 250)"),labelBoxBkgColor:e("--surface-2-rgb","rgb(32 33 36)"),labelBoxBorderColor:e("--border-rgb","rgb(37 38 41)"),labelTextColor:e("--ink-rgb","rgb(245 245 250)"),loopTextColor:e("--ink-strong-rgb","rgb(250 250 250)"),noteBkgColor:"rgb(255 200 0 / 0.12)",noteBorderColor:"rgb(255 200 0 / 0.4)",noteTextColor:e("--ink-rgb","rgb(245 245 250)")}}typeof window<"u"&&window.addEventListener("theme-changed",()=>{p=null});async function re(e,i){const r=await ee(),a=Q(i);try{await r.parse(a)}catch(c){throw new Error(`mermaid 语法校验失败: ${c instanceof Error?c.message:String(c)}`)}const{svg:s}=await r.render(e,a);if(s.includes('aria-roledescription="error"')||s.includes('class="error-text"')||s.includes("Syntax error"))throw new Error("mermaid 渲染失败(语法错误或节点 label 含未转义特殊字符)");return s}function ae({title:e,onClose:i,children:r}){const a=O(),s=o.useRef(null);return H(s,!0),o.useEffect(()=>{const c=d=>{d.key==="Escape"&&i()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[i]),U.createPortal(t.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/80","data-testid":"diagram-viewer-modal","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":e,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 shrink-0",onClick:c=>c.stopPropagation(),children:[t.jsx("h3",{className:"text-body font-bold text-white truncate",children:e}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[t.jsx("span",{className:"text-caption text-white/50 hidden sm:inline",children:a("artifact.viewer.hint")}),t.jsx("button",{onClick:i,"data-testid":"diagram-viewer-close","aria-label":a("action.close"),"data-tooltip":a("action.close"),className:"text-white/70 hover:text-white w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white/10 transition-colors",children:t.jsx(X,{className:"w-5 h-5"})})]})]}),t.jsx("div",{className:"flex-1 min-h-0 px-2 pb-2",onClick:i,children:t.jsx("div",{ref:s,className:"h-full w-full",onClick:c=>c.stopPropagation(),children:r})})]}),document.body)}function z(e){let i=5381;for(let r=0;r<e.length;r++)i=(i<<5)+i+e.charCodeAt(r)>>>0;return i.toString(36)}const v=.3,k=3,x=.2;function I({data:e,variant:i="card"}){const r=e,a=O(),s={flowchart:a("artifact.diagram.flowchart"),sequence:a("artifact.diagram.sequence"),state:a("artifact.diagram.state")},c=o.useId().replace(/[:]/g,"_"),[d,w]=o.useState({status:"loading"}),[u,A]=o.useState(()=>{try{return sessionStorage.getItem(`mmdfix:${r.mermaid.length}:${z(r.mermaid)}`)??r.mermaid}catch{return r.mermaid}}),[j,P]=o.useState(!1),[C,N]=o.useState(!1),[R,$]=o.useState(0);o.useEffect(()=>{const n=()=>$(l=>l+1);return window.addEventListener("theme-changed",n),()=>window.removeEventListener("theme-changed",n)},[]);const[m,M]=o.useState(null),[g,b]=o.useState(1),[F,y]=o.useState(!1);o.useEffect(()=>{let n=!1;return w({status:"loading"}),M(null),re(`mmd-${c}`,u).then(l=>{if(!n&&(w({status:"rendered",svg:l}),u!==r.mermaid))try{sessionStorage.setItem(`mmdfix:${r.mermaid.length}:${z(r.mermaid)}`,u)}catch{}}).catch(l=>{n||(console.error("[MermaidArtifact] render failed:",l),w({status:"error",message:l instanceof Error?l.message:String(l)}))}),()=>{n=!0}},[u,c,R,r.mermaid]),o.useEffect(()=>{var n;d.status!=="error"||j||(P(!0),u===r.mermaid&&(n=window.api)!=null&&n.repairMermaidDiagram&&(N(!0),window.api.repairMermaidDiagram({mermaid:u,errorMessage:d.message,diagramType:r.diagramType}).then(l=>{l.ok&&l.mermaid.trim()&&A(l.mermaid)}).catch(()=>{}).finally(()=>N(!1))))},[d,j,u,r.mermaid,r.diagramType]);const D=`https://mermaid.live/edit#${encodeURIComponent(u)}`,V=o.useCallback(()=>b(n=>Math.min(k,+(n+x).toFixed(2))),[]),W=o.useCallback(()=>b(n=>Math.max(v,+(n-x).toFixed(2))),[]),q=o.useCallback(()=>b(1),[]),Z=o.useCallback(n=>{if(!n.ctrlKey&&!n.metaKey)return;n.preventDefault();const l=n.deltaY>0?-x:x;b(h=>Math.min(k,Math.max(v,+(h+l).toFixed(2))))},[]),E=d.status==="rendered"?t.jsx("div",{ref:n=>{var l;if(n&&!m){const h=n.querySelector("svg");if(h){const S=h.getBoundingClientRect(),f=(l=h.viewBox)==null?void 0:l.baseVal,T=f&&f.width?f.width:S.width,_=f&&f.height?f.height:S.height;T>0&&_>0&&M({width:T,height:_})}}},style:{width:(m==null?void 0:m.width)??void 0,height:(m==null?void 0:m.height)??void 0},dangerouslySetInnerHTML:{__html:d.svg},"data-testid":"mermaid-svg"}):null;return i==="canvas"?t.jsx("div",{"data-testid":"mermaid-canvas-content",children:E}):t.jsxs("div",{className:"surface-card p-4","data-testid":"artifact-mermaid",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3 gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.jsx(J,{className:"w-4 h-4 text-ink-muted shrink-0"}),t.jsx("h3",{className:"text-body font-bold text-ink truncate",children:r.title}),t.jsx("span",{className:"text-caption font-bold px-1.5 py-0.5 rounded bg-accent/15 text-accent shrink-0",children:s[r.diagramType]??r.diagramType})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[d.status==="rendered"&&t.jsxs("div",{className:"flex items-center gap-1","data-testid":"mermaid-zoom-controls",children:[t.jsx("button",{onClick:W,disabled:g<=v,className:"w-6 h-6 rounded border border-[var(--border)] text-ink-muted hover:bg-surface-1 hover:bg-surface-3 disabled:opacity-30 text-label font-bold flex items-center justify-center",title:a("artifact.zoomOut"),"data-testid":"mermaid-zoom-out",children:"−"}),t.jsxs("button",{onClick:q,className:"px-1.5 h-6 rounded border border-[var(--border)] text-ink-muted hover:bg-surface-1 hover:bg-surface-3 text-caption font-bold tabular-nums",title:a("artifact.zoomReset"),"data-testid":"mermaid-zoom-reset",children:[Math.round(g*100),"%"]}),t.jsx("button",{onClick:V,disabled:g>=k,className:"w-6 h-6 rounded border border-[var(--border)] text-ink-muted hover:bg-surface-1 hover:bg-surface-3 disabled:opacity-30 text-label font-bold flex items-center justify-center",title:a("artifact.zoomIn"),"data-testid":"mermaid-zoom-in",children:"+"})]}),d.status==="rendered"&&t.jsx("button",{onClick:()=>y(!0),"data-testid":"mermaid-expand","aria-label":a("artifact.viewer.open"),"data-tooltip":a("artifact.viewer.open"),className:"w-6 h-6 rounded border border-[var(--border)] text-ink-muted hover:bg-surface-3 flex items-center justify-center",children:t.jsx(Y,{className:"w-3.5 h-3.5"})})]}),t.jsx("button",{onClick:()=>window.open(D,"_blank"),className:"text-caption text-accent hover:underline font-bold shrink-0","data-testid":"mermaid-open-live",title:a("artifact.mermaid.openLive"),children:"mermaid.live ↗"})]}),t.jsxs("div",{onClick:()=>{d.status==="rendered"&&y(!0)},onWheel:Z,className:"bg-surface-0/40 rounded-lg p-3 overflow-auto min-h-[120px] max-h-[500px] select-none",style:{touchAction:"pan-x pan-y"},"data-testid":"mermaid-render-area","data-noswipe":"",children:[d.status==="loading"&&t.jsxs("div",{className:"flex items-center gap-2 text-body text-ink-muted my-8 justify-center","data-testid":"mermaid-loading",children:[t.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-accent rounded-full inline-block"}),t.jsx("span",{children:a("artifact.mermaid.rendering")})]}),d.status==="rendered"&&t.jsx("div",{style:{width:m?m.width*g:"auto",height:m?m.height*g:"auto",margin:"0 auto"},children:t.jsx("div",{style:{transform:`scale(${g})`,transformOrigin:"top left"},children:E})}),d.status==="error"&&C&&t.jsxs("div",{className:"flex items-center gap-2 text-body text-ink-muted my-8 justify-center","data-testid":"mermaid-repairing",children:[t.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-accent rounded-full inline-block"}),t.jsx("span",{children:a("artifact.mermaid.repairing")})]}),d.status==="error"&&!C&&t.jsxs("div",{className:"w-full text-center my-4","data-testid":"mermaid-fallback",children:[t.jsxs("div",{className:"text-body text-warning mb-2 flex items-center justify-center gap-1.5",children:[t.jsx(L,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{children:a("artifact.mermaid.renderFailed")})]}),t.jsx("pre",{className:"text-label bg-surface-1/60 rounded p-2 overflow-x-auto text-ink-muted font-mono text-left",children:u}),t.jsx("div",{className:"text-caption text-ink-muted mt-2",children:a("artifact.mermaid.errorPrefix",{msg:d.message})})]})]}),d.status==="rendered"&&t.jsx("div",{className:"mt-1.5 text-caption text-ink-muted flex items-center gap-2",children:t.jsx("span",{children:a("artifact.mermaid.hint")})}),F&&d.status==="rendered"&&t.jsx(ae,{title:r.title,onClose:()=>y(!1),children:t.jsx("div",{className:"h-full w-full rounded-xl overflow-hidden bg-surface-0/60",children:t.jsx(G,{testid:"mermaid-modal-stage",children:t.jsx(I,{data:e,variant:"canvas"})})})}),r.warnings&&r.warnings.length>0&&t.jsxs("div",{className:"mt-2 text-caption text-warning flex items-start gap-1","data-testid":"artifact-warnings",children:[t.jsx(L,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),t.jsx("span",{children:r.warnings.join("; ")})]})]})}const oe=Object.freeze(Object.defineProperty({__proto__:null,MermaidArtifact:I},Symbol.toStringTag,{value:"Module"}));export{ae as D,I as M,oe as a};
9
+ `)):e}return e}let p=null;function ee(){return p||(p=B(()=>import("./mermaid.core-DfcXYaBE.js").then(e=>e.bI),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(async e=>{const i=e.default,{default:r}=await B(async()=>{const{default:a}=await import("./mermaid-layout-elk.core-B4Ud-kMJ.js").then(s=>s.m);return{default:a}},__vite__mapDeps([6,1,2,3,4]),import.meta.url);return i.registerLayoutLoaders(r),i.initialize({startOnLoad:!1,theme:"base",securityLevel:"strict",themeVariables:te(),flowchart:{useMaxWidth:!0,htmlLabels:!0,curve:"basis",nodeSpacing:42,rankSpacing:54,padding:10},sequence:{useMaxWidth:!0,boxMargin:8,noteMargin:8,messageMargin:32}}),i})),p}function te(){const e=(r,a)=>{if(typeof document>"u")return a;const s=getComputedStyle(document.documentElement).getPropertyValue(r).trim();return s?`rgb(${s})`:a};return{background:"transparent",fontFamily:typeof document<"u"&&getComputedStyle(document.body).fontFamily||"ui-sans-serif, system-ui, sans-serif",fontSize:"14px",primaryColor:e("--surface-3-rgb","rgb(42 43 46)"),primaryBorderColor:e("--border-rgb","rgb(37 38 41)"),primaryTextColor:e("--ink-strong-rgb","rgb(250 250 250)"),secondaryColor:e("--surface-2-rgb","rgb(32 33 36)"),secondaryBorderColor:e("--border-faint-rgb","rgb(26 26 29)"),secondaryTextColor:e("--ink-rgb","rgb(245 245 250)"),tertiaryColor:e("--surface-1-rgb","rgb(24 25 27)"),tertiaryBorderColor:e("--border-faint-rgb","rgb(26 26 29)"),tertiaryTextColor:e("--ink-rgb","rgb(245 245 250)"),lineColor:e("--ink-faint-rgb","rgb(117 117 126)"),textColor:e("--ink-rgb","rgb(245 245 250)"),edgeLabelBackground:e("--surface-0-rgb","rgb(12 13 15)"),clusterBkg:e("--surface-1-rgb","rgb(24 25 27)"),clusterBorder:e("--border-faint-rgb","rgb(26 26 29)"),nodeBorder:e("--border-rgb","rgb(37 38 41)"),mainBkg:e("--surface-3-rgb","rgb(42 43 46)"),nodeTextColor:e("--ink-rgb","rgb(245 245 250)"),arrowheadColor:e("--ink-faint-rgb","rgb(117 117 126)"),actorBkg:e("--surface-3-rgb","rgb(42 43 46)"),actorBorder:e("--border-rgb","rgb(37 38 41)"),actorTextColor:e("--ink-strong-rgb","rgb(250 250 250)"),activationBkgColor:e("--surface-3-rgb","rgb(42 43 46)"),activationBorderColor:e("--border-rgb","rgb(37 38 41)"),signalColor:e("--ink-rgb","rgb(245 245 250)"),signalTextColor:e("--ink-rgb","rgb(245 245 250)"),labelBoxBkgColor:e("--surface-2-rgb","rgb(32 33 36)"),labelBoxBorderColor:e("--border-rgb","rgb(37 38 41)"),labelTextColor:e("--ink-rgb","rgb(245 245 250)"),loopTextColor:e("--ink-strong-rgb","rgb(250 250 250)"),noteBkgColor:"rgb(255 200 0 / 0.12)",noteBorderColor:"rgb(255 200 0 / 0.4)",noteTextColor:e("--ink-rgb","rgb(245 245 250)")}}typeof window<"u"&&window.addEventListener("theme-changed",()=>{p=null});async function re(e,i){const r=await ee(),a=Q(i);try{await r.parse(a)}catch(c){throw new Error(`mermaid 语法校验失败: ${c instanceof Error?c.message:String(c)}`)}const{svg:s}=await r.render(e,a);if(s.includes('aria-roledescription="error"')||s.includes('class="error-text"')||s.includes("Syntax error"))throw new Error("mermaid 渲染失败(语法错误或节点 label 含未转义特殊字符)");return s}function ae({title:e,onClose:i,children:r}){const a=O(),s=o.useRef(null);return H(s,!0),o.useEffect(()=>{const c=d=>{d.key==="Escape"&&i()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[i]),U.createPortal(t.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/80","data-testid":"diagram-viewer-modal","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":e,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 shrink-0",onClick:c=>c.stopPropagation(),children:[t.jsx("h3",{className:"text-body font-bold text-white truncate",children:e}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[t.jsx("span",{className:"text-caption text-white/50 hidden sm:inline",children:a("artifact.viewer.hint")}),t.jsx("button",{onClick:i,"data-testid":"diagram-viewer-close","aria-label":a("action.close"),"data-tooltip":a("action.close"),className:"text-white/70 hover:text-white w-9 h-9 flex items-center justify-center rounded-lg hover:bg-white/10 transition-colors",children:t.jsx(X,{className:"w-5 h-5"})})]})]}),t.jsx("div",{className:"flex-1 min-h-0 px-2 pb-2",onClick:i,children:t.jsx("div",{ref:s,className:"h-full w-full",onClick:c=>c.stopPropagation(),children:r})})]}),document.body)}function z(e){let i=5381;for(let r=0;r<e.length;r++)i=(i<<5)+i+e.charCodeAt(r)>>>0;return i.toString(36)}const v=.3,k=3,x=.2;function I({data:e,variant:i="card"}){const r=e,a=O(),s={flowchart:a("artifact.diagram.flowchart"),sequence:a("artifact.diagram.sequence"),state:a("artifact.diagram.state")},c=o.useId().replace(/[:]/g,"_"),[d,w]=o.useState({status:"loading"}),[u,A]=o.useState(()=>{try{return sessionStorage.getItem(`mmdfix:${r.mermaid.length}:${z(r.mermaid)}`)??r.mermaid}catch{return r.mermaid}}),[j,P]=o.useState(!1),[C,N]=o.useState(!1),[R,$]=o.useState(0);o.useEffect(()=>{const n=()=>$(l=>l+1);return window.addEventListener("theme-changed",n),()=>window.removeEventListener("theme-changed",n)},[]);const[m,M]=o.useState(null),[g,b]=o.useState(1),[F,y]=o.useState(!1);o.useEffect(()=>{let n=!1;return w({status:"loading"}),M(null),re(`mmd-${c}`,u).then(l=>{if(!n&&(w({status:"rendered",svg:l}),u!==r.mermaid))try{sessionStorage.setItem(`mmdfix:${r.mermaid.length}:${z(r.mermaid)}`,u)}catch{}}).catch(l=>{n||(console.error("[MermaidArtifact] render failed:",l),w({status:"error",message:l instanceof Error?l.message:String(l)}))}),()=>{n=!0}},[u,c,R,r.mermaid]),o.useEffect(()=>{var n;d.status!=="error"||j||(P(!0),u===r.mermaid&&(n=window.api)!=null&&n.repairMermaidDiagram&&(N(!0),window.api.repairMermaidDiagram({mermaid:u,errorMessage:d.message,diagramType:r.diagramType}).then(l=>{l.ok&&l.mermaid.trim()&&A(l.mermaid)}).catch(()=>{}).finally(()=>N(!1))))},[d,j,u,r.mermaid,r.diagramType]);const D=`https://mermaid.live/edit#${encodeURIComponent(u)}`,V=o.useCallback(()=>b(n=>Math.min(k,+(n+x).toFixed(2))),[]),W=o.useCallback(()=>b(n=>Math.max(v,+(n-x).toFixed(2))),[]),q=o.useCallback(()=>b(1),[]),Z=o.useCallback(n=>{if(!n.ctrlKey&&!n.metaKey)return;n.preventDefault();const l=n.deltaY>0?-x:x;b(h=>Math.min(k,Math.max(v,+(h+l).toFixed(2))))},[]),E=d.status==="rendered"?t.jsx("div",{ref:n=>{var l;if(n&&!m){const h=n.querySelector("svg");if(h){const S=h.getBoundingClientRect(),f=(l=h.viewBox)==null?void 0:l.baseVal,T=f&&f.width?f.width:S.width,_=f&&f.height?f.height:S.height;T>0&&_>0&&M({width:T,height:_})}}},style:{width:(m==null?void 0:m.width)??void 0,height:(m==null?void 0:m.height)??void 0},dangerouslySetInnerHTML:{__html:d.svg},"data-testid":"mermaid-svg"}):null;return i==="canvas"?t.jsx("div",{"data-testid":"mermaid-canvas-content",children:E}):t.jsxs("div",{className:"surface-card p-4","data-testid":"artifact-mermaid",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3 gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.jsx(J,{className:"w-4 h-4 text-ink-muted shrink-0"}),t.jsx("h3",{className:"text-body font-bold text-ink truncate",children:r.title}),t.jsx("span",{className:"text-caption font-bold px-1.5 py-0.5 rounded bg-accent/15 text-accent shrink-0",children:s[r.diagramType]??r.diagramType})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[d.status==="rendered"&&t.jsxs("div",{className:"flex items-center gap-1","data-testid":"mermaid-zoom-controls",children:[t.jsx("button",{onClick:W,disabled:g<=v,className:"w-6 h-6 rounded border border-[var(--border)] text-ink-muted hover:bg-surface-1 hover:bg-surface-3 disabled:opacity-30 text-label font-bold flex items-center justify-center",title:a("artifact.zoomOut"),"data-testid":"mermaid-zoom-out",children:"−"}),t.jsxs("button",{onClick:q,className:"px-1.5 h-6 rounded border border-[var(--border)] text-ink-muted hover:bg-surface-1 hover:bg-surface-3 text-caption font-bold tabular-nums",title:a("artifact.zoomReset"),"data-testid":"mermaid-zoom-reset",children:[Math.round(g*100),"%"]}),t.jsx("button",{onClick:V,disabled:g>=k,className:"w-6 h-6 rounded border border-[var(--border)] text-ink-muted hover:bg-surface-1 hover:bg-surface-3 disabled:opacity-30 text-label font-bold flex items-center justify-center",title:a("artifact.zoomIn"),"data-testid":"mermaid-zoom-in",children:"+"})]}),d.status==="rendered"&&t.jsx("button",{onClick:()=>y(!0),"data-testid":"mermaid-expand","aria-label":a("artifact.viewer.open"),"data-tooltip":a("artifact.viewer.open"),className:"w-6 h-6 rounded border border-[var(--border)] text-ink-muted hover:bg-surface-3 flex items-center justify-center",children:t.jsx(Y,{className:"w-3.5 h-3.5"})})]}),t.jsx("button",{onClick:()=>window.open(D,"_blank"),className:"text-caption text-accent hover:underline font-bold shrink-0","data-testid":"mermaid-open-live",title:a("artifact.mermaid.openLive"),children:"mermaid.live ↗"})]}),t.jsxs("div",{onClick:()=>{d.status==="rendered"&&y(!0)},onWheel:Z,className:"bg-surface-0/40 rounded-lg p-3 overflow-auto min-h-[120px] max-h-[500px] select-none",style:{touchAction:"pan-x pan-y"},"data-testid":"mermaid-render-area","data-noswipe":"",children:[d.status==="loading"&&t.jsxs("div",{className:"flex items-center gap-2 text-body text-ink-muted my-8 justify-center","data-testid":"mermaid-loading",children:[t.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-accent rounded-full inline-block"}),t.jsx("span",{children:a("artifact.mermaid.rendering")})]}),d.status==="rendered"&&t.jsx("div",{style:{width:m?m.width*g:"auto",height:m?m.height*g:"auto",margin:"0 auto"},children:t.jsx("div",{style:{transform:`scale(${g})`,transformOrigin:"top left"},children:E})}),d.status==="error"&&C&&t.jsxs("div",{className:"flex items-center gap-2 text-body text-ink-muted my-8 justify-center","data-testid":"mermaid-repairing",children:[t.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-accent rounded-full inline-block"}),t.jsx("span",{children:a("artifact.mermaid.repairing")})]}),d.status==="error"&&!C&&t.jsxs("div",{className:"w-full text-center my-4","data-testid":"mermaid-fallback",children:[t.jsxs("div",{className:"text-body text-warning mb-2 flex items-center justify-center gap-1.5",children:[t.jsx(L,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{children:a("artifact.mermaid.renderFailed")})]}),t.jsx("pre",{className:"text-label bg-surface-1/60 rounded p-2 overflow-x-auto text-ink-muted font-mono text-left",children:u}),t.jsx("div",{className:"text-caption text-ink-muted mt-2",children:a("artifact.mermaid.errorPrefix",{msg:d.message})})]})]}),d.status==="rendered"&&t.jsx("div",{className:"mt-1.5 text-caption text-ink-muted flex items-center gap-2",children:t.jsx("span",{children:a("artifact.mermaid.hint")})}),F&&d.status==="rendered"&&t.jsx(ae,{title:r.title,onClose:()=>y(!1),children:t.jsx("div",{className:"h-full w-full rounded-xl overflow-hidden bg-surface-0/60",children:t.jsx(G,{testid:"mermaid-modal-stage",children:t.jsx(I,{data:e,variant:"canvas"})})})}),r.warnings&&r.warnings.length>0&&t.jsxs("div",{className:"mt-2 text-caption text-warning flex items-start gap-1","data-testid":"artifact-warnings",children:[t.jsx(L,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),t.jsx("span",{children:r.warnings.join("; ")})]})]})}const oe=Object.freeze(Object.defineProperty({__proto__:null,MermaidArtifact:I},Symbol.toStringTag,{value:"Module"}));export{ae as D,I as M,oe as a};
@@ -1,4 +1,4 @@
1
- import{r,j as e}from"./index-jKxnKPxh.js";import{c as ee,u as R,X as G,r as V,a as u,W as z,C as B,b as H,n as J,d as te,e as se,t as ae,v as ne}from"./main-C7vIrKEC.js";import{T as X,C as Y}from"./Toggle-Bkokw_WS.js";/**
1
+ import{r,j as e}from"./index-jKxnKPxh.js";import{c as ee,u as R,X as G,r as V,a as u,W as z,C as B,b as H,n as J,d as te,e as se,t as ae,v as ne}from"./main-Bwe-ngM3.js";import{T as X,C as Y}from"./Toggle-fMmuR4RN.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{r as n,j as e}from"./index-jKxnKPxh.js";import{c as L,u as I,i as T,d as G,j as F,a as c,k as H,X as q,l as K,P as O,L as V,A as X,C as J,m as Q,n as U,o as W,s as Y,p as Z}from"./main-C7vIrKEC.js";/**
1
+ import{r as n,j as e}from"./index-jKxnKPxh.js";import{c as L,u as I,i as T,d as G,j as F,a as c,k as H,X as q,l as K,P as O,L as V,A as X,C as J,m as Q,n as U,o as W,s as Y,p as Z}from"./main-Bwe-ngM3.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as a,j as e,c as S}from"./index-jKxnKPxh.js";import{u as j,a as N,S as M}from"./main-C7vIrKEC.js";function A({tree:c,onReviewNode:d,progressMap:o}){const s=j(),[l,f]=a.useState([]),[b,h]=a.useState(!0),[n,x]=a.useState(null);a.useEffect(()=>{N.getAllSrsItems().then(t=>f(t)).catch(()=>f([])).finally(()=>h(!1))},[]);const p=a.useMemo(()=>new Map(c.map(t=>[t.id,t])),[c]),g=a.useMemo(()=>new Set(l.filter(t=>t.overdue).map(t=>t.nodeId)),[l]),i=a.useMemo(()=>{const t=c.filter(u=>{var y;const m=(y=o[u.id])==null?void 0:y.status;return u.type==="lesson"&&(m==="in_progress"||m==="mastered")}),r=new Map;for(const u of t){const m=u.parentId??"(root)";r.has(m)||r.set(m,[]),r.get(m).push(u)}return r},[c,o]),w=a.useMemo(()=>Array.from(i.values()).flat().filter(t=>g.has(t.id)).length,[i,g]),v=a.useMemo(()=>Array.from(i.values()).flat(),[i]);if(a.useEffect(()=>{if(i.size>0&&(!n||!i.has(n))){const t=i.keys().next().value;t&&x(t)}},[i,n]),b)return e.jsxs("div",{className:"text-center py-12 text-body text-ink-muted flex items-center justify-center gap-2",children:[e.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),s("review.loading")]});if(v.length===0)return e.jsxs("div",{className:"text-center py-16","data-testid":"review-empty",children:[e.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),e.jsx("div",{className:"text-body text-ink-muted",children:s("review.empty.title")}),e.jsx("div",{className:"text-label text-ink-faint mt-1",children:s("review.empty.desc")})]});const k=t=>{var r;return((r=p.get(t))==null?void 0:r.title)??t};return e.jsxs("div",{className:"p-5 max-w-2xl mx-auto","data-testid":"review-panel",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-title font-extrabold text-ink-strong",children:s("review.title")}),w>0&&e.jsxs("span",{className:"text-label font-bold text-review","data-testid":"review-due-count",children:[w," ",s("review.due.count")]})]}),e.jsxs("button",{onClick:()=>{const t=v[Math.floor(Math.random()*v.length)];t&&d(t.id)},"data-testid":"review-interleave",className:"btn-3d-neutral w-full py-2.5 text-body mb-5 flex items-center justify-center gap-1.5",children:[e.jsx(M,{className:"w-4 h-4"}),s("review.interleave")]}),e.jsx("div",{className:"text-label font-bold text-ink-muted mb-2",children:s("review.selectSection")}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:Array.from(i.entries()).map(([t,r])=>e.jsxs("button",{onClick:()=>x(t),className:`px-2.5 py-1 rounded-full text-label font-bold transition-colors ${n===t?"bg-brand/15 text-brand ring-1 ring-brand/30":"bg-surface-3 text-ink-muted hover:text-ink-strong"}`,children:[k(t),e.jsxs("span",{className:"ml-1 opacity-60",children:["(",r.length,")"]})]},t))}),n&&i.has(n)&&e.jsx("div",{className:"space-y-1.5","data-testid":"review-lesson-list",children:i.get(n).map(t=>{const r=g.has(t.id);return e.jsxs("div",{className:`flex items-center justify-between gap-2 p-2.5 rounded-lg transition-colors ${r?"bg-review/8 ring-1 ring-review/20":"bg-surface-3 hover:bg-surface-3/80"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 truncate flex-1",children:[r&&e.jsx("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full bg-review"}),e.jsx("span",{className:"text-body text-ink-strong truncate",children:t.title})]}),e.jsx("button",{onClick:()=>d(t.id),"data-testid":`review-lesson-${t.id.slice(0,8)}`,className:"shrink-0 px-3 py-1 rounded-lg bg-brand/15 text-brand text-label font-bold hover:bg-brand/25 transition-colors",children:s("review.reviewLesson")})]},t.id)})})]})}function E({nodeId:c,onRated:d}){const o=a.useRef(null),s=j(),[l,f]=a.useState(!1),[b,h]=a.useState(!1),n=async x=>{if(!(l||b)){f(!0);try{await N.recordReview(c,x),h(!0),d==null||d(),S(x>=4?"correct":"wrong",{origin:x>=4&&o.current?(()=>{const p=o.current.getBoundingClientRect();return{x:p.right-48,y:p.top+24}})():void 0})}catch{}finally{f(!1)}}};return b?e.jsx("div",{className:"text-center text-body text-brand py-2","data-testid":"self-rated",children:s("review.selfrated")}):e.jsxs("div",{ref:o,className:"border-t border-[var(--border-faint)] pt-3 mt-3","data-testid":"self-rating",children:[e.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2 text-center",children:s("review.selfrate.title")}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:()=>n(1),disabled:l,"data-testid":"rate-again",className:"py-2 rounded-lg border border-warning/40 text-warning hover:bg-warning/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:s("review.selfrate.again")}),e.jsx("span",{className:"text-caption opacity-70",children:s("review.selfrate.again.hint")})]}),e.jsxs("button",{onClick:()=>n(4),disabled:l,"data-testid":"rate-remembered",className:"py-2 rounded-lg border border-accent/40 text-accent hover:bg-accent/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:s("review.selfrate.remembered")}),e.jsx("span",{className:"text-caption opacity-70",children:s("review.selfrate.remembered.hint")})]}),e.jsxs("button",{onClick:()=>n(5),disabled:l,"data-testid":"rate-mastered",className:"py-2 rounded-lg border border-brand/40 text-brand hover:bg-brand/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:s("review.selfrate.mastered")}),e.jsx("span",{className:"text-caption opacity-70",children:s("review.selfrate.mastered.hint")})]})]})]})}export{A as ReviewPanel,E as SelfRatingCard};
1
+ import{r as a,j as e,c as S}from"./index-jKxnKPxh.js";import{u as j,a as N,S as M}from"./main-Bwe-ngM3.js";function A({tree:c,onReviewNode:d,progressMap:o}){const s=j(),[l,f]=a.useState([]),[b,h]=a.useState(!0),[n,x]=a.useState(null);a.useEffect(()=>{N.getAllSrsItems().then(t=>f(t)).catch(()=>f([])).finally(()=>h(!1))},[]);const p=a.useMemo(()=>new Map(c.map(t=>[t.id,t])),[c]),g=a.useMemo(()=>new Set(l.filter(t=>t.overdue).map(t=>t.nodeId)),[l]),i=a.useMemo(()=>{const t=c.filter(u=>{var y;const m=(y=o[u.id])==null?void 0:y.status;return u.type==="lesson"&&(m==="in_progress"||m==="mastered")}),r=new Map;for(const u of t){const m=u.parentId??"(root)";r.has(m)||r.set(m,[]),r.get(m).push(u)}return r},[c,o]),w=a.useMemo(()=>Array.from(i.values()).flat().filter(t=>g.has(t.id)).length,[i,g]),v=a.useMemo(()=>Array.from(i.values()).flat(),[i]);if(a.useEffect(()=>{if(i.size>0&&(!n||!i.has(n))){const t=i.keys().next().value;t&&x(t)}},[i,n]),b)return e.jsxs("div",{className:"text-center py-12 text-body text-ink-muted flex items-center justify-center gap-2",children:[e.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),s("review.loading")]});if(v.length===0)return e.jsxs("div",{className:"text-center py-16","data-testid":"review-empty",children:[e.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),e.jsx("div",{className:"text-body text-ink-muted",children:s("review.empty.title")}),e.jsx("div",{className:"text-label text-ink-faint mt-1",children:s("review.empty.desc")})]});const k=t=>{var r;return((r=p.get(t))==null?void 0:r.title)??t};return e.jsxs("div",{className:"p-5 max-w-2xl mx-auto","data-testid":"review-panel",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-title font-extrabold text-ink-strong",children:s("review.title")}),w>0&&e.jsxs("span",{className:"text-label font-bold text-review","data-testid":"review-due-count",children:[w," ",s("review.due.count")]})]}),e.jsxs("button",{onClick:()=>{const t=v[Math.floor(Math.random()*v.length)];t&&d(t.id)},"data-testid":"review-interleave",className:"btn-3d-neutral w-full py-2.5 text-body mb-5 flex items-center justify-center gap-1.5",children:[e.jsx(M,{className:"w-4 h-4"}),s("review.interleave")]}),e.jsx("div",{className:"text-label font-bold text-ink-muted mb-2",children:s("review.selectSection")}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:Array.from(i.entries()).map(([t,r])=>e.jsxs("button",{onClick:()=>x(t),className:`px-2.5 py-1 rounded-full text-label font-bold transition-colors ${n===t?"bg-brand/15 text-brand ring-1 ring-brand/30":"bg-surface-3 text-ink-muted hover:text-ink-strong"}`,children:[k(t),e.jsxs("span",{className:"ml-1 opacity-60",children:["(",r.length,")"]})]},t))}),n&&i.has(n)&&e.jsx("div",{className:"space-y-1.5","data-testid":"review-lesson-list",children:i.get(n).map(t=>{const r=g.has(t.id);return e.jsxs("div",{className:`flex items-center justify-between gap-2 p-2.5 rounded-lg transition-colors ${r?"bg-review/8 ring-1 ring-review/20":"bg-surface-3 hover:bg-surface-3/80"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 truncate flex-1",children:[r&&e.jsx("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full bg-review"}),e.jsx("span",{className:"text-body text-ink-strong truncate",children:t.title})]}),e.jsx("button",{onClick:()=>d(t.id),"data-testid":`review-lesson-${t.id.slice(0,8)}`,className:"shrink-0 px-3 py-1 rounded-lg bg-brand/15 text-brand text-label font-bold hover:bg-brand/25 transition-colors",children:s("review.reviewLesson")})]},t.id)})})]})}function E({nodeId:c,onRated:d}){const o=a.useRef(null),s=j(),[l,f]=a.useState(!1),[b,h]=a.useState(!1),n=async x=>{if(!(l||b)){f(!0);try{await N.recordReview(c,x),h(!0),d==null||d(),S(x>=4?"correct":"wrong",{origin:x>=4&&o.current?(()=>{const p=o.current.getBoundingClientRect();return{x:p.right-48,y:p.top+24}})():void 0})}catch{}finally{f(!1)}}};return b?e.jsx("div",{className:"text-center text-body text-brand py-2","data-testid":"self-rated",children:s("review.selfrated")}):e.jsxs("div",{ref:o,className:"border-t border-[var(--border-faint)] pt-3 mt-3","data-testid":"self-rating",children:[e.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2 text-center",children:s("review.selfrate.title")}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:()=>n(1),disabled:l,"data-testid":"rate-again",className:"py-2 rounded-lg border border-warning/40 text-warning hover:bg-warning/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:s("review.selfrate.again")}),e.jsx("span",{className:"text-caption opacity-70",children:s("review.selfrate.again.hint")})]}),e.jsxs("button",{onClick:()=>n(4),disabled:l,"data-testid":"rate-remembered",className:"py-2 rounded-lg border border-accent/40 text-accent hover:bg-accent/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:s("review.selfrate.remembered")}),e.jsx("span",{className:"text-caption opacity-70",children:s("review.selfrate.remembered.hint")})]}),e.jsxs("button",{onClick:()=>n(5),disabled:l,"data-testid":"rate-mastered",className:"py-2 rounded-lg border border-brand/40 text-brand hover:bg-brand/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:s("review.selfrate.mastered")}),e.jsx("span",{className:"text-caption opacity-70",children:s("review.selfrate.mastered.hint")})]})]})]})}export{A as ReviewPanel,E as SelfRatingCard};
@@ -1,10 +1,10 @@
1
- import{r as n,j as e,V as _e,k as ce,l as Ee,m as we,s as st,n as at,C as nt,M as it}from"./index-jKxnKPxh.js";import{c as ot,u as ee,d as De,D as lt,X as ke,g as rt,a as r,H as Ae,I as ct,J as dt,t as mt,n as Re,K as ut,W as xt,C as Fe,b as ht,N as pt}from"./main-C7vIrKEC.js";import{C as Ve,T as de}from"./Toggle-Bkokw_WS.js";/**
1
+ import{r as n,j as e,V as _e,k as ce,l as Ee,m as we,s as st,n as at,C as nt,M as it}from"./index-jKxnKPxh.js";import{c as ot,u as ee,d as De,D as lt,X as ke,g as rt,a as r,H as Ae,I as ct,J as dt,t as mt,n as Re,K as ut,W as xt,C as Fe,b as ht,N as pt}from"./main-Bwe-ngM3.js";import{C as Ve,T as de}from"./Toggle-fMmuR4RN.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
6
  */const ft=ot("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),gt={vision:"companion.custom.routeVision",geometric:"companion.custom.routeGeometric",l1:"companion.custom.routeL1"};function bt(t){let l="";for(let f=0;f<t.length;f+=32768)l+=String.fromCharCode(...t.subarray(f,f+32768));return btoa(l)}async function vt(t){try{return await navigator.clipboard.writeText(t),!0}catch{}const l=document.createElement("textarea");l.value=t,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.focus(),l.select();let i=!1;try{i=document.execCommand("copy")}catch{i=!1}return l.remove(),i}function jt({onClose:t,onSaved:l}){const i=ee(),[f,v]=n.useState(!1),[c,o]=n.useState(!1),[j,w]=n.useState(0),[p,C]=n.useState(null),[b,_]=n.useState(null),[D,u]=n.useState(""),[g,S]=n.useState(""),[y,A]=n.useState("ember"),k=n.useRef(null),E=n.useRef(null);De(E,!0),n.useEffect(()=>{if(!c)return;w(0);const d=Date.now(),z=window.setInterval(()=>w(Math.floor((Date.now()-d)/1e3)),500);return()=>window.clearInterval(z)},[c]);const H=async()=>{const d=await vt(i("companion.wizard.prompt"));v(d),d?setTimeout(()=>v(!1),2400):_(i("companion.wizard.copyFail"))},R=async d=>{if(d){o(!0),_(null),C(null),u(d.name.replace(/\.png$/i,""));try{const z=bt(new Uint8Array(await d.arrayBuffer())),N=await window.api.companionPackCutFromImage({pngBase64:z});C(N),N.visionError?_(`${i("companion.custom.visionFallback")} · ${N.visionError}`):_(`${i("companion.custom.cutDone")} · ${i(gt[N.route]??"companion.custom.routeL1")}`)}catch(z){_(`${i("companion.custom.fail")}: ${String(z)}`)}finally{o(!1)}}},m=async()=>{if(p){o(!0);try{await window.api.companionPackApplyPack({name:g.trim()||D||"My Bot",manifest:{...p.manifest,vehicle:y},parts:p.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")),l()}catch(d){_(`${i("companion.custom.fail")}: ${String(d)}`)}finally{o(!1)}}};return lt.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":i("companion.wizard.title"),onClick:t,children:e.jsxs("div",{ref:E,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:i("companion.wizard.title")}),e.jsx("button",{onClick:t,"aria-label":i("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(ke,{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:i("companion.wizard.s1")}),e.jsx("p",{className:"text-caption text-ink-muted leading-relaxed",children:i("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:i("companion.wizard.s2")}),e.jsx("p",{className:"text-caption text-ink-muted leading-relaxed mb-2",children:i("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:i("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:i("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:i("companion.wizard.s2chatgpt")}),e.jsx("button",{type:"button",onClick:()=>void H(),"data-testid":"companion-wizard-copy",className:"rounded-lg bg-accent px-3 py-1.5 text-label text-white hover:opacity-90",children:i(f?"companion.wizard.copied":"companion.wizard.copy")})]}),e.jsx("textarea",{readOnly:!0,value:i("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:i("companion.wizard.s3")}),e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-caption text-ink-muted mb-1",children:i("companion.wizard.vehicle")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",role:"radiogroup","aria-label":i("companion.wizard.vehicle"),children:_e.map(d=>{const z=y===d;return e.jsxs("button",{type:"button",role:"radio","aria-checked":z,"data-testid":`companion-wizard-veh-${d}`,onClick:()=>A(d),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-label motion-safe:transition-colors
7
- ${z?"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:ce[d].dot}}),i(`companion.form.${d}.name`)]},d)})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("input",{ref:k,type:"file",accept:"image/png",className:"hidden","data-testid":"companion-custom-file",onChange:d=>{var z;return void R((z=d.target.files)==null?void 0:z[0])}}),e.jsx("button",{type:"button",disabled:c,onClick:()=>{var d;return(d=k.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:i("companion.wizard.pick")}),c&&e.jsxs("span",{className:"flex items-center gap-1.5 text-label text-ink-muted","data-testid":"companion-custom-busy",children:[e.jsx(rt,{size:14,className:"animate-spin"}),i(p?"companion.custom.applying":"companion.custom.locating"),e.jsxs("span",{className:"tabular-nums",children:[j,"s"]})]}),b&&e.jsx("span",{className:"text-caption text-ink-muted","data-testid":"companion-custom-msg",children:b})]}),p&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"companion-custom-preview",children:[p.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:g,onChange:d=>S(d.target.value),placeholder:i("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:c,onClick:()=>void m(),"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:i("companion.wizard.save")})]})]})]})}),document.body)}const wt=[{id:"shimejiorg",label:"shimeji.org",url:"https://shimeji.org/"},{id:"shimejisxyz",label:"shimejis.xyz",url:"https://shimejis.xyz/"},{id:"cachomon",label:"Cachomon",url:"https://cachomon.com/"},{id:"deviantart",label:"DeviantArt",url:"https://www.deviantart.com/search?q=shimeji"}];function kt({onClose:t,onImported:l}){const i=ee(),f=n.useRef(null),v=n.useRef(null);De(f,!0);const[c,o]=n.useState(!1),[j,w]=n.useState(null),[p,C]=n.useState(null),b=async u=>{var S;const g=(S=u.target.files)==null?void 0:S[0];if(u.target.value="",!!g){o(!0),w(null);try{const y=new Uint8Array(await g.arrayBuffer());let A="";for(let E=0;E<y.length;E+=32768)A+=String.fromCharCode(...y.subarray(E,E+32768));const k=await window.api.shimejiImportZip({zipBase64:btoa(A)});C({importId:k.importId,characters:k.characters,selected:new Set(k.characters.map(E=>E.ref))})}catch(y){w(String(y.message??y).slice(0,160))}finally{o(!1)}}},_=u=>{C(g=>{if(!g)return g;const S=new Set(g.selected);return S.has(u)?S.delete(u):S.add(u),{...g,selected:S}})},D=async()=>{if(p){o(!0);try{await window.api.shimejiConfirmImport({importId:p.importId,characterRefs:[...p.selected]}),C(null),await we(),await l(),t()}catch(u){w(String(u.message??u).slice(0,160))}finally{o(!1)}}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":i("settings.shimeji.dialog.title"),onClick:t,children:e.jsxs("div",{ref:f,onClick:u=>u.stopPropagation(),className:"relative w-full max-w-md max-h-[85dvh] flex flex-col rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4","data-testid":"shimeji-dialog",children:[e.jsx("button",{type:"button","aria-label":i("action.close"),"data-testid":"shimeji-dialog-close",onClick:t,className:"absolute top-2.5 right-2.5 w-7 h-7 rounded-lg flex items-center justify-center text-ink-muted hover:text-ink-strong hover:bg-surface-2",children:e.jsx(ke,{className:"w-4 h-4"})}),e.jsxs("div",{className:"min-h-0 overflow-y-auto",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong mb-1",children:i("settings.shimeji.dialog.title")}),e.jsx("p",{className:"text-label text-ink-muted mb-3",children:i("settings.shimeji.desc")}),!p&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button","data-testid":"shimeji-import",disabled:c,onClick:()=>{var u;return(u=v.current)==null?void 0:u.click()},className:"w-full rounded-xl border border-dashed border-[var(--border)] py-6 flex flex-col items-center gap-1.5 text-ink-faint hover:text-ink-muted hover:bg-surface-2 disabled:opacity-50",children:[e.jsx("span",{className:"text-label font-medium",children:i(c?"settings.shimeji.importing":"settings.shimeji.import")}),e.jsx("span",{className:"text-caption",children:i("settings.shimeji.guide")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2","data-testid":"shimeji-download-links",children:wt.map(u=>e.jsxs("a",{href:u.url,target:"_blank",rel:"noopener noreferrer","data-testid":`shimeji-link-${u.id}`,className:"inline-flex items-center gap-1 rounded-lg border border-[var(--border-faint)] px-2 py-1 text-caption text-ink-muted hover:text-ink-strong hover:bg-surface-2 motion-safe:transition-colors",children:[e.jsx(ft,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),u.label]},u.id))})]}),e.jsx("input",{ref:v,type:"file",accept:".zip",className:"hidden",onChange:u=>void b(u)}),j&&e.jsx("p",{className:"text-caption text-warning mt-2",role:"alert",children:j}),p&&e.jsxs("div",{className:"rounded-xl border border-[var(--border)] bg-surface-1 p-3","data-testid":"shimeji-character-picker",children:[e.jsx("div",{className:"text-body text-ink-strong mb-2",children:i("settings.shimeji.pick.title")}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:p.characters.map(u=>{const g=p.selected.has(u.ref);return e.jsxs("button",{type:"button","aria-pressed":g,onClick:()=>_(u.ref),className:`flex items-center gap-2 rounded-xl border p-2 text-left ${g?"border-[var(--accent)] bg-surface-2":"border-[var(--border-faint)]"}`,children:[u.iconBase64?e.jsx("img",{src:`data:image/png;base64,${u.iconBase64}`,alt:"",className:"w-9 h-9 rounded-lg object-contain bg-surface-2"}):e.jsx("div",{className:"w-9 h-9 rounded-lg bg-surface-2"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-body text-ink-strong",children:u.name}),e.jsxs("span",{className:"text-caption text-ink-muted",children:[u.format," · ",u.frameCount,"f · ",u.actionCount]})]})]},u.ref)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button","data-testid":"shimeji-confirm-import",className:"btn-3d-brand px-3 py-1.5 text-label",disabled:c||p.selected.size===0,onClick:()=>void D(),children:i("settings.shimeji.pick.confirm",{count:p.selected.size})}),e.jsx("button",{type:"button",className:"btn-3d-neutral px-3 py-1.5 text-label",onClick:t,children:i("action.cancel")})]})]})]})]})})}const Me="lookatstudy-theme",Be="auto",We="(prefers-color-scheme: dark)";function Se(){return typeof window>"u"||window.matchMedia(We).matches?"dark":"light"}function Nt(){if(typeof localStorage>"u")return Be;const t=localStorage.getItem(Me);return t==="auto"||t==="light"||t==="dark"?t:Be}function Ce(t){const l=document.documentElement;l.classList.remove("dark","light"),l.classList.add(t),window.dispatchEvent(new CustomEvent("theme-changed",{detail:{resolved:t}}))}function yt(){const[t,l]=n.useState(()=>Nt()),[i,f]=n.useState(()=>t==="auto"?Se():t),v=n.useCallback(c=>{l(c),localStorage.setItem(Me,c);const o=c==="auto"?Se():c;f(o),Ce(o)},[]);return n.useEffect(()=>{if(t!=="auto")return;const c=window.matchMedia(We),o=j=>{const w=j.matches?"dark":"light";f(w),Ce(w)};return c.addEventListener("change",o),()=>c.removeEventListener("change",o)},[t]),n.useEffect(()=>{const c=t==="auto"?Se():t;f(c),Ce(c)},[t]),{mode:t,resolved:i,setMode:v}}const St="0.38.0",Ct={version:St};function je(){window.dispatchEvent(new Event(pt))}const re="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",K="bg-surface-3 text-ink-muted hover:bg-surface-3 hover:bg-surface-3 hover:text-ink-strong",U="bg-brand text-white shadow-sm";function L(t){return t?"px-4 py-3.5 border-t border-[var(--border-faint)]":"px-4 py-3.5"}function Ft({onOpenModelManager:t}){const l=ee(),[i,f]=n.useState([]),[v,c]=n.useState([]),[o,j]=n.useState("glm"),[w,p]=n.useState(""),[C,b]=n.useState(!1),[_,D]=n.useState({providerId:"",modelId:""}),u=yt(),g=n.useCallback(async()=>{try{const[m,d,z,N,J,M]=await Promise.all([r.getProviderPresets(),r.listCustomProviders(),r.getSetting("active_provider"),r.getSetting("active_model"),r.getSetting("vision_provider_override"),r.getSetting("vision_model_override")]);f(m),c(d);const W=z??"glm";if(j(W),W.startsWith("custom-")){const $=d.find(T=>T.id===W);p(N??($==null?void 0:$.defaultModel)??""),b(($==null?void 0:$.hasApiKey)??!1)}else{const $=m.find(T=>T.id===W);p(N??($==null?void 0:$.defaultModel)??""),b($?await r.hasSetting($.apiKeySetting):!1)}D({providerId:J??"",modelId:M??""})}catch(m){console.error("[SettingsView] load() failed:",m)}},[]);n.useEffect(()=>{g()},[g]),n.useEffect(()=>{const m=()=>void g();return window.addEventListener("llm-config-changed",m),()=>window.removeEventListener("llm-config-changed",m)},[g]);const S=o.startsWith("custom-")?null:i.find(m=>m.id===o)??null,y=o.startsWith("custom-")?v.find(m=>m.id===o)??null:null,A=(S==null?void 0:S.label)??(y==null?void 0:y.label)??o,k=S?S.models.find(m=>m.id===w||m.id.toLowerCase()===w.toLowerCase())??null:(y==null?void 0:y.models.find(m=>m.id===w||m.id.toLowerCase()===w.toLowerCase()))??null,E=(()=>{if(!k)return null;const m=[];return k.contextWindow&&m.push(`${Math.round(k.contextWindow/1e3)}k`),k.free?m.push(l("model.picker.free")):k.pricing&&k.pricing.input!==null&&m.push(`$${String(Number(k.pricing.input.toFixed(2)))}`),(k.capabilities??[]).includes("vision")&&m.push("👁"),(k.capabilities??[]).includes("reasoning")&&m.push("🧠"),m.length>0?m.join(" · "):null})(),H=_.providerId.startsWith("custom-")?v.find(m=>m.id===_.providerId)??null:null,R=H?l("settings.modelcard.vision_bridge",{model:_.modelId||H.defaultModel}):((k==null?void 0:k.capabilities)??[]).includes("vision")?l("settings.modelcard.vision_direct"):l("settings.modelcard.vision_none");return e.jsx(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:l("settings.group.ai")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t("main"),"data-testid":"model-card-manage",className:"w-full text-left px-4 py-3.5 hover:bg-ink/[0.03] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${C?"bg-brand":"bg-ink/15"}`,"aria-hidden":!0}),e.jsx("span",{className:"text-body font-medium text-ink-strong truncate",children:A}),e.jsx("span",{className:"text-label text-ink-muted font-mono truncate",children:w}),e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:"text-label text-accent shrink-0",children:l("settings.modelcard.manage")})]}),E&&e.jsx("div",{className:"text-caption text-ink-faint mt-1 tabular-nums",children:E}),e.jsx("div",{className:"text-caption text-ink-faint mt-0.5",children:R})]})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.vision")}),e.jsxs("div",{className:"surface-card px-4 py-3.5 flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:R}),e.jsx("div",{className:"text-caption text-ink-faint",children:l("settings.modelcard.vision_hint")})]}),e.jsx("button",{onClick:()=>t==null?void 0:t("vision"),"data-testid":"model-card-vision",className:"btn-3d-neutral px-3 py-1.5 text-label shrink-0",children:l("settings.modelcard.configure")})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.speech")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(Tt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.memory")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(Et,{})})]}),e.jsxs("section",{id:"settings-section-companion",children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.companion")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(zt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.appearance")}),e.jsxs("div",{className:"surface-card overflow-hidden",children:[e.jsxs("div",{className:L(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:l("settings.row.theme")}),e.jsx("div",{className:"flex gap-2",children:[{mode:"auto",label:l("settings.theme.auto")},{mode:"light",label:l("settings.theme.light")},{mode:"dark",label:l("settings.theme.dark")}].map(({mode:m,label:d})=>e.jsx("button",{onClick:()=>u.setMode(m),"data-testid":`theme-${m}`,"aria-pressed":u.mode===m,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${u.mode===m?U:K}`,children:d},m))}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:u.mode==="auto"?l("settings.theme.following",{mode:l(`settings.theme.${u.resolved}`)}):null})]}),e.jsxs("div",{className:L(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:l("settings.row.interface_lang")}),e.jsx("div",{className:"flex gap-2",children:["zh-CN","en"].map(m=>e.jsx("button",{onClick:()=>ct(m),"data-testid":`lang-${m}`,"aria-pressed":Ae()===m,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${Ae()===m?U:K}`,children:m==="zh-CN"?"中文":"English"},m))})]}),e.jsxs("div",{className:L(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:l("settings.row.import_lang")}),e.jsx(_t,{})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.data")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(Lt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.about")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsxs("div",{className:L(!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:l("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",Ct.version]})]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:l("settings.version.hint")})]})})]})]})})}function _t(){const[t,l]=n.useState("en"),[i,f]=n.useState(!1);n.useEffect(()=>{r.getSetting("pref_lang").then(o=>{o&&l(o),f(!0)})},[]);const v=async o=>{l(o),await r.setSetting("pref_lang",o)},c=[{code:"en",label:"English"},{code:"zh-CN",label:"简体中文"},{code:"zh-TW",label:"繁體中文"}];return i?e.jsx("div",{className:"flex gap-2","data-testid":"pref-lang-options",children:c.map(o=>e.jsx("button",{onClick:()=>v(o.code),"data-testid":`pref-lang-${o.code}`,"aria-pressed":t===o.code,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${t===o.code?U:K}`,children:o.label},o.code))}):null}function Et(){const t=ee(),[l,i]=n.useState(!1),[f,v]=n.useState(!1);n.useEffect(()=>{r.getSetting("flag_memory_system").then(o=>{i(o==="true"),v(!0)})},[]);const c=async()=>{const o=!l;i(o),await r.setSetting("flag_memory_system",String(o))};return f?e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(de,{checked:l,onChange:c,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 zt(){var le,pe,Z;const t=ee(),[l,i]=n.useState(!0),[f,v]=n.useState(!1),c=n.useSyncExternalStore(st,at),[o,j]=n.useState(!0),[w,p]=n.useState(!1),C=typeof window<"u"&&!!window.__lookatstudyWeb;n.useEffect(()=>{r.getSetting("companion_enabled").then(a=>{i(a!=="false"&&a!=="0"),v(!0)}),r.getSetting("companion_sfx").then(a=>{j(a!=="false"&&a!=="0")}),r.getSetting("companion_pet_mode").then(a=>{p(a==="1")})},[]);const b=async()=>{const a=!l;i(a),await r.setSetting("companion_enabled",String(a)),window.dispatchEvent(new Event("companion-config-changed"))},_=async()=>{const a=!o;j(a),await r.setSetting("companion_sfx",String(a)),window.dispatchEvent(new Event("companion-config-changed"))},D=async()=>{const a=!w;p(a),await r.setSetting("companion_pet_mode",a?"1":"0"),window.dispatchEvent(new Event("companion-config-changed"))},u=async a=>{a!==c.form&&(await r.setSetting("companion_form",a),window.dispatchEvent(new Event("companion-config-changed")))},[g,S]=n.useState([]),[y,A]=n.useState(!1),[k,E]=n.useState(null),[H,R]=n.useState(!1),[m,d]=n.useState(!1),[z,N]=n.useState(!1),[J,M]=n.useState(null),[W,$]=n.useState(!1),[T,me]=n.useState([]),[te,q]=n.useState(null),[G,se]=n.useState(null),[ae,oe]=n.useState(null),I=n.useCallback(async()=>{try{S((await window.api.companionPackList()).packs)}catch{}},[]),B=n.useCallback(async()=>{try{me((await window.api.shimejiList()).packs)}catch{}},[]);n.useEffect(()=>{I(),B();const a=()=>{I(),B()};return window.addEventListener("companion-config-changed",a),()=>window.removeEventListener("companion-config-changed",a)},[I,B]);const Y=async a=>{await r.shimejiActivate({id:a}),c.form!=="shimeji"&&await r.setSetting("companion_form","shimeji"),window.dispatchEvent(new Event("companion-config-changed")),await B(),await we()},ue=async(a,x)=>{await window.api.shimejiSetVehicle({id:a,vehicle:x}),await B(),await we()},xe=async a=>{await window.api.shimejiDelete({id:a}),q(null),await B(),await we()},Ne=async a=>{await window.api.companionPackActivate({id:a}),c.form!=="custom"&&await r.setSetting("companion_form","custom"),await Ee(),window.dispatchEvent(new Event("companion-config-changed"))},ne=async a=>{(await window.api.companionPackDelete({id:a})).formReset&&window.dispatchEvent(new Event("companion-config-changed")),E(null),oe(null),I()},he=async(a,x)=>{var P;await window.api.companionPackSetVehicle({id:a,vehicle:x}),await I(),(P=g.find(V=>V.id===a))!=null&&P.active&&(await Ee(),window.dispatchEvent(new Event("companion-config-changed")))};return f?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(de,{checked:l,onChange:b,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")})]})]}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{checked:o,onChange:_,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")})]})]}),!C&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{checked:w,onChange:D,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:[nt.filter(a=>a!=="custom"&&a!=="shimeji").map(a=>{const x=c.form===a;return e.jsxs("button",{type:"button",role:"radio","aria-checked":x,"data-testid":`companion-form-${a}`,onClick:()=>{u(a)},className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
7
+ ${z?"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:ce[d].dot}}),i(`companion.form.${d}.name`)]},d)})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("input",{ref:k,type:"file",accept:"image/png",className:"hidden","data-testid":"companion-custom-file",onChange:d=>{var z;return void R((z=d.target.files)==null?void 0:z[0])}}),e.jsx("button",{type:"button",disabled:c,onClick:()=>{var d;return(d=k.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:i("companion.wizard.pick")}),c&&e.jsxs("span",{className:"flex items-center gap-1.5 text-label text-ink-muted","data-testid":"companion-custom-busy",children:[e.jsx(rt,{size:14,className:"animate-spin"}),i(p?"companion.custom.applying":"companion.custom.locating"),e.jsxs("span",{className:"tabular-nums",children:[j,"s"]})]}),b&&e.jsx("span",{className:"text-caption text-ink-muted","data-testid":"companion-custom-msg",children:b})]}),p&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"companion-custom-preview",children:[p.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:g,onChange:d=>S(d.target.value),placeholder:i("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:c,onClick:()=>void m(),"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:i("companion.wizard.save")})]})]})]})}),document.body)}const wt=[{id:"shimejiorg",label:"shimeji.org",url:"https://shimeji.org/"},{id:"shimejisxyz",label:"shimejis.xyz",url:"https://shimejis.xyz/"},{id:"cachomon",label:"Cachomon",url:"https://cachomon.com/"},{id:"deviantart",label:"DeviantArt",url:"https://www.deviantart.com/search?q=shimeji"}];function kt({onClose:t,onImported:l}){const i=ee(),f=n.useRef(null),v=n.useRef(null);De(f,!0);const[c,o]=n.useState(!1),[j,w]=n.useState(null),[p,C]=n.useState(null),b=async u=>{var S;const g=(S=u.target.files)==null?void 0:S[0];if(u.target.value="",!!g){o(!0),w(null);try{const y=new Uint8Array(await g.arrayBuffer());let A="";for(let E=0;E<y.length;E+=32768)A+=String.fromCharCode(...y.subarray(E,E+32768));const k=await window.api.shimejiImportZip({zipBase64:btoa(A)});C({importId:k.importId,characters:k.characters,selected:new Set(k.characters.map(E=>E.ref))})}catch(y){w(String(y.message??y).slice(0,160))}finally{o(!1)}}},_=u=>{C(g=>{if(!g)return g;const S=new Set(g.selected);return S.has(u)?S.delete(u):S.add(u),{...g,selected:S}})},D=async()=>{if(p){o(!0);try{await window.api.shimejiConfirmImport({importId:p.importId,characterRefs:[...p.selected]}),C(null),await we(),await l(),t()}catch(u){w(String(u.message??u).slice(0,160))}finally{o(!1)}}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":i("settings.shimeji.dialog.title"),onClick:t,children:e.jsxs("div",{ref:f,onClick:u=>u.stopPropagation(),className:"relative w-full max-w-md max-h-[85dvh] flex flex-col rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4","data-testid":"shimeji-dialog",children:[e.jsx("button",{type:"button","aria-label":i("action.close"),"data-testid":"shimeji-dialog-close",onClick:t,className:"absolute top-2.5 right-2.5 w-7 h-7 rounded-lg flex items-center justify-center text-ink-muted hover:text-ink-strong hover:bg-surface-2",children:e.jsx(ke,{className:"w-4 h-4"})}),e.jsxs("div",{className:"min-h-0 overflow-y-auto",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong mb-1",children:i("settings.shimeji.dialog.title")}),e.jsx("p",{className:"text-label text-ink-muted mb-3",children:i("settings.shimeji.desc")}),!p&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button","data-testid":"shimeji-import",disabled:c,onClick:()=>{var u;return(u=v.current)==null?void 0:u.click()},className:"w-full rounded-xl border border-dashed border-[var(--border)] py-6 flex flex-col items-center gap-1.5 text-ink-faint hover:text-ink-muted hover:bg-surface-2 disabled:opacity-50",children:[e.jsx("span",{className:"text-label font-medium",children:i(c?"settings.shimeji.importing":"settings.shimeji.import")}),e.jsx("span",{className:"text-caption",children:i("settings.shimeji.guide")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2","data-testid":"shimeji-download-links",children:wt.map(u=>e.jsxs("a",{href:u.url,target:"_blank",rel:"noopener noreferrer","data-testid":`shimeji-link-${u.id}`,className:"inline-flex items-center gap-1 rounded-lg border border-[var(--border-faint)] px-2 py-1 text-caption text-ink-muted hover:text-ink-strong hover:bg-surface-2 motion-safe:transition-colors",children:[e.jsx(ft,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),u.label]},u.id))})]}),e.jsx("input",{ref:v,type:"file",accept:".zip",className:"hidden",onChange:u=>void b(u)}),j&&e.jsx("p",{className:"text-caption text-warning mt-2",role:"alert",children:j}),p&&e.jsxs("div",{className:"rounded-xl border border-[var(--border)] bg-surface-1 p-3","data-testid":"shimeji-character-picker",children:[e.jsx("div",{className:"text-body text-ink-strong mb-2",children:i("settings.shimeji.pick.title")}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:p.characters.map(u=>{const g=p.selected.has(u.ref);return e.jsxs("button",{type:"button","aria-pressed":g,onClick:()=>_(u.ref),className:`flex items-center gap-2 rounded-xl border p-2 text-left ${g?"border-[var(--accent)] bg-surface-2":"border-[var(--border-faint)]"}`,children:[u.iconBase64?e.jsx("img",{src:`data:image/png;base64,${u.iconBase64}`,alt:"",className:"w-9 h-9 rounded-lg object-contain bg-surface-2"}):e.jsx("div",{className:"w-9 h-9 rounded-lg bg-surface-2"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-body text-ink-strong",children:u.name}),e.jsxs("span",{className:"text-caption text-ink-muted",children:[u.format," · ",u.frameCount,"f · ",u.actionCount]})]})]},u.ref)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button","data-testid":"shimeji-confirm-import",className:"btn-3d-brand px-3 py-1.5 text-label",disabled:c||p.selected.size===0,onClick:()=>void D(),children:i("settings.shimeji.pick.confirm",{count:p.selected.size})}),e.jsx("button",{type:"button",className:"btn-3d-neutral px-3 py-1.5 text-label",onClick:t,children:i("action.cancel")})]})]})]})]})})}const Me="lookatstudy-theme",Be="auto",We="(prefers-color-scheme: dark)";function Se(){return typeof window>"u"||window.matchMedia(We).matches?"dark":"light"}function Nt(){if(typeof localStorage>"u")return Be;const t=localStorage.getItem(Me);return t==="auto"||t==="light"||t==="dark"?t:Be}function Ce(t){const l=document.documentElement;l.classList.remove("dark","light"),l.classList.add(t),window.dispatchEvent(new CustomEvent("theme-changed",{detail:{resolved:t}}))}function yt(){const[t,l]=n.useState(()=>Nt()),[i,f]=n.useState(()=>t==="auto"?Se():t),v=n.useCallback(c=>{l(c),localStorage.setItem(Me,c);const o=c==="auto"?Se():c;f(o),Ce(o)},[]);return n.useEffect(()=>{if(t!=="auto")return;const c=window.matchMedia(We),o=j=>{const w=j.matches?"dark":"light";f(w),Ce(w)};return c.addEventListener("change",o),()=>c.removeEventListener("change",o)},[t]),n.useEffect(()=>{const c=t==="auto"?Se():t;f(c),Ce(c)},[t]),{mode:t,resolved:i,setMode:v}}const St="0.38.1",Ct={version:St};function je(){window.dispatchEvent(new Event(pt))}const re="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",K="bg-surface-3 text-ink-muted hover:bg-surface-3 hover:bg-surface-3 hover:text-ink-strong",U="bg-brand text-white shadow-sm";function L(t){return t?"px-4 py-3.5 border-t border-[var(--border-faint)]":"px-4 py-3.5"}function Ft({onOpenModelManager:t}){const l=ee(),[i,f]=n.useState([]),[v,c]=n.useState([]),[o,j]=n.useState("glm"),[w,p]=n.useState(""),[C,b]=n.useState(!1),[_,D]=n.useState({providerId:"",modelId:""}),u=yt(),g=n.useCallback(async()=>{try{const[m,d,z,N,J,M]=await Promise.all([r.getProviderPresets(),r.listCustomProviders(),r.getSetting("active_provider"),r.getSetting("active_model"),r.getSetting("vision_provider_override"),r.getSetting("vision_model_override")]);f(m),c(d);const W=z??"glm";if(j(W),W.startsWith("custom-")){const $=d.find(T=>T.id===W);p(N??($==null?void 0:$.defaultModel)??""),b(($==null?void 0:$.hasApiKey)??!1)}else{const $=m.find(T=>T.id===W);p(N??($==null?void 0:$.defaultModel)??""),b($?await r.hasSetting($.apiKeySetting):!1)}D({providerId:J??"",modelId:M??""})}catch(m){console.error("[SettingsView] load() failed:",m)}},[]);n.useEffect(()=>{g()},[g]),n.useEffect(()=>{const m=()=>void g();return window.addEventListener("llm-config-changed",m),()=>window.removeEventListener("llm-config-changed",m)},[g]);const S=o.startsWith("custom-")?null:i.find(m=>m.id===o)??null,y=o.startsWith("custom-")?v.find(m=>m.id===o)??null:null,A=(S==null?void 0:S.label)??(y==null?void 0:y.label)??o,k=S?S.models.find(m=>m.id===w||m.id.toLowerCase()===w.toLowerCase())??null:(y==null?void 0:y.models.find(m=>m.id===w||m.id.toLowerCase()===w.toLowerCase()))??null,E=(()=>{if(!k)return null;const m=[];return k.contextWindow&&m.push(`${Math.round(k.contextWindow/1e3)}k`),k.free?m.push(l("model.picker.free")):k.pricing&&k.pricing.input!==null&&m.push(`$${String(Number(k.pricing.input.toFixed(2)))}`),(k.capabilities??[]).includes("vision")&&m.push("👁"),(k.capabilities??[]).includes("reasoning")&&m.push("🧠"),m.length>0?m.join(" · "):null})(),H=_.providerId.startsWith("custom-")?v.find(m=>m.id===_.providerId)??null:null,R=H?l("settings.modelcard.vision_bridge",{model:_.modelId||H.defaultModel}):((k==null?void 0:k.capabilities)??[]).includes("vision")?l("settings.modelcard.vision_direct"):l("settings.modelcard.vision_none");return e.jsx(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:l("settings.group.ai")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t("main"),"data-testid":"model-card-manage",className:"w-full text-left px-4 py-3.5 hover:bg-ink/[0.03] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${C?"bg-brand":"bg-ink/15"}`,"aria-hidden":!0}),e.jsx("span",{className:"text-body font-medium text-ink-strong truncate",children:A}),e.jsx("span",{className:"text-label text-ink-muted font-mono truncate",children:w}),e.jsx("span",{className:"flex-1"}),e.jsx("span",{className:"text-label text-accent shrink-0",children:l("settings.modelcard.manage")})]}),E&&e.jsx("div",{className:"text-caption text-ink-faint mt-1 tabular-nums",children:E}),e.jsx("div",{className:"text-caption text-ink-faint mt-0.5",children:R})]})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.vision")}),e.jsxs("div",{className:"surface-card px-4 py-3.5 flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:R}),e.jsx("div",{className:"text-caption text-ink-faint",children:l("settings.modelcard.vision_hint")})]}),e.jsx("button",{onClick:()=>t==null?void 0:t("vision"),"data-testid":"model-card-vision",className:"btn-3d-neutral px-3 py-1.5 text-label shrink-0",children:l("settings.modelcard.configure")})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.speech")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(Tt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.memory")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(Et,{})})]}),e.jsxs("section",{id:"settings-section-companion",children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.companion")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(zt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.appearance")}),e.jsxs("div",{className:"surface-card overflow-hidden",children:[e.jsxs("div",{className:L(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:l("settings.row.theme")}),e.jsx("div",{className:"flex gap-2",children:[{mode:"auto",label:l("settings.theme.auto")},{mode:"light",label:l("settings.theme.light")},{mode:"dark",label:l("settings.theme.dark")}].map(({mode:m,label:d})=>e.jsx("button",{onClick:()=>u.setMode(m),"data-testid":`theme-${m}`,"aria-pressed":u.mode===m,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${u.mode===m?U:K}`,children:d},m))}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:u.mode==="auto"?l("settings.theme.following",{mode:l(`settings.theme.${u.resolved}`)}):null})]}),e.jsxs("div",{className:L(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:l("settings.row.interface_lang")}),e.jsx("div",{className:"flex gap-2",children:["zh-CN","en"].map(m=>e.jsx("button",{onClick:()=>ct(m),"data-testid":`lang-${m}`,"aria-pressed":Ae()===m,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${Ae()===m?U:K}`,children:m==="zh-CN"?"中文":"English"},m))})]}),e.jsxs("div",{className:L(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:l("settings.row.import_lang")}),e.jsx(_t,{})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.data")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(Lt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:l("settings.group.about")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsxs("div",{className:L(!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:l("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",Ct.version]})]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:l("settings.version.hint")})]})})]})]})})}function _t(){const[t,l]=n.useState("en"),[i,f]=n.useState(!1);n.useEffect(()=>{r.getSetting("pref_lang").then(o=>{o&&l(o),f(!0)})},[]);const v=async o=>{l(o),await r.setSetting("pref_lang",o)},c=[{code:"en",label:"English"},{code:"zh-CN",label:"简体中文"},{code:"zh-TW",label:"繁體中文"}];return i?e.jsx("div",{className:"flex gap-2","data-testid":"pref-lang-options",children:c.map(o=>e.jsx("button",{onClick:()=>v(o.code),"data-testid":`pref-lang-${o.code}`,"aria-pressed":t===o.code,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${t===o.code?U:K}`,children:o.label},o.code))}):null}function Et(){const t=ee(),[l,i]=n.useState(!1),[f,v]=n.useState(!1);n.useEffect(()=>{r.getSetting("flag_memory_system").then(o=>{i(o==="true"),v(!0)})},[]);const c=async()=>{const o=!l;i(o),await r.setSetting("flag_memory_system",String(o))};return f?e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(de,{checked:l,onChange:c,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 zt(){var le,pe,Z;const t=ee(),[l,i]=n.useState(!0),[f,v]=n.useState(!1),c=n.useSyncExternalStore(st,at),[o,j]=n.useState(!0),[w,p]=n.useState(!1),C=typeof window<"u"&&!!window.__lookatstudyWeb;n.useEffect(()=>{r.getSetting("companion_enabled").then(a=>{i(a!=="false"&&a!=="0"),v(!0)}),r.getSetting("companion_sfx").then(a=>{j(a!=="false"&&a!=="0")}),r.getSetting("companion_pet_mode").then(a=>{p(a==="1")})},[]);const b=async()=>{const a=!l;i(a),await r.setSetting("companion_enabled",String(a)),window.dispatchEvent(new Event("companion-config-changed"))},_=async()=>{const a=!o;j(a),await r.setSetting("companion_sfx",String(a)),window.dispatchEvent(new Event("companion-config-changed"))},D=async()=>{const a=!w;p(a),await r.setSetting("companion_pet_mode",a?"1":"0"),window.dispatchEvent(new Event("companion-config-changed"))},u=async a=>{a!==c.form&&(await r.setSetting("companion_form",a),window.dispatchEvent(new Event("companion-config-changed")))},[g,S]=n.useState([]),[y,A]=n.useState(!1),[k,E]=n.useState(null),[H,R]=n.useState(!1),[m,d]=n.useState(!1),[z,N]=n.useState(!1),[J,M]=n.useState(null),[W,$]=n.useState(!1),[T,me]=n.useState([]),[te,q]=n.useState(null),[G,se]=n.useState(null),[ae,oe]=n.useState(null),I=n.useCallback(async()=>{try{S((await window.api.companionPackList()).packs)}catch{}},[]),B=n.useCallback(async()=>{try{me((await window.api.shimejiList()).packs)}catch{}},[]);n.useEffect(()=>{I(),B();const a=()=>{I(),B()};return window.addEventListener("companion-config-changed",a),()=>window.removeEventListener("companion-config-changed",a)},[I,B]);const Y=async a=>{await r.shimejiActivate({id:a}),c.form!=="shimeji"&&await r.setSetting("companion_form","shimeji"),window.dispatchEvent(new Event("companion-config-changed")),await B(),await we()},ue=async(a,x)=>{await window.api.shimejiSetVehicle({id:a,vehicle:x}),await B(),await we()},xe=async a=>{await window.api.shimejiDelete({id:a}),q(null),await B(),await we()},Ne=async a=>{await window.api.companionPackActivate({id:a}),c.form!=="custom"&&await r.setSetting("companion_form","custom"),await Ee(),window.dispatchEvent(new Event("companion-config-changed"))},ne=async a=>{(await window.api.companionPackDelete({id:a})).formReset&&window.dispatchEvent(new Event("companion-config-changed")),E(null),oe(null),I()},he=async(a,x)=>{var P;await window.api.companionPackSetVehicle({id:a,vehicle:x}),await I(),(P=g.find(V=>V.id===a))!=null&&P.active&&(await Ee(),window.dispatchEvent(new Event("companion-config-changed")))};return f?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(de,{checked:l,onChange:b,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")})]})]}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{checked:o,onChange:_,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")})]})]}),!C&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{checked:w,onChange:D,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:[nt.filter(a=>a!=="custom"&&a!=="shimeji").map(a=>{const x=c.form===a;return e.jsxs("button",{type:"button",role:"radio","aria-checked":x,"data-testid":`companion-form-${a}`,onClick:()=>{u(a)},className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
8
8
  ${x?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,title:t(`companion.form.${a}.desc`),children:[e.jsx(it,{form:a,expression:"happy",pose:"float",size:64}),e.jsx("span",{className:`text-label ${x?"text-ink-strong font-medium":"text-ink-muted"}`,children:t(`companion.form.${a}.name`)})]},a)}),e.jsxs("button",{type:"button",role:"radio","aria-checked":c.form==="custom"&&g.some(a=>a.active),"data-testid":"companion-card-custom",onClick:()=>d(!0),title:t("companion.pick.custom.title"),className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
9
9
  ${c.form==="custom"&&g.some(a=>a.active)?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[(()=>{const a=g.find(x=>x.active);return a!=null&&a.thumb?e.jsx("img",{src:a.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 ${c.form==="custom"&&g.some(a=>a.active)?"text-ink-strong font-medium":"text-ink-muted"}`,children:((le=g.find(a=>a.active))==null?void 0:le.name)??t("companion.create.self.name")})]}),e.jsxs("button",{type:"button",role:"radio","aria-checked":c.form==="shimeji"&&T.some(a=>a.active),"data-testid":"companion-card-shimeji",onClick:()=>N(!0),title:t("companion.pick.shimeji.title"),className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
10
10
  ${c.form==="shimeji"&&T.some(a=>a.active)?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[(()=>{const a=T.find(x=>x.active);return a!=null&&a.iconBase64?e.jsx("img",{src:`data:image/png;base64,${a.iconBase64}`,alt:"",className:"h-14 w-14 object-contain"}):e.jsx("span",{className:"h-14 w-14 flex items-center justify-center text-caption text-ink-muted",children:"Shimeji"})})(),e.jsx("span",{className:`text-label max-w-20 truncate ${c.form==="shimeji"&&T.some(a=>a.active)?"text-ink-strong font-medium":"text-ink-muted"}`,children:((pe=T.find(a=>a.active))==null?void 0:pe.name)??"Shimeji"})]}),e.jsxs("button",{type:"button",role:"radio","aria-checked":!1,"data-testid":"companion-form-add","aria-label":t("companion.bots.add"),onClick:()=>R(!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(mt,{className:"w-6 h-6"})}),e.jsx("span",{className:"text-label text-ink-muted",children:t("companion.bots.add")})]})]}),k&&e.jsx(Re,{anchorRect:k.rect,message:t("companion.bots.deleteConfirm"),danger:!0,testid:"companion-pack-delete-confirm",onConfirm:()=>void ne(k.id),onCancel:()=>E(null)}),m&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":t("companion.pick.custom.title"),onClick:()=>d(!1),children:e.jsxs("div",{className:"relative w-full max-w-md max-h-[85dvh] flex flex-col rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4","data-testid":"custom-pack-list",onClick:a=>a.stopPropagation(),children:[e.jsx("div",{className:"text-body font-medium text-ink-strong mb-3",children:t("companion.pick.custom.title")}),e.jsxs("div",{className:"min-h-0 overflow-y-auto",children:[g.length===0?e.jsx("p",{className:"text-label text-ink-muted py-4 text-center",children:t("companion.pick.empty.custom")}):e.jsx("div",{className:"flex flex-col gap-1.5",children:g.map(a=>e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button","data-testid":`custom-pack-option-${a.id}`,onClick:()=>{Ne(a.id),d(!1)},className:`w-full flex items-center gap-2.5 rounded-xl border p-2 text-left motion-safe:transition-colors
@@ -1 +1 @@
1
- import{r as n,j as t}from"./index-jKxnKPxh.js";import{u as E,C as M,b as R,a as j}from"./main-C7vIrKEC.js";const c="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 B({kind:o,showProtocol:d=!0,testPrefix:a="custom",titleKey:p="settings.custom.form_title",modelPhKey:k="settings.custom.model_ph",testOverride:h,onSaved:N,onCancel:v}){const s=E(),[r,w]=n.useState(""),[b,C]=n.useState("openai-compatible"),[i,$]=n.useState(""),[u,S]=n.useState(""),[l,_]=n.useState(""),[f,K]=n.useState(!1),[x,y]=n.useState(!1),[m,g]=n.useState(null),T=async()=>{if(!(!i.trim()||!l.trim()||x)){y(!0),g(null);try{const e=h?await h({baseUrl:i.trim(),apiKey:u.trim(),model:l.trim()}):await j.testCustomProvider({label:r||s("settings.custom.test_label"),protocol:b,baseUrl:i.trim(),apiKey:u.trim()||void 0,defaultModel:l.trim()});g({ok:e.ok,detail:e.detail})}catch(e){g({ok:!1,detail:e instanceof Error?e.message:String(e)})}finally{y(!1)}}},U=async()=>{if(!(!r.trim()||!i.trim()||!l.trim()))try{const e=await j.createCustomProvider({label:r.trim(),kind:o,protocol:d?b:"openai-compatible",baseUrl:i.trim(),apiKey:u.trim()||void 0,defaultModel:l.trim(),vision:o==="llm"?f:void 0});N(e)}catch{}};return t.jsxs("div",{className:"space-y-2.5","data-testid":`${a}-provider-form`,children:[t.jsx("div",{className:"text-label font-bold text-ink-strong",children:s(p)}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:r,onChange:e=>w(e.target.value),placeholder:s("settings.custom.label_ph"),"data-testid":`${a}-label`,className:`${c} min-w-0 flex-1 px-2.5 py-1.5`}),d&&t.jsxs("select",{value:b,onChange:e=>C(e.target.value),"data-testid":`${a}-protocol`,className:`${c} px-2 py-1.5`,children:[t.jsx("option",{value:"openai-compatible",children:s("settings.proto.openai")}),t.jsx("option",{value:"anthropic",children:"Anthropic"}),t.jsx("option",{value:"google",children:"Google"})]})]}),t.jsx("input",{type:"text",value:i,onChange:e=>$(e.target.value),placeholder:s("settings.custom.baseurl_ph"),"data-testid":`${a}-baseurl`,className:`${c} w-full px-2.5 py-1.5 font-mono`}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:l,onChange:e=>_(e.target.value),placeholder:s(k),"data-testid":`${a}-model`,className:`${c} min-w-0 flex-1 px-2.5 py-1.5 font-mono`}),t.jsx("input",{type:"password",value:u,onChange:e=>S(e.target.value),placeholder:s("settings.custom.apikey_ph"),"data-testid":`${a}-apikey`,className:`${c} min-w-0 flex-1 px-2.5 py-1.5`})]}),o==="llm"&&t.jsxs("label",{className:"inline-flex items-center gap-2 text-label cursor-pointer select-none","data-testid":`${a}-vision`,children:[t.jsx("input",{type:"checkbox",checked:f,onChange:e=>K(e.target.checked),className:"w-4 h-4 rounded accent-brand"}),t.jsx("span",{className:"text-ink-strong",children:s("settings.custom.vision")}),t.jsx("span",{className:"text-ink-faint",children:s("settings.custom.visionHint")})]}),m&&t.jsxs("div",{className:`text-label rounded p-2 inline-flex items-start gap-1.5 ${m.ok?"bg-brand/10 text-brand":"bg-warning/10 text-warning"}`,children:[m.ok?t.jsx(M,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}):t.jsx(R,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"break-words",children:m.detail})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>void T(),disabled:!i.trim()||!l.trim()||x,"data-testid":`${a}-test`,className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:s(x?"settings.testing":"settings.test")}),t.jsx("button",{onClick:()=>void U(),disabled:!r.trim()||!i.trim()||!l.trim(),"data-testid":`${a}-save`,className:"btn-3d-brand px-3 py-1.5 text-label disabled:opacity-40",children:s("settings.custom.save")}),v&&t.jsx("button",{onClick:v,className:"text-label text-ink-muted hover:text-ink-strong px-3 py-1.5 transition-colors",children:s("action.cancel")})]})]})}function F({checked:o,onChange:d,label:a,testid:p}){return t.jsx("button",{type:"button",role:"switch","aria-checked":o,"aria-label":a,onClick:d,"data-testid":p,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)] ${o?"bg-brand":"bg-ink/20 hover:bg-ink/25"}`,children:t.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 ${o?"translate-x-6":""}`})})}export{B as C,F as T};
1
+ import{r as n,j as t}from"./index-jKxnKPxh.js";import{u as E,C as M,b as R,a as j}from"./main-Bwe-ngM3.js";const c="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 B({kind:o,showProtocol:d=!0,testPrefix:a="custom",titleKey:p="settings.custom.form_title",modelPhKey:k="settings.custom.model_ph",testOverride:h,onSaved:N,onCancel:v}){const s=E(),[r,w]=n.useState(""),[b,C]=n.useState("openai-compatible"),[i,$]=n.useState(""),[u,S]=n.useState(""),[l,_]=n.useState(""),[f,K]=n.useState(!1),[x,y]=n.useState(!1),[m,g]=n.useState(null),T=async()=>{if(!(!i.trim()||!l.trim()||x)){y(!0),g(null);try{const e=h?await h({baseUrl:i.trim(),apiKey:u.trim(),model:l.trim()}):await j.testCustomProvider({label:r||s("settings.custom.test_label"),protocol:b,baseUrl:i.trim(),apiKey:u.trim()||void 0,defaultModel:l.trim()});g({ok:e.ok,detail:e.detail})}catch(e){g({ok:!1,detail:e instanceof Error?e.message:String(e)})}finally{y(!1)}}},U=async()=>{if(!(!r.trim()||!i.trim()||!l.trim()))try{const e=await j.createCustomProvider({label:r.trim(),kind:o,protocol:d?b:"openai-compatible",baseUrl:i.trim(),apiKey:u.trim()||void 0,defaultModel:l.trim(),vision:o==="llm"?f:void 0});N(e)}catch{}};return t.jsxs("div",{className:"space-y-2.5","data-testid":`${a}-provider-form`,children:[t.jsx("div",{className:"text-label font-bold text-ink-strong",children:s(p)}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:r,onChange:e=>w(e.target.value),placeholder:s("settings.custom.label_ph"),"data-testid":`${a}-label`,className:`${c} min-w-0 flex-1 px-2.5 py-1.5`}),d&&t.jsxs("select",{value:b,onChange:e=>C(e.target.value),"data-testid":`${a}-protocol`,className:`${c} px-2 py-1.5`,children:[t.jsx("option",{value:"openai-compatible",children:s("settings.proto.openai")}),t.jsx("option",{value:"anthropic",children:"Anthropic"}),t.jsx("option",{value:"google",children:"Google"})]})]}),t.jsx("input",{type:"text",value:i,onChange:e=>$(e.target.value),placeholder:s("settings.custom.baseurl_ph"),"data-testid":`${a}-baseurl`,className:`${c} w-full px-2.5 py-1.5 font-mono`}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{type:"text",value:l,onChange:e=>_(e.target.value),placeholder:s(k),"data-testid":`${a}-model`,className:`${c} min-w-0 flex-1 px-2.5 py-1.5 font-mono`}),t.jsx("input",{type:"password",value:u,onChange:e=>S(e.target.value),placeholder:s("settings.custom.apikey_ph"),"data-testid":`${a}-apikey`,className:`${c} min-w-0 flex-1 px-2.5 py-1.5`})]}),o==="llm"&&t.jsxs("label",{className:"inline-flex items-center gap-2 text-label cursor-pointer select-none","data-testid":`${a}-vision`,children:[t.jsx("input",{type:"checkbox",checked:f,onChange:e=>K(e.target.checked),className:"w-4 h-4 rounded accent-brand"}),t.jsx("span",{className:"text-ink-strong",children:s("settings.custom.vision")}),t.jsx("span",{className:"text-ink-faint",children:s("settings.custom.visionHint")})]}),m&&t.jsxs("div",{className:`text-label rounded p-2 inline-flex items-start gap-1.5 ${m.ok?"bg-brand/10 text-brand":"bg-warning/10 text-warning"}`,children:[m.ok?t.jsx(M,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}):t.jsx(R,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"break-words",children:m.detail})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:()=>void T(),disabled:!i.trim()||!l.trim()||x,"data-testid":`${a}-test`,className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:s(x?"settings.testing":"settings.test")}),t.jsx("button",{onClick:()=>void U(),disabled:!r.trim()||!i.trim()||!l.trim(),"data-testid":`${a}-save`,className:"btn-3d-brand px-3 py-1.5 text-label disabled:opacity-40",children:s("settings.custom.save")}),v&&t.jsx("button",{onClick:v,className:"text-label text-ink-muted hover:text-ink-strong px-3 py-1.5 transition-colors",children:s("action.cancel")})]})]})}function F({checked:o,onChange:d,label:a,testid:p}){return t.jsx("button",{type:"button",role:"switch","aria-checked":o,"aria-label":a,onClick:d,"data-testid":p,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)] ${o?"bg-brand":"bg-ink/20 hover:bg-ink/25"}`,children:t.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 ${o?"translate-x-6":""}`})})}export{B as C,F as T};
@@ -1,4 +1,4 @@
1
- import{r as n,j as e}from"./index-jKxnKPxh.js";import{c as f,u as h,f as b,g}from"./main-C7vIrKEC.js";import{R as j}from"./rotate-ccw-DHjeGlQd.js";/**
1
+ import{r as n,j as e}from"./index-jKxnKPxh.js";import{c as f,u as h,f as b,g}from"./main-Bwe-ngM3.js";import{R as j}from"./rotate-ccw-DjLv5683.js";/**
2
2
  * @license lucide-react v0.468.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-SVP7TREG-CLk3nYlu.js";import{p as f}from"./chunk-JWPE2WC7-Cjsal04r.js";import{_ as n,l as o}from"./mermaid.core-B8uFE6gu.js";import"./transform-Bd_a5eGM.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-BnU7sKRp.js";import"./main-C7vIrKEC.js";import"./index-jKxnKPxh.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},I={parser:R,db:a,renderer:u,styles:p};export{I as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-SVP7TREG-S8N2_Tii.js";import{p as f}from"./chunk-JWPE2WC7-DdTAe5_k.js";import{_ as n,l as o}from"./mermaid.core-DfcXYaBE.js";import"./transform-Bd_a5eGM.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-BkB-LB8l.js";import"./main-Bwe-ngM3.js";import"./index-jKxnKPxh.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},I={parser:R,db:a,renderer:u,styles:p};export{I as diagram};
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-XCWWM2C3-CGZOunzF.js";import{p as f}from"./chunk-VII2H2IX-D9ZFtXPz.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-GVF3BKWE-C0Fp61PQ.js";import{_ as n,l as o}from"./render-O7CIS3YK-DU3B_ERD.js";import"./transform-Bd_a5eGM.js";import"./mermaid-layout-elk.core-DfOj66Qv.js";import"./main-C7vIrKEC.js";import"./index-jKxnKPxh.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),m=t?parseInt(t,10):0,l=s?parseInt(s,10):1/0;return{min:m,max:l}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},D={parser:R,db:a,renderer:u,styles:p};export{D as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-XCWWM2C3-gAY--_6y.js";import{p as f}from"./chunk-VII2H2IX-qahGaA3g.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-GVF3BKWE-D0wGTJgs.js";import{_ as n,l as o}from"./render-O7CIS3YK-BjDBnwGB.js";import"./transform-Bd_a5eGM.js";import"./mermaid-layout-elk.core-B4Ud-kMJ.js";import"./main-Bwe-ngM3.js";import"./index-jKxnKPxh.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),m=t?parseInt(t,10):0,l=s?parseInt(s,10):1/0;return{min:m,max:l}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},D={parser:R,db:a,renderer:u,styles:p};export{D as diagram};