@xopcai/xopc 0.0.126 → 0.0.127

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 (191) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C70vgt60.js → agent-avatar-dicebear-CgGgO4OV.js} +1 -1
  4. package/dist/gateway/static/root/assets/agents-k59l7NMb.js +2 -0
  5. package/dist/gateway/static/root/assets/{app-management-settings-panel-D9-HW6cy.js → app-management-settings-panel-DeQsTsyy.js} +1 -1
  6. package/dist/gateway/static/root/assets/{appearance-settings-BHlahIDL.js → appearance-settings-BnHQW7Hv.js} +1 -1
  7. package/dist/gateway/static/root/assets/{apps-page-BdJ1eQg3.js → apps-page-BG9b4abG.js} +1 -1
  8. package/dist/gateway/static/root/assets/{archive-plugin-B-aoIt0w.js → archive-plugin-5NXT7Zqv.js} +1 -1
  9. package/dist/gateway/static/root/assets/{attachment-load-BD0G0FD5.js → attachment-load-DghwhYe0.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automation-suggestion-card-iJRVI7aZ.js → automation-suggestion-card-DYmESgwl.js} +1 -1
  11. package/dist/gateway/static/root/assets/automations-page-De8mVutL.js +4 -0
  12. package/dist/gateway/static/root/assets/{binary-plugins-B0mNlVSz.js → binary-plugins-DSbPKdWX.js} +1 -1
  13. package/dist/gateway/static/root/assets/{block-editor-CJY9Lu5G.js → block-editor-CoZ-_np-.js} +27 -27
  14. package/dist/gateway/static/root/assets/browser-settings-page-C_ZRa4LF.js +8 -0
  15. package/dist/gateway/static/root/assets/{capability-presets-api-Bgc8ag55.js → capability-presets-api-hny224j-.js} +1 -1
  16. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-B1nIi0TC.js → capability-presets-settings-panel-Drc0qLsw.js} +1 -1
  17. package/dist/gateway/static/root/assets/{channel-recipient-api-0sauApoC.js → channel-recipient-api-DAlOHxKJ.js} +1 -1
  18. package/dist/gateway/static/root/assets/channels-settings-CA20zBV9.js +1 -0
  19. package/dist/gateway/static/root/assets/connectors-page-qMyMB5te.js +2 -0
  20. package/dist/gateway/static/root/assets/desktop-pet-XG6Vb_fZ.js +1 -0
  21. package/dist/gateway/static/root/assets/desktop-pet-settings-npJ0Oh5p.js +1 -0
  22. package/dist/gateway/static/root/assets/desktop-pet-sprite-DqZ6fbIj.js +1 -0
  23. package/dist/gateway/static/root/assets/directory-picker-path-field-BR2ItBuf.js +1 -0
  24. package/dist/gateway/static/root/assets/dreaming-settings-CkUZ997f.js +3 -0
  25. package/dist/gateway/static/root/assets/{extension-debug-page-BbyczVZ3.js → extension-debug-page-Tl0f1rNv.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-page-DLN1I3DR.js → extension-page-Ck7QuwE3.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-settings-page-D9VGHmYJ.js → extension-settings-page-3RMhQtZ3.js} +1 -1
  28. package/dist/gateway/static/root/assets/{fetch-5V96dUz3.js → fetch-pg2ErdAk.js} +1 -1
  29. package/dist/gateway/static/root/assets/{gateway-config-api-BtIzObwp.js → gateway-config-api-DbG97ia2.js} +1 -1
  30. package/dist/gateway/static/root/assets/gateway-settings-B8cyqKk-.js +1 -0
  31. package/dist/gateway/static/root/assets/{gateway-startup-retry-DEMad2wt.js → gateway-startup-retry-Yh8h3hkj.js} +1 -1
  32. package/dist/gateway/static/root/assets/{goal-create-dialog-4PcF6Sh6.js → goal-create-dialog-DmeW7Zz3.js} +1 -1
  33. package/dist/gateway/static/root/assets/goal-detail-page-DrTyGbVD.js +1 -0
  34. package/dist/gateway/static/root/assets/{goals-config-api-CVN7-pdM.js → goals-config-api-CxCWGIBB.js} +1 -1
  35. package/dist/gateway/static/root/assets/goals-page-DV1bJhIh.js +2 -0
  36. package/dist/gateway/static/root/assets/{goals-settings-IYCH3-Pi.js → goals-settings-9DrfOkP5.js} +1 -1
  37. package/dist/gateway/static/root/assets/{heartbeat-settings-Cf_a2Bmz.js → heartbeat-settings-KaDpZrv0.js} +1 -1
  38. package/dist/gateway/static/root/assets/index-C2F0Clvm.js +256 -0
  39. package/dist/gateway/static/root/assets/index-COQSX5d_.css +1 -0
  40. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-lKTg6St7.js → keyboard-shortcuts-settings-CfQrt_Rb.js} +1 -1
  41. package/dist/gateway/static/root/assets/logs-page-C9dpiNTF.js +2 -0
  42. package/dist/gateway/static/root/assets/{markdown-split-Bv4k6iGJ.js → markdown-split-BwiMdCf_.js} +1 -1
  43. package/dist/gateway/static/root/assets/{media-plugins-Bbi8g3N8.js → media-plugins-DhoizyZv.js} +1 -1
  44. package/dist/gateway/static/root/assets/messages-DmnbiNxU.js +3 -0
  45. package/dist/gateway/static/root/assets/models-hub-panel-zdCdmBmH.js +2 -0
  46. package/dist/gateway/static/root/assets/notes-page-MpGeFfPt.js +1 -0
  47. package/dist/gateway/static/root/assets/notes-workbench-DYCM3yd2.js +2 -0
  48. package/dist/gateway/static/root/assets/{page-tabs-Cp395RYD.js → page-tabs-DDC2t4Z8.js} +1 -1
  49. package/dist/gateway/static/root/assets/{preview-open-alternatives-DqV5OM4m.js → preview-open-alternatives-BTmk-XDM.js} +1 -1
  50. package/dist/gateway/static/root/assets/project-detail-page-Cu0ElRnS.js +1 -0
  51. package/dist/gateway/static/root/assets/projects-page-DakNaUjZ.js +1 -0
  52. package/dist/gateway/static/root/assets/remote-access-hub-DYKjt7L9.js +1 -0
  53. package/dist/gateway/static/root/assets/{save-bar-controls-BItmzAzI.js → save-bar-controls-DqU-yKIh.js} +1 -1
  54. package/dist/gateway/static/root/assets/{schedule-field-BQ8IjjCn.js → schedule-field-CUttkoSB.js} +1 -1
  55. package/dist/gateway/static/root/assets/{schema-form-BRpD6x3d.js → schema-form-CVSQA9nI.js} +1 -1
  56. package/dist/gateway/static/root/assets/sessions-page-CcGHDsz1.js +1 -0
  57. package/dist/gateway/static/root/assets/settings-advanced-gate-CuFdeKNu.js +1 -0
  58. package/dist/gateway/static/root/assets/{settings-collapsible-section-BKSPQM4R.js → settings-collapsible-section-CK7ogS-P.js} +1 -1
  59. package/dist/gateway/static/root/assets/{settings-form-section-BmyfthNQ.js → settings-form-section-Bugp38Fa.js} +1 -1
  60. package/dist/gateway/static/root/assets/settings-page-0AJoUvxi.js +1 -0
  61. package/dist/gateway/static/root/assets/{settings-page-layout-Bls5tfbH.js → settings-page-layout-DBRWwdhh.js} +1 -1
  62. package/dist/gateway/static/root/assets/{setup-status-panel-kQEsTGAs.js → setup-status-panel-D6a_hEk7.js} +1 -1
  63. package/dist/gateway/static/root/assets/{share-preview-page-DbYZNAPb.js → share-preview-page-BtsuETKF.js} +1 -1
  64. package/dist/gateway/static/root/assets/shares-settings-CcEFT7S9.js +1 -0
  65. package/dist/gateway/static/root/assets/skill-reload-api-BcN_RuTD.js +1 -0
  66. package/dist/gateway/static/root/assets/skills-page-BbRZZZA5.js +2 -0
  67. package/dist/gateway/static/root/assets/{system-settings-panel-DKDAojWM.js → system-settings-panel-DJ6YuLqR.js} +1 -1
  68. package/dist/gateway/static/root/assets/{typed-models-lib-BCCV4Kkp.js → typed-models-lib-B0T7N8Km.js} +1 -1
  69. package/dist/gateway/static/root/assets/{use-channel-catalog-NBqg3iFY.js → use-channel-catalog-C6vrxdzZ.js} +1 -1
  70. package/dist/gateway/static/root/assets/{user-profile-settings-panel-suQ2x-LB.js → user-profile-settings-panel-DZ0nKMgj.js} +1 -1
  71. package/dist/gateway/static/root/assets/{utils-DPGVr3tS.js → utils-CehXcWAY.js} +1 -1
  72. package/dist/gateway/static/root/assets/voice-api-key-field-2QKflCx8.js +1 -0
  73. package/dist/gateway/static/root/assets/work-item-detail-page-DfJnuWq1.js +1 -0
  74. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BTkRVNAh.js → workflow-run-setup-panel-c4jeaohQ.js} +2 -2
  75. package/dist/gateway/static/root/assets/{workflow-start-dialog-DAImVtdO.js → workflow-start-dialog-ENRHjoqa.js} +1 -1
  76. package/dist/gateway/static/root/assets/workflows-page-BJwwFTm_.js +18 -0
  77. package/dist/gateway/static/root/index.html +5 -5
  78. package/dist/package.js +1 -1
  79. package/dist/src/agent/agent-instance-gateway.d.ts +5 -0
  80. package/dist/src/agent/agent-manager.d.ts +14 -0
  81. package/dist/src/agent/agent-manager.js +111 -2
  82. package/dist/src/agent/agent-manager.js.map +1 -1
  83. package/dist/src/agent/capabilities/definitions.d.ts +153 -0
  84. package/dist/src/agent/capabilities/definitions.js +156 -0
  85. package/dist/src/agent/capabilities/definitions.js.map +1 -0
  86. package/dist/src/agent/capabilities/index.d.ts +2 -0
  87. package/dist/src/agent/capabilities/index.js +3 -0
  88. package/dist/src/agent/capabilities/registry.d.ts +10 -0
  89. package/dist/src/agent/capabilities/registry.js +51 -0
  90. package/dist/src/agent/capabilities/registry.js.map +1 -0
  91. package/dist/src/agent/service/process-direct-one-shot.js +5 -3
  92. package/dist/src/agent/service/process-direct-one-shot.js.map +1 -1
  93. package/dist/src/agent/service/process-direct-streaming.js +4 -3
  94. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  95. package/dist/src/agent/service.d.ts +2 -0
  96. package/dist/src/agent/service.js +3 -0
  97. package/dist/src/agent/service.js.map +1 -1
  98. package/dist/src/agent/skills/parse-skill-metadata.js +9 -1
  99. package/dist/src/agent/skills/parse-skill-metadata.js.map +1 -1
  100. package/dist/src/agent/skills/skill-manager.d.ts +4 -0
  101. package/dist/src/agent/skills/skill-manager.js +17 -0
  102. package/dist/src/agent/skills/skill-manager.js.map +1 -1
  103. package/dist/src/agent/skills/types.d.ts +5 -0
  104. package/dist/src/agent/tools/desktop-pet-tool.d.ts +24 -0
  105. package/dist/src/agent/tools/desktop-pet-tool.js +90 -0
  106. package/dist/src/agent/tools/desktop-pet-tool.js.map +1 -0
  107. package/dist/src/agent/tools/factory.d.ts +2 -0
  108. package/dist/src/agent/tools/factory.js +17 -0
  109. package/dist/src/agent/tools/factory.js.map +1 -1
  110. package/dist/src/agent/tools/index.d.ts +1 -0
  111. package/dist/src/agent/tools/index.js +2 -1
  112. package/dist/src/automations/draft/automation-draft-service.js +1 -1
  113. package/dist/src/cli/commands/agent.js +2 -2
  114. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  115. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  116. package/dist/src/cli/commands/models.js +1 -1
  117. package/dist/src/cli/commands/onboard.js +1 -1
  118. package/dist/src/cli/commands/profile.js +1 -1
  119. package/dist/src/cli/commands/tunnel.js +1 -1
  120. package/dist/src/cli/commands/update.js +1 -1
  121. package/dist/src/cli/extension-cli-register.js +1 -1
  122. package/dist/src/config/index.js +1 -1
  123. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  124. package/dist/src/gateway/agent-builtin-tools.js +1 -0
  125. package/dist/src/gateway/agent-builtin-tools.js.map +1 -1
  126. package/dist/src/gateway/hono/routes/commands-skills.js +7 -0
  127. package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
  128. package/dist/src/gateway/hono/routes/lazy-bundles.js +2 -1
  129. package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
  130. package/dist/src/gateway/hono/routes/projects.js +28 -0
  131. package/dist/src/gateway/hono/routes/projects.js.map +1 -1
  132. package/dist/src/gateway/run-loop.js +1 -1
  133. package/dist/src/gateway/service/run-gateway-agent.js +6 -2
  134. package/dist/src/gateway/service/run-gateway-agent.js.map +1 -1
  135. package/dist/src/mcp/channel-bridge.js +1 -1
  136. package/dist/src/pets/factory.d.ts +25 -0
  137. package/dist/src/pets/factory.js +327 -0
  138. package/dist/src/pets/factory.js.map +1 -0
  139. package/dist/src/pets/manifest.d.ts +2 -0
  140. package/dist/src/pets/manifest.js +16 -0
  141. package/dist/src/pets/manifest.js.map +1 -0
  142. package/dist/src/pets/validator.d.ts +12 -0
  143. package/dist/src/pets/validator.js +175 -0
  144. package/dist/src/pets/validator.js.map +1 -0
  145. package/dist/src/projects/project-service.d.ts +2 -0
  146. package/dist/src/projects/project-service.js +6 -0
  147. package/dist/src/projects/project-service.js.map +1 -1
  148. package/dist/src/projects/project-store.d.ts +1 -0
  149. package/dist/src/projects/project-store.js +14 -7
  150. package/dist/src/projects/project-store.js.map +1 -1
  151. package/dist/src/projects/types.d.ts +2 -0
  152. package/dist/src/session/session-title.js +22 -2
  153. package/dist/src/session/session-title.js.map +1 -1
  154. package/dist/src/storage/sqlite/migrations/025_project_pinned_at.sql +5 -0
  155. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  156. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  157. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  158. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  159. package/dist/src/storage/sqlite/schema.js +1 -1
  160. package/package.json +1 -1
  161. package/skills/creative/hatch-pet/SKILL.md +63 -0
  162. package/dist/gateway/static/root/assets/agents-DRYVahI-.js +0 -2
  163. package/dist/gateway/static/root/assets/automations-page-D8hYQbkl.js +0 -4
  164. package/dist/gateway/static/root/assets/browser-settings-page-CiWEO-Iy.js +0 -8
  165. package/dist/gateway/static/root/assets/channels-settings-BddPdqVo.js +0 -1
  166. package/dist/gateway/static/root/assets/connectors-page-Ba2GDhSE.js +0 -2
  167. package/dist/gateway/static/root/assets/directory-picker-path-field-CiEc4KmY.js +0 -1
  168. package/dist/gateway/static/root/assets/dist-By6Rh2ee.js +0 -1
  169. package/dist/gateway/static/root/assets/dreaming-settings-4bvpk5wr.js +0 -3
  170. package/dist/gateway/static/root/assets/gateway-settings-KFsGGDhg.js +0 -1
  171. package/dist/gateway/static/root/assets/goal-detail-page-B482PSaG.js +0 -1
  172. package/dist/gateway/static/root/assets/goals-page-CUdgJuDn.js +0 -2
  173. package/dist/gateway/static/root/assets/index-CA2tR2vm.js +0 -256
  174. package/dist/gateway/static/root/assets/index-Ds3u0LOk.css +0 -1
  175. package/dist/gateway/static/root/assets/logs-page-BCporcNH.js +0 -2
  176. package/dist/gateway/static/root/assets/messages-C22hxE1N.js +0 -3
  177. package/dist/gateway/static/root/assets/models-hub-panel-D68Pyow7.js +0 -2
  178. package/dist/gateway/static/root/assets/notes-page-CuUMOiyv.js +0 -1
  179. package/dist/gateway/static/root/assets/notes-workbench-Dx2N5zTk.js +0 -2
  180. package/dist/gateway/static/root/assets/project-detail-page-sB8AzZi3.js +0 -1
  181. package/dist/gateway/static/root/assets/projects-page-LBnJqWK2.js +0 -1
  182. package/dist/gateway/static/root/assets/remote-access-hub-Dbj0o6SC.js +0 -1
  183. package/dist/gateway/static/root/assets/sessions-page-DhDZKspB.js +0 -1
  184. package/dist/gateway/static/root/assets/settings-advanced-gate-BvXLMNL6.js +0 -1
  185. package/dist/gateway/static/root/assets/settings-page-Cfm9UxAr.js +0 -1
  186. package/dist/gateway/static/root/assets/shares-settings-BtR4B0kn.js +0 -1
  187. package/dist/gateway/static/root/assets/skill-reload-api-CJNVOWoK.js +0 -1
  188. package/dist/gateway/static/root/assets/skills-page-DcWDHrt3.js +0 -2
  189. package/dist/gateway/static/root/assets/voice-api-key-field-DaJASKFP.js +0 -1
  190. package/dist/gateway/static/root/assets/work-item-detail-page-BrCZpAWh.js +0 -1
  191. package/dist/gateway/static/root/assets/workflows-page-vyJ8wSXm.js +0 -18
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-C22hxE1N.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-5V96dUz3.js";import{a as d,i as f}from"./vendor-swr-BIWyz7Rc.js";import{Aa as p,Da as m,Ea as h,Gn as g,Hc as _,Jo as v,Lc as y,Ma as b,Oa as x,Os as S,Qr as C,To as w,Tt as T,Wo as E,aa as D,ca as O,fc as k,fl as A,fo as j,gs as M,ja as N,ka as P,la as F,mo as I,oa as L,os as R,sa as z,sl as B,tl as V}from"./index-CA2tR2vm.js";import{t as H}from"./page-tabs-Cp395RYD.js";var U=e(t(),1),W=n();function G(e){return e===`builtin`||e===`user`?e:`marketplace`}async function K(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 ee(e){let t=await u(c(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function q(e){let t=await u(c(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function J(e){let t=await u(c(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function Y(e){let t=await u(c(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var X=r();function Z(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var te={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function ne({className:e}){let t=a(o(e=>e.language)).appsPage,n=s(e=>!!e.token),r=L(),{mutate:u}=d(),[p,m]=(0,U.useReducer)(T,te),{q:h,debounced:_,detailPkg:b,rowBusy:x,actionError:C,restartHint:E}=p,D=n?`marketplace-${_}`:null;(0,U.useEffect)(()=>{let e=window.setTimeout(()=>m({type:`patch`,patch:{debounced:h.trim()}}),300);return()=>window.clearTimeout(e)},[h]);let{data:O,isLoading:k,error:A}=f(D,async()=>l(_.length>0?c(`/api/marketplace?q=${encodeURIComponent(_)}`):c(`/api/marketplace`)),{revalidateOnFocus:!1}),j=(0,U.useCallback)(()=>{u(`gateway-extensions-list`),g()},[u]),N=(0,U.useCallback)(async(e,n)=>{m({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await q({name:e,overwrite:n});j(),r.requiresGatewayRestart&&m({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw m({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{m({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,j]),P=(0,U.useCallback)(async e=>{m({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await Y(e);j(),n.requiresGatewayRestart&&m({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw m({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{m({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,j]),F=O?.extensions??[];return(0,X.jsxs)(`div`,{className:i(`flex flex-col gap-4`,e),children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(v,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:h,onChange:e=>m({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),A?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:A instanceof Error?A.message:t.marketplaceLoadFailed}):null,C?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null,E?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:E}):null,k&&!O?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-3`,children:F.length===0?(0,X.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):F.map(e=>{let n=Z(r,e.id),a=x===e.id;return(0,X.jsx)(`li`,{className:`list-none`,children:(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>m({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),m({type:`patch`,patch:{detailPkg:e.id}}))},className:i(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl bg-surface-panel p-4 text-left shadow-surface`,`transition-[transform,background-color,box-shadow] duration-150 ease-out`,`hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,X.jsx)(y,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,X.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,X.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,X.jsx)(M,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,X.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,X.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,X.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&P(e.id).catch(()=>{})},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[a?(0,X.jsx)(S,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(w,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,X.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{N(e.id,!1).catch(()=>{})},className:i(`inline-flex w-full items-center justify-center rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white`,`shadow-surface transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:pointer-events-none disabled:opacity-50`),children:[a?(0,X.jsx)(S,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),b?(0,X.jsx)(re,{packageName:b,copy:t,extensions:r,onClose:()=>m({type:`patch`,patch:{detailPkg:null}}),onInstall:N,onUninstall:P}):null]})}function re(e){let t=(0,W.c)(61),{packageName:n,copy:r,extensions:a,onClose:o,onInstall:c,onUninstall:l}=e,[u,d]=(0,U.useState)(!1),m=s(se)?`ext-mp-detail-${n}`:null,g;t[0]===n?g=t[1]:(g=async()=>ee(n),t[0]=n,t[1]=g);let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!1},t[2]=_):_=t[2];let{data:v,error:y,isLoading:b}=f(m,g,_),T;t[3]!==a||t[4]!==n?(T=Z(a,n),t[3]=a,t[4]=n,t[5]=T):T=t[5];let E=T,D=E===`user`,O;t[6]!==r.marketplaceNoReadme||t[7]!==v?(O=v?.readme?.trim()||(v?.description?.trim()?`### ${v.name}\n\n${v.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=v,t[8]=O):O=t[8];let k=O,A;t[9]===o?A=t[10]:(A=e=>!e&&o(),t[9]=o,t[10]=A);let j;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,X.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=j):j=t[11];let M;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(V,{className:`size-5`}),t[12]=M):M=t[12];let F;t[13]!==r.detailBack||t[14]!==o?(F=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:M}),t[13]=r.detailBack,t[14]=o,t[15]=F):F=t[15];let L;t[16]===r.marketplaceDetailTitle?L=t[17]:(L=(0,X.jsx)(N,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=L);let R;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,X.jsx)(I,{className:`size-5`}),t[18]=R):R=t[18];let z;t[19]!==r.detailClose||t[20]!==o?(z=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:R}),t[19]=r.detailClose,t[20]=o,t[21]=z):z=t[21];let H;t[22]!==z||t[23]!==F||t[24]!==L?(H=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[F,L,z]}),t[22]=z,t[23]=F,t[24]=L,t[25]=H):H=t[25];let G;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==v||t[32]!==y||t[33]!==b||t[34]!==k?(G=b&&!v?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):y?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):v?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:v.name}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,X.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:v.id})}),(0,X.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,X.jsx)(`dd`,{children:v.author.username})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,X.jsx)(`dd`,{children:v.latestVersion.version})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,X.jsx)(`dd`,{children:v.downloads})]})]}),v.readme?.trim()?(0,X.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,X.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,X.jsx)(C,{content:k})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=v,t[32]=y,t[33]=b,t[34]=k,t[35]=G):G=t[35];let K;t[36]===G?K=t[37]:(K=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:G}),t[36]=G,t[37]=K);let q;t[38]!==u||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==v||t[47]!==E||t[48]!==o||t[49]!==c||t[50]!==l||t[51]!==n||t[52]!==D?(q=v?(0,X.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:E===`bundled`?(0,X.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,X.jsx)(B,{to:`/apps?tab=builtin`,onClick:o,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{D&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),c(n,D).catch(ae).finally(()=>d(!1)))},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[u?(0,X.jsx)(S,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,D?r.marketplaceReinstall:r.marketplaceInstall]}),D?(0,X.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),l(n).then(()=>o()).catch(ie).finally(()=>d(!1)))},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,X.jsx)(w,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=u,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=v,t[47]=E,t[48]=o,t[49]=c,t[50]=l,t[51]=n,t[52]=D,t[53]=q):q=t[53];let J;t[54]!==H||t[55]!==K||t[56]!==q?(J=(0,X.jsxs)(P,{children:[j,(0,X.jsxs)(h,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:oe,children:[H,K,q]})]}),t[54]=H,t[55]=K,t[56]=q,t[57]=J):J=t[57];let Y;return t[58]!==J||t[59]!==A?(Y=(0,X.jsx)(p,{defaultOpen:!0,onOpenChange:A,children:J}),t[58]=J,t[59]=A,t[60]=Y):Y=t[60],Y}function ie(){}function ae(){}function oe(e){return e.preventDefault()}function se(e){return!!e.token}function ce(){let e=o(e=>e.language),t=a(e),n=b(e=>e.setPageHeader),r=b(e=>e.clearPageHeader),i=L(),s=z(),[c,l]=A(),u=G(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,U.useState)(u),[m,h]=(0,U.useState)(d),[g,_]=(0,U.useState)(null),y=c.toString(),x=(0,U.useRef)(y);if(x.current!==y){x.current=y;let e=G(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,U.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let S=(0,U.useMemo)(()=>i.filter(e=>e.source===`bundled`),[i]),C=(0,U.useMemo)(()=>i.filter(e=>e.source!==`bundled`),[i]),w=f===`builtin`?S:C,T=(0,U.useMemo)(()=>{let t=m.trim().toLowerCase(),n=w;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[w,m,e]);if((0,U.useEffect)(()=>{_(e=>{if(!e)return e;let t=i.find(t=>t.id===e.id);return t?Q(e)===Q(t)&&e.active===t.active?e:t:null})},[i]),(0,U.useLayoutEffect)(()=>(n({startExtra:null,main:(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.appsPage.title})}),end:null}),()=>r()),[r,t.appsPage.title,n]),s&&f!==`marketplace`)return(0,X.jsx)(me,{});let E=f!==`marketplace`&&w.length>0;return(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,X.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base px-3 py-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsx)(H,{items:[{id:`marketplace`,label:t.appsPage.tabMarketplace},{id:`builtin`,label:t.appsPage.tabBuiltin,count:S.length},{id:`user`,label:t.appsPage.tabUser,count:C.length}],activeTab:f,onChange:p,ariaLabel:t.appsPage.appsNavAria,tabIdPrefix:`apps-tab`,panelIdPrefix:`apps-panel`,className:`flex-wrap`}),E?(0,X.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,X.jsx)(v,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:t.appsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),f===`marketplace`?(0,X.jsx)(ne,{}):f===`builtin`&&S.length===0?(0,X.jsx)(ge,{message:t.appsPage.emptyBuiltin}):f===`user`&&C.length===0?(0,X.jsx)(ge,{message:t.appsPage.emptyUser}):T.length===0?(0,X.jsx)(`p`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-3 py-8 text-center text-sm text-fg-muted shadow-surface sm:px-5 xl:px-6`,children:t.appsPage.noSearchResults}):(0,X.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:T.map(e=>(0,X.jsx)(fe,{extension:e,copy:t.appsPage,showSourceBadge:f===`user`,onOpen:()=>_(e)},e.id))})]}),g?(0,X.jsx)(pe,{extension:g,copy:t.appsPage,onClose:()=>_(null)},g.id):null]})}function Q(e){return e.activationEligible??e.active}function le(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function ue(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function de(e,t){let n=Q(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function fe(e){let t=(0,W.c)(45),{extension:n,copy:r,showSourceBadge:a,onOpen:o}=e,s;t[0]===n?s=t[1]:(s=Q(n),t[0]=n,t[1]=s);let c=s,l=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`group flex w-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=u):u=t[2];let d=n.name||n.id,f;t[3]===d?f=t[4]:(f=d.charAt(0).toUpperCase(),t[3]=d,t[4]=f);let p;t[5]===f?p=t[6]:(p=(0,X.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:f}),t[5]=f,t[6]=p);let m;t[7]===n.name?m=t[8]:(m=(0,X.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=m);let h;t[9]===n.version?h=t[10]:(h=n.version?(0,X.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=h);let g;t[11]!==m||t[12]!==h?(g=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[11]=m,t[12]=h,t[13]=g):g=t[13];let v;t[14]!==r.statusEnabled||t[15]!==c?(v=c?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,X.jsx)(_,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,X.jsx)(R,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=c,t[16]=v):v=t[16];let y;t[17]!==g||t[18]!==v?(y=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[g,v]}),t[17]=g,t[18]=v,t[19]=y):y=t[19];let b;t[20]!==r.cardNoDescription||t[21]!==n.description?(b=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=b):b=t[22];let x;t[23]===b?x=t[24]:(x=(0,X.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:b}),t[23]=b,t[24]=x);let S=n.hasUi?r.badgeKindUi:r.badgeKindBackend,C;t[25]!==S||t[26]!==l?(C=(0,X.jsx)(`span`,{title:l,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:S}),t[25]=S,t[26]=l,t[27]=C):C=t[27];let w;t[28]!==r||t[29]!==n||t[30]!==a?(w=n.source===`bundled`?(0,X.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):a?(0,X.jsx)(`span`,{title:le(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:ue(n,r)}):null,t[28]=r,t[29]=n,t[30]=a,t[31]=w):w=t[31];let T;t[32]!==C||t[33]!==w?(T=(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[C,w]}),t[32]=C,t[33]=w,t[34]=T):T=t[34];let E;t[35]!==y||t[36]!==x||t[37]!==T?(E=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[y,x,T]}),t[35]=y,t[36]=x,t[37]=T,t[38]=E):E=t[38];let D;t[39]!==E||t[40]!==p?(D=(0,X.jsxs)(`div`,{className:`flex gap-3`,children:[p,E]}),t[39]=E,t[40]=p,t[41]=D):D=t[41];let O;return t[42]!==o||t[43]!==D?(O=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:u,children:D}),t[42]=o,t[43]=D,t[44]=O):O=t[44],O}function pe({extension:e,copy:t,onClose:n}){let{mutate:r}=d(),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(!1),f=e.activationEligible===!0,_=(0,U.useCallback)(async()=>{if(e.source===`bundled`){c(null),u(!1),o(!0);try{let{requiresGatewayRestart:t}=await J({extensionId:e.id,enabled:!f});await r(`gateway-extensions-list`),g(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{o(!1)}}},[f,t.builtinToggleFailed,e.id,e.source,r]),v=e.ui?.contributions?.pages??[],y=e.ui?.contributions?.settingsPanels??[],b=e.ui?.contributions?.chatWidgets??[],C=e.ui?.contributions?.sidebarPanels??[],w=v.find(e=>e.showInNav)??v[0],T=y[0],A=w?D(e.id,w):null,M=T?`/settings/ext/${e.id}/${T.id}`:e.hasConfigSchema||O(e)?`/settings/ext/${e.id}`:null;return(0,X.jsx)(p,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,X.jsxs)(P,{children:[(0,X.jsx)(x,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,X.jsxs)(h,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,X.jsx)(V,{className:`size-5`})}),(0,X.jsx)(N,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,X.jsxs)(m,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,X.jsx)(I,{className:`size-5`})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,X.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,X.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,le(e,t)]}),e.version?(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,X.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:de(e,t)}),e.source===`bundled`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,X.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,X.jsx)(j,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void _(),className:`shrink-0 py-1.5 text-xs`,children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(S,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):f?t.builtinToggleDisable:t.builtinToggleEnable})]}),s?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:s}):null,l?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,X.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(v.length>0||y.length>0||b.length>0)?(0,X.jsxs)(`section`,{className:`mt-8`,children:[(0,X.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,X.jsx)($,{template:t.badgePages,count:v.length,hidden:v.length===0}),(0,X.jsx)($,{template:t.badgeSettings,count:y.length,hidden:y.length===0}),(0,X.jsx)($,{template:t.badgeWidgets,count:b.length,hidden:b.length===0}),(0,X.jsx)($,{template:t.badgeSidebar,count:C.length,hidden:C.length===0})]})]}):null,F(e)&&(A||M)?(0,X.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[A?(0,X.jsxs)(B,{to:A,onClick:n,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,X.jsx)(k,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,M?(0,X.jsxs)(B,{to:M,onClick:n,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,X.jsx)(E,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,X.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function $(e){let t=(0,W.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,X.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function me(){let e=(0,W.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,X.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,X.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,X.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,X.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(he)})]})}),e[4]=a):a=e[4],a}function he(e){return(0,X.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge-subtle bg-surface-base shadow-surface`},e)}function ge(e){let t=(0,W.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-edge-subtle bg-surface-base px-4 py-12 text-center shadow-surface`,children:(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ce as AppsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DmnbiNxU.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-pg2ErdAk.js";import{a as d,i as f}from"./vendor-swr-BIWyz7Rc.js";import{Ba as p,Dc as m,Do as h,Dt as g,El as _,Ga as v,Ha as y,To as b,Ua as x,Us as S,Va as C,Wa as w,Zc as T,_a as E,ba as D,bs as O,cs as k,hl as A,is as j,js as M,nl as N,oi as P,qn as F,va as I,xa as L,xl as R,ya as z,za as B,zo as V}from"./index-C2F0Clvm.js";import{t as H}from"./page-tabs-DDC2t4Z8.js";var U=e(t(),1),W=n();function G(e){return e===`builtin`||e===`user`?e:`marketplace`}async function K(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 ee(e){let t=await u(c(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function q(e){let t=await u(c(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function J(e){let t=await u(c(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function Y(e){let t=await u(c(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var X=r();function Z(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var te={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function ne({className:e}){let t=a(o(e=>e.language)).appsPage,n=s(e=>!!e.token),r=I(),{mutate:u}=d(),[p,m]=(0,U.useReducer)(g,te),{q:h,debounced:_,detailPkg:v,rowBusy:y,actionError:b,restartHint:x}=p,C=n?`marketplace-${_}`:null;(0,U.useEffect)(()=>{let e=window.setTimeout(()=>m({type:`patch`,patch:{debounced:h.trim()}}),300);return()=>window.clearTimeout(e)},[h]);let{data:w,isLoading:E,error:D}=f(C,async()=>l(_.length>0?c(`/api/marketplace?q=${encodeURIComponent(_)}`):c(`/api/marketplace`)),{revalidateOnFocus:!1}),O=(0,U.useCallback)(()=>{u(`gateway-extensions-list`),F()},[u]),A=(0,U.useCallback)(async(e,n)=>{m({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await q({name:e,overwrite:n});O(),r.requiresGatewayRestart&&m({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw m({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{m({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,O]),j=(0,U.useCallback)(async e=>{m({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await Y(e);O(),n.requiresGatewayRestart&&m({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw m({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{m({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,O]),N=w?.extensions??[];return(0,X.jsxs)(`div`,{className:i(`flex flex-col gap-4`,e),children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(k,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:h,onChange:e=>m({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),D?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:D instanceof Error?D.message:t.marketplaceLoadFailed}):null,b?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null,x?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:x}):null,E&&!w?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-3`,children:N.length===0?(0,X.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):N.map(e=>{let n=Z(r,e.id),a=y===e.id;return(0,X.jsx)(`li`,{className:`list-none`,children:(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>m({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),m({type:`patch`,patch:{detailPkg:e.id}}))},className:i(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl bg-surface-panel p-4 text-left shadow-surface`,`transition-[transform,background-color,box-shadow] duration-150 ease-out`,`hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,X.jsx)(T,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,X.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,X.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,X.jsx)(M,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,X.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,X.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,X.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&j(e.id).catch(()=>{})},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[a?(0,X.jsx)(S,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(V,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,X.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{A(e.id,!1).catch(()=>{})},className:i(`inline-flex w-full items-center justify-center rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white`,`shadow-surface transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:pointer-events-none disabled:opacity-50`),children:[a?(0,X.jsx)(S,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),v?(0,X.jsx)(re,{packageName:v,copy:t,extensions:r,onClose:()=>m({type:`patch`,patch:{detailPkg:null}}),onInstall:A,onUninstall:j}):null]})}function re(e){let t=(0,W.c)(61),{packageName:n,copy:r,extensions:a,onClose:o,onInstall:c,onUninstall:l}=e,[u,d]=(0,U.useState)(!1),p=s(se)?`ext-mp-detail-${n}`:null,m;t[0]===n?m=t[1]:(m=async()=>ee(n),t[0]=n,t[1]=m);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},t[2]=g):g=t[2];let{data:_,error:v,isLoading:b}=f(p,m,g),T;t[3]!==a||t[4]!==n?(T=Z(a,n),t[3]=a,t[4]=n,t[5]=T):T=t[5];let E=T,D=E===`user`,O;t[6]!==r.marketplaceNoReadme||t[7]!==_?(O=_?.readme?.trim()||(_?.description?.trim()?`### ${_.name}\n\n${_.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=_,t[8]=O):O=t[8];let k=O,j;t[9]===o?j=t[10]:(j=e=>!e&&o(),t[9]=o,t[10]=j);let M;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=M):M=t[11];let N;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.jsx)(A,{className:`size-5`}),t[12]=N):N=t[12];let F;t[13]!==r.detailBack||t[14]!==o?(F=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:N}),t[13]=r.detailBack,t[14]=o,t[15]=F):F=t[15];let I;t[16]===r.marketplaceDetailTitle?I=t[17]:(I=(0,X.jsx)(w,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=I);let L;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,X.jsx)(h,{className:`size-5`}),t[18]=L):L=t[18];let z;t[19]!==r.detailClose||t[20]!==o?(z=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:L}),t[19]=r.detailClose,t[20]=o,t[21]=z):z=t[21];let H;t[22]!==z||t[23]!==F||t[24]!==I?(H=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[F,I,z]}),t[22]=z,t[23]=F,t[24]=I,t[25]=H):H=t[25];let G;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==_||t[32]!==v||t[33]!==b||t[34]!==k?(G=b&&!_?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):v?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):_?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:_.name}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,X.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:_.id})}),(0,X.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,X.jsx)(`dd`,{children:_.author.username})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,X.jsx)(`dd`,{children:_.latestVersion.version})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,X.jsx)(`dd`,{children:_.downloads})]})]}),_.readme?.trim()?(0,X.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,X.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,X.jsx)(P,{content:k})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=_,t[32]=v,t[33]=b,t[34]=k,t[35]=G):G=t[35];let K;t[36]===G?K=t[37]:(K=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:G}),t[36]=G,t[37]=K);let q;t[38]!==u||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==_||t[47]!==E||t[48]!==o||t[49]!==c||t[50]!==l||t[51]!==n||t[52]!==D?(q=_?(0,X.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:E===`bundled`?(0,X.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,X.jsx)(R,{to:`/apps?tab=builtin`,onClick:o,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{D&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),c(n,D).catch(ae).finally(()=>d(!1)))},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[u?(0,X.jsx)(S,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,D?r.marketplaceReinstall:r.marketplaceInstall]}),D?(0,X.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),l(n).then(()=>o()).catch(ie).finally(()=>d(!1)))},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,X.jsx)(V,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=u,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=_,t[47]=E,t[48]=o,t[49]=c,t[50]=l,t[51]=n,t[52]=D,t[53]=q):q=t[53];let J;t[54]!==H||t[55]!==K||t[56]!==q?(J=(0,X.jsxs)(y,{children:[M,(0,X.jsxs)(B,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:oe,children:[H,K,q]})]}),t[54]=H,t[55]=K,t[56]=q,t[57]=J):J=t[57];let Y;return t[58]!==J||t[59]!==j?(Y=(0,X.jsx)(x,{defaultOpen:!0,onOpenChange:j,children:J}),t[58]=J,t[59]=j,t[60]=Y):Y=t[60],Y}function ie(){}function ae(){}function oe(e){return e.preventDefault()}function se(e){return!!e.token}function ce(){let e=o(e=>e.language),t=a(e),n=v(e=>e.setPageHeader),r=v(e=>e.clearPageHeader),i=I(),s=z(),[c,l]=_(),u=G(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,U.useState)(u),[m,h]=(0,U.useState)(d),[g,y]=(0,U.useState)(null),b=c.toString(),x=(0,U.useRef)(b);if(x.current!==b){x.current=b;let e=G(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,U.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let S=(0,U.useMemo)(()=>i.filter(e=>e.source===`bundled`),[i]),C=(0,U.useMemo)(()=>i.filter(e=>e.source!==`bundled`),[i]),w=f===`builtin`?S:C,T=(0,U.useMemo)(()=>{let t=m.trim().toLowerCase(),n=w;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[w,m,e]);if((0,U.useEffect)(()=>{y(e=>{if(!e)return e;let t=i.find(t=>t.id===e.id);return t?Q(e)===Q(t)&&e.active===t.active?e:t:null})},[i]),(0,U.useLayoutEffect)(()=>(n({startExtra:null,main:(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.appsPage.title})}),end:null}),()=>r()),[r,t.appsPage.title,n]),s&&f!==`marketplace`)return(0,X.jsx)(me,{});let E=f!==`marketplace`&&w.length>0;return(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,X.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base px-3 py-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsx)(H,{items:[{id:`marketplace`,label:t.appsPage.tabMarketplace},{id:`builtin`,label:t.appsPage.tabBuiltin,count:S.length},{id:`user`,label:t.appsPage.tabUser,count:C.length}],activeTab:f,onChange:p,ariaLabel:t.appsPage.appsNavAria,tabIdPrefix:`apps-tab`,panelIdPrefix:`apps-panel`,className:`flex-wrap`}),E?(0,X.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,X.jsx)(k,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:t.appsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),f===`marketplace`?(0,X.jsx)(ne,{}):f===`builtin`&&S.length===0?(0,X.jsx)(ge,{message:t.appsPage.emptyBuiltin}):f===`user`&&C.length===0?(0,X.jsx)(ge,{message:t.appsPage.emptyUser}):T.length===0?(0,X.jsx)(`p`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-3 py-8 text-center text-sm text-fg-muted shadow-surface sm:px-5 xl:px-6`,children:t.appsPage.noSearchResults}):(0,X.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:T.map(e=>(0,X.jsx)(fe,{extension:e,copy:t.appsPage,showSourceBadge:f===`user`,onOpen:()=>y(e)},e.id))})]}),g?(0,X.jsx)(pe,{extension:g,copy:t.appsPage,onClose:()=>y(null)},g.id):null]})}function Q(e){return e.activationEligible??e.active}function le(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function ue(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function de(e,t){let n=Q(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function fe(e){let t=(0,W.c)(45),{extension:n,copy:r,showSourceBadge:a,onOpen:o}=e,s;t[0]===n?s=t[1]:(s=Q(n),t[0]=n,t[1]=s);let c=s,l=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`group flex w-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=u):u=t[2];let d=n.name||n.id,f;t[3]===d?f=t[4]:(f=d.charAt(0).toUpperCase(),t[3]=d,t[4]=f);let p;t[5]===f?p=t[6]:(p=(0,X.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:f}),t[5]=f,t[6]=p);let m;t[7]===n.name?m=t[8]:(m=(0,X.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=m);let h;t[9]===n.version?h=t[10]:(h=n.version?(0,X.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=h);let g;t[11]!==m||t[12]!==h?(g=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==r.statusEnabled||t[15]!==c?(_=c?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,X.jsx)(N,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,X.jsx)(O,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=c,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;t[20]!==r.cardNoDescription||t[21]!==n.description?(y=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=y):y=t[22];let b;t[23]===y?b=t[24]:(b=(0,X.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:y}),t[23]=y,t[24]=b);let x=n.hasUi?r.badgeKindUi:r.badgeKindBackend,S;t[25]!==x||t[26]!==l?(S=(0,X.jsx)(`span`,{title:l,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:x}),t[25]=x,t[26]=l,t[27]=S):S=t[27];let C;t[28]!==r||t[29]!==n||t[30]!==a?(C=n.source===`bundled`?(0,X.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):a?(0,X.jsx)(`span`,{title:le(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:ue(n,r)}):null,t[28]=r,t[29]=n,t[30]=a,t[31]=C):C=t[31];let w;t[32]!==S||t[33]!==C?(w=(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[S,C]}),t[32]=S,t[33]=C,t[34]=w):w=t[34];let T;t[35]!==v||t[36]!==b||t[37]!==w?(T=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,b,w]}),t[35]=v,t[36]=b,t[37]=w,t[38]=T):T=t[38];let E;t[39]!==T||t[40]!==p?(E=(0,X.jsxs)(`div`,{className:`flex gap-3`,children:[p,T]}),t[39]=T,t[40]=p,t[41]=E):E=t[41];let D;return t[42]!==o||t[43]!==E?(D=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:u,children:E}),t[42]=o,t[43]=E,t[44]=D):D=t[44],D}function pe({extension:e,copy:t,onClose:n}){let{mutate:r}=d(),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(!1),f=e.activationEligible===!0,g=(0,U.useCallback)(async()=>{if(e.source===`bundled`){c(null),u(!1),o(!0);try{let{requiresGatewayRestart:t}=await J({extensionId:e.id,enabled:!f});await r(`gateway-extensions-list`),F(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{o(!1)}}},[f,t.builtinToggleFailed,e.id,e.source,r]),_=e.ui?.contributions?.pages??[],v=e.ui?.contributions?.settingsPanels??[],T=e.ui?.contributions?.chatWidgets??[],O=e.ui?.contributions?.sidebarPanels??[],k=_.find(e=>e.showInNav)??_[0],M=v[0],N=k?E(e.id,k):null,P=M?`/settings/ext/${e.id}/${M.id}`:e.hasConfigSchema||D(e)?`/settings/ext/${e.id}`:null;return(0,X.jsx)(x,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,X.jsxs)(y,{children:[(0,X.jsx)(C,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,X.jsxs)(B,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,X.jsx)(A,{className:`size-5`})}),(0,X.jsx)(w,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,X.jsxs)(p,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,X.jsx)(h,{className:`size-5`})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,X.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,X.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,le(e,t)]}),e.version?(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,X.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:de(e,t)}),e.source===`bundled`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,X.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,X.jsx)(b,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void g(),className:`shrink-0 py-1.5 text-xs`,children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(S,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):f?t.builtinToggleDisable:t.builtinToggleEnable})]}),s?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:s}):null,l?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,X.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(_.length>0||v.length>0||T.length>0)?(0,X.jsxs)(`section`,{className:`mt-8`,children:[(0,X.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,X.jsx)($,{template:t.badgePages,count:_.length,hidden:_.length===0}),(0,X.jsx)($,{template:t.badgeSettings,count:v.length,hidden:v.length===0}),(0,X.jsx)($,{template:t.badgeWidgets,count:T.length,hidden:T.length===0}),(0,X.jsx)($,{template:t.badgeSidebar,count:O.length,hidden:O.length===0})]})]}):null,L(e)&&(N||P)?(0,X.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[N?(0,X.jsxs)(R,{to:N,onClick:n,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,X.jsx)(m,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,P?(0,X.jsxs)(R,{to:P,onClick:n,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,X.jsx)(j,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,X.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function $(e){let t=(0,W.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,X.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function me(){let e=(0,W.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,X.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,X.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,X.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,X.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(he)})]})}),e[4]=a):a=e[4],a}function he(e){return(0,X.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge-subtle bg-surface-base shadow-surface`},e)}function ge(e){let t=(0,W.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-edge-subtle bg-surface-base px-4 py-12 text-center shadow-surface`,children:(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ce as AppsPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-C22hxE1N.js";import{t as a}from"./jszip.min-DT31yWkU.js";import{t as o}from"./preview-open-alternatives-DqV5OM4m.js";var s=n(),c=e(a(),1),l=e(t(),1),u=r();function d(e){let t=(0,s.c)(17),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],t[0]=n):n=t[0];let[r,a]=(0,l.useState)(n),[d,m]=(0,l.useState)(null),h,g;if(t[1]===e.binaryBuffer?(h=t[2],g=t[3]):(h=()=>{if(!e.binaryBuffer)return;let t=!1;return c.default.loadAsync(e.binaryBuffer).then(e=>{t||a(Object.values(e.files).slice(0,500).map(p))}).catch(e=>{t||m(e instanceof Error?e.message:String(e))}),()=>{t=!0}},g=[e.binaryBuffer],t[1]=e.binaryBuffer,t[2]=h,t[3]=g),(0,l.useEffect)(h,g),d){let n;t[4]===e.language?n=t[5]:(n=i(e.language),t[4]=e.language,t[5]=n);let r=n,a;t[6]!==r.chat.attachmentPreviewDownloadFull||t[7]!==r.chat.attachmentPreviewOpenElsewhereHint||t[8]!==e.actions.onDownload?(a=(0,u.jsx)(o,{message:r.chat.attachmentPreviewOpenElsewhereHint,downloadLabel:r.chat.attachmentPreviewDownloadFull,onDownload:e.actions.onDownload}),t[6]=r.chat.attachmentPreviewDownloadFull,t[7]=r.chat.attachmentPreviewOpenElsewhereHint,t[8]=e.actions.onDownload,t[9]=a):a=t[9];let s;t[10]===d?s=t[11]:(s=(0,u.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}),t[10]=d,t[11]=s);let c;return t[12]!==a||t[13]!==s?(c=(0,u.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[a,s]}),t[12]=a,t[13]=s,t[14]=c):c=t[14],c}let _;return t[15]===r?_=t[16]:(_=(0,u.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:(0,u.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:r.length===0?(0,u.jsx)(`p`,{className:`p-4 text-sm text-fg-muted`,children:`Loading archive...`}):(0,u.jsx)(`table`,{className:`w-full text-left text-xs`,children:(0,u.jsx)(`tbody`,{children:r.map(f)})})})}),t[15]=r,t[16]=_),_}function f(e){return(0,u.jsxs)(`tr`,{className:`border-b border-edge-subtle last:border-b-0 dark:border-edge`,children:[(0,u.jsx)(`td`,{className:`max-w-0 truncate px-3 py-2 font-mono text-fg`,title:e.name,children:e.dir?`${e.name}/`:e.name}),(0,u.jsx)(`td`,{className:`w-24 px-3 py-2 text-right text-fg-muted`,children:e.dir?``:m(e.size)})]},e.name)}function p(e){return{name:e.name,dir:e.dir,size:e.dir?0:e._data?.uncompressedSize??0}}function m(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}export{d as ArchivePreviewPluginView};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-DmnbiNxU.js";import{t as a}from"./jszip.min-DT31yWkU.js";import{t as o}from"./preview-open-alternatives-BTmk-XDM.js";var s=n(),c=e(a(),1),l=e(t(),1),u=r();function d(e){let t=(0,s.c)(17),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],t[0]=n):n=t[0];let[r,a]=(0,l.useState)(n),[d,m]=(0,l.useState)(null),h,g;if(t[1]===e.binaryBuffer?(h=t[2],g=t[3]):(h=()=>{if(!e.binaryBuffer)return;let t=!1;return c.default.loadAsync(e.binaryBuffer).then(e=>{t||a(Object.values(e.files).slice(0,500).map(p))}).catch(e=>{t||m(e instanceof Error?e.message:String(e))}),()=>{t=!0}},g=[e.binaryBuffer],t[1]=e.binaryBuffer,t[2]=h,t[3]=g),(0,l.useEffect)(h,g),d){let n;t[4]===e.language?n=t[5]:(n=i(e.language),t[4]=e.language,t[5]=n);let r=n,a;t[6]!==r.chat.attachmentPreviewDownloadFull||t[7]!==r.chat.attachmentPreviewOpenElsewhereHint||t[8]!==e.actions.onDownload?(a=(0,u.jsx)(o,{message:r.chat.attachmentPreviewOpenElsewhereHint,downloadLabel:r.chat.attachmentPreviewDownloadFull,onDownload:e.actions.onDownload}),t[6]=r.chat.attachmentPreviewDownloadFull,t[7]=r.chat.attachmentPreviewOpenElsewhereHint,t[8]=e.actions.onDownload,t[9]=a):a=t[9];let s;t[10]===d?s=t[11]:(s=(0,u.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:d}),t[10]=d,t[11]=s);let c;return t[12]!==a||t[13]!==s?(c=(0,u.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[a,s]}),t[12]=a,t[13]=s,t[14]=c):c=t[14],c}let _;return t[15]===r?_=t[16]:(_=(0,u.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:(0,u.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:r.length===0?(0,u.jsx)(`p`,{className:`p-4 text-sm text-fg-muted`,children:`Loading archive...`}):(0,u.jsx)(`table`,{className:`w-full text-left text-xs`,children:(0,u.jsx)(`tbody`,{children:r.map(f)})})})}),t[15]=r,t[16]=_),_}function f(e){return(0,u.jsxs)(`tr`,{className:`border-b border-edge-subtle last:border-b-0 dark:border-edge`,children:[(0,u.jsx)(`td`,{className:`max-w-0 truncate px-3 py-2 font-mono text-fg`,title:e.name,children:e.dir?`${e.name}/`:e.name}),(0,u.jsx)(`td`,{className:`w-24 px-3 py-2 text-right text-fg-muted`,children:e.dir?``:m(e.size)})]},e.name)}function p(e){return{name:e.name,dir:e.dir,size:e.dir?0:e._data?.uncompressedSize??0}}function m(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}export{d as ArchivePreviewPluginView};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-RnGYy9bC.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/excel-worksheet-utils-EyvwNT4X.js"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./preload-helper-zJ_50EbN.js";import{$i as t}from"./index-CA2tR2vm.js";async function n(n,r){let i,a=r||`unnamed`,o=`application/octet-stream`,s=0;if(typeof n==`string`){let e=await fetch(n);if(!e.ok)throw Error(`Failed to fetch file`);if(i=await e.arrayBuffer(),s=i.byteLength,o=e.headers.get(`content-type`)||o,!r){let e=n.split(`/`);a=e[e.length-1]||`document`}}else if(n instanceof File)i=await n.arrayBuffer(),s=n.size,o=n.type||o,a=r||n.name;else if(n instanceof Blob)i=await n.arrayBuffer(),s=n.size,o=n.type||o;else if(n instanceof ArrayBuffer)i=n,s=n.byteLength;else throw Error(`Invalid source type`);let c=new Uint8Array(i),l=``,u=32768;for(let e=0;e<c.length;e+=u){let t=c.slice(e,e+u);l+=String.fromCharCode(...t)}let d=btoa(l),f=`${a}_${Date.now()}_${Math.random()}`;if(o===`application/pdf`||a.toLowerCase().endsWith(`.pdf`)){let{processPdf:t}=await e(async()=>{let{processPdf:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPdf:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n,preview:r}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/pdf`,size:s,content:d,extractedText:n,preview:r}}if(o===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||a.toLowerCase().endsWith(`.docx`)){let{processDocx:t}=await e(async()=>{let{processDocx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processDocx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,size:s,content:d,extractedText:n}}if(o===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||a.toLowerCase().endsWith(`.pptx`)){let{processPptx:t}=await e(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,size:s,content:d,extractedText:n}}if([`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`].includes(o)||a.toLowerCase().endsWith(`.xlsx`)||a.toLowerCase().endsWith(`.xls`)){let{processExcel:t}=await e(async()=>{let{processExcel:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processExcel:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:o&&o.startsWith(`application/vnd`)?o:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,size:s,content:d,extractedText:n}}if(o?.startsWith(`image/`))return{id:f,type:`image`,name:a,mimeType:o,size:s,content:d,preview:d};if(o?.startsWith(`audio/`))return{id:f,type:`voice`,name:a,mimeType:o,size:s,content:d};if(t(a,o??``)){let e=new TextDecoder().decode(i);return{id:f,type:`document`,name:a,mimeType:o?.startsWith(`text/`)?o:`text/plain`,size:s,content:d,extractedText:e}}throw Error(`Unsupported file type: ${o}`)}export{n as loadAttachment};
2
+ import{t as e}from"./preload-helper-zJ_50EbN.js";import{da as t}from"./index-C2F0Clvm.js";async function n(n,r){let i,a=r||`unnamed`,o=`application/octet-stream`,s=0;if(typeof n==`string`){let e=await fetch(n);if(!e.ok)throw Error(`Failed to fetch file`);if(i=await e.arrayBuffer(),s=i.byteLength,o=e.headers.get(`content-type`)||o,!r){let e=n.split(`/`);a=e[e.length-1]||`document`}}else if(n instanceof File)i=await n.arrayBuffer(),s=n.size,o=n.type||o,a=r||n.name;else if(n instanceof Blob)i=await n.arrayBuffer(),s=n.size,o=n.type||o;else if(n instanceof ArrayBuffer)i=n,s=n.byteLength;else throw Error(`Invalid source type`);let c=new Uint8Array(i),l=``,u=32768;for(let e=0;e<c.length;e+=u){let t=c.slice(e,e+u);l+=String.fromCharCode(...t)}let d=btoa(l),f=`${a}_${Date.now()}_${Math.random()}`;if(o===`application/pdf`||a.toLowerCase().endsWith(`.pdf`)){let{processPdf:t}=await e(async()=>{let{processPdf:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPdf:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n,preview:r}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/pdf`,size:s,content:d,extractedText:n,preview:r}}if(o===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||a.toLowerCase().endsWith(`.docx`)){let{processDocx:t}=await e(async()=>{let{processDocx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processDocx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,size:s,content:d,extractedText:n}}if(o===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||a.toLowerCase().endsWith(`.pptx`)){let{processPptx:t}=await e(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,size:s,content:d,extractedText:n}}if([`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`].includes(o)||a.toLowerCase().endsWith(`.xlsx`)||a.toLowerCase().endsWith(`.xls`)){let{processExcel:t}=await e(async()=>{let{processExcel:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processExcel:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:o&&o.startsWith(`application/vnd`)?o:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,size:s,content:d,extractedText:n}}if(o?.startsWith(`image/`))return{id:f,type:`image`,name:a,mimeType:o,size:s,content:d,preview:d};if(o?.startsWith(`audio/`))return{id:f,type:`voice`,name:a,mimeType:o,size:s,content:d};if(t(a,o??``)){let e=new TextDecoder().decode(i);return{id:f,type:`document`,name:a,mimeType:o?.startsWith(`text/`)?o:`text/plain`,size:s,content:d,extractedText:e}}throw Error(`Unsupported file type: ${o}`)}export{n as loadAttachment};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{t as r}from"./messages-C22hxE1N.js";import{n as i}from"./locale-store-Ba72bFmP.js";import{i as a}from"./vendor-swr-BIWyz7Rc.js";import{Ic as o,Is as s,Ro as c,_ as l,fo as u,g as d,ul as f,v as p,y as m}from"./index-CA2tR2vm.js";var h=e(),g=t();function _(e){let t=(0,h.c)(45),{title:m,description:_,prompt:x,coverage:S,className:C,variant:w}=e,T=w===void 0?`card`:w,E=i(b),D=r(E).automations.suggestions,O=r(E).automations,k=f(),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=A):A=t[0];let{data:j}=a(S?`automation-suggestion-coverage`:null,y,A),M=S?j?.automations.find(e=>p(e,S)):void 0,N=M?d(M,O):[];if(T===`titleAction`){if(M){let e;t[1]===C?e=t[2]:(e=n(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,C),t[1]=C,t[2]=e);let r;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,g.jsx)(o,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=r):r=t[3];let i;return t[4]===k?i=t[5]:(i=()=>k(`/automations`),t[4]=k,t[5]=i),(0,g.jsxs)(`section`,{className:e,children:[r,(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:D.coveredTitle}),(0,g.jsx)(u,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:i,children:D.manage})]})}let e;t[6]===C?e=t[7]:(e=n(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,C),t[6]=C,t[7]=e);let r;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,g.jsx)(s,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=r):r=t[8];let i;t[9]!==_||t[10]!==m?(i=(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:_,children:m}),t[9]=_,t[10]=m,t[11]=i):i=t[11];let a;t[12]!==k||t[13]!==x?(a=()=>{k(`/automations?${new URLSearchParams({draft:x,autogenerate:`1`}).toString()}`)},t[12]=k,t[13]=x,t[14]=a):a=t[14];let l;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,g.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),t[15]=l):l=t[15],(0,g.jsxs)(`section`,{className:e,children:[r,i,(0,g.jsxs)(u,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:a,children:[l,D.create]})]})}if(M){let e;t[16]===C?e=t[17]:(e=n(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,C),t[16]=C,t[17]=e);let r;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,g.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=r):r=t[18];let i;t[19]===k?i=t[20]:(i=()=>k(`/automations`),t[19]=k,t[20]=i);let a;return t[21]!==D||t[22]!==i?(a=(0,g.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,g.jsx)(u,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:i,children:D.manage})}),t[21]=D,t[22]=i,t[23]=a):a=t[23],(0,g.jsxs)(`section`,{className:e,children:[(0,g.jsxs)(`div`,{className:`flex items-start gap-2`,children:[r,(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:D.coveredTitle}),(0,g.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:l(D.coveredDescription,{name:M.name})})]})]}),(0,g.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:O.explain.whyCovered}),(0,g.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:N.map(v)})]}),a]})}let P;t[24]===C?P=t[25]:(P=n(`rounded-lg bg-surface-panel p-3 shadow-surface`,C),t[24]=C,t[25]=P);let F;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,g.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=F):F=t[26];let I;t[27]===m?I=t[28]:(I=(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:m}),t[27]=m,t[28]=I);let L;t[29]===_?L=t[30]:(L=(0,g.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:_}),t[29]=_,t[30]=L);let R;t[31]!==I||t[32]!==L?(R=(0,g.jsxs)(`div`,{className:`flex items-start gap-2`,children:[F,(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[I,L]})]}),t[31]=I,t[32]=L,t[33]=R):R=t[33];let z;t[34]!==k||t[35]!==x?(z=()=>{k(`/automations?${new URLSearchParams({draft:x,autogenerate:`1`}).toString()}`)},t[34]=k,t[35]=x,t[36]=z):z=t[36];let B;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,g.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),t[37]=B):B=t[37];let V;t[38]!==D.create||t[39]!==z?(V=(0,g.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,g.jsxs)(u,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:z,children:[B,D.create]})}),t[38]=D.create,t[39]=z,t[40]=V):V=t[40];let H;return t[41]!==V||t[42]!==P||t[43]!==R?(H=(0,g.jsxs)(`section`,{className:P,children:[R,V]}),t[41]=V,t[42]=P,t[43]=R,t[44]=H):H=t[44],H}function v(e){return(0,g.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function y(){return m.list()}function b(e){return e.language}export{_ as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{t as r}from"./messages-DmnbiNxU.js";import{n as i}from"./locale-store-Ba72bFmP.js";import{i as a}from"./vendor-swr-BIWyz7Rc.js";import{Qo as o,To as s,Xc as c,Zs as l,_ as u,g as d,v as f,wl as p,y as m}from"./index-C2F0Clvm.js";var h=e(),g=t();function _(e){let t=(0,h.c)(45),{title:m,description:_,prompt:x,coverage:S,className:C,variant:w}=e,T=w===void 0?`card`:w,E=i(b),D=r(E).automations.suggestions,O=r(E).automations,k=p(),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=A):A=t[0];let{data:j}=a(S?`automation-suggestion-coverage`:null,y,A),M=S?j?.automations.find(e=>f(e,S)):void 0,N=M?d(M,O):[];if(T===`titleAction`){if(M){let e;t[1]===C?e=t[2]:(e=n(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,C),t[1]=C,t[2]=e);let r;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,g.jsx)(c,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=r):r=t[3];let i;return t[4]===k?i=t[5]:(i=()=>k(`/automations`),t[4]=k,t[5]=i),(0,g.jsxs)(`section`,{className:e,children:[r,(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:D.coveredTitle}),(0,g.jsx)(s,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:i,children:D.manage})]})}let e;t[6]===C?e=t[7]:(e=n(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,C),t[6]=C,t[7]=e);let r;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,g.jsx)(l,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=r):r=t[8];let i;t[9]!==_||t[10]!==m?(i=(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:_,children:m}),t[9]=_,t[10]=m,t[11]=i):i=t[11];let a;t[12]!==k||t[13]!==x?(a=()=>{k(`/automations?${new URLSearchParams({draft:x,autogenerate:`1`}).toString()}`)},t[12]=k,t[13]=x,t[14]=a):a=t[14];let u;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,g.jsx)(o,{className:`size-3.5`,"aria-hidden":!0}),t[15]=u):u=t[15],(0,g.jsxs)(`section`,{className:e,children:[r,i,(0,g.jsxs)(s,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:a,children:[u,D.create]})]})}if(M){let e;t[16]===C?e=t[17]:(e=n(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,C),t[16]=C,t[17]=e);let r;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,g.jsx)(c,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=r):r=t[18];let i;t[19]===k?i=t[20]:(i=()=>k(`/automations`),t[19]=k,t[20]=i);let a;return t[21]!==D||t[22]!==i?(a=(0,g.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,g.jsx)(s,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:i,children:D.manage})}),t[21]=D,t[22]=i,t[23]=a):a=t[23],(0,g.jsxs)(`section`,{className:e,children:[(0,g.jsxs)(`div`,{className:`flex items-start gap-2`,children:[r,(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:D.coveredTitle}),(0,g.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:u(D.coveredDescription,{name:M.name})})]})]}),(0,g.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:O.explain.whyCovered}),(0,g.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:N.map(v)})]}),a]})}let P;t[24]===C?P=t[25]:(P=n(`rounded-lg bg-surface-panel p-3 shadow-surface`,C),t[24]=C,t[25]=P);let F;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,g.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=F):F=t[26];let I;t[27]===m?I=t[28]:(I=(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:m}),t[27]=m,t[28]=I);let L;t[29]===_?L=t[30]:(L=(0,g.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:_}),t[29]=_,t[30]=L);let R;t[31]!==I||t[32]!==L?(R=(0,g.jsxs)(`div`,{className:`flex items-start gap-2`,children:[F,(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[I,L]})]}),t[31]=I,t[32]=L,t[33]=R):R=t[33];let z;t[34]!==k||t[35]!==x?(z=()=>{k(`/automations?${new URLSearchParams({draft:x,autogenerate:`1`}).toString()}`)},t[34]=k,t[35]=x,t[36]=z):z=t[36];let B;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,g.jsx)(o,{className:`size-3.5`,"aria-hidden":!0}),t[37]=B):B=t[37];let V;t[38]!==D.create||t[39]!==z?(V=(0,g.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,g.jsxs)(s,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:z,children:[B,D.create]})}),t[38]=D.create,t[39]=z,t[40]=V):V=t[40];let H;return t[41]!==V||t[42]!==P||t[43]!==R?(H=(0,g.jsxs)(`section`,{className:P,children:[R,V]}),t[41]=V,t[42]=P,t[43]=R,t[44]=H):H=t[44],H}function v(e){return(0,g.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function y(){return m.list()}function b(e){return e.language}export{_ as t};
@@ -0,0 +1,4 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DmnbiNxU.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{r as s}from"./toast-z0toXu32.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Dc as l,Do as u,El as d,Eo as f,Fr as p,Ga as m,Ha as h,Ir as g,Lr as _,Os as v,Pr as y,Qo as b,Ra as x,Ss as S,To as C,Ua as w,Va as T,Wa as E,Xc as D,bl as O,bs as k,eo as A,fa as j,gt as M,hc as ee,ms as te,no as N,tl as P,vi as ne,xl as re,y as F,za as I,zo as L,zr as ie}from"./index-C2F0Clvm.js";import{t as R}from"./format-cron-label-arqgGlVV.js";import{i as ae,n as z,r as oe,t as B}from"./workflow-run-setup-panel-c4jeaohQ.js";var V=n(),H=e(t(),1),U=r(),W={name:``,description:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalMinutes:`60`,cronExpr:`0 9 * * *`,webhookSecretId:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,safetyMode:`suggest_only`,timeoutSeconds:`300`,afterRunMode:`none`,webhookUrl:``,disableAfterFailures:`3`};function se(e){return e===`zh`?`zh-CN`:`en-US`}function G(e,t,n){return e?new Intl.DateTimeFormat(se(n),{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e)):t.never}function K(e,t,n,r){if(e.kind===`manual`)return t.trigger.manual;if(e.kind===`webhook`)return t.trigger.webhook;if(e.kind===`event`)return t.trigger.eventWithType.replace(`{type}`,e.eventType);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,G(Date.parse(i.at),t,r)):i.kind===`interval`?t.trigger.everyMinutes.replace(`{minutes}`,String(Math.round(i.everyMs/6e4))):R(i.expr,se(r),n.scheduleBadge,{timezone:i.tz})}function q(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function ce(e){return e.safety?.mode??`auto_apply`}function le(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`?`bg-blue-500/10 text-blue-700 dark:text-blue-300`:`bg-surface-hover text-fg-muted`}function ue(e,t){if(e==null)return t.never;if(e<1e3)return`${e}ms`;let n=Math.round(e/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function J(e){return e.status===`running`||e.status===`queued`}function de(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function Y(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function fe(e){return!!Y(e)}function pe(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function X(e){return J(e)?0:de(e)?1:e.status===`succeeded`?2:3}function me(e){return[...e].sort((e,t)=>{let n=X(e)-X(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function he(e){let t=(0,V.c)(5),n;t[0]===e?n=t[1]:(n=()=>typeof window>`u`?!1:window.matchMedia(e).matches,t[0]=e,t[1]=n);let[r,i]=(0,H.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(typeof window>`u`)return;let t=window.matchMedia(e),n=()=>i(t.matches);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},o=[e],t[2]=e,t[3]=a,t[4]=o),(0,H.useEffect)(a,o),r}function ge(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;o=e.triggerMode===`manual`?{kind:`manual`}:e.triggerMode===`webhook`?{kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}}:e.triggerMode===`goalBlocked`?{kind:`event`,eventType:`goal.status_changed`,source:`goals`,payloadMatch:{status:`blocked`}}:e.triggerMode===`noteCreated`?{kind:`event`,eventType:`note.created`,source:`notes`}:e.triggerMode===`workflowFailed`?{kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}}:e.triggerMode===`sessionUpdated`?{kind:`event`,eventType:`session.transcript.updated`,source:`sessions`}:e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:Math.max(1,Number.parseInt(e.intervalMinutes,10)||60)*6e4}}:e.triggerMode===`weekly`?{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * ${e.weekday}`}}:e.triggerMode===`cron`?{kind:`schedule`,schedule:{kind:`cron`,expr:e.cronExpr.trim()}}:{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * *`}};let s=z(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.safetyMode===`auto_apply`?e.afterRunMode:`none`,u=e.actionMode===`workflow`?{kind:`workflow`,workflowId:e.workflowId.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},...s===void 0?{}:{input:s},...c?{goal:c}:{},...e.workflowInput.concurrency.trim()?{concurrency:Math.max(1,Number.parseInt(e.workflowInput.concurrency,10)||1)}:{},...e.workflowInput.maxSubagents.trim()?{maxSubagents:Math.max(1,Number.parseInt(e.workflowInput.maxSubagents,10)||1)}:{},timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)};return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},trigger:o,action:u,safety:{mode:e.safetyMode},afterRun:l===`webhook`?{kind:`webhook`,url:e.webhookUrl.trim()}:{kind:l},reliability:{timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function _e(){let e=o(e=>e.language),t=a(e),n=t.automations,r=t.cron,l=m(e=>e.setPageHeader),f=m(e=>e.clearPageHeader),[v,b]=d(),S=v.get(`run`)?.trim()??``,D=v.get(`draft`)?.trim()??``,O=v.get(`action`)?.trim()??``,A=v.get(`projectId`)?.trim()??``,ee=v.get(`autogenerate`)===`1`,te=(0,H.useRef)(``),N=he(`(min-width: 1280px)`),[P,re]=(0,H.useState)(`activity`),[L,R]=(0,H.useState)(!1),[ae,z]=(0,H.useState)(`blank`),[B,V]=(0,H.useState)(W),[se,K]=(0,H.useState)(null),[q,ce]=(0,H.useState)(null),[le,ue]=(0,H.useState)(!1),[J,Y]=(0,H.useState)(null),[pe,X]=(0,H.useState)(``),[_e,be]=(0,H.useState)(null),[xe,we]=(0,H.useState)(!1),[Te,Ee]=(0,H.useState)(!1),[Z,ke]=(0,H.useState)(null),[Ae,je]=(0,H.useState)(!1),[Ne,Pe]=(0,H.useState)(!1),[Q,$]=(0,H.useState)(!1),[Fe,Ie]=(0,H.useState)(null),Le=c([`automations`,A],()=>F.list(A?{projectId:A}:void 0),{refreshInterval:15e3}),Re=c([`automation-runs`,A],()=>F.runs(50,void 0,A?{projectId:A}:void 0),{refreshInterval:1e4}),ze=c(`automation-metrics`,()=>F.metrics(),{refreshInterval:15e3}),Be=c(q?`automation-run-events:${q}`:null,()=>F.runEvents(q),{refreshInterval:5e3}),Ve=c(`automation-workflow-definitions`,M),He=c(`automation-chat-agents`,j),Ue=Le.data?.automations??[],We=(0,H.useMemo)(()=>me(Re.data?.runs??[]),[Re.data?.runs]),Ge=(0,H.useMemo)(()=>Ue.filter(e=>!fe(e)),[Ue]),Ke=(0,H.useMemo)(()=>Ue.filter(fe),[Ue]),qe=(0,H.useMemo)(()=>new Set(Ke.map(e=>e.id)),[Ke]),Je=(0,H.useMemo)(()=>We.filter(e=>!qe.has(e.automationId)),[We,qe]),Ye=(0,H.useMemo)(()=>{let e;for(let t of Ge){let n=t.state.nextRunAtMs;n&&(e==null||n<e)&&(e=n)}return e},[Ge]),Xe=(0,H.useMemo)(()=>We.find(e=>e.id===q)??null,[We,q]),Ze=(0,H.useMemo)(()=>Ue.find(e=>e.id===J)??null,[Ue,J]),Qe=(0,H.useMemo)(()=>We.filter(e=>e.automationId===J),[We,J]),$e=Be.data?.events??[],et=(0,H.useMemo)(()=>Je.filter(de),[Je]),tt=Je[0]??null,nt=(0,H.useMemo)(()=>Ve.data??[],[Ve.data]),rt=He.data?.items??[],it=(0,H.useMemo)(()=>nt.find(e=>e.id===B.workflowId.trim())??null,[B.workflowId,nt]),at=B.actionMode===`workflow`&&(!B.workflowId.trim()||nt.length>0&&!nt.some(e=>e.id===B.workflowId)),ot=B.actionMode===`workflow`&&it?!oe(it,B.workflowInput,B.workflowInputValid).valid:!1,st=!!B.name.trim()&&(B.actionMode===`workflow`?!at&&!ot:!!B.instruction.trim())&&(B.afterRunMode!==`webhook`||!!B.webhookUrl.trim()),ct=(0,H.useMemo)(()=>[{name:n.templates.dailyAgent.name,description:n.templates.dailyAgent.description,form:{...W,name:n.templates.dailyAgent.name,instruction:n.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:n.templates.morningWorkflow.name,description:n.templates.morningWorkflow.description,form:{...W,name:n.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:nt[0]?.id??``}},{name:n.templates.webhookAgent.name,description:n.templates.webhookAgent.description,form:{...W,name:n.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:n.templates.blockedGoal.name,description:n.templates.blockedGoal.description,form:{...W,name:n.templates.blockedGoal.formName,triggerMode:`goalBlocked`,instruction:n.templates.blockedGoal.instruction}},{name:n.templates.noteCreated.name,description:n.templates.noteCreated.description,form:{...W,name:n.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:n.templates.noteCreated.instruction}}],[n,nt]),lt=(0,H.useCallback)(async()=>{await Promise.all([Le.mutate(),Re.mutate(),ze.mutate(),Be.mutate()])},[Le.mutate,ze.mutate,Be.mutate,Re.mutate]),ut=(0,H.useCallback)(e=>{z(e),R(!0),e===`blank`&&V(W)},[]),dt=(0,H.useCallback)(async()=>{$(!0),K(null);try{await lt()}catch(e){let t=e instanceof Error?e.message:String(e);K(t),s({type:`error`,title:n.feedback.actionFailed,message:t})}finally{$(!1)}},[n.feedback.actionFailed,lt]);(0,H.useEffect)(()=>{S&&(re(`activity`),ce(S),N||ue(!0))},[S,N]),(0,H.useEffect)(()=>{N&&ue(!1)},[N]),(0,H.useEffect)(()=>{O===`create`&&(ut(`blank`),b(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[O,ut,b]),(0,H.useEffect)(()=>{if(!D)return;let t=`${e}:${ee?`auto`:`seed`}:${D}`;te.current!==t&&(te.current=t,X(D),be(null),Ee(!1),z(`draft`),R(!0),b(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),ee&&(K(null),we(!0),F.draft({prompt:D,language:e}).then(e=>{be(e.draft),Ee(!1)}).catch(e=>{K(e instanceof Error?e.message:String(e))}).finally(()=>{we(!1)})))},[ee,D,e,b]);let ft=(0,H.useCallback)(e=>{ce(e),N||ue(!0),b(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[b,N]);(0,H.useEffect)(()=>{ke(null),Pe(!1)},[q]);async function pt(){if(K(null),st)try{await F.create({...ge(B,it),...A?{projectId:A}:{}}),V(W),R(!1),await lt(),s({type:`success`,title:n.dashboard.created})}catch(e){let t=e instanceof Error?e.message:String(e);K(t),s({type:`error`,title:n.feedback.actionFailed,message:t})}}async function mt(e,t,r){K(null),Ie(e);try{return await t(),await lt(),r&&s({type:`success`,title:r}),!0}catch(e){let t=e instanceof Error?e.message:String(e);return K(t),s({type:`error`,title:n.feedback.actionFailed,message:t}),!1}finally{Ie(null)}}async function ht(){let t=pe.trim();if(t){K(null),we(!0);try{be((await F.draft({prompt:t,language:e})).draft),Ee(!1)}catch(e){K(e instanceof Error?e.message:String(e))}finally{we(!1)}}}async function gt(){_e&&await mt(`draft:publish`,async()=>{await F.create({..._e.automation,...A?{projectId:A}:{}}),be(null),X(``),Ee(!1),R(!1)},n.dashboard.created)}async function _t(t){K(null),je(!0),ke(null),Pe(!1);try{ke((await F.repairDraft(t.id,{language:e})).repair)}catch(e){K(e instanceof Error?e.message:String(e))}finally{je(!1)}}async function vt(e){Z&&await mt(`run:${e.id}:repair`,async()=>{await F.update(e.automationId,Z.patch),ke(null),Pe(!1)},n.feedback.repairApplied)}let yt=(0,H.useMemo)(()=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(ne,{className:`size-9 shrink-0 p-0`,loading:Q,label:n.refresh,onClick:dt}),(0,U.jsxs)(_,{children:[(0,U.jsx)(ie,{asChild:!0,children:(0,U.jsxs)(C,{variant:`primary`,children:[(0,U.jsx)(k,{className:`size-4`}),n.new]})}),(0,U.jsx)(g,{children:(0,U.jsxs)(y,{align:`end`,className:`z-70 min-w-52 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,U.jsx)(p,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>ut(`draft`),children:n.createMenu.draft}),(0,U.jsx)(p,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>ut(`template`),children:n.createMenu.template}),(0,U.jsx)(p,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>ut(`blank`),children:n.createMenu.blank})]})})]})]}),[n.createMenu.blank,n.createMenu.draft,n.createMenu.template,n.new,n.refresh,ut,Q,dt]);return(0,H.useLayoutEffect)(()=>(l({startExtra:null,main:(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,U.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:yt}),()=>f()),[f,yt,n.subtitle,n.title,l]),(0,U.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,U.jsxs)(`div`,{className:`flex w-full flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,U.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,U.jsx)(ve,{label:n.dashboard.needsAttention,value:et.length,tone:et.length>0?`danger`:`neutral`}),(0,U.jsx)(ve,{label:n.metrics.running,value:Je.filter(e=>e.status===`running`).length}),(0,U.jsx)(ve,{label:n.dashboard.latestResult,value:tt?n.status[tt.status]:n.none,tone:tt&&de(tt)?`danger`:`neutral`}),(0,U.jsx)(ve,{label:n.metrics.next,value:Ye?G(Ye,n,e):n.none})]}),(0,U.jsx)(`nav`,{className:`inline-flex w-fit rounded-lg border border-edge bg-surface-panel p-1`,children:[{id:`activity`,label:n.dashboard.activity,count:Je.length},{id:`automations`,label:n.dashboard.manage,count:Ge.length},{id:`system`,label:n.system.title,count:Ke.length}].map(e=>(0,U.jsxs)(`button`,{className:i(`inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium text-fg-muted`,P===e.id&&`bg-surface-hover text-fg`),onClick:()=>{re(e.id),e.id!==`activity`&&ue(!1)},children:[(0,U.jsx)(`span`,{children:e.label}),(0,U.jsx)(`span`,{className:`rounded-full border border-edge/70 px-1.5 py-0.5 text-[0.6875rem] leading-none text-fg-muted`,children:e.count})]},e.id))}),se?(0,U.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:se}):null,P===`activity`?(0,U.jsxs)(`section`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(Ce,{runs:Je.slice(0,12),labels:n,cronLabels:r,language:e,selectedRunId:q,busyAction:Fe,className:`h-auto`,onSelectRun:ft,onAction:mt})}),(0,U.jsx)(De,{className:`hidden xl:block`,run:Xe,events:$e,labels:n,cronLabels:r,language:e,loading:Be.isLoading,repairDraft:Z,repairLoading:Ae,repairApproved:Ne,busyAction:Fe,onRepairApprovedChange:Pe,onSuggestRepair:_t,onApplyRepair:vt})]}):P===`automations`?(0,U.jsx)(`section`,{children:(0,U.jsx)(Se,{automations:Ge,runs:Je,labels:n,cronLabels:r,language:e,busyAction:Fe,onOpenDetails:Y,onAction:mt})}):(0,U.jsx)(`section`,{children:(0,U.jsx)(Se,{automations:Ke,runs:We,labels:n,cronLabels:r,language:e,busyAction:Fe,readOnly:!0,onOpenDetails:Y,onAction:mt})})]}),(0,U.jsx)(w,{open:L,onOpenChange:R,children:(0,U.jsxs)(h,{children:[(0,U.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,U.jsxs)(I,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,48rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,U.jsx)(E,{className:`text-base font-semibold text-fg`,children:ae===`draft`?n.draft.title:ae===`template`?n.createMenu.templatesTitle:n.createTitle}),(0,U.jsx)(x,{asChild:!0,children:(0,U.jsx)(C,{variant:`ghost`,"aria-label":n.close,children:(0,U.jsx)(u,{className:`size-4`})})})]}),ae===`draft`?(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,U.jsx)(ye,{labels:n,prompt:pe,draft:_e,loading:xe,approved:Te,publishBusy:Fe===`draft:publish`,onPromptChange:X,onGenerate:ht,onPublish:gt,onApprovedChange:Ee,onDiscard:()=>{be(null),Ee(!1)}})}):ae===`template`?(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,U.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:ct.map(e=>(0,U.jsxs)(`button`,{className:`rounded-lg bg-surface-base p-4 text-left hover:bg-surface-hover`,onClick:()=>{V(e.form),z(`blank`)},children:[(0,U.jsx)(`div`,{className:`font-medium text-fg`,children:e.name}),(0,U.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:e.description})]},e.name))})}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Me,{form:B,labels:n,setForm:V,workflowDefinitions:nt,selectedWorkflow:it,workflowsLoading:Ve.isLoading,agentOptions:rt,agentsLoading:He.isLoading,language:e}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,U.jsx)(x,{asChild:!0,children:(0,U.jsx)(C,{variant:`ghost`,children:n.cancel})}),(0,U.jsx)(C,{variant:`primary`,onClick:pt,disabled:!st,children:n.create})]})]})]})]})}),(0,U.jsx)(Oe,{automation:Ze,runs:Qe,labels:n,cronLabels:r,language:e,busyAction:Fe,onClose:()=>Y(null),onSelectRun:e=>{ft(e),Y(null)},onAction:mt}),(0,U.jsx)(w,{open:!N&&le&&!!Xe,onOpenChange:ue,children:(0,U.jsxs)(h,{children:[(0,U.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,U.jsxs)(I,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(85vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsx)(E,{className:`truncate text-base font-semibold text-fg`,children:Xe?.automationName??n.dashboard.result}),(0,U.jsx)(x,{asChild:!0,children:(0,U.jsx)(C,{variant:`ghost`,"aria-label":n.close,children:(0,U.jsx)(u,{className:`size-4`})})})]}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,U.jsx)(De,{className:`rounded-none border-0`,run:Xe,events:$e,labels:n,cronLabels:r,language:e,loading:Be.isLoading,repairDraft:Z,repairLoading:Ae,repairApproved:Ne,busyAction:Fe,onRepairApprovedChange:Pe,onSuggestRepair:_t,onApplyRepair:vt})})]})]})})]})}function ve(e){let t=(0,V.c)(13),{label:n,value:r,tone:a}=e,o=a===void 0?`neutral`:a,s=o===`danger`&&`bg-red-500/10`,c;t[0]===s?c=t[1]:(c=i(`rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 shadow-surface`,s),t[0]=s,t[1]=c);let l;t[2]===n?l=t[3]:(l=(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[2]=n,t[3]=l);let u=o===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,d;t[4]===u?d=t[5]:(d=i(`mt-1 truncate text-lg font-semibold`,u),t[4]=u,t[5]=d);let f;t[6]!==d||t[7]!==r?(f=(0,U.jsx)(`div`,{className:d,children:r}),t[6]=d,t[7]=r,t[8]=f):f=t[8];let p;return t[9]!==c||t[10]!==l||t[11]!==f?(p=(0,U.jsxs)(`div`,{className:c,children:[l,f]}),t[9]=c,t[10]=l,t[11]=f,t[12]=p):p=t[12],p}function ye(e){let t=(0,V.c)(47),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,onPromptChange:c,onGenerate:l,onPublish:u,onApprovedChange:d,onDiscard:f}=e,p=s===void 0?!1:s,m=!!(i&&i.simulation.requiredConfirmations.length>0),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,U.jsx)(b,{className:`size-4 text-accent`}),t[0]=h):h=t[0];let g;t[1]===n.draft.title?g=t[2]:(g=(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[h,n.draft.title]}),t[1]=n.draft.title,t[2]=g);let _;t[3]===n.draft.subtitle?_=t[4]:(_=(0,U.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=_);let v;t[5]!==g||t[6]!==_?(v=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[g,_]}),t[5]=g,t[6]=_,t[7]=v):v=t[7];let y;t[8]!==a||t[9]!==r?(y=a||!r.trim(),t[8]=a,t[9]=r,t[10]=y):y=t[10];let x;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,U.jsx)(b,{className:`size-4`}),t[11]=x):x=t[11];let S=a?n.draft.generating:n.draft.generate,w;t[12]!==l||t[13]!==y||t[14]!==S?(w=(0,U.jsxs)(C,{variant:`primary`,onClick:l,disabled:y,children:[x,S]}),t[12]=l,t[13]=y,t[14]=S,t[15]=w):w=t[15];let T;t[16]!==v||t[17]!==w?(T=(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[v,w]}),t[16]=v,t[17]=w,t[18]=T):T=t[18];let E;t[19]===c?E=t[20]:(E=e=>c(e.target.value),t[19]=c,t[20]=E);let D;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==E?(D=(0,U.jsx)(`textarea`,{className:`mt-4 min-h-20 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:r,onChange:E,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=E,t[24]=D):D=t[24];let O;t[25]!==o||t[26]!==i||t[27]!==n.draft.approval||t[28]!==n.draft.assumptions||t[29]!==n.draft.discard||t[30]!==n.draft.publish||t[31]!==n.draft.review||t[32]!==n.draft.risks||t[33]!==n.draft.safety||t[34]!==n.feedback||t[35]!==n.info||t[36]!==n.none||t[37]!==d||t[38]!==f||t[39]!==u||t[40]!==p||t[41]!==m?(O=i?(0,U.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,U.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,U.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,U.jsx)(Ae,{label:n.info.when,value:i.simulation.triggerSummary}),(0,U.jsx)(Ae,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,U.jsx)(be,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,U.jsx)(be,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,U.jsx)(be,{title:n.draft.risks,items:i.risks,empty:n.none}),m?(0,U.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,U.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:o,onChange:e=>d(e.target.checked)}),(0,U.jsx)(`span`,{children:n.draft.approval})]}):null,(0,U.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,U.jsx)(C,{variant:`ghost`,onClick:f,children:n.draft.discard}),(0,U.jsx)(C,{variant:`primary`,onClick:u,disabled:p||m&&!o,children:p?n.feedback.working:n.draft.publish})]})]})]}):null,t[25]=o,t[26]=i,t[27]=n.draft.approval,t[28]=n.draft.assumptions,t[29]=n.draft.discard,t[30]=n.draft.publish,t[31]=n.draft.review,t[32]=n.draft.risks,t[33]=n.draft.safety,t[34]=n.feedback,t[35]=n.info,t[36]=n.none,t[37]=d,t[38]=f,t[39]=u,t[40]=p,t[41]=m,t[42]=O):O=t[42];let k;return t[43]!==T||t[44]!==D||t[45]!==O?(k=(0,U.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[T,D,O]}),t[43]=T,t[44]=D,t[45]=O,t[46]=k):k=t[46],k}function be(e){let t=(0,V.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,U.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]!==i||t[3]!==r?(o=r.length>0?r.map(xe):(0,U.jsx)(`li`,{className:`text-fg-muted`,children:i}),t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===o?s=t[6]:(s=(0,U.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm text-fg`,children:o}),t[5]=o,t[6]=s);let c;return t[7]!==a||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function xe(e){return(0,U.jsxs)(`li`,{children:[`- `,e]},e)}function Se(e){let t=(0,V.c)(24),{automations:n,runs:r,labels:a,cronLabels:o,language:s,busyAction:c,readOnly:l,onOpenDetails:u,onAction:d}=e,p=l===void 0?!1:l;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,U.jsx)(f,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===a.empty.automations?n=t[2]:(n=(0,U.jsx)(je,{icon:e,title:a.empty.automations}),t[1]=a.empty.automations,t[2]=n),n}let m;if(t[3]!==n||t[4]!==c||t[5]!==o||t[6]!==a||t[7]!==s||t[8]!==d||t[9]!==u||t[10]!==p||t[11]!==r){let e;t[13]!==c||t[14]!==o||t[15]!==a||t[16]!==s||t[17]!==d||t[18]!==u||t[19]!==p||t[20]!==r?(e=e=>{let t=pe(e),n=r.filter(t=>t.automationId===e.id),l=n.find(J),f=n[0],m=c===`automation:${e.id}:run`,h=c===`automation:${e.id}:toggle`,g=c===`automation:${e.id}:delete`;return(0,U.jsxs)(`article`,{className:`flex min-h-44 cursor-pointer flex-col rounded-lg border border-edge-subtle bg-surface-base p-3.5 shadow-surface outline-none transition-colors hover:bg-surface-hover`,role:`button`,tabIndex:0,onClick:()=>u(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&u(e.id)},children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),l?(0,U.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-blue-500`}):null]}),t?(0,U.jsx)(`div`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:t}):null]}),(0,U.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs`,e.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:e.enabled?a.enabled:a.paused})]}),(0,U.jsxs)(`div`,{className:`mt-3 space-y-2 text-sm`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase text-fg-muted`,children:a.info.when}),(0,U.jsx)(`span`,{className:`truncate`,children:K(e.trigger,a,o,s)})]}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase`,children:a.info.run}),(0,U.jsx)(`span`,{className:`truncate`,children:q(e.action,a)})]})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,U.jsxs)(`span`,{children:[a.last,`: `,G(e.state.lastRunAtMs,a,s)]}),(0,U.jsxs)(`span`,{children:[a.next,`: `,G(e.state.nextRunAtMs,a,s)]}),(0,U.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5`,le(e.state.lastRunStatus)),children:e.state.lastRunStatus?a.status[e.state.lastRunStatus]:a.status.notRun}),f?.error?(0,U.jsx)(`p`,{className:`basis-full line-clamp-1 text-red-700 dark:text-red-300`,children:f.error}):null]}),p?null:(0,U.jsx)(`div`,{className:`mt-auto flex justify-end pt-3`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(C,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":a.dashboard.runNow,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:run`,()=>F.runNow(e.id),a.feedback.rerunQueued)},children:(0,U.jsx)(S,{className:i(`size-4`,m&&`animate-pulse`)})}),(0,U.jsx)(C,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":e.enabled?a.dashboard.pause:a.dashboard.resume,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:toggle`,()=>e.enabled?F.pause(e.id):F.resume(e.id),e.enabled?a.feedback.paused:a.dashboard.resumed)},children:h?(0,U.jsx)(te,{className:`size-4 animate-spin`}):e.enabled?(0,U.jsx)(v,{className:`size-4`}):(0,U.jsx)(S,{className:`size-4`})}),(0,U.jsx)(C,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":a.dashboard.delete,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:delete`,()=>F.remove(e.id),a.dashboard.deleted)},children:g?(0,U.jsx)(te,{className:`size-4 animate-spin`}):(0,U.jsx)(L,{className:`size-4`})})]})})]},e.id)},t[13]=c,t[14]=o,t[15]=a,t[16]=s,t[17]=d,t[18]=u,t[19]=p,t[20]=r,t[21]=e):e=t[21],m=n.map(e),t[3]=n,t[4]=c,t[5]=o,t[6]=a,t[7]=s,t[8]=d,t[9]=u,t[10]=p,t[11]=r,t[12]=m}else m=t[12];let h;return t[22]===m?h=t[23]:(h=(0,U.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:m}),t[22]=m,t[23]=h),h}function Ce(e){let t=(0,V.c)(25),{runs:n,labels:r,cronLabels:a,language:o,selectedRunId:s,busyAction:c,className:l,onSelectRun:u,onAction:d}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,U.jsx)(O,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===r.empty.runs?n=t[2]:(n=(0,U.jsx)(je,{icon:e,title:r.empty.runs}),t[1]=r.empty.runs,t[2]=n),n}let f;t[3]===l?f=t[4]:(f=i(`overflow-hidden rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,l),t[3]=l,t[4]=f);let p;if(t[5]!==c||t[6]!==a||t[7]!==r||t[8]!==o||t[9]!==d||t[10]!==u||t[11]!==n||t[12]!==s){let e;t[14]!==c||t[15]!==a||t[16]!==r||t[17]!==o||t[18]!==d||t[19]!==u||t[20]!==s?(e=e=>(0,U.jsxs)(`div`,{className:i(`grid cursor-pointer gap-3 border-b border-edge p-4 outline-none last:border-b-0 hover:bg-surface-hover md:grid-cols-[1fr_auto]`,s===e.id&&`bg-surface-hover`),role:`button`,tabIndex:0,onClick:()=>u(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&u(e.id)},children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`font-medium text-fg`,children:e.automationName}),(0,U.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs`,le(e.status)),children:r.status[e.status]}),e.workflowRunId?(0,U.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[r.workflowPrefix,` `,e.workflowRunId.slice(0,8)]}):null]}),(0,U.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:e.error||e.summary||q(e.actionSnapshot,r)}),(0,U.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[G(e.createdAtMs,r,o),` · `,e.manual?r.trigger.manual:K(e.triggerSnapshot,r,a,o)]})]}),e.status===`running`||e.status===`queued`?(0,U.jsx)(C,{variant:`ghost`,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`run:${e.id}:cancel`,()=>F.cancelRun(e.id),r.dashboard.cancelled)},children:c===`run:${e.id}:cancel`?r.feedback.working:r.cancel}):null]},e.id),t[14]=c,t[15]=a,t[16]=r,t[17]=o,t[18]=d,t[19]=u,t[20]=s,t[21]=e):e=t[21],p=n.map(e),t[5]=c,t[6]=a,t[7]=r,t[8]=o,t[9]=d,t[10]=u,t[11]=n,t[12]=s,t[13]=p}else p=t[13];let m;return t[22]!==f||t[23]!==p?(m=(0,U.jsx)(`div`,{className:f,children:p}),t[22]=f,t[23]=p,t[24]=m):m=t[24],m}function we(e,t){let n=t.events,r=e.data&&typeof e.data==`object`?e.data:{},i=typeof r.actionKind==`string`?r.actionKind:null,a=typeof r.status==`string`&&r.status in t.status?t.status[r.status]:null;switch(e.type){case`run.queued`:return e.message.toLowerCase().includes(`manual`)?n.manualQueued:e.message.toLowerCase().includes(`scheduled`)?n.scheduledQueued:n.eventQueued;case`run.started`:return n.runStarted;case`action.started`:return i?n.actionStarted.replace(`{kind}`,i):n.actionStartedFallback;case`action.completed`:return i?n.actionCompleted.replace(`{kind}`,i):n.actionCompletedFallback;case`action.failed`:return i?n.actionFailed.replace(`{kind}`,i):n.actionFailedFallback;case`after_run.started`:return n.afterRunStarted;case`after_run.completed`:return n.afterRunCompleted;case`after_run.failed`:return n.afterRunFailed;case`run.completed`:return a?n.runCompleted.replace(`{status}`,a):n.runCompletedFallback;default:return e.message}}function Te(e){let t=(0,V.c)(17),{value:n,labels:r,title:a,defaultExpanded:o}=e,[s,c]=(0,H.useState)(o===void 0?!1:o),l;t[0]===n?l=t[1]:(l=JSON.stringify(n,null,2),t[0]=n,t[1]=l);let u=l,d;t[2]===u?d=t[3]:(d=u.split(`
2
+ `),t[2]=u,t[3]=d);let f=d.length,p=u.length>720||f>18,m;t[4]!==p||t[5]!==u?(m=p?`${u.split(`
3
+ `).slice(0,10).join(`
4
+ `).trimEnd()}...`:u,t[4]=p,t[5]=u,t[6]=m):m=t[6];let h=m,g;t[7]!==s||t[8]!==p||t[9]!==r||t[10]!==a?(g=p?(0,U.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>c(Ee),"aria-expanded":s,children:[(0,U.jsx)(`span`,{children:a}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-fg`,children:[s?r.details.hideDetails:r.details.showDetails,(0,U.jsx)(P,{className:i(`size-3.5 transition-transform`,s&&`rotate-180`),"aria-hidden":!0})]})]}):(0,U.jsx)(`div`,{className:`px-2.5 py-2 text-xs font-medium text-fg-muted`,children:a}),t[7]=s,t[8]=p,t[9]=r,t[10]=a,t[11]=g):g=t[11];let _=s||!p?u:h,v;t[12]===_?v=t[13]:(v=(0,U.jsx)(`pre`,{className:`whitespace-pre-wrap break-all px-2.5 pb-2 text-xs leading-relaxed text-fg-muted`,children:_}),t[12]=_,t[13]=v);let y;return t[14]!==g||t[15]!==v?(y=(0,U.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[g,v]}),t[14]=g,t[15]=v,t[16]=y):y=t[16],y}function Ee(e){return!e}function De(e){let t=(0,V.c)(125),{className:n,run:r,events:a,labels:o,cronLabels:s,language:c,loading:u,repairDraft:d,repairLoading:f,repairApproved:p,busyAction:m,onRepairApprovedChange:h,onSuggestRepair:g,onApplyRepair:_}=e;if(!r){let e;t[0]===n?e=t[1]:(e=i(`flex min-h-64 flex-col justify-center rounded-lg border border-edge-subtle bg-surface-base px-4 text-center text-sm text-fg-muted shadow-surface`,n),t[0]=n,t[1]=e);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,U.jsx)(O,{className:`mx-auto size-5`}),t[2]=r):r=t[2];let a;t[3]===o.selectRun?a=t[4]:(a=(0,U.jsx)(`div`,{className:`mt-2`,children:o.selectRun}),t[3]=o.selectRun,t[4]=a);let s;return t[5]!==e||t[6]!==a?(s=(0,U.jsxs)(`aside`,{className:e,children:[r,a]}),t[5]=e,t[6]=a,t[7]=s):s=t[7],s}let v;t[8]===n?v=t[9]:(v=i(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=v);let y;t[10]===r.automationName?y=t[11]:(y=(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=y);let x;t[12]===r.id?x=t[13]:(x=r.id.slice(0,8),t[12]=r.id,t[13]=x);let S;t[14]===x?S=t[15]:(S=(0,U.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:x}),t[14]=x,t[15]=S);let w;t[16]!==y||t[17]!==S?(w=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[y,S]}),t[16]=y,t[17]=S,t[18]=w):w=t[18];let T;t[19]===r.status?T=t[20]:(T=i(`shrink-0 rounded-full px-2 py-0.5 text-xs`,le(r.status)),t[19]=r.status,t[20]=T);let E=o.status[r.status],D;t[21]!==T||t[22]!==E?(D=(0,U.jsx)(`span`,{className:T,children:E}),t[21]=T,t[22]=E,t[23]=D):D=t[23];let k;t[24]!==w||t[25]!==D?(k=(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[w,D]}),t[24]=w,t[25]=D,t[26]=k):k=t[26];let A=o.details.created,j;t[27]!==o||t[28]!==c||t[29]!==r.createdAtMs?(j=G(r.createdAtMs,o,c),t[27]=o,t[28]=c,t[29]=r.createdAtMs,t[30]=j):j=t[30];let M;t[31]!==o.details.created||t[32]!==j?(M=(0,U.jsx)(Z,{label:A,value:j}),t[31]=o.details.created,t[32]=j,t[33]=M):M=t[33];let te=o.details.started,N;t[34]!==o||t[35]!==c||t[36]!==r.startedAtMs?(N=G(r.startedAtMs,o,c),t[34]=o,t[35]=c,t[36]=r.startedAtMs,t[37]=N):N=t[37];let P;t[38]!==o.details.started||t[39]!==N?(P=(0,U.jsx)(Z,{label:te,value:N}),t[38]=o.details.started,t[39]=N,t[40]=P):P=t[40];let ne=o.details.duration,F;t[41]!==o||t[42]!==r.durationMs?(F=ue(r.durationMs,o),t[41]=o,t[42]=r.durationMs,t[43]=F):F=t[43];let I;t[44]!==o.details.duration||t[45]!==F?(I=(0,U.jsx)(Z,{label:ne,value:F}),t[44]=o.details.duration,t[45]=F,t[46]=I):I=t[46];let L;t[47]!==o.details.model||t[48]!==r.model?(L=r.model?(0,U.jsx)(Z,{label:o.details.model,value:r.model}):null,t[47]=o.details.model,t[48]=r.model,t[49]=L):L=t[49];let ie;t[50]!==M||t[51]!==P||t[52]!==I||t[53]!==L?(ie=(0,U.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[M,P,I,L]}),t[50]=M,t[51]=P,t[52]=I,t[53]=L,t[54]=ie):ie=t[54];let R;t[55]===o.dashboard.result?R=t[56]:(R=(0,U.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.dashboard.result}),t[55]=o.dashboard.result,t[56]=R);let ae;t[57]===r?ae=t[58]:(ae=de(r)?`text-red-700 dark:text-red-300`:`text-fg`,t[57]=r,t[58]=ae);let z;t[59]===ae?z=t[60]:(z=i(`mt-1 break-words text-sm`,ae),t[59]=ae,t[60]=z);let oe;t[61]!==o||t[62]!==r.actionSnapshot||t[63]!==r.error||t[64]!==r.summary?(oe=r.error||r.summary||q(r.actionSnapshot,o),t[61]=o,t[62]=r.actionSnapshot,t[63]=r.error,t[64]=r.summary,t[65]=oe):oe=t[65];let B;t[66]!==z||t[67]!==oe?(B=(0,U.jsx)(`p`,{className:z,children:oe}),t[66]=z,t[67]=oe,t[68]=B):B=t[68];let H;t[69]!==s||t[70]!==o||t[71]!==c||t[72]!==r.manual||t[73]!==r.triggerSnapshot?(H=r.manual?o.trigger.manual:K(r.triggerSnapshot,o,s,c),t[69]=s,t[70]=o,t[71]=c,t[72]=r.manual,t[73]=r.triggerSnapshot,t[74]=H):H=t[74];let W;t[75]!==o.explain.whyRan||t[76]!==H?(W=(0,U.jsx)(Z,{label:o.explain.whyRan,value:H}),t[75]=o.explain.whyRan,t[76]=H,t[77]=W):W=t[77];let se;t[78]!==o.dashboard.openSession||t[79]!==r.sessionKey?(se=r.sessionKey?(0,U.jsx)(C,{asChild:!0,variant:`secondary`,className:`h-8 justify-start rounded-md px-2 text-xs`,children:(0,U.jsxs)(re,{to:`/chat/${encodeURIComponent(r.sessionKey)}`,children:[(0,U.jsx)(l,{className:`size-3.5`}),o.dashboard.openSession]})}):null,t[78]=o.dashboard.openSession,t[79]=r.sessionKey,t[80]=se):se=t[80];let ce;t[81]!==o.feedback||t[82]!==r.workflowRunId?(ce=r.workflowRunId?(0,U.jsx)(C,{asChild:!0,variant:`secondary`,className:`h-8 justify-start rounded-md px-2 text-xs`,children:(0,U.jsxs)(re,{to:`/workflows?run=${encodeURIComponent(r.workflowRunId)}`,children:[(0,U.jsx)(ee,{className:`size-3.5`}),o.feedback.workflow]})}):null,t[81]=o.feedback,t[82]=r.workflowRunId,t[83]=ce):ce=t[83];let J;t[84]!==W||t[85]!==se||t[86]!==ce?(J=(0,U.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[W,se,ce]}),t[84]=W,t[85]=se,t[86]=ce,t[87]=J):J=t[87];let Y;t[88]!==R||t[89]!==B||t[90]!==J?(Y=(0,U.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge/70 bg-surface-base/50 p-3`,children:[R,B,J]}),t[88]=R,t[89]=B,t[90]=J,t[91]=Y):Y=t[91];let fe;t[92]!==o.repair||t[93]!==g||t[94]!==f||t[95]!==r?(fe=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,U.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,U.jsxs)(C,{variant:`secondary`,onClick:()=>g(r),disabled:f,children:[(0,U.jsx)(b,{className:`size-4`}),f?o.repair.generating:o.repair.suggest]})}):null,t[92]=o.repair,t[93]=g,t[94]=f,t[95]=r,t[96]=fe):fe=t[96];let pe;t[97]!==ie||t[98]!==Y||t[99]!==fe||t[100]!==k?(pe=(0,U.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[k,ie,Y,fe]}),t[97]=ie,t[98]=Y,t[99]=fe,t[100]=k,t[101]=pe):pe=t[101];let X;t[102]!==m||t[103]!==o||t[104]!==_||t[105]!==h||t[106]!==p||t[107]!==d||t[108]!==r?(X=d?(0,U.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[(0,U.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.repair.title}),(0,U.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:d.explanation}),d.expectedEffect?(0,U.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:d.expectedEffect}):null,(0,U.jsx)(be,{title:o.repair.risks,items:d.risks,empty:o.none}),(0,U.jsx)(Te,{value:d.patch,labels:o,title:o.details.repairPatch}),d.requiresApproval?(0,U.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-sm text-fg`,children:[(0,U.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:p,onChange:e=>h(e.target.checked)}),(0,U.jsx)(`span`,{children:o.repair.approval})]}):null,(0,U.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,U.jsx)(C,{variant:`primary`,onClick:()=>_(r),disabled:m===`run:${r.id}:repair`||d.requiresApproval&&!p,children:m===`run:${r.id}:repair`?o.feedback.working:o.repair.apply})})]}):null,t[102]=m,t[103]=o,t[104]=_,t[105]=h,t[106]=p,t[107]=d,t[108]=r,t[109]=X):X=t[109];let me;t[110]===o.timeline?me=t[111]:(me=(0,U.jsx)(`div`,{className:`mb-3 text-xs font-semibold uppercase text-fg-muted`,children:o.timeline}),t[110]=o.timeline,t[111]=me);let he;t[112]!==a||t[113]!==o||t[114]!==c||t[115]!==u?(he=u?(0,U.jsx)(`div`,{className:`text-sm text-fg-muted`,children:o.loading}):a.length===0?(0,U.jsx)(`div`,{className:`text-sm text-fg-muted`,children:o.empty.events}):(0,U.jsx)(`ol`,{className:`space-y-3`,children:a.map(e=>(0,U.jsxs)(`li`,{className:`grid grid-cols-[0.75rem_1fr] gap-3`,children:[(0,U.jsx)(`span`,{className:i(`mt-1 size-2 rounded-full`,ke(e.type))}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-sm text-fg`,children:we(e,o)}),(0,U.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[G(e.createdAtMs,o,c),` · `,e.type]}),e.data&&typeof e.data==`object`?(0,U.jsx)(Te,{value:e.data,labels:o,title:o.details.eventData}):null]})]},e.id))}),t[112]=a,t[113]=o,t[114]=c,t[115]=u,t[116]=he):he=t[116];let ge;t[117]!==me||t[118]!==he?(ge=(0,U.jsxs)(`div`,{className:`px-4 py-3`,children:[me,he]}),t[117]=me,t[118]=he,t[119]=ge):ge=t[119];let _e;return t[120]!==v||t[121]!==pe||t[122]!==X||t[123]!==ge?(_e=(0,U.jsxs)(`aside`,{className:v,children:[pe,X,ge]}),t[120]=v,t[121]=pe,t[122]=X,t[123]=ge,t[124]=_e):_e=t[124],_e}function Oe(e){let t=(0,V.c)(25),{automation:n,runs:r,labels:a,cronLabels:o,language:s,busyAction:c,onClose:d,onSelectRun:f,onAction:p}=e,m;t[0]===n?m=t[1]:(m=n?ce(n):`suggest_only`,t[0]=n,t[1]=m);let g=m,_=n?c===`automation:${n.id}:run`:!1,y=n?c===`automation:${n.id}:toggle`:!1,b=n?c===`automation:${n.id}:delete`:!1,k=!!n,A;t[2]===d?A=t[3]:(A=e=>!e&&d(),t[2]=d,t[3]=A);let j;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,U.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[4]=j):j=t[4];let M;t[5]!==n||t[6]!==c||t[7]!==o||t[8]!==b||t[9]!==a||t[10]!==s||t[11]!==g||t[12]!==p||t[13]!==d||t[14]!==f||t[15]!==_||t[16]!==r||t[17]!==y?(M=n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(E,{className:`truncate text-base font-semibold text-fg`,children:n.name}),n.description?(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:n.description}):null]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs`,n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:n.enabled?a.enabled:a.paused}),(0,U.jsx)(x,{asChild:!0,children:(0,U.jsx)(C,{variant:`ghost`,"aria-label":a.close,children:(0,U.jsx)(u,{className:`size-4`})})})]})]}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,U.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[18rem_1fr]`,children:[(0,U.jsxs)(`aside`,{className:`grid h-fit gap-3 rounded-lg bg-surface-base p-4`,children:[(0,U.jsx)(Ae,{label:a.info.when,value:K(n.trigger,a,o,s)}),(0,U.jsx)(Ae,{label:a.info.run,value:q(n.action,a)}),(0,U.jsx)(Ae,{label:a.info.safety,value:a.safety[g]}),(0,U.jsx)(Z,{label:a.last,value:G(n.state.lastRunAtMs,a,s)}),(0,U.jsx)(Z,{label:a.next,value:G(n.state.nextRunAtMs,a,s)}),n.state.consecutiveFailures?(0,U.jsx)(Z,{label:a.dashboard.failures,value:String(n.state.consecutiveFailures)}):null,n.state.lastError?(0,U.jsx)(`p`,{className:`break-words text-sm text-red-700 dark:text-red-300`,children:n.state.lastError}):null]}),(0,U.jsxs)(`section`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.dashboard.runHistory}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.dashboard.runHistoryDescription})]}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length})]}),r.length===0?(0,U.jsx)(je,{icon:(0,U.jsx)(O,{className:`size-5`}),title:a.empty.runs}):(0,U.jsx)(`div`,{className:`grid gap-2`,children:r.map(e=>(0,U.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,U.jsxs)(`button`,{className:`min-w-0 text-left outline-none`,onClick:()=>f(e.id),children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.status===`succeeded`?(0,U.jsx)(D,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,U.jsx)(O,{className:`size-4 shrink-0 text-fg-muted`}),(0,U.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:G(e.createdAtMs,a,s)}),(0,U.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs`,le(e.status)),children:a.status[e.status]})]}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.error||e.summary||q(e.actionSnapshot,a)})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1`,children:[e.sessionKey?(0,U.jsx)(C,{asChild:!0,variant:`ghost`,className:`h-8 rounded-md px-2 text-xs`,children:(0,U.jsxs)(re,{to:`/chat/${encodeURIComponent(e.sessionKey)}`,children:[(0,U.jsx)(l,{className:`size-3.5`}),a.dashboard.openSession]})}):null,e.workflowRunId?(0,U.jsx)(C,{asChild:!0,variant:`ghost`,className:`h-8 rounded-md px-2 text-xs`,children:(0,U.jsxs)(re,{to:`/workflows?run=${encodeURIComponent(e.workflowRunId)}`,children:[(0,U.jsx)(ee,{className:`size-3.5`}),a.feedback.workflow]})}):null]})]})},e.id))})]})]})}),(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-edge px-5 py-4`,children:[(0,U.jsxs)(C,{variant:`ghost`,disabled:c!==null,onClick:()=>void p(`automation:${n.id}:delete`,()=>F.remove(n.id),a.dashboard.deleted).then(e=>{e&&d()}),children:[b?(0,U.jsx)(te,{className:`size-4 animate-spin`}):(0,U.jsx)(L,{className:`size-4`}),a.dashboard.delete]}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsxs)(C,{variant:`secondary`,disabled:c!==null,onClick:()=>void p(`automation:${n.id}:toggle`,()=>n.enabled?F.pause(n.id):F.resume(n.id),n.enabled?a.feedback.paused:a.dashboard.resumed),children:[y?(0,U.jsx)(te,{className:`size-4 animate-spin`}):n.enabled?(0,U.jsx)(v,{className:`size-4`}):(0,U.jsx)(S,{className:`size-4`}),n.enabled?a.dashboard.pause:a.dashboard.resume]}),(0,U.jsxs)(C,{variant:`primary`,disabled:c!==null,onClick:()=>void p(`automation:${n.id}:run`,()=>F.runNow(n.id),a.feedback.rerunQueued),children:[_?(0,U.jsx)(te,{className:`size-4 animate-spin`}):(0,U.jsx)(S,{className:`size-4`}),a.dashboard.runNow]})]})]})]}):null,t[5]=n,t[6]=c,t[7]=o,t[8]=b,t[9]=a,t[10]=s,t[11]=g,t[12]=p,t[13]=d,t[14]=f,t[15]=_,t[16]=r,t[17]=y,t[18]=M):M=t[18];let N;t[19]===M?N=t[20]:(N=(0,U.jsxs)(h,{children:[j,(0,U.jsx)(I,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,56rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:M})]}),t[19]=M,t[20]=N);let P;return t[21]!==k||t[22]!==A||t[23]!==N?(P=(0,U.jsx)(w,{open:k,onOpenChange:A,children:N}),t[21]=k,t[22]=A,t[23]=N,t[24]=P):P=t[24],P}function Z(e){let t=(0,V.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,U.jsx)(`span`,{children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,U.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,U.jsxs)(`div`,{className:`grid grid-cols-[5rem_1fr] gap-2`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function ke(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function Ae(e){let t=(0,V.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,U.jsx)(`div`,{className:`mt-1 truncate text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function je(e){let t=(0,V.c)(5),{icon:n,title:r}=e,i;t[0]===r?i=t[1]:(i=(0,U.jsx)(`div`,{className:`mt-2 text-sm`,children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,U.jsxs)(`div`,{className:`flex min-h-48 flex-col items-center justify-center rounded-lg border border-edge-subtle bg-surface-base text-fg-muted shadow-surface`,children:[n,i]}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Me(e){let t=(0,V.c)(218),{form:n,labels:r,setForm:a,workflowDefinitions:o,selectedWorkflow:s,workflowsLoading:c,agentOptions:l,agentsLoading:u,language:d}=e,f;t[0]===a?f=t[1]:(f=e=>a(t=>({...t,...e})),t[0]=a,t[1]=f);let p=f,m,h;t[2]!==n.actionMode||t[3]!==n.workflowId||t[4]!==a||t[5]!==o?(m=()=>{if(n.actionMode!==`workflow`||n.workflowId.trim())return;let e=o[0]?.id;e&&a(t=>({...t,workflowId:e,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}))},h=[n.actionMode,n.workflowId,a,o],t[2]=n.actionMode,t[3]=n.workflowId,t[4]=a,t[5]=o,t[6]=m,t[7]=h):(m=t[6],h=t[7]),(0,H.useEffect)(m,h);let g;t[8]===p?g=t[9]:(g=e=>p({name:e.target.value}),t[8]=p,t[9]=g);let _;t[10]!==n.name||t[11]!==g?(_=(0,U.jsx)(`input`,{className:Q,value:n.name,onChange:g}),t[10]=n.name,t[11]=g,t[12]=_):_=t[12];let v;t[13]!==r.form.name||t[14]!==_?(v=(0,U.jsx)($,{label:r.form.name,children:_}),t[13]=r.form.name,t[14]=_,t[15]=v):v=t[15];let y;t[16]===p?y=t[17]:(y=e=>p({description:e.target.value}),t[16]=p,t[17]=y);let b;t[18]!==n.description||t[19]!==y?(b=(0,U.jsx)(`input`,{className:Q,value:n.description,onChange:y}),t[18]=n.description,t[19]=y,t[20]=b):b=t[20];let x;t[21]!==r.form.description||t[22]!==b?(x=(0,U.jsx)($,{label:r.form.description,children:b}),t[21]=r.form.description,t[22]=b,t[23]=x):x=t[23];let S;t[24]===r.form.trigger?S=t[25]:(S=(0,U.jsx)(Fe,{title:r.form.trigger}),t[24]=r.form.trigger,t[25]=S);let C;t[26]===p?C=t[27]:(C=e=>p({triggerMode:e.target.value}),t[26]=p,t[27]=C);let w;t[28]===r.trigger.manual?w=t[29]:(w=(0,U.jsx)(N,{value:`manual`,children:r.trigger.manual}),t[28]=r.trigger.manual,t[29]=w);let T;t[30]===r.trigger.daily?T=t[31]:(T=(0,U.jsx)(N,{value:`daily`,children:r.trigger.daily}),t[30]=r.trigger.daily,t[31]=T);let E;t[32]===r.trigger.weekly?E=t[33]:(E=(0,U.jsx)(N,{value:`weekly`,children:r.trigger.weekly}),t[32]=r.trigger.weekly,t[33]=E);let D;t[34]===r.trigger.interval?D=t[35]:(D=(0,U.jsx)(N,{value:`interval`,children:r.trigger.interval}),t[34]=r.trigger.interval,t[35]=D);let O;t[36]===r.trigger.customCron?O=t[37]:(O=(0,U.jsx)(N,{value:`cron`,children:r.trigger.customCron}),t[36]=r.trigger.customCron,t[37]=O);let k;t[38]===r.trigger.webhook?k=t[39]:(k=(0,U.jsx)(N,{value:`webhook`,children:r.trigger.webhook}),t[38]=r.trigger.webhook,t[39]=k);let j;t[40]===r.trigger.goalBlocked?j=t[41]:(j=(0,U.jsx)(N,{value:`goalBlocked`,children:r.trigger.goalBlocked}),t[40]=r.trigger.goalBlocked,t[41]=j);let M;t[42]===r.trigger.noteCreated?M=t[43]:(M=(0,U.jsx)(N,{value:`noteCreated`,children:r.trigger.noteCreated}),t[42]=r.trigger.noteCreated,t[43]=M);let ee;t[44]===r.trigger.workflowFailed?ee=t[45]:(ee=(0,U.jsx)(N,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[44]=r.trigger.workflowFailed,t[45]=ee);let te;t[46]===r.trigger.sessionUpdated?te=t[47]:(te=(0,U.jsx)(N,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[46]=r.trigger.sessionUpdated,t[47]=te);let P;t[48]!==n.triggerMode||t[49]!==C||t[50]!==w||t[51]!==T||t[52]!==E||t[53]!==D||t[54]!==O||t[55]!==k||t[56]!==j||t[57]!==M||t[58]!==ee||t[59]!==te?(P=(0,U.jsxs)(A,{className:Q,value:n.triggerMode,onChange:C,children:[w,T,E,D,O,k,j,M,ee,te]}),t[48]=n.triggerMode,t[49]=C,t[50]=w,t[51]=T,t[52]=E,t[53]=D,t[54]=O,t[55]=k,t[56]=j,t[57]=M,t[58]=ee,t[59]=te,t[60]=P):P=t[60];let ne;t[61]!==n.time||t[62]!==n.triggerMode||t[63]!==n.weekday||t[64]!==r.form.day||t[65]!==r.form.time||t[66]!==r.weekdays||t[67]!==p?(ne=n.triggerMode===`daily`||n.triggerMode===`weekly`?(0,U.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,U.jsx)($,{label:r.form.time,children:(0,U.jsx)(`input`,{className:Q,type:`time`,value:n.time,onChange:e=>p({time:e.target.value})})}),n.triggerMode===`weekly`?(0,U.jsx)($,{label:r.form.day,children:(0,U.jsxs)(A,{className:Q,value:n.weekday,onChange:e=>p({weekday:e.target.value}),children:[(0,U.jsx)(N,{value:`1`,children:r.weekdays.monday}),(0,U.jsx)(N,{value:`2`,children:r.weekdays.tuesday}),(0,U.jsx)(N,{value:`3`,children:r.weekdays.wednesday}),(0,U.jsx)(N,{value:`4`,children:r.weekdays.thursday}),(0,U.jsx)(N,{value:`5`,children:r.weekdays.friday}),(0,U.jsx)(N,{value:`6`,children:r.weekdays.saturday}),(0,U.jsx)(N,{value:`0`,children:r.weekdays.sunday})]})}):null]}):null,t[61]=n.time,t[62]=n.triggerMode,t[63]=n.weekday,t[64]=r.form.day,t[65]=r.form.time,t[66]=r.weekdays,t[67]=p,t[68]=ne):ne=t[68];let re;t[69]!==n.intervalMinutes||t[70]!==n.triggerMode||t[71]!==r.form.everyMinutes||t[72]!==p?(re=n.triggerMode===`interval`?(0,U.jsx)($,{label:r.form.everyMinutes,children:(0,U.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.intervalMinutes,onChange:e=>p({intervalMinutes:e.target.value})})}):null,t[69]=n.intervalMinutes,t[70]=n.triggerMode,t[71]=r.form.everyMinutes,t[72]=p,t[73]=re):re=t[73];let F;t[74]!==n.cronExpr||t[75]!==n.triggerMode||t[76]!==r.form.expression||t[77]!==p?(F=n.triggerMode===`cron`?(0,U.jsx)($,{label:r.form.expression,children:(0,U.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>p({cronExpr:e.target.value})})}):null,t[74]=n.cronExpr,t[75]=n.triggerMode,t[76]=r.form.expression,t[77]=p,t[78]=F):F=t[78];let I;t[79]!==n.triggerMode||t[80]!==n.webhookSecretId||t[81]!==r.form.secretId||t[82]!==p?(I=n.triggerMode===`webhook`?(0,U.jsx)($,{label:r.form.secretId,children:(0,U.jsx)(`input`,{className:Q,value:n.webhookSecretId,onChange:e=>p({webhookSecretId:e.target.value})})}):null,t[79]=n.triggerMode,t[80]=n.webhookSecretId,t[81]=r.form.secretId,t[82]=p,t[83]=I):I=t[83];let L;t[84]===r.form.action?L=t[85]:(L=(0,U.jsx)(Fe,{title:r.form.action}),t[84]=r.form.action,t[85]=L);let ie;t[86]!==n.workflowId||t[87]!==p||t[88]!==o?(ie=e=>{let t=e.target.value;p({actionMode:t,...t===`workflow`&&!n.workflowId.trim()&&o[0]?{workflowId:o[0].id,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}:{}})},t[86]=n.workflowId,t[87]=p,t[88]=o,t[89]=ie):ie=t[89];let R;t[90]===r.action.runAgent?R=t[91]:(R=(0,U.jsx)(N,{value:`agent`,children:r.action.runAgent}),t[90]=r.action.runAgent,t[91]=R);let z;t[92]===r.action.runWorkflow?z=t[93]:(z=(0,U.jsx)(N,{value:`workflow`,children:r.action.runWorkflow}),t[92]=r.action.runWorkflow,t[93]=z);let oe;t[94]!==n.actionMode||t[95]!==ie||t[96]!==R||t[97]!==z?(oe=(0,U.jsxs)(A,{className:Q,value:n.actionMode,onChange:ie,children:[R,z]}),t[94]=n.actionMode,t[95]=ie,t[96]=R,t[97]=z,t[98]=oe):oe=t[98];let W=r.form.agent,se=n.agentId,G;t[99]===p?G=t[100]:(G=e=>p({agentId:e.target.value}),t[99]=p,t[100]=G);let K=u?r.form.loadingAgents:r.form.defaultAgent,q;t[101]===K?q=t[102]:(q=(0,U.jsx)(N,{value:``,children:K}),t[101]=K,t[102]=q);let ce;t[103]===l?ce=t[104]:(ce=l.map(Pe),t[103]=l,t[104]=ce);let le;t[105]!==n.agentId||t[106]!==G||t[107]!==q||t[108]!==ce?(le=(0,U.jsxs)(A,{className:Q,value:se,onChange:G,children:[q,ce]}),t[105]=n.agentId,t[106]=G,t[107]=q,t[108]=ce,t[109]=le):le=t[109];let ue;t[110]!==r.form.agent||t[111]!==le?(ue=(0,U.jsx)($,{label:W,children:le}),t[110]=r.form.agent,t[111]=le,t[112]=ue):ue=t[112];let J;t[113]!==n.actionMode||t[114]!==n.agentId||t[115]!==n.description||t[116]!==n.instruction||t[117]!==n.name||t[118]!==n.triggerMode||t[119]!==n.workflowId||t[120]!==n.workflowInput||t[121]!==r.form.instruction||t[122]!==r.form.loadingWorkflows||t[123]!==r.form.noWorkflows||t[124]!==r.form.triggeredRun||t[125]!==r.form.workflow||t[126]!==d||t[127]!==s||t[128]!==p||t[129]!==o||t[130]!==c?(J=n.actionMode===`agent`?(0,U.jsxs)($,{label:r.form.instruction,children:[(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsx)(ae,{value:n.instruction,onApply:e=>p({instruction:e}),fieldId:`automation.instruction`,fieldLabel:r.form.instruction,scenario:`automation.instruction`,locale:d,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,agentId:n.agentId},showLabel:!1})}),(0,U.jsx)(`textarea`,{className:i(Q,`min-h-32 resize-y`),value:n.instruction,onChange:e=>p({instruction:e.target.value})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)($,{label:r.form.workflow,children:(0,U.jsxs)(A,{className:Q,value:n.workflowId,onChange:e=>p({workflowId:e.target.value,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}),disabled:c||o.length===0,children:[c?(0,U.jsx)(N,{value:``,children:r.form.loadingWorkflows}):null,!c&&o.length===0?(0,U.jsx)(N,{value:``,children:r.form.noWorkflows}):null,o.map(Ne)]})}),s?(0,U.jsx)(B,{definition:s,language:d,value:n.workflowInput,onChange:e=>p({workflowInput:e,workflowGoal:e.goal,workflowInputValid:!0}),mode:`automation`,badgeLabel:r.form.triggeredRun,onValidityChange:e=>p({workflowInputValid:e.valid}),aiAssist:{inputScenario:`automation.workflowInput`,goalScenario:`automation.workflowGoal`,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,workflowId:s.id,workflowTitle:s.title,workflowDescription:s.description}},inputClassName:`rounded-lg`}):null]}),t[113]=n.actionMode,t[114]=n.agentId,t[115]=n.description,t[116]=n.instruction,t[117]=n.name,t[118]=n.triggerMode,t[119]=n.workflowId,t[120]=n.workflowInput,t[121]=r.form.instruction,t[122]=r.form.loadingWorkflows,t[123]=r.form.noWorkflows,t[124]=r.form.triggeredRun,t[125]=r.form.workflow,t[126]=d,t[127]=s,t[128]=p,t[129]=o,t[130]=c,t[131]=J):J=t[131];let de;t[132]===r.form.safety?de=t[133]:(de=(0,U.jsx)(Fe,{title:r.form.safety}),t[132]=r.form.safety,t[133]=de);let Y;t[134]!==n.afterRunMode||t[135]!==p?(Y=e=>{let t=e.target.value;p({safetyMode:t,...t!==`auto_apply`&&n.afterRunMode===`webhook`?{afterRunMode:`none`,webhookUrl:``}:{}})},t[134]=n.afterRunMode,t[135]=p,t[136]=Y):Y=t[136];let fe;t[137]===r.safety.suggest_only?fe=t[138]:(fe=(0,U.jsx)(N,{value:`suggest_only`,children:r.safety.suggest_only}),t[137]=r.safety.suggest_only,t[138]=fe);let pe;t[139]===r.safety.ask_before_apply?pe=t[140]:(pe=(0,U.jsx)(N,{value:`ask_before_apply`,children:r.safety.ask_before_apply}),t[139]=r.safety.ask_before_apply,t[140]=pe);let X;t[141]===r.safety.auto_apply?X=t[142]:(X=(0,U.jsx)(N,{value:`auto_apply`,children:r.safety.auto_apply}),t[141]=r.safety.auto_apply,t[142]=X);let me;t[143]!==n.safetyMode||t[144]!==Y||t[145]!==fe||t[146]!==pe||t[147]!==X?(me=(0,U.jsxs)(A,{className:Q,value:n.safetyMode,onChange:Y,children:[fe,pe,X]}),t[143]=n.safetyMode,t[144]=Y,t[145]=fe,t[146]=pe,t[147]=X,t[148]=me):me=t[148];let he=n.safetyMode===`suggest_only`?r.safety.suggestOnlyDescription:n.safetyMode===`ask_before_apply`?r.safety.askBeforeApplyDescription:r.safety.autoApplyDescription,ge;t[149]===he?ge=t[150]:(ge=(0,U.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:he}),t[149]=he,t[150]=ge);let _e;t[151]!==r.form.safety||t[152]!==me||t[153]!==ge?(_e=(0,U.jsxs)($,{label:r.form.safety,children:[me,ge]}),t[151]=r.form.safety,t[152]=me,t[153]=ge,t[154]=_e):_e=t[154];let ve;t[155]===r.form.afterRun?ve=t[156]:(ve=(0,U.jsx)(Fe,{title:r.form.afterRun}),t[155]=r.form.afterRun,t[156]=ve);let ye;t[157]===p?ye=t[158]:(ye=e=>p({afterRunMode:e.target.value}),t[157]=p,t[158]=ye);let be;t[159]===r.afterRun.none?be=t[160]:(be=(0,U.jsx)(N,{value:`none`,children:r.afterRun.none}),t[159]=r.afterRun.none,t[160]=be);let xe;t[161]===r.afterRun.saveToSession?xe=t[162]:(xe=(0,U.jsx)(N,{value:`saveToSession`,children:r.afterRun.saveToSession}),t[161]=r.afterRun.saveToSession,t[162]=xe);let Se=n.safetyMode!==`auto_apply`,Ce;t[163]!==r.afterRun.webhook||t[164]!==Se?(Ce=(0,U.jsx)(N,{value:`webhook`,disabled:Se,children:r.afterRun.webhook}),t[163]=r.afterRun.webhook,t[164]=Se,t[165]=Ce):Ce=t[165];let we;t[166]!==n.afterRunMode||t[167]!==ye||t[168]!==be||t[169]!==xe||t[170]!==Ce?(we=(0,U.jsxs)(A,{className:Q,value:n.afterRunMode,onChange:ye,children:[be,xe,Ce]}),t[166]=n.afterRunMode,t[167]=ye,t[168]=be,t[169]=xe,t[170]=Ce,t[171]=we):we=t[171];let Te;t[172]!==n.afterRunMode||t[173]!==n.webhookUrl||t[174]!==r.form.webhookUrl||t[175]!==p?(Te=n.afterRunMode===`webhook`?(0,U.jsx)($,{label:r.form.webhookUrl,children:(0,U.jsx)(`input`,{className:Q,value:n.webhookUrl,onChange:e=>p({webhookUrl:e.target.value})})}):null,t[172]=n.afterRunMode,t[173]=n.webhookUrl,t[174]=r.form.webhookUrl,t[175]=p,t[176]=Te):Te=t[176];let Ee;t[177]===r.form.reliability?Ee=t[178]:(Ee=(0,U.jsx)(Fe,{title:r.form.reliability}),t[177]=r.form.reliability,t[178]=Ee);let De;t[179]===p?De=t[180]:(De=e=>p({timeoutSeconds:e.target.value}),t[179]=p,t[180]=De);let Oe;t[181]!==n.timeoutSeconds||t[182]!==De?(Oe=(0,U.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.timeoutSeconds,onChange:De}),t[181]=n.timeoutSeconds,t[182]=De,t[183]=Oe):Oe=t[183];let Z;t[184]!==r.form.timeoutSeconds||t[185]!==Oe?(Z=(0,U.jsx)($,{label:r.form.timeoutSeconds,children:Oe}),t[184]=r.form.timeoutSeconds,t[185]=Oe,t[186]=Z):Z=t[186];let ke;t[187]===p?ke=t[188]:(ke=e=>p({disableAfterFailures:e.target.value}),t[187]=p,t[188]=ke);let Ae;t[189]!==n.disableAfterFailures||t[190]!==ke?(Ae=(0,U.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.disableAfterFailures,onChange:ke}),t[189]=n.disableAfterFailures,t[190]=ke,t[191]=Ae):Ae=t[191];let je;t[192]!==r.form.disableAfterFailures||t[193]!==Ae?(je=(0,U.jsx)($,{label:r.form.disableAfterFailures,children:Ae}),t[192]=r.form.disableAfterFailures,t[193]=Ae,t[194]=je):je=t[194];let Me;t[195]!==Z||t[196]!==je?(Me=(0,U.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Z,je]}),t[195]=Z,t[196]=je,t[197]=Me):Me=t[197];let Ie;return t[198]!==S||t[199]!==P||t[200]!==ne||t[201]!==re||t[202]!==F||t[203]!==I||t[204]!==L||t[205]!==oe||t[206]!==ue||t[207]!==J||t[208]!==de||t[209]!==_e||t[210]!==ve||t[211]!==we||t[212]!==Te||t[213]!==Ee||t[214]!==v||t[215]!==Me||t[216]!==x?(Ie=(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,U.jsxs)(`div`,{className:`grid gap-4`,children:[v,x,S,P,ne,re,F,I,L,oe,ue,J,de,_e,ve,we,Te,Ee,Me]})}),t[198]=S,t[199]=P,t[200]=ne,t[201]=re,t[202]=F,t[203]=I,t[204]=L,t[205]=oe,t[206]=ue,t[207]=J,t[208]=de,t[209]=_e,t[210]=ve,t[211]=we,t[212]=Te,t[213]=Ee,t[214]=v,t[215]=Me,t[216]=x,t[217]=Ie):Ie=t[217],Ie}function Ne(e){return(0,U.jsx)(N,{value:e.id,children:e.title||e.name},e.id)}function Pe(e){return(0,U.jsx)(N,{value:e.id,children:e.name||e.id},e.id)}var Q=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`;function $(e){let t=(0,V.c)(5),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,U.jsxs)(`div`,{className:`grid gap-1.5`,children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Fe(e){let t=(0,V.c)(3),{title:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,U.jsx)(ee,{className:`size-4 text-fg-muted`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,U.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 text-sm font-semibold text-fg`,children:[r,n]}),t[1]=n,t[2]=i),i}export{_e as AutomationsPage};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-preview-renderer-DonnL2dL.js","assets/preload-helper-zJ_50EbN.js","assets/excel-worksheet-utils-EyvwNT4X.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./messages-C22hxE1N.js";import{Qi as o,Xi as s}from"./index-CA2tR2vm.js";import{t as c}from"./preview-open-alternatives-DqV5OM4m.js";import{t as l}from"./use-blob-object-url-D4BFuzZB.js";var u=e(t(),1),d=n();function f(e){let t=e.trim(),n=t.match(/^<pptx\s+filename="([^"]*)">\s*/),r=t;n&&(r=t.slice(n[0].length),r=r.replace(/\s*<\/pptx>\s*$/u,``).trim());let i=[],a=/<slide number="(\d+)">([\s\S]*?)<\/slide>/gu,o;for(;(o=a.exec(r))!==null;){let e=Number.parseInt(o[1],10),t=o[2].trim();i.push({slideNumber:e,text:t})}let s=[],c=/<!--([\s\S]*?)-->/gu,l;for(;(l=c.exec(r))!==null;)s.push(l[1].trim());return i.length===0?{ok:!1,raw:e}:{ok:!0,slides:i,notes:s}}var p=r();function m(e){let t=(0,d.c)(13),{text:n,slideLabel:r,emptySlideLabel:i}=e,a;t[0]===n?a=t[1]:(a=f(n),t[0]=n,t[1]=a);let o=a;if(!o.ok){let e;return t[2]===o.raw?e=t[3]:(e=(0,p.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg`,children:o.raw}),t[2]=o.raw,t[3]=e),e}let s;if(t[4]!==i||t[5]!==o.notes||t[6]!==o.slides||t[7]!==r){let e=[];if(o.notes.length>0){let n;t[9]===o.notes?n=t[10]:(n=o.notes.map(h),t[9]=o.notes,t[10]=n);let r;t[11]===n?r=t[12]:(r=(0,p.jsx)(`div`,{className:`mb-2 border-b border-edge-subtle pb-2 dark:border-edge`,role:`status`,children:n},`notes`),t[11]=n,t[12]=r),e.push(r)}for(let t of o.slides)e.push((0,p.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 dark:border-edge`,children:[(0,p.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-fg`,children:r(t.slideNumber)}),(0,p.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-fg`,children:t.text.length>0?t.text:i})]},t.slideNumber));s=(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:e}),t[4]=i,t[5]=o.notes,t[6]=o.slides,t[7]=r,t[8]=s}else s=t[8];return s}function h(e){return(0,p.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e},e)}function g(e,t){return t===`pdf`?a(e).chat.attachmentPreviewPdfRendering:e===`zh`?t===`excel`?`正在加载电子表格…`:`正在加载文档…`:t===`excel`?`Loading spreadsheet...`:`Loading document...`}function _(e,t){e.innerHTML=``;let n=document.createElement(`p`);n.className=`p-4 text-sm text-fg-muted`,n.textContent=t,e.appendChild(n)}function v({language:e,buffer:t,kind:n,fileKey:r,containerEl:o,onPdfPageCount:s}){let c=(0,u.useRef)(null),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(!1);return(0,u.useLayoutEffect)(()=>{if(c.current?.(),c.current=null,d(null),p(!1),!t||!n||!o||!r)return;let l=!1;return _(o,g(e,n)),(async()=>{try{let r=await i(()=>import(`./attachment-preview-renderer-DonnL2dL.js`),__vite__mapDeps([0,1,2]));if(l)return;let u=a(e).chat;if(n===`pdf`){let{cleanup:e}=await r.renderPdfInContainer(o,t,{loadingText:u.attachmentPreviewPdfRendering,loadMoreHint:u.attachmentPreviewPdfLoadMore,onPageCount:s});c.current=e}else if(n===`excel`){let{cleanup:e,truncated:n}=await r.renderExcelInContainer(o,t,{truncationNotice:u.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)});c.current=e,l||p(n)}else if(n===`docx`){let{cleanup:e}=await r.renderDocxInContainer(o,t);c.current=e}}catch(e){l||d(e instanceof Error?e.message:String(e))}})(),()=>{l=!0,c.current?.(),c.current=null}},[t,n,o,r,e,s]),{error:l,excelTruncated:f}}function y(e){let t=(0,d.c)(12),{props:n,message:r}=e,i;t[0]===n.language?i=t[1]:(i=a(n.language),t[0]=n.language,t[1]=i);let o=i,s=n.descriptor.context===`workspace`,l=!!n.actions.onOpenWithSystemApp&&(n.actions.canOpenWithSystemApp??!0)&&s,u=s?o.workspace.openSystemApp:void 0,f=s?o.workspace.chooseApp:void 0,m;return t[2]!==o.chat.attachmentPreviewDownloadFull||t[3]!==r||t[4]!==n.actions.canChooseOpenWithApp||t[5]!==n.actions.onChooseOpenWithApp||t[6]!==n.actions.onDownload||t[7]!==n.actions.onOpenWithSystemApp||t[8]!==l||t[9]!==u||t[10]!==f?(m=(0,p.jsx)(c,{message:r,downloadLabel:o.chat.attachmentPreviewDownloadFull,onDownload:n.actions.onDownload,openSystemLabel:u,onOpenWithSystemApp:n.actions.onOpenWithSystemApp,canOpenWithSystemApp:l,chooseAppLabel:f,onChooseOpenWithApp:n.actions.onChooseOpenWithApp,canChooseOpenWithApp:n.actions.canChooseOpenWithApp}),t[2]=o.chat.attachmentPreviewDownloadFull,t[3]=r,t[4]=n.actions.canChooseOpenWithApp,t[5]=n.actions.onChooseOpenWithApp,t[6]=n.actions.onDownload,t[7]=n.actions.onOpenWithSystemApp,t[8]=l,t[9]=u,t[10]=f,t[11]=m):m=t[11],m}function b(e){let t=a(e.language);return e.descriptor.context===`workspace`?t.workspace.openElsewhereHint:t.chat.attachmentPreviewOpenElsewhereHint}function x(e){let t=(0,d.c)(24),n;bb0:{if(!e.binaryBuffer){n=null;break bb0}let r;if(t[0]!==e.binaryBuffer||t[1]!==e.descriptor.fileName||t[2]!==e.descriptor.mimeType){let n=o(e.descriptor.fileName)??e.descriptor.mimeType??`image/png`;r=new Blob([e.binaryBuffer],{type:n}),t[0]=e.binaryBuffer,t[1]=e.descriptor.fileName,t[2]=e.descriptor.mimeType,t[3]=r}else r=t[3];n=r}let r=l(n),i;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(i={x:0,y:0},t[4]=i):i=t[4];let[a,s]=(0,u.useState)(i),c=(0,u.useRef)(null),f=(0,u.useRef)(null),m=e.controls?.zoom??1,h=e.controls?.rotation??0,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{s({x:0,y:0})},t[5]=g):g=t[5];let _;if(t[6]!==e.descriptor.id||t[7]!==h?(_=[e.descriptor.id,h],t[6]=e.descriptor.id,t[7]=h,t[8]=_):_=t[8],(0,u.useEffect)(g,_),!r)return null;let v;t[9]!==a.x||t[10]!==a.y?(v=e=>{e.button===0&&(c.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,ox:a.x,oy:a.y},e.currentTarget.setPointerCapture(e.pointerId))},t[9]=a.x,t[10]=a.y,t[11]=v):v=t[11];let y,b,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{let t=c.current;!t||t.pointerId!==e.pointerId||s({x:t.ox+e.clientX-t.x,y:t.oy+e.clientY-t.y})},b=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},x=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},t[12]=y,t[13]=b,t[14]=x):(y=t[12],b=t[13],x=t[14]);let S=`translate(${a.x}px, ${a.y}px) scale(${m}) rotate(${h}deg)`,C=m>1?`grab`:`default`,w;t[15]!==S||t[16]!==C?(w={transform:S,cursor:C},t[15]=S,t[16]=C,t[17]=w):w=t[17];let T;t[18]!==r||t[19]!==w?(T=(0,p.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`max-h-full max-w-full select-none object-contain transition-transform duration-100`,style:w}),t[18]=r,t[19]=w,t[20]=T):T=t[20];let E;return t[21]!==T||t[22]!==v?(E=(0,p.jsx)(`div`,{ref:f,className:`flex min-h-0 flex-1 touch-none items-center justify-center overflow-hidden bg-surface-base px-3 py-4 dark:bg-surface-hover/20`,onPointerDown:v,onPointerMove:y,onPointerUp:b,onPointerCancel:x,children:T}),t[21]=T,t[22]=v,t[23]=E):E=t[23],E}function S(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`pdf`}),t[0]=e,t[1]=n),n}function C(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`docx`}),t[0]=e,t[1]=n),n}function w(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`excel`}),t[0]=e,t[1]=n),n}function T(e){let t=(0,d.c)(31),n=(0,u.useRef)(null),[r,i]=(0,u.useState)(null),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{n.current=e,i(e)},t[0]=o):o=t[0];let s=o,c=e.kind===`pdf`?e.controls?.setPageCount:void 0,l;t[1]!==r||t[2]!==e.binaryBuffer||t[3]!==e.descriptor.id||t[4]!==e.kind||t[5]!==e.language||t[6]!==c?(l={language:e.language,buffer:e.binaryBuffer,kind:e.kind,fileKey:e.descriptor.id,containerEl:r,onPdfPageCount:c},t[1]=r,t[2]=e.binaryBuffer,t[3]=e.descriptor.id,t[4]=e.kind,t[5]=e.language,t[6]=c,t[7]=l):l=t[7];let{error:f,excelTruncated:m}=v(l),h=a(e.language),g=e.kind===`pdf`?e.controls?.zoom??1:1,_=e.kind===`pdf`?e.controls?.rotation??0:0,x=e.kind===`pdf`?e.controls?.page??1:1,S,C;t[8]!==e.kind||t[9]!==_||t[10]!==g?(S=()=>{e.kind!==`pdf`||!n.current||(n.current.style.setProperty(`--xopc-preview-pdf-zoom`,String(g)),n.current.style.setProperty(`--xopc-preview-pdf-rotation`,`${_}deg`),n.current.querySelectorAll(`[data-pdf-page]`).forEach(e=>{let t=e.dataset.pdfBaseHeight??(e.offsetHeight>0?String(e.offsetHeight):void 0);t&&(e.dataset.pdfBaseHeight=t,e.style.height=`${Number(t)*g}px`),e.style.transformOrigin=`top center`,e.style.transform=`scale(${g}) rotate(${_}deg)`,e.style.marginBottom=g===1?``:`${Math.max(16,24*g)}px`}))},C=[e.kind,_,g],t[8]=e.kind,t[9]=_,t[10]=g,t[11]=S,t[12]=C):(S=t[11],C=t[12]),(0,u.useEffect)(S,C);let w,T;if(t[13]!==x||t[14]!==e.kind?(w=()=>{e.kind!==`pdf`||!n.current||n.current.querySelector(`[data-pdf-page="${x}"]`)?.scrollIntoView({block:`start`})},T=[x,e.kind],t[13]=x,t[14]=e.kind,t[15]=w,t[16]=T):(w=t[15],T=t[16]),(0,u.useEffect)(w,T),f){let n;t[17]===e?n=t[18]:(n=b(e),t[17]=e,t[18]=n);let r;t[19]!==e||t[20]!==n?(r=(0,p.jsx)(y,{props:e,message:n}),t[19]=e,t[20]=n,t[21]=r):r=t[21];let i;t[22]===f?i=t[23]:(i=(0,p.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}),t[22]=f,t[23]=i);let a;return t[24]!==r||t[25]!==i?(a=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[r,i]}),t[24]=r,t[25]=i,t[26]=a):a=t[26],a}if(e.kind===`excel`){let n=m?(0,p.jsx)(y,{props:e,message:h.chat.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)}):null,r;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[27]=r):r=t[27];let i;return t[28]===n?i=t[29]:(i=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[n,r]}),t[28]=n,t[29]=i),i}let E;return t[30]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[30]=E):E=t[30],E}function E(e){let t=(0,d.c)(23),n;t[0]===e.language?n=t[1]:(n=a(e.language),t[0]=e.language,t[1]=n);let r=n,i=e.extractedText||r.chat.attachmentPreviewNoText,o=!!e.extractedTextTruncated||i.length>3e5,c;t[2]===i?c=t[3]:(c=i.length>3e5?i.slice(0,s):i,t[2]=i,t[3]=c);let l=c,u;t[4]!==r.chat.attachmentPreviewOpenElsewhereTruncated||t[5]!==e||t[6]!==o?(u=o?(0,p.jsx)(y,{props:e,message:r.chat.attachmentPreviewOpenElsewhereTruncated}):null,t[4]=r.chat.attachmentPreviewOpenElsewhereTruncated,t[5]=e,t[6]=o,t[7]=u):u=t[7];let f;t[8]!==r.chat.attachmentPreviewPptxTruncated||t[9]!==o?(f=o?(0,p.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:r.chat.attachmentPreviewPptxTruncated}):null,t[8]=r.chat.attachmentPreviewPptxTruncated,t[9]=o,t[10]=f):f=t[10];let h;t[11]===r.chat.attachmentPreviewPptxSlide?h=t[12]:(h=e=>r.chat.attachmentPreviewPptxSlide.replaceAll(`{n}`,String(e)),t[11]=r.chat.attachmentPreviewPptxSlide,t[12]=h);let g;t[13]!==r.chat.attachmentPreviewPptxEmptySlide||t[14]!==h||t[15]!==l?(g=(0,p.jsx)(m,{text:l,slideLabel:h,emptySlideLabel:r.chat.attachmentPreviewPptxEmptySlide}),t[13]=r.chat.attachmentPreviewPptxEmptySlide,t[14]=h,t[15]=l,t[16]=g):g=t[16];let _;t[17]!==f||t[18]!==g?(_=(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[f,g]}),t[17]=f,t[18]=g,t[19]=_):_=t[19];let v;return t[20]!==u||t[21]!==_?(v=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[u,_]}),t[20]=u,t[21]=_,t[22]=v):v=t[22],v}export{C as DocxPreviewPluginView,x as InteractiveImagePreview,S as PdfPreviewPluginView,E as PptxPreviewPluginView,w as SpreadsheetPreviewPluginView};
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./messages-DmnbiNxU.js";import{ca as o,ua as s}from"./index-C2F0Clvm.js";import{t as c}from"./preview-open-alternatives-BTmk-XDM.js";import{t as l}from"./use-blob-object-url-D4BFuzZB.js";var u=e(t(),1),d=n();function f(e){let t=e.trim(),n=t.match(/^<pptx\s+filename="([^"]*)">\s*/),r=t;n&&(r=t.slice(n[0].length),r=r.replace(/\s*<\/pptx>\s*$/u,``).trim());let i=[],a=/<slide number="(\d+)">([\s\S]*?)<\/slide>/gu,o;for(;(o=a.exec(r))!==null;){let e=Number.parseInt(o[1],10),t=o[2].trim();i.push({slideNumber:e,text:t})}let s=[],c=/<!--([\s\S]*?)-->/gu,l;for(;(l=c.exec(r))!==null;)s.push(l[1].trim());return i.length===0?{ok:!1,raw:e}:{ok:!0,slides:i,notes:s}}var p=r();function m(e){let t=(0,d.c)(13),{text:n,slideLabel:r,emptySlideLabel:i}=e,a;t[0]===n?a=t[1]:(a=f(n),t[0]=n,t[1]=a);let o=a;if(!o.ok){let e;return t[2]===o.raw?e=t[3]:(e=(0,p.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg`,children:o.raw}),t[2]=o.raw,t[3]=e),e}let s;if(t[4]!==i||t[5]!==o.notes||t[6]!==o.slides||t[7]!==r){let e=[];if(o.notes.length>0){let n;t[9]===o.notes?n=t[10]:(n=o.notes.map(h),t[9]=o.notes,t[10]=n);let r;t[11]===n?r=t[12]:(r=(0,p.jsx)(`div`,{className:`mb-2 border-b border-edge-subtle pb-2 dark:border-edge`,role:`status`,children:n},`notes`),t[11]=n,t[12]=r),e.push(r)}for(let t of o.slides)e.push((0,p.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 dark:border-edge`,children:[(0,p.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-fg`,children:r(t.slideNumber)}),(0,p.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-fg`,children:t.text.length>0?t.text:i})]},t.slideNumber));s=(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:e}),t[4]=i,t[5]=o.notes,t[6]=o.slides,t[7]=r,t[8]=s}else s=t[8];return s}function h(e){return(0,p.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e},e)}function g(e,t){return t===`pdf`?a(e).chat.attachmentPreviewPdfRendering:e===`zh`?t===`excel`?`正在加载电子表格…`:`正在加载文档…`:t===`excel`?`Loading spreadsheet...`:`Loading document...`}function _(e,t){e.innerHTML=``;let n=document.createElement(`p`);n.className=`p-4 text-sm text-fg-muted`,n.textContent=t,e.appendChild(n)}function v({language:e,buffer:t,kind:n,fileKey:r,containerEl:o,onPdfPageCount:s}){let c=(0,u.useRef)(null),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(!1);return(0,u.useLayoutEffect)(()=>{if(c.current?.(),c.current=null,d(null),p(!1),!t||!n||!o||!r)return;let l=!1;return _(o,g(e,n)),(async()=>{try{let r=await i(()=>import(`./attachment-preview-renderer-DonnL2dL.js`),__vite__mapDeps([0,1,2]));if(l)return;let u=a(e).chat;if(n===`pdf`){let{cleanup:e}=await r.renderPdfInContainer(o,t,{loadingText:u.attachmentPreviewPdfRendering,loadMoreHint:u.attachmentPreviewPdfLoadMore,onPageCount:s});c.current=e}else if(n===`excel`){let{cleanup:e,truncated:n}=await r.renderExcelInContainer(o,t,{truncationNotice:u.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)});c.current=e,l||p(n)}else if(n===`docx`){let{cleanup:e}=await r.renderDocxInContainer(o,t);c.current=e}}catch(e){l||d(e instanceof Error?e.message:String(e))}})(),()=>{l=!0,c.current?.(),c.current=null}},[t,n,o,r,e,s]),{error:l,excelTruncated:f}}function y(e){let t=(0,d.c)(12),{props:n,message:r}=e,i;t[0]===n.language?i=t[1]:(i=a(n.language),t[0]=n.language,t[1]=i);let o=i,s=n.descriptor.context===`workspace`,l=!!n.actions.onOpenWithSystemApp&&(n.actions.canOpenWithSystemApp??!0)&&s,u=s?o.workspace.openSystemApp:void 0,f=s?o.workspace.chooseApp:void 0,m;return t[2]!==o.chat.attachmentPreviewDownloadFull||t[3]!==r||t[4]!==n.actions.canChooseOpenWithApp||t[5]!==n.actions.onChooseOpenWithApp||t[6]!==n.actions.onDownload||t[7]!==n.actions.onOpenWithSystemApp||t[8]!==l||t[9]!==u||t[10]!==f?(m=(0,p.jsx)(c,{message:r,downloadLabel:o.chat.attachmentPreviewDownloadFull,onDownload:n.actions.onDownload,openSystemLabel:u,onOpenWithSystemApp:n.actions.onOpenWithSystemApp,canOpenWithSystemApp:l,chooseAppLabel:f,onChooseOpenWithApp:n.actions.onChooseOpenWithApp,canChooseOpenWithApp:n.actions.canChooseOpenWithApp}),t[2]=o.chat.attachmentPreviewDownloadFull,t[3]=r,t[4]=n.actions.canChooseOpenWithApp,t[5]=n.actions.onChooseOpenWithApp,t[6]=n.actions.onDownload,t[7]=n.actions.onOpenWithSystemApp,t[8]=l,t[9]=u,t[10]=f,t[11]=m):m=t[11],m}function b(e){let t=a(e.language);return e.descriptor.context===`workspace`?t.workspace.openElsewhereHint:t.chat.attachmentPreviewOpenElsewhereHint}function x(e){let t=(0,d.c)(24),n;bb0:{if(!e.binaryBuffer){n=null;break bb0}let r;if(t[0]!==e.binaryBuffer||t[1]!==e.descriptor.fileName||t[2]!==e.descriptor.mimeType){let n=s(e.descriptor.fileName)??e.descriptor.mimeType??`image/png`;r=new Blob([e.binaryBuffer],{type:n}),t[0]=e.binaryBuffer,t[1]=e.descriptor.fileName,t[2]=e.descriptor.mimeType,t[3]=r}else r=t[3];n=r}let r=l(n),i;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(i={x:0,y:0},t[4]=i):i=t[4];let[a,o]=(0,u.useState)(i),c=(0,u.useRef)(null),f=(0,u.useRef)(null),m=e.controls?.zoom??1,h=e.controls?.rotation??0,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{o({x:0,y:0})},t[5]=g):g=t[5];let _;if(t[6]!==e.descriptor.id||t[7]!==h?(_=[e.descriptor.id,h],t[6]=e.descriptor.id,t[7]=h,t[8]=_):_=t[8],(0,u.useEffect)(g,_),!r)return null;let v;t[9]!==a.x||t[10]!==a.y?(v=e=>{e.button===0&&(c.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,ox:a.x,oy:a.y},e.currentTarget.setPointerCapture(e.pointerId))},t[9]=a.x,t[10]=a.y,t[11]=v):v=t[11];let y,b,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{let t=c.current;!t||t.pointerId!==e.pointerId||o({x:t.ox+e.clientX-t.x,y:t.oy+e.clientY-t.y})},b=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},x=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},t[12]=y,t[13]=b,t[14]=x):(y=t[12],b=t[13],x=t[14]);let S=`translate(${a.x}px, ${a.y}px) scale(${m}) rotate(${h}deg)`,C=m>1?`grab`:`default`,w;t[15]!==S||t[16]!==C?(w={transform:S,cursor:C},t[15]=S,t[16]=C,t[17]=w):w=t[17];let T;t[18]!==r||t[19]!==w?(T=(0,p.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`max-h-full max-w-full select-none object-contain transition-transform duration-100`,style:w}),t[18]=r,t[19]=w,t[20]=T):T=t[20];let E;return t[21]!==T||t[22]!==v?(E=(0,p.jsx)(`div`,{ref:f,className:`flex min-h-0 flex-1 touch-none items-center justify-center overflow-hidden bg-surface-base px-3 py-4 dark:bg-surface-hover/20`,onPointerDown:v,onPointerMove:y,onPointerUp:b,onPointerCancel:x,children:T}),t[21]=T,t[22]=v,t[23]=E):E=t[23],E}function S(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`pdf`}),t[0]=e,t[1]=n),n}function C(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`docx`}),t[0]=e,t[1]=n),n}function w(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`excel`}),t[0]=e,t[1]=n),n}function T(e){let t=(0,d.c)(31),n=(0,u.useRef)(null),[r,i]=(0,u.useState)(null),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{n.current=e,i(e)},t[0]=o):o=t[0];let s=o,c=e.kind===`pdf`?e.controls?.setPageCount:void 0,l;t[1]!==r||t[2]!==e.binaryBuffer||t[3]!==e.descriptor.id||t[4]!==e.kind||t[5]!==e.language||t[6]!==c?(l={language:e.language,buffer:e.binaryBuffer,kind:e.kind,fileKey:e.descriptor.id,containerEl:r,onPdfPageCount:c},t[1]=r,t[2]=e.binaryBuffer,t[3]=e.descriptor.id,t[4]=e.kind,t[5]=e.language,t[6]=c,t[7]=l):l=t[7];let{error:f,excelTruncated:m}=v(l),h=a(e.language),g=e.kind===`pdf`?e.controls?.zoom??1:1,_=e.kind===`pdf`?e.controls?.rotation??0:0,x=e.kind===`pdf`?e.controls?.page??1:1,S,C;t[8]!==e.kind||t[9]!==_||t[10]!==g?(S=()=>{e.kind!==`pdf`||!n.current||(n.current.style.setProperty(`--xopc-preview-pdf-zoom`,String(g)),n.current.style.setProperty(`--xopc-preview-pdf-rotation`,`${_}deg`),n.current.querySelectorAll(`[data-pdf-page]`).forEach(e=>{let t=e.dataset.pdfBaseHeight??(e.offsetHeight>0?String(e.offsetHeight):void 0);t&&(e.dataset.pdfBaseHeight=t,e.style.height=`${Number(t)*g}px`),e.style.transformOrigin=`top center`,e.style.transform=`scale(${g}) rotate(${_}deg)`,e.style.marginBottom=g===1?``:`${Math.max(16,24*g)}px`}))},C=[e.kind,_,g],t[8]=e.kind,t[9]=_,t[10]=g,t[11]=S,t[12]=C):(S=t[11],C=t[12]),(0,u.useEffect)(S,C);let w,T;if(t[13]!==x||t[14]!==e.kind?(w=()=>{e.kind!==`pdf`||!n.current||n.current.querySelector(`[data-pdf-page="${x}"]`)?.scrollIntoView({block:`start`})},T=[x,e.kind],t[13]=x,t[14]=e.kind,t[15]=w,t[16]=T):(w=t[15],T=t[16]),(0,u.useEffect)(w,T),f){let n;t[17]===e?n=t[18]:(n=b(e),t[17]=e,t[18]=n);let r;t[19]!==e||t[20]!==n?(r=(0,p.jsx)(y,{props:e,message:n}),t[19]=e,t[20]=n,t[21]=r):r=t[21];let i;t[22]===f?i=t[23]:(i=(0,p.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}),t[22]=f,t[23]=i);let a;return t[24]!==r||t[25]!==i?(a=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[r,i]}),t[24]=r,t[25]=i,t[26]=a):a=t[26],a}if(e.kind===`excel`){let n=m?(0,p.jsx)(y,{props:e,message:h.chat.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)}):null,r;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[27]=r):r=t[27];let i;return t[28]===n?i=t[29]:(i=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[n,r]}),t[28]=n,t[29]=i),i}let E;return t[30]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[30]=E):E=t[30],E}function E(e){let t=(0,d.c)(23),n;t[0]===e.language?n=t[1]:(n=a(e.language),t[0]=e.language,t[1]=n);let r=n,i=e.extractedText||r.chat.attachmentPreviewNoText,s=!!e.extractedTextTruncated||i.length>3e5,c;t[2]===i?c=t[3]:(c=i.length>3e5?i.slice(0,o):i,t[2]=i,t[3]=c);let l=c,u;t[4]!==r.chat.attachmentPreviewOpenElsewhereTruncated||t[5]!==e||t[6]!==s?(u=s?(0,p.jsx)(y,{props:e,message:r.chat.attachmentPreviewOpenElsewhereTruncated}):null,t[4]=r.chat.attachmentPreviewOpenElsewhereTruncated,t[5]=e,t[6]=s,t[7]=u):u=t[7];let f;t[8]!==r.chat.attachmentPreviewPptxTruncated||t[9]!==s?(f=s?(0,p.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:r.chat.attachmentPreviewPptxTruncated}):null,t[8]=r.chat.attachmentPreviewPptxTruncated,t[9]=s,t[10]=f):f=t[10];let h;t[11]===r.chat.attachmentPreviewPptxSlide?h=t[12]:(h=e=>r.chat.attachmentPreviewPptxSlide.replaceAll(`{n}`,String(e)),t[11]=r.chat.attachmentPreviewPptxSlide,t[12]=h);let g;t[13]!==r.chat.attachmentPreviewPptxEmptySlide||t[14]!==h||t[15]!==l?(g=(0,p.jsx)(m,{text:l,slideLabel:h,emptySlideLabel:r.chat.attachmentPreviewPptxEmptySlide}),t[13]=r.chat.attachmentPreviewPptxEmptySlide,t[14]=h,t[15]=l,t[16]=g):g=t[16];let _;t[17]!==f||t[18]!==g?(_=(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[f,g]}),t[17]=f,t[18]=g,t[19]=_):_=t[19];let v;return t[20]!==u||t[21]!==_?(v=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[u,_]}),t[20]=u,t[21]=_,t[22]=v):v=t[22],v}export{C as DocxPreviewPluginView,x as InteractiveImagePreview,S as PdfPreviewPluginView,E as PptxPreviewPluginView,w as SpreadsheetPreviewPluginView};