lookatstudy-mobile 0.36.0 → 0.37.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/package.json +1 -1
- package/server.cjs +10 -4
- package/web/assets/{CanvasStage-2yeV4nPH.js → CanvasStage-DNJ3CvSQ.js} +1 -1
- package/web/assets/{CommandPalette-BFX8tcFC.js → CommandPalette-0omhbLg3.js} +1 -1
- package/web/assets/{CompanionBotLab-DTlObSeR.js → CompanionBotLab-CT_JHmNI.js} +1 -1
- package/web/assets/{CourseSearchPanel-DiuZkUSE.js → CourseSearchPanel-DVtN9ACi.js} +1 -1
- package/web/assets/{ExamView-fx7mUx8Q.js → ExamView-DPMDpplK.js} +1 -1
- package/web/assets/MermaidArtifact-BaJ5RvRv.js +9 -0
- package/web/assets/{PersonalProfileModal-CivNUd4y.js → PersonalProfileModal-IhrruXfg.js} +1 -1
- package/web/assets/{ReviewPanel-CdgUqKuF.js → ReviewPanel-C1ldctfO.js} +1 -1
- package/web/assets/{SettingsView-pzj-Jlrz.js → SettingsView-B6w445fE.js} +3 -3
- package/web/assets/{VoicePanel-Cyopy3sr.js → VoicePanel-CcYGhBPb.js} +1 -1
- package/web/assets/{abnfDiagram-VCTEODGH-Dn5J4BZu.js → abnfDiagram-VCTEODGH-BU9D6UxH.js} +1 -1
- package/web/assets/{abnfDiagram-VCTEODGH-ODA7YWAP-6WuG0Nt3.js → abnfDiagram-VCTEODGH-ODA7YWAP-CbNOQFqA.js} +1 -1
- package/web/assets/{architectureDiagram-5GKGNRK7-C4PU3XN7-BtKh8197.js → architectureDiagram-5GKGNRK7-C4PU3XN7-T9qCk6kM.js} +1 -1
- package/web/assets/{architectureDiagram-5GKGNRK7-jrCKwrXL.js → architectureDiagram-5GKGNRK7-CKMhI1Ee.js} +1 -1
- package/web/assets/{blockDiagram-I7D4REHJ-CWtkTOLG.js → blockDiagram-I7D4REHJ-Bik9DaYN.js} +1 -1
- package/web/assets/{blockDiagram-NRAW4CY4-UMJ6PMQQ-DHl4tIPo.js → blockDiagram-NRAW4CY4-UMJ6PMQQ-Dy4ybhQI.js} +1 -1
- package/web/assets/{c4Diagram-7LVT6UL2-DvgOYbmL.js → c4Diagram-7LVT6UL2-IRtYuDM_.js} +1 -1
- package/web/assets/{c4Diagram-UCG6FXSJ-75X3U2P3-8t5uU1V0.js → c4Diagram-UCG6FXSJ-75X3U2P3-BCGvMp1I.js} +1 -1
- package/web/assets/channel-D6qbQnDp.js +1 -0
- package/web/assets/{chunk-2Q5K7J3B-D-MRkRaW.js → chunk-2Q5K7J3B-DSi_blpC.js} +1 -1
- package/web/assets/{chunk-5VM5RSS4-DgMwQtQx.js → chunk-5VM5RSS4-JiyA-wo9.js} +1 -1
- package/web/assets/{chunk-7XDTSPCN-C6CLiznJ.js → chunk-7XDTSPCN-Cvb-oYet.js} +1 -1
- package/web/assets/{chunk-CTNIYPP6-CM1Z69qf.js → chunk-CTNIYPP6-HjnzrVvf.js} +1 -1
- package/web/assets/{chunk-CXNFBKHE-B6ieqKBL.js → chunk-CXNFBKHE-DzkNdxBi.js} +1 -1
- package/web/assets/{chunk-F27PBJKO-AboV3MjF.js → chunk-F27PBJKO-DqqFugb1.js} +1 -1
- package/web/assets/{chunk-IMKFNOWR-BRfxTcG3.js → chunk-IMKFNOWR-0q0swfWT.js} +1 -1
- package/web/assets/{chunk-ISA7TJRJ-BA6VnLlf.js → chunk-ISA7TJRJ-BX1hKFZw.js} +1 -1
- package/web/assets/{chunk-JWPE2WC7-CM5DFf0Z.js → chunk-JWPE2WC7-BGDdCd7e.js} +1 -1
- package/web/assets/{chunk-LV3HUYFY-DtT0YyqZ.js → chunk-LV3HUYFY-DXfPtXuN.js} +1 -1
- package/web/assets/{chunk-M3IUQBOH-DGSTxKRB.js → chunk-M3IUQBOH-BGP9XzSA.js} +1 -1
- package/web/assets/{chunk-NDIOYS4C-BDCIN1Cv.js → chunk-NDIOYS4C-CzRGOiBm.js} +1 -1
- package/web/assets/{chunk-POPQ4Y6H-CRs1ouKF.js → chunk-POPQ4Y6H-CJEN76eb.js} +1 -1
- package/web/assets/{chunk-RE4WF27V-CPwQc2vn.js → chunk-RE4WF27V-CwpP9UVY.js} +1 -1
- package/web/assets/{chunk-SVP7TREG-Cbw7rxkD.js → chunk-SVP7TREG-DKVY1S0P.js} +1 -1
- package/web/assets/{chunk-TICWLB2K-CJpuBU6m.js → chunk-TICWLB2K-DnGZt5_T.js} +1 -1
- package/web/assets/{chunk-VII2H2IX-udiwuRgE.js → chunk-VII2H2IX-DXWnTQhH.js} +1 -1
- package/web/assets/{chunk-X5GNSKZ3-DvVFKhTQ.js → chunk-X5GNSKZ3-EYUWZKOs.js} +1 -1
- package/web/assets/{chunk-XCWWM2C3-EFZq_oj4.js → chunk-XCWWM2C3-DX7b36ww.js} +1 -1
- package/web/assets/{chunk-XXDRQBXY-BCxGit2x.js → chunk-XXDRQBXY-B_w3KgBK.js} +1 -1
- package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-D2p8cYeb.js +1 -0
- package/web/assets/classDiagram-ZZMXUADV-CFJO056W.js +1 -0
- package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-D2p8cYeb.js +1 -0
- package/web/assets/classDiagram-v2-VYDZK3BY-CFJO056W.js +1 -0
- package/web/assets/{core-CTdCef6f.js → core-BKUioWC8.js} +1 -1
- package/web/assets/{cose-bilkent-JH36ORCC-Dfkex2fo.js → cose-bilkent-JH36ORCC-BQ05JG_e.js} +1 -1
- package/web/assets/{cose-bilkent-JH36ORCC-OB24KH3T-CE0-pZTl.js → cose-bilkent-JH36ORCC-OB24KH3T-7k2xivYC.js} +1 -1
- package/web/assets/{cynefin-OW5HDTMX-DeRfvx8D.js → cynefin-OW5HDTMX-DOvceb57.js} +1 -1
- package/web/assets/{cynefin-OW5HDTMX-GVF3BKWE-WBE1vO13.js → cynefin-OW5HDTMX-GVF3BKWE-CyNo44Ct.js} +1 -1
- package/web/assets/{cynefinDiagram-5FMLGOSQ-Bh5b3wB1.js → cynefinDiagram-5FMLGOSQ-CLzU5hRI.js} +1 -1
- package/web/assets/{cynefinDiagram-5FMLGOSQ-H3WIRU3N-BJvz82EQ.js → cynefinDiagram-5FMLGOSQ-H3WIRU3N-CLiDmyFZ.js} +1 -1
- package/web/assets/{dagre-3AP2YEHR-DCERTXHT-XAHjclga.js → dagre-3AP2YEHR-DCERTXHT-AZC3Sd7-.js} +1 -1
- package/web/assets/{dagre-GXQ25YYZ-DrM7-QVm.js → dagre-GXQ25YYZ-XMzOJ88I.js} +1 -1
- package/web/assets/{diagram-S7CK7UJ4-DuzIHkVE.js → diagram-S7CK7UJ4-BrCtmOAD.js} +1 -1
- package/web/assets/{diagram-S7CK7UJ4-MULGZGEL-DPqhnzpl.js → diagram-S7CK7UJ4-MULGZGEL-Cm4Xy-pF.js} +1 -1
- package/web/assets/{diagram-UQ7AKVKN-DhVHhLx3.js → diagram-UQ7AKVKN-CCcvTlE_.js} +1 -1
- package/web/assets/{diagram-UQ7AKVKN-YQBY353J-CtxlSSGF.js → diagram-UQ7AKVKN-YQBY353J-CVJLwP7S.js} +1 -1
- package/web/assets/{diagram-VSXAHHWV-KRouqsun.js → diagram-VSXAHHWV-CdYFta9M.js} +1 -1
- package/web/assets/{diagram-VSXAHHWV-WLNH2ELY-CIR4bpme.js → diagram-VSXAHHWV-WLNH2ELY-CaWgm0pD.js} +1 -1
- package/web/assets/{diagram-VX7I27RA-CTJ3vljk.js → diagram-VX7I27RA-CM05zRwP.js} +1 -1
- package/web/assets/{diagram-VX7I27RA-XW6YQV5G-BpP1BFMf.js → diagram-VX7I27RA-XW6YQV5G-DKYJGziA.js} +1 -1
- package/web/assets/{diagram-Z3DM3KII-HG7RF65D-BYiYU7xi.js → diagram-Z3DM3KII-HG7RF65D-kC8Vko9Q.js} +1 -1
- package/web/assets/{diagram-Z3DM3KII-D5hgo2N9.js → diagram-Z3DM3KII-He0OkO1p.js} +1 -1
- package/web/assets/{ebnfDiagram-PWID7BFC-DamZ_7Vh.js → ebnfDiagram-PWID7BFC-D6LQclit.js} +1 -1
- package/web/assets/{ebnfDiagram-PWID7BFC-OKY4VHYD-yPy84C7F.js → ebnfDiagram-PWID7BFC-OKY4VHYD-BPNXBqdL.js} +1 -1
- package/web/assets/{elk.bundled-Bnb7YbCz.js → elk.bundled-Oi_dp_Nb.js} +1 -1
- package/web/assets/{erDiagram-RLTQ6QDP-DXutINWC.js → erDiagram-RLTQ6QDP-BC8Dyxni.js} +1 -1
- package/web/assets/{erDiagram-SSCWMZ5O-PIPKOIK7-ZtlmPRSG.js → erDiagram-SSCWMZ5O-PIPKOIK7-BM5hP7pq.js} +1 -1
- package/web/assets/{flowDiagram-A5DVABFB-2Z4AVO5R-RWiTsxAA.js → flowDiagram-A5DVABFB-2Z4AVO5R-BI_HnDMS.js} +1 -1
- package/web/assets/{flowDiagram-HODETNUW-C0v4xgVs.js → flowDiagram-HODETNUW-CQB-KRdk.js} +1 -1
- package/web/assets/{ganttDiagram-EL5Y4UJY-C10Pxkpf.js → ganttDiagram-EL5Y4UJY-DtkBZQfB.js} +1 -1
- package/web/assets/{ganttDiagram-EL5Y4UJY-JZNG7GOG-C3JHepgy.js → ganttDiagram-EL5Y4UJY-JZNG7GOG-CAuwhLrG.js} +1 -1
- package/web/assets/{gitGraphDiagram-WWUBYQGX-DnhwejId.js → gitGraphDiagram-WWUBYQGX-CXMxBD1j.js} +1 -1
- package/web/assets/{gitGraphDiagram-WWUBYQGX-DMWMLL3G-Dvo5dray.js → gitGraphDiagram-WWUBYQGX-DMWMLL3G-CibDMxH5.js} +1 -1
- package/web/assets/{index-C06x750C.js → index-CLC7uJBc.js} +1 -1
- package/web/assets/{index-D5O6zEt9.js → index-DKUjXJrj.js} +1 -1
- package/web/assets/index-DNBtAT86.css +1 -0
- package/web/assets/index-DwG4tw4S.js +53 -0
- package/web/assets/index-pqxwzTgM.js +14 -0
- package/web/assets/{infoDiagram-27XIBGKW-BCK0GNZi.js → infoDiagram-27XIBGKW-BxdeKm2M.js} +1 -1
- package/web/assets/{infoDiagram-RXCK75RN-HANS5KVC-DnIuK4Ld.js → infoDiagram-RXCK75RN-HANS5KVC-XymudzPp.js} +1 -1
- package/web/assets/{ishikawaDiagram-5VMMS53U-7GCIT7WU-D7H0PvCT.js → ishikawaDiagram-5VMMS53U-7GCIT7WU-Ca0czL-r.js} +1 -1
- package/web/assets/{ishikawaDiagram-5VMMS53U-CwfpIEur.js → ishikawaDiagram-5VMMS53U-YiLbdVr3.js} +1 -1
- package/web/assets/{journeyDiagram-3NMN7TZE-D7yc5_ha.js → journeyDiagram-3NMN7TZE-o507o7V3.js} +1 -1
- package/web/assets/{journeyDiagram-EYS64GPL-OAPELBT7-BxN0kQu5.js → journeyDiagram-EYS64GPL-OAPELBT7-COjG9fsS.js} +1 -1
- package/web/assets/{kanban-definition-3QL26DDD-I7RKWQQY-4n8YjWaH.js → kanban-definition-3QL26DDD-I7RKWQQY-dIeka5z7.js} +1 -1
- package/web/assets/{kanban-definition-UXKFOSKX-jCn6YBMx.js → kanban-definition-UXKFOSKX-DPIPqDMI.js} +1 -1
- package/web/assets/{katex-N6JRN4PM-Dsye9nhm.js → katex-N6JRN4PM-C1WPCW7o.js} +1 -1
- package/web/assets/{layout-BGHeGqee.js → layout-CoYqjJku.js} +1 -1
- package/web/assets/{main-D7WqSbOt.js → main-s-bCU9xp.js} +117 -117
- package/web/assets/{mermaid-layout-elk.core-DTUF3xdW.js → mermaid-layout-elk.core-BDxAYedV.js} +2 -2
- package/web/assets/{mermaid.core-C-NqYAhX.js → mermaid.core-DP9HBKfF.js} +5 -5
- package/web/assets/{mindmap-definition-FBJOCRG2-KIYZG64Y-DfNqXTK3.js → mindmap-definition-FBJOCRG2-KIYZG64Y-B0M0vSNL.js} +1 -1
- package/web/assets/{mindmap-definition-YA3MSWOX-D3sKf06e.js → mindmap-definition-YA3MSWOX-CZNKLpKf.js} +1 -1
- package/web/assets/{pegDiagram-XKGWAZYB-CVKDjCVA.js → pegDiagram-XKGWAZYB-BABqVbYU.js} +1 -1
- package/web/assets/{pegDiagram-XKGWAZYB-OIP57N6J-DS2aCbPH.js → pegDiagram-XKGWAZYB-OIP57N6J-ChBhHDWi.js} +1 -1
- package/web/assets/{pet-Du-sCSbe.js → pet-BILzsmZE.js} +1 -1
- package/web/assets/{pieDiagram-E7YTZNPT-2UOTW327-yjF7mWxr.js → pieDiagram-E7YTZNPT-2UOTW327-Dh29Zr3p.js} +1 -1
- package/web/assets/{pieDiagram-E7YTZNPT-Bv5akhT4.js → pieDiagram-E7YTZNPT-van1IvDV.js} +1 -1
- package/web/assets/{quadrantDiagram-AXDQQJYC-O95BF4oR.js → quadrantDiagram-AXDQQJYC-BKgVVqxX.js} +1 -1
- package/web/assets/{quadrantDiagram-AXDQQJYC-SN3ASJJK-BLrtldcO.js → quadrantDiagram-AXDQQJYC-SN3ASJJK-CZYkjMJl.js} +1 -1
- package/web/assets/{railroadDiagram-O6MQD6OU-34742W6X-D8Re17Lm.js → railroadDiagram-O6MQD6OU-34742W6X-BpIuTMjt.js} +1 -1
- package/web/assets/{railroadDiagram-O6MQD6OU-C4dT_AHN.js → railroadDiagram-O6MQD6OU-CAJ_285V.js} +1 -1
- package/web/assets/{render-O7CIS3YK-C1LKCRfk.js → render-O7CIS3YK-Ca_t2BjR.js} +7 -7
- package/web/assets/{requirementDiagram-BXWQKSXE-DRoAJ0A4.js → requirementDiagram-BXWQKSXE-yAxTDLdz.js} +1 -1
- package/web/assets/{requirementDiagram-EFPCY7ZU-NGAFFSMB-BRpdn_yZ.js → requirementDiagram-EFPCY7ZU-NGAFFSMB-qHev6ewP.js} +1 -1
- package/web/assets/{rotate-ccw-BS0Lg3XV.js → rotate-ccw-BcZP2n0D.js} +1 -1
- package/web/assets/{sankeyDiagram-P5KCCOFB-3D3M4XPB-U2MyqhHx.js → sankeyDiagram-P5KCCOFB-3D3M4XPB-C0dgNg43.js} +1 -1
- package/web/assets/{sankeyDiagram-P5KCCOFB-DhLHY7NO.js → sankeyDiagram-P5KCCOFB-DzYIq4fM.js} +1 -1
- package/web/assets/{sequenceDiagram-WJ2MYXX4-Q2IOPB4R-C3se4pTd.js → sequenceDiagram-WJ2MYXX4-Q2IOPB4R-CYgHEbKX.js} +1 -1
- package/web/assets/{sequenceDiagram-WJ2MYXX4-C5QbVOkW.js → sequenceDiagram-WJ2MYXX4-bSfs95J7.js} +1 -1
- package/web/assets/{sizeCapture-INFHLROL-Ds6O28WR.js → sizeCapture-INFHLROL-6sblijow.js} +1 -1
- package/web/assets/{sizeCapture-X5ZJPWSS-PSGVOMYM-Dalg_GSB.js → sizeCapture-X5ZJPWSS-PSGVOMYM-BmietHRl.js} +1 -1
- package/web/assets/{stateDiagram-D77RDMKH-C4Loqn2S.js → stateDiagram-D77RDMKH-BqN2X_4K.js} +1 -1
- package/web/assets/{stateDiagram-HBIQ2CUA-4M2S6MAN-CYg9tFmx.js → stateDiagram-HBIQ2CUA-4M2S6MAN-B7l4qfxn.js} +1 -1
- package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-DnMNJ_k7.js +1 -0
- package/web/assets/stateDiagram-v2-MP3YSRHH-DjlfW1YP.js +1 -0
- package/web/assets/{swimlanes-42K2YHIH-B95g1myb.js → swimlanes-42K2YHIH-BdpdGi8U.js} +1 -1
- package/web/assets/{swimlanes-XN3QIQJK-N6N2CCQ6-BVCO5pth.js → swimlanes-XN3QIQJK-N6N2CCQ6-DeA0ywq0.js} +1 -1
- package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-rqMW1YeU.js +8 -0
- package/web/assets/swimlanesDiagram-VR7AAH4N-SUwVZHzH.js +8 -0
- package/web/assets/{timeline-definition-24CTP7MA-DfbDTQSt.js → timeline-definition-24CTP7MA-C4WRMueq.js} +1 -1
- package/web/assets/{timeline-definition-24CTP7MA-KN7RSRVM-Ba1F1ajL.js → timeline-definition-24CTP7MA-KN7RSRVM-DCfXzMAD.js} +1 -1
- package/web/assets/{vennDiagram-4TSXK5OY-AKJ7LXAN-B9Nx1RWB.js → vennDiagram-4TSXK5OY-AKJ7LXAN-B22sFTL4.js} +1 -1
- package/web/assets/{vennDiagram-4TSXK5OY-B-uAb-fo.js → vennDiagram-4TSXK5OY-Czwyh2Ss.js} +1 -1
- package/web/assets/{wardleyDiagram-VM6X3IG4-3B6A3BN5-v-icjHpd.js → wardleyDiagram-VM6X3IG4-3B6A3BN5-DUtEE3hD.js} +1 -1
- package/web/assets/{wardleyDiagram-VM6X3IG4-Cr0_wFiw.js → wardleyDiagram-VM6X3IG4-BaWPp6GW.js} +1 -1
- package/web/assets/{xychartDiagram-S5SC5T6Z-DwsgX-jd.js → xychartDiagram-S5SC5T6Z-BzArL7i2.js} +1 -1
- package/web/assets/{xychartDiagram-S5SC5T6Z-OBDNV6WG-BX7F_LDu.js → xychartDiagram-S5SC5T6Z-OBDNV6WG-C3eeDBv5.js} +1 -1
- package/web/index.html +3 -3
- package/web/pet.html +3 -3
- package/web/assets/channel-CSAHJ2BV.js +0 -1
- package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-4hLnkbwM.js +0 -1
- package/web/assets/classDiagram-ZZMXUADV-CMAUnrA5.js +0 -1
- package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-4hLnkbwM.js +0 -1
- package/web/assets/classDiagram-v2-VYDZK3BY-CMAUnrA5.js +0 -1
- package/web/assets/index-BeI-qOIb.js +0 -21
- package/web/assets/index-By7sA5iY.css +0 -1
- package/web/assets/index-C8cLLejx.js +0 -53
- package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-CMhstoHU.js +0 -1
- package/web/assets/stateDiagram-v2-MP3YSRHH-CcPVgXyv.js +0 -1
- package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-CqJNI91T.js +0 -8
- package/web/assets/swimlanesDiagram-VR7AAH4N-BrEEiqe7.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as n,j as e,V as Te,k as be,l as Me,m as Ce,s as ot,n as rt,C as ct,M as dt}from"./index-
|
|
1
|
+
import{r as n,j as e,V as Te,k as be,l as Me,m as Ce,s as ot,n as rt,C as ct,M as dt}from"./index-DwG4tw4S.js";import{c as We,u as ce,b as Oe,y as mt,X as ve,f as ut,k as xe,N as je,a as r,W as Le,r as Ue,O as De,Q as xt,q as ht,m as _e,R as pt,V as gt,Y as ft}from"./main-s-bCU9xp.js";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -9,7 +9,7 @@ import{r as n,j as e,V as Te,k as be,l as Me,m as Ce,s as ot,n as rt,C as ct,M a
|
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/const vt=We("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),jt={vision:"companion.custom.routeVision",geometric:"companion.custom.routeGeometric",l1:"companion.custom.routeL1"};function kt(t){let x="";for(let b=0;b<t.length;b+=32768)x+=String.fromCharCode(...t.subarray(b,b+32768));return btoa(x)}async function wt(t){try{return await navigator.clipboard.writeText(t),!0}catch{}const x=document.createElement("textarea");x.value=t,x.style.position="fixed",x.style.opacity="0",document.body.appendChild(x),x.focus(),x.select();let o=!1;try{o=document.execCommand("copy")}catch{o=!1}return x.remove(),o}function Nt({onClose:t,onSaved:x}){const o=ce(),[b,N]=n.useState(!1),[l,c]=n.useState(!1),[v,p]=n.useState(0),[g,S]=n.useState(null),[j,T]=n.useState(null),[$,h]=n.useState(""),[f,z]=n.useState(""),[y,A]=n.useState("ember"),R=n.useRef(null),M=n.useRef(null);Oe(M,!0),n.useEffect(()=>{if(!l)return;p(0);const m=Date.now(),E=window.setInterval(()=>p(Math.floor((Date.now()-m)/1e3)),500);return()=>window.clearInterval(E)},[l]);const q=async()=>{const m=await wt(o("companion.wizard.prompt"));N(m),m?setTimeout(()=>N(!1),2400):T(o("companion.wizard.copyFail"))},V=async m=>{if(m){c(!0),T(null),S(null),h(m.name.replace(/\.png$/i,""));try{const E=kt(new Uint8Array(await m.arrayBuffer())),_=await window.api.companionPackCutFromImage({pngBase64:E});S(_),_.visionError?T(`${o("companion.custom.visionFallback")} · ${_.visionError}`):T(`${o("companion.custom.cutDone")} · ${o(jt[_.route]??"companion.custom.routeL1")}`)}catch(E){T(`${o("companion.custom.fail")}: ${String(E)}`)}finally{c(!1)}}},B=async()=>{if(g){c(!0);try{await window.api.companionPackApplyPack({name:f.trim()||$||"My Bot",manifest:{...g.manifest,vehicle:y},parts:g.parts.map(m=>({name:m.name,pngBase64:m.pngBase64}))}),await Me(),await window.api.setSetting("companion_form","custom"),window.dispatchEvent(new Event("companion-config-changed")),x()}catch(m){T(`${o("companion.custom.fail")}: ${String(m)}`)}finally{c(!1)}}};return mt.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":o("companion.wizard.title"),onClick:t,children:e.jsxs("div",{ref:M,onClick:m=>m.stopPropagation(),className:"w-full max-w-xl max-h-[86vh] overflow-y-auto rounded-2xl bg-surface-1 shadow-pop p-4","data-testid":"companion-wizard",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-body font-bold text-ink-strong",children:o("companion.wizard.title")}),e.jsx("button",{onClick:t,"aria-label":o("action.close"),className:"text-ink-muted hover:text-ink-strong w-8 h-8 flex items-center justify-center rounded-lg hover:bg-surface-2",children:e.jsx(ve,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"rounded-xl border border-[var(--border-faint)] p-3 mb-2",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1",children:o("companion.wizard.s1")}),e.jsx("p",{className:"text-caption text-ink-muted leading-relaxed",children:o("companion.wizard.s1body")})]}),e.jsxs("div",{className:"rounded-xl border border-[var(--border-faint)] p-3 mb-2",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1",children:o("companion.wizard.s2")}),e.jsx("p",{className:"text-caption text-ink-muted leading-relaxed mb-2",children:o("companion.wizard.s2body")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("a",{href:"https://www.doubao.com/chat/",target:"_blank",rel:"noreferrer",className:"rounded-lg border border-[var(--border-faint)] px-3 py-1.5 text-label hover:bg-surface-2",children:o("companion.wizard.s2doubao")}),e.jsx("a",{href:"https://jimeng.jianying.com/",target:"_blank",rel:"noreferrer",className:"rounded-lg border border-[var(--border-faint)] px-3 py-1.5 text-label hover:bg-surface-2",children:o("companion.wizard.s2jimeng")}),e.jsx("a",{href:"https://chatgpt.com/",target:"_blank",rel:"noreferrer",className:"rounded-lg border border-[var(--border-faint)] px-3 py-1.5 text-label hover:bg-surface-2",children:o("companion.wizard.s2chatgpt")}),e.jsx("button",{type:"button",onClick:()=>void q(),"data-testid":"companion-wizard-copy",className:"rounded-lg bg-accent px-3 py-1.5 text-label text-white hover:opacity-90",children:o(b?"companion.wizard.copied":"companion.wizard.copy")})]}),e.jsx("textarea",{readOnly:!0,value:o("companion.wizard.prompt"),rows:6,className:"w-full rounded-lg bg-surface-2 border border-[var(--border-faint)] p-2 text-caption text-ink-muted font-mono resize-y select-all",onFocus:m=>m.currentTarget.select()})]}),e.jsxs("div",{className:"rounded-xl border border-[var(--border-faint)] p-3",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1",children:o("companion.wizard.s3")}),e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-caption text-ink-muted mb-1",children:o("companion.wizard.vehicle")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",role:"radiogroup","aria-label":o("companion.wizard.vehicle"),children:Te.map(m=>{const E=y===m;return e.jsxs("button",{type:"button",role:"radio","aria-checked":E,"data-testid":`companion-wizard-veh-${m}`,onClick:()=>A(m),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-label motion-safe:transition-colors
|
|
12
|
-
${E?"border-[var(--accent)] bg-surface-2 text-ink-strong font-medium":"border-[var(--border-faint)] hover:bg-surface-2 text-ink-muted"}`,children:[e.jsx("span",{"aria-hidden":"true",className:"w-3 h-3 rounded-full border border-black/20",style:{background:be[m].dot}}),o(`companion.form.${m}.name`)]},m)})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("input",{ref:R,type:"file",accept:"image/png",className:"hidden","data-testid":"companion-custom-file",onChange:m=>{var E;return void V((E=m.target.files)==null?void 0:E[0])}}),e.jsx("button",{type:"button",disabled:l,onClick:()=>{var m;return(m=R.current)==null?void 0:m.click()},"data-testid":"companion-wizard-pick",className:"rounded-lg border border-[var(--border-faint)] px-3 py-1.5 text-label hover:bg-surface-2 disabled:opacity-50",children:o("companion.wizard.pick")}),l&&e.jsxs("span",{className:"flex items-center gap-1.5 text-label text-ink-muted","data-testid":"companion-custom-busy",children:[e.jsx(ut,{size:14,className:"animate-spin"}),o(g?"companion.custom.applying":"companion.custom.locating"),e.jsxs("span",{className:"tabular-nums",children:[v,"s"]})]}),j&&e.jsx("span",{className:"text-caption text-ink-muted","data-testid":"companion-custom-msg",children:j})]}),g&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"companion-custom-preview",children:[g.parts.map(m=>e.jsx("img",{src:`data:image/png;base64,${m.pngBase64}`,alt:m.name,title:m.name,className:"h-14 w-14 object-contain rounded-lg bg-surface-2"},m.name)),e.jsx("input",{value:f,onChange:m=>z(m.target.value),placeholder:o("companion.wizard.namePh"),"data-testid":"companion-wizard-name",className:"rounded-lg border border-[var(--border-faint)] bg-surface-0 px-2.5 py-1.5 text-label text-ink-strong placeholder:text-ink-muted w-36"}),e.jsx("button",{type:"button",disabled:l,onClick:()=>void B(),"data-testid":"companion-custom-apply",className:"rounded-lg bg-brand px-3 py-1.5 text-label text-white hover:opacity-90 disabled:opacity-50",children:o("companion.wizard.save")})]})]})]})}),document.body)}const yt=[{id:"shimejiorg",label:"shimeji.org",url:"https://shimeji.org/"},{id:"shimejisxyz",label:"shimejis.xyz",url:"https://shimejis.xyz/"},{id:"cachomon",label:"Cachomon",url:"https://cachomon.com/"},{id:"deviantart",label:"DeviantArt",url:"https://www.deviantart.com/search?q=shimeji"}];function St({onClose:t,onImported:x}){const o=ce(),b=n.useRef(null),N=n.useRef(null);Oe(b,!0);const[l,c]=n.useState(!1),[v,p]=n.useState(null),[g,S]=n.useState(null),j=async h=>{var z;const f=(z=h.target.files)==null?void 0:z[0];if(h.target.value="",!!f){c(!0),p(null);try{const y=new Uint8Array(await f.arrayBuffer());let A="";for(let M=0;M<y.length;M+=32768)A+=String.fromCharCode(...y.subarray(M,M+32768));const R=await window.api.shimejiImportZip({zipBase64:btoa(A)});S({importId:R.importId,characters:R.characters,selected:new Set(R.characters.map(M=>M.ref))})}catch(y){p(String(y.message??y).slice(0,160))}finally{c(!1)}}},T=h=>{S(f=>{if(!f)return f;const z=new Set(f.selected);return z.has(h)?z.delete(h):z.add(h),{...f,selected:z}})},$=async()=>{if(g){c(!0);try{await window.api.shimejiConfirmImport({importId:g.importId,characterRefs:[...g.selected]}),S(null),await Ce(),await x(),t()}catch(h){p(String(h.message??h).slice(0,160))}finally{c(!1)}}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":o("settings.shimeji.dialog.title"),onClick:t,children:e.jsxs("div",{ref:b,onClick:h=>h.stopPropagation(),className:"relative w-full max-w-md rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4","data-testid":"shimeji-dialog",children:[e.jsx("button",{type:"button","aria-label":o("action.close"),"data-testid":"shimeji-dialog-close",onClick:t,className:"absolute top-2.5 right-2.5 w-7 h-7 rounded-lg flex items-center justify-center text-ink-muted hover:text-ink-strong hover:bg-surface-2",children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsx("div",{className:"text-body font-medium text-ink-strong mb-1",children:o("settings.shimeji.dialog.title")}),e.jsx("p",{className:"text-label text-ink-muted mb-3",children:o("settings.shimeji.desc")}),!g&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button","data-testid":"shimeji-import",disabled:l,onClick:()=>{var h;return(h=N.current)==null?void 0:h.click()},className:"w-full rounded-xl border border-dashed border-[var(--border)] py-6 flex flex-col items-center gap-1.5 text-ink-faint hover:text-ink-muted hover:bg-surface-2 disabled:opacity-50",children:[e.jsx("span",{className:"text-label font-medium",children:o(l?"settings.shimeji.importing":"settings.shimeji.import")}),e.jsx("span",{className:"text-caption",children:o("settings.shimeji.guide")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2","data-testid":"shimeji-download-links",children:yt.map(h=>e.jsxs("a",{href:h.url,target:"_blank",rel:"noopener noreferrer","data-testid":`shimeji-link-${h.id}`,className:"inline-flex items-center gap-1 rounded-lg border border-[var(--border-faint)] px-2 py-1 text-caption text-ink-muted hover:text-ink-strong hover:bg-surface-2 motion-safe:transition-colors",children:[e.jsx(bt,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),h.label]},h.id))})]}),e.jsx("input",{ref:N,type:"file",accept:".zip",className:"hidden",onChange:h=>void j(h)}),v&&e.jsx("p",{className:"text-caption text-warning mt-2",role:"alert",children:v}),g&&e.jsxs("div",{className:"rounded-xl border border-[var(--border)] bg-surface-1 p-3","data-testid":"shimeji-character-picker",children:[e.jsx("div",{className:"text-body text-ink-strong mb-2",children:o("settings.shimeji.pick.title")}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:g.characters.map(h=>{const f=g.selected.has(h.ref);return e.jsxs("button",{type:"button","aria-pressed":f,onClick:()=>T(h.ref),className:`flex items-center gap-2 rounded-xl border p-2 text-left ${f?"border-[var(--accent)] bg-surface-2":"border-[var(--border-faint)]"}`,children:[h.iconBase64?e.jsx("img",{src:`data:image/png;base64,${h.iconBase64}`,alt:"",className:"w-9 h-9 rounded-lg object-contain bg-surface-2"}):e.jsx("div",{className:"w-9 h-9 rounded-lg bg-surface-2"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-body text-ink-strong",children:h.name}),e.jsxs("span",{className:"text-caption text-ink-muted",children:[h.format," · ",h.frameCount,"f · ",h.actionCount]})]})]},h.ref)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button","data-testid":"shimeji-confirm-import",className:"btn-3d-brand px-3 py-1.5 text-label",disabled:l||g.selected.size===0,onClick:()=>void $(),children:o("settings.shimeji.pick.confirm",{count:g.selected.size})}),e.jsx("button",{type:"button",className:"btn-3d-neutral px-3 py-1.5 text-label",onClick:t,children:o("action.cancel")})]})]})]})})}const fe="bg-ink/[0.04] text-ink-strong text-label rounded-lg border border-transparent focus:border-accent focus:bg-ink/[0.06] transition-colors placeholder:text-ink-faint";function $e({kind:t,showProtocol:x=!0,testPrefix:o="custom",titleKey:b="settings.custom.form_title",modelPhKey:N="settings.custom.model_ph",testOverride:l,onSaved:c,onCancel:v}){const p=ce(),[g,S]=n.useState(""),[j,T]=n.useState("openai-compatible"),[$,h]=n.useState(""),[f,z]=n.useState(""),[y,A]=n.useState(""),[R,M]=n.useState(!1),[q,V]=n.useState(!1),[B,m]=n.useState(null),E=async()=>{if(!(!$.trim()||!y.trim()||q)){V(!0),m(null);try{const k=l?await l({baseUrl:$.trim(),apiKey:f.trim(),model:y.trim()}):await r.testCustomProvider({label:g||p("settings.custom.test_label"),protocol:j,baseUrl:$.trim(),apiKey:f.trim()||void 0,defaultModel:y.trim()});m({ok:k.ok,detail:k.detail})}catch(k){m({ok:!1,detail:k instanceof Error?k.message:String(k)})}finally{V(!1)}}},_=async()=>{if(!(!g.trim()||!$.trim()||!y.trim()))try{const k=await r.createCustomProvider({label:g.trim(),kind:t,protocol:x?j:"openai-compatible",baseUrl:$.trim(),apiKey:f.trim()||void 0,defaultModel:y.trim(),vision:t==="llm"?R:void 0});c(k)}catch{}};return e.jsxs("div",{className:"space-y-2.5","data-testid":`${o}-provider-form`,children:[e.jsx("div",{className:"text-label font-bold text-ink-strong",children:p(b)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:g,onChange:k=>S(k.target.value),placeholder:p("settings.custom.label_ph"),"data-testid":`${o}-label`,className:`${fe} min-w-0 flex-1 px-2.5 py-1.5`}),x&&e.jsxs("select",{value:j,onChange:k=>T(k.target.value),"data-testid":`${o}-protocol`,className:`${fe} px-2 py-1.5`,children:[e.jsx("option",{value:"openai-compatible",children:p("settings.proto.openai")}),e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"google",children:"Google"})]})]}),e.jsx("input",{type:"text",value:$,onChange:k=>h(k.target.value),placeholder:p("settings.custom.baseurl_ph"),"data-testid":`${o}-baseurl`,className:`${fe} w-full px-2.5 py-1.5 font-mono`}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:y,onChange:k=>A(k.target.value),placeholder:p(N),"data-testid":`${o}-model`,className:`${fe} min-w-0 flex-1 px-2.5 py-1.5 font-mono`}),e.jsx("input",{type:"password",value:f,onChange:k=>z(k.target.value),placeholder:p("settings.custom.apikey_ph"),"data-testid":`${o}-apikey`,className:`${fe} min-w-0 flex-1 px-2.5 py-1.5`})]}),t==="llm"&&e.jsxs("label",{className:"inline-flex items-center gap-2 text-label cursor-pointer select-none","data-testid":`${o}-vision`,children:[e.jsx("input",{type:"checkbox",checked:R,onChange:k=>M(k.target.checked),className:"w-4 h-4 rounded accent-brand"}),e.jsx("span",{className:"text-ink-strong",children:p("settings.custom.vision")}),e.jsx("span",{className:"text-ink-faint",children:p("settings.custom.visionHint")})]}),B&&e.jsxs("div",{className:`text-label rounded p-2 inline-flex items-start gap-1.5 ${B.ok?"bg-brand/10 text-brand":"bg-warning/10 text-warning"}`,children:[B.ok?e.jsx(xe,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"break-words",children:B.detail})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>void E(),disabled:!$.trim()||!y.trim()||q,"data-testid":`${o}-test`,className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:p(q?"settings.testing":"settings.test")}),e.jsx("button",{onClick:()=>void _(),disabled:!g.trim()||!$.trim()||!y.trim(),"data-testid":`${o}-save`,className:"btn-3d-brand px-3 py-1.5 text-label disabled:opacity-40",children:p("settings.custom.save")}),v&&e.jsx("button",{onClick:v,className:"text-label text-ink-muted hover:text-ink-strong px-3 py-1.5 transition-colors",children:p("action.cancel")})]})]})}const He="lookatstudy-theme",Ke="auto",qe="(prefers-color-scheme: dark)";function Pe(){return typeof window>"u"||window.matchMedia(qe).matches?"dark":"light"}function Ct(){if(typeof localStorage>"u")return Ke;const t=localStorage.getItem(He);return t==="auto"||t==="light"||t==="dark"?t:Ke}function ze(t){const x=document.documentElement;x.classList.remove("dark","light"),x.classList.add(t),window.dispatchEvent(new CustomEvent("theme-changed",{detail:{resolved:t}}))}function _t(){const[t,x]=n.useState(()=>Ct()),[o,b]=n.useState(()=>t==="auto"?Pe():t),N=n.useCallback(l=>{x(l),localStorage.setItem(He,l);const c=l==="auto"?Pe():l;b(c),ze(c)},[]);return n.useEffect(()=>{if(t!=="auto")return;const l=window.matchMedia(qe),c=v=>{const p=v.matches?"dark":"light";b(p),ze(p)};return l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[t]),n.useEffect(()=>{const l=t==="auto"?Pe():t;b(l),ze(l)},[t]),{mode:t,resolved:o,setMode:N}}const $t="0.36.0",Et={version:$t};function Se(){window.dispatchEvent(new Event(ft))}const ie="bg-surface-1 text-ink text-body rounded-lg border border-[var(--border)] focus:border-brand focus:outline-none transition-colors placeholder:text-ink-faint",ee="bg-surface-3 text-ink-muted hover:bg-surface-3 hover:bg-surface-3 hover:text-ink-strong",te="bg-brand text-white shadow-sm";function P(t){return t?"px-4 py-3.5 border-t border-[var(--border-faint)]":"px-4 py-3.5"}function Bt(){const t=ce(),[x,o]=n.useState([]),[b,N]=n.useState([]),[l,c]=n.useState("glm"),[v,p]=n.useState(""),[g,S]=n.useState(""),[j,T]=n.useState(null),[$,h]=n.useState(!1),[f,z]=n.useState(null),[y,A]=n.useState(!1),[R,M]=n.useState(!1),[q,V]=n.useState([]),[B,m]=n.useState(!1),[E,_]=n.useState(null),[k,O]=n.useState(null),[W,G]=n.useState(""),[d,X]=n.useState(!1),U=_t(),se=async i=>{if(I)try{await r.updateCustomProvider(I.id,{vision:i}),await H()}catch{}},ae=async()=>{m(!0),_(null);try{const i=await r.discoverModels();i.ok&&i.models?V(i.models):_(i.error||t("settings.discover_failed"))}catch(i){_(i instanceof Error?i.message:String(i))}finally{m(!1)}},H=n.useCallback(async()=>{try{const[i,C,K,Z]=await Promise.all([r.getProviderPresets(),r.listCustomProviders(),r.getSetting("active_provider"),r.getSetting("active_model")]);o(i),N(C);const F=K??"glm";if(c(F),F.startsWith("custom-")){const s=C.find(u=>u.id===F);T(s!=null&&s.hasApiKey?t("settings.key.configured"):null)}else{const s=i.find(u=>u.id===F);if(s){const u=await r.hasSetting(s.apiKeySetting);T(u?t("settings.key.configured"):null)}}if(F.startsWith("custom-")){const s=C.find(u=>u.id===F);p(Z??(s==null?void 0:s.defaultModel)??"")}else{const s=i.find(u=>u.id===F);p(Z??(s==null?void 0:s.defaultModel)??"")}}catch(i){console.error("[SettingsView] load() failed:",i)}},[t]);n.useEffect(()=>{H()},[H]);const le=async i=>{c(i),z(null),S("");const C=x.find(K=>K.id===i);if(C){const K=await r.hasSetting(C.apiKeySetting);T(K?t("settings.key.configured"):null),p(v||C.defaultModel)}},me=async()=>{A(!1);try{if(await r.setSetting("active_provider",l),await r.setSetting("active_model",v),g.trim()){const i=x.find(C=>C.id===l);i&&(await r.setSetting(i.apiKeySetting,g.trim()),T(`${g.trim().slice(0,4)}…${g.trim().slice(-4)}`),S(""))}A(!0),setTimeout(()=>A(!1),2e3),window.dispatchEvent(new Event("llm-config-changed"))}catch{}},D=async()=>{h(!0),z(null);try{const i=await r.testLlmConnection();z(i)}catch(i){z({ok:!1,detail:i instanceof Error?i.message:String(i),errorKind:"unknown"})}finally{h(!1)}},J=async i=>{await r.setSetting("active_provider",i.id),await r.setSetting("active_model",i.defaultModel),c(i.id),p(i.defaultModel),M(!1),await H(),window.dispatchEvent(new Event("llm-config-changed"))},oe=async i=>{try{await r.deleteCustomProvider(i),l===i&&(await r.setSetting("active_provider","glm"),c("glm")),await H()}catch{}},I=l.startsWith("custom-")?b.find(i=>i.id===l):null;n.useEffect(()=>{if(!I)return;const i=I.models.find(C=>C.id===v);G(i!=null&&i.contextWindow?String(i.contextWindow):"")},[I,v]);const pe=async()=>{var F,s;if(!I)return;const i=W.trim().replace(/[,\s_]/g,""),C=/^(\d+)([km]?)$/i.exec(i);if(i!==""&&!C)return;const K=((F=C==null?void 0:C[2])==null?void 0:F.toLowerCase())==="k"?1e3:((s=C==null?void 0:C[2])==null?void 0:s.toLowerCase())==="m"?1e6:1,Z=i===""||!C?null:Math.max(1,Math.round(parseInt(C[1],10)*K));X(!0);try{const u=I.models.map(L=>L.id===v?{...L,contextWindow:Z}:L);await r.updateCustomProvider(I.id,{models:u}),await H(),window.dispatchEvent(new Event("llm-config-changed"))}catch{}finally{X(!1)}},ne=l.startsWith("custom-")?null:x.find(i=>i.id===l);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-5 pt-5 space-y-6",children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.ai")}),e.jsxs("div",{className:"surface-card overflow-hidden",children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.provider")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5","data-testid":"provider-grid",children:[x.map(i=>e.jsx("button",{onClick:()=>le(i.id),"data-testid":`provider-card-${i.id}`,"aria-pressed":l===i.id,className:`px-3 py-1.5 rounded-lg text-label font-medium whitespace-nowrap transition-colors ${l===i.id?te:ee}`,children:i.label},i.id)),b.filter(i=>i.kind==="llm").map(i=>e.jsxs("button",{onClick:()=>le(i.id),"data-testid":`provider-card-${i.id}`,"aria-pressed":l===i.id,className:`px-3 py-1.5 rounded-lg text-label font-medium whitespace-nowrap transition-colors inline-flex items-center gap-1 ${l===i.id?te:ee}`,children:[e.jsx(Le,{className:"w-3.5 h-3.5","aria-hidden":"true"}),i.label]},i.id)),e.jsxs("button",{onClick:()=>M(i=>!i),"data-testid":"add-custom-provider",className:"px-3 py-1.5 rounded-lg text-label whitespace-nowrap inline-flex items-center gap-1 border border-dashed border-[var(--border)] text-ink-muted hover:border-ink-muted hover:text-ink-strong transition-colors",children:[e.jsx(Ue,{className:"w-3.5 h-3.5","aria-hidden":"true"}),t("settings.add_custom")]})]})]}),R&&e.jsx("div",{className:"px-4 py-3.5 bg-surface-1 border-t border-[var(--border-faint)]",children:e.jsx($e,{kind:"llm",testPrefix:"custom",onSaved:i=>void J(i),onCancel:()=>M(!1)})}),b.length>0&&l.startsWith("custom-")&&e.jsx("div",{className:P(!0),children:e.jsx("button",{onClick:i=>{const C=i.currentTarget.getBoundingClientRect(),K=b.find(Z=>Z.id===l);K&&O({id:K.id,label:K.label,rect:C})},className:"text-label text-warning hover:underline",children:t("settings.delete_custom")})}),ne&&e.jsxs(e.Fragment,{children:[ne.baseUrl&&e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:"Base URL"}),e.jsx("code",{className:"text-label text-ink-faint font-mono break-all",children:ne.baseUrl})]}),e.jsxs("div",{className:P(!0),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.model")}),e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[e.jsxs("select",{value:v,onChange:i=>p(i.target.value),"data-testid":"model-select",className:`${ie} flex-1 px-2.5 py-1.5`,children:[ne.models.map(i=>e.jsx("option",{value:i.id,children:i.id},i.id)),l==="openrouter"&&q.map(i=>e.jsx("option",{value:i.id,children:i.id},i.id))]}),l==="openrouter"&&e.jsxs("button",{onClick:ae,disabled:B,"data-testid":"discover-models-btn",className:"text-label text-accent hover:underline disabled:opacity-40 whitespace-nowrap inline-flex items-center gap-1",children:[e.jsx(vt,{className:`w-3.5 h-3.5 ${B?"animate-spin":""}`,"aria-hidden":"true"}),t(B?"settings.discovering":"settings.refresh")]})]})]}),E&&e.jsx("div",{className:"text-label text-warning mt-1.5 ml-[68px]",children:E})]}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.apikey")}),e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[j&&e.jsxs("span",{className:"text-label text-brand shrink-0 inline-flex items-center gap-1",children:[e.jsx(xe,{className:"w-3.5 h-3.5","aria-hidden":"true"}),j]}),e.jsx("input",{type:"password",value:g,onChange:i=>S(i.target.value),placeholder:t(j?"settings.key.overwrite_ph":"settings.key.paste_ph"),"data-testid":"settings-key-input",className:`${ie} flex-1 px-2.5 py-1.5`}),e.jsx("a",{href:ne.keyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-label text-brand hover:underline whitespace-nowrap",children:t("settings.key.get")})]})]})}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 min-w-0",children:[e.jsx("button",{onClick:D,disabled:$,"data-testid":"test-connection-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:t($?"settings.testing":"settings.test")}),f&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 min-w-0 break-words ${f.ok?"text-brand":"text-warning"}`,children:[f.ok?e.jsx(xe,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}),f.detail]})]})})]}),I&&!ne&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:"Base URL"}),e.jsx("code",{className:"text-label text-ink-faint font-mono break-all",children:I.baseUrl})]}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.model")}),I.models.length>1?e.jsx("select",{value:v,onChange:i=>p(i.target.value),"data-testid":"model-select-custom",className:`${ie} flex-1 px-2.5 py-1.5`,children:I.models.map(i=>e.jsx("option",{value:i.id,children:i.id},i.id))}):e.jsx("input",{type:"text",value:v,onChange:i=>p(i.target.value),placeholder:t("settings.custom.model_ph"),"data-testid":"model-input-custom",className:`${ie} flex-1 px-2.5 py-1.5 font-mono`})]})}),e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.custom.windowLabel")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",inputMode:"numeric",value:W,onChange:i=>G(i.target.value),placeholder:t("settings.custom.windowPh"),"data-testid":"context-window-input",className:`${ie} flex-1 px-2.5 py-1.5 font-mono tabular-nums`}),e.jsx("button",{onClick:pe,disabled:d,"data-testid":"context-window-save",className:"btn-3d-neutral px-3 py-1.5 text-label shrink-0 disabled:opacity-40",children:t("settings.custom.save")})]}),e.jsx("div",{className:"text-caption text-ink-faint mt-1",children:t("settings.custom.windowHint")})]}),e.jsx("div",{className:P(!0),children:e.jsxs("label",{className:"inline-flex items-center gap-2 text-label cursor-pointer select-none","data-testid":"custom-vision-toggle",children:[e.jsx("input",{type:"checkbox",checked:I.vision,onChange:i=>void se(i.target.checked),className:"w-4 h-4 rounded accent-brand"}),e.jsx("span",{className:"text-ink-strong",children:t("settings.custom.vision")}),e.jsx("span",{className:"text-ink-faint",children:t("settings.custom.visionHint")})]})}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 min-w-0",children:[e.jsx("button",{onClick:D,disabled:$,"data-testid":"test-connection-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:t($?"settings.testing":"settings.test")}),f&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 min-w-0 break-words ${f.ok?"text-brand":"text-warning"}`,children:[f.ok?e.jsx(xe,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}),f.detail]})]})})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.vision")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(zt,{activeProvider:l,activeModel:v,presets:x,customProviders:b,onProvidersChanged:()=>void H()})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.speech")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(At,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.memory")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(Tt,{})})]}),e.jsxs("section",{id:"settings-section-companion",children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.companion")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(Mt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.appearance")}),e.jsxs("div",{className:"surface-card overflow-hidden",children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.theme")}),e.jsx("div",{className:"flex gap-2",children:[{mode:"auto",label:t("settings.theme.auto")},{mode:"light",label:t("settings.theme.light")},{mode:"dark",label:t("settings.theme.dark")}].map(({mode:i,label:C})=>e.jsx("button",{onClick:()=>U.setMode(i),"data-testid":`theme-${i}`,"aria-pressed":U.mode===i,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${U.mode===i?te:ee}`,children:C},i))}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:U.mode==="auto"?t("settings.theme.following",{mode:t(`settings.theme.${U.resolved}`)}):null})]}),e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.interface_lang")}),e.jsx("div",{className:"flex gap-2",children:["zh-CN","en"].map(i=>e.jsx("button",{onClick:()=>xt(i),"data-testid":`lang-${i}`,"aria-pressed":De()===i,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${De()===i?te:ee}`,children:i==="zh-CN"?"中文":"English"},i))})]}),e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.import_lang")}),e.jsx(Pt,{})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.data")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(It,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.about")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsxs("div",{className:P(!1),children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:t("settings.row.version")}),e.jsxs("a",{href:"https://github.com/Kaiji-Z/LookatStudy/releases",target:"_blank",rel:"noopener noreferrer",className:"text-label font-mono text-brand hover:underline","data-testid":"settings-version",children:["v",Et.version]})]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.version.hint")})]})})]})]}),e.jsxs("div",{className:"sticky bottom-0 px-5 py-3 bg-surface-0 border-t border-[var(--border)] flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-label text-ink-muted",children:t("settings.footer.hint")}),e.jsxs("button",{onClick:me,"data-testid":"settings-save",className:"btn-3d-brand px-5 py-2 text-body inline-flex items-center gap-1.5",children:[y&&e.jsx(ht,{className:"w-4 h-4","aria-hidden":"true"}),t(y?"settings.saved_text":"settings.footer.save")]})]}),k&&e.jsx(_e,{anchorRect:k.rect,message:t("settings.delete_custom_confirm",{name:k.label}),danger:!0,confirmLabel:t("action.delete"),testid:"custom-provider-delete-confirm",onConfirm:()=>{oe(k.id),O(null)},onCancel:()=>O(null)})]})}function Pt(){const[t,x]=n.useState("en"),[o,b]=n.useState(!1);n.useEffect(()=>{r.getSetting("pref_lang").then(c=>{c&&x(c),b(!0)})},[]);const N=async c=>{x(c),await r.setSetting("pref_lang",c)},l=[{code:"en",label:"English"},{code:"zh-CN",label:"简体中文"},{code:"zh-TW",label:"繁體中文"}];return o?e.jsx("div",{className:"flex gap-2","data-testid":"pref-lang-options",children:l.map(c=>e.jsx("button",{onClick:()=>N(c.code),"data-testid":`pref-lang-${c.code}`,"aria-pressed":t===c.code,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${t===c.code?te:ee}`,children:c.label},c.code))}):null}function zt({activeProvider:t,activeModel:x,presets:o,customProviders:b,onProvidersChanged:N}){const l=ce(),[c,v]=n.useState(!1),[p,g]=n.useState(!1),[S,j]=n.useState(""),[T,$]=n.useState(!1),[h,f]=n.useState(!1),[z,y]=n.useState(null),[A,R]=n.useState(!1);n.useEffect(()=>{Promise.all([r.getSetting("flag_multimodal_import"),r.getSetting("vision_provider_override"),r.getSetting("vision_model_override"),r.getSetting("flag_math_vision")]).then(([d,X,U])=>{v(d==="true"),j(X??""),R(U==="true"),g(!0)})},[]);const M=async()=>{const d=!c;v(d),await r.setSetting("flag_multimodal_import",String(d))},q=async()=>{const d=!A;R(d),await r.setSetting("flag_math_vision",String(d))},V=async d=>{await r.setSetting("vision_provider_override",d.id),await r.setSetting("vision_model_override",d.defaultModel),j(d.id),$(!1)},B=async()=>{await r.setSetting("vision_provider_override",""),await r.setSetting("vision_model_override",""),j(""),$(!1)},[m,E]=n.useState(null),_=async d=>{try{S===d&&(await r.setSetting("vision_provider_override",""),await r.setSetting("vision_model_override",""),j("")),await r.deleteCustomProvider(d)}catch{}finally{N==null||N()}},k=async()=>{if(!h){f(!0),y(null);try{const d=await r.testLlmConnection({vision:!0});y({ok:d.ok,detail:d.detail})}catch(d){y({ok:!1,detail:d instanceof Error?d.message:String(d)})}finally{f(!1)}}},O=b.filter(d=>d.kind==="vision"),W=S.startsWith("custom-")?b.find(d=>d.id===S):null,G=S&&!S.startsWith("custom-")?o.find(d=>d.id===S):null;return p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(he,{checked:c,onChange:M,label:l("settings.multimodal.toggle"),testid:"multimodal-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:l("settings.multimodal.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:l("settings.multimodal.toggle.desc")})]})]}),e.jsxs("div",{className:"px-4 py-3.5 border-t border-[var(--border-faint)] space-y-3",children:[e.jsxs("div",{className:"text-label text-ink-muted bg-ink/5 rounded-lg p-3",children:[e.jsx("div",{className:"font-medium mb-1",children:l("settings.multimodal.current_model",{model:x||l("settings.multimodal.not_selected")})}),e.jsx("div",{children:t.startsWith("custom-")?l("settings.multimodal.hint_custom"):l("settings.multimodal.hint_preset")})]}),e.jsxs("div",{className:"bg-ink/5 rounded-lg p-3",children:[e.jsx("div",{className:"text-label font-medium text-ink-muted mb-2",children:l("settings.multimodal.override_title")}),e.jsx("div",{className:"text-caption text-ink-muted mb-2",children:l("settings.multimodal.override_bridge_hint")}),e.jsxs("div",{className:"space-y-3 mt-1",children:[W&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx(Le,{className:"w-3.5 h-3.5 text-ink-faint shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium text-ink-strong",children:W.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:W.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:W.baseUrl})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{onClick:()=>void k(),disabled:h,"data-testid":"vision-override-test",className:"btn-3d-neutral px-4 py-1.5 text-label disabled:opacity-50",children:l(h?"settings.testing":"settings.multimodal.test_override")}),e.jsx("button",{onClick:()=>$(d=>!d),className:"text-label text-accent hover:underline",children:l("settings.multimodal.replace_custom")}),e.jsx("button",{onClick:()=>void B(),className:"text-label text-ink-muted hover:text-ink-strong",children:l("settings.multimodal.stop_override")}),e.jsx("button",{onClick:d=>{d.stopPropagation(),E({id:W.id,label:W.label,rect:d.currentTarget.getBoundingClientRect()})},"data-testid":`vision-delete-${W.id}`,className:"text-label text-ink-muted hover:text-warning",children:l("action.delete")}),z&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${z.ok?"text-brand":"text-warning"}`,children:[z.ok?e.jsx(xe,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4","aria-hidden":"true"}),z.detail]})]})]}),G&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx("span",{className:"text-ink-muted",children:l("settings.multimodal.legacy_preset",{label:G.label})}),e.jsx("button",{onClick:()=>void B(),className:"text-label text-ink-muted hover:text-ink-strong underline",children:l("settings.multimodal.stop_override")})]}),!W&&!G&&e.jsxs(e.Fragment,{children:[O.map(d=>e.jsxs("span",{className:"relative block",children:[e.jsxs("button",{onClick:()=>void V(d),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`vision-pick-${d.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:d.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:d.defaultModel})]}),e.jsx("button",{type:"button","aria-label":l("action.delete"),"data-tooltip":l("action.delete"),"data-testid":`vision-delete-${d.id}`,onClick:X=>{X.stopPropagation(),E({id:d.id,label:d.label,rect:X.currentTarget.getBoundingClientRect()})},className:"absolute top-1.5 right-1.5 w-6 h-6 rounded-full text-ink-muted hover:text-warning flex items-center justify-center hover:bg-surface-2",children:e.jsx(ve,{className:"w-3.5 h-3.5"})})]},d.id)),(T||O.length===0)&&e.jsx($e,{kind:"vision",testPrefix:"vision-custom",titleKey:"settings.custom.form_title_vision",modelPhKey:"settings.custom.model_ph_vision",onSaved:d=>void V(d),onCancel:()=>$(!1)}),O.length>0&&e.jsx("button",{onClick:()=>$(d=>!d),className:"text-label text-accent hover:underline",children:l(T?"action.cancel":"settings.custom.new")})]})]})]}),e.jsxs("div",{className:"bg-ink/5 rounded-lg p-3 flex items-center gap-3",children:[e.jsx(he,{checked:A,onChange:q,label:l("settings.mathvision.toggle"),testid:"math-vision-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:l("settings.mathvision.toggle")}),e.jsx("div",{className:"text-caption text-ink-muted",children:l("settings.mathvision.desc")})]})]})]}),m&&e.jsx(_e,{anchorRect:m.rect,message:l("settings.delete_custom_confirm",{name:m.label}),danger:!0,confirmLabel:l("action.delete"),testid:"vision-provider-delete-confirm",onConfirm:()=>{_(m.id),E(null)},onCancel:()=>E(null)})]}):null}function Tt(){const t=ce(),[x,o]=n.useState(!1),[b,N]=n.useState(!1);n.useEffect(()=>{r.getSetting("flag_memory_system").then(c=>{o(c==="true"),N(!0)})},[]);const l=async()=>{const c=!x;o(c),await r.setSetting("flag_memory_system",String(c))};return b?e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(he,{checked:x,onChange:l,label:t("settings.memory.toggle"),testid:"memory-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.memory.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.memory.toggle.desc")})]})]}):null}function Mt(){var K,Z,F;const t=ce(),[x,o]=n.useState(!0),[b,N]=n.useState(!1),l=n.useSyncExternalStore(ot,rt),[c,v]=n.useState(!0),[p,g]=n.useState(!1),S=typeof window<"u"&&!!window.__lookatstudyWeb;n.useEffect(()=>{r.getSetting("companion_enabled").then(s=>{o(s!=="false"&&s!=="0"),N(!0)}),r.getSetting("companion_sfx").then(s=>{v(s!=="false"&&s!=="0")}),r.getSetting("companion_pet_mode").then(s=>{g(s==="1")})},[]);const j=async()=>{const s=!x;o(s),await r.setSetting("companion_enabled",String(s)),window.dispatchEvent(new Event("companion-config-changed"))},T=async()=>{const s=!c;v(s),await r.setSetting("companion_sfx",String(s)),window.dispatchEvent(new Event("companion-config-changed"))},$=async()=>{const s=!p;g(s),await r.setSetting("companion_pet_mode",s?"1":"0"),window.dispatchEvent(new Event("companion-config-changed"))},h=async s=>{s!==l.form&&(await r.setSetting("companion_form",s),window.dispatchEvent(new Event("companion-config-changed")))},[f,z]=n.useState([]),[y,A]=n.useState(!1),[R,M]=n.useState(null),[q,V]=n.useState(!1),[B,m]=n.useState(!1),[E,_]=n.useState(!1),[k,O]=n.useState(null),[W,G]=n.useState(!1),[d,X]=n.useState([]),[U,se]=n.useState(null),[ae,H]=n.useState(null),[le,me]=n.useState(null),D=n.useCallback(async()=>{try{z((await window.api.companionPackList()).packs)}catch{}},[]),J=n.useCallback(async()=>{try{X((await window.api.shimejiList()).packs)}catch{}},[]);n.useEffect(()=>{D(),J();const s=()=>{D(),J()};return window.addEventListener("companion-config-changed",s),()=>window.removeEventListener("companion-config-changed",s)},[D,J]);const oe=async s=>{await r.shimejiActivate({id:s}),l.form!=="shimeji"&&await r.setSetting("companion_form","shimeji"),window.dispatchEvent(new Event("companion-config-changed")),await J(),await Ce()},I=async(s,u)=>{await window.api.shimejiSetVehicle({id:s,vehicle:u}),await J(),await Ce()},pe=async s=>{await window.api.shimejiDelete({id:s}),se(null),await J(),await Ce()},ne=async s=>{await window.api.companionPackActivate({id:s}),l.form!=="custom"&&await r.setSetting("companion_form","custom"),await Me(),window.dispatchEvent(new Event("companion-config-changed"))},i=async s=>{(await window.api.companionPackDelete({id:s})).formReset&&window.dispatchEvent(new Event("companion-config-changed")),M(null),me(null),D()},C=async(s,u)=>{var L;await window.api.companionPackSetVehicle({id:s,vehicle:u}),await D(),(L=f.find(Q=>Q.id===s))!=null&&L.active&&(await Me(),window.dispatchEvent(new Event("companion-config-changed")))};return b?e.jsxs("div",{className:"px-4 py-3.5 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{checked:x,onChange:j,label:t("settings.companion.toggle"),testid:"companion-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.companion.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.companion.toggle.desc")})]})]}),x&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{checked:c,onChange:T,label:t("settings.companion.sfx"),testid:"companion-sfx-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.companion.sfx")}),e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.companion.sfx.desc")})]})]}),!S&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{checked:p,onChange:$,label:t("settings.companion.pet"),testid:"companion-pet-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.companion.pet")}),e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.companion.pet.desc")})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-label text-ink-muted mb-2",children:t("settings.companion.form")}),e.jsxs("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":t("settings.companion.form"),children:[ct.filter(s=>s!=="custom"&&s!=="shimeji").map(s=>{const u=l.form===s;return e.jsxs("button",{type:"button",role:"radio","aria-checked":u,"data-testid":`companion-form-${s}`,onClick:()=>{h(s)},className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
|
|
12
|
+
${E?"border-[var(--accent)] bg-surface-2 text-ink-strong font-medium":"border-[var(--border-faint)] hover:bg-surface-2 text-ink-muted"}`,children:[e.jsx("span",{"aria-hidden":"true",className:"w-3 h-3 rounded-full border border-black/20",style:{background:be[m].dot}}),o(`companion.form.${m}.name`)]},m)})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("input",{ref:R,type:"file",accept:"image/png",className:"hidden","data-testid":"companion-custom-file",onChange:m=>{var E;return void V((E=m.target.files)==null?void 0:E[0])}}),e.jsx("button",{type:"button",disabled:l,onClick:()=>{var m;return(m=R.current)==null?void 0:m.click()},"data-testid":"companion-wizard-pick",className:"rounded-lg border border-[var(--border-faint)] px-3 py-1.5 text-label hover:bg-surface-2 disabled:opacity-50",children:o("companion.wizard.pick")}),l&&e.jsxs("span",{className:"flex items-center gap-1.5 text-label text-ink-muted","data-testid":"companion-custom-busy",children:[e.jsx(ut,{size:14,className:"animate-spin"}),o(g?"companion.custom.applying":"companion.custom.locating"),e.jsxs("span",{className:"tabular-nums",children:[v,"s"]})]}),j&&e.jsx("span",{className:"text-caption text-ink-muted","data-testid":"companion-custom-msg",children:j})]}),g&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"companion-custom-preview",children:[g.parts.map(m=>e.jsx("img",{src:`data:image/png;base64,${m.pngBase64}`,alt:m.name,title:m.name,className:"h-14 w-14 object-contain rounded-lg bg-surface-2"},m.name)),e.jsx("input",{value:f,onChange:m=>z(m.target.value),placeholder:o("companion.wizard.namePh"),"data-testid":"companion-wizard-name",className:"rounded-lg border border-[var(--border-faint)] bg-surface-0 px-2.5 py-1.5 text-label text-ink-strong placeholder:text-ink-muted w-36"}),e.jsx("button",{type:"button",disabled:l,onClick:()=>void B(),"data-testid":"companion-custom-apply",className:"rounded-lg bg-brand px-3 py-1.5 text-label text-white hover:opacity-90 disabled:opacity-50",children:o("companion.wizard.save")})]})]})]})}),document.body)}const yt=[{id:"shimejiorg",label:"shimeji.org",url:"https://shimeji.org/"},{id:"shimejisxyz",label:"shimejis.xyz",url:"https://shimejis.xyz/"},{id:"cachomon",label:"Cachomon",url:"https://cachomon.com/"},{id:"deviantart",label:"DeviantArt",url:"https://www.deviantart.com/search?q=shimeji"}];function St({onClose:t,onImported:x}){const o=ce(),b=n.useRef(null),N=n.useRef(null);Oe(b,!0);const[l,c]=n.useState(!1),[v,p]=n.useState(null),[g,S]=n.useState(null),j=async h=>{var z;const f=(z=h.target.files)==null?void 0:z[0];if(h.target.value="",!!f){c(!0),p(null);try{const y=new Uint8Array(await f.arrayBuffer());let A="";for(let M=0;M<y.length;M+=32768)A+=String.fromCharCode(...y.subarray(M,M+32768));const R=await window.api.shimejiImportZip({zipBase64:btoa(A)});S({importId:R.importId,characters:R.characters,selected:new Set(R.characters.map(M=>M.ref))})}catch(y){p(String(y.message??y).slice(0,160))}finally{c(!1)}}},T=h=>{S(f=>{if(!f)return f;const z=new Set(f.selected);return z.has(h)?z.delete(h):z.add(h),{...f,selected:z}})},$=async()=>{if(g){c(!0);try{await window.api.shimejiConfirmImport({importId:g.importId,characterRefs:[...g.selected]}),S(null),await Ce(),await x(),t()}catch(h){p(String(h.message??h).slice(0,160))}finally{c(!1)}}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":o("settings.shimeji.dialog.title"),onClick:t,children:e.jsxs("div",{ref:b,onClick:h=>h.stopPropagation(),className:"relative w-full max-w-md rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4","data-testid":"shimeji-dialog",children:[e.jsx("button",{type:"button","aria-label":o("action.close"),"data-testid":"shimeji-dialog-close",onClick:t,className:"absolute top-2.5 right-2.5 w-7 h-7 rounded-lg flex items-center justify-center text-ink-muted hover:text-ink-strong hover:bg-surface-2",children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsx("div",{className:"text-body font-medium text-ink-strong mb-1",children:o("settings.shimeji.dialog.title")}),e.jsx("p",{className:"text-label text-ink-muted mb-3",children:o("settings.shimeji.desc")}),!g&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button","data-testid":"shimeji-import",disabled:l,onClick:()=>{var h;return(h=N.current)==null?void 0:h.click()},className:"w-full rounded-xl border border-dashed border-[var(--border)] py-6 flex flex-col items-center gap-1.5 text-ink-faint hover:text-ink-muted hover:bg-surface-2 disabled:opacity-50",children:[e.jsx("span",{className:"text-label font-medium",children:o(l?"settings.shimeji.importing":"settings.shimeji.import")}),e.jsx("span",{className:"text-caption",children:o("settings.shimeji.guide")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2","data-testid":"shimeji-download-links",children:yt.map(h=>e.jsxs("a",{href:h.url,target:"_blank",rel:"noopener noreferrer","data-testid":`shimeji-link-${h.id}`,className:"inline-flex items-center gap-1 rounded-lg border border-[var(--border-faint)] px-2 py-1 text-caption text-ink-muted hover:text-ink-strong hover:bg-surface-2 motion-safe:transition-colors",children:[e.jsx(bt,{className:"w-3 h-3 shrink-0","aria-hidden":"true"}),h.label]},h.id))})]}),e.jsx("input",{ref:N,type:"file",accept:".zip",className:"hidden",onChange:h=>void j(h)}),v&&e.jsx("p",{className:"text-caption text-warning mt-2",role:"alert",children:v}),g&&e.jsxs("div",{className:"rounded-xl border border-[var(--border)] bg-surface-1 p-3","data-testid":"shimeji-character-picker",children:[e.jsx("div",{className:"text-body text-ink-strong mb-2",children:o("settings.shimeji.pick.title")}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:g.characters.map(h=>{const f=g.selected.has(h.ref);return e.jsxs("button",{type:"button","aria-pressed":f,onClick:()=>T(h.ref),className:`flex items-center gap-2 rounded-xl border p-2 text-left ${f?"border-[var(--accent)] bg-surface-2":"border-[var(--border-faint)]"}`,children:[h.iconBase64?e.jsx("img",{src:`data:image/png;base64,${h.iconBase64}`,alt:"",className:"w-9 h-9 rounded-lg object-contain bg-surface-2"}):e.jsx("div",{className:"w-9 h-9 rounded-lg bg-surface-2"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-body text-ink-strong",children:h.name}),e.jsxs("span",{className:"text-caption text-ink-muted",children:[h.format," · ",h.frameCount,"f · ",h.actionCount]})]})]},h.ref)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button","data-testid":"shimeji-confirm-import",className:"btn-3d-brand px-3 py-1.5 text-label",disabled:l||g.selected.size===0,onClick:()=>void $(),children:o("settings.shimeji.pick.confirm",{count:g.selected.size})}),e.jsx("button",{type:"button",className:"btn-3d-neutral px-3 py-1.5 text-label",onClick:t,children:o("action.cancel")})]})]})]})})}const fe="bg-ink/[0.04] text-ink-strong text-label rounded-lg border border-transparent focus:border-accent focus:bg-ink/[0.06] transition-colors placeholder:text-ink-faint";function $e({kind:t,showProtocol:x=!0,testPrefix:o="custom",titleKey:b="settings.custom.form_title",modelPhKey:N="settings.custom.model_ph",testOverride:l,onSaved:c,onCancel:v}){const p=ce(),[g,S]=n.useState(""),[j,T]=n.useState("openai-compatible"),[$,h]=n.useState(""),[f,z]=n.useState(""),[y,A]=n.useState(""),[R,M]=n.useState(!1),[q,V]=n.useState(!1),[B,m]=n.useState(null),E=async()=>{if(!(!$.trim()||!y.trim()||q)){V(!0),m(null);try{const k=l?await l({baseUrl:$.trim(),apiKey:f.trim(),model:y.trim()}):await r.testCustomProvider({label:g||p("settings.custom.test_label"),protocol:j,baseUrl:$.trim(),apiKey:f.trim()||void 0,defaultModel:y.trim()});m({ok:k.ok,detail:k.detail})}catch(k){m({ok:!1,detail:k instanceof Error?k.message:String(k)})}finally{V(!1)}}},_=async()=>{if(!(!g.trim()||!$.trim()||!y.trim()))try{const k=await r.createCustomProvider({label:g.trim(),kind:t,protocol:x?j:"openai-compatible",baseUrl:$.trim(),apiKey:f.trim()||void 0,defaultModel:y.trim(),vision:t==="llm"?R:void 0});c(k)}catch{}};return e.jsxs("div",{className:"space-y-2.5","data-testid":`${o}-provider-form`,children:[e.jsx("div",{className:"text-label font-bold text-ink-strong",children:p(b)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:g,onChange:k=>S(k.target.value),placeholder:p("settings.custom.label_ph"),"data-testid":`${o}-label`,className:`${fe} min-w-0 flex-1 px-2.5 py-1.5`}),x&&e.jsxs("select",{value:j,onChange:k=>T(k.target.value),"data-testid":`${o}-protocol`,className:`${fe} px-2 py-1.5`,children:[e.jsx("option",{value:"openai-compatible",children:p("settings.proto.openai")}),e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"google",children:"Google"})]})]}),e.jsx("input",{type:"text",value:$,onChange:k=>h(k.target.value),placeholder:p("settings.custom.baseurl_ph"),"data-testid":`${o}-baseurl`,className:`${fe} w-full px-2.5 py-1.5 font-mono`}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:y,onChange:k=>A(k.target.value),placeholder:p(N),"data-testid":`${o}-model`,className:`${fe} min-w-0 flex-1 px-2.5 py-1.5 font-mono`}),e.jsx("input",{type:"password",value:f,onChange:k=>z(k.target.value),placeholder:p("settings.custom.apikey_ph"),"data-testid":`${o}-apikey`,className:`${fe} min-w-0 flex-1 px-2.5 py-1.5`})]}),t==="llm"&&e.jsxs("label",{className:"inline-flex items-center gap-2 text-label cursor-pointer select-none","data-testid":`${o}-vision`,children:[e.jsx("input",{type:"checkbox",checked:R,onChange:k=>M(k.target.checked),className:"w-4 h-4 rounded accent-brand"}),e.jsx("span",{className:"text-ink-strong",children:p("settings.custom.vision")}),e.jsx("span",{className:"text-ink-faint",children:p("settings.custom.visionHint")})]}),B&&e.jsxs("div",{className:`text-label rounded p-2 inline-flex items-start gap-1.5 ${B.ok?"bg-brand/10 text-brand":"bg-warning/10 text-warning"}`,children:[B.ok?e.jsx(xe,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"break-words",children:B.detail})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>void E(),disabled:!$.trim()||!y.trim()||q,"data-testid":`${o}-test`,className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:p(q?"settings.testing":"settings.test")}),e.jsx("button",{onClick:()=>void _(),disabled:!g.trim()||!$.trim()||!y.trim(),"data-testid":`${o}-save`,className:"btn-3d-brand px-3 py-1.5 text-label disabled:opacity-40",children:p("settings.custom.save")}),v&&e.jsx("button",{onClick:v,className:"text-label text-ink-muted hover:text-ink-strong px-3 py-1.5 transition-colors",children:p("action.cancel")})]})]})}const He="lookatstudy-theme",Ke="auto",qe="(prefers-color-scheme: dark)";function Pe(){return typeof window>"u"||window.matchMedia(qe).matches?"dark":"light"}function Ct(){if(typeof localStorage>"u")return Ke;const t=localStorage.getItem(He);return t==="auto"||t==="light"||t==="dark"?t:Ke}function ze(t){const x=document.documentElement;x.classList.remove("dark","light"),x.classList.add(t),window.dispatchEvent(new CustomEvent("theme-changed",{detail:{resolved:t}}))}function _t(){const[t,x]=n.useState(()=>Ct()),[o,b]=n.useState(()=>t==="auto"?Pe():t),N=n.useCallback(l=>{x(l),localStorage.setItem(He,l);const c=l==="auto"?Pe():l;b(c),ze(c)},[]);return n.useEffect(()=>{if(t!=="auto")return;const l=window.matchMedia(qe),c=v=>{const p=v.matches?"dark":"light";b(p),ze(p)};return l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[t]),n.useEffect(()=>{const l=t==="auto"?Pe():t;b(l),ze(l)},[t]),{mode:t,resolved:o,setMode:N}}const $t="0.37.0",Et={version:$t};function Se(){window.dispatchEvent(new Event(ft))}const ie="bg-surface-1 text-ink text-body rounded-lg border border-[var(--border)] focus:border-brand focus:outline-none transition-colors placeholder:text-ink-faint",ee="bg-surface-3 text-ink-muted hover:bg-surface-3 hover:bg-surface-3 hover:text-ink-strong",te="bg-brand text-white shadow-sm";function P(t){return t?"px-4 py-3.5 border-t border-[var(--border-faint)]":"px-4 py-3.5"}function Bt(){const t=ce(),[x,o]=n.useState([]),[b,N]=n.useState([]),[l,c]=n.useState("glm"),[v,p]=n.useState(""),[g,S]=n.useState(""),[j,T]=n.useState(null),[$,h]=n.useState(!1),[f,z]=n.useState(null),[y,A]=n.useState(!1),[R,M]=n.useState(!1),[q,V]=n.useState([]),[B,m]=n.useState(!1),[E,_]=n.useState(null),[k,O]=n.useState(null),[W,G]=n.useState(""),[d,X]=n.useState(!1),U=_t(),se=async i=>{if(I)try{await r.updateCustomProvider(I.id,{vision:i}),await H()}catch{}},ae=async()=>{m(!0),_(null);try{const i=await r.discoverModels();i.ok&&i.models?V(i.models):_(i.error||t("settings.discover_failed"))}catch(i){_(i instanceof Error?i.message:String(i))}finally{m(!1)}},H=n.useCallback(async()=>{try{const[i,C,K,Z]=await Promise.all([r.getProviderPresets(),r.listCustomProviders(),r.getSetting("active_provider"),r.getSetting("active_model")]);o(i),N(C);const F=K??"glm";if(c(F),F.startsWith("custom-")){const s=C.find(u=>u.id===F);T(s!=null&&s.hasApiKey?t("settings.key.configured"):null)}else{const s=i.find(u=>u.id===F);if(s){const u=await r.hasSetting(s.apiKeySetting);T(u?t("settings.key.configured"):null)}}if(F.startsWith("custom-")){const s=C.find(u=>u.id===F);p(Z??(s==null?void 0:s.defaultModel)??"")}else{const s=i.find(u=>u.id===F);p(Z??(s==null?void 0:s.defaultModel)??"")}}catch(i){console.error("[SettingsView] load() failed:",i)}},[t]);n.useEffect(()=>{H()},[H]);const le=async i=>{c(i),z(null),S("");const C=x.find(K=>K.id===i);if(C){const K=await r.hasSetting(C.apiKeySetting);T(K?t("settings.key.configured"):null),p(v||C.defaultModel)}},me=async()=>{A(!1);try{if(await r.setSetting("active_provider",l),await r.setSetting("active_model",v),g.trim()){const i=x.find(C=>C.id===l);i&&(await r.setSetting(i.apiKeySetting,g.trim()),T(`${g.trim().slice(0,4)}…${g.trim().slice(-4)}`),S(""))}A(!0),setTimeout(()=>A(!1),2e3),window.dispatchEvent(new Event("llm-config-changed"))}catch{}},D=async()=>{h(!0),z(null);try{const i=await r.testLlmConnection();z(i)}catch(i){z({ok:!1,detail:i instanceof Error?i.message:String(i),errorKind:"unknown"})}finally{h(!1)}},Y=async i=>{await r.setSetting("active_provider",i.id),await r.setSetting("active_model",i.defaultModel),c(i.id),p(i.defaultModel),M(!1),await H(),window.dispatchEvent(new Event("llm-config-changed"))},oe=async i=>{try{await r.deleteCustomProvider(i),l===i&&(await r.setSetting("active_provider","glm"),c("glm")),await H()}catch{}},I=l.startsWith("custom-")?b.find(i=>i.id===l):null;n.useEffect(()=>{if(!I)return;const i=I.models.find(C=>C.id===v);G(i!=null&&i.contextWindow?String(i.contextWindow):"")},[I,v]);const pe=async()=>{var F,s;if(!I)return;const i=W.trim().replace(/[,\s_]/g,""),C=/^(\d+)([km]?)$/i.exec(i);if(i!==""&&!C)return;const K=((F=C==null?void 0:C[2])==null?void 0:F.toLowerCase())==="k"?1e3:((s=C==null?void 0:C[2])==null?void 0:s.toLowerCase())==="m"?1e6:1,Z=i===""||!C?null:Math.max(1,Math.round(parseInt(C[1],10)*K));X(!0);try{const u=I.models.map(L=>L.id===v?{...L,contextWindow:Z}:L);await r.updateCustomProvider(I.id,{models:u}),await H(),window.dispatchEvent(new Event("llm-config-changed"))}catch{}finally{X(!1)}},ne=l.startsWith("custom-")?null:x.find(i=>i.id===l);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-5 pt-5 space-y-6",children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.ai")}),e.jsxs("div",{className:"surface-card overflow-hidden",children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.provider")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5","data-testid":"provider-grid",children:[x.map(i=>e.jsx("button",{onClick:()=>le(i.id),"data-testid":`provider-card-${i.id}`,"aria-pressed":l===i.id,className:`px-3 py-1.5 rounded-lg text-label font-medium whitespace-nowrap transition-colors ${l===i.id?te:ee}`,children:i.label},i.id)),b.filter(i=>i.kind==="llm").map(i=>e.jsxs("button",{onClick:()=>le(i.id),"data-testid":`provider-card-${i.id}`,"aria-pressed":l===i.id,className:`px-3 py-1.5 rounded-lg text-label font-medium whitespace-nowrap transition-colors inline-flex items-center gap-1 ${l===i.id?te:ee}`,children:[e.jsx(Le,{className:"w-3.5 h-3.5","aria-hidden":"true"}),i.label]},i.id)),e.jsxs("button",{onClick:()=>M(i=>!i),"data-testid":"add-custom-provider",className:"px-3 py-1.5 rounded-lg text-label whitespace-nowrap inline-flex items-center gap-1 border border-dashed border-[var(--border)] text-ink-muted hover:border-ink-muted hover:text-ink-strong transition-colors",children:[e.jsx(Ue,{className:"w-3.5 h-3.5","aria-hidden":"true"}),t("settings.add_custom")]})]})]}),R&&e.jsx("div",{className:"px-4 py-3.5 bg-surface-1 border-t border-[var(--border-faint)]",children:e.jsx($e,{kind:"llm",testPrefix:"custom",onSaved:i=>void Y(i),onCancel:()=>M(!1)})}),b.length>0&&l.startsWith("custom-")&&e.jsx("div",{className:P(!0),children:e.jsx("button",{onClick:i=>{const C=i.currentTarget.getBoundingClientRect(),K=b.find(Z=>Z.id===l);K&&O({id:K.id,label:K.label,rect:C})},className:"text-label text-warning hover:underline",children:t("settings.delete_custom")})}),ne&&e.jsxs(e.Fragment,{children:[ne.baseUrl&&e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:"Base URL"}),e.jsx("code",{className:"text-label text-ink-faint font-mono break-all",children:ne.baseUrl})]}),e.jsxs("div",{className:P(!0),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.model")}),e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[e.jsxs("select",{value:v,onChange:i=>p(i.target.value),"data-testid":"model-select",className:`${ie} flex-1 px-2.5 py-1.5`,children:[ne.models.map(i=>e.jsx("option",{value:i.id,children:i.id},i.id)),l==="openrouter"&&q.map(i=>e.jsx("option",{value:i.id,children:i.id},i.id))]}),l==="openrouter"&&e.jsxs("button",{onClick:ae,disabled:B,"data-testid":"discover-models-btn",className:"text-label text-accent hover:underline disabled:opacity-40 whitespace-nowrap inline-flex items-center gap-1",children:[e.jsx(vt,{className:`w-3.5 h-3.5 ${B?"animate-spin":""}`,"aria-hidden":"true"}),t(B?"settings.discovering":"settings.refresh")]})]})]}),E&&e.jsx("div",{className:"text-label text-warning mt-1.5 ml-[68px]",children:E})]}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.apikey")}),e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[j&&e.jsxs("span",{className:"text-label text-brand shrink-0 inline-flex items-center gap-1",children:[e.jsx(xe,{className:"w-3.5 h-3.5","aria-hidden":"true"}),j]}),e.jsx("input",{type:"password",value:g,onChange:i=>S(i.target.value),placeholder:t(j?"settings.key.overwrite_ph":"settings.key.paste_ph"),"data-testid":"settings-key-input",className:`${ie} flex-1 px-2.5 py-1.5`}),e.jsx("a",{href:ne.keyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-label text-brand hover:underline whitespace-nowrap",children:t("settings.key.get")})]})]})}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 min-w-0",children:[e.jsx("button",{onClick:D,disabled:$,"data-testid":"test-connection-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:t($?"settings.testing":"settings.test")}),f&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 min-w-0 break-words ${f.ok?"text-brand":"text-warning"}`,children:[f.ok?e.jsx(xe,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}),f.detail]})]})})]}),I&&!ne&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:"Base URL"}),e.jsx("code",{className:"text-label text-ink-faint font-mono break-all",children:I.baseUrl})]}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.model")}),I.models.length>1?e.jsx("select",{value:v,onChange:i=>p(i.target.value),"data-testid":"model-select-custom",className:`${ie} flex-1 px-2.5 py-1.5`,children:I.models.map(i=>e.jsx("option",{value:i.id,children:i.id},i.id))}):e.jsx("input",{type:"text",value:v,onChange:i=>p(i.target.value),placeholder:t("settings.custom.model_ph"),"data-testid":"model-input-custom",className:`${ie} flex-1 px-2.5 py-1.5 font-mono`})]})}),e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.custom.windowLabel")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",inputMode:"numeric",value:W,onChange:i=>G(i.target.value),placeholder:t("settings.custom.windowPh"),"data-testid":"context-window-input",className:`${ie} flex-1 px-2.5 py-1.5 font-mono tabular-nums`}),e.jsx("button",{onClick:pe,disabled:d,"data-testid":"context-window-save",className:"btn-3d-neutral px-3 py-1.5 text-label shrink-0 disabled:opacity-40",children:t("settings.custom.save")})]}),e.jsx("div",{className:"text-caption text-ink-faint mt-1",children:t("settings.custom.windowHint")})]}),e.jsx("div",{className:P(!0),children:e.jsxs("label",{className:"inline-flex items-center gap-2 text-label cursor-pointer select-none","data-testid":"custom-vision-toggle",children:[e.jsx("input",{type:"checkbox",checked:I.vision,onChange:i=>void se(i.target.checked),className:"w-4 h-4 rounded accent-brand"}),e.jsx("span",{className:"text-ink-strong",children:t("settings.custom.vision")}),e.jsx("span",{className:"text-ink-faint",children:t("settings.custom.visionHint")})]})}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 min-w-0",children:[e.jsx("button",{onClick:D,disabled:$,"data-testid":"test-connection-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:t($?"settings.testing":"settings.test")}),f&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 min-w-0 break-words ${f.ok?"text-brand":"text-warning"}`,children:[f.ok?e.jsx(xe,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4 shrink-0","aria-hidden":"true"}),f.detail]})]})})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.vision")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(zt,{activeProvider:l,activeModel:v,presets:x,customProviders:b,onProvidersChanged:()=>void H()})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.speech")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(At,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.memory")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(Tt,{})})]}),e.jsxs("section",{id:"settings-section-companion",children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.companion")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(Mt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.appearance")}),e.jsxs("div",{className:"surface-card overflow-hidden",children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.theme")}),e.jsx("div",{className:"flex gap-2",children:[{mode:"auto",label:t("settings.theme.auto")},{mode:"light",label:t("settings.theme.light")},{mode:"dark",label:t("settings.theme.dark")}].map(({mode:i,label:C})=>e.jsx("button",{onClick:()=>U.setMode(i),"data-testid":`theme-${i}`,"aria-pressed":U.mode===i,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${U.mode===i?te:ee}`,children:C},i))}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:U.mode==="auto"?t("settings.theme.following",{mode:t(`settings.theme.${U.resolved}`)}):null})]}),e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.interface_lang")}),e.jsx("div",{className:"flex gap-2",children:["zh-CN","en"].map(i=>e.jsx("button",{onClick:()=>xt(i),"data-testid":`lang-${i}`,"aria-pressed":De()===i,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${De()===i?te:ee}`,children:i==="zh-CN"?"中文":"English"},i))})]}),e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.row.import_lang")}),e.jsx(Pt,{})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.data")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(It,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:t("settings.group.about")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsxs("div",{className:P(!1),children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:t("settings.row.version")}),e.jsxs("a",{href:"https://github.com/Kaiji-Z/LookatStudy/releases",target:"_blank",rel:"noopener noreferrer",className:"text-label font-mono text-brand hover:underline","data-testid":"settings-version",children:["v",Et.version]})]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.version.hint")})]})})]})]}),e.jsxs("div",{className:"sticky bottom-0 px-5 py-3 bg-surface-0 border-t border-[var(--border)] flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-label text-ink-muted",children:t("settings.footer.hint")}),e.jsxs("button",{onClick:me,"data-testid":"settings-save",className:"btn-3d-brand px-5 py-2 text-body inline-flex items-center gap-1.5",children:[y&&e.jsx(ht,{className:"w-4 h-4","aria-hidden":"true"}),t(y?"settings.saved_text":"settings.footer.save")]})]}),k&&e.jsx(_e,{anchorRect:k.rect,message:t("settings.delete_custom_confirm",{name:k.label}),danger:!0,confirmLabel:t("action.delete"),testid:"custom-provider-delete-confirm",onConfirm:()=>{oe(k.id),O(null)},onCancel:()=>O(null)})]})}function Pt(){const[t,x]=n.useState("en"),[o,b]=n.useState(!1);n.useEffect(()=>{r.getSetting("pref_lang").then(c=>{c&&x(c),b(!0)})},[]);const N=async c=>{x(c),await r.setSetting("pref_lang",c)},l=[{code:"en",label:"English"},{code:"zh-CN",label:"简体中文"},{code:"zh-TW",label:"繁體中文"}];return o?e.jsx("div",{className:"flex gap-2","data-testid":"pref-lang-options",children:l.map(c=>e.jsx("button",{onClick:()=>N(c.code),"data-testid":`pref-lang-${c.code}`,"aria-pressed":t===c.code,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${t===c.code?te:ee}`,children:c.label},c.code))}):null}function zt({activeProvider:t,activeModel:x,presets:o,customProviders:b,onProvidersChanged:N}){const l=ce(),[c,v]=n.useState(!1),[p,g]=n.useState(!1),[S,j]=n.useState(""),[T,$]=n.useState(!1),[h,f]=n.useState(!1),[z,y]=n.useState(null),[A,R]=n.useState(!1);n.useEffect(()=>{Promise.all([r.getSetting("flag_multimodal_import"),r.getSetting("vision_provider_override"),r.getSetting("vision_model_override"),r.getSetting("flag_math_vision")]).then(([d,X,U])=>{v(d==="true"),j(X??""),R(U==="true"),g(!0)})},[]);const M=async()=>{const d=!c;v(d),await r.setSetting("flag_multimodal_import",String(d))},q=async()=>{const d=!A;R(d),await r.setSetting("flag_math_vision",String(d))},V=async d=>{await r.setSetting("vision_provider_override",d.id),await r.setSetting("vision_model_override",d.defaultModel),j(d.id),$(!1)},B=async()=>{await r.setSetting("vision_provider_override",""),await r.setSetting("vision_model_override",""),j(""),$(!1)},[m,E]=n.useState(null),_=async d=>{try{S===d&&(await r.setSetting("vision_provider_override",""),await r.setSetting("vision_model_override",""),j("")),await r.deleteCustomProvider(d)}catch{}finally{N==null||N()}},k=async()=>{if(!h){f(!0),y(null);try{const d=await r.testLlmConnection({vision:!0});y({ok:d.ok,detail:d.detail})}catch(d){y({ok:!1,detail:d instanceof Error?d.message:String(d)})}finally{f(!1)}}},O=b.filter(d=>d.kind==="vision"),W=S.startsWith("custom-")?b.find(d=>d.id===S):null,G=S&&!S.startsWith("custom-")?o.find(d=>d.id===S):null;return p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(he,{checked:c,onChange:M,label:l("settings.multimodal.toggle"),testid:"multimodal-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:l("settings.multimodal.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:l("settings.multimodal.toggle.desc")})]})]}),e.jsxs("div",{className:"px-4 py-3.5 border-t border-[var(--border-faint)] space-y-3",children:[e.jsxs("div",{className:"text-label text-ink-muted bg-ink/5 rounded-lg p-3",children:[e.jsx("div",{className:"font-medium mb-1",children:l("settings.multimodal.current_model",{model:x||l("settings.multimodal.not_selected")})}),e.jsx("div",{children:t.startsWith("custom-")?l("settings.multimodal.hint_custom"):l("settings.multimodal.hint_preset")})]}),e.jsxs("div",{className:"bg-ink/5 rounded-lg p-3",children:[e.jsx("div",{className:"text-label font-medium text-ink-muted mb-2",children:l("settings.multimodal.override_title")}),e.jsx("div",{className:"text-caption text-ink-muted mb-2",children:l("settings.multimodal.override_bridge_hint")}),e.jsxs("div",{className:"space-y-3 mt-1",children:[W&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx(Le,{className:"w-3.5 h-3.5 text-ink-faint shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium text-ink-strong",children:W.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:W.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:W.baseUrl})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{onClick:()=>void k(),disabled:h,"data-testid":"vision-override-test",className:"btn-3d-neutral px-4 py-1.5 text-label disabled:opacity-50",children:l(h?"settings.testing":"settings.multimodal.test_override")}),e.jsx("button",{onClick:()=>$(d=>!d),className:"text-label text-accent hover:underline",children:l("settings.multimodal.replace_custom")}),e.jsx("button",{onClick:()=>void B(),className:"text-label text-ink-muted hover:text-ink-strong",children:l("settings.multimodal.stop_override")}),e.jsx("button",{onClick:d=>{d.stopPropagation(),E({id:W.id,label:W.label,rect:d.currentTarget.getBoundingClientRect()})},"data-testid":`vision-delete-${W.id}`,className:"text-label text-ink-muted hover:text-warning",children:l("action.delete")}),z&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${z.ok?"text-brand":"text-warning"}`,children:[z.ok?e.jsx(xe,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4","aria-hidden":"true"}),z.detail]})]})]}),G&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx("span",{className:"text-ink-muted",children:l("settings.multimodal.legacy_preset",{label:G.label})}),e.jsx("button",{onClick:()=>void B(),className:"text-label text-ink-muted hover:text-ink-strong underline",children:l("settings.multimodal.stop_override")})]}),!W&&!G&&e.jsxs(e.Fragment,{children:[O.map(d=>e.jsxs("span",{className:"relative block",children:[e.jsxs("button",{onClick:()=>void V(d),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`vision-pick-${d.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:d.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:d.defaultModel})]}),e.jsx("button",{type:"button","aria-label":l("action.delete"),"data-tooltip":l("action.delete"),"data-testid":`vision-delete-${d.id}`,onClick:X=>{X.stopPropagation(),E({id:d.id,label:d.label,rect:X.currentTarget.getBoundingClientRect()})},className:"absolute top-1.5 right-1.5 w-6 h-6 rounded-full text-ink-muted hover:text-warning flex items-center justify-center hover:bg-surface-2",children:e.jsx(ve,{className:"w-3.5 h-3.5"})})]},d.id)),(T||O.length===0)&&e.jsx($e,{kind:"vision",testPrefix:"vision-custom",titleKey:"settings.custom.form_title_vision",modelPhKey:"settings.custom.model_ph_vision",onSaved:d=>void V(d),onCancel:()=>$(!1)}),O.length>0&&e.jsx("button",{onClick:()=>$(d=>!d),className:"text-label text-accent hover:underline",children:l(T?"action.cancel":"settings.custom.new")})]})]})]}),e.jsxs("div",{className:"bg-ink/5 rounded-lg p-3 flex items-center gap-3",children:[e.jsx(he,{checked:A,onChange:q,label:l("settings.mathvision.toggle"),testid:"math-vision-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:l("settings.mathvision.toggle")}),e.jsx("div",{className:"text-caption text-ink-muted",children:l("settings.mathvision.desc")})]})]})]}),m&&e.jsx(_e,{anchorRect:m.rect,message:l("settings.delete_custom_confirm",{name:m.label}),danger:!0,confirmLabel:l("action.delete"),testid:"vision-provider-delete-confirm",onConfirm:()=>{_(m.id),E(null)},onCancel:()=>E(null)})]}):null}function Tt(){const t=ce(),[x,o]=n.useState(!1),[b,N]=n.useState(!1);n.useEffect(()=>{r.getSetting("flag_memory_system").then(c=>{o(c==="true"),N(!0)})},[]);const l=async()=>{const c=!x;o(c),await r.setSetting("flag_memory_system",String(c))};return b?e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(he,{checked:x,onChange:l,label:t("settings.memory.toggle"),testid:"memory-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.memory.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.memory.toggle.desc")})]})]}):null}function Mt(){var K,Z,F;const t=ce(),[x,o]=n.useState(!0),[b,N]=n.useState(!1),l=n.useSyncExternalStore(ot,rt),[c,v]=n.useState(!0),[p,g]=n.useState(!1),S=typeof window<"u"&&!!window.__lookatstudyWeb;n.useEffect(()=>{r.getSetting("companion_enabled").then(s=>{o(s!=="false"&&s!=="0"),N(!0)}),r.getSetting("companion_sfx").then(s=>{v(s!=="false"&&s!=="0")}),r.getSetting("companion_pet_mode").then(s=>{g(s==="1")})},[]);const j=async()=>{const s=!x;o(s),await r.setSetting("companion_enabled",String(s)),window.dispatchEvent(new Event("companion-config-changed"))},T=async()=>{const s=!c;v(s),await r.setSetting("companion_sfx",String(s)),window.dispatchEvent(new Event("companion-config-changed"))},$=async()=>{const s=!p;g(s),await r.setSetting("companion_pet_mode",s?"1":"0"),window.dispatchEvent(new Event("companion-config-changed"))},h=async s=>{s!==l.form&&(await r.setSetting("companion_form",s),window.dispatchEvent(new Event("companion-config-changed")))},[f,z]=n.useState([]),[y,A]=n.useState(!1),[R,M]=n.useState(null),[q,V]=n.useState(!1),[B,m]=n.useState(!1),[E,_]=n.useState(!1),[k,O]=n.useState(null),[W,G]=n.useState(!1),[d,X]=n.useState([]),[U,se]=n.useState(null),[ae,H]=n.useState(null),[le,me]=n.useState(null),D=n.useCallback(async()=>{try{z((await window.api.companionPackList()).packs)}catch{}},[]),Y=n.useCallback(async()=>{try{X((await window.api.shimejiList()).packs)}catch{}},[]);n.useEffect(()=>{D(),Y();const s=()=>{D(),Y()};return window.addEventListener("companion-config-changed",s),()=>window.removeEventListener("companion-config-changed",s)},[D,Y]);const oe=async s=>{await r.shimejiActivate({id:s}),l.form!=="shimeji"&&await r.setSetting("companion_form","shimeji"),window.dispatchEvent(new Event("companion-config-changed")),await Y(),await Ce()},I=async(s,u)=>{await window.api.shimejiSetVehicle({id:s,vehicle:u}),await Y(),await Ce()},pe=async s=>{await window.api.shimejiDelete({id:s}),se(null),await Y(),await Ce()},ne=async s=>{await window.api.companionPackActivate({id:s}),l.form!=="custom"&&await r.setSetting("companion_form","custom"),await Me(),window.dispatchEvent(new Event("companion-config-changed"))},i=async s=>{(await window.api.companionPackDelete({id:s})).formReset&&window.dispatchEvent(new Event("companion-config-changed")),M(null),me(null),D()},C=async(s,u)=>{var L;await window.api.companionPackSetVehicle({id:s,vehicle:u}),await D(),(L=f.find(Q=>Q.id===s))!=null&&L.active&&(await Me(),window.dispatchEvent(new Event("companion-config-changed")))};return b?e.jsxs("div",{className:"px-4 py-3.5 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{checked:x,onChange:j,label:t("settings.companion.toggle"),testid:"companion-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.companion.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.companion.toggle.desc")})]})]}),x&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{checked:c,onChange:T,label:t("settings.companion.sfx"),testid:"companion-sfx-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.companion.sfx")}),e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.companion.sfx.desc")})]})]}),!S&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{checked:p,onChange:$,label:t("settings.companion.pet"),testid:"companion-pet-toggle"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.companion.pet")}),e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.companion.pet.desc")})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-label text-ink-muted mb-2",children:t("settings.companion.form")}),e.jsxs("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":t("settings.companion.form"),children:[ct.filter(s=>s!=="custom"&&s!=="shimeji").map(s=>{const u=l.form===s;return e.jsxs("button",{type:"button",role:"radio","aria-checked":u,"data-testid":`companion-form-${s}`,onClick:()=>{h(s)},className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
|
|
13
13
|
${u?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,title:t(`companion.form.${s}.desc`),children:[e.jsx(dt,{form:s,expression:"happy",pose:"float",size:64}),e.jsx("span",{className:`text-label ${u?"text-ink-strong font-medium":"text-ink-muted"}`,children:t(`companion.form.${s}.name`)})]},s)}),e.jsxs("button",{type:"button",role:"radio","aria-checked":l.form==="custom"&&f.some(s=>s.active),"data-testid":"companion-card-custom",onClick:()=>m(!0),title:t("companion.pick.custom.title"),className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
|
|
14
14
|
${l.form==="custom"&&f.some(s=>s.active)?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[(()=>{const s=f.find(u=>u.active);return s!=null&&s.thumb?e.jsx("img",{src:s.thumb,alt:"",className:"h-14 w-14 object-contain"}):e.jsx("span",{className:"h-14 w-14 flex items-center justify-center",children:e.jsx("span",{className:"h-9 w-9 rounded-full bg-[#c8a06e]"})})})(),e.jsx("span",{className:`text-label max-w-20 truncate ${l.form==="custom"&&f.some(s=>s.active)?"text-ink-strong font-medium":"text-ink-muted"}`,children:((K=f.find(s=>s.active))==null?void 0:K.name)??t("companion.create.self.name")})]}),e.jsxs("button",{type:"button",role:"radio","aria-checked":l.form==="shimeji"&&d.some(s=>s.active),"data-testid":"companion-card-shimeji",onClick:()=>_(!0),title:t("companion.pick.shimeji.title"),className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
|
|
15
15
|
${l.form==="shimeji"&&d.some(s=>s.active)?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[(()=>{const s=d.find(u=>u.active);return s!=null&&s.iconBase64?e.jsx("img",{src:`data:image/png;base64,${s.iconBase64}`,alt:"",className:"h-14 w-14 object-contain"}):e.jsx("span",{className:"h-14 w-14 flex items-center justify-center text-caption text-ink-muted",children:"Shimeji"})})(),e.jsx("span",{className:`text-label max-w-20 truncate ${l.form==="shimeji"&&d.some(s=>s.active)?"text-ink-strong font-medium":"text-ink-muted"}`,children:((Z=d.find(s=>s.active))==null?void 0:Z.name)??"Shimeji"})]}),e.jsxs("button",{type:"button",role:"radio","aria-checked":!1,"data-testid":"companion-form-add","aria-label":t("companion.bots.add"),onClick:()=>V(!0),className:"flex flex-col items-center gap-0.5 rounded-xl p-1.5 border border-dashed border-[var(--border-faint)] hover:bg-surface-2",children:[e.jsx("span",{className:"h-14 w-14 flex items-center justify-center text-ink-muted",children:e.jsx(Ue,{className:"w-6 h-6"})}),e.jsx("span",{className:"text-label text-ink-muted",children:t("companion.bots.add")})]})]}),R&&e.jsx(_e,{anchorRect:R.rect,message:t("companion.bots.deleteConfirm"),danger:!0,testid:"companion-pack-delete-confirm",onConfirm:()=>void i(R.id),onCancel:()=>M(null)}),B&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":t("companion.pick.custom.title"),onClick:()=>m(!1),children:e.jsxs("div",{className:"relative w-full max-w-md rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4","data-testid":"custom-pack-list",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"text-body font-medium text-ink-strong mb-3",children:t("companion.pick.custom.title")}),f.length===0?e.jsx("p",{className:"text-label text-ink-muted py-4 text-center",children:t("companion.pick.empty.custom")}):e.jsx("div",{className:"flex flex-col gap-1.5",children:f.map(s=>e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button","data-testid":`custom-pack-option-${s.id}`,onClick:()=>{ne(s.id),m(!1)},className:`w-full flex items-center gap-2.5 rounded-xl border p-2 text-left motion-safe:transition-colors
|
|
@@ -17,4 +17,4 @@ import{r as n,j as e,V as Te,k as be,l as Me,m as Ce,s as ot,n as rt,C as ct,M a
|
|
|
17
17
|
${u?"border-[var(--accent)] bg-surface-2 text-ink-strong font-medium":"border-[var(--border-faint)] hover:bg-surface-2 text-ink-muted"}`,children:[e.jsx("span",{"aria-hidden":"true",className:"w-3 h-3 rounded-full border border-black/20",style:{background:be[s].dot}}),t(s==="silver"?"companion.veh.silver":`companion.form.${s}.name`)]},s)})})]})]})}),E&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":t("companion.pick.shimeji.title"),onClick:()=>_(!1),children:e.jsxs("div",{className:"relative w-full max-w-md rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4","data-testid":"shimeji-pack-list",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"text-body font-medium text-ink-strong mb-3",children:t("companion.pick.shimeji.title")}),d.length===0?e.jsx("p",{className:"text-label text-ink-muted py-4 text-center",children:t("companion.pick.empty.shimeji")}):e.jsx("div",{className:"flex flex-col gap-1.5",children:d.map(s=>e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button","data-testid":`shimeji-pack-option-${s.id}`,onClick:()=>{oe(s.id),_(!1)},className:`w-full flex items-center gap-2.5 rounded-xl border p-2 text-left motion-safe:transition-colors
|
|
18
18
|
${s.active&&l.form==="shimeji"?"border-[var(--accent)] bg-surface-2":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[s.iconBase64?e.jsx("img",{src:`data:image/png;base64,${s.iconBase64}`,alt:"",className:"w-10 h-10 rounded-lg object-contain bg-surface-2"}):e.jsx("span",{className:"w-10 h-10 rounded-lg bg-surface-2 inline-block"}),e.jsxs("span",{className:"flex flex-col flex-1 min-w-0",children:[e.jsx("span",{className:"text-body text-ink-strong truncate",children:s.name}),e.jsxs("span",{className:"text-caption text-ink-muted",children:[s.format," · ",s.frameCount,"f · ",s.actionCount]})]}),s.active&&l.form==="shimeji"&&e.jsx("span",{className:"text-caption text-brand font-medium",children:t("settings.shimeji.active")})]}),e.jsx("button",{type:"button","aria-label":t("companion.bots.veh"),"data-tooltip":t("companion.bots.veh"),"data-testid":`shimeji-pack-veh-${s.id}`,onClick:u=>{u.stopPropagation(),H(L=>L===s.id?null:s.id)},className:"absolute top-1.5 -left-1.5 w-5 h-5 rounded-full border border-black/25 shadow-card hover:scale-110 motion-safe:transition-transform",style:{background:be[s.vehicle??"silver"].dot}}),e.jsx("button",{type:"button","aria-label":t("settings.shimeji.delete"),onClick:u=>{u.stopPropagation(),se({id:s.id,rect:u.currentTarget.getBoundingClientRect()})},className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full flex items-center justify-center text-ink-faint hover:text-warning",children:e.jsx(ve,{className:"w-3.5 h-3.5"})})]},s.id))}),ae&&e.jsxs("div",{className:"mt-2.5 rounded-xl border border-[var(--border-faint)] bg-surface-0 p-2.5","data-testid":"shimeji-veh-picker",children:[e.jsx("div",{className:"text-caption text-ink-muted mb-1.5",children:t("companion.wizard.vehicle")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",role:"radiogroup","aria-label":t("companion.wizard.vehicle"),children:["silver",...Te].map(s=>{var L;const u=(((L=d.find(Q=>Q.id===ae))==null?void 0:L.vehicle)??"silver")===s;return e.jsxs("button",{type:"button",role:"radio","aria-checked":u,"data-testid":`shimeji-veh-pick-${s}`,onClick:()=>void I(ae,s),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-label motion-safe:transition-colors
|
|
19
19
|
${u?"border-[var(--accent)] bg-surface-2 text-ink-strong font-medium":"border-[var(--border-faint)] hover:bg-surface-2 text-ink-muted"}`,children:[e.jsx("span",{"aria-hidden":"true",className:"w-3 h-3 rounded-full border border-black/20",style:{background:be[s].dot}}),t(s==="silver"?"companion.veh.silver":`companion.form.${s}.name`)]},s)})})]})]})}),q&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-noswipe":"",role:"dialog","aria-modal":"true","aria-label":t("companion.create.title"),onClick:()=>V(!1),children:e.jsxs("div",{className:"relative w-full max-w-md rounded-2xl bg-surface-0 border border-[var(--border)] shadow-elevated p-4",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"text-body font-medium text-ink-strong mb-3",children:t("companion.create.title")}),e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:[{key:"self",testid:"companion-create-self",name:t("companion.create.self.name"),hover:t("companion.create.self.hover"),open:()=>{V(!1),A(!0)}},{key:"shimeji",testid:"companion-create-shimeji",name:t("companion.create.shimeji.name"),hover:t("companion.create.shimeji.hover"),open:()=>{V(!1),G(!0)}}].map(s=>e.jsxs("button",{type:"button","data-testid":s.testid,onMouseEnter:()=>O(s.key),onMouseLeave:()=>O(u=>u===s.key?null:u),onFocus:()=>O(s.key),onBlur:()=>O(u=>u===s.key?null:u),onClick:s.open,className:`flex flex-col items-center gap-1.5 rounded-xl border p-4 motion-safe:transition-colors
|
|
20
|
-
${k===s.key?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[e.jsx("span",{className:"text-body font-medium text-ink-strong",children:s.name}),e.jsx("span",{className:`text-caption text-ink-muted text-center leading-snug ${k===s.key?"":"opacity-0 h-0 overflow-hidden"} motion-safe:transition-all`,children:s.hover})]},s.key))}),e.jsx("p",{className:"text-caption text-ink-faint mt-3 text-center",children:t("companion.create.hint")})]})}),W&&e.jsx(St,{onClose:()=>G(!1),onImported:async()=>{await J()}}),U&&e.jsx(_e,{anchorRect:U.rect,message:t("settings.shimeji.deleteConfirm",{name:((F=d.find(s=>s.id===U.id))==null?void 0:F.name)??""}),danger:!0,testid:"shimeji-delete-confirm",onConfirm:()=>void pe(U.id),onCancel:()=>se(null)}),y&&e.jsx(Nt,{onClose:()=>A(!1),onSaved:()=>{A(!1),D()}})]})]})]}):null}function he({checked:t,onChange:x,label:o,testid:b}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":o,onClick:x,"data-testid":b,className:`relative w-12 h-6 rounded-full transition-colors shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/60 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface-2)] ${t?"bg-brand":"bg-ink/20 hover:bg-ink/25"}`,children:e.jsx("span",{className:`absolute left-0.5 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full bg-white shadow transition-transform ${t?"translate-x-6":""}`})})}const Lt=[{id:"zh-CN-XiaoxiaoNeural",label:"zh-CN · 晓晓(女)"},{id:"zh-CN-XiaoyiNeural",label:"zh-CN · 晓伊(女)"},{id:"zh-CN-YunxiNeural",label:"zh-CN · 云希(男)"},{id:"zh-CN-YunyangNeural",label:"zh-CN · 云扬(男·新闻)"},{id:"zh-CN-liaoning-XiaobeiNeural",label:"zh-CN · 晓北(女·东北)"},{id:"zh-CN-shaanxi-XiaoniNeural",label:"zh-CN · 晓妮(女·陕西)"},{id:"en-US-AriaNeural",label:"en-US · Aria(女)"},{id:"en-US-GuyNeural",label:"en-US · Guy(男)"},{id:"en-US-JennyNeural",label:"en-US · Jenny(女)"}],Rt=[{sid:"45",label:"zf_xiaobei(女)"},{sid:"46",label:"zf_xiaoni(女)"},{sid:"47",label:"zf_xiaoxiao(女)"},{sid:"48",label:"zf_xiaoyi(女·默认)"},{sid:"49",label:"zm_yunjian(男)"},{sid:"50",label:"zm_yunxi(男)"},{sid:"51",label:"zm_yunxia(男)"},{sid:"52",label:"zm_yunyang(男)"}];function At(){const t=ce(),[x,o]=n.useState([]),[b,N]=n.useState(null),[l,c]=n.useState(null),[v,p]=n.useState(null),[g,S]=n.useState(null),[j,T]=n.useState("edge"),[$,h]=n.useState("zh-CN-XiaoxiaoNeural"),[f,z]=n.useState("48"),[y,A]=n.useState("1.0"),[R,M]=n.useState(""),[q,V]=n.useState(""),[B,m]=n.useState([]),E=typeof window<"u"&&"speechSynthesis"in window,[_,k]=n.useState("local"),[O,W]=n.useState("asr-whisper-turbo"),[G,d]=n.useState(!0),[X,U]=n.useState([]),[se,ae]=n.useState(!1),[H,le]=n.useState(!1),[me,D]=n.useState(!1),[J,oe]=n.useState(!1),[I,pe]=n.useState(!1),[ne,i]=n.useState(null),[C,K]=n.useState(!1),[Z,F]=n.useState(null),[s,u]=n.useState(null),L=n.useCallback(()=>{r.listCustomProviders().then(a=>U(a.filter(w=>w.kind==="tts"||w.kind==="asr"))).catch(()=>{})},[]);n.useEffect(()=>{Promise.all([r.getSetting("tts_engine"),r.getSetting("tts_voice_edge"),r.getSetting("tts_sid_local"),r.getSetting("tts_speed"),r.getSetting("tts_custom_voice"),r.getSetting("tts_system_voice"),r.getSetting("asr_engine"),r.getSetting("asr_local_model"),r.getSetting("asr_auto_stop")]).then(([a,w,Y,re,ye,Ve,Be,Ee,lt])=>{a&&T(a),w&&h(w),Y&&z(Y),re&&A(re),ye&&M(ye),Ve&&V(Ve),Be&&k(Be),(Ee==="asr-whisper-turbo"||Ee==="asr-whisper-small")&&W(Ee),d(lt!=="0")}),L()},[L]),n.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const a=()=>m(gt(window.speechSynthesis.getVoices()));return a(),window.speechSynthesis.addEventListener("voiceschanged",a),()=>window.speechSynthesis.removeEventListener("voiceschanged",a)},[]);const Q=n.useCallback(()=>{window.api.getSpeechModelStatus().then(a=>o(a)).catch(()=>{})},[]);n.useEffect(()=>(Q(),window.api.on("speech:modelProgress",w=>{p({id:w.id,pct:Math.floor(w.progress*100),label:w.currentFile?w.currentFile.split("/").pop()??"":""})})),[Q]);const Ge=a=>{c(null),N(a),p({id:a,pct:0,label:""}),window.api.ensureSpeechModel(a).then(()=>{N(null),p(null),Q()}).catch(w=>{N(null),p(null),c(w instanceof Error?w.message:String(w)),Q()})},Xe=a=>{N(a),S(null),window.api.deleteSpeechModel(a).then(Q).catch(w=>c(w instanceof Error?w.message:String(w))).finally(()=>N(null))},Je=a=>t(a==="tts-kokoro"?"settings.speech.model.tts":a==="asr-whisper-turbo"?"settings.speech.model.asr_turbo":"settings.speech.model.asr_small"),Ye=a=>t(a==="asr-whisper-turbo"?"settings.speech.model.turbo_short":"settings.speech.model.small_short"),Ze=a=>a.startsWith("asr-whisper")?t("settings.speech.license_mit"):t("settings.speech.license"),Re=a=>t(a==="ready"?"settings.speech.state.ready":a==="error"?"settings.speech.state.error":"settings.speech.state.absent"),Ae=a=>{var w;return((w=x.find(Y=>Y.id===a))==null?void 0:w.state)??"absent"},ge=a=>{T(a),i(null),r.setSetting("tts_engine",a),Se()},Qe=a=>{V(a),r.setSetting("tts_system_voice",a),Se()},ke=a=>{k(a),F(null),r.setSetting("asr_engine",a)},we=X.filter(a=>a.kind==="tts"),Ne=X.filter(a=>a.kind==="asr"),de=j.startsWith("custom-")?we.find(a=>a.id===j)??null:null,ue=_.startsWith("custom-")?Ne.find(a=>a.id===_)??null:null,et=j==="azure",tt=_==="groq",st=_==="azure",at=async()=>{if(!(!de||I)){pe(!0),i(null);try{i(await r.testCustomTts({providerId:de.id}))}catch(a){i({ok:!1,detail:a instanceof Error?a.message:String(a)})}finally{pe(!1)}}},nt=async()=>{if(!(!ue||C)){K(!0),F(null);try{F(await r.testCustomAsr({providerId:ue.id}))}catch(a){F({ok:!1,detail:a instanceof Error?a.message:String(a)})}finally{K(!1)}}},it=async(a,w)=>{u(null);try{await r.deleteCustomProvider(a),w==="tts"&&j===a&&ge("edge"),w==="asr"&&_===a&&ke("local"),L()}catch{}},Ie=a=>{const w=x.find(re=>re.id===a),Y=(w==null?void 0:w.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:Je(a)}),e.jsxs("div",{className:"text-caption text-ink-muted",children:[Re(Y)," · ",Ze(a)]}),b===a&&(v==null?void 0:v.id)===a&&e.jsx("div",{className:"mt-1.5 h-1.5 rounded-full bg-ink/[0.08] overflow-hidden","data-testid":`speech-dl-bar-${a}`,children:e.jsx("div",{className:"h-full bg-brand transition-all",style:{width:`${v.pct}%`}})}),b===a&&(v==null?void 0:v.id)===a&&e.jsxs("div",{className:"text-caption text-ink-faint mt-0.5","data-testid":`speech-dl-pct-${a}`,children:[v.pct,"%",v.label?` · ${v.label}`:""]})]}),Y==="ready"?g===a?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-caption text-warning",children:t("settings.speech.confirm_del")}),e.jsx("button",{onClick:()=>Xe(a),className:"text-label text-warning hover:underline","data-testid":`speech-del-confirm-${a}`,children:t("settings.speech.delete")}),e.jsx("button",{onClick:()=>S(null),className:"text-label text-ink-muted hover:text-ink-strong",children:t("action.cancel")})]}):e.jsx("button",{onClick:()=>S(a),disabled:b===a,className:"text-label text-ink-muted hover:text-warning disabled:opacity-40","data-testid":`speech-del-${a}`,children:t("settings.speech.delete")}):e.jsx("button",{onClick:()=>Ge(a),disabled:b!=null||Y==="downloading",className:"btn-3d-brand px-3 py-1 text-label disabled:opacity-40","data-testid":`speech-dl-${a}`,children:t(b===a||Y==="downloading"?"settings.speech.downloading":"settings.speech.download")})]},a)},Fe=(a,w,Y,re,ye)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx(Le,{className:"w-3.5 h-3.5 text-ink-faint shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium text-ink-strong",children:a.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:a.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:a.baseUrl}),a.hasApiKey&&e.jsxs("span",{className:"text-brand shrink-0 inline-flex items-center gap-0.5",children:[e.jsx(xe,{className:"w-3.5 h-3.5","aria-hidden":"true"}),t("settings.speech.key_saved")]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:()=>void ye(),disabled:Y,className:"btn-3d-neutral px-3 py-1 text-label disabled:opacity-40","data-testid":`${w}-custom-test`,children:t(Y?"settings.testing":"settings.test")}),s===a.id?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-caption text-warning",children:t("settings.speech.confirm_del_custom")}),e.jsx("button",{onClick:()=>void it(a.id,w),className:"text-label text-warning hover:underline","data-testid":`${w}-custom-del-confirm`,children:t("settings.speech.delete")}),e.jsx("button",{onClick:()=>u(null),className:"text-label text-ink-muted hover:text-ink-strong",children:t("action.cancel")})]}):e.jsx("button",{onClick:()=>u(a.id),className:"text-label text-ink-muted hover:text-warning","data-testid":`${w}-custom-del`,children:t("settings.speech.delete")}),re&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${re.ok?"text-brand":"text-warning"}`,children:[re.ok?e.jsx(xe,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4","aria-hidden":"true"}),re.detail]})]})]});return e.jsxs("div",{"data-testid":"settings-speech",children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.speech.tts_title")}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>{ge("edge"),ae(!1),D(!1)},"data-testid":"tts-engine-edge","aria-pressed":j==="edge",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${j==="edge"?te:ee}`,children:t("settings.speech.engine.edge")}),e.jsxs("button",{onClick:()=>{ge("local"),ae(!1),D(!1)},"data-testid":"tts-engine-local","aria-pressed":j==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${j==="local"?te:ee}`,children:[t("settings.speech.engine.local"),Ae("tts-kokoro")!=="ready"?` · ${t("settings.speech.state.absent")}`:""]}),e.jsx("button",{onClick:()=>{ge("system"),ae(!1),D(!1)},disabled:!E,"data-testid":"tts-engine-system","aria-pressed":j==="system",title:E?void 0:t("settings.speech.engine.system_unavailable"),className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${j==="system"?te:ee} ${E?"":"opacity-40 cursor-not-allowed"}`,children:t("settings.speech.engine.system")}),e.jsx("button",{onClick:()=>{ae(a=>!a),se||D(!1)},"data-testid":"tts-engine-custom","aria-pressed":j.startsWith("custom-")||se,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${j.startsWith("custom-")||se?te:ee}`,children:t("settings.speech.engine.custom")}),et&&e.jsxs("button",{disabled:!0,"data-testid":"tts-engine-azure",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Azure · ",t("settings.speech.legacy")]})]}),j==="edge"&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.engine.edge_note")})]}),j==="edge"&&e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsx("select",{value:$,onChange:a=>{h(a.target.value),r.setSetting("tts_voice_edge",a.target.value)},"data-testid":"tts-voice-select",className:`${ie} w-full min-w-0 px-2.5 py-1.5`,children:Lt.map(a=>e.jsx("option",{value:a.id,children:a.label},a.id))})]}),j==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsx("select",{value:f,onChange:a=>{z(a.target.value),r.setSetting("tts_sid_local",a.target.value)},"data-testid":"tts-sid-select",className:`${ie} w-full min-w-0 px-2.5 py-1.5`,children:Rt.map(a=>e.jsx("option",{value:a.sid,children:a.label},a.sid))})]}),e.jsx("div",{className:P(!1),children:Ie("tts-kokoro")})]}),j==="system"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsxs("select",{value:q,onChange:a=>Qe(a.target.value),"data-testid":"tts-system-voice-select",className:`${ie} w-full min-w-0 px-2.5 py-1.5`,children:[e.jsx("option",{value:"",children:t("settings.speech.voice_auto")}),B.map(a=>e.jsx("option",{value:a.name,children:pt(a)},a.voiceURI))]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.engine.system_note")})]})}),se&&e.jsx("div",{className:P(!1),children:e.jsxs("div",{className:"space-y-3",children:[de&&Fe(de,"tts",I,ne,at),de&&e.jsxs("div",{children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsx("input",{type:"text",value:R,onChange:a=>M(a.target.value),onBlur:()=>void r.setSetting("tts_custom_voice",R.trim()),placeholder:t("settings.speech.custom_voice_ph"),"data-testid":"tts-custom-voice",className:`${ie} w-full min-w-0 px-2.5 py-1.5 font-mono`})]}),!de&&we.map(a=>e.jsxs("button",{onClick:()=>ge(a.id),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`tts-pick-${a.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:a.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:a.defaultModel})]},a.id)),(me||!de&&we.length===0)&&e.jsx($e,{kind:"tts",showProtocol:!1,testPrefix:"tts-custom",titleKey:"settings.custom.form_title_tts",modelPhKey:"settings.custom.model_ph_tts",testOverride:a=>r.testCustomTts({baseUrl:a.baseUrl,apiKey:a.apiKey||void 0,model:a.model}),onSaved:a=>{ge(a.id),D(!1),L()},onCancel:()=>D(!1)}),(de||we.length>0)&&e.jsx("button",{onClick:()=>D(a=>!a),className:"text-label text-accent hover:underline",children:t(me?"action.cancel":"settings.custom.new")})]})}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.speech.speed")}),e.jsx("input",{type:"range",min:"0.5",max:"2",step:"0.05",value:y,onChange:a=>A(a.target.value),onPointerUp:()=>{r.setSetting("tts_speed",y),Se()},onKeyUp:()=>{r.setSetting("tts_speed",y),Se()},"data-testid":"tts-speed-range",className:"flex-1 min-w-0 accent-[var(--brand)]"}),e.jsxs("span",{className:"text-label text-ink-muted tabular-nums w-10 text-right","data-testid":"tts-speed-value",children:[Number(y).toFixed(2),"x"]})]})}),e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.speech.asr_title")}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>{ke("local"),le(!1),oe(!1)},"data-testid":"asr-engine-local","aria-pressed":_==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${_==="local"?te:ee}`,children:t("settings.speech.asr_engine.local")}),e.jsx("button",{onClick:()=>{le(a=>!a),H||oe(!1)},"data-testid":"asr-engine-custom","aria-pressed":_.startsWith("custom-")||H,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${_.startsWith("custom-")||H?te:ee}`,children:t("settings.speech.engine.custom")}),tt&&e.jsxs("button",{disabled:!0,"data-testid":"asr-engine-groq",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Groq · ",t("settings.speech.legacy")]}),st&&e.jsxs("button",{disabled:!0,"data-testid":"asr-engine-azure",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Azure · ",t("settings.speech.legacy")]})]}),_==="local"?e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_engine.local_note")}):_.startsWith("custom-")&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_engine.custom_note")})]}),_==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.model")}),e.jsx("select",{value:O,onChange:a=>{W(a.target.value),r.setSetting("asr_local_model",a.target.value)},"data-testid":"asr-model-select",className:`${ie} w-full min-w-0 px-2.5 py-1.5`,children:["asr-whisper-turbo","asr-whisper-small"].map(a=>e.jsxs("option",{value:a,children:[Ye(a)," · ",Re(Ae(a))]},a))})]}),e.jsx("div",{className:P(!1),children:Ie(O)})]}),H&&e.jsx("div",{className:P(!1),children:e.jsxs("div",{className:"space-y-3",children:[ue&&Fe(ue,"asr",C,Z,nt),!ue&&Ne.map(a=>e.jsxs("button",{onClick:()=>ke(a.id),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`asr-pick-${a.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:a.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:a.defaultModel})]},a.id)),(J||!ue&&Ne.length===0)&&e.jsx($e,{kind:"asr",showProtocol:!1,testPrefix:"asr-custom",titleKey:"settings.custom.form_title_asr",modelPhKey:"settings.custom.model_ph_asr",testOverride:a=>r.testCustomAsr({baseUrl:a.baseUrl,apiKey:a.apiKey||void 0,model:a.model}),onSaved:a=>{ke(a.id),oe(!1),L()},onCancel:()=>oe(!1)}),(ue||Ne.length>0)&&e.jsx("button",{onClick:()=>oe(a=>!a),className:"text-label text-accent hover:underline",children:t(J?"action.cancel":"settings.custom.new")})]})}),e.jsxs("div",{className:P(!0),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{checked:G,onChange:()=>{const a=!G;d(a),r.setSetting("asr_auto_stop",a?"1":"0")},label:t("settings.speech.asr_auto_stop"),testid:"asr-auto-stop-toggle"}),e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.speech.asr_auto_stop")})]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_ux_note")})]}),l&&e.jsx("div",{className:"px-4 py-3 text-label text-warning break-all",role:"alert",children:l==="engine-unavailable"?t("chat.speech.engine_unavailable"):l})]})}function It(){const t=ce(),x=n.useRef(null),[o,b]=n.useState(null),[N,l]=n.useState(!1),[c,v]=n.useState(null);n.useEffect(()=>{r.dshImportDetect().then(b).catch(()=>b({found:!1,path:null,version:null}))},[]);const p=g=>{l(!0),v(null),g.then(v).catch(S=>v({ok:!1,error:String(S)})).finally(()=>l(!1))};return e.jsxs("div",{className:"p-4 space-y-3","data-testid":"settings-dsh-import",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:t("settings.dsh.title")}),e.jsx("p",{className:"text-label text-ink-muted leading-relaxed",children:t("settings.dsh.desc")}),o==null?null:o.found?e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"settings-dsh-detected",children:[e.jsx("span",{className:"text-label text-ink-strong",children:t("settings.dsh.detectFound",{v:o.version??"?"})}),e.jsx("button",{onClick:()=>p(r.dshImportFromPath(o.path??"")),disabled:N,"data-testid":"settings-dsh-import-btn",className:"px-3 py-1.5 rounded-xl text-label font-bold btn-3d-brand disabled:opacity-50",children:t(N?"settings.dsh.importing":"settings.dsh.import")})]}):e.jsx("div",{className:"text-label text-ink-muted","data-testid":"settings-dsh-none",children:t("settings.dsh.detectNone")}),e.jsxs("div",{children:[e.jsx("input",{ref:x,type:"file",accept:".json,application/json",className:"hidden","data-testid":"settings-dsh-file-input",onChange:g=>{var j;const S=(j=g.target.files)==null?void 0:j[0];S&&(S.text().then(T=>p(r.dshImportFromText(T))),g.target.value="")}}),e.jsx("button",{onClick:()=>{var g;return(g=x.current)==null?void 0:g.click()},disabled:N,className:"px-3 py-1.5 rounded-xl text-label font-bold btn-3d-neutral disabled:opacity-50",children:t("settings.dsh.pickFile")})]}),N&&!c?e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.dsh.importing")}):null,c!=null&&c.ok?e.jsxs("div",{className:"text-label text-brand leading-relaxed break-all",role:"status","data-testid":"settings-dsh-result",children:[t("settings.dsh.done",{courses:c.coursesCreated+c.coursesMapped+c.coursesRefreshed,nodes:c.nodes,progress:c.progressRows,srs:c.srsRows,xp:c.xpDelta}),c.skippedCourses.length>0?` · ${t("settings.dsh.skipped",{n:c.skippedCourses.length})}`:""]}):c?e.jsxs("div",{className:"text-label text-warning break-all",role:"alert","data-testid":"settings-dsh-error",children:[t("settings.dsh.failed"),": ",c.error??"unknown"]}):null]})}export{Bt as SettingsView};
|
|
20
|
+
${k===s.key?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,children:[e.jsx("span",{className:"text-body font-medium text-ink-strong",children:s.name}),e.jsx("span",{className:`text-caption text-ink-muted text-center leading-snug ${k===s.key?"":"opacity-0 h-0 overflow-hidden"} motion-safe:transition-all`,children:s.hover})]},s.key))}),e.jsx("p",{className:"text-caption text-ink-faint mt-3 text-center",children:t("companion.create.hint")})]})}),W&&e.jsx(St,{onClose:()=>G(!1),onImported:async()=>{await Y()}}),U&&e.jsx(_e,{anchorRect:U.rect,message:t("settings.shimeji.deleteConfirm",{name:((F=d.find(s=>s.id===U.id))==null?void 0:F.name)??""}),danger:!0,testid:"shimeji-delete-confirm",onConfirm:()=>void pe(U.id),onCancel:()=>se(null)}),y&&e.jsx(Nt,{onClose:()=>A(!1),onSaved:()=>{A(!1),D()}})]})]})]}):null}function he({checked:t,onChange:x,label:o,testid:b}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":o,onClick:x,"data-testid":b,className:`relative w-12 h-6 rounded-full transition-colors shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/60 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface-2)] ${t?"bg-brand":"bg-ink/20 hover:bg-ink/25"}`,children:e.jsx("span",{className:`absolute left-0.5 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full bg-white shadow transition-transform ${t?"translate-x-6":""}`})})}const Lt=[{id:"zh-CN-XiaoxiaoNeural",label:"zh-CN · 晓晓(女)"},{id:"zh-CN-XiaoyiNeural",label:"zh-CN · 晓伊(女)"},{id:"zh-CN-YunxiNeural",label:"zh-CN · 云希(男)"},{id:"zh-CN-YunyangNeural",label:"zh-CN · 云扬(男·新闻)"},{id:"zh-CN-liaoning-XiaobeiNeural",label:"zh-CN · 晓北(女·东北)"},{id:"zh-CN-shaanxi-XiaoniNeural",label:"zh-CN · 晓妮(女·陕西)"},{id:"en-US-AriaNeural",label:"en-US · Aria(女)"},{id:"en-US-GuyNeural",label:"en-US · Guy(男)"},{id:"en-US-JennyNeural",label:"en-US · Jenny(女)"}],Rt=[{sid:"45",label:"zf_xiaobei(女)"},{sid:"46",label:"zf_xiaoni(女)"},{sid:"47",label:"zf_xiaoxiao(女)"},{sid:"48",label:"zf_xiaoyi(女·默认)"},{sid:"49",label:"zm_yunjian(男)"},{sid:"50",label:"zm_yunxi(男)"},{sid:"51",label:"zm_yunxia(男)"},{sid:"52",label:"zm_yunyang(男)"}];function At(){const t=ce(),[x,o]=n.useState([]),[b,N]=n.useState(null),[l,c]=n.useState(null),[v,p]=n.useState(null),[g,S]=n.useState(null),[j,T]=n.useState("edge"),[$,h]=n.useState("zh-CN-XiaoxiaoNeural"),[f,z]=n.useState("48"),[y,A]=n.useState("1.0"),[R,M]=n.useState(""),[q,V]=n.useState(""),[B,m]=n.useState([]),E=typeof window<"u"&&"speechSynthesis"in window,[_,k]=n.useState("local"),[O,W]=n.useState("asr-whisper-turbo"),[G,d]=n.useState(!0),[X,U]=n.useState([]),[se,ae]=n.useState(!1),[H,le]=n.useState(!1),[me,D]=n.useState(!1),[Y,oe]=n.useState(!1),[I,pe]=n.useState(!1),[ne,i]=n.useState(null),[C,K]=n.useState(!1),[Z,F]=n.useState(null),[s,u]=n.useState(null),L=n.useCallback(()=>{r.listCustomProviders().then(a=>U(a.filter(w=>w.kind==="tts"||w.kind==="asr"))).catch(()=>{})},[]);n.useEffect(()=>{Promise.all([r.getSetting("tts_engine"),r.getSetting("tts_voice_edge"),r.getSetting("tts_sid_local"),r.getSetting("tts_speed"),r.getSetting("tts_custom_voice"),r.getSetting("tts_system_voice"),r.getSetting("asr_engine"),r.getSetting("asr_local_model"),r.getSetting("asr_auto_stop")]).then(([a,w,J,re,ye,Ve,Be,Ee,lt])=>{a&&T(a),w&&h(w),J&&z(J),re&&A(re),ye&&M(ye),Ve&&V(Ve),Be&&k(Be),(Ee==="asr-whisper-turbo"||Ee==="asr-whisper-small")&&W(Ee),d(lt!=="0")}),L()},[L]),n.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const a=()=>m(gt(window.speechSynthesis.getVoices()));return a(),window.speechSynthesis.addEventListener("voiceschanged",a),()=>window.speechSynthesis.removeEventListener("voiceschanged",a)},[]);const Q=n.useCallback(()=>{window.api.getSpeechModelStatus().then(a=>o(a)).catch(()=>{})},[]);n.useEffect(()=>(Q(),window.api.on("speech:modelProgress",w=>{p({id:w.id,pct:Math.floor(w.progress*100),label:w.currentFile?w.currentFile.split("/").pop()??"":""})})),[Q]);const Ge=a=>{c(null),N(a),p({id:a,pct:0,label:""}),window.api.ensureSpeechModel(a).then(()=>{N(null),p(null),Q()}).catch(w=>{N(null),p(null),c(w instanceof Error?w.message:String(w)),Q()})},Xe=a=>{N(a),S(null),window.api.deleteSpeechModel(a).then(Q).catch(w=>c(w instanceof Error?w.message:String(w))).finally(()=>N(null))},Ye=a=>t(a==="tts-kokoro"?"settings.speech.model.tts":a==="asr-whisper-turbo"?"settings.speech.model.asr_turbo":"settings.speech.model.asr_small"),Je=a=>t(a==="asr-whisper-turbo"?"settings.speech.model.turbo_short":"settings.speech.model.small_short"),Ze=a=>a.startsWith("asr-whisper")?t("settings.speech.license_mit"):t("settings.speech.license"),Re=a=>t(a==="ready"?"settings.speech.state.ready":a==="error"?"settings.speech.state.error":"settings.speech.state.absent"),Ae=a=>{var w;return((w=x.find(J=>J.id===a))==null?void 0:w.state)??"absent"},ge=a=>{T(a),i(null),r.setSetting("tts_engine",a),Se()},Qe=a=>{V(a),r.setSetting("tts_system_voice",a),Se()},ke=a=>{k(a),F(null),r.setSetting("asr_engine",a)},we=X.filter(a=>a.kind==="tts"),Ne=X.filter(a=>a.kind==="asr"),de=j.startsWith("custom-")?we.find(a=>a.id===j)??null:null,ue=_.startsWith("custom-")?Ne.find(a=>a.id===_)??null:null,et=j==="azure",tt=_==="groq",st=_==="azure",at=async()=>{if(!(!de||I)){pe(!0),i(null);try{i(await r.testCustomTts({providerId:de.id}))}catch(a){i({ok:!1,detail:a instanceof Error?a.message:String(a)})}finally{pe(!1)}}},nt=async()=>{if(!(!ue||C)){K(!0),F(null);try{F(await r.testCustomAsr({providerId:ue.id}))}catch(a){F({ok:!1,detail:a instanceof Error?a.message:String(a)})}finally{K(!1)}}},it=async(a,w)=>{u(null);try{await r.deleteCustomProvider(a),w==="tts"&&j===a&&ge("edge"),w==="asr"&&_===a&&ke("local"),L()}catch{}},Ie=a=>{const w=x.find(re=>re.id===a),J=(w==null?void 0:w.state)??"absent";return e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong truncate",children:Ye(a)}),e.jsxs("div",{className:"text-caption text-ink-muted",children:[Re(J)," · ",Ze(a)]}),b===a&&(v==null?void 0:v.id)===a&&e.jsx("div",{className:"mt-1.5 h-1.5 rounded-full bg-ink/[0.08] overflow-hidden","data-testid":`speech-dl-bar-${a}`,children:e.jsx("div",{className:"h-full bg-brand transition-all",style:{width:`${v.pct}%`}})}),b===a&&(v==null?void 0:v.id)===a&&e.jsxs("div",{className:"text-caption text-ink-faint mt-0.5","data-testid":`speech-dl-pct-${a}`,children:[v.pct,"%",v.label?` · ${v.label}`:""]})]}),J==="ready"?g===a?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-caption text-warning",children:t("settings.speech.confirm_del")}),e.jsx("button",{onClick:()=>Xe(a),className:"text-label text-warning hover:underline","data-testid":`speech-del-confirm-${a}`,children:t("settings.speech.delete")}),e.jsx("button",{onClick:()=>S(null),className:"text-label text-ink-muted hover:text-ink-strong",children:t("action.cancel")})]}):e.jsx("button",{onClick:()=>S(a),disabled:b===a,className:"text-label text-ink-muted hover:text-warning disabled:opacity-40","data-testid":`speech-del-${a}`,children:t("settings.speech.delete")}):e.jsx("button",{onClick:()=>Ge(a),disabled:b!=null||J==="downloading",className:"btn-3d-brand px-3 py-1 text-label disabled:opacity-40","data-testid":`speech-dl-${a}`,children:t(b===a||J==="downloading"?"settings.speech.downloading":"settings.speech.download")})]},a)},Fe=(a,w,J,re,ye)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx(Le,{className:"w-3.5 h-3.5 text-ink-faint shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-medium text-ink-strong",children:a.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:a.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:a.baseUrl}),a.hasApiKey&&e.jsxs("span",{className:"text-brand shrink-0 inline-flex items-center gap-0.5",children:[e.jsx(xe,{className:"w-3.5 h-3.5","aria-hidden":"true"}),t("settings.speech.key_saved")]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:()=>void ye(),disabled:J,className:"btn-3d-neutral px-3 py-1 text-label disabled:opacity-40","data-testid":`${w}-custom-test`,children:t(J?"settings.testing":"settings.test")}),s===a.id?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-caption text-warning",children:t("settings.speech.confirm_del_custom")}),e.jsx("button",{onClick:()=>void it(a.id,w),className:"text-label text-warning hover:underline","data-testid":`${w}-custom-del-confirm`,children:t("settings.speech.delete")}),e.jsx("button",{onClick:()=>u(null),className:"text-label text-ink-muted hover:text-ink-strong",children:t("action.cancel")})]}):e.jsx("button",{onClick:()=>u(a.id),className:"text-label text-ink-muted hover:text-warning","data-testid":`${w}-custom-del`,children:t("settings.speech.delete")}),re&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${re.ok?"text-brand":"text-warning"}`,children:[re.ok?e.jsx(xe,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(je,{className:"w-4 h-4","aria-hidden":"true"}),re.detail]})]})]});return e.jsxs("div",{"data-testid":"settings-speech",children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.speech.tts_title")}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>{ge("edge"),ae(!1),D(!1)},"data-testid":"tts-engine-edge","aria-pressed":j==="edge",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${j==="edge"?te:ee}`,children:t("settings.speech.engine.edge")}),e.jsxs("button",{onClick:()=>{ge("local"),ae(!1),D(!1)},"data-testid":"tts-engine-local","aria-pressed":j==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${j==="local"?te:ee}`,children:[t("settings.speech.engine.local"),Ae("tts-kokoro")!=="ready"?` · ${t("settings.speech.state.absent")}`:""]}),e.jsx("button",{onClick:()=>{ge("system"),ae(!1),D(!1)},disabled:!E,"data-testid":"tts-engine-system","aria-pressed":j==="system",title:E?void 0:t("settings.speech.engine.system_unavailable"),className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${j==="system"?te:ee} ${E?"":"opacity-40 cursor-not-allowed"}`,children:t("settings.speech.engine.system")}),e.jsx("button",{onClick:()=>{ae(a=>!a),se||D(!1)},"data-testid":"tts-engine-custom","aria-pressed":j.startsWith("custom-")||se,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${j.startsWith("custom-")||se?te:ee}`,children:t("settings.speech.engine.custom")}),et&&e.jsxs("button",{disabled:!0,"data-testid":"tts-engine-azure",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Azure · ",t("settings.speech.legacy")]})]}),j==="edge"&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.engine.edge_note")})]}),j==="edge"&&e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsx("select",{value:$,onChange:a=>{h(a.target.value),r.setSetting("tts_voice_edge",a.target.value)},"data-testid":"tts-voice-select",className:`${ie} w-full min-w-0 px-2.5 py-1.5`,children:Lt.map(a=>e.jsx("option",{value:a.id,children:a.label},a.id))})]}),j==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsx("select",{value:f,onChange:a=>{z(a.target.value),r.setSetting("tts_sid_local",a.target.value)},"data-testid":"tts-sid-select",className:`${ie} w-full min-w-0 px-2.5 py-1.5`,children:Rt.map(a=>e.jsx("option",{value:a.sid,children:a.label},a.sid))})]}),e.jsx("div",{className:P(!1),children:Ie("tts-kokoro")})]}),j==="system"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsxs("select",{value:q,onChange:a=>Qe(a.target.value),"data-testid":"tts-system-voice-select",className:`${ie} w-full min-w-0 px-2.5 py-1.5`,children:[e.jsx("option",{value:"",children:t("settings.speech.voice_auto")}),B.map(a=>e.jsx("option",{value:a.name,children:pt(a)},a.voiceURI))]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.engine.system_note")})]})}),se&&e.jsx("div",{className:P(!1),children:e.jsxs("div",{className:"space-y-3",children:[de&&Fe(de,"tts",I,ne,at),de&&e.jsxs("div",{children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.speech.voice")}),e.jsx("input",{type:"text",value:R,onChange:a=>M(a.target.value),onBlur:()=>void r.setSetting("tts_custom_voice",R.trim()),placeholder:t("settings.speech.custom_voice_ph"),"data-testid":"tts-custom-voice",className:`${ie} w-full min-w-0 px-2.5 py-1.5 font-mono`})]}),!de&&we.map(a=>e.jsxs("button",{onClick:()=>ge(a.id),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`tts-pick-${a.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:a.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:a.defaultModel})]},a.id)),(me||!de&&we.length===0)&&e.jsx($e,{kind:"tts",showProtocol:!1,testPrefix:"tts-custom",titleKey:"settings.custom.form_title_tts",modelPhKey:"settings.custom.model_ph_tts",testOverride:a=>r.testCustomTts({baseUrl:a.baseUrl,apiKey:a.apiKey||void 0,model:a.model}),onSaved:a=>{ge(a.id),D(!1),L()},onCancel:()=>D(!1)}),(de||we.length>0)&&e.jsx("button",{onClick:()=>D(a=>!a),className:"text-label text-accent hover:underline",children:t(me?"action.cancel":"settings.custom.new")})]})}),e.jsx("div",{className:P(!0),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-label font-medium text-ink-strong shrink-0 w-14",children:t("settings.speech.speed")}),e.jsx("input",{type:"range",min:"0.5",max:"2",step:"0.05",value:y,onChange:a=>A(a.target.value),onPointerUp:()=>{r.setSetting("tts_speed",y),Se()},onKeyUp:()=>{r.setSetting("tts_speed",y),Se()},"data-testid":"tts-speed-range",className:"flex-1 min-w-0 accent-[var(--brand)]"}),e.jsxs("span",{className:"text-label text-ink-muted tabular-nums w-10 text-right","data-testid":"tts-speed-value",children:[Number(y).toFixed(2),"x"]})]})}),e.jsxs("div",{className:P(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:t("settings.speech.asr_title")}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>{ke("local"),le(!1),oe(!1)},"data-testid":"asr-engine-local","aria-pressed":_==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${_==="local"?te:ee}`,children:t("settings.speech.asr_engine.local")}),e.jsx("button",{onClick:()=>{le(a=>!a),H||oe(!1)},"data-testid":"asr-engine-custom","aria-pressed":_.startsWith("custom-")||H,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${_.startsWith("custom-")||H?te:ee}`,children:t("settings.speech.engine.custom")}),tt&&e.jsxs("button",{disabled:!0,"data-testid":"asr-engine-groq",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Groq · ",t("settings.speech.legacy")]}),st&&e.jsxs("button",{disabled:!0,"data-testid":"asr-engine-azure",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Azure · ",t("settings.speech.legacy")]})]}),_==="local"?e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_engine.local_note")}):_.startsWith("custom-")&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_engine.custom_note")})]}),_==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:P(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:t("settings.model")}),e.jsx("select",{value:O,onChange:a=>{W(a.target.value),r.setSetting("asr_local_model",a.target.value)},"data-testid":"asr-model-select",className:`${ie} w-full min-w-0 px-2.5 py-1.5`,children:["asr-whisper-turbo","asr-whisper-small"].map(a=>e.jsxs("option",{value:a,children:[Je(a)," · ",Re(Ae(a))]},a))})]}),e.jsx("div",{className:P(!1),children:Ie(O)})]}),H&&e.jsx("div",{className:P(!1),children:e.jsxs("div",{className:"space-y-3",children:[ue&&Fe(ue,"asr",C,Z,nt),!ue&&Ne.map(a=>e.jsxs("button",{onClick:()=>ke(a.id),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`asr-pick-${a.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:a.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:a.defaultModel})]},a.id)),(Y||!ue&&Ne.length===0)&&e.jsx($e,{kind:"asr",showProtocol:!1,testPrefix:"asr-custom",titleKey:"settings.custom.form_title_asr",modelPhKey:"settings.custom.model_ph_asr",testOverride:a=>r.testCustomAsr({baseUrl:a.baseUrl,apiKey:a.apiKey||void 0,model:a.model}),onSaved:a=>{ke(a.id),oe(!1),L()},onCancel:()=>oe(!1)}),(ue||Ne.length>0)&&e.jsx("button",{onClick:()=>oe(a=>!a),className:"text-label text-accent hover:underline",children:t(Y?"action.cancel":"settings.custom.new")})]})}),e.jsxs("div",{className:P(!0),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(he,{checked:G,onChange:()=>{const a=!G;d(a),r.setSetting("asr_auto_stop",a?"1":"0")},label:t("settings.speech.asr_auto_stop"),testid:"asr-auto-stop-toggle"}),e.jsx("div",{className:"text-body font-medium text-ink-strong",children:t("settings.speech.asr_auto_stop")})]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:t("settings.speech.asr_ux_note")})]}),l&&e.jsx("div",{className:"px-4 py-3 text-label text-warning break-all",role:"alert",children:l==="engine-unavailable"?t("chat.speech.engine_unavailable"):l})]})}function It(){const t=ce(),x=n.useRef(null),[o,b]=n.useState(null),[N,l]=n.useState(!1),[c,v]=n.useState(null);n.useEffect(()=>{r.dshImportDetect().then(b).catch(()=>b({found:!1,path:null,version:null}))},[]);const p=g=>{l(!0),v(null),g.then(v).catch(S=>v({ok:!1,error:String(S)})).finally(()=>l(!1))};return e.jsxs("div",{className:"p-4 space-y-3","data-testid":"settings-dsh-import",children:[e.jsx("div",{className:"text-label font-medium text-ink-strong",children:t("settings.dsh.title")}),e.jsx("p",{className:"text-label text-ink-muted leading-relaxed",children:t("settings.dsh.desc")}),o==null?null:o.found?e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"settings-dsh-detected",children:[e.jsx("span",{className:"text-label text-ink-strong",children:t("settings.dsh.detectFound",{v:o.version??"?"})}),e.jsx("button",{onClick:()=>p(r.dshImportFromPath(o.path??"")),disabled:N,"data-testid":"settings-dsh-import-btn",className:"px-3 py-1.5 rounded-xl text-label font-bold btn-3d-brand disabled:opacity-50",children:t(N?"settings.dsh.importing":"settings.dsh.import")})]}):e.jsx("div",{className:"text-label text-ink-muted","data-testid":"settings-dsh-none",children:t("settings.dsh.detectNone")}),e.jsxs("div",{children:[e.jsx("input",{ref:x,type:"file",accept:".json,application/json",className:"hidden","data-testid":"settings-dsh-file-input",onChange:g=>{var j;const S=(j=g.target.files)==null?void 0:j[0];S&&(S.text().then(T=>p(r.dshImportFromText(T))),g.target.value="")}}),e.jsx("button",{onClick:()=>{var g;return(g=x.current)==null?void 0:g.click()},disabled:N,className:"px-3 py-1.5 rounded-xl text-label font-bold btn-3d-neutral disabled:opacity-50",children:t("settings.dsh.pickFile")})]}),N&&!c?e.jsx("div",{className:"text-label text-ink-muted",children:t("settings.dsh.importing")}):null,c!=null&&c.ok?e.jsxs("div",{className:"text-label text-brand leading-relaxed break-all",role:"status","data-testid":"settings-dsh-result",children:[t("settings.dsh.done",{courses:c.coursesCreated+c.coursesMapped+c.coursesRefreshed,nodes:c.nodes,progress:c.progressRows,srs:c.srsRows,xp:c.xpDelta}),c.skippedCourses.length>0?` · ${t("settings.dsh.skipped",{n:c.skippedCourses.length})}`:""]}):c?e.jsxs("div",{className:"text-label text-warning break-all",role:"alert","data-testid":"settings-dsh-error",children:[t("settings.dsh.failed"),": ",c.error??"unknown"]}):null]})}export{Bt as SettingsView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as n,j as e}from"./index-
|
|
1
|
+
import{r as n,j as e}from"./index-DwG4tw4S.js";import{c as f,u as h,e as b,f as g}from"./main-s-bCU9xp.js";import{R as j}from"./rotate-ccw-BcZP2n0D.js";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,r as u,d as a}from"./chunk-SVP7TREG-
|
|
1
|
+
import{g as p,r as u,d as a}from"./chunk-SVP7TREG-DKVY1S0P.js";import{p as f}from"./chunk-JWPE2WC7-BGDdCd7e.js";import{_ as n,l as o}from"./mermaid.core-DP9HBKfF.js";import"./transform-Bd_a5eGM.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-DOvceb57.js";import"./main-s-bCU9xp.js";import"./index-DwG4tw4S.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},I={parser:R,db:a,renderer:u,styles:p};export{I as diagram};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,r as u,d as a}from"./chunk-XCWWM2C3-
|
|
1
|
+
import{g as p,r as u,d as a}from"./chunk-XCWWM2C3-DX7b36ww.js";import{p as f}from"./chunk-VII2H2IX-DXWnTQhH.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-GVF3BKWE-CyNo44Ct.js";import{_ as n,l as o}from"./render-O7CIS3YK-Ca_t2BjR.js";import"./transform-Bd_a5eGM.js";import"./mermaid-layout-elk.core-BDxAYedV.js";import"./main-s-bCU9xp.js";import"./index-DwG4tw4S.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),m=t?parseInt(t,10):0,l=s?parseInt(s,10):1/0;return{min:m,max:l}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},D={parser:R,db:a,renderer:u,styles:p};export{D as diagram};
|