lookatstudy-mobile 0.22.1 → 0.23.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 +8 -6
- package/web/assets/{CanvasStage--cO-dGou.js → CanvasStage-Ba-21anG.js} +1 -1
- package/web/assets/{CommandPalette-B9yujZKA.js → CommandPalette-SKnzQMcN.js} +1 -1
- package/web/assets/{CourseSearchPanel-C7Mz8cwp.js → CourseSearchPanel-BW3fNReR.js} +1 -1
- package/web/assets/{ExamView-CxgAmCWD.js → ExamView-BnH6BraN.js} +1 -1
- package/web/assets/{MindmapView-D2NywTY1.js → MindmapView-B4SeCLQj.js} +3 -3
- package/web/assets/{ReviewPanel-CLOe8uSS.js → ReviewPanel-DkGT8tNA.js} +1 -1
- package/web/assets/{SettingsView-Crx4fWxj.js → SettingsView-dExmRnIv.js} +3 -3
- package/web/assets/{VoicePanel-B9o8PTlU.js → VoicePanel-CxNeKn4V.js} +2 -7
- package/web/assets/{abnfDiagram-N423BO3Z-DlR3JtCi.js → abnfDiagram-N423BO3Z-B4kvB05N.js} +1 -1
- package/web/assets/{abnfDiagram-VCTEODGH-ODA7YWAP-Cc60_NCH.js → abnfDiagram-VCTEODGH-ODA7YWAP-B5zhG8XJ.js} +1 -1
- package/web/assets/{architectureDiagram-5GKGNRK7-C4PU3XN7-DxA8-TH0.js → architectureDiagram-5GKGNRK7-C4PU3XN7-ybcWxxhr.js} +1 -1
- package/web/assets/{architectureDiagram-T3A2C74G-b87f0Zfh.js → architectureDiagram-T3A2C74G-D5eb-etB.js} +1 -1
- package/web/assets/{arrow-right-B_6KkCJV.js → arrow-right-D4GV0Gpo.js} +1 -1
- package/web/assets/{blockDiagram-NRAW4CY4-UMJ6PMQQ-DujiZmu6.js → blockDiagram-NRAW4CY4-UMJ6PMQQ-DwEVReBp.js} +1 -1
- package/web/assets/{blockDiagram-VBNYF7ZC-BVvgfsGF.js → blockDiagram-VBNYF7ZC-DuM7ndnl.js} +1 -1
- package/web/assets/{c4Diagram-5PPSVZJV-5YSQGEVW.js → c4Diagram-5PPSVZJV-BQkRaO7S.js} +1 -1
- package/web/assets/{c4Diagram-UCG6FXSJ-75X3U2P3-DOEKYDP0.js → c4Diagram-UCG6FXSJ-75X3U2P3-Di1jNn7S.js} +1 -1
- package/web/assets/channel-KoPlHvUR.js +1 -0
- package/web/assets/{chunk-2GRJ4B5K-7x3UypsR.js → chunk-2GRJ4B5K-C7VAL2Yd.js} +1 -1
- package/web/assets/{chunk-2Q5K7J3B-5RQfakW9.js → chunk-2Q5K7J3B-Jpo34qVL.js} +1 -1
- package/web/assets/{chunk-5RXB4S5H-CX91mO_w.js → chunk-5RXB4S5H-CrW8aZl4.js} +1 -1
- package/web/assets/{chunk-5VM5RSS4-DhfIWqOK.js → chunk-5VM5RSS4-Dv4MffdC.js} +1 -1
- package/web/assets/{chunk-6Q2QTUOP-DyBMkImn.js → chunk-6Q2QTUOP-CI07iNTB.js} +1 -1
- package/web/assets/{chunk-7XDTSPCN-l_wcpmq6.js → chunk-7XDTSPCN-DsQtrF-N.js} +1 -1
- package/web/assets/{chunk-CTNIYPP6-Bej-ifE4.js → chunk-CTNIYPP6-CpdWBpIN.js} +1 -1
- package/web/assets/{chunk-CXNFBKHE-BymXgi-y.js → chunk-CXNFBKHE-BDCDRaZC.js} +1 -1
- package/web/assets/{chunk-GF5L2VYU-DeTnv5Qk.js → chunk-GF5L2VYU-DtpZkefy.js} +1 -1
- package/web/assets/{chunk-ISA7TJRJ-CFmR6SoA.js → chunk-ISA7TJRJ-C3LgQ-bA.js} +1 -1
- package/web/assets/{chunk-JWPE2WC7-BU-fMtWi.js → chunk-JWPE2WC7-DJM1SevB.js} +1 -1
- package/web/assets/{chunk-KBJHAD2P-BjlTMp1m.js → chunk-KBJHAD2P-7KeTMqC1.js} +1 -1
- package/web/assets/{chunk-LV3HUYFY-riE_n54k.js → chunk-LV3HUYFY-B2sGhGxz.js} +1 -1
- package/web/assets/{chunk-M3IUQBOH-DYx0J19K.js → chunk-M3IUQBOH-Dazbegdb.js} +1 -1
- package/web/assets/{chunk-NDIOYS4C-D34dHdEf.js → chunk-NDIOYS4C-Cx7mCz5-.js} +1 -1
- package/web/assets/{chunk-RE4WF27V-qx7CV25O.js → chunk-RE4WF27V-BNzpDJts.js} +1 -1
- package/web/assets/{chunk-RYQCIY6F-AqdEeieF.js → chunk-RYQCIY6F-Boq_29rU.js} +1 -1
- package/web/assets/{chunk-VII2H2IX-CzkbeZYY.js → chunk-VII2H2IX-kQVDZD-x.js} +1 -1
- package/web/assets/{chunk-X5GNSKZ3-DVqvzTCj.js → chunk-X5GNSKZ3-DT5Ja5IF.js} +1 -1
- package/web/assets/{chunk-XCWWM2C3-BJLKBAh0.js → chunk-XCWWM2C3-BAq7zpgL.js} +1 -1
- package/web/assets/{chunk-XXDRQBXY-Nz1f1JPS.js → chunk-XXDRQBXY-D3vcLngc.js} +1 -1
- package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K-P8Aw4zHn.js +1 -0
- package/web/assets/classDiagram-JCYQIIEL-Dm2NSERp.js +1 -0
- package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2-P8Aw4zHn.js +1 -0
- package/web/assets/classDiagram-v2-OCEON4UE-Dm2NSERp.js +1 -0
- package/web/assets/{core-5AezUpt1.js → core-4d9vIKK9.js} +4 -4
- package/web/assets/{cose-bilkent-JH36ORCC-OB24KH3T-B46Ih9E8.js → cose-bilkent-JH36ORCC-OB24KH3T-DwFzf1xR.js} +1 -1
- package/web/assets/{cose-bilkent-JH36ORCC-Bwf1adzB.js → cose-bilkent-JH36ORCC-RoUdcSs7.js} +1 -1
- package/web/assets/{cynefin-OW5HDTMX-GVF3BKWE-DcR0n-8p.js → cynefin-OW5HDTMX-GVF3BKWE-Bdt2EF7g.js} +1 -1
- package/web/assets/{cynefin-VYW2F7L2-BtjjXqMe.js → cynefin-VYW2F7L2-Br1TXK2f.js} +1 -1
- package/web/assets/{cynefinDiagram-5FMLGOSQ-H3WIRU3N-CecBQ3WS.js → cynefinDiagram-5FMLGOSQ-H3WIRU3N-DFRlDIhn.js} +1 -1
- package/web/assets/{cynefinDiagram-MW4NZA55-CeLD6_7i.js → cynefinDiagram-MW4NZA55-DeqLH2Db.js} +1 -1
- package/web/assets/{dagre-3AP2YEHR-DCERTXHT-I_531Mm0.js → dagre-3AP2YEHR-DCERTXHT-wbCkJQSQ.js} +1 -1
- package/web/assets/{dagre-VZM6K2ZE-BYSfxtKs.js → dagre-VZM6K2ZE-X3laLObS.js} +1 -1
- package/web/assets/{diagram-7IWD3JNH-CfUUB3zT.js → diagram-7IWD3JNH-8bZxUpBi.js} +1 -1
- package/web/assets/{diagram-B4RE2ZJO-B4h2KVGE.js → diagram-B4RE2ZJO-CsGnKBa4.js} +1 -1
- package/web/assets/{diagram-LBJQPF4R-BycPUMao.js → diagram-LBJQPF4R-CxaNBwKI.js} +1 -1
- package/web/assets/{diagram-Q27KOJAE-nUmmLOWc.js → diagram-Q27KOJAE-CjVLD6gb.js} +1 -1
- package/web/assets/{diagram-S7CK7UJ4-MULGZGEL-YmP_5pu9.js → diagram-S7CK7UJ4-MULGZGEL-wKLcWkw4.js} +1 -1
- package/web/assets/{diagram-UB23O5K3-AbqPe_Lw.js → diagram-UB23O5K3-CUZ34yVE.js} +1 -1
- package/web/assets/{diagram-UQ7AKVKN-YQBY353J-CSBHhT_p.js → diagram-UQ7AKVKN-YQBY353J-B_ah6OV8.js} +1 -1
- package/web/assets/{diagram-VSXAHHWV-WLNH2ELY-BIWRzcG_.js → diagram-VSXAHHWV-WLNH2ELY-BhbJ7E_e.js} +1 -1
- package/web/assets/{diagram-VX7I27RA-XW6YQV5G-DOIsDS0u.js → diagram-VX7I27RA-XW6YQV5G-DnFEyO87.js} +1 -1
- package/web/assets/{diagram-Z3DM3KII-HG7RF65D-CL_RkrR1.js → diagram-Z3DM3KII-HG7RF65D-Vughovua.js} +1 -1
- package/web/assets/{ebnfDiagram-BXEA7PRR-CiCY0Nb_.js → ebnfDiagram-BXEA7PRR-B2ehf44X.js} +1 -1
- package/web/assets/{ebnfDiagram-PWID7BFC-OKY4VHYD-30_W7bxy.js → ebnfDiagram-PWID7BFC-OKY4VHYD-BjbgNq8R.js} +1 -1
- package/web/assets/{elk.bundled-CoJK8Y5o.js → elk.bundled-CktUbZ7z.js} +1 -1
- package/web/assets/{erDiagram-JOGREHBK-CiMrd6Dm.js → erDiagram-JOGREHBK-9wI_YE-7.js} +1 -1
- package/web/assets/{erDiagram-SSCWMZ5O-PIPKOIK7-DR-Xlax4.js → erDiagram-SSCWMZ5O-PIPKOIK7-V60k7zg6.js} +1 -1
- package/web/assets/{flowDiagram-A5DVABFB-2Z4AVO5R-Bm2DnZWS.js → flowDiagram-A5DVABFB-2Z4AVO5R-CJdwjvtN.js} +1 -1
- package/web/assets/{flowDiagram-UKHOOZJN-DlA7YU9i.js → flowDiagram-UKHOOZJN-B3XmqjMH.js} +1 -1
- package/web/assets/{ganttDiagram-EL5Y4UJY-JZNG7GOG-CycOiHbj.js → ganttDiagram-EL5Y4UJY-JZNG7GOG-2a6TiXM3.js} +1 -1
- package/web/assets/{ganttDiagram-PKOTCBZU-BT4d6R51.js → ganttDiagram-PKOTCBZU-B7B9nD6g.js} +1 -1
- package/web/assets/{gitGraphDiagram-DS77QQ5N-DyUz04eh.js → gitGraphDiagram-DS77QQ5N-VwKL0Ozk.js} +1 -1
- package/web/assets/{gitGraphDiagram-WWUBYQGX-DMWMLL3G-Cp635UIu.js → gitGraphDiagram-WWUBYQGX-DMWMLL3G-BMs5FYkE.js} +1 -1
- package/web/assets/{index-D619gSoN.js → index-D0FRqjBW.js} +2 -2
- package/web/assets/{index-ClPJ1xdX.js → index-DFryMRAp.js} +6 -6
- package/web/assets/{index-c6Br465X.css → index-DjoBjasB.css} +1 -1
- package/web/assets/{index-8JL6mw1y.js → index-DkjixD09.js} +1 -1
- package/web/assets/{index-BSXjRLsf.js → index-Vtc_VHiK.js} +1 -1
- package/web/assets/{infoDiagram-6WML65LV-rj50EKNC.js → infoDiagram-6WML65LV-CD6GNI7J.js} +1 -1
- package/web/assets/{infoDiagram-RXCK75RN-HANS5KVC-BHovTPxo.js → infoDiagram-RXCK75RN-HANS5KVC-k8vzCiSp.js} +1 -1
- package/web/assets/{ishikawaDiagram-5VMMS53U-7GCIT7WU-B0aX9dg0.js → ishikawaDiagram-5VMMS53U-7GCIT7WU-Ckl5jIU6.js} +1 -1
- package/web/assets/{ishikawaDiagram-WSZJBQD7-Cs68VzMS.js → ishikawaDiagram-WSZJBQD7-CEdvuK4K.js} +1 -1
- package/web/assets/{journeyDiagram-EYS64GPL-OAPELBT7-BaF1Okyl.js → journeyDiagram-EYS64GPL-OAPELBT7-DtCRso4h.js} +1 -1
- package/web/assets/{journeyDiagram-NVQOT4AX-CxamcAfg.js → journeyDiagram-NVQOT4AX-CxPjI9L-.js} +1 -1
- package/web/assets/{kanban-definition-27J2QSJJ-CqkEoxuc.js → kanban-definition-27J2QSJJ-DnuNCFkl.js} +1 -1
- package/web/assets/{kanban-definition-3QL26DDD-I7RKWQQY-KQq8LJIu.js → kanban-definition-3QL26DDD-I7RKWQQY-yNRn2nj0.js} +1 -1
- package/web/assets/{katex-N6JRN4PM-BRgAOu7M.js → katex-N6JRN4PM-B9dEOiMG.js} +1 -1
- package/web/assets/main-CGE6fm01.js +462 -0
- package/web/assets/{mermaid-layout-elk.core-CS6tfHSb.js → mermaid-layout-elk.core-BUAJJUsd.js} +2 -2
- package/web/assets/{mermaid.core-D_Bznvdr.js → mermaid.core-BD32Za4p.js} +4 -4
- package/web/assets/{mindmap-definition-FAOFIHXS-h9YeSHf4.js → mindmap-definition-FAOFIHXS-DX6VEGs_.js} +1 -1
- package/web/assets/{mindmap-definition-FBJOCRG2-KIYZG64Y-DT9Y6a9o.js → mindmap-definition-FBJOCRG2-KIYZG64Y-DYiBZnHG.js} +1 -1
- package/web/assets/{pegDiagram-VL7TDLO6-C--Hsstu.js → pegDiagram-VL7TDLO6-Big72xut.js} +1 -1
- package/web/assets/{pegDiagram-XKGWAZYB-OIP57N6J-CXtA7B8B.js → pegDiagram-XKGWAZYB-OIP57N6J-N0pgSR7W.js} +1 -1
- package/web/assets/{pet-BWlfq4I-.js → pet-DopPVlAf.js} +1 -1
- package/web/assets/{pieDiagram-7S7Q4E2Y-CVnsOokB.js → pieDiagram-7S7Q4E2Y-BLXLqOCg.js} +1 -1
- package/web/assets/{pieDiagram-E7YTZNPT-2UOTW327-DkYfAF2K.js → pieDiagram-E7YTZNPT-2UOTW327-BuB4rTS2.js} +1 -1
- package/web/assets/{quadrantDiagram-AXDQQJYC-SN3ASJJK-B3grZeFo.js → quadrantDiagram-AXDQQJYC-SN3ASJJK-4S-5LgOz.js} +1 -1
- package/web/assets/{quadrantDiagram-CIZ2JOQS-i1yx34JH.js → quadrantDiagram-CIZ2JOQS-BUwizsLb.js} +1 -1
- package/web/assets/{railroadDiagram-AXF67PYL-DJuiGlbf.js → railroadDiagram-AXF67PYL-D3qxyYSE.js} +1 -1
- package/web/assets/{railroadDiagram-O6MQD6OU-34742W6X-up2Y0ZV_.js → railroadDiagram-O6MQD6OU-34742W6X-CzT_bN34.js} +1 -1
- package/web/assets/{render-O7CIS3YK-Dn1e27o_.js → render-O7CIS3YK-DhYmSGoI.js} +7 -7
- package/web/assets/{requirementDiagram-EFPCY7ZU-NGAFFSMB-BI_BSQB1.js → requirementDiagram-EFPCY7ZU-NGAFFSMB-iWwnW8VG.js} +1 -1
- package/web/assets/{requirementDiagram-LRYGKXZP-nFTGE1MQ.js → requirementDiagram-LRYGKXZP-Cf95T2or.js} +1 -1
- package/web/assets/{rotate-ccw-nkiipcxH.js → rotate-ccw-natFwqj6.js} +1 -1
- package/web/assets/{sankeyDiagram-P5KCCOFB-3D3M4XPB-Bqf3rmL6.js → sankeyDiagram-P5KCCOFB-3D3M4XPB-CjA_LC6M.js} +1 -1
- package/web/assets/{sankeyDiagram-W5VNT64P-BIhgGHwI.js → sankeyDiagram-W5VNT64P-CeGCHk7F.js} +1 -1
- package/web/assets/{sequenceDiagram-SI44F4Z6-BASko1ED.js → sequenceDiagram-SI44F4Z6-BDsExCj2.js} +1 -1
- package/web/assets/{sequenceDiagram-WJ2MYXX4-Q2IOPB4R-BiNVA6gm.js → sequenceDiagram-WJ2MYXX4-Q2IOPB4R-DbWhuP8u.js} +1 -1
- package/web/assets/{sizeCapture-X5ZJPWSS-PSGVOMYM-TxBOTj1p.js → sizeCapture-X5ZJPWSS-PSGVOMYM-DB5JtURh.js} +1 -1
- package/web/assets/{sizeCapture-X5ZJPWSS-CGWs4y9a.js → sizeCapture-X5ZJPWSS-_5trx7u2.js} +1 -1
- package/web/assets/{stateDiagram-HBIQ2CUA-4M2S6MAN-BdhmANKG.js → stateDiagram-HBIQ2CUA-4M2S6MAN-CBEhL8_A.js} +1 -1
- package/web/assets/{stateDiagram-OKZ733FA-CkUDyLVf.js → stateDiagram-OKZ733FA-BPHwMfDA.js} +1 -1
- package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-lZeXiw9L.js +1 -0
- package/web/assets/stateDiagram-v2-UEYNNEHI-cH9YNExR.js +1 -0
- package/web/assets/{swimlanes-SLNWSIFB-CZxwkAvO.js → swimlanes-SLNWSIFB-CDgj9OM9.js} +2 -2
- package/web/assets/{swimlanes-XN3QIQJK-N6N2CCQ6-Zac8KNFb.js → swimlanes-XN3QIQJK-N6N2CCQ6-D3F0tmOR.js} +1 -1
- package/web/assets/swimlanesDiagram-ULZ7WXOC-C3faa0-8.js +8 -0
- package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-D5nVBF4q.js +8 -0
- package/web/assets/{timeline-definition-24CTP7MA-KN7RSRVM-DCu4MVvb.js → timeline-definition-24CTP7MA-KN7RSRVM-C0Ufqqk-.js} +1 -1
- package/web/assets/{timeline-definition-Z64GVDOM-DEFnQeMY.js → timeline-definition-Z64GVDOM-81O3UI2y.js} +1 -1
- package/web/assets/{vennDiagram-4TSXK5OY-AKJ7LXAN-Bi1vBY1O.js → vennDiagram-4TSXK5OY-AKJ7LXAN-Cwa7TjWJ.js} +1 -1
- package/web/assets/{vennDiagram-T6HMQDX7-Wls_-1IU.js → vennDiagram-T6HMQDX7-BfOTIcvk.js} +1 -1
- package/web/assets/{wardleyDiagram-T6FBY63Y-BSjNiv26.js → wardleyDiagram-T6FBY63Y-CYCyu4_S.js} +1 -1
- package/web/assets/{wardleyDiagram-VM6X3IG4-3B6A3BN5-BWtS3yVZ.js → wardleyDiagram-VM6X3IG4-3B6A3BN5-CHXrbpNv.js} +1 -1
- package/web/assets/{xychartDiagram-ELKLHX3M-B5qgODUp.js → xychartDiagram-ELKLHX3M-7mp6PB7p.js} +1 -1
- package/web/assets/{xychartDiagram-S5SC5T6Z-OBDNV6WG-j0XdC2zd.js → xychartDiagram-S5SC5T6Z-OBDNV6WG-Ch73fB_B.js} +1 -1
- package/web/index.html +3 -3
- package/web/pet.html +3 -3
- package/web/assets/channel-CWI530Vq.js +0 -1
- package/web/assets/classDiagram-DTDB5LWJ-LWRDKZ5K---3y6DiQ.js +0 -1
- package/web/assets/classDiagram-JCYQIIEL-CKDJ6TE8.js +0 -1
- package/web/assets/classDiagram-v2-JRS7N3AN-2BZHGRP2---3y6DiQ.js +0 -1
- package/web/assets/classDiagram-v2-OCEON4UE-CKDJ6TE8.js +0 -1
- package/web/assets/main-BBu4fQk-.js +0 -457
- package/web/assets/stateDiagram-v2-4QOOHH4V-LBBLA2WV-DLoWKuNC.js +0 -1
- package/web/assets/stateDiagram-v2-UEYNNEHI-C4uNy_P4.js +0 -1
- package/web/assets/swimlanesDiagram-ULZ7WXOC-Ch9trOTe.js +0 -8
- package/web/assets/swimlanesDiagram-VK2B7HYN-E6N4H5SY-DBYYfTTt.js +0 -8
- /package/web/assets/{index-C5s4t4ce.js → index-xynt7zMk.js} +0 -0
package/package.json
CHANGED
package/server.cjs
CHANGED
|
@@ -555090,9 +555090,10 @@ async function handleAgentChat(win, nodeId, userMessage, locale) {
|
|
|
555090
555090
|
onProposalCreated: (id, summary) => {
|
|
555091
555091
|
win?.send("chat:proposal", id, summary, "pending");
|
|
555092
555092
|
},
|
|
555093
|
-
onError: (msg) => win?.send("chat:error", msg),
|
|
555093
|
+
onError: (msg) => win?.send("chat:error", msg, nodeId),
|
|
555094
555094
|
// v0.2 parts 协议:把 reasoning/tool-start/tool-result/tool-error 透传给渲染层
|
|
555095
|
-
|
|
555095
|
+
// (v0.23 第二参带会话标识,旧接口用 nodeId 充当;第三参同)
|
|
555096
|
+
onPart: (part) => win?.send("chat:part", part, nodeId, nodeId)
|
|
555096
555097
|
},
|
|
555097
555098
|
controller.signal,
|
|
555098
555099
|
locale
|
|
@@ -555101,7 +555102,7 @@ async function handleAgentChat(win, nodeId, userMessage, locale) {
|
|
|
555101
555102
|
history2.push({ role: "assistant", content: reply });
|
|
555102
555103
|
saveChatHistory(db, nodeId, history2);
|
|
555103
555104
|
markDirty();
|
|
555104
|
-
win?.send("chat:done", reply, {});
|
|
555105
|
+
win?.send("chat:done", reply, {}, nodeId);
|
|
555105
555106
|
return reply;
|
|
555106
555107
|
}
|
|
555107
555108
|
function abortAgentChat(nodeId) {
|
|
@@ -555205,8 +555206,9 @@ ${s}` : s;
|
|
|
555205
555206
|
onProposalCreated: (id, summary) => {
|
|
555206
555207
|
win?.send("chat:proposal", id, summary, "pending");
|
|
555207
555208
|
},
|
|
555208
|
-
onError: (msg) => win?.send("chat:error", msg),
|
|
555209
|
-
|
|
555209
|
+
onError: (msg) => win?.send("chat:error", msg, threadId),
|
|
555210
|
+
// v0.23: part 带 threadId(渲染层按 thread 分发)+focusNodeId(地图球后台指示)
|
|
555211
|
+
onPart: (part) => win?.send("chat:part", part, threadId, focusNodeId)
|
|
555210
555212
|
},
|
|
555211
555213
|
controller.signal,
|
|
555212
555214
|
locale,
|
|
@@ -555223,7 +555225,7 @@ ${s}` : s;
|
|
|
555223
555225
|
win?.send("chat:done", reply, {
|
|
555224
555226
|
userMessageId: savedUserMsg.id,
|
|
555225
555227
|
assistantMessageId: savedAssistantMsg.id
|
|
555226
|
-
});
|
|
555228
|
+
}, threadId);
|
|
555227
555229
|
return reply;
|
|
555228
555230
|
}
|
|
555229
555231
|
function abortAgentChatThread(threadId) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r,j as h}from"./index-
|
|
1
|
+
import{r,j as h}from"./index-xynt7zMk.js";import{c as T,u as L,P as D}from"./main-CGE6fm01.js";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as s,j as t}from"./index-
|
|
1
|
+
import{r as s,j as t}from"./index-xynt7zMk.js";import{c as y,u as v,b as k,L as j,F as N,M as w,G as C,T as M,d as _}from"./main-CGE6fm01.js";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as u,j as t}from"./index-
|
|
1
|
+
import{r as u,j as t}from"./index-xynt7zMk.js";import{c as C,U as I,u as y,a as L,d as S,X as N,g as M,T as E,C as R}from"./main-CGE6fm01.js";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as o,k as U,j as e,c as ie}from"./index-
|
|
1
|
+
import{r as o,k as U,j as e,c as ie}from"./index-xynt7zMk.js";import{c as te,u as ce,a as j,l as de,T as z,p as Y,L as V,k as oe,X as xe}from"./main-CGE6fm01.js";import{R as G}from"./rotate-ccw-natFwqj6.js";import{A as q}from"./arrow-right-D4GV0Gpo.js";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-
|
|
2
|
-
import{u as v,_ as d,B as _}from"./main-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-DkjixD09.js","./index-CU6ublfJ.js","./index-xynt7zMk.js","./index-DjoBjasB.css","./index-H1bePBGl.js","./transform-CzGDKG_M.js","./min-tv6RD-6E.js","./ordinal-Cboi1Yqb.js","./init-Gi6I4Gst.js","./colors-Cc3OSVma.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as v,_ as d,B as _}from"./main-CGE6fm01.js";import{r as o,j as a}from"./index-xynt7zMk.js";import{C as w}from"./CanvasStage-Ba-21anG.js";function b(c){const e=[];let t=null,n=0;for(const r of c.split(`
|
|
3
3
|
`)){const s=/^(\s*)(`{3,}|~{3,})/.exec(r);if(t==null){if(s){t=(s[2]??"")[0]??"`",n=(s[2]??"").length,e.push(`${s[1]??""}- 代码块`);continue}e.push(r)}else new RegExp(`^\\s*\\${t==="~"?"~":"`"}{${n},}\\s*$`).test(r)&&(t=null)}return e.join(`
|
|
4
|
-
`).replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/<!--[\s\S]*?-->/g,"")}function E(){if(typeof document>"u")return["#58cc02","#1cb0f6","#ffc800","#a67cd8","#ff7a00"];const c=getComputedStyle(document.documentElement),e=(t,n)=>{const r=c.getPropertyValue(t).trim();return r?`rgb(${r})`:n};return[e("--brand-rgb","#58cc02"),e("--accent-rgb","#1cb0f6"),e("--gold-rgb","#ffc800"),"#a67cd8",e("--warning-rgb","#ff7a00")]}function P({markdown:c}){const e=v(),t=o.useRef(null),n=o.useRef(null),[r,s]=o.useState(!1),i=b(c);return o.useEffect(()=>{let l=!1;return(async()=>{try{const[{Transformer:p},{Markmap:g}]=await Promise.all([d(()=>import("./index-
|
|
4
|
+
`).replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/<!--[\s\S]*?-->/g,"")}function E(){if(typeof document>"u")return["#58cc02","#1cb0f6","#ffc800","#a67cd8","#ff7a00"];const c=getComputedStyle(document.documentElement),e=(t,n)=>{const r=c.getPropertyValue(t).trim();return r?`rgb(${r})`:n};return[e("--brand-rgb","#58cc02"),e("--accent-rgb","#1cb0f6"),e("--gold-rgb","#ffc800"),"#a67cd8",e("--warning-rgb","#ff7a00")]}function P({markdown:c}){const e=v(),t=o.useRef(null),n=o.useRef(null),[r,s]=o.useState(!1),i=b(c);return o.useEffect(()=>{let l=!1;return(async()=>{try{const[{Transformer:p},{Markmap:g}]=await Promise.all([d(()=>import("./index-DkjixD09.js"),__vite__mapDeps([0,1,2,3]),import.meta.url),d(()=>import("./index-H1bePBGl.js"),__vite__mapDeps([4,1,5,6,7,8,9]),import.meta.url)]),u=t.current;if(!u||l)return;if(!n.current){const f=E();n.current=g.create(u,{autoFit:!1,duration:0,pan:!1,zoom:!1,initialExpandLevel:2,maxWidth:260,spacingVertical:10,spacingHorizontal:96,paddingX:12,color:h=>{var m;return f[(((m=h.state)==null?void 0:m.depth)??0)%f.length]??f[0]}})}const{root:x}=new p().transform(i);n.current.setData(x),n.current.fit()}catch{l||s(!0)}})(),()=>{l=!0}},[i]),r?a.jsxs("div",{className:"text-body text-ink-muted flex items-center gap-2 my-4",children:[a.jsx(_,{className:"w-4 h-4"}),e("notebook.content.render_failed")]}):a.jsx("div",{"data-testid":"mindmap-view",className:"mindmap-view h-[68vh] min-h-[420px] my-2",children:a.jsx(w,{grid:!0,testid:"mindmap-stage",children:a.jsx("div",{className:"w-[1280px] h-[760px]",children:a.jsx("svg",{ref:t,className:"w-full h-full block"})})})})}export{P as MindmapView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as e,c as S}from"./index-
|
|
1
|
+
import{r,j as e,c as S}from"./index-xynt7zMk.js";import{u as y,a as j,S as M}from"./main-CGE6fm01.js";function A({tree:c,onReviewNode:d,progressMap:n}){const s=y(),[x,m]=r.useState([]),[u,f]=r.useState(!0),[l,v]=r.useState(null);r.useEffect(()=>{j.getAllSrsItems().then(t=>m(t)).catch(()=>m([])).finally(()=>f(!1))},[]);const N=r.useMemo(()=>new Map(c.map(t=>[t.id,t])),[c]),p=r.useMemo(()=>new Set(x.filter(t=>t.overdue).map(t=>t.nodeId)),[x]),i=r.useMemo(()=>{const t=c.filter(b=>{var w;const o=(w=n[b.id])==null?void 0:w.status;return b.type==="lesson"&&(o==="in_progress"||o==="mastered")}),a=new Map;for(const b of t){const o=b.parentId??"(root)";a.has(o)||a.set(o,[]),a.get(o).push(b)}return a},[c,n]),g=r.useMemo(()=>Array.from(i.values()).flat().filter(t=>p.has(t.id)).length,[i,p]),h=r.useMemo(()=>Array.from(i.values()).flat(),[i]);if(r.useEffect(()=>{if(i.size>0&&(!l||!i.has(l))){const t=i.keys().next().value;t&&v(t)}},[i,l]),u)return e.jsxs("div",{className:"text-center py-12 text-body text-ink-muted flex items-center justify-center gap-2",children:[e.jsx("span",{className:"typing-dot w-1.5 h-1.5 bg-brand rounded-full inline-block"}),s("review.loading")]});if(h.length===0)return e.jsxs("div",{className:"text-center py-16","data-testid":"review-empty",children:[e.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"📖"}),e.jsx("div",{className:"text-body text-ink-muted",children:s("review.empty.title")}),e.jsx("div",{className:"text-label text-ink-faint mt-1",children:s("review.empty.desc")})]});const k=t=>{var a;return((a=N.get(t))==null?void 0:a.title)??t};return e.jsxs("div",{className:"p-5 max-w-2xl mx-auto","data-testid":"review-panel",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-title font-extrabold text-ink-strong",children:s("review.title")}),g>0&&e.jsxs("span",{className:"text-label font-bold text-review","data-testid":"review-due-count",children:[g," ",s("review.due.count")]})]}),e.jsxs("button",{onClick:()=>{const t=h[Math.floor(Math.random()*h.length)];t&&d(t.id)},"data-testid":"review-interleave",className:"btn-3d-neutral w-full py-2.5 text-body mb-5 flex items-center justify-center gap-1.5",children:[e.jsx(M,{className:"w-4 h-4"}),s("review.interleave")]}),e.jsx("div",{className:"text-label font-bold text-ink-muted mb-2",children:s("review.selectSection")}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:Array.from(i.entries()).map(([t,a])=>e.jsxs("button",{onClick:()=>v(t),className:`px-2.5 py-1 rounded-full text-label font-bold transition-colors ${l===t?"bg-brand/15 text-brand ring-1 ring-brand/30":"bg-surface-3 text-ink-muted hover:text-ink-strong"}`,children:[k(t),e.jsxs("span",{className:"ml-1 opacity-60",children:["(",a.length,")"]})]},t))}),l&&i.has(l)&&e.jsx("div",{className:"space-y-1.5","data-testid":"review-lesson-list",children:i.get(l).map(t=>{const a=p.has(t.id);return e.jsxs("div",{className:`flex items-center justify-between gap-2 p-2.5 rounded-lg transition-colors ${a?"bg-review/8 ring-1 ring-review/20":"bg-surface-3 hover:bg-surface-3/80"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 truncate flex-1",children:[a&&e.jsx("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full bg-review"}),e.jsx("span",{className:"text-body text-ink-strong truncate",children:t.title})]}),e.jsx("button",{onClick:()=>d(t.id),"data-testid":`review-lesson-${t.id.slice(0,8)}`,className:"shrink-0 px-3 py-1 rounded-lg bg-brand/15 text-brand text-label font-bold hover:bg-brand/25 transition-colors",children:s("review.reviewLesson")})]},t.id)})})]})}function E({nodeId:c,onRated:d}){const n=y(),[s,x]=r.useState(!1),[m,u]=r.useState(!1),f=async l=>{if(!(s||m)){x(!0);try{await j.recordReview(c,l),u(!0),d==null||d(),S(l>=4?"correct":"wrong")}catch{}finally{x(!1)}}};return m?e.jsx("div",{className:"text-center text-body text-brand py-2","data-testid":"self-rated",children:n("review.selfrated")}):e.jsxs("div",{className:"border-t border-[var(--border-faint)] pt-3 mt-3","data-testid":"self-rating",children:[e.jsx("div",{className:"text-caption font-bold text-ink-muted uppercase tracking-wider mb-2 text-center",children:n("review.selfrate.title")}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:()=>f(1),disabled:s,"data-testid":"rate-again",className:"py-2 rounded-lg border border-warning/40 text-warning hover:bg-warning/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:n("review.selfrate.again")}),e.jsx("span",{className:"text-caption opacity-70",children:n("review.selfrate.again.hint")})]}),e.jsxs("button",{onClick:()=>f(4),disabled:s,"data-testid":"rate-remembered",className:"py-2 rounded-lg border border-accent/40 text-accent hover:bg-accent/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:n("review.selfrate.remembered")}),e.jsx("span",{className:"text-caption opacity-70",children:n("review.selfrate.remembered.hint")})]}),e.jsxs("button",{onClick:()=>f(5),disabled:s,"data-testid":"rate-mastered",className:"py-2 rounded-lg border border-brand/40 text-brand hover:bg-brand/10 transition-colors disabled:opacity-40 flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:"text-body font-bold",children:n("review.selfrate.mastered")}),e.jsx("span",{className:"text-caption opacity-70",children:n("review.selfrate.mastered.hint")})]})]})]})}export{A as ReviewPanel,E as SelfRatingCard};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{r as a,j as e,s as Qe,h as Ze,C as et,M as tt}from"./index-
|
|
1
|
+
import{r as a,j as e,s as Qe,h as Ze,C as et,M as tt}from"./index-xynt7zMk.js";import{c as st,u as de,h as ne,i as he,a as i,W as $e,P as nt,j as ze,s as at,k as it,l as lt,m as ot,n as dt,o as ct}from"./main-CGE6fm01.js";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const rt=st("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"}]]),xe="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 ke({kind:s,showProtocol:x=!0,testPrefix:b="custom",titleKey:p="settings.custom.form_title",modelPhKey:r="settings.custom.model_ph",testOverride:d,onSaved:c,onCancel:g}){const m=de(),[j,T]=a.useState(""),[h,S]=a.useState("openai-compatible"),[y,P]=a.useState(""),[o,_]=a.useState(""),[w,K]=a.useState(""),[B,V]=a.useState(!1),[I,D]=a.useState(!1),[A,z]=a.useState(null),L=async()=>{if(!(!y.trim()||!w.trim()||I)){D(!0),z(null);try{const l=d?await d({baseUrl:y.trim(),apiKey:o.trim(),model:w.trim()}):await i.testCustomProvider({label:j||m("settings.custom.test_label"),protocol:h,baseUrl:y.trim(),apiKey:o.trim()||void 0,defaultModel:w.trim()});z({ok:l.ok,detail:l.detail})}catch(l){z({ok:!1,detail:l instanceof Error?l.message:String(l)})}finally{D(!1)}}},N=async()=>{if(!(!j.trim()||!y.trim()||!w.trim()))try{const l=await i.createCustomProvider({label:j.trim(),kind:s,protocol:x?h:"openai-compatible",baseUrl:y.trim(),apiKey:o.trim()||void 0,defaultModel:w.trim(),vision:s==="llm"?B:void 0});c(l)}catch{}};return e.jsxs("div",{className:"space-y-2.5","data-testid":`${b}-provider-form`,children:[e.jsx("div",{className:"text-label font-bold text-ink-strong",children:m(p)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:j,onChange:l=>T(l.target.value),placeholder:m("settings.custom.label_ph"),"data-testid":`${b}-label`,className:`${xe} flex-1 px-2.5 py-1.5`}),x&&e.jsxs("select",{value:h,onChange:l=>S(l.target.value),"data-testid":`${b}-protocol`,className:`${xe} px-2 py-1.5`,children:[e.jsx("option",{value:"openai-compatible",children:m("settings.proto.openai")}),e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"google",children:"Google"})]})]}),e.jsx("input",{type:"text",value:y,onChange:l=>P(l.target.value),placeholder:m("settings.custom.baseurl_ph"),"data-testid":`${b}-baseurl`,className:`${xe} w-full px-2.5 py-1.5 font-mono`}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:w,onChange:l=>K(l.target.value),placeholder:m(r),"data-testid":`${b}-model`,className:`${xe} flex-1 px-2.5 py-1.5 font-mono`}),e.jsx("input",{type:"password",value:o,onChange:l=>_(l.target.value),placeholder:m("settings.custom.apikey_ph"),"data-testid":`${b}-apikey`,className:`${xe} flex-1 px-2.5 py-1.5`})]}),s==="llm"&&e.jsxs("label",{className:"inline-flex items-center gap-2 text-label cursor-pointer select-none","data-testid":`${b}-vision`,children:[e.jsx("input",{type:"checkbox",checked:B,onChange:l=>V(l.target.checked),className:"w-4 h-4 rounded accent-brand"}),e.jsx("span",{className:"text-ink-strong",children:m("settings.custom.vision")}),e.jsx("span",{className:"text-ink-faint",children:m("settings.custom.visionHint")})]}),A&&e.jsxs("div",{className:`text-label rounded p-2 inline-flex items-start gap-1.5 ${A.ok?"bg-brand/10 text-brand":"bg-warning/10 text-warning"}`,children:[A.ok?e.jsx(ne,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}):e.jsx(ge,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"break-words",children:A.detail})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>void L(),disabled:!y.trim()||!w.trim()||I,"data-testid":`${b}-test`,className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:m(I?"settings.testing":"settings.test")}),e.jsx("button",{onClick:()=>void N(),disabled:!j.trim()||!y.trim()||!w.trim(),"data-testid":`${b}-save`,className:"btn-3d-brand px-3 py-1.5 text-label disabled:opacity-40",children:m("settings.custom.save")}),g&&e.jsx("button",{onClick:g,className:"text-label text-ink-muted hover:text-ink-strong px-3 py-1.5 transition-colors",children:m("action.cancel")})]})]})}const Ke="lookatstudy-theme",We="auto",Ue="(prefers-color-scheme: dark)";function _e(){return typeof window>"u"||window.matchMedia(Ue).matches?"dark":"light"}function mt(){if(typeof localStorage>"u")return We;const s=localStorage.getItem(Ke);return s==="auto"||s==="light"||s==="dark"?s:We}function Ce(s){const x=document.documentElement;x.classList.remove("dark","light"),x.classList.add(s),window.dispatchEvent(new CustomEvent("theme-changed",{detail:{resolved:s}}))}function ut(){const[s,x]=a.useState(()=>mt()),[b,p]=a.useState(()=>s==="auto"?_e():s),r=a.useCallback(d=>{x(d),localStorage.setItem(Ke,d);const c=d==="auto"?_e():d;p(c),Ce(c)},[]);return a.useEffect(()=>{if(s!=="auto")return;const d=window.matchMedia(Ue),c=g=>{const m=g.matches?"dark":"light";p(m),Ce(m)};return d.addEventListener("change",c),()=>d.removeEventListener("change",c)},[s]),a.useEffect(()=>{const d=s==="auto"?_e():s;p(d),Ce(d)},[s]),{mode:s,resolved:b,setMode:r}}function we(){window.dispatchEvent(new Event(ct))}const G="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",F="bg-surface-3 text-ink-muted hover:bg-surface-3 hover:bg-surface-3 hover:text-ink-strong",R="bg-brand text-white shadow-sm";function v(s){return s?"px-4 py-3.5 border-t border-[var(--border-faint)]":"px-4 py-3.5"}function yt(){const s=de(),[x,b]=a.useState([]),[p,r]=a.useState([]),[d,c]=a.useState("glm"),[g,m]=a.useState(""),[j,T]=a.useState(""),[h,S]=a.useState(null),[y,P]=a.useState(!1),[o,_]=a.useState(null),[w,K]=a.useState(!1),[B,V]=a.useState(!1),[I,D]=a.useState([]),[A,z]=a.useState(!1),[L,N]=a.useState(null),[l,H]=a.useState(null),[Z,ce]=a.useState(""),[he,re]=a.useState(!1),ee=ut(),ie=async n=>{if($)try{await i.updateCustomProvider($.id,{vision:n}),await U()}catch{}},le=async()=>{z(!0),N(null);try{const n=await i.discoverModels();n.ok&&n.models?D(n.models):N(n.error||s("settings.discover_failed"))}catch(n){N(n instanceof Error?n.message:String(n))}finally{z(!1)}},U=a.useCallback(async()=>{try{const[n,f,E,J]=await Promise.all([i.getProviderPresets(),i.listCustomProviders(),i.getSetting("active_provider"),i.getSetting("active_model")]);b(n),r(f);const M=E??"glm";if(c(M),M.startsWith("custom-")){const k=f.find(C=>C.id===M);S(k!=null&&k.hasApiKey?s("settings.key.configured"):null)}else{const k=n.find(C=>C.id===M);if(k){const C=await i.getSetting(k.apiKeySetting);S(C?`${C.slice(0,4)}…${C.slice(-4)}`:null)}}if(M.startsWith("custom-")){const k=f.find(C=>C.id===M);m(J??(k==null?void 0:k.defaultModel)??"")}else{const k=n.find(C=>C.id===M);m(J??(k==null?void 0:k.defaultModel)??"")}}catch(n){console.error("[SettingsView] load() failed:",n)}},[s]);a.useEffect(()=>{U()},[U]);const me=async n=>{c(n),_(null),T("");const f=x.find(E=>E.id===n);if(f){const E=await i.getSetting(f.apiKeySetting);S(E?`${E.slice(0,4)}…${E.slice(-4)}`:null),m(g||f.defaultModel)}},pe=async()=>{K(!1);try{if(await i.setSetting("active_provider",d),await i.setSetting("active_model",g),j.trim()){const n=x.find(f=>f.id===d);n&&(await i.setSetting(n.apiKeySetting,j.trim()),S(`${j.trim().slice(0,4)}…${j.trim().slice(-4)}`),T(""))}K(!0),setTimeout(()=>K(!1),2e3),window.dispatchEvent(new Event("llm-config-changed"))}catch{}},O=async()=>{P(!0),_(null);try{const n=await i.testLlmConnection();_(n)}catch(n){_({ok:!1,detail:n instanceof Error?n.message:String(n),errorKind:"unknown"})}finally{P(!1)}},fe=async n=>{await i.setSetting("active_provider",n.id),await i.setSetting("active_model",n.defaultModel),c(n.id),m(n.defaultModel),V(!1),await U(),window.dispatchEvent(new Event("llm-config-changed"))},te=async n=>{try{await i.deleteCustomProvider(n),d===n&&(await i.setSetting("active_provider","glm"),c("glm")),await U()}catch{}},$=d.startsWith("custom-")?p.find(n=>n.id===d):null;a.useEffect(()=>{if(!$)return;const n=$.models.find(f=>f.id===g);ce(n!=null&&n.contextWindow?String(n.contextWindow):"")},[$,g]);const be=async()=>{var M,k;if(!$)return;const n=Z.trim().replace(/[,\s_]/g,""),f=/^(\d+)([km]?)$/i.exec(n);if(n!==""&&!f)return;const E=((M=f==null?void 0:f[2])==null?void 0:M.toLowerCase())==="k"?1e3:((k=f==null?void 0:f[2])==null?void 0:k.toLowerCase())==="m"?1e6:1,J=n===""||!f?null:Math.max(1,Math.round(parseInt(f[1],10)*E));re(!0);try{const C=$.models.map(q=>q.id===g?{...q,contextWindow:J}:q);await i.updateCustomProvider($.id,{models:C}),await U(),window.dispatchEvent(new Event("llm-config-changed"))}catch{}finally{re(!1)}},Y=d.startsWith("custom-")?null:x.find(n=>n.id===d);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:s("settings.group.ai")}),e.jsxs("div",{className:"surface-card overflow-hidden",children:[e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:s("settings.row.provider")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5","data-testid":"provider-grid",children:[x.map(n=>e.jsx("button",{onClick:()=>me(n.id),"data-testid":`provider-card-${n.id}`,"aria-pressed":d===n.id,className:`px-3 py-1.5 rounded-lg text-label font-medium whitespace-nowrap transition-colors ${d===n.id?R:F}`,children:n.label},n.id)),p.filter(n=>n.kind==="llm").map(n=>e.jsxs("button",{onClick:()=>me(n.id),"data-testid":`provider-card-${n.id}`,"aria-pressed":d===n.id,className:`px-3 py-1.5 rounded-lg text-label font-medium whitespace-nowrap transition-colors inline-flex items-center gap-1 ${d===n.id?R:F}`,children:[e.jsx($e,{className:"w-3.5 h-3.5","aria-hidden":"true"}),n.label]},n.id)),e.jsxs("button",{onClick:()=>V(n=>!n),"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(nt,{className:"w-3.5 h-3.5","aria-hidden":"true"}),s("settings.add_custom")]})]})]}),B&&e.jsx("div",{className:"px-4 py-3.5 bg-surface-1 border-t border-[var(--border-faint)]",children:e.jsx(ke,{kind:"llm",testPrefix:"custom",onSaved:n=>void fe(n),onCancel:()=>V(!1)})}),p.length>0&&d.startsWith("custom-")&&e.jsx("div",{className:v(!0),children:e.jsx("button",{onClick:n=>{const f=n.currentTarget.getBoundingClientRect(),E=p.find(J=>J.id===d);E&&H({id:E.id,label:E.label,rect:f})},className:"text-label text-warning hover:underline",children:s("settings.delete_custom")})}),Y&&e.jsxs(e.Fragment,{children:[Y.baseUrl&&e.jsxs("div",{className:v(!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:Y.baseUrl})]}),e.jsxs("div",{className:v(!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:s("settings.model")}),e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[e.jsxs("select",{value:g,onChange:n=>m(n.target.value),"data-testid":"model-select",className:`${G} flex-1 px-2.5 py-1.5`,children:[Y.models.map(n=>e.jsx("option",{value:n.id,children:n.id},n.id)),d==="openrouter"&&I.map(n=>e.jsx("option",{value:n.id,children:n.id},n.id))]}),d==="openrouter"&&e.jsxs("button",{onClick:le,disabled:A,"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(rt,{className:`w-3.5 h-3.5 ${A?"animate-spin":""}`,"aria-hidden":"true"}),s(A?"settings.discovering":"settings.refresh")]})]})]}),L&&e.jsx("div",{className:"text-label text-warning mt-1.5 ml-[68px]",children:L})]}),e.jsx("div",{className:v(!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:s("settings.apikey")}),e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[h&&e.jsxs("span",{className:"text-label text-brand shrink-0 inline-flex items-center gap-1",children:[e.jsx(ne,{className:"w-3.5 h-3.5","aria-hidden":"true"}),h]}),e.jsx("input",{type:"password",value:j,onChange:n=>T(n.target.value),placeholder:s(h?"settings.key.overwrite_ph":"settings.key.paste_ph"),"data-testid":"settings-key-input",className:`${G} flex-1 px-2.5 py-1.5`}),e.jsx("a",{href:Y.keyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-label text-brand hover:underline whitespace-nowrap",children:s("settings.key.get")})]})]})}),e.jsx("div",{className:v(!0),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:O,disabled:y,"data-testid":"test-connection-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:s(y?"settings.testing":"settings.test")}),o&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${o.ok?"text-brand":"text-warning"}`,children:[o.ok?e.jsx(ne,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(ge,{className:"w-4 h-4","aria-hidden":"true"}),o.detail]})]})})]}),$&&!Y&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:v(!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:$.baseUrl})]}),e.jsx("div",{className:v(!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:s("settings.model")}),$.models.length>1?e.jsx("select",{value:g,onChange:n=>m(n.target.value),"data-testid":"model-select-custom",className:`${G} flex-1 px-2.5 py-1.5`,children:$.models.map(n=>e.jsx("option",{value:n.id,children:n.id},n.id))}):e.jsx("input",{type:"text",value:g,onChange:n=>m(n.target.value),placeholder:s("settings.custom.model_ph"),"data-testid":"model-input-custom",className:`${G} flex-1 px-2.5 py-1.5 font-mono`})]})}),e.jsxs("div",{className:v(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:s("settings.custom.windowLabel")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",inputMode:"numeric",value:Z,onChange:n=>ce(n.target.value),placeholder:s("settings.custom.windowPh"),"data-testid":"context-window-input",className:`${G} flex-1 px-2.5 py-1.5 font-mono tabular-nums`}),e.jsx("button",{onClick:be,disabled:he,"data-testid":"context-window-save",className:"btn-3d-neutral px-3 py-1.5 text-label shrink-0 disabled:opacity-40",children:s("settings.custom.save")})]}),e.jsx("div",{className:"text-caption text-ink-faint mt-1",children:s("settings.custom.windowHint")})]}),e.jsx("div",{className:v(!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:$.vision,onChange:n=>void ie(n.target.checked),className:"w-4 h-4 rounded accent-brand"}),e.jsx("span",{className:"text-ink-strong",children:s("settings.custom.vision")}),e.jsx("span",{className:"text-ink-faint",children:s("settings.custom.visionHint")})]})}),e.jsx("div",{className:v(!0),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:O,disabled:y,"data-testid":"test-connection-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:s(y?"settings.testing":"settings.test")}),o&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${o.ok?"text-brand":"text-warning"}`,children:[o.ok?e.jsx(ne,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(ge,{className:"w-4 h-4","aria-hidden":"true"}),o.detail]})]})})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:s("settings.group.vision")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(gt,{activeProvider:d,activeModel:g,presets:x,customProviders:p})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:s("settings.group.speech")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(vt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:s("settings.group.memory")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(ht,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:s("settings.group.companion")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(pt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:s("settings.group.appearance")}),e.jsxs("div",{className:"surface-card overflow-hidden",children:[e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:s("settings.row.theme")}),e.jsx("div",{className:"flex gap-2",children:[{mode:"auto",label:s("settings.theme.auto")},{mode:"light",label:s("settings.theme.light")},{mode:"dark",label:s("settings.theme.dark")}].map(({mode:n,label:f})=>e.jsx("button",{onClick:()=>ee.setMode(n),"data-testid":`theme-${n}`,"aria-pressed":ee.mode===n,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${ee.mode===n?R:F}`,children:f},n))}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:ee.mode==="auto"?s("settings.theme.following",{mode:s(`settings.theme.${ee.resolved}`)}):null})]}),e.jsxs("div",{className:v(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:s("settings.row.interface_lang")}),e.jsx("div",{className:"flex gap-2",children:["zh-CN","en"].map(n=>e.jsx("button",{onClick:()=>at(n),"data-testid":`lang-${n}`,"aria-pressed":ze()===n,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${ze()===n?R:F}`,children:n==="zh-CN"?"中文":"English"},n))})]}),e.jsxs("div",{className:v(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:s("settings.row.import_lang")}),e.jsx(xt,{})]})]})]})]}),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:s("settings.footer.hint")}),e.jsxs("button",{onClick:pe,"data-testid":"settings-save",className:"btn-3d-brand px-5 py-2 text-body inline-flex items-center gap-1.5",children:[w&&e.jsx(it,{className:"w-4 h-4","aria-hidden":"true"}),s(w?"settings.saved_text":"settings.footer.save")]})]}),l&&e.jsx(lt,{anchorRect:l.rect,message:s("settings.delete_custom_confirm",{name:l.label}),danger:!0,confirmLabel:s("action.delete"),testid:"custom-provider-delete-confirm",onConfirm:()=>{te(l.id),H(null)},onCancel:()=>H(null)})]})}function xt(){const[s,x]=a.useState("en"),[b,p]=a.useState(!1);a.useEffect(()=>{i.getSetting("pref_lang").then(c=>{c&&x(c),p(!0)})},[]);const r=async c=>{x(c),await i.setSetting("pref_lang",c)},d=[{code:"en",label:"English"},{code:"zh-CN",label:"简体中文"},{code:"zh-TW",label:"繁體中文"}];return b?e.jsx("div",{className:"flex gap-2","data-testid":"pref-lang-options",children:d.map(c=>e.jsx("button",{onClick:()=>r(c.code),"data-testid":`pref-lang-${c.code}`,"aria-pressed":s===c.code,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${s===c.code?R:F}`,children:c.label},c.code))}):null}function gt({activeProvider:s,activeModel:x,presets:b,customProviders:p}){const r=de(),[d,c]=a.useState(!1),[g,m]=a.useState(!1),[j,T]=a.useState(""),[h,S]=a.useState(!1),[y,P]=a.useState(!1),[o,_]=a.useState(null),[w,K]=a.useState(!1);a.useEffect(()=>{Promise.all([i.getSetting("flag_multimodal_import"),i.getSetting("vision_provider_override"),i.getSetting("vision_model_override"),i.getSetting("flag_math_vision")]).then(([l,H,Z])=>{c(l==="true"),T(H??""),K(Z==="true"),m(!0)})},[]);const B=async()=>{const l=!d;c(l),await i.setSetting("flag_multimodal_import",String(l))},V=async()=>{const l=!w;K(l),await i.setSetting("flag_math_vision",String(l))},I=async l=>{await i.setSetting("vision_provider_override",l.id),await i.setSetting("vision_model_override",l.defaultModel),T(l.id),S(!1)},D=async()=>{await i.setSetting("vision_provider_override",""),await i.setSetting("vision_model_override",""),T(""),S(!1)},A=async()=>{if(!y){P(!0),_(null);try{const l=await i.testLlmConnection({vision:!0});_({ok:l.ok,detail:l.detail})}catch(l){_({ok:!1,detail:l instanceof Error?l.message:String(l)})}finally{P(!1)}}},z=p.filter(l=>l.kind==="vision"),L=j.startsWith("custom-")?p.find(l=>l.id===j):null,N=j&&!j.startsWith("custom-")?b.find(l=>l.id===j):null;return g?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(ae,{checked:d,onChange:B,label:r("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:r("settings.multimodal.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:r("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:r("settings.multimodal.current_model",{model:x||r("settings.multimodal.not_selected")})}),e.jsx("div",{children:s.startsWith("custom-")?r("settings.multimodal.hint_custom"):r("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:r("settings.multimodal.override_title")}),e.jsx("div",{className:"text-caption text-ink-muted mb-2",children:r("settings.multimodal.override_bridge_hint")}),e.jsxs("div",{className:"space-y-3 mt-1",children:[L&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx($e,{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:L.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:L.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:L.baseUrl})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{onClick:()=>void A(),disabled:y,"data-testid":"vision-override-test",className:"btn-3d-neutral px-4 py-1.5 text-label disabled:opacity-50",children:r(y?"settings.testing":"settings.multimodal.test_override")}),e.jsx("button",{onClick:()=>S(l=>!l),className:"text-label text-accent hover:underline",children:r("settings.multimodal.replace_custom")}),e.jsx("button",{onClick:()=>void D(),className:"text-label text-ink-muted hover:text-ink-strong",children:r("settings.multimodal.stop_override")}),o&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${o.ok?"text-brand":"text-warning"}`,children:[o.ok?e.jsx(ne,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(ge,{className:"w-4 h-4","aria-hidden":"true"}),o.detail]})]})]}),N&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx("span",{className:"text-ink-muted",children:r("settings.multimodal.legacy_preset",{label:N.label})}),e.jsx("button",{onClick:()=>void D(),className:"text-label text-ink-muted hover:text-ink-strong underline",children:r("settings.multimodal.stop_override")})]}),!L&&!N&&e.jsxs(e.Fragment,{children:[z.map(l=>e.jsxs("button",{onClick:()=>void I(l),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`vision-pick-${l.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:l.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:l.defaultModel})]},l.id)),(h||z.length===0)&&e.jsx(ke,{kind:"vision",testPrefix:"vision-custom",titleKey:"settings.custom.form_title_vision",modelPhKey:"settings.custom.model_ph_vision",onSaved:l=>void I(l),onCancel:()=>S(!1)}),z.length>0&&e.jsx("button",{onClick:()=>S(l=>!l),className:"text-label text-accent hover:underline",children:r(h?"action.cancel":"settings.custom.new")})]})]})]}),e.jsxs("div",{className:"bg-ink/5 rounded-lg p-3 flex items-center gap-3",children:[e.jsx(ae,{checked:w,onChange:V,label:r("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:r("settings.mathvision.toggle")}),e.jsx("div",{className:"text-caption text-ink-muted",children:r("settings.mathvision.desc")})]})]})]})]}):null}function ht(){const s=de(),[x,b]=a.useState(!1),[p,r]=a.useState(!1);a.useEffect(()=>{i.getSetting("flag_memory_system").then(c=>{b(c==="true"),r(!0)})},[]);const d=async()=>{const c=!x;b(c),await i.setSetting("flag_memory_system",String(c))};return p?e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(ae,{checked:x,onChange:d,label:s("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:s("settings.memory.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:s("settings.memory.toggle.desc")})]})]}):null}function pt(){const s=de(),[x,b]=a.useState(!0),[p,r]=a.useState(!1),d=a.useSyncExternalStore(Qe,Ze),[c,g]=a.useState(!0),[m,j]=a.useState(!1),T=typeof window<"u"&&!!window.__lookatstudyWeb;a.useEffect(()=>{i.getSetting("companion_enabled").then(o=>{b(o!=="false"&&o!=="0"),r(!0)}),i.getSetting("companion_sfx").then(o=>{g(o!=="false"&&o!=="0")}),i.getSetting("companion_pet_mode").then(o=>{j(o==="1")})},[]);const h=async()=>{const o=!x;b(o),await i.setSetting("companion_enabled",String(o)),window.dispatchEvent(new Event("companion-config-changed"))},S=async()=>{const o=!c;g(o),await i.setSetting("companion_sfx",String(o)),window.dispatchEvent(new Event("companion-config-changed"))},y=async()=>{const o=!m;j(o),await i.setSetting("companion_pet_mode",o?"1":"0"),window.dispatchEvent(new Event("companion-config-changed"))},P=async o=>{o!==d.form&&(await i.setSetting("companion_form",o),window.dispatchEvent(new Event("companion-config-changed")))};return p?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(ae,{checked:x,onChange:h,label:s("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:s("settings.companion.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:s("settings.companion.toggle.desc")})]})]}),x&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ae,{checked:c,onChange:S,label:s("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:s("settings.companion.sfx")}),e.jsx("div",{className:"text-label text-ink-muted",children:s("settings.companion.sfx.desc")})]})]}),!T&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ae,{checked:m,onChange:y,label:s("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:s("settings.companion.pet")}),e.jsx("div",{className:"text-label text-ink-muted",children:s("settings.companion.pet.desc")})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-label text-ink-muted mb-2",children:s("settings.companion.form")}),e.jsx("div",{className:"grid grid-cols-5 gap-2",role:"radiogroup","aria-label":s("settings.companion.form"),children:et.map(o=>{const _=d.form===o;return e.jsxs("button",{type:"button",role:"radio","aria-checked":_,"data-testid":`companion-form-${o}`,onClick:()=>{P(o)},className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
|
|
7
|
-
${_?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,title:s(`companion.form.${o}.desc`),children:[e.jsx(tt,{form:o,expression:"happy",pose:"float",size:64}),e.jsx("span",{className:`text-label ${_?"text-ink-strong font-medium":"text-ink-muted"}`,children:s(`companion.form.${o}.name`)})]},o)})})]})]})]}):null}function ae({checked:s,onChange:x,label:b,testid:p}){return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":b,onClick:x,"data-testid":p,className:`relative w-12 h-6 rounded-full transition-colors shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/60 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface-2)] ${s?"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 ${s?"translate-x-6":""}`})})}const ft=[{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(女)"}],bt=[{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 vt(){const s=de(),[x,b]=a.useState([]),[p,r]=a.useState(null),[d,c]=a.useState(null),[g,m]=a.useState(null),[j,T]=a.useState(null),[h,S]=a.useState("edge"),[y,P]=a.useState("zh-CN-XiaoxiaoNeural"),[o,_]=a.useState("48"),[w,K]=a.useState("1.0"),[B,V]=a.useState(""),[I,D]=a.useState(""),[A,z]=a.useState([]),L=typeof window<"u"&&"speechSynthesis"in window,[N,l]=a.useState("local"),[H,Z]=a.useState("asr-whisper-turbo"),[ce,he]=a.useState(!0),[re,ee]=a.useState([]),[ie,le]=a.useState(!1),[U,me]=a.useState(!1),[pe,O]=a.useState(!1),[fe,te]=a.useState(!1),[$,be]=a.useState(!1),[Y,n]=a.useState(null),[f,E]=a.useState(!1),[J,M]=a.useState(null),[k,C]=a.useState(null),q=a.useCallback(()=>{i.listCustomProviders().then(t=>ee(t.filter(u=>u.kind==="tts"||u.kind==="asr"))).catch(()=>{})},[]);a.useEffect(()=>{Promise.all([i.getSetting("tts_engine"),i.getSetting("tts_voice_edge"),i.getSetting("tts_sid_local"),i.getSetting("tts_speed"),i.getSetting("tts_custom_voice"),i.getSetting("tts_system_voice"),i.getSetting("asr_engine"),i.getSetting("asr_local_model"),i.getSetting("asr_auto_stop")]).then(([t,u,W,X,ye,Pe,Ae,Se,Je])=>{t&&S(t),u&&P(u),W&&_(W),X&&K(X),ye&&V(ye),Pe&&D(Pe),Ae&&l(Ae),(Se==="asr-whisper-turbo"||Se==="asr-whisper-small")&&Z(Se),he(Je!=="0")}),q()},[q]),a.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const t=()=>z(dt(window.speechSynthesis.getVoices()));return t(),window.speechSynthesis.addEventListener("voiceschanged",t),()=>window.speechSynthesis.removeEventListener("voiceschanged",t)},[]);const ue=a.useCallback(()=>{window.api.getSpeechModelStatus().then(t=>b(t)).catch(()=>{})},[]);a.useEffect(()=>(ue(),window.api.on("speech:modelProgress",u=>{m({id:u.id,pct:Math.floor(u.progress*100),label:u.currentFile?u.currentFile.split("/").pop()??"":""})})),[ue]);const Fe=t=>{c(null),r(t),m({id:t,pct:0,label:""}),window.api.ensureSpeechModel(t).then(()=>{r(null),m(null),ue()}).catch(u=>{r(null),m(null),c(u instanceof Error?u.message:String(u)),ue()})},Re=t=>{r(t),T(null),window.api.deleteSpeechModel(t).then(ue).catch(u=>c(u instanceof Error?u.message:String(u))).finally(()=>r(null))},Ve=t=>s(t==="tts-kokoro"?"settings.speech.model.tts":t==="asr-whisper-turbo"?"settings.speech.model.asr_turbo":"settings.speech.model.asr_small"),Ie=t=>s(t==="asr-whisper-turbo"?"settings.speech.model.turbo_short":"settings.speech.model.small_short"),De=t=>t.startsWith("asr-whisper")?s("settings.speech.license_mit"):s("settings.speech.license"),Ee=t=>s(t==="ready"?"settings.speech.state.ready":t==="error"?"settings.speech.state.error":"settings.speech.state.absent"),Te=t=>{var u;return((u=x.find(W=>W.id===t))==null?void 0:u.state)??"absent"},oe=t=>{S(t),n(null),i.setSetting("tts_engine",t),we()},Oe=t=>{D(t),i.setSetting("tts_system_voice",t),we()},ve=t=>{l(t),M(null),i.setSetting("asr_engine",t)},je=re.filter(t=>t.kind==="tts"),Ne=re.filter(t=>t.kind==="asr"),Q=h.startsWith("custom-")?je.find(t=>t.id===h)??null:null,se=N.startsWith("custom-")?Ne.find(t=>t.id===N)??null:null,Ge=h==="azure",Be=N==="groq",qe=N==="azure",Xe=async()=>{if(!(!Q||$)){be(!0),n(null);try{n(await i.testCustomTts({providerId:Q.id}))}catch(t){n({ok:!1,detail:t instanceof Error?t.message:String(t)})}finally{be(!1)}}},He=async()=>{if(!(!se||f)){E(!0),M(null);try{M(await i.testCustomAsr({providerId:se.id}))}catch(t){M({ok:!1,detail:t instanceof Error?t.message:String(t)})}finally{E(!1)}}},Ye=async(t,u)=>{C(null);try{await i.deleteCustomProvider(t),u==="tts"&&h===t&&oe("edge"),u==="asr"&&N===t&&ve("local"),q()}catch{}},Me=t=>{const u=x.find(X=>X.id===t),W=(u==null?void 0:u.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:Ve(t)}),e.jsxs("div",{className:"text-caption text-ink-muted",children:[Ee(W)," · ",De(t)]}),p===t&&(g==null?void 0:g.id)===t&&e.jsx("div",{className:"mt-1.5 h-1.5 rounded-full bg-ink/[0.08] overflow-hidden","data-testid":`speech-dl-bar-${t}`,children:e.jsx("div",{className:"h-full bg-brand transition-all",style:{width:`${g.pct}%`}})}),p===t&&(g==null?void 0:g.id)===t&&e.jsxs("div",{className:"text-caption text-ink-faint mt-0.5","data-testid":`speech-dl-pct-${t}`,children:[g.pct,"%",g.label?` · ${g.label}`:""]})]}),W==="ready"?j===t?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-caption text-warning",children:s("settings.speech.confirm_del")}),e.jsx("button",{onClick:()=>Re(t),className:"text-label text-warning hover:underline","data-testid":`speech-del-confirm-${t}`,children:s("settings.speech.delete")}),e.jsx("button",{onClick:()=>T(null),className:"text-label text-ink-muted hover:text-ink-strong",children:s("action.cancel")})]}):e.jsx("button",{onClick:()=>T(t),disabled:p===t,className:"text-label text-ink-muted hover:text-warning disabled:opacity-40","data-testid":`speech-del-${t}`,children:s("settings.speech.delete")}):e.jsx("button",{onClick:()=>Fe(t),disabled:p!=null||W==="downloading",className:"btn-3d-brand px-3 py-1 text-label disabled:opacity-40","data-testid":`speech-dl-${t}`,children:s(p===t||W==="downloading"?"settings.speech.downloading":"settings.speech.download")})]},t)},Le=(t,u,W,X,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($e,{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:t.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:t.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:t.baseUrl}),t.hasApiKey&&e.jsxs("span",{className:"text-brand shrink-0 inline-flex items-center gap-0.5",children:[e.jsx(ne,{className:"w-3.5 h-3.5","aria-hidden":"true"}),s("settings.speech.key_saved")]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:()=>void ye(),disabled:W,className:"btn-3d-neutral px-3 py-1 text-label disabled:opacity-40","data-testid":`${u}-custom-test`,children:s(W?"settings.testing":"settings.test")}),k===t.id?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-caption text-warning",children:s("settings.speech.confirm_del_custom")}),e.jsx("button",{onClick:()=>void Ye(t.id,u),className:"text-label text-warning hover:underline","data-testid":`${u}-custom-del-confirm`,children:s("settings.speech.delete")}),e.jsx("button",{onClick:()=>C(null),className:"text-label text-ink-muted hover:text-ink-strong",children:s("action.cancel")})]}):e.jsx("button",{onClick:()=>C(t.id),className:"text-label text-ink-muted hover:text-warning","data-testid":`${u}-custom-del`,children:s("settings.speech.delete")}),X&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${X.ok?"text-brand":"text-warning"}`,children:[X.ok?e.jsx(ne,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(ge,{className:"w-4 h-4","aria-hidden":"true"}),X.detail]})]})]});return e.jsxs("div",{"data-testid":"settings-speech",children:[e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:s("settings.speech.tts_title")}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>{oe("edge"),le(!1),O(!1)},"data-testid":"tts-engine-edge","aria-pressed":h==="edge",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${h==="edge"?R:F}`,children:s("settings.speech.engine.edge")}),e.jsxs("button",{onClick:()=>{oe("local"),le(!1),O(!1)},"data-testid":"tts-engine-local","aria-pressed":h==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${h==="local"?R:F}`,children:[s("settings.speech.engine.local"),Te("tts-kokoro")!=="ready"?` · ${s("settings.speech.state.absent")}`:""]}),e.jsx("button",{onClick:()=>{oe("system"),le(!1),O(!1)},disabled:!L,"data-testid":"tts-engine-system","aria-pressed":h==="system",title:L?void 0:s("settings.speech.engine.system_unavailable"),className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${h==="system"?R:F} ${L?"":"opacity-40 cursor-not-allowed"}`,children:s("settings.speech.engine.system")}),e.jsx("button",{onClick:()=>{le(t=>!t),ie||O(!1)},"data-testid":"tts-engine-custom","aria-pressed":h.startsWith("custom-")||ie,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${h.startsWith("custom-")||ie?R:F}`,children:s("settings.speech.engine.custom")}),Ge&&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 · ",s("settings.speech.legacy")]})]}),h==="edge"&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:s("settings.speech.engine.edge_note")})]}),h==="edge"&&e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:s("settings.speech.voice")}),e.jsx("select",{value:y,onChange:t=>{P(t.target.value),i.setSetting("tts_voice_edge",t.target.value)},"data-testid":"tts-voice-select",className:`${G} w-full min-w-0 px-2.5 py-1.5`,children:ft.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))})]}),h==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:s("settings.speech.voice")}),e.jsx("select",{value:o,onChange:t=>{_(t.target.value),i.setSetting("tts_sid_local",t.target.value)},"data-testid":"tts-sid-select",className:`${G} w-full min-w-0 px-2.5 py-1.5`,children:bt.map(t=>e.jsx("option",{value:t.sid,children:t.label},t.sid))})]}),e.jsx("div",{className:v(!1),children:Me("tts-kokoro")})]}),h==="system"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:s("settings.speech.voice")}),e.jsxs("select",{value:I,onChange:t=>Oe(t.target.value),"data-testid":"tts-system-voice-select",className:`${G} w-full min-w-0 px-2.5 py-1.5`,children:[e.jsx("option",{value:"",children:s("settings.speech.voice_auto")}),A.map(t=>e.jsx("option",{value:t.name,children:ot(t)},t.voiceURI))]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:s("settings.speech.engine.system_note")})]})}),ie&&e.jsx("div",{className:v(!1),children:e.jsxs("div",{className:"space-y-3",children:[Q&&Le(Q,"tts",$,Y,Xe),Q&&e.jsxs("div",{children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:s("settings.speech.voice")}),e.jsx("input",{type:"text",value:B,onChange:t=>V(t.target.value),onBlur:()=>void i.setSetting("tts_custom_voice",B.trim()),placeholder:s("settings.speech.custom_voice_ph"),"data-testid":"tts-custom-voice",className:`${G} w-full min-w-0 px-2.5 py-1.5 font-mono`})]}),!Q&&je.map(t=>e.jsxs("button",{onClick:()=>oe(t.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-${t.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:t.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:t.defaultModel})]},t.id)),(pe||!Q&&je.length===0)&&e.jsx(ke,{kind:"tts",showProtocol:!1,testPrefix:"tts-custom",titleKey:"settings.custom.form_title_tts",modelPhKey:"settings.custom.model_ph_tts",testOverride:t=>i.testCustomTts({baseUrl:t.baseUrl,apiKey:t.apiKey||void 0,model:t.model}),onSaved:t=>{oe(t.id),O(!1),q()},onCancel:()=>O(!1)}),(Q||je.length>0)&&e.jsx("button",{onClick:()=>O(t=>!t),className:"text-label text-accent hover:underline",children:s(pe?"action.cancel":"settings.custom.new")})]})}),e.jsx("div",{className:v(!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:s("settings.speech.speed")}),e.jsx("input",{type:"range",min:"0.5",max:"2",step:"0.05",value:w,onChange:t=>K(t.target.value),onPointerUp:()=>{i.setSetting("tts_speed",w),we()},onKeyUp:()=>{i.setSetting("tts_speed",w),we()},"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(w).toFixed(2),"x"]})]})}),e.jsxs("div",{className:v(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:s("settings.speech.asr_title")}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>{ve("local"),me(!1),te(!1)},"data-testid":"asr-engine-local","aria-pressed":N==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${N==="local"?R:F}`,children:s("settings.speech.asr_engine.local")}),e.jsx("button",{onClick:()=>{me(t=>!t),U||te(!1)},"data-testid":"asr-engine-custom","aria-pressed":N.startsWith("custom-")||U,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${N.startsWith("custom-")||U?R:F}`,children:s("settings.speech.engine.custom")}),Be&&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 · ",s("settings.speech.legacy")]}),qe&&e.jsxs("button",{disabled:!0,"data-testid":"asr-engine-azure",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Azure · ",s("settings.speech.legacy")]})]}),N==="local"?e.jsx("p",{className:"text-label text-ink-muted mt-2",children:s("settings.speech.asr_engine.local_note")}):N.startsWith("custom-")&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:s("settings.speech.asr_engine.custom_note")})]}),N==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:s("settings.model")}),e.jsx("select",{value:H,onChange:t=>{Z(t.target.value),i.setSetting("asr_local_model",t.target.value)},"data-testid":"asr-model-select",className:`${G} w-full min-w-0 px-2.5 py-1.5`,children:["asr-whisper-turbo","asr-whisper-small"].map(t=>e.jsxs("option",{value:t,children:[Ie(t)," · ",Ee(Te(t))]},t))})]}),e.jsx("div",{className:v(!1),children:Me(H)})]}),U&&e.jsx("div",{className:v(!1),children:e.jsxs("div",{className:"space-y-3",children:[se&&Le(se,"asr",f,J,He),!se&&Ne.map(t=>e.jsxs("button",{onClick:()=>ve(t.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-${t.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:t.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:t.defaultModel})]},t.id)),(fe||!se&&Ne.length===0)&&e.jsx(ke,{kind:"asr",showProtocol:!1,testPrefix:"asr-custom",titleKey:"settings.custom.form_title_asr",modelPhKey:"settings.custom.model_ph_asr",testOverride:t=>i.testCustomAsr({baseUrl:t.baseUrl,apiKey:t.apiKey||void 0,model:t.model}),onSaved:t=>{ve(t.id),te(!1),q()},onCancel:()=>te(!1)}),(se||Ne.length>0)&&e.jsx("button",{onClick:()=>te(t=>!t),className:"text-label text-accent hover:underline",children:s(fe?"action.cancel":"settings.custom.new")})]})}),e.jsxs("div",{className:v(!0),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ae,{checked:ce,onChange:()=>{const t=!ce;he(t),i.setSetting("asr_auto_stop",t?"1":"0")},label:s("settings.speech.asr_auto_stop"),testid:"asr-auto-stop-toggle"}),e.jsx("div",{className:"text-body font-medium text-ink-strong",children:s("settings.speech.asr_auto_stop")})]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:s("settings.speech.asr_ux_note")})]}),d&&e.jsx("div",{className:"px-4 py-3 text-label text-warning break-all",role:"alert",children:d==="engine-unavailable"?s("chat.speech.engine_unavailable"):d})]})}export{yt as SettingsView};
|
|
6
|
+
*/const rt=st("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"}]]),xe="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 ke({kind:s,showProtocol:x=!0,testPrefix:b="custom",titleKey:p="settings.custom.form_title",modelPhKey:r="settings.custom.model_ph",testOverride:d,onSaved:c,onCancel:h}){const m=de(),[j,T]=a.useState(""),[g,S]=a.useState("openai-compatible"),[y,P]=a.useState(""),[o,_]=a.useState(""),[w,K]=a.useState(""),[B,V]=a.useState(!1),[I,D]=a.useState(!1),[A,z]=a.useState(null),L=async()=>{if(!(!y.trim()||!w.trim()||I)){D(!0),z(null);try{const l=d?await d({baseUrl:y.trim(),apiKey:o.trim(),model:w.trim()}):await i.testCustomProvider({label:j||m("settings.custom.test_label"),protocol:g,baseUrl:y.trim(),apiKey:o.trim()||void 0,defaultModel:w.trim()});z({ok:l.ok,detail:l.detail})}catch(l){z({ok:!1,detail:l instanceof Error?l.message:String(l)})}finally{D(!1)}}},N=async()=>{if(!(!j.trim()||!y.trim()||!w.trim()))try{const l=await i.createCustomProvider({label:j.trim(),kind:s,protocol:x?g:"openai-compatible",baseUrl:y.trim(),apiKey:o.trim()||void 0,defaultModel:w.trim(),vision:s==="llm"?B:void 0});c(l)}catch{}};return e.jsxs("div",{className:"space-y-2.5","data-testid":`${b}-provider-form`,children:[e.jsx("div",{className:"text-label font-bold text-ink-strong",children:m(p)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:j,onChange:l=>T(l.target.value),placeholder:m("settings.custom.label_ph"),"data-testid":`${b}-label`,className:`${xe} flex-1 px-2.5 py-1.5`}),x&&e.jsxs("select",{value:g,onChange:l=>S(l.target.value),"data-testid":`${b}-protocol`,className:`${xe} px-2 py-1.5`,children:[e.jsx("option",{value:"openai-compatible",children:m("settings.proto.openai")}),e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"google",children:"Google"})]})]}),e.jsx("input",{type:"text",value:y,onChange:l=>P(l.target.value),placeholder:m("settings.custom.baseurl_ph"),"data-testid":`${b}-baseurl`,className:`${xe} w-full px-2.5 py-1.5 font-mono`}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:w,onChange:l=>K(l.target.value),placeholder:m(r),"data-testid":`${b}-model`,className:`${xe} flex-1 px-2.5 py-1.5 font-mono`}),e.jsx("input",{type:"password",value:o,onChange:l=>_(l.target.value),placeholder:m("settings.custom.apikey_ph"),"data-testid":`${b}-apikey`,className:`${xe} flex-1 px-2.5 py-1.5`})]}),s==="llm"&&e.jsxs("label",{className:"inline-flex items-center gap-2 text-label cursor-pointer select-none","data-testid":`${b}-vision`,children:[e.jsx("input",{type:"checkbox",checked:B,onChange:l=>V(l.target.checked),className:"w-4 h-4 rounded accent-brand"}),e.jsx("span",{className:"text-ink-strong",children:m("settings.custom.vision")}),e.jsx("span",{className:"text-ink-faint",children:m("settings.custom.visionHint")})]}),A&&e.jsxs("div",{className:`text-label rounded p-2 inline-flex items-start gap-1.5 ${A.ok?"bg-brand/10 text-brand":"bg-warning/10 text-warning"}`,children:[A.ok?e.jsx(ne,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}):e.jsx(he,{className:"w-4 h-4 mt-px shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"break-words",children:A.detail})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>void L(),disabled:!y.trim()||!w.trim()||I,"data-testid":`${b}-test`,className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:m(I?"settings.testing":"settings.test")}),e.jsx("button",{onClick:()=>void N(),disabled:!j.trim()||!y.trim()||!w.trim(),"data-testid":`${b}-save`,className:"btn-3d-brand px-3 py-1.5 text-label disabled:opacity-40",children:m("settings.custom.save")}),h&&e.jsx("button",{onClick:h,className:"text-label text-ink-muted hover:text-ink-strong px-3 py-1.5 transition-colors",children:m("action.cancel")})]})]})}const Ke="lookatstudy-theme",We="auto",Ue="(prefers-color-scheme: dark)";function _e(){return typeof window>"u"||window.matchMedia(Ue).matches?"dark":"light"}function mt(){if(typeof localStorage>"u")return We;const s=localStorage.getItem(Ke);return s==="auto"||s==="light"||s==="dark"?s:We}function Ce(s){const x=document.documentElement;x.classList.remove("dark","light"),x.classList.add(s),window.dispatchEvent(new CustomEvent("theme-changed",{detail:{resolved:s}}))}function ut(){const[s,x]=a.useState(()=>mt()),[b,p]=a.useState(()=>s==="auto"?_e():s),r=a.useCallback(d=>{x(d),localStorage.setItem(Ke,d);const c=d==="auto"?_e():d;p(c),Ce(c)},[]);return a.useEffect(()=>{if(s!=="auto")return;const d=window.matchMedia(Ue),c=h=>{const m=h.matches?"dark":"light";p(m),Ce(m)};return d.addEventListener("change",c),()=>d.removeEventListener("change",c)},[s]),a.useEffect(()=>{const d=s==="auto"?_e():s;p(d),Ce(d)},[s]),{mode:s,resolved:b,setMode:r}}function we(){window.dispatchEvent(new Event(ct))}const G="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",F="bg-surface-3 text-ink-muted hover:bg-surface-3 hover:bg-surface-3 hover:text-ink-strong",R="bg-brand text-white shadow-sm";function v(s){return s?"px-4 py-3.5 border-t border-[var(--border-faint)]":"px-4 py-3.5"}function yt(){const s=de(),[x,b]=a.useState([]),[p,r]=a.useState([]),[d,c]=a.useState("glm"),[h,m]=a.useState(""),[j,T]=a.useState(""),[g,S]=a.useState(null),[y,P]=a.useState(!1),[o,_]=a.useState(null),[w,K]=a.useState(!1),[B,V]=a.useState(!1),[I,D]=a.useState([]),[A,z]=a.useState(!1),[L,N]=a.useState(null),[l,H]=a.useState(null),[Z,ce]=a.useState(""),[ge,re]=a.useState(!1),ee=ut(),ie=async n=>{if($)try{await i.updateCustomProvider($.id,{vision:n}),await U()}catch{}},le=async()=>{z(!0),N(null);try{const n=await i.discoverModels();n.ok&&n.models?D(n.models):N(n.error||s("settings.discover_failed"))}catch(n){N(n instanceof Error?n.message:String(n))}finally{z(!1)}},U=a.useCallback(async()=>{try{const[n,f,E,J]=await Promise.all([i.getProviderPresets(),i.listCustomProviders(),i.getSetting("active_provider"),i.getSetting("active_model")]);b(n),r(f);const M=E??"glm";if(c(M),M.startsWith("custom-")){const k=f.find(C=>C.id===M);S(k!=null&&k.hasApiKey?s("settings.key.configured"):null)}else{const k=n.find(C=>C.id===M);if(k){const C=await i.getSetting(k.apiKeySetting);S(C?`${C.slice(0,4)}…${C.slice(-4)}`:null)}}if(M.startsWith("custom-")){const k=f.find(C=>C.id===M);m(J??(k==null?void 0:k.defaultModel)??"")}else{const k=n.find(C=>C.id===M);m(J??(k==null?void 0:k.defaultModel)??"")}}catch(n){console.error("[SettingsView] load() failed:",n)}},[s]);a.useEffect(()=>{U()},[U]);const me=async n=>{c(n),_(null),T("");const f=x.find(E=>E.id===n);if(f){const E=await i.getSetting(f.apiKeySetting);S(E?`${E.slice(0,4)}…${E.slice(-4)}`:null),m(h||f.defaultModel)}},pe=async()=>{K(!1);try{if(await i.setSetting("active_provider",d),await i.setSetting("active_model",h),j.trim()){const n=x.find(f=>f.id===d);n&&(await i.setSetting(n.apiKeySetting,j.trim()),S(`${j.trim().slice(0,4)}…${j.trim().slice(-4)}`),T(""))}K(!0),setTimeout(()=>K(!1),2e3),window.dispatchEvent(new Event("llm-config-changed"))}catch{}},O=async()=>{P(!0),_(null);try{const n=await i.testLlmConnection();_(n)}catch(n){_({ok:!1,detail:n instanceof Error?n.message:String(n),errorKind:"unknown"})}finally{P(!1)}},fe=async n=>{await i.setSetting("active_provider",n.id),await i.setSetting("active_model",n.defaultModel),c(n.id),m(n.defaultModel),V(!1),await U(),window.dispatchEvent(new Event("llm-config-changed"))},te=async n=>{try{await i.deleteCustomProvider(n),d===n&&(await i.setSetting("active_provider","glm"),c("glm")),await U()}catch{}},$=d.startsWith("custom-")?p.find(n=>n.id===d):null;a.useEffect(()=>{if(!$)return;const n=$.models.find(f=>f.id===h);ce(n!=null&&n.contextWindow?String(n.contextWindow):"")},[$,h]);const be=async()=>{var M,k;if(!$)return;const n=Z.trim().replace(/[,\s_]/g,""),f=/^(\d+)([km]?)$/i.exec(n);if(n!==""&&!f)return;const E=((M=f==null?void 0:f[2])==null?void 0:M.toLowerCase())==="k"?1e3:((k=f==null?void 0:f[2])==null?void 0:k.toLowerCase())==="m"?1e6:1,J=n===""||!f?null:Math.max(1,Math.round(parseInt(f[1],10)*E));re(!0);try{const C=$.models.map(q=>q.id===h?{...q,contextWindow:J}:q);await i.updateCustomProvider($.id,{models:C}),await U(),window.dispatchEvent(new Event("llm-config-changed"))}catch{}finally{re(!1)}},Y=d.startsWith("custom-")?null:x.find(n=>n.id===d);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:s("settings.group.ai")}),e.jsxs("div",{className:"surface-card overflow-hidden",children:[e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:s("settings.row.provider")}),e.jsxs("div",{className:"flex flex-wrap gap-1.5","data-testid":"provider-grid",children:[x.map(n=>e.jsx("button",{onClick:()=>me(n.id),"data-testid":`provider-card-${n.id}`,"aria-pressed":d===n.id,className:`px-3 py-1.5 rounded-lg text-label font-medium whitespace-nowrap transition-colors ${d===n.id?R:F}`,children:n.label},n.id)),p.filter(n=>n.kind==="llm").map(n=>e.jsxs("button",{onClick:()=>me(n.id),"data-testid":`provider-card-${n.id}`,"aria-pressed":d===n.id,className:`px-3 py-1.5 rounded-lg text-label font-medium whitespace-nowrap transition-colors inline-flex items-center gap-1 ${d===n.id?R:F}`,children:[e.jsx($e,{className:"w-3.5 h-3.5","aria-hidden":"true"}),n.label]},n.id)),e.jsxs("button",{onClick:()=>V(n=>!n),"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(nt,{className:"w-3.5 h-3.5","aria-hidden":"true"}),s("settings.add_custom")]})]})]}),B&&e.jsx("div",{className:"px-4 py-3.5 bg-surface-1 border-t border-[var(--border-faint)]",children:e.jsx(ke,{kind:"llm",testPrefix:"custom",onSaved:n=>void fe(n),onCancel:()=>V(!1)})}),p.length>0&&d.startsWith("custom-")&&e.jsx("div",{className:v(!0),children:e.jsx("button",{onClick:n=>{const f=n.currentTarget.getBoundingClientRect(),E=p.find(J=>J.id===d);E&&H({id:E.id,label:E.label,rect:f})},className:"text-label text-warning hover:underline",children:s("settings.delete_custom")})}),Y&&e.jsxs(e.Fragment,{children:[Y.baseUrl&&e.jsxs("div",{className:v(!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:Y.baseUrl})]}),e.jsxs("div",{className:v(!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:s("settings.model")}),e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[e.jsxs("select",{value:h,onChange:n=>m(n.target.value),"data-testid":"model-select",className:`${G} flex-1 px-2.5 py-1.5`,children:[Y.models.map(n=>e.jsx("option",{value:n.id,children:n.id},n.id)),d==="openrouter"&&I.map(n=>e.jsx("option",{value:n.id,children:n.id},n.id))]}),d==="openrouter"&&e.jsxs("button",{onClick:le,disabled:A,"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(rt,{className:`w-3.5 h-3.5 ${A?"animate-spin":""}`,"aria-hidden":"true"}),s(A?"settings.discovering":"settings.refresh")]})]})]}),L&&e.jsx("div",{className:"text-label text-warning mt-1.5 ml-[68px]",children:L})]}),e.jsx("div",{className:v(!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:s("settings.apikey")}),e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[g&&e.jsxs("span",{className:"text-label text-brand shrink-0 inline-flex items-center gap-1",children:[e.jsx(ne,{className:"w-3.5 h-3.5","aria-hidden":"true"}),g]}),e.jsx("input",{type:"password",value:j,onChange:n=>T(n.target.value),placeholder:s(g?"settings.key.overwrite_ph":"settings.key.paste_ph"),"data-testid":"settings-key-input",className:`${G} flex-1 px-2.5 py-1.5`}),e.jsx("a",{href:Y.keyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-label text-brand hover:underline whitespace-nowrap",children:s("settings.key.get")})]})]})}),e.jsx("div",{className:v(!0),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:O,disabled:y,"data-testid":"test-connection-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:s(y?"settings.testing":"settings.test")}),o&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${o.ok?"text-brand":"text-warning"}`,children:[o.ok?e.jsx(ne,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(he,{className:"w-4 h-4","aria-hidden":"true"}),o.detail]})]})})]}),$&&!Y&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:v(!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:$.baseUrl})]}),e.jsx("div",{className:v(!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:s("settings.model")}),$.models.length>1?e.jsx("select",{value:h,onChange:n=>m(n.target.value),"data-testid":"model-select-custom",className:`${G} flex-1 px-2.5 py-1.5`,children:$.models.map(n=>e.jsx("option",{value:n.id,children:n.id},n.id))}):e.jsx("input",{type:"text",value:h,onChange:n=>m(n.target.value),placeholder:s("settings.custom.model_ph"),"data-testid":"model-input-custom",className:`${G} flex-1 px-2.5 py-1.5 font-mono`})]})}),e.jsxs("div",{className:v(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:s("settings.custom.windowLabel")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",inputMode:"numeric",value:Z,onChange:n=>ce(n.target.value),placeholder:s("settings.custom.windowPh"),"data-testid":"context-window-input",className:`${G} flex-1 px-2.5 py-1.5 font-mono tabular-nums`}),e.jsx("button",{onClick:be,disabled:ge,"data-testid":"context-window-save",className:"btn-3d-neutral px-3 py-1.5 text-label shrink-0 disabled:opacity-40",children:s("settings.custom.save")})]}),e.jsx("div",{className:"text-caption text-ink-faint mt-1",children:s("settings.custom.windowHint")})]}),e.jsx("div",{className:v(!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:$.vision,onChange:n=>void ie(n.target.checked),className:"w-4 h-4 rounded accent-brand"}),e.jsx("span",{className:"text-ink-strong",children:s("settings.custom.vision")}),e.jsx("span",{className:"text-ink-faint",children:s("settings.custom.visionHint")})]})}),e.jsx("div",{className:v(!0),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:O,disabled:y,"data-testid":"test-connection-btn",className:"btn-3d-neutral px-3 py-1.5 text-label disabled:opacity-40",children:s(y?"settings.testing":"settings.test")}),o&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${o.ok?"text-brand":"text-warning"}`,children:[o.ok?e.jsx(ne,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(he,{className:"w-4 h-4","aria-hidden":"true"}),o.detail]})]})})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:s("settings.group.vision")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(ht,{activeProvider:d,activeModel:h,presets:x,customProviders:p})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:s("settings.group.speech")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(vt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:s("settings.group.memory")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(gt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:s("settings.group.companion")}),e.jsx("div",{className:"surface-card overflow-hidden",children:e.jsx(pt,{})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-label font-bold text-ink-muted mb-2 px-1",children:s("settings.group.appearance")}),e.jsxs("div",{className:"surface-card overflow-hidden",children:[e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:s("settings.row.theme")}),e.jsx("div",{className:"flex gap-2",children:[{mode:"auto",label:s("settings.theme.auto")},{mode:"light",label:s("settings.theme.light")},{mode:"dark",label:s("settings.theme.dark")}].map(({mode:n,label:f})=>e.jsx("button",{onClick:()=>ee.setMode(n),"data-testid":`theme-${n}`,"aria-pressed":ee.mode===n,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${ee.mode===n?R:F}`,children:f},n))}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:ee.mode==="auto"?s("settings.theme.following",{mode:s(`settings.theme.${ee.resolved}`)}):null})]}),e.jsxs("div",{className:v(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:s("settings.row.interface_lang")}),e.jsx("div",{className:"flex gap-2",children:["zh-CN","en"].map(n=>e.jsx("button",{onClick:()=>at(n),"data-testid":`lang-${n}`,"aria-pressed":ze()===n,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${ze()===n?R:F}`,children:n==="zh-CN"?"中文":"English"},n))})]}),e.jsxs("div",{className:v(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:s("settings.row.import_lang")}),e.jsx(xt,{})]})]})]})]}),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:s("settings.footer.hint")}),e.jsxs("button",{onClick:pe,"data-testid":"settings-save",className:"btn-3d-brand px-5 py-2 text-body inline-flex items-center gap-1.5",children:[w&&e.jsx(it,{className:"w-4 h-4","aria-hidden":"true"}),s(w?"settings.saved_text":"settings.footer.save")]})]}),l&&e.jsx(lt,{anchorRect:l.rect,message:s("settings.delete_custom_confirm",{name:l.label}),danger:!0,confirmLabel:s("action.delete"),testid:"custom-provider-delete-confirm",onConfirm:()=>{te(l.id),H(null)},onCancel:()=>H(null)})]})}function xt(){const[s,x]=a.useState("en"),[b,p]=a.useState(!1);a.useEffect(()=>{i.getSetting("pref_lang").then(c=>{c&&x(c),p(!0)})},[]);const r=async c=>{x(c),await i.setSetting("pref_lang",c)},d=[{code:"en",label:"English"},{code:"zh-CN",label:"简体中文"},{code:"zh-TW",label:"繁體中文"}];return b?e.jsx("div",{className:"flex gap-2","data-testid":"pref-lang-options",children:d.map(c=>e.jsx("button",{onClick:()=>r(c.code),"data-testid":`pref-lang-${c.code}`,"aria-pressed":s===c.code,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${s===c.code?R:F}`,children:c.label},c.code))}):null}function ht({activeProvider:s,activeModel:x,presets:b,customProviders:p}){const r=de(),[d,c]=a.useState(!1),[h,m]=a.useState(!1),[j,T]=a.useState(""),[g,S]=a.useState(!1),[y,P]=a.useState(!1),[o,_]=a.useState(null),[w,K]=a.useState(!1);a.useEffect(()=>{Promise.all([i.getSetting("flag_multimodal_import"),i.getSetting("vision_provider_override"),i.getSetting("vision_model_override"),i.getSetting("flag_math_vision")]).then(([l,H,Z])=>{c(l==="true"),T(H??""),K(Z==="true"),m(!0)})},[]);const B=async()=>{const l=!d;c(l),await i.setSetting("flag_multimodal_import",String(l))},V=async()=>{const l=!w;K(l),await i.setSetting("flag_math_vision",String(l))},I=async l=>{await i.setSetting("vision_provider_override",l.id),await i.setSetting("vision_model_override",l.defaultModel),T(l.id),S(!1)},D=async()=>{await i.setSetting("vision_provider_override",""),await i.setSetting("vision_model_override",""),T(""),S(!1)},A=async()=>{if(!y){P(!0),_(null);try{const l=await i.testLlmConnection({vision:!0});_({ok:l.ok,detail:l.detail})}catch(l){_({ok:!1,detail:l instanceof Error?l.message:String(l)})}finally{P(!1)}}},z=p.filter(l=>l.kind==="vision"),L=j.startsWith("custom-")?p.find(l=>l.id===j):null,N=j&&!j.startsWith("custom-")?b.find(l=>l.id===j):null;return h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(ae,{checked:d,onChange:B,label:r("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:r("settings.multimodal.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:r("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:r("settings.multimodal.current_model",{model:x||r("settings.multimodal.not_selected")})}),e.jsx("div",{children:s.startsWith("custom-")?r("settings.multimodal.hint_custom"):r("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:r("settings.multimodal.override_title")}),e.jsx("div",{className:"text-caption text-ink-muted mb-2",children:r("settings.multimodal.override_bridge_hint")}),e.jsxs("div",{className:"space-y-3 mt-1",children:[L&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx($e,{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:L.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:L.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:L.baseUrl})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{onClick:()=>void A(),disabled:y,"data-testid":"vision-override-test",className:"btn-3d-neutral px-4 py-1.5 text-label disabled:opacity-50",children:r(y?"settings.testing":"settings.multimodal.test_override")}),e.jsx("button",{onClick:()=>S(l=>!l),className:"text-label text-accent hover:underline",children:r("settings.multimodal.replace_custom")}),e.jsx("button",{onClick:()=>void D(),className:"text-label text-ink-muted hover:text-ink-strong",children:r("settings.multimodal.stop_override")}),o&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${o.ok?"text-brand":"text-warning"}`,children:[o.ok?e.jsx(ne,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(he,{className:"w-4 h-4","aria-hidden":"true"}),o.detail]})]})]}),N&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-label",children:[e.jsx("span",{className:"text-ink-muted",children:r("settings.multimodal.legacy_preset",{label:N.label})}),e.jsx("button",{onClick:()=>void D(),className:"text-label text-ink-muted hover:text-ink-strong underline",children:r("settings.multimodal.stop_override")})]}),!L&&!N&&e.jsxs(e.Fragment,{children:[z.map(l=>e.jsxs("button",{onClick:()=>void I(l),className:"w-full text-left px-3 py-2 rounded-lg bg-surface-1 hover:bg-surface-3 transition-colors","data-testid":`vision-pick-${l.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:l.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:l.defaultModel})]},l.id)),(g||z.length===0)&&e.jsx(ke,{kind:"vision",testPrefix:"vision-custom",titleKey:"settings.custom.form_title_vision",modelPhKey:"settings.custom.model_ph_vision",onSaved:l=>void I(l),onCancel:()=>S(!1)}),z.length>0&&e.jsx("button",{onClick:()=>S(l=>!l),className:"text-label text-accent hover:underline",children:r(g?"action.cancel":"settings.custom.new")})]})]})]}),e.jsxs("div",{className:"bg-ink/5 rounded-lg p-3 flex items-center gap-3",children:[e.jsx(ae,{checked:w,onChange:V,label:r("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:r("settings.mathvision.toggle")}),e.jsx("div",{className:"text-caption text-ink-muted",children:r("settings.mathvision.desc")})]})]})]})]}):null}function gt(){const s=de(),[x,b]=a.useState(!1),[p,r]=a.useState(!1);a.useEffect(()=>{i.getSetting("flag_memory_system").then(c=>{b(c==="true"),r(!0)})},[]);const d=async()=>{const c=!x;b(c),await i.setSetting("flag_memory_system",String(c))};return p?e.jsxs("div",{className:"px-4 py-3.5 flex items-center gap-3",children:[e.jsx(ae,{checked:x,onChange:d,label:s("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:s("settings.memory.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:s("settings.memory.toggle.desc")})]})]}):null}function pt(){const s=de(),[x,b]=a.useState(!0),[p,r]=a.useState(!1),d=a.useSyncExternalStore(Qe,Ze),[c,h]=a.useState(!0),[m,j]=a.useState(!1),T=typeof window<"u"&&!!window.__lookatstudyWeb;a.useEffect(()=>{i.getSetting("companion_enabled").then(o=>{b(o!=="false"&&o!=="0"),r(!0)}),i.getSetting("companion_sfx").then(o=>{h(o!=="false"&&o!=="0")}),i.getSetting("companion_pet_mode").then(o=>{j(o==="1")})},[]);const g=async()=>{const o=!x;b(o),await i.setSetting("companion_enabled",String(o)),window.dispatchEvent(new Event("companion-config-changed"))},S=async()=>{const o=!c;h(o),await i.setSetting("companion_sfx",String(o)),window.dispatchEvent(new Event("companion-config-changed"))},y=async()=>{const o=!m;j(o),await i.setSetting("companion_pet_mode",o?"1":"0"),window.dispatchEvent(new Event("companion-config-changed"))},P=async o=>{o!==d.form&&(await i.setSetting("companion_form",o),window.dispatchEvent(new Event("companion-config-changed")))};return p?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(ae,{checked:x,onChange:g,label:s("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:s("settings.companion.toggle")}),e.jsx("div",{className:"text-label text-ink-muted",children:s("settings.companion.toggle.desc")})]})]}),x&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ae,{checked:c,onChange:S,label:s("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:s("settings.companion.sfx")}),e.jsx("div",{className:"text-label text-ink-muted",children:s("settings.companion.sfx.desc")})]})]}),!T&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ae,{checked:m,onChange:y,label:s("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:s("settings.companion.pet")}),e.jsx("div",{className:"text-label text-ink-muted",children:s("settings.companion.pet.desc")})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-label text-ink-muted mb-2",children:s("settings.companion.form")}),e.jsx("div",{className:"grid grid-cols-5 gap-2",role:"radiogroup","aria-label":s("settings.companion.form"),children:et.map(o=>{const _=d.form===o;return e.jsxs("button",{type:"button",role:"radio","aria-checked":_,"data-testid":`companion-form-${o}`,onClick:()=>{P(o)},className:`flex flex-col items-center gap-0.5 rounded-xl p-1.5 border motion-safe:transition-colors
|
|
7
|
+
${_?"border-[var(--accent)] bg-surface-2 shadow-card":"border-[var(--border-faint)] hover:bg-surface-2"}`,title:s(`companion.form.${o}.desc`),children:[e.jsx(tt,{form:o,expression:"happy",pose:"float",size:64}),e.jsx("span",{className:`text-label ${_?"text-ink-strong font-medium":"text-ink-muted"}`,children:s(`companion.form.${o}.name`)})]},o)})})]})]})]}):null}function ae({checked:s,onChange:x,label:b,testid:p}){return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":b,onClick:x,"data-testid":p,className:`relative w-12 h-6 rounded-full transition-colors shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/60 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface-2)] ${s?"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 ${s?"translate-x-6":""}`})})}const ft=[{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(女)"}],bt=[{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 vt(){const s=de(),[x,b]=a.useState([]),[p,r]=a.useState(null),[d,c]=a.useState(null),[h,m]=a.useState(null),[j,T]=a.useState(null),[g,S]=a.useState("edge"),[y,P]=a.useState("zh-CN-XiaoxiaoNeural"),[o,_]=a.useState("48"),[w,K]=a.useState("1.0"),[B,V]=a.useState(""),[I,D]=a.useState(""),[A,z]=a.useState([]),L=typeof window<"u"&&"speechSynthesis"in window,[N,l]=a.useState("local"),[H,Z]=a.useState("asr-whisper-turbo"),[ce,ge]=a.useState(!0),[re,ee]=a.useState([]),[ie,le]=a.useState(!1),[U,me]=a.useState(!1),[pe,O]=a.useState(!1),[fe,te]=a.useState(!1),[$,be]=a.useState(!1),[Y,n]=a.useState(null),[f,E]=a.useState(!1),[J,M]=a.useState(null),[k,C]=a.useState(null),q=a.useCallback(()=>{i.listCustomProviders().then(t=>ee(t.filter(u=>u.kind==="tts"||u.kind==="asr"))).catch(()=>{})},[]);a.useEffect(()=>{Promise.all([i.getSetting("tts_engine"),i.getSetting("tts_voice_edge"),i.getSetting("tts_sid_local"),i.getSetting("tts_speed"),i.getSetting("tts_custom_voice"),i.getSetting("tts_system_voice"),i.getSetting("asr_engine"),i.getSetting("asr_local_model"),i.getSetting("asr_auto_stop")]).then(([t,u,W,X,ye,Pe,Ae,Se,Je])=>{t&&S(t),u&&P(u),W&&_(W),X&&K(X),ye&&V(ye),Pe&&D(Pe),Ae&&l(Ae),(Se==="asr-whisper-turbo"||Se==="asr-whisper-small")&&Z(Se),ge(Je!=="0")}),q()},[q]),a.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const t=()=>z(dt(window.speechSynthesis.getVoices()));return t(),window.speechSynthesis.addEventListener("voiceschanged",t),()=>window.speechSynthesis.removeEventListener("voiceschanged",t)},[]);const ue=a.useCallback(()=>{window.api.getSpeechModelStatus().then(t=>b(t)).catch(()=>{})},[]);a.useEffect(()=>(ue(),window.api.on("speech:modelProgress",u=>{m({id:u.id,pct:Math.floor(u.progress*100),label:u.currentFile?u.currentFile.split("/").pop()??"":""})})),[ue]);const Fe=t=>{c(null),r(t),m({id:t,pct:0,label:""}),window.api.ensureSpeechModel(t).then(()=>{r(null),m(null),ue()}).catch(u=>{r(null),m(null),c(u instanceof Error?u.message:String(u)),ue()})},Re=t=>{r(t),T(null),window.api.deleteSpeechModel(t).then(ue).catch(u=>c(u instanceof Error?u.message:String(u))).finally(()=>r(null))},Ve=t=>s(t==="tts-kokoro"?"settings.speech.model.tts":t==="asr-whisper-turbo"?"settings.speech.model.asr_turbo":"settings.speech.model.asr_small"),Ie=t=>s(t==="asr-whisper-turbo"?"settings.speech.model.turbo_short":"settings.speech.model.small_short"),De=t=>t.startsWith("asr-whisper")?s("settings.speech.license_mit"):s("settings.speech.license"),Ee=t=>s(t==="ready"?"settings.speech.state.ready":t==="error"?"settings.speech.state.error":"settings.speech.state.absent"),Te=t=>{var u;return((u=x.find(W=>W.id===t))==null?void 0:u.state)??"absent"},oe=t=>{S(t),n(null),i.setSetting("tts_engine",t),we()},Oe=t=>{D(t),i.setSetting("tts_system_voice",t),we()},ve=t=>{l(t),M(null),i.setSetting("asr_engine",t)},je=re.filter(t=>t.kind==="tts"),Ne=re.filter(t=>t.kind==="asr"),Q=g.startsWith("custom-")?je.find(t=>t.id===g)??null:null,se=N.startsWith("custom-")?Ne.find(t=>t.id===N)??null:null,Ge=g==="azure",Be=N==="groq",qe=N==="azure",Xe=async()=>{if(!(!Q||$)){be(!0),n(null);try{n(await i.testCustomTts({providerId:Q.id}))}catch(t){n({ok:!1,detail:t instanceof Error?t.message:String(t)})}finally{be(!1)}}},He=async()=>{if(!(!se||f)){E(!0),M(null);try{M(await i.testCustomAsr({providerId:se.id}))}catch(t){M({ok:!1,detail:t instanceof Error?t.message:String(t)})}finally{E(!1)}}},Ye=async(t,u)=>{C(null);try{await i.deleteCustomProvider(t),u==="tts"&&g===t&&oe("edge"),u==="asr"&&N===t&&ve("local"),q()}catch{}},Me=t=>{const u=x.find(X=>X.id===t),W=(u==null?void 0:u.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:Ve(t)}),e.jsxs("div",{className:"text-caption text-ink-muted",children:[Ee(W)," · ",De(t)]}),p===t&&(h==null?void 0:h.id)===t&&e.jsx("div",{className:"mt-1.5 h-1.5 rounded-full bg-ink/[0.08] overflow-hidden","data-testid":`speech-dl-bar-${t}`,children:e.jsx("div",{className:"h-full bg-brand transition-all",style:{width:`${h.pct}%`}})}),p===t&&(h==null?void 0:h.id)===t&&e.jsxs("div",{className:"text-caption text-ink-faint mt-0.5","data-testid":`speech-dl-pct-${t}`,children:[h.pct,"%",h.label?` · ${h.label}`:""]})]}),W==="ready"?j===t?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-caption text-warning",children:s("settings.speech.confirm_del")}),e.jsx("button",{onClick:()=>Re(t),className:"text-label text-warning hover:underline","data-testid":`speech-del-confirm-${t}`,children:s("settings.speech.delete")}),e.jsx("button",{onClick:()=>T(null),className:"text-label text-ink-muted hover:text-ink-strong",children:s("action.cancel")})]}):e.jsx("button",{onClick:()=>T(t),disabled:p===t,className:"text-label text-ink-muted hover:text-warning disabled:opacity-40","data-testid":`speech-del-${t}`,children:s("settings.speech.delete")}):e.jsx("button",{onClick:()=>Fe(t),disabled:p!=null||W==="downloading",className:"btn-3d-brand px-3 py-1 text-label disabled:opacity-40","data-testid":`speech-dl-${t}`,children:s(p===t||W==="downloading"?"settings.speech.downloading":"settings.speech.download")})]},t)},Le=(t,u,W,X,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($e,{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:t.label}),e.jsx("code",{className:"text-ink-faint font-mono break-all",children:t.defaultModel}),e.jsx("span",{className:"text-ink-faint break-all min-w-0",children:t.baseUrl}),t.hasApiKey&&e.jsxs("span",{className:"text-brand shrink-0 inline-flex items-center gap-0.5",children:[e.jsx(ne,{className:"w-3.5 h-3.5","aria-hidden":"true"}),s("settings.speech.key_saved")]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{onClick:()=>void ye(),disabled:W,className:"btn-3d-neutral px-3 py-1 text-label disabled:opacity-40","data-testid":`${u}-custom-test`,children:s(W?"settings.testing":"settings.test")}),k===t.id?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-caption text-warning",children:s("settings.speech.confirm_del_custom")}),e.jsx("button",{onClick:()=>void Ye(t.id,u),className:"text-label text-warning hover:underline","data-testid":`${u}-custom-del-confirm`,children:s("settings.speech.delete")}),e.jsx("button",{onClick:()=>C(null),className:"text-label text-ink-muted hover:text-ink-strong",children:s("action.cancel")})]}):e.jsx("button",{onClick:()=>C(t.id),className:"text-label text-ink-muted hover:text-warning","data-testid":`${u}-custom-del`,children:s("settings.speech.delete")}),X&&e.jsxs("span",{className:`text-label inline-flex items-center gap-1 ${X.ok?"text-brand":"text-warning"}`,children:[X.ok?e.jsx(ne,{className:"w-4 h-4","aria-hidden":"true"}):e.jsx(he,{className:"w-4 h-4","aria-hidden":"true"}),X.detail]})]})]});return e.jsxs("div",{"data-testid":"settings-speech",children:[e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:s("settings.speech.tts_title")}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>{oe("edge"),le(!1),O(!1)},"data-testid":"tts-engine-edge","aria-pressed":g==="edge",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${g==="edge"?R:F}`,children:s("settings.speech.engine.edge")}),e.jsxs("button",{onClick:()=>{oe("local"),le(!1),O(!1)},"data-testid":"tts-engine-local","aria-pressed":g==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${g==="local"?R:F}`,children:[s("settings.speech.engine.local"),Te("tts-kokoro")!=="ready"?` · ${s("settings.speech.state.absent")}`:""]}),e.jsx("button",{onClick:()=>{oe("system"),le(!1),O(!1)},disabled:!L,"data-testid":"tts-engine-system","aria-pressed":g==="system",title:L?void 0:s("settings.speech.engine.system_unavailable"),className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${g==="system"?R:F} ${L?"":"opacity-40 cursor-not-allowed"}`,children:s("settings.speech.engine.system")}),e.jsx("button",{onClick:()=>{le(t=>!t),ie||O(!1)},"data-testid":"tts-engine-custom","aria-pressed":g.startsWith("custom-")||ie,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${g.startsWith("custom-")||ie?R:F}`,children:s("settings.speech.engine.custom")}),Ge&&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 · ",s("settings.speech.legacy")]})]}),g==="edge"&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:s("settings.speech.engine.edge_note")})]}),g==="edge"&&e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:s("settings.speech.voice")}),e.jsx("select",{value:y,onChange:t=>{P(t.target.value),i.setSetting("tts_voice_edge",t.target.value)},"data-testid":"tts-voice-select",className:`${G} w-full min-w-0 px-2.5 py-1.5`,children:ft.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))})]}),g==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:s("settings.speech.voice")}),e.jsx("select",{value:o,onChange:t=>{_(t.target.value),i.setSetting("tts_sid_local",t.target.value)},"data-testid":"tts-sid-select",className:`${G} w-full min-w-0 px-2.5 py-1.5`,children:bt.map(t=>e.jsx("option",{value:t.sid,children:t.label},t.sid))})]}),e.jsx("div",{className:v(!1),children:Me("tts-kokoro")})]}),g==="system"&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:s("settings.speech.voice")}),e.jsxs("select",{value:I,onChange:t=>Oe(t.target.value),"data-testid":"tts-system-voice-select",className:`${G} w-full min-w-0 px-2.5 py-1.5`,children:[e.jsx("option",{value:"",children:s("settings.speech.voice_auto")}),A.map(t=>e.jsx("option",{value:t.name,children:ot(t)},t.voiceURI))]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:s("settings.speech.engine.system_note")})]})}),ie&&e.jsx("div",{className:v(!1),children:e.jsxs("div",{className:"space-y-3",children:[Q&&Le(Q,"tts",$,Y,Xe),Q&&e.jsxs("div",{children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:s("settings.speech.voice")}),e.jsx("input",{type:"text",value:B,onChange:t=>V(t.target.value),onBlur:()=>void i.setSetting("tts_custom_voice",B.trim()),placeholder:s("settings.speech.custom_voice_ph"),"data-testid":"tts-custom-voice",className:`${G} w-full min-w-0 px-2.5 py-1.5 font-mono`})]}),!Q&&je.map(t=>e.jsxs("button",{onClick:()=>oe(t.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-${t.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:t.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:t.defaultModel})]},t.id)),(pe||!Q&&je.length===0)&&e.jsx(ke,{kind:"tts",showProtocol:!1,testPrefix:"tts-custom",titleKey:"settings.custom.form_title_tts",modelPhKey:"settings.custom.model_ph_tts",testOverride:t=>i.testCustomTts({baseUrl:t.baseUrl,apiKey:t.apiKey||void 0,model:t.model}),onSaved:t=>{oe(t.id),O(!1),q()},onCancel:()=>O(!1)}),(Q||je.length>0)&&e.jsx("button",{onClick:()=>O(t=>!t),className:"text-label text-accent hover:underline",children:s(pe?"action.cancel":"settings.custom.new")})]})}),e.jsx("div",{className:v(!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:s("settings.speech.speed")}),e.jsx("input",{type:"range",min:"0.5",max:"2",step:"0.05",value:w,onChange:t=>K(t.target.value),onPointerUp:()=>{i.setSetting("tts_speed",w),we()},onKeyUp:()=>{i.setSetting("tts_speed",w),we()},"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(w).toFixed(2),"x"]})]})}),e.jsxs("div",{className:v(!0),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-2",children:s("settings.speech.asr_title")}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>{ve("local"),me(!1),te(!1)},"data-testid":"asr-engine-local","aria-pressed":N==="local",className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${N==="local"?R:F}`,children:s("settings.speech.asr_engine.local")}),e.jsx("button",{onClick:()=>{me(t=>!t),U||te(!1)},"data-testid":"asr-engine-custom","aria-pressed":N.startsWith("custom-")||U,className:`px-4 py-2 rounded-xl text-body font-bold transition-all ${N.startsWith("custom-")||U?R:F}`,children:s("settings.speech.engine.custom")}),Be&&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 · ",s("settings.speech.legacy")]}),qe&&e.jsxs("button",{disabled:!0,"data-testid":"asr-engine-azure",className:"px-4 py-2 rounded-xl text-body font-bold opacity-50 cursor-not-allowed",children:["Azure · ",s("settings.speech.legacy")]})]}),N==="local"?e.jsx("p",{className:"text-label text-ink-muted mt-2",children:s("settings.speech.asr_engine.local_note")}):N.startsWith("custom-")&&e.jsx("p",{className:"text-label text-ink-muted mt-2",children:s("settings.speech.asr_engine.custom_note")})]}),N==="local"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:v(!1),children:[e.jsx("div",{className:"text-label font-medium text-ink-strong mb-1.5",children:s("settings.model")}),e.jsx("select",{value:H,onChange:t=>{Z(t.target.value),i.setSetting("asr_local_model",t.target.value)},"data-testid":"asr-model-select",className:`${G} w-full min-w-0 px-2.5 py-1.5`,children:["asr-whisper-turbo","asr-whisper-small"].map(t=>e.jsxs("option",{value:t,children:[Ie(t)," · ",Ee(Te(t))]},t))})]}),e.jsx("div",{className:v(!1),children:Me(H)})]}),U&&e.jsx("div",{className:v(!1),children:e.jsxs("div",{className:"space-y-3",children:[se&&Le(se,"asr",f,J,He),!se&&Ne.map(t=>e.jsxs("button",{onClick:()=>ve(t.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-${t.id}`,children:[e.jsx("span",{className:"text-label font-medium text-ink-strong",children:t.label}),e.jsx("span",{className:"text-label text-ink-faint font-mono break-all ml-2",children:t.defaultModel})]},t.id)),(fe||!se&&Ne.length===0)&&e.jsx(ke,{kind:"asr",showProtocol:!1,testPrefix:"asr-custom",titleKey:"settings.custom.form_title_asr",modelPhKey:"settings.custom.model_ph_asr",testOverride:t=>i.testCustomAsr({baseUrl:t.baseUrl,apiKey:t.apiKey||void 0,model:t.model}),onSaved:t=>{ve(t.id),te(!1),q()},onCancel:()=>te(!1)}),(se||Ne.length>0)&&e.jsx("button",{onClick:()=>te(t=>!t),className:"text-label text-accent hover:underline",children:s(fe?"action.cancel":"settings.custom.new")})]})}),e.jsxs("div",{className:v(!0),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ae,{checked:ce,onChange:()=>{const t=!ce;ge(t),i.setSetting("asr_auto_stop",t?"1":"0")},label:s("settings.speech.asr_auto_stop"),testid:"asr-auto-stop-toggle"}),e.jsx("div",{className:"text-body font-medium text-ink-strong",children:s("settings.speech.asr_auto_stop")})]}),e.jsx("p",{className:"text-label text-ink-muted mt-2",children:s("settings.speech.asr_ux_note")})]}),d&&e.jsx("div",{className:"px-4 py-3 text-label text-warning break-all",role:"alert",children:d==="engine-unavailable"?s("chat.speech.engine_unavailable"):d})]})}export{yt as SettingsView};
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import{r as n,j as e}from"./index-
|
|
1
|
+
import{r as n,j as e}from"./index-xynt7zMk.js";import{c as f,u as h,e as b,f as g}from"./main-CGE6fm01.js";import{R as j}from"./rotate-ccw-natFwqj6.js";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
7
|
-
* @license lucide-react v0.468.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const y=d("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);function N(t){const a=Math.floor(t/1e3),r=Math.floor(a/60);return`${String(r).padStart(2,"0")}:${String(a%60).padStart(2,"0")}`}function C({view:t,level:a,text:r,onTextChange:x,onSend:p,onRerecord:i,errorMessage:u,sendDisabled:m}){const s=f(),[h,l]=n.useState(0),o=n.useRef(performance.now());return n.useEffect(()=>{o.current=performance.now(),l(0)},[t]),n.useEffect(()=>{if(t!=="recording")return;const c=window.setInterval(()=>l(performance.now()-o.current),250);return()=>window.clearInterval(c)},[t]),e.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-20 rounded-2xl bg-surface-0 shadow-elevated p-4 flex flex-col gap-3",role:"status","aria-live":"polite","data-testid":t==="recording"?"voice-panel-recording":t==="transcribing"?"voice-panel-transcribing":t==="review"?"voice-panel-review":"voice-panel-error",children:[t==="recording"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"w-11 h-11 shrink-0 rounded-full bg-warning/15 text-warning flex items-center justify-center",children:e.jsx(b,{className:"w-5 h-5 animate-pulse"})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-label text-ink-muted",children:[e.jsx("span",{children:s("chat.speech.recording_hint")}),e.jsx("span",{className:"tabular-nums",children:N(h)})]}),e.jsx("span",{className:"block h-2 rounded-full bg-ink/[0.08] overflow-hidden","data-testid":"voice-level",children:e.jsx("span",{className:"block h-full bg-warning transition-[width] duration-100",style:{width:`${Math.round(Math.min(1,a)*100)}%`}})})]})]}),t==="transcribing"&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-body text-ink-muted",children:[e.jsx(j,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:s("chat.speech.transcribing")})]}),t==="review"&&e.jsxs(e.Fragment,{children:[e.jsx("textarea",{value:r,onChange:c=>x(c.target.value),autoFocus:!0,rows:4,"data-testid":"voice-result-text",className:"w-full bg-ink/[0.05] text-body text-ink-strong rounded-xl px-3 py-2 resize-none focus:outline-none focus:bg-ink/[0.08]"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:i,"data-testid":"voice-rerecord",className:"btn-3d-neutral px-4 py-1.5 text-body",children:s("chat.speech.rerecord")}),e.jsxs("button",{type:"button",onClick:p,disabled:m,"data-testid":"voice-send",className:"btn-3d-brand px-4 py-1.5 text-body flex items-center gap-1.5 disabled:opacity-40",children:[e.jsx(y,{className:"w-3.5 h-3.5"}),s("chat.send")]})]})]}),t==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-body text-warning py-1",children:u??s("chat.speech.asr_failed")}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs("button",{type:"button",onClick:i,"data-testid":"voice-rerecord",className:"btn-3d-neutral px-4 py-1.5 text-body flex items-center gap-1.5",children:[e.jsx(g,{className:"w-3.5 h-3.5"}),s("chat.speech.retry")]})})]})]})}export{C as VoicePanel};
|
|
6
|
+
*/const y=f("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);function N(t){const a=Math.floor(t/1e3),r=Math.floor(a/60);return`${String(r).padStart(2,"0")}:${String(a%60).padStart(2,"0")}`}function S({view:t,level:a,text:r,onTextChange:d,onSend:x,onRerecord:i,errorMessage:p,sendDisabled:u}){const s=h(),[m,l]=n.useState(0),o=n.useRef(performance.now());return n.useEffect(()=>{o.current=performance.now(),l(0)},[t]),n.useEffect(()=>{if(t!=="recording")return;const c=window.setInterval(()=>l(performance.now()-o.current),250);return()=>window.clearInterval(c)},[t]),e.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-20 rounded-2xl bg-surface-0 shadow-elevated p-4 flex flex-col gap-3",role:"status","aria-live":"polite","data-testid":t==="recording"?"voice-panel-recording":t==="transcribing"?"voice-panel-transcribing":t==="review"?"voice-panel-review":"voice-panel-error",children:[t==="recording"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"w-11 h-11 shrink-0 rounded-full bg-warning/15 text-warning flex items-center justify-center",children:e.jsx(b,{className:"w-5 h-5 animate-pulse"})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-label text-ink-muted",children:[e.jsx("span",{children:s("chat.speech.recording_hint")}),e.jsx("span",{className:"tabular-nums",children:N(m)})]}),e.jsx("span",{className:"block h-2 rounded-full bg-ink/[0.08] overflow-hidden","data-testid":"voice-level",children:e.jsx("span",{className:"block h-full bg-warning transition-[width] duration-100",style:{width:`${Math.round(Math.min(1,a)*100)}%`}})})]})]}),t==="transcribing"&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-body text-ink-muted",children:[e.jsx(g,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:s("chat.speech.transcribing")})]}),t==="review"&&e.jsxs(e.Fragment,{children:[e.jsx("textarea",{value:r,onChange:c=>d(c.target.value),autoFocus:!0,rows:4,"data-testid":"voice-result-text",className:"w-full bg-ink/[0.05] text-body text-ink-strong rounded-xl px-3 py-2 resize-none focus:outline-none focus:bg-ink/[0.08]"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:i,"data-testid":"voice-rerecord",className:"btn-3d-neutral px-4 py-1.5 text-body",children:s("chat.speech.rerecord")}),e.jsxs("button",{type:"button",onClick:x,disabled:u,"data-testid":"voice-send",className:"btn-3d-brand px-4 py-1.5 text-body flex items-center gap-1.5 disabled:opacity-40",children:[e.jsx(y,{className:"w-3.5 h-3.5"}),s("chat.send")]})]})]}),t==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-body text-warning py-1",children:p??s("chat.speech.asr_failed")}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs("button",{type:"button",onClick:i,"data-testid":"voice-rerecord",className:"btn-3d-neutral px-4 py-1.5 text-body flex items-center gap-1.5",children:[e.jsx(j,{className:"w-3.5 h-3.5"}),s("chat.speech.retry")]})})]})]})}export{S as VoicePanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-
|
|
1
|
+
import{g as p,r as u,d as a}from"./chunk-6Q2QTUOP-CI07iNTB.js";import{p as f}from"./chunk-JWPE2WC7-DJM1SevB.js";import{_ as n,l as o}from"./mermaid.core-BD32Za4p.js";import"./transform-CzGDKG_M.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-Br1TXK2f.js";import"./main-CGE6fm01.js";import"./index-xynt7zMk.js";import"./step-SI6FXFD6.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}},C={parser:R,db:a,renderer:u,styles:p};export{C 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-BAq7zpgL.js";import{p as f}from"./chunk-VII2H2IX-kQVDZD-x.js";import{M as c,b as d}from"./cynefin-OW5HDTMX-GVF3BKWE-Bdt2EF7g.js";import{_ as n,l as o}from"./render-O7CIS3YK-DhYmSGoI.js";import"./transform-CzGDKG_M.js";import"./mermaid-layout-elk.core-BUAJJUsd.js";import"./main-CGE6fm01.js";import"./index-xynt7zMk.js";import"./step-SI6FXFD6.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}},L={parser:R,db:a,renderer:u,styles:p};export{L as diagram};
|