lookatstudy-mobile 0.37.2 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/model-catalog.json +9025 -0
- package/package.json +1 -1
- package/server.cjs +1075 -564
- package/web/assets/{CanvasStage-By84li0a.js → CanvasStage-vallbGco.js} +1 -1
- package/web/assets/{CommandPalette-DJpv5YLk.js → CommandPalette-Kyu6mhyt.js} +1 -1
- package/web/assets/{CompanionBotLab-BrjON5X5.js → CompanionBotLab-DHmGbQJd.js} +1 -1
- package/web/assets/{CourseSearchPanel-Dp-83TJq.js → CourseSearchPanel-CrpFIaU8.js} +2 -2
- package/web/assets/{ExamView-BiWyQCTQ.js → ExamView-BBwDRS1g.js} +1 -1
- package/web/assets/{MermaidArtifact-C-9JGr1S.js → MermaidArtifact-x5kLLb52.js} +3 -3
- package/web/assets/ModelManagerModal-CHz1i5v2.js +6 -0
- package/web/assets/{PersonalProfileModal-Bberh-21.js → PersonalProfileModal-DJdHOMH9.js} +2 -2
- package/web/assets/{ReviewPanel-D52vKY80.js → ReviewPanel-BJhoJAOK.js} +1 -1
- package/web/assets/SettingsView-COw_GSOo.js +15 -0
- package/web/assets/Toggle-Bkokw_WS.js +1 -0
- package/web/assets/{VoicePanel-Df6DgExP.js → VoicePanel-DPrlBZ48.js} +1 -1
- package/web/assets/{abnfDiagram-VCTEODGH-xWn5W_Em.js → abnfDiagram-VCTEODGH-DXAHXtdM.js} +1 -1
- package/web/assets/{abnfDiagram-VCTEODGH-ODA7YWAP-GEEhu7or.js → abnfDiagram-VCTEODGH-ODA7YWAP-BdHlSP1w.js} +1 -1
- package/web/assets/api-web-BhgWWd1h.js +1 -0
- package/web/assets/{architectureDiagram-5GKGNRK7-C4PU3XN7-JmOGh5LH.js → architectureDiagram-5GKGNRK7-C4PU3XN7-B4RCVI81.js} +1 -1
- package/web/assets/{architectureDiagram-5GKGNRK7-CvI35bTW.js → architectureDiagram-5GKGNRK7-DViQRgRS.js} +1 -1
- package/web/assets/{blockDiagram-I7D4REHJ-BMKUeuF0.js → blockDiagram-I7D4REHJ-Bm4Jv7XO.js} +1 -1
- package/web/assets/{blockDiagram-NRAW4CY4-UMJ6PMQQ-Dv4-Yiui.js → blockDiagram-NRAW4CY4-UMJ6PMQQ-dOUZFc-F.js} +1 -1
- package/web/assets/{c4Diagram-7LVT6UL2-DNalANVV.js → c4Diagram-7LVT6UL2-Cn_bbm4P.js} +1 -1
- package/web/assets/{c4Diagram-UCG6FXSJ-75X3U2P3-BMz228D6.js → c4Diagram-UCG6FXSJ-75X3U2P3-DgytixUD.js} +1 -1
- package/web/assets/channel-D_-re5YU.js +1 -0
- package/web/assets/{chunk-2Q5K7J3B-M3FYrmxX.js → chunk-2Q5K7J3B-hNQuZg4_.js} +1 -1
- package/web/assets/{chunk-5VM5RSS4-nbGREPjw.js → chunk-5VM5RSS4-DwAMOseZ.js} +1 -1
- package/web/assets/{chunk-7XDTSPCN-rYhyRTOx.js → chunk-7XDTSPCN-COFFwjaS.js} +1 -1
- package/web/assets/{chunk-CTNIYPP6-BgXYMFW5.js → chunk-CTNIYPP6-B3zyRQW8.js} +1 -1
- package/web/assets/{chunk-CXNFBKHE-CkmFhBAk.js → chunk-CXNFBKHE-C91q6lvg.js} +1 -1
- package/web/assets/{chunk-F27PBJKO-CAqAYmMM.js → chunk-F27PBJKO-ia4EagnF.js} +1 -1
- package/web/assets/{chunk-IMKFNOWR-pDBbu4GI.js → chunk-IMKFNOWR-vd22BhM5.js} +1 -1
- package/web/assets/{chunk-ISA7TJRJ-CHl4BhBt.js → chunk-ISA7TJRJ-BReqmCMw.js} +1 -1
- package/web/assets/{chunk-JWPE2WC7-DSVI_4gB.js → chunk-JWPE2WC7-Cjsal04r.js} +1 -1
- package/web/assets/{chunk-LV3HUYFY-Doco33ZI.js → chunk-LV3HUYFY-D2A9VNi8.js} +1 -1
- package/web/assets/{chunk-M3IUQBOH-RTAJkyza.js → chunk-M3IUQBOH-DZWUYlu1.js} +1 -1
- package/web/assets/{chunk-NDIOYS4C-DcWvuy8G.js → chunk-NDIOYS4C-Cg_gB3IQ.js} +1 -1
- package/web/assets/{chunk-POPQ4Y6H-yjjWWA8X.js → chunk-POPQ4Y6H-CpFBYm4R.js} +1 -1
- package/web/assets/{chunk-RE4WF27V-C32wZGPA.js → chunk-RE4WF27V-DJhALSJZ.js} +1 -1
- package/web/assets/{chunk-SVP7TREG-BdekvWAw.js → chunk-SVP7TREG-CLk3nYlu.js} +1 -1
- package/web/assets/{chunk-TICWLB2K-Cz68TTKA.js → chunk-TICWLB2K-CAAm7rEI.js} +1 -1
- package/web/assets/{chunk-VII2H2IX-fTD7U-xL.js → chunk-VII2H2IX-D9ZFtXPz.js} +1 -1
- package/web/assets/{chunk-X5GNSKZ3-16RMlpb5.js → chunk-X5GNSKZ3-BRpQXOuk.js} +1 -1
- package/web/assets/{chunk-XCWWM2C3-CO-wuQPY.js → chunk-XCWWM2C3-CGZOunzF.js} +1 -1
- package/web/assets/{chunk-XXDRQBXY-DPkBKESf.js → chunk-XXDRQBXY-IwMJhHxA.js} +1 -1
- package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-DsXVuA3q.js +1 -0
- package/web/assets/classDiagram-ZZMXUADV-mIT3v2vU.js +1 -0
- package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-DsXVuA3q.js +1 -0
- package/web/assets/classDiagram-v2-VYDZK3BY-mIT3v2vU.js +1 -0
- package/web/assets/{core-CQhot3Yw.js → core-KfkXlXB0.js} +1 -1
- package/web/assets/{cose-bilkent-JH36ORCC-NQkKxkmm.js → cose-bilkent-JH36ORCC-CvvDvDJy.js} +1 -1
- package/web/assets/{cose-bilkent-JH36ORCC-OB24KH3T-71WGRXpy.js → cose-bilkent-JH36ORCC-OB24KH3T-C0vuvt-a.js} +1 -1
- package/web/assets/{cynefin-OW5HDTMX-Ycd8yaFB.js → cynefin-OW5HDTMX-BnU7sKRp.js} +1 -1
- package/web/assets/{cynefin-OW5HDTMX-GVF3BKWE-wLMpc-W6.js → cynefin-OW5HDTMX-GVF3BKWE-C0Fp61PQ.js} +1 -1
- package/web/assets/{cynefinDiagram-5FMLGOSQ-qdatKGJp.js → cynefinDiagram-5FMLGOSQ-Ci7ijXRa.js} +1 -1
- package/web/assets/{cynefinDiagram-5FMLGOSQ-H3WIRU3N-BqUnto1I.js → cynefinDiagram-5FMLGOSQ-H3WIRU3N-BG1dQkD8.js} +1 -1
- package/web/assets/{dagre-3AP2YEHR-DCERTXHT-DU7hl9mL.js → dagre-3AP2YEHR-DCERTXHT-SRdJ45ZG.js} +1 -1
- package/web/assets/{dagre-GXQ25YYZ-DXBvPLCC.js → dagre-GXQ25YYZ-a6zLLMCL.js} +1 -1
- package/web/assets/{diagram-S7CK7UJ4-CJndlA9d.js → diagram-S7CK7UJ4-DwGQoHs5.js} +1 -1
- package/web/assets/{diagram-S7CK7UJ4-MULGZGEL-ChZOJtIr.js → diagram-S7CK7UJ4-MULGZGEL-DFbcMEGe.js} +1 -1
- package/web/assets/{diagram-UQ7AKVKN-ByEgUbMO.js → diagram-UQ7AKVKN-DObuhRvP.js} +1 -1
- package/web/assets/{diagram-UQ7AKVKN-YQBY353J-CBg1xAIv.js → diagram-UQ7AKVKN-YQBY353J-f7iJnEEP.js} +1 -1
- package/web/assets/{diagram-VSXAHHWV-DG9QiDXM.js → diagram-VSXAHHWV-Ctso7LL9.js} +1 -1
- package/web/assets/{diagram-VSXAHHWV-WLNH2ELY-BmmwN3nm.js → diagram-VSXAHHWV-WLNH2ELY-DwsW9ccQ.js} +1 -1
- package/web/assets/{diagram-VX7I27RA-D5I8_1IH.js → diagram-VX7I27RA-B1-W9xu6.js} +1 -1
- package/web/assets/{diagram-VX7I27RA-XW6YQV5G-BpJ1XA39.js → diagram-VX7I27RA-XW6YQV5G-DckTcRvE.js} +1 -1
- package/web/assets/{diagram-Z3DM3KII-BgBYUzLO.js → diagram-Z3DM3KII-CvmndeRP.js} +1 -1
- package/web/assets/{diagram-Z3DM3KII-HG7RF65D-DvYaKe9o.js → diagram-Z3DM3KII-HG7RF65D-Cg1XNNOC.js} +1 -1
- package/web/assets/{ebnfDiagram-PWID7BFC-BvljgvDM.js → ebnfDiagram-PWID7BFC-Cs9GSL14.js} +1 -1
- package/web/assets/{ebnfDiagram-PWID7BFC-OKY4VHYD-Cnq_rs5C.js → ebnfDiagram-PWID7BFC-OKY4VHYD-C0q6BGVW.js} +1 -1
- package/web/assets/{elk.bundled-DuC4qO17.js → elk.bundled-Cez1bZui.js} +1 -1
- package/web/assets/{erDiagram-RLTQ6QDP-CuGCxm27.js → erDiagram-RLTQ6QDP-CvYV5Bmu.js} +1 -1
- package/web/assets/{erDiagram-SSCWMZ5O-PIPKOIK7-DWea4HYD.js → erDiagram-SSCWMZ5O-PIPKOIK7-Di0McTkf.js} +1 -1
- package/web/assets/{flowDiagram-A5DVABFB-2Z4AVO5R-Bt5oLSB0.js → flowDiagram-A5DVABFB-2Z4AVO5R-C_7fHJVS.js} +1 -1
- package/web/assets/{flowDiagram-HODETNUW-ChwXi3ep.js → flowDiagram-HODETNUW-CEwpjqJR.js} +1 -1
- package/web/assets/{ganttDiagram-EL5Y4UJY-Cip61aQW.js → ganttDiagram-EL5Y4UJY-Bjj2P85p.js} +1 -1
- package/web/assets/{ganttDiagram-EL5Y4UJY-JZNG7GOG-DIt3-EPi.js → ganttDiagram-EL5Y4UJY-JZNG7GOG-BWxHKrFA.js} +1 -1
- package/web/assets/{gitGraphDiagram-WWUBYQGX-DMWMLL3G-CsyX4tkZ.js → gitGraphDiagram-WWUBYQGX-DMWMLL3G-D4hn_rGb.js} +1 -1
- package/web/assets/{gitGraphDiagram-WWUBYQGX-BGE_KKwm.js → gitGraphDiagram-WWUBYQGX-DhH7fsJW.js} +1 -1
- package/web/assets/index-CS4Wtfwl.css +1 -0
- package/web/assets/{index-D3SI1A7X.js → index-DcWGv1Ix.js} +2 -2
- package/web/assets/{index-48coRDBX.js → index-eHVYJyBS.js} +4 -4
- package/web/assets/{index-CatQea2M.js → index-nwyPdk23.js} +1 -1
- package/web/assets/{infoDiagram-27XIBGKW-CHFCryER.js → infoDiagram-27XIBGKW-DDm2aahL.js} +1 -1
- package/web/assets/{infoDiagram-RXCK75RN-HANS5KVC-ocLW6L6_.js → infoDiagram-RXCK75RN-HANS5KVC-CwBcehVD.js} +1 -1
- package/web/assets/{ishikawaDiagram-5VMMS53U-7GCIT7WU-BUo_yhnm.js → ishikawaDiagram-5VMMS53U-7GCIT7WU-CBAcnlnt.js} +1 -1
- package/web/assets/{ishikawaDiagram-5VMMS53U-Bhg1TVZJ.js → ishikawaDiagram-5VMMS53U-BViel9G3.js} +1 -1
- package/web/assets/{journeyDiagram-3NMN7TZE-C3OfUgiV.js → journeyDiagram-3NMN7TZE-CO3lCO75.js} +1 -1
- package/web/assets/{journeyDiagram-EYS64GPL-OAPELBT7-DQESZnLZ.js → journeyDiagram-EYS64GPL-OAPELBT7-sBJrBBzK.js} +1 -1
- package/web/assets/{kanban-definition-3QL26DDD-I7RKWQQY-BF-ZXqR5.js → kanban-definition-3QL26DDD-I7RKWQQY-hit6oZsH.js} +1 -1
- package/web/assets/{kanban-definition-UXKFOSKX-CSI_GcJW.js → kanban-definition-UXKFOSKX-CKgCw87L.js} +1 -1
- package/web/assets/{katex-N6JRN4PM-CxrguQd-.js → katex-N6JRN4PM-D81co42V.js} +1 -1
- package/web/assets/{layout-CDbDCQeb.js → layout-Gnf9u57J.js} +1 -1
- package/web/assets/{main-jV_OilRs.js → main-C7vIrKEC.js} +120 -120
- package/web/assets/{mermaid-layout-elk.core-B1-o2tyd.js → mermaid-layout-elk.core-DfOj66Qv.js} +2 -2
- package/web/assets/{mermaid.core-37_hzSNp.js → mermaid.core-B8uFE6gu.js} +5 -5
- package/web/assets/{mindmap-definition-FBJOCRG2-KIYZG64Y-rppk7mo-.js → mindmap-definition-FBJOCRG2-KIYZG64Y-DdU7WsWK.js} +1 -1
- package/web/assets/{mindmap-definition-YA3MSWOX-BUzaoDCs.js → mindmap-definition-YA3MSWOX-Dlr3j6bz.js} +1 -1
- package/web/assets/{pegDiagram-XKGWAZYB-CQPL5MMj.js → pegDiagram-XKGWAZYB-DUukoOjY.js} +1 -1
- package/web/assets/{pegDiagram-XKGWAZYB-OIP57N6J-CngQPdjr.js → pegDiagram-XKGWAZYB-OIP57N6J-ClyIfOjy.js} +1 -1
- package/web/assets/{pet-xGooCXVY.js → pet-7_82JHov.js} +1 -1
- package/web/assets/{pieDiagram-E7YTZNPT-2UOTW327-DkHaDPtZ.js → pieDiagram-E7YTZNPT-2UOTW327-CXr_-LKy.js} +1 -1
- package/web/assets/{pieDiagram-E7YTZNPT-BDTdqFkm.js → pieDiagram-E7YTZNPT-BoX73GVV.js} +1 -1
- package/web/assets/{quadrantDiagram-AXDQQJYC-SN3ASJJK-KFKnY5SQ.js → quadrantDiagram-AXDQQJYC-SN3ASJJK-BfJPVLX8.js} +1 -1
- package/web/assets/{quadrantDiagram-AXDQQJYC-CXFhoJ1v.js → quadrantDiagram-AXDQQJYC-fWVY4hSA.js} +1 -1
- package/web/assets/{railroadDiagram-O6MQD6OU-34742W6X-BMHll5kZ.js → railroadDiagram-O6MQD6OU-34742W6X-LEvRYv_-.js} +1 -1
- package/web/assets/{railroadDiagram-O6MQD6OU-DdZMZ3P-.js → railroadDiagram-O6MQD6OU-BtJHgxH_.js} +1 -1
- package/web/assets/{render-O7CIS3YK-BUZqrLRp.js → render-O7CIS3YK-DU3B_ERD.js} +7 -7
- package/web/assets/{requirementDiagram-BXWQKSXE-WrY_I6-V.js → requirementDiagram-BXWQKSXE-DeBI9tYJ.js} +1 -1
- package/web/assets/{requirementDiagram-EFPCY7ZU-NGAFFSMB-CmLM20oA.js → requirementDiagram-EFPCY7ZU-NGAFFSMB-DDu5KaVc.js} +1 -1
- package/web/assets/{rotate-ccw-DZE_kYZu.js → rotate-ccw-DHjeGlQd.js} +1 -1
- package/web/assets/{sankeyDiagram-P5KCCOFB-3D3M4XPB-RJsf4h9t.js → sankeyDiagram-P5KCCOFB-3D3M4XPB-CuAwPvR9.js} +1 -1
- package/web/assets/{sankeyDiagram-P5KCCOFB-Bjyi_fcC.js → sankeyDiagram-P5KCCOFB-Cn7EgJJg.js} +1 -1
- package/web/assets/{sequenceDiagram-WJ2MYXX4-Co6SKGyz.js → sequenceDiagram-WJ2MYXX4-Cc4unhAQ.js} +1 -1
- package/web/assets/{sequenceDiagram-WJ2MYXX4-Q2IOPB4R-B5nuUy2h.js → sequenceDiagram-WJ2MYXX4-Q2IOPB4R-Bhw9XiPP.js} +1 -1
- package/web/assets/{sizeCapture-INFHLROL-CF0_wtm2.js → sizeCapture-INFHLROL-D5ATuvis.js} +1 -1
- package/web/assets/{sizeCapture-X5ZJPWSS-PSGVOMYM-xWY2H6Me.js → sizeCapture-X5ZJPWSS-PSGVOMYM-pk47pQ9r.js} +1 -1
- package/web/assets/{stateDiagram-D77RDMKH-5V-346Qd.js → stateDiagram-D77RDMKH-CQSVKJos.js} +1 -1
- package/web/assets/{stateDiagram-HBIQ2CUA-4M2S6MAN-B6gqxipM.js → stateDiagram-HBIQ2CUA-4M2S6MAN-CtK20myG.js} +1 -1
- package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-z3Zfnb5n.js +1 -0
- package/web/assets/stateDiagram-v2-MP3YSRHH-BEw4hFwV.js +1 -0
- package/web/assets/{swimlanes-42K2YHIH-D9gzHPsn.js → swimlanes-42K2YHIH-C_TtTWTU.js} +1 -1
- package/web/assets/{swimlanes-XN3QIQJK-N6N2CCQ6-rlPeyqTj.js → swimlanes-XN3QIQJK-N6N2CCQ6-BcUMswQj.js} +1 -1
- package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-D6SdGCA2.js +8 -0
- package/web/assets/swimlanesDiagram-VR7AAH4N-BCgYwpZp.js +8 -0
- package/web/assets/{timeline-definition-24CTP7MA-B2GfJfmd.js → timeline-definition-24CTP7MA-DUWrxPBR.js} +1 -1
- package/web/assets/{timeline-definition-24CTP7MA-KN7RSRVM-CKXP2kGU.js → timeline-definition-24CTP7MA-KN7RSRVM-guNGP5k9.js} +1 -1
- package/web/assets/{vennDiagram-4TSXK5OY-AKJ7LXAN-CybCMyEX.js → vennDiagram-4TSXK5OY-AKJ7LXAN-CqrpJGZz.js} +1 -1
- package/web/assets/{vennDiagram-4TSXK5OY-DkP-OS8t.js → vennDiagram-4TSXK5OY-DpAMU-X3.js} +1 -1
- package/web/assets/{wardleyDiagram-VM6X3IG4-3B6A3BN5-BdgAi1Gp.js → wardleyDiagram-VM6X3IG4-3B6A3BN5-CvLFmNdB.js} +1 -1
- package/web/assets/{wardleyDiagram-VM6X3IG4-DvRT9ehw.js → wardleyDiagram-VM6X3IG4-CwLky2tH.js} +1 -1
- package/web/assets/{xychartDiagram-S5SC5T6Z-D0gQ0QKw.js → xychartDiagram-S5SC5T6Z-C0uS7jlH.js} +1 -1
- package/web/assets/{xychartDiagram-S5SC5T6Z-OBDNV6WG-23Q1AKCq.js → xychartDiagram-S5SC5T6Z-OBDNV6WG-DUua3NqS.js} +1 -1
- package/web/index.html +3 -3
- package/web/pet.html +3 -3
- package/web/assets/SettingsView-BE8J-BR5.js +0 -20
- package/web/assets/api-web-ChIPnpHO.js +0 -1
- package/web/assets/channel-BsRXIHWg.js +0 -1
- package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-BwnHfZhN.js +0 -1
- package/web/assets/classDiagram-ZZMXUADV-BBeyyi3H.js +0 -1
- package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-BwnHfZhN.js +0 -1
- package/web/assets/classDiagram-v2-VYDZK3BY-BBeyyi3H.js +0 -1
- package/web/assets/index-EInfxfl9.css +0 -1
- package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-DnphY6WO.js +0 -1
- package/web/assets/stateDiagram-v2-MP3YSRHH-DKtXGidN.js +0 -1
- package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-8pA5lT4C.js +0 -8
- package/web/assets/swimlanesDiagram-VR7AAH4N-B7BbPyRn.js +0 -8
- /package/web/assets/{index-C9fscARj.js → index-jKxnKPxh.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r,j as h}from"./index-
|
|
1
|
+
import{r,j as h}from"./index-jKxnKPxh.js";import{c as T,u as L,t as D}from"./main-C7vIrKEC.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-
|
|
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";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as G,r as v,j as c,o as ie,p as ce,c as le}from"./index-
|
|
1
|
+
import{u as G,r as v,j as c,o as ie,p as ce,c as le}from"./index-jKxnKPxh.js";function A(e,t){return{code:e,message:t}}function me(e,t={}){const n=t.minSide??256,u=t.maxSide??4096,i=t.marginRatio??.02,o=t.alphaThreshold??128,r=t.minBlobAreaRatio??.05,h=t.maxSamples??1e6,l=[],g=(s,p=0,w=0)=>({ok:!1,issues:s.map(([T,C])=>A(T,C)),opaqueRatio:p,blobCount:w}),{width:a,height:m,rgba:b}=e;if(!Number.isFinite(a)||!Number.isFinite(m)||a<=0||m<=0||!Number.isInteger(a)||!Number.isInteger(m))return g([["BAD_DIMENSIONS",`非法尺寸 ${a}x${m}`]]);if(Math.min(a,m)<n&&l.push(A("TOO_SMALL",`短边 ${Math.min(a,m)}px < ${n}px`)),Math.max(a,m)>u&&l.push(A("TOO_LARGE",`长边 ${Math.max(a,m)}px > ${u}px(导入时自动缩放)`)),!b||b.length!==a*m*4)return l.push(A("BAD_PIXEL_BUFFER",`rgba 长度 ${(b==null?void 0:b.length)??0} ≠ ${a}*${m}*4`)),{ok:!1,issues:l,opaqueRatio:0,blobCount:0};const x=Math.max(1,Math.ceil(Math.sqrt(a*m/h))),d=Math.floor((a-1)/x)+1,f=Math.floor((m-1)/x)+1,y=new Uint8Array(d*f);let L=0,M=0,N=255,S=d,R=-1,k=f,Y=-1;for(let s=0;s<f;s++){const p=s*x;for(let w=0;w<d;w++){const T=w*x,C=b[(p*a+T)*4+3];M++,C<N&&(N=C),C>=o&&(y[s*d+w]=1,L++,w<S&&(S=w),w>R&&(R=w),s<k&&(k=s),s>Y&&(Y=s))}}const J=M>0?L/M:0;if(L===0)return l.push(A("ALL_TRANSPARENT","整图无不透明像素(空图/坏抠图)")),{ok:l.length===0,issues:l,opaqueRatio:J,blobCount:0};if(N===255&&l.push(A("NO_ALPHA","未检出任何透明像素——需要透明底 PNG(可一键抠图/豆包抠图)")),S===0||k===0||R===d-1||Y===f-1){const s=a*i,p=m*i;(S*x<s||k*x<p||R*x+x-1>a-1-s||Y*x+x-1>m-1-p)&&l.push(A("EDGE_TOUCH","主体贴边——四周留 5~10% 空白,给跳跃/挤压变换留余地"))}const _=new Uint8Array(d*f),B=[],$=[];for(let s=0;s<y.length;s++){if(!y[s]||_[s])continue;let p=0,w=d,T=-1,C=f,O=-1;for($.push(s),_[s]=1;$.length>0;){const E=$.pop();p++;const P=E%d,X=(E-P)/d;P<w&&(w=P),P>T&&(T=P),X<C&&(C=X),X>O&&(O=X);const D=I=>{y[I]&&!_[I]&&(_[I]=1,$.push(I))};P>0&&D(E-1),P<d-1&&D(E+1),X>0&&D(E-d),X<f-1&&D(E+d)}B.push({area:p,minX:w,maxX:T,minY:C,maxY:O})}const se=B.length>0?Math.max(...B.map(s=>s.area)):0,Z=B.filter(s=>s.area>=se*r),re=(s,p)=>s.minX>=p.minX&&s.maxX<=p.maxX&&s.minY>=p.minY&&s.maxY<=p.maxY,oe=(s,p)=>{const w=Math.min(s.maxX,p.maxX)-Math.max(s.minX,p.minX),T=Math.min(s.maxY,p.maxY)-Math.max(s.minY,p.minY);if(w<=0||T<=0)return 0;const C=w*T,O=(s.maxX-s.minX+1)*(s.maxY-s.minY+1),E=(p.maxX-p.minX+1)*(p.maxY-p.minY+1);return C/Math.min(O,E)},F=Z.filter(s=>!Z.some(p=>p!==s&&p.area>=s.area&&(re(s,p)||oe(s,p)>=.4))).length;return F>=2&&l.push(A("MULTI_BLOB",`检出 ${F} 个独立主体——请裁剪到单角色`)),{ok:l.length===0,issues:l,opaqueRatio:J,blobCount:F}}function de(e){return typeof e.poseHoldMs=="number"?e.poseHoldMs:1200}const ue=""+new URL("alien-idle-D2VKjYsl.png",import.meta.url).href,fe=""+new URL("alien-happy-Ci3JfpxD.png",import.meta.url).href,he=""+new URL("alien-thinking-gWKA2xDz.png",import.meta.url).href,pe=""+new URL("alien-keyL-C_tZriGQ.png",import.meta.url).href,xe=""+new URL("alien-keyL-C_tZriGQ.png",import.meta.url).href,z=""+new URL("alien-head-CS10QxqG.png",import.meta.url).href,be=""+new URL("alien-body-DXq5WJRs.png",import.meta.url).href,j={head:{x:.3,y:.05,w:.4,h:.2726},body:{x:.3,y:.3226,w:.4,h:.2841}},ee={x:.5,y:.3226},ye={formatVersion:1,id:"lab-alien",name:"Lab 小宇航员(Kenney)",author:"Kenney",license:"CC0-1.0 (Kenney Platformer Characters)",tier:"bongo",states:{idle:"idle.png",keyL:"keyl.png",keyR:"keyr.png",happy:"happy.png",thinking:"thinking.png"},poseHoldMs:1100};async function ge(){const e={idle:ue,keyL:pe,keyR:xe,happy:fe,thinking:he},t=await we(z),n=document.createElement("canvas");n.width=512,n.height=512;const u=n.getContext("2d");u.drawImage(t,0,0);const i=u.getImageData(0,0,512,512),o=me({width:512,height:512,rgba:i.data});return{srcs:e,parts:{head:z,body:be},selfSpec:o}}function we(e){return new Promise((t,n)=>{const u=new Image;u.onload=()=>t(u),u.onerror=()=>n(new Error(`image load failed: ${e}`)),u.src=e})}function te(e,t,n){const{x:u,y:i,w:o,h:r,t:h,deform:l}=n,g=n.cols??6,a=n.rows??8,m=n.src??{x:0,y:0,w:t.width,h:t.height},b=[];for(let d=0;d<=a;d++)for(let f=0;f<=g;f++){const y=f/g,L=d/a,M=l(y,L,h);b.push([u+y*o+M.dx,i+L*r+M.dy])}const x=(d,f)=>b[f*(g+1)+d];for(let d=0;d<a;d++)for(let f=0;f<g;f++){const y=x(f,d),L=x(f+1,d),M=x(f,d+1),N=x(f+1,d+1),S=m.x+f/g*m.w,R=m.y+d/a*m.h,k=m.x+(f+1)/g*m.w,Y=m.y+(d+1)/a*m.h;ne(e,t,[S,R],[k,R],[S,Y],y,L,M),ne(e,t,[k,R],[k,Y],[S,Y],L,N,M)}}function ne(e,t,n,u,i,o,r,h){const l=(u[0]-n[0])*(i[1]-n[1])-(i[0]-n[0])*(u[1]-n[1]);if(Math.abs(l)<1e-8)return;const g=((r[0]-o[0])*(i[1]-n[1])-(h[0]-o[0])*(u[1]-n[1]))/l,a=((h[0]-o[0])*(u[0]-n[0])-(r[0]-o[0])*(i[0]-n[0]))/l,m=((r[1]-o[1])*(i[1]-n[1])-(h[1]-o[1])*(u[1]-n[1]))/l,b=((h[1]-o[1])*(u[0]-n[0])-(r[1]-o[1])*(i[0]-n[0]))/l,x=o[0]-g*n[0]-a*n[1],d=o[1]-m*n[0]-b*n[1];e.save(),e.beginPath(),e.moveTo(o[0],o[1]),e.lineTo(r[0],r[1]),e.lineTo(h[0],h[1]),e.closePath(),e.clip(),e.transform(g,m,a,b,x,d),e.drawImage(t,0,0),e.restore()}function K(e){const t=v.useRef(e);t.current=e,v.useEffect(()=>{const n={side:1},u=r=>{if(r.repeat)return;const h=ce(r.code,n.side);n.side=n.side===1?-1:1,t.current(h===1?"keyR":"keyL")},i=r=>t.current(r.detail?"thinking":"idle"),o=ie(r=>t.current(r.kind==="wrong"?"wrong":"happy"));return window.addEventListener("keydown",u,{passive:!0}),window.addEventListener("companion-streaming",i),()=>{window.removeEventListener("keydown",u),window.removeEventListener("companion-streaming",i),o()}},[])}function H(){const[e,t]=v.useState("idle"),n=v.useRef(null),u=v.useCallback((i,o=0)=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,t(i);const r=o>0?o:0;r>0&&i!=="idle"&&(n.current=window.setTimeout(()=>t("idle"),r))},[]);return v.useEffect(()=>()=>{n.current!==null&&window.clearTimeout(n.current)},[]),{pose:e,setTimed:u}}function Q(e,t){t||!e||typeof e.animate!="function"||e.animate([{transform:"translateY(0)"},{transform:"translateY(-12%)"},{transform:"translateY(2%)"},{transform:"translateY(0)"}],{duration:380,easing:"cubic-bezier(0.2, 1.4, 0.4, 1)"})}function V(e,t){t||!e||typeof e.animate!="function"||e.animate([{transform:"rotate(0deg)"},{transform:"rotate(-6deg)"},{transform:"rotate(6deg)"},{transform:"rotate(0deg)"}],{duration:280})}function q(e,t){t||!e||typeof e.animate!="function"||e.animate([{transform:"translateY(0px) scale(1, 1)"},{transform:"translateY(2.5px) scale(1.045, 0.93)",offset:.42},{transform:"translateY(0px) scale(1, 1)"}],{duration:185,easing:"ease-out",composite:"add"})}const W=`
|
|
2
2
|
.cbot { position: relative; display: inline-block; line-height: 0;
|
|
3
3
|
animation: cbot-breath 3.4s ease-in-out infinite; transform-origin: 50% 62%; }
|
|
4
4
|
.cbot img, .cbot canvas { display: block; user-select: none; }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{r as u,j as t}from"./index-
|
|
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";/**
|
|
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
|
-
*/const T=
|
|
6
|
+
*/const T=I("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);function B(e,i,n){return[...e].sort((r,c)=>r.orderIdx-c.orderIdx).map(r=>{const c=i.filter(l=>l.parentId===r.id).sort((l,a)=>l.orderIdx-a.orderIdx),d=c.filter(l=>l.type==="lesson"),h=d.length>0&&d.every(l=>{var a;return(((a=n[l.id])==null?void 0:a.mastery)??0)>=C});return{section:r,lessons:c,chapterLessonsMastered:h}})}function w(e,i,n){var r;return e.type==="exam"?!n:(((r=i[e.id])==null?void 0:r.status)??"locked")==="locked"}function $(e,i){const n=i.trim().toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e;const r=c=>{const d=c.toLowerCase();return n.every(h=>d.includes(h))};return e.map(c=>{if(r(c.section.title))return c;const d=c.lessons.filter(h=>r(h.title));return d.length>0?{...c,lessons:d}:null}).filter(c=>c!==null)}function H(e,i){const n=i.trim().split(/\s+/).filter(Boolean)[0];if(!n)return null;const r=e.toLowerCase().indexOf(n.toLowerCase());return r>=0?[r,r+n.length]:null}function D(e){const i=y(),[n,r]=u.useState(""),[c,d]=u.useState([]),h=u.useRef(null);u.useEffect(()=>{var s;(s=h.current)==null||s.focus()},[]);const l=u.useMemo(()=>B(e.sections,e.tree,e.progressMap),[e.sections,e.tree,e.progressMap]),a=u.useMemo(()=>$(l,n),[l,n]),x=u.useMemo(()=>new Set(e.tree.map(s=>s.id)),[e.tree]),f=u.useMemo(()=>new Set(a.flatMap(s=>s.lessons.map(o=>o.id))),[a]),g=u.useMemo(()=>new Map(e.tree.map(s=>[s.id,s])),[e.tree]),p=u.useMemo(()=>new Map(l.map(s=>[s.section.id,s.chapterLessonsMastered])),[l]);u.useEffect(()=>{const s=n.trim();if(s.length<2){d([]);return}const o=setTimeout(()=>{L.searchContent(s).then(m=>{d(m.filter(k=>x.has(k.nodeId)&&!f.has(k.nodeId)).slice(0,8))}).catch(()=>d([]))},250);return()=>clearTimeout(o)},[n,x,f]);const j=u.useMemo(()=>{for(const s of a){const o=s.lessons.find(m=>!w(m,e.progressMap,s.chapterLessonsMastered));if(o)return o}return null},[a,e.progressMap]),v=a.length>0||c.length>0;return t.jsxs("div",{"data-testid":"course-search-panel",className:"absolute inset-0 z-50 flex flex-col",style:{background:"rgb(var(--surface-rail-rgb) / 0.96)",backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)"},onKeyDown:s=>{s.key==="Escape"&&e.onClose()},children:[t.jsxs("div",{className:"flex items-center gap-1.5 m-2 p-1.5 rounded-lg bg-black/40 ring-1 ring-white/15 focus-within:ring-brand/60 transition-colors",children:[t.jsx(S,{className:"w-4 h-4 text-white/50 shrink-0"}),t.jsx("input",{ref:h,value:n,onChange:s=>r(s.target.value),onKeyDown:s=>{s.key==="Enter"&&j&&e.onJump(j)},placeholder:i("map.search.placeholder"),"data-testid":"course-search-input",className:"flex-1 bg-transparent text-body text-white placeholder:text-white/35 outline-none min-w-0"}),n&&t.jsx("button",{onClick:()=>{var s;r(""),(s=h.current)==null||s.focus()},"aria-label":i("map.search.clear"),className:"shrink-0 flex items-center justify-center w-5 h-5 rounded-md text-white/50 hover:text-white hover:bg-white/10 transition-colors",children:t.jsx(N,{className:"w-3.5 h-3.5"})}),t.jsx("button",{onClick:e.onClose,"data-testid":"course-search-close","aria-label":i("map.search.close"),className:"shrink-0 flex items-center justify-center w-5 h-5 rounded-md text-white/50 hover:text-white hover:bg-white/10 transition-colors",children:t.jsx(N,{className:"w-3.5 h-3.5"})})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-2 pb-3 space-y-2",children:[!v&&t.jsx("div",{"data-testid":"course-search-empty",className:"text-center text-label text-white/60 mt-8 px-4",children:i("map.search.noResults")}),a.map((s,o)=>t.jsx(F,{row:s,sectionIndex:o,query:n,progressMap:e.progressMap,selectedNodeId:e.selectedNodeId,onPick:e.onJump},s.section.id)),c.length>0&&t.jsxs("div",{"data-testid":"course-search-content-group",className:"pt-1",children:[t.jsx("div",{className:"px-1.5 py-1 text-caption font-bold text-white/50 uppercase tracking-wider",children:i("map.search.contentGroup")}),c.map(s=>{const o=g.get(s.nodeId);if(!o)return null;const m=w(o,e.progressMap,p.get(o.parentId??"")??!1);return t.jsxs("button",{disabled:m,"data-testid":`search-content-row-${o.id.slice(0,8)}`,onClick:()=>!m&&e.onJump(o),className:`w-full text-left px-2 py-1.5 rounded-lg transition-colors ${m?"opacity-45 cursor-not-allowed":"hover:bg-white/10 cursor-pointer"} ${o.id===e.selectedNodeId?"bg-accent/15 ring-1 ring-accent/40":""}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(M,{className:"w-3.5 h-3.5 text-white/70 shrink-0"}),t.jsx("span",{className:"flex-1 text-label font-bold text-white truncate",children:t.jsx(b,{text:s.title,query:n})})]}),t.jsx("div",{className:"text-caption text-white/55 line-clamp-2 leading-snug pl-5.5",children:s.snippet})]},s.nodeId)})]})]})]})}function F({row:e,sectionIndex:i,query:n,progressMap:r,selectedNodeId:c,onPick:d}){const h=y(),l=(e.section.world??"study")==="practice";return t.jsxs("div",{"data-testid":`search-section-${e.section.id.slice(0,8)}`,children:[t.jsxs("div",{className:"flex items-center gap-2 px-1.5 py-1",children:[t.jsx("span",{className:"w-5 h-5 rounded-full bg-gold text-neutral-900 text-caption font-extrabold flex items-center justify-center shrink-0 ring-2 ring-gold/40",children:i+1}),t.jsx("span",{className:"text-label font-bold text-white truncate flex-1",children:t.jsx(b,{text:e.section.title,query:n})}),l&&t.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-full bg-accent/20 text-accent text-caption font-bold",children:h("map.world.practice")})]}),e.lessons.map(a=>{var p;const x=w(a,r,e.chapterLessonsMastered),f=((p=r[a.id])==null?void 0:p.status)??"locked",g=a.type==="exam";return t.jsxs("button",{disabled:x,"data-testid":`search-row-${a.id.slice(0,8)}`,onClick:()=>!x&&d(a),className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left transition-colors ${x?"opacity-45 cursor-not-allowed":"hover:bg-white/10 cursor-pointer"} ${a.id===c?"bg-accent/15 ring-1 ring-accent/40":""}`,children:[x?t.jsx(T,{className:"w-3.5 h-3.5 text-white/50 shrink-0"}):g?t.jsx(E,{className:"w-3.5 h-3.5 text-accent shrink-0"}):f==="mastered"?t.jsx(R,{className:"w-3.5 h-3.5 text-gold shrink-0"}):t.jsx(M,{className:"w-3.5 h-3.5 text-white/70 shrink-0"}),t.jsx("span",{className:"flex-1 text-label text-white truncate",children:t.jsx(b,{text:a.title,query:n})})]},a.id)})]})}function b({text:e,query:i}){const n=H(e,i);return n?t.jsxs(t.Fragment,{children:[e.slice(0,n[0]),t.jsx("span",{className:"text-brand font-extrabold",children:e.slice(n[0],n[1])}),e.slice(n[1])]}):t.jsx(t.Fragment,{children:e})}export{D as CourseSearchPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as o,h as U,j as e,c as ie}from"./index-
|
|
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";/**
|
|
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-
|
|
2
|
-
import{r as o,j as t}from"./index-
|
|
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";/**
|
|
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-37_hzSNp.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-B1-o2tyd.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-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};
|
|
@@ -0,0 +1,6 @@
|
|
|
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";/**
|
|
2
|
+
* @license lucide-react v0.468.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ie=ee("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);function le(t,m,b,g=new Date().toISOString()){var f;const x=((f=t[m])==null?void 0:f.added)??[],i=new Set(x.map(k=>k.id.toLowerCase())),d=[...x];for(const k of b){if(!k.id)continue;const D=k.id.toLowerCase();i.has(D)||(i.add(D),d.push(k))}return{...t,[m]:{added:d,fetchedAt:g}}}function oe(t,m,b){const g=t[m];if(!g)return t;const x=g.added.filter(d=>d.id.toLowerCase()!==b.toLowerCase());if(x.length===g.added.length)return t;const i={...t};return x.length===0?delete i[m]:i[m]={...g,added:x},i}function Q(t){return t==null?"?":String(Number(t.toFixed(2)))}function re(t){const m=[];return t.contextWindow&&m.push(`${Math.round(t.contextWindow/1e3)}k`),t.pricing&&(t.pricing.input!==null||t.pricing.output!==null)&&m.push(`$${Q(t.pricing.input)}/${Q(t.pricing.output)}`),m.join(" · ")}function Z({providerId:t,existingModels:m,removableModels:b,customProvider:g,onApplied:x}){const i=R(),[d,f]=r.useState("idle"),[k,D]=r.useState([]),[E,v]=r.useState(null),[C,S]=r.useState(new Set),[M,L]=r.useState(""),[_,T]=r.useState(""),[N,h]=r.useState(!1),w=r.useMemo(()=>new Set(m.map(s=>s.id.toLowerCase())),[m]),P=r.useMemo(()=>{const s=M.trim().toLowerCase(),n=k.filter(p=>!w.has(p.id.toLowerCase()));return s?n.filter(p=>p.id.toLowerCase().includes(s)||p.label.toLowerCase().includes(s)):n},[k,M,w]),c=async()=>{f("fetching"),v(null),S(new Set);try{const s=await u.discoverModelsFor(t);s.ok&&s.models?(D(s.models),f("list")):(v(s.error??i("settings.models.discover_failed")),f("error"))}catch(s){v(s instanceof Error?s.message:String(s)),f("error")}},K=s=>{S(n=>{const p=new Set(n);return p.has(s)?p.delete(s):p.add(s),p})},l=async s=>{if(!(N||s.length===0)){h(!0);try{if(g){const n=[...g.models],p=new Set(n.map(W=>W.id.toLowerCase()));for(const W of s)p.has(W.id.toLowerCase())||(p.add(W.id.toLowerCase()),n.push(W));await u.updateCustomProvider(g.id,{models:n})}else{const n=await u.getModelOverlay();await u.setModelOverlay(le(n,t,s))}x(),window.dispatchEvent(new Event("llm-config-changed")),S(new Set),T("")}catch{}finally{h(!1)}}},j=async s=>{if(!N){h(!0);try{if(g){const n=g.models.filter(p=>p.id.toLowerCase()!==s.toLowerCase());await u.updateCustomProvider(g.id,{models:n})}else{const n=await u.getModelOverlay();await u.setModelOverlay(oe(n,t,s))}x(),window.dispatchEvent(new Event("llm-config-changed"))}catch{}finally{h(!1)}}},F=()=>{const s=_.trim();if(!s)return;const n=k.find(p=>p.id.toLowerCase()===s.toLowerCase());l([n??{id:s,label:s,contextWindow:null}])};return e.jsxs("div",{className:"space-y-2","data-testid":"model-discovery-panel",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{onClick:()=>void c(),disabled:d==="fetching","data-testid":"discover-for-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40 inline-flex items-center gap-1",children:[e.jsx(ie,{className:`w-3.5 h-3.5 ${d==="fetching"?"animate-spin":""}`,"aria-hidden":"true"}),i(d==="fetching"?"settings.models.fetching":"settings.models.discover")]}),d==="list"&&e.jsx("span",{className:"text-label text-ink-faint",children:i("settings.models.discover_done",{n:String(k.length)})}),d==="error"&&e.jsx("span",{className:"text-label text-warning break-all",children:E})]}),b.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-caption font-bold text-ink-faint",children:i("settings.models.added_title")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:b.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-full bg-surface-3 text-label text-ink-strong",children:[e.jsx("span",{className:"font-mono",children:s.id}),e.jsx("button",{type:"button",onClick:()=>void j(s.id),disabled:N,"aria-label":`${i("settings.models.manual_add")} ✕ ${s.id}`,"data-tooltip":i("action.delete"),"data-testid":`discovery-remove-${s.id}`,className:"w-5 h-5 rounded-full hover:bg-ink/10 flex items-center justify-center text-ink-muted hover:text-warning",children:e.jsx(G,{className:"w-3 h-3"})})]},s.id))})]}),d==="list"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("input",{type:"text",value:M,onChange:s=>L(s.target.value),placeholder:i("settings.models.search_ph"),className:"w-full 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 px-2.5 py-1.5","data-testid":"discovery-search"}),e.jsxs("div",{className:"max-h-56 overflow-y-auto rounded-lg border border-[var(--border-faint)]",children:[P.length===0&&e.jsx("div",{className:"px-3 py-2 text-label text-ink-faint",children:i("settings.models.empty")}),P.map(s=>{const n=C.has(s.id),p=re(s);return e.jsxs("label",{className:`flex items-center gap-2 px-2.5 py-1.5 cursor-pointer border-b border-[var(--border-faint)] last:border-b-0 ${n?"bg-brand/[0.08]":"hover:bg-ink/[0.04]"}`,children:[e.jsx("input",{type:"checkbox",checked:n,onChange:()=>K(s.id),className:"w-4 h-4 rounded accent-brand shrink-0","data-testid":`discovery-check-${s.id}`}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-label font-mono text-ink-strong truncate",children:s.id}),p&&e.jsx("span",{className:"block text-caption text-ink-faint",children:p})]}),(s.capabilities??[]).includes("vision")&&e.jsx("span",{className:"text-caption text-ink-faint shrink-0",title:i("model.picker.vision"),children:"👁"}),n&&e.jsx(V,{className:"w-3.5 h-3.5 text-brand shrink-0","aria-hidden":"true"})]},s.id)})]}),e.jsx("button",{onClick:()=>void l(P.filter(s=>C.has(s.id))),disabled:N||C.size===0,"data-testid":"discovery-apply",className:"btn-3d-brand px-3 py-1.5 text-label disabled:opacity-40",children:i("settings.models.add_selected",{n:String(C.size)})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:_,onChange:s=>T(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),F())},placeholder:i("settings.models.manual_ph"),className:"flex-1 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 px-2.5 py-1.5 font-mono","data-testid":"discovery-manual-input"}),e.jsx("button",{onClick:F,disabled:N||!_.trim(),className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40 shrink-0","data-testid":"discovery-manual-add",children:i("settings.models.manual_add")})]})]})}function de({activeProvider:t,activeModel:m,presets:b,customProviders:g,onProvidersChanged:x}){const i=R(),[d,f]=r.useState(!1),[k,D]=r.useState(!1),[E,v]=r.useState(""),[C,S]=r.useState(""),[M,L]=r.useState(!1),[_,T]=r.useState(!1),[N,h]=r.useState(null),[w,P]=r.useState(!1);r.useEffect(()=>{Promise.all([u.getSetting("flag_multimodal_import"),u.getSetting("vision_provider_override"),u.getSetting("vision_model_override"),u.getSetting("flag_math_vision")]).then(([a,$,A,U])=>{f(a==="true"),v($??""),S(A??""),P(U==="true"),D(!0)})},[]);const c=async()=>{const a=!d;f(a),await u.setSetting("flag_multimodal_import",String(a))},K=async()=>{const a=!w;P(a),await u.setSetting("flag_math_vision",String(a))},l=async a=>{await u.setSetting("vision_provider_override",a.id),await u.setSetting("vision_model_override",a.defaultModel),v(a.id),S(a.defaultModel),L(!1)},j=async a=>{S(a),await u.setSetting("vision_model_override",a)},F=async()=>{await u.setSetting("vision_provider_override",""),await u.setSetting("vision_model_override",""),v(""),S(""),L(!1)},[s,n]=r.useState(null),p=async a=>{try{E===a&&(await u.setSetting("vision_provider_override",""),await u.setSetting("vision_model_override",""),v("")),await u.deleteCustomProvider(a)}catch{}finally{x==null||x()}},W=async()=>{if(!_){T(!0),h(null);try{const a=await u.testLlmConnection({vision:!0});h({ok:a.ok,detail:a.detail})}catch(a){h({ok:!1,detail:a instanceof Error?a.message:String(a)})}finally{T(!1)}}},o=g.filter(a=>a.kind==="vision"),y=E.startsWith("custom-")?g.find(a=>a.id===E):null,O=E&&!E.startsWith("custom-")?b.find(a=>a.id===E):null;return k?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(X,{checked:d,onChange:c,label:i("settings.multimodal.toggle"),testid:"multimodal-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:i("settings.multimodal.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:i("settings.multimodal.toggle.desc")})]})]}),e.jsxs("div",{className:"px-4 py-3.5 border-t border-[var(--border-faint)] space-y-3",children:[e.jsxs("div",{className:"text-label text-ink-muted bg-ink/5 rounded-lg p-3",children:[e.jsx("div",{className:"font-medium mb-1",children:i("settings.multimodal.current_model",{model:m||i("settings.multimodal.not_selected")})}),e.jsx("div",{children:t.startsWith("custom-")?i("settings.multimodal.hint_custom"):i("settings.multimodal.hint_preset")})]}),e.jsxs("div",{className:"bg-ink/5 rounded-lg p-3",children:[e.jsx("div",{className:"text-label font-medium text-ink-muted mb-2",children:i("settings.multimodal.override_title")}),e.jsx("div",{className:"text-caption text-ink-muted mb-2",children:i("settings.multimodal.override_bridge_hint")}),e.jsxs("div",{className:"space-y-3 mt-1",children:[y&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx(z,{className:"w-3.5 h-3.5 text-ink-faint shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium text-ink-strong",children:y.label}),y.models.length>1?e.jsx("select",{value:C||y.defaultModel,onChange:a=>void j(a.target.value),"aria-label":i("settings.multimodal.model_label"),"data-testid":"vision-override-model-select",className:"bg-surface-1 text-ink text-label rounded-lg border border-[var(--border)] focus:border-brand focus:outline-none px-2 py-1 max-w-[12rem]",children:y.models.map(a=>e.jsxs("option",{value:a.id,children:[a.id,(a.capabilities??[]).includes("vision")?" ✅":""]},a.id))}):e.jsx("code",{className:"text-ink-faint font-mono break-all",children:C||y.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:y.baseUrl})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{onClick:()=>void W(),disabled:_,"data-testid":"vision-override-test",className:"btn-3d-neutral px-4 py-1.5 text-label disabled:opacity-50",children:i(_?"settings.testing":"settings.multimodal.test_override")}),e.jsx("button",{onClick:()=>L(a=>!a),className:"text-label text-accent hover:underline",children:i("settings.multimodal.replace_custom")}),e.jsx("button",{onClick:()=>void F(),className:"text-label text-ink-muted hover:text-ink-strong",children:i("settings.multimodal.stop_override")}),e.jsx("button",{onClick:a=>{a.stopPropagation(),n({id:y.id,label:y.label,rect:a.currentTarget.getBoundingClientRect()})},"data-testid":`vision-delete-${y.id}`,className:"text-label text-ink-muted hover:text-warning",children:i("action.delete")}),N&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${N.ok?"text-brand":"text-warning"}`,children:[N.ok?e.jsx(B,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(H,{className:"w-4 h-4","aria-hidden":"true"}),N.detail]})]})]}),O&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx("span",{className:"text-ink-muted",children:i("settings.multimodal.legacy_preset",{label:O.label})}),e.jsx("button",{onClick:()=>void F(),className:"text-label text-ink-muted hover:text-ink-strong underline",children:i("settings.multimodal.stop_override")})]}),!y&&!O&&e.jsxs(e.Fragment,{children:[o.map(a=>e.jsxs("span",{className:"relative block",children:[e.jsxs("button",{onClick:()=>void l(a),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`vision-pick-${a.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:a.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:a.defaultModel})]}),e.jsx("button",{type:"button","aria-label":i("action.delete"),"data-tooltip":i("action.delete"),"data-testid":`vision-delete-${a.id}`,onClick:$=>{$.stopPropagation(),n({id:a.id,label:a.label,rect:$.currentTarget.getBoundingClientRect()})},className:"absolute top-1.5 right-1.5 w-6 h-6 rounded-full text-ink-muted hover:text-warning flex items-center justify-center hover:bg-surface-2",children:e.jsx(G,{className:"w-3.5 h-3.5"})})]},a.id)),(M||o.length===0)&&e.jsx(Y,{kind:"vision",testPrefix:"vision-custom",titleKey:"settings.custom.form_title_vision",modelPhKey:"settings.custom.model_ph_vision",onSaved:a=>void l(a),onCancel:()=>L(!1)}),o.length>0&&e.jsx("button",{onClick:()=>L(a=>!a),className:"text-label text-accent hover:underline",children:i(M?"action.cancel":"settings.custom.new")})]})]})]}),e.jsxs("div",{className:"bg-ink/5 rounded-lg p-3 flex items-center gap-3",children:[e.jsx(X,{checked:w,onChange:K,label:i("settings.mathvision.toggle"),testid:"math-vision-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:i("settings.mathvision.toggle")}),e.jsx("div",{className:"text-caption text-ink-muted",children:i("settings.mathvision.desc")})]})]})]}),s&&e.jsx(J,{anchorRect:s.rect,message:i("settings.delete_custom_confirm",{name:s.label}),danger:!0,confirmLabel:i("action.delete"),testid:"vision-provider-delete-confirm",onConfirm:()=>{p(s.id),n(null)},onCancel:()=>n(null)})]}):null}function ce(t){return!t||t.input===null||t.input===void 0?null:`$${String(Number(t.input.toFixed(2)))}`}function I(t){if(!t)return null;const m=[];t.contextWindow&&m.push(ne(t.contextWindow));const b=t.free?null:ce(t.pricing);return t.free?m.push("free"):b&&m.push(b),(t.capabilities??[]).includes("vision")&&m.push("👁"),((t.capabilities??[]).includes("reasoning")||t.reasoning)&&m.push("🧠"),t.status==="deprecated"&&m.push("deprecated"),m.length>0?m.join(" · "):null}function pe({tab:t="main",onClose:m}){const b=R(),g=r.useRef(null);te(g,!0);const[x,i]=r.useState(t);r.useEffect(()=>{const n=p=>{p.key==="Escape"&&m()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[m]);const[d,f]=r.useState([]),[k,D]=r.useState([]),[E,v]=r.useState("glm"),[C,S]=r.useState(""),[M,L]=r.useState({}),[_,T]=r.useState({}),[N,h]=r.useState(null),[w,P]=r.useState(!1),c=r.useCallback(async()=>{try{const[n,p,W,o,y]=await Promise.all([u.getProviderPresets(),u.listCustomProviders(),u.getSetting("active_provider"),u.getSetting("active_model"),u.getModelOverlay()]),O=p.filter($=>$.kind==="llm");f(n),D(p),v(W??"glm"),S(o??""),T(y);const a={};await Promise.all(n.map(async $=>{a[$.id]=await u.hasSetting($.apiKeySetting)})),L(a),h($=>$&&(n.some(A=>A.id===$)||O.some(A=>A.id===$))?$:W??"glm"),P(!0)}catch{P(!0)}},[]);r.useEffect(()=>{c();const n=()=>void c();return window.addEventListener("llm-config-changed",n),()=>window.removeEventListener("llm-config-changed",n)},[c]),r.useEffect(()=>{let n=!0;return u.refreshModelCatalog().then(()=>{n&&c()}).catch(()=>{}),()=>{n=!1}},[c]);const K=()=>window.dispatchEvent(new Event("llm-config-changed")),l=r.useCallback(async(n,p)=>{try{await u.setSetting("active_provider",n),await u.setSetting("active_model",p),K()}catch{}},[]),[j,F]=r.useState(null),s=async n=>{F(null);try{await u.deleteCustomProvider(n),E===n&&await u.setSetting("active_provider","glm"),N===n&&h("glm"),K()}catch{}};return w?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:m,"data-testid":"model-manager-modal",children:[e.jsxs("div",{ref:g,role:"dialog","aria-modal":"true","aria-label":b("model.manager.title"),className:"w-[min(880px,94vw)] max-h-[86dvh] rounded-2xl bg-surface-0 shadow-elevated flex flex-col",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-3 px-4 py-3 border-b border-[var(--border)]",children:[e.jsx("h2",{className:"text-body font-bold text-ink-strong",children:b("model.manager.title")}),e.jsx("div",{className:"flex gap-1 bg-surface-3 rounded-full p-0.5",role:"tablist","aria-label":b("model.manager.title"),children:["main","vision"].map(n=>e.jsx("button",{role:"tab","aria-selected":x===n,onClick:()=>i(n),"data-testid":`model-manager-tab-${n}`,className:`px-3 py-1 rounded-full text-label font-medium transition-colors ${x===n?"bg-surface-0 text-ink-strong shadow-sm":"text-ink-muted hover:text-ink-strong"}`,children:b(n==="main"?"model.manager.tab_main":"model.manager.tab_vision")},n))}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:m,"data-testid":"model-manager-close","aria-label":b("action.close"),className:"w-8 h-8 flex items-center justify-center rounded-lg text-ink-muted hover:text-ink-strong hover:bg-surface-3",children:"✕"})]}),x==="vision"?e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx(de,{activeProvider:E,activeModel:C,presets:d,customProviders:k,onProvidersChanged:()=>void c()})}):e.jsx("div",{className:"flex-1 min-h-0 flex flex-col md:flex-row",children:e.jsx(me,{presets:d,customs:k.filter(n=>n.kind==="llm"),overlay:_,presetKeyFlags:M,activeProviderId:E,activeModel:C,selectedId:N,onSelect:h,onActivate:l,onReload:c,setConfirmDelete:F})})]}),j&&e.jsx(J,{anchorRect:j.rect,message:b("settings.delete_custom_confirm",{name:j.label}),danger:!0,confirmLabel:b("action.delete"),testid:"model-manager-delete-confirm",onConfirm:()=>void s(j.id),onCancel:()=>F(null)})]}):e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4","data-testid":"model-manager-modal",children:e.jsx("div",{ref:g,role:"dialog","aria-modal":"true","aria-label":b("model.manager.title"),className:"w-[min(880px,94vw)] h-[60dvh] rounded-2xl bg-surface-0 shadow-elevated",onClick:n=>n.stopPropagation()})})}function me({presets:t,customs:m,overlay:b,presetKeyFlags:g,activeProviderId:x,activeModel:i,selectedId:d,onSelect:f,onActivate:k,onReload:D,setConfirmDelete:E}){const v=R(),[C,S]=r.useState(""),[M,L]=r.useState(!1),_=C.trim().toLowerCase(),T=_?t.filter(l=>l.label.toLowerCase().includes(_)||l.id.toLowerCase().includes(_)||(l.note??"").toLowerCase().includes(_)):t,N=_?m.filter(l=>l.label.toLowerCase().includes(_)):m,h=d&&!d.startsWith("custom-")?t.find(l=>l.id===d)??null:null,w=d&&d.startsWith("custom-")?m.find(l=>l.id===d)??null:null,P=l=>`w-full flex items-center gap-2 px-2.5 py-2 rounded-lg text-left transition-colors shrink-0 ${l?"bg-brand/[0.1] text-ink-strong":"text-ink-muted hover:bg-ink/[0.05] hover:text-ink-strong"}`,c=(l,j)=>`w-2 h-2 rounded-full shrink-0 ${l?"bg-brand":j?"bg-ink/40":"bg-ink/15"}`,K=(l,j)=>v(l?"model.manager.active":j?"model.manager.key_set":"model.manager.no_key");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 md:w-60 flex flex-col min-h-0 border-b md:border-b-0 md:border-r border-[var(--border-faint)]",children:[e.jsx("div",{className:"p-2 pb-1.5 shrink-0",children:e.jsxs("div",{className:"relative",children:[e.jsx(se,{className:"w-3.5 h-3.5 absolute left-2 top-1/2 -translate-y-1/2 text-ink-faint","aria-hidden":!0}),e.jsx("input",{type:"text",value:C,onChange:l=>S(l.target.value),placeholder:v("model.manager.search"),"data-testid":"model-manager-search",className:"w-full bg-surface-1 text-ink text-label rounded-lg border border-[var(--border)] focus:border-brand focus:outline-none pl-7 pr-2 py-1.5 placeholder:text-ink-faint"})]})}),e.jsxs("div",{className:"flex flex-row md:flex-col gap-1 overflow-x-auto md:overflow-y-auto px-2 pb-2 min-h-0","data-testid":"model-manager-list",children:[T.map(l=>{const j=l.id===x,F=!!g[l.id];return e.jsxs("button",{onClick:()=>f(l.id),className:P(d===l.id),"data-testid":`mm-provider-${l.id}`,title:K(j,F),children:[e.jsx("span",{className:c(j,F),"aria-hidden":!0}),e.jsx("span",{className:"truncate text-label flex-1",children:l.label}),j&&e.jsx(V,{className:"w-3.5 h-3.5 text-brand shrink-0","aria-label":v("model.manager.active")})]},l.id)}),N.length>0&&e.jsx("div",{className:"hidden md:block px-1.5 pt-2 pb-0.5 text-caption font-bold text-ink-faint shrink-0",children:v("model.manager.group_custom")}),N.map(l=>{const j=l.id===x;return e.jsxs("button",{onClick:()=>f(l.id),className:`${P(d===l.id)} md:w-full`,"data-testid":`mm-provider-${l.id}`,title:K(j,l.hasApiKey),children:[e.jsx("span",{className:c(j,l.hasApiKey),"aria-hidden":!0}),e.jsx(z,{className:"w-3 h-3 shrink-0 text-ink-faint","aria-hidden":!0}),e.jsx("span",{className:"truncate text-label flex-1",children:l.label}),j&&e.jsx(V,{className:"w-3.5 h-3.5 text-brand shrink-0","aria-label":v("model.manager.active")})]},l.id)}),e.jsxs("button",{onClick:()=>L(l=>!l),className:"shrink-0 w-full flex items-center gap-1.5 px-2.5 py-2 rounded-lg border border-dashed border-[var(--border)] text-ink-muted hover:border-ink-muted hover:text-ink-strong text-label transition-colors","data-testid":"mm-add-custom",children:[e.jsx(ae,{className:"w-3.5 h-3.5","aria-hidden":!0}),v("model.manager.add_custom")]})]}),M&&e.jsx("div",{className:"p-2 border-t border-[var(--border-faint)] shrink-0 md:overflow-y-auto",children:e.jsx(Y,{kind:"llm",testPrefix:"mm-custom",onSaved:l=>{L(!1),f(l.id),D(),window.dispatchEvent(new Event("llm-config-changed"))},onCancel:()=>L(!1)})})]}),e.jsxs("div",{className:"flex-1 min-w-0 min-h-0 overflow-y-auto p-4 space-y-4","data-testid":"model-manager-detail",children:[!h&&!w&&e.jsx("div",{className:"text-label text-ink-faint py-8 text-center",children:v("model.manager.no_selection")}),h&&e.jsx(ue,{preset:h,keyConfigured:!!g[h.id],isActive:h.id===x,shownModel:h.id===x&&i||h.defaultModel,overlayEntry:b[h.id],onActivate:k,onReload:D},h.id),w&&e.jsx(xe,{custom:w,isActive:w.id===x,activeModel:w.id===x?i:"",onActivate:k,onReload:D,onAskDelete:l=>E({id:w.id,label:w.label,rect:l})},w.id)]})]})}function ue({preset:t,keyConfigured:m,isActive:b,shownModel:g,overlayEntry:x,onActivate:i,onReload:d}){const f=R(),[k,D]=r.useState(""),[E,v]=r.useState(0),[C,S]=r.useState(!1),[M,L]=r.useState(null),[_,T]=r.useState(!1),N=t.models.find(c=>c.id===g)??null,h=I(N),w=async()=>{const c=k.trim();if(c)try{await u.setSetting(t.apiKeySetting,c),D(""),v(Date.now()),window.dispatchEvent(new Event("llm-config-changed")),await d()}catch{}},P=async()=>{if(!C){S(!0),L(null);try{const c=await u.testProvider(t.id,g);L(c)}catch(c){L({ok:!1,detail:c instanceof Error?c.message:String(c)})}finally{S(!1)}}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${b?"bg-brand":m?"bg-ink/40":"bg-ink/15"}`,"aria-hidden":!0}),e.jsx("span",{className:"text-body font-bold text-ink-strong",children:t.label}),t.note&&e.jsx("span",{className:"text-caption text-ink-faint",children:t.note})]}),t.baseUrl&&e.jsxs("div",{children:[e.jsx("div",{className:"text-caption font-bold text-ink-faint mb-1",children:"Base URL"}),e.jsx("code",{className:"text-label text-ink-muted font-mono break-all",children:t.baseUrl})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-caption font-bold text-ink-faint mb-1",children:f("settings.apikey")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[m&&e.jsxs("span",{className:"text-label text-brand inline-flex items-center gap-1 shrink-0",children:[e.jsx(B,{className:"w-3.5 h-3.5","aria-hidden":"true"}),f("settings.key.configured")]}),e.jsx("input",{type:"password",value:k,onChange:c=>D(c.target.value),onBlur:()=>void w(),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),w())},placeholder:f(m?"settings.key.overwrite_ph":"settings.key.paste_ph"),"data-testid":"mm-key-input",className:"flex-1 min-w-[10rem] 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 px-2.5 py-1.5"}),e.jsx("a",{href:t.keyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-label text-brand hover:underline whitespace-nowrap",children:f("settings.key.get")}),E>0&&e.jsxs("span",{className:"text-caption text-brand inline-flex items-center gap-0.5 shrink-0",children:[e.jsx(V,{className:"w-3 h-3","aria-hidden":!0}),f("model.manager.key_saved")]})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-caption font-bold text-ink-faint mb-1",children:f("settings.model")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("select",{value:g,onChange:c=>i(t.id,c.target.value),"data-testid":"mm-model-select","aria-label":f("settings.model"),className:"flex-1 min-w-[12rem] bg-surface-1 text-ink text-body rounded-lg border border-[var(--border)] focus:border-brand focus:outline-none px-2.5 py-1.5",children:t.models.map(c=>e.jsxs("option",{value:c.id,children:[c.id,c.status==="deprecated"?" (deprecated)":""]},c.id))}),e.jsx("button",{onClick:()=>void P(),disabled:C,"data-testid":"mm-test-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40 shrink-0",children:f(C?"settings.testing":"settings.test")}),e.jsx("button",{onClick:()=>T(c=>!c),"data-testid":"mm-discover-toggle",className:"text-label text-accent hover:underline whitespace-nowrap shrink-0",children:f("settings.models.discover")})]}),h&&e.jsx("div",{className:"text-caption text-ink-faint mt-1 tabular-nums",children:h}),M&&e.jsxs("div",{className:`text-label mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 min-w-0 ${M.ok?"text-brand":"text-warning"}`,children:[M.ok?e.jsx(B,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}):e.jsx(H,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}),M.detail]})]}),_&&e.jsx("div",{className:"rounded-lg bg-surface-1 border border-[var(--border-faint)] p-3",children:e.jsx(Z,{providerId:t.id,existingModels:t.models,removableModels:(x==null?void 0:x.added)??[],customProvider:null,onApplied:()=>void d()})})]})}function xe({custom:t,isActive:m,activeModel:b,onActivate:g,onReload:x,onAskDelete:i}){const d=R(),[f,k]=r.useState(""),[D,E]=r.useState(0),[v,C]=r.useState(!1),[S,M]=r.useState(null),[L,_]=r.useState(!1),[T,N]=r.useState(null),h=m&&b||t.defaultModel,w=t.models.find(o=>o.id===h)??null,[P,c]=r.useState(w!=null&&w.contextWindow?String(w.contextWindow):""),[K,l]=r.useState(!1),j=I(w),F=async()=>{const o=f.trim();if(o)try{await u.updateCustomProvider(t.id,{apiKey:o}),k(""),E(Date.now()),window.dispatchEvent(new Event("llm-config-changed")),await x()}catch{}},s=async()=>{if(T===null)return;const o=T.trim();N(null),!(!o||o===h)&&g(t.id,o)},n=async()=>{var $,A;const o=P.trim().replace(/[,\s_]/g,""),y=/^(\d+)([km]?)$/i.exec(o);if(o!==""&&!y)return;const O=(($=y==null?void 0:y[2])==null?void 0:$.toLowerCase())==="k"?1e3:((A=y==null?void 0:y[2])==null?void 0:A.toLowerCase())==="m"?1e6:1,a=o===""||!y?null:Math.max(1,Math.round(parseInt(y[1],10)*O));l(!0);try{const U=t.models.map(q=>q.id===h?{...q,contextWindow:a}:q);await u.updateCustomProvider(t.id,{models:U}),await x(),window.dispatchEvent(new Event("llm-config-changed"))}catch{}finally{l(!1)}},p=async o=>{try{await u.updateCustomProvider(t.id,{vision:o}),await x(),window.dispatchEvent(new Event("llm-config-changed"))}catch{}},W=async()=>{if(!v){C(!0),M(null);try{const o=await u.testProvider(t.id,h);M(o)}catch(o){M({ok:!1,detail:o instanceof Error?o.message:String(o)})}finally{C(!1)}}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${m?"bg-brand":t.hasApiKey?"bg-ink/40":"bg-ink/15"}`,"aria-hidden":!0}),e.jsx(z,{className:"w-3.5 h-3.5 text-ink-faint shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"text-body font-bold text-ink-strong",children:t.label}),e.jsx("button",{onClick:o=>i(o.currentTarget.getBoundingClientRect()),"data-testid":"mm-delete-custom",className:"text-label text-ink-muted hover:text-warning ml-auto",children:d("action.delete")})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-caption font-bold text-ink-faint mb-1",children:"Base URL"}),e.jsx("code",{className:"text-label text-ink-muted font-mono break-all",children:t.baseUrl})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-caption font-bold text-ink-faint mb-1",children:d("settings.apikey")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.hasApiKey&&e.jsxs("span",{className:"text-label text-brand inline-flex items-center gap-1 shrink-0",children:[e.jsx(B,{className:"w-3.5 h-3.5","aria-hidden":"true"}),d("settings.key.configured")]}),e.jsx("input",{type:"password",value:f,onChange:o=>k(o.target.value),onBlur:()=>void F(),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),F())},placeholder:t.hasApiKey?d("settings.key.overwrite_ph"):d("settings.custom.apikey_ph"),"data-testid":"mm-key-input-custom",className:"flex-1 min-w-[10rem] 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 px-2.5 py-1.5"}),D>0&&e.jsxs("span",{className:"text-caption text-brand inline-flex items-center gap-0.5 shrink-0",children:[e.jsx(V,{className:"w-3 h-3","aria-hidden":!0}),d("model.manager.key_saved")]})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-caption font-bold text-ink-faint mb-1",children:d("settings.model")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.models.length>1?e.jsx("select",{value:h,onChange:o=>g(t.id,o.target.value),"data-testid":"mm-model-select-custom","aria-label":d("settings.model"),className:"flex-1 min-w-[12rem] bg-surface-1 text-ink text-body rounded-lg border border-[var(--border)] focus:border-brand focus:outline-none px-2.5 py-1.5",children:t.models.map(o=>e.jsx("option",{value:o.id,children:o.id},o.id))}):e.jsx("input",{type:"text",value:T??h,onChange:o=>N(o.target.value),onBlur:()=>void s(),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),s())},placeholder:d("settings.custom.model_ph"),"data-testid":"mm-model-input-custom",className:"flex-1 min-w-[12rem] 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 px-2.5 py-1.5 font-mono"}),e.jsx("button",{onClick:()=>void W(),disabled:v,"data-testid":"mm-test-btn-custom",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40 shrink-0",children:d(v?"settings.testing":"settings.test")}),t.protocol==="openai-compatible"&&e.jsx("button",{onClick:()=>_(o=>!o),"data-testid":"mm-discover-toggle-custom",className:"text-label text-accent hover:underline whitespace-nowrap shrink-0",children:d("settings.models.discover")})]}),j&&e.jsx("div",{className:"text-caption text-ink-faint mt-1 tabular-nums",children:j}),S&&e.jsxs("div",{className:`text-label mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 min-w-0 ${S.ok?"text-brand":"text-warning"}`,children:[S.ok?e.jsx(B,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}):e.jsx(H,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}),S.detail]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-caption font-bold text-ink-faint mb-1",children:d("settings.custom.windowLabel")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{type:"text",inputMode:"numeric",value:P,onChange:o=>c(o.target.value),placeholder:d("settings.custom.windowPh"),"data-testid":"mm-context-window-input",className:"flex-1 min-w-[10rem] 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 px-2.5 py-1.5 font-mono tabular-nums"}),e.jsx("button",{onClick:()=>void n(),disabled:K,"data-testid":"mm-context-window-save",className:"btn-3d-neutral px-3 py-1.5 text-label shrink-0 disabled:opacity-40",children:d("settings.custom.save")})]}),e.jsx("div",{className:"text-caption text-ink-faint mt-1",children:d("settings.custom.windowHint")})]}),e.jsxs("label",{className:"inline-flex items-center gap-2 text-label cursor-pointer select-none","data-testid":"mm-vision-toggle",children:[e.jsx("input",{type:"checkbox",checked:t.vision,onChange:o=>void p(o.target.checked),className:"w-4 h-4 rounded accent-brand"}),e.jsx("span",{className:"text-ink-strong",children:d("settings.custom.vision")}),e.jsx("span",{className:"text-ink-faint",children:d("settings.custom.visionHint")})]}),L&&e.jsx("div",{className:"rounded-lg bg-surface-1 border border-[var(--border-faint)] p-3",children:e.jsx(Z,{providerId:t.id,existingModels:t.models,removableModels:t.models,customProvider:t,onApplied:()=>void x()})})]})}export{pe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as n,j as e}from"./index-
|
|
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";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -13,4 +13,4 @@ import{r as n,j as e}from"./index-C9fscARj.js";import{c as L,u as I,g as T,b as
|
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const se=L("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);function R(a,r,s){var f;if(a.mbti){const x=W(a.mbti,r);return{field:s("boot.profile.field.mbti"),value:`${a.mbti} · ${x.name}`}}if(a.name)return{field:s("boot.profile.field.name"),value:a.name};if((f=a.interests)!=null&&f.length)return{field:s("profile.field.interests"),value:a.interests.join(r==="en"?", ":"、")};if(a.freeNote)return{field:s("boot.profile.field.free"),value:a.freeNote};const p=a.style;if(p){const x=[["start","start"],["interaction","interaction"],["feedback","feedback"],["pacing","pacing"]];for(const[o]of x){const d=p[o];if(d)return{field:`${s("boot.profile.field.style")} · ${s(`profile.style.${o}`)}`,value:Y(o,d,r)}}}return null}function ie({onClose:a,onProfileSaved:r}){var E;const s=I(),f=T()==="en"?"en":"zh-CN",x=n.useRef(null);G(x,!0);const o=F(),[d,u]=n.useState(null),[k,M]=n.useState(null),[P,S]=n.useState(null),[i,N]=n.useState(null),[g,b]=n.useState(!1),[j,h]=n.useState(null),m=n.useRef(new Map);n.useEffect(()=>{const t=l=>{l.key==="Escape"&&a()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[a]);const v=n.useCallback(()=>{c.profileListProposals().then(M).catch(()=>M([]))},[]),y=n.useCallback(t=>{S(t),t&&c.memoryListAll().then(N).catch(()=>N(null))},[]);n.useEffect(()=>{c.profileGet().then(u).catch(()=>u(H())),v(),c.hasSetting("flag_memory_system").then(t=>y(t)).catch(()=>y(!1))},[v,y]);const A=n.useCallback(t=>{u(t),c.profileSet(t).then(()=>{o.show(s("profile.saved"),{duration:2500}),r==null||r()}).catch(()=>o.show(s("profile.save_failed"),{duration:3500}))},[r,o,s]),B=n.useCallback(async(t,l)=>{b(!0);try{l==="apply"?await c.applyProposal(t):await c.rejectProposal(t),v(),c.profileGet().then(u).catch(()=>{})}finally{b(!1)}},[v]),$=n.useCallback(async()=>{b(!0);try{await c.setSetting("flag_memory_system","true"),y(!0)}finally{b(!1)}},[y]),_=n.useCallback(async t=>{h(null),b(!0);try{await c.memoryDeleteSlot(t),c.memoryListAll().then(N).catch(()=>{}),o.show(s("profile.memory.deleted"),{duration:2500})}finally{b(!1)}},[o,s]),D=(k??[]).filter(t=>t.status==="pending"),
|
|
16
|
+
*/const se=L("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);function R(a,r,s){var f;if(a.mbti){const x=W(a.mbti,r);return{field:s("boot.profile.field.mbti"),value:`${a.mbti} · ${x.name}`}}if(a.name)return{field:s("boot.profile.field.name"),value:a.name};if((f=a.interests)!=null&&f.length)return{field:s("profile.field.interests"),value:a.interests.join(r==="en"?", ":"、")};if(a.freeNote)return{field:s("boot.profile.field.free"),value:a.freeNote};const p=a.style;if(p){const x=[["start","start"],["interaction","interaction"],["feedback","feedback"],["pacing","pacing"]];for(const[o]of x){const d=p[o];if(d)return{field:`${s("boot.profile.field.style")} · ${s(`profile.style.${o}`)}`,value:Y(o,d,r)}}}return null}function ie({onClose:a,onProfileSaved:r}){var E;const s=I(),f=T()==="en"?"en":"zh-CN",x=n.useRef(null);G(x,!0);const o=F(),[d,u]=n.useState(null),[k,M]=n.useState(null),[P,S]=n.useState(null),[i,N]=n.useState(null),[g,b]=n.useState(!1),[j,h]=n.useState(null),m=n.useRef(new Map);n.useEffect(()=>{const t=l=>{l.key==="Escape"&&a()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[a]);const v=n.useCallback(()=>{c.profileListProposals().then(M).catch(()=>M([]))},[]),y=n.useCallback(t=>{S(t),t&&c.memoryListAll().then(N).catch(()=>N(null))},[]);n.useEffect(()=>{c.profileGet().then(u).catch(()=>u(H())),v(),c.hasSetting("flag_memory_system").then(t=>y(t)).catch(()=>y(!1))},[v,y]);const A=n.useCallback(t=>{u(t),c.profileSet(t).then(()=>{o.show(s("profile.saved"),{duration:2500}),r==null||r()}).catch(()=>o.show(s("profile.save_failed"),{duration:3500}))},[r,o,s]),B=n.useCallback(async(t,l)=>{b(!0);try{l==="apply"?await c.applyProposal(t):await c.rejectProposal(t),v(),c.profileGet().then(u).catch(()=>{})}finally{b(!1)}},[v]),$=n.useCallback(async()=>{b(!0);try{await c.setSetting("flag_memory_system","true"),y(!0)}finally{b(!1)}},[y]),_=n.useCallback(async t=>{h(null),b(!0);try{await c.memoryDeleteSlot(t),c.memoryListAll().then(N).catch(()=>{}),o.show(s("profile.memory.deleted"),{duration:2500})}finally{b(!1)}},[o,s]),D=(k??[]).filter(t=>t.status==="pending"),C=(k??[]).filter(t=>t.status!=="pending");return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:a,"data-testid":"profile-modal",children:e.jsxs("div",{ref:x,role:"dialog","aria-modal":"true","aria-label":s("profile.title"),className:"w-[min(560px,94vw)] max-h-[86vh] rounded-2xl bg-surface-0 shadow-elevated flex flex-col",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-6 pt-6 pb-4 shrink-0",children:[e.jsx("div",{className:"text-hero font-bold text-ink",children:s("profile.title")}),e.jsxs("button",{className:"btn-3d-neutral inline-flex items-center gap-1 px-3 py-2",onClick:a,"data-testid":"profile-close",children:[e.jsx(q,{size:16}),s("action.close")]})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 pb-6 flex flex-col gap-6",children:[e.jsxs("section",{className:"flex flex-col gap-3","data-testid":"profile-section-declared",children:[e.jsx(w,{icon:e.jsx(K,{size:16,className:"text-accent"}),label:s("profile.section.declared")}),d?e.jsx(O,{t:s,locale:f,profile:d,onSave:A,testIdPrefix:"pf"}):e.jsx("div",{className:"text-label text-ink-faint",children:"…"})]}),e.jsxs("section",{className:"flex flex-col gap-3","data-testid":"profile-section-suggestions",children:[e.jsx(w,{icon:e.jsx(V,{size:16,className:"text-accent"}),label:s("profile.section.suggestions")}),k===null?e.jsx("div",{className:"text-label text-ink-faint",children:"…"}):D.length===0?e.jsx("div",{className:"rounded-xl bg-surface-1 p-3 text-label text-ink-muted","data-testid":"profile-suggest-empty",children:s("profile.suggest.empty")}):D.map(t=>{const l=R(t.patch,f,s);return e.jsxs("div",{className:"rounded-xl border border-accent/30 bg-accent/5 p-3 flex flex-col gap-2","data-testid":"profile-suggest-card",children:[e.jsx("div",{className:"text-label text-ink leading-relaxed",children:s("profile.suggest.title",{field:(l==null?void 0:l.field)??"",value:(l==null?void 0:l.value)??""})}),t.rationale&&e.jsxs("div",{className:"text-label text-ink-muted leading-relaxed",children:[s("profile.suggest.reason"),t.rationale]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{className:"btn-3d-brand inline-flex items-center gap-1 px-3 py-2",disabled:g,onClick:()=>void B(t.id,"apply"),"data-testid":"profile-suggest-apply",children:[e.jsx(X,{size:14}),s("profile.suggest.apply",{value:(l==null?void 0:l.value)??""})]}),e.jsx("button",{className:"btn-3d-neutral px-3 py-2",disabled:g,onClick:()=>void B(t.id,"reject"),"data-testid":"profile-suggest-keep",children:s("profile.suggest.keep")})]})]},t.id)}),C.length>0&&e.jsxs("details",{className:"rounded-xl bg-surface-1 p-3","data-testid":"profile-suggest-history",children:[e.jsxs("summary",{className:"text-label font-bold text-ink cursor-pointer inline-flex items-center gap-1.5",children:[e.jsx(se,{size:14}),s("profile.suggest.history",{n:C.length})]}),e.jsx("div",{className:"mt-2 flex flex-col gap-1.5",children:C.map(t=>{const l=R(t.patch,f,s);return e.jsxs("div",{className:"text-caption text-ink-muted flex items-start gap-1.5",children:[t.status==="applied"?e.jsx(J,{size:13,className:"shrink-0 mt-0.5 text-brand"}):t.status==="rejected"?e.jsx(ee,{size:13,className:"shrink-0 mt-0.5 text-ink-faint"}):e.jsx(te,{size:13,className:"shrink-0 mt-0.5 text-ink-faint"}),e.jsxs("span",{children:[s("profile.suggest.title",{field:(l==null?void 0:l.field)??"",value:(l==null?void 0:l.value)??""}),t.rationale?` — ${t.rationale}`:""]})]},t.id)})})]})]}),e.jsxs("section",{className:"flex flex-col gap-3","data-testid":"profile-section-memory",children:[e.jsx(w,{icon:e.jsx(Q,{size:16,className:"text-accent"}),label:s("profile.section.memory")}),P===null?e.jsx("div",{className:"text-label text-ink-faint",children:"…"}):P?e.jsxs("div",{className:"flex flex-col gap-3","data-testid":"profile-memory-on",children:[e.jsx("div",{className:"text-caption text-ink-muted",children:s("profile.memory.disclaimer")}),e.jsx(z,{t:s,label:s("profile.memory.global"),items:i!=null&&i.global?[{id:i.global.id,text:i.global.summary}]:[],onAskDelete:t=>h(t),registerBtn:(t,l)=>{l?m.current.set(t,l):m.current.delete(t)},busy:g}),e.jsx(z,{t:s,label:s("profile.memory.pattern"),items:((i==null?void 0:i.patterns)??[]).map(t=>({id:t.id,text:t.summary})),onAskDelete:t=>h(t),registerBtn:(t,l)=>{l?m.current.set(t,l):m.current.delete(t)},busy:g}),e.jsx(z,{t:s,label:s("profile.memory.nodes"),items:((i==null?void 0:i.nodes)??[]).slice(0,8).map(t=>({id:t.id,text:t.summary})),extra:(((E=i==null?void 0:i.nodes)==null?void 0:E.length)??0)>8?s("profile.memory.more",{n:((i==null?void 0:i.nodes.length)??0)-8}):void 0,onAskDelete:t=>h(t),registerBtn:(t,l)=>{l?m.current.set(t,l):m.current.delete(t)},busy:g}),j&&m.current.get(j)&&e.jsx(U,{anchorRect:m.current.get(j).getBoundingClientRect(),message:s("profile.memory.confirm"),danger:!0,onConfirm:()=>void _(j),onCancel:()=>h(null),testid:"profile-memory-confirm"})]}):e.jsxs("div",{className:"rounded-xl bg-surface-1 p-4 flex flex-col gap-3","data-testid":"profile-memory-off",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-label font-bold text-ink mb-1",children:s("profile.memory.off.title")}),e.jsx("div",{className:"text-label text-ink-muted leading-relaxed",children:s("profile.memory.off.desc")})]}),e.jsx("button",{className:"btn-3d-brand self-start px-4 py-2",disabled:g,onClick:()=>void $(),"data-testid":"profile-memory-enable",children:s("profile.memory.enable")})]})]})]})]})})}function w({icon:a,label:r}){return e.jsxs("div",{className:"flex items-center gap-2 text-label font-bold text-ink",children:[a,r]})}function z({t:a,label:r,items:s,extra:p,onAskDelete:f,registerBtn:x,busy:o}){return e.jsxs("div",{className:"rounded-xl bg-surface-1 p-3 flex flex-col gap-2",children:[e.jsx("div",{className:"text-caption font-bold text-ink-faint",children:r}),s.length===0?e.jsx("div",{className:"text-caption text-ink-faint",children:a("profile.memory.empty")}):s.map(d=>e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 text-caption text-ink-muted leading-relaxed",children:d.text}),e.jsx("button",{className:"shrink-0 p-1.5 rounded-lg text-ink-faint hover:text-warning transition-colors",disabled:o,onClick:()=>f(d.id),"aria-label":a("profile.memory.delete"),ref:u=>x(d.id,u),"data-testid":"profile-memory-delete",children:e.jsx(Z,{size:15})})]},d.id)),p&&e.jsx("div",{className:"text-caption text-ink-faint",children:p})]})}export{ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,j as e,c as S}from"./index-
|
|
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};
|
|
@@ -0,0 +1,15 @@
|
|
|
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";/**
|
|
2
|
+
* @license lucide-react v0.468.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ft=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
|
|
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
|
+
${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
|
+
${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
|
|
11
|
+
${a.active&&c.form==="custom"?"border-[var(--accent)] bg-surface-2":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[a.thumb?e.jsx("img",{src:a.thumb,alt:"",className:"w-10 h-10 rounded-lg object-contain bg-surface-2"}):e.jsx("span",{className:"w-10 h-10 rounded-lg bg-surface-2 inline-block"}),e.jsx("span",{className:"text-body text-ink-strong flex-1 truncate",children:a.name}),a.active&&c.form==="custom"&&e.jsx("span",{className:"text-caption text-brand font-medium",children:t("settings.shimeji.active")})]}),e.jsx("button",{type:"button","aria-label":t("companion.bots.veh"),"data-tooltip":t("companion.bots.veh"),"data-testid":`companion-pack-veh-${a.id}`,onClick:x=>{x.stopPropagation(),oe(P=>P===a.id?null:a.id)},className:"absolute top-1.5 -left-1.5 w-5 h-5 rounded-full border border-black/25 shadow-card hover:scale-110 motion-safe:transition-transform",style:{background:ce[a.vehicle??"silver"].dot}}),e.jsx("button",{type:"button","aria-label":t("companion.custom.delete"),onClick:x=>{x.stopPropagation(),E({id:a.id,rect:x.currentTarget.getBoundingClientRect()})},className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full flex items-center justify-center text-ink-faint hover:text-warning",children:e.jsx(ke,{className:"w-3.5 h-3.5"})})]},a.id))}),ae&&e.jsxs("div",{className:"mt-2.5 rounded-xl border border-[var(--border-faint)] bg-surface-0 p-2.5","data-testid":"companion-veh-picker",children:[e.jsx("div",{className:"text-caption text-ink-muted mb-1.5",children:t("companion.wizard.vehicle")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5",role:"radiogroup","aria-label":t("companion.wizard.vehicle"),children:["silver",..._e].map(a=>{var P;const x=(((P=g.find(V=>V.id===ae))==null?void 0:P.vehicle)??"silver")===a;return e.jsxs("button",{type:"button",role:"radio","aria-checked":x,"data-testid":`companion-veh-pick-${a}`,onClick:()=>void he(ae,a),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-label motion-safe:transition-colors
|
|
12
|
+
${x?"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[a].dot}}),t(a==="silver"?"companion.veh.silver":`companion.form.${a}.name`)]},a)})})]})]})]})}),z&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":t("companion.pick.shimeji.title"),onClick:()=>N(!1),children:e.jsxs("div",{className:"relative w-full max-w-md max-h-[85dvh] flex flex-col rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4","data-testid":"shimeji-pack-list",onClick:a=>a.stopPropagation(),children:[e.jsx("div",{className:"text-body font-medium text-ink-strong mb-3",children:t("companion.pick.shimeji.title")}),e.jsxs("div",{className:"min-h-0 overflow-y-auto",children:[T.length===0?e.jsx("p",{className:"text-label text-ink-muted py-4 text-center",children:t("companion.pick.empty.shimeji")}):e.jsx("div",{className:"flex flex-col gap-1.5",children:T.map(a=>e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button","data-testid":`shimeji-pack-option-${a.id}`,onClick:()=>{Y(a.id),N(!1)},className:`w-full flex items-center gap-2.5 rounded-xl border p-2 text-left motion-safe:transition-colors
|
|
13
|
+
${a.active&&c.form==="shimeji"?"border-[var(--accent)] bg-surface-2":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[a.iconBase64?e.jsx("img",{src:`data:image/png;base64,${a.iconBase64}`,alt:"",className:"w-10 h-10 rounded-lg object-contain bg-surface-2"}):e.jsx("span",{className:"w-10 h-10 rounded-lg bg-surface-2 inline-block"}),e.jsxs("span",{className:"flex flex-col flex-1 min-w-0",children:[e.jsx("span",{className:"text-body text-ink-strong truncate",children:a.name}),e.jsxs("span",{className:"text-caption text-ink-muted",children:[a.format," · ",a.frameCount,"f · ",a.actionCount]})]}),a.active&&c.form==="shimeji"&&e.jsx("span",{className:"text-caption text-brand font-medium",children:t("settings.shimeji.active")})]}),e.jsx("button",{type:"button","aria-label":t("companion.bots.veh"),"data-tooltip":t("companion.bots.veh"),"data-testid":`shimeji-pack-veh-${a.id}`,onClick:x=>{x.stopPropagation(),se(P=>P===a.id?null:a.id)},className:"absolute top-1.5 -left-1.5 w-5 h-5 rounded-full border border-black/25 shadow-card hover:scale-110 motion-safe:transition-transform",style:{background:ce[a.vehicle??"silver"].dot}}),e.jsx("button",{type:"button","aria-label":t("settings.shimeji.delete"),onClick:x=>{x.stopPropagation(),q({id:a.id,rect:x.currentTarget.getBoundingClientRect()})},className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full flex items-center justify-center text-ink-faint hover:text-warning",children:e.jsx(ke,{className:"w-3.5 h-3.5"})})]},a.id))}),G&&e.jsxs("div",{className:"mt-2.5 rounded-xl border border-[var(--border-faint)] bg-surface-0 p-2.5","data-testid":"shimeji-veh-picker",children:[e.jsx("div",{className:"text-caption text-ink-muted mb-1.5",children:t("companion.wizard.vehicle")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5",role:"radiogroup","aria-label":t("companion.wizard.vehicle"),children:["silver",..._e].map(a=>{var P;const x=(((P=T.find(V=>V.id===G))==null?void 0:P.vehicle)??"silver")===a;return e.jsxs("button",{type:"button",role:"radio","aria-checked":x,"data-testid":`shimeji-veh-pick-${a}`,onClick:()=>void ue(G,a),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-label motion-safe:transition-colors
|
|
14
|
+
${x?"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[a].dot}}),t(a==="silver"?"companion.veh.silver":`companion.form.${a}.name`)]},a)})})]})]})]})}),H&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":t("companion.create.title"),onClick:()=>R(!1),children:e.jsxs("div",{className:"relative w-full max-w-md rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4",onClick:a=>a.stopPropagation(),children:[e.jsx("div",{className:"text-body font-medium text-ink-strong mb-3",children:t("companion.create.title")}),e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:[{key:"self",testid:"companion-create-self",name:t("companion.create.self.name"),hover:t("companion.create.self.hover"),open:()=>{R(!1),A(!0)}},{key:"shimeji",testid:"companion-create-shimeji",name:t("companion.create.shimeji.name"),hover:t("companion.create.shimeji.hover"),open:()=>{R(!1),$(!0)}}].map(a=>e.jsxs("button",{type:"button","data-testid":a.testid,onMouseEnter:()=>M(a.key),onMouseLeave:()=>M(x=>x===a.key?null:x),onFocus:()=>M(a.key),onBlur:()=>M(x=>x===a.key?null:x),onClick:a.open,className:`flex flex-col items-center gap-1.5 rounded-xl border p-4 motion-safe:transition-colors
|
|
15
|
+
${J===a.key?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[e.jsx("span",{className:"text-body font-medium text-ink-strong",children:a.name}),e.jsx("span",{className:`text-caption text-ink-muted text-center leading-snug ${J===a.key?"":"opacity-0 h-0 overflow-hidden"} motion-safe:transition-all`,children:a.hover})]},a.key))}),e.jsx("p",{className:"text-caption text-ink-faint mt-3 text-center",children:t("companion.create.hint")})]})}),W&&e.jsx(kt,{onClose:()=>$(!1),onImported:async()=>{await B()}}),te&&e.jsx(Re,{anchorRect:te.rect,message:t("settings.shimeji.deleteConfirm",{name:((Z=T.find(a=>a.id===te.id))==null?void 0:Z.name)??""}),danger:!0,testid:"shimeji-delete-confirm",onConfirm:()=>void xe(te.id),onCancel:()=>q(null)}),y&&e.jsx(jt,{onClose:()=>A(!1),onSaved:()=>{A(!1),I()}})]})]})]}):null}const $t=[{id:"zh-CN-XiaoxiaoNeural",label:"zh-CN · 晓晓(女)"},{id:"zh-CN-XiaoyiNeural",label:"zh-CN · 晓伊(女)"},{id:"zh-CN-YunxiNeural",label:"zh-CN · 云希(男)"},{id:"zh-CN-YunyangNeural",label:"zh-CN · 云扬(男·新闻)"},{id:"zh-CN-liaoning-XiaobeiNeural",label:"zh-CN · 晓北(女·东北)"},{id:"zh-CN-shaanxi-XiaoniNeural",label:"zh-CN · 晓妮(女·陕西)"},{id:"en-US-AriaNeural",label:"en-US · Aria(女)"},{id:"en-US-GuyNeural",label:"en-US · Guy(男)"},{id:"en-US-JennyNeural",label:"en-US · Jenny(女)"}],Pt=[{sid:"45",label:"zf_xiaobei(女)"},{sid:"46",label:"zf_xiaoni(女)"},{sid:"47",label:"zf_xiaoxiao(女)"},{sid:"48",label:"zf_xiaoyi(女·默认)"},{sid:"49",label:"zm_yunjian(男)"},{sid:"50",label:"zm_yunxi(男)"},{sid:"51",label:"zm_yunxia(男)"},{sid:"52",label:"zm_yunyang(男)"}];function Tt(){const t=ee(),[l,i]=n.useState([]),[f,v]=n.useState(null),[c,o]=n.useState(null),[j,w]=n.useState(null),[p,C]=n.useState(null),[b,_]=n.useState("edge"),[D,u]=n.useState("zh-CN-XiaoxiaoNeural"),[g,S]=n.useState("48"),[y,A]=n.useState("1.0"),[k,E]=n.useState(""),[H,R]=n.useState(""),[m,d]=n.useState([]),z=typeof window<"u"&&"speechSynthesis"in window,[N,J]=n.useState("local"),[M,W]=n.useState("asr-whisper-turbo"),[$,T]=n.useState(!0),[me,te]=n.useState([]),[q,G]=n.useState(!1),[se,ae]=n.useState(!1),[oe,I]=n.useState(!1),[B,Y]=n.useState(!1),[ue,xe]=n.useState(!1),[Ne,ne]=n.useState(null),[he,le]=n.useState(!1),[pe,Z]=n.useState(null),[a,x]=n.useState(null),P=n.useCallback(()=>{r.listCustomProviders().then(s=>te(s.filter(h=>h.kind==="tts"||h.kind==="asr"))).catch(()=>{})},[]);n.useEffect(()=>{Promise.all([r.getSetting("tts_engine"),r.getSetting("tts_voice_edge"),r.getSetting("tts_sid_local"),r.getSetting("tts_speed"),r.getSetting("tts_custom_voice"),r.getSetting("tts_system_voice"),r.getSetting("asr_engine"),r.getSetting("asr_local_model"),r.getSetting("asr_auto_stop")]).then(([s,h,F,O,ve,Le,Ie,ye,tt])=>{s&&_(s),h&&u(h),F&&S(F),O&&A(O),ve&&E(ve),Le&&R(Le),Ie&&J(Ie),(ye==="asr-whisper-turbo"||ye==="asr-whisper-small")&&W(ye),T(tt!=="0")}),P()},[P]),n.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const s=()=>d(ut(window.speechSynthesis.getVoices()));return s(),window.speechSynthesis.addEventListener("voiceschanged",s),()=>window.speechSynthesis.removeEventListener("voiceschanged",s)},[]);const V=n.useCallback(()=>{window.api.getSpeechModelStatus().then(s=>i(s)).catch(()=>{})},[]);n.useEffect(()=>(V(),window.api.on("speech:modelProgress",h=>{w({id:h.id,pct:Math.floor(h.progress*100),label:h.currentFile?h.currentFile.split("/").pop()??"":""})})),[V]);const Oe=s=>{o(null),v(s),w({id:s,pct:0,label:""}),window.api.ensureSpeechModel(s).then(()=>{v(null),w(null),V()}).catch(h=>{v(null),w(null),o(h instanceof Error?h.message:String(h)),V()})},Ke=s=>{v(s),C(null),window.api.deleteSpeechModel(s).then(V).catch(h=>o(h instanceof Error?h.message:String(h))).finally(()=>v(null))},Ue=s=>t(s==="tts-kokoro"?"settings.speech.model.tts":s==="asr-whisper-turbo"?"settings.speech.model.asr_turbo":"settings.speech.model.asr_small"),He=s=>t(s==="asr-whisper-turbo"?"settings.speech.model.turbo_short":"settings.speech.model.small_short"),qe=s=>s.startsWith("asr-whisper")?t("settings.speech.license_mit"):t("settings.speech.license"),ze=s=>t(s==="ready"?"settings.speech.state.ready":s==="error"?"settings.speech.state.error":"settings.speech.state.absent"),$e=s=>{var h;return((h=l.find(F=>F.id===s))==null?void 0:h.state)??"absent"},ie=s=>{_(s),ne(null),r.setSetting("tts_engine",s),je()},Ge=s=>{R(s),r.setSetting("tts_system_voice",s),je()},fe=s=>{J(s),Z(null),r.setSetting("asr_engine",s)},ge=me.filter(s=>s.kind==="tts"),be=me.filter(s=>s.kind==="asr"),X=b.startsWith("custom-")?ge.find(s=>s.id===b)??null:null,Q=N.startsWith("custom-")?be.find(s=>s.id===N)??null:null,Xe=b==="azure",Je=N==="groq",Ye=N==="azure",Ze=async()=>{if(!(!X||ue)){xe(!0),ne(null);try{ne(await r.testCustomTts({providerId:X.id}))}catch(s){ne({ok:!1,detail:s instanceof Error?s.message:String(s)})}finally{xe(!1)}}},Qe=async()=>{if(!(!Q||he)){le(!0),Z(null);try{Z(await r.testCustomAsr({providerId:Q.id}))}catch(s){Z({ok:!1,detail:s instanceof Error?s.message:String(s)})}finally{le(!1)}}},et=async(s,h)=>{x(null);try{await r.deleteCustomProvider(s),h==="tts"&&b===s&&ie("edge"),h==="asr"&&N===s&&fe("local"),P()}catch{}},Pe=s=>{const h=l.find(O=>O.id===s),F=(h==null?void 0:h.state)??"absent";return e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong truncate",children:Ue(s)}),e.jsxs("div",{className:"text-caption text-ink-muted",children:[ze(F)," · ",qe(s)]}),f===s&&(j==null?void 0:j.id)===s&&e.jsx("div",{className:"mt-1.5 h-1.5 rounded-full bg-ink/[0.08] overflow-hidden","data-testid":`speech-dl-bar-${s}`,children:e.jsx("div",{className:"h-full bg-brand transition-all",style:{width:`${j.pct}%`}})}),f===s&&(j==null?void 0:j.id)===s&&e.jsxs("div",{className:"text-caption text-ink-faint mt-0.5","data-testid":`speech-dl-pct-${s}`,children:[j.pct,"%",j.label?` · ${j.label}`:""]})]}),F==="ready"?p===s?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-caption text-warning",children:t("settings.speech.confirm_del")}),e.jsx("button",{onClick:()=>Ke(s),className:"text-label text-warning hover:underline","data-testid":`speech-del-confirm-${s}`,children:t("settings.speech.delete")}),e.jsx("button",{onClick:()=>C(null),className:"text-label text-ink-muted hover:text-ink-strong",children:t("action.cancel")})]}):e.jsx("button",{onClick:()=>C(s),disabled:f===s,className:"text-label text-ink-muted hover:text-warning disabled:opacity-40","data-testid":`speech-del-${s}`,children:t("settings.speech.delete")}):e.jsx("button",{onClick:()=>Oe(s),disabled:f!=null||F==="downloading",className:"btn-3d-brand px-3 py-1 text-label disabled:opacity-40","data-testid":`speech-dl-${s}`,children:t(f===s||F==="downloading"?"settings.speech.downloading":"settings.speech.download")})]},s)},Te=(s,h,F,O,ve)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx(xt,{className:"w-3.5 h-3.5 text-ink-faint shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium text-ink-strong",children:s.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:s.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:s.baseUrl}),s.hasApiKey&&e.jsxs("span",{className:"text-brand shrink-0 inline-flex items-center gap-0.5",children:[e.jsx(Fe,{className:"w-3.5 h-3.5","aria-hidden":"true"}),t("settings.speech.key_saved")]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:()=>void ve(),disabled:F,className:"btn-3d-neutral px-3 py-1 text-label disabled:opacity-40","data-testid":`${h}-custom-test`,children:t(F?"settings.testing":"settings.test")}),a===s.id?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-caption text-warning",children:t("settings.speech.confirm_del_custom")}),e.jsx("button",{onClick:()=>void et(s.id,h),className:"text-label text-warning hover:underline","data-testid":`${h}-custom-del-confirm`,children:t("settings.speech.delete")}),e.jsx("button",{onClick:()=>x(null),className:"text-label text-ink-muted hover:text-ink-strong",children:t("action.cancel")})]}):e.jsx("button",{onClick:()=>x(s.id),className:"text-label text-ink-muted hover:text-warning","data-testid":`${h}-custom-del`,children:t("settings.speech.delete")}),O&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${O.ok?"text-brand":"text-warning"}`,children:[O.ok?e.jsx(Fe,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(ht,{className:"w-4 h-4","aria-hidden":"true"}),O.detail]})]})]});return e.jsxs("div",{"data-testid":"settings-speech",children:[e.jsxs("div",{className:L(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.speech.tts_title")}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>{ie("edge"),G(!1),I(!1)},"data-testid":"tts-engine-edge","aria-pressed":b==="edge",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${b==="edge"?U:K}`,children:t("settings.speech.engine.edge")}),e.jsxs("button",{onClick:()=>{ie("local"),G(!1),I(!1)},"data-testid":"tts-engine-local","aria-pressed":b==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${b==="local"?U:K}`,children:[t("settings.speech.engine.local"),$e("tts-kokoro")!=="ready"?` · ${t("settings.speech.state.absent")}`:""]}),e.jsx("button",{onClick:()=>{ie("system"),G(!1),I(!1)},disabled:!z,"data-testid":"tts-engine-system","aria-pressed":b==="system",title:z?void 0:t("settings.speech.engine.system_unavailable"),className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${b==="system"?U:K} ${z?"":"opacity-40 cursor-not-allowed"}`,children:t("settings.speech.engine.system")}),e.jsx("button",{onClick:()=>{G(s=>!s),q||I(!1)},"data-testid":"tts-engine-custom","aria-pressed":b.startsWith("custom-")||q,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${b.startsWith("custom-")||q?U:K}`,children:t("settings.speech.engine.custom")}),Xe&&e.jsxs("button",{disabled:!0,"data-testid":"tts-engine-azure",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Azure · ",t("settings.speech.legacy")]})]}),b==="edge"&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.engine.edge_note")})]}),b==="edge"&&e.jsxs("div",{className:L(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsx("select",{value:D,onChange:s=>{u(s.target.value),r.setSetting("tts_voice_edge",s.target.value)},"data-testid":"tts-voice-select",className:`${re} w-full min-w-0 px-2.5 py-1.5`,children:$t.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))})]}),b==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:L(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsx("select",{value:g,onChange:s=>{S(s.target.value),r.setSetting("tts_sid_local",s.target.value)},"data-testid":"tts-sid-select",className:`${re} w-full min-w-0 px-2.5 py-1.5`,children:Pt.map(s=>e.jsx("option",{value:s.sid,children:s.label},s.sid))})]}),e.jsx("div",{className:L(!1),children:Pe("tts-kokoro")})]}),b==="system"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:L(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsxs("select",{value:H,onChange:s=>Ge(s.target.value),"data-testid":"tts-system-voice-select",className:`${re} w-full min-w-0 px-2.5 py-1.5`,children:[e.jsx("option",{value:"",children:t("settings.speech.voice_auto")}),m.map(s=>e.jsx("option",{value:s.name,children:dt(s)},s.voiceURI))]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.engine.system_note")})]})}),q&&e.jsx("div",{className:L(!1),children:e.jsxs("div",{className:"space-y-3",children:[X&&Te(X,"tts",ue,Ne,Ze),X&&e.jsxs("div",{children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsx("input",{type:"text",value:k,onChange:s=>E(s.target.value),onBlur:()=>void r.setSetting("tts_custom_voice",k.trim()),placeholder:t("settings.speech.custom_voice_ph"),"data-testid":"tts-custom-voice",className:`${re} w-full min-w-0 px-2.5 py-1.5 font-mono`})]}),!X&&ge.map(s=>e.jsxs("button",{onClick:()=>ie(s.id),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`tts-pick-${s.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:s.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:s.defaultModel})]},s.id)),(oe||!X&&ge.length===0)&&e.jsx(Ve,{kind:"tts",showProtocol:!1,testPrefix:"tts-custom",titleKey:"settings.custom.form_title_tts",modelPhKey:"settings.custom.model_ph_tts",testOverride:s=>r.testCustomTts({baseUrl:s.baseUrl,apiKey:s.apiKey||void 0,model:s.model}),onSaved:s=>{ie(s.id),I(!1),P()},onCancel:()=>I(!1)}),(X||ge.length>0)&&e.jsx("button",{onClick:()=>I(s=>!s),className:"text-label text-accent hover:underline",children:t(oe?"action.cancel":"settings.custom.new")})]})}),e.jsx("div",{className:L(!0),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.speech.speed")}),e.jsx("input",{type:"range",min:"0.5",max:"2",step:"0.05",value:y,onChange:s=>A(s.target.value),onPointerUp:()=>{r.setSetting("tts_speed",y),je()},onKeyUp:()=>{r.setSetting("tts_speed",y),je()},"data-testid":"tts-speed-range",className:"flex-1 min-w-0 accent-[var(--brand)]"}),e.jsxs("span",{className:"text-label text-ink-muted tabular-nums w-10 text-right","data-testid":"tts-speed-value",children:[Number(y).toFixed(2),"x"]})]})}),e.jsxs("div",{className:L(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.speech.asr_title")}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>{fe("local"),ae(!1),Y(!1)},"data-testid":"asr-engine-local","aria-pressed":N==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${N==="local"?U:K}`,children:t("settings.speech.asr_engine.local")}),e.jsx("button",{onClick:()=>{ae(s=>!s),se||Y(!1)},"data-testid":"asr-engine-custom","aria-pressed":N.startsWith("custom-")||se,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${N.startsWith("custom-")||se?U:K}`,children:t("settings.speech.engine.custom")}),Je&&e.jsxs("button",{disabled:!0,"data-testid":"asr-engine-groq",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Groq · ",t("settings.speech.legacy")]}),Ye&&e.jsxs("button",{disabled:!0,"data-testid":"asr-engine-azure",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Azure · ",t("settings.speech.legacy")]})]}),N==="local"?e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_engine.local_note")}):N.startsWith("custom-")&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_engine.custom_note")})]}),N==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:L(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.model")}),e.jsx("select",{value:M,onChange:s=>{W(s.target.value),r.setSetting("asr_local_model",s.target.value)},"data-testid":"asr-model-select",className:`${re} w-full min-w-0 px-2.5 py-1.5`,children:["asr-whisper-turbo","asr-whisper-small"].map(s=>e.jsxs("option",{value:s,children:[He(s)," · ",ze($e(s))]},s))})]}),e.jsx("div",{className:L(!1),children:Pe(M)})]}),se&&e.jsx("div",{className:L(!1),children:e.jsxs("div",{className:"space-y-3",children:[Q&&Te(Q,"asr",he,pe,Qe),!Q&&be.map(s=>e.jsxs("button",{onClick:()=>fe(s.id),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`asr-pick-${s.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:s.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:s.defaultModel})]},s.id)),(B||!Q&&be.length===0)&&e.jsx(Ve,{kind:"asr",showProtocol:!1,testPrefix:"asr-custom",titleKey:"settings.custom.form_title_asr",modelPhKey:"settings.custom.model_ph_asr",testOverride:s=>r.testCustomAsr({baseUrl:s.baseUrl,apiKey:s.apiKey||void 0,model:s.model}),onSaved:s=>{fe(s.id),Y(!1),P()},onCancel:()=>Y(!1)}),(Q||be.length>0)&&e.jsx("button",{onClick:()=>Y(s=>!s),className:"text-label text-accent hover:underline",children:t(B?"action.cancel":"settings.custom.new")})]})}),e.jsxs("div",{className:L(!0),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{checked:$,onChange:()=>{const s=!$;T(s),r.setSetting("asr_auto_stop",s?"1":"0")},label:t("settings.speech.asr_auto_stop"),testid:"asr-auto-stop-toggle"}),e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.speech.asr_auto_stop")})]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_ux_note")})]}),c&&e.jsx("div",{className:"px-4 py-3 text-label text-warning break-all",role:"alert",children:c==="engine-unavailable"?t("chat.speech.engine_unavailable"):c})]})}function Lt(){const t=ee(),l=n.useRef(null),[i,f]=n.useState(null),[v,c]=n.useState(!1),[o,j]=n.useState(null);n.useEffect(()=>{r.dshImportDetect().then(f).catch(()=>f({found:!1,path:null,version:null}))},[]);const w=p=>{c(!0),j(null),p.then(j).catch(C=>j({ok:!1,error:String(C)})).finally(()=>c(!1))};return e.jsxs("div",{className:"p-4 space-y-3","data-testid":"settings-dsh-import",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:t("settings.dsh.title")}),e.jsx("p",{className:"text-label text-ink-muted leading-relaxed",children:t("settings.dsh.desc")}),i==null?null:i.found?e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"settings-dsh-detected",children:[e.jsx("span",{className:"text-label text-ink-strong",children:t("settings.dsh.detectFound",{v:i.version??"?"})}),e.jsx("button",{onClick:()=>w(r.dshImportFromPath(i.path??"")),disabled:v,"data-testid":"settings-dsh-import-btn",className:"px-3 py-1.5 rounded-xl text-label font-bold btn-3d-brand disabled:opacity-50",children:t(v?"settings.dsh.importing":"settings.dsh.import")})]}):e.jsx("div",{className:"text-label text-ink-muted","data-testid":"settings-dsh-none",children:t("settings.dsh.detectNone")}),e.jsxs("div",{children:[e.jsx("input",{ref:l,type:"file",accept:".json,application/json",className:"hidden","data-testid":"settings-dsh-file-input",onChange:p=>{var b;const C=(b=p.target.files)==null?void 0:b[0];C&&(C.text().then(_=>w(r.dshImportFromText(_))),p.target.value="")}}),e.jsx("button",{onClick:()=>{var p;return(p=l.current)==null?void 0:p.click()},disabled:v,className:"px-3 py-1.5 rounded-xl text-label font-bold btn-3d-neutral disabled:opacity-50",children:t("settings.dsh.pickFile")})]}),v&&!o?e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.dsh.importing")}):null,o!=null&&o.ok?e.jsxs("div",{className:"text-label text-brand leading-relaxed break-all",role:"status","data-testid":"settings-dsh-result",children:[t("settings.dsh.done",{courses:o.coursesCreated+o.coursesMapped+o.coursesRefreshed,nodes:o.nodes,progress:o.progressRows,srs:o.srsRows,xp:o.xpDelta}),o.skippedCourses.length>0?` · ${t("settings.dsh.skipped",{n:o.skippedCourses.length})}`:""]}):o?e.jsxs("div",{className:"text-label text-warning break-all",role:"alert","data-testid":"settings-dsh-error",children:[t("settings.dsh.failed"),": ",o.error??"unknown"]}):null]})}export{Ft as SettingsView};
|