@xopcai/xopc 0.0.456 → 0.0.457
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/browser-ext/dist/sidepanel.js +5 -1
- 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-DYwR1u3f.js → activity-store-CQHh48Zf.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CsRBprL-.js → agent-avatar-dicebear-CAz-Ke6Q.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-display-DqFYHXCS.js → agent-avatar-display-loBdGw_i.js} +2 -2
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-DOAJrMLe.js → agent-defaults-settings-panel-By2Q-6JS.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-vqlN3ORH.js → agent-plugin-dialog-CikzCYAG.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-BgHlOVRV.js → agents-CGUdvmIT.js} +3 -3
- package/dist/gateway/static/root/assets/{agents-admin-api-CKscfdvA.js → agents-admin-api-D0N09mqJ.js} +1 -1
- package/dist/gateway/static/root/assets/{api-CHM2c_Ah.js → api-B1J5ajiP.js} +1 -1
- package/dist/gateway/static/root/assets/{api-DPNeNCmR.js → api-B4FJ51EC.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Bhz6bj1C.js → app-management-settings-panel-BHlUDZOG.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BX32aogA.js → appearance-settings-Du5JLyV1.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-0Yo3jBsQ.js → apps-page-M2XD1Pzu.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-Bha8obMe.js → archive-plugin-BAvglLfu.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-api-mn8ihWJ_.js → automation-api-DxBmyzp0.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-result-state-COzakzak.js → automation-result-state-CAsqgMNR.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-run-list-BhtaMpTb.js → automation-run-list-BmYeWB_N.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-task-card-BY_k6iWp.js → automation-task-card-BjqxvYqc.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CgQDpSpK.js → automations-page-BSnPWyYd.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-DIaCdxtX.js +9 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DUbrJFLU.js → binary-plugins-D2bFqG6K.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DW--pXAc.js → block-editor-CmnkluMF.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-CDh6nxs9.js → browser-settings-page-CGcgZOWh.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-DB713nRi.js +1 -0
- package/dist/gateway/static/root/assets/{capabilities-DKbXv8Ck.js → capabilities-DDqDvCBs.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-D1wQ2sPI.js → capabilities-page-dXDa0i5o.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-BW5jQz5R.js → capabilities-settings-panel-CvF8VRTv.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-BzZp42yO.js → channels-BDVQ6Z7A.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-agents-api-UOdNWZ0_.js → chat-agents-api-CjlzCSmC.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-chart-block-NSy-B0NS.js → chat-chart-block-stPJEZ90.js} +1 -1
- package/dist/gateway/static/root/assets/chat-page-Bx_A__qB.js +71 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CAaHWS7F.js → chat-terminal-dock-B4uA_W6R.js} +1 -1
- package/dist/gateway/static/root/assets/{command-palette-api-Dkn9bbYd.js → command-palette-api-CP0F6sIm.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-model-config-control-BrK8-SNz.js → composer-model-config-control-DAagrRx_.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-notifications-B-kL3qAA.js → composer-notifications-CqV6Xj-H.js} +1 -1
- package/dist/gateway/static/root/assets/composer-payload-handoff-Dc43dgSg.js +1 -0
- package/dist/gateway/static/root/assets/{computer-settings-page-C9KdEecx.js → computer-settings-page-f-vcEpeF.js} +1 -1
- package/dist/gateway/static/root/assets/{connected-providers-grid-D_8v6Qex.js → connected-providers-grid-CZ-FXxaW.js} +1 -1
- package/dist/gateway/static/root/assets/{connection-usage-guide-CiVpcbds.js → connection-usage-guide-Cibh2lrV.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-B919cKSm.js → connector-service-page-Btz68iy8.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-CgsSm-Av.js → connectors-api-CTuVWwBf.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-CEpfDCLA.js → connectors-page-BwJHhyRb.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-dx284jQI.js → date-picker-XnE3iFhG.js} +1 -1
- package/dist/gateway/static/root/assets/{date-time-picker-Dj-bhLNP.js → date-time-picker-VGKm0HVn.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Cn1TfGz4.js → desktop-pet-CBm3DySQ.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CsmrvoxU.js → desktop-pet-settings-6O77QXGo.js} +1 -1
- package/dist/gateway/static/root/assets/{dev-view-store-BOxbj1ie.js → dev-view-store-B8fGILny.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-CAqFIFRC.js → device-pairing-wizard-qtUvtdDT.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BxEw5OrT.js → directory-picker-path-field-ByDqf5fE.js} +1 -1
- package/dist/gateway/static/root/assets/{discussion-annotation-sync-CyntTwIa.js → discussion-annotation-sync-fwPPMPv9.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-authoritative-grants-C0ReZguU.js → extension-authoritative-grants-BfL8dMBf.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-Cd3HMUbi.js → extension-debug-page-BPwRrP3L.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-DiIqM2JO.js → extension-iframe-host-DIH4TcdH.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-marketplace-api-CK5CMKTs.js → extension-marketplace-api-BIzkukYp.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-message-router-Dn8JzOdR.js → extension-message-router-C9JDpo_7.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CLZtAtqm.js → extension-page-CLDoL5N8.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-CbVokTvd.js → extension-provider-BPIoHw4r.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BM79cwUy.js → extension-settings-page-BO_UKeG8.js} +1 -1
- package/dist/gateway/static/root/assets/file-preview-surface-i5UOFnQF.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-OGhON-s6.js → gateway-config-swr-1Rk0LeEM.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-B9u4uSXW.js → gateway-realtime-DIs1pjkQ.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-sx7B8kdC.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-restart-DKAweWmg.js → gateway-restart-DTmlcJps.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-Dc7qUbG-.js → gateway-settings-ClcCloqQ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BaaoKBoB.js → gateway-startup-retry-D6WPS0RW.js} +1 -1
- package/dist/gateway/static/root/assets/{global-defaults-api-BIr3ApRj.js → global-defaults-api-BpDMnJe7.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-D1sTZYAY.js +3 -0
- package/dist/gateway/static/root/assets/{image-generation-api-C7D2IetZ.js → image-generation-api-sbtx4NiC.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-BjEdZJxZ.js → imports-page-CBlaxUhl.js} +1 -1
- package/dist/gateway/static/root/assets/index-CHAVhyVb.js +11 -0
- package/dist/gateway/static/root/assets/index-CQABygtM.css +1 -0
- package/dist/gateway/static/root/assets/{install-connector-dialog-BsiyYQhx.js → install-connector-dialog-DxSv1wS2.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CIthQ1lp.js → keyboard-shortcuts-settings-CnAV96nr.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CSCIHvZV.js → local-app-workbench-page-D8oqDDAn.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-EntiM0tz.js → local-apps-page-BI3Be5qo.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-XurtjR58.js → local-session-drafts-BIBHRkpM.js} +2 -2
- package/dist/gateway/static/root/assets/{locale-store-cg9cm2EL.js → locale-store-Dy1EByeG.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-rmS9VSem.js → logs-page-CMW34T31.js} +1 -1
- package/dist/gateway/static/root/assets/{management-api-B6jVuJ6W.js → management-api-B5w5DdXH.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-DdI9gs51.js → management-settings-DfcMIqbQ.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-D1zBWkfB.js → markdown-view-BlxIaCCQ.js} +1 -1
- package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-Bn49Ph1n.js → mcp-conversation-setup-page-CsTSmjmX.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Cd6hAGDp.js → media-plugins-DGhWjPIU.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BAnhwALN.js +3 -0
- package/dist/gateway/static/root/assets/{model-selector-CL6WT-jw.js → model-selector-C-CqPBao.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-cache-s0FMNhq9.js → models-hub-cache-Bgh3Gfgl.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-C6s0WlNL.js → note-detail-panel-B1cq9sU2.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-CqK_uJ6Y.js +1 -0
- package/dist/gateway/static/root/assets/{notes-api-CR75RHd0.js → notes-api-CdXA-g9r.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-CR7dNVDi.js → notes-page-Do0l5Ddr.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-api-CvPnQTlH.js → oauth-api-B560CHeD.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-provider-connect-Dk1NeeqD.js → oauth-provider-connect-D63M8Iv7.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-BPtX67hZ.js → page-context-capture-button-Dibmspef.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-draft-Ckb8baxj.js → page-context-draft-Cr5GqS2D.js} +1 -1
- package/dist/gateway/static/root/assets/page-header-store-Bm8oxpFR.js +1 -0
- package/dist/gateway/static/root/assets/{personal-avatar-CZSnrSfc.js → personal-avatar-BMRVyTrE.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-C89kLOIL.js → personal-page-DrYh0NPE.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-profile-settings-DJRDcK2c.js → personal-profile-settings-HMQY9lz9.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-C6p25Noq.js → personal-settings-panel-BppxtWBl.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-dependencies-card-DKkFFpqi.js → phone-dependencies-card-flTci8mm.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-connection-CRRHq4PQ.js → phone-model-connection-Vi_Swyv6.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-picker-CN_I0-46.js → phone-model-picker-BOv3mb_F.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-settings-page-CkdSOA7D.js → phone-settings-page-vD0bTcHj.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-workspace-store-CC61pIuJ.js → phone-workspace-store-Ltrevdsx.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-Bqz4jT53.js → plugin-details-dialog-nSDw8sfo.js} +1 -1
- package/dist/gateway/static/root/assets/{preference-select-fields-DHeNbAvn.js → preference-select-fields-D1pZekPs.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-BN2HTA9T.js → product-automation-feedback-D51I7Lg3.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-B-j4gpLD.js → product-open-page-BO8lUvw3.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-EqrTk7kU.js → product-preview-content-CUaHxyiE.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-modal-aurFBFq4.js → product-preview-modal-BUeyRD5W.js} +2 -2
- package/dist/gateway/static/root/assets/{project-detail-page-sHcdluTm.js → project-detail-page-D3k1NzXQ.js} +2 -2
- package/dist/gateway/static/root/assets/{project-understanding-HNK9lFVy.js → project-understanding-Cg8WbBNB.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-CugSyKl5.js → projects-page-C6Pt6OdT.js} +1 -1
- package/dist/gateway/static/root/assets/{providers-api-DUntOOqr.js → providers-api-Nytkkop9.js} +1 -1
- package/dist/gateway/static/root/assets/{recording-upload-DIwP541B.js → recording-upload-CyZSl2DJ.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-BTd_OgbD.js → registry-api-DuDIthjL.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-f5mIfsBF.js → remote-access-hub-DePwafOK.js} +1 -1
- package/dist/gateway/static/root/assets/{resource-unavailable-DtQ2rfu_.js → resource-unavailable-BRKhKJA0.js} +1 -1
- package/dist/gateway/static/root/assets/right-workspace-store-HPw7Gw0n.js +1 -0
- package/dist/gateway/static/root/assets/route-preload-CTuS4GFj.js +2 -0
- package/dist/gateway/static/root/assets/routine-panel-9UC3NU5V.js +2 -0
- package/dist/gateway/static/root/assets/{runtime-tools-api-C1iI8EPo.js → runtime-tools-api-Dd8a07eo.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-0tdI1z0g.js → runtime-tools-settings-panel-CvHQoqHu.js} +1 -1
- package/dist/gateway/static/root/assets/{service-recommendation-list-DSIe-NRe.js → service-recommendation-list-8mVIWB38.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-CQlEq0MB.js → session-api-BFiIYodK.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-C7RfUfqI.js → session-manager-D2LaQymu.js} +2 -2
- package/dist/gateway/static/root/assets/{sessions-page-DdS8U0RV.js → sessions-page-DQEq_VJS.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-Cvx7DnU8.js +1 -0
- package/dist/gateway/static/root/assets/{settings-advanced-section-C6dPu5i1.js → settings-advanced-section-B-H1gYOs.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-mode-store-BSiiowQa.js → settings-mode-store-YH60sibB.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-C4CYw21O.js → settings-page-CGiZCF8z.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-header-BSMu5Zq3.js → settings-page-header-DEZZ8D0S.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-B_vMffB1.js → settings-page-layout-De2j64Lo.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-interaction-page-DKXfFdNt.js → setup-interaction-page-Dh6BPwv0.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BbAZ9w77.js → setup-status-panel-DGAAczL-.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-ztX1WPXG.js → share-link-dialog-C1t_HB6f.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-Ds2Ydfg6.js → share-preview-page-fV5USZb1.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-CSZqeNL4.js → shares-api-Dm07CnXw.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-CX3TNAmI.js → shares-settings-sl40lqND.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-CGzAQ-MX.js → skill-api-BV8oFqeE.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-list-api-DfUsku-x.js → skill-list-api-1o_YRCu9.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-Y9qSMnBd.js → skill-reload-api-fGsO9Y86.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-DnMN50Ot.js → skills-page-FTd0Z7Ey.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DWNkQmme.js → system-settings-panel-CUI6QHEP.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DBnkT1Nj.js → task-detail-page-CWwwumsy.js} +3 -3
- package/dist/gateway/static/root/assets/task-result-evidence-CSJeB9AH.js +1 -0
- package/dist/gateway/static/root/assets/{terminal-panel-store-D8eZPvql.js → terminal-panel-store-Du53Upr2.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-GZQ3pTgy.js → theme-store-BaWep_o7.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-DM3-7Hlw.js → tracing-settings-page-CnciBMVH.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-DOGAIXRR.js → tunnel-api-Iz7JCBt3.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-activity-store-CuPfe0eQ.js → understanding-activity-store-BFc8PamJ.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-refresh-store-CIpGYSl0.js → understanding-refresh-store-CdEfR40A.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-BA9Yrvqu.js → usage-page-DL2fmeOh.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-CO0IPCVg.js → use-autosave-N_SjHXTw.js} +1 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-CO7XLI4x.js +2 -0
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-dhNMHf5b.js → use-file-preview-expanded-BXXeXnT0.js} +3 -3
- package/dist/gateway/static/root/assets/{use-personal-profile-CVqDWBDS.js → use-personal-profile-C1vqD9yV.js} +1 -1
- package/dist/gateway/static/root/assets/{use-realtime-voice-DDVVlX1R.js → use-realtime-voice-C7iWQuUv.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-CZej8mhf.js → use-workspace-tree-D27u-eoX.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-Bbi2MpIS.js → user-model-page-D2FHjLi7.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DpwUDAvu.js → voice-api-key-field-B_GApUQP.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-GIuXoHXw.js → voice-config-api-DhJ3l8fk.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-input-shortcut-events-Cc30ZcFy.js → voice-input-shortcut-events-CEeFBhp3.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-settings-DA3m5MT0.js → voice-settings-BiqJ0tlf.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-yGUkk1NV.js → work-discovery-overlay-BNZK4hQ4.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-RN6iuY-0.js → work-discovery-page-KwSPhukU.js} +1 -1
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-CeXl9w6z.js → working-directory-picker-modal-BGZduAXV.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-B1Uirhxf.js → workspace-api-LghfbP5g.js} +2 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-DVPJcbuE.js +1 -0
- package/dist/gateway/static/root/assets/workspace-file-preview-dialog-NffP-UXC.js +1 -0
- package/dist/gateway/static/root/assets/{workspace-open-location-menu-DWGNOIE2.js → workspace-open-location-menu-CvZxU9de.js} +1 -1
- package/dist/gateway/static/root/assets/workspace-preview-store-Do31QQH5.js +1 -0
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-x-XT4bKF.js → xopc-cloud-account-card-Q_jezTUy.js} +1 -1
- package/dist/gateway/static/root/index.html +90 -88
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/automations.js +6 -0
- package/dist/packages/gateway-contract/src/capabilities.js +1 -1
- package/dist/packages/gateway-contract/src/home.js +3 -0
- package/dist/packages/gateway-contract/src/index.js +3 -1
- package/dist/packages/gateway-contract/src/observation.js +177 -0
- package/dist/packages/gateway-contract/src/session-input-command.js +5 -1
- package/dist/src/agent/agent-manager.js +1 -1
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/client-error-format.js +1 -1
- package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -0
- package/dist/src/agent/embedded/execution-tool-policy.js +31 -5
- package/dist/src/agent/embedded/run-for-session.js +16 -8
- package/dist/src/agent/embedded/run-turn.js +65 -29
- package/dist/src/agent/embedded/types.d.ts +2 -0
- package/dist/src/agent/external-tools/cliProvider.js +2 -2
- package/dist/src/agent/external-tools/composio-provider.js +2 -2
- package/dist/src/agent/external-tools/endpoint-provider.js +3 -3
- package/dist/src/agent/fallback/reason.js +1 -1
- package/dist/src/agent/orchestration/llm-turn-retry.d.ts +5 -0
- package/dist/src/agent/orchestration/llm-turn-retry.js +17 -6
- package/dist/src/agent/service.js +1 -1
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/tools/personal-memory-tool.js +1 -1
- package/dist/src/agent/tools/personal-read-tool.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/agent-catalog/repository.js +1 -1
- package/dist/src/automations/api/routes.js +2 -2
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/capabilities/write.d.ts +10 -0
- package/dist/src/automations/capabilities/write.js +1 -1
- package/dist/src/automations/configuration-conversation.js +1 -1
- package/dist/src/automations/domain/types.d.ts +14 -0
- package/dist/src/automations/domain/validation.d.ts +20 -0
- package/dist/src/automations/domain/validation.js +6 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +5 -0
- package/dist/src/automations/draft/automation-draft-validator.js +1 -0
- package/dist/src/automations/index.js +2 -2
- package/dist/src/automations/service/action-executor.d.ts +2 -0
- package/dist/src/automations/service/action-executor.js +18 -2
- package/dist/src/automations/service/index.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/computer/endpoint-transport.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/execution-environments/local-worktree-manager.js +1 -1
- package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/global-defaults-admin.js +1 -1
- package/dist/src/gateway/hono/routes/agents.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/home.js +100 -2
- package/dist/src/gateway/hono/routes/local-app-run-streams.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/phone-setup.js +1 -1
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +2 -2
- package/dist/src/gateway/image-generation-setup.js +1 -1
- package/dist/src/gateway/security/gateway-scopes.js +1 -0
- package/dist/src/gateway/service.js +21 -4
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/application-service.d.ts +1 -0
- package/dist/src/home-intelligence/application-service.js +1 -1
- package/dist/src/home-intelligence/generator.js +4 -0
- package/dist/src/home-intelligence/host.d.ts +157 -1
- package/dist/src/home-intelligence/host.js +198 -14
- package/dist/src/home-intelligence/observation.d.ts +41 -0
- package/dist/src/home-intelligence/observation.js +297 -0
- package/dist/src/home-intelligence/repository.d.ts +1 -1
- package/dist/src/home-intelligence/routines.d.ts +36 -0
- package/dist/src/home-intelligence/routines.js +444 -0
- package/dist/src/home-intelligence/snapshot.d.ts +14 -0
- package/dist/src/imports/importService.js +1 -1
- package/dist/src/local-apps/automation-proposals.d.ts +20 -0
- package/dist/src/local-apps/automation-proposals.js +1 -1
- package/dist/src/local-apps/capabilities/automation-policy.js +1 -1
- package/dist/src/local-apps/capabilities/delegate.js +3 -3
- package/dist/src/local-apps/p1-services.js +1 -1
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/personal-agent/proactivity/repository.d.ts +1 -1
- package/dist/src/personal-agent/service.js +1 -1
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/providers/model-response.js +1 -1
- package/dist/src/realtime/compact-run-event.js +9 -0
- package/dist/src/runtime-tools/archive.js +1 -1
- package/dist/src/storage/sqlite/schema.d.ts +2 -2
- package/dist/src/storage/sqlite/schema.js +7 -7
- package/dist/src/storage/sqlite/schema.sql +71 -0
- package/dist/src/storage/sqlite/session-input-control-repository.js +2 -0
- package/dist/src/storage/sqlite/upgrades/272_home_observation.sql +41 -0
- package/dist/src/storage/sqlite/upgrades/273_observation_routines.sql +30 -0
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/capabilities/write.js +1 -1
- package/dist/src/tasks/home-query-service.js +1 -0
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-CWEDraTP.js +0 -9
- package/dist/gateway/static/root/assets/capabilities-kG175Q-7.js +0 -1
- package/dist/gateway/static/root/assets/chat-page-BjYumhaI.js +0 -71
- package/dist/gateway/static/root/assets/composer-payload-handoff-DBE1mvOS.js +0 -1
- package/dist/gateway/static/root/assets/file-preview-surface-z7_HV0WN.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-xB7Bq4Zs.js +0 -1
- package/dist/gateway/static/root/assets/home-page-i_PIrDCU.js +0 -3
- package/dist/gateway/static/root/assets/index-DBlVVXOA.js +0 -11
- package/dist/gateway/static/root/assets/index-DpkEeFEQ.css +0 -1
- package/dist/gateway/static/root/assets/messages-eQ2CYlpG.js +0 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-DfK2KSgu.js +0 -1
- package/dist/gateway/static/root/assets/page-header-store-DU4NnGap.js +0 -1
- package/dist/gateway/static/root/assets/route-preload-DrfQJkmW.js +0 -2
- package/dist/gateway/static/root/assets/settings-advanced-gate-DnfH22f_.js +0 -1
- package/dist/gateway/static/root/assets/task-input-card-lCMSy6YY.js +0 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-CLIrD0mm.js +0 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-Nos5ebMv.js +0 -1
- package/dist/gateway/static/root/assets/workspace-file-preview-dialog-D0h2yJ3v.js +0 -1
|
@@ -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-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};
|
|
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-Dy1EByeG.js";import{t as u}from"./messages-BAnhwALN.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-CjlzCSmC.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-DIH4TcdH.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-B-H1gYOs.js";import{n as ue}from"./settings-page-header-DEZZ8D0S.js";import"./settings-page-layout-De2j64Lo.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-UOdNWZ0_.js → chat-agents-api-CjlzCSmC.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-Dy1EByeG.js";import{t as n}from"./gateway-config-swr-1Rk0LeEM.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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid-render-oOellPHt.js","assets/rolldown-runtime-aKtaBQYM.js","assets/highlight-code-BH65IIbJ.js","assets/xml-_d7dTN2Q.js","assets/echarts-runtime-QSmTlXOu.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{n as a}from"./locale-store-cg9cm2EL.js";import{t as o}from"./messages-eQ2CYlpG.js";import{a as s,i as c,n as l,o as u,r as d,s as f,t as p}from"./dist-CY7CS_D3.js";import{t as m}from"./check-DUBLcKHA.js";import{t as h}from"./copy-Dv6d4Dvw.js";import{t as g}from"./download-Dk-ZjtO6.js";import{K as _,U as v,W as y,a as b,i as x,o as S,s as C}from"./markdown-view-D1zBWkfB.js";import{t as w}from"./x-B_N4OPjy.js";import{t as T}from"./skeleton-DzdOeGYz.js";import{t as E}from"./copy-to-clipboard-HOJ79TWv.js";var D=n(),O=e(t(),1),k=r(),A=2,j=(0,O.createContext)(null);function M(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function N(e){let t=(0,D.c)(14),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=(0,O.useRef)(r),a=(0,O.useRef)(0),o=(0,O.useRef)(null),s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,t[1]=s):s=t[1];let[c,l]=(0,O.useState)(s),u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=new Set,t[2]=u):u=t[2];let[d,f]=(0,O.useState)(u),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{if(document.visibilityState===`hidden`){l(R);return}let e=[...i.current.entries()].filter(L).sort(I),t=new Set(e.slice(0,A).map(F)),n=new Set(e.map(P));l(e=>M(e,t)?e:t),f(e=>M(e,n)?e:n)},t[3]=p):p=t[3];let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{let n=i.current.get(e);if(n&&o.current?.unobserve(n.element),!t){i.current.delete(e),m();return}i.current.set(e,{element:t,near:!1,visible:!1,manualPriority:n?.manualPriority??0,distance:1/0}),o.current?.observe(t)},t[4]=h):h=t[4];let g=h,_;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{let t=i.current.get(e);t&&(a.current+=1,t.manualPriority=a.current,t.near=!0,t.visible=!0,t.distance=0,m())},t[5]=_):_=t[5];let v=_,y,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{if(typeof IntersectionObserver>`u`)return;o.current=new IntersectionObserver(e=>{for(let t of e){let e=[...i.current.values()].find(e=>e.element===t.target);if(!e)continue;let n=t.boundingClientRect;e.near=t.isIntersecting,e.visible=t.isIntersecting&&n.bottom>0&&n.top<window.innerHeight,e.distance=Math.abs((n.top+n.bottom)/2-window.innerHeight/2),e.near||(e.manualPriority=0)}m()},{rootMargin:`480px 0px`,threshold:0});for(let e of i.current.values())o.current.observe(e.element);let e=()=>m();return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),o.current?.disconnect(),o.current=null}},b=[m],t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,O.useEffect)(y,b);let x;t[8]!==c||t[9]!==d?(x={activeIds:c,nearIds:d,register:g,activate:v},t[8]=c,t[9]=d,t[10]=x):x=t[10];let S=x,C;return t[11]!==n||t[12]!==S?(C=(0,k.jsx)(j.Provider,{value:S,children:n}),t[11]=n,t[12]=S,t[13]=C):C=t[13],C}function P(e){let[t]=e;return t}function F(e){let[t]=e;return t}function I(e,t){let[,n]=e,[,r]=t;return r.manualPriority-n.manualPriority||Number(r.visible)-Number(n.visible)||n.distance-r.distance}function L(e){let[,t]=e;return t.near||t.manualPriority>0}function R(e){return e.size?new Set:e}function z(e){let t=(0,D.c)(16),n=(0,O.useContext)(j),r=n?.register,i=n?.activate,a;t[0]!==e||t[1]!==r?(a=t=>r?.(e,t),t[0]=e,t[1]=r,t[2]=a):a=t[2];let o=a;if(!n){let e;return t[3]===o?e=t[4]:(e={active:!0,state:`active`,containerRef:o,activate:B},t[3]=o,t[4]=e),e}let s;t[5]!==e||t[6]!==n.activeIds?(s=n.activeIds.has(e),t[5]=e,t[6]=n.activeIds,t[7]=s):s=t[7];let c=s,l=c?`active`:n.nearIds.has(e)?`queued`:`dormant`,u;t[8]!==e||t[9]!==i?(u=()=>i?.(e),t[8]=e,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==o||t[13]!==l||t[14]!==u?(d={active:c,state:l,containerRef:o,activate:u},t[11]=c,t[12]=o,t[13]=l,t[14]=u,t[15]=d):d=t[15],d}function B(){}var V=new class{maxBytes;maxEntries;entries=new Map;bytes=0;constructor(e=8*1024*1024,t=256){this.maxBytes=e,this.maxEntries=t}get(e){let t=this.entries.get(e);if(t)return this.entries.delete(e),this.entries.set(e,t),t.value}set(e,t){let n=this.entries.get(e);n&&(this.bytes-=n.bytes),this.entries.delete(e);let r=(e.length+t.length)*2;if(!(r>this.maxBytes))for(this.entries.set(e,{value:t,bytes:r}),this.bytes+=r;this.bytes>this.maxBytes||this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.bytes-=this.entries.get(e).bytes,this.entries.delete(e)}}get sizeBytes(){return this.bytes}},H=(0,O.memo)(function({code:e,language:t,incomplete:n,renderMermaid:r,actions:s,copy:c}){let l=z((0,O.useId)()),u=(0,O.useRef)(null),[d,f]=(0,O.useState)(null),[p,w]=(0,O.useState)(null),[T,D]=(0,O.useState)(!1),[A,j]=(0,O.useState)(!1),[M,N]=(0,O.useState)(0),P=(0,O.useRef)(null),F=(0,O.useRef)(!1),I=(0,O.useRef)(e),L=o(a(e=>e.language)).chat,R=(t===`mermaid`||!t&&b(e))&&r&&!n,B=`${R?`mermaid`:`code`}:${t}:${e}`;(0,O.useEffect)(()=>{if(n||!l.active||new TextEncoder().encode(e).byteLength>100*1024)return;let r=!0;j(!1);let a=V.get(B);return(a===void 0?R?i(async()=>{let{renderMermaidSvg:e}=await import(`./mermaid-render-oOellPHt.js`).then(e=>e.t);return{renderMermaidSvg:e}},__vite__mapDeps([0,1])).then(({renderMermaidSvg:t})=>v(t(e))):i(async()=>{let{highlightCode:e}=await import(`./highlight-code-BH65IIbJ.js`);return{highlightCode:e}},__vite__mapDeps([2,3,1])).then(({highlightCode:n})=>y.sanitize(n(e,t),{ALLOWED_TAGS:[`span`],ALLOWED_ATTR:[`class`]})):Promise.resolve(a)).then(e=>{r&&(V.set(B,e),f({key:B,value:e}))}).catch(()=>{r&&j(!0)}),()=>{r=!1}},[B,e,R,n,t,l.active,M]),(0,O.useLayoutEffect)(()=>{I.current=e},[e]),(0,O.useEffect)(()=>(F.current=!0,()=>{F.current=!1,P.current&&clearTimeout(P.current)}),[]);let H=()=>{let e=u.current,t=e?.querySelector(`svg`);return e&&t?S(t,e):null},U=d?.key===B?d.value:null,W=R&&!!U&&!A,G={title:L.mermaidPreviewTitle,close:L.mermaidPreviewClose,zoomIn:L.mermaidZoomIn,zoomOut:L.mermaidZoomOut,fit:L.mermaidFit,downloadPng:L.mermaidDownloadPng,downloadSvg:L.mermaidDownloadSvg,downloadFailed:L.mermaidDownloadFailed};return(0,k.jsxs)(`div`,{ref:l.containerRef,className:W?`markdown-mermaid markdown-mermaid-interactive`:`markdown-code-block`,"data-mermaid-diagram":W?``:void 0,children:[W?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{ref:u,dangerouslySetInnerHTML:{__html:U}}),s&&(0,k.jsxs)(`div`,{className:`markdown-mermaid-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`markdown-mermaid-action-button`,title:L.mermaidPreview,"aria-label":L.mermaidPreview,onClick:()=>{let e=H();e&&w({snapshot:e,baseName:`diagram`})},children:(0,k.jsx)(_,{className:`size-4`,"aria-hidden":!0})}),(0,k.jsx)(`button`,{type:`button`,className:`markdown-mermaid-action-button`,title:L.mermaidDownloadPng,"aria-label":L.mermaidDownloadPng,onClick:()=>{let e=H();e&&C(e,`diagram.png`).catch(()=>{F.current&&j(!0)})},children:(0,k.jsx)(g,{className:`size-4`,"aria-hidden":!0})})]})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`markdown-code-block-header`,children:[(0,k.jsx)(`span`,{className:`markdown-code-block-lang`,children:t||`text`}),R&&(0,k.jsx)(`button`,{type:`button`,className:`markdown-code-copy-btn`,title:L.mermaidPreview,"aria-label":L.mermaidPreview,onClick:()=>{l.activate(),N(e=>e+1)},children:(0,k.jsx)(_,{})}),c&&(0,k.jsx)(`button`,{type:`button`,className:`markdown-code-copy-btn`,title:T?L.messageCopied:L.codeBlockCopy,"aria-label":T?L.messageCopied:L.codeBlockCopy,onClick:()=>{E(e).then(t=>{!t||!F.current||I.current!==e||(D(!0),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>D(!1),2e3))})},children:T?(0,k.jsx)(m,{"aria-hidden":`true`}):(0,k.jsx)(h,{"aria-hidden":`true`})})]}),(0,k.jsx)(`pre`,{children:(0,k.jsx)(`code`,{className:`hljs${t?` language-${t}`:``}`,children:U&&!R?(0,k.jsx)(`span`,{dangerouslySetInnerHTML:{__html:U}}):e})}),A&&R&&(0,k.jsx)(`p`,{className:`markdown-mermaid-error-message`,role:`status`,children:L.mermaidRenderError})]}),(0,k.jsx)(x,{preview:p,labels:G,onClose:()=>w(null)})]})}),U={bytes:100*1024,series:20,points:1e4,text:200,summary:2e3},W=class extends Error{path;code;constructor(e,t){super(`${e}: ${t}`),this.path=e,this.code=t,this.name=`ChartSpecError`}};function G(e,t){throw new W(e,t)}function K(e,t,n){(!e||typeof e!=`object`||Array.isArray(e))&&G(n,`OBJECT_REQUIRED`);let r=e;for(let e of Object.keys(r))t.includes(e)||G(`${n}.${e}`,`UNKNOWN_FIELD`);return r}function q(e,t,n=U.text){return(typeof e!=`string`||!e.trim()||e.length>n)&&G(t,`INVALID_TEXT`),e}function J(e,t,n){return(!Array.isArray(e)||e.length===0||e.length>n)&&G(t,`INVALID_ARRAY`),e}function Y(e){(e.length>U.bytes||new TextEncoder().encode(e).byteLength>U.bytes)&&G(`$`,`TOO_LARGE`);let t;try{t=JSON.parse(e)}catch{G(`$`,`INVALID_JSON`)}let n=K(t,[`version`,`type`,`title`,`summary`,`dataKind`,`sources`,`xAxis`,`yAxis`,`series`],`$`);n.version!==1&&G(`$.version`,`UNSUPPORTED_VERSION`),n.type!==`line`&&n.type!==`bar`&&G(`$.type`,`UNSUPPORTED_TYPE`),n.dataKind!==`real`&&n.dataKind!==`example`&&G(`$.dataKind`,`INVALID_DATA_KIND`);let r=K(n.xAxis,[`label`,`values`],`$.xAxis`),i=K(n.yAxis,[`label`,`unit`],`$.yAxis`),a=J(r.values,`$.xAxis.values`,U.points).map((e,t)=>q(e,`$.xAxis.values[${t}]`)),o=new Set,s=J(n.series,`$.series`,U.series).map((e,t)=>{let n=`$.series[${t}]`,r=K(e,[`name`,`values`],n),i=q(r.name,`${n}.name`);o.has(i)&&G(`${n}.name`,`DUPLICATE_SERIES`),o.add(i);let s=J(r.values,`${n}.values`,U.points);return s.length!==a.length&&G(`${n}.values`,`LENGTH_MISMATCH`),{name:i,values:s.map((e,t)=>e===null?null:((typeof e!=`number`||!Number.isFinite(e))&&G(`${n}.values[${t}]`,`INVALID_NUMBER`),e))}});s.length*a.length>U.points&&G(`$.series`,`TOO_MANY_POINTS`),s.some(e=>e.values.some(e=>e!==null))||G(`$.series`,`EMPTY_DATA`);let c=n.sources===void 0?void 0:J(n.sources,`$.sources`,20).map((e,t)=>q(e,`$.sources[${t}]`,2e3));return n.dataKind===`real`&&!c&&G(`$.sources`,`SOURCES_REQUIRED`),{version:1,type:n.type,title:q(n.title,`$.title`),summary:q(n.summary,`$.summary`,U.summary),dataKind:n.dataKind,...c?{sources:c}:{},xAxis:{label:q(r.label,`$.xAxis.label`),values:a},yAxis:{label:q(i.label,`$.yAxis.label`),unit:q(i.unit,`$.yAxis.unit`)},series:s}}function X(e,t){return{animation:!1,backgroundColor:t.background,color:[t.accent,t.muted,`#659c95`,`#b49166`,`#927daf`],textStyle:{color:t.foreground,fontFamily:`sans-serif`},grid:{left:16,right:24,top:84,bottom:48,outerBoundsMode:`same`,outerBoundsContain:`all`},legend:{type:`scroll`,top:8,textStyle:{color:t.foreground,width:160,overflow:`truncate`}},tooltip:{trigger:`axis`,renderMode:`richText`,confine:!0},xAxis:{type:`category`,data:[...e.xAxis.values],name:e.xAxis.label,nameLocation:`middle`,nameGap:32,nameTextStyle:{color:t.muted},boundaryGap:e.type===`bar`,axisLabel:{color:t.muted,width:72,overflow:`truncate`,hideOverlap:!0},axisLine:{lineStyle:{color:t.border}},axisTick:{show:!1}},yAxis:{type:`value`,name:`${e.yAxis.label} (${e.yAxis.unit})`,nameTextStyle:{color:t.muted,width:200,overflow:`truncate`,align:`left`},scale:!1,axisLabel:{color:t.muted},splitLine:{lineStyle:{color:t.border}}},series:e.series.map((t,n)=>e.type===`line`?{name:t.name,type:`line`,data:[...t.values],smooth:!1,connectNulls:!1,showSymbol:e.xAxis.values.length<=100,symbol:[`circle`,`rect`,`triangle`,`diamond`,`roundRect`][n%5],lineStyle:{type:n%2?`dashed`:`solid`}}:{name:t.name,type:`bar`,data:[...t.values],barMaxWidth:40})}}function Z(e,t){return X(e,t)}function ee(e){let t=getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n;return{foreground:n(`--color-fg`,`#111111`),muted:n(`--color-fg-muted`,`#666666`),border:n(`--color-edge`,`#ececec`),background:n(`--color-surface-panel`,`#ffffff`),accent:n(`--color-accent`,`#3a6bff`)}}function te(){return i(()=>import(`./echarts-runtime-QSmTlXOu.js`),__vite__mapDeps([4,1]))}function Q({spec:e,onError:t,expanded:n=!1}){let r=(0,O.useRef)(null),i=(0,O.useRef)(null),[s,c]=(0,O.useState)(!1),[l,u]=(0,O.useState)(!1),d=o(a(e=>e.language)).chat.chart;return(0,O.useEffect)(()=>{let n=r.current;if(!n)return;let a=!0,o,s,l=0,u=0,d=``;c(!1);let f=()=>{let r=n.clientWidth,s=n.clientHeight;if(!(!a||!o||r<=0||s<=0))try{let t=ee(n),a=JSON.stringify(t);i.current||(i.current=o.init(n,void 0,{renderer:`canvas`,devicePixelRatio:Math.min(window.devicePixelRatio||1,2)}),c(!0)),a!==d&&(i.current.setOption(Z(e,t),{notMerge:!0}),d=a),l&&(r!==l||s!==u)&&i.current.resize(),l=r,u=s}catch{i.current?.dispose(),i.current=null,t()}},p=()=>{!a||s!==void 0||(s=requestAnimationFrame(()=>{s=void 0,f()}))},m=typeof ResizeObserver>`u`?null:new ResizeObserver(p);m?.observe(n);let h=new MutationObserver(p);return h.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-theme`,`data-color-scheme`,`style`]}),window.addEventListener(`resize`,p),te().then(e=>{a&&(o=e,f())}).catch(()=>{a&&t()}),()=>{a=!1,s!==void 0&&cancelAnimationFrame(s),m?.disconnect(),h.disconnect(),window.removeEventListener(`resize`,p),i.current?.dispose(),i.current=null}},[e,t]),(0,k.jsxs)(`div`,{className:n?`relative h-full min-h-0`:`relative h-[280px] sm:h-[360px]`,children:[(0,k.jsx)(`div`,{ref:r,className:`h-full w-full`,role:`img`,"aria-label":`${e.title}. ${e.summary}`}),!s&&(0,k.jsx)(`div`,{className:`absolute inset-0 p-4`,role:`status`,"aria-label":d.loading,children:(0,k.jsx)(T,{className:`h-full w-full`})}),s&&(0,k.jsxs)(`button`,{type:`button`,className:`absolute bottom-1 right-1 flex min-h-9 items-center gap-1 rounded-md bg-surface-overlay px-2 text-xs text-fg-muted hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,onClick:()=>{if(i.current)try{let e=i.current,t=Math.min(2,8192/e.getWidth(),8192/e.getHeight(),Math.sqrt(32e6/(e.getWidth()*e.getHeight()))),n=e.getDataURL({type:`png`,pixelRatio:t}),r=document.createElement(`a`);r.href=n,r.download=`chart.png`,document.body.append(r),r.click(),r.remove(),u(!1)}catch{u(!0)}},"aria-label":d.download,children:[(0,k.jsx)(g,{className:`size-4`,"aria-hidden":!0}),`PNG`]}),l&&(0,k.jsx)(`p`,{role:`status`,className:`absolute bottom-10 right-2 bg-surface-overlay p-2 text-xs text-fg-muted`,children:d.downloadFailed})]})}var $=`min-h-11 rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-accent sm:min-h-9`;function ne({spec:e,source:t,copy:n}){let r=z((0,O.useId)()),[i,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(!1),[v,y]=(0,O.useState)(!1),[b,x]=(0,O.useState)(!1),[S,C]=(0,O.useState)(!1),[D,A]=(0,O.useState)(!1),[j,M]=(0,O.useState)(!1),N=(0,O.useCallback)(()=>g(!0),[]),P=(0,O.useCallback)(()=>x(!0),[]),F=a(e=>e.language),I=o(F).chat.chart,L=i||h;return(0,k.jsxs)(`figure`,{ref:r.containerRef,className:`my-4 min-w-0 overflow-hidden rounded-lg border border-edge bg-surface-panel`,"data-chart-block":``,children:[(0,k.jsxs)(`figcaption`,{className:`flex flex-wrap items-center gap-1 border-b border-edge px-3 py-1`,children:[(0,k.jsx)(`span`,{className:`min-w-0 basis-full break-words text-sm font-medium text-fg sm:flex-1 sm:basis-0`,children:e.title}),e.dataKind===`example`&&(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:I.example}),(0,k.jsx)(`button`,{type:`button`,className:$,"aria-pressed":L,onClick:()=>m(!L),disabled:h,children:L?I.chart:I.source}),n&&(0,k.jsx)(`button`,{type:`button`,className:$,onClick:()=>{E(t).then(e=>{A(!e),M(e)})},children:j?o(F).chat.messageCopied:I.copy}),(0,k.jsx)(`button`,{type:`button`,className:$,"aria-label":I.preview,onClick:()=>{x(!1),y(!0)},children:(0,k.jsx)(_,{className:`size-4`,"aria-hidden":!0})})]}),D&&(0,k.jsx)(`p`,{role:`status`,className:`px-3 text-xs text-fg-muted`,children:I.copyFailed}),h&&(0,k.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-fg-muted`,role:`status`,children:[I.failed,(0,k.jsx)(`button`,{type:`button`,className:$,onClick:()=>{r.activate(),g(!1),m(!1)},children:I.retry})]}),L?(0,k.jsx)(`pre`,{className:`max-h-[360px] overflow-auto p-3 text-xs`,children:(0,k.jsx)(`code`,{className:`language-json`,children:t})}):r.active&&!v?(0,k.jsx)(Q,{spec:e,onError:N}):(0,k.jsxs)(`div`,{className:`relative h-[280px] p-4 sm:h-[360px]`,children:[(0,k.jsx)(T,{className:`h-full w-full`}),(0,k.jsx)(`button`,{type:`button`,className:`${$} absolute inset-0 m-auto h-10 w-fit bg-surface-overlay`,onClick:r.activate,children:I.activate})]}),(0,k.jsx)(`p`,{className:`px-3 pb-2 text-xs text-fg-muted`,children:e.summary}),e.sources&&(0,k.jsxs)(`p`,{className:`px-3 pb-2 text-xs text-fg-muted`,children:[I.sources,`: `,e.sources.join(` · `)]}),(0,k.jsxs)(`details`,{className:`border-t border-edge px-3 py-2 text-xs text-fg-muted`,onToggle:e=>C(e.currentTarget.open),children:[(0,k.jsx)(`summary`,{className:`cursor-pointer`,children:I.data}),S&&(0,k.jsx)(`div`,{className:`max-h-64 overflow-auto`,children:(0,k.jsxs)(`table`,{children:[(0,k.jsxs)(`caption`,{children:[e.yAxis.label,` (`,e.yAxis.unit,`)`]}),(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{scope:`col`,children:e.xAxis.label}),e.series.map(e=>(0,k.jsx)(`th`,{scope:`col`,children:e.name},e.name))]})}),(0,k.jsx)(`tbody`,{children:e.xAxis.values.map((t,n)=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{scope:`row`,children:t}),e.series.map(e=>(0,k.jsx)(`td`,{children:e.values[n]??`—`},e.name))]},n))})]})})]}),(0,k.jsx)(p,{open:v,onOpenChange:y,children:(0,k.jsxs)(u,{children:[(0,k.jsx)(s,{className:`fixed inset-0 z-[90] bg-scrim/90 backdrop-blur-sm`}),(0,k.jsxs)(d,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[91] flex h-[min(90dvh,52rem)] w-[min(96vw,80rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay outline-none`,children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-3 py-2`,children:[(0,k.jsx)(f,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.title}),(0,k.jsx)(l,{className:$,"aria-label":I.close,children:(0,k.jsx)(w,{className:`size-4`,"aria-hidden":!0})})]}),(0,k.jsx)(c,{className:`line-clamp-2 shrink-0 px-3 py-2 text-xs text-fg-muted`,children:e.summary}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden p-2`,children:b?(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:I.failed}):(0,k.jsx)(Q,{spec:e,expanded:!0,onError:P})})]})]})})]})}var re=(0,O.memo)(function(e){let t=(0,D.c)(35),{source:n,incomplete:r,streaming:i,copy:s}=e,c=a(ie),l;t[0]===c?l=t[1]:(l=o(c),t[0]=c,t[1]=l);let u=l.chat.chart,d;bb0:{if(r){d=null;break bb0}try{let e;t[2]===n?e=t[3]:(e=Y(n),t[2]=n,t[3]=e);let r;t[4]===e?r=t[5]:(r={spec:e},t[4]=e,t[5]=r),d=r}catch(e){let n=e,r;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(r={error:n instanceof W?n:new W(`$`,`INVALID_JSON`)},t[6]=r):r=t[6],d=r}}let f=d;if(!f){let e;t[7]!==u.generating||t[8]!==u.incomplete||t[9]!==i?(e=i?(0,k.jsx)(`div`,{className:`h-[280px] sm:h-[360px]`,role:`status`,"aria-label":u.generating,children:(0,k.jsx)(T,{className:`h-full w-full`})}):(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:u.incomplete}),t[7]=u.generating,t[8]=u.incomplete,t[9]=i,t[10]=e):e=t[10];let r;t[11]===u.source?r=t[12]:(r=(0,k.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:u.source}),t[11]=u.source,t[12]=r);let a;t[13]===n?a=t[14]:(a=(0,k.jsx)(`pre`,{className:`max-h-64 overflow-auto text-xs`,children:(0,k.jsx)(`code`,{children:n})}),t[13]=n,t[14]=a);let o;t[15]!==r||t[16]!==a?(o=(0,k.jsxs)(`details`,{children:[r,a]}),t[15]=r,t[16]=a,t[17]=o):o=t[17];let s;return t[18]!==e||t[19]!==o?(s=(0,k.jsxs)(`div`,{className:`my-4 rounded-lg border border-edge p-3`,"data-chart-pending":``,children:[e,o]}),t[18]=e,t[19]=o,t[20]=s):s=t[20],s}if(f.error){let e=u.errors[f.error.code]??u.invalid,r;t[21]!==u.invalid||t[22]!==f.error.path||t[23]!==e?(r=(0,k.jsxs)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:[u.invalid,` (`,f.error.path,`: `,e,`)`]}),t[21]=u.invalid,t[22]=f.error.path,t[23]=e,t[24]=r):r=t[24];let i;t[25]!==s||t[26]!==n?(i=(0,k.jsx)(H,{code:n,language:`json`,incomplete:!1,renderMermaid:!1,actions:!1,copy:s}),t[25]=s,t[26]=n,t[27]=i):i=t[27];let a;return t[28]!==r||t[29]!==i?(a=(0,k.jsxs)(`div`,{className:`my-4 rounded-lg border border-edge p-3`,"data-chart-error":``,children:[r,i]}),t[28]=r,t[29]=i,t[30]=a):a=t[30],a}let p;return t[31]!==s||t[32]!==f.spec||t[33]!==n?(p=(0,k.jsx)(ne,{spec:f.spec,source:n,copy:s},n),t[31]=s,t[32]=f.spec,t[33]=n,t[34]=p):p=t[34],p});function ie(e){return e.language}export{z as i,H as n,N as r,re as t};
|
|
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{n as a}from"./locale-store-Dy1EByeG.js";import{t as o}from"./messages-BAnhwALN.js";import{a as s,i as c,n as l,o as u,r as d,s as f,t as p}from"./dist-CY7CS_D3.js";import{t as m}from"./check-DUBLcKHA.js";import{t as h}from"./copy-Dv6d4Dvw.js";import{t as g}from"./download-Dk-ZjtO6.js";import{K as _,U as v,W as y,a as b,i as x,o as S,s as C}from"./markdown-view-BlxIaCCQ.js";import{t as w}from"./x-B_N4OPjy.js";import{t as T}from"./skeleton-DzdOeGYz.js";import{t as E}from"./copy-to-clipboard-HOJ79TWv.js";var D=n(),O=e(t(),1),k=r(),A=2,j=(0,O.createContext)(null);function M(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function N(e){let t=(0,D.c)(14),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=(0,O.useRef)(r),a=(0,O.useRef)(0),o=(0,O.useRef)(null),s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,t[1]=s):s=t[1];let[c,l]=(0,O.useState)(s),u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=new Set,t[2]=u):u=t[2];let[d,f]=(0,O.useState)(u),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{if(document.visibilityState===`hidden`){l(R);return}let e=[...i.current.entries()].filter(L).sort(I),t=new Set(e.slice(0,A).map(F)),n=new Set(e.map(P));l(e=>M(e,t)?e:t),f(e=>M(e,n)?e:n)},t[3]=p):p=t[3];let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{let n=i.current.get(e);if(n&&o.current?.unobserve(n.element),!t){i.current.delete(e),m();return}i.current.set(e,{element:t,near:!1,visible:!1,manualPriority:n?.manualPriority??0,distance:1/0}),o.current?.observe(t)},t[4]=h):h=t[4];let g=h,_;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{let t=i.current.get(e);t&&(a.current+=1,t.manualPriority=a.current,t.near=!0,t.visible=!0,t.distance=0,m())},t[5]=_):_=t[5];let v=_,y,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{if(typeof IntersectionObserver>`u`)return;o.current=new IntersectionObserver(e=>{for(let t of e){let e=[...i.current.values()].find(e=>e.element===t.target);if(!e)continue;let n=t.boundingClientRect;e.near=t.isIntersecting,e.visible=t.isIntersecting&&n.bottom>0&&n.top<window.innerHeight,e.distance=Math.abs((n.top+n.bottom)/2-window.innerHeight/2),e.near||(e.manualPriority=0)}m()},{rootMargin:`480px 0px`,threshold:0});for(let e of i.current.values())o.current.observe(e.element);let e=()=>m();return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),o.current?.disconnect(),o.current=null}},b=[m],t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,O.useEffect)(y,b);let x;t[8]!==c||t[9]!==d?(x={activeIds:c,nearIds:d,register:g,activate:v},t[8]=c,t[9]=d,t[10]=x):x=t[10];let S=x,C;return t[11]!==n||t[12]!==S?(C=(0,k.jsx)(j.Provider,{value:S,children:n}),t[11]=n,t[12]=S,t[13]=C):C=t[13],C}function P(e){let[t]=e;return t}function F(e){let[t]=e;return t}function I(e,t){let[,n]=e,[,r]=t;return r.manualPriority-n.manualPriority||Number(r.visible)-Number(n.visible)||n.distance-r.distance}function L(e){let[,t]=e;return t.near||t.manualPriority>0}function R(e){return e.size?new Set:e}function z(e){let t=(0,D.c)(16),n=(0,O.useContext)(j),r=n?.register,i=n?.activate,a;t[0]!==e||t[1]!==r?(a=t=>r?.(e,t),t[0]=e,t[1]=r,t[2]=a):a=t[2];let o=a;if(!n){let e;return t[3]===o?e=t[4]:(e={active:!0,state:`active`,containerRef:o,activate:B},t[3]=o,t[4]=e),e}let s;t[5]!==e||t[6]!==n.activeIds?(s=n.activeIds.has(e),t[5]=e,t[6]=n.activeIds,t[7]=s):s=t[7];let c=s,l=c?`active`:n.nearIds.has(e)?`queued`:`dormant`,u;t[8]!==e||t[9]!==i?(u=()=>i?.(e),t[8]=e,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==o||t[13]!==l||t[14]!==u?(d={active:c,state:l,containerRef:o,activate:u},t[11]=c,t[12]=o,t[13]=l,t[14]=u,t[15]=d):d=t[15],d}function B(){}var V=new class{maxBytes;maxEntries;entries=new Map;bytes=0;constructor(e=8*1024*1024,t=256){this.maxBytes=e,this.maxEntries=t}get(e){let t=this.entries.get(e);if(t)return this.entries.delete(e),this.entries.set(e,t),t.value}set(e,t){let n=this.entries.get(e);n&&(this.bytes-=n.bytes),this.entries.delete(e);let r=(e.length+t.length)*2;if(!(r>this.maxBytes))for(this.entries.set(e,{value:t,bytes:r}),this.bytes+=r;this.bytes>this.maxBytes||this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.bytes-=this.entries.get(e).bytes,this.entries.delete(e)}}get sizeBytes(){return this.bytes}},H=(0,O.memo)(function({code:e,language:t,incomplete:n,renderMermaid:r,actions:s,copy:c}){let l=z((0,O.useId)()),u=(0,O.useRef)(null),[d,f]=(0,O.useState)(null),[p,w]=(0,O.useState)(null),[T,D]=(0,O.useState)(!1),[A,j]=(0,O.useState)(!1),[M,N]=(0,O.useState)(0),P=(0,O.useRef)(null),F=(0,O.useRef)(!1),I=(0,O.useRef)(e),L=o(a(e=>e.language)).chat,R=(t===`mermaid`||!t&&b(e))&&r&&!n,B=`${R?`mermaid`:`code`}:${t}:${e}`;(0,O.useEffect)(()=>{if(n||!l.active||new TextEncoder().encode(e).byteLength>100*1024)return;let r=!0;j(!1);let a=V.get(B);return(a===void 0?R?i(async()=>{let{renderMermaidSvg:e}=await import(`./mermaid-render-oOellPHt.js`).then(e=>e.t);return{renderMermaidSvg:e}},__vite__mapDeps([0,1])).then(({renderMermaidSvg:t})=>v(t(e))):i(async()=>{let{highlightCode:e}=await import(`./highlight-code-BH65IIbJ.js`);return{highlightCode:e}},__vite__mapDeps([2,3,1])).then(({highlightCode:n})=>y.sanitize(n(e,t),{ALLOWED_TAGS:[`span`],ALLOWED_ATTR:[`class`]})):Promise.resolve(a)).then(e=>{r&&(V.set(B,e),f({key:B,value:e}))}).catch(()=>{r&&j(!0)}),()=>{r=!1}},[B,e,R,n,t,l.active,M]),(0,O.useLayoutEffect)(()=>{I.current=e},[e]),(0,O.useEffect)(()=>(F.current=!0,()=>{F.current=!1,P.current&&clearTimeout(P.current)}),[]);let H=()=>{let e=u.current,t=e?.querySelector(`svg`);return e&&t?S(t,e):null},U=d?.key===B?d.value:null,W=R&&!!U&&!A,G={title:L.mermaidPreviewTitle,close:L.mermaidPreviewClose,zoomIn:L.mermaidZoomIn,zoomOut:L.mermaidZoomOut,fit:L.mermaidFit,downloadPng:L.mermaidDownloadPng,downloadSvg:L.mermaidDownloadSvg,downloadFailed:L.mermaidDownloadFailed};return(0,k.jsxs)(`div`,{ref:l.containerRef,className:W?`markdown-mermaid markdown-mermaid-interactive`:`markdown-code-block`,"data-mermaid-diagram":W?``:void 0,children:[W?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{ref:u,dangerouslySetInnerHTML:{__html:U}}),s&&(0,k.jsxs)(`div`,{className:`markdown-mermaid-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`markdown-mermaid-action-button`,title:L.mermaidPreview,"aria-label":L.mermaidPreview,onClick:()=>{let e=H();e&&w({snapshot:e,baseName:`diagram`})},children:(0,k.jsx)(_,{className:`size-4`,"aria-hidden":!0})}),(0,k.jsx)(`button`,{type:`button`,className:`markdown-mermaid-action-button`,title:L.mermaidDownloadPng,"aria-label":L.mermaidDownloadPng,onClick:()=>{let e=H();e&&C(e,`diagram.png`).catch(()=>{F.current&&j(!0)})},children:(0,k.jsx)(g,{className:`size-4`,"aria-hidden":!0})})]})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`markdown-code-block-header`,children:[(0,k.jsx)(`span`,{className:`markdown-code-block-lang`,children:t||`text`}),R&&(0,k.jsx)(`button`,{type:`button`,className:`markdown-code-copy-btn`,title:L.mermaidPreview,"aria-label":L.mermaidPreview,onClick:()=>{l.activate(),N(e=>e+1)},children:(0,k.jsx)(_,{})}),c&&(0,k.jsx)(`button`,{type:`button`,className:`markdown-code-copy-btn`,title:T?L.messageCopied:L.codeBlockCopy,"aria-label":T?L.messageCopied:L.codeBlockCopy,onClick:()=>{E(e).then(t=>{!t||!F.current||I.current!==e||(D(!0),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>D(!1),2e3))})},children:T?(0,k.jsx)(m,{"aria-hidden":`true`}):(0,k.jsx)(h,{"aria-hidden":`true`})})]}),(0,k.jsx)(`pre`,{children:(0,k.jsx)(`code`,{className:`hljs${t?` language-${t}`:``}`,children:U&&!R?(0,k.jsx)(`span`,{dangerouslySetInnerHTML:{__html:U}}):e})}),A&&R&&(0,k.jsx)(`p`,{className:`markdown-mermaid-error-message`,role:`status`,children:L.mermaidRenderError})]}),(0,k.jsx)(x,{preview:p,labels:G,onClose:()=>w(null)})]})}),U={bytes:100*1024,series:20,points:1e4,text:200,summary:2e3},W=class extends Error{path;code;constructor(e,t){super(`${e}: ${t}`),this.path=e,this.code=t,this.name=`ChartSpecError`}};function G(e,t){throw new W(e,t)}function K(e,t,n){(!e||typeof e!=`object`||Array.isArray(e))&&G(n,`OBJECT_REQUIRED`);let r=e;for(let e of Object.keys(r))t.includes(e)||G(`${n}.${e}`,`UNKNOWN_FIELD`);return r}function q(e,t,n=U.text){return(typeof e!=`string`||!e.trim()||e.length>n)&&G(t,`INVALID_TEXT`),e}function J(e,t,n){return(!Array.isArray(e)||e.length===0||e.length>n)&&G(t,`INVALID_ARRAY`),e}function Y(e){(e.length>U.bytes||new TextEncoder().encode(e).byteLength>U.bytes)&&G(`$`,`TOO_LARGE`);let t;try{t=JSON.parse(e)}catch{G(`$`,`INVALID_JSON`)}let n=K(t,[`version`,`type`,`title`,`summary`,`dataKind`,`sources`,`xAxis`,`yAxis`,`series`],`$`);n.version!==1&&G(`$.version`,`UNSUPPORTED_VERSION`),n.type!==`line`&&n.type!==`bar`&&G(`$.type`,`UNSUPPORTED_TYPE`),n.dataKind!==`real`&&n.dataKind!==`example`&&G(`$.dataKind`,`INVALID_DATA_KIND`);let r=K(n.xAxis,[`label`,`values`],`$.xAxis`),i=K(n.yAxis,[`label`,`unit`],`$.yAxis`),a=J(r.values,`$.xAxis.values`,U.points).map((e,t)=>q(e,`$.xAxis.values[${t}]`)),o=new Set,s=J(n.series,`$.series`,U.series).map((e,t)=>{let n=`$.series[${t}]`,r=K(e,[`name`,`values`],n),i=q(r.name,`${n}.name`);o.has(i)&&G(`${n}.name`,`DUPLICATE_SERIES`),o.add(i);let s=J(r.values,`${n}.values`,U.points);return s.length!==a.length&&G(`${n}.values`,`LENGTH_MISMATCH`),{name:i,values:s.map((e,t)=>e===null?null:((typeof e!=`number`||!Number.isFinite(e))&&G(`${n}.values[${t}]`,`INVALID_NUMBER`),e))}});s.length*a.length>U.points&&G(`$.series`,`TOO_MANY_POINTS`),s.some(e=>e.values.some(e=>e!==null))||G(`$.series`,`EMPTY_DATA`);let c=n.sources===void 0?void 0:J(n.sources,`$.sources`,20).map((e,t)=>q(e,`$.sources[${t}]`,2e3));return n.dataKind===`real`&&!c&&G(`$.sources`,`SOURCES_REQUIRED`),{version:1,type:n.type,title:q(n.title,`$.title`),summary:q(n.summary,`$.summary`,U.summary),dataKind:n.dataKind,...c?{sources:c}:{},xAxis:{label:q(r.label,`$.xAxis.label`),values:a},yAxis:{label:q(i.label,`$.yAxis.label`),unit:q(i.unit,`$.yAxis.unit`)},series:s}}function X(e,t){return{animation:!1,backgroundColor:t.background,color:[t.accent,t.muted,`#659c95`,`#b49166`,`#927daf`],textStyle:{color:t.foreground,fontFamily:`sans-serif`},grid:{left:16,right:24,top:84,bottom:48,outerBoundsMode:`same`,outerBoundsContain:`all`},legend:{type:`scroll`,top:8,textStyle:{color:t.foreground,width:160,overflow:`truncate`}},tooltip:{trigger:`axis`,renderMode:`richText`,confine:!0},xAxis:{type:`category`,data:[...e.xAxis.values],name:e.xAxis.label,nameLocation:`middle`,nameGap:32,nameTextStyle:{color:t.muted},boundaryGap:e.type===`bar`,axisLabel:{color:t.muted,width:72,overflow:`truncate`,hideOverlap:!0},axisLine:{lineStyle:{color:t.border}},axisTick:{show:!1}},yAxis:{type:`value`,name:`${e.yAxis.label} (${e.yAxis.unit})`,nameTextStyle:{color:t.muted,width:200,overflow:`truncate`,align:`left`},scale:!1,axisLabel:{color:t.muted},splitLine:{lineStyle:{color:t.border}}},series:e.series.map((t,n)=>e.type===`line`?{name:t.name,type:`line`,data:[...t.values],smooth:!1,connectNulls:!1,showSymbol:e.xAxis.values.length<=100,symbol:[`circle`,`rect`,`triangle`,`diamond`,`roundRect`][n%5],lineStyle:{type:n%2?`dashed`:`solid`}}:{name:t.name,type:`bar`,data:[...t.values],barMaxWidth:40})}}function Z(e,t){return X(e,t)}function ee(e){let t=getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n;return{foreground:n(`--color-fg`,`#111111`),muted:n(`--color-fg-muted`,`#666666`),border:n(`--color-edge`,`#ececec`),background:n(`--color-surface-panel`,`#ffffff`),accent:n(`--color-accent`,`#3a6bff`)}}function te(){return i(()=>import(`./echarts-runtime-QSmTlXOu.js`),__vite__mapDeps([4,1]))}function Q({spec:e,onError:t,expanded:n=!1}){let r=(0,O.useRef)(null),i=(0,O.useRef)(null),[s,c]=(0,O.useState)(!1),[l,u]=(0,O.useState)(!1),d=o(a(e=>e.language)).chat.chart;return(0,O.useEffect)(()=>{let n=r.current;if(!n)return;let a=!0,o,s,l=0,u=0,d=``;c(!1);let f=()=>{let r=n.clientWidth,s=n.clientHeight;if(!(!a||!o||r<=0||s<=0))try{let t=ee(n),a=JSON.stringify(t);i.current||(i.current=o.init(n,void 0,{renderer:`canvas`,devicePixelRatio:Math.min(window.devicePixelRatio||1,2)}),c(!0)),a!==d&&(i.current.setOption(Z(e,t),{notMerge:!0}),d=a),l&&(r!==l||s!==u)&&i.current.resize(),l=r,u=s}catch{i.current?.dispose(),i.current=null,t()}},p=()=>{!a||s!==void 0||(s=requestAnimationFrame(()=>{s=void 0,f()}))},m=typeof ResizeObserver>`u`?null:new ResizeObserver(p);m?.observe(n);let h=new MutationObserver(p);return h.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-theme`,`data-color-scheme`,`style`]}),window.addEventListener(`resize`,p),te().then(e=>{a&&(o=e,f())}).catch(()=>{a&&t()}),()=>{a=!1,s!==void 0&&cancelAnimationFrame(s),m?.disconnect(),h.disconnect(),window.removeEventListener(`resize`,p),i.current?.dispose(),i.current=null}},[e,t]),(0,k.jsxs)(`div`,{className:n?`relative h-full min-h-0`:`relative h-[280px] sm:h-[360px]`,children:[(0,k.jsx)(`div`,{ref:r,className:`h-full w-full`,role:`img`,"aria-label":`${e.title}. ${e.summary}`}),!s&&(0,k.jsx)(`div`,{className:`absolute inset-0 p-4`,role:`status`,"aria-label":d.loading,children:(0,k.jsx)(T,{className:`h-full w-full`})}),s&&(0,k.jsxs)(`button`,{type:`button`,className:`absolute bottom-1 right-1 flex min-h-9 items-center gap-1 rounded-md bg-surface-overlay px-2 text-xs text-fg-muted hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,onClick:()=>{if(i.current)try{let e=i.current,t=Math.min(2,8192/e.getWidth(),8192/e.getHeight(),Math.sqrt(32e6/(e.getWidth()*e.getHeight()))),n=e.getDataURL({type:`png`,pixelRatio:t}),r=document.createElement(`a`);r.href=n,r.download=`chart.png`,document.body.append(r),r.click(),r.remove(),u(!1)}catch{u(!0)}},"aria-label":d.download,children:[(0,k.jsx)(g,{className:`size-4`,"aria-hidden":!0}),`PNG`]}),l&&(0,k.jsx)(`p`,{role:`status`,className:`absolute bottom-10 right-2 bg-surface-overlay p-2 text-xs text-fg-muted`,children:d.downloadFailed})]})}var $=`min-h-11 rounded-md px-2 text-xs text-fg-muted hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-accent sm:min-h-9`;function ne({spec:e,source:t,copy:n}){let r=z((0,O.useId)()),[i,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(!1),[v,y]=(0,O.useState)(!1),[b,x]=(0,O.useState)(!1),[S,C]=(0,O.useState)(!1),[D,A]=(0,O.useState)(!1),[j,M]=(0,O.useState)(!1),N=(0,O.useCallback)(()=>g(!0),[]),P=(0,O.useCallback)(()=>x(!0),[]),F=a(e=>e.language),I=o(F).chat.chart,L=i||h;return(0,k.jsxs)(`figure`,{ref:r.containerRef,className:`my-4 min-w-0 overflow-hidden rounded-lg border border-edge bg-surface-panel`,"data-chart-block":``,children:[(0,k.jsxs)(`figcaption`,{className:`flex flex-wrap items-center gap-1 border-b border-edge px-3 py-1`,children:[(0,k.jsx)(`span`,{className:`min-w-0 basis-full break-words text-sm font-medium text-fg sm:flex-1 sm:basis-0`,children:e.title}),e.dataKind===`example`&&(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:I.example}),(0,k.jsx)(`button`,{type:`button`,className:$,"aria-pressed":L,onClick:()=>m(!L),disabled:h,children:L?I.chart:I.source}),n&&(0,k.jsx)(`button`,{type:`button`,className:$,onClick:()=>{E(t).then(e=>{A(!e),M(e)})},children:j?o(F).chat.messageCopied:I.copy}),(0,k.jsx)(`button`,{type:`button`,className:$,"aria-label":I.preview,onClick:()=>{x(!1),y(!0)},children:(0,k.jsx)(_,{className:`size-4`,"aria-hidden":!0})})]}),D&&(0,k.jsx)(`p`,{role:`status`,className:`px-3 text-xs text-fg-muted`,children:I.copyFailed}),h&&(0,k.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-fg-muted`,role:`status`,children:[I.failed,(0,k.jsx)(`button`,{type:`button`,className:$,onClick:()=>{r.activate(),g(!1),m(!1)},children:I.retry})]}),L?(0,k.jsx)(`pre`,{className:`max-h-[360px] overflow-auto p-3 text-xs`,children:(0,k.jsx)(`code`,{className:`language-json`,children:t})}):r.active&&!v?(0,k.jsx)(Q,{spec:e,onError:N}):(0,k.jsxs)(`div`,{className:`relative h-[280px] p-4 sm:h-[360px]`,children:[(0,k.jsx)(T,{className:`h-full w-full`}),(0,k.jsx)(`button`,{type:`button`,className:`${$} absolute inset-0 m-auto h-10 w-fit bg-surface-overlay`,onClick:r.activate,children:I.activate})]}),(0,k.jsx)(`p`,{className:`px-3 pb-2 text-xs text-fg-muted`,children:e.summary}),e.sources&&(0,k.jsxs)(`p`,{className:`px-3 pb-2 text-xs text-fg-muted`,children:[I.sources,`: `,e.sources.join(` · `)]}),(0,k.jsxs)(`details`,{className:`border-t border-edge px-3 py-2 text-xs text-fg-muted`,onToggle:e=>C(e.currentTarget.open),children:[(0,k.jsx)(`summary`,{className:`cursor-pointer`,children:I.data}),S&&(0,k.jsx)(`div`,{className:`max-h-64 overflow-auto`,children:(0,k.jsxs)(`table`,{children:[(0,k.jsxs)(`caption`,{children:[e.yAxis.label,` (`,e.yAxis.unit,`)`]}),(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{scope:`col`,children:e.xAxis.label}),e.series.map(e=>(0,k.jsx)(`th`,{scope:`col`,children:e.name},e.name))]})}),(0,k.jsx)(`tbody`,{children:e.xAxis.values.map((t,n)=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{scope:`row`,children:t}),e.series.map(e=>(0,k.jsx)(`td`,{children:e.values[n]??`—`},e.name))]},n))})]})})]}),(0,k.jsx)(p,{open:v,onOpenChange:y,children:(0,k.jsxs)(u,{children:[(0,k.jsx)(s,{className:`fixed inset-0 z-[90] bg-scrim/90 backdrop-blur-sm`}),(0,k.jsxs)(d,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[91] flex h-[min(90dvh,52rem)] w-[min(96vw,80rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay outline-none`,children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-3 py-2`,children:[(0,k.jsx)(f,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.title}),(0,k.jsx)(l,{className:$,"aria-label":I.close,children:(0,k.jsx)(w,{className:`size-4`,"aria-hidden":!0})})]}),(0,k.jsx)(c,{className:`line-clamp-2 shrink-0 px-3 py-2 text-xs text-fg-muted`,children:e.summary}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden p-2`,children:b?(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:I.failed}):(0,k.jsx)(Q,{spec:e,expanded:!0,onError:P})})]})]})})]})}var re=(0,O.memo)(function(e){let t=(0,D.c)(35),{source:n,incomplete:r,streaming:i,copy:s}=e,c=a(ie),l;t[0]===c?l=t[1]:(l=o(c),t[0]=c,t[1]=l);let u=l.chat.chart,d;bb0:{if(r){d=null;break bb0}try{let e;t[2]===n?e=t[3]:(e=Y(n),t[2]=n,t[3]=e);let r;t[4]===e?r=t[5]:(r={spec:e},t[4]=e,t[5]=r),d=r}catch(e){let n=e,r;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(r={error:n instanceof W?n:new W(`$`,`INVALID_JSON`)},t[6]=r):r=t[6],d=r}}let f=d;if(!f){let e;t[7]!==u.generating||t[8]!==u.incomplete||t[9]!==i?(e=i?(0,k.jsx)(`div`,{className:`h-[280px] sm:h-[360px]`,role:`status`,"aria-label":u.generating,children:(0,k.jsx)(T,{className:`h-full w-full`})}):(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:u.incomplete}),t[7]=u.generating,t[8]=u.incomplete,t[9]=i,t[10]=e):e=t[10];let r;t[11]===u.source?r=t[12]:(r=(0,k.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:u.source}),t[11]=u.source,t[12]=r);let a;t[13]===n?a=t[14]:(a=(0,k.jsx)(`pre`,{className:`max-h-64 overflow-auto text-xs`,children:(0,k.jsx)(`code`,{children:n})}),t[13]=n,t[14]=a);let o;t[15]!==r||t[16]!==a?(o=(0,k.jsxs)(`details`,{children:[r,a]}),t[15]=r,t[16]=a,t[17]=o):o=t[17];let s;return t[18]!==e||t[19]!==o?(s=(0,k.jsxs)(`div`,{className:`my-4 rounded-lg border border-edge p-3`,"data-chart-pending":``,children:[e,o]}),t[18]=e,t[19]=o,t[20]=s):s=t[20],s}if(f.error){let e=u.errors[f.error.code]??u.invalid,r;t[21]!==u.invalid||t[22]!==f.error.path||t[23]!==e?(r=(0,k.jsxs)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:[u.invalid,` (`,f.error.path,`: `,e,`)`]}),t[21]=u.invalid,t[22]=f.error.path,t[23]=e,t[24]=r):r=t[24];let i;t[25]!==s||t[26]!==n?(i=(0,k.jsx)(H,{code:n,language:`json`,incomplete:!1,renderMermaid:!1,actions:!1,copy:s}),t[25]=s,t[26]=n,t[27]=i):i=t[27];let a;return t[28]!==r||t[29]!==i?(a=(0,k.jsxs)(`div`,{className:`my-4 rounded-lg border border-edge p-3`,"data-chart-error":``,children:[r,i]}),t[28]=r,t[29]=i,t[30]=a):a=t[30],a}let p;return t[31]!==s||t[32]!==f.spec||t[33]!==n?(p=(0,k.jsx)(ne,{spec:f.spec,source:n,copy:s},n),t[31]=s,t[32]=f.spec,t[33]=n,t[34]=p):p=t[34],p});function ie(e){return e.language}export{z as i,H as n,N as r,re as t};
|