@xopcai/xopc 0.0.454 → 0.0.455
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/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/eventEmitter2.js +40 -0
- package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/index.js +56 -0
- package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/shared/conout.js +16 -0
- package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/terminal.js +190 -0
- package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/unixTerminal.js +287 -0
- package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/utils.js +49 -0
- package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsConoutConnection.js +190 -0
- package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsPtyAgent.js +265 -0
- package/dist/.pnpm/node-pty@1.1.0/node_modules/node-pty/lib/windowsTerminal.js +178 -0
- package/dist/_virtual/_rolldown/runtime.js +10 -2
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-BKH-qNPt.js → activity-store-DYwR1u3f.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DY6IWy0_.js → agent-avatar-dicebear-CsRBprL-.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-display-tnAtQOAZ.js → agent-avatar-display-DqFYHXCS.js} +2 -2
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BLQ2N_dY.js → agent-defaults-settings-panel-DOAJrMLe.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-Bfsm4GOs.js → agent-plugin-dialog-vqlN3ORH.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-CDNiLv0W.js → agents-BgHlOVRV.js} +3 -3
- package/dist/gateway/static/root/assets/{agents-admin-api-DGZsm8U4.js → agents-admin-api-CKscfdvA.js} +1 -1
- package/dist/gateway/static/root/assets/{api-BhipC15e.js → api-CHM2c_Ah.js} +1 -1
- package/dist/gateway/static/root/assets/{api-Bbj5k-7e.js → api-DPNeNCmR.js} +1 -1
- package/dist/gateway/static/root/assets/{app-link-CCZ-LmVT.js → app-link-DImAfVs5.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-fwhXHKxt.js → app-management-settings-panel-Bhz6bj1C.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BHkl-vFO.js → appearance-settings-BX32aogA.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DtCWwdsK.js → apps-page-0Yo3jBsQ.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-B9xaxa7V.js → archive-plugin-Bha8obMe.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-api-BHMjSwcy.js → automation-api-mn8ihWJ_.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-result-state-BgAjEoNV.js → automation-result-state-COzakzak.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-run-list-D3Eon5C0.js → automation-run-list-BhtaMpTb.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-task-card-DJRg72t-.js → automation-task-card-BY_k6iWp.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DdAzXb7s.js → automations-page-Dt_Z1UTT.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-D0nNat6N.js → automations-workspace-BhHgruhH.js} +2 -2
- package/dist/gateway/static/root/assets/{binary-plugins-CgsjdprR.js → binary-plugins-DUbrJFLU.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-r6vj6dZO.js → block-editor-DW--pXAc.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-APCGT8Yr.js → browser-settings-page-CDh6nxs9.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-0gYkjdax.js → capabilities-DKbXv8Ck.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-BgBwcqvY.js → capabilities-kG175Q-7.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-B1x3TwdV.js → capabilities-page-D1wQ2sPI.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BW5jQz5R.js +8 -0
- package/dist/gateway/static/root/assets/{channels-8Y08v4Q2.js → channels-BzZp42yO.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-agents-api-BRQDNNI5.js → chat-agents-api-UOdNWZ0_.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-chart-block-qMGhfeQZ.js → chat-chart-block-NSy-B0NS.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-page-CSTyfO9c.js → chat-page-dY6aCCRx.js} +4 -4
- package/dist/gateway/static/root/assets/{chat-terminal-dock-0PJ9dURQ.js → chat-terminal-dock-CAaHWS7F.js} +1 -1
- package/dist/gateway/static/root/assets/{command-palette-api-C4U_-rDo.js → command-palette-api-Dkn9bbYd.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-model-config-control-B9Q40ptH.js → composer-model-config-control-BrK8-SNz.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-notifications-ByuA8h5Z.js → composer-notifications-B-kL3qAA.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-payload-handoff-zr1JDn3p.js → composer-payload-handoff-DBE1mvOS.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-D2F1quZR.js → computer-settings-page-C9KdEecx.js} +1 -1
- package/dist/gateway/static/root/assets/connected-providers-grid-D_8v6Qex.js +1 -0
- package/dist/gateway/static/root/assets/{connection-usage-guide-DkDsHm_l.js → connection-usage-guide-CiVpcbds.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-1AcvESmp.js → connector-service-page-B919cKSm.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-C1OML7OO.js → connectors-api-CgsSm-Av.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-CMIY0Zj_.js → connectors-page-CEpfDCLA.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-D1eFhoMI.js → date-picker-dx284jQI.js} +1 -1
- package/dist/gateway/static/root/assets/{date-time-picker-CqplKVk6.js → date-time-picker-Dj-bhLNP.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-UmrjWSq-.js → desktop-pet-DlTuGzZ2.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-narrative-B7I1II0Z.js → desktop-pet-narrative-cBFIPXzR.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DRRDJMu6.js → desktop-pet-settings-CsmrvoxU.js} +1 -1
- package/dist/gateway/static/root/assets/{dev-view-store-CtKJMK52.js → dev-view-store-BOxbj1ie.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-C4aSCbqo.js → device-pairing-wizard-CAqFIFRC.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-D9U9yfnb.js → directory-picker-path-field-BxEw5OrT.js} +1 -1
- package/dist/gateway/static/root/assets/{discussion-annotation-sync-D-eGt1_L.js → discussion-annotation-sync-CyntTwIa.js} +1 -1
- package/dist/gateway/static/root/assets/extension-authoritative-grants-C0ReZguU.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-BTLcC8-r.js → extension-debug-page-Cd3HMUbi.js} +1 -1
- package/dist/gateway/static/root/assets/extension-iframe-host-DiIqM2JO.js +1 -0
- package/dist/gateway/static/root/assets/{extension-marketplace-api-DLRCNlej.js → extension-marketplace-api-CK5CMKTs.js} +1 -1
- package/dist/gateway/static/root/assets/extension-message-router-Dn8JzOdR.js +8 -0
- package/dist/gateway/static/root/assets/{extension-page-CdpI-Plq.js → extension-page-CLZtAtqm.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-DUDaMvQg.js → extension-provider-CbVokTvd.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-biWCnMGr.js → extension-settings-page-BM79cwUy.js} +1 -1
- package/dist/gateway/static/root/assets/{file-preview-surface-CnBRiQo8.js → file-preview-surface-z7_HV0WN.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BV5fpBSK.js → gateway-config-swr-OGhON-s6.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-CIqLQXlm.js → gateway-realtime-B9u4uSXW.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-xB7Bq4Zs.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-restart-DBkfCzT5.js → gateway-restart-DKAweWmg.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DTzXUm9f.js → gateway-settings-Dc7qUbG-.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-B49N_Ngm.js → gateway-startup-retry-BaaoKBoB.js} +1 -1
- package/dist/gateway/static/root/assets/{global-defaults-api-DVpxe45P.js → global-defaults-api-BIr3ApRj.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-DvaxBrjG.js → home-page-i_PIrDCU.js} +2 -2
- package/dist/gateway/static/root/assets/{image-generation-api-CAKYslID.js → image-generation-api-C7D2IetZ.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-C2KmQJ2H.js → imports-page-BjEdZJxZ.js} +1 -1
- package/dist/gateway/static/root/assets/index-Bj5exyow.css +1 -0
- package/dist/gateway/static/root/assets/{index-BpzvsoS1.js → index-CZI3VGGW.js} +5 -5
- package/dist/gateway/static/root/assets/{install-connector-dialog-CmNvZt8M.js → install-connector-dialog-BsiyYQhx.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-syG2KRr2.js → keyboard-shortcuts-settings-CIthQ1lp.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DGA4EHGm.js → local-app-workbench-page-CSCIHvZV.js} +1 -1
- package/dist/gateway/static/root/assets/local-apps-DeqzkJiF.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-I0O2ybpp.js → local-apps-page-EntiM0tz.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-DsPDloiq.js → local-session-drafts-XurtjR58.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-D3c8DIm-.js → locale-store-cg9cm2EL.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-u9FTZaTh.js → logs-page-rmS9VSem.js} +1 -1
- package/dist/gateway/static/root/assets/{management-api-uxRxRX-6.js → management-api-B6jVuJ6W.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-BCbDfM7f.js → management-settings-DdI9gs51.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-ohhExTMC.js → markdown-view-D1zBWkfB.js} +1 -1
- package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-382BGqQC.js → mcp-conversation-setup-page-Bn49Ph1n.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-B5wtLz3Z.js → media-plugins-Cd6hAGDp.js} +1 -1
- package/dist/gateway/static/root/assets/messages-eQ2CYlpG.js +3 -0
- package/dist/gateway/static/root/assets/{model-selector-CoKcq0AZ.js → model-selector-CL6WT-jw.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-cache-CtooMAQW.js → models-hub-cache-s0FMNhq9.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-DiGQtSD0.js → note-detail-panel-anM38aV6.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-DfK2KSgu.js +1 -0
- package/dist/gateway/static/root/assets/{notes-api-Cvet94d8.js → notes-api-CR75RHd0.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-DwlmKweX.js → notes-page-BsZmT7Zw.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-api-BHp5dVNh.js → oauth-api-CvPnQTlH.js} +1 -1
- package/dist/gateway/static/root/assets/oauth-provider-connect-Dk1NeeqD.js +1 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-BwsK2uDe.js → page-context-capture-button-BPtX67hZ.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-draft-ieK9IN3R.js → page-context-draft-Ckb8baxj.js} +1 -1
- package/dist/gateway/static/root/assets/page-header-store-DU4NnGap.js +1 -0
- package/dist/gateway/static/root/assets/{personal-avatar-BZSC0BLP.js → personal-avatar-CZSnrSfc.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-CbiD8Wn7.js → personal-page-BSCNuRMT.js} +1 -1
- package/dist/gateway/static/root/assets/personal-profile-settings-DJRDcK2c.js +1 -0
- package/dist/gateway/static/root/assets/{personal-settings-panel-_cxSzWsN.js → personal-settings-panel-C6p25Noq.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-dependencies-card-C2OWtG2B.js → phone-dependencies-card-DKkFFpqi.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-connection-CqmafRhr.js → phone-model-connection-CRRHq4PQ.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-picker-BwYQtl_5.js → phone-model-picker-CN_I0-46.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-settings-page-CPteZZWu.js → phone-settings-page-CkdSOA7D.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-workspace-store-ReUEjG9m.js → phone-workspace-store-CC61pIuJ.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-BlNVtbEU.js → plugin-details-dialog-Bqz4jT53.js} +1 -1
- package/dist/gateway/static/root/assets/{preference-select-fields-BbA-g7Zq.js → preference-select-fields-DHeNbAvn.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-DcPY76PG.js → product-automation-feedback-BN2HTA9T.js} +1 -1
- package/dist/gateway/static/root/assets/{product-delivery-2Ks17_OH.js → product-delivery-BFfqdKLe.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-BBJ7glAm.js → product-open-page-B-j4gpLD.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-UTOSc_ii.js → product-preview-content-EqrTk7kU.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-modal-Q1RZqeMo.js → product-preview-modal-aurFBFq4.js} +2 -2
- package/dist/gateway/static/root/assets/{project-detail-page-BlrtsEZK.js → project-detail-page-ibZZ_w51.js} +1 -1
- package/dist/gateway/static/root/assets/{project-understanding-B35f5MkG.js → project-understanding-HNK9lFVy.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-CBH-sHOU.js → projects-page-CugSyKl5.js} +1 -1
- package/dist/gateway/static/root/assets/providers-api-DUntOOqr.js +1 -0
- package/dist/gateway/static/root/assets/{recording-upload-P1WcsdEY.js → recording-upload-DIwP541B.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-DnVlwJ6M.js → registry-api-BTd_OgbD.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-CVEj3p0J.js → remote-access-hub-f5mIfsBF.js} +1 -1
- package/dist/gateway/static/root/assets/{resource-unavailable-B_S1dFze.js → resource-unavailable-DtQ2rfu_.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-DGmrxJSb.js → route-preload-anuckzRl.js} +2 -2
- package/dist/gateway/static/root/assets/{runtime-tools-api-970sp5zI.js → runtime-tools-api-C1iI8EPo.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-au6vZ0sL.js → runtime-tools-settings-panel-0tdI1z0g.js} +1 -1
- package/dist/gateway/static/root/assets/{service-recommendation-list-XeRFtJ-Z.js → service-recommendation-list-DSIe-NRe.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-CuT7EPI0.js → session-api-CQlEq0MB.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-CyZHiuWY.js → session-manager-C7RfUfqI.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-BIxDwAIX.js → sessions-page-DdS8U0RV.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DnfH22f_.js +1 -0
- package/dist/gateway/static/root/assets/{settings-advanced-section-nbkGHQ_4.js → settings-advanced-section-C6dPu5i1.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-mode-store-EQHfksdV.js → settings-mode-store-BSiiowQa.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-D6RNHRHq.js → settings-page-DAc5n-mM.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-header-19GJ_a45.js → settings-page-header-BSMu5Zq3.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-B2WCzSel.js → settings-page-layout-B_vMffB1.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-interaction-page-C5i7y_pM.js → setup-interaction-page-DKXfFdNt.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-Cwp8YKdT.js → setup-status-panel-BbAZ9w77.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-DDsVTMZ-.js → share-link-dialog-ztX1WPXG.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-C1S_gWGf.js → share-preview-page-Ds2Ydfg6.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-CepTFl1f.js → shares-api-CSZqeNL4.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-Cv-tdcAN.js → shares-settings-CX3TNAmI.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-CsT-iHnl.js → skill-api-CGzAQ-MX.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-list-api-CMJTjvSo.js → skill-list-api-DfUsku-x.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-S6B7P9ur.js → skill-reload-api-Y9qSMnBd.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-BKcsJtYx.js → skills-page-DnMN50Ot.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DhHPM5qU.js → system-settings-panel-DWNkQmme.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-BHH2_Z9_.js → task-detail-page-BJok6V1K.js} +1 -1
- package/dist/gateway/static/root/assets/{task-input-card-D_2rNF31.js → task-input-card-lCMSy6YY.js} +1 -1
- package/dist/gateway/static/root/assets/{terminal-panel-store-CcUWpqvC.js → terminal-panel-store-D8eZPvql.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-D9pquJiM.js → theme-store-GZQ3pTgy.js} +1 -1
- package/dist/gateway/static/root/assets/tool-friendly-title-DC8_9-Lo.js +2 -0
- package/dist/gateway/static/root/assets/{tracing-settings-page-CjNrKILr.js → tracing-settings-page-DM3-7Hlw.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-GtLO40pc.js → tunnel-api-DOGAIXRR.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-activity-store-BhB5wAbq.js → understanding-activity-store-CuPfe0eQ.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-refresh-store-BxtpXRfV.js → understanding-refresh-store-Ihz2p9Vg.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-CZa_a6_7.js → usage-page-BA9Yrvqu.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-BtOp6W9H.js → use-autosave-CO0IPCVg.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-BTQZx8Nj.js → use-composer-attachments-CLIrD0mm.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-B7nscYS4.js → use-file-preview-expanded-dhNMHf5b.js} +3 -3
- package/dist/gateway/static/root/assets/{use-personal-profile-Cj7WGOfv.js → use-personal-profile-CVqDWBDS.js} +1 -1
- package/dist/gateway/static/root/assets/{use-realtime-voice-BS1rygyV.js → use-realtime-voice-DDVVlX1R.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-DYosm4Gz.js → use-workspace-tree-CZej8mhf.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-DmmJODQ4.js → user-model-page-1eYattnk.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-8voN8dQG.js → voice-api-key-field-DpwUDAvu.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-CrZd2aqw.js → voice-config-api-GIuXoHXw.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-input-shortcut-events-DcFp_fy4.js → voice-input-shortcut-events-Cc30ZcFy.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-settings-AckvhNnP.js → voice-settings-DA3m5MT0.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DAIk5csp.js → work-discovery-overlay-yGUkk1NV.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-CJeixeWQ.js → work-discovery-page-RN6iuY-0.js} +1 -1
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-BW76VaD5.js → working-directory-picker-modal-CeXl9w6z.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-Cu2gzmVn.js → workspace-api-B1Uirhxf.js} +2 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-Nos5ebMv.js +1 -0
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-DyqI793w.js → workspace-file-preview-dialog-D0h2yJ3v.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-open-location-menu-DTYkApy8.js → workspace-open-location-menu-DWGNOIE2.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-Rytp_NWV.js → xopc-cloud-account-card-x-XT4bKF.js} +1 -1
- package/dist/gateway/static/root/index.html +91 -91
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/extension-capabilities.js +69 -4
- package/dist/packages/gateway-contract/src/local-app-delegation.js +4 -1
- package/dist/src/agent/agent-manager.js +1 -1
- package/dist/src/agent/child-agent-factory.js +24 -1
- package/dist/src/agent/commands/command-registry.d.ts +10 -0
- package/dist/src/agent/commands/command-registry.js +37 -16
- package/dist/src/agent/commands/command-transport.d.ts +19 -0
- package/dist/src/agent/commands/command-transport.js +92 -0
- package/dist/src/agent/context/project-context.js +1 -1
- package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -0
- package/dist/src/agent/embedded/execution-tool-policy.js +16 -5
- package/dist/src/agent/embedded/index.js +1 -1
- package/dist/src/agent/embedded/run-turn.js +74 -14
- package/dist/src/agent/embedded/runs.d.ts +2 -0
- package/dist/src/agent/embedded/runs.js +8 -1
- package/dist/src/agent/embedded/session-runner.js +2 -2
- package/dist/src/agent/external-tools/endpoint-provider.js +1 -1
- package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js +1 -1
- package/dist/src/agent/orchestration/child-run-monitor.d.ts +35 -0
- package/dist/src/agent/orchestration/child-run-monitor.js +104 -0
- package/dist/src/agent/orchestration/child-run-resume.d.ts +3 -0
- package/dist/src/agent/orchestration/child-run-resume.js +67 -0
- package/dist/src/agent/sandbox/native-command.d.ts +15 -0
- package/dist/src/agent/sandbox/native-command.js +65 -0
- package/dist/src/agent/service/btw-query.d.ts +1 -0
- package/dist/src/agent/service/btw-query.js +1 -1
- package/dist/src/agent/service/direct-turn-helpers.js +2 -2
- package/dist/src/agent/service/process-direct-streaming.js +2 -2
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/session/interaction-policy.d.ts +21 -0
- package/dist/src/agent/session/interaction-policy.js +58 -0
- package/dist/src/agent/session/session-inspector.js +3 -2
- package/dist/src/agent/tools/create-share-tool.js +1 -1
- package/dist/src/agent/tools/exec-command.js +5 -0
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/index.js +1 -1
- package/dist/src/agent/tools/list-dir.js +1 -1
- package/dist/src/agent/tools/managed-job-tool.js +16 -1
- package/dist/src/agent/tools/personal-read-tool.js +1 -1
- package/dist/src/agent/tools/publish-artifacts.js +1 -1
- package/dist/src/agent/tools/read.js +1 -1
- package/dist/src/agent/tools/send-media.js +1 -1
- package/dist/src/agent/tools/write.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +4 -4
- package/dist/src/automations/capabilities/drafts.js +5 -1
- package/dist/src/automations/capabilities/read.js +58 -8
- package/dist/src/automations/capabilities/write.js +53 -0
- package/dist/src/automations/delivery/delivery-router.js +3 -1
- package/dist/src/automations/run-changes.d.ts +2 -0
- package/dist/src/automations/run-changes.js +18 -0
- package/dist/src/automations/service/automation-service.d.ts +2 -9
- package/dist/src/automations/service/automation-service.js +3 -2
- package/dist/src/automations/storage/automation-run-repository.d.ts +5 -0
- package/dist/src/automations/storage/automation-run-repository.js +15 -1
- package/dist/src/capabilities/runtime/dispatcher.d.ts +1 -0
- package/dist/src/capabilities/runtime/product.d.ts +2 -0
- package/dist/src/capabilities/runtime/product.js +26 -6
- package/dist/src/channels/attachments/voice-stt-webchat.js +1 -1
- package/dist/src/chat-commands/types.d.ts +2 -0
- package/dist/src/cli/commands/tui-runner.d.ts +1 -1
- package/dist/src/cli/commands/tui-runner.js +1 -0
- package/dist/src/cli/commands/tui.js +1 -1
- package/dist/src/config/schema.d.ts +1 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +107 -10
- package/dist/src/gateway/hono/routes/imports.js +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +2 -2
- package/dist/src/gateway/hono/routes/local-app-capabilities.js +12 -2
- package/dist/src/gateway/hono/routes/local-app-run-streams.d.ts +4 -0
- package/dist/src/gateway/hono/routes/local-app-run-streams.js +105 -0
- package/dist/src/gateway/hono/routes/sessions.js +2 -2
- package/dist/src/gateway/hono/routes/shares.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +2 -2
- package/dist/src/gateway/hono/routes/tui.js +308 -0
- package/dist/src/gateway/media-access.js +1 -1
- package/dist/src/gateway/security/gateway-scopes.js +1 -1
- package/dist/src/gateway/service/agent-runner.js +1 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
- package/dist/src/gateway/service/sessions-api.d.ts +1 -1
- package/dist/src/gateway/service/sessions-api.js +3 -3
- package/dist/src/gateway/service.js +8 -8
- package/dist/src/gateway/session-reset-service.js +1 -1
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/infra/execution-authority.d.ts +12 -0
- package/dist/src/infra/execution-authority.js +27 -0
- package/dist/src/local-apps/automation-proposals.d.ts +754 -0
- package/dist/src/local-apps/automation-proposals.js +185 -0
- package/dist/src/local-apps/capabilities/automation-policy.d.ts +7 -0
- package/dist/src/local-apps/capabilities/automation-policy.js +46 -0
- package/dist/src/local-apps/capabilities/contracts.js +23 -0
- package/dist/src/local-apps/capabilities/delegate.js +21 -4
- package/dist/src/local-apps/capabilities/projections.d.ts +588 -0
- package/dist/src/local-apps/capabilities/projections.js +135 -2
- package/dist/src/local-apps/capabilities/resource-policy.js +76 -0
- package/dist/src/local-apps/capabilities/runtime.js +2 -1
- package/dist/src/local-apps/execution-authority.d.ts +13 -0
- package/dist/src/local-apps/execution-authority.js +104 -0
- package/dist/src/local-apps/p1-services.d.ts +189 -0
- package/dist/src/local-apps/p1-services.js +620 -0
- package/dist/src/local-apps/preview-sessions.d.ts +1 -1
- package/dist/src/local-apps/preview-sessions.js +2 -2
- package/dist/src/local-apps/preview-worker.js +11 -2
- package/dist/src/local-apps/service.d.ts +81 -1
- package/dist/src/local-apps/service.js +18 -1
- package/dist/src/local-apps/store.js +1 -1
- package/dist/src/notes/agent-context.js +1 -1
- package/dist/src/personal-agent/request-service.js +1 -1
- package/dist/src/personal-agent/task-cancel.js +1 -1
- package/dist/src/platform/contracts.d.ts +3 -3
- package/dist/src/projects/capabilities/read.js +43 -2
- package/dist/src/projects/capabilities/write.js +25 -0
- package/dist/src/projects/project-store.js +12 -1
- package/dist/src/projects/types.d.ts +1 -0
- package/dist/src/review/review-git.js +14 -1
- package/dist/src/share/share-store.js +1 -1
- package/dist/src/share/site-share-store.js +1 -1
- package/dist/src/storage/sqlite/resource-scope.js +2 -2
- package/dist/src/tasks/capabilities/management.js +3 -0
- package/dist/src/tasks/capabilities/write.js +11 -2
- package/dist/src/tasks/index.js +1 -1
- package/dist/src/tui/backend-services.d.ts +14 -0
- package/dist/src/tui/backend-services.js +67 -0
- package/dist/src/tui/backends/embedded-backend.d.ts +48 -4
- package/dist/src/tui/backends/embedded-backend.js +248 -42
- package/dist/src/tui/backends/gateway-realtime-backend.d.ts +46 -2
- package/dist/src/tui/backends/gateway-realtime-backend.js +205 -62
- package/dist/src/tui/components/chat-log.d.ts +1 -0
- package/dist/src/tui/components/chat-log.js +11 -5
- package/dist/src/tui/components/scoped-models-selector.js +1 -1
- package/dist/src/tui/components/session-selector.js +1 -1
- package/dist/src/tui/components/text-viewer.d.ts +32 -0
- package/dist/src/tui/components/text-viewer.js +132 -0
- package/dist/src/tui/components/tui-bottom-bar.js +3 -0
- package/dist/src/tui/extension-host/autocomplete.js +9 -1
- package/dist/src/tui/extension-host/runtime.d.ts +1 -0
- package/dist/src/tui/extension-host/runtime.js +1 -0
- package/dist/src/tui/tui-backend.d.ts +36 -3
- package/dist/src/tui/tui-capabilities.d.ts +15 -0
- package/dist/src/tui/tui-capabilities.js +46 -0
- package/dist/src/tui/tui-capability-controls.d.ts +9 -0
- package/dist/src/tui/tui-capability-controls.js +250 -0
- package/dist/src/tui/tui-clarification.d.ts +15 -0
- package/dist/src/tui/tui-clarification.js +91 -0
- package/dist/src/tui/tui-command-formatters.d.ts +0 -4
- package/dist/src/tui/tui-command-formatters.js +3 -43
- package/dist/src/tui/tui-commands.d.ts +4 -4
- package/dist/src/tui/tui-commands.js +219 -127
- package/dist/src/tui/tui-control-commands.d.ts +12 -0
- package/dist/src/tui/tui-control-commands.js +127 -0
- package/dist/src/tui/tui-image-files.d.ts +2 -0
- package/dist/src/tui/tui-image-files.js +47 -0
- package/dist/src/tui/tui-local-shell.d.ts +6 -0
- package/dist/src/tui/tui-local-shell.js +36 -2
- package/dist/src/tui/tui-management.d.ts +114 -0
- package/dist/src/tui/tui-management.js +233 -0
- package/dist/src/tui/tui-picker-overlay.d.ts +1 -6
- package/dist/src/tui/tui-picker-overlay.js +1 -62
- package/dist/src/tui/tui-session-actions.d.ts +1 -0
- package/dist/src/tui/tui-session-actions.js +97 -29
- package/dist/src/tui/tui-settings.js +1 -1
- package/dist/src/tui/tui-side-chat.d.ts +10 -0
- package/dist/src/tui/tui-side-chat.js +56 -0
- package/dist/src/tui/tui-terminal.d.ts +3 -0
- package/dist/src/tui/tui-terminal.js +52 -0
- package/dist/src/tui/tui-types.d.ts +4 -1
- package/dist/src/tui/tui.js +422 -211
- package/dist/src/tui/xopc-tui-keybindings.d.ts +29 -9
- package/dist/src/tui/xopc-tui-keybindings.js +27 -7
- package/dist/src/usage/recorder.js +2 -0
- package/package.json +2 -1
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CZ78ckHR.js +0 -8
- package/dist/gateway/static/root/assets/connected-providers-grid-CgULhOBZ.js +0 -1
- package/dist/gateway/static/root/assets/extension-authoritative-grants-8ONVOjPW.js +0 -1
- package/dist/gateway/static/root/assets/extension-iframe-host-D0-OvFV2.js +0 -1
- package/dist/gateway/static/root/assets/extension-message-router-DboLTCVp.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-B6T1Xzag.js +0 -1
- package/dist/gateway/static/root/assets/index-B49yIcMR.css +0 -1
- package/dist/gateway/static/root/assets/local-apps-CB-MZAaL.js +0 -1
- package/dist/gateway/static/root/assets/messages-DPLud9GK.js +0 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-Ds4M9fJJ.js +0 -1
- package/dist/gateway/static/root/assets/oauth-provider-connect-cvxtmf3C.js +0 -1
- package/dist/gateway/static/root/assets/page-header-store-Xe8CP_4a.js +0 -1
- package/dist/gateway/static/root/assets/personal-profile-settings-KvdNnaNv.js +0 -1
- package/dist/gateway/static/root/assets/providers-api-BSmKlQ8K.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-Cy7xeKmH.js +0 -1
- package/dist/gateway/static/root/assets/tool-friendly-title-YQmN1S2k.js +0 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-pVOYuH7u.js +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-CdRzEUwF.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{f as a,l as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as u,i as d,l as f,n as p,o as m}from"./locale-store-cg9cm2EL.js";import{t as h}from"./messages-eQ2CYlpG.js";import{a as g,i as _,n as v,o as y,r as b,s as x,t as S}from"./dist-CY7CS_D3.js";import{t as C}from"./arrow-right-DSSvoX71.js";import{t as w}from"./arrow-up-right-T72JbQ1Q.js";import{t as T}from"./chevron-right-BweFrslA.js";import{n as E,r as D,t as O}from"./popover-select-CLsphyzA.js";import{t as k}from"./circle-check-C23XjkUj.js";import{C as A,S as j,T as M,_ as N,a as P,b as F,c as I,d as L,f as ee,g as R,h as z,i as B,l as V,m as H,n as te,o as ne,p as U,r as re,s as W,t as ie,u as ae,v as oe,w as se,x as G,y as ce}from"./connected-providers-grid-D_8v6Qex.js";import{t as K}from"./cloud-C4-yfnnk.js";import{t as le}from"./external-link-DjqjBmc3.js";import{t as ue}from"./secret-input-DsjfQmDn.js";import{t as de}from"./eye-CABVeTq0.js";import{t as q}from"./image-Cwyalflz.js";import{t as fe}from"./key-round-DWbpyU2U.js";import{t as pe}from"./loader-circle-CifKLtgG.js";import{t as me}from"./pencil-DmIY3Oa-.js";import{t as he}from"./plug-DKYPEgkR.js";import{t as ge}from"./plus-Q2yW6OE7.js";import{t as _e}from"./refresh-cw-BRlGaq2w.js";import{t as ve}from"./settings-2-D-csvaET.js";import{t as ye}from"./shield-check-BU58siTV.js";import{t as be}from"./sliders-horizontal-DqsYor6I.js";import{t as xe}from"./trash-2-DusmjVPV.js";import{t as Se}from"./triangle-alert-2JXFNNKU.js";import{t as Ce}from"./wrench-DFb4r8bH.js";import{t as we}from"./x-B_N4OPjy.js";import{t as J}from"./cn-0WouolD0.js";import{t as Y}from"./skeleton-DzdOeGYz.js";import{t as Te}from"./voice-CDlC6XMH.js";import{i as X}from"./vendor-swr-CdRzEUwF.js";import{n as Ee,r as De}from"./gateway-config-swr-OGhON-s6.js";import{n as Oe,t as ke}from"./registry-api-BTd_OgbD.js";import{t as Z}from"./button-Cc4hUNTt.js";import{i as Ae,o as je}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as Me}from"./open-capability-settings-DQsmJxI7.js";import{n as Ne,t as Pe}from"./interaction-BdhHBbYa.js";import{n as Fe,t as Ie}from"./voice-settings-DA3m5MT0.js";import{a as Le,o as Re,s as ze}from"./form-field-width-DJw_jULe.js";import{n as Be}from"./is-masked-secret-DOkL5b_X.js";import{n as Ve,t as He}from"./secret-input-labels-B5Jl5HqK.js";import{a as Ue}from"./navigation-ByOzYT0t.js";import{t as We}from"./electron-env-DHOGevH3.js";import{n as Ge,t as Ke}from"./settings-form-draft-Dy10ldo8.js";import{t as qe}from"./sliding-tab-list-CmcrqRzN.js";import{t as Je}from"./confirm-dialog-DrA5mTQp.js";import{n as Ye,t as Xe}from"./model-sort-_Tz8s_4N.js";import{n as Ze,r as Qe}from"./model-selector-CL6WT-jw.js";import{n as $e}from"./agents-app-path-ciChvpCS.js";import{n as et,t as tt}from"./global-defaults-api-BIr3ApRj.js";import{t as nt}from"./settings-loading-skeleton-CAoOV17i.js";import{i as rt,n as it,r as at,t as ot}from"./capability-navigation-QtHJxxW2.js";import{i as st,r as ct,t as lt}from"./models-hub-cache-s0FMNhq9.js";import{a as ut,r as dt,s as ft,t as pt}from"./providers-api-DUntOOqr.js";import{a as mt,i as ht,n as gt,o as _t,r as vt,t as yt}from"./oauth-api-CvPnQTlH.js";import{t as bt}from"./settings-advanced-section-C6dPu5i1.js";import{n as xt,r as St,t as Ct}from"./oauth-authorization-window-o6URRos4.js";import{t as wt}from"./number-input-El7Szeln.js";import{n as Tt,t as Et}from"./settings-page-header-BSMu5Zq3.js";import"./settings-page-layout-B_vMffB1.js";import{n as Dt,t as Ot}from"./settings-form-section-num14vSv.js";import{n as kt,t as At}from"./use-autosave-CO0IPCVg.js";import{c as jt,h as Mt,l as Nt,n as Pt,o as Ft,t as It}from"./voice-config-api-GIuXoHXw.js";import{a as Lt,i as Rt,n as zt,o as Bt,r as Vt,s as Ht,t as Ut}from"./image-generation-api-C7D2IetZ.js";import{t as Wt}from"./xopc-cloud-account-card-x-XT4bKF.js";var Gt=n(),Q=e(t(),1),$=r(),Kt={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},qt=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function Jt(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function Yt(e){let t=e.split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function Xt({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a,portalContainer:o,onPendingChange:s}){let c=Kt[i],[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(``),[h,C]=(0,Q.useState)(`bearer`),[T,E]=(0,Q.useState)(`x-api-key`),[D,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(``),[M,N]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(`/images/generations`),[I,L]=(0,Q.useState)(`/images/edits`),[ee,R]=(0,Q.useState)(``),[z,B]=(0,Q.useState)(``),[V,H]=(0,Q.useState)([Jt()]),[te,ne]=(0,Q.useState)(``),[U,re]=(0,Q.useState)(),[W,ie]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(),[se,G]=(0,Q.useState)(),[ce,K]=(0,Q.useState)();(0,Q.useEffect)(()=>(s?.(!!U),()=>s?.(!1)),[U,s]),(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;u(n?.providerId??``),f(t?.name??``),m(n?.baseUrl??``),C(t?.auth.type??`bearer`),E(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),k(r?`••••••••••••`:``),j(t?.apiKeyUrl??``),N(t?.documentationUrl??``),F(t?.paths?.generations??`/images/generations`),L(t?.paths?.edits??`/images/edits`),R(t?.network?.allowedHosts.join(`
|
|
4
|
+
`)??``),B(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
5
|
+
`)),H(t?.models.map(Jt)??[Jt()]),ne(t?.defaultModel??``),G(void 0),re(void 0),ie(!1),oe(void 0),K(void 0)},[r,e,n]);let le=(0,Q.useMemo)(()=>V.filter(e=>e.id.trim()).sort(Ye).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[V]),q=(e,t)=>{H(n=>n.map((n,r)=>r===e?{...n,...t}:n))},fe=()=>{let e=l.trim(),t=V.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!d.trim()||!p.trim()||t.some(e=>!e.id))throw Error(c.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(c.duplicateModels);let n=te||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(c.required);let r;try{r=Yt(z)}catch{throw Error(c.invalidHeaders)}return{providerId:e,input:{baseUrl:p.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:d.trim(),...M.trim()?{documentationUrl:M.trim()}:{},...A.trim()?{apiKeyUrl:A.trim()}:{},defaultModel:n,auth:h===`header`?{type:`header`,headerName:T.trim()}:{type:h},paths:{...P.trim()?{generations:P.trim()}:{},...I.trim()?{edits:I.trim()}:{}},...ee.trim()?{network:{allowedHosts:ee.split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(Boolean)}}:{},models:t.map(e=>({...e.original,id:e.id,...e.name?{name:e.name}:{name:void 0},capabilities:{...e.original.capabilities,generate:{...e.original.capabilities.generate,maxCount:Math.max(1,Number.parseInt(e.maxCount,10)||1),supportsSize:e.supportsSize},edit:{...e.original.capabilities.edit,enabled:e.editEnabled}},defaults:{...e.original.defaults,...e.defaultCount?{count:Math.max(1,Number.parseInt(e.defaultCount,10)||1)}:{count:void 0},...e.defaultSize.trim()?{size:e.defaultSize.trim()}:{size:void 0},...e.outputFormat?{outputFormat:e.outputFormat}:{outputFormat:void 0}}}))}}}},me=async()=>{let e=fe();return await Rt(e.providerId,e.input),h!==`none`&&D.trim()&&!Be(D)&&await Lt(e.providerId,D.trim()),await a(e.providerId),e},he=async()=>{re(`save`),oe(void 0),G(void 0);try{await me(),k(h===`none`?``:`••••••••••••`),G(c.saved)}catch(e){oe(e instanceof Error?e.message:String(e))}finally{re(void 0)}},_e=async()=>{re(`test`),oe(void 0),G(void 0),K(void 0);try{let e=await me(),t=await Bt(e.providerId,e.input.imageGeneration.defaultModel);K(t.images[0]?.dataUrl),G(c.testReady)}catch(e){oe(e instanceof Error?e.message:String(e))}finally{re(void 0)}},ve=async()=>{if(n){if(!W){ie(!0);return}re(`delete`),oe(void 0);try{await Ut(n.providerId),await a(),t(!1)}catch(e){oe(e instanceof Error?e.message:String(e))}finally{re(void 0)}}};return(0,$.jsx)(S,{open:e,onOpenChange:e=>{U||t(e)},children:(0,$.jsxs)(y,{container:o,children:[(0,$.jsx)(g,{className:J(`xopc-dialog-overlay fixed inset-0 bg-scrim`,je)}),(0,$.jsxs)(b,{className:J(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(88vh,760px)] w-[min(calc(100%-2rem),52rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,Ae),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(x,{className:`font-semibold text-fg`,children:n?c.editTitle:c.addTitle}),(0,$.jsx)(_,{className:`mt-1 text-sm text-fg-muted`,children:c.intro})]}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,disabled:!!U,className:`rounded-md p-1 text-fg-muted hover:bg-surface-inset hover:text-fg`,"aria-label":c.cancel,children:(0,$.jsx)(we,{className:`size-5`})})})]}),(0,$.jsxs)(`fieldset`,{disabled:!!U,className:`min-h-0 min-w-0 flex-1 space-y-6 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:c.connection}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.providerId,(0,$.jsx)(`input`,{value:l,disabled:!!n,onChange:e=>u(e.target.value),placeholder:`my-image-service`,className:qt}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.name,(0,$.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`My Image Service`,className:qt})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[c.baseUrl,(0,$.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`https://api.example.com/v1`,className:qt})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.auth,(0,$.jsx)(O,{value:h,options:[{value:`bearer`,label:c.bearer},{value:`header`,label:c.header},{value:`none`,label:c.none}],placeholder:c.auth,allowEmpty:!1,onChange:e=>C(e),triggerClassName:`mt-1.5`})]}),h===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.headerName,(0,$.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),className:qt})]}):null]}),h===`none`?null:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-image-api-key`,className:`text-xs font-medium text-fg-muted`,children:c.apiKey}),A.trim()?(0,$.jsxs)(`a`,{href:A.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[c.openKeyPage,(0,$.jsx)(w,{className:`size-3.5`})]}):null]}),(0,$.jsx)(ue,{id:`custom-image-api-key`,value:D,onChange:e=>k(Be(D)?e.replace(/^•+/,``):e),labels:{show:c.show,hide:c.hide,copy:c.copy,copied:c.copied},reveal:()=>ft(l).then(e=>e.apiKey),loadFailedLabel:c.revealFailed,notInConfigFile:c.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:c.apiKeyHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.apiKeyUrl,(0,$.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:`https://…`,className:qt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.docsUrl,(0,$.jsx)(`input`,{value:M,onChange:e=>N(e.target.value),placeholder:`https://…`,className:qt})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:c.paths}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.generationsPath,(0,$.jsx)(`input`,{value:P,onChange:e=>F(e.target.value),className:qt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.editsPath,(0,$.jsx)(`input`,{value:I,onChange:e=>L(e.target.value),className:qt})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[c.allowedHosts,(0,$.jsx)(`textarea`,{value:ee,onChange:e=>R(e.target.value),rows:2,placeholder:`127.0.0.1
|
|
7
|
+
image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[c.staticHeaders,(0,$.jsx)(`textarea`,{value:z,onChange:e=>B(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.staticHeadersHint})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:c.models}),(0,$.jsxs)(Z,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>H(e=>[...e,Jt()]),children:[(0,$.jsx)(ge,{className:`size-4`}),c.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[c.defaultModel,(0,$.jsx)(O,{value:te||V.find(e=>e.id.trim())?.id.trim()||``,options:le,placeholder:c.defaultModel,allowEmpty:!1,onChange:ne,triggerClassName:`mt-1.5 max-w-sm`})]}),V.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>q(t,{id:e.target.value}),placeholder:`image-1`,className:qt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>q(t,{name:e.target.value}),className:qt})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>q(t,{maxCount:e.target.value}),className:qt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>q(t,{defaultCount:e.target.value}),className:qt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>q(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:qt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.format,(0,$.jsx)(O,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:c.format,allowEmpty:!0,onChange:e=>q(t,{outputFormat:e}),triggerClassName:`mt-1.5`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.supportsSize,onChange:e=>q(t,{supportsSize:e.target.checked})}),c.supportsSize]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.editEnabled,onChange:e=>q(t,{editEnabled:e.target.checked})}),c.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:V.length===1,onClick:()=>H(e=>e.filter((e,n)=>n!==t)),className:`ml-auto inline-flex items-center gap-1 text-xs text-red-600 disabled:opacity-40 dark:text-red-400`,children:[(0,$.jsx)(xe,{className:`size-3.5`}),c.remove]})]})]},t))]}),ce?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(de,{className:`size-4`}),c.testReady]}),(0,$.jsx)(`img`,{src:ce,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,se?(0,$.jsx)(`p`,{className:`rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:se}):null,ae?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:ae}):null]}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-5 py-3`,children:[n?(0,$.jsxs)(Z,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!U,onClick:()=>void ve(),children:[U===`delete`?(0,$.jsx)(pe,{className:`size-4 animate-spin`}):(0,$.jsx)(xe,{className:`size-4`}),W?c.confirmDelete:c.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(Z,{variant:`secondary`,disabled:!!U,children:c.cancel})}),(0,$.jsxs)(Z,{variant:`secondary`,disabled:!!U,onClick:()=>void _e(),children:[U===`test`?(0,$.jsx)(pe,{className:`size-4 animate-spin`}):null,U===`test`?c.testing:c.test]}),(0,$.jsxs)(Z,{variant:`primary`,disabled:!!U,onClick:()=>void he(),children:[U===`save`?(0,$.jsx)(pe,{className:`size-4 animate-spin`}):null,U===`save`?c.saving:c.save]})]})]})]})]})})}var Zt=`••••••••••••`,Qt={en:{title:`Image generation`,intro:`Configure the default image model and service. Agents inherit this setting unless overridden in Agent settings.`,provider:`Provider`,model:`Model`,apiKey:`API key`,getApiKey:`Get API key`,apiKeyHint:`Stored in the local credential store, never in xopc.json.`,existingKey:`A credential or environment variable is already available. Leave this blank to reuse it.`,savedKey:`A credential is saved. Use the eye button to view it, or type a new key to replace it.`,revealFailed:`Unable to load the saved API key.`,keyNotRevealable:`This credential comes from an environment variable or another non-revealable source.`,advanced:`Provider settings`,enable:`Enable image generation`,enabling:`Verifying and enabling…`,enabled:`Image generation is ready.`,addService:`Add image service`,manageService:`Manage service`,custom:`Custom`,current:`Current`,configured:`Credential ready`,needsKey:`API key required`,connect:`Connect to a gateway to continue.`,loadError:`Unable to load image generation settings.`,selectModel:`Select a model`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`},zh:{title:`图片生成`,intro:`配置全局图片生成模型和服务。各智能体默认继承此设置,也可在智能体详情中单独覆盖。`,provider:`Provider`,model:`模型`,apiKey:`API Key`,getApiKey:`获取 API Key`,apiKeyHint:`密钥只保存在本机凭据存储中,不会写入 xopc.json。`,existingKey:`已有凭据或环境变量;留空即可继续使用。`,savedKey:`凭据已保存。点击眼睛可查看,直接输入新密钥可替换。`,revealFailed:`无法读取已保存的 API Key。`,keyNotRevealable:`当前凭据来自环境变量或其他不可查看的来源。`,advanced:`服务商设置`,enable:`启用图片生成`,enabling:`正在验证并启用…`,enabled:`图片生成已可用。`,addService:`添加图片服务`,manageService:`管理服务`,custom:`自定义`,current:`当前使用`,configured:`凭据已就绪`,needsKey:`需要 API Key`,connect:`请先连接网关。`,loadError:`无法加载图片生成设置。`,selectModel:`选择模型`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`}};async function $t(){let e=await m(d(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function en(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function tn(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function nn(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function rn(e){let t=(0,Gt.c)(11),{field:n,value:r,onChange:i}=e,a;t[0]!==n.label||t[1]!==n.options||t[2]!==n.placeholder||t[3]!==n.required||t[4]!==n.type||t[5]!==i||t[6]!==r?(a=n.type===`select`?(0,$.jsx)(O,{value:r,options:(n.options??[]).map(an),placeholder:n.placeholder??n.label,allowEmpty:!n.required,onChange:i,triggerClassName:`mt-1.5`}):(0,$.jsx)(`input`,{type:`url`,value:r,required:n.required,onChange:e=>i(e.target.value),placeholder:n.placeholder,className:`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[0]=n.label,t[1]=n.options,t[2]=n.placeholder,t[3]=n.required,t[4]=n.type,t[5]=i,t[6]=r,t[7]=a):a=t[7];let o;return t[8]!==n.label||t[9]!==a?(o=(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[n.label,a]}),t[8]=n.label,t[9]=a,t[10]=o):o=t[10],o}function an(e){return{value:e.value,label:e.label}}function on(){let e=(0,Gt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Y,{className:`h-24 rounded-xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[t,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:5}).map(sn)}),(0,$.jsx)(Y,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function sn(e,t){return(0,$.jsx)(Y,{className:`h-24 rounded-xl`},t)}function cn({connectOnly:e=!1,onConnected:t,onPendingChange:n}={}){let r=p(e=>e.language),a=Qt[r],o=!!f(e=>e.conversationId),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)({}),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,T]=(0,Q.useState)(null);(0,Q.useEffect)(()=>(n?.(y||x),()=>n?.(!1)),[y,x,n]);let[E,D]=(0,Q.useState)(),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(),{data:I,isLoading:L,error:ee,mutate:R}=X(o?d(`/api/image-generation/catalog`):null,Vt,{revalidateOnFocus:!1}),{data:z,isLoading:B,error:V,mutate:H}=X(o?d(`/api/image-generation/custom-providers`):null,zt,{revalidateOnFocus:!1}),{data:te,isLoading:ne,error:U,mutate:re}=X(o?`default-image-generation`:null,$t,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!I||!te)return;let e=en(te.model?.primary),t=I.find(t=>t.id===e)??I.find(e=>e.configured)??I[0];t&&(c(t.id),u(t.id===e&&tn(te.model?.primary)||t.defaultModel),g(t.configured?Zt:``),v(nn(t)))},[te,I]);let W=I?.find(e=>e.id===s),ie=W?W.apiKeyUrl??ce(W.id,r)[0]?.href:void 0,ae=(0,Q.useMemo)(()=>[...W?.models??[]].sort(Xe).map(e=>({value:e,label:e})),[W?.models]),oe=te?.model?.primary,se=!!(W&&l&&(W.credentialMode!==`api-key`||W.configured||h.trim())&&W.configFields.every(e=>!e.required||_[e.key]?.trim()));if(!o)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.connect});if(L||B||ne)return(0,$.jsx)(on,{});if(ee||V||U||!I||!z)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a.loadError});let G=e=>{c(e.id),u(e.defaultModel),g(e.configured?Zt:``),v(nn(e)),D(void 0)},K=()=>{F(void 0),N(!0)},le=()=>{let e=z.find(e=>e.providerId===W?.id);e&&(F(e),N(!0))},de=async n=>{let[r,i]=await Promise.all([H(),R()]);if(n&&i?.some(e=>e.id===n)){let a=i.find(e=>e.id===n);c(a.id),u(a.defaultModel),g(a.configured?Zt:``),v(nn(a)),F(r?.find(e=>e.providerId===n)),e&&a.configured&&t?.()}},me=async()=>{if(!(!W||!se)){b(!0),D(void 0),j(!1);try{if(e){h.trim()&&!Be(h)&&await Lt(W.id,h.trim()),Object.keys(_).length&&await m(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:{[W.id]:_}})});let[e]=await Promise.all([R(),Ee()]);if(!e?.find(e=>e.id===W.id)?.configured)throw Error(r===`zh`?`连接尚未就绪,请先完成对应服务的授权或凭据设置。`:`Connection is not ready. Complete authorization or credentials first.`);j(!0),t?.();return}let n=await m(d(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:W.id,modelId:l,...h.trim()&&!Be(h)?{apiKey:h.trim()}:{},providerConfig:Object.fromEntries(Object.entries(_).filter(([,e])=>e.trim()))})});if(!n.payload)throw Error(`Invalid setup response`);await Promise.all([re(n.payload.default,{revalidate:!1}),R(n.payload.providers,{revalidate:!1}),i(async()=>{let{mutate:e}=await import(`./vendor-swr-CdRzEUwF.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([0,1,2])).then(({mutate:e})=>Promise.all([e(`settings-agent-defaults`),e(`settings-gateway-agents`)])),Ee()]),g(Zt),j(!0)}catch(e){D(e instanceof Error?e.message:String(e))}finally{b(!1)}}};return(0,$.jsxs)(`div`,{ref:T,className:`flex flex-col gap-4`,children:[(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,$.jsx)(q,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:e?r===`zh`?`连接图片来源,不修改默认模型,也不发送生成测试请求。`:`Connect image sources without changing defaults or sending generation tests.`:a.intro})]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:a.provider}),(0,$.jsxs)(Z,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:K,children:[(0,$.jsx)(ge,{className:`size-4`}),a.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:I.map(e=>{let t=e.id===s,n=e.id===en(oe);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>G(e),className:`min-h-24 rounded-xl p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${t?`bg-accent-soft shadow-surface`:`bg-surface-base/55 hover:bg-surface-hover`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-[10px] text-fg-subtle`,children:a.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!n,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${n?``:`invisible`}`,children:a.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(k,{className:`size-3.5`}):(0,$.jsx)(fe,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?a.configured:a.needsKey]})]},e.id)})})]}),W?(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[e?null:(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a.model,(0,$.jsx)(O,{value:l,options:ae,placeholder:a.selectModel,allowEmpty:!1,onChange:u,triggerClassName:`mt-1.5`})]}),W.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(rn,{field:e,value:_[e.key]??``,onChange:t=>v(n=>({...n,[e.key]:t}))},e.key))]}),W.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(Z,{variant:`secondary`,onClick:le,children:[(0,$.jsx)(ve,{className:`size-4`}),a.manageService]})}):null,W.credentialMode===`api-key`?(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`image-generation-api-key`,className:`text-xs font-medium text-fg-muted`,children:a.apiKey}),ie?(0,$.jsxs)(`a`,{href:ie,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[a.getApiKey,(0,$.jsx)(w,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(ue,{id:`image-generation-api-key`,value:h,onChange:e=>g(Be(h)?e.replace(/^•+/,``):e),placeholder:W.configured?a.existingKey:a.needsKey,labels:{show:a.show,hide:a.hide,copy:a.copy,copied:a.copied},reveal:()=>ft(W.id).then(e=>e.apiKey),loadFailedLabel:a.revealFailed,notInConfigFile:a.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},W.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:W.configured?a.savedKey:a.apiKeyHint})]}):null,W.configFields.some(e=>!e.required)?(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(be,{className:`size-4`}),a.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:W.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(rn,{field:e,value:_[e.key]??``,onChange:t=>v(n=>({...n,[e.key]:t}))},e.key))})]}):null,A?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:e?r===`zh`?`连接已保存`:`Connection saved`:a.enabled}):null,E?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:E}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(Z,{variant:`primary`,disabled:!se||y,onClick:()=>void me(),children:[y?(0,$.jsx)(pe,{className:`size-4 animate-spin`}):(0,$.jsx)(k,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:a.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:a.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:e?y?r===`zh`?`保存中…`:`Saving…`:r===`zh`?`保存图片连接`:`Save image connection`:y?a.enabling:a.enable})]})]})})]}):null,(0,$.jsx)(Xt,{portalContainer:C?.closest(`[role="dialog"]`),onPendingChange:S,open:M,onOpenChange:N,provider:P,configured:!!(P&&I.find(e=>e.id===P.providerId)?.configured),language:r,onSaved:de})]})}function ln(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function un(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map((e,t)=>{let n=e&&typeof e==`object`?e:{},r=n.type,i=r===`brave`||r===`tavily`||r===`bing`||r===`searxng`||r===`deepseek`?r:`brave`;return{clientKey:`search-provider-${t}`,type:i,apiKey:typeof n.apiKey==`string`?n.apiKey:``,url:typeof n.url==`string`?n.url:``,disabled:n.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function dn(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return(e.type===`searxng`||e.type===`deepseek`)&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await m(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),Ee()}async function fn(e){let t=await m(d(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function pn(e){let t=(0,Gt.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function mn(){return J(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,ze,`dark:border-edge`)}function hn(){return J(Re,Le)}var gn=[`brave`,`tavily`,`bing`,`searxng`,`deepseek`];function _n(){return{clientKey:crypto.randomUUID(),type:`brave`,apiKey:``,url:``,disabled:!1}}var vn=Ke();function yn(){let e=h(p(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!f(e=>e.conversationId),[i,a]=(0,Q.useReducer)(vn,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),l=(0,Q.useRef)(o);l.current=o;let u=(0,Q.useRef)(null),{data:d,error:m,isLoading:g,mutate:_}=De(r);Ge({enabled:r,parsed:(0,Q.useMemo)(()=>d?.payload?.config===void 0?null:un(d.payload.config),[d]),dirty:c.current,trackedParsedRef:u,dispatch:a,onResetDirty:()=>{c.current=!1}});let v=!!(r&&g&&d===void 0&&!m),y=m instanceof Error?m.message:m?String(m):null,b=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),x=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),S=At({value:o,dirty:b,onSave:(0,Q.useCallback)(async e=>{try{await dn(e),a({type:`saved`,value:e}),c.current=!!(l.current&&JSON.stringify(l.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});if(!r)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(v)return(0,$.jsx)(nt,{rows:3});if(!o)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y??t.loadError}),(0,$.jsx)(Z,{type:`button`,variant:`secondary`,onClick:()=>void _(),children:n.refresh})]});let C=ln(o.providers);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,onBlurCapture:S.onBlurCapture,children:[S.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S.error}):null,(0,$.jsxs)(Ot,{children:[(0,$.jsx)(Dt,{icon:he,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(kt,{status:S.status,error:S.error})}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-base/55 px-4 py-3`,children:[(0,$.jsx)(K,{className:`mt-0.5 size-5 shrink-0 text-accent`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.cloudProvider}),(0,$.jsx)(`span`,{className:J(`rounded-full px-2 py-0.5 text-[11px] font-medium`,C?`bg-surface-panel text-fg-muted`:`bg-accent-soft text-accent`),children:C?t.cloudOverridden:t.cloudAutomatic})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-subtle`,children:C?t.cloudOverriddenHint:t.cloudAutomaticHint})]})]}),(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(bn,{row:n,providerIndex:r,labels:t,secretLabels:Ve(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,x({providers:t})},onRemove:()=>{x({providers:o.providers.filter((e,t)=>t!==r)})}},n.clientKey??r)),(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>x({providers:[...o.providers,_n()]}),children:[(0,$.jsx)(ge,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(Ot,{children:[(0,$.jsx)(Dt,{icon:be,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(pn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(E,{className:hn(),value:o.regionMode,onChange:e=>x({regionMode:e.target.value}),children:[(0,$.jsx)(D,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(D,{value:`cn`,children:t.regionCn}),(0,$.jsx)(D,{value:`global`,children:t.regionGlobal})]})}),(0,$.jsx)(bt,{title:t.maxResultsLabel,summary:o.maxResults,children:(0,$.jsx)(pn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(wt,{type:`number`,min:1,max:50,className:mn(),value:o.maxResults,onChange:e=>x({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})})})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.sectionBlocklist,` · `,o.blocklistEnabled?o.blocklistDomains.length:0]}),(0,$.jsxs)(Ot,{children:[(0,$.jsx)(Dt,{icon:ye,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:o.blocklistEnabled,onChange:e=>x({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),o.blocklistEnabled?(0,$.jsx)(pn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:J(mn(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
|
|
8
|
+
`),placeholder:t.blocklistDomainsPlaceholder,onChange:e=>{let t=e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]});x({blocklistDomains:t})}})}):null]})]})]})]})}function bn(e){let t=(0,Gt.c)(56),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>fn(r).then(xn),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=J(hn(),`min-w-[8rem]`),t[2]=u):u=t[2];let d=n.type,f;t[3]!==o||t[4]!==n?(f=e=>o({...n,type:e.target.value,url:``,apiKey:``}),t[3]=o,t[4]=n,t[5]=f):f=t[5];let p;t[6]===i.providerTypes?p=t[7]:(p=gn.map(e=>(0,$.jsx)(D,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=p);let m;t[8]!==n.type||t[9]!==f||t[10]!==p?(m=(0,$.jsx)(E,{className:u,value:d,onChange:f,children:p}),t[8]=n.type,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]!==o||t[13]!==n?(h=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=h):h=t[14];let g;t[15]!==n.disabled||t[16]!==h?(g=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.disabled,onChange:h}),t[15]=n.disabled,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==i.disabled||t[19]!==g?(_=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[g,i.disabled]}),t[18]=i.disabled,t[19]=g,t[20]=_):_=t[20];let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(xe,{className:`size-4`}),t[21]=v):v=t[21];let y;t[22]===s?y=t[23]:(y=(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:v}),t[22]=s,t[23]=y);let b;t[24]!==y||t[25]!==_?(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_,y]}),t[24]=y,t[25]=_,t[26]=b):b=t[26];let x;t[27]!==b||t[28]!==m?(x=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[m,b]}),t[27]=b,t[28]=m,t[29]=x):x=t[29];let S;t[30]!==i.deepseekUrlDesc||t[31]!==i.deepseekUrlLabel||t[32]!==i.urlDesc||t[33]!==i.urlLabel||t[34]!==o||t[35]!==n?(S=n.type===`searxng`||n.type===`deepseek`?(0,$.jsx)(pn,{label:n.type===`deepseek`?i.deepseekUrlLabel:i.urlLabel,description:n.type===`deepseek`?i.deepseekUrlDesc:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:mn(),value:n.url,placeholder:n.type===`deepseek`?`https://api.deepseek.com`:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.deepseekUrlDesc,t[31]=i.deepseekUrlLabel,t[32]=i.urlDesc,t[33]=i.urlLabel,t[34]=o,t[35]=n,t[36]=S):S=t[36];let C;t[37]!==o||t[38]!==n?(C=e=>o({...n,apiKey:e}),t[37]=o,t[38]=n,t[39]=C):C=t[39];let w;t[40]!==i.keyPlaceholder||t[41]!==i.keyPlaceholderMasked||t[42]!==i.saveError||t[43]!==l||t[44]!==n.apiKey||t[45]!==a||t[46]!==C?(w=(0,$.jsx)(ue,{value:n.apiKey,onChange:C,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[40]=i.keyPlaceholder,t[41]=i.keyPlaceholderMasked,t[42]=i.saveError,t[43]=l,t[44]=n.apiKey,t[45]=a,t[46]=C,t[47]=w):w=t[47];let T;t[48]!==i.apiKeyDesc||t[49]!==i.apiKeyLabel||t[50]!==w?(T=(0,$.jsx)(pn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:w}),t[48]=i.apiKeyDesc,t[49]=i.apiKeyLabel,t[50]=w,t[51]=T):T=t[51];let O;return t[52]!==x||t[53]!==S||t[54]!==T?(O=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/60 p-4`,children:[x,S,T]}),t[52]=x,t[53]=S,t[54]=T,t[55]=O):O=t[55],O}function xn(e){return e.apiKey??null}function Sn(e,t,n=[]){return e.filter(e=>!n.includes(e.providerId)&&e.uses.some(e=>e.id===t&&e.choices.length>0))}function Cn(e){let t=(0,Gt.c)(75),{use:n,data:r,language:i,labels:a,onSaved:o,inline:s,onPendingChange:c,onEditingChange:l}=e,u=s!==void 0&&s,d=i===`zh`,[f,p]=(0,Q.useState)(),[m,h]=(0,Q.useState)(!1),g;t[0]===c?g=t[1]:(g=e=>{h(e),c?.(e)},t[0]=c,t[1]=g);let _=g,v=n===`transcription`?`stt`:n===`speech`?`tts`:void 0,y,b,x;if(t[2]!==r.builtinRows||t[3]!==r.cards||t[4]!==r.customConfig?.providers||t[5]!==r.loading||t[6]!==n){let e=new Set(r.cards.filter(e=>!U(e.id)||!!r.customConfig?.providers?.[e.id]).map(Mn));y=[...new Set([...r.builtinRows.map(jn),...e])].filter(t=>!U(t)||e.has(t)).sort(),b=X,x=r.loading?null:[`capability-service-connections`,n,y.join(`,`)],t[2]=r.builtinRows,t[3]=r.cards,t[4]=r.customConfig?.providers,t[5]=r.loading,t[6]=n,t[7]=y,t[8]=b,t[9]=x}else y=t[7],b=t[8],x=t[9];let S;t[10]!==y||t[11]!==n||t[12]!==v?(S=async()=>{let e=v===`stt`?await jt():v===`tts`?await Ft():void 0,t=e?.providers.filter(An).map(kn),r=e?.providers.filter(On).map(Dn)??[],i=t?y.filter(e=>t.includes(e)):y,a=await Promise.allSettled(i.map(j));return{services:Sn(a.flatMap(En),n,r),failed:a.some(Tn)}},t[10]=y,t[11]=n,t[12]=v,t[13]=S):S=t[13];let C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},t[14]=C):C=t[14];let{data:w,error:T,isLoading:E,mutate:D}=b(x,S,C),O;t[15]===w?.services?O=t[16]:(O=new Set(w?.services.map(wn)),t[15]=w?.services,t[16]=O);let k=O,A,M;if(t[17]!==l||t[18]!==f?(A=()=>(l?.(!!f),()=>l?.(!1)),M=[f,l],t[17]=l,t[18]=f,t[19]=A,t[20]=M):(A=t[19],M=t[20]),(0,Q.useEffect)(A,M),f&&u){let e;if(t[21]!==r.builtinRows||t[22]!==f){let n;t[24]===f?n=t[25]:(n=e=>e.id===f,t[24]=f,t[25]=n),e=r.builtinRows.find(n),t[21]=r.builtinRows,t[22]=f,t[23]=e}else e=t[23];let a;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>p(void 0),t[26]=a):a=t[26];let s;t[27]!==D||t[28]!==o?(s=()=>{D(),p(void 0),o()},t[27]=D,t[28]=o,t[29]=s):s=t[29];let c;return t[30]!==i||t[31]!==f||t[32]!==_||t[33]!==e||t[34]!==s||t[35]!==n?(c=(0,$.jsx)(`section`,{className:`overflow-hidden rounded-xl border border-edge`,children:(0,$.jsx)(P,{inline:!0,providerId:f,row:e,targetUse:n,language:i,onPendingChange:_,onDone:a,onApplied:s},f)}),t[30]=i,t[31]=f,t[32]=_,t[33]=e,t[34]=s,t[35]=n,t[36]=c):c=t[36],c}let N=d?`选择服务`:`Choose a service`,F;t[37]===N?F=t[38]:(F=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:N}),t[37]=N,t[38]=F);let I;t[39]!==r.loading||t[40]!==E?(I=r.loading||E?(0,$.jsx)(Y,{className:`h-24 w-full`}):null,t[39]=r.loading,t[40]=E,t[41]=I):I=t[41];let L;t[42]!==w?.failed||t[43]!==T||t[44]!==D||t[45]!==d?(L=T||w?.failed?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:[d?`部分服务目录暂时不可用。`:`Some service catalogs are unavailable.`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void D(),children:d?`重试`:`Retry`})]}):null,t[42]=w?.failed,t[43]=T,t[44]=D,t[45]=d,t[46]=L):L=t[46];let ee;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ee=[!0,!1],t[47]=ee):ee=t[47];let R;t[48]!==m||t[49]!==w?.services||t[50]!==d?(R=ee.map(e=>{let t=w?.services.filter(t=>t.configured===e)??[];return t.length?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:e?d?`已连接`:`Connected`:d?`添加服务`:`Add a service`}),t.map(t=>(0,$.jsxs)(`button`,{type:`button`,disabled:m,onClick:()=>p(t.providerId),className:`flex min-h-14 w-full items-center justify-between gap-3 rounded-lg px-3 py-3 text-left transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-sm font-medium text-fg`,children:V(t.providerId,t.profile.name,d)}),(0,$.jsx)(`span`,{className:`shrink-0 text-sm text-accent-fg`,children:e?d?`选择`:`Choose`:d?`连接`:`Connect`})]},t.providerId))]},String(e)):null}),t[48]=m,t[49]=w?.services,t[50]=d,t[51]=R):R=t[51];let z;t[52]!==w||t[53]!==d?(z=w&&!w.services.length&&!w.failed?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d?`暂无支持此能力的模型服务。`:`No model services currently support this capability.`}):null,t[52]=w,t[53]=d,t[54]=z):z=t[54];let B=d?`仅列出支持${it[n][0]}的服务。`:`Only compatible services are shown. Reuse saved credentials, then return to select a model.`,H;t[55]===B?H=t[56]:(H=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:B}),t[55]=B,t[56]=H);let te;t[57]!==r.builtinRows||t[58]!==r.customConfig||t[59]!==k||t[60]!==a||t[61]!==i||t[62]!==D||t[63]!==o||t[64]!==f||t[65]!==n?(te=f?(0,$.jsx)(re,{open:!0,initialProviderId:f,initialUse:n,connectOnly:!0,onOpenChange:e=>{e||p(void 0)},builtinRows:r.builtinRows.filter(e=>k.has(e.id)),customConfig:r.customConfig,labels:a,language:i,onSaved:()=>{D(),p(void 0),o()}},f):null,t[57]=r.builtinRows,t[58]=r.customConfig,t[59]=k,t[60]=a,t[61]=i,t[62]=D,t[63]=o,t[64]=f,t[65]=n,t[66]=te):te=t[66];let ne;return t[67]!==F||t[68]!==I||t[69]!==L||t[70]!==R||t[71]!==z||t[72]!==H||t[73]!==te?(ne=(0,$.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[F,I,L,R,z,H,te]}),t[67]=F,t[68]=I,t[69]=L,t[70]=R,t[71]=z,t[72]=H,t[73]=te,t[74]=ne):ne=t[74],ne}function wn(e){return e.providerId}function Tn(e){return e.status===`rejected`}function En(e){return e.status===`fulfilled`?[e.value]:[]}function Dn(e){return e.id}function On(e){return e.diagnostics.requiresApiKey}function kn(e){return e.id}function An(e){return!e.diagnostics.requiresApiKey}function jn(e){return e.id}function Mn(e){return e.id}function Nn({zh:e,kind:t,modelServiceIds:n,onSaved:r,onPendingChange:i}){let{data:a,error:o,mutate:s}=X([`native-voice-connections`,t??`all`,n.join(`,`)],async()=>{let[e,r]=await Promise.all([t===`tts`?Promise.resolve({providers:[]}):jt(),t===`stt`?Promise.resolve({providers:[]}):Ft()]);return[...e.providers.map(e=>({...e,kind:`stt`})),...r.providers.map(e=>({...e,kind:`tts`}))].filter(e=>e.diagnostics.requiresApiKey||!n.includes(e.id))}),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)({}),[p,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(!1),[_,v]=(0,Q.useState)(``);(0,Q.useEffect)(()=>(i?.(p),()=>i?.(!1)),[p,i]);let y=a?.find(e=>`${e.kind}:${e.id}`===c),b=y?.fields.filter(e=>e.secret||e.type===`password`||[`baseUrl`,`region`,`groupId`].includes(e.key))??[],x=async()=>{if(!(!y||g.current)){g.current=!0,h(!0),v(``);try{let t=Object.fromEntries(Object.entries(u).filter(([,e])=>e.trim()).map(([e,t])=>[e,t.trim()]));Object.keys(t).length&&await m(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({[y.kind]:{providers:{[y.id]:t}}})});let[n]=await Promise.all([s(),st()]);if(!n?.find(e=>e.kind===y.kind&&e.id===y.id)?.configured)throw Error(e?`连接尚未就绪,请补齐所需凭据。`:`Connection is not ready. Complete the required credentials.`);f({}),r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g.current=!1,h(!1)}}};return a&&!a.length?null:(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e?`其他语音服务与本地语音`:`Other voice services and local speech`}),(0,$.jsxs)(`section`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t===`stt`?e?`其他识别服务`:`Other recognition services`:t===`tts`?e?`其他合成服务与本地语音`:`Other synthesis services and local speech`:e?`语音 API 与本地语音`:`Voice APIs and local speech`}),!a&&!o?(0,$.jsx)(Y,{className:`h-20 w-full`}):null,o?(0,$.jsxs)(`p`,{role:`alert`,children:[e?`语音服务加载失败`:`Could not load voice services`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void s(),children:e?`重试`:`Retry`})]}):null,(0,$.jsxs)(E,{value:c,disabled:p,"aria-label":e?`语音服务接入`:`Connect voice service`,onChange:e=>{l(e.target.value),f({}),v(``)},children:[(0,$.jsx)(D,{value:``,children:e?`选择语音来源`:`Choose a voice source`}),a?.map(n=>(0,$.jsxs)(D,{value:`${n.kind}:${n.id}`,children:[n.displayName,t?``:` · ${n.kind.toUpperCase()}`,n.configured?e?` · 已连接`:` · Connected`:``]},`${n.kind}:${n.id}`))]}),y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:y.diagnostics.requiresApiKey?e?`此服务使用独立的 API Key。保存连接后,可在“模型与参数”中选用。`:`This service uses its own API key. Save the connection, then choose it in Model and parameters.`:e?`此来源无需 API Key,可返回能力设置选择。`:`No API key needed. Choose this source in capability settings.`}),b.map(t=>(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm text-fg`,children:[(0,$.jsx)(`span`,{children:t.label}),t.secret||t.type===`password`?(0,$.jsx)(ue,{labels:He,value:u[t.key]??``,onChange:e=>f(n=>({...n,[t.key]:e})),disabled:p}):t.options?.length?(0,$.jsxs)(E,{value:u[t.key]??``,disabled:p,onChange:e=>f(n=>({...n,[t.key]:e.target.value})),children:[(0,$.jsx)(D,{value:``,children:e?`保留现有值`:`Keep existing`}),(t.key===`model`?[...t.options].sort(Ye):t.options).map(e=>(0,$.jsx)(D,{value:e.id,children:e.name},e.id))]}):(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel p-2`,value:u[t.key]??``,disabled:p,placeholder:t.placeholder,onChange:e=>f(n=>({...n,[t.key]:e.target.value}))})]},t.key)),_?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:_}):null,(0,$.jsx)(Z,{disabled:p||!y.configured&&y.diagnostics.requiresApiKey&&!Object.values(u).some(e=>e.trim()),onClick:()=>void x(),children:p?e?`保存中…`:`Saving…`:e?`保存连接`:`Save connection`})]}):null]})]})}var Pn=`clear-natural-model`;function Fn({label:e,value:t,currentLabel:n,options:r,loading:i,disabled:a,zh:o,onConnect:s,onSelect:c}){let[l,u]=(0,Q.useState)(``),d=l.trim().toLowerCase().split(/\s+/).filter(Boolean),f=[...r].sort((e,t)=>(e.group??``).localeCompare(t.group??``,`en`,{numeric:!0,sensitivity:`base`})||Xe(e.label,t.label)||Xe(e.value,t.value)).filter(e=>{let t=`${e.label} ${e.group} ${e.value} ${e.searchText??``}`.toLowerCase();return d.every(e=>t.includes(e))}),p=r.find(e=>e.value===t),m=p?.group??r.find(e=>e.value.split(`/`)[0]===t?.split(`/`)[0])?.group,h=p?.label??(t?.endsWith(`/default`)?o?`默认模型`:`Default model`:n??t),g=m?`${h} · ${m}`:h;return!i&&!r.length?(0,$.jsx)(Z,{variant:`secondary`,className:`min-h-11 w-full sm:justify-start`,"aria-label":`${o?`连接`:`Connect`} ${e}`,disabled:a,onClick:s,children:o?`连接服务以启用`:`Connect a service to enable`}):(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(O,{value:t??``,options:f,selectedLabel:h,title:g,placeholder:o?`选择模型`:`Choose a model`,ariaLabel:`${o?`选择`:`Select`} ${e}`,allowEmpty:!1,disabled:a,loading:i,onChange:c,searchPlaceholder:o?`搜索模型或服务`:`Search models or services`,searchValue:l,onSearchChange:u,statusMessage:f.length?void 0:o?`没有可用模型`:`No available models`,triggerClassName:`min-h-11`}),m?(0,$.jsx)(`p`,{className:`px-1 text-xs text-fg-muted`,children:m}):null]})}function In({data:e,zh:t,onChange:n,onSettings:r,onlyUse:i,disabled:a=!1,onPendingChange:o}){let{data:s,error:c,mutate:l}=X(`settings-agent-defaults`,tt),{data:u}=De(!0),{data:f,mutate:p}=X(!i||i===`conversation`?d(It):null,Pt),{data:m,isLoading:h,error:g,mutate:_}=X(`model-capability-media-sources`,async()=>{let e=await Promise.allSettled([Ft(),jt(),Vt()]);return{ids:[...new Set(e.flatMap(e=>e.status===`fulfilled`?(Array.isArray(e.value)?e.value:e.value.providers).filter(e=>e.configured).map(e=>e.id):[]))],failed:e.some(e=>e.status===`rejected`)}}),v=[...new Set([...e.cards.filter(t=>t.configured&&(!U(t.id)||!!e.customConfig?.providers?.[t.id])).map(e=>e.id),...m?.ids??[]])].sort(),{data:y,isLoading:b,mutate:x}=X(e.loading?null:[`model-use-choices`,...v],async()=>{let e=await Promise.allSettled(v.map(j));return{previews:e.flatMap(e=>e.status===`fulfilled`&&e.value.configured?[e.value]:[]),failed:e.some(e=>e.status===`rejected`)}},{revalidateOnFocus:!1}),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),E=(0,Q.useRef)(!1),D=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>o?.(!1),[o]);let O=async(e,t)=>{if(E.current||a)return;let n=y?.previews.find(n=>n.uses.some(n=>n.id===e&&n.choices.some(e=>e.id===t))),r=e===`conversation`&&(t===`boson/higgs-realtime`||t===Pn);if(!n&&!r)return;E.current=!0,o?.(!0),C(e),T(null);let i={mode:`replace`,selected:[e],overrides:{[e]:t}};try{if(r)await p(await Mt({defaultForNatural:t===Te}),{revalidate:!1}),await Ee();else if(n){let t=await A(n.providerId,i);await G(n.providerId,i,t.revision),await Promise.all([l(),x(),...e===`conversation`?[p(),Ee()]:[]])}T({use:e})}catch(t){T({use:e,error:t instanceof Error?t.message:String(t)}),Promise.allSettled([l(),x()])}finally{E.current=!1,C(null),o?.(!1),requestAnimationFrame(()=>D.current?.querySelector(`[data-capability="${e}"] button[aria-label]`)?.focus())}},k=u?.payload?.config?Nt(u.payload.config):void 0;if(!s&&!c)return(0,$.jsx)(Y,{className:`h-48 w-full rounded-xl`});if(c)return(0,$.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[t?`模型用途加载失败`:`Could not load model uses`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void l(),children:t?`重试`:`Retry`})]});let M=s.defaults.models,N=k?.voice.realtime,P=N?.enabled&&N.omni?`${N.omni.provider}/${N.omni.model}`:void 0,F=f?.defaultForNatural??N?.boson?.defaultForNatural?Te:P,L=M.background?.primary??M.chat.primary,ee=e.builtinRows.find(e=>e.id===L.split(`/`)[0])?.setupProfile?.interactiveOnly!==!0,R=y?.previews[0]?.uses.find(e=>e.id===`background`),z=R?R.current:ee?L:void 0,B=[{id:`chat`,label:t?`对话与任务`:`Chat and tasks`,ref:M.chat.primary},{id:`vision`,label:t?`看图`:`Image understanding`,ref:M.imageUnderstanding?.primary},{id:`image`,label:t?`画图`:`Image generation`,ref:M.imageGeneration?.primary},{id:`background`,label:t?`后台任务`:`Background tasks`,ref:z,inherited:!M.background&&!!z},{id:`transcription`,label:t?`录音与听写`:`Recording and dictation`,ref:k?.stt.enabled?`${k.stt.provider}/${k.stt.providers?.[k.stt.provider]?.model??`default`}`:void 0},{id:`speech`,label:t?`语音合成`:`Speech synthesis`,ref:k?.tts.enabled?`${k.tts.provider}/${k.tts.providers?.[k.tts.provider]?.model??`default`}`:void 0},{id:`conversation`,label:t?`自然语音模型`:`Natural voice model`,ref:F}];return(0,$.jsxs)(`section`,{ref:D,className:`@container min-w-0`,children:[(0,$.jsx)(`h2`,{className:i?`mb-2 text-sm font-semibold text-fg`:`sr-only`,children:i?t?`当前模型`:`Current model`:t?`能力总览`:`Capabilities`}),(0,$.jsx)(`div`,{className:i?`space-y-4`:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:ot.filter(e=>!i||e.uses.includes(i)).map(o=>(0,$.jsxs)(`section`,{className:i?`min-w-0`:`min-w-0 border-t border-edge first:border-t-0`,children:[i?null:(0,$.jsxs)(`div`,{className:`flex items-center justify-between bg-surface-inset/55 px-4 py-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:o.label[+!t]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.uses[0]===`chat`?t?`基础能力`:`Core capability`:t?`按需启用`:`Optional`})]}),(0,$.jsx)(`div`,{className:i?`divide-y divide-edge-subtle`:`divide-y divide-edge-subtle px-4`,children:o.uses.filter(e=>!i||e===i).map(o=>{let s=B.find(e=>e.id===o),c=Ln(y?.previews??[],s.id,t);s.id===`conversation`&&((f?.credentialSource||s.ref===`boson/higgs-realtime`)&&c.push({value:Te,label:`Higgs Realtime`,group:`Boson AI`,disabled:!f?.credentialSource}),s.ref===`boson/higgs-realtime`&&!c.some(e=>e.value!==`boson/higgs-realtime`)&&c.push({value:Pn,label:t?`取消默认模型`:`Clear default model`}));let l=s.ref?e.allModels.find(e=>e.id===s.ref):void 0,u=l?Qe(l,t?`zh`:`en`):s.ref;return(0,$.jsx)(`div`,{"data-capability":s.id,children:(0,$.jsxs)(`div`,{className:i?`py-2`:`grid grid-cols-1 items-center gap-x-3 gap-y-2 py-3 @min-[40rem]:gap-x-4 ${r?`@min-[40rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)_auto]`:`@min-[40rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)]`}`,children:[(0,$.jsxs)(`div`,{className:i?`hidden`:`col-start-1 row-start-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:it[s.id][+!t]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:s.ref?c.some(e=>e.value===s.ref||s.ref?.endsWith(`/default`)&&e.value.split(`/`)[0]===s.ref.split(`/`)[0])?null:t?`待连接`:`Connection needed`:t?`未配置`:`Not set up`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:I[s.id][+!t]}),s.inherited?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t?`继承默认对话`:`Inherits chat default`}):null]}),(0,$.jsxs)(`div`,{className:i?`w-full min-w-0 space-y-1`:`row-start-2 w-full min-w-0 space-y-1 @min-[40rem]:col-span-1 @min-[40rem]:col-start-2 @min-[40rem]:row-start-1`,children:[(0,$.jsx)(Fn,{label:s.id===`conversation`?s.label:it[s.id][+!t],value:s.ref,currentLabel:u,options:c,loading:e.loading||b||h,disabled:S!==null||a,zh:t,onConnect:()=>n(s.id),onSelect:e=>{e!==s.ref&&O(s.id,e)}}),S===s.id?(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:t?`正在切换…`:`Switching…`}):null,w?.use===s.id?(0,$.jsx)(`div`,{role:w.error?`alert`:`status`,className:`text-xs text-fg-muted`,children:w.error?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-danger`,children:t?`未能切换模型,请重试。`:`Could not switch models. Please retry.`}),(0,$.jsxs)(`details`,{className:`mt-1`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:t?`查看详情`:`Show details`}),(0,$.jsx)(`p`,{className:`mt-1 break-words`,children:w.error})]})]}):t?`已切换`:`Model changed`}):null]}),r&&(s.id===`conversation`||c.length>0||b||h)?(0,$.jsxs)(`div`,{className:`row-start-3 flex flex-wrap items-center justify-end gap-1 @min-[40rem]:col-start-3 @min-[40rem]:row-start-1`,children:[(0,$.jsx)(Z,{variant:`ghost`,disabled:S!==null||a,onClick:()=>r(s.id),children:t?`设置`:`Settings`}),(0,$.jsx)(Z,{variant:`ghost`,disabled:S!==null||a,onClick:()=>n(s.id),children:t?`管理服务`:`Manage services`})]}):null]})},s.id)})})]},o.uses[0]))}),(!r||i)&&(y?.failed||m?.failed||g)?(0,$.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:[t?`部分服务的模型加载失败`:`Some model services could not be loaded`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void Promise.all([_(),x()]),children:t?`重试`:`Retry`})]}):null,i||r?null:(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t?`快速与复杂任务模型随对话配置;音色、流式听写及电脑操作可在详细设置中调整。`:`Fast and complex task models follow chat setup. Voices, streaming dictation and Computer Use have detailed settings.`})]})}function Ln(e,t,n=!1){return e.flatMap(e=>e.uses.find(e=>e.id===t)?.choices.map(t=>({value:t.id,label:t.name,group:V(e.providerId,e.profile.name,n),searchText:e.profile.name}))??[])}function Rn(e){let t=(0,Gt.c)(208),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=p(Bn)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:R(``),t[0]=n,t[1]=l);let[u,d]=(0,Q.useState)(l),[f,m]=(0,Q.useState)(zn),h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{d(n=>({...n,[e]:t})),m(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=h):h=t[2];let g=h,_;t[3]!==u.computerUse||t[4]!==u.contextWindow||t[5]!==u.id||t[6]!==u.input||t[7]!==u.maxTokens||t[8]!==s.modelIdRequired||t[9]!==s.mustBePositive||t[10]!==c?(_=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,s.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),u.computerUse&&!u.input?.includes(`image`)&&e.set(`computerUse`,c?`电脑控制模型必须支持图片输入`:`Computer Use requires image input`),m(e),e.size===0},t[3]=u.computerUse,t[4]=u.contextWindow,t[5]=u.id,t[6]=u.input,t[7]=u.maxTokens,t[8]=s.modelIdRequired,t[9]=s.mustBePositive,t[10]=c,t[11]=_):_=t[11];let y=_,b;t[12]!==u||t[13]!==o||t[14]!==a||t[15]!==y?(b=()=>{if(!y())return;let e=(u.id||``).trim(),t={...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}};a(t),o()},t[12]=u,t[13]=o,t[14]=a,t[15]=y,t[16]=b):b=t[16];let S=b,C=u,w;t[17]===C?w=t[18]:(w=H(C),t[17]=C,t[18]=w);let T=w,O=r?s.addModelTitle:s.editModelTitle,k;t[19]===O?k=t[20]:(k=(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:O}),t[19]=O,t[20]=k);let A;t[21]!==s.modelProviderLabel||t[22]!==i?(A=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[21]=s.modelProviderLabel,t[22]=i,t[23]=A):A=t[23];let j;t[24]!==k||t[25]!==A?(j=(0,$.jsxs)(`div`,{children:[k,A]}),t[24]=k,t[25]=A,t[26]=j):j=t[26];let M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=J(Pe,`p-1.5 hover:bg-surface-base`),t[27]=M):M=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(we,{className:`size-4`}),t[28]=N):N=t[28];let P;t[29]===s.close?P=t[30]:(P=(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:M,"aria-label":s.close,children:N})}),t[29]=s.close,t[30]=P);let F;t[31]!==j||t[32]!==P?(F=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[j,P]}),t[31]=j,t[32]=P,t[33]=F):F=t[33];let I;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=I):I=t[34];let B;t[35]===s.modelId?B=t[36]:(B=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,I]}),t[35]=s.modelId,t[36]=B);let V;t[37]===f?V=t[38]:(V=J(L(),f.has(`id`)&&`border-red-500`),t[37]=f,t[38]=V);let te=u.id||``,ne;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>g(`id`,e.target.value),t[39]=ne):ne=t[39];let U=!r,re;t[40]!==V||t[41]!==te||t[42]!==U?(re=(0,$.jsx)(`input`,{className:V,value:te,onChange:ne,placeholder:`e.g. llama3.1:8b`,disabled:U}),t[40]=V,t[41]=te,t[42]=U,t[43]=re):re=t[43];let W;t[44]===f?W=t[45]:(W=f.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[44]=f,t[45]=W);let ie;t[46]!==B||t[47]!==re||t[48]!==W?(ie=(0,$.jsxs)(`div`,{children:[B,re,W]}),t[46]=B,t[47]=re,t[48]=W,t[49]=ie):ie=t[49];let oe;t[50]===s.displayName?oe=t[51]:(oe=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=oe);let se;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(se=L(),t[52]=se):se=t[52];let G=u.name||``,ce;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>g(`name`,e.target.value),t[53]=ce):ce=t[53];let K;t[54]===G?K=t[55]:(K=(0,$.jsx)(`input`,{className:se,value:G,onChange:ce}),t[54]=G,t[55]=K);let le;t[56]!==oe||t[57]!==K?(le=(0,$.jsxs)(`div`,{children:[oe,K]}),t[56]=oe,t[57]=K,t[58]=le):le=t[58];let ue;t[59]===s.inputTypes?ue=t[60]:(ue=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=ue);let de;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(de=z(),t[61]=de):de=t[61];let q;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(q=e=>g(`input`,ee(e.target.value)),t[62]=q):q=t[62];let fe;t[63]===s?fe=t[64]:(fe=ae.map(e=>(0,$.jsx)(D,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=fe);let pe;t[65]!==T||t[66]!==fe?(pe=(0,$.jsx)(E,{className:de,value:T,onChange:q,children:fe}),t[65]=T,t[66]=fe,t[67]=pe):pe=t[67];let me;t[68]!==ue||t[69]!==pe?(me=(0,$.jsxs)(`div`,{children:[ue,pe]}),t[68]=ue,t[69]=pe,t[70]=me):me=t[70];let he=u.reasoning||!1,ge;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>g(`reasoning`,e.target.checked),t[71]=ge):ge=t[71];let _e;t[72]===he?_e=t[73]:(_e=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:he,onChange:ge}),t[72]=he,t[73]=_e);let ve;t[74]!==s.reasoning||t[75]!==_e?(ve=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[_e,s.reasoning]}),t[74]=s.reasoning,t[75]=_e,t[76]=ve):ve=t[76];let ye;t[77]!==me||t[78]!==ve?(ye=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[me,ve]}),t[77]=me,t[78]=ve,t[79]=ye):ye=t[79];let be;t[80]===s.contextWindow?be=t[81]:(be=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=be);let xe;t[82]===f?xe=t[83]:(xe=J(L(),f.has(`contextWindow`)&&`border-red-500`),t[82]=f,t[83]=xe);let Se=u.contextWindow??128e3,Ce;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=e=>g(`contextWindow`,parseInt(e.target.value,10)||0),t[84]=Ce):Ce=t[84];let Y;t[85]!==xe||t[86]!==Se?(Y=(0,$.jsx)(wt,{type:`number`,min:1,className:xe,value:Se,onChange:Ce}),t[85]=xe,t[86]=Se,t[87]=Y):Y=t[87];let Te;t[88]===f?Te=t[89]:(Te=f.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[88]=f,t[89]=Te);let X;t[90]!==be||t[91]!==Y||t[92]!==Te?(X=(0,$.jsxs)(`div`,{children:[be,Y,Te]}),t[90]=be,t[91]=Y,t[92]=Te,t[93]=X):X=t[93];let Ee;t[94]===s.maxOutputTokens?Ee=t[95]:(Ee=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[94]=s.maxOutputTokens,t[95]=Ee);let De;t[96]===f?De=t[97]:(De=J(L(),f.has(`maxTokens`)&&`border-red-500`),t[96]=f,t[97]=De);let Oe=u.maxTokens??16384,ke;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(ke=e=>g(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=ke):ke=t[98];let Ae;t[99]!==De||t[100]!==Oe?(Ae=(0,$.jsx)(wt,{type:`number`,min:1,className:De,value:Oe,onChange:ke}),t[99]=De,t[100]=Oe,t[101]=Ae):Ae=t[101];let je;t[102]===f?je=t[103]:(je=f.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[102]=f,t[103]=je);let Me;t[104]!==Ee||t[105]!==Ae||t[106]!==je?(Me=(0,$.jsxs)(`div`,{children:[Ee,Ae,je]}),t[104]=Ee,t[105]=Ae,t[106]=je,t[107]=Me):Me=t[107];let Ne;t[108]!==X||t[109]!==Me?(Ne=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[X,Me]}),t[108]=X,t[109]=Me,t[110]=Ne):Ne=t[110];let Fe;t[111]===s.costSection?Fe=t[112]:(Fe=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=Fe);let Ie;t[113]===s.costInput?Ie=t[114]:(Ie=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Ie);let Le;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(Le=L(),t[115]=Le):Le=t[115];let Re=u.cost?.input??0,ze;t[116]===u.cost?ze=t[117]:(ze=e=>g(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[116]=u.cost,t[117]=ze);let Be;t[118]!==Re||t[119]!==ze?(Be=(0,$.jsx)(wt,{type:`number`,step:`any`,min:0,className:Le,value:Re,onChange:ze}),t[118]=Re,t[119]=ze,t[120]=Be):Be=t[120];let Ve;t[121]!==Ie||t[122]!==Be?(Ve=(0,$.jsxs)(`div`,{children:[Ie,Be]}),t[121]=Ie,t[122]=Be,t[123]=Ve):Ve=t[123];let He;t[124]===s.costOutput?He=t[125]:(He=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=He);let Ue;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=L(),t[126]=Ue):Ue=t[126];let We=u.cost?.output??0,Ge;t[127]===u.cost?Ge=t[128]:(Ge=e=>g(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[127]=u.cost,t[128]=Ge);let Ke;t[129]!==We||t[130]!==Ge?(Ke=(0,$.jsx)(wt,{type:`number`,step:`any`,min:0,className:Ue,value:We,onChange:Ge}),t[129]=We,t[130]=Ge,t[131]=Ke):Ke=t[131];let qe;t[132]!==He||t[133]!==Ke?(qe=(0,$.jsxs)(`div`,{children:[He,Ke]}),t[132]=He,t[133]=Ke,t[134]=qe):qe=t[134];let Je;t[135]!==Ve||t[136]!==qe?(Je=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Ve,qe]}),t[135]=Ve,t[136]=qe,t[137]=Je):Je=t[137];let Ye;t[138]!==Fe||t[139]!==Je?(Ye=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Fe,Je]}),t[138]=Fe,t[139]=Je,t[140]=Ye):Ye=t[140];let Xe;t[141]!==ie||t[142]!==le||t[143]!==ye||t[144]!==Ne||t[145]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[ie,le,ye,Ne,Ye]}),t[141]=ie,t[142]=le,t[143]=ye,t[144]=Ne,t[145]=Ye,t[146]=Xe):Xe=t[146];let Ze=c?`高级:手机操作协议`:`Advanced: Phone Use protocol`,Qe;t[147]===Ze?Qe=t[148]:(Qe=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Ze}),t[147]=Ze,t[148]=Qe);let $e=c?`手机操作协议`:`Phone Use protocol`,et=u.phoneUse?.profile??``,tt;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(tt=e=>g(`phoneUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=tt):tt=t[149];let nt=c?`自动识别`:`Automatic`,rt;t[150]===nt?rt=t[151]:(rt=(0,$.jsx)(D,{value:``,children:nt}),t[150]=nt,t[151]=rt);let it,at,ot,st,ct;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(it=(0,$.jsx)(D,{value:`autoglm-phone-v1`,children:`AutoGLM Phone`}),at=(0,$.jsx)(D,{value:`structured-phone-v1`,children:`Structured Phone`}),ot=(0,$.jsx)(D,{value:`structured-tools-phone-v1`,children:`Visual function tools`}),st=(0,$.jsx)(D,{value:`doubao-seed-phone-v1`,children:`Doubao Seed GUI`}),ct=(0,$.jsx)(D,{value:`gui-owl-phone-v1`,children:`GUI-Owl 1.5`}),t[152]=it,t[153]=at,t[154]=ot,t[155]=st,t[156]=ct):(it=t[152],at=t[153],ot=t[154],st=t[155],ct=t[156]);let lt;t[157]!==$e||t[158]!==et||t[159]!==rt?(lt=(0,$.jsxs)(E,{"aria-label":$e,value:et,onChange:tt,children:[rt,it,at,ot,st,ct]}),t[157]=$e,t[158]=et,t[159]=rt,t[160]=lt):lt=t[160];let ut=c?`通用视觉模型支持图片输入和工具调用时会自动显示;也可指定专用手机协议。`:`Visual models with image input and function tools appear automatically. Dedicated phone protocols can also be selected.`,dt;t[161]===ut?dt=t[162]:(dt=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ut}),t[161]=ut,t[162]=dt);let ft;t[163]!==lt||t[164]!==dt?(ft=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[lt,dt]}),t[163]=lt,t[164]=dt,t[165]=ft):ft=t[165];let pt;t[166]!==Qe||t[167]!==ft?(pt=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Qe,ft]}),t[166]=Qe,t[167]=ft,t[168]=pt):pt=t[168];let mt=c?`高级:电脑控制协议`:`Advanced: Computer Use protocol`,ht;t[169]===mt?ht=t[170]:(ht=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:mt}),t[169]=mt,t[170]=ht);let gt=c?`电脑控制协议`:`Computer Use protocol`,_t=u.computerUse?.profile??``,vt;t[171]===Symbol.for(`react.memo_cache_sentinel`)?(vt=e=>g(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[171]=vt):vt=t[171];let yt=c?`自动识别`:`Automatic`,bt;t[172]===yt?bt=t[173]:(bt=(0,$.jsx)(D,{value:``,children:yt}),t[172]=yt,t[173]=bt);let xt,St,Ct;t[174]===Symbol.for(`react.memo_cache_sentinel`)?(xt=(0,$.jsx)(D,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),St=(0,$.jsx)(D,{value:`structured-tools-v1`,children:`structured-tools-v1`}),Ct=(0,$.jsx)(D,{value:`openai-responses-computer-v1`,children:`OpenAI Responses Computer`}),t[174]=xt,t[175]=St,t[176]=Ct):(xt=t[174],St=t[175],Ct=t[176]);let Tt;t[177]!==gt||t[178]!==_t||t[179]!==bt?(Tt=(0,$.jsxs)(E,{"aria-label":gt,value:_t,onChange:vt,children:[bt,xt,St,Ct]}),t[177]=gt,t[178]=_t,t[179]=bt,t[180]=Tt):Tt=t[180];let Et=c?`协议必须与模型 API 匹配。声明协议不代表模型已通过效果验证。`:`The protocol must match the model API. Declaring a protocol does not certify model quality.`,Dt;t[181]===Et?Dt=t[182]:(Dt=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:Et}),t[181]=Et,t[182]=Dt);let Ot;t[183]===f?Ot=t[184]:(Ot=f.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:f.get(`computerUse`)}),t[183]=f,t[184]=Ot);let kt;t[185]!==Dt||t[186]!==Ot||t[187]!==Tt?(kt=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[Tt,Dt,Ot]}),t[185]=Dt,t[186]=Ot,t[187]=Tt,t[188]=kt):kt=t[188];let At;t[189]!==kt||t[190]!==ht?(At=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[ht,kt]}),t[189]=kt,t[190]=ht,t[191]=At):At=t[191];let jt;t[192]!==At||t[193]!==Xe||t[194]!==pt?(jt=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[Xe,pt,At]}),t[192]=At,t[193]=Xe,t[194]=pt,t[195]=jt):jt=t[195];let Mt;t[196]===s.cancel?Mt=t[197]:(Mt=(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(Z,{type:`button`,variant:`secondary`,children:s.cancel})}),t[196]=s.cancel,t[197]=Mt);let Nt=r?s.addModelConfirm:s.saveModelConfirm,Pt;t[198]!==S||t[199]!==Nt?(Pt=(0,$.jsx)(Z,{type:`button`,variant:`primary`,className:`hover:bg-accent/90`,onClick:S,children:Nt}),t[198]=S,t[199]=Nt,t[200]=Pt):Pt=t[200];let Ft;t[201]!==Mt||t[202]!==Pt?(Ft=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[Mt,Pt]}),t[201]=Mt,t[202]=Pt,t[203]=Ft):Ft=t[203];let It;return t[204]!==jt||t[205]!==Ft||t[206]!==F?(It=(0,$.jsxs)($.Fragment,{children:[F,jt,Ft]}),t[204]=jt,t[205]=Ft,t[206]=F,t[207]=It):It=t[207],It}function zn(){return new Map}function Bn(e){return e.language}function Vn(e){let t=(0,Gt.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(g,{className:J(`xopc-dialog-overlay fixed inset-0 bg-scrim`,je)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=J(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col`,Ae,`overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`),t[1]=u):u=t[1];let d;t[2]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(d=n?(0,$.jsx)(Rn,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=d):d=t[9];let f;t[10]===d?f=t[11]:(f=(0,$.jsxs)(y,{children:[l,(0,$.jsx)(b,{className:u,onOpenAutoFocus:Hn,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(S,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function Hn(e){return e.preventDefault()}function Un(e){let t=(0,Gt.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>ft(n).then(Wn),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,$.jsx)(ue,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function Wn(e){return e.apiKey??null}function Gn(e){let t=(0,Gt.c)(23),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f=(0,Q.useRef)(null),[p,m]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(null),v;t[0]===r?v=t[1]:(v=e=>{e||(_(null),m(!1)),r(e)},t[0]=r,t[1]=v);let x=v,C;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(g,{className:J(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,je)}),t[2]=C):C=t[2];let w,T,E;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{f.current=document.activeElement instanceof HTMLElement?document.activeElement:null},T=e=>{f.current?.isConnected&&(e.preventDefault(),f.current.focus({preventScroll:!0}))},E=J(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(85vh,720px)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,Ae),t[3]=w,t[4]=T,t[5]=E):(w=t[3],T=t[4],E=t[5]);let D;t[6]!==c||t[7]!==o||t[8]!==s||t[9]!==x||t[10]!==a||t[11]!==l||t[12]!==u||t[13]!==r||t[14]!==d||t[15]!==i||t[16]!==p||t[17]!==h?(D=(0,$.jsxs)(y,{children:[C,(0,$.jsx)(b,{onOpenAutoFocus:w,onCloseAutoFocus:T,className:E,children:h?(0,$.jsx)(B,{target:h,zh:u===`zh`,onDone:()=>x(!1)}):!a&&p?(0,$.jsx)(P,{providerId:i,existingConnection:!0,row:o.find(e=>e.id===i),language:u,onApplied:d,onBack:()=>m(!1),onDone:()=>x(!1)}):a?(0,$.jsx)(qn,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onModelAdded:e=>_({providerId:i,modelIds:[e]})}):(0,$.jsx)(Kn,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onQuickSetup:()=>m(!0)},i)})]}),t[6]=c,t[7]=o,t[8]=s,t[9]=x,t[10]=a,t[11]=l,t[12]=u,t[13]=r,t[14]=d,t[15]=i,t[16]=p,t[17]=h,t[18]=D):D=t[18];let O;return t[19]!==x||t[20]!==n||t[21]!==D?(O=(0,$.jsx)(S,{open:n,onOpenChange:x,children:D}),t[19]=x,t[20]=n,t[21]=D,t[22]=O):O=t[22],O}function Kn({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o,onQuickSetup:s}){let c=t.find(t=>t.id===e),u=oe[e],d=n.filter(t=>t.provider===e),[f,p]=(0,Q.useState)(!1),[m,g]=(0,Q.useState)(c?.apiKey??``),[_,y]=(0,Q.useState)(!1),[b,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),D=h(i).providersSettings,O=c?.supportsApiKey!==!1,A=c?.supportsOAuth===!0,[j,M]=(0,Q.useState)(c?.authMode===`oauth`||!O?`oauth`:`api-key`),N=c?.authMode===`oauth`&&c.authStatus===`connected`,P=c?.configured===!0&&c.authMode!==`oauth`&&c.activeKeySource!==`env`&&c.activeKeySource!==`extension`&&c.activeKeySource!==`models_json`,[I,L]=(0,Q.useState)(null),[ee,R]=(0,Q.useState)(null),[z,B]=(0,Q.useState)(`idle`),[V,H]=(0,Q.useState)(null),[te,U]=(0,Q.useState)(null),[re,ie]=(0,Q.useState)(null),[ae,G]=(0,Q.useState)(``),K=(0,Q.useRef)(null),ue=(0,Q.useRef)(null),de=z===`waiting`||z===`waiting_code`,q=(0,Q.useMemo)(()=>ce(e,i),[e,i]),fe=m!==(c?.apiKey??``),me=async()=>{let t=m.trim();if(!(!t||!O||dt(t))){y(!0),w(null);try{await ut({[e]:t}),S(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){w(e instanceof Error?e.message:r.saveError)}finally{y(!1)}}};(0,Q.useEffect)(()=>{if(!I||!de)return;let e=window.setInterval(()=>{(async()=>{try{let t=await vt(I);t.status===`waiting_auth`||t.status===`waiting_code`?(B(t.status===`waiting_code`?`waiting_code`:`waiting`),R(t.message??null),H(t.authUrl??null),U(t.instructions??null),ie(t.deviceCode??null),t.authUrl&&t.authUrl!==ue.current&&(ue.current=t.authUrl,xt(t.authUrl,K.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),Ct(K.current),K.current=null,B(`success`),R(t.message??D.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),Ct(K.current),K.current=null,B(`error`),R(t.error??t.message??D.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[I,de,a,o,D.revokeFailed,D.saved]),(0,Q.useEffect)(()=>()=>{I&>(I).catch(()=>{})},[I]),(0,Q.useEffect)(()=>()=>{Ct(K.current),K.current=null},[]);let he=async()=>{try{await pt(e),o(),a()}catch{}},ge=async()=>{Ct(K.current),K.current=St(),ue.current=null,B(`waiting`),R(D.oauthStarting),H(null),U(null),ie(null),w(null);try{let t=await mt(e);L(t.sessionId)}catch(e){Ct(K.current),K.current=null,B(`error`),R(e instanceof Error?e.message:D.revokeFailed)}},_e=async()=>{if(I){try{await yt(I)}catch{}Ct(K.current),K.current=null,ue.current=null,B(`idle`),R(null),L(null),H(null),U(null),ie(null)}},ve=async()=>{if(!(!I||!ae.trim()))try{await _t(I,ae.trim()),G(``),R(D.oauthProcessingCode)}catch(e){B(`error`),R(e instanceof Error?e.message:D.revokeFailed)}},ye=async()=>{try{await ht(e),o(),a()}catch(e){w(e instanceof Error?e.message:D.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:c?.name??e}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Ne.press),children:(0,$.jsx)(we,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-5 py-4`,children:[u?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,(0,$.jsx)(W,{row:c,language:i}),O&&A?(0,$.jsx)(ne,{value:j,onChange:M,language:i,disabled:de||_}):null,O&&j===`api-key`?(0,$.jsx)(Un,{providerId:e,inputId:`manage-api-key`,value:m,onChange:e=>{g(e),S(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):!O&&c?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),c?.extensionId?(0,$.jsxs)(l,{to:`/settings/ext/${encodeURIComponent(c.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(le,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,A&&j===`oauth`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:D.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:N?i===`zh`?`账号已连接`:`Account connected`:c?.authMode===`oauth`&&c.authStatus===`expired`?i===`zh`?`授权已过期,请重新登录`:`Authorization expired. Sign in again.`:i===`zh`?`通过浏览器授权连接账号`:`Authorize your account in the browser`})]}),N?(0,$.jsx)(Z,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void ye(),children:D.revoke}):(0,$.jsxs)(Z,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:de,onClick:()=>void ge(),children:[de?(0,$.jsx)(pe,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),D.oauth]})]}),ee?(0,$.jsx)(`p`,{className:J(`text-xs`,z===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:ee}):null,z===`waiting`||z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[V?(0,$.jsxs)(`a`,{href:V,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover`,children:[(0,$.jsx)(le,{className:`size-4`,"aria-hidden":!0}),D.openAuthPage]}):null,(0,$.jsx)(Z,{type:`button`,variant:`secondary`,onClick:()=>void _e(),children:D.cancelOAuth})]}):null,te?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:te}):null,re?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:D.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:re}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:D.deviceCodeHint})]}):null,z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:ae,onChange:e=>G(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ve(),"aria-label":D.pasteRedirectUrl,placeholder:D.pasteRedirectUrl,className:J(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,ze)}),(0,$.jsx)(Z,{type:`button`,variant:`primary`,onClick:()=>void ve(),children:D.submitCode})]}):null]}):null,q.length>0&&O&&j===`api-key`?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:q.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[F(e,r),(0,$.jsx)(le,{className:`size-3`,"aria-hidden":!0})]},e))}):null,j===`api-key`&&c?.baseUrl?(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:i===`zh`?`高级设置`:`Advanced settings`}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all font-mono text-xs text-fg-muted`,children:c.baseUrl})]})]}):c?.category===`extension`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.apiUrlExtensionHint}):null,d.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[i===`zh`?`模型目录`:`Model catalog`,` (`,d.length,`)`]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i===`zh`?`此服务的模型目录;实际访问权限取决于当前生效的凭据和账号。`:`Models registered for this provider. Access depends on the active credentials and account.`}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:f,onChange:e=>p(e.target.checked)}),i===`zh`?`仅电脑控制模型`:`Computer Use only`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.filter(e=>!f||e.computerUse).map(e=>(0,$.jsxs)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:[Qe(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),s?(0,$.jsx)(Z,{variant:`secondary`,disabled:fe||de||c?.authStatus!==`connected`,onClick:s,children:i===`zh`?`配置模型用途`:`Configure model uses`}):null,C?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[P?(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>E(!0),children:[(0,$.jsx)(xe,{className:`size-3.5`,"aria-hidden":!0}),i===`zh`?`移除 API Key`:`Remove API key`]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:O&&j===`api-key`&&fe&&!dt(m.trim())?(0,$.jsx)(Z,{type:`button`,variant:`primary`,disabled:!m.trim()||_||b,onClick:()=>void me(),children:b?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(k,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):_?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(pe,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(Je,{open:T,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,c?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void he(),onCancel:()=>E(!1)})]})}function qn({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a,onModelAdded:o}){let s=h(r).modelsSettings,c=t?.providers[e],[l,u]=(0,Q.useState)(c?.baseUrl??``),[d,f]=(0,Q.useState)(c?.apiKey??``),[p,m]=(0,Q.useState)(c?.models??[]),[g,_]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(c?.modelDiscovery?.enabled===!0),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),[M,P]=(0,Q.useState)(null),F=n=>{if(!t)return null;let r=d.trim(),i={...c,baseUrl:l.trim()||void 0,apiKey:dt(r)?c?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},I=async()=>{let e=F({models:p,modelDiscovery:{enabled:y}});if(e){C(!0),T(null);try{await N(e),a(),i()}catch(e){T(e instanceof Error?e.message:n.saveError)}finally{C(!1)}}},L=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await N({providers:r}),a(),i()}catch{}},ee=(e,t)=>{P({model:e,isNew:t}),j(!0)},R=async e=>{if(!M)return;let t=M.isNew&&!p.some(t=>t.id===e.id),r=M.isNew?[...p,e]:p.map(t=>t.id===e.id?e:t);m(r);let i=F({models:r});if(i)try{await N(i),a(),t&&!e.computerUse&&o(e.id)}catch(e){T(e instanceof Error?e.message:n.saveError)}},z=async e=>{let t=p.filter(t=>t.id!==e);m(t),k(null);let r=F({models:t});if(r)try{await N(r),a()}catch(e){T(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Ne.press),children:(0,$.jsx)(we,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:l,onChange:e=>u(e.target.value),className:J(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,ze)})]}),(0,$.jsx)(Un,{providerId:e,inputId:`manage-custom-api-key`,value:d,onChange:f,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r===`zh`?`自动同步模型目录`:`Automatically sync model catalog`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:r===`zh`?`启动时及定时从此服务的 /models 接口更新模型。`:`Update models from this service’s /models endpoint at startup and on schedule.`})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[s.modelsSection,p.length>0?` (${p.length})`:``]}),(0,$.jsxs)(Z,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>ee(null,!0),children:[(0,$.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),s.addModel]})]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:g,onChange:e=>_(e.target.checked)}),r===`zh`?`仅电脑控制模型`:`Computer Use only`]}),p.filter(e=>!g||e.computerUse).length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:p.filter(e=>!g||e.computerUse).map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.computerUse&&(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Computer Use`}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:J(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Ne.press),onClick:()=>ee(e,!1),"aria-label":s.editModel,children:(0,$.jsx)(me,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:J(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,Ne.press),onClick:()=>k(e.id),"aria-label":s.removeModel,children:(0,$.jsx)(xe,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),w?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>D(!0),children:[(0,$.jsx)(xe,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(Z,{type:`button`,variant:`primary`,disabled:S,onClick:()=>void I(),children:S?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(pe,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(Je,{open:E,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void L(),onCancel:()=>D(!1)}),(0,$.jsx)(Je,{open:O!==null,title:s.removeModel,description:s.removeModelConfirm.replace(`{{id}}`,O??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{O&&z(O)},onCancel:()=>k(null)}),(0,$.jsx)(Vn,{open:A,onOpenChange:e=>{j(e),e||P(null)},providerId:e,model:M?.model??null,isNew:M?.isNew??!1,onSave:e=>void R(e),m:s})]})}var Jn=[`fast`,`reasoning`,`coding`,`review`,`vision`,`understanding`],Yn=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`,Xn={en:{fast:[`Fast tasks`,`Short, low-latency work`],reasoning:[`Complex reasoning`,`Planning and multi-step analysis`],coding:[`Coding`,`Implementation and debugging`],review:[`Review`,`Critique and verification`],vision:[`Vision`,`Image and visual analysis`],understanding:[`Understanding`,`Long-form content comprehension`]},zh:{fast:[`快速任务`,`简短、低延迟的工作`],reasoning:[`复杂推理`,`规划和多步骤分析`],coding:[`编程`,`实现、调试和代码修改`],review:[`审查`,`检查、批评和验证`],vision:[`视觉任务`,`图片和视觉内容分析`],understanding:[`内容理解`,`长内容阅读和理解`]}};function Zn(e,t){return{primary:t,fallbacks:e?.fallbacks??[]}}function Qn(e){let t=(0,Gt.c)(38),{draft:n,setDraft:r,zh:i,capability:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[0]=o):o=t[0];let s=X(ke,Oe,o),c;t[1]===s.data?c=t[2]:(c=s.data??[],t[1]=s.data,t[2]=c);let l=c,u=i?Xn.zh:Xn.en,d;t[3]!==n||t[4]!==r?(d=(e,t)=>{let i={...n.models.intents};t?i[e]=Zn(i[e],t):delete i[e],r({...n,models:{...n.models,intents:i}})},t[3]=n,t[4]=r,t[5]=d):d=t[5];let f=d,p;t[6]!==a||t[7]!==n||t[8]!==l||t[9]!==s.error||t[10]!==s.isLoading||t[11]!==r||t[12]!==i?(p=a===`chat`?(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:(0,$.jsx)(bt,{title:i?`模型回退`:`Model fallbacks`,summary:i?`已配置 ${n.models.chat.fallbacks.length} 个备用模型。`:`${n.models.chat.fallbacks.length} fallback models configured.`,children:(0,$.jsx)(`div`,{className:`mt-6 rounded-xl bg-surface-base/45 p-4`,children:(0,$.jsx)(Ht,{primary:n.models.chat.primary,value:n.models.chat.fallbacks,models:l,loading:s.isLoading,error:s.error,zh:i,onChange:e=>r({...n,models:{...n.models,chat:{...n.models.chat,fallbacks:e}}})})})})}):null,t[6]=a,t[7]=n,t[8]=l,t[9]=s.error,t[10]=s.isLoading,t[11]=r,t[12]=i,t[13]=p):p=t[13];let m;t[14]!==a||t[15]!==n||t[16]!==r||t[17]!==i?(m=a===`image`?(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:n.models.imageGeneration?(0,$.jsx)(bt,{title:i?`图片执行策略`:`Image execution policy`,summary:i?`当前超时与回退策略继续生效。`:`The current timeout and fallback policy remains active.`,children:(0,$.jsxs)(`div`,{className:`mt-5 grid gap-4 rounded-xl bg-surface-base/45 p-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[i?`生成超时(毫秒)`:`Generation timeout (ms)`,(0,$.jsx)(wt,{allowEmpty:!0,type:`number`,min:1,className:`${Yn} mt-2`,value:n.models.imageGeneration.timeoutMs??``,onChange:e=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,timeoutMs:e.target.value?Number(e.target.value):void 0}}})})]}),(0,$.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(`span`,{children:i?`服务商自动回退`:`Automatic provider fallback`}),(0,$.jsx)(qe,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,role:`group`,"aria-label":i?`服务商自动回退`:`Automatic provider fallback`,children:[!0,!1].map(e=>(0,$.jsx)(Z,{"aria-pressed":n.models.imageGeneration?.autoProviderFallback===e,variant:n.models.imageGeneration?.autoProviderFallback===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,autoProviderFallback:e}}}),children:e?i?`开启`:`On`:i?`关闭`:`Off`},String(e)))})]})]})}):null}):null,t[14]=a,t[15]=n,t[16]=r,t[17]=i,t[18]=m):m=t[18];let h;t[19]!==a||t[20]!==n||t[21]!==l||t[22]!==s.error||t[23]!==s.isLoading||t[24]!==r||t[25]!==i?(h=a===`vision`&&n.models.imageUnderstanding?(0,$.jsx)(bt,{title:i?`模型回退`:`Model fallbacks`,summary:i?`主模型不可用时使用已配置的备用模型。`:`Use configured fallback models when the primary is unavailable.`,children:(0,$.jsx)(Ht,{primary:n.models.imageUnderstanding.primary,value:n.models.imageUnderstanding.fallbacks,models:l.filter($n),loading:s.isLoading,error:s.error,zh:i,onChange:e=>r({...n,models:{...n.models,imageUnderstanding:{...n.models.imageUnderstanding,fallbacks:e}}})})}):null,t[19]=a,t[20]=n,t[21]=l,t[22]=s.error,t[23]=s.isLoading,t[24]=r,t[25]=i,t[26]=h):h=t[26];let g;t[27]!==a||t[28]!==u||t[29]!==n||t[30]!==f||t[31]!==i?(g=a===`chat`?(0,$.jsx)(bt,{title:i?`任务模型路由`:`Task model routing`,summary:i?`已配置 ${Object.keys(n.models.intents).length} 类任务路由;其他任务使用默认模型。`:`${Object.keys(n.models.intents).length} task routes configured; other tasks use the default model.`,children:(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:i?`按任务选择模型`:`Route by task`}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i?`仅在确实需要不同模型时设置;否则保持“使用默认对话模型”。`:`Set a route only when a task genuinely needs another model; otherwise keep the default.`}),(0,$.jsx)(`div`,{className:`mt-5 grid gap-3 lg:grid-cols-2`,children:Jn.map(e=>(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/55 p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:u[e][0]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u[e][1]})]}),(0,$.jsx)(Ze,{value:n.models.intents[e]?.primary??``,placeholder:i?`使用默认对话模型`:`Use default conversation model`,searchPlaceholder:i?`搜索模型或服务商`:`Search models or providers`,noMatches:i?`没有匹配的模型`:`No matching models`,allowEmpty:!0,emptyLabel:i?`使用默认对话模型`:`Use default conversation model`,showProviderInTrigger:!1,contentAlign:`start`,className:`w-full`,ariaLabel:i?`${u[e][0]}模型`:`${u[e][0]} model`,onChange:t=>f(e,t)})]},e))})]})}):null,t[27]=a,t[28]=u,t[29]=n,t[30]=f,t[31]=i,t[32]=g):g=t[32];let _;return t[33]!==p||t[34]!==m||t[35]!==h||t[36]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-5`,children:[p,m,h,g]}),t[33]=p,t[34]=m,t[35]=h,t[36]=g,t[37]=_):_=t[37],_}function $n(e){return e.vision}function er(e){let t=(0,Gt.c)(9),{data:n,error:r}=X(`settings-agent-defaults`,tt);if(r&&!n){let e=String(r),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e}),t[0]=e,t[1]=n),n}if(!n){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{className:`h-32 rounded-xl`}),t[2]=e):e=t[2],e}let i;t[3]===n.defaults.models?i=t[4]:(i=JSON.stringify(n.defaults.models),t[3]=n.defaults.models,t[4]=i);let a;return t[5]!==n.defaults||t[6]!==e||t[7]!==i?(a=(0,$.jsx)(tr,{...e,initial:n.defaults},i),t[5]=n.defaults,t[6]=e,t[7]=i,t[8]=a):a=t[8],a}function tr(e){let t=(0,Gt.c)(36),{initial:n,capability:r,zh:i,disabled:a,onPendingChange:o}=e,s;t[0]===n?s=t[1]:(s=()=>structuredClone(n),t[0]=n,t[1]=s);let[c,l]=(0,Q.useState)(s),u;t[2]===n?u=t[3]:(u=()=>structuredClone(n),t[2]=n,t[3]=u);let[d,f]=(0,Q.useState)(u),p;t[4]===c.models?p=t[5]:(p=JSON.stringify(c.models),t[4]=c.models,t[5]=p);let m;t[6]===d.models?m=t[7]:(m=JSON.stringify(d.models),t[6]=d.models,t[7]=m);let h=p!==m,g;t[8]!==n.models||t[9]!==i?(g=async e=>{let t=await tt();if(JSON.stringify(t.defaults.models)!==JSON.stringify(n.models))throw Error(i?`模型设置已变化,请刷新后重试。`:`Model settings changed. Refresh before retrying.`);let r=await et({...t.defaults,models:e.models},{scope:`models`,expectedModels:n.models});f(r.defaults),await st()},t[8]=n.models,t[9]=i,t[10]=g):g=t[10];let _=g,v;t[11]!==h||t[12]!==c||t[13]!==_?(v={value:c,dirty:h,onSave:_,delayMs:0},t[11]=h,t[12]=c,t[13]=_,t[14]=v):v=t[14];let y=At(v),b=h||y.status===`saving`||!!y.error,x,S;t[15]!==o||t[16]!==b?(x=()=>(o(b),()=>o(!1)),S=[b,o],t[15]=o,t[16]=b,t[17]=x,t[18]=S):(x=t[17],S=t[18]),(0,Q.useEffect)(x,S);let C=a||y.status===`saving`,w;t[19]!==y.error||t[20]!==y.status?(w=(0,$.jsx)(kt,{status:y.status,error:y.error}),t[19]=y.error,t[20]=y.status,t[21]=w):w=t[21];let T;t[22]!==y.error||t[23]!==y.retry||t[24]!==i?(T=y.error?(0,$.jsx)(Z,{variant:`secondary`,onClick:y.retry,children:i?`重试保存`:`Retry saving`}):null,t[22]=y.error,t[23]=y.retry,t[24]=i,t[25]=T):T=t[25];let E;t[26]!==r||t[27]!==c||t[28]!==i?(E=(0,$.jsx)(Qn,{capability:r,draft:c,setDraft:l,zh:i}),t[26]=r,t[27]=c,t[28]=i,t[29]=E):E=t[29];let D;return t[30]!==y.onBlurCapture||t[31]!==w||t[32]!==T||t[33]!==E||t[34]!==C?(D=(0,$.jsxs)(`fieldset`,{disabled:C,onBlurCapture:y.onBlurCapture,className:`min-w-0 space-y-3`,children:[w,T,E]}),t[30]=y.onBlurCapture,t[31]=w,t[32]=T,t[33]=E,t[34]=C,t[35]=D):D=t[35],D}function nr(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function rr(e,t){if(e.startsWith(`agentCatalog.defaults.models`))return{label:t?`模型与能力`:`Models and capabilities`,href:`/settings/capabilities/models`};let n=e.match(/^agentCatalog\.agents\.([^.]+)\.models/);return n?.[1]?{label:t?`智能体 ${n[1]}`:`Agent ${n[1]}`,href:$e(n[1])}:e.startsWith(`sessions.`)?{label:t?`会话模型覆盖`:`Session model override`,href:`/settings/sessions`}:{label:e,href:`/settings/agent-defaults`}}function ir(e,t){switch(e){case`computer-use`:return{guidance:t?`选择兼容的电脑控制模型;本机权限需单独授权`:`Select a compatible computer model; local access requires separate approval`,action:t?`配置电脑控制`:`Configure computer use`};case`vision`:return{guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{guidance:t?`选择语音识别服务,或安装自管 STT 插件`:`Choose a speech-to-text service or install a self-managed STT plugin`,action:t?`去配置语音识别`:`Configure speech-to-text`};case`tts`:return{guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}async function ar(){let e=await u(d(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}async function or(){let e=await u(d(`/api/capabilities/readiness`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function sr({showCapabilities:e=!0,embedded:t=!1}={}){let n=p(e=>e.language)===`zh`,{data:r,error:i,isLoading:a}=X(ct,ar,{revalidateOnFocus:!0,refreshInterval:6e4}),{data:o}=X(lt,or,{revalidateOnFocus:!1}),[s,c]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(null),h=Object.values(r?.sources??{}),g=h.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),_=(r?.references??[]).filter(e=>e.availability===`unavailable`),v=r?.sync.lastSuccessAt??Math.max(0,...h.map(e=>e.lastSuccessAt)),y=!!i,b=r?.sync.sourceErrors??{},x=[...r?.sync.lastError?[[`catalog`,r.sync.lastError]]:[],...Object.entries(b),...f?[[`refresh`,f]]:[],...i instanceof Error?[[`load`,i.message]]:[]],S=r?.sync.lastAttemptAt??v,w=Object.entries(o?.capabilities??{}).filter(([e])=>e!==`computer-use`||We()),E=w.some(([,e])=>{let t=nr(e);return t===`degraded`||t===`misconfigured`}),D=w.filter(([,e])=>nr(e)===`ready`).length,O=(0,Q.useRef)(null);if((0,Q.useEffect)(()=>{E&&!a&&O.current?.setAttribute(`open`,``)},[E,a]),a)return(0,$.jsx)(Y,{className:`h-24 w-full rounded-2xl`});let A=async()=>{c(!0),m(null);try{let e=await u(d(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await st()}catch(e){m(e instanceof Error?e.message:String(e))}finally{c(!1)}},j=(0,$.jsx)(`div`,{className:`mt-2 space-y-1 rounded-lg bg-surface-base/45 p-2 font-mono text-[11px] leading-5`,"aria-label":n?`同步错误详情`:`Sync error details`,children:x.map(([e,t],n)=>(0,$.jsxs)(`p`,{className:`break-words`,children:[e,`: `,t]},`${e}-${n}`))}),N=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:n?`${h.length} 个来源,${g} 个可用模型${v?` · 最近同步 ${new Date(v).toLocaleString()}`:``}`:`${h.length} sources, ${g} available models${v?` · Last synced ${new Date(v).toLocaleString()}`:``}`}),x.length>0?t?(0,$.jsxs)(`details`,{className:`mt-2 rounded-lg bg-surface-base/45 p-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer rounded text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`高级诊断`:`Advanced diagnostics`}),j]}):j:null]}),(0,$.jsxs)(Z,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:s,onClick:()=>void A(),children:[s?(0,$.jsx)(pe,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(_e,{className:`size-4`,"aria-hidden":!0}),s?n?`刷新中…`:`Refreshing…`:n?`刷新目录`:`Refresh catalog`]})]});return(0,$.jsxs)(`section`,{className:t?`mt-4 border-t border-edge-subtle pt-1`:`rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[e?(0,$.jsxs)(`details`,{ref:O,className:`group`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2`,children:[E?(0,$.jsx)(Se,{className:`size-4 text-amber-500`,"aria-hidden":!0}):D===w.length&&w.length>0?(0,$.jsx)(k,{className:`size-4 text-emerald-500`,"aria-hidden":!0}):(0,$.jsx)(M,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:n?`可选能力`:`Optional capabilities`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-fg-muted`,children:n?`${D}/${w.length} 项已配置,不影响基础聊天功能`:`${D} of ${w.length} configured · Not required for chat`})]}),(0,$.jsx)(T,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]})}),o?(0,$.jsx)(`div`,{className:`mt-3 grid gap-1 sm:grid-cols-2`,children:Object.entries(o.capabilities).map(([e,t])=>{if(e===`computer-use`&&!We())return null;let r=e===`vision`?n?`图片理解`:`Vision`:e===`image-generation`?n?`图片生成`:`Image generation`:e===`computer-use`?n?`电脑控制模型`:`Computer use model`:e.toUpperCase(),i=t.selectionSource!==`explicit-config`,a=nr(t),o=a===`degraded`||a===`misconfigured`,s=ir(e,n),c=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-xs font-medium text-fg`,children:r}),(0,$.jsx)(`span`,{className:a===`ready`?`shrink-0 text-xs text-emerald-600 dark:text-emerald-400`:a===`off`||a===`not-configured`?`shrink-0 text-xs text-fg-muted`:`shrink-0 text-xs text-amber-600 dark:text-amber-400`,children:a===`ready`?e===`computer-use`?n?`已配置`:`Configured`:n?`可用`:`Ready`:a===`off`?n?`已关闭`:`Off`:a===`not-configured`?n?`未配置`:`Not configured`:a===`degraded`?n?`正在使用备用方案`:`Using fallback`:n?`需处理`:`Needs attention`})]}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,title:t.primary?`${t.primary.provider}/${t.primary.model}`:void 0,children:t.primary?`${i?n?`自动`:`Auto`:n?`显式`:`Explicit`} · ${t.primary.provider}/${t.primary.model}`:a===`not-configured`?n?`可稍后按需配置`:`Set up later if needed`:n?`已配置的模型不可用`:`The configured model is unavailable`}),o?(0,$.jsxs)(`div`,{className:`mt-2 rounded-lg bg-amber-500/10 p-2`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-amber-700 dark:text-amber-300`,children:t.status===`degraded`?n?`当前配置不可用,正在使用备用方案。${s.guidance}`:`The current configuration is unavailable, so a fallback is in use. ${s.guidance}.`:s.guidance}),(0,$.jsxs)(`span`,{className:`mt-1 inline-flex items-center gap-1 text-xs font-medium text-accent`,children:[s.action,(0,$.jsx)(C,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]}),u={"aria-label":o?`${r}:${s.action}`:`${n?`配置`:`Configure`} ${r}`,className:J(`rounded-lg bg-surface-base/45 px-3 py-3 text-left transition-colors`,o?`bg-amber-500/5 hover:bg-amber-500/10`:`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`)};if(e===`computer-use`)return(0,$.jsx)(l,{to:`/settings/computer-use`,...u,children:c},e);let d={vision:`vision`,"image-generation":`image`,stt:`transcription`,tts:`speech`}[e];return(0,$.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,...u,onClick:()=>Me(d,o?`services`:`settings`),children:c},e)})}):null]}):null,_.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-2`,"aria-live":`polite`,children:_.map(e=>(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 p-3`,children:(()=>{let t=e.ref.split(`/`)[0]??``,r=!!b[t],i=rr(e.locations[0]??``,n);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(Se,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`p`,{className:`break-words text-sm font-medium text-fg`,children:[e.ref,(0,$.jsx)(`span`,{className:`ml-2 font-normal text-amber-700 dark:text-amber-300`,children:r?n?`暂时无法验证`:`Temporarily unverified`:n?`不可用`:`Unavailable`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r?n?`模型目录同步暂时失败,当前状态可能已过期;不会影响其他可用模型。`:`Catalog sync temporarily failed, so this status may be stale. Other available models are unaffected.`:n?`此模型已无法从当前配置中解析,使用它的功能可能失败。`:`This model no longer resolves from the current configuration. Features using it may fail.`,S?` · ${n?`最近检测`:`Last checked`} ${new Date(S).toLocaleString()}`:``]}),e.suggestedRef?(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[n?`可替换为`:`Suggested replacement`,`:`,(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.suggestedRef})]}):null]})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:[(0,$.jsxs)(Z,{className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,disabled:s,onClick:()=>void A(),children:[s?(0,$.jsx)(pe,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(_e,{className:`size-3.5`,"aria-hidden":!0}),s?n?`检测中…`:`Checking…`:n?`重新检测`:`Check again`]}),(0,$.jsx)(Z,{asChild:!0,className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,children:(0,$.jsxs)(l,{to:i.href,children:[(0,$.jsx)(Ce,{className:`size-3.5`,"aria-hidden":!0}),e.suggestedRef?n?`更换模型`:`Replace model`:n?`调整配置`:`Adjust configuration`]})}),(0,$.jsxs)(`details`,{className:`group/references`,children:[(0,$.jsxs)(`summary`,{className:`touch-target inline-flex cursor-pointer list-none items-center gap-1 rounded-xl px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n?`查看 ${e.locations.length} 处引用`:`View ${e.locations.length} ${e.locations.length===1?`reference`:`references`}`,(0,$.jsx)(T,{className:`size-3.5 transition-transform group-open/references:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 pl-2 text-xs text-fg-muted`,children:e.locations.map(e=>{let t=rr(e,n);return(0,$.jsx)(`li`,{children:(0,$.jsx)(l,{className:`inline-flex rounded px-1.5 py-1 text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,to:t.href,title:e,children:t.label})},e)})})]})]})]})})()},e.ref))}):null,y||f?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:y?n?`暂时无法读取模型状态,请重新检测;详细信息可在高级诊断中查看。`:`Model status is temporarily unavailable. Check again; details are available in Advanced diagnostics.`:n?`重新检测失败,请稍后重试;详细信息可在高级诊断中查看。`:`The check failed. Try again later; details are available in Advanced diagnostics.`}):null,t?N:(0,$.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`summary`,{className:`min-h-8 cursor-pointer rounded-md py-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`高级诊断`:`Advanced diagnostics`}),N]})]})}function cr(e){let t=(0,Gt.c)(177),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{inlineUse:r,inlineView:i,onViewChange:u,onPendingChange:d}=n,f=i===void 0?`settings`:i,m=p(fr),g=m===`zh`,_;t[2]===m?_=t[3]:(_=h(m),t[2]=m,t[3]=_);let v=_.capabilitiesSettings,{capability:y}=a(),[b,x]=s(),{state:S}=o(),C;t[4]===b?C=t[5]:(C=at(b.get(`returnTo`)),t[4]=b,t[5]=C);let w=C,[T,E]=(0,Q.useState)(),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),F=j||N||k,[I,L]=(0,Q.useState)(!1),[ee,R]=(0,Q.useState)(null),z=(0,Q.useRef)(null),B=te(),V;t[6]===B.cards?V=t[7]:(V=B.cards.some(dr),t[6]=B.cards,t[7]=V);let H=V,ne=ur,U,W;t[8]!==d||t[9]!==F?(U=()=>(d?.(F),()=>d?.(!1)),W=[F,d],t[8]=d,t[9]=F,t[10]=U,t[11]=W):(U=t[10],W=t[11]),(0,Q.useEffect)(U,W);let ae,oe;t[12]!==y||t[13]!==r||t[14]!==S||t[15]!==b||t[16]!==x?(ae=()=>{if(r||y!==`models`)return;let e=rt(b.get(`configure`));if(!e&&b.get(`add`)!==`1`)return;let t=window.setTimeout(()=>{e?Me(e,b.get(`tab`)===`services`?`services`:`settings`):L(!0);let t=new URLSearchParams(b);t.delete(`configure`),t.delete(`tab`),t.delete(`add`),x(t,{replace:!0,state:S})},0);return()=>window.clearTimeout(t)},oe=[y,r,b,x,S],t[12]=y,t[13]=r,t[14]=S,t[15]=b,t[16]=x,t[17]=ae,t[18]=oe):(ae=t[17],oe=t[18]),(0,Q.useEffect)(ae,oe);let se;t[19]!==r||t[20]!==u||t[21]!==F?(se=e=>{if(!F){if(!r){Me(e,`services`);return}u?.(`services`),E(void 0)}},t[19]=r,t[20]=u,t[21]=F,t[22]=se):se=t[22];let G=se,ce;t[23]===u?ce=t[24]:(ce=e=>{ne(),u?.(`settings`),E(e)},t[23]=u,t[24]=ce);let K=ce;if(r){let e=f===`services`,n=N||k,i;t[25]!==r||t[26]!==G||t[27]!==B||t[28]!==n||t[29]!==g?(i=(0,$.jsx)(In,{data:B,zh:g,onlyUse:r,disabled:n,onPendingChange:M,onChange:G}),t[25]=r,t[26]=G,t[27]=B,t[28]=n,t[29]=g,t[30]=i):i=t[30];let a;t[31]!==e||t[32]!==i?(a=(0,$.jsx)(`div`,{hidden:e,children:i}),t[31]=e,t[32]=i,t[33]=a):a=t[33];let o;t[34]!==T||t[35]!==r||t[36]!==f||t[37]!==g?(o=T===r&&f===`settings`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:g?`服务设置已保存`:`Service settings saved`}):null,t[34]=T,t[35]=r,t[36]=f,t[37]=g,t[38]=o):o=t[38];let s=f!==`services`,c;t[39]!==K||t[40]!==r?(c=()=>K(r),t[39]=K,t[40]=r,t[41]=c):c=t[41];let l;t[42]!==v.addProviderDialog||t[43]!==r||t[44]!==m||t[45]!==B||t[46]!==c?(l=(0,$.jsx)(Cn,{inline:!0,onEditingChange:O,use:r,data:B,language:m,labels:v.addProviderDialog,onPendingChange:A,onSaved:c},r),t[42]=v.addProviderDialog,t[43]=r,t[44]=m,t[45]=B,t[46]=c,t[47]=l):l=t[47];let d;t[48]!==K||t[49]!==D||t[50]!==r||t[51]!==B.builtinRows||t[52]!==g?(d=r===`transcription`||r===`speech`?(0,$.jsx)(`div`,{hidden:D,children:(0,$.jsx)(Nn,{kind:r===`transcription`?`stt`:`tts`,modelServiceIds:B.builtinRows.map(lr),zh:g,onPendingChange:A,onSaved:()=>K(r)},r)}):null,t[48]=K,t[49]=D,t[50]=r,t[51]=B.builtinRows,t[52]=g,t[53]=d):d=t[53];let p;t[54]!==D||t[55]!==r||t[56]!==u||t[57]!==g?(p=r===`conversation`&&!D&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`span`,{className:`text-sm text-fg`,children:`Boson AI · Higgs Realtime`}),(0,$.jsx)(Z,{variant:`secondary`,onClick:()=>u?.(`settings`),children:g?`配置 Boson`:`Configure Boson`})]}),t[54]=D,t[55]=r,t[56]=u,t[57]=g,t[58]=p):p=t[58];let h;t[59]!==K||t[60]!==r?(h=r===`image`?(0,$.jsx)(cn,{connectOnly:!0,onPendingChange:A,onConnected:()=>K(r)}):null,t[59]=K,t[60]=r,t[61]=h):h=t[61];let _;t[62]!==k||t[63]!==s||t[64]!==l||t[65]!==d||t[66]!==p||t[67]!==h?(_=(0,$.jsxs)(`fieldset`,{hidden:s,disabled:k,className:`min-w-0 space-y-3`,children:[l,d,p,h]}),t[62]=k,t[63]=s,t[64]=l,t[65]=d,t[66]=p,t[67]=h,t[68]=_):_=t[68];let y=f===`services`,b;t[69]!==k||t[70]!==r||t[71]!==j?(b=r===`transcription`||r===`speech`||r===`conversation`?(0,$.jsx)(Ie,{capability:r,onPendingChange:P,disabled:j||k},r):null,t[69]=k,t[70]=r,t[71]=j,t[72]=b):b=t[72];let x;t[73]!==k||t[74]!==r||t[75]!==j||t[76]!==g?(x=r===`chat`||r===`vision`||r===`image`?(0,$.jsx)(er,{capability:r,zh:g,disabled:j||k,onPendingChange:P}):null,t[73]=k,t[74]=r,t[75]=j,t[76]=g,t[77]=x):x=t[77];let S;t[78]!==r||t[79]!==g?(S=r===`background`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g?`使用所选模型执行自动化、定时和无人值守任务。此设置不会启用任务,也不会自动改用其他计费服务。`:`Use the selected model for automations, schedules and unattended tasks. This does not enable tasks or automatically switch billing services.`}):null,t[78]=r,t[79]=g,t[80]=S):S=t[80];let C;t[81]!==y||t[82]!==b||t[83]!==x||t[84]!==S?(C=(0,$.jsxs)(`div`,{hidden:y,className:`space-y-4`,children:[b,x,S]}),t[81]=y,t[82]=b,t[83]=x,t[84]=S,t[85]=C):C=t[85];let w;t[86]!==G||t[87]!==o||t[88]!==_||t[89]!==C?(w=(0,$.jsxs)(Fe.Provider,{value:G,children:[o,_,C]}),t[86]=G,t[87]=o,t[88]=_,t[89]=C,t[90]=w):w=t[90];let E;return t[91]!==a||t[92]!==w?(E=(0,$.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[a,w]}),t[91]=a,t[92]=w,t[93]=E):E=t[93],E}if(y===`search`){let e;t[94]===m?e=t[95]:(e=h(m),t[94]=m,t[95]=e);let n;t[96]===e.nav.settingsSearch?n=t[97]:(n=(0,$.jsx)(Et,{title:e.nav.settingsSearch}),t[96]=e.nav.settingsSearch,t[97]=n);let r;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(yn,{}),t[98]=r):r=t[98];let i;return t[99]===n?i=t[100]:(i=(0,$.jsxs)(Tt,{children:[n,r]}),t[99]=n,t[100]=i),i}if(y!==`models`){let e;return t[101]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(c,{to:`/settings/capabilities/models`,replace:!0}),t[101]=e):e=t[101],e}let le=g?`模型与能力`:`Models and capabilities`,ue=g?`按用途选择模型,在设置中调整参数与服务连接。`:`Choose models by purpose. Adjust parameters and connections in settings.`,de;t[102]===m?de=t[103]:(de=Ue(m,`configuration`),t[102]=m,t[103]=de);let q;t[104]!==v.docsLink||t[105]!==de?(q=(0,$.jsx)(`a`,{href:de,target:`_blank`,rel:`noreferrer`,className:`inline-flex min-h-11 items-center rounded-lg px-2 text-xs text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:v.docsLink}),t[104]=v.docsLink,t[105]=de,t[106]=q):q=t[106];let fe;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(fe=()=>{z.current?.scrollIntoView?.({block:`start`}),z.current?.focus({preventScroll:!0})},t[107]=fe):fe=t[107];let pe=g?`服务账户`:`Service accounts`,me;t[108]!==F||t[109]!==pe?(me=(0,$.jsx)(Z,{variant:`secondary`,disabled:F,onClick:fe,children:pe}),t[108]=F,t[109]=pe,t[110]=me):me=t[110];let he;t[111]!==q||t[112]!==me?(he=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[q,me]}),t[111]=q,t[112]=me,t[113]=he):he=t[113];let ge;t[114]!==le||t[115]!==ue||t[116]!==he?(ge=(0,$.jsx)(Et,{title:le,subtitle:ue,actions:he}),t[114]=le,t[115]=ue,t[116]=he,t[117]=ge):ge=t[117];let _e;t[118]!==w||t[119]!==g?(_e=w?(0,$.jsx)(l,{to:w,className:`text-sm text-accent-fg hover:underline`,children:w===`/settings/phone-use`?g?`返回手机控制并测试模型`:`Return to phone control and test the model`:g?`返回原来的工作`:`Return to your work`}):null,t[118]=w,t[119]=g,t[120]=_e):_e=t[120];let ve;t[121]!==w||t[122]!==g?(ve=w?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:w===`/settings/phone-use`?g?`正在为手机控制连接模型服务;此处保存服务设置后,还需返回选择并测试手机模型。`:`Connect a model service for phone control, then return to select and test the phone model.`:g?`正在为原来的工作配置模型。服务保存、模型选择和实际运行验证分别生效。`:`Configure models for your work. Saving a service, choosing a model and verifying a run are separate steps.`}):null,t[121]=w,t[122]=g,t[123]=ve):ve=t[123];let ye;t[124]===F?ye=t[125]:(ye=e=>{F||Me(e)},t[124]=F,t[125]=ye);let be;t[126]!==G||t[127]!==B||t[128]!==F||t[129]!==ye||t[130]!==g?(be=(0,$.jsx)(In,{data:B,zh:g,disabled:F,onPendingChange:M,onChange:G,onSettings:ye}),t[126]=G,t[127]=B,t[128]=F,t[129]=ye,t[130]=g,t[131]=be):be=t[131];let xe=g?`连接的服务`:`Connected services`,Se;t[132]===xe?Se=t[133]:(Se=(0,$.jsx)(`h2`,{id:`model-services-heading`,className:`text-base font-semibold text-fg`,children:xe}),t[132]=xe,t[133]=Se);let Ce=g?`在这里管理账户和密钥;各项能力的模型与参数在上方调整。`:`Manage accounts and keys here. Choose models and adjust capability settings above.`,we;t[134]===Ce?we=t[135]:(we=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Ce}),t[134]=Ce,t[135]=we);let J;t[136]!==Se||t[137]!==we?(J=(0,$.jsxs)(`div`,{children:[Se,we]}),t[136]=Se,t[137]=we,t[138]=J):J=t[138];let Y;t[139]!==v.xopcCloudAccount||t[140]!==H?(Y=H?(0,$.jsx)(Wt,{labels:v.xopcCloudAccount,children:(0,$.jsx)(sr,{showCapabilities:!1,embedded:!0})}):null,t[139]=v.xopcCloudAccount,t[140]=H,t[141]=Y):Y=t[141];let Te,X;t[142]===Symbol.for(`react.memo_cache_sentinel`)?(Te=()=>L(!0),X=(e,t)=>R({providerId:e,isCustom:t}),t[142]=Te,t[143]=X):(Te=t[142],X=t[143]);let Ee;t[144]!==v.connectedProviders||t[145]!==B?(Ee=(0,$.jsx)(ie,{labels:v.connectedProviders,data:B,onAdd:Te,onManage:X}),t[144]=v.connectedProviders,t[145]=B,t[146]=Ee):Ee=t[146];let De;t[147]!==H||t[148]!==B.cards.length?(De=!H&&B.cards.length>0?(0,$.jsx)(sr,{showCapabilities:!1}):null,t[147]=H,t[148]=B.cards.length,t[149]=De):De=t[149];let Oe;t[150]!==J||t[151]!==Y||t[152]!==Ee||t[153]!==De?(Oe=(0,$.jsxs)(`section`,{ref:z,tabIndex:-1,"aria-labelledby":`model-services-heading`,className:`space-y-4 scroll-mt-4 rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[J,Y,Ee,De]}),t[150]=J,t[151]=Y,t[152]=Ee,t[153]=De,t[154]=Oe):Oe=t[154];let ke;t[155]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>{ne(),L(!1)},t[155]=ke):ke=t[155];let Ae;t[156]!==I||t[157]!==v.addProviderDialog||t[158]!==m||t[159]!==B.builtinRows||t[160]!==B.customConfig?(Ae=(0,$.jsx)(re,{open:I,connectOnly:!0,onOpenChange:L,builtinRows:B.builtinRows,customConfig:B.customConfig,labels:v.addProviderDialog,language:m,onSaved:ke}),t[156]=I,t[157]=v.addProviderDialog,t[158]=m,t[159]=B.builtinRows,t[160]=B.customConfig,t[161]=Ae):Ae=t[161];let je;t[162]!==v.manageProviderDialog||t[163]!==m||t[164]!==ee||t[165]!==B.allModels||t[166]!==B.builtinRows||t[167]!==B.customConfig?(je=ee?(0,$.jsx)(Gn,{open:!0,onOpenChange:e=>{e||R(null)},providerId:ee.providerId,isCustom:ee.isCustom,builtinRows:B.builtinRows,customConfig:B.customConfig,allModels:B.allModels,labels:v.manageProviderDialog,language:m,onSaved:ne}):null,t[162]=v.manageProviderDialog,t[163]=m,t[164]=ee,t[165]=B.allModels,t[166]=B.builtinRows,t[167]=B.customConfig,t[168]=je):je=t[168];let Ne;return t[169]!==ge||t[170]!==_e||t[171]!==ve||t[172]!==be||t[173]!==Oe||t[174]!==Ae||t[175]!==je?(Ne=(0,$.jsxs)(Tt,{children:[ge,_e,ve,be,Oe,Ae,je]}),t[169]=ge,t[170]=_e,t[171]=ve,t[172]=be,t[173]=Oe,t[174]=Ae,t[175]=je,t[176]=Ne):Ne=t[176],Ne}function lr(e){return e.id}function ur(){st()}function dr(e){return e.id===`xopc-cloud`&&!e.isCustom}function fr(e){return e.language}export{cr as CapabilitiesSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{u as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a,i as o,l as s,n as c,o as l}from"./locale-store-D3c8DIm-.js";import{t as u}from"./messages-DPLud9GK.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-CY7CS_D3.js";import{s as v,t as y}from"./popover-select-CLsphyzA.js";import{t as b}from"./circle-alert-BEjgurr2.js";import{t as x}from"./circle-check-C23XjkUj.js";import{t as S}from"./external-link-DjqjBmc3.js";import{t as C}from"./loader-circle-CifKLtgG.js";import{t as w}from"./session-channel-icon-BzkFo-Ci.js";import{i as T,n as E,r as D,t as O}from"./channels-routes-r2g-9DdC.js";import{t as k}from"./rotate-ccw-JM1TBLpp.js";import{t as A}from"./settings-2-D-csvaET.js";import{t as j}from"./stethoscope-DRqTAtjD.js";import{t as M}from"./triangle-alert-2JXFNNKU.js";import{t as N}from"./x-B_N4OPjy.js";import{t as P}from"./cn-0WouolD0.js";import{t as F}from"./skeleton-DzdOeGYz.js";import{i as I}from"./vendor-swr-CdRzEUwF.js";import{t as L}from"./chat-agents-api-BRQDNNI5.js";import{t as R}from"./button-Cc4hUNTt.js";import{i as z,o as ee}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as te}from"./interaction-BdhHBbYa.js";import{n as ne}from"./secret-input-labels-B5Jl5HqK.js";import{i as re}from"./navigation-ByOzYT0t.js";import{t as ie}from"./refresh-button-DiWdGAaX.js";import{t as ae}from"./extension-iframe-host-D0-OvFV2.js";import{n as oe}from"./agent-display-names-Bje7vfSn.js";import{n as se}from"./settings-loading-skeleton-CAoOV17i.js";import{t as ce}from"./browser-BLJWD7WI.js";import{t as le}from"./settings-advanced-section-nbkGHQ_4.js";import{n as ue}from"./settings-page-header-19GJ_a45.js";import"./settings-page-layout-B2WCzSel.js";import{t as de}from"./schema-form-C9TYGa0_.js";var B=n(),V=r();function fe(e){let t=(0,B.c)(21),{language:n}=e,r=n===`zh`,i=r?`Telegram 接入步骤`:`Telegram setup steps`,a=r?`先连接机器人,再确认谁能访问`:`Connect your bot, then choose who can access it`,o;t[0]===a?o=t[1]:(o=(0,V.jsx)(`h3`,{className:`font-medium text-fg`,children:a}),t[0]=a,t[1]=o);let s=r?`在 Telegram 打开 `:`Open `,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,V.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noreferrer`,className:`text-accent hover:underline`,children:`@BotFather`}),t[2]=c):c=t[2];let l=r?`,发送 /newbot 创建机器人并获取 Bot Token。请勿把 Token 发给其他人。`:` in Telegram. Send /newbot to create a bot and obtain its token. Keep the token private.`,u;t[3]!==s||t[4]!==l?(u=(0,V.jsxs)(`li`,{children:[s,c,l]}),t[3]=s,t[4]=l,t[5]=u):u=t[5];let d=r?`填写 Bot Token。首次接入建议使用 pairing(配对);allowlist 只允许名单中的用户,open 允许所有人。群聊访问单独设置。`:`Enter the bot token. Use pairing for first setup; allowlist admits listed users, while open admits everyone. Group access is configured separately.`,f;t[6]===d?f=t[7]:(f=(0,V.jsx)(`li`,{children:d}),t[6]=d,t[7]=f);let p=r?`保存后检查上方连接状态;已保存不代表已经连通。`:`Save, then check the connection status above. Saved settings do not prove a working connection.`,m;t[8]===p?m=t[9]:(m=(0,V.jsx)(`li`,{children:p}),t[8]=p,t[9]=m);let h=r?`在 Telegram 给机器人发一条消息。若使用配对策略,按返回的配对提示批准自己的账号后再试。`:`Message your bot in Telegram. With pairing enabled, follow the pairing instructions to approve your account, then try again.`,g;t[10]===h?g=t[11]:(g=(0,V.jsx)(`li`,{children:h}),t[10]=h,t[11]=g);let _;t[12]!==m||t[13]!==g||t[14]!==u||t[15]!==f?(_=(0,V.jsxs)(`ol`,{className:`mt-2 list-decimal space-y-2 pl-5 text-fg-muted`,children:[u,f,m,g]}),t[12]=m,t[13]=g,t[14]=u,t[15]=f,t[16]=_):_=t[16];let v;return t[17]!==i||t[18]!==_||t[19]!==o?(v=(0,V.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4 text-sm`,"aria-label":i,children:[o,_]}),t[17]=i,t[18]=_,t[19]=o,t[20]=v):v=t[20],v}var H=e(t(),1);async function pe(){return(await l(o(`/api/channels/status`))).payload?.channels||[]}function me(){return o(`/api/channels/status`)}var he=pe;function ge(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var _e=e(ce(),1);async function U(e){let t=await a(o(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ve({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,H.useMemo)(()=>ge(e),[e]),o=(0,H.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[s,c]=(0,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{c({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let l=(0,H.useCallback)(async(n,i)=>{c(e=>({...e,busy:!0,error:null}));try{let a=await U({channelId:e.id,actionId:n,locale:t,input:i});c(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){c(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{let t=K(s.payload,e.id);if(!t){c(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return c(e=>e.generatedQr?{...e,generatedQr:null}:e),_e.toDataURL(t,{width:220,margin:1}).then(e=>{n||c(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,s.payload]),(0,H.useEffect)(()=>{let n=s.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||U({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(c(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||c(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,s.poll]);let u=a?.[1].label??(e.configured?n.reconnect:n.connect),d=e.actions?.[`doctor.run`]?.label??n.diagnose,f=G(s.payload),p=K(s.payload,e.id),m=p?s.generatedQr:q(s.payload),h=a?.[1].result===`qr`&&(s.busy||s.payload?.type===`qr`||s.payload?.type===`poll`),g=s.payload?.type===`form`?s.payload:null,_=s.payload?.type===`diagnostics`?s.payload.checks:null;return(0,V.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,V.jsxs)(`div`,{className:P(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,V.jsxs)(R,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(a[0]),children:[s.busy?(0,V.jsx)(C,{className:`size-4 animate-spin`}):(0,V.jsx)(T,{className:`size-4`}),u]}):null,e.actions?.[`doctor.run`]?(0,V.jsxs)(R,{type:`button`,variant:`secondary`,disabled:s.busy,onClick:()=>void l(`doctor.run`),children:[(0,V.jsx)(j,{className:`size-4`}),d]}):null]})]}),f?(0,V.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:f}):null,s.error?(0,V.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,h?(0,V.jsxs)(`div`,{className:P(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,V.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:m?(0,V.jsx)(`img`,{src:m,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,V.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,V.jsx)(F,{className:`size-48 rounded-md`})})}),(0,V.jsxs)(`div`,{className:P(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[m?(0,V.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,V.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,V.jsx)(F,{className:`h-4 w-48 max-w-full`}),(0,V.jsx)(F,{className:`h-4 w-36 max-w-full`})]}),p?(0,V.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:p,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,V.jsx)(S,{className:`size-3.5`})]}):null]})]}):null,s.payload?.type===`poll`&&s.payload.phase===`done`?(0,V.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,V.jsx)(x,{className:s.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,V.jsx)(`span`,{className:s.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:s.payload.message??(s.payload.ok?n.complete:n.failed)})]}):null,g?(0,V.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,V.jsx)(de,{schema:g.schema,values:s.formDraft,onChange:e=>c(t=>({...t,formDraft:e})),disabled:s.busy,labels:o}),(0,V.jsx)(R,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(g.submitAction,s.formDraft),children:n.saveSetup})]}):null,_?(0,V.jsx)(`div`,{className:`mt-4 space-y-2`,children:_.map((e,t)=>(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,V.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var ye=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function be(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function xe(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:ye,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Se(e,t,n){let r=Y(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Ce(e,t=!1){return e===`drawer`?P(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,z):P(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,z,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function we(e){let t=(0,B.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:u,footer:y,wide:b,headerExtra:x}=e,S=b!==void 0&&b,C=n===`drawer`,[w,T]=(0,H.useState)(null),E;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,V.jsx)(d,{className:P(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),t[0]=E):E=t[0];let D;t[1]!==n||t[2]!==S?(D=Ce(n,S),t[1]=n,t[2]=S,t[3]=D):D=t[3];let O;t[4]===s?O=t[5]:(O=s?(0,V.jsx)(g,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=O);let k;t[6]===c?k=t[7]:(k=c?(0,V.jsx)(f,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=k);let A;t[8]!==l||t[9]!==o||t[10]!==x||t[11]!==C||t[12]!==a?(A=C?(0,V.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,V.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,V.jsx)(p,{asChild:!0,children:(0,V.jsx)(R,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,V.jsx)(N,{className:`size-5`,strokeWidth:1.75})})})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(p,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:P(te,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,V.jsx)(N,{className:`size-4`})})}),x]}),t[8]=l,t[9]=o,t[10]=x,t[11]=C,t[12]=a,t[13]=A):A=t[13];let j=C?`p-4`:`p-6`,M;t[14]===j?M=t[15]:(M=P(`min-h-0 flex-1 overflow-y-auto`,j),t[14]=j,t[15]=M);let F;t[16]!==u||t[17]!==M?(F=(0,V.jsx)(`div`,{className:M,children:u}),t[16]=u,t[17]=M,t[18]=F):F=t[18];let I;t[19]!==y||t[20]!==w||t[21]!==O||t[22]!==k||t[23]!==A||t[24]!==F?(I=(0,V.jsxs)(v,{layer:`modal`,portalContainer:w,children:[O,k,A,F,y]}),t[19]=y,t[20]=w,t[21]=O,t[22]=k,t[23]=A,t[24]=F,t[25]=I):I=t[25];let L;t[26]!==I||t[27]!==D?(L=(0,V.jsxs)(m,{children:[E,(0,V.jsx)(h,{ref:T,className:D,onOpenAutoFocus:Te,children:I})]}),t[26]=I,t[27]=D,t[28]=L):L=t[28];let z;return t[29]!==i||t[30]!==r||t[31]!==L?(z=(0,V.jsx)(_,{open:r,onOpenChange:i,children:L}),t[29]=i,t[30]=r,t[31]=L,t[32]=z):z=t[32],z}function Te(e){return e.preventDefault()}var Ee=(0,H.memo)(function(e){let t=(0,B.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,V.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,V.jsx)(ie,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,V.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function De(e){let t=(0,B.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0||c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,V.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,V.jsx)(R,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,V.jsx)(R,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,V.jsx)(R,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,V.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-overlay px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function Oe(e){return o(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function ke(e){return(await l(Oe(e))).payload?.channels??[]}function Ae(e,t){let n=(0,B.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Oe(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>ke(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=I(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var je=`channels-status`;function Me(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Ne(e){let t=t=>e(t.detail);return window.addEventListener(je,t),()=>window.removeEventListener(je,t)}function Pe(e,t){let n=(0,B.c)(4),r=t===void 0||t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Ne(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,H.useEffect)(i,a)}function Fe(e){return e?o(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Ie(e){return(await l(o(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Le=[`enabled`],Re=`max-w-7xl`,ze=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Be(){let e=await l(o(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Ve(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function He(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Ue(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function We(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ge(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ke(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=new Set([`dmPolicy`,`groupPolicy`,`allowFrom`,`groupAllowFrom`]),a=[...Object.keys(t).filter(e=>!e.includes(`*`)&&i.has(e.split(`.`).at(-1)??``)),...Object.keys(Z(e.configSchema?.properties)?e.configSchema.properties:{}).filter(e=>i.has(e))],o=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Le.includes(e));return Array.from(new Set([...o,...a,...n,...r])).filter(e=>!Le.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qe(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Je(e,t){let n={...qe(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...qe(r[n]),properties:{}}),e===t.length-1){o[n]=qe(r[n]);break}i=r[n],a=o[n]}}return n}function Ye(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ye(n)&&delete t[e];return Object.keys(t).length===0}function Xe(e,t){let n=qe(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return Ye(n),n}function Ze(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Q(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function Qe(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function $e(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function et(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push($(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=$e(e,Q(t,e),n);i&&r.push(i)}let a=Qe(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function tt(e,t){let n=X(e),r=ge(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function nt(e,t){let n=ge(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function rt(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function $(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function it({entry:e}){let[t,n]=(0,H.useState)(!1),r=(0,H.useMemo)(()=>!e.ui?.icon||t?null:new URL(o(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Ve(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,V.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,V.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,V.jsx)(w,{sourceChannel:e.id,className:`size-7`})})}function at(e){let t=(0,B.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=P(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=P(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,V.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,V.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function ot(e){let t=(0,B.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:l,onRestart:u}=e,d;t[0]===n?d=t[1]:(d=X(n),t[0]=n,t[1]=d);let f=d,p,m,h,g,_,v,y;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==u||t[8]!==l||t[9]!==i||t[10]!==f.enabled||t[11]!==f.ready){let e=et(n,r,s),o=rt(n,s);p=!f.enabled&&f.ready?l:i===`stopped`?u:c,v=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let d;t[19]===n?d=t[20]:(d=(0,V.jsx)(it,{entry:n}),t[19]=n,t[20]=d);let b;t[21]===n.label?b=t[22]:(b=(0,V.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=b);let x;t[23]===i?x=t[24]:(x=P(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ge(i)),t[23]=i,t[24]=x);let S;t[25]!==s||t[26]!==i?(S=Ue(i,s),t[25]=s,t[26]=i,t[27]=S):S=t[27];let C;t[28]!==x||t[29]!==S?(C=(0,V.jsx)(`span`,{className:x,children:S}),t[28]=x,t[29]=S,t[30]=C):C=t[30];let w;t[31]!==C||t[32]!==b?(w=(0,V.jsxs)(`div`,{className:`min-w-0`,children:[b,C]}),t[31]=C,t[32]=b,t[33]=w):w=t[33];let T;t[34]!==w||t[35]!==d?(T=(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[d,w]}),t[34]=w,t[35]=d,t[36]=T):T=t[36];let E=f.enabled,D;t[37]!==s.toggleChannel||t[38]!==n.label?(D=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=D):D=t[39];let O;t[40]!==a||t[41]!==l||t[42]!==f.enabled||t[43]!==D?(O=(0,V.jsx)(at,{checked:E,disabled:a,label:D,onToggle:l}),t[40]=a,t[41]=l,t[42]=f.enabled,t[43]=D,t[44]=O):O=t[44],t[45]!==T||t[46]!==O?(y=(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[T,O]}),t[45]=T,t[46]=O,t[47]=y):y=t[47],m=`button`,h=c,g=`mt-5 min-h-[6.25rem] text-left`,_=f.ready?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,V.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(ct)}):null]}):(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,V.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??nt(n,s)}),o.length>0?(0,V.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(st)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=u,t[8]=l,t[9]=i,t[10]=f.enabled,t[11]=f.ready,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_,t[17]=v,t[18]=y}else p=t[12],m=t[13],h=t[14],g=t[15],_=t[16],v=t[17],y=t[18];let b;t[48]!==m||t[49]!==h||t[50]!==g||t[51]!==_?(b=(0,V.jsx)(`button`,{type:m,onClick:h,className:g,children:_}),t[48]=m,t[49]=h,t[50]=g,t[51]=_,t[52]=b):b=t[52];let x=a||o,S;t[53]!==a||t[54]!==o?(S=a||o?(0,V.jsx)(C,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=S):S=t[55];let w;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(w=o?s.restartingChannel:i===`stopped`?s.restartChannel:tt(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=w):w=t[60];let T;t[61]!==p||t[62]!==S||t[63]!==w||t[64]!==x?(T=(0,V.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,V.jsxs)(R,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:p,disabled:x,children:[S,w]})}),t[61]=p,t[62]=S,t[63]=w,t[64]=x,t[65]=T):T=t[65];let E;return t[66]!==T||t[67]!==v||t[68]!==y||t[69]!==b?(E=(0,V.jsxs)(`article`,{className:v,children:[y,b,T]}),t[66]=T,t[67]=v,t[68]=y,t[69]=b,t[70]=E):E=t[70],E}function st(e){return(0,V.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function ct(e){return(0,V.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function lt(e){let t=(0,B.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:s,onRestart:c,onCheck:l,onManageConnection:u}=e,d=n===`running`?x:n===`stopped`||n===`needs_setup`?b:C,f=n===`running`&&`text-emerald-600 dark:text-emerald-400`,p=n===`stopped`&&`text-red-600 dark:text-red-400`,m=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,h=n===`disabled`&&`text-fg-muted`,g=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,_;t[0]!==f||t[1]!==p||t[2]!==m||t[3]!==h||t[4]!==g?(_=P(`mt-0.5 size-5 shrink-0`,f,p,m,h,g),t[0]=f,t[1]=p,t[2]=m,t[3]=h,t[4]=g,t[5]=_):_=t[5];let v;t[6]!==d||t[7]!==_?(v=(0,V.jsx)(d,{className:_}),t[6]=d,t[7]=_,t[8]=v):v=t[8];let y;t[9]===s.connectionStatus?y=t[10]:(y=(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectionStatus}),t[9]=s.connectionStatus,t[10]=y);let S;t[11]!==s||t[12]!==n?(S=We(n,s),t[11]=s,t[12]=n,t[13]=S):S=t[13];let w;t[14]===S?w=t[15]:(w=(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=w);let T;t[16]!==w||t[17]!==y?(T=(0,V.jsxs)(`div`,{children:[y,w]}),t[16]=w,t[17]=y,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==v?(E=(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[v,T]}),t[19]=T,t[20]=v,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,V.jsx)(C,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let A=i?s.checkingConnection:s.checkConnection,j;t[24]!==l||t[25]!==D||t[26]!==O||t[27]!==A?(j=(0,V.jsxs)(R,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:l,children:[O,A]}),t[24]=l,t[25]=D,t[26]=O,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==s.restartChannel||t[30]!==s.restartingChannel||t[31]!==i||t[32]!==c||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,V.jsxs)(R,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:c,children:[r?(0,V.jsx)(C,{className:`size-4 animate-spin`}):(0,V.jsx)(k,{className:`size-4`}),r?s.restartingChannel:s.restartChannel]}):null,t[29]=s.restartChannel,t[30]=s.restartingChannel,t[31]=i,t[32]=c,t[33]=r,t[34]=n,t[35]=M):M=t[35];let N;t[36]!==o||t[37]!==s.connectionOptions||t[38]!==s.hideConnectionOptions||t[39]!==i||t[40]!==u||t[41]!==r||t[42]!==a?(N=o?(0,V.jsx)(R,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:u,children:a?s.hideConnectionOptions:s.connectionOptions}):null,t[36]=o,t[37]=s.connectionOptions,t[38]=s.hideConnectionOptions,t[39]=i,t[40]=u,t[41]=r,t[42]=a,t[43]=N):N=t[43];let F;t[44]!==j||t[45]!==M||t[46]!==N?(F=(0,V.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=F):F=t[47];let I;return t[48]!==E||t[49]!==F?(I=(0,V.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,F]})}),t[48]=E,t[49]=F,t[50]=I):I=t[50],I}function ut(e){let t=(0,B.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=X(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl bg-amber-50 px-4 py-3 text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,V.jsx)(M,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,V.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,V.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,V.jsx)(`li`,{children:$(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,V.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,V.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,V.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,V.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function dt({channelId:e,onHeaderActionChange:t}){let n=c(e=>e.language),r=u(n),l=s(e=>!!e.conversationId),d=i(),f=D(e),p=Ae(l,n),m=p.entries,{data:h,mutate:g,isValidating:_}=I(l?me():null,he,{revalidateOnFocus:!0}),{data:v,mutate:b}=I(l?`channels-config-map`:null,Be,{revalidateOnFocus:!1}),x=v?.channels??{},C=v?.bindings??[],{data:w}=I(l?`channel-routing-agents`:null,L,{revalidateOnFocus:!1}),T=(0,H.useMemo)(()=>m.find(e=>e.id===f),[f,m]),k=T?He(T):null,{data:j,mutate:M}=I(l&&k?Fe(k):null,()=>Ie(k)),[N,F]=(0,H.useState)(null),[R,z]=(0,H.useState)(!1),[ee,te]=(0,H.useState)(null),[ie,ce]=(0,H.useState)(null),[B,pe]=(0,H.useState)(!1),[_e,U]=(0,H.useState)(null),[W,G]=(0,H.useState)(null),K=N??j??{},q=r.channelsSettings,ye=(0,H.useMemo)(()=>T?.configSchema??{type:`object`,properties:{}},[T?.configSchema]),J=(0,H.useMemo)(()=>Xe(ye,Le),[ye]),Y=(0,H.useMemo)(()=>Ke(T),[T]),Ce=(0,H.useMemo)(()=>T?.id===`telegram`?ft(Je(J,Y)):Je(J,Y),[T?.id,Y,J]),Te=(0,H.useMemo)(()=>Xe(J,Y),[T?.id,Y,J]),Oe=(0,H.useMemo)(()=>Ze(Ce),[Ce]),ke=T?W??be(C,T.id):``,je=(0,H.useMemo)(()=>(w?.items??[]).map(e=>{let t=oe(e,r.agentsSettings);return{value:e.id,label:t===e.id?t:`${t} · ${e.id}`}}),[w?.items,r.agentsSettings]),Ne=w?.items.find(e=>e.id===w.defaultId),Ve=Ne?oe(Ne,r.agentsSettings):w?.defaultId??``,We=(0,H.useMemo)(()=>({secretInputLabels:ne(q),defaultBooleanLabel:q.schemaBooleanDefault,unsupportedArrayType:q.schemaUnsupportedArrayType,arrayAddPlaceholder:q.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>q.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[q]),Z=(0,H.useMemo)(()=>new Map((h??[]).map(e=>[e.name,e])),[h]),qe=h!==void 0,Ye=(0,H.useCallback)(e=>Se(e,Z.get(e.id),qe),[Z,qe]),Q=(0,H.useCallback)(async()=>{await Promise.all([p.mutate(),g()])},[p,g]);Pe((0,H.useCallback)(e=>{let t=Me(e);t&&g(t,!1)},[g]),l);let Qe=(0,H.useMemo)(()=>l?{secondary:(0,V.jsx)(Ee,{ch:q,refreshing:p.isValidating||_,saveOk:!1,onRefresh:()=>void Q()})}:null,[p.isValidating,q,l,_,Q]);(0,H.useLayoutEffect)(()=>(t?.(Qe),()=>t?.(null)),[Qe,t]);let $e=(0,H.useCallback)(e=>{d(E(e)),F(null),G(null),U(null)},[d]),et=(0,H.useCallback)(()=>{d(O),F(null),G(null),U(null)},[d]),tt=(0,H.useCallback)(async e=>{ce(e.id),U(null);try{let t=await a(o(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){U(e instanceof Error?e.message:String(e))}finally{ce(null)}},[Q]);(0,H.useEffect)(()=>{G(null),pe(!1)},[T?.id]);let nt=(0,H.useCallback)(async()=>{if(!T||!N&&W===null)return!1;let e=He(T);z(!0),U(null);try{let t=await a(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({...N?{channels:{[e]:N}}:{},...W===null?{}:{bindings:xe(C,T.id,W)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return N&&await M(N,!1),await b(),await p.mutate(),F(null),G(null),!0}catch(e){return U(e instanceof Error?e.message:String(e)),!1}finally{z(!1)}},[T,W,C,p,N,b,M]),rt=(0,H.useCallback)(async e=>{let t=X(e),n=He(e),r=T?.id===e.id?N:null;if(!t.enabled&&!t.ready&&!r){$e(e.id);return}te(e.id),U(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},s=await a(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error?.message??s.statusText)}await p.mutate(),await b(),await g(),T?.id===e.id&&(await M(),F(null))}catch(e){U(e instanceof Error?e.message:String(e))}finally{te(null)}},[T?.id,p,N,b,M,g,$e]),$=T?.ui?.modal,st=$?.placement!==`replace-config`,ct=T?Ye(T):`checking`,dt=T?!X(T).ready||B:!1;return l?(0,V.jsxs)(ue,{gap:`gap-4`,className:Re,padding:ze,children:[p.isLoading?(0,V.jsx)(se,{sections:2}):p.error?(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(p.error)}):(0,V.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:m.map(e=>(0,V.jsx)(ot,{entry:e,config:x[He(e)]?.config,runtime:Ye(e),busy:ee===e.id,restarting:ie===e.id,ch:q,onOpen:()=>$e(e.id),onToggle:()=>void rt(e),onRestart:()=>void tt(e)},e.id))}),_e?(0,V.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:_e}):null,(0,V.jsx)(we,{presentation:`modal`,open:!!T,onOpenChange:e=>{e||et()},closeAriaLabel:q.close,srTitle:T?.label??q.selectChannel,srDescription:T?.description,wide:!0,footer:T?(0,V.jsx)(De,{ch:q,dirty:!!N||W!==null,saving:R,onCancel:et,onDiscard:()=>{F(null),G(null)},onSave:nt}):null,children:T?(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,V.jsx)(it,{entry:T}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,V.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:T.label}),(0,V.jsx)(`span`,{className:P(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ge(ct)),children:Ue(ct,q)})]}),(0,V.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(T).ready&&ge(T)?.[1].result===`qr`?q.scanLoginHint.replace(`{{channel}}`,T.label):T.description}),T.docsPath?(0,V.jsxs)(`a`,{href:re(n,T.docsPath),target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[q.docs,(0,V.jsx)(S,{className:`size-3.5`})]}):null]})]})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,V.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(T).enabled?q.enabledLabel:q.disabledLabel}),(0,V.jsx)(at,{checked:X(T).enabled,disabled:ee===T.id,label:q.toggleChannel.replace(`{{channel}}`,T.label),onToggle:()=>void rt(T)})]})]})}),(0,V.jsx)(lt,{runtime:ct,restarting:ie===T.id,checking:_,showConnectionOptions:B,canManageConnection:X(T).ready&&$?.placement!==`replace-config`,ch:q,onRestart:()=>void tt(T),onCheck:()=>void Q(),onManageConnection:()=>pe(e=>!e)}),(0,V.jsx)(ut,{entry:T,ch:q}),T.id===`telegram`?(0,V.jsx)(fe,{language:n}):null,dt&&$?.placement!==`replace-config`?(0,V.jsx)(ve,{entry:T,locale:n,messages:q,compact:!0,onChanged:async()=>{await M(),await Q(),await b()}},T.id):null,$?.entrypoint&&$.placement===`before-config`?(0,V.jsx)(ae,{extensionId:T.extensionId,extensionName:T.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:T.id,entry:T,config:K}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,V.jsx)(ae,{extensionId:T.extensionId,extensionName:T.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:T.id,entry:T,config:K}}):null,st&&Oe?(0,V.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.basicConfiguration}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.basicConfigurationHint})]}),(0,V.jsx)(de,{schema:Ce,values:K,onChange:e=>F(e),disabled:R,labels:We})]}):null,(0,V.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,V.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,V.jsx)(A,{className:`size-4 text-fg-muted`}),q.messageHandling]}),(0,V.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,V.jsxs)(`div`,{className:`mb-3`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.agentRouting}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.messageHandlingHint})]}),(0,V.jsx)(y,{value:ke,options:je,placeholder:q.agentRoutingSelect,emptyLabel:q.agentRoutingDefault.replace(`{{agent}}`,Ve||q.agentRoutingSelect),ariaLabel:q.agentRouting,disabled:R||!w,onChange:e=>G(e)})]})]}),st&&Ze(Te)?(0,V.jsx)(le,{title:q.advancedConfiguration,summary:q.messageHandlingHint,children:(0,V.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,V.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,V.jsx)(A,{className:`size-4 text-fg-muted`}),q.advancedConfiguration]}),(0,V.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,V.jsx)(de,{schema:Te,values:K,onChange:e=>F(e),disabled:R,labels:We})})]})}):null,_e?(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:_e}):null]}):null})]}):(0,V.jsx)(ue,{gap:`gap-3`,className:Re,padding:ze,children:(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:q.tokenRequired})})}function ft(e){let t=e.properties;if(!t)return e;let n=[`botToken`,`dmPolicy`,`allowFrom`,`groupPolicy`,`groupAllowFrom`];return{...e,properties:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...ft(t),...n.includes(e)?{"x-order":n.indexOf(e)}:{}}]))}}export{dt as ChannelsSettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{u as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a,i as o,l as s,n as c,o as l}from"./locale-store-cg9cm2EL.js";import{t as u}from"./messages-eQ2CYlpG.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-CY7CS_D3.js";import{s as v,t as y}from"./popover-select-CLsphyzA.js";import{t as b}from"./circle-alert-BEjgurr2.js";import{t as x}from"./circle-check-C23XjkUj.js";import{t as S}from"./external-link-DjqjBmc3.js";import{t as C}from"./loader-circle-CifKLtgG.js";import{t as w}from"./session-channel-icon-BzkFo-Ci.js";import{i as T,n as E,r as D,t as O}from"./channels-routes-r2g-9DdC.js";import{t as k}from"./rotate-ccw-JM1TBLpp.js";import{t as A}from"./settings-2-D-csvaET.js";import{t as j}from"./stethoscope-DRqTAtjD.js";import{t as M}from"./triangle-alert-2JXFNNKU.js";import{t as N}from"./x-B_N4OPjy.js";import{t as P}from"./cn-0WouolD0.js";import{t as F}from"./skeleton-DzdOeGYz.js";import{i as I}from"./vendor-swr-CdRzEUwF.js";import{t as L}from"./chat-agents-api-UOdNWZ0_.js";import{t as R}from"./button-Cc4hUNTt.js";import{i as z,o as ee}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as te}from"./interaction-BdhHBbYa.js";import{n as ne}from"./secret-input-labels-B5Jl5HqK.js";import{i as re}from"./navigation-ByOzYT0t.js";import{t as ie}from"./refresh-button-DiWdGAaX.js";import{t as ae}from"./extension-iframe-host-DiIqM2JO.js";import{n as oe}from"./agent-display-names-Bje7vfSn.js";import{n as se}from"./settings-loading-skeleton-CAoOV17i.js";import{t as ce}from"./browser-BLJWD7WI.js";import{t as le}from"./settings-advanced-section-C6dPu5i1.js";import{n as ue}from"./settings-page-header-BSMu5Zq3.js";import"./settings-page-layout-B_vMffB1.js";import{t as de}from"./schema-form-C9TYGa0_.js";var B=n(),V=r();function fe(e){let t=(0,B.c)(21),{language:n}=e,r=n===`zh`,i=r?`Telegram 接入步骤`:`Telegram setup steps`,a=r?`先连接机器人,再确认谁能访问`:`Connect your bot, then choose who can access it`,o;t[0]===a?o=t[1]:(o=(0,V.jsx)(`h3`,{className:`font-medium text-fg`,children:a}),t[0]=a,t[1]=o);let s=r?`在 Telegram 打开 `:`Open `,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,V.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noreferrer`,className:`text-accent hover:underline`,children:`@BotFather`}),t[2]=c):c=t[2];let l=r?`,发送 /newbot 创建机器人并获取 Bot Token。请勿把 Token 发给其他人。`:` in Telegram. Send /newbot to create a bot and obtain its token. Keep the token private.`,u;t[3]!==s||t[4]!==l?(u=(0,V.jsxs)(`li`,{children:[s,c,l]}),t[3]=s,t[4]=l,t[5]=u):u=t[5];let d=r?`填写 Bot Token。首次接入建议使用 pairing(配对);allowlist 只允许名单中的用户,open 允许所有人。群聊访问单独设置。`:`Enter the bot token. Use pairing for first setup; allowlist admits listed users, while open admits everyone. Group access is configured separately.`,f;t[6]===d?f=t[7]:(f=(0,V.jsx)(`li`,{children:d}),t[6]=d,t[7]=f);let p=r?`保存后检查上方连接状态;已保存不代表已经连通。`:`Save, then check the connection status above. Saved settings do not prove a working connection.`,m;t[8]===p?m=t[9]:(m=(0,V.jsx)(`li`,{children:p}),t[8]=p,t[9]=m);let h=r?`在 Telegram 给机器人发一条消息。若使用配对策略,按返回的配对提示批准自己的账号后再试。`:`Message your bot in Telegram. With pairing enabled, follow the pairing instructions to approve your account, then try again.`,g;t[10]===h?g=t[11]:(g=(0,V.jsx)(`li`,{children:h}),t[10]=h,t[11]=g);let _;t[12]!==m||t[13]!==g||t[14]!==u||t[15]!==f?(_=(0,V.jsxs)(`ol`,{className:`mt-2 list-decimal space-y-2 pl-5 text-fg-muted`,children:[u,f,m,g]}),t[12]=m,t[13]=g,t[14]=u,t[15]=f,t[16]=_):_=t[16];let v;return t[17]!==i||t[18]!==_||t[19]!==o?(v=(0,V.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4 text-sm`,"aria-label":i,children:[o,_]}),t[17]=i,t[18]=_,t[19]=o,t[20]=v):v=t[20],v}var H=e(t(),1);async function pe(){return(await l(o(`/api/channels/status`))).payload?.channels||[]}function me(){return o(`/api/channels/status`)}var he=pe;function ge(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var _e=e(ce(),1);async function U(e){let t=await a(o(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ve({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,H.useMemo)(()=>ge(e),[e]),o=(0,H.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[s,c]=(0,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{c({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let l=(0,H.useCallback)(async(n,i)=>{c(e=>({...e,busy:!0,error:null}));try{let a=await U({channelId:e.id,actionId:n,locale:t,input:i});c(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){c(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{let t=K(s.payload,e.id);if(!t){c(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return c(e=>e.generatedQr?{...e,generatedQr:null}:e),_e.toDataURL(t,{width:220,margin:1}).then(e=>{n||c(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,s.payload]),(0,H.useEffect)(()=>{let n=s.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||U({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(c(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||c(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,s.poll]);let u=a?.[1].label??(e.configured?n.reconnect:n.connect),d=e.actions?.[`doctor.run`]?.label??n.diagnose,f=G(s.payload),p=K(s.payload,e.id),m=p?s.generatedQr:q(s.payload),h=a?.[1].result===`qr`&&(s.busy||s.payload?.type===`qr`||s.payload?.type===`poll`),g=s.payload?.type===`form`?s.payload:null,_=s.payload?.type===`diagnostics`?s.payload.checks:null;return(0,V.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,V.jsxs)(`div`,{className:P(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,V.jsxs)(R,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(a[0]),children:[s.busy?(0,V.jsx)(C,{className:`size-4 animate-spin`}):(0,V.jsx)(T,{className:`size-4`}),u]}):null,e.actions?.[`doctor.run`]?(0,V.jsxs)(R,{type:`button`,variant:`secondary`,disabled:s.busy,onClick:()=>void l(`doctor.run`),children:[(0,V.jsx)(j,{className:`size-4`}),d]}):null]})]}),f?(0,V.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:f}):null,s.error?(0,V.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,h?(0,V.jsxs)(`div`,{className:P(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,V.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:m?(0,V.jsx)(`img`,{src:m,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,V.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,V.jsx)(F,{className:`size-48 rounded-md`})})}),(0,V.jsxs)(`div`,{className:P(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[m?(0,V.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,V.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,V.jsx)(F,{className:`h-4 w-48 max-w-full`}),(0,V.jsx)(F,{className:`h-4 w-36 max-w-full`})]}),p?(0,V.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:p,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,V.jsx)(S,{className:`size-3.5`})]}):null]})]}):null,s.payload?.type===`poll`&&s.payload.phase===`done`?(0,V.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,V.jsx)(x,{className:s.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,V.jsx)(`span`,{className:s.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:s.payload.message??(s.payload.ok?n.complete:n.failed)})]}):null,g?(0,V.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,V.jsx)(de,{schema:g.schema,values:s.formDraft,onChange:e=>c(t=>({...t,formDraft:e})),disabled:s.busy,labels:o}),(0,V.jsx)(R,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(g.submitAction,s.formDraft),children:n.saveSetup})]}):null,_?(0,V.jsx)(`div`,{className:`mt-4 space-y-2`,children:_.map((e,t)=>(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,V.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var ye=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function be(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function xe(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:ye,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Se(e,t,n){let r=Y(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Ce(e,t=!1){return e===`drawer`?P(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,z):P(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,z,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function we(e){let t=(0,B.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:u,footer:y,wide:b,headerExtra:x}=e,S=b!==void 0&&b,C=n===`drawer`,[w,T]=(0,H.useState)(null),E;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,V.jsx)(d,{className:P(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),t[0]=E):E=t[0];let D;t[1]!==n||t[2]!==S?(D=Ce(n,S),t[1]=n,t[2]=S,t[3]=D):D=t[3];let O;t[4]===s?O=t[5]:(O=s?(0,V.jsx)(g,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=O);let k;t[6]===c?k=t[7]:(k=c?(0,V.jsx)(f,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=k);let A;t[8]!==l||t[9]!==o||t[10]!==x||t[11]!==C||t[12]!==a?(A=C?(0,V.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,V.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,V.jsx)(p,{asChild:!0,children:(0,V.jsx)(R,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,V.jsx)(N,{className:`size-5`,strokeWidth:1.75})})})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(p,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:P(te,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,V.jsx)(N,{className:`size-4`})})}),x]}),t[8]=l,t[9]=o,t[10]=x,t[11]=C,t[12]=a,t[13]=A):A=t[13];let j=C?`p-4`:`p-6`,M;t[14]===j?M=t[15]:(M=P(`min-h-0 flex-1 overflow-y-auto`,j),t[14]=j,t[15]=M);let F;t[16]!==u||t[17]!==M?(F=(0,V.jsx)(`div`,{className:M,children:u}),t[16]=u,t[17]=M,t[18]=F):F=t[18];let I;t[19]!==y||t[20]!==w||t[21]!==O||t[22]!==k||t[23]!==A||t[24]!==F?(I=(0,V.jsxs)(v,{layer:`modal`,portalContainer:w,children:[O,k,A,F,y]}),t[19]=y,t[20]=w,t[21]=O,t[22]=k,t[23]=A,t[24]=F,t[25]=I):I=t[25];let L;t[26]!==I||t[27]!==D?(L=(0,V.jsxs)(m,{children:[E,(0,V.jsx)(h,{ref:T,className:D,onOpenAutoFocus:Te,children:I})]}),t[26]=I,t[27]=D,t[28]=L):L=t[28];let z;return t[29]!==i||t[30]!==r||t[31]!==L?(z=(0,V.jsx)(_,{open:r,onOpenChange:i,children:L}),t[29]=i,t[30]=r,t[31]=L,t[32]=z):z=t[32],z}function Te(e){return e.preventDefault()}var Ee=(0,H.memo)(function(e){let t=(0,B.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,V.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,V.jsx)(ie,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,V.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function De(e){let t=(0,B.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0||c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,V.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,V.jsx)(R,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,V.jsx)(R,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,V.jsx)(R,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,V.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-overlay px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function Oe(e){return o(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function ke(e){return(await l(Oe(e))).payload?.channels??[]}function Ae(e,t){let n=(0,B.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Oe(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>ke(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=I(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var je=`channels-status`;function Me(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Ne(e){let t=t=>e(t.detail);return window.addEventListener(je,t),()=>window.removeEventListener(je,t)}function Pe(e,t){let n=(0,B.c)(4),r=t===void 0||t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Ne(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,H.useEffect)(i,a)}function Fe(e){return e?o(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Ie(e){return(await l(o(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Le=[`enabled`],Re=`max-w-7xl`,ze=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Be(){let e=await l(o(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Ve(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function He(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Ue(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function We(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ge(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ke(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=new Set([`dmPolicy`,`groupPolicy`,`allowFrom`,`groupAllowFrom`]),a=[...Object.keys(t).filter(e=>!e.includes(`*`)&&i.has(e.split(`.`).at(-1)??``)),...Object.keys(Z(e.configSchema?.properties)?e.configSchema.properties:{}).filter(e=>i.has(e))],o=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Le.includes(e));return Array.from(new Set([...o,...a,...n,...r])).filter(e=>!Le.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qe(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Je(e,t){let n={...qe(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...qe(r[n]),properties:{}}),e===t.length-1){o[n]=qe(r[n]);break}i=r[n],a=o[n]}}return n}function Ye(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ye(n)&&delete t[e];return Object.keys(t).length===0}function Xe(e,t){let n=qe(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return Ye(n),n}function Ze(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Q(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function Qe(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function $e(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function et(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push($(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=$e(e,Q(t,e),n);i&&r.push(i)}let a=Qe(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function tt(e,t){let n=X(e),r=ge(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function nt(e,t){let n=ge(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function rt(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function $(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function it({entry:e}){let[t,n]=(0,H.useState)(!1),r=(0,H.useMemo)(()=>!e.ui?.icon||t?null:new URL(o(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Ve(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,V.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,V.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,V.jsx)(w,{sourceChannel:e.id,className:`size-7`})})}function at(e){let t=(0,B.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=P(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=P(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,V.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,V.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function ot(e){let t=(0,B.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:l,onRestart:u}=e,d;t[0]===n?d=t[1]:(d=X(n),t[0]=n,t[1]=d);let f=d,p,m,h,g,_,v,y;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==u||t[8]!==l||t[9]!==i||t[10]!==f.enabled||t[11]!==f.ready){let e=et(n,r,s),o=rt(n,s);p=!f.enabled&&f.ready?l:i===`stopped`?u:c,v=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let d;t[19]===n?d=t[20]:(d=(0,V.jsx)(it,{entry:n}),t[19]=n,t[20]=d);let b;t[21]===n.label?b=t[22]:(b=(0,V.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=b);let x;t[23]===i?x=t[24]:(x=P(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ge(i)),t[23]=i,t[24]=x);let S;t[25]!==s||t[26]!==i?(S=Ue(i,s),t[25]=s,t[26]=i,t[27]=S):S=t[27];let C;t[28]!==x||t[29]!==S?(C=(0,V.jsx)(`span`,{className:x,children:S}),t[28]=x,t[29]=S,t[30]=C):C=t[30];let w;t[31]!==C||t[32]!==b?(w=(0,V.jsxs)(`div`,{className:`min-w-0`,children:[b,C]}),t[31]=C,t[32]=b,t[33]=w):w=t[33];let T;t[34]!==w||t[35]!==d?(T=(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[d,w]}),t[34]=w,t[35]=d,t[36]=T):T=t[36];let E=f.enabled,D;t[37]!==s.toggleChannel||t[38]!==n.label?(D=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=D):D=t[39];let O;t[40]!==a||t[41]!==l||t[42]!==f.enabled||t[43]!==D?(O=(0,V.jsx)(at,{checked:E,disabled:a,label:D,onToggle:l}),t[40]=a,t[41]=l,t[42]=f.enabled,t[43]=D,t[44]=O):O=t[44],t[45]!==T||t[46]!==O?(y=(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[T,O]}),t[45]=T,t[46]=O,t[47]=y):y=t[47],m=`button`,h=c,g=`mt-5 min-h-[6.25rem] text-left`,_=f.ready?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,V.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(ct)}):null]}):(0,V.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,V.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??nt(n,s)}),o.length>0?(0,V.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(st)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=u,t[8]=l,t[9]=i,t[10]=f.enabled,t[11]=f.ready,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_,t[17]=v,t[18]=y}else p=t[12],m=t[13],h=t[14],g=t[15],_=t[16],v=t[17],y=t[18];let b;t[48]!==m||t[49]!==h||t[50]!==g||t[51]!==_?(b=(0,V.jsx)(`button`,{type:m,onClick:h,className:g,children:_}),t[48]=m,t[49]=h,t[50]=g,t[51]=_,t[52]=b):b=t[52];let x=a||o,S;t[53]!==a||t[54]!==o?(S=a||o?(0,V.jsx)(C,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=S):S=t[55];let w;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(w=o?s.restartingChannel:i===`stopped`?s.restartChannel:tt(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=w):w=t[60];let T;t[61]!==p||t[62]!==S||t[63]!==w||t[64]!==x?(T=(0,V.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,V.jsxs)(R,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:p,disabled:x,children:[S,w]})}),t[61]=p,t[62]=S,t[63]=w,t[64]=x,t[65]=T):T=t[65];let E;return t[66]!==T||t[67]!==v||t[68]!==y||t[69]!==b?(E=(0,V.jsxs)(`article`,{className:v,children:[y,b,T]}),t[66]=T,t[67]=v,t[68]=y,t[69]=b,t[70]=E):E=t[70],E}function st(e){return(0,V.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function ct(e){return(0,V.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function lt(e){let t=(0,B.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:s,onRestart:c,onCheck:l,onManageConnection:u}=e,d=n===`running`?x:n===`stopped`||n===`needs_setup`?b:C,f=n===`running`&&`text-emerald-600 dark:text-emerald-400`,p=n===`stopped`&&`text-red-600 dark:text-red-400`,m=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,h=n===`disabled`&&`text-fg-muted`,g=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,_;t[0]!==f||t[1]!==p||t[2]!==m||t[3]!==h||t[4]!==g?(_=P(`mt-0.5 size-5 shrink-0`,f,p,m,h,g),t[0]=f,t[1]=p,t[2]=m,t[3]=h,t[4]=g,t[5]=_):_=t[5];let v;t[6]!==d||t[7]!==_?(v=(0,V.jsx)(d,{className:_}),t[6]=d,t[7]=_,t[8]=v):v=t[8];let y;t[9]===s.connectionStatus?y=t[10]:(y=(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectionStatus}),t[9]=s.connectionStatus,t[10]=y);let S;t[11]!==s||t[12]!==n?(S=We(n,s),t[11]=s,t[12]=n,t[13]=S):S=t[13];let w;t[14]===S?w=t[15]:(w=(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=w);let T;t[16]!==w||t[17]!==y?(T=(0,V.jsxs)(`div`,{children:[y,w]}),t[16]=w,t[17]=y,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==v?(E=(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[v,T]}),t[19]=T,t[20]=v,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,V.jsx)(C,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let A=i?s.checkingConnection:s.checkConnection,j;t[24]!==l||t[25]!==D||t[26]!==O||t[27]!==A?(j=(0,V.jsxs)(R,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:l,children:[O,A]}),t[24]=l,t[25]=D,t[26]=O,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==s.restartChannel||t[30]!==s.restartingChannel||t[31]!==i||t[32]!==c||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,V.jsxs)(R,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:c,children:[r?(0,V.jsx)(C,{className:`size-4 animate-spin`}):(0,V.jsx)(k,{className:`size-4`}),r?s.restartingChannel:s.restartChannel]}):null,t[29]=s.restartChannel,t[30]=s.restartingChannel,t[31]=i,t[32]=c,t[33]=r,t[34]=n,t[35]=M):M=t[35];let N;t[36]!==o||t[37]!==s.connectionOptions||t[38]!==s.hideConnectionOptions||t[39]!==i||t[40]!==u||t[41]!==r||t[42]!==a?(N=o?(0,V.jsx)(R,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:u,children:a?s.hideConnectionOptions:s.connectionOptions}):null,t[36]=o,t[37]=s.connectionOptions,t[38]=s.hideConnectionOptions,t[39]=i,t[40]=u,t[41]=r,t[42]=a,t[43]=N):N=t[43];let F;t[44]!==j||t[45]!==M||t[46]!==N?(F=(0,V.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=F):F=t[47];let I;return t[48]!==E||t[49]!==F?(I=(0,V.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,F]})}),t[48]=E,t[49]=F,t[50]=I):I=t[50],I}function ut(e){let t=(0,B.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=X(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl bg-amber-50 px-4 py-3 text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,V.jsx)(M,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,V.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,V.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,V.jsx)(`li`,{children:$(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,V.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,V.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,V.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,V.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function dt({channelId:e,onHeaderActionChange:t}){let n=c(e=>e.language),r=u(n),l=s(e=>!!e.conversationId),d=i(),f=D(e),p=Ae(l,n),m=p.entries,{data:h,mutate:g,isValidating:_}=I(l?me():null,he,{revalidateOnFocus:!0}),{data:v,mutate:b}=I(l?`channels-config-map`:null,Be,{revalidateOnFocus:!1}),x=v?.channels??{},C=v?.bindings??[],{data:w}=I(l?`channel-routing-agents`:null,L,{revalidateOnFocus:!1}),T=(0,H.useMemo)(()=>m.find(e=>e.id===f),[f,m]),k=T?He(T):null,{data:j,mutate:M}=I(l&&k?Fe(k):null,()=>Ie(k)),[N,F]=(0,H.useState)(null),[R,z]=(0,H.useState)(!1),[ee,te]=(0,H.useState)(null),[ie,ce]=(0,H.useState)(null),[B,pe]=(0,H.useState)(!1),[_e,U]=(0,H.useState)(null),[W,G]=(0,H.useState)(null),K=N??j??{},q=r.channelsSettings,ye=(0,H.useMemo)(()=>T?.configSchema??{type:`object`,properties:{}},[T?.configSchema]),J=(0,H.useMemo)(()=>Xe(ye,Le),[ye]),Y=(0,H.useMemo)(()=>Ke(T),[T]),Ce=(0,H.useMemo)(()=>T?.id===`telegram`?ft(Je(J,Y)):Je(J,Y),[T?.id,Y,J]),Te=(0,H.useMemo)(()=>Xe(J,Y),[T?.id,Y,J]),Oe=(0,H.useMemo)(()=>Ze(Ce),[Ce]),ke=T?W??be(C,T.id):``,je=(0,H.useMemo)(()=>(w?.items??[]).map(e=>{let t=oe(e,r.agentsSettings);return{value:e.id,label:t===e.id?t:`${t} · ${e.id}`}}),[w?.items,r.agentsSettings]),Ne=w?.items.find(e=>e.id===w.defaultId),Ve=Ne?oe(Ne,r.agentsSettings):w?.defaultId??``,We=(0,H.useMemo)(()=>({secretInputLabels:ne(q),defaultBooleanLabel:q.schemaBooleanDefault,unsupportedArrayType:q.schemaUnsupportedArrayType,arrayAddPlaceholder:q.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>q.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[q]),Z=(0,H.useMemo)(()=>new Map((h??[]).map(e=>[e.name,e])),[h]),qe=h!==void 0,Ye=(0,H.useCallback)(e=>Se(e,Z.get(e.id),qe),[Z,qe]),Q=(0,H.useCallback)(async()=>{await Promise.all([p.mutate(),g()])},[p,g]);Pe((0,H.useCallback)(e=>{let t=Me(e);t&&g(t,!1)},[g]),l);let Qe=(0,H.useMemo)(()=>l?{secondary:(0,V.jsx)(Ee,{ch:q,refreshing:p.isValidating||_,saveOk:!1,onRefresh:()=>void Q()})}:null,[p.isValidating,q,l,_,Q]);(0,H.useLayoutEffect)(()=>(t?.(Qe),()=>t?.(null)),[Qe,t]);let $e=(0,H.useCallback)(e=>{d(E(e)),F(null),G(null),U(null)},[d]),et=(0,H.useCallback)(()=>{d(O),F(null),G(null),U(null)},[d]),tt=(0,H.useCallback)(async e=>{ce(e.id),U(null);try{let t=await a(o(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){U(e instanceof Error?e.message:String(e))}finally{ce(null)}},[Q]);(0,H.useEffect)(()=>{G(null),pe(!1)},[T?.id]);let nt=(0,H.useCallback)(async()=>{if(!T||!N&&W===null)return!1;let e=He(T);z(!0),U(null);try{let t=await a(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({...N?{channels:{[e]:N}}:{},...W===null?{}:{bindings:xe(C,T.id,W)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return N&&await M(N,!1),await b(),await p.mutate(),F(null),G(null),!0}catch(e){return U(e instanceof Error?e.message:String(e)),!1}finally{z(!1)}},[T,W,C,p,N,b,M]),rt=(0,H.useCallback)(async e=>{let t=X(e),n=He(e),r=T?.id===e.id?N:null;if(!t.enabled&&!t.ready&&!r){$e(e.id);return}te(e.id),U(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},s=await a(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error?.message??s.statusText)}await p.mutate(),await b(),await g(),T?.id===e.id&&(await M(),F(null))}catch(e){U(e instanceof Error?e.message:String(e))}finally{te(null)}},[T?.id,p,N,b,M,g,$e]),$=T?.ui?.modal,st=$?.placement!==`replace-config`,ct=T?Ye(T):`checking`,dt=T?!X(T).ready||B:!1;return l?(0,V.jsxs)(ue,{gap:`gap-4`,className:Re,padding:ze,children:[p.isLoading?(0,V.jsx)(se,{sections:2}):p.error?(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(p.error)}):(0,V.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:m.map(e=>(0,V.jsx)(ot,{entry:e,config:x[He(e)]?.config,runtime:Ye(e),busy:ee===e.id,restarting:ie===e.id,ch:q,onOpen:()=>$e(e.id),onToggle:()=>void rt(e),onRestart:()=>void tt(e)},e.id))}),_e?(0,V.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:_e}):null,(0,V.jsx)(we,{presentation:`modal`,open:!!T,onOpenChange:e=>{e||et()},closeAriaLabel:q.close,srTitle:T?.label??q.selectChannel,srDescription:T?.description,wide:!0,footer:T?(0,V.jsx)(De,{ch:q,dirty:!!N||W!==null,saving:R,onCancel:et,onDiscard:()=>{F(null),G(null)},onSave:nt}):null,children:T?(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,V.jsx)(it,{entry:T}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,V.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:T.label}),(0,V.jsx)(`span`,{className:P(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ge(ct)),children:Ue(ct,q)})]}),(0,V.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,V.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(T).ready&&ge(T)?.[1].result===`qr`?q.scanLoginHint.replace(`{{channel}}`,T.label):T.description}),T.docsPath?(0,V.jsxs)(`a`,{href:re(n,T.docsPath),target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[q.docs,(0,V.jsx)(S,{className:`size-3.5`})]}):null]})]})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,V.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(T).enabled?q.enabledLabel:q.disabledLabel}),(0,V.jsx)(at,{checked:X(T).enabled,disabled:ee===T.id,label:q.toggleChannel.replace(`{{channel}}`,T.label),onToggle:()=>void rt(T)})]})]})}),(0,V.jsx)(lt,{runtime:ct,restarting:ie===T.id,checking:_,showConnectionOptions:B,canManageConnection:X(T).ready&&$?.placement!==`replace-config`,ch:q,onRestart:()=>void tt(T),onCheck:()=>void Q(),onManageConnection:()=>pe(e=>!e)}),(0,V.jsx)(ut,{entry:T,ch:q}),T.id===`telegram`?(0,V.jsx)(fe,{language:n}):null,dt&&$?.placement!==`replace-config`?(0,V.jsx)(ve,{entry:T,locale:n,messages:q,compact:!0,onChanged:async()=>{await M(),await Q(),await b()}},T.id):null,$?.entrypoint&&$.placement===`before-config`?(0,V.jsx)(ae,{extensionId:T.extensionId,extensionName:T.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:T.id,entry:T,config:K}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,V.jsx)(ae,{extensionId:T.extensionId,extensionName:T.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:T.id,entry:T,config:K}}):null,st&&Oe?(0,V.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.basicConfiguration}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.basicConfigurationHint})]}),(0,V.jsx)(de,{schema:Ce,values:K,onChange:e=>F(e),disabled:R,labels:We})]}):null,(0,V.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,V.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,V.jsx)(A,{className:`size-4 text-fg-muted`}),q.messageHandling]}),(0,V.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,V.jsxs)(`div`,{className:`mb-3`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.agentRouting}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.messageHandlingHint})]}),(0,V.jsx)(y,{value:ke,options:je,placeholder:q.agentRoutingSelect,emptyLabel:q.agentRoutingDefault.replace(`{{agent}}`,Ve||q.agentRoutingSelect),ariaLabel:q.agentRouting,disabled:R||!w,onChange:e=>G(e)})]})]}),st&&Ze(Te)?(0,V.jsx)(le,{title:q.advancedConfiguration,summary:q.messageHandlingHint,children:(0,V.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,V.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,V.jsx)(A,{className:`size-4 text-fg-muted`}),q.advancedConfiguration]}),(0,V.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,V.jsx)(de,{schema:Te,values:K,onChange:e=>F(e),disabled:R,labels:We})})]})}):null,_e?(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:_e}):null]}):null})]}):(0,V.jsx)(ue,{gap:`gap-3`,className:Re,padding:ze,children:(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:q.tokenRequired})})}function ft(e){let t=e.properties;if(!t)return e;let n=[`botToken`,`dmPolicy`,`allowFrom`,`groupPolicy`,`groupAllowFrom`];return{...e,properties:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...ft(t),...n.includes(e)?{"x-order":n.indexOf(e)}:{}}]))}}export{dt as ChannelsSettingsPanel};
|
package/dist/gateway/static/root/assets/{chat-agents-api-BRQDNNI5.js → chat-agents-api-UOdNWZ0_.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t}from"./locale-store-
|
|
1
|
+
import{a as e,i as t}from"./locale-store-cg9cm2EL.js";import{t as n}from"./gateway-config-swr-OGhON-s6.js";var r=null;async function i(){return r||(r=a().finally(()=>{r=null}),r)}async function a(){let r=await e(t(`/api/agents`));if(r.ok){let e=await r.json();if(e.ok&&e.payload?.defaultId&&Array.isArray(e.payload.agents)){let t=e.payload.defaultId.trim().toLowerCase(),n=e.payload.agents.filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{},skills:(e.effective?.skills?.mode===`selected`?e.effective.skills.include??[]:[]).filter(e=>typeof e==`string`&&!!e.trim())}));if(n.length>0)return{defaultId:t,items:n}}}let i=(await n()).payload?.config?.agents,a=(i?.defaultId??`main`).trim().toLowerCase(),o=(Array.isArray(i?.list)?i.list:[]).filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase()}));return o.length===0?{defaultId:a,items:[{id:a}]}:{defaultId:a,items:o}}export{i as t};
|