@xopcai/xopc 0.0.424 → 0.0.426
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/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-AI081rxe.js → activity-store-D_DXNHba.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DupnTbL7.js → agent-avatar-dicebear-CjaQxFQt.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-display-CmEj6Uqy.js → agent-avatar-display-6Z4m31Fz.js} +2 -2
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-IEV5yKuu.js → agent-defaults-settings-panel-Dne9A10p.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-D_njOuFA.js → agent-plugin-dialog-BoHL-b1o.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-B_yg9nA3.js → agents-CIiIlVBp.js} +3 -3
- package/dist/gateway/static/root/assets/{agents-admin-api-CUZUolwG.js → agents-admin-api-u5c3GREg.js} +1 -1
- package/dist/gateway/static/root/assets/{api-bpQ7yR10.js → api-C3Tp9MkF.js} +1 -1
- package/dist/gateway/static/root/assets/{api-CWWEVThO.js → api-CRT9ZyH0.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-C0_hxwgg.js → app-management-settings-panel-C8yc3yHG.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CLh-qnCC.js → appearance-settings-BELgtR3O.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-Bjtm3Rgi.js → apps-page-vgS1CHDj.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-dGnstkhB.js → archive-plugin-BCQnOkV8.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-api-MB2xCoFF.js → automation-api-hRsGx-qe.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-result-state-DJQflY78.js → automation-result-state-CMfVTv_i.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-task-card-DXgBxVE2.js → automation-task-card-MnzgyTVA.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-D3O7M2FH.js → automations-page-CdIPdwF0.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-Dk3FVWoX.js → automations-workspace-C3xZLafX.js} +2 -2
- package/dist/gateway/static/root/assets/{binary-plugins-BrVJXmYf.js → binary-plugins-CIB5cbvQ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Dok4sfT3.js → block-editor-BQtTLe6Q.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-PJbT3CxW.js → browser-automation-inputs-DeraGZ1y.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-kkpX1Q7K.js → browser-automations-page-SpPzRNqU.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-control-api-Bg4wnkeA.js → browser-control-api-CbbPvhHR.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-BrgX_Yb2.js → browser-settings-page-BD1uF_Nb.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-BMaJizw4.js → capabilities-BGE6hiUE.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-Cs6Jt5Gl.js → capabilities-DLMuj21P.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-D5hvAG6D.js → capabilities-page-Bda4mSdf.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-BrEvm4IH.js → capabilities-settings-panel-B2B7no22.js} +2 -2
- package/dist/gateway/static/root/assets/{channels-1jQgGVc9.js → channels-NtsjZThx.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-agents-api-BAOWaUJf.js → chat-agents-api-D8YS5amE.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-chart-block-DeWrb9XR.js → chat-chart-block-DCzUECct.js} +1 -1
- package/dist/gateway/static/root/assets/chat-page-BnOCCAXG.js +72 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-C544n0-R.js → chat-terminal-dock-Dl-OTkJI.js} +1 -1
- package/dist/gateway/static/root/assets/{command-palette-api-D9PXzY8b.js → command-palette-api-Dijix7V6.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-payload-handoff-CYXfjpem.js → composer-payload-handoff-CQc-VTaL.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-DJmod8-w.js → computer-settings-page-B-lGMimW.js} +1 -1
- package/dist/gateway/static/root/assets/connected-providers-grid-CcXe9kz5.js +1 -0
- package/dist/gateway/static/root/assets/{connector-service-page-BqDbTOTp.js → connector-service-page-C8InhrMt.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-CwRuUnH4.js → connectors-api-DEJU8mgn.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-Mq9Bvoax.js → connectors-page-Ci0L2How.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-DWaT0IC0.js → date-picker-kqic8j73.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DV9XAt6F.js → dependency-picker-cbC6-2Ya.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Dffq2NxL.js → desktop-pet-DFNehTtd.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-narrative-CS8qJpNO.js → desktop-pet-narrative-ChwjpnsG.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CrB1ICax.js → desktop-pet-settings-BDS7_tQ_.js} +1 -1
- package/dist/gateway/static/root/assets/{dev-view-store-liRgSkcT.js → dev-view-store-CeZZLOc6.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-_3BJFWVQ.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-EKqQLQrE.js → directory-picker-path-field-Di0h3ws4.js} +1 -1
- package/dist/gateway/static/root/assets/{discussion-annotation-sync-D-b1X6ro.js → discussion-annotation-sync-ClKEyXmN.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-wD97GeG0.js → extension-debug-page-DwB5KMGk.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-B4Q1CjvW.js → extension-iframe-host-Cqg1K70e.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-marketplace-api-ak1_K3u8.js → extension-marketplace-api-DRBszrCR.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DWFI4iIh.js → extension-page-DyrQtG82.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-BZwcaU5Y.js → extension-provider-C_uKqJxP.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-cn4KS42C.js → extension-settings-page-BAMQHzkX.js} +1 -1
- package/dist/gateway/static/root/assets/{file-preview-surface-c3gDD9sM.js → file-preview-surface-DfkXvFnc.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-Dmt5JhZU.js → gateway-config-swr-BOCt_zOo.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-CJtDXQCt.js → gateway-realtime-BL_Cf0OQ.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BHBOPF_q.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-restart-DInvvT5u.js → gateway-restart-CHf8qY7H.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-BZXdv2FE.js → gateway-settings-uAboiElC.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-s2KcWekp.js → gateway-startup-retry-CvkJYurV.js} +1 -1
- package/dist/gateway/static/root/assets/{global-defaults-api-DtnmDd87.js → global-defaults-api-BWMbKu72.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-CAVjA5rO.js → home-page-D6pCBY1V.js} +2 -2
- package/dist/gateway/static/root/assets/{image-generation-api-RQQokgE9.js → image-generation-api-CQxZSTWA.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-BP_4TubV.js → imports-page-C90644id.js} +1 -1
- package/dist/gateway/static/root/assets/index-Cc41XQid.css +1 -0
- package/dist/gateway/static/root/assets/index-CnOYR6jq.js +11 -0
- package/dist/gateway/static/root/assets/{install-connector-dialog-BNzNuXJ8.js → install-connector-dialog-BuNXON0P.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DNRQFepg.js → keyboard-shortcuts-settings-CbeubKe1.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CvY5XxbX.js → local-app-workbench-page-CP-BkbB6.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-DfwEvd8G.js → local-apps-page-C6zFgwkr.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-CuDdIyxR.js → local-session-drafts-BJ1B1dQ7.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-TQcz_Vjt.js → locale-store-Br7IfbXK.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-eq49F1Rt.js → logs-page-CpVCvAWE.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-BaYXDMOJ.js → management-settings-I-pXv4ML.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-D4nII6Zv.js → markdown-view-DrVAMlwc.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-MvlAY405.js → media-plugins-Ba6vUE4J.js} +1 -1
- package/dist/gateway/static/root/assets/messages-ByFlEbsu.js +3 -0
- package/dist/gateway/static/root/assets/{model-selector-nsoNHqif.js → model-selector-CXcxc30J.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-cache-CFIazNIF.js → models-hub-cache-Bd-fYUrV.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-KPzbHiEW.js → note-detail-panel-CbpLXAVh.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-cLGiF8oU.js +1 -0
- package/dist/gateway/static/root/assets/{notes-api-HVxR5bRD.js → notes-api-CUlhTRv0.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-yShJeR3i.js → notes-page-eoKX85K5.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-api-CfKjRVnb.js → oauth-api-DMMdeaNd.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-provider-connect-D4uqONWr.js → oauth-provider-connect-C8BXow79.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-B98nlKTc.js → page-context-capture-button-CBFK41OS.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-draft-HcuK45iu.js → page-context-draft-LF33STHC.js} +1 -1
- package/dist/gateway/static/root/assets/page-header-store-Du44NIEJ.js +1 -0
- package/dist/gateway/static/root/assets/{personal-avatar-_d72UP_d.js → personal-avatar-D6CzIIfo.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-B19h_3WQ.js → personal-page-CXR1Gy0x.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-CfwtGyue.js → personal-settings-panel-DnYapLo7.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-dependencies-card-D8bqsDk_.js → phone-dependencies-card-DBiKtzwz.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-picker-CL_Zn6Xd.js → phone-model-picker-BmSxEr7M.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-settings-page-C5Jia8eQ.js → phone-settings-page-vg65qilc.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-workspace-store-FBfrfkYq.js → phone-workspace-store-SN7hfddU.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-gAq2KPzK.js → plugin-details-dialog-B3Hn2cbx.js} +1 -1
- package/dist/gateway/static/root/assets/{preference-select-fields-Ck8GAX_y.js → preference-select-fields-Cu_ZC9Up.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-BJ9oTnNs.js → product-automation-feedback-Tn2dUJWM.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-Dw9hUdxP.js → product-open-page-Nf-Oqf1h.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-C0iPzmSm.js → product-preview-content-D6NwUm3A.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-modal-COFtHoh6.js → product-preview-modal-BfNcGgXA.js} +2 -2
- package/dist/gateway/static/root/assets/{project-detail-page-C5Amjah-.js → project-detail-page-Ch-ZMyTu.js} +1 -1
- package/dist/gateway/static/root/assets/{project-understanding-DpL9ADQU.js → project-understanding-B1BK7Ixi.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-gGg9nM2t.js → projects-page-B7cetxao.js} +1 -1
- package/dist/gateway/static/root/assets/{providers-api-D6JJRlJb.js → providers-api-DOnNfkwQ.js} +1 -1
- package/dist/gateway/static/root/assets/{recording-upload-DxX1xKyt.js → recording-upload-RAhaLUcQ.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-BfXzBR1D.js → registry-api-DFDvOTg4.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BZA4StwC.js → remote-access-hub-DWsOWetc.js} +1 -1
- package/dist/gateway/static/root/assets/{resource-unavailable-X-SIrZYI.js → resource-unavailable-TQcRCpAg.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-CWRb0UCt.js → route-preload-Zc5Z3fNv.js} +2 -2
- package/dist/gateway/static/root/assets/{runtime-tools-api-1DjsPyQ5.js → runtime-tools-api-9o3Wfji1.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BnCtyORj.js → runtime-tools-settings-panel-BGiXeHF5.js} +1 -1
- package/dist/gateway/static/root/assets/{service-recommendation-list-ChSOfHHh.js → service-recommendation-list-BEnNx0u7.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-rvY5aWw8.js → session-api-Bs3r_d2_.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-ChUtTAoG.js +23 -0
- package/dist/gateway/static/root/assets/{sessions-page-DAS2IUGT.js → sessions-page-Bt52kBvJ.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BI4DMz4_.js +1 -0
- package/dist/gateway/static/root/assets/{settings-advanced-section-ZKRIuk7h.js → settings-advanced-section-CURRjsLK.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-mode-store-CtJ8pEfm.js → settings-mode-store-CiRpsdTJ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B3pUce-_.js → settings-page-GtsbT6as.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-header-DuNCn8i-.js → settings-page-header-DBL0_u0Z.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-DeNC8YHJ.js → settings-page-layout-IAvpbz4A.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-Fc3vuz_h.js → setup-status-panel-A6uMpGRy.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-B3hwjVAx.js → share-link-dialog-D1otGSXD.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-D_9oFzGS.js → share-preview-page-L9KYu8M7.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-BoUpXmxq.js → shares-api-D8Q-m46d.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-Drfuvepz.js → shares-settings-Bmfadz8A.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-By2HhJ9O.js → skill-api-uKU4sRiv.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-list-api-TaUCzS8Y.js → skill-list-api-BzKzG-xG.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-CN2fpS1n.js → skill-reload-api-DkUXekcd.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-LzGLique.js → skills-page-BZklXTX9.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-Cuyg8Ml3.js → system-settings-panel-CsvcFoaJ.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-SjZGW1Dx.js +2 -0
- package/dist/gateway/static/root/assets/{task-result-evidence-DDubAU_5.js → task-result-evidence-B8xUiwW3.js} +1 -1
- package/dist/gateway/static/root/assets/{terminal-panel-store-BNs75Wdr.js → terminal-panel-store-DJVC7HqA.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-DB1ZfBUm.js → theme-store-Dlnmgryi.js} +1 -1
- package/dist/gateway/static/root/assets/tool-friendly-title-DcCc6g7o.js +1 -0
- package/dist/gateway/static/root/assets/{tracing-settings-page-TvtX4Goh.js → tracing-settings-page-MvG4SH64.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-COoVEdV9.js → tunnel-api-BB7u79ID.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-activity-store-Dr_MLgYe.js → understanding-activity-store-C4bblRnQ.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-refresh-store-DGmLGEqw.js → understanding-refresh-store-BvCj9-Ue.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-DP6eb6ed.js → usage-page-Cv4Je5XJ.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-itwjDYUb.js → use-autosave-YHxQ-UZg.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-hjIGlI_2.js → use-composer-attachments-vDdxHtUb.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-ClLa0g8D.js → use-file-preview-expanded-Ce2mgYme.js} +2 -2
- package/dist/gateway/static/root/assets/{use-personal-profile-vhWk6tTU.js → use-personal-profile-D2Un8G1L.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-dfXXjA2-.js → use-workspace-tree-BQEiJzK7.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-D8dswPWd.js → user-model-page-DRSsn4EV.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-BIfBySnN.js → voice-api-key-field-DCM69u8Y.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-J4o59ICE.js → voice-config-api-CrULrSKC.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-input-shortcut-events-B1mlpUdC.js → voice-input-shortcut-events-DFMNIyy4.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-transcribe-api-xxaSOOmq.js → voice-transcribe-api-Bbyj0yGR.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DqwT1E5u.js → work-discovery-overlay-CVe9UmFl.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-BzYQmPLT.js → work-discovery-page-CtqkRMN5.js} +1 -1
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-D2Zf3GOG.js → working-directory-picker-modal-CDZ1xh3o.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-Bnx3eS2M.js → workspace-api-tbifz2zY.js} +2 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-4cZ26iaD.js +1 -0
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-D13qHzVr.js → workspace-file-preview-dialog-BubQwQwU.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-open-location-menu-Cou-ig1H.js → workspace-open-location-menu-DZk3MBSa.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DQGPKxHA.js → xopc-cloud-account-card-CIavPUr3.js} +1 -1
- package/dist/gateway/static/root/index.html +81 -81
- package/dist/package.js +1 -1
- package/dist/packages/computer-control-contract/src/index.js +33 -3
- package/dist/src/agent/embedded/run-turn.js +64 -4
- package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
- package/dist/src/agent/tool-manuals/computer.js +6 -0
- package/dist/src/agent/tools/computer-use-tool.js +18 -5
- package/dist/src/agent/tools/phone-use-tool.js +12 -2
- package/dist/src/computer/agent-context.d.ts +21 -0
- package/dist/src/computer/agent-context.js +107 -0
- package/dist/src/computer/broker.d.ts +4 -2
- package/dist/src/computer/broker.js +26 -11
- package/dist/src/computer/diagnostics.d.ts +60 -6
- package/dist/src/computer/diagnostics.js +45 -4
- package/dist/src/computer/errors.d.ts +1 -1
- package/dist/src/computer/errors.js +4 -0
- package/dist/src/computer/evaluation.d.ts +2 -2
- package/dist/src/computer/native-timing.d.ts +15 -0
- package/dist/src/computer/native-timing.js +49 -0
- package/dist/src/computer/program-runtime.d.ts +22 -0
- package/dist/src/computer/program-runtime.js +105 -0
- package/dist/src/computer/runtime.d.ts +36 -2
- package/dist/src/computer/runtime.js +269 -58
- package/dist/src/config/models-json.d.ts +12 -0
- package/dist/src/config/schema.d.ts +18 -0
- package/dist/src/gateway/hono/routes/phone-setup.js +12 -7
- package/dist/src/gateway/hono/routes/phone.js +2 -4
- package/dist/src/gateway/service/config-coordinator.d.ts +6 -0
- package/dist/src/gateway/service.js +4 -4
- package/dist/src/gateway/xopc-cloud-capability-setup.js +9 -1
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/phone/adb-driver.d.ts +15 -1
- package/dist/src/phone/adb-driver.js +104 -41
- package/dist/src/phone/autoglm-protocol.d.ts +36 -0
- package/dist/src/phone/autoglm-protocol.js +88 -0
- package/dist/src/phone/autoglm-upstream-prompt.d.ts +2 -0
- package/dist/src/phone/autoglm-upstream-prompt.js +5 -0
- package/dist/src/phone/autoglm-upstream.LICENSE +201 -0
- package/dist/src/phone/cloud-adb-connection.d.ts +3 -0
- package/dist/src/phone/cloud-adb-connection.js +105 -31
- package/dist/src/phone/cloud-adb.js +18 -6
- package/dist/src/phone/completion-recovery.d.ts +6 -0
- package/dist/src/phone/completion-recovery.js +30 -0
- package/dist/src/phone/contracts.d.ts +24 -0
- package/dist/src/phone/contracts.js +12 -1
- package/dist/src/phone/execution-trace.d.ts +51 -0
- package/dist/src/phone/execution-trace.js +78 -0
- package/dist/src/phone/gui-protocol.d.ts +7 -0
- package/dist/src/phone/gui-protocol.js +302 -0
- package/dist/src/phone/model-adapter.d.ts +10 -2
- package/dist/src/phone/model-adapter.js +136 -62
- package/dist/src/phone/model-response.d.ts +5 -0
- package/dist/src/phone/model-response.js +118 -0
- package/dist/src/phone/runtime.d.ts +4 -0
- package/dist/src/phone/runtime.js +154 -18
- package/dist/src/phone/text-session.d.ts +14 -0
- package/dist/src/phone/text-session.js +39 -0
- package/dist/src/phone/ui-dump-binary.d.ts +1 -1
- package/dist/src/phone/ui-dump-binary.js +1 -1
- package/dist/src/phone/ui-session.d.ts +24 -0
- package/dist/src/phone/ui-session.js +210 -0
- package/dist/src/process/phone-process.d.ts +1 -0
- package/dist/src/process/phone-process.js +11 -1
- package/dist/src/providers/env-keys.js +2 -0
- package/dist/src/providers/index.js +11 -0
- package/dist/src/providers/model-catalog-types.d.ts +1 -1
- package/dist/src/providers/model-supplements.d.ts +1 -1
- package/dist/src/providers/model-supplements.js +6 -3
- package/dist/src/providers/phone-models.d.ts +3 -0
- package/dist/src/providers/phone-models.js +33 -0
- package/dist/src/providers/presentation.js +0 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/voice/platform-catalog.d.ts +1 -1
- package/package.json +2 -1
- package/dist/gateway/static/root/assets/chat-page-CafkCKOj.js +0 -72
- package/dist/gateway/static/root/assets/connected-providers-grid-b46VH4uy.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-1du1hfi5.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-DcsZyYEa.js +0 -1
- package/dist/gateway/static/root/assets/index-BS9mjvSL.js +0 -11
- package/dist/gateway/static/root/assets/index-pT-m6l6b.css +0 -1
- package/dist/gateway/static/root/assets/messages-DaLmc4W1.js +0 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-DticJxxh.js +0 -1
- package/dist/gateway/static/root/assets/page-header-store-D6SzJ9Ch.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-D2rbRfX3.js +0 -23
- package/dist/gateway/static/root/assets/settings-advanced-gate-CYDQybNF.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-6A9337pK.js +0 -2
- package/dist/gateway/static/root/assets/tool-friendly-title-DGmi7rCQ.js +0 -1
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-COUVwj-p.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-TQcz_Vjt.js";import{t as u}from"./messages-DaLmc4W1.js";import{s as d,t as f}from"./popover-select-DD8fmrxH.js";import{t as p}from"./circle-alert-BEjgurr2.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./external-link-DjqjBmc3.js";import{t as g}from"./loader-circle-CifKLtgG.js";import{t as _}from"./session-channel-icon-SsY70Z6t.js";import{i as v,n as y,r as b,t as x}from"./channels-routes-r2g-9DdC.js";import{t as S}from"./rotate-ccw-JM1TBLpp.js";import{t as C}from"./settings-2-D-csvaET.js";import{t as w}from"./stethoscope-DRqTAtjD.js";import{t as T}from"./triangle-alert-2JXFNNKU.js";import{t as E}from"./x-B_N4OPjy.js";import{t as D}from"./cn-0WouolD0.js";import{t as O}from"./button-CnRSIP6m.js";import{t as k}from"./skeleton-BI5TyibZ.js";import{a as A,i as j,n as M,o as N,r as P,s as F,t as I}from"./dist-DfWfZ9iu.js";import{i as L,o as ee}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{i as R}from"./vendor-swr-CdRzEUwF.js";import{t as te}from"./interaction-BdhHBbYa.js";import{n as ne}from"./secret-input-labels-B5Jl5HqK.js";import{a as re}from"./navigation-D62kPsA9.js";import{t as ie}from"./chat-agents-api-BAOWaUJf.js";import{t as ae}from"./refresh-button-bU_0NarN.js";import{t as oe}from"./extension-iframe-host-B4Q1CjvW.js";import{n as se}from"./agent-display-names-Bje7vfSn.js";import{n as ce}from"./settings-loading-skeleton-BTqvr_Fw.js";import{t as le}from"./browser-BLJWD7WI.js";import{t as ue}from"./settings-advanced-section-ZKRIuk7h.js";import{n as de}from"./settings-page-header-DuNCn8i-.js";import"./settings-page-layout-DeNC8YHJ.js";import{t as fe}from"./schema-form-BKeP5G7b.js";var z=n(),B=r();function pe(e){let t=(0,z.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,B.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,B.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,B.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,B.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,B.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,B.jsx)(`li`,{children:h}),t[10]=h,t[11]=g);let _;t[12]!==m||t[13]!==g||t[14]!==u||t[15]!==f?(_=(0,B.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,B.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 V=e(t(),1);async function me(){return(await l(o(`/api/channels/status`))).payload?.channels||[]}function he(){return o(`/api/channels/status`)}var ge=me;function _e(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 ve=e(le(),1);async function H(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 U(e){return e?.type===`poll`&&e.phase===`done`}function W(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function G(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function K(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ye({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>_e(e),[e]),o=(0,V.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,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{c({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let l=(0,V.useCallback)(async(n,i)=>{c(e=>({...e,busy:!0,error:null}));try{let a=await H({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,V.useEffect)(()=>{let t=G(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),ve.toDataURL(t,{width:220,margin:1}).then(e=>{n||c(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,s.payload]),(0,V.useEffect)(()=>{let n=s.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||H({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(c(t=>({...t,payload:e,poll:U(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),U(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=W(s.payload),p=G(s.payload,e.id),_=p?s.generatedQr:K(s.payload),y=a?.[1].result===`qr`&&(s.busy||s.payload?.type===`qr`||s.payload?.type===`poll`),b=s.payload?.type===`form`?s.payload:null,x=s.payload?.type===`diagnostics`?s.payload.checks:null;return(0,B.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,B.jsxs)(`div`,{className:D(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,B.jsxs)(O,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(a[0]),children:[s.busy?(0,B.jsx)(g,{className:`size-4 animate-spin`}):(0,B.jsx)(v,{className:`size-4`}),u]}):null,e.actions?.[`doctor.run`]?(0,B.jsxs)(O,{type:`button`,variant:`secondary`,disabled:s.busy,onClick:()=>void l(`doctor.run`),children:[(0,B.jsx)(w,{className:`size-4`}),d]}):null]})]}),f?(0,B.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:f}):null,s.error?(0,B.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,y?(0,B.jsxs)(`div`,{className:D(`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,B.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,B.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,B.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,B.jsx)(k,{className:`size-48 rounded-md`})})}),(0,B.jsxs)(`div`,{className:D(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[_?(0,B.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,B.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,B.jsx)(k,{className:`h-4 w-48 max-w-full`}),(0,B.jsx)(k,{className:`h-4 w-36 max-w-full`})]}),p?(0,B.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,B.jsx)(h,{className:`size-3.5`})]}):null]})]}):null,s.payload?.type===`poll`&&s.payload.phase===`done`?(0,B.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,B.jsx)(m,{className:s.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,B.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,b?(0,B.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,B.jsx)(fe,{schema:b.schema,values:s.formDraft,onChange:e=>c(t=>({...t,formDraft:e})),disabled:s.busy,labels:o}),(0,B.jsx)(O,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(b.submitAction,s.formDraft),children:n.saveSetup})]}):null,x?(0,B.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,B.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,B.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,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var be=40;function q(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function xe(e,t){return e.find(e=>e.id===q(t))?.agentId?.trim().toLowerCase()??``}function Se(e,t,n){let r=q(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:be,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function J(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 Ce(e,t,n){let r=J(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function we(e,t=!1){return e===`drawer`?D(`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`,L):D(`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)]`,L,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function Te(e){let t=(0,z.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:u,footer:f,wide:p,headerExtra:m}=e,h=p!==void 0&&p,g=n===`drawer`,[_,v]=(0,V.useState)(null),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,B.jsx)(A,{className:D(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),t[0]=y):y=t[0];let b;t[1]!==n||t[2]!==h?(b=we(n,h),t[1]=n,t[2]=h,t[3]=b):b=t[3];let x;t[4]===s?x=t[5]:(x=s?(0,B.jsx)(F,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=x);let S;t[6]===c?S=t[7]:(S=c?(0,B.jsx)(j,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=S);let C;t[8]!==l||t[9]!==o||t[10]!==m||t[11]!==g||t[12]!==a?(C=g?(0,B.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,B.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,B.jsx)(M,{asChild:!0,children:(0,B.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,B.jsx)(E,{className:`size-5`,strokeWidth:1.75})})})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(M,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,className:D(te,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,B.jsx)(E,{className:`size-4`})})}),m]}),t[8]=l,t[9]=o,t[10]=m,t[11]=g,t[12]=a,t[13]=C):C=t[13];let w=g?`p-4`:`p-6`,T;t[14]===w?T=t[15]:(T=D(`min-h-0 flex-1 overflow-y-auto`,w),t[14]=w,t[15]=T);let k;t[16]!==u||t[17]!==T?(k=(0,B.jsx)(`div`,{className:T,children:u}),t[16]=u,t[17]=T,t[18]=k):k=t[18];let L;t[19]!==f||t[20]!==_||t[21]!==x||t[22]!==S||t[23]!==C||t[24]!==k?(L=(0,B.jsxs)(d,{layer:`modal`,portalContainer:_,children:[x,S,C,k,f]}),t[19]=f,t[20]=_,t[21]=x,t[22]=S,t[23]=C,t[24]=k,t[25]=L):L=t[25];let R;t[26]!==L||t[27]!==b?(R=(0,B.jsxs)(N,{children:[y,(0,B.jsx)(P,{ref:v,className:b,onOpenAutoFocus:Ee,children:L})]}),t[26]=L,t[27]=b,t[28]=R):R=t[28];let ne;return t[29]!==i||t[30]!==r||t[31]!==R?(ne=(0,B.jsx)(I,{open:r,onOpenChange:i,children:R}),t[29]=i,t[30]=r,t[31]=R,t[32]=ne):ne=t[32],ne}function Ee(e){return e.preventDefault()}var De=(0,V.memo)(function(e){let t=(0,z.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,B.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,B.jsx)(ae,{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,B.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 Oe(e){let t=(0,z.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,B.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,B.jsx)(O,{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,B.jsx)(O,{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,B.jsx)(O,{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,B.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,B.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 ke(e){return o(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Ae(e){return(await l(ke(e))).payload?.channels??[]}function je(e,t){let n=(0,z.c)(14),r;n[0]!==e||n[1]!==t?(r=e?ke(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Ae(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}=R(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 Me=`channels-status`;function Ne(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Pe(e){let t=t=>e(t.detail);return window.addEventListener(Me,t),()=>window.removeEventListener(Me,t)}function Fe(e,t){let n=(0,z.c)(4),r=t===void 0||t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Pe(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Ie(e){return e?o(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Le(e){return(await l(o(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Re=[`enabled`],ze=`max-w-7xl`,Be=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Ve(){let e=await l(o(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function He(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Ue(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}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 We(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ge(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ke(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 qe(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(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(X(e.configSchema?.properties)?e.configSchema.properties:{}).filter(e=>i.has(e))],o=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Re.includes(e));return Array.from(new Set([...o,...a,...n,...r])).filter(e=>!Re.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Je(e,t){let n={...Z(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(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ye(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ye(n)&&delete t[e];return Object.keys(t).length===0}function Xe(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ye(n),n}function Ze(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Q(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Qe(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(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=Y(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=Y(e),r=_e(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=_e(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,V.useState)(!1),r=(0,V.useMemo)(()=>!e.ui?.icon||t?null:new URL(o(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${He(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,B.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,B.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,B.jsx)(_,{sourceChannel:e.id,className:`size-7`})})}function at(e){let t=(0,z.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=D(`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=D(`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,B.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,B.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,z.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=Y(n),t[0]=n,t[1]=d);let f=d,p,m,h,_,v,y,b;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,y=`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,B.jsx)(it,{entry:n}),t[19]=n,t[20]=d);let g;t[21]===n.label?g=t[22]:(g=(0,B.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=g);let x;t[23]===i?x=t[24]:(x=D(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ke(i)),t[23]=i,t[24]=x);let S;t[25]!==s||t[26]!==i?(S=We(i,s),t[25]=s,t[26]=i,t[27]=S):S=t[27];let C;t[28]!==x||t[29]!==S?(C=(0,B.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]!==g?(w=(0,B.jsxs)(`div`,{className:`min-w-0`,children:[g,C]}),t[31]=C,t[32]=g,t[33]=w):w=t[33];let T;t[34]!==w||t[35]!==d?(T=(0,B.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,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==l||t[42]!==f.enabled||t[43]!==O?(k=(0,B.jsx)(at,{checked:E,disabled:a,label:O,onToggle:l}),t[40]=a,t[41]=l,t[42]=f.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==T||t[46]!==k?(b=(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[T,k]}),t[45]=T,t[46]=k,t[47]=b):b=t[47],m=`button`,h=c,_=`mt-5 min-h-[6.25rem] text-left`,v=f.ready?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,B.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(ct)}):null]}):(0,B.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,B.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,B.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]=_,t[16]=v,t[17]=y,t[18]=b}else p=t[12],m=t[13],h=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==m||t[49]!==h||t[50]!==_||t[51]!==v?(x=(0,B.jsx)(`button`,{type:m,onClick:h,className:_,children:v}),t[48]=m,t[49]=h,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,B.jsx)(g,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=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]!==C||t[63]!==w||t[64]!==S?(T=(0,B.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,B.jsxs)(O,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:p,disabled:S,children:[C,w]})}),t[61]=p,t[62]=C,t[63]=w,t[64]=S,t[65]=T):T=t[65];let E;return t[66]!==T||t[67]!==y||t[68]!==b||t[69]!==x?(E=(0,B.jsxs)(`article`,{className:y,children:[b,x,T]}),t[66]=T,t[67]=y,t[68]=b,t[69]=x,t[70]=E):E=t[70],E}function st(e){return(0,B.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,B.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function lt(e){let t=(0,z.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:s,onRestart:c,onCheck:l,onManageConnection:u}=e,d=n===`running`?m:n===`stopped`||n===`needs_setup`?p:g,f=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,_=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,v=n===`disabled`&&`text-fg-muted`,y=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,b;t[0]!==f||t[1]!==h||t[2]!==_||t[3]!==v||t[4]!==y?(b=D(`mt-0.5 size-5 shrink-0`,f,h,_,v,y),t[0]=f,t[1]=h,t[2]=_,t[3]=v,t[4]=y,t[5]=b):b=t[5];let x;t[6]!==d||t[7]!==b?(x=(0,B.jsx)(d,{className:b}),t[6]=d,t[7]=b,t[8]=x):x=t[8];let C;t[9]===s.connectionStatus?C=t[10]:(C=(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectionStatus}),t[9]=s.connectionStatus,t[10]=C);let w;t[11]!==s||t[12]!==n?(w=Ge(n,s),t[11]=s,t[12]=n,t[13]=w):w=t[13];let T;t[14]===w?T=t[15]:(T=(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:w}),t[14]=w,t[15]=T);let E;t[16]!==T||t[17]!==C?(E=(0,B.jsxs)(`div`,{children:[C,T]}),t[16]=T,t[17]=C,t[18]=E):E=t[18];let k;t[19]!==E||t[20]!==x?(k=(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[x,E]}),t[19]=E,t[20]=x,t[21]=k):k=t[21];let A=i||r,j;t[22]===i?j=t[23]:(j=i?(0,B.jsx)(g,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=j);let M=i?s.checkingConnection:s.checkConnection,N;t[24]!==l||t[25]!==A||t[26]!==j||t[27]!==M?(N=(0,B.jsxs)(O,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:A,onClick:l,children:[j,M]}),t[24]=l,t[25]=A,t[26]=j,t[27]=M,t[28]=N):N=t[28];let P;t[29]!==s.restartChannel||t[30]!==s.restartingChannel||t[31]!==i||t[32]!==c||t[33]!==r||t[34]!==n?(P=n===`stopped`?(0,B.jsxs)(O,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:c,children:[r?(0,B.jsx)(g,{className:`size-4 animate-spin`}):(0,B.jsx)(S,{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]=P):P=t[35];let F;t[36]!==o||t[37]!==s.connectionOptions||t[38]!==s.hideConnectionOptions||t[39]!==i||t[40]!==u||t[41]!==r||t[42]!==a?(F=o?(0,B.jsx)(O,{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]=F):F=t[43];let I;t[44]!==N||t[45]!==P||t[46]!==F?(I=(0,B.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[N,P,F]}),t[44]=N,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==k||t[49]!==I?(L=(0,B.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[k,I]})}),t[48]=k,t[49]=I,t[50]=L):L=t[50],L}function ut(e){let t=(0,z.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=Y(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,B.jsx)(T,{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,B.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,B.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,B.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,B.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,B.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,B.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,B.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(),p=b(e),m=je(l,n),g=m.entries,{data:_,mutate:v,isValidating:S}=R(l?he():null,ge,{revalidateOnFocus:!0}),{data:w,mutate:T}=R(l?`channels-config-map`:null,Ve,{revalidateOnFocus:!1}),E=w?.channels??{},O=w?.bindings??[],{data:k}=R(l?`channel-routing-agents`:null,ie,{revalidateOnFocus:!1}),A=(0,V.useMemo)(()=>g.find(e=>e.id===p),[p,g]),j=A?Ue(A):null,{data:M,mutate:N}=R(l&&j?Ie(j):null,()=>Le(j)),[P,F]=(0,V.useState)(null),[I,L]=(0,V.useState)(!1),[ee,te]=(0,V.useState)(null),[ae,le]=(0,V.useState)(null),[z,me]=(0,V.useState)(!1),[ve,H]=(0,V.useState)(null),[U,W]=(0,V.useState)(null),G=P??M??{},K=r.channelsSettings,be=(0,V.useMemo)(()=>A?.configSchema??{type:`object`,properties:{}},[A?.configSchema]),q=(0,V.useMemo)(()=>Xe(be,Re),[be]),J=(0,V.useMemo)(()=>qe(A),[A]),we=(0,V.useMemo)(()=>A?.id===`telegram`?ft(Je(q,J)):Je(q,J),[A?.id,J,q]),Ee=(0,V.useMemo)(()=>Xe(q,J),[A?.id,J,q]),ke=(0,V.useMemo)(()=>Ze(we),[we]),Ae=A?U??xe(O,A.id):``,Me=(0,V.useMemo)(()=>(k?.items??[]).map(e=>{let t=se(e,r.agentsSettings);return{value:e.id,label:t===e.id?t:`${t} · ${e.id}`}}),[k?.items,r.agentsSettings]),Pe=k?.items.find(e=>e.id===k.defaultId),He=Pe?se(Pe,r.agentsSettings):k?.defaultId??``,Ge=(0,V.useMemo)(()=>({secretInputLabels:ne(K),defaultBooleanLabel:K.schemaBooleanDefault,unsupportedArrayType:K.schemaUnsupportedArrayType,arrayAddPlaceholder:K.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>K.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[K]),X=(0,V.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),Z=_!==void 0,Ye=(0,V.useCallback)(e=>Ce(e,X.get(e.id),Z),[X,Z]),Q=(0,V.useCallback)(async()=>{await Promise.all([m.mutate(),v()])},[m,v]);Fe((0,V.useCallback)(e=>{let t=Ne(e);t&&v(t,!1)},[v]),l);let Qe=(0,V.useMemo)(()=>l?{secondary:(0,B.jsx)(De,{ch:K,refreshing:m.isValidating||S,saveOk:!1,onRefresh:()=>void Q()})}:null,[m.isValidating,K,l,S,Q]);(0,V.useLayoutEffect)(()=>(t?.(Qe),()=>t?.(null)),[Qe,t]);let $e=(0,V.useCallback)(e=>{d(y(e)),F(null),W(null),H(null)},[d]),et=(0,V.useCallback)(()=>{d(x),F(null),W(null),H(null)},[d]),tt=(0,V.useCallback)(async e=>{le(e.id),H(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){H(e instanceof Error?e.message:String(e))}finally{le(null)}},[Q]);(0,V.useEffect)(()=>{W(null),me(!1)},[A?.id]);let nt=(0,V.useCallback)(async()=>{if(!A||!P&&U===null)return!1;let e=Ue(A);L(!0),H(null);try{let t=await a(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({...P?{channels:{[e]:P}}:{},...U===null?{}:{bindings:Se(O,A.id,U)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return P&&await N(P,!1),await T(),await m.mutate(),F(null),W(null),!0}catch(e){return H(e instanceof Error?e.message:String(e)),!1}finally{L(!1)}},[A,U,O,m,P,T,N]),rt=(0,V.useCallback)(async e=>{let t=Y(e),n=Ue(e),r=A?.id===e.id?P:null;if(!t.enabled&&!t.ready&&!r){$e(e.id);return}te(e.id),H(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 m.mutate(),await T(),await v(),A?.id===e.id&&(await N(),F(null))}catch(e){H(e instanceof Error?e.message:String(e))}finally{te(null)}},[A?.id,m,P,T,N,v,$e]),$=A?.ui?.modal,st=$?.placement!==`replace-config`,ct=A?Ye(A):`checking`,dt=A?!Y(A).ready||z:!1;return l?(0,B.jsxs)(de,{gap:`gap-4`,className:ze,padding:Be,children:[m.isLoading?(0,B.jsx)(ce,{sections:2}):m.error?(0,B.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(m.error)}):(0,B.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,B.jsx)(ot,{entry:e,config:E[Ue(e)]?.config,runtime:Ye(e),busy:ee===e.id,restarting:ae===e.id,ch:K,onOpen:()=>$e(e.id),onToggle:()=>void rt(e),onRestart:()=>void tt(e)},e.id))}),ve?(0,B.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:ve}):null,(0,B.jsx)(Te,{presentation:`modal`,open:!!A,onOpenChange:e=>{e||et()},closeAriaLabel:K.close,srTitle:A?.label??K.selectChannel,srDescription:A?.description,wide:!0,footer:A?(0,B.jsx)(Oe,{ch:K,dirty:!!P||U!==null,saving:I,onCancel:et,onDiscard:()=>{F(null),W(null)},onSave:nt}):null,children:A?(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,B.jsx)(it,{entry:A}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:A.label}),(0,B.jsx)(`span`,{className:D(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ke(ct)),children:We(ct,K)})]}),(0,B.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,B.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(A).ready&&_e(A)?.[1].result===`qr`?K.scanLoginHint.replace(`{{channel}}`,A.label):A.description}),A.docsPath?(0,B.jsxs)(`a`,{href:re(n,A.docsPath),target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[K.docs,(0,B.jsx)(h,{className:`size-3.5`})]}):null]})]})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,B.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(A).enabled?K.enabledLabel:K.disabledLabel}),(0,B.jsx)(at,{checked:Y(A).enabled,disabled:ee===A.id,label:K.toggleChannel.replace(`{{channel}}`,A.label),onToggle:()=>void rt(A)})]})]})}),(0,B.jsx)(lt,{runtime:ct,restarting:ae===A.id,checking:S,showConnectionOptions:z,canManageConnection:Y(A).ready&&$?.placement!==`replace-config`,ch:K,onRestart:()=>void tt(A),onCheck:()=>void Q(),onManageConnection:()=>me(e=>!e)}),(0,B.jsx)(ut,{entry:A,ch:K}),A.id===`telegram`?(0,B.jsx)(pe,{language:n}):null,dt&&$?.placement!==`replace-config`?(0,B.jsx)(ye,{entry:A,locale:n,messages:K,compact:!0,onChanged:async()=>{await N(),await Q(),await T()}},A.id):null,$?.entrypoint&&$.placement===`before-config`?(0,B.jsx)(oe,{extensionId:A.extensionId,extensionName:A.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:A.id,entry:A,config:G}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,B.jsx)(oe,{extensionId:A.extensionId,extensionName:A.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:A.id,entry:A,config:G}}):null,st&&ke?(0,B.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:K.basicConfiguration}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:K.basicConfigurationHint})]}),(0,B.jsx)(fe,{schema:we,values:G,onChange:e=>F(e),disabled:I,labels:Ge})]}):null,(0,B.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,B.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,B.jsx)(C,{className:`size-4 text-fg-muted`}),K.messageHandling]}),(0,B.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,B.jsxs)(`div`,{className:`mb-3`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:K.agentRouting}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:K.messageHandlingHint})]}),(0,B.jsx)(f,{value:Ae,options:Me,placeholder:K.agentRoutingSelect,emptyLabel:K.agentRoutingDefault.replace(`{{agent}}`,He||K.agentRoutingSelect),ariaLabel:K.agentRouting,disabled:I||!k,onChange:e=>W(e)})]})]}),st&&Ze(Ee)?(0,B.jsx)(ue,{title:K.advancedConfiguration,summary:K.messageHandlingHint,children:(0,B.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,B.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,B.jsx)(C,{className:`size-4 text-fg-muted`}),K.advancedConfiguration]}),(0,B.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,B.jsx)(fe,{schema:Ee,values:G,onChange:e=>F(e),disabled:I,labels:Ge})})]})}):null,ve?(0,B.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ve}):null]}):null})]}):(0,B.jsx)(de,{gap:`gap-3`,className:ze,padding:Be,children:(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:K.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-Br7IfbXK.js";import{t as u}from"./messages-ByFlEbsu.js";import{s as d,t as f}from"./popover-select-DD8fmrxH.js";import{t as p}from"./circle-alert-BEjgurr2.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./external-link-DjqjBmc3.js";import{t as g}from"./loader-circle-CifKLtgG.js";import{t as _}from"./session-channel-icon-SsY70Z6t.js";import{i as v,n as y,r as b,t as x}from"./channels-routes-r2g-9DdC.js";import{t as S}from"./rotate-ccw-JM1TBLpp.js";import{t as C}from"./settings-2-D-csvaET.js";import{t as w}from"./stethoscope-DRqTAtjD.js";import{t as T}from"./triangle-alert-2JXFNNKU.js";import{t as E}from"./x-B_N4OPjy.js";import{t as D}from"./cn-0WouolD0.js";import{t as O}from"./button-CnRSIP6m.js";import{t as k}from"./skeleton-BI5TyibZ.js";import{a as A,i as j,n as M,o as N,r as P,s as F,t as I}from"./dist-DfWfZ9iu.js";import{i as L,o as ee}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{i as R}from"./vendor-swr-CdRzEUwF.js";import{t as te}from"./interaction-BdhHBbYa.js";import{n as ne}from"./secret-input-labels-B5Jl5HqK.js";import{a as re}from"./navigation-D62kPsA9.js";import{t as ie}from"./chat-agents-api-D8YS5amE.js";import{t as ae}from"./refresh-button-bU_0NarN.js";import{t as oe}from"./extension-iframe-host-Cqg1K70e.js";import{n as se}from"./agent-display-names-Bje7vfSn.js";import{n as ce}from"./settings-loading-skeleton-BTqvr_Fw.js";import{t as le}from"./browser-BLJWD7WI.js";import{t as ue}from"./settings-advanced-section-CURRjsLK.js";import{n as de}from"./settings-page-header-DBL0_u0Z.js";import"./settings-page-layout-IAvpbz4A.js";import{t as fe}from"./schema-form-BKeP5G7b.js";var z=n(),B=r();function pe(e){let t=(0,z.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,B.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,B.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,B.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,B.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,B.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,B.jsx)(`li`,{children:h}),t[10]=h,t[11]=g);let _;t[12]!==m||t[13]!==g||t[14]!==u||t[15]!==f?(_=(0,B.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,B.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 V=e(t(),1);async function me(){return(await l(o(`/api/channels/status`))).payload?.channels||[]}function he(){return o(`/api/channels/status`)}var ge=me;function _e(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 ve=e(le(),1);async function H(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 U(e){return e?.type===`poll`&&e.phase===`done`}function W(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function G(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function K(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ye({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>_e(e),[e]),o=(0,V.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,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{c({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let l=(0,V.useCallback)(async(n,i)=>{c(e=>({...e,busy:!0,error:null}));try{let a=await H({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,V.useEffect)(()=>{let t=G(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),ve.toDataURL(t,{width:220,margin:1}).then(e=>{n||c(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,s.payload]),(0,V.useEffect)(()=>{let n=s.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||H({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(c(t=>({...t,payload:e,poll:U(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),U(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=W(s.payload),p=G(s.payload,e.id),_=p?s.generatedQr:K(s.payload),y=a?.[1].result===`qr`&&(s.busy||s.payload?.type===`qr`||s.payload?.type===`poll`),b=s.payload?.type===`form`?s.payload:null,x=s.payload?.type===`diagnostics`?s.payload.checks:null;return(0,B.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,B.jsxs)(`div`,{className:D(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,B.jsxs)(O,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(a[0]),children:[s.busy?(0,B.jsx)(g,{className:`size-4 animate-spin`}):(0,B.jsx)(v,{className:`size-4`}),u]}):null,e.actions?.[`doctor.run`]?(0,B.jsxs)(O,{type:`button`,variant:`secondary`,disabled:s.busy,onClick:()=>void l(`doctor.run`),children:[(0,B.jsx)(w,{className:`size-4`}),d]}):null]})]}),f?(0,B.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:f}):null,s.error?(0,B.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,y?(0,B.jsxs)(`div`,{className:D(`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,B.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,B.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,B.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,B.jsx)(k,{className:`size-48 rounded-md`})})}),(0,B.jsxs)(`div`,{className:D(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[_?(0,B.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,B.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,B.jsx)(k,{className:`h-4 w-48 max-w-full`}),(0,B.jsx)(k,{className:`h-4 w-36 max-w-full`})]}),p?(0,B.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,B.jsx)(h,{className:`size-3.5`})]}):null]})]}):null,s.payload?.type===`poll`&&s.payload.phase===`done`?(0,B.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,B.jsx)(m,{className:s.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,B.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,b?(0,B.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,B.jsx)(fe,{schema:b.schema,values:s.formDraft,onChange:e=>c(t=>({...t,formDraft:e})),disabled:s.busy,labels:o}),(0,B.jsx)(O,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(b.submitAction,s.formDraft),children:n.saveSetup})]}):null,x?(0,B.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,B.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,B.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,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var be=40;function q(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function xe(e,t){return e.find(e=>e.id===q(t))?.agentId?.trim().toLowerCase()??``}function Se(e,t,n){let r=q(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:be,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function J(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 Ce(e,t,n){let r=J(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function we(e,t=!1){return e===`drawer`?D(`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`,L):D(`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)]`,L,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function Te(e){let t=(0,z.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:u,footer:f,wide:p,headerExtra:m}=e,h=p!==void 0&&p,g=n===`drawer`,[_,v]=(0,V.useState)(null),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,B.jsx)(A,{className:D(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),t[0]=y):y=t[0];let b;t[1]!==n||t[2]!==h?(b=we(n,h),t[1]=n,t[2]=h,t[3]=b):b=t[3];let x;t[4]===s?x=t[5]:(x=s?(0,B.jsx)(F,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=x);let S;t[6]===c?S=t[7]:(S=c?(0,B.jsx)(j,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=S);let C;t[8]!==l||t[9]!==o||t[10]!==m||t[11]!==g||t[12]!==a?(C=g?(0,B.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,B.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,B.jsx)(M,{asChild:!0,children:(0,B.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,B.jsx)(E,{className:`size-5`,strokeWidth:1.75})})})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(M,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,className:D(te,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,B.jsx)(E,{className:`size-4`})})}),m]}),t[8]=l,t[9]=o,t[10]=m,t[11]=g,t[12]=a,t[13]=C):C=t[13];let w=g?`p-4`:`p-6`,T;t[14]===w?T=t[15]:(T=D(`min-h-0 flex-1 overflow-y-auto`,w),t[14]=w,t[15]=T);let k;t[16]!==u||t[17]!==T?(k=(0,B.jsx)(`div`,{className:T,children:u}),t[16]=u,t[17]=T,t[18]=k):k=t[18];let L;t[19]!==f||t[20]!==_||t[21]!==x||t[22]!==S||t[23]!==C||t[24]!==k?(L=(0,B.jsxs)(d,{layer:`modal`,portalContainer:_,children:[x,S,C,k,f]}),t[19]=f,t[20]=_,t[21]=x,t[22]=S,t[23]=C,t[24]=k,t[25]=L):L=t[25];let R;t[26]!==L||t[27]!==b?(R=(0,B.jsxs)(N,{children:[y,(0,B.jsx)(P,{ref:v,className:b,onOpenAutoFocus:Ee,children:L})]}),t[26]=L,t[27]=b,t[28]=R):R=t[28];let ne;return t[29]!==i||t[30]!==r||t[31]!==R?(ne=(0,B.jsx)(I,{open:r,onOpenChange:i,children:R}),t[29]=i,t[30]=r,t[31]=R,t[32]=ne):ne=t[32],ne}function Ee(e){return e.preventDefault()}var De=(0,V.memo)(function(e){let t=(0,z.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,B.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,B.jsx)(ae,{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,B.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 Oe(e){let t=(0,z.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,B.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,B.jsx)(O,{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,B.jsx)(O,{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,B.jsx)(O,{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,B.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,B.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 ke(e){return o(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Ae(e){return(await l(ke(e))).payload?.channels??[]}function je(e,t){let n=(0,z.c)(14),r;n[0]!==e||n[1]!==t?(r=e?ke(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Ae(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}=R(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 Me=`channels-status`;function Ne(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Pe(e){let t=t=>e(t.detail);return window.addEventListener(Me,t),()=>window.removeEventListener(Me,t)}function Fe(e,t){let n=(0,z.c)(4),r=t===void 0||t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Pe(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Ie(e){return e?o(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Le(e){return(await l(o(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Re=[`enabled`],ze=`max-w-7xl`,Be=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Ve(){let e=await l(o(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function He(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Ue(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}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 We(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ge(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ke(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 qe(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(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(X(e.configSchema?.properties)?e.configSchema.properties:{}).filter(e=>i.has(e))],o=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Re.includes(e));return Array.from(new Set([...o,...a,...n,...r])).filter(e=>!Re.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Je(e,t){let n={...Z(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(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ye(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ye(n)&&delete t[e];return Object.keys(t).length===0}function Xe(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ye(n),n}function Ze(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Q(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Qe(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(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=Y(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=Y(e),r=_e(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=_e(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,V.useState)(!1),r=(0,V.useMemo)(()=>!e.ui?.icon||t?null:new URL(o(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${He(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,B.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,B.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,B.jsx)(_,{sourceChannel:e.id,className:`size-7`})})}function at(e){let t=(0,z.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=D(`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=D(`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,B.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,B.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,z.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=Y(n),t[0]=n,t[1]=d);let f=d,p,m,h,_,v,y,b;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,y=`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,B.jsx)(it,{entry:n}),t[19]=n,t[20]=d);let g;t[21]===n.label?g=t[22]:(g=(0,B.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=g);let x;t[23]===i?x=t[24]:(x=D(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ke(i)),t[23]=i,t[24]=x);let S;t[25]!==s||t[26]!==i?(S=We(i,s),t[25]=s,t[26]=i,t[27]=S):S=t[27];let C;t[28]!==x||t[29]!==S?(C=(0,B.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]!==g?(w=(0,B.jsxs)(`div`,{className:`min-w-0`,children:[g,C]}),t[31]=C,t[32]=g,t[33]=w):w=t[33];let T;t[34]!==w||t[35]!==d?(T=(0,B.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,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==l||t[42]!==f.enabled||t[43]!==O?(k=(0,B.jsx)(at,{checked:E,disabled:a,label:O,onToggle:l}),t[40]=a,t[41]=l,t[42]=f.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==T||t[46]!==k?(b=(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[T,k]}),t[45]=T,t[46]=k,t[47]=b):b=t[47],m=`button`,h=c,_=`mt-5 min-h-[6.25rem] text-left`,v=f.ready?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,B.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(ct)}):null]}):(0,B.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,B.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,B.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,B.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]=_,t[16]=v,t[17]=y,t[18]=b}else p=t[12],m=t[13],h=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==m||t[49]!==h||t[50]!==_||t[51]!==v?(x=(0,B.jsx)(`button`,{type:m,onClick:h,className:_,children:v}),t[48]=m,t[49]=h,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,B.jsx)(g,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=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]!==C||t[63]!==w||t[64]!==S?(T=(0,B.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,B.jsxs)(O,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:p,disabled:S,children:[C,w]})}),t[61]=p,t[62]=C,t[63]=w,t[64]=S,t[65]=T):T=t[65];let E;return t[66]!==T||t[67]!==y||t[68]!==b||t[69]!==x?(E=(0,B.jsxs)(`article`,{className:y,children:[b,x,T]}),t[66]=T,t[67]=y,t[68]=b,t[69]=x,t[70]=E):E=t[70],E}function st(e){return(0,B.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,B.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function lt(e){let t=(0,z.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:s,onRestart:c,onCheck:l,onManageConnection:u}=e,d=n===`running`?m:n===`stopped`||n===`needs_setup`?p:g,f=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,_=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,v=n===`disabled`&&`text-fg-muted`,y=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,b;t[0]!==f||t[1]!==h||t[2]!==_||t[3]!==v||t[4]!==y?(b=D(`mt-0.5 size-5 shrink-0`,f,h,_,v,y),t[0]=f,t[1]=h,t[2]=_,t[3]=v,t[4]=y,t[5]=b):b=t[5];let x;t[6]!==d||t[7]!==b?(x=(0,B.jsx)(d,{className:b}),t[6]=d,t[7]=b,t[8]=x):x=t[8];let C;t[9]===s.connectionStatus?C=t[10]:(C=(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectionStatus}),t[9]=s.connectionStatus,t[10]=C);let w;t[11]!==s||t[12]!==n?(w=Ge(n,s),t[11]=s,t[12]=n,t[13]=w):w=t[13];let T;t[14]===w?T=t[15]:(T=(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:w}),t[14]=w,t[15]=T);let E;t[16]!==T||t[17]!==C?(E=(0,B.jsxs)(`div`,{children:[C,T]}),t[16]=T,t[17]=C,t[18]=E):E=t[18];let k;t[19]!==E||t[20]!==x?(k=(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[x,E]}),t[19]=E,t[20]=x,t[21]=k):k=t[21];let A=i||r,j;t[22]===i?j=t[23]:(j=i?(0,B.jsx)(g,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=j);let M=i?s.checkingConnection:s.checkConnection,N;t[24]!==l||t[25]!==A||t[26]!==j||t[27]!==M?(N=(0,B.jsxs)(O,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:A,onClick:l,children:[j,M]}),t[24]=l,t[25]=A,t[26]=j,t[27]=M,t[28]=N):N=t[28];let P;t[29]!==s.restartChannel||t[30]!==s.restartingChannel||t[31]!==i||t[32]!==c||t[33]!==r||t[34]!==n?(P=n===`stopped`?(0,B.jsxs)(O,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:c,children:[r?(0,B.jsx)(g,{className:`size-4 animate-spin`}):(0,B.jsx)(S,{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]=P):P=t[35];let F;t[36]!==o||t[37]!==s.connectionOptions||t[38]!==s.hideConnectionOptions||t[39]!==i||t[40]!==u||t[41]!==r||t[42]!==a?(F=o?(0,B.jsx)(O,{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]=F):F=t[43];let I;t[44]!==N||t[45]!==P||t[46]!==F?(I=(0,B.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[N,P,F]}),t[44]=N,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==k||t[49]!==I?(L=(0,B.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[k,I]})}),t[48]=k,t[49]=I,t[50]=L):L=t[50],L}function ut(e){let t=(0,z.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=Y(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,B.jsx)(T,{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,B.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,B.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,B.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,B.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,B.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,B.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,B.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(),p=b(e),m=je(l,n),g=m.entries,{data:_,mutate:v,isValidating:S}=R(l?he():null,ge,{revalidateOnFocus:!0}),{data:w,mutate:T}=R(l?`channels-config-map`:null,Ve,{revalidateOnFocus:!1}),E=w?.channels??{},O=w?.bindings??[],{data:k}=R(l?`channel-routing-agents`:null,ie,{revalidateOnFocus:!1}),A=(0,V.useMemo)(()=>g.find(e=>e.id===p),[p,g]),j=A?Ue(A):null,{data:M,mutate:N}=R(l&&j?Ie(j):null,()=>Le(j)),[P,F]=(0,V.useState)(null),[I,L]=(0,V.useState)(!1),[ee,te]=(0,V.useState)(null),[ae,le]=(0,V.useState)(null),[z,me]=(0,V.useState)(!1),[ve,H]=(0,V.useState)(null),[U,W]=(0,V.useState)(null),G=P??M??{},K=r.channelsSettings,be=(0,V.useMemo)(()=>A?.configSchema??{type:`object`,properties:{}},[A?.configSchema]),q=(0,V.useMemo)(()=>Xe(be,Re),[be]),J=(0,V.useMemo)(()=>qe(A),[A]),we=(0,V.useMemo)(()=>A?.id===`telegram`?ft(Je(q,J)):Je(q,J),[A?.id,J,q]),Ee=(0,V.useMemo)(()=>Xe(q,J),[A?.id,J,q]),ke=(0,V.useMemo)(()=>Ze(we),[we]),Ae=A?U??xe(O,A.id):``,Me=(0,V.useMemo)(()=>(k?.items??[]).map(e=>{let t=se(e,r.agentsSettings);return{value:e.id,label:t===e.id?t:`${t} · ${e.id}`}}),[k?.items,r.agentsSettings]),Pe=k?.items.find(e=>e.id===k.defaultId),He=Pe?se(Pe,r.agentsSettings):k?.defaultId??``,Ge=(0,V.useMemo)(()=>({secretInputLabels:ne(K),defaultBooleanLabel:K.schemaBooleanDefault,unsupportedArrayType:K.schemaUnsupportedArrayType,arrayAddPlaceholder:K.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>K.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[K]),X=(0,V.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),Z=_!==void 0,Ye=(0,V.useCallback)(e=>Ce(e,X.get(e.id),Z),[X,Z]),Q=(0,V.useCallback)(async()=>{await Promise.all([m.mutate(),v()])},[m,v]);Fe((0,V.useCallback)(e=>{let t=Ne(e);t&&v(t,!1)},[v]),l);let Qe=(0,V.useMemo)(()=>l?{secondary:(0,B.jsx)(De,{ch:K,refreshing:m.isValidating||S,saveOk:!1,onRefresh:()=>void Q()})}:null,[m.isValidating,K,l,S,Q]);(0,V.useLayoutEffect)(()=>(t?.(Qe),()=>t?.(null)),[Qe,t]);let $e=(0,V.useCallback)(e=>{d(y(e)),F(null),W(null),H(null)},[d]),et=(0,V.useCallback)(()=>{d(x),F(null),W(null),H(null)},[d]),tt=(0,V.useCallback)(async e=>{le(e.id),H(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){H(e instanceof Error?e.message:String(e))}finally{le(null)}},[Q]);(0,V.useEffect)(()=>{W(null),me(!1)},[A?.id]);let nt=(0,V.useCallback)(async()=>{if(!A||!P&&U===null)return!1;let e=Ue(A);L(!0),H(null);try{let t=await a(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({...P?{channels:{[e]:P}}:{},...U===null?{}:{bindings:Se(O,A.id,U)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return P&&await N(P,!1),await T(),await m.mutate(),F(null),W(null),!0}catch(e){return H(e instanceof Error?e.message:String(e)),!1}finally{L(!1)}},[A,U,O,m,P,T,N]),rt=(0,V.useCallback)(async e=>{let t=Y(e),n=Ue(e),r=A?.id===e.id?P:null;if(!t.enabled&&!t.ready&&!r){$e(e.id);return}te(e.id),H(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 m.mutate(),await T(),await v(),A?.id===e.id&&(await N(),F(null))}catch(e){H(e instanceof Error?e.message:String(e))}finally{te(null)}},[A?.id,m,P,T,N,v,$e]),$=A?.ui?.modal,st=$?.placement!==`replace-config`,ct=A?Ye(A):`checking`,dt=A?!Y(A).ready||z:!1;return l?(0,B.jsxs)(de,{gap:`gap-4`,className:ze,padding:Be,children:[m.isLoading?(0,B.jsx)(ce,{sections:2}):m.error?(0,B.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(m.error)}):(0,B.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,B.jsx)(ot,{entry:e,config:E[Ue(e)]?.config,runtime:Ye(e),busy:ee===e.id,restarting:ae===e.id,ch:K,onOpen:()=>$e(e.id),onToggle:()=>void rt(e),onRestart:()=>void tt(e)},e.id))}),ve?(0,B.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:ve}):null,(0,B.jsx)(Te,{presentation:`modal`,open:!!A,onOpenChange:e=>{e||et()},closeAriaLabel:K.close,srTitle:A?.label??K.selectChannel,srDescription:A?.description,wide:!0,footer:A?(0,B.jsx)(Oe,{ch:K,dirty:!!P||U!==null,saving:I,onCancel:et,onDiscard:()=>{F(null),W(null)},onSave:nt}):null,children:A?(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,B.jsx)(it,{entry:A}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:A.label}),(0,B.jsx)(`span`,{className:D(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ke(ct)),children:We(ct,K)})]}),(0,B.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,B.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(A).ready&&_e(A)?.[1].result===`qr`?K.scanLoginHint.replace(`{{channel}}`,A.label):A.description}),A.docsPath?(0,B.jsxs)(`a`,{href:re(n,A.docsPath),target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[K.docs,(0,B.jsx)(h,{className:`size-3.5`})]}):null]})]})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,B.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(A).enabled?K.enabledLabel:K.disabledLabel}),(0,B.jsx)(at,{checked:Y(A).enabled,disabled:ee===A.id,label:K.toggleChannel.replace(`{{channel}}`,A.label),onToggle:()=>void rt(A)})]})]})}),(0,B.jsx)(lt,{runtime:ct,restarting:ae===A.id,checking:S,showConnectionOptions:z,canManageConnection:Y(A).ready&&$?.placement!==`replace-config`,ch:K,onRestart:()=>void tt(A),onCheck:()=>void Q(),onManageConnection:()=>me(e=>!e)}),(0,B.jsx)(ut,{entry:A,ch:K}),A.id===`telegram`?(0,B.jsx)(pe,{language:n}):null,dt&&$?.placement!==`replace-config`?(0,B.jsx)(ye,{entry:A,locale:n,messages:K,compact:!0,onChanged:async()=>{await N(),await Q(),await T()}},A.id):null,$?.entrypoint&&$.placement===`before-config`?(0,B.jsx)(oe,{extensionId:A.extensionId,extensionName:A.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:A.id,entry:A,config:G}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,B.jsx)(oe,{extensionId:A.extensionId,extensionName:A.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:A.id,entry:A,config:G}}):null,st&&ke?(0,B.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,B.jsxs)(`div`,{className:`mb-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:K.basicConfiguration}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:K.basicConfigurationHint})]}),(0,B.jsx)(fe,{schema:we,values:G,onChange:e=>F(e),disabled:I,labels:Ge})]}):null,(0,B.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,B.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,B.jsx)(C,{className:`size-4 text-fg-muted`}),K.messageHandling]}),(0,B.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,B.jsxs)(`div`,{className:`mb-3`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:K.agentRouting}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:K.messageHandlingHint})]}),(0,B.jsx)(f,{value:Ae,options:Me,placeholder:K.agentRoutingSelect,emptyLabel:K.agentRoutingDefault.replace(`{{agent}}`,He||K.agentRoutingSelect),ariaLabel:K.agentRouting,disabled:I||!k,onChange:e=>W(e)})]})]}),st&&Ze(Ee)?(0,B.jsx)(ue,{title:K.advancedConfiguration,summary:K.messageHandlingHint,children:(0,B.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,B.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,B.jsx)(C,{className:`size-4 text-fg-muted`}),K.advancedConfiguration]}),(0,B.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,B.jsx)(fe,{schema:Ee,values:G,onChange:e=>F(e),disabled:I,labels:Ge})})]})}):null,ve?(0,B.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ve}):null]}):null})]}):(0,B.jsx)(de,{gap:`gap-3`,className:ze,padding:Be,children:(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:K.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-BAOWaUJf.js → chat-agents-api-D8YS5amE.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-Br7IfbXK.js";import{t as n}from"./gateway-config-swr-BOCt_zOo.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-TQcz_Vjt.js";import{t as o}from"./messages-DaLmc4W1.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./download-Dk-ZjtO6.js";import{K as u,U as d,W as f,a as p,i as m,o as h,s as g}from"./markdown-view-D4nII6Zv.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./skeleton-BI5TyibZ.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as T}from"./dist-DfWfZ9iu.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:_,copy:v}){let y=z((0,O.useId)()),b=(0,O.useRef)(null),[x,S]=(0,O.useState)(null),[C,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&&p(e))&&r&&!n,B=`${R?`mermaid`:`code`}:${t}:${e}`;(0,O.useEffect)(()=>{if(n||!y.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})=>d(t(e))):i(async()=>{let{highlightCode:e}=await import(`./highlight-code-BH65IIbJ.js`);return{highlightCode:e}},__vite__mapDeps([2,3,1])).then(({highlightCode:n})=>f.sanitize(n(e,t),{ALLOWED_TAGS:[`span`],ALLOWED_ATTR:[`class`]})):Promise.resolve(a)).then(e=>{r&&(V.set(B,e),S({key:B,value:e}))}).catch(()=>{r&&j(!0)}),()=>{r=!1}},[B,e,R,n,t,y.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=b.current,t=e?.querySelector(`svg`);return e&&t?h(t,e):null},U=x?.key===B?x.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:y.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:b,dangerouslySetInnerHTML:{__html:U}}),_&&(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)(u,{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&&g(e,`diagram.png`).catch(()=>{F.current&&j(!0)})},children:(0,k.jsx)(l,{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:()=>{y.activate(),N(e=>e+1)},children:(0,k.jsx)(u,{})}),v&&(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)(s,{"aria-hidden":`true`}):(0,k.jsx)(c,{"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)(m,{preview:C,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),[u,d]=(0,O.useState)(!1),f=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":f.loading,children:(0,k.jsx)(v,{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(),d(!1)}catch{d(!0)}},"aria-label":f.download,children:[(0,k.jsx)(l,{className:`size-4`,"aria-hidden":!0}),`PNG`]}),u&&(0,k.jsx)(`p`,{role:`status`,className:`absolute bottom-10 right-2 bg-surface-overlay p-2 text-xs text-fg-muted`,children:f.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,s]=(0,O.useState)(!1),[c,l]=(0,O.useState)(!1),[d,f]=(0,O.useState)(!1),[p,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(!1),[D,A]=(0,O.useState)(!1),[j,M]=(0,O.useState)(!1),N=(0,O.useCallback)(()=>l(!0),[]),P=(0,O.useCallback)(()=>m(!0),[]),F=a(e=>e.language),I=o(F).chat.chart,L=i||c;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:()=>s(!L),disabled:c,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:()=>{m(!1),f(!0)},children:(0,k.jsx)(u,{className:`size-4`,"aria-hidden":!0})})]}),D&&(0,k.jsx)(`p`,{role:`status`,className:`px-3 text-xs text-fg-muted`,children:I.copyFailed}),c&&(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(),l(!1),s(!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&&!d?(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)(v,{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=>g(e.currentTarget.open),children:[(0,k.jsx)(`summary`,{className:`cursor-pointer`,children:I.data}),h&&(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)(T,{open:d,onOpenChange:f,children:(0,k.jsxs)(S,{children:[(0,k.jsx)(y,{className:`fixed inset-0 z-[90] bg-scrim/90 backdrop-blur-sm`}),(0,k.jsxs)(C,{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)(w,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.title}),(0,k.jsx)(x,{className:$,"aria-label":I.close,children:(0,k.jsx)(_,{className:`size-4`,"aria-hidden":!0})})]}),(0,k.jsx)(b,{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:p?(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)(v,{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-Br7IfbXK.js";import{t as o}from"./messages-ByFlEbsu.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./download-Dk-ZjtO6.js";import{K as u,U as d,W as f,a as p,i as m,o as h,s as g}from"./markdown-view-DrVAMlwc.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./skeleton-BI5TyibZ.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as T}from"./dist-DfWfZ9iu.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:_,copy:v}){let y=z((0,O.useId)()),b=(0,O.useRef)(null),[x,S]=(0,O.useState)(null),[C,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&&p(e))&&r&&!n,B=`${R?`mermaid`:`code`}:${t}:${e}`;(0,O.useEffect)(()=>{if(n||!y.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})=>d(t(e))):i(async()=>{let{highlightCode:e}=await import(`./highlight-code-BH65IIbJ.js`);return{highlightCode:e}},__vite__mapDeps([2,3,1])).then(({highlightCode:n})=>f.sanitize(n(e,t),{ALLOWED_TAGS:[`span`],ALLOWED_ATTR:[`class`]})):Promise.resolve(a)).then(e=>{r&&(V.set(B,e),S({key:B,value:e}))}).catch(()=>{r&&j(!0)}),()=>{r=!1}},[B,e,R,n,t,y.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=b.current,t=e?.querySelector(`svg`);return e&&t?h(t,e):null},U=x?.key===B?x.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:y.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:b,dangerouslySetInnerHTML:{__html:U}}),_&&(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)(u,{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&&g(e,`diagram.png`).catch(()=>{F.current&&j(!0)})},children:(0,k.jsx)(l,{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:()=>{y.activate(),N(e=>e+1)},children:(0,k.jsx)(u,{})}),v&&(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)(s,{"aria-hidden":`true`}):(0,k.jsx)(c,{"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)(m,{preview:C,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),[u,d]=(0,O.useState)(!1),f=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":f.loading,children:(0,k.jsx)(v,{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(),d(!1)}catch{d(!0)}},"aria-label":f.download,children:[(0,k.jsx)(l,{className:`size-4`,"aria-hidden":!0}),`PNG`]}),u&&(0,k.jsx)(`p`,{role:`status`,className:`absolute bottom-10 right-2 bg-surface-overlay p-2 text-xs text-fg-muted`,children:f.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,s]=(0,O.useState)(!1),[c,l]=(0,O.useState)(!1),[d,f]=(0,O.useState)(!1),[p,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(!1),[D,A]=(0,O.useState)(!1),[j,M]=(0,O.useState)(!1),N=(0,O.useCallback)(()=>l(!0),[]),P=(0,O.useCallback)(()=>m(!0),[]),F=a(e=>e.language),I=o(F).chat.chart,L=i||c;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:()=>s(!L),disabled:c,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:()=>{m(!1),f(!0)},children:(0,k.jsx)(u,{className:`size-4`,"aria-hidden":!0})})]}),D&&(0,k.jsx)(`p`,{role:`status`,className:`px-3 text-xs text-fg-muted`,children:I.copyFailed}),c&&(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(),l(!1),s(!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&&!d?(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)(v,{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=>g(e.currentTarget.open),children:[(0,k.jsx)(`summary`,{className:`cursor-pointer`,children:I.data}),h&&(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)(T,{open:d,onOpenChange:f,children:(0,k.jsxs)(S,{children:[(0,k.jsx)(y,{className:`fixed inset-0 z-[90] bg-scrim/90 backdrop-blur-sm`}),(0,k.jsxs)(C,{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)(w,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.title}),(0,k.jsx)(x,{className:$,"aria-label":I.close,children:(0,k.jsx)(_,{className:`size-4`,"aria-hidden":!0})})]}),(0,k.jsx)(b,{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:p?(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)(v,{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};
|