@xopcai/xopc 0.0.433 → 0.0.435

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 (362) hide show
  1. package/README.md +5 -5
  2. package/README.zh-CN.md +5 -5
  3. package/dist/browser-ext/dist/sidepanel.js +11 -0
  4. package/dist/browser-ext/manifest.json +1 -1
  5. package/dist/extensions/telegram/xopc.extension.json +1 -1
  6. package/dist/gateway/static/root/assets/{activity-store-BpYGrRXw.js → activity-store-Cwn_CNwl.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DTgOSv6G.js → agent-avatar-dicebear-Cd23LnJJ.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agent-avatar-display-BUH7ljEo.js → agent-avatar-display-ByzM7u9S.js} +2 -2
  9. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-B_FAikHA.js → agent-defaults-settings-panel-B0i37diS.js} +1 -1
  10. package/dist/gateway/static/root/assets/{agent-plugin-dialog-DPabZaSE.js → agent-plugin-dialog-XN-tZ-Ox.js} +1 -1
  11. package/dist/gateway/static/root/assets/{agents-BAPYP1Ka.js → agents-ZDA1OaLv.js} +3 -3
  12. package/dist/gateway/static/root/assets/{agents-admin-api-CXCAHNPj.js → agents-admin-api-B5lKH_ps.js} +1 -1
  13. package/dist/gateway/static/root/assets/{api-oIK4hYkJ.js → api-B9fZL-V8.js} +1 -1
  14. package/dist/gateway/static/root/assets/{api-DMbimMEi.js → api-Djju8qIR.js} +1 -1
  15. package/dist/gateway/static/root/assets/{app-management-settings-panel-BZ3Fy8ZR.js → app-management-settings-panel-IlyzDPJu.js} +1 -1
  16. package/dist/gateway/static/root/assets/{appearance-settings-DsRTj1by.js → appearance-settings-BxdFGob3.js} +1 -1
  17. package/dist/gateway/static/root/assets/apps-page-CxEKiOTA.js +1 -0
  18. package/dist/gateway/static/root/assets/{archive-plugin-Bg1VTieK.js → archive-plugin-4gEvotPr.js} +1 -1
  19. package/dist/gateway/static/root/assets/{automation-api-CLPsgcQN.js → automation-api-4fVKv9PJ.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automation-result-state-CKVnR4KG.js → automation-result-state-m7PeK2kl.js} +1 -1
  21. package/dist/gateway/static/root/assets/automation-run-list-CJOdy_R2.js +1 -0
  22. package/dist/gateway/static/root/assets/{automation-task-card-D27Mw66U.js → automation-task-card-DZWhCWJa.js} +3 -3
  23. package/dist/gateway/static/root/assets/{automations-page-DGNTJ8lN.js → automations-page-BjbM15eY.js} +1 -1
  24. package/dist/gateway/static/root/assets/automations-workspace-CqurzLYX.js +9 -0
  25. package/dist/gateway/static/root/assets/{binary-plugins-CuwSdCG5.js → binary-plugins-69WyJLNW.js} +1 -1
  26. package/dist/gateway/static/root/assets/{block-editor-Dtl2BG3t.js → block-editor-DUONDIZR.js} +1 -1
  27. package/dist/gateway/static/root/assets/{browser-automation-inputs-uGK086ag.js → browser-automation-inputs-DL4YPCuN.js} +1 -1
  28. package/dist/gateway/static/root/assets/{browser-automations-page-Da_edNNS.js → browser-automations-page-1Aq6XmRs.js} +1 -1
  29. package/dist/gateway/static/root/assets/{browser-control-api-k3OOX3bS.js → browser-control-api-yjru8E7R.js} +1 -1
  30. package/dist/gateway/static/root/assets/{browser-settings-page-C1bSw-Jq.js → browser-settings-page-CvwpT8Um.js} +1 -1
  31. package/dist/gateway/static/root/assets/{capabilities-DlHPLld_.js → capabilities-C7lnwKKm.js} +1 -1
  32. package/dist/gateway/static/root/assets/{capabilities-CoeuLRt6.js → capabilities-DaeQXJT4.js} +1 -1
  33. package/dist/gateway/static/root/assets/capabilities-page-B5avAOUM.js +2 -0
  34. package/dist/gateway/static/root/assets/{capabilities-settings-panel-CtY-bGIi.js → capabilities-settings-panel-_9yCS78i.js} +1 -1
  35. package/dist/gateway/static/root/assets/capability-links-DeO34GIF.js +1 -0
  36. package/dist/gateway/static/root/assets/{channels-Cn1MWBL_.js → channels-CoQb4HOF.js} +1 -1
  37. package/dist/gateway/static/root/assets/{chat-agents-api-BB0biwc7.js → chat-agents-api-BUi_7GRo.js} +1 -1
  38. package/dist/gateway/static/root/assets/{chat-chart-block-QSvjx4w6.js → chat-chart-block-CcVcKsDZ.js} +1 -1
  39. package/dist/gateway/static/root/assets/chat-page--wcFhTjW.js +72 -0
  40. package/dist/gateway/static/root/assets/{chat-terminal-dock-Cd51G9eG.js → chat-terminal-dock-BMXJpPuH.js} +1 -1
  41. package/dist/gateway/static/root/assets/{command-palette-api-CEG10uE-.js → command-palette-api-luUjQPsh.js} +1 -1
  42. package/dist/gateway/static/root/assets/{composer-payload-handoff-Bogdq9Hy.js → composer-payload-handoff-B5XNxNCb.js} +1 -1
  43. package/dist/gateway/static/root/assets/computer-settings-page-CWtdyEJH.js +1 -0
  44. package/dist/gateway/static/root/assets/connected-providers-grid-2idMtk65.js +1 -0
  45. package/dist/gateway/static/root/assets/connection-usage-Cm_McddI.js +1 -0
  46. package/dist/gateway/static/root/assets/connection-usage-guide-Ddh0bfkj.js +1 -0
  47. package/dist/gateway/static/root/assets/{connector-service-page-k2rjyjrp.js → connector-service-page-C3msXaBk.js} +1 -1
  48. package/dist/gateway/static/root/assets/{connectors-api-DtvB9Cjm.js → connectors-api-NcWECWKg.js} +1 -1
  49. package/dist/gateway/static/root/assets/connectors-page-Crb6DILX.js +1 -0
  50. package/dist/gateway/static/root/assets/{date-picker-CAankdQw.js → date-picker-Cfjq1hD_.js} +1 -1
  51. package/dist/gateway/static/root/assets/{desktop-pet-DjM73fir.js → desktop-pet-ChFn9v-3.js} +1 -1
  52. package/dist/gateway/static/root/assets/{desktop-pet-settings-Rmh-GxHl.js → desktop-pet-settings-DvnVIv25.js} +1 -1
  53. package/dist/gateway/static/root/assets/{dev-view-store-BgW2Riyk.js → dev-view-store-DQJ61P5L.js} +1 -1
  54. package/dist/gateway/static/root/assets/{device-pairing-wizard-UdzSpNa5.js → device-pairing-wizard-KxaIL-OX.js} +1 -1
  55. package/dist/gateway/static/root/assets/{directory-picker-path-field-Rkw3f7lG.js → directory-picker-path-field-Drv864uE.js} +1 -1
  56. package/dist/gateway/static/root/assets/{discussion-annotation-sync-Dudoj_Fz.js → discussion-annotation-sync-DfBRkWtw.js} +1 -1
  57. package/dist/gateway/static/root/assets/{extension-debug-page-DxIGAO23.js → extension-debug-page-DAlBIt_R.js} +1 -1
  58. package/dist/gateway/static/root/assets/{extension-iframe-host-63KpX6IP.js → extension-iframe-host-Bds-5kY_.js} +1 -1
  59. package/dist/gateway/static/root/assets/{extension-marketplace-api-yXNUkQDA.js → extension-marketplace-api-CZg8nBwW.js} +1 -1
  60. package/dist/gateway/static/root/assets/{extension-page-C811A_Ww.js → extension-page-ZTw-oucT.js} +1 -1
  61. package/dist/gateway/static/root/assets/{extension-provider-C4jLFIgh.js → extension-provider-NKWfjpdP.js} +1 -1
  62. package/dist/gateway/static/root/assets/{extension-settings-page-WJSw5MT0.js → extension-settings-page-CT7PPt_q.js} +1 -1
  63. package/dist/gateway/static/root/assets/{file-preview-surface-zE9AcaHM.js → file-preview-surface-BcLeaSNe.js} +1 -1
  64. package/dist/gateway/static/root/assets/{gateway-config-swr-D6cc6W6E.js → gateway-config-swr-Cq-ByXL4.js} +1 -1
  65. package/dist/gateway/static/root/assets/{gateway-realtime-BSRNLciy.js → gateway-realtime-DwMd2PCt.js} +1 -1
  66. package/dist/gateway/static/root/assets/gateway-realtime-store-CHrf6-nR.js +1 -0
  67. package/dist/gateway/static/root/assets/{gateway-restart-Unun5hRL.js → gateway-restart-DdiVzbkL.js} +1 -1
  68. package/dist/gateway/static/root/assets/{gateway-settings-DP-DV-e5.js → gateway-settings-1QUdNwrZ.js} +1 -1
  69. package/dist/gateway/static/root/assets/{gateway-startup-retry-C8g666Ja.js → gateway-startup-retry-PMJi5mX4.js} +1 -1
  70. package/dist/gateway/static/root/assets/{global-defaults-api-BObi-1ww.js → global-defaults-api-DgzZh3wX.js} +1 -1
  71. package/dist/gateway/static/root/assets/{home-page-CIcs7Mzy.js → home-page-Chn7YTiD.js} +2 -2
  72. package/dist/gateway/static/root/assets/{image-generation-api-C2SqYNyD.js → image-generation-api-CjVpsckq.js} +1 -1
  73. package/dist/gateway/static/root/assets/{imports-page-C8ezUkOJ.js → imports-page-CJCvZFaQ.js} +1 -1
  74. package/dist/gateway/static/root/assets/index-8xLWo0Tt.js +11 -0
  75. package/dist/gateway/static/root/assets/index-iukJWzxG.css +1 -0
  76. package/dist/gateway/static/root/assets/install-connector-dialog-Bo06Ry3H.js +1 -0
  77. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BRaY4-wA.js → keyboard-shortcuts-settings-BylFJeGu.js} +1 -1
  78. package/dist/gateway/static/root/assets/{local-app-workbench-page-BZtVcjF3.js → local-app-workbench-page-B3MSSFsr.js} +1 -1
  79. package/dist/gateway/static/root/assets/{local-apps-page-MqP4EnJm.js → local-apps-page-BeV86rMJ.js} +1 -1
  80. package/dist/gateway/static/root/assets/{local-session-drafts-DTq9776a.js → local-session-drafts-jgw8UGsO.js} +2 -2
  81. package/dist/gateway/static/root/assets/{locale-store-B6OrWgY1.js → locale-store-CAZaC05J.js} +1 -1
  82. package/dist/gateway/static/root/assets/{logs-page-hkHBjblX.js → logs-page-BMmSsUP5.js} +1 -1
  83. package/dist/gateway/static/root/assets/{management-settings-DoX4eTM3.js → management-settings-Bu7T8ewk.js} +1 -1
  84. package/dist/gateway/static/root/assets/{markdown-view-DrhYZSmg.js → markdown-view-BatP4qeK.js} +1 -1
  85. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-BEp5E6TD.js → mcp-conversation-setup-page-rROtr0UN.js} +1 -1
  86. package/dist/gateway/static/root/assets/{media-plugins-D987i9Gc.js → media-plugins-88OV72YE.js} +1 -1
  87. package/dist/gateway/static/root/assets/messages-C7fckbyG.js +3 -0
  88. package/dist/gateway/static/root/assets/{model-selector-DXm4NS1_.js → model-selector-raBRBkN_.js} +1 -1
  89. package/dist/gateway/static/root/assets/{models-hub-cache-BLcha5rx.js → models-hub-cache-CzC9y3D0.js} +1 -1
  90. package/dist/gateway/static/root/assets/{note-detail-panel-Cl851ivY.js → note-detail-panel-BvA8Vkbm.js} +3 -3
  91. package/dist/gateway/static/root/assets/note-image-lightbox-D6kUDDd5.js +1 -0
  92. package/dist/gateway/static/root/assets/{notes-api-Ddsf7FVg.js → notes-api-zXpV6UXu.js} +1 -1
  93. package/dist/gateway/static/root/assets/{notes-page-DSwA1MU1.js → notes-page-CjYH9Kle.js} +1 -1
  94. package/dist/gateway/static/root/assets/{oauth-api-CMmu4DzH.js → oauth-api-DmxSaxM1.js} +1 -1
  95. package/dist/gateway/static/root/assets/{oauth-provider-connect-BkhnftBq.js → oauth-provider-connect-D4Gfs-Ba.js} +1 -1
  96. package/dist/gateway/static/root/assets/{page-context-capture-button-urhQBRaN.js → page-context-capture-button-Mig3d0UX.js} +1 -1
  97. package/dist/gateway/static/root/assets/{page-context-draft-BuNUerth.js → page-context-draft-C4IIZaKd.js} +1 -1
  98. package/dist/gateway/static/root/assets/page-header-store-D7G5utVi.js +1 -0
  99. package/dist/gateway/static/root/assets/{personal-avatar-B49ueeZO.js → personal-avatar-DLa-CpaK.js} +1 -1
  100. package/dist/gateway/static/root/assets/{personal-page-f05ceuFn.js → personal-page-BhuT79Wd.js} +1 -1
  101. package/dist/gateway/static/root/assets/{personal-settings-panel-DLQxzPYr.js → personal-settings-panel-XSUkgcr2.js} +1 -1
  102. package/dist/gateway/static/root/assets/phone-dependencies-card-DYwnuVh3.js +1 -0
  103. package/dist/gateway/static/root/assets/phone-model-connection-2F32QTHA.js +1 -0
  104. package/dist/gateway/static/root/assets/phone-model-picker-DCVzIr0s.js +1 -0
  105. package/dist/gateway/static/root/assets/phone-settings-page-DJttE4id.js +1 -0
  106. package/dist/gateway/static/root/assets/{phone-workspace-store-DbqktZbO.js → phone-workspace-store-Dxp-KhFP.js} +1 -1
  107. package/dist/gateway/static/root/assets/plugin-details-dialog-tyjAjFjA.js +1 -0
  108. package/dist/gateway/static/root/assets/{preference-select-fields-BZWqG7pu.js → preference-select-fields-BVP3MhGK.js} +1 -1
  109. package/dist/gateway/static/root/assets/{product-automation-feedback-DDQUsag7.js → product-automation-feedback-DbJvv92z.js} +1 -1
  110. package/dist/gateway/static/root/assets/{product-open-page-BkRP_HmA.js → product-open-page-RImqlhCD.js} +1 -1
  111. package/dist/gateway/static/root/assets/{product-preview-content-o2Y3VNE7.js → product-preview-content-DxSqrKsg.js} +1 -1
  112. package/dist/gateway/static/root/assets/{product-preview-modal-7Ohx-7OR.js → product-preview-modal-Cw8Q8Uom.js} +2 -2
  113. package/dist/gateway/static/root/assets/{project-detail-page-B2RsSHya.js → project-detail-page-CuugOYfe.js} +1 -1
  114. package/dist/gateway/static/root/assets/{project-understanding-BIMouiYX.js → project-understanding-BMKcoUW5.js} +1 -1
  115. package/dist/gateway/static/root/assets/{projects-page-C9R5u3tF.js → projects-page-CFsABLvs.js} +1 -1
  116. package/dist/gateway/static/root/assets/{providers-api-BOCkRZ7X.js → providers-api-CAeXbJNF.js} +1 -1
  117. package/dist/gateway/static/root/assets/{recording-upload-C6muEHEO.js → recording-upload-CfpllTe5.js} +1 -1
  118. package/dist/gateway/static/root/assets/{registry-api-Bl2guMRg.js → registry-api-fLOqFyrz.js} +1 -1
  119. package/dist/gateway/static/root/assets/{remote-access-hub-BceSMbCs.js → remote-access-hub-BvKOxy0L.js} +1 -1
  120. package/dist/gateway/static/root/assets/{resource-unavailable-CUNbPkdj.js → resource-unavailable-D15jzjV_.js} +1 -1
  121. package/dist/gateway/static/root/assets/route-preload-BQapekpy.js +2 -0
  122. package/dist/gateway/static/root/assets/{runtime-tools-api-LopLjgvu.js → runtime-tools-api-D0Nrvuqv.js} +1 -1
  123. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-9HIPerDP.js → runtime-tools-settings-panel-CA27XgL2.js} +1 -1
  124. package/dist/gateway/static/root/assets/{service-recommendation-list-CoMI6MB1.js → service-recommendation-list-B0RoYLVT.js} +1 -1
  125. package/dist/gateway/static/root/assets/session-api-CHRP5Lwf.js +1 -0
  126. package/dist/gateway/static/root/assets/session-channel-icon-D1ktvt1P.js +1 -0
  127. package/dist/gateway/static/root/assets/session-identity-label-BP7OIYth.js +1 -0
  128. package/dist/gateway/static/root/assets/session-manager-DRRWwKE4.js +25 -0
  129. package/dist/gateway/static/root/assets/{sessions-page-BT0GdXdS.js → sessions-page-uJHS3-6F.js} +1 -1
  130. package/dist/gateway/static/root/assets/settings-advanced-gate-CZ4J3Kuy.js +1 -0
  131. package/dist/gateway/static/root/assets/{settings-advanced-section-CEorDLUp.js → settings-advanced-section-D-llwfSj.js} +1 -1
  132. package/dist/gateway/static/root/assets/{settings-mode-store-C2LZqBES.js → settings-mode-store-BspMKc9N.js} +1 -1
  133. package/dist/gateway/static/root/assets/{settings-page-C_Np_6qZ.js → settings-page-CedwaHM0.js} +1 -1
  134. package/dist/gateway/static/root/assets/{settings-page-header-BAN34UQi.js → settings-page-header-LuOJvqNa.js} +1 -1
  135. package/dist/gateway/static/root/assets/{settings-page-layout-B5TVFBV2.js → settings-page-layout-CduQ8w4a.js} +1 -1
  136. package/dist/gateway/static/root/assets/{setup-interaction-page-BYvTJW3_.js → setup-interaction-page-ujpPGl84.js} +1 -1
  137. package/dist/gateway/static/root/assets/{setup-status-panel-UY2dH-sK.js → setup-status-panel-BN2aCJUN.js} +1 -1
  138. package/dist/gateway/static/root/assets/{share-link-dialog-BMcXyzr2.js → share-link-dialog-CTATUaa4.js} +1 -1
  139. package/dist/gateway/static/root/assets/{share-preview-page-UQ6eUM2_.js → share-preview-page-Dq0J3VgS.js} +1 -1
  140. package/dist/gateway/static/root/assets/{shares-api-DOeDN6Tm.js → shares-api-zegE8pSE.js} +1 -1
  141. package/dist/gateway/static/root/assets/{shares-settings-W8XhuAoL.js → shares-settings-DXpvsRXq.js} +1 -1
  142. package/dist/gateway/static/root/assets/{skill-api-Do_c0d9n.js → skill-api-DCL1EN7f.js} +1 -1
  143. package/dist/gateway/static/root/assets/{skill-list-api-DpHaXI2l.js → skill-list-api-Bv0mmHbu.js} +1 -1
  144. package/dist/gateway/static/root/assets/{skill-reload-api-DDRd9IJ2.js → skill-reload-api-DPZbadiO.js} +1 -1
  145. package/dist/gateway/static/root/assets/{skills-page-CaeJVKhO.js → skills-page-DMC7Gaku.js} +1 -1
  146. package/dist/gateway/static/root/assets/{system-settings-panel-DYWlWPJL.js → system-settings-panel-BYFUhlqG.js} +1 -1
  147. package/dist/gateway/static/root/assets/{task-detail-page-De0qD7xw.js → task-detail-page-_Og3plZL.js} +3 -3
  148. package/dist/gateway/static/root/assets/{task-result-evidence-CICR5K1t.js → task-result-evidence-Bxm8-H0B.js} +1 -1
  149. package/dist/gateway/static/root/assets/{terminal-panel-store-BbWUcQe7.js → terminal-panel-store-Djf9l2qZ.js} +1 -1
  150. package/dist/gateway/static/root/assets/{theme-store-TkG5mo0p.js → theme-store-8GFVtotZ.js} +1 -1
  151. package/dist/gateway/static/root/assets/{tracing-settings-page-CYXEy4EG.js → tracing-settings-page-oWW3SBZ4.js} +1 -1
  152. package/dist/gateway/static/root/assets/{tunnel-api-DquDm6U2.js → tunnel-api-D-mEsSGF.js} +1 -1
  153. package/dist/gateway/static/root/assets/{understanding-activity-store-Ot3wZ3oQ.js → understanding-activity-store-CvDjsd0I.js} +1 -1
  154. package/dist/gateway/static/root/assets/{understanding-refresh-store-C5KYFMaC.js → understanding-refresh-store-DzOZJm7A.js} +1 -1
  155. package/dist/gateway/static/root/assets/{usage-page-1xFO4smo.js → usage-page-z-o6Uuev.js} +1 -1
  156. package/dist/gateway/static/root/assets/{use-autosave-HL8XRNR8.js → use-autosave-BVYS8UoK.js} +1 -1
  157. package/dist/gateway/static/root/assets/{use-composer-attachments-XRlQBdNF.js → use-composer-attachments-lecOV2q5.js} +1 -1
  158. package/dist/gateway/static/root/assets/{use-file-preview-expanded-CW956CXS.js → use-file-preview-expanded-nd_CuFsd.js} +2 -2
  159. package/dist/gateway/static/root/assets/{use-personal-profile-202s6tJt.js → use-personal-profile-CQi2ZCxV.js} +1 -1
  160. package/dist/gateway/static/root/assets/{use-workspace-tree-CjydkmH1.js → use-workspace-tree-BiaddkzX.js} +1 -1
  161. package/dist/gateway/static/root/assets/{user-model-page-OGPXx3pe.js → user-model-page-Bks1n0Nj.js} +1 -1
  162. package/dist/gateway/static/root/assets/{voice-api-key-field-CxFu4MEA.js → voice-api-key-field-BbW8NFeZ.js} +1 -1
  163. package/dist/gateway/static/root/assets/{voice-config-api-MHe5Pn-A.js → voice-config-api-jSMzZWWy.js} +1 -1
  164. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-B9xc1oK8.js → voice-input-shortcut-events-_SgYmx7X.js} +1 -1
  165. package/dist/gateway/static/root/assets/{voice-transcribe-api-CVEcB6Pe.js → voice-transcribe-api-BJCfiRFU.js} +1 -1
  166. package/dist/gateway/static/root/assets/{work-discovery-overlay-C-JoAg2D.js → work-discovery-overlay-DSTSNyU7.js} +1 -1
  167. package/dist/gateway/static/root/assets/{work-discovery-page-B5Kx29Ru.js → work-discovery-page-Dd_QJJvb.js} +1 -1
  168. package/dist/gateway/static/root/assets/{working-directory-picker-modal-DGp9cNzH.js → working-directory-picker-modal-q39BUcJ6.js} +1 -1
  169. package/dist/gateway/static/root/assets/{workspace-api-HBXn8pL9.js → workspace-api-Di2OmCvz.js} +2 -2
  170. package/dist/gateway/static/root/assets/workspace-editor-agent-store-B2r9wlix.js +1 -0
  171. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-3cpwSG2w.js → workspace-file-preview-dialog-BUGNT765.js} +1 -1
  172. package/dist/gateway/static/root/assets/{workspace-open-location-menu-D0VOFvuP.js → workspace-open-location-menu-bMSvmQW7.js} +1 -1
  173. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-BkdW2p3v.js → xopc-cloud-account-card-Bbe19Del.js} +1 -1
  174. package/dist/gateway/static/root/index.html +87 -85
  175. package/dist/package.js +1 -1
  176. package/dist/packages/computer-control-contract/src/index.js +33 -3
  177. package/dist/packages/gateway-contract/src/session-identity.js +2 -1
  178. package/dist/packages/gateway-contract/src/session-input-command.js +19 -2
  179. package/dist/packages/gateway-contract/src/specialists.js +1 -0
  180. package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -1
  181. package/dist/src/agent/embedded/execution-tool-policy.js +2 -2
  182. package/dist/src/agent/embedded/run-for-session.js +23 -8
  183. package/dist/src/agent/embedded/run-turn.js +30 -7
  184. package/dist/src/agent/embedded/runs.d.ts +2 -2
  185. package/dist/src/agent/embedded/runs.js +4 -4
  186. package/dist/src/agent/embedded/session-runner.js +26 -11
  187. package/dist/src/agent/embedded/tool-search-extension.d.ts +8 -2
  188. package/dist/src/agent/embedded/tool-search-extension.js +122 -30
  189. package/dist/src/agent/external-tools/cliProvider.d.ts +10 -9
  190. package/dist/src/agent/external-tools/cliProvider.js +24 -4
  191. package/dist/src/agent/external-tools/composio-provider.d.ts +3 -3
  192. package/dist/src/agent/external-tools/composio-provider.js +6 -3
  193. package/dist/src/agent/external-tools/discovery.d.ts +47 -0
  194. package/dist/src/agent/external-tools/discovery.js +56 -0
  195. package/dist/src/agent/external-tools/gateway-tools.js +26 -46
  196. package/dist/src/agent/external-tools/index.d.ts +1 -0
  197. package/dist/src/agent/external-tools/index.js +7 -0
  198. package/dist/src/agent/external-tools/personal-request-scope.d.ts +7 -0
  199. package/dist/src/agent/external-tools/personal-request-scope.js +83 -0
  200. package/dist/src/agent/external-tools/read-policy.js +5 -4
  201. package/dist/src/agent/external-tools/service.d.ts +2 -0
  202. package/dist/src/agent/external-tools/service.js +22 -3
  203. package/dist/src/agent/external-tools/tool-registry.d.ts +6 -0
  204. package/dist/src/agent/external-tools/types.d.ts +7 -2
  205. package/dist/src/agent/inbound/turn-dispatcher.d.ts +1 -1
  206. package/dist/src/agent/inbound/turn-dispatcher.js +3 -2
  207. package/dist/src/agent/orchestration/llm-turn-retry.d.ts +1 -1
  208. package/dist/src/agent/orchestration/llm-turn-retry.js +13 -8
  209. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.d.ts +1 -0
  210. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +3 -1
  211. package/dist/src/agent/prompt/sections/tooling.js +1 -1
  212. package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
  213. package/dist/src/agent/tool-manuals/computer.js +6 -4
  214. package/dist/src/agent/tool-manuals/phone.d.ts +1 -1
  215. package/dist/src/agent/tool-manuals/phone.js +4 -4
  216. package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +1 -1
  217. package/dist/src/agent/tool-manuals/xopc-configuration.js +4 -2
  218. package/dist/src/agent/tools/computer-use-tool.js +7 -6
  219. package/dist/src/agent/tools/delegation-policy.js +1 -0
  220. package/dist/src/agent/tools/factory.js +4 -2
  221. package/dist/src/agent/tools/phone-use-tool.js +2 -2
  222. package/dist/src/agent/tools/web.js +22 -3
  223. package/dist/src/agent-matching/service.js +2 -2
  224. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  225. package/dist/src/computer/batch.d.ts +108 -0
  226. package/dist/src/computer/batch.js +125 -0
  227. package/dist/src/computer/broker.d.ts +30 -2
  228. package/dist/src/computer/broker.js +109 -17
  229. package/dist/src/computer/diagnostics.d.ts +5 -1
  230. package/dist/src/computer/diagnostics.js +22 -3
  231. package/dist/src/computer/errors.d.ts +15 -0
  232. package/dist/src/computer/errors.js +59 -3
  233. package/dist/src/computer/model-adapter.d.ts +58 -0
  234. package/dist/src/computer/model-adapter.js +112 -66
  235. package/dist/src/computer/native-errors.d.ts +2 -0
  236. package/dist/src/computer/native-errors.js +13 -0
  237. package/dist/src/computer/program-runtime.d.ts +1 -1
  238. package/dist/src/computer/program-runtime.js +1 -0
  239. package/dist/src/computer/runtime.d.ts +11 -0
  240. package/dist/src/computer/runtime.js +102 -34
  241. package/dist/src/computer/semantic-actions.js +4 -0
  242. package/dist/src/config/schema.d.ts +6 -0
  243. package/dist/src/extensions/agent-plugins/formats.js +2 -1
  244. package/dist/src/extensions/agent-plugins/inventory.d.ts +2 -0
  245. package/dist/src/extensions/agent-plugins/inventory.js +4 -1
  246. package/dist/src/extensions/agent-plugins/validation.d.ts +1 -0
  247. package/dist/src/extensions/agent-plugins/validation.js +2 -1
  248. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  249. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  250. package/dist/src/gateway/hono/routes/phone-dependencies.js +26 -5
  251. package/dist/src/gateway/hono/routes/phone-setup.js +42 -16
  252. package/dist/src/gateway/hono/routes/phone.js +22 -7
  253. package/dist/src/gateway/hono/routes/session-command-handler.js +9 -0
  254. package/dist/src/gateway/hono/routes/session-input-control.d.ts +3 -0
  255. package/dist/src/gateway/hono/routes/session-input-control.js +37 -0
  256. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +12 -0
  257. package/dist/src/gateway/hono/routes/session-input-handler.js +22 -0
  258. package/dist/src/gateway/hono/routes/sessions.js +4 -0
  259. package/dist/src/gateway/service/agent-runner.js +5 -4
  260. package/dist/src/gateway/service/config-coordinator.d.ts +6 -0
  261. package/dist/src/gateway/service/session-input-coordinator.d.ts +6 -3
  262. package/dist/src/gateway/service/session-input-coordinator.js +47 -6
  263. package/dist/src/gateway/service.d.ts +1 -0
  264. package/dist/src/gateway/service.js +8 -5
  265. package/dist/src/home-intelligence/host.js +2 -2
  266. package/dist/src/personal-agent/capability-service.js +1 -1
  267. package/dist/src/personal-agent/request-access.d.ts +2 -0
  268. package/dist/src/personal-agent/request-access.js +22 -2
  269. package/dist/src/personal-agent/request-service.js +2 -2
  270. package/dist/src/personal-agent/specialist-capabilities.d.ts +2 -0
  271. package/dist/src/personal-agent/specialist-capabilities.js +9 -3
  272. package/dist/src/phone/adb-driver.d.ts +3 -0
  273. package/dist/src/phone/adb-driver.js +29 -0
  274. package/dist/src/phone/contracts.d.ts +14 -2
  275. package/dist/src/phone/contracts.js +8 -1
  276. package/dist/src/phone/gui-protocol.js +1 -1
  277. package/dist/src/phone/hdc-driver.d.ts +30 -0
  278. package/dist/src/phone/hdc-driver.js +331 -0
  279. package/dist/src/phone/hdc-video-bridge.d.ts +2 -0
  280. package/dist/src/phone/hdc-video-bridge.js +91 -0
  281. package/dist/src/phone/hdc-video-tools.d.ts +15 -0
  282. package/dist/src/phone/hdc-video-tools.js +123 -0
  283. package/dist/src/phone/hdc-video.d.ts +69 -0
  284. package/dist/src/phone/hdc-video.js +350 -0
  285. package/dist/src/phone/interactive-session.js +1 -1
  286. package/dist/src/phone/live-provider.d.ts +6 -0
  287. package/dist/src/phone/live-provider.js +1 -0
  288. package/dist/src/phone/model-adapter.d.ts +3 -0
  289. package/dist/src/phone/model-adapter.js +5 -3
  290. package/dist/src/phone/repository.js +2 -1
  291. package/dist/src/phone/runtime.d.ts +10 -4
  292. package/dist/src/phone/runtime.js +151 -85
  293. package/dist/src/phone/setup/service.d.ts +8 -6
  294. package/dist/src/phone/setup/service.js +33 -16
  295. package/dist/src/platform/client.d.ts +1 -1
  296. package/dist/src/platform/contracts.d.ts +1 -1
  297. package/dist/src/process/phone-process.d.ts +1 -1
  298. package/dist/src/process/phone-process.js +2 -2
  299. package/dist/src/runtime-tools/downloader.d.ts +1 -0
  300. package/dist/src/runtime-tools/downloader.js +8 -4
  301. package/dist/src/runtime-tools/harmony-dependencies.d.ts +24 -0
  302. package/dist/src/runtime-tools/harmony-dependencies.js +272 -0
  303. package/dist/src/runtime-tools/harmony-dependency-catalog.d.ts +4 -0
  304. package/dist/src/runtime-tools/harmony-dependency-catalog.js +54 -0
  305. package/dist/src/runtime-tools/harmony-paths.d.ts +9 -0
  306. package/dist/src/runtime-tools/harmony-paths.js +15 -0
  307. package/dist/src/runtime-tools/hdc-dependency-catalog.d.ts +8 -0
  308. package/dist/src/runtime-tools/hdc-dependency-catalog.js +83 -0
  309. package/dist/src/runtime-tools/hdc-files.d.ts +14 -0
  310. package/dist/src/runtime-tools/hdc-files.js +87 -0
  311. package/dist/src/runtime-tools/phone-dependencies.d.ts +6 -1
  312. package/dist/src/runtime-tools/phone-dependencies.js +20 -2
  313. package/dist/src/runtime-tools/phone-dependency-catalog.d.ts +10 -1
  314. package/dist/src/runtime-tools/phone-dependency-catalog.js +2 -0
  315. package/dist/src/runtime-tools/types.d.ts +1 -1
  316. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  317. package/dist/src/storage/sqlite/schema.js +7 -7
  318. package/dist/src/storage/sqlite/schema.sql +16 -0
  319. package/dist/src/storage/sqlite/session-creation-repository.js +3 -0
  320. package/dist/src/storage/sqlite/session-input-control-repository.d.ts +12 -0
  321. package/dist/src/storage/sqlite/session-input-control-repository.js +83 -0
  322. package/dist/src/storage/sqlite/session-input-repository.d.ts +2 -0
  323. package/dist/src/storage/sqlite/session-input-repository.js +17 -5
  324. package/dist/src/storage/sqlite/session-repository.js +1 -0
  325. package/dist/src/storage/sqlite/session-turn-replace-repository.d.ts +2 -0
  326. package/dist/src/storage/sqlite/session-turn-replace-repository.js +14 -2
  327. package/dist/src/storage/sqlite/upgrades/262_session_input_control.sql +15 -0
  328. package/package.json +2 -2
  329. package/skills/tools/configure-xopc/SKILL.md +2 -2
  330. package/skills/tools/configure-xopc/references/phone/acceptance.md +3 -2
  331. package/skills/tools/configure-xopc/references/phone/dependencies.md +18 -2
  332. package/skills/tools/configure-xopc/references/phone/harmonyos.md +16 -0
  333. package/skills/tools/configure-xopc/references/phone/overview.md +2 -2
  334. package/skills/tools/configure-xopc/references/scene-index.md +2 -2
  335. package/dist/gateway/static/root/assets/apps-page-D-n71lO1.js +0 -1
  336. package/dist/gateway/static/root/assets/automations-workspace-DWDWy-SG.js +0 -9
  337. package/dist/gateway/static/root/assets/capabilities-page-IcwojmJK.js +0 -2
  338. package/dist/gateway/static/root/assets/capability-links-DzQWK1Fh.js +0 -1
  339. package/dist/gateway/static/root/assets/chat-page-CwP4OMdW.js +0 -72
  340. package/dist/gateway/static/root/assets/computer-settings-page-DyAlOzqY.js +0 -1
  341. package/dist/gateway/static/root/assets/connected-providers-grid-D0lXg22c.js +0 -1
  342. package/dist/gateway/static/root/assets/connectors-page-DI_Q0CKz.js +0 -1
  343. package/dist/gateway/static/root/assets/gateway-realtime-store-BFeFfApQ.js +0 -1
  344. package/dist/gateway/static/root/assets/index-Cz-VjTNd.css +0 -1
  345. package/dist/gateway/static/root/assets/index-D1_PUrJf.js +0 -11
  346. package/dist/gateway/static/root/assets/install-connector-dialog-Cn4nRSyt.js +0 -1
  347. package/dist/gateway/static/root/assets/list-tree-B0OMswgM.js +0 -1
  348. package/dist/gateway/static/root/assets/messages-jwdBhfL9.js +0 -3
  349. package/dist/gateway/static/root/assets/note-image-lightbox-DGYRJS03.js +0 -1
  350. package/dist/gateway/static/root/assets/page-header-store-CEn_kPsn.js +0 -1
  351. package/dist/gateway/static/root/assets/phone-dependencies-card-DjmC1Z5j.js +0 -1
  352. package/dist/gateway/static/root/assets/phone-model-connection-BRjHSgYn.js +0 -1
  353. package/dist/gateway/static/root/assets/phone-model-picker-DgIiWLhR.js +0 -1
  354. package/dist/gateway/static/root/assets/phone-settings-page-DCZGCL_z.js +0 -1
  355. package/dist/gateway/static/root/assets/plugin-details-dialog-D4tGKip4.js +0 -1
  356. package/dist/gateway/static/root/assets/route-preload-C1BKDjnu.js +0 -2
  357. package/dist/gateway/static/root/assets/session-api-Bfmlmn9F.js +0 -1
  358. package/dist/gateway/static/root/assets/session-channel-icon-SsY70Z6t.js +0 -1
  359. package/dist/gateway/static/root/assets/session-identity-label-B7sgG1PE.js +0 -1
  360. package/dist/gateway/static/root/assets/session-manager-X4UHOjjO.js +0 -25
  361. package/dist/gateway/static/root/assets/settings-advanced-gate-Dk9c-Z5e.js +0 -1
  362. package/dist/gateway/static/root/assets/workspace-editor-agent-store-msZa42fU.js +0 -1
