@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.
Files changed (252) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-AI081rxe.js → activity-store-D_DXNHba.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DupnTbL7.js → agent-avatar-dicebear-CjaQxFQt.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-display-CmEj6Uqy.js → agent-avatar-display-6Z4m31Fz.js} +2 -2
  6. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-IEV5yKuu.js → agent-defaults-settings-panel-Dne9A10p.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agent-plugin-dialog-D_njOuFA.js → agent-plugin-dialog-BoHL-b1o.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agents-B_yg9nA3.js → agents-CIiIlVBp.js} +3 -3
  9. package/dist/gateway/static/root/assets/{agents-admin-api-CUZUolwG.js → agents-admin-api-u5c3GREg.js} +1 -1
  10. package/dist/gateway/static/root/assets/{api-bpQ7yR10.js → api-C3Tp9MkF.js} +1 -1
  11. package/dist/gateway/static/root/assets/{api-CWWEVThO.js → api-CRT9ZyH0.js} +1 -1
  12. package/dist/gateway/static/root/assets/{app-management-settings-panel-C0_hxwgg.js → app-management-settings-panel-C8yc3yHG.js} +1 -1
  13. package/dist/gateway/static/root/assets/{appearance-settings-CLh-qnCC.js → appearance-settings-BELgtR3O.js} +1 -1
  14. package/dist/gateway/static/root/assets/{apps-page-Bjtm3Rgi.js → apps-page-vgS1CHDj.js} +1 -1
  15. package/dist/gateway/static/root/assets/{archive-plugin-dGnstkhB.js → archive-plugin-BCQnOkV8.js} +1 -1
  16. package/dist/gateway/static/root/assets/{automation-api-MB2xCoFF.js → automation-api-hRsGx-qe.js} +1 -1
  17. package/dist/gateway/static/root/assets/{automation-result-state-DJQflY78.js → automation-result-state-CMfVTv_i.js} +1 -1
  18. package/dist/gateway/static/root/assets/{automation-task-card-DXgBxVE2.js → automation-task-card-MnzgyTVA.js} +1 -1
  19. package/dist/gateway/static/root/assets/{automations-page-D3O7M2FH.js → automations-page-CdIPdwF0.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automations-workspace-Dk3FVWoX.js → automations-workspace-C3xZLafX.js} +2 -2
  21. package/dist/gateway/static/root/assets/{binary-plugins-BrVJXmYf.js → binary-plugins-CIB5cbvQ.js} +1 -1
  22. package/dist/gateway/static/root/assets/{block-editor-Dok4sfT3.js → block-editor-BQtTLe6Q.js} +1 -1
  23. package/dist/gateway/static/root/assets/{browser-automation-inputs-PJbT3CxW.js → browser-automation-inputs-DeraGZ1y.js} +1 -1
  24. package/dist/gateway/static/root/assets/{browser-automations-page-kkpX1Q7K.js → browser-automations-page-SpPzRNqU.js} +1 -1
  25. package/dist/gateway/static/root/assets/{browser-control-api-Bg4wnkeA.js → browser-control-api-CbbPvhHR.js} +1 -1
  26. package/dist/gateway/static/root/assets/{browser-settings-page-BrgX_Yb2.js → browser-settings-page-BD1uF_Nb.js} +1 -1
  27. package/dist/gateway/static/root/assets/{capabilities-BMaJizw4.js → capabilities-BGE6hiUE.js} +1 -1
  28. package/dist/gateway/static/root/assets/{capabilities-Cs6Jt5Gl.js → capabilities-DLMuj21P.js} +1 -1
  29. package/dist/gateway/static/root/assets/{capabilities-page-D5hvAG6D.js → capabilities-page-Bda4mSdf.js} +2 -2
  30. package/dist/gateway/static/root/assets/{capabilities-settings-panel-BrEvm4IH.js → capabilities-settings-panel-B2B7no22.js} +2 -2
  31. package/dist/gateway/static/root/assets/{channels-1jQgGVc9.js → channels-NtsjZThx.js} +1 -1
  32. package/dist/gateway/static/root/assets/{chat-agents-api-BAOWaUJf.js → chat-agents-api-D8YS5amE.js} +1 -1
  33. package/dist/gateway/static/root/assets/{chat-chart-block-DeWrb9XR.js → chat-chart-block-DCzUECct.js} +1 -1
  34. package/dist/gateway/static/root/assets/chat-page-BnOCCAXG.js +72 -0
  35. package/dist/gateway/static/root/assets/{chat-terminal-dock-C544n0-R.js → chat-terminal-dock-Dl-OTkJI.js} +1 -1
  36. package/dist/gateway/static/root/assets/{command-palette-api-D9PXzY8b.js → command-palette-api-Dijix7V6.js} +1 -1
  37. package/dist/gateway/static/root/assets/{composer-payload-handoff-CYXfjpem.js → composer-payload-handoff-CQc-VTaL.js} +1 -1
  38. package/dist/gateway/static/root/assets/{computer-settings-page-DJmod8-w.js → computer-settings-page-B-lGMimW.js} +1 -1
  39. package/dist/gateway/static/root/assets/connected-providers-grid-CcXe9kz5.js +1 -0
  40. package/dist/gateway/static/root/assets/{connector-service-page-BqDbTOTp.js → connector-service-page-C8InhrMt.js} +1 -1
  41. package/dist/gateway/static/root/assets/{connectors-api-CwRuUnH4.js → connectors-api-DEJU8mgn.js} +1 -1
  42. package/dist/gateway/static/root/assets/{connectors-page-Mq9Bvoax.js → connectors-page-Ci0L2How.js} +1 -1
  43. package/dist/gateway/static/root/assets/{date-picker-DWaT0IC0.js → date-picker-kqic8j73.js} +1 -1
  44. package/dist/gateway/static/root/assets/{dependency-picker-DV9XAt6F.js → dependency-picker-cbC6-2Ya.js} +1 -1
  45. package/dist/gateway/static/root/assets/{desktop-pet-Dffq2NxL.js → desktop-pet-DFNehTtd.js} +1 -1
  46. package/dist/gateway/static/root/assets/{desktop-pet-narrative-CS8qJpNO.js → desktop-pet-narrative-ChwjpnsG.js} +1 -1
  47. package/dist/gateway/static/root/assets/{desktop-pet-settings-CrB1ICax.js → desktop-pet-settings-BDS7_tQ_.js} +1 -1
  48. package/dist/gateway/static/root/assets/{dev-view-store-liRgSkcT.js → dev-view-store-CeZZLOc6.js} +1 -1
  49. package/dist/gateway/static/root/assets/device-pairing-wizard-_3BJFWVQ.js +1 -0
  50. package/dist/gateway/static/root/assets/{directory-picker-path-field-EKqQLQrE.js → directory-picker-path-field-Di0h3ws4.js} +1 -1
  51. package/dist/gateway/static/root/assets/{discussion-annotation-sync-D-b1X6ro.js → discussion-annotation-sync-ClKEyXmN.js} +1 -1
  52. package/dist/gateway/static/root/assets/{extension-debug-page-wD97GeG0.js → extension-debug-page-DwB5KMGk.js} +1 -1
  53. package/dist/gateway/static/root/assets/{extension-iframe-host-B4Q1CjvW.js → extension-iframe-host-Cqg1K70e.js} +1 -1
  54. package/dist/gateway/static/root/assets/{extension-marketplace-api-ak1_K3u8.js → extension-marketplace-api-DRBszrCR.js} +1 -1
  55. package/dist/gateway/static/root/assets/{extension-page-DWFI4iIh.js → extension-page-DyrQtG82.js} +1 -1
  56. package/dist/gateway/static/root/assets/{extension-provider-BZwcaU5Y.js → extension-provider-C_uKqJxP.js} +1 -1
  57. package/dist/gateway/static/root/assets/{extension-settings-page-cn4KS42C.js → extension-settings-page-BAMQHzkX.js} +1 -1
  58. package/dist/gateway/static/root/assets/{file-preview-surface-c3gDD9sM.js → file-preview-surface-DfkXvFnc.js} +1 -1
  59. package/dist/gateway/static/root/assets/{gateway-config-swr-Dmt5JhZU.js → gateway-config-swr-BOCt_zOo.js} +1 -1
  60. package/dist/gateway/static/root/assets/{gateway-realtime-CJtDXQCt.js → gateway-realtime-BL_Cf0OQ.js} +1 -1
  61. package/dist/gateway/static/root/assets/gateway-realtime-store-BHBOPF_q.js +1 -0
  62. package/dist/gateway/static/root/assets/{gateway-restart-DInvvT5u.js → gateway-restart-CHf8qY7H.js} +1 -1
  63. package/dist/gateway/static/root/assets/{gateway-settings-BZXdv2FE.js → gateway-settings-uAboiElC.js} +1 -1
  64. package/dist/gateway/static/root/assets/{gateway-startup-retry-s2KcWekp.js → gateway-startup-retry-CvkJYurV.js} +1 -1
  65. package/dist/gateway/static/root/assets/{global-defaults-api-DtnmDd87.js → global-defaults-api-BWMbKu72.js} +1 -1
  66. package/dist/gateway/static/root/assets/{home-page-CAVjA5rO.js → home-page-D6pCBY1V.js} +2 -2
  67. package/dist/gateway/static/root/assets/{image-generation-api-RQQokgE9.js → image-generation-api-CQxZSTWA.js} +1 -1
  68. package/dist/gateway/static/root/assets/{imports-page-BP_4TubV.js → imports-page-C90644id.js} +1 -1
  69. package/dist/gateway/static/root/assets/index-Cc41XQid.css +1 -0
  70. package/dist/gateway/static/root/assets/index-CnOYR6jq.js +11 -0
  71. package/dist/gateway/static/root/assets/{install-connector-dialog-BNzNuXJ8.js → install-connector-dialog-BuNXON0P.js} +1 -1
  72. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DNRQFepg.js → keyboard-shortcuts-settings-CbeubKe1.js} +1 -1
  73. package/dist/gateway/static/root/assets/{local-app-workbench-page-CvY5XxbX.js → local-app-workbench-page-CP-BkbB6.js} +1 -1
  74. package/dist/gateway/static/root/assets/{local-apps-page-DfwEvd8G.js → local-apps-page-C6zFgwkr.js} +1 -1
  75. package/dist/gateway/static/root/assets/{local-session-drafts-CuDdIyxR.js → local-session-drafts-BJ1B1dQ7.js} +1 -1
  76. package/dist/gateway/static/root/assets/{locale-store-TQcz_Vjt.js → locale-store-Br7IfbXK.js} +1 -1
  77. package/dist/gateway/static/root/assets/{logs-page-eq49F1Rt.js → logs-page-CpVCvAWE.js} +1 -1
  78. package/dist/gateway/static/root/assets/{management-settings-BaYXDMOJ.js → management-settings-I-pXv4ML.js} +1 -1
  79. package/dist/gateway/static/root/assets/{markdown-view-D4nII6Zv.js → markdown-view-DrVAMlwc.js} +1 -1
  80. package/dist/gateway/static/root/assets/{media-plugins-MvlAY405.js → media-plugins-Ba6vUE4J.js} +1 -1
  81. package/dist/gateway/static/root/assets/messages-ByFlEbsu.js +3 -0
  82. package/dist/gateway/static/root/assets/{model-selector-nsoNHqif.js → model-selector-CXcxc30J.js} +1 -1
  83. package/dist/gateway/static/root/assets/{models-hub-cache-CFIazNIF.js → models-hub-cache-Bd-fYUrV.js} +1 -1
  84. package/dist/gateway/static/root/assets/{note-detail-panel-KPzbHiEW.js → note-detail-panel-CbpLXAVh.js} +3 -3
  85. package/dist/gateway/static/root/assets/note-image-lightbox-cLGiF8oU.js +1 -0
  86. package/dist/gateway/static/root/assets/{notes-api-HVxR5bRD.js → notes-api-CUlhTRv0.js} +1 -1
  87. package/dist/gateway/static/root/assets/{notes-page-yShJeR3i.js → notes-page-eoKX85K5.js} +1 -1
  88. package/dist/gateway/static/root/assets/{oauth-api-CfKjRVnb.js → oauth-api-DMMdeaNd.js} +1 -1
  89. package/dist/gateway/static/root/assets/{oauth-provider-connect-D4uqONWr.js → oauth-provider-connect-C8BXow79.js} +1 -1
  90. package/dist/gateway/static/root/assets/{page-context-capture-button-B98nlKTc.js → page-context-capture-button-CBFK41OS.js} +1 -1
  91. package/dist/gateway/static/root/assets/{page-context-draft-HcuK45iu.js → page-context-draft-LF33STHC.js} +1 -1
  92. package/dist/gateway/static/root/assets/page-header-store-Du44NIEJ.js +1 -0
  93. package/dist/gateway/static/root/assets/{personal-avatar-_d72UP_d.js → personal-avatar-D6CzIIfo.js} +1 -1
  94. package/dist/gateway/static/root/assets/{personal-page-B19h_3WQ.js → personal-page-CXR1Gy0x.js} +1 -1
  95. package/dist/gateway/static/root/assets/{personal-settings-panel-CfwtGyue.js → personal-settings-panel-DnYapLo7.js} +1 -1
  96. package/dist/gateway/static/root/assets/{phone-dependencies-card-D8bqsDk_.js → phone-dependencies-card-DBiKtzwz.js} +1 -1
  97. package/dist/gateway/static/root/assets/{phone-model-picker-CL_Zn6Xd.js → phone-model-picker-BmSxEr7M.js} +1 -1
  98. package/dist/gateway/static/root/assets/{phone-settings-page-C5Jia8eQ.js → phone-settings-page-vg65qilc.js} +1 -1
  99. package/dist/gateway/static/root/assets/{phone-workspace-store-FBfrfkYq.js → phone-workspace-store-SN7hfddU.js} +1 -1
  100. package/dist/gateway/static/root/assets/{plugin-details-dialog-gAq2KPzK.js → plugin-details-dialog-B3Hn2cbx.js} +1 -1
  101. package/dist/gateway/static/root/assets/{preference-select-fields-Ck8GAX_y.js → preference-select-fields-Cu_ZC9Up.js} +1 -1
  102. package/dist/gateway/static/root/assets/{product-automation-feedback-BJ9oTnNs.js → product-automation-feedback-Tn2dUJWM.js} +1 -1
  103. package/dist/gateway/static/root/assets/{product-open-page-Dw9hUdxP.js → product-open-page-Nf-Oqf1h.js} +1 -1
  104. package/dist/gateway/static/root/assets/{product-preview-content-C0iPzmSm.js → product-preview-content-D6NwUm3A.js} +1 -1
  105. package/dist/gateway/static/root/assets/{product-preview-modal-COFtHoh6.js → product-preview-modal-BfNcGgXA.js} +2 -2
  106. package/dist/gateway/static/root/assets/{project-detail-page-C5Amjah-.js → project-detail-page-Ch-ZMyTu.js} +1 -1
  107. package/dist/gateway/static/root/assets/{project-understanding-DpL9ADQU.js → project-understanding-B1BK7Ixi.js} +1 -1
  108. package/dist/gateway/static/root/assets/{projects-page-gGg9nM2t.js → projects-page-B7cetxao.js} +1 -1
  109. package/dist/gateway/static/root/assets/{providers-api-D6JJRlJb.js → providers-api-DOnNfkwQ.js} +1 -1
  110. package/dist/gateway/static/root/assets/{recording-upload-DxX1xKyt.js → recording-upload-RAhaLUcQ.js} +1 -1
  111. package/dist/gateway/static/root/assets/{registry-api-BfXzBR1D.js → registry-api-DFDvOTg4.js} +1 -1
  112. package/dist/gateway/static/root/assets/{remote-access-hub-BZA4StwC.js → remote-access-hub-DWsOWetc.js} +1 -1
  113. package/dist/gateway/static/root/assets/{resource-unavailable-X-SIrZYI.js → resource-unavailable-TQcRCpAg.js} +1 -1
  114. package/dist/gateway/static/root/assets/{route-preload-CWRb0UCt.js → route-preload-Zc5Z3fNv.js} +2 -2
  115. package/dist/gateway/static/root/assets/{runtime-tools-api-1DjsPyQ5.js → runtime-tools-api-9o3Wfji1.js} +1 -1
  116. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BnCtyORj.js → runtime-tools-settings-panel-BGiXeHF5.js} +1 -1
  117. package/dist/gateway/static/root/assets/{service-recommendation-list-ChSOfHHh.js → service-recommendation-list-BEnNx0u7.js} +1 -1
  118. package/dist/gateway/static/root/assets/{session-api-rvY5aWw8.js → session-api-Bs3r_d2_.js} +1 -1
  119. package/dist/gateway/static/root/assets/session-manager-ChUtTAoG.js +23 -0
  120. package/dist/gateway/static/root/assets/{sessions-page-DAS2IUGT.js → sessions-page-Bt52kBvJ.js} +1 -1
  121. package/dist/gateway/static/root/assets/settings-advanced-gate-BI4DMz4_.js +1 -0
  122. package/dist/gateway/static/root/assets/{settings-advanced-section-ZKRIuk7h.js → settings-advanced-section-CURRjsLK.js} +1 -1
  123. package/dist/gateway/static/root/assets/{settings-mode-store-CtJ8pEfm.js → settings-mode-store-CiRpsdTJ.js} +1 -1
  124. package/dist/gateway/static/root/assets/{settings-page-B3pUce-_.js → settings-page-GtsbT6as.js} +1 -1
  125. package/dist/gateway/static/root/assets/{settings-page-header-DuNCn8i-.js → settings-page-header-DBL0_u0Z.js} +1 -1
  126. package/dist/gateway/static/root/assets/{settings-page-layout-DeNC8YHJ.js → settings-page-layout-IAvpbz4A.js} +1 -1
  127. package/dist/gateway/static/root/assets/{setup-status-panel-Fc3vuz_h.js → setup-status-panel-A6uMpGRy.js} +1 -1
  128. package/dist/gateway/static/root/assets/{share-link-dialog-B3hwjVAx.js → share-link-dialog-D1otGSXD.js} +1 -1
  129. package/dist/gateway/static/root/assets/{share-preview-page-D_9oFzGS.js → share-preview-page-L9KYu8M7.js} +1 -1
  130. package/dist/gateway/static/root/assets/{shares-api-BoUpXmxq.js → shares-api-D8Q-m46d.js} +1 -1
  131. package/dist/gateway/static/root/assets/{shares-settings-Drfuvepz.js → shares-settings-Bmfadz8A.js} +1 -1
  132. package/dist/gateway/static/root/assets/{skill-api-By2HhJ9O.js → skill-api-uKU4sRiv.js} +1 -1
  133. package/dist/gateway/static/root/assets/{skill-list-api-TaUCzS8Y.js → skill-list-api-BzKzG-xG.js} +1 -1
  134. package/dist/gateway/static/root/assets/{skill-reload-api-CN2fpS1n.js → skill-reload-api-DkUXekcd.js} +1 -1
  135. package/dist/gateway/static/root/assets/{skills-page-LzGLique.js → skills-page-BZklXTX9.js} +1 -1
  136. package/dist/gateway/static/root/assets/{system-settings-panel-Cuyg8Ml3.js → system-settings-panel-CsvcFoaJ.js} +1 -1
  137. package/dist/gateway/static/root/assets/task-detail-page-SjZGW1Dx.js +2 -0
  138. package/dist/gateway/static/root/assets/{task-result-evidence-DDubAU_5.js → task-result-evidence-B8xUiwW3.js} +1 -1
  139. package/dist/gateway/static/root/assets/{terminal-panel-store-BNs75Wdr.js → terminal-panel-store-DJVC7HqA.js} +1 -1
  140. package/dist/gateway/static/root/assets/{theme-store-DB1ZfBUm.js → theme-store-Dlnmgryi.js} +1 -1
  141. package/dist/gateway/static/root/assets/tool-friendly-title-DcCc6g7o.js +1 -0
  142. package/dist/gateway/static/root/assets/{tracing-settings-page-TvtX4Goh.js → tracing-settings-page-MvG4SH64.js} +1 -1
  143. package/dist/gateway/static/root/assets/{tunnel-api-COoVEdV9.js → tunnel-api-BB7u79ID.js} +1 -1
  144. package/dist/gateway/static/root/assets/{understanding-activity-store-Dr_MLgYe.js → understanding-activity-store-C4bblRnQ.js} +1 -1
  145. package/dist/gateway/static/root/assets/{understanding-refresh-store-DGmLGEqw.js → understanding-refresh-store-BvCj9-Ue.js} +1 -1
  146. package/dist/gateway/static/root/assets/{usage-page-DP6eb6ed.js → usage-page-Cv4Je5XJ.js} +1 -1
  147. package/dist/gateway/static/root/assets/{use-autosave-itwjDYUb.js → use-autosave-YHxQ-UZg.js} +1 -1
  148. package/dist/gateway/static/root/assets/{use-composer-attachments-hjIGlI_2.js → use-composer-attachments-vDdxHtUb.js} +1 -1
  149. package/dist/gateway/static/root/assets/{use-file-preview-expanded-ClLa0g8D.js → use-file-preview-expanded-Ce2mgYme.js} +2 -2
  150. package/dist/gateway/static/root/assets/{use-personal-profile-vhWk6tTU.js → use-personal-profile-D2Un8G1L.js} +1 -1
  151. package/dist/gateway/static/root/assets/{use-workspace-tree-dfXXjA2-.js → use-workspace-tree-BQEiJzK7.js} +1 -1
  152. package/dist/gateway/static/root/assets/{user-model-page-D8dswPWd.js → user-model-page-DRSsn4EV.js} +1 -1
  153. package/dist/gateway/static/root/assets/{voice-api-key-field-BIfBySnN.js → voice-api-key-field-DCM69u8Y.js} +1 -1
  154. package/dist/gateway/static/root/assets/{voice-config-api-J4o59ICE.js → voice-config-api-CrULrSKC.js} +1 -1
  155. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-B1mlpUdC.js → voice-input-shortcut-events-DFMNIyy4.js} +1 -1
  156. package/dist/gateway/static/root/assets/{voice-transcribe-api-xxaSOOmq.js → voice-transcribe-api-Bbyj0yGR.js} +1 -1
  157. package/dist/gateway/static/root/assets/{work-discovery-overlay-DqwT1E5u.js → work-discovery-overlay-CVe9UmFl.js} +1 -1
  158. package/dist/gateway/static/root/assets/{work-discovery-page-BzYQmPLT.js → work-discovery-page-CtqkRMN5.js} +1 -1
  159. package/dist/gateway/static/root/assets/{working-directory-picker-modal-D2Zf3GOG.js → working-directory-picker-modal-CDZ1xh3o.js} +1 -1
  160. package/dist/gateway/static/root/assets/{workspace-api-Bnx3eS2M.js → workspace-api-tbifz2zY.js} +2 -2
  161. package/dist/gateway/static/root/assets/workspace-editor-agent-store-4cZ26iaD.js +1 -0
  162. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-D13qHzVr.js → workspace-file-preview-dialog-BubQwQwU.js} +1 -1
  163. package/dist/gateway/static/root/assets/{workspace-open-location-menu-Cou-ig1H.js → workspace-open-location-menu-DZk3MBSa.js} +1 -1
  164. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DQGPKxHA.js → xopc-cloud-account-card-CIavPUr3.js} +1 -1
  165. package/dist/gateway/static/root/index.html +81 -81
  166. package/dist/package.js +1 -1
  167. package/dist/packages/computer-control-contract/src/index.js +33 -3
  168. package/dist/src/agent/embedded/run-turn.js +64 -4
  169. package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
  170. package/dist/src/agent/tool-manuals/computer.js +6 -0
  171. package/dist/src/agent/tools/computer-use-tool.js +18 -5
  172. package/dist/src/agent/tools/phone-use-tool.js +12 -2
  173. package/dist/src/computer/agent-context.d.ts +21 -0
  174. package/dist/src/computer/agent-context.js +107 -0
  175. package/dist/src/computer/broker.d.ts +4 -2
  176. package/dist/src/computer/broker.js +26 -11
  177. package/dist/src/computer/diagnostics.d.ts +60 -6
  178. package/dist/src/computer/diagnostics.js +45 -4
  179. package/dist/src/computer/errors.d.ts +1 -1
  180. package/dist/src/computer/errors.js +4 -0
  181. package/dist/src/computer/evaluation.d.ts +2 -2
  182. package/dist/src/computer/native-timing.d.ts +15 -0
  183. package/dist/src/computer/native-timing.js +49 -0
  184. package/dist/src/computer/program-runtime.d.ts +22 -0
  185. package/dist/src/computer/program-runtime.js +105 -0
  186. package/dist/src/computer/runtime.d.ts +36 -2
  187. package/dist/src/computer/runtime.js +269 -58
  188. package/dist/src/config/models-json.d.ts +12 -0
  189. package/dist/src/config/schema.d.ts +18 -0
  190. package/dist/src/gateway/hono/routes/phone-setup.js +12 -7
  191. package/dist/src/gateway/hono/routes/phone.js +2 -4
  192. package/dist/src/gateway/service/config-coordinator.d.ts +6 -0
  193. package/dist/src/gateway/service.js +4 -4
  194. package/dist/src/gateway/xopc-cloud-capability-setup.js +9 -1
  195. package/dist/src/home-intelligence/host.js +2 -2
  196. package/dist/src/phone/adb-driver.d.ts +15 -1
  197. package/dist/src/phone/adb-driver.js +104 -41
  198. package/dist/src/phone/autoglm-protocol.d.ts +36 -0
  199. package/dist/src/phone/autoglm-protocol.js +88 -0
  200. package/dist/src/phone/autoglm-upstream-prompt.d.ts +2 -0
  201. package/dist/src/phone/autoglm-upstream-prompt.js +5 -0
  202. package/dist/src/phone/autoglm-upstream.LICENSE +201 -0
  203. package/dist/src/phone/cloud-adb-connection.d.ts +3 -0
  204. package/dist/src/phone/cloud-adb-connection.js +105 -31
  205. package/dist/src/phone/cloud-adb.js +18 -6
  206. package/dist/src/phone/completion-recovery.d.ts +6 -0
  207. package/dist/src/phone/completion-recovery.js +30 -0
  208. package/dist/src/phone/contracts.d.ts +24 -0
  209. package/dist/src/phone/contracts.js +12 -1
  210. package/dist/src/phone/execution-trace.d.ts +51 -0
  211. package/dist/src/phone/execution-trace.js +78 -0
  212. package/dist/src/phone/gui-protocol.d.ts +7 -0
  213. package/dist/src/phone/gui-protocol.js +302 -0
  214. package/dist/src/phone/model-adapter.d.ts +10 -2
  215. package/dist/src/phone/model-adapter.js +136 -62
  216. package/dist/src/phone/model-response.d.ts +5 -0
  217. package/dist/src/phone/model-response.js +118 -0
  218. package/dist/src/phone/runtime.d.ts +4 -0
  219. package/dist/src/phone/runtime.js +154 -18
  220. package/dist/src/phone/text-session.d.ts +14 -0
  221. package/dist/src/phone/text-session.js +39 -0
  222. package/dist/src/phone/ui-dump-binary.d.ts +1 -1
  223. package/dist/src/phone/ui-dump-binary.js +1 -1
  224. package/dist/src/phone/ui-session.d.ts +24 -0
  225. package/dist/src/phone/ui-session.js +210 -0
  226. package/dist/src/process/phone-process.d.ts +1 -0
  227. package/dist/src/process/phone-process.js +11 -1
  228. package/dist/src/providers/env-keys.js +2 -0
  229. package/dist/src/providers/index.js +11 -0
  230. package/dist/src/providers/model-catalog-types.d.ts +1 -1
  231. package/dist/src/providers/model-supplements.d.ts +1 -1
  232. package/dist/src/providers/model-supplements.js +6 -3
  233. package/dist/src/providers/phone-models.d.ts +3 -0
  234. package/dist/src/providers/phone-models.js +33 -0
  235. package/dist/src/providers/presentation.js +0 -1
  236. package/dist/src/tui/tui.js +1 -1
  237. package/dist/src/voice/platform-catalog.d.ts +1 -1
  238. package/package.json +2 -1
  239. package/dist/gateway/static/root/assets/chat-page-CafkCKOj.js +0 -72
  240. package/dist/gateway/static/root/assets/connected-providers-grid-b46VH4uy.js +0 -1
  241. package/dist/gateway/static/root/assets/device-pairing-wizard-1du1hfi5.js +0 -1
  242. package/dist/gateway/static/root/assets/gateway-realtime-store-DcsZyYEa.js +0 -1
  243. package/dist/gateway/static/root/assets/index-BS9mjvSL.js +0 -11
  244. package/dist/gateway/static/root/assets/index-pT-m6l6b.css +0 -1
  245. package/dist/gateway/static/root/assets/messages-DaLmc4W1.js +0 -3
  246. package/dist/gateway/static/root/assets/note-image-lightbox-DticJxxh.js +0 -1
  247. package/dist/gateway/static/root/assets/page-header-store-D6SzJ9Ch.js +0 -1
  248. package/dist/gateway/static/root/assets/session-manager-D2rbRfX3.js +0 -23
  249. package/dist/gateway/static/root/assets/settings-advanced-gate-CYDQybNF.js +0 -1
  250. package/dist/gateway/static/root/assets/task-detail-page-6A9337pK.js +0 -2
  251. package/dist/gateway/static/root/assets/tool-friendly-title-DGmi7rCQ.js +0 -1
  252. 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{n as i}from"./locale-store-TQcz_Vjt.js";import{t as a}from"./calendar-days-hw_Y-g-s.js";import{t as ee}from"./chevron-left-DqFhpbvK.js";import{t as te}from"./chevron-right-BweFrslA.js";import{c as ne,l as re,u as ie}from"./popover-select-DD8fmrxH.js";import{t as ae}from"./cn-0WouolD0.js";import{c as oe,n as se,s as ce}from"./dist-CaUuvp8-.js";var o=e(t(),1),le=n();function s(e){return String(e).padStart(2,`0`)}function ue(e){return`${e.getFullYear()}-${s(e.getMonth()+1)}-${s(e.getDate())}`}function de(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2])-1,i=Number(t[3]),a=new Date(n,r,i,12);return a.getFullYear()===n&&a.getMonth()===r&&a.getDate()===i?a:null}function fe(e,t){let n=de(e);return n?t===`zh`?`${n.getFullYear()}/${s(n.getMonth()+1)}/${s(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}var c=r();function pe(e,t){let n=new Date(e.getFullYear(),e.getMonth(),1,12),r=(n.getDay()-t+7)%7;return Array.from({length:42},(e,t)=>new Date(n.getFullYear(),n.getMonth(),1-r+t,12))}function l(e){let t=(0,le.c)(106),{value:n,onChange:r,disabled:s,className:l,ariaLabel:ve,placeholder:ye,min:u,max:d}=e,f=i(_e),p=f===`zh`?`zh-CN`:`en`,be;t[0]===n?be=t[1]:(be=de(n),t[0]=n,t[1]=be);let m=be,[h,xe]=(0,o.useState)(!1),[Se,Ce]=(0,o.useState)(null),g;t[2]===m?g=t[3]:(g=()=>m??new Date,t[2]=m,t[3]=g);let[_,we]=(0,o.useState)(g),Te=ne(Se),Ee=ie(re(),Te!==null),v=+(f===`zh`),y,b;t[4]!==h||t[5]!==n?(y=()=>{if(!h)return;let e=de(n);e&&we(e)},b=[h,n],t[4]=h,t[5]=n,t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,o.useEffect)(y,b);let x;t[8]!==_||t[9]!==v?(x=pe(_,v),t[8]=_,t[9]=v,t[10]=x):x=t[10];let De=x,S;if(t[11]!==p||t[12]!==v){let e=new Date(2026,7,23,12);S=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+v+n),new Intl.DateTimeFormat(p,{weekday:`narrow`}).format(r)}),t[11]=p,t[12]=v,t[13]=S}else S=t[13];let Oe=S,C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C=ue(new Date),t[14]=C):C=t[14];let w=C,T;t[15]===m?T=t[16]:(T=m?ue(m):``,t[15]=m,t[16]=T);let E=T,D;t[17]!==p||t[18]!==_?(D=new Intl.DateTimeFormat(p,{year:`numeric`,month:`long`}).format(_),t[17]=p,t[18]=_,t[19]=D):D=t[19];let ke=D,O;t[20]===r?O=t[21]:(O=e=>{r(e),xe(!1)},t[20]=r,t[21]=O);let k=O,Ae=oe,je=s&&`cursor-not-allowed opacity-50`,A;t[22]!==l||t[23]!==je?(A=ae(`flex h-10 w-full min-w-0 items-center justify-between gap-3 rounded-lg bg-surface-hover px-3 text-left text-sm text-fg outline-none transition-colors`,`hover:bg-surface-active focus-visible:ring-2 focus-visible:ring-accent/40`,je,l),t[22]=l,t[23]=je,t[24]=A):A=t[24];let Me=!n&&`text-fg-subtle`,j;t[25]===Me?j=t[26]:(j=ae(`min-w-0 truncate tabular-nums`,Me),t[25]=Me,t[26]=j);let M;t[27]!==f||t[28]!==ye||t[29]!==n?(M=fe(n,f)||ye||(f===`zh`?`选择日期`:`Select date`),t[27]=f,t[28]=ye,t[29]=n,t[30]=M):M=t[30];let N;t[31]!==j||t[32]!==M?(N=(0,c.jsx)(`span`,{className:j,children:M}),t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,c.jsx)(a,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=P):P=t[34];let F;t[35]!==ve||t[36]!==s||t[37]!==A||t[38]!==N?(F=(0,c.jsx)(ce,{asChild:!0,children:(0,c.jsxs)(`button`,{ref:Ce,type:`button`,disabled:s,"aria-label":ve,className:A,children:[N,P]})}),t[35]=ve,t[36]=s,t[37]=A,t[38]=N,t[39]=F):F=t[39];let Ne=oe,Pe=Te??void 0,Fe=oe,Ie=Te??void 0,Le=ae(Ee,`max-h-[var(--radix-popover-content-available-height)] w-[19rem] overflow-y-auto rounded-2xl border border-edge bg-surface-overlay p-3 shadow-float outline-none`),Re=f===`zh`?`上个月`:`Previous month`,I,L;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>we(ge),L=(0,c.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[40]=I,t[41]=L):(I=t[40],L=t[41]);let R;t[42]===Re?R=t[43]:(R=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Re,onClick:I,children:L}),t[42]=Re,t[43]=R);let z;t[44]===ke?z=t[45]:(z=(0,c.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ke}),t[44]=ke,t[45]=z);let ze=f===`zh`?`下个月`:`Next month`,B,V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>we(he),V=(0,c.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[46]=B,t[47]=V):(B=t[46],V=t[47]);let H;t[48]===ze?H=t[49]:(H=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":ze,onClick:B,children:V}),t[48]=ze,t[49]=H);let U;t[50]!==R||t[51]!==z||t[52]!==H?(U=(0,c.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[R,z,H]}),t[50]=R,t[51]=z,t[52]=H,t[53]=U):U=t[53];let W;t[54]===Oe?W=t[55]:(W=(0,c.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:Oe.map(me)}),t[54]=Oe,t[55]=W);let G;if(t[56]!==De||t[57]!==p||t[58]!==d||t[59]!==u||t[60]!==k||t[61]!==E||t[62]!==_){let e;t[64]!==p||t[65]!==d||t[66]!==u||t[67]!==k||t[68]!==E||t[69]!==_?(e=e=>{let t=ue(e),n=t===E,r=t===w,i=e.getMonth()!==_.getMonth(),a=!!(u&&t<u||d&&t>d);return(0,c.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-disabled":a,disabled:a,"aria-label":new Intl.DateTimeFormat(p,{dateStyle:`full`}).format(e),className:ae(`mx-auto flex size-9 items-center justify-center rounded-xl text-sm tabular-nums text-fg transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i&&`text-fg-disabled`,a&&`cursor-not-allowed opacity-35 hover:bg-transparent`,r&&!n&&`bg-accent-soft font-semibold text-accent-fg`,n&&`bg-accent font-semibold text-on-accent hover:bg-accent-hover`),onClick:()=>k(t),children:e.getDate()},t)},t[64]=p,t[65]=d,t[66]=u,t[67]=k,t[68]=E,t[69]=_,t[70]=e):e=t[70],G=De.map(e),t[56]=De,t[57]=p,t[58]=d,t[59]=u,t[60]=k,t[61]=E,t[62]=_,t[63]=G}else G=t[63];let K;t[71]===G?K=t[72]:(K=(0,c.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:G}),t[71]=G,t[72]=K);let Be=!n,q;t[73]===k?q=t[74]:(q=()=>k(``),t[73]=k,t[74]=q);let Ve=f===`zh`?`清除`:`Clear`,J;t[75]!==Be||t[76]!==q||t[77]!==Ve?(J=(0,c.jsx)(`button`,{type:`button`,disabled:Be,className:`rounded-lg px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,onClick:q,children:Ve}),t[75]=Be,t[76]=q,t[77]=Ve,t[78]=J):J=t[78];let He=!!(u&&w<u||d&&w>d),Y;t[79]===k?Y=t[80]:(Y=()=>k(w),t[79]=k,t[80]=Y);let Ue=f===`zh`?`今天`:`Today`,X;t[81]!==He||t[82]!==Y||t[83]!==Ue?(X=(0,c.jsx)(`button`,{type:`button`,disabled:He,className:`rounded-lg bg-accent-soft px-2.5 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80 disabled:pointer-events-none disabled:opacity-35`,onClick:Y,children:Ue}),t[81]=He,t[82]=Y,t[83]=Ue,t[84]=X):X=t[84];let Z;t[85]!==J||t[86]!==X?(Z=(0,c.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[J,X]}),t[85]=J,t[86]=X,t[87]=Z):Z=t[87];let We;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,c.jsx)(se,{className:`fill-surface-overlay`}),t[88]=We):We=t[88];let Q;t[89]!==Fe.Content||t[90]!==Ie||t[91]!==Le||t[92]!==U||t[93]!==W||t[94]!==K||t[95]!==Z?(Q=(0,c.jsxs)(Fe.Content,{align:`start`,sideOffset:6,collisionPadding:12,collisionBoundary:Ie,className:Le,children:[U,W,K,Z,We]}),t[89]=Fe.Content,t[90]=Ie,t[91]=Le,t[92]=U,t[93]=W,t[94]=K,t[95]=Z,t[96]=Q):Q=t[96];let $;t[97]!==Ne.Portal||t[98]!==Pe||t[99]!==Q?($=(0,c.jsx)(Ne.Portal,{container:Pe,children:Q}),t[97]=Ne.Portal,t[98]=Pe,t[99]=Q,t[100]=$):$=t[100];let Ge;return t[101]!==h||t[102]!==Ae.Root||t[103]!==F||t[104]!==$?(Ge=(0,c.jsxs)(Ae.Root,{open:h,onOpenChange:xe,children:[F,$]}),t[101]=h,t[102]=Ae.Root,t[103]=F,t[104]=$,t[105]=Ge):Ge=t[105],Ge}function me(e,t){return(0,c.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function he(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function ge(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function _e(e){return e.language}export{l as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{n as i}from"./locale-store-Br7IfbXK.js";import{t as a}from"./calendar-days-hw_Y-g-s.js";import{t as ee}from"./chevron-left-DqFhpbvK.js";import{t as te}from"./chevron-right-BweFrslA.js";import{c as ne,l as re,u as ie}from"./popover-select-DD8fmrxH.js";import{t as ae}from"./cn-0WouolD0.js";import{c as oe,n as se,s as ce}from"./dist-CaUuvp8-.js";var o=e(t(),1),le=n();function s(e){return String(e).padStart(2,`0`)}function ue(e){return`${e.getFullYear()}-${s(e.getMonth()+1)}-${s(e.getDate())}`}function de(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2])-1,i=Number(t[3]),a=new Date(n,r,i,12);return a.getFullYear()===n&&a.getMonth()===r&&a.getDate()===i?a:null}function fe(e,t){let n=de(e);return n?t===`zh`?`${n.getFullYear()}/${s(n.getMonth()+1)}/${s(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}var c=r();function pe(e,t){let n=new Date(e.getFullYear(),e.getMonth(),1,12),r=(n.getDay()-t+7)%7;return Array.from({length:42},(e,t)=>new Date(n.getFullYear(),n.getMonth(),1-r+t,12))}function l(e){let t=(0,le.c)(106),{value:n,onChange:r,disabled:s,className:l,ariaLabel:ve,placeholder:ye,min:u,max:d}=e,f=i(_e),p=f===`zh`?`zh-CN`:`en`,be;t[0]===n?be=t[1]:(be=de(n),t[0]=n,t[1]=be);let m=be,[h,xe]=(0,o.useState)(!1),[Se,Ce]=(0,o.useState)(null),g;t[2]===m?g=t[3]:(g=()=>m??new Date,t[2]=m,t[3]=g);let[_,we]=(0,o.useState)(g),Te=ne(Se),Ee=ie(re(),Te!==null),v=+(f===`zh`),y,b;t[4]!==h||t[5]!==n?(y=()=>{if(!h)return;let e=de(n);e&&we(e)},b=[h,n],t[4]=h,t[5]=n,t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,o.useEffect)(y,b);let x;t[8]!==_||t[9]!==v?(x=pe(_,v),t[8]=_,t[9]=v,t[10]=x):x=t[10];let De=x,S;if(t[11]!==p||t[12]!==v){let e=new Date(2026,7,23,12);S=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+v+n),new Intl.DateTimeFormat(p,{weekday:`narrow`}).format(r)}),t[11]=p,t[12]=v,t[13]=S}else S=t[13];let Oe=S,C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C=ue(new Date),t[14]=C):C=t[14];let w=C,T;t[15]===m?T=t[16]:(T=m?ue(m):``,t[15]=m,t[16]=T);let E=T,D;t[17]!==p||t[18]!==_?(D=new Intl.DateTimeFormat(p,{year:`numeric`,month:`long`}).format(_),t[17]=p,t[18]=_,t[19]=D):D=t[19];let ke=D,O;t[20]===r?O=t[21]:(O=e=>{r(e),xe(!1)},t[20]=r,t[21]=O);let k=O,Ae=oe,je=s&&`cursor-not-allowed opacity-50`,A;t[22]!==l||t[23]!==je?(A=ae(`flex h-10 w-full min-w-0 items-center justify-between gap-3 rounded-lg bg-surface-hover px-3 text-left text-sm text-fg outline-none transition-colors`,`hover:bg-surface-active focus-visible:ring-2 focus-visible:ring-accent/40`,je,l),t[22]=l,t[23]=je,t[24]=A):A=t[24];let Me=!n&&`text-fg-subtle`,j;t[25]===Me?j=t[26]:(j=ae(`min-w-0 truncate tabular-nums`,Me),t[25]=Me,t[26]=j);let M;t[27]!==f||t[28]!==ye||t[29]!==n?(M=fe(n,f)||ye||(f===`zh`?`选择日期`:`Select date`),t[27]=f,t[28]=ye,t[29]=n,t[30]=M):M=t[30];let N;t[31]!==j||t[32]!==M?(N=(0,c.jsx)(`span`,{className:j,children:M}),t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,c.jsx)(a,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=P):P=t[34];let F;t[35]!==ve||t[36]!==s||t[37]!==A||t[38]!==N?(F=(0,c.jsx)(ce,{asChild:!0,children:(0,c.jsxs)(`button`,{ref:Ce,type:`button`,disabled:s,"aria-label":ve,className:A,children:[N,P]})}),t[35]=ve,t[36]=s,t[37]=A,t[38]=N,t[39]=F):F=t[39];let Ne=oe,Pe=Te??void 0,Fe=oe,Ie=Te??void 0,Le=ae(Ee,`max-h-[var(--radix-popover-content-available-height)] w-[19rem] overflow-y-auto rounded-2xl border border-edge bg-surface-overlay p-3 shadow-float outline-none`),Re=f===`zh`?`上个月`:`Previous month`,I,L;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>we(ge),L=(0,c.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[40]=I,t[41]=L):(I=t[40],L=t[41]);let R;t[42]===Re?R=t[43]:(R=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Re,onClick:I,children:L}),t[42]=Re,t[43]=R);let z;t[44]===ke?z=t[45]:(z=(0,c.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ke}),t[44]=ke,t[45]=z);let ze=f===`zh`?`下个月`:`Next month`,B,V;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>we(he),V=(0,c.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[46]=B,t[47]=V):(B=t[46],V=t[47]);let H;t[48]===ze?H=t[49]:(H=(0,c.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":ze,onClick:B,children:V}),t[48]=ze,t[49]=H);let U;t[50]!==R||t[51]!==z||t[52]!==H?(U=(0,c.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[R,z,H]}),t[50]=R,t[51]=z,t[52]=H,t[53]=U):U=t[53];let W;t[54]===Oe?W=t[55]:(W=(0,c.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:Oe.map(me)}),t[54]=Oe,t[55]=W);let G;if(t[56]!==De||t[57]!==p||t[58]!==d||t[59]!==u||t[60]!==k||t[61]!==E||t[62]!==_){let e;t[64]!==p||t[65]!==d||t[66]!==u||t[67]!==k||t[68]!==E||t[69]!==_?(e=e=>{let t=ue(e),n=t===E,r=t===w,i=e.getMonth()!==_.getMonth(),a=!!(u&&t<u||d&&t>d);return(0,c.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-disabled":a,disabled:a,"aria-label":new Intl.DateTimeFormat(p,{dateStyle:`full`}).format(e),className:ae(`mx-auto flex size-9 items-center justify-center rounded-xl text-sm tabular-nums text-fg transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i&&`text-fg-disabled`,a&&`cursor-not-allowed opacity-35 hover:bg-transparent`,r&&!n&&`bg-accent-soft font-semibold text-accent-fg`,n&&`bg-accent font-semibold text-on-accent hover:bg-accent-hover`),onClick:()=>k(t),children:e.getDate()},t)},t[64]=p,t[65]=d,t[66]=u,t[67]=k,t[68]=E,t[69]=_,t[70]=e):e=t[70],G=De.map(e),t[56]=De,t[57]=p,t[58]=d,t[59]=u,t[60]=k,t[61]=E,t[62]=_,t[63]=G}else G=t[63];let K;t[71]===G?K=t[72]:(K=(0,c.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:G}),t[71]=G,t[72]=K);let Be=!n,q;t[73]===k?q=t[74]:(q=()=>k(``),t[73]=k,t[74]=q);let Ve=f===`zh`?`清除`:`Clear`,J;t[75]!==Be||t[76]!==q||t[77]!==Ve?(J=(0,c.jsx)(`button`,{type:`button`,disabled:Be,className:`rounded-lg px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,onClick:q,children:Ve}),t[75]=Be,t[76]=q,t[77]=Ve,t[78]=J):J=t[78];let He=!!(u&&w<u||d&&w>d),Y;t[79]===k?Y=t[80]:(Y=()=>k(w),t[79]=k,t[80]=Y);let Ue=f===`zh`?`今天`:`Today`,X;t[81]!==He||t[82]!==Y||t[83]!==Ue?(X=(0,c.jsx)(`button`,{type:`button`,disabled:He,className:`rounded-lg bg-accent-soft px-2.5 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80 disabled:pointer-events-none disabled:opacity-35`,onClick:Y,children:Ue}),t[81]=He,t[82]=Y,t[83]=Ue,t[84]=X):X=t[84];let Z;t[85]!==J||t[86]!==X?(Z=(0,c.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[J,X]}),t[85]=J,t[86]=X,t[87]=Z):Z=t[87];let We;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(We=(0,c.jsx)(se,{className:`fill-surface-overlay`}),t[88]=We):We=t[88];let Q;t[89]!==Fe.Content||t[90]!==Ie||t[91]!==Le||t[92]!==U||t[93]!==W||t[94]!==K||t[95]!==Z?(Q=(0,c.jsxs)(Fe.Content,{align:`start`,sideOffset:6,collisionPadding:12,collisionBoundary:Ie,className:Le,children:[U,W,K,Z,We]}),t[89]=Fe.Content,t[90]=Ie,t[91]=Le,t[92]=U,t[93]=W,t[94]=K,t[95]=Z,t[96]=Q):Q=t[96];let $;t[97]!==Ne.Portal||t[98]!==Pe||t[99]!==Q?($=(0,c.jsx)(Ne.Portal,{container:Pe,children:Q}),t[97]=Ne.Portal,t[98]=Pe,t[99]=Q,t[100]=$):$=t[100];let Ge;return t[101]!==h||t[102]!==Ae.Root||t[103]!==F||t[104]!==$?(Ge=(0,c.jsxs)(Ae.Root,{open:h,onOpenChange:xe,children:[F,$]}),t[101]=h,t[102]=Ae.Root,t[103]=F,t[104]=$,t[105]=Ge):Ge=t[105],Ge}function me(e,t){return(0,c.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function he(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function ge(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function _e(e){return e.language}export{l as t};
@@ -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{t as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./chevron-down-ccbiQQz_.js";import{T as s}from"./use-file-preview-expanded-ClLa0g8D.js";import{t as c}from"./search-DA7gz22f.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./cn-0WouolD0.js";import{t as d}from"./button-CnRSIP6m.js";import{a as f,i as p,o as m,r as h,s as g}from"./copy-text-row-CYIv7RfP.js";var _=n(),v=e(t(),1),y=r(),b=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-overlay px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function x(e){let t=(0,_.c)(31),{candidates:n,selectedIds:r,labels:x,disabled:C,borderless:w,getTaskHref:T,onChange:E}=e,D=w!==void 0&&w,[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(``),M;t[0]===A?M=t[1]:(M=A.trim().toLocaleLowerCase(),t[0]=A,t[1]=M);let N=M,P;if(t[2]!==n||t[3]!==N){let e;t[5]===N?e=t[6]:(e=e=>!N||e.title.toLocaleLowerCase().includes(N),t[5]=N,t[6]=e),P=n.filter(e).slice(0,20),t[2]=n,t[3]=N,t[4]=P}else P=t[4];let F=P,I;t[7]!==n||t[8]!==C||t[9]!==T||t[10]!==x.remove||t[11]!==E||t[12]!==r?(I=r.length>0?(0,y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-surface-hover px-2.5 py-1.5 text-xs text-fg-muted`,children:[(0,y.jsxs)(m,{children:[(0,y.jsx)(g,{asChild:!0,children:T?(0,y.jsx)(i,{to:T(t.id),className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere] rounded-sm outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/50`,children:t.title}):(0,y.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere]`,children:t.title})}),(0,y.jsx)(p,{children:(0,y.jsx)(h,{side:`top`,sideOffset:6,collisionPadding:12,className:b,children:(0,y.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-fg-subtle transition-colors hover:text-fg`,"aria-label":x.remove.replace(`{{task}}`,t.title),disabled:C,onClick:()=>E(r.filter(e=>e!==t.id)),children:(0,y.jsx)(l,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=C,t[9]=T,t[10]=x.remove,t[11]=E,t[12]=r,t[13]=I):I=t[13];let L;t[14]!==D||t[15]!==n.length||t[16]!==C||t[17]!==x.link||t[18]!==x.linked||t[19]!==x.noCandidates||t[20]!==x.noMatches||t[21]!==x.searchPlaceholder||t[22]!==F||t[23]!==E||t[24]!==O||t[25]!==A||t[26]!==r?(L=n.length>0?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(d,{type:`button`,variant:`secondary`,className:u(`w-fit rounded-lg`,D&&`border-0 bg-surface-hover shadow-none`),disabled:C,"aria-expanded":O,onClick:()=>k(S),children:[(0,y.jsx)(s,{className:`size-4`,"aria-hidden":!0}),r.length>0?x.linked.replace(`{{count}}`,String(r.length)):x.link,(0,y.jsx)(o,{className:u(`size-3.5 transition-transform`,O&&`rotate-180`),"aria-hidden":!0})]}),O?(0,y.jsxs)(`div`,{className:u(`grid gap-2 rounded-lg p-2`,D?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(c,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,y.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:x.searchPlaceholder,className:u(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,D?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),F.length>0?(0,y.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:F.map(e=>{let t=r.includes(e.id);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:C,onClick:()=>E(t?r.filter(t=>t!==e.id):[...r,e.id]),className:u(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,y.jsx)(`span`,{className:u(`flex size-4 shrink-0 items-center justify-center rounded`,D?t?`bg-accent text-on-accent`:`bg-surface-active`:t?`border border-accent bg-accent text-on-accent`:`border border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-words [overflow-wrap:anywhere]`,children:e.title})]},e.id)})}):(0,y.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:x.noMatches})]}):null]}):(0,y.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:x.noCandidates}),t[14]=D,t[15]=n.length,t[16]=C,t[17]=x.link,t[18]=x.linked,t[19]=x.noCandidates,t[20]=x.noMatches,t[21]=x.searchPlaceholder,t[22]=F,t[23]=E,t[24]=O,t[25]=A,t[26]=r,t[27]=L):L=t[27];let R;return t[28]!==I||t[29]!==L?(R=(0,y.jsx)(f,{delayDuration:300,children:(0,y.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[I,L]})}),t[28]=I,t[29]=L,t[30]=R):R=t[30],R}function S(e){return!e}export{x as t};
1
+ 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"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./chevron-down-ccbiQQz_.js";import{T as s}from"./use-file-preview-expanded-Ce2mgYme.js";import{t as c}from"./search-DA7gz22f.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./cn-0WouolD0.js";import{t as d}from"./button-CnRSIP6m.js";import{a as f,i as p,o as m,r as h,s as g}from"./copy-text-row-CYIv7RfP.js";var _=n(),v=e(t(),1),y=r(),b=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-overlay px-2.5 py-2 text-left text-xs leading-relaxed text-fg shadow-lg`;function x(e){let t=(0,_.c)(31),{candidates:n,selectedIds:r,labels:x,disabled:C,borderless:w,getTaskHref:T,onChange:E}=e,D=w!==void 0&&w,[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(``),M;t[0]===A?M=t[1]:(M=A.trim().toLocaleLowerCase(),t[0]=A,t[1]=M);let N=M,P;if(t[2]!==n||t[3]!==N){let e;t[5]===N?e=t[6]:(e=e=>!N||e.title.toLocaleLowerCase().includes(N),t[5]=N,t[6]=e),P=n.filter(e).slice(0,20),t[2]=n,t[3]=N,t[4]=P}else P=t[4];let F=P,I;t[7]!==n||t[8]!==C||t[9]!==T||t[10]!==x.remove||t[11]!==E||t[12]!==r?(I=r.length>0?(0,y.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:r.map(e=>{let t=n.find(t=>t.id===e);return t?(0,y.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-lg bg-surface-hover px-2.5 py-1.5 text-xs text-fg-muted`,children:[(0,y.jsxs)(m,{children:[(0,y.jsx)(g,{asChild:!0,children:T?(0,y.jsx)(i,{to:T(t.id),className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere] rounded-sm outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-2 focus-visible:ring-accent/50`,children:t.title}):(0,y.jsx)(`span`,{className:`min-w-0 whitespace-normal break-words [overflow-wrap:anywhere]`,children:t.title})}),(0,y.jsx)(p,{children:(0,y.jsx)(h,{side:`top`,sideOffset:6,collisionPadding:12,className:b,children:(0,y.jsx)(`span`,{className:`break-words`,children:t.title})})})]}),(0,y.jsx)(`button`,{type:`button`,className:`shrink-0 rounded text-fg-subtle transition-colors hover:text-fg`,"aria-label":x.remove.replace(`{{task}}`,t.title),disabled:C,onClick:()=>E(r.filter(e=>e!==t.id)),children:(0,y.jsx)(l,{className:`size-3.5`,"aria-hidden":!0})})]},t.id):null})}):null,t[7]=n,t[8]=C,t[9]=T,t[10]=x.remove,t[11]=E,t[12]=r,t[13]=I):I=t[13];let L;t[14]!==D||t[15]!==n.length||t[16]!==C||t[17]!==x.link||t[18]!==x.linked||t[19]!==x.noCandidates||t[20]!==x.noMatches||t[21]!==x.searchPlaceholder||t[22]!==F||t[23]!==E||t[24]!==O||t[25]!==A||t[26]!==r?(L=n.length>0?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(d,{type:`button`,variant:`secondary`,className:u(`w-fit rounded-lg`,D&&`border-0 bg-surface-hover shadow-none`),disabled:C,"aria-expanded":O,onClick:()=>k(S),children:[(0,y.jsx)(s,{className:`size-4`,"aria-hidden":!0}),r.length>0?x.linked.replace(`{{count}}`,String(r.length)):x.link,(0,y.jsx)(o,{className:u(`size-3.5 transition-transform`,O&&`rotate-180`),"aria-hidden":!0})]}),O?(0,y.jsxs)(`div`,{className:u(`grid gap-2 rounded-lg p-2`,D?`bg-surface-hover`:`border border-edge bg-surface-base`),children:[(0,y.jsxs)(`label`,{className:`relative block`,children:[(0,y.jsx)(c,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,y.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:x.searchPlaceholder,className:u(`h-9 w-full rounded-md bg-surface-panel pl-8 pr-3 text-sm text-fg outline-none placeholder:text-fg-subtle`,D?`focus:ring-2 focus:ring-accent/30`:`border border-edge focus:border-accent`),autoFocus:!0})]}),F.length>0?(0,y.jsx)(`div`,{className:`grid max-h-52 gap-1 overflow-y-auto`,children:F.map(e=>{let t=r.includes(e.id);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":t,disabled:C,onClick:()=>E(t?r.filter(t=>t!==e.id):[...r,e.id]),className:u(`flex items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm transition-colors`,t?`bg-accent-soft text-accent-fg`:`text-fg hover:bg-surface-hover`),children:[(0,y.jsx)(`span`,{className:u(`flex size-4 shrink-0 items-center justify-center rounded`,D?t?`bg-accent text-on-accent`:`bg-surface-active`:t?`border border-accent bg-accent text-on-accent`:`border border-edge`),children:t?(0,y.jsx)(a,{className:`size-3`,"aria-hidden":!0}):null}),(0,y.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-normal break-words [overflow-wrap:anywhere]`,children:e.title})]},e.id)})}):(0,y.jsx)(`p`,{className:`px-2 py-3 text-center text-sm text-fg-subtle`,children:x.noMatches})]}):null]}):(0,y.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:x.noCandidates}),t[14]=D,t[15]=n.length,t[16]=C,t[17]=x.link,t[18]=x.linked,t[19]=x.noCandidates,t[20]=x.noMatches,t[21]=x.searchPlaceholder,t[22]=F,t[23]=E,t[24]=O,t[25]=A,t[26]=r,t[27]=L):L=t[27];let R;return t[28]!==I||t[29]!==L?(R=(0,y.jsx)(f,{delayDuration:300,children:(0,y.jsxs)(`div`,{className:`min-w-0 grid gap-2`,children:[I,L]})}),t[28]=I,t[29]=L,t[30]=R):R=t[30],R}function S(e){return!e}export{x as t};
@@ -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{n as i}from"./locale-store-TQcz_Vjt.js";import{t as a}from"./messages-DaLmc4W1.js";import{t as o}from"./resource-unavailable-X-SIrZYI.js";import{t as s}from"./chevron-down-ccbiQQz_.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./desktop-pet-narrative-CS8qJpNO.js";import{t as u}from"./desktop-pet-sprite-D5YYq2zC.js";var d=e(t(),1),f=n(),p=9e4,m=3e4,h=20*6e4,g=45e3,_=45*6e4,v=58;function y(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=p}function b(e,t){return e.state===`running`&&t-e.timestamp>=m}function x(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.detail&&!e.action.includes(e.detail)?n.replace(/\{\{detail\}\}/g,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function S(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>v?`${n.slice(0,v-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function C(e,t,n){if(b(e,t))return n.stale;if(y(e,t))return n.longRunning}function w(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function ee(e){let t=e.now-e.lastActivityAt,n=t>=h?(t-h)%_:1/0;return e.bubbleEnabled&&e.behaviorMode!==`focus`&&e.proactiveTipsEnabled&&(!e.remindersPausedUntil||e.now>=e.remindersPausedUntil)&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&n<=g&&e.now>=e.dismissedUntil}function T(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:b(e,n)||t===`playful`||t===`companion`&&y(e,n)?`notice`:`ambient`}function E(e,t,n,r){let i=T(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var D=8e3;function O(e,t){let n=e?.runId===t.runId,r=t.feedback?.sensitivity===`private`;return{...n?e:void 0,...t,startedAt:n?e.startedAt??e.timestamp:t.timestamp,publicSummary:r?void 0:t.publicSummary??(n?e.publicSummary:void 0),feedback:t.feedback??(n?e.feedback:void 0),expiresAt:t.state===`success`?t.timestamp+D:void 0}}function k(e,t){let n={...e};for(let e of t){let t=n[e.conversationId];t?.runId===e.runId&&e.sequence<=t.sequence||(n[e.conversationId]=O(t,e))}return n}function A(e,t){return t?.runId===e.runId&&t.state===e.state}function j(e,t){let n={error:0,waiting:1,running:2,success:3};return e.filter(e=>!e.expiresAt||e.expiresAt>t).sort((e,t)=>n[e.state]-n[t.state]||t.timestamp-e.timestamp).slice(0,3)}function M(e){return e?`/chat/${e.conversationId}`:void 0}var N=r();function P(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??l(e.phase):`idle`}function F(e,t){if(!e?.length)return;let n=t.sequence;for(let e of`${t.conversationId}:${t.runId}`)n=n*31+e.charCodeAt(0)>>>0;return e[n%e.length]}function I(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return F(r?.success,t);if(t.state===`waiting`)return F(r?.waiting,t);if(t.state===`error`)return F(r?.error,t)}function L(e,t,n){return e?n?`${e} · ${t}`:e:t}function R(e,t){let n=e.feedback?.nextAction?.type;if(n===`confirm`)return t.needsInput;if(n===`review_error`)return t.reviewIssue;if(n===`open_session`)return t.open;if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function z(){let e=Date.now();return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`loopi`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,behaviorMode:`companion`,proactiveTipsEnabled:!0,interactionEnabled:!0,reducedMotion:!1,sizePercent:100,collapsed:!1},relationship:{firstMetAt:e,lastSeenAt:e,completedTaskCount:0,unlockedReactions:[],recentCompletedRunIds:[]},pets:[],visible:!0,customPetsDir:``,petIssues:[],activities:[]}}function B(){let e=a(i(e=>e.language)).desktopPet,[t,n]=(0,d.useState)(z),[r,o]=(0,d.useState)({}),[l,f]=(0,d.useState)({}),[p,m]=(0,d.useState)(Date.now()),[h,g]=(0,d.useState)(()=>Date.now()),[v,y]=(0,d.useState)(0),[b,T]=(0,d.useState)(null),D=(0,d.useRef)(null),O=(0,d.useRef)(!1),B=(0,d.useRef)(null),V=(0,d.useRef)(null),H=(0,d.useRef)(null),U=(0,d.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),W=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),G=(0,d.useMemo)(()=>j(Object.values(r),p),[r,p]),K=(0,d.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>!A(e,l[e.conversationId])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[G,l,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),q=(0,d.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>A(e,l[e.conversationId])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[G,l,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),J=K[0]??G[0],te=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,ne=b??(J?P(J):te),Y=e.personaPhrases[U?.persona?.tone??`calm`],X=ee({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:K.length,activeCount:G.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,d.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),o(t=>k(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>o(t=>(g(Date.now()),k(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,d.useEffect)(()=>{if(!t.relationshipMoment)return;T(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>T(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,d.useLayoutEffect)(()=>{let e=B.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[V.current,H.current].filter(e=>e!==null).map(e=>({left:e.offsetLeft,top:e.offsetTop,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}));if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom)),o=Math.round(132*W),s=o+(V.current?8+V.current.offsetHeight:0);t.setContentSize({width:Math.ceil(Math.max(i-n,o)),height:Math.ceil(Math.max(a-r,s))})},r=new ResizeObserver(n);return r.observe(e),V.current&&r.observe(V.current),H.current&&r.observe(H.current),n(),()=>r.disconnect()},[X,K.length,t.prefs.collapsed,W]);let Z=(e=J)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.conversationId,e.runId),o(t=>{let{[e.conversationId]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(M(e))},re=async()=>{if(Object.keys(l).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,d.useCallback)(e=>{e.button===0&&(D.current={pointerId:e.pointerId,x:e.screenX,y:e.screenY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),ae=(0,d.useCallback)(e=>{let t=D.current;!t||t.pointerId!==e.pointerId||(t.moved||Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4)&&(t.moved=!0,T(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,d.useCallback)(e=>{let t=D.current;if(!t||e&&t.pointerId!==e.pointerId)return;D.current=null;let n=e?.type===`pointerup`&&Number.isFinite(e.screenX)&&Number.isFinite(e.screenY),r=t.moved||n&&Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4;r&&n&&window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}),window.electronAPI?.pet?.endDrag(),r&&(T(`released`),window.setTimeout(()=>T(null),700),O.current=!0,window.setTimeout(()=>{O.current=!1},0))},[]);(0,d.useEffect)(()=>{let e=e=>Q(e),t=()=>Q();return window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`blur`,t),()=>{window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`blur`,t)}},[Q]);let oe=()=>{O.current||Z()};if(!U)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*W)}px`,"--desktop-pet-menu-size":`${Math.round(28*W)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*W)}px`},$=t.prefs.collapsed?K.length:q;return(0,N.jsxs)(`div`,{ref:B,className:`desktop-pet-window`,"data-reduced-motion":t.prefs.reducedMotion,style:se,children:[!t.prefs.collapsed&&K.length>0?(0,N.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue`,children:K.map(t=>{let n=C(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=S(t,e.tipCompleteSummary),i=w(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),a=r??n??i??t.action,o=L(I(U,t,Y),a,!!(r||n||i)),s=R(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:t.sessionLabel}),(0,N.jsxs)(`span`,{children:[o,r||n?``:x(t,p,e.tipTargetSuffix)]})]}),s?(0,N.jsx)(`span`,{className:`desktop-pet-session-cta`,children:s}):null]}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>{window.electronAPI?.pet?.acknowledgeEvent(t.conversationId,t.runId),f(e=>({...e,[t.conversationId]:{runId:t.runId,state:t.state}}))},children:(0,N.jsx)(c,{size:12})})]},t.conversationId)})}):null,X?(0,N.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:e.idleTipTitle}),(0,N.jsx)(`span`,{children:F(U.persona?.phrases?.greeting??Y.greeting,{conversationId:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+_),children:(0,N.jsx)(c,{size:12})})]})}):null,(0,N.jsxs)(`div`,{ref:H,className:`desktop-pet-stage`,children:[(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,N.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,N.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!J&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&T(`greet`)},onPointerLeave:()=>{D.current||T(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,onLostPointerCapture:Q,title:e.openApp,children:(0,N.jsx)(u,{animationKey:J?.runId,pet:U,action:ne,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*W)},U.id)})]})]})}function V(){let e=(0,f.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=window.electronAPI?.pet?(0,N.jsx)(B,{}):(0,N.jsx)(o,{kind:`desktop`,backTo:`/`}),e[0]=t):t=e[0],t}export{V as DesktopPetPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{n as i}from"./locale-store-Br7IfbXK.js";import{t as a}from"./messages-ByFlEbsu.js";import{t as o}from"./resource-unavailable-TQcRCpAg.js";import{t as s}from"./chevron-down-ccbiQQz_.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./desktop-pet-narrative-ChwjpnsG.js";import{t as u}from"./desktop-pet-sprite-D5YYq2zC.js";var d=e(t(),1),f=n(),p=9e4,m=3e4,h=20*6e4,g=45e3,_=45*6e4,v=58;function y(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=p}function b(e,t){return e.state===`running`&&t-e.timestamp>=m}function x(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.detail&&!e.action.includes(e.detail)?n.replace(/\{\{detail\}\}/g,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function S(e,t){if(e.state!==`success`||!e.publicSummary)return;let n=e.publicSummary.replace(/\s+/g,` `).trim(),r=n.length>v?`${n.slice(0,v-1)}…`:n;return t.replace(/\{\{summary\}\}/g,r)}function C(e,t,n){if(b(e,t))return n.stale;if(y(e,t))return n.longRunning}function w(e,t){let n=e.feedback?.reassurance;return n?t[n]:void 0}function ee(e){let t=e.now-e.lastActivityAt,n=t>=h?(t-h)%_:1/0;return e.bubbleEnabled&&e.behaviorMode!==`focus`&&e.proactiveTipsEnabled&&(!e.remindersPausedUntil||e.now>=e.remindersPausedUntil)&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&n<=g&&e.now>=e.dismissedUntil}function T(e,t,n){return e.state===`waiting`||e.state===`error`?`action_required`:e.state===`success`?t===`focus`?`ambient`:`notice`:b(e,n)||t===`playful`||t===`companion`&&y(e,n)?`notice`:`ambient`}function E(e,t,n,r){let i=T(e,t,n);return i===`action_required`?!0:r&&n<r?!1:i===`notice`}var D=8e3;function O(e,t){let n=e?.runId===t.runId,r=t.feedback?.sensitivity===`private`;return{...n?e:void 0,...t,startedAt:n?e.startedAt??e.timestamp:t.timestamp,publicSummary:r?void 0:t.publicSummary??(n?e.publicSummary:void 0),feedback:t.feedback??(n?e.feedback:void 0),expiresAt:t.state===`success`?t.timestamp+D:void 0}}function k(e,t){let n={...e};for(let e of t){let t=n[e.conversationId];t?.runId===e.runId&&e.sequence<=t.sequence||(n[e.conversationId]=O(t,e))}return n}function A(e,t){return t?.runId===e.runId&&t.state===e.state}function j(e,t){let n={error:0,waiting:1,running:2,success:3};return e.filter(e=>!e.expiresAt||e.expiresAt>t).sort((e,t)=>n[e.state]-n[t.state]||t.timestamp-e.timestamp).slice(0,3)}function M(e){return e?`/chat/${e.conversationId}`:void 0}var N=r();function P(e){return e?e.state===`error`?`concern`:e.state===`success`?`success`:e.animation??l(e.phase):`idle`}function F(e,t){if(!e?.length)return;let n=t.sequence;for(let e of`${t.conversationId}:${t.runId}`)n=n*31+e.charCodeAt(0)>>>0;return e[n%e.length]}function I(e,t,n){let r=e.persona?.phrases??n;if(t.state===`success`)return F(r?.success,t);if(t.state===`waiting`)return F(r?.waiting,t);if(t.state===`error`)return F(r?.error,t)}function L(e,t,n){return e?n?`${e} · ${t}`:e:t}function R(e,t){let n=e.feedback?.nextAction?.type;if(n===`confirm`)return t.needsInput;if(n===`review_error`)return t.reviewIssue;if(n===`open_session`)return t.open;if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function z(){let e=Date.now();return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`loopi`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,behaviorMode:`companion`,proactiveTipsEnabled:!0,interactionEnabled:!0,reducedMotion:!1,sizePercent:100,collapsed:!1},relationship:{firstMetAt:e,lastSeenAt:e,completedTaskCount:0,unlockedReactions:[],recentCompletedRunIds:[]},pets:[],visible:!0,customPetsDir:``,petIssues:[],activities:[]}}function B(){let e=a(i(e=>e.language)).desktopPet,[t,n]=(0,d.useState)(z),[r,o]=(0,d.useState)({}),[l,f]=(0,d.useState)({}),[p,m]=(0,d.useState)(Date.now()),[h,g]=(0,d.useState)(()=>Date.now()),[v,y]=(0,d.useState)(0),[b,T]=(0,d.useState)(null),D=(0,d.useRef)(null),O=(0,d.useRef)(!1),B=(0,d.useRef)(null),V=(0,d.useRef)(null),H=(0,d.useRef)(null),U=(0,d.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),W=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),G=(0,d.useMemo)(()=>j(Object.values(r),p),[r,p]),K=(0,d.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>!A(e,l[e.conversationId])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)):[],[G,l,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),q=(0,d.useMemo)(()=>t.prefs.bubbleEnabled?G.filter(e=>A(e,l[e.conversationId])&&E(e,t.prefs.behaviorMode,p,t.prefs.remindersPausedUntil)).length:0,[G,l,p,t.prefs.behaviorMode,t.prefs.bubbleEnabled,t.prefs.remindersPausedUntil]),J=K[0]??G[0],te=p-h>20*6e4&&(new Date(p).getHours()>=23||new Date(p).getHours()<7)?`sleep`:`idle`,ne=b??(J?P(J):te),Y=e.personaPhrases[U?.persona?.tone??`calm`],X=ee({bubbleEnabled:t.prefs.bubbleEnabled,behaviorMode:t.prefs.behaviorMode,proactiveTipsEnabled:t.prefs.proactiveTipsEnabled,remindersPausedUntil:t.prefs.remindersPausedUntil,collapsed:t.prefs.collapsed,queuedCount:K.length,activeCount:G.length,now:p,lastActivityAt:h,dismissedUntil:v});(0,d.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;let t=e=>{n(e),o(t=>k(t,e.activities))};e.getState().then(t).catch(()=>{});let r=e.onStateChanged(t),i=e.onEvent(e=>o(t=>(g(Date.now()),k(t,[e])))),a=window.setInterval(()=>m(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,r(),i(),window.clearInterval(a)}},[]),(0,d.useEffect)(()=>{if(!t.relationshipMoment)return;T(t.relationshipMoment===`first_meeting`?`wake`:`greet`);let e=window.setTimeout(()=>T(null),1400);return()=>window.clearTimeout(e)},[t.relationshipMoment]),(0,d.useLayoutEffect)(()=>{let e=B.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[V.current,H.current].filter(e=>e!==null).map(e=>({left:e.offsetLeft,top:e.offsetTop,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}));if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom)),o=Math.round(132*W),s=o+(V.current?8+V.current.offsetHeight:0);t.setContentSize({width:Math.ceil(Math.max(i-n,o)),height:Math.ceil(Math.max(a-r,s))})},r=new ResizeObserver(n);return r.observe(e),V.current&&r.observe(V.current),H.current&&r.observe(H.current),n(),()=>r.disconnect()},[X,K.length,t.prefs.collapsed,W]);let Z=(e=J)=>{e&&e.state!==`running`&&(window.electronAPI?.pet?.acknowledgeEvent(e.conversationId,e.runId),o(t=>{let{[e.conversationId]:n,...r}=t;return r})),window.electronAPI?.pet?.openMainWindow(M(e))},re=async()=>{if(Object.keys(l).length>0&&(f({}),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},ie=(0,d.useCallback)(e=>{e.button===0&&(D.current={pointerId:e.pointerId,x:e.screenX,y:e.screenY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),ae=(0,d.useCallback)(e=>{let t=D.current;!t||t.pointerId!==e.pointerId||(t.moved||Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4)&&(t.moved=!0,T(`pickedUp`),window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Q=(0,d.useCallback)(e=>{let t=D.current;if(!t||e&&t.pointerId!==e.pointerId)return;D.current=null;let n=e?.type===`pointerup`&&Number.isFinite(e.screenX)&&Number.isFinite(e.screenY),r=t.moved||n&&Math.abs(e.screenX-t.x)+Math.abs(e.screenY-t.y)>4;r&&n&&window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}),window.electronAPI?.pet?.endDrag(),r&&(T(`released`),window.setTimeout(()=>T(null),700),O.current=!0,window.setTimeout(()=>{O.current=!1},0))},[]);(0,d.useEffect)(()=>{let e=e=>Q(e),t=()=>Q();return window.addEventListener(`pointerup`,e),window.addEventListener(`pointercancel`,e),window.addEventListener(`blur`,t),()=>{window.removeEventListener(`pointerup`,e),window.removeEventListener(`pointercancel`,e),window.removeEventListener(`blur`,t)}},[Q]);let oe=()=>{O.current||Z()};if(!U)return null;let se={"--desktop-pet-stage-size":`${Math.round(132*W)}px`,"--desktop-pet-menu-size":`${Math.round(28*W)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*W)}px`},$=t.prefs.collapsed?K.length:q;return(0,N.jsxs)(`div`,{ref:B,className:`desktop-pet-window`,"data-reduced-motion":t.prefs.reducedMotion,style:se,children:[!t.prefs.collapsed&&K.length>0?(0,N.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue`,children:K.map(t=>{let n=C(t,p,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=S(t,e.tipCompleteSummary),i=w(t,{making_progress:e.petReassuranceMakingProgress,waiting_safely:e.petReassuranceWaitingSafely,completed:e.petReassuranceCompleted,work_preserved:e.petReassuranceWorkPreserved,details_available:e.petReassuranceDetailsAvailable}),a=r??n??i??t.action,o=L(I(U,t,Y),a,!!(r||n||i)),s=R(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(t),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:t.sessionLabel}),(0,N.jsxs)(`span`,{children:[o,r||n?``:x(t,p,e.tipTargetSuffix)]})]}),s?(0,N.jsx)(`span`,{className:`desktop-pet-session-cta`,children:s}):null]}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>{window.electronAPI?.pet?.acknowledgeEvent(t.conversationId,t.runId),f(e=>({...e,[t.conversationId]:{runId:t.runId,state:t.state}}))},children:(0,N.jsx)(c,{size:12})})]},t.conversationId)})}):null,X?(0,N.jsx)(`div`,{ref:V,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,N.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>Z(),children:[(0,N.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,N.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,N.jsx)(`strong`,{children:e.idleTipTitle}),(0,N.jsx)(`span`,{children:F(U.persona?.phrases?.greeting??Y.greeting,{conversationId:`idle`,runId:`idle`,sessionLabel:``,sequence:0,timestamp:h,state:`running`,phase:`waiting`,action:e.idleTipBody})??e.idleTipBody})]})]}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":e.dismissSession,onClick:()=>y(p+_),children:(0,N.jsx)(c,{size:12})})]})}):null,(0,N.jsxs)(`div`,{ref:H,className:`desktop-pet-stage`,children:[(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void re(),"aria-label":e.menu,children:$>0?(0,N.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,N.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,N.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:oe,onPointerEnter:()=>{!J&&t.prefs.interactionEnabled&&t.prefs.behaviorMode===`playful`&&T(`greet`)},onPointerLeave:()=>{D.current||T(null)},onPointerDown:ie,onPointerMove:ae,onPointerUp:Q,onPointerCancel:Q,onLostPointerCapture:Q,title:e.openApp,children:(0,N.jsx)(u,{animationKey:J?.runId,pet:U,action:ne,reducedMotion:t.prefs.reducedMotion,displayHeight:Math.round(112*W)},U.id)})]})]})}function V(){let e=(0,f.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=window.electronAPI?.pet?(0,N.jsx)(B,{}):(0,N.jsx)(o,{kind:`desktop`,backTo:`/`}),e[0]=t):t=e[0],t}export{V as DesktopPetPage};
@@ -1 +1 @@
1
- import{n as e}from"./tool-friendly-title-DGmi7rCQ.js";function t(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>{let r=t[n];return r===void 0||r===``?``:String(r)}).replace(/\s+/g,` `).trim()}function n(e,t,n){return typeof t!=`number`||typeof n!=`number`?``:e.progressSuffix.replace(/\{\{completed\}\}/g,String(t)).replace(/\{\{total\}\}/g,String(n))}function r(e){return e===`researching`||e===`browsing`?`research`:e===`reading`?`read`:e===`editing`?`create`:e===`planning`||e===`compacting`||e===`preparing`?`prepare`:e===`waiting`?`wait`:`execute`}function i(n,i,a,o,s){let c=e(i,n,s);return{action:t(n.tipTool,{action:c,detail:o?t(n.targetSuffix,{detail:o}):``}),animation:r(a),priority:`normal`}}function a(e,i,a,o){return{action:t(i===`running`?e.tipValidate:e.tipProgress,{progress:n(e,a,o)}),animation:r(i),priority:`normal`}}export{a as n,i as r,r as t};
1
+ import{n as e}from"./tool-friendly-title-DcCc6g7o.js";function t(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>{let r=t[n];return r===void 0||r===``?``:String(r)}).replace(/\s+/g,` `).trim()}function n(e,t,n){return typeof t!=`number`||typeof n!=`number`?``:e.progressSuffix.replace(/\{\{completed\}\}/g,String(t)).replace(/\{\{total\}\}/g,String(n))}function r(e){return e===`researching`||e===`browsing`?`research`:e===`reading`?`read`:e===`editing`?`create`:e===`planning`||e===`compacting`||e===`preparing`?`prepare`:e===`waiting`?`wait`:`execute`}function i(n,i,a,o,s){let c=e(i,n,s);return{action:t(n.tipTool,{action:c,detail:o?t(n.targetSuffix,{detail:o}):``}),animation:r(a),priority:`normal`}}function a(e,i,a,o){return{action:t(i===`running`?e.tipValidate:e.tipProgress,{progress:n(e,a,o)}),animation:r(i),priority:`normal`}}export{a as n,i as r,r as t};
@@ -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{n as a}from"./locale-store-TQcz_Vjt.js";import{t as o}from"./messages-DaLmc4W1.js";import{t as s}from"./resource-unavailable-X-SIrZYI.js";import{t as c}from"./chevron-down-ccbiQQz_.js";import{n as l,r as u}from"./popover-select-DD8fmrxH.js";import{t as d}from"./circle-alert-BEjgurr2.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./message-square-plus-XP0tGdlV.js";import{n as m,t as h}from"./wand-sparkles-CkSL-3Fy.js";import{t as g}from"./rotate-ccw-JM1TBLpp.js";import{t as _}from"./cn-0WouolD0.js";import{t as v}from"./skeleton-BI5TyibZ.js";import{n as y}from"./interaction-BdhHBbYa.js";import{n as b}from"./electron-env-DHOGevH3.js";import{t as x}from"./refresh-button-bU_0NarN.js";import{t as S}from"./desktop-pet-sprite-D5YYq2zC.js";import{n as C,t as w}from"./settings-page-header-DuNCn8i-.js";import"./settings-page-layout-DeNC8YHJ.js";var T=n(),E=e(t(),1),D=r();function O(e){let t=(0,T.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,D.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,D.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r}):null,t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,D.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,D.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,D.jsxs)(`label`,{className:`flex min-h-12 cursor-pointer items-center justify-between gap-3 py-3`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function k(){let e=o(a(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,E.useState)(null),[T,k]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),M=typeof window<`u`?window.electronAPI?.pet:void 0,N=(0,E.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),P=(0,E.useCallback)(async()=>{if(M){k(!0);try{r(await M.getState())}finally{k(!1)}}},[M]);if((0,E.useEffect)(()=>{if(M)return P(),M.onStateChanged(r)},[M,P]),!b()||!M)return(0,D.jsx)(s,{kind:`desktop`,backTo:`/settings/overview`});if(!n)return(0,D.jsxs)(C,{gap:`gap-4`,children:[(0,D.jsx)(w,{title:e.title,subtitle:e.subtitle}),(0,D.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(v,{className:`h-14 rounded-xl`}),(0,D.jsx)(v,{className:`h-14 rounded-xl`}),(0,D.jsx)(v,{className:`h-24 rounded-xl`}),(0,D.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(v,{className:`h-16 rounded-xl`},t))})]})})]});let F=async e=>{k(!0);try{r(await M.setPrefs(e))}finally{k(!1)}},I=async e=>{e?(await M.show(),r(await M.getState())):r(await M.setPrefs({enabled:!1}))},L=e=>{F({selectedPetId:e})},R=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},z=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},B=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=R(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},V=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),H=()=>{z(e.createChatDraft)},U=t=>{let n=V(e.optimizeChatDraft,{id:t.id,name:R(t).name,description:R(t).description,sourcePrompt:B(t)});z(n)},W=t=>{let n=V(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails});z(n)},G=A??n.prefs.sizePercent,K=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),q=async(e=G)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));j(null),t!==n.prefs.sizePercent&&await F({sizePercent:t})};return(0,D.jsxs)(C,{gap:`gap-5`,children:[(0,D.jsx)(w,{title:e.title,subtitle:e.subtitle,actions:(0,D.jsx)(x,{className:`size-9 shrink-0 p-0`,disabled:T,label:e.refresh,onClick:P})}),(0,D.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:gap-6`,children:[(0,D.jsx)(`div`,{className:`grid h-40 w-40 shrink-0 place-items-center self-center rounded-xl bg-surface-hover/35`,children:N?(0,D.jsx)(S,{pet:N,action:`idle`,displayHeight:Math.round(104*G/100),reducedMotion:n.prefs.reducedMotion}):null}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-2`,children:[(0,D.jsx)(`h2`,{className:`break-words text-xl font-semibold text-fg`,children:N?R(N).name:e.title}),(0,D.jsx)(O,{title:e.enable,checked:n.prefs.enabled,disabled:T,onChange:e=>void I(e)})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondSummary.replace(`{days}`,String(K)).replace(`{tasks}`,String(n.relationship.completedTaskCount))}),n.pets.length>1?(0,D.jsx)(`div`,{className:`mt-4 max-w-56`,children:(0,D.jsx)(l,{"aria-label":e.petList,value:N?.id??``,onChange:e=>L(e.target.value),disabled:T,children:n.pets.map(e=>(0,D.jsx)(u,{value:e.id,children:R(e).name},e.id))})}):null,N&&!N.builtin?(0,D.jsxs)(`button`,{type:`button`,onClick:()=>U(N),className:`mt-3 inline-flex min-h-9 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,D.jsx)(m,{className:`size-3.5`}),e.optimizeInChat]}):null]})]}),(0,D.jsx)(`div`,{className:`border-t border-edge px-5 py-2`,children:(0,D.jsxs)(`button`,{type:`button`,onClick:H,className:_(`inline-flex min-h-10 items-center gap-2 text-xs font-medium text-fg-muted hover:text-accent-fg`,y.press),children:[(0,D.jsx)(h,{className:`size-4`}),e.createTitle]})})]}),n.petIssues.length>0?(0,D.jsxs)(`section`,{className:`rounded-xl border border-danger/20 bg-danger/5 p-4`,children:[(0,D.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,D.jsx)(d,{className:`size-4`}),e.invalidPets]}),(0,D.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.petIssues.map(t=>(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,D.jsx)(`p`,{className:`break-words`,children:t.reason}),(0,D.jsxs)(`details`,{className:`mt-1`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer`,children:e.issueDetails}),(0,D.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:t.dir}),t.details?.length?(0,D.jsx)(`p`,{className:`mt-1 break-words`,children:t.details.join(`; `)}):null]})]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>W(t),className:`inline-flex min-h-9 shrink-0 items-center gap-1.5 text-xs font-medium text-danger`,children:[(0,D.jsx)(p,{className:`size-3.5`}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null,(0,D.jsxs)(`section`,{"aria-label":e.displayGroup,children:[(0,D.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.displayGroup}),(0,D.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,D.jsx)(O,{title:e.showOnStartup,checked:n.prefs.showOnStartup,disabled:T,onChange:e=>void F({showOnStartup:e})}),(0,D.jsx)(O,{title:e.alwaysOnTop,checked:n.prefs.alwaysOnTop,disabled:T,onChange:e=>void F({alwaysOnTop:e})}),(0,D.jsx)(O,{title:e.bubbles,checked:n.prefs.bubbleEnabled,disabled:T,onChange:e=>void F({bubbleEnabled:e})}),(0,D.jsxs)(`div`,{className:`py-3`,children:[(0,D.jsxs)(`label`,{htmlFor:`desktop-pet-size`,className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[e.size,(0,D.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[G,`%`]})]}),(0,D.jsx)(`input`,{id:`desktop-pet-size`,type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:G,disabled:T,onChange:e=>j(Number(e.target.value)),onBlur:()=>void q(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&q()},onPointerUp:()=>void q()})]})]})]}),(0,D.jsxs)(`section`,{"aria-label":e.interactionGroup,children:[(0,D.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.interactionGroup}),(0,D.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,D.jsx)(O,{title:e.proactiveTips,checked:n.prefs.proactiveTipsEnabled,disabled:T,onChange:e=>void F({proactiveTipsEnabled:e})}),(0,D.jsx)(O,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:T,onChange:e=>void F({interactionEnabled:e})}),(0,D.jsx)(O,{title:e.reducedMotion,checked:n.prefs.reducedMotion,disabled:T,onChange:e=>void F({reducedMotion:e})}),(0,D.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-3 py-3`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,D.jsxs)(l,{"aria-label":e.behaviorMode,className:`w-36`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,disabled:T,onChange:e=>void F({behaviorMode:e.target.value}),children:[(0,D.jsx)(u,{value:`focus`,children:e.behaviorFocus}),(0,D.jsx)(u,{value:`companion`,children:e.behaviorCompanion}),(0,D.jsx)(u,{value:`playful`,children:e.behaviorPlayful})]})]})]})]}),(0,D.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-panel`,children:[(0,D.jsxs)(`summary`,{className:`flex min-h-12 cursor-pointer list-none items-center justify-between gap-3 px-4 text-sm font-medium text-fg [&::-webkit-details-marker]:hidden`,children:[e.advanced,(0,D.jsx)(c,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`})]}),(0,D.jsxs)(`div`,{className:`space-y-3 border-t border-edge px-4 pb-4`,children:[(0,D.jsx)(O,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:T,onChange:e=>void F({clickThroughWhenIdle:e})}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge pt-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.customPets}),(0,D.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void M.openCustomPetsDir(),className:`inline-flex min-h-10 shrink-0 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,D.jsx)(f,{className:`size-3.5`}),e.openFolder]})]}),(0,D.jsxs)(`button`,{type:`button`,className:_(`inline-flex min-h-10 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg disabled:opacity-50`,y.press),disabled:T,onClick:()=>void M.resetPosition().then(r),children:[(0,D.jsx)(g,{className:`size-3.5`}),e.resetPosition]})]})]})]})}export{k as DesktopPetSettings};
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{n as a}from"./locale-store-Br7IfbXK.js";import{t as o}from"./messages-ByFlEbsu.js";import{t as s}from"./resource-unavailable-TQcRCpAg.js";import{t as c}from"./chevron-down-ccbiQQz_.js";import{n as l,r as u}from"./popover-select-DD8fmrxH.js";import{t as d}from"./circle-alert-BEjgurr2.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./message-square-plus-XP0tGdlV.js";import{n as m,t as h}from"./wand-sparkles-CkSL-3Fy.js";import{t as g}from"./rotate-ccw-JM1TBLpp.js";import{t as _}from"./cn-0WouolD0.js";import{t as v}from"./skeleton-BI5TyibZ.js";import{n as y}from"./interaction-BdhHBbYa.js";import{n as b}from"./electron-env-DHOGevH3.js";import{t as x}from"./refresh-button-bU_0NarN.js";import{t as S}from"./desktop-pet-sprite-D5YYq2zC.js";import{n as C,t as w}from"./settings-page-header-DBL0_u0Z.js";import"./settings-page-layout-IAvpbz4A.js";var T=n(),E=e(t(),1),D=r();function O(e){let t=(0,T.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,D.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=r?(0,D.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r}):null,t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,D.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,D.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,D.jsxs)(`label`,{className:`flex min-h-12 cursor-pointer items-center justify-between gap-3 py-3`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function k(){let e=o(a(e=>e.language)).desktopPetSettings,t=i(),[n,r]=(0,E.useState)(null),[T,k]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),M=typeof window<`u`?window.electronAPI?.pet:void 0,N=(0,E.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),P=(0,E.useCallback)(async()=>{if(M){k(!0);try{r(await M.getState())}finally{k(!1)}}},[M]);if((0,E.useEffect)(()=>{if(M)return P(),M.onStateChanged(r)},[M,P]),!b()||!M)return(0,D.jsx)(s,{kind:`desktop`,backTo:`/settings/overview`});if(!n)return(0,D.jsxs)(C,{gap:`gap-4`,children:[(0,D.jsx)(w,{title:e.title,subtitle:e.subtitle}),(0,D.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,"aria-busy":!0,"aria-label":e.loading,children:(0,D.jsxs)(`div`,{className:`space-y-3`,children:[(0,D.jsx)(v,{className:`h-14 rounded-xl`}),(0,D.jsx)(v,{className:`h-14 rounded-xl`}),(0,D.jsx)(v,{className:`h-24 rounded-xl`}),(0,D.jsx)(`div`,{className:`space-y-2 pt-2`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(v,{className:`h-16 rounded-xl`},t))})]})})]});let F=async e=>{k(!0);try{r(await M.setPrefs(e))}finally{k(!1)}},I=async e=>{e?(await M.show(),r(await M.getState())):r(await M.setPrefs({enabled:!1}))},L=e=>{F({selectedPetId:e})},R=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},z=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},B=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=R(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},V=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),H=()=>{z(e.createChatDraft)},U=t=>{let n=V(e.optimizeChatDraft,{id:t.id,name:R(t).name,description:R(t).description,sourcePrompt:B(t)});z(n)},W=t=>{let n=V(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails});z(n)},G=A??n.prefs.sizePercent,K=Math.max(1,Math.floor((Date.now()-n.relationship.firstMetAt)/864e5)+1),q=async(e=G)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));j(null),t!==n.prefs.sizePercent&&await F({sizePercent:t})};return(0,D.jsxs)(C,{gap:`gap-5`,children:[(0,D.jsx)(w,{title:e.title,subtitle:e.subtitle,actions:(0,D.jsx)(x,{className:`size-9 shrink-0 p-0`,disabled:T,label:e.refresh,onClick:P})}),(0,D.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:gap-6`,children:[(0,D.jsx)(`div`,{className:`grid h-40 w-40 shrink-0 place-items-center self-center rounded-xl bg-surface-hover/35`,children:N?(0,D.jsx)(S,{pet:N,action:`idle`,displayHeight:Math.round(104*G/100),reducedMotion:n.prefs.reducedMotion}):null}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-6 gap-y-2`,children:[(0,D.jsx)(`h2`,{className:`break-words text-xl font-semibold text-fg`,children:N?R(N).name:e.title}),(0,D.jsx)(O,{title:e.enable,checked:n.prefs.enabled,disabled:T,onChange:e=>void I(e)})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.bondSummary.replace(`{days}`,String(K)).replace(`{tasks}`,String(n.relationship.completedTaskCount))}),n.pets.length>1?(0,D.jsx)(`div`,{className:`mt-4 max-w-56`,children:(0,D.jsx)(l,{"aria-label":e.petList,value:N?.id??``,onChange:e=>L(e.target.value),disabled:T,children:n.pets.map(e=>(0,D.jsx)(u,{value:e.id,children:R(e).name},e.id))})}):null,N&&!N.builtin?(0,D.jsxs)(`button`,{type:`button`,onClick:()=>U(N),className:`mt-3 inline-flex min-h-9 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,D.jsx)(m,{className:`size-3.5`}),e.optimizeInChat]}):null]})]}),(0,D.jsx)(`div`,{className:`border-t border-edge px-5 py-2`,children:(0,D.jsxs)(`button`,{type:`button`,onClick:H,className:_(`inline-flex min-h-10 items-center gap-2 text-xs font-medium text-fg-muted hover:text-accent-fg`,y.press),children:[(0,D.jsx)(h,{className:`size-4`}),e.createTitle]})})]}),n.petIssues.length>0?(0,D.jsxs)(`section`,{className:`rounded-xl border border-danger/20 bg-danger/5 p-4`,children:[(0,D.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-medium text-danger`,children:[(0,D.jsx)(d,{className:`size-4`}),e.invalidPets]}),(0,D.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.petIssues.map(t=>(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,D.jsx)(`p`,{className:`break-words`,children:t.reason}),(0,D.jsxs)(`details`,{className:`mt-1`,children:[(0,D.jsx)(`summary`,{className:`cursor-pointer`,children:e.issueDetails}),(0,D.jsx)(`p`,{className:`mt-2 break-all font-mono`,children:t.dir}),t.details?.length?(0,D.jsx)(`p`,{className:`mt-1 break-words`,children:t.details.join(`; `)}):null]})]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>W(t),className:`inline-flex min-h-9 shrink-0 items-center gap-1.5 text-xs font-medium text-danger`,children:[(0,D.jsx)(p,{className:`size-3.5`}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null,(0,D.jsxs)(`section`,{"aria-label":e.displayGroup,children:[(0,D.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.displayGroup}),(0,D.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,D.jsx)(O,{title:e.showOnStartup,checked:n.prefs.showOnStartup,disabled:T,onChange:e=>void F({showOnStartup:e})}),(0,D.jsx)(O,{title:e.alwaysOnTop,checked:n.prefs.alwaysOnTop,disabled:T,onChange:e=>void F({alwaysOnTop:e})}),(0,D.jsx)(O,{title:e.bubbles,checked:n.prefs.bubbleEnabled,disabled:T,onChange:e=>void F({bubbleEnabled:e})}),(0,D.jsxs)(`div`,{className:`py-3`,children:[(0,D.jsxs)(`label`,{htmlFor:`desktop-pet-size`,className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[e.size,(0,D.jsxs)(`span`,{className:`text-xs tabular-nums text-fg-muted`,children:[G,`%`]})]}),(0,D.jsx)(`input`,{id:`desktop-pet-size`,type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:G,disabled:T,onChange:e=>j(Number(e.target.value)),onBlur:()=>void q(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&q()},onPointerUp:()=>void q()})]})]})]}),(0,D.jsxs)(`section`,{"aria-label":e.interactionGroup,children:[(0,D.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.interactionGroup}),(0,D.jsxs)(`div`,{className:`divide-y divide-edge rounded-xl border border-edge bg-surface-panel px-4`,children:[(0,D.jsx)(O,{title:e.proactiveTips,checked:n.prefs.proactiveTipsEnabled,disabled:T,onChange:e=>void F({proactiveTipsEnabled:e})}),(0,D.jsx)(O,{title:e.interactions,desc:e.interactionsDesc,checked:n.prefs.interactionEnabled,disabled:T,onChange:e=>void F({interactionEnabled:e})}),(0,D.jsx)(O,{title:e.reducedMotion,checked:n.prefs.reducedMotion,disabled:T,onChange:e=>void F({reducedMotion:e})}),(0,D.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-3 py-3`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.behaviorMode}),(0,D.jsxs)(l,{"aria-label":e.behaviorMode,className:`w-36`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.behaviorMode,disabled:T,onChange:e=>void F({behaviorMode:e.target.value}),children:[(0,D.jsx)(u,{value:`focus`,children:e.behaviorFocus}),(0,D.jsx)(u,{value:`companion`,children:e.behaviorCompanion}),(0,D.jsx)(u,{value:`playful`,children:e.behaviorPlayful})]})]})]})]}),(0,D.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-panel`,children:[(0,D.jsxs)(`summary`,{className:`flex min-h-12 cursor-pointer list-none items-center justify-between gap-3 px-4 text-sm font-medium text-fg [&::-webkit-details-marker]:hidden`,children:[e.advanced,(0,D.jsx)(c,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`})]}),(0,D.jsxs)(`div`,{className:`space-y-3 border-t border-edge px-4 pb-4`,children:[(0,D.jsx)(O,{title:e.clickThrough,desc:e.clickThroughDesc,checked:n.prefs.clickThroughWhenIdle,disabled:T,onChange:e=>void F({clickThroughWhenIdle:e})}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge pt-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.customPets}),(0,D.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void M.openCustomPetsDir(),className:`inline-flex min-h-10 shrink-0 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[(0,D.jsx)(f,{className:`size-3.5`}),e.openFolder]})]}),(0,D.jsxs)(`button`,{type:`button`,className:_(`inline-flex min-h-10 items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg disabled:opacity-50`,y.press),disabled:T,onClick:()=>void M.resetPosition().then(r),children:[(0,D.jsx)(g,{className:`size-3.5`}),e.resetPosition]})]})]})]})}export{k as DesktopPetSettings};
@@ -1 +1 @@
1
- import{p as e}from"./locale-store-TQcz_Vjt.js";import{t}from"./middleware-Pd0e8Igk.js";var n=e(t(e=>({showRawToolData:!1,setShowRawToolData:t=>e({showRawToolData:t})}),{name:`xopc-web-dev-view`}));export{n as t};
1
+ import{p as e}from"./locale-store-Br7IfbXK.js";import{t}from"./middleware-Pd0e8Igk.js";var n=e(t(e=>({showRawToolData:!1,setShowRawToolData:t=>e({showRawToolData:t})}),{name:`xopc-web-dev-view`}));export{n as t};
@@ -0,0 +1 @@
1
+ import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{n as o}from"./locale-store-Br7IfbXK.js";import{t as s}from"./messages-ByFlEbsu.js";import{t as c}from"./chevron-right-BweFrslA.js";import{t as l}from"./circle-check-C23XjkUj.js";import{t as u}from"./clock-3-DnrAnuyZ.js";import{t as d}from"./download-Dk-ZjtO6.js";import{t as f}from"./external-link-DjqjBmc3.js";import{t as p}from"./laptop-CI3hBVrl.js";import{t as m}from"./panel-right-CFGrHTsD.js";import{t as h}from"./smartphone-DSSsQFqA.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./cn-0WouolD0.js";import{t as v}from"./button-CnRSIP6m.js";import{t as y}from"./skeleton-BI5TyibZ.js";import{a as b,i as ee,o as x,r as S,s as te,t as C}from"./dist-DfWfZ9iu.js";import{a as w,i as T,o as E,s as D}from"./dist-CaUuvp8-.js";import{a as O,i as ne,o as re}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{i as k}from"./vendor-swr-CdRzEUwF.js";import{n as A}from"./app-link-1j40sJ-z.js";import{t as j}from"./use-async-resource-BHFGZCY2.js";import{t as M}from"./copy-text-row-CYIv7RfP.js";import{a as ie,n as N,r as P}from"./oauth-api-DMMdeaNd.js";import{n as ae,r as F,t as I}from"./oauth-authorization-window-o6URRos4.js";import{_ as oe,a as L,b as se,d as R,f as ce,g as le,h as ue,i as de,l as z,m as fe,n as pe,p as me,r as B,s as V,t as H,u as he,v as ge,y as _e}from"./tunnel-api-BB7u79ID.js";import{t as ve}from"./mobile-pair-qr-CuIbmw5x.js";var U=r(),W=e(n(),1),G=i();function ye(){let e=s(o(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=k(`tunnel-status`,pe,{refreshInterval:1500}),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!0),[h,g]=(0,W.useState)(`idle`),[_,b]=(0,W.useState)(null),[ee,x]=(0,W.useState)(``),[S,te]=(0,W.useState)(``),C=(0,W.useRef)(!0);(0,W.useEffect)(()=>(C.current=!0,()=>{C.current=!1}),[]),(0,W.useEffect)(()=>{r?.state===`connected`&&(b(null),x(``))},[r?.state]);let w=_?_===`registration-rejected`:r?.state===`error`&&ce(Error(r.lastError??``)),T=_?_===`recovery-rejected`:r?.state===`error`&&R(Error(r.lastError??``)),E=async()=>{if(!r)return;if(r.consentRequired&&!c){d(!0);return}let e=w||!r.registrationSecret?.configured,t=e?F():null,n,i=!1;b(null),x(``);try{if(r.consentRequired&&await L(),e){g(`provisioning`),w&&await B({registrationSecret:null});let e=!1;try{await de()}catch(t){if(!he(t))throw t;e=!0}if(e){g(`authorizing`);let e=sessionStorage.getItem(`device-pairing-oauth`),r=e?JSON.parse(e):null;n=r&&r.expiresAt>Date.now()?r.sessionId:(await ie(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:n,expiresAt:r&&r.expiresAt>Date.now()?r.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;C.current&&Date.now()<o;){let e=await P(n);if(e.authUrl&&e.authUrl!==a&&(a=e.authUrl,await ae(a,t)||te(a)),e.status===`completed`){s=!0,i=!0;break}if(e.status===`failed`||e.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!C.current)return;if(!s)throw Error(`Authorization expired`);await de()}await a()}if(!C.current)return;g(`starting`),await V(T?{recoverActiveLease:!0}:void 0),p&&await B({autoStart:!0}),await a(),i=!0}catch(e){i=!0,C.current&&(b(z(e)===`tunnel_key_limit_reached`?`key-limit`:ce(e)?`registration-rejected`:R(e)?`recovery-rejected`:`failed`),x(e instanceof Error?e.message:``))}finally{I(t),i&&(sessionStorage.removeItem(`device-pairing-oauth`),n&&N(n).catch(()=>{})),C.current&&(g(`idle`),te(``))}};if(!r&&!i)return(0,G.jsxs)(`div`,{className:`space-y-5`,children:[(0,G.jsx)(y,{className:`h-5 w-4/5`}),(0,G.jsx)(y,{className:`h-24 w-full`})]});let D=h===`provisioning`||h===`starting`||r?.state===`connecting`||r?.state===`reconnecting`,O=h===`idle`&&!D&&(_||i||r?.state===`error`),ne=ee||(i instanceof Error?i.message:``)||(r?.state===`error`?r.lastError:``);return(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:D?t.preparingHint:h===`authorizing`?t.authorizing:t.enableHint}),S&&h===`authorizing`?(0,G.jsx)(`a`,{href:S,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,D?(0,G.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,G.jsx)(y,{className:`h-2 w-full`}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(u||r?.consentRequired)&&h===`idle`?(0,G.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,G.jsxs)(`details`,{open:u,className:`text-sm text-fg-muted`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,G.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,G.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,G.jsx)(`li`,{children:e},e))})]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,O&&_===`key-limit`?(0,G.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,G.jsxs)(v,{variant:`secondary`,className:`mt-3`,onClick:()=>void A(H),children:[t.manageTunnelKeys,(0,G.jsx)(f,{className:`size-3`})]})]}):O?(0,G.jsxs)(`div`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:[(0,G.jsx)(`p`,{children:i&&!r?t.readinessFailed:w?t.routeAuthorizationRequired:T?t.routeRecoveryRequired:t.routeSetupFailed}),ne?(0,G.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,G.jsx)(`p`,{className:`break-words whitespace-pre-wrap`,children:ne})]}):null]}):null,(0,G.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:p,disabled:h!==`idle`,onChange:e=>m(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),i&&!r?(0,G.jsx)(v,{className:`w-full`,variant:`primary`,onClick:()=>void a().catch(()=>{}),children:t.retry}):(0,G.jsx)(v,{className:`w-full`,variant:`primary`,disabled:!r||h!==`idle`||D||u&&!c,onClick:()=>void E(),children:h===`authorizing`?t.authorizing:D?t.preparing:w?t.authorize:T?t.recoverRoute:O?t.retry:t.enable})]})}var K=t({DevicePairingWizard:()=>q});function q(e){let t=(0,U.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,W.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,W.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,G.jsx)(X,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,G.jsx)(Y,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,G.jsx)(C,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function J(e){let t=(0,U.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,G.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,G.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,G.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let l;t[4]===i?l=t[5]:(l=(0,G.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=l);let u;t[6]!==s||t[7]!==l?(u=(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[s,l]}),t[6]=s,t[7]=l,t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,G.jsx)(c,{className:`size-4 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":`true`}),t[9]=d):d=t[9];let f;return t[10]!==a||t[11]!==o||t[12]!==u?(f=(0,G.jsxs)(`button`,{type:`button`,className:`group flex min-h-18 w-full cursor-pointer items-center gap-4 rounded-xl border border-edge bg-surface-panel px-4 py-3.5 text-left shadow-surface transition-[background-color,border-color,box-shadow,transform] hover:border-edge-strong hover:bg-surface-active hover:shadow-elevated active:translate-y-px active:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel motion-reduce:active:translate-y-0`,onClick:a,children:[o,u,d]}),t[10]=a,t[11]=o,t[12]=u,t[13]=f):f=t[13],f}function Y(e){let t=(0,U.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=o(be),c;t[0]===a?c=t[1]:(c=s(a),t[0]=a,t[1]=c);let l=c.endpointToolsSettings.deviceAccess,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,G.jsx)(b,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,re)}),t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=_(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(28rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,ne),t[3]=d):d=t[3];let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,G.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=f):f=t[4];let v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,G.jsx)(g,{className:`size-4`}),t[5]=v):v=t[5];let y;t[6]!==l.cancel||t[7]!==i?(y=(0,G.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[f,(0,G.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":l.cancel,onClick:i,children:v})]}),t[6]=l.cancel,t[7]=i,t[8]=y):y=t[8];let C;t[9]===l.chooseTitle?C=t[10]:(C=(0,G.jsx)(te,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:l.chooseTitle}),t[9]=l.chooseTitle,t[10]=C);let w;t[11]===l.chooseHint?w=t[12]:(w=(0,G.jsx)(ee,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:l.chooseHint}),t[11]=l.chooseHint,t[12]=w);let T;t[13]!==l.localBrowserHint||t[14]!==l.localBrowserTitle||t[15]!==r?(T=(0,G.jsx)(J,{icon:p,title:l.localBrowserTitle,hint:l.localBrowserHint,onClick:r}),t[13]=l.localBrowserHint,t[14]=l.localBrowserTitle,t[15]=r,t[16]=T):T=t[16];let E;t[17]===n?E=t[18]:(E=()=>n(`mobile`),t[17]=n,t[18]=E);let D;t[19]!==l.mobileHint||t[20]!==l.mobileTitle||t[21]!==E?(D=(0,G.jsx)(J,{icon:h,title:l.mobileTitle,hint:l.mobileHint,onClick:E}),t[19]=l.mobileHint,t[20]=l.mobileTitle,t[21]=E,t[22]=D):D=t[22];let O;t[23]===n?O=t[24]:(O=()=>n(`browser`),t[23]=n,t[24]=O);let k;t[25]!==l.remoteBrowserHint||t[26]!==l.remoteBrowserTitle||t[27]!==O?(k=(0,G.jsx)(J,{icon:m,title:l.remoteBrowserTitle,hint:l.remoteBrowserHint,onClick:O}),t[25]=l.remoteBrowserHint,t[26]=l.remoteBrowserTitle,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==D||t[30]!==k||t[31]!==T?(A=(0,G.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[T,D,k]}),t[29]=D,t[30]=k,t[31]=T,t[32]=A):A=t[32];let j;t[33]!==A||t[34]!==C||t[35]!==w?(j=(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[C,w,A]}),t[33]=A,t[34]=C,t[35]=w,t[36]=j):j=t[36];let M;return t[37]!==j||t[38]!==y?(M=(0,G.jsxs)(x,{children:[u,(0,G.jsxs)(S,{className:d,children:[y,j]})]}),t[37]=j,t[38]=y,t[39]=M):M=t[39],M}function be(e){return e.language}function X({targetKind:e,onClose:t,onPaired:n}){let r=o(e=>e.language),i=s(r),a=i.endpointToolsSettings.deviceAccess,p=a.flow,[m,h]=(0,W.useState)(e===`mobile`),[C,ie]=(0,W.useState)(!1),N=k(m?`device-pairing-readiness`:null,oe,{refreshInterval:1500}),[P,ae]=(0,W.useState)(),[F,I]=(0,W.useState)(null),[L,R]=(0,W.useState)(!1),[ce,de]=(0,W.useState)(Date.now()),[z,pe]=(0,W.useState)(null),B=(0,W.useRef)(!0),V=(0,W.useRef)(null),H=(0,W.useRef)(!1),he=(0,W.useRef)(!1),U=k(P?[`device-pairing-setup`,P.id]:null,()=>ge(P.id),{refreshInterval:1500}),K=U.data?.request,q=K?.status===`completed`,J=q&&K.connectedAt!==void 0,Y=k(J&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),be=P?.targetKind===`mobile`?P.universalLink:``,X=j(()=>ve(be),[be],{enabled:!!be,initial:null,errorData:null}),xe=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,Se=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,Ce=j(()=>ve(xe),[xe],{enabled:C&&e===`mobile`,initial:null,errorData:null});(0,W.useEffect)(()=>{B.current=!0;let e=setInterval(()=>de(Date.now()),1e3);return()=>{B.current=!1,clearInterval(e),V.current&&me(V.current).catch(()=>{})}},[]);let Z=(0,W.useCallback)(async()=>{if(!H.current){H.current=!0,R(!0),I(null);try{V.current&&await me(V.current),V.current=null,ae(void 0);let t=await fe(e);if(t.kind===`ready`){if(!B.current){await me(t.setup.id);return}V.current=t.setup.id,ae(t.setup)}else await N.mutate()}catch{B.current&&I(`create`)}finally{H.current=!1,B.current&&R(!1)}}},[N,e]);(0,W.useEffect)(()=>{N.data?.ready&&!P&&F!==`create`&&!H.current&&Z()},[N.data,P,F,Z]),(0,W.useEffect)(()=>{J&&!he.current&&(he.current=!0,n?.())},[J,n]);let we=async e=>{if(K){R(!0),I(null);try{await ue(K,e),await U.mutate()}catch{I(`decision`),await U.mutate()}finally{B.current&&R(!1)}}},Te=(0,W.useRef)(0);(0,W.useEffect)(()=>{U.data&&(Te.current=U.data.serverTime-Date.now())},[U.data]);let Q=ce+Te.current,Ee=P&&Q>=P.expiresAt&&!K,De=K&&[`expired`,`rejected`,`cancelled`].includes(K.status),Oe=P?P.expiresAt-Q<6e4:!1,ke=P?Oe?`${Math.max(0,Math.ceil((P.expiresAt-Q)/1e3))}s`:p.valid:``,$=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},Ae=a.browserPrepareTitle,je=a.browserPrepareHint,Me=m?J?$.success:K?.status===`pending`?$.allowTitle:q||K?.status===`approved`?p.waiting:P?$.connect:p.title:Ae,Ne=F===`create`?p.createFailed:F===`decision`?p.decisionFailed:F===`background`?p.backgroundFailed:F===`download`?a.browserDownloadFailed:null,Pe=async()=>{R(!0),I(null);try{await le()}catch{I(`download`)}finally{B.current&&R(!1)}};return(0,G.jsxs)(x,{children:[(0,G.jsx)(b,{className:_(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,re)}),(0,G.jsxs)(S,{className:_(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,ne),children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,G.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e===`mobile`?(0,G.jsxs)(E,{open:C,onOpenChange:ie,children:[(0,G.jsx)(D,{asChild:!0,children:(0,G.jsxs)(v,{variant:`ghost`,className:`min-h-10`,children:[(0,G.jsx)(d,{className:`size-4`,"aria-hidden":`true`}),a.mobileDownloadAction]})}),(0,G.jsx)(w,{children:(0,G.jsxs)(T,{align:`end`,sideOffset:8,"aria-label":a.mobileDownloadAction,className:_(`w-[min(26rem,calc(100vw-2rem))] max-h-[var(--radix-popover-content-available-height)] overflow-y-auto rounded-xl border border-edge bg-surface-overlay p-6 sm:p-7 shadow-elevated`,O),children:[(0,G.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:a.mobileDownloadAction}),(0,G.jsx)(`div`,{className:`my-6 flex justify-center`,children:Ce.data?(0,G.jsx)(`img`,{src:Ce.data,alt:a.mobileDownloadQrAlt,width:216,height:216,className:`size-[216px] max-w-full rounded-lg bg-white`}):Ce.error?(0,G.jsx)(`p`,{role:`status`,className:`text-sm text-warning`,children:p.qrFailed}):(0,G.jsx)(y,{className:`size-[216px] max-w-full`})}),(0,G.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:a.mobileDownloadHint}),(0,G.jsxs)(v,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void A(xe),children:[(0,G.jsx)(f,{className:`size-4`,"aria-hidden":`true`}),a.mobileDownload]})]})})]}):null,(0,G.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":p.cancel,onClick:t,children:(0,G.jsx)(g,{className:`size-4`,"aria-hidden":`true`})})]})]}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[J?(0,G.jsx)(l,{className:`mb-5 size-7 text-success`}):null,(0,G.jsx)(te,{className:`text-xl font-semibold tracking-tight text-fg`,children:Me}),(0,G.jsx)(ee,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:m?J?$.successHint:q?p.waitingForDevice:K?K.displayName:P?$.connectHint:p.intro:je}),Ne?(0,G.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ne}):null,m&&N.error?(0,G.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:p.readinessFailed}):null,m&&U.error?(0,G.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:p.statusUnavailable}):null,m?N.data?J?(0,G.jsxs)(G.Fragment,{children:[Y.data?(0,G.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,G.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":Y.data.runInBackground??!1,disabled:!Y.data.backgroundSupported,checked:Y.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>Y.mutate(e.behavior)).catch(()=>I(`background`))}})]}):null,(0,G.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):De||Ee?(0,G.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Ee||K?.status===`expired`?p.expired:p.declined}),(0,G.jsx)(v,{variant:`primary`,onClick:()=>void Z(),disabled:L,children:p.refresh})]}):K?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:p.scope}),(0,G.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[K.confirmationCode.slice(0,3),` `,K.confirmationCode.slice(3)]}),(0,G.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:p.compare}),(0,G.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer py-2`,children:p.access}),(0,G.jsx)(`p`,{children:p.accessHint})]})]}):P?.targetKind===`mobile`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,G.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,G.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:X.data?(0,G.jsx)(`img`,{src:X.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):X.error?null:(0,G.jsx)(y,{className:`size-[240px] rounded-xl`})})}),X.error?null:(0,G.jsxs)(`p`,{className:_(`mt-4 inline-flex min-h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium`,Oe?`bg-warning-soft text-warning`:`bg-surface-hover text-fg-muted`),"aria-live":`polite`,children:[(0,G.jsx)(u,{className:`size-3.5`,"aria-hidden":`true`}),ke]})]}),X.error?(0,G.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:p.qrFailed}):null,X.error?(0,G.jsx)(`div`,{className:`mt-5`,children:(0,G.jsx)(M,{text:P.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,G.jsxs)(`details`,{className:`group mx-auto mt-1 w-full max-w-sm rounded-xl border border-edge bg-surface-panel text-xs text-fg-muted`,children:[(0,G.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-3.5 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,children:[(0,G.jsx)(`span`,{children:p.fallback}),(0,G.jsx)(c,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,G.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,G.jsx)(M,{text:P.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):P?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,G.jsx)(`div`,{className:`mt-6`,children:(0,G.jsx)(M,{text:P.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,G.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:P.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((P.expiresAt-Q)/1e3))}s`:p.valid})]}):N.data.ready?(0,G.jsx)(`div`,{className:`mt-8`,children:(0,G.jsx)(y,{className:`mx-auto size-[216px]`})}):(0,G.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[z===`tailscale`?(0,G.jsx)(se,{embedded:!0}):z===`https`?(0,G.jsx)(_e,{}):z===`choices`?(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(v,{variant:`secondary`,className:`w-full`,onClick:()=>pe(`tailscale`),children:a.useTailscale}),(0,G.jsx)(v,{variant:`secondary`,className:`w-full`,onClick:()=>pe(`https`),children:a.useOwnHttps})]}):(0,G.jsx)(ye,{}),(0,G.jsx)(v,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>pe(z?null:`choices`),children:z?p.back:p.existing})]}):(0,G.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,G.jsx)(y,{className:`h-5 w-3/4`}),(0,G.jsx)(y,{className:`h-40 w-full`})]}):(0,G.jsxs)(`div`,{className:`mt-7`,children:[(0,G.jsxs)(v,{variant:`secondary`,className:`w-full`,disabled:L,onClick:()=>void Pe(),children:[(0,G.jsx)(d,{className:`size-4`}),a.browserDownload]}),(0,G.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,G.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void A(Se),children:[a.browserInstallHelp,(0,G.jsx)(f,{className:`size-3`})]})]})]}),!m||N.error||J||K?.status===`pending`||F===`create`||F===`decision`?(0,G.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:m?J?(0,G.jsx)(v,{className:`w-full`,variant:`primary`,onClick:t,children:p.done}):K?.status===`pending`?(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(v,{className:`w-full`,variant:`primary`,disabled:L,onClick:()=>void we(`approve`),children:p.allow}),(0,G.jsx)(v,{className:`w-full`,variant:`ghost`,disabled:L,onClick:()=>void we(`reject`),children:p.cancel})]}):N.error?(0,G.jsx)(v,{className:`w-full`,variant:`primary`,onClick:()=>void N.mutate(),children:p.retry}):(0,G.jsx)(v,{className:`w-full`,variant:`primary`,disabled:L,onClick:()=>void Z(),children:p.retry}):(0,G.jsx)(v,{className:`w-full`,variant:`primary`,onClick:()=>{I(null),h(!0)},children:a.browserReady})}):null]})]})}export{K as n,q as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{r as n,t as r}from"./working-directory-picker-modal-D2Zf3GOG.js";import{t as i}from"./cn-0WouolD0.js";import{n as a}from"./interaction-BdhHBbYa.js";import{n as o,t as s}from"./use-directory-picker-C4p7AgWY.js";var c=e(),l=t();function u(e){let t=(0,c.c)(27),{value:r,onPick:s,disabled:u,placeholder:d,title:f,className:p,maxWidthClass:m,compact:h,"aria-label":g}=e,_=m===void 0?`max-w-[min(12rem,40vw)]`:m,v=h!==void 0&&h,y,b;t[0]!==d||t[1]!==r?(b=r.trim(),y=b?o(b):d??``,t[0]=d,t[1]=r,t[2]=y,t[3]=b):(y=t[2],b=t[3]);let x=y,S=f??(b||void 0),C=g??f??x,w=v?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,T=!v&&_,E=u&&`cursor-not-allowed opacity-60`,D;t[4]!==p||t[5]!==w||t[6]!==T||t[7]!==E?(D=i(w,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,a.transition,a.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,T,E,p),t[4]=p,t[5]=w,t[6]=T,t[7]=E,t[8]=D):D=t[8];let O;t[9]!==u||t[10]!==s?(O=e=>{e.stopPropagation(),u||s()},t[9]=u,t[10]=s,t[11]=O):O=t[11];let k=v?`size-4`:`size-3.5`,A;t[12]===k?A=t[13]:(A=i(`shrink-0 text-fg-muted`,k),t[12]=k,t[13]=A);let j;t[14]===A?j=t[15]:(j=(0,l.jsx)(n,{className:A,"aria-hidden":!0}),t[14]=A,t[15]=j);let M;t[16]!==v||t[17]!==x?(M=v?null:(0,l.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:x}),t[16]=v,t[17]=x,t[18]=M):M=t[18];let N;return t[19]!==u||t[20]!==O||t[21]!==j||t[22]!==M||t[23]!==S||t[24]!==C||t[25]!==D?(N=(0,l.jsxs)(`button`,{type:`button`,disabled:u,title:S,"aria-label":C,className:D,onClick:O,children:[j,M]}),t[19]=u,t[20]=O,t[21]=j,t[22]=M,t[23]=S,t[24]=C,t[25]=D,t[26]=N):N=t[26],N}function d(e){let t=(0,c.c)(39),{value:n,onChange:a,disabled:o,wd:d,placeholder:f,inputAriaLabel:p,inputClassName:m,autoFocus:h,trailing:g}=e,_;t[0]!==a||t[1]!==n?(_={initialPath:n,onPicked:a},t[0]=a,t[1]=n,t[2]=_):_=t[2];let v=s(_),y;t[3]===n?y=t[4]:(y=n.trim(),t[3]=n,t[4]=y);let b=y,x=b?`${b}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,S;t[5]===m?S=t[6]:(S=i(`min-w-0 flex-1`,m),t[5]=m,t[6]=S);let C=o||v.picking,w;t[7]===a?w=t[8]:(w=e=>void a(e.target.value),t[7]=a,t[8]=w);let T=f??d.pathInputPlaceholder,E;t[9]!==h||t[10]!==p||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==T||t[15]!==n?(E=(0,l.jsx)(`input`,{type:`text`,className:S,value:n,disabled:C,onChange:w,placeholder:T,"aria-label":p,autoFocus:h,autoComplete:`off`,spellCheck:!1}),t[9]=h,t[10]=p,t[11]=S,t[12]=C,t[13]=w,t[14]=T,t[15]=n,t[16]=E):E=t[16];let D=o||v.picking,O;t[17]!==x||t[18]!==v.pick||t[19]!==D||t[20]!==n||t[21]!==d.selectWorkingDirectory?(O=(0,l.jsx)(u,{compact:!0,value:n,onPick:v.pick,disabled:D,title:x,"aria-label":d.selectWorkingDirectory}),t[17]=x,t[18]=v.pick,t[19]=D,t[20]=n,t[21]=d.selectWorkingDirectory,t[22]=O):O=t[22];let k;t[23]!==O||t[24]!==g?(k=(0,l.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[O,g]}),t[23]=O,t[24]=g,t[25]=k):k=t[25];let A;t[26]!==k||t[27]!==E?(A=(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[E,k]}),t[26]=k,t[27]=E,t[28]=A):A=t[28];let j;t[29]!==v.confirmPick||t[30]!==v.hasNativePicker||t[31]!==v.modalOpen||t[32]!==v.setModalOpen||t[33]!==b||t[34]!==d?(j=v.hasNativePicker?null:(0,l.jsx)(r,{open:v.modalOpen,onOpenChange:v.setModalOpen,initialAbsolutePath:b||void 0,onConfirm:v.confirmPick,wd:d}),t[29]=v.confirmPick,t[30]=v.hasNativePicker,t[31]=v.modalOpen,t[32]=v.setModalOpen,t[33]=b,t[34]=d,t[35]=j):j=t[35];let M;return t[36]!==A||t[37]!==j?(M=(0,l.jsxs)(l.Fragment,{children:[A,j]}),t[36]=A,t[37]=j,t[38]=M):M=t[38],M}export{d as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{r as n,t as r}from"./working-directory-picker-modal-CDZ1xh3o.js";import{t as i}from"./cn-0WouolD0.js";import{n as a}from"./interaction-BdhHBbYa.js";import{n as o,t as s}from"./use-directory-picker-C4p7AgWY.js";var c=e(),l=t();function u(e){let t=(0,c.c)(27),{value:r,onPick:s,disabled:u,placeholder:d,title:f,className:p,maxWidthClass:m,compact:h,"aria-label":g}=e,_=m===void 0?`max-w-[min(12rem,40vw)]`:m,v=h!==void 0&&h,y,b;t[0]!==d||t[1]!==r?(b=r.trim(),y=b?o(b):d??``,t[0]=d,t[1]=r,t[2]=y,t[3]=b):(y=t[2],b=t[3]);let x=y,S=f??(b||void 0),C=g??f??x,w=v?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,T=!v&&_,E=u&&`cursor-not-allowed opacity-60`,D;t[4]!==p||t[5]!==w||t[6]!==T||t[7]!==E?(D=i(w,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,a.transition,a.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,T,E,p),t[4]=p,t[5]=w,t[6]=T,t[7]=E,t[8]=D):D=t[8];let O;t[9]!==u||t[10]!==s?(O=e=>{e.stopPropagation(),u||s()},t[9]=u,t[10]=s,t[11]=O):O=t[11];let k=v?`size-4`:`size-3.5`,A;t[12]===k?A=t[13]:(A=i(`shrink-0 text-fg-muted`,k),t[12]=k,t[13]=A);let j;t[14]===A?j=t[15]:(j=(0,l.jsx)(n,{className:A,"aria-hidden":!0}),t[14]=A,t[15]=j);let M;t[16]!==v||t[17]!==x?(M=v?null:(0,l.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:x}),t[16]=v,t[17]=x,t[18]=M):M=t[18];let N;return t[19]!==u||t[20]!==O||t[21]!==j||t[22]!==M||t[23]!==S||t[24]!==C||t[25]!==D?(N=(0,l.jsxs)(`button`,{type:`button`,disabled:u,title:S,"aria-label":C,className:D,onClick:O,children:[j,M]}),t[19]=u,t[20]=O,t[21]=j,t[22]=M,t[23]=S,t[24]=C,t[25]=D,t[26]=N):N=t[26],N}function d(e){let t=(0,c.c)(39),{value:n,onChange:a,disabled:o,wd:d,placeholder:f,inputAriaLabel:p,inputClassName:m,autoFocus:h,trailing:g}=e,_;t[0]!==a||t[1]!==n?(_={initialPath:n,onPicked:a},t[0]=a,t[1]=n,t[2]=_):_=t[2];let v=s(_),y;t[3]===n?y=t[4]:(y=n.trim(),t[3]=n,t[4]=y);let b=y,x=b?`${b}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,S;t[5]===m?S=t[6]:(S=i(`min-w-0 flex-1`,m),t[5]=m,t[6]=S);let C=o||v.picking,w;t[7]===a?w=t[8]:(w=e=>void a(e.target.value),t[7]=a,t[8]=w);let T=f??d.pathInputPlaceholder,E;t[9]!==h||t[10]!==p||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==T||t[15]!==n?(E=(0,l.jsx)(`input`,{type:`text`,className:S,value:n,disabled:C,onChange:w,placeholder:T,"aria-label":p,autoFocus:h,autoComplete:`off`,spellCheck:!1}),t[9]=h,t[10]=p,t[11]=S,t[12]=C,t[13]=w,t[14]=T,t[15]=n,t[16]=E):E=t[16];let D=o||v.picking,O;t[17]!==x||t[18]!==v.pick||t[19]!==D||t[20]!==n||t[21]!==d.selectWorkingDirectory?(O=(0,l.jsx)(u,{compact:!0,value:n,onPick:v.pick,disabled:D,title:x,"aria-label":d.selectWorkingDirectory}),t[17]=x,t[18]=v.pick,t[19]=D,t[20]=n,t[21]=d.selectWorkingDirectory,t[22]=O):O=t[22];let k;t[23]!==O||t[24]!==g?(k=(0,l.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[O,g]}),t[23]=O,t[24]=g,t[25]=k):k=t[25];let A;t[26]!==k||t[27]!==E?(A=(0,l.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[E,k]}),t[26]=k,t[27]=E,t[28]=A):A=t[28];let j;t[29]!==v.confirmPick||t[30]!==v.hasNativePicker||t[31]!==v.modalOpen||t[32]!==v.setModalOpen||t[33]!==b||t[34]!==d?(j=v.hasNativePicker?null:(0,l.jsx)(r,{open:v.modalOpen,onOpenChange:v.setModalOpen,initialAbsolutePath:b||void 0,onConfirm:v.confirmPick,wd:d}),t[29]=v.confirmPick,t[30]=v.hasNativePicker,t[31]=v.modalOpen,t[32]=v.setModalOpen,t[33]=b,t[34]=d,t[35]=j):j=t[35];let M;return t[36]!==A||t[37]!==j?(M=(0,l.jsxs)(l.Fragment,{children:[A,j]}),t[36]=A,t[37]=j,t[38]=M):M=t[38],M}export{d as t};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r}from"./locale-store-TQcz_Vjt.js";import{t as i}from"./createLucideIcon-DPHK1VkS.js";import{t as a}from"./chevron-down-ccbiQQz_.js";import{t as o}from"./button-CnRSIP6m.js";var s=i(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),c=i(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),l=i(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]);function u(e){let t=e.audioAvailable&&!e.audioDeleted,n=`sync_pending`,r=`none`;return e.audioDeleted?n=`audio_deleted`:e.localSave===`saving`?n=`local_saving`:e.localSave===`failed`?n=`save_failed`:e.localSave===`partial`?(n=`local_partial`,r=`recover`):t?e.serverStatus===`cancelled`?n=`cancelled`:e.serverStatus===`needs_attention`?(n=e.failureStage===`organization`?`analysis_failed`:`transcription_failed`,r=`pipeline`):e.serverStatus===`completed`?e.noteAvailable?e.analysisStale?(n=`analysis_stale`,r=`analyze`):n=`ready`:(n=`analysis_missing`,r=`regenerate`):n=e.serverStatus===`organizing`?e.retryScheduled?`analysis_retrying`:`organizing`:e.retryScheduled?`transcription_retrying`:`transcribing`:e.jobState===`failed`?(n=`verify_failed`,r=`pipeline`):e.jobState===`queued`||e.jobState===`running`||e.sync===`verifying`?n=`verifying`:e.sync===`offline`||e.sync===`failed`?(n=`sync_failed`,r=e.localSave===`complete`?`sync`:`none`):e.localSave!==`complete`&&e.serverStatus===`needs_attention`&&(n=`source_missing`),{stage:n,leave:e.localSave===`saving`?`hold`:t?`cloud`:e.localSave===`complete`?`local`:`hold`,retry:r,audio:t,text:e.textAvailable,note:e.noteAvailable,stale:e.analysisStale}}var d=`open-discussion-capture`;function f(e){window.dispatchEvent(new CustomEvent(d,{detail:e?{projectId:e}:{}}))}var p=e(),m={save_failed:[`录音未能保存`,`Recording could not be saved`,`尚未确认可恢复的原音。请检查麦克风权限和可用存储空间后重新录制。`,`No recoverable audio has been confirmed. Check microphone permission and available storage before recording again.`],cancelled:[`已停止整理`,`Processing stopped`,`已有原音、文字和笔记仍可使用。`,`Existing audio, text and notes remain available.`],local_saving:[`正在保存录音`,`Saving recording`,`请稍候,确认保存完成前请留在此页面。`,`Please stay on this page until saving is confirmed.`],local_partial:[`已保留部分录音`,`Part of the recording was retained`,`本次录音未完整保存。请先恢复或导出已保存部分,确认缺失范围。`,`This recording was not saved completely. Recover or export the saved portion and review the missing parts.`],sync_pending:[`正在同步原音`,`Syncing original audio`,`已完成的文字和笔记可先使用。原音确认可用后,会继续整理。`,`Available text and notes can be used now. Processing continues once the original audio is confirmed.`],sync_failed:[`原音同步未完成`,`Audio sync incomplete`,`已保存的内容仍保留在录制设备。连接网络后可重试同步,无需重新录音。`,`Saved content remains on the recording device. Reconnect and retry sync without recording again.`],verifying:[`原音已上传,正在确认`,`Confirming uploaded audio`,`上传完成后,还需确认原音可用。已有文字可以先查看。`,`Uploaded audio is being checked. Existing text can be read now.`],verify_failed:[`原音确认未完成`,`Audio confirmation incomplete`,`上传内容已保留,可重试确认原音。已有文字和笔记仍可使用。`,`Uploaded content is retained. Retry audio confirmation; existing text and notes remain available.`],transcribing:[`正在整理文字`,`Preparing transcript`,`原音已可回听,已完成的文字可先搜索和查看。文字完成后继续生成笔记。`,`Play the original audio and search available text now. Notes will follow the transcript.`],transcription_retrying:[`正在重试整理文字`,`Retrying transcription`,`原音和处理进度已保留,系统稍后自动重试。已有文字仍可使用。`,`Audio and progress are retained. An automatic retry is scheduled; existing text remains available.`],transcription_failed:[`文字整理未完成`,`Transcription incomplete`,`原音和已有文字均保留。重试会从已保存进度继续,无需重新录音。`,`Audio and existing text are retained. Retry from saved progress without recording again.`],organizing:[`正在生成笔记`,`Preparing notes`,`可以先回听原音、查找原话。笔记完成后可查看重点、结论和行动建议。`,`Play audio and find original statements now. Highlights, conclusions and suggested actions will follow.`],analysis_retrying:[`正在重试生成笔记`,`Retrying notes`,`原音、文字和已有笔记均保留,系统稍后自动重试。`,`Audio, text and existing notes are retained. An automatic retry is scheduled.`],analysis_failed:[`笔记生成未完成`,`Notes incomplete`,`原音、文字和已有笔记均保留。重试只继续整理,不会重新录音或创建重复笔记。`,`Audio, text and existing notes are retained. Retry continues processing without recording again or creating another note.`],ready:[`录音与笔记已就绪`,`Recording and notes are ready`,`现在可以回听原音、查找原话,并回顾重要信息。`,`Play the audio, find original statements and review important information.`],analysis_missing:[`暂未生成笔记`,`Notes are not available yet`,`原音和已有文字仍可使用,可以从原音重新生成文字与笔记。`,`Audio and existing text remain available. Regenerate text and notes from the original audio.`],analysis_stale:[`原文已更新`,`Transcript updated`,`当前笔记基于修改前的原文,可保留查看,也可按新版原文重新整理。`,`Existing notes use an earlier transcript. Keep them or generate notes from the updated text.`],source_missing:[`原音尚不可用`,`Original audio is not available yet`,`请到录制设备的待恢复录音中继续同步。已有文字和笔记仍可查看。`,`Continue sync from recoverable recordings on the recording device. Existing text and notes remain readable.`],audio_deleted:[`原音已删除`,`Original audio was deleted`,`已有文字和笔记仍可查看;重新生成需要重新导入原音。`,`Existing text and notes remain readable. Import the original audio again to regenerate.`]},h={leave_local:[`录音已在本机保存,可以离开当前页面。`,`Recording saved on this device. You can leave this page.`],leave_cloud:[`原音已同步,可以离开当前页面。`,`Original audio synced. You can leave this page.`],leave_hold:[`请先确认保存结果,再离开当前页面。`,`Confirm the recording is saved before leaving this page.`],local_hint:[`关闭应用后,可在待恢复录音中继续同步。请保留本机录音数据。`,`After closing the app, continue sync from recoverable recordings. Keep the recording data on this device.`],cloud_hint:[`后续转写与笔记整理在后台继续;失败时可在这条笔记中重试。`,`Transcription and notes continue on the server. Retry here if processing fails.`],retry_sync:[`重试同步`,`Retry sync`],retry_pipeline:[`继续处理`,`Resume processing`],retry_analysis_failed:[`重试生成笔记`,`Retry notes`],retry_transcription_failed:[`继续整理文字`,`Resume transcription`],retry_verify_failed:[`重试确认原音`,`Retry audio confirmation`],retry_recover:[`恢复已录内容`,`Recover saved audio`],retry_regenerate:[`从原音重新生成`,`Regenerate from audio`],retry_analyze:[`按新版原文整理`,`Update notes from transcript`],audio:[`原音`,`Audio`],text:[`文字`,`Transcript`],note:[`笔记`,`Notes`],available:[`可用`,`Available`],pending:[`尚未完成`,`Not ready`],old_note:[`旧版可用`,`Earlier version available`],open:[`打开笔记`,`Open note`],recover:[`待恢复录音`,`Recoverable recordings`],export:[`导出已录内容`,`Export saved audio`],close:[`稍后查看`,`View later`],annotation_failed:[`重点同步未完成,原音和笔记处理不受影响。`,`Highlights are not synced yet. Audio and note processing are unaffected.`],retry_annotation:[`重试重点同步`,`Retry highlights`]},g=t();function _(e,t=`unknown`,n=`pending`){return{localSave:t,sync:n,serverStatus:e?.discussion.status??``,failureStage:e?.discussion.failureStage??``,jobState:e?.recordingJob?.state??``,retryScheduled:!!e?.processing?.nextAttemptAt,audioAvailable:!!e?.discussion.audioAttachmentId,audioDeleted:!!e?.discussion.audioDeletedAt,textAvailable:!!e?.transcript?.text?.trim()||!!e?.discussion.canonicalTranscript?.trim(),noteAvailable:!!e?.organization?.organization,analysisStale:!!e?.organization&&e.organization.transcriptRevision!==e.transcript?.revision}}function v(e){let t=(0,p.c)(58),{input:n,zh:r,compact:i,busy:s,onRetry:c,children:l,context:d}=e,f=i!==void 0&&i,_=s!==void 0&&s,v=d===void 0?`capture`:d,y,b,x,S,C,w,T,E,D,O,k,A;if(t[0]!==v||t[1]!==n||t[2]!==r){S=u(n),x=m[S.stage];let e;t[15]===r?e=t[16]:(e=e=>h[e][+!r],t[15]=r,t[16]=e),y=e,b=`retry_${[`analysis_failed`,`transcription_failed`,`verify_failed`].includes(S.stage)?S.stage:S.retry}`,k=`polite`,A=S.stage,C=v===`note`?`text-fg`:`rounded-xl bg-surface-inset p-3 text-fg`,w=v===`capture`?(0,g.jsx)(`p`,{className:`mb-1 text-sm font-medium`,children:y(`leave_${S.leave}`)}):null,D=`group`,O=v,E=`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-lg text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,T=S.stage.endsWith(`_failed`)||S.stage===`local_partial`?`bg-danger`:`bg-accent`,t[0]=v,t[1]=n,t[2]=r,t[3]=y,t[4]=b,t[5]=x,t[6]=S,t[7]=C,t[8]=w,t[9]=T,t[10]=E,t[11]=D,t[12]=O,t[13]=k,t[14]=A}else y=t[3],b=t[4],x=t[5],S=t[6],C=t[7],w=t[8],T=t[9],E=t[10],D=t[11],O=t[12],k=t[13],A=t[14];let j=`size-1.5 shrink-0 rounded-full ${T}`,M;t[17]===j?M=t[18]:(M=(0,g.jsx)(`span`,{className:j,"aria-hidden":!0}),t[17]=j,t[18]=M);let N=x[+!r],P;t[19]===N?P=t[20]:(P=(0,g.jsx)(`span`,{className:`min-w-0 flex-1`,children:N}),t[19]=N,t[20]=P);let F;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,g.jsx)(a,{className:`size-3.5 shrink-0 text-fg-muted transition-transform group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0}),t[21]=F):F=t[21];let I;t[22]!==M||t[23]!==P||t[24]!==E?(I=(0,g.jsxs)(`summary`,{className:E,children:[M,P,F]}),t[22]=M,t[23]=P,t[24]=E,t[25]=I):I=t[25];let L;t[26]!==v||t[27]!==y||t[28]!==S.leave?(L=v===`note`?(0,g.jsx)(`p`,{children:y(`leave_${S.leave}`)}):null,t[26]=v,t[27]=y,t[28]=S.leave,t[29]=L):L=t[29];let R;t[30]!==f||t[31]!==y||t[32]!==x||t[33]!==S||t[34]!==r?(R=f?null:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`p`,{children:x[r?2:3]}),S.leave===`local`?(0,g.jsx)(`p`,{children:y(`local_hint`)}):null,(0,g.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1`,"aria-label":r?`已可用内容`:`Available content`,children:[`audio`,`text`,`note`].map(e=>(0,g.jsxs)(`li`,{children:[y(e),` · `,e===`note`&&S.note&&S.stale?y(`old_note`):y(S[e]?`available`:`pending`)]},e))})]}),t[30]=f,t[31]=y,t[32]=x,t[33]=S,t[34]=r,t[35]=R):R=t[35];let z;t[36]!==L||t[37]!==R?(z=(0,g.jsxs)(`div`,{className:`space-y-2 pb-3 text-xs leading-5 text-fg-muted`,children:[L,R]}),t[36]=L,t[37]=R,t[38]=z):z=t[38];let B;t[39]!==I||t[40]!==z||t[41]!==D||t[42]!==O?(B=(0,g.jsxs)(`details`,{className:D,children:[I,z]},O),t[39]=I,t[40]=z,t[41]=D,t[42]=O,t[43]=B):B=t[43];let V;t[44]!==_||t[45]!==c||t[46]!==y||t[47]!==b||t[48]!==S.retry?(V=S.retry!==`none`&&c?(0,g.jsx)(o,{className:`min-h-11`,disabled:_,onClick:()=>c(S.retry),children:y(b)}):null,t[44]=_,t[45]=c,t[46]=y,t[47]=b,t[48]=S.retry,t[49]=V):V=t[49];let H;return t[50]!==l||t[51]!==C||t[52]!==w||t[53]!==B||t[54]!==V||t[55]!==k||t[56]!==A?(H=(0,g.jsxs)(`section`,{"aria-live":k,"data-recording-outcome":A,className:C,children:[w,B,V,l]}),t[50]=l,t[51]=C,t[52]=w,t[53]=B,t[54]=V,t[55]=k,t[56]=A,t[57]=H):H=t[57],H}function y(){return r(n(`/api/discussion-capture/settings`))}function b(e){return r(n(`/api/discussion-capture/settings`),{method:`PUT`,body:JSON.stringify({consentPolicyVersion:e})})}async function x(e){return r(n(`/api/discussions`),{method:`POST`,body:JSON.stringify(e)})}function S(e){return r(n(`/api/discussions/${encodeURIComponent(e)}`))}async function C(e){try{return await r(n(`/api/discussions/by-note/${encodeURIComponent(e)}`))}catch(e){if(e.status===404)return null;throw e}}function w(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/transcript`))}function T(e,t,i){let a=new FormData;return a.set(`file`,i.blob,`segment-${t}.wav`),a.set(`startedAtMs`,String(i.startedAtMs)),a.set(`endedAtMs`,String(i.endedAtMs)),a.set(`sha256`,i.sha256),r(n(`/api/discussions/${encodeURIComponent(e)}/segments/${t}`),{method:`PUT`,body:a})}function E(e,t=`resume`){return r(n(`/api/discussions/${encodeURIComponent(e)}/retry`),{method:`POST`,body:JSON.stringify({mode:t})})}function D(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/project`),{method:`DELETE`})}function O(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/chunks`))}function k(e,t,i,a){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/chunks/${t}`),{method:`PUT`,headers:{"Content-Type":`application/octet-stream`,"x-audio-sha256":a},body:i})}function A(e,t){return r(n(`/api/discussions/${encodeURIComponent(e)}/capture/seal`),{method:`POST`,body:JSON.stringify(t)})}function j(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/job`))}var M=()=>window.dispatchEvent(new Event(`discussion-annotations-changed`));async function N(){return new Promise((e,t)=>{let n=indexedDB.open(`xopc-note-annotations`,1);n.onupgradeneeded=()=>{n.result.createObjectStore(`annotations`,{keyPath:[`recordingId`,`annotation.id`]}).createIndex(`recordingId`,`recordingId`)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function P(e,t){let n=await N();try{return await new Promise((r,i)=>{let a=n.transaction(`annotations`,e?`readwrite`:`readonly`,{durability:`strict`}),o,s;a.oncomplete=()=>r(o),a.onabort=()=>i(s??a.error??Error(`Annotation save failed`)),a.onerror=()=>i(a.error);try{t(a.objectStore(`annotations`),e=>{o=e},e=>{s=e,a.abort()})}catch(e){a.abort(),i(e)}})}finally{n.close()}}async function F(e){return P(!1,(t,n)=>{let r=t.index(`recordingId`).getAll(e);r.onsuccess=()=>n(r.result)})}async function I(e,t,n){await P(!0,(r,i,a)=>{let o=r.get([e,t.id]);o.onsuccess=()=>{let s=o.result;if(n!==void 0&&(n===null?s&&s.state!==`synced`:s?.nonce!==n)){a(Error(`Annotation changed in another tab. Your editor content is retained; reload before saving.`));return}r.put({recordingId:e,annotation:t,nonce:crypto.randomUUID(),state:`pending`}),i()}}),M()}function L(e,t=`highlight`){let n=Date.now();return{id:crypto.randomUUID(),kind:t,text:``,anchor:e,revision:0,deleted:!1,createdAt:n,updatedAt:n}}async function R(e,t,n){await P(!0,(r,i)=>{let a=r.get([e,t]);a.onsuccess=()=>{let e=a.result;e&&e.annotation.anchor.offsetMs===void 0&&r.put({...e,nonce:crypto.randomUUID(),state:`pending`,annotation:{...e.annotation,anchor:{...e.annotation.anchor,offsetMs:n}}}),i()}}),M()}async function z(e,t,n=!1){await P(!0,(r,i)=>{let a=r.get([e.recordingId,e.annotation.id]);a.onsuccess=()=>{let o=a.result;o&&(o.nonce===e.nonce?r.put({...o,annotation:t??o.annotation,state:n?`conflict`:`synced`}):t&&o.annotation.revision===e.annotation.revision&&r.put({...o,annotation:{...o.annotation,revision:t.revision}})),i()}}),M()}var B=new Map;function V(e,t){let i=`${e}:${t}`;if(B.has(i))return B.get(i);let a=(async()=>{for(let i=0;i<5;i++){let i=(await F(e)).filter(e=>e.state===`pending`);if(!i.length)return;for(let e of i){if(e.state!==`pending`)continue;let i=e.annotation;try{await z(e,await r(n(`/api/discussions/${encodeURIComponent(t)}/annotations/${encodeURIComponent(i.id)}`),{method:`PUT`,signal:AbortSignal.timeout(15e3),body:JSON.stringify({id:i.id,kind:i.kind,text:i.text,anchor:i.anchor,expectedRevision:i.revision,deleted:i.deleted})}))}catch(t){throw t.status===409&&await z(e,void 0,!0),t}}}throw Error(`Highlights are still being updated. Saved local changes will sync on retry.`)})().finally(()=>B.delete(i));return B.set(i,a),a}export{f as C,s as E,d as S,c as T,D as _,R as a,v as b,x as c,C as d,w as f,A as g,E as h,L as i,S as l,j as m,z as n,I as o,O as p,F as r,b as s,V as t,y as u,T as v,l as w,_ as x,k as y};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{i as n,o as r}from"./locale-store-Br7IfbXK.js";import{t as i}from"./createLucideIcon-DPHK1VkS.js";import{t as a}from"./chevron-down-ccbiQQz_.js";import{t as o}from"./button-CnRSIP6m.js";var s=i(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),c=i(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),l=i(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]);function u(e){let t=e.audioAvailable&&!e.audioDeleted,n=`sync_pending`,r=`none`;return e.audioDeleted?n=`audio_deleted`:e.localSave===`saving`?n=`local_saving`:e.localSave===`failed`?n=`save_failed`:e.localSave===`partial`?(n=`local_partial`,r=`recover`):t?e.serverStatus===`cancelled`?n=`cancelled`:e.serverStatus===`needs_attention`?(n=e.failureStage===`organization`?`analysis_failed`:`transcription_failed`,r=`pipeline`):e.serverStatus===`completed`?e.noteAvailable?e.analysisStale?(n=`analysis_stale`,r=`analyze`):n=`ready`:(n=`analysis_missing`,r=`regenerate`):n=e.serverStatus===`organizing`?e.retryScheduled?`analysis_retrying`:`organizing`:e.retryScheduled?`transcription_retrying`:`transcribing`:e.jobState===`failed`?(n=`verify_failed`,r=`pipeline`):e.jobState===`queued`||e.jobState===`running`||e.sync===`verifying`?n=`verifying`:e.sync===`offline`||e.sync===`failed`?(n=`sync_failed`,r=e.localSave===`complete`?`sync`:`none`):e.localSave!==`complete`&&e.serverStatus===`needs_attention`&&(n=`source_missing`),{stage:n,leave:e.localSave===`saving`?`hold`:t?`cloud`:e.localSave===`complete`?`local`:`hold`,retry:r,audio:t,text:e.textAvailable,note:e.noteAvailable,stale:e.analysisStale}}var d=`open-discussion-capture`;function f(e){window.dispatchEvent(new CustomEvent(d,{detail:e?{projectId:e}:{}}))}var p=e(),m={save_failed:[`录音未能保存`,`Recording could not be saved`,`尚未确认可恢复的原音。请检查麦克风权限和可用存储空间后重新录制。`,`No recoverable audio has been confirmed. Check microphone permission and available storage before recording again.`],cancelled:[`已停止整理`,`Processing stopped`,`已有原音、文字和笔记仍可使用。`,`Existing audio, text and notes remain available.`],local_saving:[`正在保存录音`,`Saving recording`,`请稍候,确认保存完成前请留在此页面。`,`Please stay on this page until saving is confirmed.`],local_partial:[`已保留部分录音`,`Part of the recording was retained`,`本次录音未完整保存。请先恢复或导出已保存部分,确认缺失范围。`,`This recording was not saved completely. Recover or export the saved portion and review the missing parts.`],sync_pending:[`正在同步原音`,`Syncing original audio`,`已完成的文字和笔记可先使用。原音确认可用后,会继续整理。`,`Available text and notes can be used now. Processing continues once the original audio is confirmed.`],sync_failed:[`原音同步未完成`,`Audio sync incomplete`,`已保存的内容仍保留在录制设备。连接网络后可重试同步,无需重新录音。`,`Saved content remains on the recording device. Reconnect and retry sync without recording again.`],verifying:[`原音已上传,正在确认`,`Confirming uploaded audio`,`上传完成后,还需确认原音可用。已有文字可以先查看。`,`Uploaded audio is being checked. Existing text can be read now.`],verify_failed:[`原音确认未完成`,`Audio confirmation incomplete`,`上传内容已保留,可重试确认原音。已有文字和笔记仍可使用。`,`Uploaded content is retained. Retry audio confirmation; existing text and notes remain available.`],transcribing:[`正在整理文字`,`Preparing transcript`,`原音已可回听,已完成的文字可先搜索和查看。文字完成后继续生成笔记。`,`Play the original audio and search available text now. Notes will follow the transcript.`],transcription_retrying:[`正在重试整理文字`,`Retrying transcription`,`原音和处理进度已保留,系统稍后自动重试。已有文字仍可使用。`,`Audio and progress are retained. An automatic retry is scheduled; existing text remains available.`],transcription_failed:[`文字整理未完成`,`Transcription incomplete`,`原音和已有文字均保留。重试会从已保存进度继续,无需重新录音。`,`Audio and existing text are retained. Retry from saved progress without recording again.`],organizing:[`正在生成笔记`,`Preparing notes`,`可以先回听原音、查找原话。笔记完成后可查看重点、结论和行动建议。`,`Play audio and find original statements now. Highlights, conclusions and suggested actions will follow.`],analysis_retrying:[`正在重试生成笔记`,`Retrying notes`,`原音、文字和已有笔记均保留,系统稍后自动重试。`,`Audio, text and existing notes are retained. An automatic retry is scheduled.`],analysis_failed:[`笔记生成未完成`,`Notes incomplete`,`原音、文字和已有笔记均保留。重试只继续整理,不会重新录音或创建重复笔记。`,`Audio, text and existing notes are retained. Retry continues processing without recording again or creating another note.`],ready:[`录音与笔记已就绪`,`Recording and notes are ready`,`现在可以回听原音、查找原话,并回顾重要信息。`,`Play the audio, find original statements and review important information.`],analysis_missing:[`暂未生成笔记`,`Notes are not available yet`,`原音和已有文字仍可使用,可以从原音重新生成文字与笔记。`,`Audio and existing text remain available. Regenerate text and notes from the original audio.`],analysis_stale:[`原文已更新`,`Transcript updated`,`当前笔记基于修改前的原文,可保留查看,也可按新版原文重新整理。`,`Existing notes use an earlier transcript. Keep them or generate notes from the updated text.`],source_missing:[`原音尚不可用`,`Original audio is not available yet`,`请到录制设备的待恢复录音中继续同步。已有文字和笔记仍可查看。`,`Continue sync from recoverable recordings on the recording device. Existing text and notes remain readable.`],audio_deleted:[`原音已删除`,`Original audio was deleted`,`已有文字和笔记仍可查看;重新生成需要重新导入原音。`,`Existing text and notes remain readable. Import the original audio again to regenerate.`]},h={leave_local:[`录音已在本机保存,可以离开当前页面。`,`Recording saved on this device. You can leave this page.`],leave_cloud:[`原音已同步,可以离开当前页面。`,`Original audio synced. You can leave this page.`],leave_hold:[`请先确认保存结果,再离开当前页面。`,`Confirm the recording is saved before leaving this page.`],local_hint:[`关闭应用后,可在待恢复录音中继续同步。请保留本机录音数据。`,`After closing the app, continue sync from recoverable recordings. Keep the recording data on this device.`],cloud_hint:[`后续转写与笔记整理在后台继续;失败时可在这条笔记中重试。`,`Transcription and notes continue on the server. Retry here if processing fails.`],retry_sync:[`重试同步`,`Retry sync`],retry_pipeline:[`继续处理`,`Resume processing`],retry_analysis_failed:[`重试生成笔记`,`Retry notes`],retry_transcription_failed:[`继续整理文字`,`Resume transcription`],retry_verify_failed:[`重试确认原音`,`Retry audio confirmation`],retry_recover:[`恢复已录内容`,`Recover saved audio`],retry_regenerate:[`从原音重新生成`,`Regenerate from audio`],retry_analyze:[`按新版原文整理`,`Update notes from transcript`],audio:[`原音`,`Audio`],text:[`文字`,`Transcript`],note:[`笔记`,`Notes`],available:[`可用`,`Available`],pending:[`尚未完成`,`Not ready`],old_note:[`旧版可用`,`Earlier version available`],open:[`打开笔记`,`Open note`],recover:[`待恢复录音`,`Recoverable recordings`],export:[`导出已录内容`,`Export saved audio`],close:[`稍后查看`,`View later`],annotation_failed:[`重点同步未完成,原音和笔记处理不受影响。`,`Highlights are not synced yet. Audio and note processing are unaffected.`],retry_annotation:[`重试重点同步`,`Retry highlights`]},g=t();function _(e,t=`unknown`,n=`pending`){return{localSave:t,sync:n,serverStatus:e?.discussion.status??``,failureStage:e?.discussion.failureStage??``,jobState:e?.recordingJob?.state??``,retryScheduled:!!e?.processing?.nextAttemptAt,audioAvailable:!!e?.discussion.audioAttachmentId,audioDeleted:!!e?.discussion.audioDeletedAt,textAvailable:!!e?.transcript?.text?.trim()||!!e?.discussion.canonicalTranscript?.trim(),noteAvailable:!!e?.organization?.organization,analysisStale:!!e?.organization&&e.organization.transcriptRevision!==e.transcript?.revision}}function v(e){let t=(0,p.c)(58),{input:n,zh:r,compact:i,busy:s,onRetry:c,children:l,context:d}=e,f=i!==void 0&&i,_=s!==void 0&&s,v=d===void 0?`capture`:d,y,b,x,S,C,w,T,E,D,O,k,A;if(t[0]!==v||t[1]!==n||t[2]!==r){S=u(n),x=m[S.stage];let e;t[15]===r?e=t[16]:(e=e=>h[e][+!r],t[15]=r,t[16]=e),y=e,b=`retry_${[`analysis_failed`,`transcription_failed`,`verify_failed`].includes(S.stage)?S.stage:S.retry}`,k=`polite`,A=S.stage,C=v===`note`?`text-fg`:`rounded-xl bg-surface-inset p-3 text-fg`,w=v===`capture`?(0,g.jsx)(`p`,{className:`mb-1 text-sm font-medium`,children:y(`leave_${S.leave}`)}):null,D=`group`,O=v,E=`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-lg text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,T=S.stage.endsWith(`_failed`)||S.stage===`local_partial`?`bg-danger`:`bg-accent`,t[0]=v,t[1]=n,t[2]=r,t[3]=y,t[4]=b,t[5]=x,t[6]=S,t[7]=C,t[8]=w,t[9]=T,t[10]=E,t[11]=D,t[12]=O,t[13]=k,t[14]=A}else y=t[3],b=t[4],x=t[5],S=t[6],C=t[7],w=t[8],T=t[9],E=t[10],D=t[11],O=t[12],k=t[13],A=t[14];let j=`size-1.5 shrink-0 rounded-full ${T}`,M;t[17]===j?M=t[18]:(M=(0,g.jsx)(`span`,{className:j,"aria-hidden":!0}),t[17]=j,t[18]=M);let N=x[+!r],P;t[19]===N?P=t[20]:(P=(0,g.jsx)(`span`,{className:`min-w-0 flex-1`,children:N}),t[19]=N,t[20]=P);let F;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,g.jsx)(a,{className:`size-3.5 shrink-0 text-fg-muted transition-transform group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0}),t[21]=F):F=t[21];let I;t[22]!==M||t[23]!==P||t[24]!==E?(I=(0,g.jsxs)(`summary`,{className:E,children:[M,P,F]}),t[22]=M,t[23]=P,t[24]=E,t[25]=I):I=t[25];let L;t[26]!==v||t[27]!==y||t[28]!==S.leave?(L=v===`note`?(0,g.jsx)(`p`,{children:y(`leave_${S.leave}`)}):null,t[26]=v,t[27]=y,t[28]=S.leave,t[29]=L):L=t[29];let R;t[30]!==f||t[31]!==y||t[32]!==x||t[33]!==S||t[34]!==r?(R=f?null:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`p`,{children:x[r?2:3]}),S.leave===`local`?(0,g.jsx)(`p`,{children:y(`local_hint`)}):null,(0,g.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1`,"aria-label":r?`已可用内容`:`Available content`,children:[`audio`,`text`,`note`].map(e=>(0,g.jsxs)(`li`,{children:[y(e),` · `,e===`note`&&S.note&&S.stale?y(`old_note`):y(S[e]?`available`:`pending`)]},e))})]}),t[30]=f,t[31]=y,t[32]=x,t[33]=S,t[34]=r,t[35]=R):R=t[35];let z;t[36]!==L||t[37]!==R?(z=(0,g.jsxs)(`div`,{className:`space-y-2 pb-3 text-xs leading-5 text-fg-muted`,children:[L,R]}),t[36]=L,t[37]=R,t[38]=z):z=t[38];let B;t[39]!==I||t[40]!==z||t[41]!==D||t[42]!==O?(B=(0,g.jsxs)(`details`,{className:D,children:[I,z]},O),t[39]=I,t[40]=z,t[41]=D,t[42]=O,t[43]=B):B=t[43];let V;t[44]!==_||t[45]!==c||t[46]!==y||t[47]!==b||t[48]!==S.retry?(V=S.retry!==`none`&&c?(0,g.jsx)(o,{className:`min-h-11`,disabled:_,onClick:()=>c(S.retry),children:y(b)}):null,t[44]=_,t[45]=c,t[46]=y,t[47]=b,t[48]=S.retry,t[49]=V):V=t[49];let H;return t[50]!==l||t[51]!==C||t[52]!==w||t[53]!==B||t[54]!==V||t[55]!==k||t[56]!==A?(H=(0,g.jsxs)(`section`,{"aria-live":k,"data-recording-outcome":A,className:C,children:[w,B,V,l]}),t[50]=l,t[51]=C,t[52]=w,t[53]=B,t[54]=V,t[55]=k,t[56]=A,t[57]=H):H=t[57],H}function y(){return r(n(`/api/discussion-capture/settings`))}function b(e){return r(n(`/api/discussion-capture/settings`),{method:`PUT`,body:JSON.stringify({consentPolicyVersion:e})})}async function x(e){return r(n(`/api/discussions`),{method:`POST`,body:JSON.stringify(e)})}function S(e){return r(n(`/api/discussions/${encodeURIComponent(e)}`))}async function C(e){try{return await r(n(`/api/discussions/by-note/${encodeURIComponent(e)}`))}catch(e){if(e.status===404)return null;throw e}}function w(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/transcript`))}function T(e,t,i){let a=new FormData;return a.set(`file`,i.blob,`segment-${t}.wav`),a.set(`startedAtMs`,String(i.startedAtMs)),a.set(`endedAtMs`,String(i.endedAtMs)),a.set(`sha256`,i.sha256),r(n(`/api/discussions/${encodeURIComponent(e)}/segments/${t}`),{method:`PUT`,body:a})}function E(e,t=`resume`){return r(n(`/api/discussions/${encodeURIComponent(e)}/retry`),{method:`POST`,body:JSON.stringify({mode:t})})}function D(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/project`),{method:`DELETE`})}function O(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/chunks`))}function k(e,t,i,a){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/chunks/${t}`),{method:`PUT`,headers:{"Content-Type":`application/octet-stream`,"x-audio-sha256":a},body:i})}function A(e,t){return r(n(`/api/discussions/${encodeURIComponent(e)}/capture/seal`),{method:`POST`,body:JSON.stringify(t)})}function j(e){return r(n(`/api/discussions/${encodeURIComponent(e)}/recording/job`))}var M=()=>window.dispatchEvent(new Event(`discussion-annotations-changed`));async function N(){return new Promise((e,t)=>{let n=indexedDB.open(`xopc-note-annotations`,1);n.onupgradeneeded=()=>{n.result.createObjectStore(`annotations`,{keyPath:[`recordingId`,`annotation.id`]}).createIndex(`recordingId`,`recordingId`)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function P(e,t){let n=await N();try{return await new Promise((r,i)=>{let a=n.transaction(`annotations`,e?`readwrite`:`readonly`,{durability:`strict`}),o,s;a.oncomplete=()=>r(o),a.onabort=()=>i(s??a.error??Error(`Annotation save failed`)),a.onerror=()=>i(a.error);try{t(a.objectStore(`annotations`),e=>{o=e},e=>{s=e,a.abort()})}catch(e){a.abort(),i(e)}})}finally{n.close()}}async function F(e){return P(!1,(t,n)=>{let r=t.index(`recordingId`).getAll(e);r.onsuccess=()=>n(r.result)})}async function I(e,t,n){await P(!0,(r,i,a)=>{let o=r.get([e,t.id]);o.onsuccess=()=>{let s=o.result;if(n!==void 0&&(n===null?s&&s.state!==`synced`:s?.nonce!==n)){a(Error(`Annotation changed in another tab. Your editor content is retained; reload before saving.`));return}r.put({recordingId:e,annotation:t,nonce:crypto.randomUUID(),state:`pending`}),i()}}),M()}function L(e,t=`highlight`){let n=Date.now();return{id:crypto.randomUUID(),kind:t,text:``,anchor:e,revision:0,deleted:!1,createdAt:n,updatedAt:n}}async function R(e,t,n){await P(!0,(r,i)=>{let a=r.get([e,t]);a.onsuccess=()=>{let e=a.result;e&&e.annotation.anchor.offsetMs===void 0&&r.put({...e,nonce:crypto.randomUUID(),state:`pending`,annotation:{...e.annotation,anchor:{...e.annotation.anchor,offsetMs:n}}}),i()}}),M()}async function z(e,t,n=!1){await P(!0,(r,i)=>{let a=r.get([e.recordingId,e.annotation.id]);a.onsuccess=()=>{let o=a.result;o&&(o.nonce===e.nonce?r.put({...o,annotation:t??o.annotation,state:n?`conflict`:`synced`}):t&&o.annotation.revision===e.annotation.revision&&r.put({...o,annotation:{...o.annotation,revision:t.revision}})),i()}}),M()}var B=new Map;function V(e,t){let i=`${e}:${t}`;if(B.has(i))return B.get(i);let a=(async()=>{for(let i=0;i<5;i++){let i=(await F(e)).filter(e=>e.state===`pending`);if(!i.length)return;for(let e of i){if(e.state!==`pending`)continue;let i=e.annotation;try{await z(e,await r(n(`/api/discussions/${encodeURIComponent(t)}/annotations/${encodeURIComponent(i.id)}`),{method:`PUT`,signal:AbortSignal.timeout(15e3),body:JSON.stringify({id:i.id,kind:i.kind,text:i.text,anchor:i.anchor,expectedRevision:i.revision,deleted:i.deleted})}))}catch(t){throw t.status===409&&await z(e,void 0,!0),t}}}throw Error(`Highlights are still being updated. Saved local changes will sync on retry.`)})().finally(()=>B.delete(i));return B.set(i,a),a}export{f as C,s as E,d as S,c as T,D as _,R as a,v as b,x as c,C as d,w as f,A as g,E as h,L as i,S as l,j as m,z as n,I as o,O as p,F as r,b as s,V as t,y as u,T as v,l as w,_ as x,k as y};
@@ -1 +1 @@
1
- import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r}from"./locale-store-TQcz_Vjt.js";import{t as i}from"./messages-DaLmc4W1.js";import{r as a}from"./extension-provider-BZwcaU5Y.js";import{n as o,t as s}from"./settings-page-header-DuNCn8i-.js";import"./settings-page-layout-DeNC8YHJ.js";var c=t();e();var l=n();function u(){let e=(0,c.c)(40),t=r(p),n;e[0]===t?n=e[1]:(n=i(t),e[0]=t,e[1]=n);let u=n.extensionDebug,m=a(),h;e[2]===m?h=e[3]:(h=m.toSorted(f),e[2]=m,e[3]=h);let g=h,_;e[4]!==u.subtitle||e[5]!==u.title?(_=(0,l.jsx)(s,{title:u.title,subtitle:u.subtitle}),e[4]=u.subtitle,e[5]=u.title,e[6]=_):_=e[6];let v;e[7]===u.listHeading?v=e[8]:(v=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.listHeading}),e[7]=u.listHeading,e[8]=v);let y;e[9]===u.colId?y=e[10]:(y=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colId}),e[9]=u.colId,e[10]=y);let b;e[11]===u.colName?b=e[12]:(b=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colName}),e[11]=u.colName,e[12]=b);let x;e[13]===u.colPermissions?x=e[14]:(x=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colPermissions}),e[13]=u.colPermissions,e[14]=x);let S;e[15]!==y||e[16]!==b||e[17]!==x?(S=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`text-xs uppercase text-fg-muted`,children:[y,b,x]})}),e[15]=y,e[16]=b,e[17]=x,e[18]=S):S=e[18];let C;e[19]===g?C=e[20]:(C=g.map(d),e[19]=g,e[20]=C);let w;e[21]===C?w=e[22]:(w=(0,l.jsx)(`tbody`,{children:C}),e[21]=C,e[22]=w);let T;e[23]!==S||e[24]!==w?(T=(0,l.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full min-w-[32rem] border-separate border-spacing-y-1 text-left text-sm`,children:[S,w]})}),e[23]=S,e[24]=w,e[25]=T):T=e[25];let E;e[26]!==T||e[27]!==v?(E=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[v,T]}),e[26]=T,e[27]=v,e[28]=E):E=e[28];let D;e[29]===u.futureHeading?D=e[30]:(D=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.futureHeading}),e[29]=u.futureHeading,e[30]=D);let O;e[31]===u.futureBody?O=e[32]:(O=(0,l.jsx)(`p`,{className:`mt-2`,children:u.futureBody}),e[31]=u.futureBody,e[32]=O);let k;e[33]!==D||e[34]!==O?(k=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4 text-sm text-fg-muted`,children:[D,O]}),e[33]=D,e[34]=O,e[35]=k):k=e[35];let A;return e[36]!==E||e[37]!==k||e[38]!==_?(A=(0,l.jsxs)(o,{gap:`gap-5`,children:[_,E,k]}),e[36]=E,e[37]=k,e[38]=_,e[39]=A):A=e[39],A}function d(e){return(0,l.jsxs)(`tr`,{className:`bg-surface-base/55`,children:[(0,l.jsx)(`td`,{className:`rounded-l-lg px-3 py-2 font-mono text-xs text-fg`,children:e.id}),(0,l.jsx)(`td`,{className:`px-3 py-2 text-fg`,children:e.name}),(0,l.jsx)(`td`,{className:`rounded-r-lg px-3 py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function f(e,t){return e.id.localeCompare(t.id)}function p(e){return e.language}export{u as ExtensionDebugPage};
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r}from"./locale-store-Br7IfbXK.js";import{t as i}from"./messages-ByFlEbsu.js";import{r as a}from"./extension-provider-C_uKqJxP.js";import{n as o,t as s}from"./settings-page-header-DBL0_u0Z.js";import"./settings-page-layout-IAvpbz4A.js";var c=t();e();var l=n();function u(){let e=(0,c.c)(40),t=r(p),n;e[0]===t?n=e[1]:(n=i(t),e[0]=t,e[1]=n);let u=n.extensionDebug,m=a(),h;e[2]===m?h=e[3]:(h=m.toSorted(f),e[2]=m,e[3]=h);let g=h,_;e[4]!==u.subtitle||e[5]!==u.title?(_=(0,l.jsx)(s,{title:u.title,subtitle:u.subtitle}),e[4]=u.subtitle,e[5]=u.title,e[6]=_):_=e[6];let v;e[7]===u.listHeading?v=e[8]:(v=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.listHeading}),e[7]=u.listHeading,e[8]=v);let y;e[9]===u.colId?y=e[10]:(y=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colId}),e[9]=u.colId,e[10]=y);let b;e[11]===u.colName?b=e[12]:(b=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colName}),e[11]=u.colName,e[12]=b);let x;e[13]===u.colPermissions?x=e[14]:(x=(0,l.jsx)(`th`,{className:`px-3 py-2`,children:u.colPermissions}),e[13]=u.colPermissions,e[14]=x);let S;e[15]!==y||e[16]!==b||e[17]!==x?(S=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`text-xs uppercase text-fg-muted`,children:[y,b,x]})}),e[15]=y,e[16]=b,e[17]=x,e[18]=S):S=e[18];let C;e[19]===g?C=e[20]:(C=g.map(d),e[19]=g,e[20]=C);let w;e[21]===C?w=e[22]:(w=(0,l.jsx)(`tbody`,{children:C}),e[21]=C,e[22]=w);let T;e[23]!==S||e[24]!==w?(T=(0,l.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full min-w-[32rem] border-separate border-spacing-y-1 text-left text-sm`,children:[S,w]})}),e[23]=S,e[24]=w,e[25]=T):T=e[25];let E;e[26]!==T||e[27]!==v?(E=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[v,T]}),e[26]=T,e[27]=v,e[28]=E):E=e[28];let D;e[29]===u.futureHeading?D=e[30]:(D=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:u.futureHeading}),e[29]=u.futureHeading,e[30]=D);let O;e[31]===u.futureBody?O=e[32]:(O=(0,l.jsx)(`p`,{className:`mt-2`,children:u.futureBody}),e[31]=u.futureBody,e[32]=O);let k;e[33]!==D||e[34]!==O?(k=(0,l.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4 text-sm text-fg-muted`,children:[D,O]}),e[33]=D,e[34]=O,e[35]=k):k=e[35];let A;return e[36]!==E||e[37]!==k||e[38]!==_?(A=(0,l.jsxs)(o,{gap:`gap-5`,children:[_,E,k]}),e[36]=E,e[37]=k,e[38]=_,e[39]=A):A=e[39],A}function d(e){return(0,l.jsxs)(`tr`,{className:`bg-surface-base/55`,children:[(0,l.jsx)(`td`,{className:`rounded-l-lg px-3 py-2 font-mono text-xs text-fg`,children:e.id}),(0,l.jsx)(`td`,{className:`px-3 py-2 text-fg`,children:e.name}),(0,l.jsx)(`td`,{className:`rounded-r-lg px-3 py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function f(e,t){return e.id.localeCompare(t.id)}function p(e){return e.language}export{u as ExtensionDebugPage};
@@ -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{i,l as a,n as ee,o}from"./locale-store-TQcz_Vjt.js";import{t as te}from"./messages-DaLmc4W1.js";import{a as s,n as c,o as l,r as ne,s as re,t as u}from"./dist-DfWfZ9iu.js";import{c as d,n as f}from"./extension-provider-BZwcaU5Y.js";import{i as p}from"./theme-store-DB1ZfBUm.js";import{r as m}from"./settings-form-draft-Dy10ldo8.js";var h=e(t(),1),ie=n();function g(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function _(e,t){let n=g(t);return i(`/api/extensions/${encodeURIComponent(e)}/assets/${n}`)}var v={"capability:xopc.notes.create":`Create notes in this workspace`,"capability:xopc.notes.update":`Change notes in this workspace at an exact revision`,"capability:xopc.notes.append":`Append content to notes in this workspace`,"capability:xopc.notes.get":`Read notes in this workspace by ID`,"capability:xopc.notes.list":`Search and list notes in this workspace`,"capability:xopc.tasks.get":`Read tasks and their context in this workspace`,"capability:xopc.tasks.list":`Search and list tasks in this workspace`,theme:`Read theme (light / dark)`,"agent.send":`Send messages to the assistant`,"agent.subscribe":`Receive live agent stream events for a chat`,"session.read":`List and open chat sessions`,"config.read":`Read plugin configuration`,"config.write":`Write plugin configuration`,storage:`Read and write plugin storage`,notification:`Show in-app notifications`},y={"capability:xopc.notes.create":`在当前工作区创建笔记`,"capability:xopc.notes.update":`按精确版本修改当前工作区的笔记`,"capability:xopc.notes.append":`向当前工作区的笔记追加内容`,"capability:xopc.notes.get":`按 ID 读取当前工作区的笔记`,"capability:xopc.notes.list":`搜索和列出当前工作区的笔记`,"capability:xopc.tasks.get":`读取当前工作区的任务及其上下文`,"capability:xopc.tasks.list":`搜索和列出当前工作区的任务`,theme:`读取主题(浅色/深色)`,"agent.send":`向助手发送消息`,"agent.subscribe":`接收会话的实时助手流式事件`,"session.read":`列出并打开聊天会话`,"config.read":`读取插件配置`,"config.write":`写入插件配置`,storage:`读写插件存储`,notification:`显示应用内通知`};function b(e,t){let n=v[e];return t===`zh`&&y[e]?y[e]:n??e}var x=r();function S(e){let t=(0,ie.c)(59),{open:n,onOpenChange:r,extensionId:i,extensionName:a,permissions:o,onConfirm:d,confirmDisabled:f}=e,p=ee(w),m,h,g,_,v,y,S,T,E,D,O,k;t[0]!==a||t[1]!==p||t[2]!==r||t[3]!==n?(v=te(p).extensionUi,_=u,O=n,k=r,g=l,t[16]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,x.jsx)(s,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[16]=D):D=t[16],h=ne,T=`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-5`,E=C,m=re,y=`text-base font-semibold text-fg`,S=v.permissionTitle.replace(`{{name}}`,a),t[0]=a,t[1]=p,t[2]=r,t[3]=n,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=v,t[9]=y,t[10]=S,t[11]=T,t[12]=E,t[13]=D,t[14]=O,t[15]=k):(m=t[4],h=t[5],g=t[6],_=t[7],v=t[8],y=t[9],S=t[10],T=t[11],E=t[12],D=t[13],O=t[14],k=t[15]);let A;t[17]!==m||t[18]!==y||t[19]!==S?(A=(0,x.jsx)(m,{className:y,children:S}),t[17]=m,t[18]=y,t[19]=S,t[20]=A):A=t[20];let j;t[21]===i?j=t[22]:(j=(0,x.jsxs)(`span`,{className:`font-mono text-xs text-fg-muted`,title:i,children:[`(`,i,`)`]}),t[21]=i,t[22]=j);let M;t[23]!==v.permissionSubtitle||t[24]!==j?(M=(0,x.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[v.permissionSubtitle,` `,j]}),t[23]=v.permissionSubtitle,t[24]=j,t[25]=M):M=t[25];let N;t[26]!==p||t[27]!==o||t[28]!==v.permissionsNone?(N=o.length===0?(0,x.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:v.permissionsNone}):(0,x.jsx)(`ul`,{className:`mt-4 max-h-48 list-inside list-disc space-y-1 overflow-y-auto text-sm text-fg`,children:o.map(e=>(0,x.jsx)(`li`,{children:b(e,p)},e))}),t[26]=p,t[27]=o,t[28]=v.permissionsNone,t[29]=N):N=t[29];let P;t[30]===v.deny?P=t[31]:(P=(0,x.jsx)(c,{asChild:!0,children:(0,x.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-inset`,children:v.deny})}),t[30]=v.deny,t[31]=P);let F;t[32]!==d||t[33]!==r?(F=()=>{d(),r(!1)},t[32]=d,t[33]=r,t[34]=F):F=t[34];let I;t[35]!==f||t[36]!==v.allow||t[37]!==F?(I=(0,x.jsx)(`button`,{type:`button`,disabled:f,className:`rounded-lg bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:opacity-90`,onClick:F,children:v.allow}),t[35]=f,t[36]=v.allow,t[37]=F,t[38]=I):I=t[38];let L;t[39]!==P||t[40]!==I?(L=(0,x.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[39]=P,t[40]=I,t[41]=L):L=t[41];let R;t[42]!==h||t[43]!==M||t[44]!==N||t[45]!==L||t[46]!==T||t[47]!==E||t[48]!==A?(R=(0,x.jsxs)(h,{className:T,onOpenAutoFocus:E,children:[A,M,N,L]}),t[42]=h,t[43]=M,t[44]=N,t[45]=L,t[46]=T,t[47]=E,t[48]=A,t[49]=R):R=t[49];let z;t[50]!==g||t[51]!==R||t[52]!==D?(z=(0,x.jsxs)(g,{children:[D,R]}),t[50]=g,t[51]=R,t[52]=D,t[53]=z):z=t[53];let B;return t[54]!==_||t[55]!==z||t[56]!==O||t[57]!==k?(B=(0,x.jsx)(_,{open:O,onOpenChange:k,children:z}),t[54]=_,t[55]=z,t[56]=O,t[57]=k,t[58]=B):B=t[58],B}function C(e){return e.preventDefault()}function w(e){return e.language}async function T(e){let{grant:t}=await o(i(`/api/extensions/${encodeURIComponent(e)}/ui-grant`));return t}async function E(e,t){return(await o(i(`/api/extensions/${encodeURIComponent(e)}/ui-grant`),{method:`POST`,body:JSON.stringify({manifestDigest:t})})).grant}var D=48,O=2e3,k=`allow-scripts allow-forms allow-popups`;function A(e){let t=(0,ie.c)(98),{extensionId:n,extensionName:r,entrypoint:i,permissions:o,title:s,className:c,fixedHeight:l,maxHeight:ne,minHeight:re,initialData:u}=e,g=ne===void 0?O:ne,v=re===void 0?D:re,y=ee(P),b;t[0]===y?b=t[1]:(b=te(y),t[0]=y,t[1]=b);let C=b.extensionUi,w=f(),A=a(N),F=a(M),I=(0,h.useRef)(0),L=(0,h.useRef)(!1),R=(0,h.useRef)(null),z=p(j),B;t[2]!==n||t[3]!==r?(B=r?.trim()||n,t[2]=n,t[3]=r,t[4]=B):B=t[4];let ae=B,oe;t[5]!==n||t[6]!==s?(oe=s?.trim()||`Extension ${n}`,t[5]=n,t[6]=s,t[7]=oe):oe=t[7];let se=oe,V;t[8]===o?V=t[9]:(V=JSON.stringify(Array.from(o??[]).toSorted()),t[8]=o,t[9]=V);let ce=V,H;t[10]===ce?H=t[11]:(H=JSON.parse(ce),t[10]=ce,t[11]=H);let le=H,ue=l??Math.min(g,Math.max(v,320)),U;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(U=[],t[12]=U):U=t[12];let W;t[13]===ue?W=t[14]:(W={allowed:!1,dialogOpen:!1,reloadKey:0,loadError:!1,dynamicHeight:ue,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:U},t[13]=ue,t[14]=W);let[G,K]=(0,h.useReducer)(m,W),{allowed:q,dialogOpen:J,reloadKey:Y,loadError:de,dynamicHeight:fe,grantResolved:pe,grantError:X}=G,me;t[15]===n?me=t[16]:(me=()=>{let e=!0;return L.current=!1,K({type:`patch`,patch:{allowed:!1,dialogOpen:!1,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:[]}}),T(n).then(t=>{if(e){if(t.extensionId!==n||!t.manifestDigest)throw Error(`Could not verify plugin permissions`);K({type:`patch`,patch:{allowed:t.granted,dialogOpen:!t.granted,grantResolved:!0,manifestDigest:t.manifestDigest,grantedPermissions:t.permissions}})}}).catch(t=>{e&&K({type:`patch`,patch:{allowed:!1,dialogOpen:!0,grantResolved:!0,grantError:t instanceof Error?t.message:String(t)}})}),()=>{e=!1,I.current+=1}},t[15]=n,t[16]=me);let he;t[17]!==n||t[18]!==A||t[19]!==F||t[20]!==le||t[21]!==Y?(he=[n,le,A,F,Y],t[17]=n,t[18]=A,t[19]=F,t[20]=le,t[21]=Y,t[22]=he):he=t[22],(0,h.useEffect)(me,he);let ge;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>K({type:`patch`,patch:{dialogOpen:e}}),t[23]=ge):ge=t[23];let _e=ge,ve;t[24]!==i||t[25]!==n?(ve=_(n,i),t[24]=i,t[25]=n,t[26]=ve):ve=t[26];let ye=ve,be;t[27]!==q||t[28]!==n||t[29]!==l||t[30]!==g||t[31]!==v||t[32]!==w||t[33]!==G.grantedPermissions||t[34]!==G.manifestDigest?(be=()=>{if(!q)return;let e=R.current;if(!e)return;w.registerIframe(n,e,G.grantedPermissions,G.manifestDigest??void 0);let t=w.subscribeExtensionEvents(n,e=>{if(e.event!==`ui.resize`||!e.data||typeof e.data!=`object`||e.data===null)return;let t=Number(e.data.height);Number.isFinite(t)&&l===void 0&&K({type:`patch`,patch:{dynamicHeight:Math.min(g,Math.max(v,t))}})});return()=>{t(),w.unregisterIframe(n)}},t[27]=q,t[28]=n,t[29]=l,t[30]=g,t[31]=v,t[32]=w,t[33]=G.grantedPermissions,t[34]=G.manifestDigest,t[35]=be):be=t[35];let xe;t[36]!==q||t[37]!==n||t[38]!==l||t[39]!==g||t[40]!==v||t[41]!==Y||t[42]!==w||t[43]!==G.grantedPermissions||t[44]!==G.manifestDigest?(xe=[q,n,l,g,v,G.grantedPermissions,G.manifestDigest,w,Y],t[36]=q,t[37]=n,t[38]=l,t[39]=g,t[40]=v,t[41]=Y,t[42]=w,t[43]=G.grantedPermissions,t[44]=G.manifestDigest,t[45]=xe):xe=t[45],(0,h.useLayoutEffect)(be,xe);let Se,Ce;t[46]!==q||t[47]!==n||t[48]!==z||t[49]!==w?(Se=()=>{if(!q)return;let e=d(z);w.sendEvent(n,`theme.changed`,e)},Ce=[q,n,z,w],t[46]=q,t[47]=n,t[48]=z,t[49]=w,t[50]=Se,t[51]=Ce):(Se=t[50],Ce=t[51]),(0,h.useEffect)(Se,Ce);let we;t[52]!==fe||t[53]!==l?(we=l===void 0?{width:`100%`,height:fe,border:`none`}:{width:`100%`,height:l,border:`none`},t[52]=fe,t[53]=l,t[54]=we):we=t[54];let Te=we,Ee;t[55]!==n||t[56]!==A||t[57]!==F||t[58]!==G.manifestDigest?(Ee=()=>{if(L.current||!G.manifestDigest)return;L.current=!0;let e=I.current,t=()=>I.current===e&&a.getState().baseUrl===A&&a.getState().conversationId===F;E(n,G.manifestDigest).then(e=>{if(t()){if(!e.granted||e.extensionId!==n||e.manifestDigest!==G.manifestDigest)throw Error(`Permission grant was not persisted`);K({type:`patch`,patch:{allowed:!0,grantError:null}})}}).catch(e=>{t()&&K({type:`patch`,patch:{allowed:!1,manifestDigest:null,grantError:e instanceof Error?e.message:String(e)}})}).finally(()=>{t()&&(L.current=!1)})},t[55]=n,t[56]=A,t[57]=F,t[58]=G.manifestDigest,t[59]=Ee):Ee=t[59];let De=Ee;if(!pe){let e=`${c??``} min-h-32 animate-pulse rounded-lg bg-surface-inset`,n;return t[60]===e?n=t[61]:(n=(0,x.jsx)(`div`,{className:e}),t[60]=e,t[61]=n),n}if(!q){let e=!G.manifestDigest,r;t[62]!==J||t[63]!==ae||t[64]!==n||t[65]!==De||t[66]!==e||t[67]!==G.grantedPermissions?(r=(0,x.jsx)(S,{open:J,onOpenChange:_e,extensionId:n,extensionName:ae,permissions:G.grantedPermissions,confirmDisabled:e,onConfirm:De}),t[62]=J,t[63]=ae,t[64]=n,t[65]=De,t[66]=e,t[67]=G.grantedPermissions,t[68]=r):r=t[68];let i;t[69]!==c||t[70]!==J||t[71]!==X||t[72]!==Y||t[73]!==C?(i=J?null:(0,x.jsxs)(`div`,{className:c?`${c} rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`:`rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`,children:[X?(0,x.jsx)(`p`,{className:`mb-2 text-danger`,children:X}):null,(0,x.jsx)(`p`,{children:C.deniedHint}),(0,x.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>K({type:`patch`,patch:{reloadKey:Y+1}}),children:C.reviewPermissions})]}),t[69]=c,t[70]=J,t[71]=X,t[72]=Y,t[73]=C,t[74]=i):i=t[74];let a;return t[75]!==r||t[76]!==i?(a=(0,x.jsxs)(x.Fragment,{children:[r,i]}),t[75]=r,t[76]=i,t[77]=a):a=t[77],a}let Z;t[78]!==de||t[79]!==Y||t[80]!==C?(Z=de?(0,x.jsxs)(`div`,{className:`mb-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-fg`,children:[(0,x.jsx)(`p`,{children:C.loadFailed}),(0,x.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:C.loadFailedConnectionHint}),(0,x.jsx)(`button`,{type:`button`,className:`mt-2 font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>{K({type:`patch`,patch:{loadError:!1,reloadKey:Y+1}})},children:C.retryLoad})]}):null,t[78]=de,t[79]=Y,t[80]=C,t[81]=Z):Z=t[81];let Oe=`${n}-${i}-${Y}`,ke;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>K({type:`patch`,patch:{loadError:!0}}),t[82]=ke):ke=t[82];let Q;t[83]!==n||t[84]!==u||t[85]!==y||t[86]!==w?(Q=()=>{K({type:`patch`,patch:{loadError:!1}}),w.sendInit(n,d(p.getState().resolved),y),u!==void 0&&w.sendEvent(n,`widget.data`,u)},t[83]=n,t[84]=u,t[85]=y,t[86]=w,t[87]=Q):Q=t[87];let $;t[88]!==c||t[89]!==se||t[90]!==ye||t[91]!==Te||t[92]!==Oe||t[93]!==Q?($=(0,x.jsx)(`iframe`,{ref:R,className:c,title:se,src:ye,style:Te,sandbox:k,referrerPolicy:`no-referrer`,onError:ke,onLoad:Q},Oe),t[88]=c,t[89]=se,t[90]=ye,t[91]=Te,t[92]=Oe,t[93]=Q,t[94]=$):$=t[94];let Ae;return t[95]!==Z||t[96]!==$?(Ae=(0,x.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col`,children:[Z,$]}),t[95]=Z,t[96]=$,t[97]=Ae):Ae=t[97],Ae}function j(e){return e.resolved}function M(e){return e.conversationId}function N(e){return e.baseUrl}function P(e){return e.language}export{A as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,l as a,n as ee,o}from"./locale-store-Br7IfbXK.js";import{t as te}from"./messages-ByFlEbsu.js";import{a as s,n as c,o as l,r as ne,s as re,t as u}from"./dist-DfWfZ9iu.js";import{c as d,n as f}from"./extension-provider-C_uKqJxP.js";import{i as p}from"./theme-store-Dlnmgryi.js";import{r as m}from"./settings-form-draft-Dy10ldo8.js";var h=e(t(),1),ie=n();function g(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function _(e,t){let n=g(t);return i(`/api/extensions/${encodeURIComponent(e)}/assets/${n}`)}var v={"capability:xopc.notes.create":`Create notes in this workspace`,"capability:xopc.notes.update":`Change notes in this workspace at an exact revision`,"capability:xopc.notes.append":`Append content to notes in this workspace`,"capability:xopc.notes.get":`Read notes in this workspace by ID`,"capability:xopc.notes.list":`Search and list notes in this workspace`,"capability:xopc.tasks.get":`Read tasks and their context in this workspace`,"capability:xopc.tasks.list":`Search and list tasks in this workspace`,theme:`Read theme (light / dark)`,"agent.send":`Send messages to the assistant`,"agent.subscribe":`Receive live agent stream events for a chat`,"session.read":`List and open chat sessions`,"config.read":`Read plugin configuration`,"config.write":`Write plugin configuration`,storage:`Read and write plugin storage`,notification:`Show in-app notifications`},y={"capability:xopc.notes.create":`在当前工作区创建笔记`,"capability:xopc.notes.update":`按精确版本修改当前工作区的笔记`,"capability:xopc.notes.append":`向当前工作区的笔记追加内容`,"capability:xopc.notes.get":`按 ID 读取当前工作区的笔记`,"capability:xopc.notes.list":`搜索和列出当前工作区的笔记`,"capability:xopc.tasks.get":`读取当前工作区的任务及其上下文`,"capability:xopc.tasks.list":`搜索和列出当前工作区的任务`,theme:`读取主题(浅色/深色)`,"agent.send":`向助手发送消息`,"agent.subscribe":`接收会话的实时助手流式事件`,"session.read":`列出并打开聊天会话`,"config.read":`读取插件配置`,"config.write":`写入插件配置`,storage:`读写插件存储`,notification:`显示应用内通知`};function b(e,t){let n=v[e];return t===`zh`&&y[e]?y[e]:n??e}var x=r();function S(e){let t=(0,ie.c)(59),{open:n,onOpenChange:r,extensionId:i,extensionName:a,permissions:o,onConfirm:d,confirmDisabled:f}=e,p=ee(w),m,h,g,_,v,y,S,T,E,D,O,k;t[0]!==a||t[1]!==p||t[2]!==r||t[3]!==n?(v=te(p).extensionUi,_=u,O=n,k=r,g=l,t[16]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,x.jsx)(s,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[16]=D):D=t[16],h=ne,T=`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-5`,E=C,m=re,y=`text-base font-semibold text-fg`,S=v.permissionTitle.replace(`{{name}}`,a),t[0]=a,t[1]=p,t[2]=r,t[3]=n,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=v,t[9]=y,t[10]=S,t[11]=T,t[12]=E,t[13]=D,t[14]=O,t[15]=k):(m=t[4],h=t[5],g=t[6],_=t[7],v=t[8],y=t[9],S=t[10],T=t[11],E=t[12],D=t[13],O=t[14],k=t[15]);let A;t[17]!==m||t[18]!==y||t[19]!==S?(A=(0,x.jsx)(m,{className:y,children:S}),t[17]=m,t[18]=y,t[19]=S,t[20]=A):A=t[20];let j;t[21]===i?j=t[22]:(j=(0,x.jsxs)(`span`,{className:`font-mono text-xs text-fg-muted`,title:i,children:[`(`,i,`)`]}),t[21]=i,t[22]=j);let M;t[23]!==v.permissionSubtitle||t[24]!==j?(M=(0,x.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[v.permissionSubtitle,` `,j]}),t[23]=v.permissionSubtitle,t[24]=j,t[25]=M):M=t[25];let N;t[26]!==p||t[27]!==o||t[28]!==v.permissionsNone?(N=o.length===0?(0,x.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:v.permissionsNone}):(0,x.jsx)(`ul`,{className:`mt-4 max-h-48 list-inside list-disc space-y-1 overflow-y-auto text-sm text-fg`,children:o.map(e=>(0,x.jsx)(`li`,{children:b(e,p)},e))}),t[26]=p,t[27]=o,t[28]=v.permissionsNone,t[29]=N):N=t[29];let P;t[30]===v.deny?P=t[31]:(P=(0,x.jsx)(c,{asChild:!0,children:(0,x.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-inset`,children:v.deny})}),t[30]=v.deny,t[31]=P);let F;t[32]!==d||t[33]!==r?(F=()=>{d(),r(!1)},t[32]=d,t[33]=r,t[34]=F):F=t[34];let I;t[35]!==f||t[36]!==v.allow||t[37]!==F?(I=(0,x.jsx)(`button`,{type:`button`,disabled:f,className:`rounded-lg bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:opacity-90`,onClick:F,children:v.allow}),t[35]=f,t[36]=v.allow,t[37]=F,t[38]=I):I=t[38];let L;t[39]!==P||t[40]!==I?(L=(0,x.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[39]=P,t[40]=I,t[41]=L):L=t[41];let R;t[42]!==h||t[43]!==M||t[44]!==N||t[45]!==L||t[46]!==T||t[47]!==E||t[48]!==A?(R=(0,x.jsxs)(h,{className:T,onOpenAutoFocus:E,children:[A,M,N,L]}),t[42]=h,t[43]=M,t[44]=N,t[45]=L,t[46]=T,t[47]=E,t[48]=A,t[49]=R):R=t[49];let z;t[50]!==g||t[51]!==R||t[52]!==D?(z=(0,x.jsxs)(g,{children:[D,R]}),t[50]=g,t[51]=R,t[52]=D,t[53]=z):z=t[53];let B;return t[54]!==_||t[55]!==z||t[56]!==O||t[57]!==k?(B=(0,x.jsx)(_,{open:O,onOpenChange:k,children:z}),t[54]=_,t[55]=z,t[56]=O,t[57]=k,t[58]=B):B=t[58],B}function C(e){return e.preventDefault()}function w(e){return e.language}async function T(e){let{grant:t}=await o(i(`/api/extensions/${encodeURIComponent(e)}/ui-grant`));return t}async function E(e,t){return(await o(i(`/api/extensions/${encodeURIComponent(e)}/ui-grant`),{method:`POST`,body:JSON.stringify({manifestDigest:t})})).grant}var D=48,O=2e3,k=`allow-scripts allow-forms allow-popups`;function A(e){let t=(0,ie.c)(98),{extensionId:n,extensionName:r,entrypoint:i,permissions:o,title:s,className:c,fixedHeight:l,maxHeight:ne,minHeight:re,initialData:u}=e,g=ne===void 0?O:ne,v=re===void 0?D:re,y=ee(P),b;t[0]===y?b=t[1]:(b=te(y),t[0]=y,t[1]=b);let C=b.extensionUi,w=f(),A=a(N),F=a(M),I=(0,h.useRef)(0),L=(0,h.useRef)(!1),R=(0,h.useRef)(null),z=p(j),B;t[2]!==n||t[3]!==r?(B=r?.trim()||n,t[2]=n,t[3]=r,t[4]=B):B=t[4];let ae=B,oe;t[5]!==n||t[6]!==s?(oe=s?.trim()||`Extension ${n}`,t[5]=n,t[6]=s,t[7]=oe):oe=t[7];let se=oe,V;t[8]===o?V=t[9]:(V=JSON.stringify(Array.from(o??[]).toSorted()),t[8]=o,t[9]=V);let ce=V,H;t[10]===ce?H=t[11]:(H=JSON.parse(ce),t[10]=ce,t[11]=H);let le=H,ue=l??Math.min(g,Math.max(v,320)),U;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(U=[],t[12]=U):U=t[12];let W;t[13]===ue?W=t[14]:(W={allowed:!1,dialogOpen:!1,reloadKey:0,loadError:!1,dynamicHeight:ue,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:U},t[13]=ue,t[14]=W);let[G,K]=(0,h.useReducer)(m,W),{allowed:q,dialogOpen:J,reloadKey:Y,loadError:de,dynamicHeight:fe,grantResolved:pe,grantError:X}=G,me;t[15]===n?me=t[16]:(me=()=>{let e=!0;return L.current=!1,K({type:`patch`,patch:{allowed:!1,dialogOpen:!1,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:[]}}),T(n).then(t=>{if(e){if(t.extensionId!==n||!t.manifestDigest)throw Error(`Could not verify plugin permissions`);K({type:`patch`,patch:{allowed:t.granted,dialogOpen:!t.granted,grantResolved:!0,manifestDigest:t.manifestDigest,grantedPermissions:t.permissions}})}}).catch(t=>{e&&K({type:`patch`,patch:{allowed:!1,dialogOpen:!0,grantResolved:!0,grantError:t instanceof Error?t.message:String(t)}})}),()=>{e=!1,I.current+=1}},t[15]=n,t[16]=me);let he;t[17]!==n||t[18]!==A||t[19]!==F||t[20]!==le||t[21]!==Y?(he=[n,le,A,F,Y],t[17]=n,t[18]=A,t[19]=F,t[20]=le,t[21]=Y,t[22]=he):he=t[22],(0,h.useEffect)(me,he);let ge;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ge=e=>K({type:`patch`,patch:{dialogOpen:e}}),t[23]=ge):ge=t[23];let _e=ge,ve;t[24]!==i||t[25]!==n?(ve=_(n,i),t[24]=i,t[25]=n,t[26]=ve):ve=t[26];let ye=ve,be;t[27]!==q||t[28]!==n||t[29]!==l||t[30]!==g||t[31]!==v||t[32]!==w||t[33]!==G.grantedPermissions||t[34]!==G.manifestDigest?(be=()=>{if(!q)return;let e=R.current;if(!e)return;w.registerIframe(n,e,G.grantedPermissions,G.manifestDigest??void 0);let t=w.subscribeExtensionEvents(n,e=>{if(e.event!==`ui.resize`||!e.data||typeof e.data!=`object`||e.data===null)return;let t=Number(e.data.height);Number.isFinite(t)&&l===void 0&&K({type:`patch`,patch:{dynamicHeight:Math.min(g,Math.max(v,t))}})});return()=>{t(),w.unregisterIframe(n)}},t[27]=q,t[28]=n,t[29]=l,t[30]=g,t[31]=v,t[32]=w,t[33]=G.grantedPermissions,t[34]=G.manifestDigest,t[35]=be):be=t[35];let xe;t[36]!==q||t[37]!==n||t[38]!==l||t[39]!==g||t[40]!==v||t[41]!==Y||t[42]!==w||t[43]!==G.grantedPermissions||t[44]!==G.manifestDigest?(xe=[q,n,l,g,v,G.grantedPermissions,G.manifestDigest,w,Y],t[36]=q,t[37]=n,t[38]=l,t[39]=g,t[40]=v,t[41]=Y,t[42]=w,t[43]=G.grantedPermissions,t[44]=G.manifestDigest,t[45]=xe):xe=t[45],(0,h.useLayoutEffect)(be,xe);let Se,Ce;t[46]!==q||t[47]!==n||t[48]!==z||t[49]!==w?(Se=()=>{if(!q)return;let e=d(z);w.sendEvent(n,`theme.changed`,e)},Ce=[q,n,z,w],t[46]=q,t[47]=n,t[48]=z,t[49]=w,t[50]=Se,t[51]=Ce):(Se=t[50],Ce=t[51]),(0,h.useEffect)(Se,Ce);let we;t[52]!==fe||t[53]!==l?(we=l===void 0?{width:`100%`,height:fe,border:`none`}:{width:`100%`,height:l,border:`none`},t[52]=fe,t[53]=l,t[54]=we):we=t[54];let Te=we,Ee;t[55]!==n||t[56]!==A||t[57]!==F||t[58]!==G.manifestDigest?(Ee=()=>{if(L.current||!G.manifestDigest)return;L.current=!0;let e=I.current,t=()=>I.current===e&&a.getState().baseUrl===A&&a.getState().conversationId===F;E(n,G.manifestDigest).then(e=>{if(t()){if(!e.granted||e.extensionId!==n||e.manifestDigest!==G.manifestDigest)throw Error(`Permission grant was not persisted`);K({type:`patch`,patch:{allowed:!0,grantError:null}})}}).catch(e=>{t()&&K({type:`patch`,patch:{allowed:!1,manifestDigest:null,grantError:e instanceof Error?e.message:String(e)}})}).finally(()=>{t()&&(L.current=!1)})},t[55]=n,t[56]=A,t[57]=F,t[58]=G.manifestDigest,t[59]=Ee):Ee=t[59];let De=Ee;if(!pe){let e=`${c??``} min-h-32 animate-pulse rounded-lg bg-surface-inset`,n;return t[60]===e?n=t[61]:(n=(0,x.jsx)(`div`,{className:e}),t[60]=e,t[61]=n),n}if(!q){let e=!G.manifestDigest,r;t[62]!==J||t[63]!==ae||t[64]!==n||t[65]!==De||t[66]!==e||t[67]!==G.grantedPermissions?(r=(0,x.jsx)(S,{open:J,onOpenChange:_e,extensionId:n,extensionName:ae,permissions:G.grantedPermissions,confirmDisabled:e,onConfirm:De}),t[62]=J,t[63]=ae,t[64]=n,t[65]=De,t[66]=e,t[67]=G.grantedPermissions,t[68]=r):r=t[68];let i;t[69]!==c||t[70]!==J||t[71]!==X||t[72]!==Y||t[73]!==C?(i=J?null:(0,x.jsxs)(`div`,{className:c?`${c} rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`:`rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`,children:[X?(0,x.jsx)(`p`,{className:`mb-2 text-danger`,children:X}):null,(0,x.jsx)(`p`,{children:C.deniedHint}),(0,x.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>K({type:`patch`,patch:{reloadKey:Y+1}}),children:C.reviewPermissions})]}),t[69]=c,t[70]=J,t[71]=X,t[72]=Y,t[73]=C,t[74]=i):i=t[74];let a;return t[75]!==r||t[76]!==i?(a=(0,x.jsxs)(x.Fragment,{children:[r,i]}),t[75]=r,t[76]=i,t[77]=a):a=t[77],a}let Z;t[78]!==de||t[79]!==Y||t[80]!==C?(Z=de?(0,x.jsxs)(`div`,{className:`mb-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-fg`,children:[(0,x.jsx)(`p`,{children:C.loadFailed}),(0,x.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:C.loadFailedConnectionHint}),(0,x.jsx)(`button`,{type:`button`,className:`mt-2 font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>{K({type:`patch`,patch:{loadError:!1,reloadKey:Y+1}})},children:C.retryLoad})]}):null,t[78]=de,t[79]=Y,t[80]=C,t[81]=Z):Z=t[81];let Oe=`${n}-${i}-${Y}`,ke;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>K({type:`patch`,patch:{loadError:!0}}),t[82]=ke):ke=t[82];let Q;t[83]!==n||t[84]!==u||t[85]!==y||t[86]!==w?(Q=()=>{K({type:`patch`,patch:{loadError:!1}}),w.sendInit(n,d(p.getState().resolved),y),u!==void 0&&w.sendEvent(n,`widget.data`,u)},t[83]=n,t[84]=u,t[85]=y,t[86]=w,t[87]=Q):Q=t[87];let $;t[88]!==c||t[89]!==se||t[90]!==ye||t[91]!==Te||t[92]!==Oe||t[93]!==Q?($=(0,x.jsx)(`iframe`,{ref:R,className:c,title:se,src:ye,style:Te,sandbox:k,referrerPolicy:`no-referrer`,onError:ke,onLoad:Q},Oe),t[88]=c,t[89]=se,t[90]=ye,t[91]=Te,t[92]=Oe,t[93]=Q,t[94]=$):$=t[94];let Ae;return t[95]!==Z||t[96]!==$?(Ae=(0,x.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col`,children:[Z,$]}),t[95]=Z,t[96]=$,t[97]=Ae):Ae=t[97],Ae}function j(e){return e.resolved}function M(e){return e.conversationId}function N(e){return e.baseUrl}function P(e){return e.language}export{A as t};
@@ -1 +1 @@
1
- import{a as e,i as t}from"./locale-store-TQcz_Vjt.js";async function n(n=``){let i=await e(t(`/api/marketplace${n.trim()?`?q=${encodeURIComponent(n.trim())}`:``}`),{cache:`no-store`});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!Array.isArray(a.extensions))throw Error(a.error??`Invalid response`);return a.extensions}async function r(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function i(n){let i=await e(t(`/api/marketplace/packages/${encodeURIComponent(n.trim())}`),{cache:`no-store`});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload?.id)throw Error(a.error??`Invalid response`);return a.payload}async function a(n){let i=await e(t(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload?.extensionId)throw Error(a.error??`Invalid response`);return a.payload}async function o(n){let i=await e(t(`/api/extensions/${encodeURIComponent(n.extensionId.trim())}/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n.enabled})});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload)throw Error(a.error?.message??`Invalid response`);return a.payload}async function s(n){let i=await e(t(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:n})});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload)throw Error(a.error??`Invalid response`);return a.payload}export{s as a,o as i,i as n,a as r,n as t};
1
+ import{a as e,i as t}from"./locale-store-Br7IfbXK.js";async function n(n=``){let i=await e(t(`/api/marketplace${n.trim()?`?q=${encodeURIComponent(n.trim())}`:``}`),{cache:`no-store`});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!Array.isArray(a.extensions))throw Error(a.error??`Invalid response`);return a.extensions}async function r(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function i(n){let i=await e(t(`/api/marketplace/packages/${encodeURIComponent(n.trim())}`),{cache:`no-store`});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload?.id)throw Error(a.error??`Invalid response`);return a.payload}async function a(n){let i=await e(t(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload?.extensionId)throw Error(a.error??`Invalid response`);return a.payload}async function o(n){let i=await e(t(`/api/extensions/${encodeURIComponent(n.extensionId.trim())}/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n.enabled})});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload)throw Error(a.error?.message??`Invalid response`);return a.payload}async function s(n){let i=await e(t(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:n})});if(!i.ok)throw Error(await r(i));let a=await i.json();if(!a.ok||!a.payload)throw Error(a.error??`Invalid response`);return a.payload}export{s as a,o as i,i as n,a as r,n as t};
@@ -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{f as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as a}from"./resource-unavailable-X-SIrZYI.js";import{r as o,s}from"./extension-provider-BZwcaU5Y.js";import{t as c}from"./page-header-store-D6SzJ9Ch.js";import{t as l}from"./extension-iframe-host-B4Q1CjvW.js";var u=n(),d=e(t(),1),f=r();function p(){let e=(0,u.c)(24),{extensionId:t,pageId:n}=i(),r=o(),p=c(h),g=c(m),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&s(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==p?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return p({startExtra:null,main:(0,f.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,f.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,p],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=p,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,d.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[13]=t):t=e[13],t}if(!_){let n=r.some(e=>e.id===t)?`plugin-page`:`plugin`,i;return e[14]===n?i=e[15]:(i=(0,f.jsx)(a,{kind:n,backTo:`/capabilities/extensions`}),e[14]=n,e[15]=i),i}if(!v?.length){let t;return e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin-page`,backTo:`/capabilities/extensions`}),e[16]=t):t=e[16],t}if(!b){let t;return e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[17]=t):t=e[17],t}let C=_.ui?.permissions,w;return e[18]!==_.name||e[19]!==t||e[20]!==b.entrypoint||e[21]!==b.title||e[22]!==C?(w=(0,f.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,f.jsx)(l,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[18]=_.name,e[19]=t,e[20]=b.entrypoint,e[21]=b.title,e[22]=C,e[23]=w):w=e[23],w}function m(e){return e.clearPageHeader}function h(e){return e.setPageHeader}export{p as ExtensionPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{t as a}from"./resource-unavailable-TQcRCpAg.js";import{r as o,s}from"./extension-provider-C_uKqJxP.js";import{t as c}from"./page-header-store-Du44NIEJ.js";import{t as l}from"./extension-iframe-host-Cqg1K70e.js";var u=n(),d=e(t(),1),f=r();function p(){let e=(0,u.c)(24),{extensionId:t,pageId:n}=i(),r=o(),p=c(h),g=c(m),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&s(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==p?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return p({startExtra:null,main:(0,f.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,f.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,p],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=p,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,d.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[13]=t):t=e[13],t}if(!_){let n=r.some(e=>e.id===t)?`plugin-page`:`plugin`,i;return e[14]===n?i=e[15]:(i=(0,f.jsx)(a,{kind:n,backTo:`/capabilities/extensions`}),e[14]=n,e[15]=i),i}if(!v?.length){let t;return e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin-page`,backTo:`/capabilities/extensions`}),e[16]=t):t=e[16],t}if(!b){let t;return e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(a,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[17]=t):t=e[17],t}let C=_.ui?.permissions,w;return e[18]!==_.name||e[19]!==t||e[20]!==b.entrypoint||e[21]!==b.title||e[22]!==C?(w=(0,f.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,f.jsx)(l,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[18]=_.name,e[19]=t,e[20]=b.entrypoint,e[21]=b.title,e[22]=C,e[23]=w):w=e[23],w}function m(e){return e.clearPageHeader}function h(e){return e.setPageHeader}export{p as ExtensionPage};
@@ -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{a as i,i as a,l as o,o as s}from"./locale-store-TQcz_Vjt.js";import{i as c}from"./vendor-swr-CdRzEUwF.js";import{d as l,i as u,t as d}from"./session-manager-D2rbRfX3.js";import{i as f,m as p,n as m,p as h,u as g}from"./schemas-CCWMleym.js";import{a as _}from"./gateway-realtime-CJtDXQCt.js";import{t as v}from"./capabilities-BMaJizw4.js";import{t as y}from"./activity-store-AI081rxe.js";import{i as b}from"./theme-store-DB1ZfBUm.js";var x=h({id:m([`xopc.notes.get`,`xopc.notes.list`,`xopc.tasks.get`,`xopc.tasks.list`,`xopc.notes.create`,`xopc.notes.update`,`xopc.notes.append`]),majorVersion:g().int().positive(),descriptorDigest:p().regex(/^[a-f0-9]{64}$/)});f(x).max(7).refine(e=>new Set(e.map(e=>e.id)).size===e.length,`Duplicate capability binding`);var S=e(t(),1),C=n(),w=`agent-stream-event`;function T(e){return e===`off`||e===`on`||e===`stream`}function E(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.conversationId==`string`?t.conversationId.trim():``,r=typeof t.runId==`string`?t.runId.trim():``;return n&&r?{conversationId:n,runId:r}:null}function D(e,t,n){return t&&typeof t==`object`&&!Array.isArray(t)?{...t,seq:n}:{type:e,seq:n,payload:t}}async function O(e){try{let t=await i(a(`/api/sessions/${encodeURIComponent(e)}/agent-config`));if(!t.ok)return`on`;let n=await t.json(),r=n.payload?.activityDetail?.effective;if(T(r))return r;let o=n.payload?.activityDetail?.default;return T(o)?o:`on`}catch{return`on`}}function k(e){window.dispatchEvent(new CustomEvent(w,{detail:e}))}function A(e={}){let t=e.subscribe??_,n=e.loadActivityDetailLevel??O,r=e.dispatch??k,i=new Map,a=!1,o=e=>{let o=E(e.detail);if(!o||i.has(o.runId))return;let s=`on`,c=!1,l,u=!1,d=!1,f=()=>{},p=()=>{u||(u=!0,f(),i.get(o.runId)===p&&i.delete(o.runId))},m=e=>{a||u||r({conversationId:o.conversationId,event:e,activityDetailLevel:s})};n(o.conversationId).then(e=>{s=e,c=!0,e===`stream`&&l&&!d&&m(l),l=void 0}),f=t(`run:${o.runId}`,{onEvent:e=>{if(u||d)return;let t=D(e.event,e.data,e.seq);e.event===`thinking_delta`&&!c?l=t:m(t),e.event===`run_end`&&(d=!0,l=void 0,queueMicrotask(p))},onGap:e=>{e.recoverable||p()}},0),i.set(o.runId,p)},s=e=>{let t=E(e.detail);t&&i.get(t.runId)?.()};return window.addEventListener(`run-started`,o),window.addEventListener(`run-completed`,s),window.addEventListener(`agent-run-ended`,s),()=>{a=!0,window.removeEventListener(`run-started`,o),window.removeEventListener(`run-completed`,s),window.removeEventListener(`agent-run-ended`,s);for(let e of[...i.values()])e()}}var j=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({});async function M(e,t,n){let r=new d,i=await r.loadSessionAgentConfig(e);await r.loadSession(e),l(e,i),await new u().send(t,e,n,i.thinkingLevel)}var N=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function P(e){let t=getComputedStyle(document.documentElement),n={};for(let e of N){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var F={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"theme.get":`theme`},I=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;releaseBindings=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.releaseBindings.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n,r){let i=this.iframes.get(e);if(i&&i!==t&&i.contentWindow&&this.byContentWindow.delete(i.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.releaseBindings.delete(e),r){let t=o.getState();this.releaseBindings.set(e,{digest:r,baseUrl:t.baseUrl,namespace:t.conversationId})}this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);this.sendEvent(e,`panel.dispose`),t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.releaseBindings.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{conversationId:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}getReleaseDigest(e){let t=this.releaseBindings.get(e),n=o.getState();if(!t||t.baseUrl!==n.baseUrl||t.namespace!==n.conversationId)throw Error(`Extension release authorization is unavailable`);return t.digest}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow,o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};!a||a!==t?.source||a.postMessage(o,`*`)}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`||!e.source)return;let n=this.byContentWindow.get(e.source);if(!n)return;let{iframe:r,extensionId:i}=n;if(this.iframes.get(i)!==r||r.contentWindow!==e.source)return;if(t.type===`event`){this.handleExtensionEvent(i,t.event,t.data);let e=this.eventSubscribers.get(i);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:a,method:s,params:c}=t;if(typeof a!=`string`||a.length>200||typeof s!=`string`||s.length>200)return;let l=this.handlers.get(s);if(!l){this.postResponse(r,e,a,void 0,{code:j.MethodNotFound,message:`Unknown method: ${s}`});return}let u=c&&typeof c==`object`&&`id`in c?c.id:void 0,d=s===`capability.describe`||s===`capability.call`?`capability:${typeof u==`string`?u:``}`:F[s],f=this.extensionPermissions.get(i)??new Set;if(d&&!f.has(d)){this.postResponse(r,e,a,void 0,{code:j.PermissionDenied,message:`Missing permission: ${d}`});return}let p=o.getState(),m=()=>this.iframes.get(i)===r&&r.contentWindow===e.source&&this.extensionPermissions.get(i)===f&&o.getState().baseUrl===p.baseUrl&&o.getState().conversationId===p.conversationId;try{let t=await l(i,c);if(!m())return;this.postResponse(r,e,a,t)}catch(t){if(!m())return;let n=t instanceof Error?t.message:String(t);this.postResponse(r,e,a,void 0,{code:j.InternalError,message:n})}}};function L(e){let t=h({id:x.shape.id}),n=t.extend({call:v});e.registerMethod(`capability.describe`,async(n,r)=>{let{id:i}=t.parse(r),o=e.getReleaseDigest(n),c=(await s(a(`/api/local-app-capabilities/${encodeURIComponent(n)}?manifestDigest=${encodeURIComponent(o)}`))).capabilities.find(e=>e.id===i);if(!c)throw Error(`Capability is unavailable for this release`);return c}),e.registerMethod(`capability.call`,async(t,r)=>{let{id:i,call:o}=n.parse(r),c=e.getReleaseDigest(t);return s(a(`/api/local-app-capabilities/${encodeURIComponent(t)}/${encodeURIComponent(i)}/invocations`),{method:`POST`,body:JSON.stringify({manifestDigest:c,call:o})})}),e.registerMethod(`theme.get`,async()=>P(b.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;if(n){let e=n.startsWith(`/`)?n:`/${n}`;window.location.hash=`#${e}`}}),e.registerMethod(`ui.notification`,async(e,t)=>{if(!t||typeof t!=`object`)return;let n=t,r=typeof n.title==`string`?n.title.trim():``;r&&y({tone:n.type===`success`||n.type===`warning`||n.type===`error`||n.type===`info`?n.type:`info`,title:r,message:typeof n.message==`string`?n.message:void 0,source:e,dedupeKey:`extension:${e}:${r}`})}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`conversationId`in t?String(t.conversationId??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await i(a(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({conversationId:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,conversationId:r,newSession:i}=t,a=r?.trim()||``;return(i||!a)&&(a=(await new d().createSession()).key),await M(a,n),{conversationId:a}}),e.registerMethod(`config.get`,async e=>{let t=await i(a(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await i(a(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,o=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!o.ok)throw Error(`Failed to set storage key: ${o.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}function R(e){return e.active||e.activationEligible===!0}function z(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0:!1}function B(e){return e.source===`bundled`&&e.hasUi===!0&&z(e)}function V(e){return e.kind===`image-generation`||e.kind===`media-provider`}function H(e){return R(e)?e.hasConfigSchema||V(e)?!0:e.hasUi?z(e):!1:!1}function U(e){return H(e)||B(e)}var W=r(),G=(0,S.createContext)(null);function K({children:e}){let t=(0,S.useRef)(null);if(!t.current){let e=new I;L(e),t.current=e}let n=t.current,{data:r,isLoading:i,mutate:l}=c(o(e=>!!e.conversationId)?`gateway-extensions-list`:null,()=>s(a(`/api/extensions`)),{revalidateOnFocus:!1}),u=r?.extensions??[],d=b(e=>e.resolved);(0,S.useEffect)(()=>{let e=()=>{l()};return window.addEventListener(`config-reload`,e),window.addEventListener(`registry-updated`,e),()=>{window.removeEventListener(`config-reload`,e),window.removeEventListener(`registry-updated`,e)}},[l]);let f=(0,S.useCallback)(e=>{let t=e.detail;t?.conversationId&&n.forwardAgentStreamEvent(t.conversationId,t.event??t)},[n]),p=(0,S.useRef)(f);p.current=f,(0,S.useEffect)(()=>{let e=e=>{p.current(e)};return window.addEventListener(w,e),()=>{window.removeEventListener(w,e)}},[]),(0,S.useEffect)(()=>{let e=P(d);n.broadcastEvent(`theme.changed`,e)},[d,n]);let m=(0,S.useRef)(n);m.current=n,(0,S.useEffect)(()=>()=>{m.current.dispose(),t.current=null},[]);let h=(0,S.useMemo)(()=>({router:n,extensions:u,loading:i}),[n,u,i]);return(0,W.jsx)(G.Provider,{value:h,children:e})}function q(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function J(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function Y(){let e=(0,C.c)(2),t=J(),n;return e[0]===t?n=e[1]:(n=t.filter(H),e[0]=t,e[1]=n),n}function X(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}export{Y as a,P as c,A as d,X as i,M as l,q as n,V as o,J as r,U as s,K as t,w as u};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{a as i,i as a,l as o,o as s}from"./locale-store-Br7IfbXK.js";import{i as c}from"./vendor-swr-CdRzEUwF.js";import{d as l,i as u,t as d}from"./session-manager-ChUtTAoG.js";import{i as f,m as p,n as m,p as h,u as g}from"./schemas-CCWMleym.js";import{a as _}from"./gateway-realtime-BL_Cf0OQ.js";import{t as v}from"./capabilities-BGE6hiUE.js";import{t as y}from"./activity-store-D_DXNHba.js";import{i as b}from"./theme-store-Dlnmgryi.js";var x=h({id:m([`xopc.notes.get`,`xopc.notes.list`,`xopc.tasks.get`,`xopc.tasks.list`,`xopc.notes.create`,`xopc.notes.update`,`xopc.notes.append`]),majorVersion:g().int().positive(),descriptorDigest:p().regex(/^[a-f0-9]{64}$/)});f(x).max(7).refine(e=>new Set(e.map(e=>e.id)).size===e.length,`Duplicate capability binding`);var S=e(t(),1),C=n(),w=`agent-stream-event`;function T(e){return e===`off`||e===`on`||e===`stream`}function E(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.conversationId==`string`?t.conversationId.trim():``,r=typeof t.runId==`string`?t.runId.trim():``;return n&&r?{conversationId:n,runId:r}:null}function D(e,t,n){return t&&typeof t==`object`&&!Array.isArray(t)?{...t,seq:n}:{type:e,seq:n,payload:t}}async function O(e){try{let t=await i(a(`/api/sessions/${encodeURIComponent(e)}/agent-config`));if(!t.ok)return`on`;let n=await t.json(),r=n.payload?.activityDetail?.effective;if(T(r))return r;let o=n.payload?.activityDetail?.default;return T(o)?o:`on`}catch{return`on`}}function k(e){window.dispatchEvent(new CustomEvent(w,{detail:e}))}function A(e={}){let t=e.subscribe??_,n=e.loadActivityDetailLevel??O,r=e.dispatch??k,i=new Map,a=!1,o=e=>{let o=E(e.detail);if(!o||i.has(o.runId))return;let s=`on`,c=!1,l,u=!1,d=!1,f=()=>{},p=()=>{u||(u=!0,f(),i.get(o.runId)===p&&i.delete(o.runId))},m=e=>{a||u||r({conversationId:o.conversationId,event:e,activityDetailLevel:s})};n(o.conversationId).then(e=>{s=e,c=!0,e===`stream`&&l&&!d&&m(l),l=void 0}),f=t(`run:${o.runId}`,{onEvent:e=>{if(u||d)return;let t=D(e.event,e.data,e.seq);e.event===`thinking_delta`&&!c?l=t:m(t),e.event===`run_end`&&(d=!0,l=void 0,queueMicrotask(p))},onGap:e=>{e.recoverable||p()}},0),i.set(o.runId,p)},s=e=>{let t=E(e.detail);t&&i.get(t.runId)?.()};return window.addEventListener(`run-started`,o),window.addEventListener(`run-completed`,s),window.addEventListener(`agent-run-ended`,s),()=>{a=!0,window.removeEventListener(`run-started`,o),window.removeEventListener(`run-completed`,s),window.removeEventListener(`agent-run-ended`,s);for(let e of[...i.values()])e()}}var j=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({});async function M(e,t,n){let r=new d,i=await r.loadSessionAgentConfig(e);await r.loadSession(e),l(e,i),await new u().send(t,e,n,i.thinkingLevel)}var N=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function P(e){let t=getComputedStyle(document.documentElement),n={};for(let e of N){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var F={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"theme.get":`theme`},I=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;releaseBindings=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.releaseBindings.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n,r){let i=this.iframes.get(e);if(i&&i!==t&&i.contentWindow&&this.byContentWindow.delete(i.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.releaseBindings.delete(e),r){let t=o.getState();this.releaseBindings.set(e,{digest:r,baseUrl:t.baseUrl,namespace:t.conversationId})}this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);this.sendEvent(e,`panel.dispose`),t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.releaseBindings.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{conversationId:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}getReleaseDigest(e){let t=this.releaseBindings.get(e),n=o.getState();if(!t||t.baseUrl!==n.baseUrl||t.namespace!==n.conversationId)throw Error(`Extension release authorization is unavailable`);return t.digest}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow,o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};!a||a!==t?.source||a.postMessage(o,`*`)}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`||!e.source)return;let n=this.byContentWindow.get(e.source);if(!n)return;let{iframe:r,extensionId:i}=n;if(this.iframes.get(i)!==r||r.contentWindow!==e.source)return;if(t.type===`event`){this.handleExtensionEvent(i,t.event,t.data);let e=this.eventSubscribers.get(i);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:a,method:s,params:c}=t;if(typeof a!=`string`||a.length>200||typeof s!=`string`||s.length>200)return;let l=this.handlers.get(s);if(!l){this.postResponse(r,e,a,void 0,{code:j.MethodNotFound,message:`Unknown method: ${s}`});return}let u=c&&typeof c==`object`&&`id`in c?c.id:void 0,d=s===`capability.describe`||s===`capability.call`?`capability:${typeof u==`string`?u:``}`:F[s],f=this.extensionPermissions.get(i)??new Set;if(d&&!f.has(d)){this.postResponse(r,e,a,void 0,{code:j.PermissionDenied,message:`Missing permission: ${d}`});return}let p=o.getState(),m=()=>this.iframes.get(i)===r&&r.contentWindow===e.source&&this.extensionPermissions.get(i)===f&&o.getState().baseUrl===p.baseUrl&&o.getState().conversationId===p.conversationId;try{let t=await l(i,c);if(!m())return;this.postResponse(r,e,a,t)}catch(t){if(!m())return;let n=t instanceof Error?t.message:String(t);this.postResponse(r,e,a,void 0,{code:j.InternalError,message:n})}}};function L(e){let t=h({id:x.shape.id}),n=t.extend({call:v});e.registerMethod(`capability.describe`,async(n,r)=>{let{id:i}=t.parse(r),o=e.getReleaseDigest(n),c=(await s(a(`/api/local-app-capabilities/${encodeURIComponent(n)}?manifestDigest=${encodeURIComponent(o)}`))).capabilities.find(e=>e.id===i);if(!c)throw Error(`Capability is unavailable for this release`);return c}),e.registerMethod(`capability.call`,async(t,r)=>{let{id:i,call:o}=n.parse(r),c=e.getReleaseDigest(t);return s(a(`/api/local-app-capabilities/${encodeURIComponent(t)}/${encodeURIComponent(i)}/invocations`),{method:`POST`,body:JSON.stringify({manifestDigest:c,call:o})})}),e.registerMethod(`theme.get`,async()=>P(b.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;if(n){let e=n.startsWith(`/`)?n:`/${n}`;window.location.hash=`#${e}`}}),e.registerMethod(`ui.notification`,async(e,t)=>{if(!t||typeof t!=`object`)return;let n=t,r=typeof n.title==`string`?n.title.trim():``;r&&y({tone:n.type===`success`||n.type===`warning`||n.type===`error`||n.type===`info`?n.type:`info`,title:r,message:typeof n.message==`string`?n.message:void 0,source:e,dedupeKey:`extension:${e}:${r}`})}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`conversationId`in t?String(t.conversationId??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await i(a(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({conversationId:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,conversationId:r,newSession:i}=t,a=r?.trim()||``;return(i||!a)&&(a=(await new d().createSession()).key),await M(a,n),{conversationId:a}}),e.registerMethod(`config.get`,async e=>{let t=await i(a(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await i(a(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,o=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!o.ok)throw Error(`Failed to set storage key: ${o.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await i(a(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}function R(e){return e.active||e.activationEligible===!0}function z(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0:!1}function B(e){return e.source===`bundled`&&e.hasUi===!0&&z(e)}function V(e){return e.kind===`image-generation`||e.kind===`media-provider`}function H(e){return R(e)?e.hasConfigSchema||V(e)?!0:e.hasUi?z(e):!1:!1}function U(e){return H(e)||B(e)}var W=r(),G=(0,S.createContext)(null);function K({children:e}){let t=(0,S.useRef)(null);if(!t.current){let e=new I;L(e),t.current=e}let n=t.current,{data:r,isLoading:i,mutate:l}=c(o(e=>!!e.conversationId)?`gateway-extensions-list`:null,()=>s(a(`/api/extensions`)),{revalidateOnFocus:!1}),u=r?.extensions??[],d=b(e=>e.resolved);(0,S.useEffect)(()=>{let e=()=>{l()};return window.addEventListener(`config-reload`,e),window.addEventListener(`registry-updated`,e),()=>{window.removeEventListener(`config-reload`,e),window.removeEventListener(`registry-updated`,e)}},[l]);let f=(0,S.useCallback)(e=>{let t=e.detail;t?.conversationId&&n.forwardAgentStreamEvent(t.conversationId,t.event??t)},[n]),p=(0,S.useRef)(f);p.current=f,(0,S.useEffect)(()=>{let e=e=>{p.current(e)};return window.addEventListener(w,e),()=>{window.removeEventListener(w,e)}},[]),(0,S.useEffect)(()=>{let e=P(d);n.broadcastEvent(`theme.changed`,e)},[d,n]);let m=(0,S.useRef)(n);m.current=n,(0,S.useEffect)(()=>()=>{m.current.dispose(),t.current=null},[]);let h=(0,S.useMemo)(()=>({router:n,extensions:u,loading:i}),[n,u,i]);return(0,W.jsx)(G.Provider,{value:h,children:e})}function q(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function J(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function Y(){let e=(0,C.c)(2),t=J(),n;return e[0]===t?n=e[1]:(n=t.filter(H),e[0]=t,e[1]=n),n}function X(){let e=(0,S.useContext)(G);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}export{Y as a,P as c,A as d,X as i,M as l,q as n,V as o,J as r,U as s,K as t,w as u};