@@ -1 +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-B6OrWgY1.js";import{t as s}from"./messages-jwdBhfL9.js";import{a as c,i as l,o as u,r as d,s as f,t as p}from"./dist-BGTk37IG.js";import{t as m}from"./chevron-right-BweFrslA.js";import{t as h}from"./circle-check-C23XjkUj.js";import{t as g}from"./clock-3-DnrAnuyZ.js";import{t as _}from"./download-Dk-ZjtO6.js";import{t as v}from"./external-link-DjqjBmc3.js";import{t as y}from"./laptop-CI3hBVrl.js";import{t as b}from"./panel-right-CFGrHTsD.js";import{t as x}from"./smartphone-DSSsQFqA.js";import{t as ee}from"./x-B_N4OPjy.js";import{t as S}from"./cn-0WouolD0.js";import{t as C}from"./skeleton-BI5TyibZ.js";import{i as w}from"./vendor-swr-CdRzEUwF.js";import{t as T}from"./button-Cc4hUNTt.js";import{a as E,i as D,o as O,s as k}from"./dist-GJ8-1PAx.js";import{a as A,i as te,o as ne}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as j}from"./app-link-DRy3-k7j.js";import{t as M}from"./use-async-resource-BHFGZCY2.js";import{t as N}from"./copy-text-row-CpiRzq4G.js";import{a as re,n as P,r as F}from"./oauth-api-CMmu4DzH.js";import{n as ie,r as I,t as L}from"./oauth-authorization-window-o6URRos4.js";import{_ as ae,a as R,b as oe,d as z,f as se,g as ce,h as le,i as ue,l as B,m as de,n as fe,p as pe,r as V,s as H,t as U,u as me,v as he,y as ge}from"./tunnel-api-DquDm6U2.js";import{t as _e}from"./mobile-pair-qr-CuIbmw5x.js";var W=r(),G=e(n(),1),K=i();function ve(){let e=s(o(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=w(`tunnel-status`,fe,{refreshInterval:1500}),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!0),[m,h]=(0,G.useState)(`idle`),[g,_]=(0,G.useState)(null),[y,b]=(0,G.useState)(``),[x,ee]=(0,G.useState)(``),S=(0,G.useRef)(!0);(0,G.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]),(0,G.useEffect)(()=>{r?.state===`connected`&&(_(null),b(``))},[r?.state]);let E=g?g===`registration-rejected`:r?.state===`error`&&se(Error(r.lastError??``)),D=g?g===`recovery-rejected`:r?.state===`error`&&z(Error(r.lastError??``)),O=async()=>{if(!r)return;if(r.consentRequired&&!c){d(!0);return}let e=E||!r.registrationSecret?.configured,t=e?I():null,n,i=!1;_(null),b(``);try{if(r.consentRequired&&await R(),e){h(`provisioning`),E&&await V({registrationSecret:null});let e=!1;try{await ue()}catch(t){if(!me(t))throw t;e=!0}if(e){h(`authorizing`);let e=sessionStorage.getItem(`device-pairing-oauth`),r=e?JSON.parse(e):null;n=r&&r.expiresAt>Date.now()?r.sessionId:(await re(`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(;S.current&&Date.now()<o;){let e=await F(n);if(e.authUrl&&e.authUrl!==a&&(a=e.authUrl,await ie(a,t)||ee(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(!S.current)return;if(!s)throw Error(`Authorization expired`);await ue()}await a()}if(!S.current)return;h(`starting`),await H(D?{recoverActiveLease:!0}:void 0),f&&await V({autoStart:!0}),await a(),i=!0}catch(e){i=!0,S.current&&(_(B(e)===`tunnel_key_limit_reached`?`key-limit`:se(e)?`registration-rejected`:z(e)?`recovery-rejected`:`failed`),b(e instanceof Error?e.message:``))}finally{L(t),i&&(sessionStorage.removeItem(`device-pairing-oauth`),n&&P(n).catch(()=>{})),S.current&&(h(`idle`),ee(``))}};if(!r&&!i)return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsx)(C,{className:`h-5 w-4/5`}),(0,K.jsx)(C,{className:`h-24 w-full`})]});let k=m===`provisioning`||m===`starting`||r?.state===`connecting`||r?.state===`reconnecting`,A=m===`idle`&&!k&&(g||i||r?.state===`error`),te=y||(i instanceof Error?i.message:``)||(r?.state===`error`?r.lastError:``);return(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:k?t.preparingHint:m===`authorizing`?t.authorizing:t.enableHint}),x&&m===`authorizing`?(0,K.jsx)(`a`,{href:x,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,k?(0,K.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,K.jsx)(C,{className:`h-2 w-full`}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(u||r?.consentRequired)&&m===`idle`?(0,K.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,K.jsxs)(`details`,{open:u,className:`text-sm text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,K.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,K.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,K.jsx)(`li`,{children:e},e))})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,A&&g===`key-limit`?(0,K.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,K.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,K.jsxs)(T,{variant:`secondary`,className:`mt-3`,onClick:()=>void j(U),children:[t.manageTunnelKeys,(0,K.jsx)(v,{className:`size-3`})]})]}):A?(0,K.jsxs)(`div`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:[(0,K.jsx)(`p`,{children:i&&!r?t.readinessFailed:E?t.routeAuthorizationRequired:D?t.routeRecoveryRequired:t.routeSetupFailed}),te?(0,K.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,K.jsx)(`p`,{className:`break-words whitespace-pre-wrap`,children:te})]}):null]}):null,(0,K.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:f,disabled:m!==`idle`,onChange:e=>p(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),i&&!r?(0,K.jsx)(T,{className:`w-full`,variant:`primary`,onClick:()=>void a().catch(()=>{}),children:t.retry}):(0,K.jsx)(T,{className:`w-full`,variant:`primary`,disabled:!r||m!==`idle`||k||u&&!c,onClick:()=>void O(),children:m===`authorizing`?t.authorizing:k?t.preparing:E?t.authorize:D?t.recoverRoute:A?t.retry:t.enable})]})}var q=t({DevicePairingWizard:()=>J});function J(e){let t=(0,W.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,G.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,G.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 m=f,h;t[6]!==m||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(h=n?c?(0,K.jsx)(Z,{targetKind:c,onClose:()=>m(!1),onPaired:i}):(0,K.jsx)(X,{onChoose:l,onChooseLocalBrowser:()=>{m(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>m(!1)}):null,t[6]=m,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=h):h=t[11];let g;return t[12]!==m||t[13]!==n||t[14]!==h?(g=(0,K.jsx)(p,{open:n,onOpenChange:m,children:h}),t[12]=m,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function Y(e){let t=(0,W.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,K.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,K.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,K.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,K.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,K.jsx)(m,{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]=u):u=t[9];let d;return t[10]!==a||t[11]!==o||t[12]!==l?(d=(0,K.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,l,u]}),t[10]=a,t[11]=o,t[12]=l,t[13]=d):d=t[13],d}function X(e){let t=(0,W.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=o(ye),p;t[0]===a?p=t[1]:(p=s(a),t[0]=a,t[1]=p);let m=p.endpointToolsSettings.deviceAccess,h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,K.jsx)(c,{className:S(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ne)}),t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=S(`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`,te),t[3]=g):g=t[3];let _;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=_):_=t[4];let v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,K.jsx)(ee,{className:`size-4`}),t[5]=v):v=t[5];let C;t[6]!==m.cancel||t[7]!==i?(C=(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[_,(0,K.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":m.cancel,onClick:i,children:v})]}),t[6]=m.cancel,t[7]=i,t[8]=C):C=t[8];let w;t[9]===m.chooseTitle?w=t[10]:(w=(0,K.jsx)(f,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:m.chooseTitle}),t[9]=m.chooseTitle,t[10]=w);let T;t[11]===m.chooseHint?T=t[12]:(T=(0,K.jsx)(l,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:m.chooseHint}),t[11]=m.chooseHint,t[12]=T);let E;t[13]!==m.localBrowserHint||t[14]!==m.localBrowserTitle||t[15]!==r?(E=(0,K.jsx)(Y,{icon:y,title:m.localBrowserTitle,hint:m.localBrowserHint,onClick:r}),t[13]=m.localBrowserHint,t[14]=m.localBrowserTitle,t[15]=r,t[16]=E):E=t[16];let D;t[17]===n?D=t[18]:(D=()=>n(`mobile`),t[17]=n,t[18]=D);let O;t[19]!==m.mobileHint||t[20]!==m.mobileTitle||t[21]!==D?(O=(0,K.jsx)(Y,{icon:x,title:m.mobileTitle,hint:m.mobileHint,onClick:D}),t[19]=m.mobileHint,t[20]=m.mobileTitle,t[21]=D,t[22]=O):O=t[22];let k;t[23]===n?k=t[24]:(k=()=>n(`browser`),t[23]=n,t[24]=k);let A;t[25]!==m.remoteBrowserHint||t[26]!==m.remoteBrowserTitle||t[27]!==k?(A=(0,K.jsx)(Y,{icon:b,title:m.remoteBrowserTitle,hint:m.remoteBrowserHint,onClick:k}),t[25]=m.remoteBrowserHint,t[26]=m.remoteBrowserTitle,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==O||t[30]!==A||t[31]!==E?(j=(0,K.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[E,O,A]}),t[29]=O,t[30]=A,t[31]=E,t[32]=j):j=t[32];let M;t[33]!==j||t[34]!==w||t[35]!==T?(M=(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[w,T,j]}),t[33]=j,t[34]=w,t[35]=T,t[36]=M):M=t[36];let N;return t[37]!==M||t[38]!==C?(N=(0,K.jsxs)(u,{children:[h,(0,K.jsxs)(d,{className:g,children:[C,M]})]}),t[37]=M,t[38]=C,t[39]=N):N=t[39],N}function ye(e){return e.language}function Z({targetKind:e,onClose:t,onPaired:n}){let r=o(e=>e.language),i=s(r),a=i.endpointToolsSettings.deviceAccess,p=a.flow,[y,b]=(0,G.useState)(e===`mobile`),[x,re]=(0,G.useState)(!1),P=w(y?`device-pairing-readiness`:null,ae,{refreshInterval:1500}),[F,ie]=(0,G.useState)(),[I,L]=(0,G.useState)(null),[R,z]=(0,G.useState)(!1),[se,ue]=(0,G.useState)(Date.now()),[B,fe]=(0,G.useState)(null),V=(0,G.useRef)(!0),H=(0,G.useRef)(null),U=(0,G.useRef)(!1),me=(0,G.useRef)(!1),W=w(F?[`device-pairing-setup`,F.id]:null,()=>he(F.id),{refreshInterval:1500}),q=W.data?.request,J=q?.status===`completed`,Y=J&&q.connectedAt!==void 0,X=w(Y&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),ye=F?.targetKind===`mobile`?F.universalLink:``,Z=M(()=>_e(ye),[ye],{enabled:!!ye,initial:null,errorData:null}),be=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,xe=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,Se=M(()=>_e(be),[be],{enabled:x&&e===`mobile`,initial:null,errorData:null});(0,G.useEffect)(()=>{V.current=!0;let e=setInterval(()=>ue(Date.now()),1e3);return()=>{V.current=!1,clearInterval(e),H.current&&pe(H.current).catch(()=>{})}},[]);let Ce=(0,G.useCallback)(async()=>{if(!U.current){U.current=!0,z(!0),L(null);try{H.current&&await pe(H.current),H.current=null,ie(void 0);let t=await de(e);if(t.kind===`ready`){if(!V.current){await pe(t.setup.id);return}H.current=t.setup.id,ie(t.setup)}else await P.mutate()}catch{V.current&&L(`create`)}finally{U.current=!1,V.current&&z(!1)}}},[P,e]);(0,G.useEffect)(()=>{P.data?.ready&&!F&&I!==`create`&&!U.current&&Ce()},[P.data,F,I,Ce]),(0,G.useEffect)(()=>{Y&&!me.current&&(me.current=!0,n?.())},[Y,n]);let we=async e=>{if(q){z(!0),L(null);try{await le(q,e),await W.mutate()}catch{L(`decision`),await W.mutate()}finally{V.current&&z(!1)}}},Te=(0,G.useRef)(0);(0,G.useEffect)(()=>{W.data&&(Te.current=W.data.serverTime-Date.now())},[W.data]);let Q=se+Te.current,Ee=F&&Q>=F.expiresAt&&!q,De=q&&[`expired`,`rejected`,`cancelled`].includes(q.status),Oe=F?F.expiresAt-Q<6e4:!1,ke=F?Oe?`${Math.max(0,Math.ceil((F.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=y?Y?$.success:q?.status===`pending`?$.allowTitle:J||q?.status===`approved`?p.waiting:F?$.connect:p.title:Ae,Ne=I===`create`?p.createFailed:I===`decision`?p.decisionFailed:I===`background`?p.backgroundFailed:I===`download`?a.browserDownloadFailed:null,Pe=async()=>{z(!0),L(null);try{await ce()}catch{L(`download`)}finally{V.current&&z(!1)}};return(0,K.jsxs)(u,{children:[(0,K.jsx)(c,{className:S(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ne)}),(0,K.jsxs)(d,{className:S(`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`,te),children:[(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e===`mobile`?(0,K.jsxs)(O,{open:x,onOpenChange:re,children:[(0,K.jsx)(k,{asChild:!0,children:(0,K.jsxs)(T,{variant:`ghost`,className:`min-h-10`,children:[(0,K.jsx)(_,{className:`size-4`,"aria-hidden":`true`}),a.mobileDownloadAction]})}),(0,K.jsx)(E,{children:(0,K.jsxs)(D,{align:`end`,sideOffset:8,"aria-label":a.mobileDownloadAction,className:S(`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`,A),children:[(0,K.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:a.mobileDownloadAction}),(0,K.jsx)(`div`,{className:`my-6 flex justify-center`,children:Se.data?(0,K.jsx)(`img`,{src:Se.data,alt:a.mobileDownloadQrAlt,width:216,height:216,className:`size-[216px] max-w-full rounded-lg bg-white`}):Se.error?(0,K.jsx)(`p`,{role:`status`,className:`text-sm text-warning`,children:p.qrFailed}):(0,K.jsx)(C,{className:`size-[216px] max-w-full`})}),(0,K.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:a.mobileDownloadHint}),(0,K.jsxs)(T,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void j(be),children:[(0,K.jsx)(v,{className:`size-4`,"aria-hidden":`true`}),a.mobileDownload]})]})})]}):null,(0,K.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,K.jsx)(ee,{className:`size-4`,"aria-hidden":`true`})})]})]}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[Y?(0,K.jsx)(h,{className:`mb-5 size-7 text-success`}):null,(0,K.jsx)(f,{className:`text-xl font-semibold tracking-tight text-fg`,children:Me}),(0,K.jsx)(l,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:y?Y?$.successHint:J?p.waitingForDevice:q?q.displayName:F?$.connectHint:p.intro:je}),Ne?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ne}):null,y&&P.error?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:p.readinessFailed}):null,y&&W.error?(0,K.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:p.statusUnavailable}):null,y?P.data?Y?(0,K.jsxs)(K.Fragment,{children:[X.data?(0,K.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,K.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":X.data.runInBackground??!1,disabled:!X.data.backgroundSupported,checked:X.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>X.mutate(e.behavior)).catch(()=>L(`background`))}})]}):null,(0,K.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):De||Ee?(0,K.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Ee||q?.status===`expired`?p.expired:p.declined}),(0,K.jsx)(T,{variant:`primary`,onClick:()=>void Ce(),disabled:R,children:p.refresh})]}):q?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:p.scope}),(0,K.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[q.confirmationCode.slice(0,3),` `,q.confirmationCode.slice(3)]}),(0,K.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:p.compare}),(0,K.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:p.access}),(0,K.jsx)(`p`,{children:p.accessHint})]})]}):F?.targetKind===`mobile`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,K.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,K.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:Z.data?(0,K.jsx)(`img`,{src:Z.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):Z.error?null:(0,K.jsx)(C,{className:`size-[240px] rounded-xl`})})}),Z.error?null:(0,K.jsxs)(`p`,{className:S(`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,K.jsx)(g,{className:`size-3.5`,"aria-hidden":`true`}),ke]})]}),Z.error?(0,K.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:p.qrFailed}):null,Z.error?(0,K.jsx)(`div`,{className:`mt-5`,children:(0,K.jsx)(N,{text:F.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,K.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,K.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,K.jsx)(`span`,{children:p.fallback}),(0,K.jsx)(m,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,K.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,K.jsx)(N,{text:F.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):F?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,K.jsx)(`div`,{className:`mt-6`,children:(0,K.jsx)(N,{text:F.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,K.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:F.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((F.expiresAt-Q)/1e3))}s`:p.valid})]}):P.data.ready?(0,K.jsx)(`div`,{className:`mt-8`,children:(0,K.jsx)(C,{className:`mx-auto size-[216px]`})}):(0,K.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[B===`tailscale`?(0,K.jsx)(oe,{embedded:!0}):B===`https`?(0,K.jsx)(ge,{}):B===`choices`?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(T,{variant:`secondary`,className:`w-full`,onClick:()=>fe(`tailscale`),children:a.useTailscale}),(0,K.jsx)(T,{variant:`secondary`,className:`w-full`,onClick:()=>fe(`https`),children:a.useOwnHttps})]}):(0,K.jsx)(ve,{}),(0,K.jsx)(T,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>fe(B?null:`choices`),children:B?p.back:p.existing})]}):(0,K.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,K.jsx)(C,{className:`h-5 w-3/4`}),(0,K.jsx)(C,{className:`h-40 w-full`})]}):(0,K.jsxs)(`div`,{className:`mt-7`,children:[(0,K.jsxs)(T,{variant:`secondary`,className:`w-full`,disabled:R,onClick:()=>void Pe(),children:[(0,K.jsx)(_,{className:`size-4`}),a.browserDownload]}),(0,K.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,K.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void j(xe),children:[a.browserInstallHelp,(0,K.jsx)(v,{className:`size-3`})]})]})]}),!y||P.error||Y||q?.status===`pending`||I===`create`||I===`decision`?(0,K.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:y?Y?(0,K.jsx)(T,{className:`w-full`,variant:`primary`,onClick:t,children:p.done}):q?.status===`pending`?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(T,{className:`w-full`,variant:`primary`,disabled:R,onClick:()=>void we(`approve`),children:p.allow}),(0,K.jsx)(T,{className:`w-full`,variant:`ghost`,disabled:R,onClick:()=>void we(`reject`),children:p.cancel})]}):P.error?(0,K.jsx)(T,{className:`w-full`,variant:`primary`,onClick:()=>void P.mutate(),children:p.retry}):(0,K.jsx)(T,{className:`w-full`,variant:`primary`,disabled:R,onClick:()=>void Ce(),children:p.retry}):(0,K.jsx)(T,{className:`w-full`,variant:`primary`,onClick:()=>{L(null),b(!0)},children:a.browserReady})}):null]})]})}export{q as n,J as t};
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-CAZaC05J.js";import{t as s}from"./messages-C7fckbyG.js";import{a as c,i as l,o as u,r as d,s as f,t as p}from"./dist-BGTk37IG.js";import{t as m}from"./chevron-right-BweFrslA.js";import{t as h}from"./circle-check-C23XjkUj.js";import{t as g}from"./clock-3-DnrAnuyZ.js";import{t as _}from"./download-Dk-ZjtO6.js";import{t as v}from"./external-link-DjqjBmc3.js";import{t as y}from"./laptop-CI3hBVrl.js";import{t as b}from"./panel-right-CFGrHTsD.js";import{t as x}from"./smartphone-DSSsQFqA.js";import{t as ee}from"./x-B_N4OPjy.js";import{t as S}from"./cn-0WouolD0.js";import{t as C}from"./skeleton-BI5TyibZ.js";import{i as w}from"./vendor-swr-CdRzEUwF.js";import{t as T}from"./button-Cc4hUNTt.js";import{a as E,i as D,o as O,s as k}from"./dist-GJ8-1PAx.js";import{a as A,i as te,o as ne}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as j}from"./app-link-DRy3-k7j.js";import{t as M}from"./use-async-resource-BHFGZCY2.js";import{t as N}from"./copy-text-row-CpiRzq4G.js";import{a as re,n as P,r as F}from"./oauth-api-DmxSaxM1.js";import{n as ie,r as I,t as L}from"./oauth-authorization-window-o6URRos4.js";import{_ as ae,a as R,b as oe,d as z,f as se,g as ce,h as le,i as ue,l as B,m as de,n as fe,p as pe,r as V,s as H,t as U,u as me,v as he,y as ge}from"./tunnel-api-D-mEsSGF.js";import{t as _e}from"./mobile-pair-qr-CuIbmw5x.js";var W=r(),G=e(n(),1),K=i();function ve(){let e=s(o(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=w(`tunnel-status`,fe,{refreshInterval:1500}),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!0),[m,h]=(0,G.useState)(`idle`),[g,_]=(0,G.useState)(null),[y,b]=(0,G.useState)(``),[x,ee]=(0,G.useState)(``),S=(0,G.useRef)(!0);(0,G.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]),(0,G.useEffect)(()=>{r?.state===`connected`&&(_(null),b(``))},[r?.state]);let E=g?g===`registration-rejected`:r?.state===`error`&&se(Error(r.lastError??``)),D=g?g===`recovery-rejected`:r?.state===`error`&&z(Error(r.lastError??``)),O=async()=>{if(!r)return;if(r.consentRequired&&!c){d(!0);return}let e=E||!r.registrationSecret?.configured,t=e?I():null,n,i=!1;_(null),b(``);try{if(r.consentRequired&&await R(),e){h(`provisioning`),E&&await V({registrationSecret:null});let e=!1;try{await ue()}catch(t){if(!me(t))throw t;e=!0}if(e){h(`authorizing`);let e=sessionStorage.getItem(`device-pairing-oauth`),r=e?JSON.parse(e):null;n=r&&r.expiresAt>Date.now()?r.sessionId:(await re(`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(;S.current&&Date.now()<o;){let e=await F(n);if(e.authUrl&&e.authUrl!==a&&(a=e.authUrl,await ie(a,t)||ee(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(!S.current)return;if(!s)throw Error(`Authorization expired`);await ue()}await a()}if(!S.current)return;h(`starting`),await H(D?{recoverActiveLease:!0}:void 0),f&&await V({autoStart:!0}),await a(),i=!0}catch(e){i=!0,S.current&&(_(B(e)===`tunnel_key_limit_reached`?`key-limit`:se(e)?`registration-rejected`:z(e)?`recovery-rejected`:`failed`),b(e instanceof Error?e.message:``))}finally{L(t),i&&(sessionStorage.removeItem(`device-pairing-oauth`),n&&P(n).catch(()=>{})),S.current&&(h(`idle`),ee(``))}};if(!r&&!i)return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsx)(C,{className:`h-5 w-4/5`}),(0,K.jsx)(C,{className:`h-24 w-full`})]});let k=m===`provisioning`||m===`starting`||r?.state===`connecting`||r?.state===`reconnecting`,A=m===`idle`&&!k&&(g||i||r?.state===`error`),te=y||(i instanceof Error?i.message:``)||(r?.state===`error`?r.lastError:``);return(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:k?t.preparingHint:m===`authorizing`?t.authorizing:t.enableHint}),x&&m===`authorizing`?(0,K.jsx)(`a`,{href:x,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,k?(0,K.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,K.jsx)(C,{className:`h-2 w-full`}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(u||r?.consentRequired)&&m===`idle`?(0,K.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,K.jsxs)(`details`,{open:u,className:`text-sm text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,K.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,K.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,K.jsx)(`li`,{children:e},e))})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,A&&g===`key-limit`?(0,K.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,K.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,K.jsxs)(T,{variant:`secondary`,className:`mt-3`,onClick:()=>void j(U),children:[t.manageTunnelKeys,(0,K.jsx)(v,{className:`size-3`})]})]}):A?(0,K.jsxs)(`div`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:[(0,K.jsx)(`p`,{children:i&&!r?t.readinessFailed:E?t.routeAuthorizationRequired:D?t.routeRecoveryRequired:t.routeSetupFailed}),te?(0,K.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,K.jsx)(`p`,{className:`break-words whitespace-pre-wrap`,children:te})]}):null]}):null,(0,K.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:f,disabled:m!==`idle`,onChange:e=>p(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),i&&!r?(0,K.jsx)(T,{className:`w-full`,variant:`primary`,onClick:()=>void a().catch(()=>{}),children:t.retry}):(0,K.jsx)(T,{className:`w-full`,variant:`primary`,disabled:!r||m!==`idle`||k||u&&!c,onClick:()=>void O(),children:m===`authorizing`?t.authorizing:k?t.preparing:E?t.authorize:D?t.recoverRoute:A?t.retry:t.enable})]})}var q=t({DevicePairingWizard:()=>J});function J(e){let t=(0,W.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,G.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,G.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 m=f,h;t[6]!==m||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(h=n?c?(0,K.jsx)(Z,{targetKind:c,onClose:()=>m(!1),onPaired:i}):(0,K.jsx)(X,{onChoose:l,onChooseLocalBrowser:()=>{m(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>m(!1)}):null,t[6]=m,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=h):h=t[11];let g;return t[12]!==m||t[13]!==n||t[14]!==h?(g=(0,K.jsx)(p,{open:n,onOpenChange:m,children:h}),t[12]=m,t[13]=n,t[14]=h,t[15]=g):g=t[15],g}function Y(e){let t=(0,W.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,K.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,K.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,K.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,K.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,K.jsx)(m,{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]=u):u=t[9];let d;return t[10]!==a||t[11]!==o||t[12]!==l?(d=(0,K.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,l,u]}),t[10]=a,t[11]=o,t[12]=l,t[13]=d):d=t[13],d}function X(e){let t=(0,W.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=o(ye),p;t[0]===a?p=t[1]:(p=s(a),t[0]=a,t[1]=p);let m=p.endpointToolsSettings.deviceAccess,h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,K.jsx)(c,{className:S(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ne)}),t[2]=h):h=t[2];let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=S(`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`,te),t[3]=g):g=t[3];let _;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=_):_=t[4];let v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,K.jsx)(ee,{className:`size-4`}),t[5]=v):v=t[5];let C;t[6]!==m.cancel||t[7]!==i?(C=(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[_,(0,K.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":m.cancel,onClick:i,children:v})]}),t[6]=m.cancel,t[7]=i,t[8]=C):C=t[8];let w;t[9]===m.chooseTitle?w=t[10]:(w=(0,K.jsx)(f,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:m.chooseTitle}),t[9]=m.chooseTitle,t[10]=w);let T;t[11]===m.chooseHint?T=t[12]:(T=(0,K.jsx)(l,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:m.chooseHint}),t[11]=m.chooseHint,t[12]=T);let E;t[13]!==m.localBrowserHint||t[14]!==m.localBrowserTitle||t[15]!==r?(E=(0,K.jsx)(Y,{icon:y,title:m.localBrowserTitle,hint:m.localBrowserHint,onClick:r}),t[13]=m.localBrowserHint,t[14]=m.localBrowserTitle,t[15]=r,t[16]=E):E=t[16];let D;t[17]===n?D=t[18]:(D=()=>n(`mobile`),t[17]=n,t[18]=D);let O;t[19]!==m.mobileHint||t[20]!==m.mobileTitle||t[21]!==D?(O=(0,K.jsx)(Y,{icon:x,title:m.mobileTitle,hint:m.mobileHint,onClick:D}),t[19]=m.mobileHint,t[20]=m.mobileTitle,t[21]=D,t[22]=O):O=t[22];let k;t[23]===n?k=t[24]:(k=()=>n(`browser`),t[23]=n,t[24]=k);let A;t[25]!==m.remoteBrowserHint||t[26]!==m.remoteBrowserTitle||t[27]!==k?(A=(0,K.jsx)(Y,{icon:b,title:m.remoteBrowserTitle,hint:m.remoteBrowserHint,onClick:k}),t[25]=m.remoteBrowserHint,t[26]=m.remoteBrowserTitle,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==O||t[30]!==A||t[31]!==E?(j=(0,K.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[E,O,A]}),t[29]=O,t[30]=A,t[31]=E,t[32]=j):j=t[32];let M;t[33]!==j||t[34]!==w||t[35]!==T?(M=(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[w,T,j]}),t[33]=j,t[34]=w,t[35]=T,t[36]=M):M=t[36];let N;return t[37]!==M||t[38]!==C?(N=(0,K.jsxs)(u,{children:[h,(0,K.jsxs)(d,{className:g,children:[C,M]})]}),t[37]=M,t[38]=C,t[39]=N):N=t[39],N}function ye(e){return e.language}function Z({targetKind:e,onClose:t,onPaired:n}){let r=o(e=>e.language),i=s(r),a=i.endpointToolsSettings.deviceAccess,p=a.flow,[y,b]=(0,G.useState)(e===`mobile`),[x,re]=(0,G.useState)(!1),P=w(y?`device-pairing-readiness`:null,ae,{refreshInterval:1500}),[F,ie]=(0,G.useState)(),[I,L]=(0,G.useState)(null),[R,z]=(0,G.useState)(!1),[se,ue]=(0,G.useState)(Date.now()),[B,fe]=(0,G.useState)(null),V=(0,G.useRef)(!0),H=(0,G.useRef)(null),U=(0,G.useRef)(!1),me=(0,G.useRef)(!1),W=w(F?[`device-pairing-setup`,F.id]:null,()=>he(F.id),{refreshInterval:1500}),q=W.data?.request,J=q?.status===`completed`,Y=J&&q.connectedAt!==void 0,X=w(Y&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),ye=F?.targetKind===`mobile`?F.universalLink:``,Z=M(()=>_e(ye),[ye],{enabled:!!ye,initial:null,errorData:null}),be=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,xe=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,Se=M(()=>_e(be),[be],{enabled:x&&e===`mobile`,initial:null,errorData:null});(0,G.useEffect)(()=>{V.current=!0;let e=setInterval(()=>ue(Date.now()),1e3);return()=>{V.current=!1,clearInterval(e),H.current&&pe(H.current).catch(()=>{})}},[]);let Ce=(0,G.useCallback)(async()=>{if(!U.current){U.current=!0,z(!0),L(null);try{H.current&&await pe(H.current),H.current=null,ie(void 0);let t=await de(e);if(t.kind===`ready`){if(!V.current){await pe(t.setup.id);return}H.current=t.setup.id,ie(t.setup)}else await P.mutate()}catch{V.current&&L(`create`)}finally{U.current=!1,V.current&&z(!1)}}},[P,e]);(0,G.useEffect)(()=>{P.data?.ready&&!F&&I!==`create`&&!U.current&&Ce()},[P.data,F,I,Ce]),(0,G.useEffect)(()=>{Y&&!me.current&&(me.current=!0,n?.())},[Y,n]);let we=async e=>{if(q){z(!0),L(null);try{await le(q,e),await W.mutate()}catch{L(`decision`),await W.mutate()}finally{V.current&&z(!1)}}},Te=(0,G.useRef)(0);(0,G.useEffect)(()=>{W.data&&(Te.current=W.data.serverTime-Date.now())},[W.data]);let Q=se+Te.current,Ee=F&&Q>=F.expiresAt&&!q,De=q&&[`expired`,`rejected`,`cancelled`].includes(q.status),Oe=F?F.expiresAt-Q<6e4:!1,ke=F?Oe?`${Math.max(0,Math.ceil((F.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=y?Y?$.success:q?.status===`pending`?$.allowTitle:J||q?.status===`approved`?p.waiting:F?$.connect:p.title:Ae,Ne=I===`create`?p.createFailed:I===`decision`?p.decisionFailed:I===`background`?p.backgroundFailed:I===`download`?a.browserDownloadFailed:null,Pe=async()=>{z(!0),L(null);try{await ce()}catch{L(`download`)}finally{V.current&&z(!1)}};return(0,K.jsxs)(u,{children:[(0,K.jsx)(c,{className:S(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ne)}),(0,K.jsxs)(d,{className:S(`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`,te),children:[(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e===`mobile`?(0,K.jsxs)(O,{open:x,onOpenChange:re,children:[(0,K.jsx)(k,{asChild:!0,children:(0,K.jsxs)(T,{variant:`ghost`,className:`min-h-10`,children:[(0,K.jsx)(_,{className:`size-4`,"aria-hidden":`true`}),a.mobileDownloadAction]})}),(0,K.jsx)(E,{children:(0,K.jsxs)(D,{align:`end`,sideOffset:8,"aria-label":a.mobileDownloadAction,className:S(`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`,A),children:[(0,K.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:a.mobileDownloadAction}),(0,K.jsx)(`div`,{className:`my-6 flex justify-center`,children:Se.data?(0,K.jsx)(`img`,{src:Se.data,alt:a.mobileDownloadQrAlt,width:216,height:216,className:`size-[216px] max-w-full rounded-lg bg-white`}):Se.error?(0,K.jsx)(`p`,{role:`status`,className:`text-sm text-warning`,children:p.qrFailed}):(0,K.jsx)(C,{className:`size-[216px] max-w-full`})}),(0,K.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:a.mobileDownloadHint}),(0,K.jsxs)(T,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void j(be),children:[(0,K.jsx)(v,{className:`size-4`,"aria-hidden":`true`}),a.mobileDownload]})]})})]}):null,(0,K.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,K.jsx)(ee,{className:`size-4`,"aria-hidden":`true`})})]})]}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[Y?(0,K.jsx)(h,{className:`mb-5 size-7 text-success`}):null,(0,K.jsx)(f,{className:`text-xl font-semibold tracking-tight text-fg`,children:Me}),(0,K.jsx)(l,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:y?Y?$.successHint:J?p.waitingForDevice:q?q.displayName:F?$.connectHint:p.intro:je}),Ne?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ne}):null,y&&P.error?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:p.readinessFailed}):null,y&&W.error?(0,K.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:p.statusUnavailable}):null,y?P.data?Y?(0,K.jsxs)(K.Fragment,{children:[X.data?(0,K.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,K.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":X.data.runInBackground??!1,disabled:!X.data.backgroundSupported,checked:X.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>X.mutate(e.behavior)).catch(()=>L(`background`))}})]}):null,(0,K.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):De||Ee?(0,K.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Ee||q?.status===`expired`?p.expired:p.declined}),(0,K.jsx)(T,{variant:`primary`,onClick:()=>void Ce(),disabled:R,children:p.refresh})]}):q?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:p.scope}),(0,K.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[q.confirmationCode.slice(0,3),` `,q.confirmationCode.slice(3)]}),(0,K.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:p.compare}),(0,K.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:p.access}),(0,K.jsx)(`p`,{children:p.accessHint})]})]}):F?.targetKind===`mobile`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,K.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,K.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:Z.data?(0,K.jsx)(`img`,{src:Z.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):Z.error?null:(0,K.jsx)(C,{className:`size-[240px] rounded-xl`})})}),Z.error?null:(0,K.jsxs)(`p`,{className:S(`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,K.jsx)(g,{className:`size-3.5`,"aria-hidden":`true`}),ke]})]}),Z.error?(0,K.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:p.qrFailed}):null,Z.error?(0,K.jsx)(`div`,{className:`mt-5`,children:(0,K.jsx)(N,{text:F.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,K.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,K.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,K.jsx)(`span`,{children:p.fallback}),(0,K.jsx)(m,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,K.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,K.jsx)(N,{text:F.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):F?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,K.jsx)(`div`,{className:`mt-6`,children:(0,K.jsx)(N,{text:F.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,K.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:F.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((F.expiresAt-Q)/1e3))}s`:p.valid})]}):P.data.ready?(0,K.jsx)(`div`,{className:`mt-8`,children:(0,K.jsx)(C,{className:`mx-auto size-[216px]`})}):(0,K.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[B===`tailscale`?(0,K.jsx)(oe,{embedded:!0}):B===`https`?(0,K.jsx)(ge,{}):B===`choices`?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(T,{variant:`secondary`,className:`w-full`,onClick:()=>fe(`tailscale`),children:a.useTailscale}),(0,K.jsx)(T,{variant:`secondary`,className:`w-full`,onClick:()=>fe(`https`),children:a.useOwnHttps})]}):(0,K.jsx)(ve,{}),(0,K.jsx)(T,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>fe(B?null:`choices`),children:B?p.back:p.existing})]}):(0,K.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,K.jsx)(C,{className:`h-5 w-3/4`}),(0,K.jsx)(C,{className:`h-40 w-full`})]}):(0,K.jsxs)(`div`,{className:`mt-7`,children:[(0,K.jsxs)(T,{variant:`secondary`,className:`w-full`,disabled:R,onClick:()=>void Pe(),children:[(0,K.jsx)(_,{className:`size-4`}),a.browserDownload]}),(0,K.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,K.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void j(xe),children:[a.browserInstallHelp,(0,K.jsx)(v,{className:`size-3`})]})]})]}),!y||P.error||Y||q?.status===`pending`||I===`create`||I===`decision`?(0,K.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:y?Y?(0,K.jsx)(T,{className:`w-full`,variant:`primary`,onClick:t,children:p.done}):q?.status===`pending`?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(T,{className:`w-full`,variant:`primary`,disabled:R,onClick:()=>void we(`approve`),children:p.allow}),(0,K.jsx)(T,{className:`w-full`,variant:`ghost`,disabled:R,onClick:()=>void we(`reject`),children:p.cancel})]}):P.error?(0,K.jsx)(T,{className:`w-full`,variant:`primary`,onClick:()=>void P.mutate(),children:p.retry}):(0,K.jsx)(T,{className:`w-full`,variant:`primary`,disabled:R,onClick:()=>void Ce(),children:p.retry}):(0,K.jsx)(T,{className:`w-full`,variant:`primary`,onClick:()=>{L(null),b(!0)},children:a.browserReady})}):null]})]})}export{q as n,J 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-DGp9cNzH.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-q39BUcJ6.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-B6OrWgY1.js";import{t as i}from"./createLucideIcon-DPHK1VkS.js";import{t as a}from"./chevron-down-ccbiQQz_.js";import{t as o}from"./button-Cc4hUNTt.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-CAZaC05J.js";import{t as i}from"./createLucideIcon-DPHK1VkS.js";import{t as a}from"./chevron-down-ccbiQQz_.js";import{t as o}from"./button-Cc4hUNTt.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-B6OrWgY1.js";import{t as i}from"./messages-jwdBhfL9.js";import{r as a}from"./extension-provider-C4jLFIgh.js";import{n as o,t as s}from"./settings-page-header-BAN34UQi.js";import"./settings-page-layout-B5TVFBV2.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-CAZaC05J.js";import{t as i}from"./messages-C7fckbyG.js";import{r as a}from"./extension-provider-NKWfjpdP.js";import{n as o,t as s}from"./settings-page-header-LuOJvqNa.js";import"./settings-page-layout-CduQ8w4a.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-B6OrWgY1.js";import{t as te}from"./messages-jwdBhfL9.js";import{a as s,n as c,o as l,r as ne,s as re,t as u}from"./dist-BGTk37IG.js";import{c as d,n as f}from"./extension-provider-C4jLFIgh.js";import{i as p}from"./theme-store-TkG5mo0p.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-CAZaC05J.js";import{t as te}from"./messages-C7fckbyG.js";import{a as s,n as c,o as l,r as ne,s as re,t as u}from"./dist-BGTk37IG.js";import{c as d,n as f}from"./extension-provider-NKWfjpdP.js";import{i as p}from"./theme-store-8GFVtotZ.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-B6OrWgY1.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-CAZaC05J.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-CUNbPkdj.js";import{r as o,s}from"./extension-provider-C4jLFIgh.js";import{t as c}from"./page-header-store-CEn_kPsn.js";import{t as l}from"./extension-iframe-host-63KpX6IP.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-D15jzjV_.js";import{r as o,s}from"./extension-provider-NKWfjpdP.js";import{t as c}from"./page-header-store-D7G5utVi.js";import{t as l}from"./extension-iframe-host-Bds-5kY_.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-B6OrWgY1.js";import{i as c,m as l,n as u,p as d,u as f}from"./schemas-CCWMleym.js";import{d as p,i as m,t as h}from"./session-manager-X4UHOjjO.js";import{t as g}from"./capabilities-DlHPLld_.js";import{i as _}from"./vendor-swr-CdRzEUwF.js";import{a as v}from"./gateway-realtime-BSRNLciy.js";import{t as y}from"./activity-store-BpYGrRXw.js";import{i as b}from"./theme-store-TkG5mo0p.js";var x=d({id:u([`xopc.notes.get`,`xopc.notes.list`,`xopc.tasks.get`,`xopc.tasks.list`,`xopc.notes.create`,`xopc.notes.update`,`xopc.notes.append`]),majorVersion:f().int().positive(),descriptorDigest:l().regex(/^[a-f0-9]{64}$/)});c(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??v,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 h,i=await r.loadSessionAgentConfig(e);await r.loadSession(e),p(e,i),await new m().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=d({id:x.shape.id}),n=t.extend({call:g});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 h().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:c}=_(o(e=>!!e.conversationId)?`gateway-extensions-list`:null,()=>s(a(`/api/extensions`)),{revalidateOnFocus:!1}),l=r?.extensions??[],u=b(e=>e.resolved);(0,S.useEffect)(()=>{let e=()=>{c()};return window.addEventListener(`config-reload`,e),window.addEventListener(`registry-updated`,e),()=>{window.removeEventListener(`config-reload`,e),window.removeEventListener(`registry-updated`,e)}},[c]);let d=(0,S.useCallback)(e=>{let t=e.detail;t?.conversationId&&n.forwardAgentStreamEvent(t.conversationId,t.event??t)},[n]),f=(0,S.useRef)(d);f.current=d,(0,S.useEffect)(()=>{let e=e=>{f.current(e)};return window.addEventListener(w,e),()=>{window.removeEventListener(w,e)}},[]),(0,S.useEffect)(()=>{let e=P(u);n.broadcastEvent(`theme.changed`,e)},[u,n]);let p=(0,S.useRef)(n);p.current=n,(0,S.useEffect)(()=>()=>{p.current.dispose(),t.current=null},[]);let m=(0,S.useMemo)(()=>({router:n,extensions:l,loading:i}),[n,l,i]);return(0,W.jsx)(G.Provider,{value:m,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-CAZaC05J.js";import{i as c,m as l,n as u,p as d,u as f}from"./schemas-CCWMleym.js";import{d as p,i as m,t as h}from"./session-manager-DRRWwKE4.js";import{t as g}from"./capabilities-C7lnwKKm.js";import{i as _}from"./vendor-swr-CdRzEUwF.js";import{a as v}from"./gateway-realtime-DwMd2PCt.js";import{t as y}from"./activity-store-Cwn_CNwl.js";import{i as b}from"./theme-store-8GFVtotZ.js";var x=d({id:u([`xopc.notes.get`,`xopc.notes.list`,`xopc.tasks.get`,`xopc.tasks.list`,`xopc.notes.create`,`xopc.notes.update`,`xopc.notes.append`]),majorVersion:f().int().positive(),descriptorDigest:l().regex(/^[a-f0-9]{64}$/)});c(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??v,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 h,i=await r.loadSessionAgentConfig(e);await r.loadSession(e),p(e,i),await new m().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=d({id:x.shape.id}),n=t.extend({call:g});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 h().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:c}=_(o(e=>!!e.conversationId)?`gateway-extensions-list`:null,()=>s(a(`/api/extensions`)),{revalidateOnFocus:!1}),l=r?.extensions??[],u=b(e=>e.resolved);(0,S.useEffect)(()=>{let e=()=>{c()};return window.addEventListener(`config-reload`,e),window.addEventListener(`registry-updated`,e),()=>{window.removeEventListener(`config-reload`,e),window.removeEventListener(`registry-updated`,e)}},[c]);let d=(0,S.useCallback)(e=>{let t=e.detail;t?.conversationId&&n.forwardAgentStreamEvent(t.conversationId,t.event??t)},[n]),f=(0,S.useRef)(d);f.current=d,(0,S.useEffect)(()=>{let e=e=>{f.current(e)};return window.addEventListener(w,e),()=>{window.removeEventListener(w,e)}},[]),(0,S.useEffect)(()=>{let e=P(u);n.broadcastEvent(`theme.changed`,e)},[u,n]);let p=(0,S.useRef)(n);p.current=n,(0,S.useEffect)(()=>()=>{p.current.dispose(),t.current=null},[]);let m=(0,S.useMemo)(()=>({router:n,extensions:l,loading:i}),[n,l,i]);return(0,W.jsx)(G.Provider,{value:m,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 +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,t as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as o,i as s,l as c,n as l,o as u}from"./locale-store-B6OrWgY1.js";import{t as d}from"./messages-jwdBhfL9.js";import{t as f}from"./resource-unavailable-CUNbPkdj.js";import{n as p,r as m}from"./popover-select-CEMWIrtY.js";import{t as h}from"./cn-0WouolD0.js";import{r as g}from"./extension-provider-C4jLFIgh.js";import{i as _}from"./vendor-swr-CdRzEUwF.js";import{t as v}from"./button-Cc4hUNTt.js";import{a as y,o as b,s as x}from"./form-field-width-DJw_jULe.js";import{t as S}from"./extension-iframe-host-63KpX6IP.js";import{t as C}from"./settings-loading-skeleton-BTqvr_Fw.js";import{n as w,t as T}from"./settings-page-header-BAN34UQi.js";import"./settings-page-layout-B5TVFBV2.js";import{n as E,t as D}from"./use-autosave-HL8XRNR8.js";import{a as O,c as k,o as A}from"./voice-config-api-MHe5Pn-A.js";import{t as j}from"./voice-api-key-field-CxFu4MEA.js";import{t as M}from"./schema-form-C-jw6Hid.js";var N=e(t(),1),P=n(),F=r();function I(e){let t=(0,P.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function L(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function R(){return h(b,y)}function z(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,x,`dark:border-edge`)}function B(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function V({providerId:e,voiceSettings:t,mutateVoice:n}){let r=d(l(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,o={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:c}=_(s(`/api/voice/stt-providers`),A,{revalidateOnFocus:!1}),u=(0,N.useMemo)(()=>c?.providers.find(t=>t.id===e),[e,c]),f=u?.configured??!1,g=u?.models??[],v=g[0]?.id??u?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,N.useMemo)(()=>B(t,e,v),[v,e,t]),x=(0,N.useRef)(!1),[S,C]=(0,N.useState)(null),w=S??b,T=(0,N.useRef)(w);T.current=w;let O=b,M=D({value:w,dirty:w.apiKey!==O.apiKey||w.model!==O.model,onSave:(0,N.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await k(i,`transcription`),await n(i,!1),x.current=JSON.stringify(T.current)!==JSON.stringify(r),C(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),P=g.length>0?g:w.model?[{id:w.model,name:w.model}]:[];return(0,F.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:M.onBlurCapture,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(E,{status:M.status,error:M.error}),(0,F.jsx)(`span`,{className:h(`rounded-full px-2 py-0.5 text-xs font-medium`,f?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:f?a.configured:a.notConfigured})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:h(`flex flex-col gap-1.5`,y),children:[(0,F.jsx)(I,{children:i.stt.apiKey}),(0,F.jsx)(j,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:w.apiKey,onChange:e=>{x.current=!0,C(t=>({...t??b,apiKey:e}))},labels:o,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,F.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,F.jsxs)(`div`,{className:h(`flex flex-col gap-1.5`,y),children:[(0,F.jsx)(I,{children:i.stt.model}),P.length>0?(0,F.jsx)(p,{className:R(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value})),M.saveNow({...w,model:e.target.value})},children:P.map(e=>(0,F.jsx)(m,{value:e.id,children:e.name},e.id))}):(0,F.jsx)(`input`,{className:z(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value}))}})]})]})]})}function H(e){let t=(0,P.c)(13),{extensionId:n}=e,r=l(W),i=c(U),a;t[0]===n?a=t[1]:(a=()=>u(s(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:d}=_(i&&n?`ext-stt-detail-${n}`:null,a),f;t[2]===o?f=t[3]:(f=L(o),t[2]=o,t[3]=f);let p=f,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m={revalidateOnFocus:!1},t[4]=m):m=t[4];let{data:h,mutate:g,isLoading:v}=_(i?`voice-settings-ext-stt`:null,O,m);if(!i)return null;if(d||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,F.jsx)(C,{rows:2}),t[5]=e):e=t[5],e}if(!p){let e=r===`zh`?`该插件未声明 mediaUnderstandingProviders。`:`This plugin does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!h)return null;let y=`${n}:${p}`,b;return t[8]!==g||t[9]!==p||t[10]!==y||t[11]!==h?(b=(0,F.jsx)(V,{providerId:p,voiceSettings:h,mutateVoice:g},y),t[8]=g,t[9]=p,t[10]=y,t[11]=h,t[12]=b):b=t[12],b}function U(e){return!!e.conversationId}function W(e){return e.language}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){let t={};if(e.type!==`object`||!G(e.properties))return t;for(let[n,r]of Object.entries(e.properties))G(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function q(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function J({extensionId:e}){let t=c(e=>!!e.conversationId),{data:n,error:r}=_(t&&e?`ext-detail-${e}`:null,()=>u(s(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:l}=_(t&&e?`ext-cfg-${e}`:null,()=>u(s(`/api/extensions/${encodeURIComponent(e)}/config`))),d=n?.manifest?.configSchema,f=(0,N.useMemo)(()=>d&&d.type===`object`?K(d):{},[d]),p=(0,N.useMemo)(()=>({...f,...i??{}}),[f,i]),[m,h]=(0,N.useReducer)(q,{localValues:{},isDirty:!1}),g=(0,N.useRef)(!1),y=(0,N.useRef)(m.localValues);y.current=m.localValues;let b=(0,N.useRef)(p);!g.current&&b.current!==p&&(b.current=p,h({type:`sync`,value:p}));let x=(0,N.useCallback)(e=>{g.current=!0,h({type:`change`,value:e})},[]),S=(0,N.useCallback)(()=>{!d||d.type!==`object`||(g.current=!0,h({type:`reset-defaults`,value:{...K(d)}}))},[d]),C=(0,N.useCallback)(async t=>{if(!e)return;let n=await o(s(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),h({type:`saved`,value:t}),g.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),w=D({value:m.localValues,dirty:m.isDirty,onSave:C});if(!t)return null;if(r||l){let e=r??l;return(0,F.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!d||d.type!==`object`?null:(0,F.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-hover/20 p-4`,onBlurCapture:w.onBlurCapture,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(E,{status:w.status,error:w.error}),(0,F.jsx)(v,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,F.jsx)(M,{schema:d,values:m.localValues,onChange:x})]})}function Y(){let e=(0,P.c)(36),t=l(X),n;e[0]===t?n=e[1]:(n=d(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),c=g();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[2]=t):t=e[2],t}let u,p,m;if(e[3]!==o||e[4]!==c||e[5]!==s){m=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),u=c.find(t),!u){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[11]=t):t=e[11],m=t;break bb0}let n=u.ui?.contributions?.settingsPanels;p=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=c,e[5]=s,e[6]=u,e[7]=p,e[8]=m}else u=e[6],p=e[7],m=e[8];if(m!==Symbol.for(`react.early_return_sentinel`))return m;let h=p,_=!!(h&&u.ui),v=!!u.hasConfigSchema,y=u.kind===`media-provider`;if(!v&&!_&&!y){let t;return e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin-settings`,backTo:`/capabilities/extensions`}),e[12]=t):t=e[12],t}let b=h?.title??(t===`zh`?`${u.name} 设置`:`${u.name} Settings`),x;e[13]===b?x=e[14]:(x=(0,F.jsx)(T,{title:b}),e[13]=b,e[14]=x);let C;e[15]!==y||e[16]!==r?(C=y?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,F.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,F.jsx)(a,{to:`/settings/capabilities/models?configure=transcription`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[15]=y,e[16]=r,e[17]=C):C=e[17];let E;e[18]!==o||e[19]!==y?(E=y?(0,F.jsx)(H,{extensionId:o}):null,e[18]=o,e[19]=y,e[20]=E):E=e[20];let D;e[21]!==o||e[22]!==v?(D=v?(0,F.jsx)(J,{extensionId:o}):null,e[21]=o,e[22]=v,e[23]=D):D=e[23];let O;e[24]!==u.name||e[25]!==u.ui||e[26]!==o||e[27]!==_||e[28]!==h?(O=_&&h&&u.ui?(0,F.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,F.jsx)(S,{extensionId:o,extensionName:u.name,entrypoint:h.entrypoint,permissions:u.ui?.permissions,title:h.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[24]=u.name,e[25]=u.ui,e[26]=o,e[27]=_,e[28]=h,e[29]=O):O=e[29];let k;return e[30]!==x||e[31]!==C||e[32]!==E||e[33]!==D||e[34]!==O?(k=(0,F.jsxs)(w,{gap:`gap-5`,children:[x,C,E,D,O]}),e[30]=x,e[31]=C,e[32]=E,e[33]=D,e[34]=O,e[35]=k):k=e[35],k}function X(e){return e.language}export{Y as ExtensionSettingsPage};
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,t as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as o,i as s,l as c,n as l,o as u}from"./locale-store-CAZaC05J.js";import{t as d}from"./messages-C7fckbyG.js";import{t as f}from"./resource-unavailable-D15jzjV_.js";import{n as p,r as m}from"./popover-select-CEMWIrtY.js";import{t as h}from"./cn-0WouolD0.js";import{r as g}from"./extension-provider-NKWfjpdP.js";import{i as _}from"./vendor-swr-CdRzEUwF.js";import{t as v}from"./button-Cc4hUNTt.js";import{a as y,o as b,s as x}from"./form-field-width-DJw_jULe.js";import{t as S}from"./extension-iframe-host-Bds-5kY_.js";import{t as C}from"./settings-loading-skeleton-BTqvr_Fw.js";import{n as w,t as T}from"./settings-page-header-LuOJvqNa.js";import"./settings-page-layout-CduQ8w4a.js";import{n as E,t as D}from"./use-autosave-BVYS8UoK.js";import{a as O,c as k,o as A}from"./voice-config-api-jSMzZWWy.js";import{t as j}from"./voice-api-key-field-BbW8NFeZ.js";import{t as M}from"./schema-form-C-jw6Hid.js";var N=e(t(),1),P=n(),F=r();function I(e){let t=(0,P.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function L(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function R(){return h(b,y)}function z(){return h(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,x,`dark:border-edge`)}function B(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function V({providerId:e,voiceSettings:t,mutateVoice:n}){let r=d(l(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,o={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:c}=_(s(`/api/voice/stt-providers`),A,{revalidateOnFocus:!1}),u=(0,N.useMemo)(()=>c?.providers.find(t=>t.id===e),[e,c]),f=u?.configured??!1,g=u?.models??[],v=g[0]?.id??u?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,N.useMemo)(()=>B(t,e,v),[v,e,t]),x=(0,N.useRef)(!1),[S,C]=(0,N.useState)(null),w=S??b,T=(0,N.useRef)(w);T.current=w;let O=b,M=D({value:w,dirty:w.apiKey!==O.apiKey||w.model!==O.model,onSave:(0,N.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await k(i,`transcription`),await n(i,!1),x.current=JSON.stringify(T.current)!==JSON.stringify(r),C(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),P=g.length>0?g:w.model?[{id:w.model,name:w.model}]:[];return(0,F.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:M.onBlurCapture,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(E,{status:M.status,error:M.error}),(0,F.jsx)(`span`,{className:h(`rounded-full px-2 py-0.5 text-xs font-medium`,f?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:f?a.configured:a.notConfigured})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:h(`flex flex-col gap-1.5`,y),children:[(0,F.jsx)(I,{children:i.stt.apiKey}),(0,F.jsx)(j,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:w.apiKey,onChange:e=>{x.current=!0,C(t=>({...t??b,apiKey:e}))},labels:o,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,F.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,F.jsxs)(`div`,{className:h(`flex flex-col gap-1.5`,y),children:[(0,F.jsx)(I,{children:i.stt.model}),P.length>0?(0,F.jsx)(p,{className:R(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value})),M.saveNow({...w,model:e.target.value})},children:P.map(e=>(0,F.jsx)(m,{value:e.id,children:e.name},e.id))}):(0,F.jsx)(`input`,{className:z(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value}))}})]})]})]})}function H(e){let t=(0,P.c)(13),{extensionId:n}=e,r=l(W),i=c(U),a;t[0]===n?a=t[1]:(a=()=>u(s(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:d}=_(i&&n?`ext-stt-detail-${n}`:null,a),f;t[2]===o?f=t[3]:(f=L(o),t[2]=o,t[3]=f);let p=f,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m={revalidateOnFocus:!1},t[4]=m):m=t[4];let{data:h,mutate:g,isLoading:v}=_(i?`voice-settings-ext-stt`:null,O,m);if(!i)return null;if(d||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,F.jsx)(C,{rows:2}),t[5]=e):e=t[5],e}if(!p){let e=r===`zh`?`该插件未声明 mediaUnderstandingProviders。`:`This plugin does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!h)return null;let y=`${n}:${p}`,b;return t[8]!==g||t[9]!==p||t[10]!==y||t[11]!==h?(b=(0,F.jsx)(V,{providerId:p,voiceSettings:h,mutateVoice:g},y),t[8]=g,t[9]=p,t[10]=y,t[11]=h,t[12]=b):b=t[12],b}function U(e){return!!e.conversationId}function W(e){return e.language}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){let t={};if(e.type!==`object`||!G(e.properties))return t;for(let[n,r]of Object.entries(e.properties))G(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function q(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function J({extensionId:e}){let t=c(e=>!!e.conversationId),{data:n,error:r}=_(t&&e?`ext-detail-${e}`:null,()=>u(s(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:l}=_(t&&e?`ext-cfg-${e}`:null,()=>u(s(`/api/extensions/${encodeURIComponent(e)}/config`))),d=n?.manifest?.configSchema,f=(0,N.useMemo)(()=>d&&d.type===`object`?K(d):{},[d]),p=(0,N.useMemo)(()=>({...f,...i??{}}),[f,i]),[m,h]=(0,N.useReducer)(q,{localValues:{},isDirty:!1}),g=(0,N.useRef)(!1),y=(0,N.useRef)(m.localValues);y.current=m.localValues;let b=(0,N.useRef)(p);!g.current&&b.current!==p&&(b.current=p,h({type:`sync`,value:p}));let x=(0,N.useCallback)(e=>{g.current=!0,h({type:`change`,value:e})},[]),S=(0,N.useCallback)(()=>{!d||d.type!==`object`||(g.current=!0,h({type:`reset-defaults`,value:{...K(d)}}))},[d]),C=(0,N.useCallback)(async t=>{if(!e)return;let n=await o(s(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),h({type:`saved`,value:t}),g.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),w=D({value:m.localValues,dirty:m.isDirty,onSave:C});if(!t)return null;if(r||l){let e=r??l;return(0,F.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!d||d.type!==`object`?null:(0,F.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-hover/20 p-4`,onBlurCapture:w.onBlurCapture,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(E,{status:w.status,error:w.error}),(0,F.jsx)(v,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,F.jsx)(M,{schema:d,values:m.localValues,onChange:x})]})}function Y(){let e=(0,P.c)(36),t=l(X),n;e[0]===t?n=e[1]:(n=d(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),c=g();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[2]=t):t=e[2],t}let u,p,m;if(e[3]!==o||e[4]!==c||e[5]!==s){m=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),u=c.find(t),!u){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin`,backTo:`/capabilities/extensions`}),e[11]=t):t=e[11],m=t;break bb0}let n=u.ui?.contributions?.settingsPanels;p=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=c,e[5]=s,e[6]=u,e[7]=p,e[8]=m}else u=e[6],p=e[7],m=e[8];if(m!==Symbol.for(`react.early_return_sentinel`))return m;let h=p,_=!!(h&&u.ui),v=!!u.hasConfigSchema,y=u.kind===`media-provider`;if(!v&&!_&&!y){let t;return e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(f,{kind:`plugin-settings`,backTo:`/capabilities/extensions`}),e[12]=t):t=e[12],t}let b=h?.title??(t===`zh`?`${u.name} 设置`:`${u.name} Settings`),x;e[13]===b?x=e[14]:(x=(0,F.jsx)(T,{title:b}),e[13]=b,e[14]=x);let C;e[15]!==y||e[16]!==r?(C=y?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,F.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,F.jsx)(a,{to:`/settings/capabilities/models?configure=transcription`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[15]=y,e[16]=r,e[17]=C):C=e[17];let E;e[18]!==o||e[19]!==y?(E=y?(0,F.jsx)(H,{extensionId:o}):null,e[18]=o,e[19]=y,e[20]=E):E=e[20];let D;e[21]!==o||e[22]!==v?(D=v?(0,F.jsx)(J,{extensionId:o}):null,e[21]=o,e[22]=v,e[23]=D):D=e[23];let O;e[24]!==u.name||e[25]!==u.ui||e[26]!==o||e[27]!==_||e[28]!==h?(O=_&&h&&u.ui?(0,F.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,F.jsx)(S,{extensionId:o,extensionName:u.name,entrypoint:h.entrypoint,permissions:u.ui?.permissions,title:h.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[24]=u.name,e[25]=u.ui,e[26]=o,e[27]=_,e[28]=h,e[29]=O):O=e[29];let k;return e[30]!==x||e[31]!==C||e[32]!==E||e[33]!==D||e[34]!==O?(k=(0,F.jsxs)(w,{gap:`gap-5`,children:[x,C,E,D,O]}),e[30]=x,e[31]=C,e[32]=E,e[33]=D,e[34]=O,e[35]=k):k=e[35],k}function X(e){return e.language}export{Y as ExtensionSettingsPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,p as a}from"./locale-store-B6OrWgY1.js";import{t as o}from"./cn-0WouolD0.js";import{t as s}from"./phone-workspace-store-DbqktZbO.js";import{n as c}from"./electron-env-DHOGevH3.js";import{a as l}from"./shares-api-DOeDN6Tm.js";var u=`xopc:right-workspace:v1`,d={open:!1,tabs:[],activeId:null},f={panes:{},width:0,treeWidth:240,fileTreeOpen:!0,sideTreeOpen:!1};function p(){try{let e=JSON.parse(sessionStorage.getItem(u)||`null`);if(!e||e.version!==1||typeof e.panes!=`object`||!e.panes||e.identity!==i.getState().conversationId||e.gateway!==i.getState().baseUrl)return f;let t={};for(let[n,r]of Object.entries(e.panes)){let e=r;if(!e||!Array.isArray(e.tabs))continue;let i=e.tabs.filter(e=>e&&typeof e.id==`string`&&typeof e.title==`string`&&(e.kind===`file`&&typeof e.path==`string`||e.kind===`sidechat`&&typeof e.sideChatId==`string`||e.kind===`home`||e.kind===`files`));t[n]={open:e.open===!0&&i.length>0,tabs:i,activeId:i.some(t=>t.id===e.activeId)?e.activeId:i[0]?.id??null}}return{...f,panes:t}}catch{return f}}function m(e,t){try{let n=Number(localStorage.getItem(e));return n>0&&Number.isFinite(n)?n:t}catch{return t}}function h(e){try{let t=Object.fromEntries(Object.entries(e.panes).map(([e,t])=>[e,{...t,tabs:t.tabs.filter(e=>e.kind!==`browser`&&(e.kind!==`file`||!e.attachment)).map(e=>({...e}))}]));sessionStorage.setItem(u,JSON.stringify({version:1,identity:i.getState().conversationId,gateway:i.getState().baseUrl,panes:t}))}catch{}}var g=new WeakMap;function _(e){return e?e.id||e.uri?e.id||e.uri:(g.has(e)||g.set(e,crypto.randomUUID()),g.get(e)):``}function v(e){return e.replace(/\\/g,`/`).split(`/`).filter(e=>e!==`.`).join(`/`)}function y(e){let t=e.projectId?`project:${e.projectId}`:e.conversationId?`session:${e.conversationId}`:`agent:${e.agentId??``}`;return JSON.stringify([t,e.path?v(e.path):_(e.attachment)])}var b=a((e,t)=>{let n=(n,r)=>{e(e=>({panes:{...e.panes,[n]:r(e.panes[n]??d)}})),h(t())};return{...p(),width:m(`xopc:workspace-width`,0),treeWidth:m(`xopc:workspace-tree-width`,240),notices:{},setNotice:(t,n)=>e(e=>({notices:{...e.notices,[t]:n}})),fileStatus:{},setFileStatus:(n,r)=>{r&&t().keepFileOpen(n),e(e=>({fileStatus:{...e.fileStatus,[n]:r??``}}))},keepFileOpen:e=>{for(let[r,i]of Object.entries(t().panes))i.tabs.some(t=>t.id===e&&t.kind===`file`&&t.preview)&&n(r,t=>({...t,tabs:t.tabs.map(t=>t.id===e?{...t,preview:!1}:t)}))},scope:`new`,setScope:t=>e({scope:t}),migrateScope:(n,r)=>{let i=t().panes[n];if(!i||n===r)return;let a=t().panes[r]??d,o={...t().panes,[r]:{open:i.open||a.open,tabs:[...a.tabs,...i.tabs.filter(e=>!a.tabs.some(t=>t.id===e.id))],activeId:i.activeId??a.activeId}};delete o[n],e({panes:o,scope:t().scope===n?r:t().scope}),h(t())},openPhone:(e,t,r,i=!0,a=!0)=>{let o=`phone:${e}`;n(r,n=>({open:i||n.open,activeId:i?o:n.activeId,tabs:n.tabs.some(e=>e.id===o)?n.tabs.map(e=>e.id===o?{...e,title:t}:e):[...n.tabs,{id:o,kind:`phone`,phoneSessionId:e,title:t,visitedAt:Date.now()}]})),a&&s.getState().show(e,i,/^[\da-f]{8}-[\da-f-]{27}$/i.test(r)?r:void 0)},openTools:(e=t().scope)=>{let r=crypto.randomUUID();return n(e,e=>{let t=[...e.tabs];return t.splice(Math.max(0,t.findIndex(t=>t.id===e.activeId)+1),0,{id:r,kind:`home`,title:`New tab`,visitedAt:Date.now()}),{open:!0,tabs:t,activeId:r}}),r},openBrowser:(e,r=t().scope,i)=>{let a=t().panes[r]??d,o=a.tabs.find(e=>e.id===a.activeId&&e.kind===`home`)?.id??crypto.randomUUID(),s={id:o,kind:`browser`,title:`Browser`,initialUrl:e,visitedAt:Date.now(),returnTo:i??a.activeId??void 0};return n(r,e=>{let t=[...e.tabs],n=t.findIndex(e=>e.id===o);return n>=0?t[n]=s:t.splice(Math.max(0,t.findIndex(t=>t.id===e.activeId)+1),0,s),{open:!0,activeId:o,tabs:t}}),o},updateBrowserTitle:(e,r)=>{for(let[i,a]of Object.entries(t().panes))a.tabs.some(t=>t.id===e&&t.kind===`browser`&&t.title!==r)&&n(i,t=>({...t,tabs:t.tabs.map(t=>t.id===e?{...t,title:r.slice(0,200)}:t)}))},openFiles:(e=t().scope)=>{let r=t().panes[e]??d,i=r.tabs.find(e=>e.kind===`files`);if(i){t().activate(i.id,e);return}let a=r.tabs.find(e=>e.id===r.activeId&&e.kind===`home`),o=a?.id??crypto.randomUUID();n(e,e=>({open:!0,activeId:o,tabs:a?e.tabs.map(e=>e.id===o?{...e,kind:`files`,title:`Files`}:e):[...e.tabs,{id:o,kind:`files`,title:`Files`,visitedAt:Date.now()}]}))},setOpen:(e,r=t().scope)=>{if(e&&!t().panes[r]?.tabs.length){t().openTools(r);return}n(r,t=>({...t,open:e,activeId:t.activeId??t.tabs[0]?.id??null}))},activate:(e,r=t().scope)=>{let i=t().panes[r]?.tabs.find(t=>t.id===e);i?.kind===`phone`&&(s.getState().setDisplayMode(`docked`),s.getState().show(i.phoneSessionId,!0,/^[\da-f]{8}-[\da-f-]{27}$/i.test(r)?r:void 0)),n(r,t=>({...t,open:!!(e&&t.tabs.some(t=>t.id===e)),activeId:e&&t.tabs.some(t=>t.id===e)?e:t.activeId,tabs:t.tabs.map(t=>t.id===e?{...t,visitedAt:Date.now()}:t)}))},openFile:(e,r=t().scope)=>{let i=t().panes[r]??d,a=i.tabs.find(t=>t.kind===`file`&&(y(t)===y(e)||t.aliases?.includes(y(e)))),o=!a&&e.preview!==!1?i.tabs.find(e=>e.kind===`file`&&e.preview&&!t().fileStatus[e.id]):void 0,s=a?.id??crypto.randomUUID(),c={...a?.kind===`file`?a:{},...e,preview:a?.kind===`file`?a.preview===!0:e.preview!==!1,id:s,kind:`file`,title:e.path?.replace(/\\/g,`/`).split(`/`).pop()||e.attachment?.name||`File`,visitedAt:Date.now(),returnTo:a?.returnTo??(o?o.returnTo:i.activeId??void 0)};return n(r,e=>{let t=[...e.tabs],n=t.findIndex(e=>e.id===s);return n>=0?t[n]=c:o?t[t.findIndex(e=>e.id===o.id)]=c:t.splice(Math.max(0,t.findIndex(t=>t.id===e.activeId)+1),0,c),{open:!0,tabs:t,activeId:s}}),s},addSideChat:(e,t,r,i=!0)=>n(r,n=>{let r=`side:${e}`;if(n.tabs.some(e=>e.id===r))return i?{...n,open:!0,activeId:r}:n;let a=i?n.tabs.findIndex(e=>e.id===n.activeId&&e.kind===`home`):-1,o=[...n.tabs];return a>=0&&o.splice(a,1),o.splice(a>=0?a:Math.max(0,o.findIndex(e=>e.id===n.activeId)+1),0,{id:r,kind:`sidechat`,sideChatId:e,title:t,visitedAt:Date.now()}),{tabs:o,activeId:i?r:n.activeId,open:i||n.open}}),resolveFileIdentity:(e,r)=>{for(let[i,a]of Object.entries(t().panes)){let o=a.tabs.find(t=>t.kind===`file`&&t.id===e);if(!o||o.resourceId===r)continue;let s=a.tabs.find(t=>t.kind===`file`&&t.id!==e&&t.resourceId===r);n(i,n=>!s||t().fileStatus[e]?{...n,tabs:n.tabs.map(t=>t.id===e?{...t,resourceId:r}:t)}:{...n,activeId:n.activeId===e?s.id:n.activeId,tabs:n.tabs.filter(t=>t.id!==e).map(e=>e.id===s.id?{...s,preview:s.preview===!0&&o.preview===!0,aliases:[...new Set([...s.aliases??[],y(o)])],line:o.line??s.line}:e)})}},replaceSideChat:(e,t,r)=>n(r,n=>({...n,activeId:n.activeId===`side:${e}`?`side:${t}`:n.activeId,tabs:n.tabs.map(n=>n.id===`side:${e}`?{...n,id:`side:${t}`,kind:`sidechat`,sideChatId:t}:n)})),remove:(e,r=t().scope)=>n(r,t=>{let n=t.tabs.find(t=>t.id===e),r=t.tabs.filter(t=>t.id!==e),i=r.find(e=>e.id===n?.returnTo)??[...r].sort((e,t)=>t.visitedAt-e.visitedAt)[0];return{...t,open:t.open&&r.length>0,tabs:r,activeId:t.activeId===e?i?.id??null:t.activeId}}),setWidth:t=>{e({width:t});try{localStorage.setItem(`xopc:workspace-width`,String(t))}catch{}},setTreeWidth:n=>{e({treeWidth:Math.max(200,Math.min(320,n))});try{localStorage.setItem(`xopc:workspace-tree-width`,String(t().treeWidth))}catch{}},setTreeOpen:(t,n)=>e(t===`file`?{fileTreeOpen:n}:{sideTreeOpen:n}),reset:()=>{e({panes:{},fileStatus:{},notices:{},scope:`new`}),h(t())}}});i.subscribe((e,t)=>{e.baseUrl!==t.baseUrl||t.conversationId!==void 0&&e.conversationId!==t.conversationId?b.getState().reset():e.conversationId&&!t.conversationId&&b.setState({panes:p().panes})});var x=e(t(),1);function S(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(null),[c,u]=(0,x.useState)(null),d=(0,x.useCallback)(e=>{t(!0),u(e),a(null),s(null)},[]),f=(0,x.useCallback)(async e=>{if(!c||n)return null;r(!0),s(null);try{let t=await l({...c,...e});return a(t.payload),t.payload}catch(e){let t=e instanceof Error?e.message:String(e);return s(t),null}finally{r(!1)}},[n,c]),p=(0,x.useCallback)(()=>{a(null),s(null),r(!1),u(null)},[]);return{dialogOpen:e,loading:n,result:i,error:o,pendingParams:c,createShareLink:d,confirmShareLink:f,handleOpenChange:(0,x.useCallback)(e=>{t(e),e||p()},[p])}}var C=e(n(),1);function w(){return c()&&window.electronAPI?.platform===`darwin`}function T(){return c()&&window.electronAPI?.platform===`win32`}function E(){return T()?`windows-preview-viewport`:``}var D=r();function O({expanded:e,children:t}){let n=(0,x.useRef)(null),r=e?n.current?.closest(`.app-main-surface`)??document.querySelector(`.app-main-surface`):null,i=(0,D.jsx)(`div`,{"data-file-preview-expanded":e||void 0,"data-browser-occluder":e||void 0,className:o(`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-inset [&_.markdown-body_h1]:border-b-0! [&_.markdown-body_h2]:border-b-0!`,e&&(r?`absolute inset-0 z-[115]`:`fixed inset-0 z-[115] h-[100dvh] w-screen`),e&&!r&&E()),children:t});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{ref:n,hidden:!0,"aria-hidden":!0}),e?(0,C.createPortal)(i,r??document.body):i]})}export{S as a,T as i,E as n,d as o,w as r,b as s,O as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,p as a}from"./locale-store-CAZaC05J.js";import{t as o}from"./cn-0WouolD0.js";import{t as s}from"./phone-workspace-store-Dxp-KhFP.js";import{n as c}from"./electron-env-DHOGevH3.js";import{a as l}from"./shares-api-zegE8pSE.js";var u=`xopc:right-workspace:v1`,d={open:!1,tabs:[],activeId:null},f={panes:{},width:0,treeWidth:240,fileTreeOpen:!0,sideTreeOpen:!1};function p(){try{let e=JSON.parse(sessionStorage.getItem(u)||`null`);if(!e||e.version!==1||typeof e.panes!=`object`||!e.panes||e.identity!==i.getState().conversationId||e.gateway!==i.getState().baseUrl)return f;let t={};for(let[n,r]of Object.entries(e.panes)){let e=r;if(!e||!Array.isArray(e.tabs))continue;let i=e.tabs.filter(e=>e&&typeof e.id==`string`&&typeof e.title==`string`&&(e.kind===`file`&&typeof e.path==`string`||e.kind===`sidechat`&&typeof e.sideChatId==`string`||e.kind===`home`||e.kind===`files`));t[n]={open:e.open===!0&&i.length>0,tabs:i,activeId:i.some(t=>t.id===e.activeId)?e.activeId:i[0]?.id??null}}return{...f,panes:t}}catch{return f}}function m(e,t){try{let n=Number(localStorage.getItem(e));return n>0&&Number.isFinite(n)?n:t}catch{return t}}function h(e){try{let t=Object.fromEntries(Object.entries(e.panes).map(([e,t])=>[e,{...t,tabs:t.tabs.filter(e=>e.kind!==`browser`&&(e.kind!==`file`||!e.attachment)).map(e=>({...e}))}]));sessionStorage.setItem(u,JSON.stringify({version:1,identity:i.getState().conversationId,gateway:i.getState().baseUrl,panes:t}))}catch{}}var g=new WeakMap;function _(e){return e?e.id||e.uri?e.id||e.uri:(g.has(e)||g.set(e,crypto.randomUUID()),g.get(e)):``}function v(e){return e.replace(/\\/g,`/`).split(`/`).filter(e=>e!==`.`).join(`/`)}function y(e){let t=e.projectId?`project:${e.projectId}`:e.conversationId?`session:${e.conversationId}`:`agent:${e.agentId??``}`;return JSON.stringify([t,e.path?v(e.path):_(e.attachment)])}var b=a((e,t)=>{let n=(n,r)=>{e(e=>({panes:{...e.panes,[n]:r(e.panes[n]??d)}})),h(t())};return{...p(),width:m(`xopc:workspace-width`,0),treeWidth:m(`xopc:workspace-tree-width`,240),notices:{},setNotice:(t,n)=>e(e=>({notices:{...e.notices,[t]:n}})),fileStatus:{},setFileStatus:(n,r)=>{r&&t().keepFileOpen(n),e(e=>({fileStatus:{...e.fileStatus,[n]:r??``}}))},keepFileOpen:e=>{for(let[r,i]of Object.entries(t().panes))i.tabs.some(t=>t.id===e&&t.kind===`file`&&t.preview)&&n(r,t=>({...t,tabs:t.tabs.map(t=>t.id===e?{...t,preview:!1}:t)}))},scope:`new`,setScope:t=>e({scope:t}),migrateScope:(n,r)=>{let i=t().panes[n];if(!i||n===r)return;let a=t().panes[r]??d,o={...t().panes,[r]:{open:i.open||a.open,tabs:[...a.tabs,...i.tabs.filter(e=>!a.tabs.some(t=>t.id===e.id))],activeId:i.activeId??a.activeId}};delete o[n],e({panes:o,scope:t().scope===n?r:t().scope}),h(t())},openPhone:(e,t,r,i=!0,a=!0)=>{let o=`phone:${e}`;n(r,n=>({open:i||n.open,activeId:i?o:n.activeId,tabs:n.tabs.some(e=>e.id===o)?n.tabs.map(e=>e.id===o?{...e,title:t}:e):[...n.tabs,{id:o,kind:`phone`,phoneSessionId:e,title:t,visitedAt:Date.now()}]})),a&&s.getState().show(e,i,/^[\da-f]{8}-[\da-f-]{27}$/i.test(r)?r:void 0)},openTools:(e=t().scope)=>{let r=crypto.randomUUID();return n(e,e=>{let t=[...e.tabs];return t.splice(Math.max(0,t.findIndex(t=>t.id===e.activeId)+1),0,{id:r,kind:`home`,title:`New tab`,visitedAt:Date.now()}),{open:!0,tabs:t,activeId:r}}),r},openBrowser:(e,r=t().scope,i)=>{let a=t().panes[r]??d,o=a.tabs.find(e=>e.id===a.activeId&&e.kind===`home`)?.id??crypto.randomUUID(),s={id:o,kind:`browser`,title:`Browser`,initialUrl:e,visitedAt:Date.now(),returnTo:i??a.activeId??void 0};return n(r,e=>{let t=[...e.tabs],n=t.findIndex(e=>e.id===o);return n>=0?t[n]=s:t.splice(Math.max(0,t.findIndex(t=>t.id===e.activeId)+1),0,s),{open:!0,activeId:o,tabs:t}}),o},updateBrowserTitle:(e,r)=>{for(let[i,a]of Object.entries(t().panes))a.tabs.some(t=>t.id===e&&t.kind===`browser`&&t.title!==r)&&n(i,t=>({...t,tabs:t.tabs.map(t=>t.id===e?{...t,title:r.slice(0,200)}:t)}))},openFiles:(e=t().scope)=>{let r=t().panes[e]??d,i=r.tabs.find(e=>e.kind===`files`);if(i){t().activate(i.id,e);return}let a=r.tabs.find(e=>e.id===r.activeId&&e.kind===`home`),o=a?.id??crypto.randomUUID();n(e,e=>({open:!0,activeId:o,tabs:a?e.tabs.map(e=>e.id===o?{...e,kind:`files`,title:`Files`}:e):[...e.tabs,{id:o,kind:`files`,title:`Files`,visitedAt:Date.now()}]}))},setOpen:(e,r=t().scope)=>{if(e&&!t().panes[r]?.tabs.length){t().openTools(r);return}n(r,t=>({...t,open:e,activeId:t.activeId??t.tabs[0]?.id??null}))},activate:(e,r=t().scope)=>{let i=t().panes[r]?.tabs.find(t=>t.id===e);i?.kind===`phone`&&(s.getState().setDisplayMode(`docked`),s.getState().show(i.phoneSessionId,!0,/^[\da-f]{8}-[\da-f-]{27}$/i.test(r)?r:void 0)),n(r,t=>({...t,open:!!(e&&t.tabs.some(t=>t.id===e)),activeId:e&&t.tabs.some(t=>t.id===e)?e:t.activeId,tabs:t.tabs.map(t=>t.id===e?{...t,visitedAt:Date.now()}:t)}))},openFile:(e,r=t().scope)=>{let i=t().panes[r]??d,a=i.tabs.find(t=>t.kind===`file`&&(y(t)===y(e)||t.aliases?.includes(y(e)))),o=!a&&e.preview!==!1?i.tabs.find(e=>e.kind===`file`&&e.preview&&!t().fileStatus[e.id]):void 0,s=a?.id??crypto.randomUUID(),c={...a?.kind===`file`?a:{},...e,preview:a?.kind===`file`?a.preview===!0:e.preview!==!1,id:s,kind:`file`,title:e.path?.replace(/\\/g,`/`).split(`/`).pop()||e.attachment?.name||`File`,visitedAt:Date.now(),returnTo:a?.returnTo??(o?o.returnTo:i.activeId??void 0)};return n(r,e=>{let t=[...e.tabs],n=t.findIndex(e=>e.id===s);return n>=0?t[n]=c:o?t[t.findIndex(e=>e.id===o.id)]=c:t.splice(Math.max(0,t.findIndex(t=>t.id===e.activeId)+1),0,c),{open:!0,tabs:t,activeId:s}}),s},addSideChat:(e,t,r,i=!0)=>n(r,n=>{let r=`side:${e}`;if(n.tabs.some(e=>e.id===r))return i?{...n,open:!0,activeId:r}:n;let a=i?n.tabs.findIndex(e=>e.id===n.activeId&&e.kind===`home`):-1,o=[...n.tabs];return a>=0&&o.splice(a,1),o.splice(a>=0?a:Math.max(0,o.findIndex(e=>e.id===n.activeId)+1),0,{id:r,kind:`sidechat`,sideChatId:e,title:t,visitedAt:Date.now()}),{tabs:o,activeId:i?r:n.activeId,open:i||n.open}}),resolveFileIdentity:(e,r)=>{for(let[i,a]of Object.entries(t().panes)){let o=a.tabs.find(t=>t.kind===`file`&&t.id===e);if(!o||o.resourceId===r)continue;let s=a.tabs.find(t=>t.kind===`file`&&t.id!==e&&t.resourceId===r);n(i,n=>!s||t().fileStatus[e]?{...n,tabs:n.tabs.map(t=>t.id===e?{...t,resourceId:r}:t)}:{...n,activeId:n.activeId===e?s.id:n.activeId,tabs:n.tabs.filter(t=>t.id!==e).map(e=>e.id===s.id?{...s,preview:s.preview===!0&&o.preview===!0,aliases:[...new Set([...s.aliases??[],y(o)])],line:o.line??s.line}:e)})}},replaceSideChat:(e,t,r)=>n(r,n=>({...n,activeId:n.activeId===`side:${e}`?`side:${t}`:n.activeId,tabs:n.tabs.map(n=>n.id===`side:${e}`?{...n,id:`side:${t}`,kind:`sidechat`,sideChatId:t}:n)})),remove:(e,r=t().scope)=>n(r,t=>{let n=t.tabs.find(t=>t.id===e),r=t.tabs.filter(t=>t.id!==e),i=r.find(e=>e.id===n?.returnTo)??[...r].sort((e,t)=>t.visitedAt-e.visitedAt)[0];return{...t,open:t.open&&r.length>0,tabs:r,activeId:t.activeId===e?i?.id??null:t.activeId}}),setWidth:t=>{e({width:t});try{localStorage.setItem(`xopc:workspace-width`,String(t))}catch{}},setTreeWidth:n=>{e({treeWidth:Math.max(200,Math.min(320,n))});try{localStorage.setItem(`xopc:workspace-tree-width`,String(t().treeWidth))}catch{}},setTreeOpen:(t,n)=>e(t===`file`?{fileTreeOpen:n}:{sideTreeOpen:n}),reset:()=>{e({panes:{},fileStatus:{},notices:{},scope:`new`}),h(t())}}});i.subscribe((e,t)=>{e.baseUrl!==t.baseUrl||t.conversationId!==void 0&&e.conversationId!==t.conversationId?b.getState().reset():e.conversationId&&!t.conversationId&&b.setState({panes:p().panes})});var x=e(t(),1);function S(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(null),[c,u]=(0,x.useState)(null),d=(0,x.useCallback)(e=>{t(!0),u(e),a(null),s(null)},[]),f=(0,x.useCallback)(async e=>{if(!c||n)return null;r(!0),s(null);try{let t=await l({...c,...e});return a(t.payload),t.payload}catch(e){let t=e instanceof Error?e.message:String(e);return s(t),null}finally{r(!1)}},[n,c]),p=(0,x.useCallback)(()=>{a(null),s(null),r(!1),u(null)},[]);return{dialogOpen:e,loading:n,result:i,error:o,pendingParams:c,createShareLink:d,confirmShareLink:f,handleOpenChange:(0,x.useCallback)(e=>{t(e),e||p()},[p])}}var C=e(n(),1);function w(){return c()&&window.electronAPI?.platform===`darwin`}function T(){return c()&&window.electronAPI?.platform===`win32`}function E(){return T()?`windows-preview-viewport`:``}var D=r();function O({expanded:e,children:t}){let n=(0,x.useRef)(null),r=e?n.current?.closest(`.app-main-surface`)??document.querySelector(`.app-main-surface`):null,i=(0,D.jsx)(`div`,{"data-file-preview-expanded":e||void 0,"data-browser-occluder":e||void 0,className:o(`file-preview-surface flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden [&_.markdown-body_h1]:border-b-0! [&_.markdown-body_h2]:border-b-0!`,e&&(r?`absolute inset-0 z-[115]`:`fixed inset-0 z-[115] h-[100dvh] w-screen`),e&&!r&&E()),children:t});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{ref:n,hidden:!0,"aria-hidden":!0}),e?(0,C.createPortal)(i,r??document.body):i]})}export{S as a,T as i,E as n,d as o,w as r,b as s,O as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{i as r,o as i}from"./locale-store-B6OrWgY1.js";import{i as a,o}from"./vendor-swr-CdRzEUwF.js";var s=e(t(),1),c=n();function l(e){if(!(!e||typeof e!=`object`||!(`section`in e)))return e.section}function u(e){return l(e)===`skills`}function d(){return r(`/api/config`)}var f=null;async function p(){return f||(f=i(d()).finally(()=>{f=null}),f)}function m(e){let t=(0,c.c)(6),n;t[0]===e?n=t[1]:(n=e?d():null,t[0]=e,t[1]=n);let r=n,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let l=a(r,p,i),f,m;return t[3]===e?(f=t[4],m=t[5]):(f=()=>{if(!e)return;let t=d(),n=e=>{u(e.detail)||o(t)};return window.addEventListener(`config-reload`,n),()=>window.removeEventListener(`config-reload`,n)},m=[e],t[3]=e,t[4]=f,t[5]=m),(0,s.useEffect)(f,m),l}function h(){return o(d())}export{u as a,l as i,h as n,m as r,p as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{i as r,o as i}from"./locale-store-CAZaC05J.js";import{i as a,o}from"./vendor-swr-CdRzEUwF.js";var s=e(t(),1),c=n();function l(e){if(!(!e||typeof e!=`object`||!(`section`in e)))return e.section}function u(e){return l(e)===`skills`}function d(){return r(`/api/config`)}var f=null;async function p(){return f||(f=i(d()).finally(()=>{f=null}),f)}function m(e){let t=(0,c.c)(6),n;t[0]===e?n=t[1]:(n=e?d():null,t[0]=e,t[1]=n);let r=n,i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let l=a(r,p,i),f,m;return t[3]===e?(f=t[4],m=t[5]):(f=()=>{if(!e)return;let t=d(),n=e=>{u(e.detail)||o(t)};return window.addEventListener(`config-reload`,n),()=>window.removeEventListener(`config-reload`,n)},m=[e],t[3]=e,t[4]=f,t[5]=m),(0,s.useEffect)(f,m),l}function h(){return o(d())}export{u as a,l as i,h as n,m as r,p as t};