@xopcai/xopc 0.0.147 → 0.0.148

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 (97) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-DXeSSlw1.js → activity-store-B5h0UGWn.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CFdJKSjY.js → agent-avatar-dicebear-Dy5VvLUq.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-DKjbRpbA.js → agents-Ci1U96gj.js} +1 -1
  6. package/dist/gateway/static/root/assets/{api-Bs69B5zA.js → api-B3J2AmQW.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-ag1ViXT_.js → app-management-settings-panel-BbSLDubO.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-C6iMpwOM.js → appearance-settings-D9wK0UKA.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-Z6cQTPS6.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-Dwi3mIBy.js → archive-plugin-DaDK-FYa.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-BaCDoq40.js → attachment-load-CKiBdU_s.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-CwqtFgnw.js → automation-suggestion-card-8Qbnxq-p.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-DlupOxFQ.js → automations-page-D7HmeFdr.js} +1 -1
  14. package/dist/gateway/static/root/assets/{binary-plugins-DoAYhsxa.js → binary-plugins-ByZbwN2A.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-Bw72pO7S.js → block-editor-DGaI2ucU.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-settings-page-BwLoUBcZ.js → browser-settings-page-BZ25v96s.js} +1 -1
  17. package/dist/gateway/static/root/assets/{capability-presets-api-vdbAR65Q.js → capability-presets-api-DaPf3b5d.js} +1 -1
  18. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-BAsKbJgm.js → capability-presets-settings-panel-C0iHFbY9.js} +1 -1
  19. package/dist/gateway/static/root/assets/{channel-recipient-api-rTG26jpV.js → channel-recipient-api-DrbkoYyF.js} +1 -1
  20. package/dist/gateway/static/root/assets/{channels-settings-CxFWy0cE.js → channels-settings-Bc7FVeqs.js} +1 -1
  21. package/dist/gateway/static/root/assets/channels-status-swr-P3J5voxb.js +1 -0
  22. package/dist/gateway/static/root/assets/{connector-logo-DIMP4NWY.js → connector-logo-CiHea96v.js} +1 -1
  23. package/dist/gateway/static/root/assets/{connectors-page-BjQQwX62.js → connectors-page-oi41mE3U.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-kQq2e0BN.js → desktop-pet-DzdsBRdD.js} +1 -1
  25. package/dist/gateway/static/root/assets/{desktop-pet-settings-B6vtozMY.js → desktop-pet-settings-B-URlTdB.js} +1 -1
  26. package/dist/gateway/static/root/assets/{directory-picker-path-field-Dn5-e3v4.js → directory-picker-path-field-g_N_ROC-.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dreaming-settings-BzwIujPG.js → dreaming-settings-DnEe0Mxg.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-debug-page-D_e_hsEy.js → extension-debug-page-DPkoOQED.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-page-D15CWHBd.js → extension-page-Cf_gDelx.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-settings-page-D4P0n1om.js → extension-settings-page-YlXpJV9k.js} +1 -1
  31. package/dist/gateway/static/root/assets/{gateway-config-api-B4qZctjG.js → gateway-config-api-BxHgXB-I.js} +1 -1
  32. package/dist/gateway/static/root/assets/{gateway-settings-BvndV7TP.js → gateway-settings-CGphLe9T.js} +1 -1
  33. package/dist/gateway/static/root/assets/{gateway-startup-retry-BpgMunEb.js → gateway-startup-retry-ChI88pp7.js} +1 -1
  34. package/dist/gateway/static/root/assets/{goal-create-dialog-DrVHKXHq.js → goal-create-dialog-ClzciTH5.js} +1 -1
  35. package/dist/gateway/static/root/assets/{goal-detail-page-PHlCwv68.js → goal-detail-page-CyaLkWhd.js} +1 -1
  36. package/dist/gateway/static/root/assets/{goals-config-api-B6YJB_ct.js → goals-config-api-NoJKU8UZ.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goals-page-Hg9uyO6e.js → goals-page-C-srWhsP.js} +1 -1
  38. package/dist/gateway/static/root/assets/{goals-settings-BROWCIcL.js → goals-settings-kQ1pBOM9.js} +1 -1
  39. package/dist/gateway/static/root/assets/{heartbeat-settings-CoCwIOIg.js → heartbeat-settings-C6jSQCXQ.js} +1 -1
  40. package/dist/gateway/static/root/assets/index-DktduA8Z.css +1 -0
  41. package/dist/gateway/static/root/assets/{index-CxkNzw3e.js → index-twNrYC3D.js} +59 -59
  42. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Bm_AIYQ7.js → keyboard-shortcuts-settings-CIQ6wLqH.js} +1 -1
  43. package/dist/gateway/static/root/assets/{local-app-workbench-page-BJWFcxwG.js → local-app-workbench-page-DcaqgchY.js} +1 -1
  44. package/dist/gateway/static/root/assets/local-apps-page-BO6odwNn.js +1 -0
  45. package/dist/gateway/static/root/assets/{locale-store-Bp8joZck.js → locale-store-BP67jtYG.js} +1 -1
  46. package/dist/gateway/static/root/assets/{logs-page-DOmK61ey.js → logs-page-B_13EkK7.js} +1 -1
  47. package/dist/gateway/static/root/assets/{markdown-split-Dy7QpaAz.js → markdown-split-DbJZwtmM.js} +1 -1
  48. package/dist/gateway/static/root/assets/{media-plugins-3Lxliy9D.js → media-plugins-B0WH561o.js} +1 -1
  49. package/dist/gateway/static/root/assets/{messages-CQGpD-dC.js → messages-BIsSVgW7.js} +5 -5
  50. package/dist/gateway/static/root/assets/{models-hub-panel-DGCZom4o.js → models-hub-panel-DkCTjUj_.js} +1 -1
  51. package/dist/gateway/static/root/assets/{notes-page-BJtT4vSf.js → notes-page-B72S7M1Z.js} +1 -1
  52. package/dist/gateway/static/root/assets/{notes-workbench-B_bN7cOR.js → notes-workbench-CfWQczho.js} +2 -2
  53. package/dist/gateway/static/root/assets/{page-tabs-DKB6RDre.js → page-tabs-LjSEtOvG.js} +1 -1
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-Br_YhYHp.js → preview-open-alternatives-Cn8Jp9jw.js} +1 -1
  55. package/dist/gateway/static/root/assets/project-detail-page-BWOTQX4M.js +1 -0
  56. package/dist/gateway/static/root/assets/{projects-page-DvfL7fSe.js → projects-page-C81dHQ5i.js} +1 -1
  57. package/dist/gateway/static/root/assets/{remote-access-hub-DqwMXSXP.js → remote-access-hub-U1FQUBtJ.js} +1 -1
  58. package/dist/gateway/static/root/assets/{save-bar-controls-BgIE9BBh.js → save-bar-controls-BDUPII5R.js} +1 -1
  59. package/dist/gateway/static/root/assets/{schedule-field-BXDP-oMz.js → schedule-field-B1NY9MNs.js} +1 -1
  60. package/dist/gateway/static/root/assets/{schema-form-Dhv-SmjG.js → schema-form-CnsFMun1.js} +1 -1
  61. package/dist/gateway/static/root/assets/{sessions-page-B_mOZkQk.js → sessions-page-t6DzYLpM.js} +1 -1
  62. package/dist/gateway/static/root/assets/settings-advanced-gate-DggKrWED.js +1 -0
  63. package/dist/gateway/static/root/assets/{settings-collapsible-section-CUTExnlK.js → settings-collapsible-section-D9jJ6KlR.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-form-section-CmnDhsf0.js → settings-form-section-36IjMuUY.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-loading-skeleton-B79dq-XY.js → settings-loading-skeleton-DyYMmawg.js} +1 -1
  66. package/dist/gateway/static/root/assets/{settings-page-layout-DaFwstQw.js → settings-page-layout-BAP5LguT.js} +1 -1
  67. package/dist/gateway/static/root/assets/{settings-page-Db8uAv3X.js → settings-page-yv4TeHfF.js} +1 -1
  68. package/dist/gateway/static/root/assets/{setup-status-panel-BUSEj0KK.js → setup-status-panel-DncjFopP.js} +1 -1
  69. package/dist/gateway/static/root/assets/{share-preview-page-Bi00uXzV.js → share-preview-page-BBxZ9lX5.js} +1 -1
  70. package/dist/gateway/static/root/assets/{shares-settings-DzsTYfuX.js → shares-settings-Brx1LsY9.js} +1 -1
  71. package/dist/gateway/static/root/assets/skill-reload-api-C_sLcSxh.js +1 -0
  72. package/dist/gateway/static/root/assets/{skills-page-DeB1tQZL.js → skills-page-BPzqM78D.js} +1 -1
  73. package/dist/gateway/static/root/assets/{system-settings-panel-Cxaph7hW.js → system-settings-panel-B3ceUo4i.js} +1 -1
  74. package/dist/gateway/static/root/assets/{theme-store-eCTN1RpG.js → theme-store-_efiWyB8.js} +1 -1
  75. package/dist/gateway/static/root/assets/{typed-models-lib-CcZ_tyFY.js → typed-models-lib-Dp1PvxGZ.js} +1 -1
  76. package/dist/gateway/static/root/assets/{use-channel-catalog-C4PWbNoi.js → use-channel-catalog-XHelnCa_.js} +1 -1
  77. package/dist/gateway/static/root/assets/{user-context-page-QTVMx_hG.js → user-context-page-Dg_4sJJz.js} +1 -1
  78. package/dist/gateway/static/root/assets/{user-profile-fields-editor-CPOO9Jz5.js → user-profile-fields-editor-nOOg0uBi.js} +1 -1
  79. package/dist/gateway/static/root/assets/{user-profile-settings-panel-C8cgtSF7.js → user-profile-settings-panel-9fBPCoA9.js} +1 -1
  80. package/dist/gateway/static/root/assets/{utils-CiZK2KwH.js → utils-3AORlPIm.js} +1 -1
  81. package/dist/gateway/static/root/assets/{voice-api-key-field-b-YZtvUu.js → voice-api-key-field-Bc-xxEHw.js} +1 -1
  82. package/dist/gateway/static/root/assets/{work-discovery-page-4zVDOl2G.js → work-discovery-page-CCMe2E98.js} +1 -1
  83. package/dist/gateway/static/root/assets/{work-item-detail-page-CHe2tfkc.js → work-item-detail-page-CnVze8sW.js} +1 -1
  84. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-8SLCYeXE.js → workflow-run-setup-panel-DUKlCVcY.js} +1 -1
  85. package/dist/gateway/static/root/assets/{workflows-page-DEOFqiWn.js → workflows-page-1Hh-__Ur.js} +1 -1
  86. package/dist/gateway/static/root/index.html +7 -7
  87. package/dist/package.js +1 -1
  88. package/dist/src/config/agent-profile.js +1 -1
  89. package/dist/src/gateway/agents-admin.js +1 -1
  90. package/package.json +1 -1
  91. package/dist/gateway/static/root/assets/apps-page-CpX3lBFF.js +0 -1
  92. package/dist/gateway/static/root/assets/channels-status-swr-OKlqTtKJ.js +0 -1
  93. package/dist/gateway/static/root/assets/index-DjCSOyaN.css +0 -1
  94. package/dist/gateway/static/root/assets/local-apps-page-BsiZMrEf.js +0 -1
  95. package/dist/gateway/static/root/assets/project-detail-page-Dq8JouJj.js +0 -1
  96. package/dist/gateway/static/root/assets/settings-advanced-gate-BHGmH6YS.js +0 -1
  97. package/dist/gateway/static/root/assets/skill-reload-api-DSsdU081.js +0 -1
@@ -1 +1 @@
1
- import{d as e,i as t}from"./locale-store-Bp8joZck.js";async function n(){return(await t(e(`/api/local-apps`))).apps}async function r(n){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}`))).app}async function i(n){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}/validate`),{method:`POST`})).validation}async function a(n,r,i){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}/acceptance-runs`),{method:`POST`,body:JSON.stringify({sourceHash:r,...i})})).acceptance}async function o(n){return(await t(e(`/api/local-apps`),{method:`POST`,body:JSON.stringify(n)})).app}async function s(n){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}/install`),{method:`POST`})).app}async function c(n,r){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}/releases/${encodeURIComponent(r)}/rollback`),{method:`POST`})).app}async function l(n,r){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}/${r?`enable`:`disable`}`),{method:`POST`})).app}async function u(n){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}/install`),{method:`DELETE`})).app}export{a,u as c,n as i,i as l,r as n,c as o,s as r,l as s,o as t};
1
+ import{d as e,i as t}from"./locale-store-BP67jtYG.js";async function n(){return(await t(e(`/api/local-apps`))).apps}async function r(n){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}`))).app}async function i(n){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}/validate`),{method:`POST`})).validation}async function a(n,r,i){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}/acceptance-runs`),{method:`POST`,body:JSON.stringify({sourceHash:r,...i})})).acceptance}async function o(n){return(await t(e(`/api/local-apps`),{method:`POST`,body:JSON.stringify(n)})).app}async function s(n){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}/install`),{method:`POST`})).app}async function c(n,r){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}/releases/${encodeURIComponent(r)}/rollback`),{method:`POST`})).app}async function l(n,r){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}/${r?`enable`:`disable`}`),{method:`POST`})).app}async function u(n){return(await t(e(`/api/local-apps/${encodeURIComponent(n)}/install`),{method:`DELETE`})).app}export{a,u as c,n as i,i as l,r as n,c as o,s as r,l as s,o as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./copy-to-clipboard-HOJ79TWv.js";import{t as o}from"./messages-CQGpD-dC.js";import{d as s,i as c,n as l}from"./locale-store-Bp8joZck.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Ao as d,Io as f,Jo as p,Mo as m,Nl as h,No as g,Oo as _,Po as v,Tc as y,Yo as b,cs as x,io as S,jo as C,kt as w,ms as T}from"./index-CxkNzw3e.js";import{n as E,t as D}from"./settings-page-layout-DaFwstQw.js";import{r as O}from"./settings-loading-skeleton-B79dq-XY.js";import{r as k,t as A}from"./settings-form-section-CmnDhsf0.js";var j=n(),M=e(t(),1),N=r();function P(e,t){return e==null?t:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function F(e,t){return e===`PENDING_UPDATE`?t.pendingUpdate??t.generic:e===`UNINSTALLER_NOT_FOUND`?t.uninstallerNotFound??t.generic:e===`NOT_PACKAGED`?t.notPackaged??t.generic:t.generic}function I(e,t){if(e.platform===`darwin`)return t.uninstallDescDarwin;if(e.platform===`win32`)return t.uninstallDescWin;if(e.platform===`linux`){if(e.linuxPackageKind===`appimage`)return t.uninstallDescLinuxAppImage;if(e.linuxPackageKind===`deb`){let n=e.linuxDebPackageName??`xopc`;return t.uninstallDescLinuxDeb.replace(/\{\{package\}\}/g,n)}return t.uninstallDescLinuxUnknown}return t.uninstallDescLinuxUnknown}var L={info:null,loadError:null,actionError:null,copiedField:null,clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``,uninstallDialogOpen:!1,removeUserDataOnUninstall:!1,busy:!1};function R({api:e,messages:t,embedded:n=!0}){let[r,o]=(0,M.useReducer)(w,L),{info:s,loadError:c,actionError:l,copiedField:u,clearDialogOpen:f,clearConfirmChecked:S,clearConfirmText:E,uninstallDialogOpen:D,removeUserDataOnUninstall:k,busy:j}=r,R=(0,M.useCallback)(async()=>{if(e?.getUninstallInfo){o({type:`patch`,patch:{loadError:null}});try{o({type:`patch`,patch:{info:await e.getUninstallInfo()}})}catch(e){o({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}}},[e]);(0,M.useEffect)(()=>{R()},[R]);let z=async(e,n)=>{if(await a(e)){o({type:`patch`,patch:{actionError:null,copiedField:n}}),window.setTimeout(()=>o({type:`patch`,patch:{copiedField:null}}),2e3);return}o({type:`patch`,patch:{actionError:t.copyFailed}})},B=async()=>{if(e?.clearUserData){o({type:`patch`,patch:{busy:!0,actionError:null}});try{let n=await e.clearUserData();n.ok||o({type:`patch`,patch:{actionError:F(n.error,t.errors)}})}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.errors.generic}})}finally{o({type:`patch`,patch:{busy:!1,clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})}}},V=async()=>{if(e?.uninstallApp){o({type:`patch`,patch:{busy:!0,actionError:null}});try{let n=await e.uninstallApp({removeUserData:k});n.ok||o({type:`patch`,patch:{actionError:F(n.error,t.errors)}})}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.errors.generic}})}finally{o({type:`patch`,patch:{busy:!1,uninstallDialogOpen:!1}})}}};if(c)return(0,N.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:c});if(!s)return(0,N.jsx)(O,{rows:2});let H=!s.packaged,U=j||s.pendingUpdate||H,W=!H&&s.uninstallMode!==`unsupported`,G=I(s,t),K=S&&E.trim()===t.clearDataConfirmPhrase;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(A,{children:[n?(0,N.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,N.jsx)(y,{className:`size-4 text-accent`,strokeWidth:1.75}),t.title]}):null,l?(0,N.jsx)(`p`,{className:`mb-3 text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:l}):null,H?(0,N.jsxs)(`div`,{className:`mb-4 rounded-xl bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.devOnlyTitle}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.devOnlyBody})]}):null,s.pendingUpdate?(0,N.jsx)(`p`,{className:`mb-3 rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:t.pendingUpdateBlocked}):null,(0,N.jsxs)(`dl`,{className:`space-y-3 text-sm`,children:[(0,N.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,children:[(0,N.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:t.appPath}),(0,N.jsxs)(`dd`,{className:`mt-1 flex items-start justify-between gap-2`,children:[(0,N.jsx)(`code`,{className:`break-all text-xs text-fg`,children:s.appPath}),(0,N.jsxs)(`button`,{type:`button`,className:i(`inline-flex shrink-0 items-center gap-1 rounded-lg border border-edge px-2 py-1 text-xs text-fg hover:bg-surface-hover`,x.press),onClick:()=>void z(s.appPath,`app`),children:[(0,N.jsx)(h,{className:`size-3`,"aria-hidden":!0}),u===`app`?t.copied:t.copyPath]})]})]}),(0,N.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,children:[(0,N.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:t.dataPath}),(0,N.jsxs)(`dd`,{className:`mt-1 flex items-start justify-between gap-2`,children:[(0,N.jsx)(`code`,{className:`break-all text-xs text-fg`,children:s.dataPath}),(0,N.jsxs)(`button`,{type:`button`,className:i(`inline-flex shrink-0 items-center gap-1 rounded-lg border border-edge px-2 py-1 text-xs text-fg hover:bg-surface-hover`,x.press),onClick:()=>void z(s.dataPath,`data`),children:[(0,N.jsx)(h,{className:`size-3`,"aria-hidden":!0}),u===`data`?t.copied:t.copyPath]})]}),(0,N.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[t.dataSize,`: `,P(s.dataSizeBytes,t.dataSizeUnknown)]}),(0,N.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:t.sharedDataWarning})]})]}),(0,N.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,N.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.clearData}),(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.clearDataDesc})]}),(0,N.jsx)(`button`,{type:`button`,disabled:U,className:i(`inline-flex shrink-0 items-center justify-center rounded-lg border border-danger/40 bg-danger px-3 py-1.5 text-sm font-medium text-white hover:bg-danger/90 disabled:opacity-50`,x.press),onClick:()=>{o({type:`patch`,patch:{clearConfirmChecked:!1,clearConfirmText:``,clearDialogOpen:!0}})},children:t.clearData})]}),W?(0,N.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.uninstall}),(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:G})]}),(0,N.jsx)(`button`,{type:`button`,disabled:U,className:i(`inline-flex shrink-0 items-center justify-center rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-sm font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,x.press),onClick:()=>{o({type:`patch`,patch:{removeUserDataOnUninstall:!1,uninstallDialogOpen:!0}})},children:t.uninstall})]}):null]})]}),(0,N.jsx)(_,{open:f,onOpenChange:e=>{e||o({type:`patch`,patch:{clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})},children:(0,N.jsxs)(g,{children:[(0,N.jsx)(m,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,b)}),(0,N.jsxs)(d,{className:i(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,p,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,N.jsx)(v,{className:`text-base font-semibold text-fg`,children:t.clearDataConfirmTitle}),(0,N.jsx)(C,{className:`mt-2 text-sm text-fg-muted`,children:t.clearDataConfirmDesc}),(0,N.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,N.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:S,onChange:e=>o({type:`patch`,patch:{clearConfirmChecked:e.target.checked}})}),(0,N.jsx)(`span`,{children:t.clearDataConfirmCheckbox})]}),(0,N.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-fg`,htmlFor:`clear-data-confirm`,children:t.clearDataConfirmLabel}),(0,N.jsx)(`input`,{id:`clear-data-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:i(`w-full rounded-md border border-edge bg-surface-panel px-3 py-1.5 font-mono text-xs text-fg`,`placeholder:text-fg-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:border-edge`),placeholder:t.clearDataConfirmPhrase,value:E,onChange:e=>o({type:`patch`,patch:{clearConfirmText:e.target.value}})}),(0,N.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.clearDataConfirmHint})]}),(0,N.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,N.jsx)(T,{type:`button`,variant:`secondary`,disabled:j,onClick:()=>{o({type:`patch`,patch:{clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})},children:t.cancel}),(0,N.jsx)(T,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:j||!K,onClick:()=>void B(),children:t.confirmClear})]})]})]})}),W?(0,N.jsx)(_,{open:D,onOpenChange:e=>{e||o({type:`patch`,patch:{uninstallDialogOpen:!1}})},children:(0,N.jsxs)(g,{children:[(0,N.jsx)(m,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,b)}),(0,N.jsxs)(d,{className:i(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,p,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,N.jsx)(v,{className:`text-base font-semibold text-fg`,children:t.uninstallConfirmTitle}),(0,N.jsx)(C,{className:`mt-2 text-sm text-fg-muted`,children:G}),(0,N.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,N.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:k,onChange:e=>o({type:`patch`,patch:{removeUserDataOnUninstall:e.target.checked}})}),(0,N.jsx)(`span`,{children:t.removeUserDataCheckbox})]}),k?(0,N.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.clearDataConfirmDesc}):null,(0,N.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,N.jsx)(T,{type:`button`,variant:`secondary`,disabled:j,onClick:()=>o({type:`patch`,patch:{uninstallDialogOpen:!1}}),children:t.cancel}),(0,N.jsx)(T,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:j,onClick:()=>void V(),children:t.confirmUninstall})]})]})]})}):null]})}async function z(){return(await c(s(`/api/migrations/status`))).payload}async function B(){await c(s(`/api/migrations/apply`),{method:`POST`,body:`{}`})}function V({messages:e}){let{data:t,error:n,isLoading:r,mutate:i}=u(`settings-migration-status`,z,{refreshInterval:0,revalidateOnFocus:!1}),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(null);async function l(){o(!0),c(null);try{await B(),await i(),window.dispatchEvent(new CustomEvent(`config-reload`))}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}}if(r)return(0,N.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,N.jsx)(S,{className:`h-5 w-40 max-w-full`}),(0,N.jsx)(S,{className:`mt-2 h-4 w-64 max-w-full`})]});if(n)return(0,N.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e.title}),(0,N.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.checkFailed})]});let d=t?.items??[],f=d.filter(e=>e.status===`conflict`||e.status===`error`),p=d.filter(e=>e.safety===`auto`&&e.status===`planned`),m=f.length>0||d.some(e=>e.safety!==`auto`);return(0,N.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,N.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e.title}),(0,N.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:d.length===0?e.upToDate:m?e.manualAttention:e.safeRepairs.replace(`{{count}}`,String(p.length))})]}),p.length>0&&!m?(0,N.jsx)(T,{type:`button`,variant:`primary`,className:`px-3 py-1.5 text-xs`,onClick:()=>void l(),disabled:a,children:a?e.applying:e.apply}):null]}),d.length>0?(0,N.jsx)(`div`,{className:`mt-3 space-y-2`,children:d.map(e=>(0,N.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-3 py-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,N.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,N.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] uppercase tracking-wide text-fg-muted`,children:e.status})]}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.message})]},e.id))}):null,s?(0,N.jsx)(`p`,{className:`mt-3 text-sm text-red-500`,children:s}):null]})}function H(){let e=(0,j.c)(28),t=l(U),n;e[0]===t?n=e[1]:(n=o(t),e[0]=t,e[1]=n);let r=n.systemSettings,i=r.desktopApp,a=typeof window<`u`?window.electronAPI?.system:void 0;if(!f()||!a){let t;e[2]===i.title?t=e[3]:(t=(0,N.jsx)(E,{title:i.title}),e[2]=i.title,e[3]=t);let n;e[4]===i.migrations?n=e[5]:(n=(0,N.jsx)(V,{messages:i.migrations}),e[4]=i.migrations,e[5]=n);let a;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(a=k(),e[6]=a):a=e[6];let o;e[7]===r.desktopOnlyTitle?o=e[8]:(o=(0,N.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.desktopOnlyTitle}),e[7]=r.desktopOnlyTitle,e[8]=o);let s;e[9]===r.desktopOnlyBody?s=e[10]:(s=(0,N.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.desktopOnlyBody}),e[9]=r.desktopOnlyBody,e[10]=s);let c;e[11]!==o||e[12]!==s?(c=(0,N.jsxs)(`div`,{className:a,children:[o,s]}),e[11]=o,e[12]=s,e[13]=c):c=e[13];let l;return e[14]!==t||e[15]!==n||e[16]!==c?(l=(0,N.jsxs)(D,{gap:`gap-3`,children:[t,n,c]}),e[14]=t,e[15]=n,e[16]=c,e[17]=l):l=e[17],l}let s;e[18]===i.title?s=e[19]:(s=(0,N.jsx)(E,{title:i.title}),e[18]=i.title,e[19]=s);let c;e[20]===i.migrations?c=e[21]:(c=(0,N.jsx)(V,{messages:i.migrations}),e[20]=i.migrations,e[21]=c);let u;e[22]===i?u=e[23]:(u=(0,N.jsx)(R,{api:a,messages:i,embedded:!1}),e[22]=i,e[23]=u);let d;return e[24]!==s||e[25]!==c||e[26]!==u?(d=(0,N.jsxs)(D,{gap:`gap-6`,children:[s,c,u]}),e[24]=s,e[25]=c,e[26]=u,e[27]=d):d=e[27],d}function U(e){return e.language}export{H as AppManagementSettingsPanel};
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"./copy-to-clipboard-HOJ79TWv.js";import{t as o}from"./messages-BIsSVgW7.js";import{d as s,i as c,n as l}from"./locale-store-BP67jtYG.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Ao as d,Io as f,Jo as p,Mo as m,Nl as h,No as g,Oo as _,Po as v,Tc as y,Yo as b,cs as x,io as S,jo as C,kt as w,ms as T}from"./index-twNrYC3D.js";import{n as E,t as D}from"./settings-page-layout-BAP5LguT.js";import{r as O}from"./settings-loading-skeleton-DyYMmawg.js";import{r as k,t as A}from"./settings-form-section-36IjMuUY.js";var j=n(),M=e(t(),1),N=r();function P(e,t){return e==null?t:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function F(e,t){return e===`PENDING_UPDATE`?t.pendingUpdate??t.generic:e===`UNINSTALLER_NOT_FOUND`?t.uninstallerNotFound??t.generic:e===`NOT_PACKAGED`?t.notPackaged??t.generic:t.generic}function I(e,t){if(e.platform===`darwin`)return t.uninstallDescDarwin;if(e.platform===`win32`)return t.uninstallDescWin;if(e.platform===`linux`){if(e.linuxPackageKind===`appimage`)return t.uninstallDescLinuxAppImage;if(e.linuxPackageKind===`deb`){let n=e.linuxDebPackageName??`xopc`;return t.uninstallDescLinuxDeb.replace(/\{\{package\}\}/g,n)}return t.uninstallDescLinuxUnknown}return t.uninstallDescLinuxUnknown}var L={info:null,loadError:null,actionError:null,copiedField:null,clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``,uninstallDialogOpen:!1,removeUserDataOnUninstall:!1,busy:!1};function R({api:e,messages:t,embedded:n=!0}){let[r,o]=(0,M.useReducer)(w,L),{info:s,loadError:c,actionError:l,copiedField:u,clearDialogOpen:f,clearConfirmChecked:S,clearConfirmText:E,uninstallDialogOpen:D,removeUserDataOnUninstall:k,busy:j}=r,R=(0,M.useCallback)(async()=>{if(e?.getUninstallInfo){o({type:`patch`,patch:{loadError:null}});try{o({type:`patch`,patch:{info:await e.getUninstallInfo()}})}catch(e){o({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}}},[e]);(0,M.useEffect)(()=>{R()},[R]);let z=async(e,n)=>{if(await a(e)){o({type:`patch`,patch:{actionError:null,copiedField:n}}),window.setTimeout(()=>o({type:`patch`,patch:{copiedField:null}}),2e3);return}o({type:`patch`,patch:{actionError:t.copyFailed}})},B=async()=>{if(e?.clearUserData){o({type:`patch`,patch:{busy:!0,actionError:null}});try{let n=await e.clearUserData();n.ok||o({type:`patch`,patch:{actionError:F(n.error,t.errors)}})}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.errors.generic}})}finally{o({type:`patch`,patch:{busy:!1,clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})}}},V=async()=>{if(e?.uninstallApp){o({type:`patch`,patch:{busy:!0,actionError:null}});try{let n=await e.uninstallApp({removeUserData:k});n.ok||o({type:`patch`,patch:{actionError:F(n.error,t.errors)}})}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.errors.generic}})}finally{o({type:`patch`,patch:{busy:!1,uninstallDialogOpen:!1}})}}};if(c)return(0,N.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:c});if(!s)return(0,N.jsx)(O,{rows:2});let H=!s.packaged,U=j||s.pendingUpdate||H,W=!H&&s.uninstallMode!==`unsupported`,G=I(s,t),K=S&&E.trim()===t.clearDataConfirmPhrase;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(A,{children:[n?(0,N.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,N.jsx)(y,{className:`size-4 text-accent`,strokeWidth:1.75}),t.title]}):null,l?(0,N.jsx)(`p`,{className:`mb-3 text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:l}):null,H?(0,N.jsxs)(`div`,{className:`mb-4 rounded-xl bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.devOnlyTitle}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.devOnlyBody})]}):null,s.pendingUpdate?(0,N.jsx)(`p`,{className:`mb-3 rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:t.pendingUpdateBlocked}):null,(0,N.jsxs)(`dl`,{className:`space-y-3 text-sm`,children:[(0,N.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,children:[(0,N.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:t.appPath}),(0,N.jsxs)(`dd`,{className:`mt-1 flex items-start justify-between gap-2`,children:[(0,N.jsx)(`code`,{className:`break-all text-xs text-fg`,children:s.appPath}),(0,N.jsxs)(`button`,{type:`button`,className:i(`inline-flex shrink-0 items-center gap-1 rounded-lg border border-edge px-2 py-1 text-xs text-fg hover:bg-surface-hover`,x.press),onClick:()=>void z(s.appPath,`app`),children:[(0,N.jsx)(h,{className:`size-3`,"aria-hidden":!0}),u===`app`?t.copied:t.copyPath]})]})]}),(0,N.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,children:[(0,N.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:t.dataPath}),(0,N.jsxs)(`dd`,{className:`mt-1 flex items-start justify-between gap-2`,children:[(0,N.jsx)(`code`,{className:`break-all text-xs text-fg`,children:s.dataPath}),(0,N.jsxs)(`button`,{type:`button`,className:i(`inline-flex shrink-0 items-center gap-1 rounded-lg border border-edge px-2 py-1 text-xs text-fg hover:bg-surface-hover`,x.press),onClick:()=>void z(s.dataPath,`data`),children:[(0,N.jsx)(h,{className:`size-3`,"aria-hidden":!0}),u===`data`?t.copied:t.copyPath]})]}),(0,N.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[t.dataSize,`: `,P(s.dataSizeBytes,t.dataSizeUnknown)]}),(0,N.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:t.sharedDataWarning})]})]}),(0,N.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,N.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.clearData}),(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.clearDataDesc})]}),(0,N.jsx)(`button`,{type:`button`,disabled:U,className:i(`inline-flex shrink-0 items-center justify-center rounded-lg border border-danger/40 bg-danger px-3 py-1.5 text-sm font-medium text-white hover:bg-danger/90 disabled:opacity-50`,x.press),onClick:()=>{o({type:`patch`,patch:{clearConfirmChecked:!1,clearConfirmText:``,clearDialogOpen:!0}})},children:t.clearData})]}),W?(0,N.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.uninstall}),(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:G})]}),(0,N.jsx)(`button`,{type:`button`,disabled:U,className:i(`inline-flex shrink-0 items-center justify-center rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-sm font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,x.press),onClick:()=>{o({type:`patch`,patch:{removeUserDataOnUninstall:!1,uninstallDialogOpen:!0}})},children:t.uninstall})]}):null]})]}),(0,N.jsx)(_,{open:f,onOpenChange:e=>{e||o({type:`patch`,patch:{clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})},children:(0,N.jsxs)(g,{children:[(0,N.jsx)(m,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,b)}),(0,N.jsxs)(d,{className:i(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,p,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,N.jsx)(v,{className:`text-base font-semibold text-fg`,children:t.clearDataConfirmTitle}),(0,N.jsx)(C,{className:`mt-2 text-sm text-fg-muted`,children:t.clearDataConfirmDesc}),(0,N.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,N.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:S,onChange:e=>o({type:`patch`,patch:{clearConfirmChecked:e.target.checked}})}),(0,N.jsx)(`span`,{children:t.clearDataConfirmCheckbox})]}),(0,N.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,N.jsx)(`label`,{className:`block text-sm font-medium text-fg`,htmlFor:`clear-data-confirm`,children:t.clearDataConfirmLabel}),(0,N.jsx)(`input`,{id:`clear-data-confirm`,type:`text`,autoComplete:`off`,spellCheck:!1,className:i(`w-full rounded-md border border-edge bg-surface-panel px-3 py-1.5 font-mono text-xs text-fg`,`placeholder:text-fg-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:border-edge`),placeholder:t.clearDataConfirmPhrase,value:E,onChange:e=>o({type:`patch`,patch:{clearConfirmText:e.target.value}})}),(0,N.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.clearDataConfirmHint})]}),(0,N.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,N.jsx)(T,{type:`button`,variant:`secondary`,disabled:j,onClick:()=>{o({type:`patch`,patch:{clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})},children:t.cancel}),(0,N.jsx)(T,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:j||!K,onClick:()=>void B(),children:t.confirmClear})]})]})]})}),W?(0,N.jsx)(_,{open:D,onOpenChange:e=>{e||o({type:`patch`,patch:{uninstallDialogOpen:!1}})},children:(0,N.jsxs)(g,{children:[(0,N.jsx)(m,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,b)}),(0,N.jsxs)(d,{className:i(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,p,`rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,N.jsx)(v,{className:`text-base font-semibold text-fg`,children:t.uninstallConfirmTitle}),(0,N.jsx)(C,{className:`mt-2 text-sm text-fg-muted`,children:G}),(0,N.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,N.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:k,onChange:e=>o({type:`patch`,patch:{removeUserDataOnUninstall:e.target.checked}})}),(0,N.jsx)(`span`,{children:t.removeUserDataCheckbox})]}),k?(0,N.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.clearDataConfirmDesc}):null,(0,N.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,N.jsx)(T,{type:`button`,variant:`secondary`,disabled:j,onClick:()=>o({type:`patch`,patch:{uninstallDialogOpen:!1}}),children:t.cancel}),(0,N.jsx)(T,{type:`button`,variant:`secondary`,className:`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,disabled:j,onClick:()=>void V(),children:t.confirmUninstall})]})]})]})}):null]})}async function z(){return(await c(s(`/api/migrations/status`))).payload}async function B(){await c(s(`/api/migrations/apply`),{method:`POST`,body:`{}`})}function V({messages:e}){let{data:t,error:n,isLoading:r,mutate:i}=u(`settings-migration-status`,z,{refreshInterval:0,revalidateOnFocus:!1}),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(null);async function l(){o(!0),c(null);try{await B(),await i(),window.dispatchEvent(new CustomEvent(`config-reload`))}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}}if(r)return(0,N.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,N.jsx)(S,{className:`h-5 w-40 max-w-full`}),(0,N.jsx)(S,{className:`mt-2 h-4 w-64 max-w-full`})]});if(n)return(0,N.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e.title}),(0,N.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.checkFailed})]});let d=t?.items??[],f=d.filter(e=>e.status===`conflict`||e.status===`error`),p=d.filter(e=>e.safety===`auto`&&e.status===`planned`),m=f.length>0||d.some(e=>e.safety!==`auto`);return(0,N.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,N.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:e.title}),(0,N.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:d.length===0?e.upToDate:m?e.manualAttention:e.safeRepairs.replace(`{{count}}`,String(p.length))})]}),p.length>0&&!m?(0,N.jsx)(T,{type:`button`,variant:`primary`,className:`px-3 py-1.5 text-xs`,onClick:()=>void l(),disabled:a,children:a?e.applying:e.apply}):null]}),d.length>0?(0,N.jsx)(`div`,{className:`mt-3 space-y-2`,children:d.map(e=>(0,N.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-3 py-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,N.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,N.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] uppercase tracking-wide text-fg-muted`,children:e.status})]}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.message})]},e.id))}):null,s?(0,N.jsx)(`p`,{className:`mt-3 text-sm text-red-500`,children:s}):null]})}function H(){let e=(0,j.c)(28),t=l(U),n;e[0]===t?n=e[1]:(n=o(t),e[0]=t,e[1]=n);let r=n.systemSettings,i=r.desktopApp,a=typeof window<`u`?window.electronAPI?.system:void 0;if(!f()||!a){let t;e[2]===i.title?t=e[3]:(t=(0,N.jsx)(E,{title:i.title}),e[2]=i.title,e[3]=t);let n;e[4]===i.migrations?n=e[5]:(n=(0,N.jsx)(V,{messages:i.migrations}),e[4]=i.migrations,e[5]=n);let a;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(a=k(),e[6]=a):a=e[6];let o;e[7]===r.desktopOnlyTitle?o=e[8]:(o=(0,N.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.desktopOnlyTitle}),e[7]=r.desktopOnlyTitle,e[8]=o);let s;e[9]===r.desktopOnlyBody?s=e[10]:(s=(0,N.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.desktopOnlyBody}),e[9]=r.desktopOnlyBody,e[10]=s);let c;e[11]!==o||e[12]!==s?(c=(0,N.jsxs)(`div`,{className:a,children:[o,s]}),e[11]=o,e[12]=s,e[13]=c):c=e[13];let l;return e[14]!==t||e[15]!==n||e[16]!==c?(l=(0,N.jsxs)(D,{gap:`gap-3`,children:[t,n,c]}),e[14]=t,e[15]=n,e[16]=c,e[17]=l):l=e[17],l}let s;e[18]===i.title?s=e[19]:(s=(0,N.jsx)(E,{title:i.title}),e[18]=i.title,e[19]=s);let c;e[20]===i.migrations?c=e[21]:(c=(0,N.jsx)(V,{messages:i.migrations}),e[20]=i.migrations,e[21]=c);let u;e[22]===i?u=e[23]:(u=(0,N.jsx)(R,{api:a,messages:i,embedded:!1}),e[22]=i,e[23]=u);let d;return e[24]!==s||e[25]!==c||e[26]!==u?(d=(0,N.jsxs)(D,{gap:`gap-6`,children:[s,c,u]}),e[24]=s,e[25]=c,e[26]=u,e[27]=d):d=e[27],d}function U(e){return e.language}export{H as AppManagementSettingsPanel};
@@ -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-CQGpD-dC.js";import{n as i}from"./locale-store-Bp8joZck.js";import{i as a}from"./theme-store-eCTN1RpG.js";import{Ho as o,at as s,cs as c}from"./index-CxkNzw3e.js";import{n as l,t as u}from"./settings-page-layout-DaFwstQw.js";import{t as d}from"./settings-advanced-gate-BHGmH6YS.js";var f=e(),p=t();function m(){return n(`rounded-xl bg-surface-base px-4 py-1 sm:px-5`)}var h={default:{light:{canvas:`#ffffff`,panel:`#fafafa`,accent:`#3a6bff`,fg:`#111111`,muted:`#ececec`},dark:{canvas:`#0a0a0a`,panel:`#121212`,accent:`#3a6bff`,fg:`#f5f5f5`,muted:`#222222`}},emerald:{light:{canvas:`#f0fdf4`,panel:`#ffffff`,accent:`#059669`,fg:`#052e16`,muted:`#86efac`},dark:{canvas:`#000000`,panel:`#0a0a0a`,accent:`#10b981`,fg:`#d1fae5`,muted:`#134e2a`}},mono:{light:{canvas:`#ffffff`,panel:`#f5f5f5`,accent:`#111111`,fg:`#111111`,muted:`#e5e7eb`},dark:{canvas:`#101010`,panel:`#1a1a1a`,accent:`#737373`,fg:`#fafafa`,muted:`#333333`}},clay:{light:{canvas:`#fffaf0`,panel:`#ffffff`,accent:`#1a3a3a`,fg:`#0a0a0a`,muted:`#e5e5e5`},dark:{canvas:`#0a1a1a`,panel:`#1a2a2a`,accent:`#ffb084`,fg:`#fffaf0`,muted:`#2a3a3a`}}};function g(e){let t=(0,f.c)(24),{canvas:n,panel:r,accent:i,fg:a,muted:o}=e,s;t[0]===n?s=t[1]:(s={backgroundColor:n},t[0]=n,t[1]=s);let c;t[2]!==o||t[3]!==r?(c={backgroundColor:r,borderColor:o},t[2]=o,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,p.jsx)(`div`,{className:`size-1 shrink-0 rounded-full`,style:{backgroundColor:i}}),t[5]=i,t[6]=l);let u;t[7]===a?u=t[8]:(u=(0,p.jsx)(`div`,{className:`h-1 min-w-0 flex-1 rounded-full`,style:{backgroundColor:a,opacity:.85}}),t[7]=a,t[8]=u);let d;t[9]!==l||t[10]!==u?(d=(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11];let m;t[12]===o?m=t[13]:(m=(0,p.jsx)(`div`,{className:`h-1 w-2/3 max-w-[70%] rounded-full`,style:{backgroundColor:o}}),t[12]=o,t[13]=m);let h;t[14]===o?h=t[15]:(h=(0,p.jsx)(`div`,{className:`size-1/2 max-w-[55%] rounded-full`,style:{backgroundColor:o}}),t[14]=o,t[15]=h);let g;t[16]!==c||t[17]!==d||t[18]!==m||t[19]!==h?(g=(0,p.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-sm border p-1`,style:c,children:[d,m,h]}),t[16]=c,t[17]=d,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;return t[21]!==s||t[22]!==g?(_=(0,p.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col justify-center gap-1 p-1.5`,style:s,children:g}),t[21]=s,t[22]=g,t[23]=_):_=t[23],_}function _(e){let t=(0,f.c)(8),{scheme:n}=e,{light:r,dark:i}=h[n],a;t[0]===r?a=t[1]:(a=(0,p.jsx)(g,{...r}),t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,p.jsx)(`div`,{className:`w-px shrink-0 bg-black/12 dark:bg-white/12`,"aria-hidden":!0}),t[2]=o):o=t[2];let s;t[3]===i?s=t[4]:(s=(0,p.jsx)(g,{...i}),t[3]=i,t[4]=s);let c;return t[5]!==a||t[6]!==s?(c=(0,p.jsxs)(`div`,{className:`flex h-11 w-full overflow-hidden rounded-md border border-edge-subtle`,children:[a,o,s]}),t[5]=a,t[6]=s,t[7]=c):c=t[7],c}var v=[{value:`default`,labelKey:`colorSchemeDefault`},{value:`emerald`,labelKey:`colorSchemeLightGreen`},{value:`mono`,labelKey:`colorSchemeModernMono`},{value:`clay`,labelKey:`colorSchemeClay`}];function y(){let e=(0,f.c)(18),t=i(S),o;e[0]===t?o=e[1]:(o=r(t),e[0]=t,e[1]=o);let s=o.appearanceSettings,l=a(x),u=a(b),d;e[2]===s.colorSchemeTitle?d=e[3]:(d=(0,p.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:s.colorSchemeTitle}),e[2]=s.colorSchemeTitle,e[3]=d);let m;e[4]===s.colorSchemeDescription?m=e[5]:(m=(0,p.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:s.colorSchemeDescription}),e[4]=s.colorSchemeDescription,e[5]=m);let h;e[6]!==d||e[7]!==m?(h=(0,p.jsxs)(`div`,{className:`min-w-0`,children:[d,m]}),e[6]=d,e[7]=m,e[8]=h):h=e[8];let g;e[9]!==s||e[10]!==l||e[11]!==u?(g=v.map(e=>{let{value:t,labelKey:r}=e,i=l===t;return(0,p.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>u(t),className:n(`flex flex-col gap-2 rounded-xl border-2 p-2.5 text-left transition-[border-color,box-shadow,transform] duration-150`,c.pressCard,i?`border-accent shadow-[0_0_0_1px_var(--color-accent)]`:`border-edge-subtle hover:border-edge`),children:[(0,p.jsx)(_,{scheme:t}),(0,p.jsx)(`span`,{className:n(`text-xs font-medium leading-none`,i?`text-accent-fg`:`text-fg-muted`),children:s[r]})]},t)}),e[9]=s,e[10]=l,e[11]=u,e[12]=g):g=e[12];let y;e[13]===g?y=e[14]:(y=(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:g}),e[13]=g,e[14]=y);let C;return e[15]!==h||e[16]!==y?(C=(0,p.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-panel/50 px-3 py-3.5 sm:py-4`,children:[h,y]}),e[15]=h,e[16]=y,e[17]=C):C=e[17],C}function b(e){return e.setColorScheme}function x(e){return e.colorScheme}function S(e){return e.language}function C(){let e=(0,f.c)(27),t=i(E),n;e[0]===t?n=e[1]:(n=r(t),e[0]=t,e[1]=n);let a=n.appearanceSettings,o=s(T),c=s(w),l;e[2]===a.developerGroupTitle?l=e[3]:(l=(0,p.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:a.developerGroupTitle}),e[2]=a.developerGroupTitle,e[3]=l);let u;e[4]===a.developerGroupDescription?u=e[5]:(u=(0,p.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:a.developerGroupDescription}),e[4]=a.developerGroupDescription,e[5]=u);let d;e[6]!==l||e[7]!==u?(d=(0,p.jsxs)(`div`,{className:`min-w-0`,children:[l,u]}),e[6]=l,e[7]=u,e[8]=d):d=e[8];let m;e[9]===a.showRawToolDataTitle?m=e[10]:(m=(0,p.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:a.showRawToolDataTitle}),e[9]=a.showRawToolDataTitle,e[10]=m);let h;e[11]===a.showRawToolDataDescription?h=e[12]:(h=(0,p.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.showRawToolDataDescription}),e[11]=a.showRawToolDataDescription,e[12]=h);let g;e[13]!==m||e[14]!==h?(g=(0,p.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),e[13]=m,e[14]=h,e[15]=g):g=e[15];let _;e[16]===c?_=e[17]:(_=e=>c(e.target.checked),e[16]=c,e[17]=_);let v;e[18]!==o||e[19]!==_?(v=(0,p.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o,onChange:_}),e[18]=o,e[19]=_,e[20]=v):v=e[20];let y;e[21]!==g||e[22]!==v?(y=(0,p.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[g,v]}),e[21]=g,e[22]=v,e[23]=y):y=e[23];let b;return e[24]!==d||e[25]!==y?(b=(0,p.jsxs)(`div`,{className:`flex flex-col gap-2 py-3.5 sm:py-4`,children:[d,y]}),e[24]=d,e[25]=y,e[26]=b):b=e[26],b}function w(e){return e.setShowRawToolData}function T(e){return e.showRawToolData}function E(e){return e.language}function D(){let e=(0,f.c)(29),t=i(O),n;e[0]===t?n=e[1]:(n=r(t),e[0]=t,e[1]=n);let a=n.appearanceSettings,s;e[2]!==a.pageTitle||e[3]!==a.subtitle?(s=(0,p.jsx)(l,{title:a.pageTitle,subtitle:a.subtitle}),e[2]=a.pageTitle,e[3]=a.subtitle,e[4]=s):s=e[4];let c;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=m(),e[5]=c):c=e[5];let h;e[6]===a.languageTitle?h=e[7]:(h=(0,p.jsx)(`h2`,{id:`pref-language-heading`,className:`sr-only`,children:a.languageTitle}),e[6]=a.languageTitle,e[7]=h);let g;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,p.jsx)(o,{variant:`page`,sections:[`language`]}),e[8]=g):g=e[8];let _;e[9]===h?_=e[10]:(_=(0,p.jsxs)(`section`,{className:c,"aria-labelledby":`pref-language-heading`,children:[h,g]}),e[9]=h,e[10]=_);let v;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=m(),e[11]=v):v=e[11];let b;e[12]===a.themeTitle?b=e[13]:(b=(0,p.jsx)(`h2`,{id:`pref-appearance-heading`,className:`sr-only`,children:a.themeTitle}),e[12]=a.themeTitle,e[13]=b);let x,S;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,p.jsx)(o,{variant:`page`,sections:[`theme`,`font`]}),S=(0,p.jsx)(y,{}),e[14]=x,e[15]=S):(x=e[14],S=e[15]);let w;e[16]===b?w=e[17]:(w=(0,p.jsxs)(`section`,{className:v,"aria-labelledby":`pref-appearance-heading`,children:[b,x,S]}),e[16]=b,e[17]=w);let T;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(T=m(),e[18]=T):T=e[18];let E;e[19]===a.developerGroupTitle?E=e[20]:(E=(0,p.jsx)(`h2`,{id:`pref-developer-heading`,className:`sr-only`,children:a.developerGroupTitle}),e[19]=a.developerGroupTitle,e[20]=E);let D;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,p.jsx)(C,{}),e[21]=D):D=e[21];let k;e[22]===E?k=e[23]:(k=(0,p.jsx)(d,{children:(0,p.jsxs)(`section`,{className:T,"aria-labelledby":`pref-developer-heading`,children:[E,D]})}),e[22]=E,e[23]=k);let A;return e[24]!==s||e[25]!==w||e[26]!==k||e[27]!==_?(A=(0,p.jsxs)(u,{gap:`gap-6`,children:[s,_,w,k]}),e[24]=s,e[25]=w,e[26]=k,e[27]=_,e[28]=A):A=e[28],A}function O(e){return e.language}export{D as AppearanceSettingsPanel};
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-BIsSVgW7.js";import{n as i}from"./locale-store-BP67jtYG.js";import{i as a}from"./theme-store-_efiWyB8.js";import{Ho as o,at as s,cs as c}from"./index-twNrYC3D.js";import{n as l,t as u}from"./settings-page-layout-BAP5LguT.js";import{t as d}from"./settings-advanced-gate-DggKrWED.js";var f=e(),p=t();function m(){return n(`rounded-xl bg-surface-base px-4 py-1 sm:px-5`)}var h={default:{light:{canvas:`#ffffff`,panel:`#fafafa`,accent:`#3a6bff`,fg:`#111111`,muted:`#ececec`},dark:{canvas:`#0a0a0a`,panel:`#121212`,accent:`#3a6bff`,fg:`#f5f5f5`,muted:`#222222`}},emerald:{light:{canvas:`#f0fdf4`,panel:`#ffffff`,accent:`#059669`,fg:`#052e16`,muted:`#86efac`},dark:{canvas:`#000000`,panel:`#0a0a0a`,accent:`#10b981`,fg:`#d1fae5`,muted:`#134e2a`}},mono:{light:{canvas:`#ffffff`,panel:`#f5f5f5`,accent:`#111111`,fg:`#111111`,muted:`#e5e7eb`},dark:{canvas:`#101010`,panel:`#1a1a1a`,accent:`#737373`,fg:`#fafafa`,muted:`#333333`}},clay:{light:{canvas:`#fffaf0`,panel:`#ffffff`,accent:`#1a3a3a`,fg:`#0a0a0a`,muted:`#e5e5e5`},dark:{canvas:`#0a1a1a`,panel:`#1a2a2a`,accent:`#ffb084`,fg:`#fffaf0`,muted:`#2a3a3a`}}};function g(e){let t=(0,f.c)(24),{canvas:n,panel:r,accent:i,fg:a,muted:o}=e,s;t[0]===n?s=t[1]:(s={backgroundColor:n},t[0]=n,t[1]=s);let c;t[2]!==o||t[3]!==r?(c={backgroundColor:r,borderColor:o},t[2]=o,t[3]=r,t[4]=c):c=t[4];let l;t[5]===i?l=t[6]:(l=(0,p.jsx)(`div`,{className:`size-1 shrink-0 rounded-full`,style:{backgroundColor:i}}),t[5]=i,t[6]=l);let u;t[7]===a?u=t[8]:(u=(0,p.jsx)(`div`,{className:`h-1 min-w-0 flex-1 rounded-full`,style:{backgroundColor:a,opacity:.85}}),t[7]=a,t[8]=u);let d;t[9]!==l||t[10]!==u?(d=(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11];let m;t[12]===o?m=t[13]:(m=(0,p.jsx)(`div`,{className:`h-1 w-2/3 max-w-[70%] rounded-full`,style:{backgroundColor:o}}),t[12]=o,t[13]=m);let h;t[14]===o?h=t[15]:(h=(0,p.jsx)(`div`,{className:`size-1/2 max-w-[55%] rounded-full`,style:{backgroundColor:o}}),t[14]=o,t[15]=h);let g;t[16]!==c||t[17]!==d||t[18]!==m||t[19]!==h?(g=(0,p.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-sm border p-1`,style:c,children:[d,m,h]}),t[16]=c,t[17]=d,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;return t[21]!==s||t[22]!==g?(_=(0,p.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col justify-center gap-1 p-1.5`,style:s,children:g}),t[21]=s,t[22]=g,t[23]=_):_=t[23],_}function _(e){let t=(0,f.c)(8),{scheme:n}=e,{light:r,dark:i}=h[n],a;t[0]===r?a=t[1]:(a=(0,p.jsx)(g,{...r}),t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,p.jsx)(`div`,{className:`w-px shrink-0 bg-black/12 dark:bg-white/12`,"aria-hidden":!0}),t[2]=o):o=t[2];let s;t[3]===i?s=t[4]:(s=(0,p.jsx)(g,{...i}),t[3]=i,t[4]=s);let c;return t[5]!==a||t[6]!==s?(c=(0,p.jsxs)(`div`,{className:`flex h-11 w-full overflow-hidden rounded-md border border-edge-subtle`,children:[a,o,s]}),t[5]=a,t[6]=s,t[7]=c):c=t[7],c}var v=[{value:`default`,labelKey:`colorSchemeDefault`},{value:`emerald`,labelKey:`colorSchemeLightGreen`},{value:`mono`,labelKey:`colorSchemeModernMono`},{value:`clay`,labelKey:`colorSchemeClay`}];function y(){let e=(0,f.c)(18),t=i(S),o;e[0]===t?o=e[1]:(o=r(t),e[0]=t,e[1]=o);let s=o.appearanceSettings,l=a(x),u=a(b),d;e[2]===s.colorSchemeTitle?d=e[3]:(d=(0,p.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:s.colorSchemeTitle}),e[2]=s.colorSchemeTitle,e[3]=d);let m;e[4]===s.colorSchemeDescription?m=e[5]:(m=(0,p.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:s.colorSchemeDescription}),e[4]=s.colorSchemeDescription,e[5]=m);let h;e[6]!==d||e[7]!==m?(h=(0,p.jsxs)(`div`,{className:`min-w-0`,children:[d,m]}),e[6]=d,e[7]=m,e[8]=h):h=e[8];let g;e[9]!==s||e[10]!==l||e[11]!==u?(g=v.map(e=>{let{value:t,labelKey:r}=e,i=l===t;return(0,p.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>u(t),className:n(`flex flex-col gap-2 rounded-xl border-2 p-2.5 text-left transition-[border-color,box-shadow,transform] duration-150`,c.pressCard,i?`border-accent shadow-[0_0_0_1px_var(--color-accent)]`:`border-edge-subtle hover:border-edge`),children:[(0,p.jsx)(_,{scheme:t}),(0,p.jsx)(`span`,{className:n(`text-xs font-medium leading-none`,i?`text-accent-fg`:`text-fg-muted`),children:s[r]})]},t)}),e[9]=s,e[10]=l,e[11]=u,e[12]=g):g=e[12];let y;e[13]===g?y=e[14]:(y=(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:g}),e[13]=g,e[14]=y);let C;return e[15]!==h||e[16]!==y?(C=(0,p.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-panel/50 px-3 py-3.5 sm:py-4`,children:[h,y]}),e[15]=h,e[16]=y,e[17]=C):C=e[17],C}function b(e){return e.setColorScheme}function x(e){return e.colorScheme}function S(e){return e.language}function C(){let e=(0,f.c)(27),t=i(E),n;e[0]===t?n=e[1]:(n=r(t),e[0]=t,e[1]=n);let a=n.appearanceSettings,o=s(T),c=s(w),l;e[2]===a.developerGroupTitle?l=e[3]:(l=(0,p.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:a.developerGroupTitle}),e[2]=a.developerGroupTitle,e[3]=l);let u;e[4]===a.developerGroupDescription?u=e[5]:(u=(0,p.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:a.developerGroupDescription}),e[4]=a.developerGroupDescription,e[5]=u);let d;e[6]!==l||e[7]!==u?(d=(0,p.jsxs)(`div`,{className:`min-w-0`,children:[l,u]}),e[6]=l,e[7]=u,e[8]=d):d=e[8];let m;e[9]===a.showRawToolDataTitle?m=e[10]:(m=(0,p.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:a.showRawToolDataTitle}),e[9]=a.showRawToolDataTitle,e[10]=m);let h;e[11]===a.showRawToolDataDescription?h=e[12]:(h=(0,p.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.showRawToolDataDescription}),e[11]=a.showRawToolDataDescription,e[12]=h);let g;e[13]!==m||e[14]!==h?(g=(0,p.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),e[13]=m,e[14]=h,e[15]=g):g=e[15];let _;e[16]===c?_=e[17]:(_=e=>c(e.target.checked),e[16]=c,e[17]=_);let v;e[18]!==o||e[19]!==_?(v=(0,p.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o,onChange:_}),e[18]=o,e[19]=_,e[20]=v):v=e[20];let y;e[21]!==g||e[22]!==v?(y=(0,p.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[g,v]}),e[21]=g,e[22]=v,e[23]=y):y=e[23];let b;return e[24]!==d||e[25]!==y?(b=(0,p.jsxs)(`div`,{className:`flex flex-col gap-2 py-3.5 sm:py-4`,children:[d,y]}),e[24]=d,e[25]=y,e[26]=b):b=e[26],b}function w(e){return e.setShowRawToolData}function T(e){return e.showRawToolData}function E(e){return e.language}function D(){let e=(0,f.c)(29),t=i(O),n;e[0]===t?n=e[1]:(n=r(t),e[0]=t,e[1]=n);let a=n.appearanceSettings,s;e[2]!==a.pageTitle||e[3]!==a.subtitle?(s=(0,p.jsx)(l,{title:a.pageTitle,subtitle:a.subtitle}),e[2]=a.pageTitle,e[3]=a.subtitle,e[4]=s):s=e[4];let c;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=m(),e[5]=c):c=e[5];let h;e[6]===a.languageTitle?h=e[7]:(h=(0,p.jsx)(`h2`,{id:`pref-language-heading`,className:`sr-only`,children:a.languageTitle}),e[6]=a.languageTitle,e[7]=h);let g;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,p.jsx)(o,{variant:`page`,sections:[`language`]}),e[8]=g):g=e[8];let _;e[9]===h?_=e[10]:(_=(0,p.jsxs)(`section`,{className:c,"aria-labelledby":`pref-language-heading`,children:[h,g]}),e[9]=h,e[10]=_);let v;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=m(),e[11]=v):v=e[11];let b;e[12]===a.themeTitle?b=e[13]:(b=(0,p.jsx)(`h2`,{id:`pref-appearance-heading`,className:`sr-only`,children:a.themeTitle}),e[12]=a.themeTitle,e[13]=b);let x,S;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,p.jsx)(o,{variant:`page`,sections:[`theme`,`font`]}),S=(0,p.jsx)(y,{}),e[14]=x,e[15]=S):(x=e[14],S=e[15]);let w;e[16]===b?w=e[17]:(w=(0,p.jsxs)(`section`,{className:v,"aria-labelledby":`pref-appearance-heading`,children:[b,x,S]}),e[16]=b,e[17]=w);let T;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(T=m(),e[18]=T):T=e[18];let E;e[19]===a.developerGroupTitle?E=e[20]:(E=(0,p.jsx)(`h2`,{id:`pref-developer-heading`,className:`sr-only`,children:a.developerGroupTitle}),e[19]=a.developerGroupTitle,e[20]=E);let D;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,p.jsx)(C,{}),e[21]=D):D=e[21];let k;e[22]===E?k=e[23]:(k=(0,p.jsx)(d,{children:(0,p.jsxs)(`section`,{className:T,"aria-labelledby":`pref-developer-heading`,children:[E,D]})}),e[22]=E,e[23]=k);let A;return e[24]!==s||e[25]!==w||e[26]!==k||e[27]!==_?(A=(0,p.jsxs)(u,{gap:`gap-6`,children:[s,_,w,k]}),e[24]=s,e[25]=w,e[26]=k,e[27]=_,e[28]=A):A=e[28],A}function O(e){return e.language}export{D as AppearanceSettingsPanel};
@@ -0,0 +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{d as i,t as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./messages-BIsSVgW7.js";import{d as l,i as u,n as d,o as f,r as p}from"./locale-store-BP67jtYG.js";import{a as m,i as h}from"./vendor-swr-BIWyz7Rc.js";import{Ao as g,As as _,Dl as v,Fo as y,Ji as b,Js as x,Mo as S,No as C,Oo as w,Po as T,Pr as E,Rc as D,Tc as O,Xs as k,Zl as A,co as j,ec as M,hu as ee,io as N,jo as P,ks as te,kt as F,lo as I,mc as L,ms as R,oo as z,ou as B,so as V,uo as H,vs as ne}from"./index-twNrYC3D.js";import{t as U}from"./page-tabs-LjSEtOvG.js";var W=e(t(),1),G=n();function K(e){return e===`builtin`||e===`user`?e:`marketplace`}async function q(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 re(e){let t=await p(l(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function J(e){let t=await p(l(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function Y(e){let t=await p(l(`/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 q(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function X(e){let t=await p(l(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await q(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var Z=r();function ie(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var Q={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function $({className:e}){let t=c(d(e=>e.language)).extensionsPage,n=f(e=>!!e.token),r=V(),{mutate:i}=m(),[a,s]=(0,W.useReducer)(F,Q),{q:p,debounced:g,detailPkg:v,rowBusy:y,actionError:b,restartHint:x}=a,S=n?`marketplace-${g}`:null;(0,W.useEffect)(()=>{let e=window.setTimeout(()=>s({type:`patch`,patch:{debounced:p.trim()}}),300);return()=>window.clearTimeout(e)},[p]);let{data:C,isLoading:w,error:T}=h(S,async()=>u(g.length>0?l(`/api/marketplace?q=${encodeURIComponent(g)}`):l(`/api/marketplace`)),{revalidateOnFocus:!1}),k=(0,W.useCallback)(()=>{i(`gateway-extensions-list`),E()},[i]),j=(0,W.useCallback)(async(e,n)=>{s({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await J({name:e,overwrite:n});k(),r.requiresGatewayRestart&&s({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw s({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{s({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,k]),ee=(0,W.useCallback)(async e=>{s({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await X(e);k(),n.requiresGatewayRestart&&s({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw s({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{s({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,k]),P=C?.extensions??[];return(0,Z.jsxs)(`div`,{className:o(`flex flex-col gap-4`,e),children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(M,{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,Z.jsx)(`input`,{type:`search`,value:p,onChange:e=>s({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`})]}),T?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:T instanceof Error?T.message:t.marketplaceLoadFailed}):null,b?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b}):null,x?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:x}):null,w&&!C?(0,Z.jsx)(`ul`,{className:`flex flex-col gap-3`,"aria-label":t.marketplaceLoading,children:[0,1,2].map(e=>(0,Z.jsx)(`li`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2.5`,children:[(0,Z.jsx)(N,{className:`h-5 w-40`}),(0,Z.jsx)(N,{className:`h-4 w-full max-w-xl`}),(0,Z.jsx)(N,{className:`h-4 w-2/3 max-w-md`})]}),(0,Z.jsx)(N,{className:`h-8 w-20`})]})},e))}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-3`,children:P.length===0?(0,Z.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):P.map(e=>{let n=ie(r,e.id),i=y===e.id;return(0,Z.jsx)(`li`,{className:`list-none`,children:(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>s({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),s({type:`patch`,patch:{detailPkg:e.id}}))},className:o(`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,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,Z.jsx)(A,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,Z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,Z.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,Z.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Z.jsx)(O,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,Z.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,Z.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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,Z.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&ee(e.id).catch(()=>{})},className:o(`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:[i?(0,Z.jsx)(D,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(_,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s({type:`patch`,patch:{detailPkg:e.id}}),className:o(`inline-flex w-full items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:t.marketplaceReview})})]})},e.id)})}),v?(0,Z.jsx)(ae,{packageName:v,copy:t,extensions:r,onClose:()=>s({type:`patch`,patch:{detailPkg:null}}),onInstall:j,onUninstall:ee}):null]})}function ae(e){let t=(0,G.c)(102),{packageName:n,copy:r,extensions:i,onClose:s,onInstall:c,onUninstall:l}=e,[u,d]=(0,W.useState)(!1),[p,m]=(0,W.useState)(!1),v=f(ue)?`ext-mp-detail-${n}`:null,y;t[0]===n?y=t[1]:(y=async()=>re(n),t[0]=n,t[1]=y);let E;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E={revalidateOnFocus:!1},t[2]=E):E=t[2];let{data:O,error:k,isLoading:A}=h(v,y,E),j;t[3]!==i||t[4]!==n?(j=ie(i,n),t[3]=i,t[4]=n,t[5]=j):j=t[5];let M=j,P=M===`user`,F=O?.manifest?.permissions,I,L,R,z,B,V,H,U,K,q,J;if(t[6]!==r.detailBack||t[7]!==r.detailClose||t[8]!==r.marketplaceAuthor||t[9]!==r.marketplaceCodeRisk||t[10]!==r.marketplaceDependencies||t[11]!==r.marketplaceDetailLoadFailed||t[12]!==r.marketplaceDetailReadmeHeading||t[13]!==r.marketplaceDetailTitle||t[14]!==r.marketplaceDownloads||t[15]!==r.marketplaceIntegrity||t[16]!==r.marketplaceIntegrityVerified||t[17]!==r.marketplaceLifecycleScripts||t[18]!==r.marketplaceLoadFailed||t[19]!==r.marketplaceLoading||t[20]!==r.marketplaceNoReadme||t[21]!==r.marketplacePermissions||t[22]!==r.marketplacePermissionsNone||t[23]!==r.marketplaceRiskConfirm||t[24]!==r.marketplaceRiskTitle||t[25]!==r.marketplaceUnavailableBody||t[26]!==r.marketplaceUnavailableTitle||t[27]!==r.marketplaceVersion||t[28]!==O||t[29]!==k||t[30]!==M||t[31]!==A||t[32]!==s||t[33]!==F||t[34]!==p){let e=F&&typeof F==`object`&&!Array.isArray(F)?Object.entries(F):[],n;t[46]!==r.marketplaceNoReadme||t[47]!==O?(n=O?.readme?.trim()||(O?.description?.trim()?`### ${O.name}\n\n${O.description}`:`*${r.marketplaceNoReadme}*`),t[46]=r.marketplaceNoReadme,t[47]=O,t[48]=n):n=t[48];let i=n;R=w,z=!0,t[49]===s?B=t[50]:(B=e=>!e&&s(),t[49]=s,t[50]=B),L=C,t[51]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Z.jsx)(S,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[51]=J):J=t[51],I=g,U=`fixed left-1/2 top-1/2 z-[131] flex h-[min(44rem,calc(100vh-1.5rem))] 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`,K=le;let a;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)(ee,{className:`size-5`}),t[52]=a):a=t[52];let o;t[53]!==r.detailBack||t[54]!==s?(o=(0,Z.jsx)(`button`,{type:`button`,onClick:s,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:a}),t[53]=r.detailBack,t[54]=s,t[55]=o):o=t[55];let c;t[56]===r.marketplaceDetailTitle?c=t[57]:(c=(0,Z.jsx)(T,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[56]=r.marketplaceDetailTitle,t[57]=c);let l;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Z.jsx)(ne,{className:`size-5`}),t[58]=l):l=t[58];let u;t[59]!==r.detailClose||t[60]!==s?(u=(0,Z.jsx)(`button`,{type:`button`,onClick:s,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[59]=r.detailClose,t[60]=s,t[61]=u):u=t[61],t[62]!==o||t[63]!==c||t[64]!==u?(q=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[o,c,u]}),t[62]=o,t[63]=c,t[64]=u,t[65]=q):q=t[65],V=`min-h-0 flex-1 overflow-y-auto p-5`,H=A&&!O?(0,Z.jsxs)(`div`,{className:`space-y-4`,"aria-label":r.marketplaceLoading,children:[(0,Z.jsx)(N,{className:`h-6 w-48`}),(0,Z.jsx)(N,{className:`h-4 w-28`}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsx)(N,{className:`h-12`}),(0,Z.jsx)(N,{className:`h-12`})]}),(0,Z.jsx)(N,{className:`h-28 w-full`}),(0,Z.jsx)(N,{className:`h-36 w-full`})]}):k?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-red-300/70 bg-red-50 p-4 text-sm dark:border-red-900 dark:bg-red-950/30`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-red-700 dark:text-red-300`,children:r.marketplaceDetailLoadFailed}),(0,Z.jsx)(`p`,{className:`mt-1 break-words text-red-600 dark:text-red-400`,children:k instanceof Error?k.message:r.marketplaceLoadFailed})]}):O?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:O.name}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,Z.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:O.id})}),(0,Z.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,Z.jsx)(`dd`,{children:O.author.username})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,Z.jsx)(`dd`,{children:O.latestVersion.version})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,Z.jsx)(`dd`,{children:O.downloads})]})]}),M===`bundled`?null:(0,Z.jsxs)(`section`,{className:`mt-5 space-y-3 rounded-lg border border-edge bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[O.installability.available?(0,Z.jsx)(x,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,Z.jsx)(te,{className:`mt-0.5 size-5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:O.installability.available?r.marketplaceRiskTitle:r.marketplaceUnavailableTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:O.installability.available?r.marketplaceCodeRisk:O.installability.reason??r.marketplaceUnavailableBody})]})]}),O.installability.available?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceIntegrity}),(0,Z.jsx)(`dd`,{children:r.marketplaceIntegrityVerified})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDependencies}),(0,Z.jsx)(`dd`,{children:O.packageSummary?.dependencyCount??0})]})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-fg`,children:r.marketplacePermissions}),e.length>0?(0,Z.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(ce)}):(0,Z.jsx)(`p`,{className:`mt-1`,children:r.marketplacePermissionsNone})]}),(O.packageSummary?.lifecycleScripts.length??0)>0?(0,Z.jsxs)(`p`,{className:`text-xs leading-relaxed text-amber-700 dark:text-amber-300`,children:[r.marketplaceLifecycleScripts,`: `,O.packageSummary?.lifecycleScripts.join(`, `)]}):null,(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,Z.jsx)(`span`,{children:r.marketplaceRiskConfirm})]})]}):null]}),O.readme?.trim()?(0,Z.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,Z.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,Z.jsx)(b,{content:i})})]}):null,t[6]=r.detailBack,t[7]=r.detailClose,t[8]=r.marketplaceAuthor,t[9]=r.marketplaceCodeRisk,t[10]=r.marketplaceDependencies,t[11]=r.marketplaceDetailLoadFailed,t[12]=r.marketplaceDetailReadmeHeading,t[13]=r.marketplaceDetailTitle,t[14]=r.marketplaceDownloads,t[15]=r.marketplaceIntegrity,t[16]=r.marketplaceIntegrityVerified,t[17]=r.marketplaceLifecycleScripts,t[18]=r.marketplaceLoadFailed,t[19]=r.marketplaceLoading,t[20]=r.marketplaceNoReadme,t[21]=r.marketplacePermissions,t[22]=r.marketplacePermissionsNone,t[23]=r.marketplaceRiskConfirm,t[24]=r.marketplaceRiskTitle,t[25]=r.marketplaceUnavailableBody,t[26]=r.marketplaceUnavailableTitle,t[27]=r.marketplaceVersion,t[28]=O,t[29]=k,t[30]=M,t[31]=A,t[32]=s,t[33]=F,t[34]=p,t[35]=I,t[36]=L,t[37]=R,t[38]=z,t[39]=B,t[40]=V,t[41]=H,t[42]=U,t[43]=K,t[44]=q,t[45]=J}else I=t[35],L=t[36],R=t[37],z=t[38],B=t[39],V=t[40],H=t[41],U=t[42],K=t[43],q=t[44],J=t[45];let Y;t[66]!==V||t[67]!==H?(Y=(0,Z.jsx)(`div`,{className:V,children:H}),t[66]=V,t[67]=H,t[68]=Y):Y=t[68];let X;t[69]!==u||t[70]!==r.marketplaceBuiltinGoBuiltin||t[71]!==r.marketplaceBuiltinManageHint||t[72]!==r.marketplaceInstall||t[73]!==r.marketplaceReinstall||t[74]!==r.marketplaceReinstallConfirm||t[75]!==r.marketplaceUninstall||t[76]!==r.marketplaceUninstallConfirm||t[77]!==O||t[78]!==M||t[79]!==s||t[80]!==c||t[81]!==l||t[82]!==n||t[83]!==p||t[84]!==P?(X=O?(0,Z.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:M===`bundled`?(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,Z.jsx)(a,{to:`/extensions?tab=builtin`,onClick:s,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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:u||!O.installability.available||!p,onClick:()=>{P&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),c(n,P).catch(se).finally(()=>d(!1)))},className:o(`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,Z.jsx)(D,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,P?r.marketplaceReinstall:r.marketplaceInstall]}),P?(0,Z.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),l(n).then(()=>s()).catch(oe).finally(()=>d(!1)))},className:o(`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,Z.jsx)(_,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[69]=u,t[70]=r.marketplaceBuiltinGoBuiltin,t[71]=r.marketplaceBuiltinManageHint,t[72]=r.marketplaceInstall,t[73]=r.marketplaceReinstall,t[74]=r.marketplaceReinstallConfirm,t[75]=r.marketplaceUninstall,t[76]=r.marketplaceUninstallConfirm,t[77]=O,t[78]=M,t[79]=s,t[80]=c,t[81]=l,t[82]=n,t[83]=p,t[84]=P,t[85]=X):X=t[85];let Q;t[86]!==I||t[87]!==Y||t[88]!==X||t[89]!==U||t[90]!==K||t[91]!==q?(Q=(0,Z.jsxs)(I,{className:U,onOpenAutoFocus:K,children:[q,Y,X]}),t[86]=I,t[87]=Y,t[88]=X,t[89]=U,t[90]=K,t[91]=q,t[92]=Q):Q=t[92];let $;t[93]!==L||t[94]!==Q||t[95]!==J?($=(0,Z.jsxs)(L,{children:[J,Q]}),t[93]=L,t[94]=Q,t[95]=J,t[96]=$):$=t[96];let ae;return t[97]!==R||t[98]!==z||t[99]!==B||t[100]!==$?(ae=(0,Z.jsx)(R,{defaultOpen:z,onOpenChange:B,children:$}),t[97]=R,t[98]=z,t[99]=B,t[100]=$,t[101]=ae):ae=t[101],ae}function oe(){}function se(){}function ce(e){let[t,n]=e;return(0,Z.jsxs)(`li`,{className:`break-words`,children:[(0,Z.jsx)(`code`,{children:t}),`: `,Array.isArray(n)?n.join(`, `):String(n)]},t)}function le(e){return e.preventDefault()}function ue(e){return!!e.token}function de(){let e=d(e=>e.language),t=c(e),n=y(e=>e.setPageHeader),r=y(e=>e.clearPageHeader),o=V(),s=j(),[l,u]=i(),f=K(l.get(`tab`)),p=l.get(`q`)??``,[m,h]=(0,W.useState)(f),[g,_]=(0,W.useState)(p),[v,b]=(0,W.useState)(null),x=l.toString(),S=(0,W.useRef)(x);if(S.current!==x){S.current=x;let e=K(l.get(`tab`)),t=l.get(`q`)??``;h(t=>t===e?t:e),_(e=>e===t?e:t)}(0,W.useEffect)(()=>{u(e=>{let t=new URLSearchParams(e),n=g.trim();return n?t.set(`q`,n):t.delete(`q`),m===`marketplace`?t.delete(`tab`):t.set(`tab`,m),t.toString()===e.toString()?e:t},{replace:!0})},[m,g,u]);let C=(0,W.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),w=(0,W.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),T=m===`builtin`?C:w,E=(0,W.useMemo)(()=>{let t=g.trim().toLowerCase(),n=T;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)},[T,g,e]);if((0,W.useEffect)(()=>{b(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?fe(e)===fe(t)&&e.active===t.active?e:t:null})},[o]),(0,W.useLayoutEffect)(()=>(n({startExtra:null,main:(0,Z.jsx)(`div`,{className:`min-w-0`,children:(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.extensionsPage.title})}),end:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(R,{asChild:!0,variant:`secondary`,className:`h-9`,children:(0,Z.jsxs)(a,{to:`/local-apps`,"aria-label":t.extensionsPage.openLocalApps,title:t.extensionsPage.openLocalApps,children:[(0,Z.jsx)(B,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:t.extensionsPage.openLocalApps})]})}),(0,Z.jsx)(R,{asChild:!0,variant:`primary`,className:`h-9`,children:(0,Z.jsxs)(a,{to:`/local-apps/new`,children:[(0,Z.jsx)(L,{className:`size-4`}),t.extensionsPage.createLocalApp]})})]})}),()=>r()),[r,t.extensionsPage.createLocalApp,t.extensionsPage.openLocalApps,t.extensionsPage.title,n]),s&&m!==`marketplace`)return(0,Z.jsx)(ye,{});let D=m!==`marketplace`&&T.length>0;return(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[(0,Z.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,Z.jsx)(U,{items:[{id:`marketplace`,label:t.extensionsPage.tabMarketplace},{id:`builtin`,label:t.extensionsPage.tabBuiltin,count:C.length},{id:`user`,label:t.extensionsPage.tabUser,count:w.length}],activeTab:m,onChange:h,ariaLabel:t.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`}),D?(0,Z.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,Z.jsx)(M,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:g,onChange:e=>_(e.target.value),placeholder:t.extensionsPage.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]}),m===`marketplace`?(0,Z.jsx)($,{}):m===`builtin`&&C.length===0?(0,Z.jsx)(xe,{message:t.extensionsPage.emptyBuiltin}):m===`user`&&w.length===0?(0,Z.jsx)(xe,{message:t.extensionsPage.emptyUser}):E.length===0?(0,Z.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.extensionsPage.noSearchResults}):(0,Z.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:E.map(e=>(0,Z.jsx)(ge,{extension:e,copy:t.extensionsPage,showSourceBadge:m===`user`,onOpen:()=>b(e)},e.id))})]}),v?(0,Z.jsx)(_e,{extension:v,copy:t.extensionsPage,onClose:()=>b(null)},v.id):null]})}function fe(e){return e.activationEligible??e.active}function pe(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function me(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function he(e,t){let n=fe(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function ge(e){let t=(0,G.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,c;t[0]===n?c=t[1]:(c=fe(n),t[0]=n,t[1]=c);let l=c,u=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=o(`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]=d):d=t[2];let f=n.name||n.id,p;t[3]===f?p=t[4]:(p=f.charAt(0).toUpperCase(),t[3]=f,t[4]=p);let m;t[5]===p?m=t[6]:(m=(0,Z.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:p}),t[5]=p,t[6]=m);let h;t[7]===n.name?h=t[8]:(h=(0,Z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=h);let g;t[9]===n.version?g=t[10]:(g=n.version?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=g);let _;t[11]!==h||t[12]!==g?(_=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[h,g]}),t[11]=h,t[12]=g,t[13]=_):_=t[13];let v;t[14]!==r.statusEnabled||t[15]!==l?(v=l?(0,Z.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,Z.jsx)(s,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,Z.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,Z.jsx)(L,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=l,t[16]=v):v=t[16];let y;t[17]!==_||t[18]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[_,v]}),t[17]=_,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,Z.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]!==u?(C=(0,Z.jsx)(`span`,{title:u,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]=u,t[27]=C):C=t[27];let w;t[28]!==r||t[29]!==n||t[30]!==i?(w=n.source===`bundled`?(0,Z.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}):i?(0,Z.jsx)(`span`,{title:pe(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:me(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=w):w=t[31];let T;t[32]!==C||t[33]!==w?(T=(0,Z.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,Z.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]!==m?(D=(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[m,E]}),t[39]=E,t[40]=m,t[41]=D):D=t[41];let O;return t[42]!==a||t[43]!==D?(O=(0,Z.jsx)(`button`,{type:`button`,onClick:a,className:d,children:D}),t[42]=a,t[43]=D,t[44]=O):O=t[44],O}function _e({extension:e,copy:t,onClose:n}){let{mutate:r}=m(),[i,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(!1),f=e.activationEligible===!0,p=(0,W.useCallback)(async()=>{if(e.source===`bundled`){l(null),d(!1),s(!0);try{let{requiresGatewayRestart:t}=await Y({extensionId:e.id,enabled:!f});await r(`gateway-extensions-list`),E(),d(t)}catch(e){l(e instanceof Error?e.message:t.builtinToggleFailed)}finally{s(!1)}}},[f,t.builtinToggleFailed,e.id,e.source,r]),h=e.ui?.contributions?.pages??[],_=e.ui?.contributions?.settingsPanels??[],y=e.ui?.contributions?.chatWidgets??[],b=e.ui?.contributions?.sidebarPanels??[],x=h.find(e=>e.showInNav)??h[0],O=_[0],A=x?z(e.id,x):null,j=O?`/settings/ext/${e.id}/${O.id}`:e.hasConfigSchema||I(e)?`/settings/ext/${e.id}`:null;return(0,Z.jsx)(w,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,Z.jsxs)(C,{children:[(0,Z.jsx)(S,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,Z.jsxs)(g,{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,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,Z.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,Z.jsx)(ee,{className:`size-5`})}),(0,Z.jsx)(T,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,Z.jsxs)(P,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,Z.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,Z.jsx)(ne,{className:`size-5`})})]}),(0,Z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,Z.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,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,Z.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,pe(e,t)]}),e.version?(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,Z.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:he(e,t)}),e.source===`bundled`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.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,Z.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,Z.jsx)(R,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void p(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(D,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):f?t.builtinToggleDisable:t.builtinToggleEnable})]}),c?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:c}):null,u?(0,Z.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,Z.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&&(h.length>0||_.length>0||y.length>0)?(0,Z.jsxs)(`section`,{className:`mt-8`,children:[(0,Z.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,Z.jsx)(ve,{template:t.badgePages,count:h.length,hidden:h.length===0}),(0,Z.jsx)(ve,{template:t.badgeSettings,count:_.length,hidden:_.length===0}),(0,Z.jsx)(ve,{template:t.badgeWidgets,count:y.length,hidden:y.length===0}),(0,Z.jsx)(ve,{template:t.badgeSidebar,count:b.length,hidden:b.length===0})]})]}):null,H(e)&&(A||j)?(0,Z.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[A?(0,Z.jsxs)(a,{to:A,onClick:n,className:o(`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,Z.jsx)(v,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,j?(0,Z.jsxs)(a,{to:j,onClick:n,className:o(`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,Z.jsx)(k,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,Z.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function ve(e){let t=(0,G.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,Z.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 ye(){let e=(0,G.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,Z.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,Z.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,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Z.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,Z.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(be)})]})}),e[4]=a):a=e[4],a}function be(e){return(0,Z.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge-subtle bg-surface-base shadow-surface`},e)}function xe(e){let t=(0,G.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.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,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{de as ExtensionsPage};
@@ -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-CQGpD-dC.js";import{t as a}from"./jszip.min-DT31yWkU.js";import{t as o}from"./preview-open-alternatives-Br_YhYHp.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-BIsSVgW7.js";import{t as a}from"./jszip.min-DT31yWkU.js";import{t as o}from"./preview-open-alternatives-Cn8Jp9jw.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{$a as t}from"./index-CxkNzw3e.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{$a as t}from"./index-twNrYC3D.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{l as n}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as r}from"./cn-BQ_8x0bT.js";import{t as i}from"./messages-CQGpD-dC.js";import{n as a}from"./locale-store-Bp8joZck.js";import{i as o}from"./vendor-swr-BIWyz7Rc.js";import{Ws as s,Xl as c,b as l,ms as u,qc as d,v as f,x as p,y as m}from"./index-CxkNzw3e.js";var h=e(),g=t();function _(e){let t=(0,h.c)(45),{title:p,description:_,prompt:x,coverage:S,className:C,variant:w}=e,T=w===void 0?`card`:w,E=a(b),D=i(E).automations.suggestions,O=i(E).automations,k=n(),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=A):A=t[0];let{data:j}=o(S?`automation-suggestion-coverage`:null,y,A),M=S?j?.automations.find(e=>l(e,S)):void 0,N=M?f(M,O):[];if(T===`titleAction`){if(M){let e;t[1]===C?e=t[2]:(e=r(`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 n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,g.jsx)(c,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=n):n=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:[n,(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=r(`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 n;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,g.jsx)(d,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=n):n=t[8];let i;t[9]!==_||t[10]!==p?(i=(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:_,children:p}),t[9]=_,t[10]=p,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 o;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,g.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),t[15]=o):o=t[15],(0,g.jsxs)(`section`,{className:e,children:[n,i,(0,g.jsxs)(u,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:a,children:[o,D.create]})]})}if(M){let e;t[16]===C?e=t[17]:(e=r(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,C),t[16]=C,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,g.jsx)(c,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=n):n=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:[n,(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:m(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=r(`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)(d,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=F):F=t[26];let I;t[27]===p?I=t[28]:(I=(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:p}),t[27]=p,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)(s,{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 p.list()}function b(e){return e.language}export{_ as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{l as n}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as r}from"./cn-BQ_8x0bT.js";import{t as i}from"./messages-BIsSVgW7.js";import{n as a}from"./locale-store-BP67jtYG.js";import{i as o}from"./vendor-swr-BIWyz7Rc.js";import{Ws as s,Xl as c,b as l,ms as u,qc as d,v as f,x as p,y as m}from"./index-twNrYC3D.js";var h=e(),g=t();function _(e){let t=(0,h.c)(45),{title:p,description:_,prompt:x,coverage:S,className:C,variant:w}=e,T=w===void 0?`card`:w,E=a(b),D=i(E).automations.suggestions,O=i(E).automations,k=n(),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=A):A=t[0];let{data:j}=o(S?`automation-suggestion-coverage`:null,y,A),M=S?j?.automations.find(e=>l(e,S)):void 0,N=M?f(M,O):[];if(T===`titleAction`){if(M){let e;t[1]===C?e=t[2]:(e=r(`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 n;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,g.jsx)(c,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=n):n=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:[n,(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=r(`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 n;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,g.jsx)(d,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=n):n=t[8];let i;t[9]!==_||t[10]!==p?(i=(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:_,children:p}),t[9]=_,t[10]=p,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 o;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,g.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),t[15]=o):o=t[15],(0,g.jsxs)(`section`,{className:e,children:[n,i,(0,g.jsxs)(u,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:a,children:[o,D.create]})]})}if(M){let e;t[16]===C?e=t[17]:(e=r(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,C),t[16]=C,t[17]=e);let n;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,g.jsx)(c,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=n):n=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:[n,(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:m(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=r(`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)(d,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=F):F=t[26];let I;t[27]===p?I=t[28]:(I=(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:p}),t[27]=p,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)(s,{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 p.list()}function b(e){return e.language}export{_ as t};
@@ -1,4 +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{d as i,t as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./circle-alert-RzVebuX2.js";import{t as c}from"./messages-CQGpD-dC.js";import{n as l}from"./locale-store-Bp8joZck.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Ao as d,As as f,Bc as p,Ci as m,Dl as h,Ei as g,Fc as _,Fo as v,Ir as y,Ji as b,Js as x,Ko as S,Lo as C,Mo as w,No as T,Oo as E,Po as D,Ql as O,Sc as k,Si as A,Wo as j,Ws as ee,Xl as te,_s as M,bc as N,bu as P,eo as ne,eu as re,gc as F,ht as ie,io as I,ko as ae,mc as oe,ms as L,oa as se,pl as ce,sc as R,tu as z,vs as le,wi as ue,x as B,xi as de}from"./index-CxkNzw3e.js";import{t as fe}from"./format-cron-label-arqgGlVV.js";import{a as V,i as H,n as pe,r as me,t as he}from"./workflow-run-setup-panel-8SLCYeXE.js";var U=e(t(),1),W=n(),G=1e3,K=60*G,ge=60*K,_e=24*ge,q=7*_e,ve={minute:K,hour:ge,day:_e,week:q};function ye(e){return e===`zh`?`zh-CN`:`en-US`}function be(e,t,n){return n===`zh`?`${e} ${t===`week`?`周`:t===`day`?`天`:t===`hour`?`小时`:t===`minute`?`分钟`:`秒`}`:new Intl.NumberFormat(ye(n),{style:`unit`,unit:t,unitDisplay:`long`}).format(e)}function xe(e,t){return t===`zh`?e.join(` `):new Intl.ListFormat(`en-US`,{type:`conjunction`}).format(e)}function Se(e,t){let n=typeof e==`number`?e:Number.parseFloat(e);return Math.max(K,Math.round((Number.isFinite(n)&&n>0?n:1)*ve[t]))}function Ce(e,t,n){let r=typeof e==`number`?e:Number.parseFloat(e),i=Number.isFinite(r)&&r>0?r:1;return String(Number.parseFloat((i*ve[t]/ve[n]).toFixed(6)))}function we(e,t){let n=Math.max(G,Math.round(e)),r=n===_e?[{unit:`hour`,ms:ge}]:n>=q&&n%q===0?[{unit:`week`,ms:q}]:n>=_e?[{unit:`day`,ms:_e},{unit:`hour`,ms:ge},{unit:`minute`,ms:K},{unit:`second`,ms:G}]:n>=ge?[{unit:`hour`,ms:ge},{unit:`minute`,ms:K},{unit:`second`,ms:G}]:n>=K?[{unit:`minute`,ms:K},{unit:`second`,ms:G}]:[{unit:`second`,ms:G}],i=n,a=[];for(let{unit:e,ms:n}of r){let r=Math.floor(i/n);r<=0||(a.push(be(r,e,t)),i%=n)}return xe(a,t)}function Te(e,t){let n=we(e,t);return t===`zh`?`每 ${n}运行一次`:`Runs every ${n}`}function Ee(e,t){return new Intl.DateTimeFormat(ye(t),{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e))}function De(e){return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function Oe(e,t,n=Date.now()){let r=new Date(e),i=Math.round((De(r)-De(new Date(n)))/_e),a=new Intl.DateTimeFormat(ye(t),{hour:`2-digit`,minute:`2-digit`}).format(r);return i===0?t===`zh`?`今天 ${a}`:`today at ${a}`:i===1?t===`zh`?`明天 ${a}`:`tomorrow at ${a}`:i===-1?t===`zh`?`昨天 ${a}`:`yesterday at ${a}`:Ee(e,t)}function ke(e,t){return e.eventType===`goal.status_changed`&&e.payloadMatch?.status===`blocked`?t.trigger.goalBlockedWhen:e.eventType===`note.created`?t.trigger.noteCreatedWhen:e.eventType===`workflow.run.completed`&&e.payloadMatch?.status===`failed`?t.trigger.workflowFailedWhen:e.eventType===`session.transcript.updated`?t.trigger.sessionUpdatedWhen:t.trigger.eventWithType.replace(`{type}`,e.eventType)}function Ae(e,t,n,r){if(e.kind===`manual`)return t.trigger.manualWhen;if(e.kind===`webhook`)return t.trigger.webhookWhen;if(e.kind===`event`)return ke(e,t);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,Oe(Date.parse(i.at),r)):i.kind===`interval`?Te(i.everyMs,r):fe(i.expr,ye(r),n.scheduleBadge,{timezone:i.tz})}function J(e,t,n,r=Date.now()){return e.enabled?e.state.nextRunAtMs?Oe(e.state.nextRunAtMs,n,r):e.trigger.kind===`manual`?t.info.noAutomaticTrigger:e.trigger.kind===`event`||e.trigger.kind===`webhook`?t.info.waitingForTrigger:t.info.noUpcomingRun:t.info.pausedNoAutomaticRuns}function je(e,t,n,r=Date.now()){if(!e.state.lastRunAtMs)return t.info.notRunYet;let i=Oe(e.state.lastRunAtMs,n,r),a=e.state.lastRunStatus;return a?`${i} · ${t.status[a]}`:i}var Y=r(),X={name:``,description:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalValue:`1`,intervalUnit:`hour`,cronExpr:`0 9 * * *`,webhookSecretId:``,onceAt:``,eventType:``,eventSource:``,eventPayloadMatch:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,safetyMode:`suggest_only`,timeoutSeconds:`300`,afterRunMode:`none`,webhookUrl:``,disableAfterFailures:`3`},Me=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function Ne(e,t,n){return e?Ee(e,n):t.never}function Z(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 Pe(e){return e.safety?.mode??`auto_apply`}function Fe(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 Ie(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 Le(e){return e.status===`running`||e.status===`queued`}function Re(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function ze(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function Be(e){return!!ze(e)}function Ve(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function He(e){return Le(e)?0:Re(e)?1:e.status===`succeeded`?2:3}function Ue(e){return[...e].sort((e,t)=>{let n=He(e)-He(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function We(e){let t=(0,W.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,U.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,U.useEffect)(a,o),r}function Ge(){let e=(0,W.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Y.jsx)(I,{className:`h-4 w-36`}),(0,Y.jsx)(I,{className:`h-3 w-56 max-w-full`})]}),(0,Y.jsx)(I,{className:`h-7 w-20 rounded-full`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Y.jsxs)(`section`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:[t,(0,Y.jsx)(`div`,{className:`mt-4 grid gap-2`,children:Array.from({length:6}).map(Ke)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Y.jsx)(I,{className:`h-4 w-32`}),i=(0,Y.jsx)(I,{className:`mt-4 h-24 rounded-lg`}),e[2]=r,e[3]=i):(r=e[2],i=e[3]);let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Y.jsx)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:(0,Y.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[n,(0,Y.jsxs)(`section`,{className:`hidden rounded-xl bg-surface-panel p-4 shadow-surface xl:block`,children:[r,i,(0,Y.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,Y.jsx)(I,{className:`h-12 rounded-lg`}),(0,Y.jsx)(I,{className:`h-12 rounded-lg`}),(0,Y.jsx)(I,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function Ke(e,t){return(0,Y.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(I,{className:`size-4 rounded-full`}),(0,Y.jsx)(I,{className:`h-4 w-32`}),(0,Y.jsx)(I,{className:`h-5 w-20 rounded-full`})]}),(0,Y.jsx)(I,{className:`mt-3 h-4 w-full`}),(0,Y.jsx)(I,{className:`mt-2 h-4 w-3/5`})]}),(0,Y.jsx)(I,{className:`h-8 w-24 rounded-md`})]})},t)}function qe(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;if(e.triggerMode===`manual`)o={kind:`manual`};else if(e.triggerMode===`once`)o={kind:`schedule`,schedule:{kind:`once`,at:new Date(e.onceAt).toISOString()}};else if(e.triggerMode===`webhook`)o={kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}};else if(e.triggerMode===`goalBlocked`)o={kind:`event`,eventType:`goal.status_changed`,source:`goals`,payloadMatch:{status:`blocked`}};else if(e.triggerMode===`noteCreated`)o={kind:`event`,eventType:`note.created`,source:`notes`};else if(e.triggerMode===`workflowFailed`)o={kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}};else if(e.triggerMode===`sessionUpdated`)o={kind:`event`,eventType:`session.transcript.updated`,source:`sessions`};else if(e.triggerMode===`event`){let t=e.eventPayloadMatch.trim()?JSON.parse(e.eventPayloadMatch):void 0;o={kind:`event`,eventType:e.eventType.trim(),...e.eventSource.trim()?{source:e.eventSource.trim()}:{},...t?{payloadMatch:t}:{}}}else o=e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:Se(e.intervalValue,e.intervalUnit)}}: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=pe(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 Je(e){let t=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);if(t)return{triggerMode:`daily`,time:`${t[2].padStart(2,`0`)}:${t[1].padStart(2,`0`)}`,weekday:`1`,cronExpr:e};let n=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-6])$/);return n?{triggerMode:`weekly`,time:`${n[2].padStart(2,`0`)}:${n[1].padStart(2,`0`)}`,weekday:n[3],cronExpr:e}:{triggerMode:`cron`,time:X.time,weekday:X.weekday,cronExpr:e}}function Ye(e){let t=[[`week`,10080*6e4],[`day`,1440*6e4],[`hour`,60*6e4],[`minute`,6e4]],[n,r]=t.find(([,t])=>e>=t&&e%t===0)??t.at(-1);return{intervalValue:String(e/r),intervalUnit:n}}function Xe(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=t.getTimezoneOffset()*6e4;return new Date(t.getTime()-n).toISOString().slice(0,16)}function Ze(e){let t=e.payloadMatch;return e.eventType===`goal.status_changed`&&e.source===`goals`&&t?.status===`blocked`?{triggerMode:`goalBlocked`}:e.eventType===`note.created`&&e.source===`notes`&&!t?{triggerMode:`noteCreated`}:e.eventType===`workflow.run.completed`&&e.source===`workflows`&&t?.status===`failed`?{triggerMode:`workflowFailed`}:e.eventType===`session.transcript.updated`&&e.source===`sessions`&&!t?{triggerMode:`sessionUpdated`}:{triggerMode:`event`,eventType:e.eventType,eventSource:e.source??``,eventPayloadMatch:t?JSON.stringify(t,null,2):``}}function Qe(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function $e(e){if(!e.trim())return!0;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&!Array.isArray(t)&&Object.values(t).every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))}catch{return!1}}function et(e,t=[]){let n={triggerMode:`manual`};if(e.trigger.kind===`webhook`)n={triggerMode:`webhook`,webhookSecretId:e.trigger.secretId??``};else if(e.trigger.kind===`event`)n=Ze(e.trigger);else if(e.trigger.kind===`schedule`){let t=e.trigger.schedule;t.kind===`cron`&&(n=Je(t.expr)),t.kind===`interval`&&(n={triggerMode:`interval`,...Ye(t.everyMs)}),t.kind===`once`&&(n={triggerMode:`once`,onceAt:Xe(t.at)})}let r=e.action,i=r.kind===`workflow`?t.find(e=>e.id===r.workflowId)??null:null,a=r.kind===`workflow`?Qe(r.input):{},o=e.afterRun??{kind:`none`},s=r.timeoutSeconds??e.reliability?.timeoutSeconds??300;return{...X,...n,name:e.name,description:e.description??``,actionMode:r.kind,agentId:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?H(i.name,a):{},schemaInput:a,concurrency:r.kind===`workflow`&&r.concurrency?String(r.concurrency):``,maxSubagents:r.kind===`workflow`&&r.maxSubagents?String(r.maxSubagents):``},workflowInputValid:!0,safetyMode:e.safety?.mode??`auto_apply`,timeoutSeconds:String(s),afterRunMode:o.kind,webhookUrl:o.kind===`webhook`?o.url:``,disableAfterFailures:String(e.reliability?.disableAfterConsecutiveFailures??3)}}function tt(e,t,n){let r=qe(t,n),i=e.trigger.kind===`schedule`&&r.trigger.kind===`schedule`&&e.trigger.schedule.kind===r.trigger.schedule.kind?{...r.trigger,schedule:{...e.trigger.schedule,...r.trigger.schedule}}:r.trigger,a=r.action;return e.action.kind===`agent`&&r.action.kind===`agent`?a={...e.action,...r.action,agentId:r.action.agentId}:e.action.kind===`workflow`&&r.action.kind===`workflow`&&(a={...e.action,...r.action,agentId:r.action.agentId,input:r.action.input,goal:r.action.goal,concurrency:r.action.concurrency,maxSubagents:r.action.maxSubagents}),{...r,description:t.description.trim(),trigger:i,action:a,reliability:{...e.reliability,...r.reliability}}}function nt(){let e=l(e=>e.language),t=c(e),n=t.automations,r=t.cron,a=v(e=>e.setPageHeader),s=v(e=>e.clearPageHeader),[f,p]=i(),h=f.get(`run`)?.trim()??``,_=f.get(`draft`)?.trim()??``,y=f.get(`action`)?.trim()??``,b=f.get(`projectId`)?.trim()??``,x=f.get(`autogenerate`)===`1`,S=f.get(`insight`)?.trim()??``,O=(0,U.useRef)(``),k=We(`(min-width: 1280px)`),[j,ee]=(0,U.useState)(`activity`),[te,M]=(0,U.useState)(!1),[N,P]=(0,U.useState)(`blank`),[re,F]=(0,U.useState)(null),[I,ce]=(0,U.useState)(!1),[R,z]=(0,U.useState)(X),[fe,V]=(0,U.useState)(null),[H,pe]=(0,U.useState)(null),[he,W]=(0,U.useState)(!1),[G,K]=(0,U.useState)(null),[ge,_e]=(0,U.useState)(``),[q,ve]=(0,U.useState)(null),[ye,be]=(0,U.useState)(!1),[xe,Se]=(0,U.useState)(!1),[Ce,we]=(0,U.useState)(null),[Te,Ee]=(0,U.useState)(!1),[De,Oe]=(0,U.useState)(!1),[ke,Ae]=(0,U.useState)(!1),[J,je]=(0,U.useState)(null),Me=u([`automations`,b],()=>B.list(b?{projectId:b}:void 0),{refreshInterval:15e3}),Z=u([`automation-runs`,b],()=>B.runs(50,void 0,b?{projectId:b}:void 0),{refreshInterval:1e4}),Pe=u(`automation-metrics`,()=>B.metrics(),{refreshInterval:15e3}),Fe=u(H?`automation-run-events:${H}`:null,()=>B.runEvents(H),{refreshInterval:5e3}),Ie=u(`automation-workflow-definitions`,ie),Le=u(`automation-chat-agents`,ne),ze=Me.isLoading&&!Me.data||Z.isLoading&&!Z.data||Pe.isLoading&&!Pe.data,Ve=Me.data?.automations??[],He=(0,U.useMemo)(()=>Ue(Z.data?.runs??[]),[Z.data?.runs]),Ke=(0,U.useMemo)(()=>Ve.filter(e=>!Be(e)),[Ve]),Je=(0,U.useMemo)(()=>Ve.filter(Be),[Ve]),Ye=(0,U.useMemo)(()=>new Set(Je.map(e=>e.id)),[Je]),Xe=(0,U.useMemo)(()=>He.filter(e=>!Ye.has(e.automationId)),[He,Ye]),Ze=(0,U.useMemo)(()=>{let e;for(let t of Ke){let n=t.state.nextRunAtMs;n&&(e==null||n<e)&&(e=n)}return e},[Ke]),Qe=(0,U.useMemo)(()=>He.find(e=>e.id===H)??null,[He,H]),nt=(0,U.useMemo)(()=>Ve.find(e=>e.id===G)??null,[Ve,G]),at=(0,U.useMemo)(()=>Ve.find(e=>e.id===re)??null,[Ve,re]),ot=(0,U.useMemo)(()=>He.filter(e=>e.automationId===G),[He,G]),lt=Fe.data?.events??[],ut=(0,U.useMemo)(()=>Xe.filter(Re),[Xe]),dt=Xe[0]??null,mt=(0,U.useMemo)(()=>Ie.data??[],[Ie.data]),ht=Le.data?.items??[],gt=(0,U.useMemo)(()=>mt.find(e=>e.id===R.workflowId.trim())??null,[R.workflowId,mt]),_t=R.actionMode===`workflow`&&(!R.workflowId.trim()||mt.length>0&&!mt.some(e=>e.id===R.workflowId)),vt=R.actionMode===`workflow`&&gt?!me(gt,R.workflowInput,R.workflowInputValid).valid:!1,yt=!!R.name.trim()&&(R.triggerMode!==`once`||Number.isFinite(new Date(R.onceAt).getTime()))&&(R.triggerMode!==`event`||!!R.eventType.trim()&&$e(R.eventPayloadMatch))&&(R.actionMode===`workflow`?!_t&&!vt:!!R.instruction.trim())&&(R.afterRunMode!==`webhook`||!!R.webhookUrl.trim()),bt=(0,U.useMemo)(()=>[{name:n.templates.dailyAgent.name,description:n.templates.dailyAgent.description,form:{...X,name:n.templates.dailyAgent.name,instruction:n.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:n.templates.morningWorkflow.name,description:n.templates.morningWorkflow.description,form:{...X,name:n.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:mt[0]?.id??``}},{name:n.templates.webhookAgent.name,description:n.templates.webhookAgent.description,form:{...X,name:n.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:n.templates.blockedGoal.name,description:n.templates.blockedGoal.description,form:{...X,name:n.templates.blockedGoal.formName,triggerMode:`goalBlocked`,instruction:n.templates.blockedGoal.instruction}},{name:n.templates.noteCreated.name,description:n.templates.noteCreated.description,form:{...X,name:n.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:n.templates.noteCreated.instruction}}],[n,mt]);(0,U.useEffect)(()=>{j!==`activity`||Xe.length===0||H&&Xe.some(e=>e.id===H)||pe(Xe[0].id)},[H,Xe,j]);let xt=(0,U.useCallback)(async()=>{await Promise.all([Me.mutate(),Z.mutate(),Pe.mutate(),Fe.mutate()])},[Me.mutate,Pe.mutate,Fe.mutate,Z.mutate]),Ct=(0,U.useCallback)(e=>{F(null),ce(!1),P(e),M(!0),e===`blank`&&z(X)},[]),Q=(0,U.useCallback)(e=>{z(et(e,mt)),F(e.id),ce(!1),K(null),P(`blank`),M(!0)},[mt]),$=(0,U.useCallback)(()=>{q&&(z(et(q.automation,mt)),F(null),ce(!0),P(`blank`))},[q,mt]),wt=(0,U.useCallback)(async()=>{Ae(!0),V(null);try{await xt()}catch(e){let t=e instanceof Error?e.message:String(e);V(t),C({type:`error`,title:n.feedback.actionFailed,message:t})}finally{Ae(!1)}},[n.feedback.actionFailed,xt]);(0,U.useEffect)(()=>{h&&(ee(`activity`),pe(h),k||W(!0))},[h,k]),(0,U.useEffect)(()=>{k&&W(!1)},[k]),(0,U.useEffect)(()=>{y===`create`&&(Ct(`blank`),p(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[y,Ct,p]),(0,U.useEffect)(()=>{if(!_)return;let t=`${e}:${x?`auto`:`seed`}:${_}`;O.current!==t&&(O.current=t,_e(_),ve(null),Se(!1),P(`draft`),M(!0),p(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t.delete(`insight`),t},{replace:!0}),x&&(V(null),be(!0),B.draft({prompt:_,language:e}).then(e=>{ve(e.draft),Se(!1),S&&B.completeInsightDraft(S)}).catch(e=>{V(e instanceof Error?e.message:String(e))}).finally(()=>{be(!1)})))},[x,_,S,e,p]);let Tt=(0,U.useCallback)(e=>{pe(e),k||W(!0),p(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[p,k]);(0,U.useEffect)(()=>{we(null),Oe(!1)},[H]);async function Et(){if(V(null),yt){if(I&&q){je(`draft:edit`);try{let e=qe(R,gt),{simulation:t}=await B.simulate(e);ve({...q,automation:e,simulation:t}),Se(!1),ce(!1),P(`draft`)}catch(e){let t=e instanceof Error?e.message:String(e);V(t),C({type:`error`,title:n.feedback.actionFailed,message:t})}finally{je(null)}return}if(at){let e=at.id;await Dt(`automation:${e}:edit`,()=>B.update(e,tt(at,R,gt)))&&(M(!1),F(null),K(e));return}try{await B.create({...qe(R,gt),...b?{projectId:b}:{}}),z(X),M(!1),await xt()}catch(e){let t=e instanceof Error?e.message:String(e);V(t),C({type:`error`,title:n.feedback.actionFailed,message:t})}}}async function Dt(e,t){V(null),je(e);try{return await t(),await xt(),!0}catch(e){let t=e instanceof Error?e.message:String(e);return V(t),C({type:`error`,title:n.feedback.actionFailed,message:t}),!1}finally{je(null)}}async function Ot(){let t=ge.trim();if(t){V(null),be(!0);try{ve((await B.draft({prompt:t,language:e})).draft),Se(!1)}catch(e){V(e instanceof Error?e.message:String(e))}finally{be(!1)}}}async function kt(){q&&await Dt(`draft:publish`,async()=>{await B.create({...q.automation,...b?{projectId:b}:{}}),ve(null),_e(``),Se(!1),M(!1)})}async function At(t){V(null),Ee(!0),we(null),Oe(!1);try{we((await B.repairDraft(t.id,{language:e})).repair)}catch(e){V(e instanceof Error?e.message:String(e))}finally{Ee(!1)}}async function jt(e){Ce&&await Dt(`run:${e.id}:repair`,async()=>{await B.update(e.automationId,Ce.patch),we(null),Oe(!1)})}let Mt=(0,U.useMemo)(()=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(se,{className:`size-9 shrink-0 p-0`,loading:ke,label:n.refresh,onClick:wt}),(0,Y.jsxs)(ue,{children:[(0,Y.jsx)(g,{asChild:!0,children:(0,Y.jsxs)(L,{variant:`primary`,children:[(0,Y.jsx)(oe,{className:`size-4`}),n.new]})}),(0,Y.jsx)(m,{children:(0,Y.jsxs)(de,{align:`end`,className:`z-70 min-w-52 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Y.jsx)(A,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>Ct(`draft`),children:n.createMenu.draft}),(0,Y.jsx)(A,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>Ct(`template`),children:n.createMenu.template}),(0,Y.jsx)(A,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>Ct(`blank`),children:n.createMenu.blank})]})})]})]}),[n.createMenu.blank,n.createMenu.draft,n.createMenu.template,n.new,n.refresh,Ct,ke,wt]);return(0,U.useLayoutEffect)(()=>(a({startExtra:null,main:(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,Y.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:Mt}),()=>s()),[s,Mt,n.subtitle,n.title,a]),(0,Y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Y.jsxs)(`div`,{className:`flex w-full flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Y.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,Y.jsx)(rt,{label:n.dashboard.needsAttention,value:ut.length,tone:ut.length>0?`danger`:`neutral`}),(0,Y.jsx)(rt,{label:n.metrics.running,value:Xe.filter(e=>e.status===`running`).length}),(0,Y.jsx)(rt,{label:n.dashboard.latestResult,value:dt?n.status[dt.status]:n.none,tone:dt&&Re(dt)?`danger`:`neutral`}),(0,Y.jsx)(rt,{label:n.metrics.next,value:Ze?Ne(Ze,n,e):n.none})]}),(0,Y.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:Xe.length},{id:`automations`,label:n.dashboard.manage,count:Ke.length},{id:`system`,label:n.system.title,count:Je.length}].map(e=>(0,Y.jsxs)(`button`,{className:o(`inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium text-fg-muted`,j===e.id&&`bg-surface-hover text-fg`),onClick:()=>{ee(e.id),e.id!==`activity`&&W(!1)},children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.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))}),fe?(0,Y.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:fe}):null,ze?(0,Y.jsx)(Ge,{}):j===`activity`?(0,Y.jsxs)(`section`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(18rem,22rem)_minmax(0,1fr)]`,children:[(0,Y.jsx)(`div`,{className:`min-w-0`,children:(0,Y.jsx)(ct,{runs:Xe.slice(0,12),labels:n,cronLabels:r,language:e,selectedRunId:H,busyAction:J,className:`h-auto`,onSelectRun:Tt,onAction:Dt})}),(0,Y.jsx)(ft,{className:`hidden xl:sticky xl:top-4 xl:block`,run:Qe,events:lt,labels:n,cronLabels:r,language:e,loading:Fe.isLoading,repairDraft:Ce,repairLoading:Te,repairApproved:De,busyAction:J,onRepairApprovedChange:Oe,onSuggestRepair:At,onApplyRepair:jt})]}):j===`automations`?(0,Y.jsx)(`section`,{children:(0,Y.jsx)(st,{automations:Ke,runs:Xe,labels:n,cronLabels:r,language:e,busyAction:J,onOpenDetails:K,onAction:Dt})}):(0,Y.jsx)(`section`,{children:(0,Y.jsx)(st,{automations:Je,runs:He,labels:n,cronLabels:r,language:e,busyAction:J,readOnly:!0,onOpenDetails:K,onAction:Dt})})]}),(0,Y.jsx)(E,{open:te,onOpenChange:e=>{M(e),e||(F(null),ce(!1))},children:(0,Y.jsxs)(T,{children:[(0,Y.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Y.jsxs)(d,{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,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Y.jsx)(D,{className:`text-base font-semibold text-fg`,children:N===`draft`?n.draft.title:N===`template`?n.createMenu.templatesTitle:at?n.editTitle:I?n.draft.editTitle:n.createTitle}),(0,Y.jsx)(ae,{asChild:!0,children:(0,Y.jsx)(L,{variant:`ghost`,"aria-label":n.close,children:(0,Y.jsx)(le,{className:`size-4`})})})]}),N===`draft`?(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Y.jsx)(it,{labels:n,prompt:ge,draft:q,loading:ye,approved:xe,publishBusy:J===`draft:publish`,onPromptChange:_e,onGenerate:Ot,onEdit:$,onPublish:kt,onApprovedChange:Se,onDiscard:()=>{ve(null),Se(!1)}})}):N===`template`?(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Y.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:bt.map(e=>(0,Y.jsxs)(`button`,{className:`rounded-lg bg-surface-base p-4 text-left hover:bg-surface-hover`,onClick:()=>{z(e.form),P(`blank`)},children:[(0,Y.jsx)(`div`,{className:`font-medium text-fg`,children:e.name}),(0,Y.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:e.description})]},e.name))})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(St,{form:R,labels:n,setForm:z,workflowDefinitions:mt,selectedWorkflow:gt,workflowsLoading:Ie.isLoading,agentOptions:ht,agentsLoading:Le.isLoading,language:e}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[I?(0,Y.jsx)(L,{variant:`ghost`,onClick:()=>{ce(!1),P(`draft`)},children:n.cancel}):(0,Y.jsx)(ae,{asChild:!0,children:(0,Y.jsx)(L,{variant:`ghost`,children:n.cancel})}),(0,Y.jsx)(L,{variant:`primary`,onClick:Et,disabled:!yt||J===`draft:edit`||!!(at&&J),children:J===`draft:edit`||at&&J===`automation:${at.id}:edit`?n.feedback.working:at||I?n.save:n.create})]})]})]})]})}),(0,Y.jsx)(pt,{automation:nt,runs:ot,labels:n,cronLabels:r,language:e,busyAction:J,onClose:()=>K(null),onSelectRun:e=>{Tt(e),K(null)},onEdit:Q,onAction:Dt}),(0,Y.jsx)(E,{open:!k&&he&&!!Qe,onOpenChange:W,children:(0,Y.jsxs)(T,{children:[(0,Y.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Y.jsxs)(d,{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,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Y.jsx)(D,{className:`truncate text-base font-semibold text-fg`,children:Qe?.automationName??n.dashboard.result}),(0,Y.jsx)(ae,{asChild:!0,children:(0,Y.jsx)(L,{variant:`ghost`,"aria-label":n.close,children:(0,Y.jsx)(le,{className:`size-4`})})})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Y.jsx)(ft,{className:`rounded-none border-0`,run:Qe,events:lt,labels:n,cronLabels:r,language:e,loading:Fe.isLoading,repairDraft:Ce,repairLoading:Te,repairApproved:De,busyAction:J,onRepairApprovedChange:Oe,onSuggestRepair:At,onApplyRepair:jt})})]})]})})]})}function rt(e){let t=(0,W.c)(13),{label:n,value:r,tone:i}=e,a=i===void 0?`neutral`:i,s=a===`danger`&&`bg-red-500/10`,c;t[0]===s?c=t[1]:(c=o(`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,Y.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[2]=n,t[3]=l);let u=a===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,d;t[4]===u?d=t[5]:(d=o(`mt-1 truncate text-lg font-semibold`,u),t[4]=u,t[5]=d);let f;t[6]!==d||t[7]!==r?(f=(0,Y.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,Y.jsxs)(`div`,{className:c,children:[l,f]}),t[9]=c,t[10]=l,t[11]=f,t[12]=p):p=t[12],p}function it(e){let t=(0,W.c)(49),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,onPromptChange:c,onGenerate:l,onEdit:u,onPublish:d,onApprovedChange:f,onDiscard:p}=e,m=s===void 0?!1:s,h=!!(i&&i.simulation.requiredConfirmations.length>0),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Y.jsx)(ee,{className:`size-4 text-accent`}),t[0]=g):g=t[0];let _;t[1]===n.draft.title?_=t[2]:(_=(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[g,n.draft.title]}),t[1]=n.draft.title,t[2]=_);let v;t[3]===n.draft.subtitle?v=t[4]:(v=(0,Y.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=v);let y;t[5]!==_||t[6]!==v?(y=(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[_,v]}),t[5]=_,t[6]=v,t[7]=y):y=t[7];let b;t[8]!==a||t[9]!==r?(b=a||!r.trim(),t[8]=a,t[9]=r,t[10]=b):b=t[10];let x;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Y.jsx)(ee,{className:`size-4`}),t[11]=x):x=t[11];let S=a?n.draft.generating:n.draft.generate,C;t[12]!==l||t[13]!==b||t[14]!==S?(C=(0,Y.jsxs)(L,{variant:`primary`,onClick:l,disabled:b,children:[x,S]}),t[12]=l,t[13]=b,t[14]=S,t[15]=C):C=t[15];let w;t[16]!==y||t[17]!==C?(w=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[y,C]}),t[16]=y,t[17]=C,t[18]=w):w=t[18];let T;t[19]===c?T=t[20]:(T=e=>c(e.target.value),t[19]=c,t[20]=T);let E;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==T?(E=(0,Y.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:T,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=T,t[24]=E):E=t[24];let D;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.edit||t[31]!==n.draft.publish||t[32]!==n.draft.review||t[33]!==n.draft.risks||t[34]!==n.draft.safety||t[35]!==n.feedback||t[36]!==n.info||t[37]!==n.none||t[38]!==f||t[39]!==p||t[40]!==u||t[41]!==d||t[42]!==m||t[43]!==h?(D=i?(0,Y.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,Y.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,Y.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,Y.jsx)(bt,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Y.jsx)(bt,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,Y.jsx)(at,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Y.jsx)(at,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Y.jsx)(at,{title:n.draft.risks,items:i.risks,empty:n.none}),h?(0,Y.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,Y.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:o,onChange:e=>f(e.target.checked)}),(0,Y.jsx)(`span`,{children:n.draft.approval})]}):null,(0,Y.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Y.jsx)(L,{variant:`ghost`,onClick:p,children:n.draft.discard}),(0,Y.jsxs)(L,{variant:`secondary`,onClick:u,children:[(0,Y.jsx)(N,{className:`size-4`}),n.draft.edit]}),(0,Y.jsx)(L,{variant:`primary`,onClick:d,disabled:m||h&&!o,children:m?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.edit,t[31]=n.draft.publish,t[32]=n.draft.review,t[33]=n.draft.risks,t[34]=n.draft.safety,t[35]=n.feedback,t[36]=n.info,t[37]=n.none,t[38]=f,t[39]=p,t[40]=u,t[41]=d,t[42]=m,t[43]=h,t[44]=D):D=t[44];let O;return t[45]!==w||t[46]!==E||t[47]!==D?(O=(0,Y.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[w,E,D]}),t[45]=w,t[46]=E,t[47]=D,t[48]=O):O=t[48],O}function at(e){let t=(0,W.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,Y.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(ot):(0,Y.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,Y.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,Y.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function ot(e){return(0,Y.jsxs)(`li`,{children:[`- `,e]},e)}function st(e){let t=(0,W.c)(24),{automations:n,runs:r,labels:i,cronLabels:a,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,Y.jsx)(M,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.automations?n=t[2]:(n=(0,Y.jsx)(xt,{icon:e,title:i.empty.automations}),t[1]=i.empty.automations,t[2]=n),n}let m;if(t[3]!==n||t[4]!==c||t[5]!==a||t[6]!==i||t[7]!==s||t[8]!==d||t[9]!==u||t[10]!==p||t[11]!==r){let e;t[13]!==c||t[14]!==a||t[15]!==i||t[16]!==s||t[17]!==d||t[18]!==u||t[19]!==p||t[20]!==r?(e=e=>{let t=Ve(e),n=r.filter(t=>t.automationId===e.id),l=n.find(Le),m=n[0],h=c===`automation:${e.id}:run`,g=c===`automation:${e.id}:toggle`,_=c===`automation:${e.id}:delete`;return(0,Y.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,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),l?(0,Y.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-blue-500`}):null]}),t?(0,Y.jsx)(`div`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:t}):null]}),(0,Y.jsx)(`span`,{className:o(`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?i.enabled:i.paused})]}),(0,Y.jsxs)(`div`,{className:`mt-3 space-y-2 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase text-fg-muted`,children:i.info.when}),(0,Y.jsx)(`span`,{className:`truncate`,children:Ae(e.trigger,i,a,s)})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg-muted`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase`,children:i.info.run}),(0,Y.jsx)(`span`,{className:`truncate`,children:Z(e.action,i)})]})]}),(0,Y.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Y.jsxs)(`span`,{children:[i.last,`: `,Ne(e.state.lastRunAtMs,i,s)]}),(0,Y.jsxs)(`span`,{children:[i.next,`: `,Ne(e.state.nextRunAtMs,i,s)]}),(0,Y.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5`,Fe(e.state.lastRunStatus)),children:e.state.lastRunStatus?i.status[e.state.lastRunStatus]:i.status.notRun}),m?.error?(0,Y.jsx)(`p`,{className:`basis-full line-clamp-1 text-red-700 dark:text-red-300`,children:m.error}):null]}),p?null:(0,Y.jsx)(`div`,{className:`mt-auto flex justify-end pt-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(L,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":i.dashboard.runNow,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:run`,()=>B.runNow(e.id),i.feedback.rerunQueued)},children:(0,Y.jsx)(F,{className:o(`size-4`,h&&`animate-pulse`)})}),(0,Y.jsx)(L,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":e.enabled?i.dashboard.pause:i.dashboard.resume,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:toggle`,()=>e.enabled?B.pause(e.id):B.resume(e.id),e.enabled?i.feedback.paused:i.dashboard.resumed)},children:g?(0,Y.jsx)(R,{className:`size-4 animate-spin`}):e.enabled?(0,Y.jsx)(k,{className:`size-4`}):(0,Y.jsx)(F,{className:`size-4`})}),(0,Y.jsx)(L,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":i.dashboard.delete,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:delete`,()=>B.remove(e.id),i.dashboard.deleted)},children:_?(0,Y.jsx)(R,{className:`size-4 animate-spin`}):(0,Y.jsx)(f,{className:`size-4`})})]})})]},e.id)},t[13]=c,t[14]=a,t[15]=i,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]=a,t[6]=i,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,Y.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:m}),t[22]=m,t[23]=h),h}function ct(e){let t=(0,W.c)(25),{runs:n,labels:r,cronLabels:i,language:a,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,Y.jsx)(P,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===r.empty.runs?n=t[2]:(n=(0,Y.jsx)(xt,{icon:e,title:r.empty.runs}),t[1]=r.empty.runs,t[2]=n),n}let f;t[3]===l?f=t[4]:(f=o(`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]!==i||t[7]!==r||t[8]!==a||t[9]!==d||t[10]!==u||t[11]!==n||t[12]!==s){let e;t[14]!==c||t[15]!==i||t[16]!==r||t[17]!==a||t[18]!==d||t[19]!==u||t[20]!==s?(e=e=>(0,Y.jsxs)(`div`,{className:o(`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,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-fg`,children:e.automationName}),(0,Y.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs`,Fe(e.status)),children:r.status[e.status]}),e.workflowRunId?(0,Y.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[r.workflowPrefix,` `,e.workflowRunId.slice(0,8)]}):null]}),(0,Y.jsx)(`div`,{className:o(`mt-1 line-clamp-2 whitespace-pre-line text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||(Le(e)?r.runDetail.resultPending:r.runDetail.noResult)}),(0,Y.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[Ne(e.createdAtMs,r,a),` · `,e.manual?r.trigger.manual:Ae(e.triggerSnapshot,r,i,a)]})]}),e.status===`running`||e.status===`queued`?(0,Y.jsx)(L,{variant:`ghost`,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`run:${e.id}:cancel`,()=>B.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]=i,t[16]=r,t[17]=a,t[18]=d,t[19]=u,t[20]=s,t[21]=e):e=t[21],p=n.map(e),t[5]=c,t[6]=i,t[7]=r,t[8]=a,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,Y.jsx)(`div`,{className:f,children:p}),t[22]=f,t[23]=p,t[24]=m):m=t[24],m}function lt(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 ut(e){let t=(0,W.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[s,c]=(0,U.useState)(a===void 0?!1:a),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(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,t as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./circle-alert-RzVebuX2.js";import{t as c}from"./messages-BIsSVgW7.js";import{n as l}from"./locale-store-BP67jtYG.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Ao as d,As as f,Bc as p,Ci as m,Dl as h,Ei as g,Fc as _,Fo as v,Ir as y,Ji as b,Js as x,Ko as S,Lo as C,Mo as w,No as T,Oo as E,Po as D,Ql as O,Sc as k,Si as A,Wo as j,Ws as ee,Xl as te,_s as M,bc as N,bu as P,eo as ne,eu as re,gc as F,ht as ie,io as I,ko as ae,mc as oe,ms as L,oa as se,pl as ce,sc as R,tu as z,vs as le,wi as ue,x as B,xi as de}from"./index-twNrYC3D.js";import{t as fe}from"./format-cron-label-arqgGlVV.js";import{a as V,i as H,n as pe,r as me,t as he}from"./workflow-run-setup-panel-DUKlCVcY.js";var U=e(t(),1),W=n(),G=1e3,K=60*G,ge=60*K,_e=24*ge,q=7*_e,ve={minute:K,hour:ge,day:_e,week:q};function ye(e){return e===`zh`?`zh-CN`:`en-US`}function be(e,t,n){return n===`zh`?`${e} ${t===`week`?`周`:t===`day`?`天`:t===`hour`?`小时`:t===`minute`?`分钟`:`秒`}`:new Intl.NumberFormat(ye(n),{style:`unit`,unit:t,unitDisplay:`long`}).format(e)}function xe(e,t){return t===`zh`?e.join(` `):new Intl.ListFormat(`en-US`,{type:`conjunction`}).format(e)}function Se(e,t){let n=typeof e==`number`?e:Number.parseFloat(e);return Math.max(K,Math.round((Number.isFinite(n)&&n>0?n:1)*ve[t]))}function Ce(e,t,n){let r=typeof e==`number`?e:Number.parseFloat(e),i=Number.isFinite(r)&&r>0?r:1;return String(Number.parseFloat((i*ve[t]/ve[n]).toFixed(6)))}function we(e,t){let n=Math.max(G,Math.round(e)),r=n===_e?[{unit:`hour`,ms:ge}]:n>=q&&n%q===0?[{unit:`week`,ms:q}]:n>=_e?[{unit:`day`,ms:_e},{unit:`hour`,ms:ge},{unit:`minute`,ms:K},{unit:`second`,ms:G}]:n>=ge?[{unit:`hour`,ms:ge},{unit:`minute`,ms:K},{unit:`second`,ms:G}]:n>=K?[{unit:`minute`,ms:K},{unit:`second`,ms:G}]:[{unit:`second`,ms:G}],i=n,a=[];for(let{unit:e,ms:n}of r){let r=Math.floor(i/n);r<=0||(a.push(be(r,e,t)),i%=n)}return xe(a,t)}function Te(e,t){let n=we(e,t);return t===`zh`?`每 ${n}运行一次`:`Runs every ${n}`}function Ee(e,t){return new Intl.DateTimeFormat(ye(t),{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e))}function De(e){return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function Oe(e,t,n=Date.now()){let r=new Date(e),i=Math.round((De(r)-De(new Date(n)))/_e),a=new Intl.DateTimeFormat(ye(t),{hour:`2-digit`,minute:`2-digit`}).format(r);return i===0?t===`zh`?`今天 ${a}`:`today at ${a}`:i===1?t===`zh`?`明天 ${a}`:`tomorrow at ${a}`:i===-1?t===`zh`?`昨天 ${a}`:`yesterday at ${a}`:Ee(e,t)}function ke(e,t){return e.eventType===`goal.status_changed`&&e.payloadMatch?.status===`blocked`?t.trigger.goalBlockedWhen:e.eventType===`note.created`?t.trigger.noteCreatedWhen:e.eventType===`workflow.run.completed`&&e.payloadMatch?.status===`failed`?t.trigger.workflowFailedWhen:e.eventType===`session.transcript.updated`?t.trigger.sessionUpdatedWhen:t.trigger.eventWithType.replace(`{type}`,e.eventType)}function Ae(e,t,n,r){if(e.kind===`manual`)return t.trigger.manualWhen;if(e.kind===`webhook`)return t.trigger.webhookWhen;if(e.kind===`event`)return ke(e,t);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,Oe(Date.parse(i.at),r)):i.kind===`interval`?Te(i.everyMs,r):fe(i.expr,ye(r),n.scheduleBadge,{timezone:i.tz})}function J(e,t,n,r=Date.now()){return e.enabled?e.state.nextRunAtMs?Oe(e.state.nextRunAtMs,n,r):e.trigger.kind===`manual`?t.info.noAutomaticTrigger:e.trigger.kind===`event`||e.trigger.kind===`webhook`?t.info.waitingForTrigger:t.info.noUpcomingRun:t.info.pausedNoAutomaticRuns}function je(e,t,n,r=Date.now()){if(!e.state.lastRunAtMs)return t.info.notRunYet;let i=Oe(e.state.lastRunAtMs,n,r),a=e.state.lastRunStatus;return a?`${i} · ${t.status[a]}`:i}var Y=r(),X={name:``,description:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalValue:`1`,intervalUnit:`hour`,cronExpr:`0 9 * * *`,webhookSecretId:``,onceAt:``,eventType:``,eventSource:``,eventPayloadMatch:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,safetyMode:`suggest_only`,timeoutSeconds:`300`,afterRunMode:`none`,webhookUrl:``,disableAfterFailures:`3`},Me=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function Ne(e,t,n){return e?Ee(e,n):t.never}function Z(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 Pe(e){return e.safety?.mode??`auto_apply`}function Fe(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 Ie(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 Le(e){return e.status===`running`||e.status===`queued`}function Re(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function ze(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function Be(e){return!!ze(e)}function Ve(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function He(e){return Le(e)?0:Re(e)?1:e.status===`succeeded`?2:3}function Ue(e){return[...e].sort((e,t)=>{let n=He(e)-He(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function We(e){let t=(0,W.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,U.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,U.useEffect)(a,o),r}function Ge(){let e=(0,W.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Y.jsx)(I,{className:`h-4 w-36`}),(0,Y.jsx)(I,{className:`h-3 w-56 max-w-full`})]}),(0,Y.jsx)(I,{className:`h-7 w-20 rounded-full`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Y.jsxs)(`section`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:[t,(0,Y.jsx)(`div`,{className:`mt-4 grid gap-2`,children:Array.from({length:6}).map(Ke)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Y.jsx)(I,{className:`h-4 w-32`}),i=(0,Y.jsx)(I,{className:`mt-4 h-24 rounded-lg`}),e[2]=r,e[3]=i):(r=e[2],i=e[3]);let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Y.jsx)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:(0,Y.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[n,(0,Y.jsxs)(`section`,{className:`hidden rounded-xl bg-surface-panel p-4 shadow-surface xl:block`,children:[r,i,(0,Y.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,Y.jsx)(I,{className:`h-12 rounded-lg`}),(0,Y.jsx)(I,{className:`h-12 rounded-lg`}),(0,Y.jsx)(I,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function Ke(e,t){return(0,Y.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(I,{className:`size-4 rounded-full`}),(0,Y.jsx)(I,{className:`h-4 w-32`}),(0,Y.jsx)(I,{className:`h-5 w-20 rounded-full`})]}),(0,Y.jsx)(I,{className:`mt-3 h-4 w-full`}),(0,Y.jsx)(I,{className:`mt-2 h-4 w-3/5`})]}),(0,Y.jsx)(I,{className:`h-8 w-24 rounded-md`})]})},t)}function qe(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;if(e.triggerMode===`manual`)o={kind:`manual`};else if(e.triggerMode===`once`)o={kind:`schedule`,schedule:{kind:`once`,at:new Date(e.onceAt).toISOString()}};else if(e.triggerMode===`webhook`)o={kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}};else if(e.triggerMode===`goalBlocked`)o={kind:`event`,eventType:`goal.status_changed`,source:`goals`,payloadMatch:{status:`blocked`}};else if(e.triggerMode===`noteCreated`)o={kind:`event`,eventType:`note.created`,source:`notes`};else if(e.triggerMode===`workflowFailed`)o={kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}};else if(e.triggerMode===`sessionUpdated`)o={kind:`event`,eventType:`session.transcript.updated`,source:`sessions`};else if(e.triggerMode===`event`){let t=e.eventPayloadMatch.trim()?JSON.parse(e.eventPayloadMatch):void 0;o={kind:`event`,eventType:e.eventType.trim(),...e.eventSource.trim()?{source:e.eventSource.trim()}:{},...t?{payloadMatch:t}:{}}}else o=e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:Se(e.intervalValue,e.intervalUnit)}}: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=pe(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 Je(e){let t=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);if(t)return{triggerMode:`daily`,time:`${t[2].padStart(2,`0`)}:${t[1].padStart(2,`0`)}`,weekday:`1`,cronExpr:e};let n=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-6])$/);return n?{triggerMode:`weekly`,time:`${n[2].padStart(2,`0`)}:${n[1].padStart(2,`0`)}`,weekday:n[3],cronExpr:e}:{triggerMode:`cron`,time:X.time,weekday:X.weekday,cronExpr:e}}function Ye(e){let t=[[`week`,10080*6e4],[`day`,1440*6e4],[`hour`,60*6e4],[`minute`,6e4]],[n,r]=t.find(([,t])=>e>=t&&e%t===0)??t.at(-1);return{intervalValue:String(e/r),intervalUnit:n}}function Xe(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=t.getTimezoneOffset()*6e4;return new Date(t.getTime()-n).toISOString().slice(0,16)}function Ze(e){let t=e.payloadMatch;return e.eventType===`goal.status_changed`&&e.source===`goals`&&t?.status===`blocked`?{triggerMode:`goalBlocked`}:e.eventType===`note.created`&&e.source===`notes`&&!t?{triggerMode:`noteCreated`}:e.eventType===`workflow.run.completed`&&e.source===`workflows`&&t?.status===`failed`?{triggerMode:`workflowFailed`}:e.eventType===`session.transcript.updated`&&e.source===`sessions`&&!t?{triggerMode:`sessionUpdated`}:{triggerMode:`event`,eventType:e.eventType,eventSource:e.source??``,eventPayloadMatch:t?JSON.stringify(t,null,2):``}}function Qe(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function $e(e){if(!e.trim())return!0;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&!Array.isArray(t)&&Object.values(t).every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))}catch{return!1}}function et(e,t=[]){let n={triggerMode:`manual`};if(e.trigger.kind===`webhook`)n={triggerMode:`webhook`,webhookSecretId:e.trigger.secretId??``};else if(e.trigger.kind===`event`)n=Ze(e.trigger);else if(e.trigger.kind===`schedule`){let t=e.trigger.schedule;t.kind===`cron`&&(n=Je(t.expr)),t.kind===`interval`&&(n={triggerMode:`interval`,...Ye(t.everyMs)}),t.kind===`once`&&(n={triggerMode:`once`,onceAt:Xe(t.at)})}let r=e.action,i=r.kind===`workflow`?t.find(e=>e.id===r.workflowId)??null:null,a=r.kind===`workflow`?Qe(r.input):{},o=e.afterRun??{kind:`none`},s=r.timeoutSeconds??e.reliability?.timeoutSeconds??300;return{...X,...n,name:e.name,description:e.description??``,actionMode:r.kind,agentId:r.agentId??``,instruction:r.kind===`agent`?r.instruction:``,workflowId:r.kind===`workflow`?r.workflowId:``,workflowGoal:r.kind===`workflow`?r.goal??``:``,workflowInput:{goal:r.kind===`workflow`?r.goal??``:``,argValues:i?H(i.name,a):{},schemaInput:a,concurrency:r.kind===`workflow`&&r.concurrency?String(r.concurrency):``,maxSubagents:r.kind===`workflow`&&r.maxSubagents?String(r.maxSubagents):``},workflowInputValid:!0,safetyMode:e.safety?.mode??`auto_apply`,timeoutSeconds:String(s),afterRunMode:o.kind,webhookUrl:o.kind===`webhook`?o.url:``,disableAfterFailures:String(e.reliability?.disableAfterConsecutiveFailures??3)}}function tt(e,t,n){let r=qe(t,n),i=e.trigger.kind===`schedule`&&r.trigger.kind===`schedule`&&e.trigger.schedule.kind===r.trigger.schedule.kind?{...r.trigger,schedule:{...e.trigger.schedule,...r.trigger.schedule}}:r.trigger,a=r.action;return e.action.kind===`agent`&&r.action.kind===`agent`?a={...e.action,...r.action,agentId:r.action.agentId}:e.action.kind===`workflow`&&r.action.kind===`workflow`&&(a={...e.action,...r.action,agentId:r.action.agentId,input:r.action.input,goal:r.action.goal,concurrency:r.action.concurrency,maxSubagents:r.action.maxSubagents}),{...r,description:t.description.trim(),trigger:i,action:a,reliability:{...e.reliability,...r.reliability}}}function nt(){let e=l(e=>e.language),t=c(e),n=t.automations,r=t.cron,a=v(e=>e.setPageHeader),s=v(e=>e.clearPageHeader),[f,p]=i(),h=f.get(`run`)?.trim()??``,_=f.get(`draft`)?.trim()??``,y=f.get(`action`)?.trim()??``,b=f.get(`projectId`)?.trim()??``,x=f.get(`autogenerate`)===`1`,S=f.get(`insight`)?.trim()??``,O=(0,U.useRef)(``),k=We(`(min-width: 1280px)`),[j,ee]=(0,U.useState)(`activity`),[te,M]=(0,U.useState)(!1),[N,P]=(0,U.useState)(`blank`),[re,F]=(0,U.useState)(null),[I,ce]=(0,U.useState)(!1),[R,z]=(0,U.useState)(X),[fe,V]=(0,U.useState)(null),[H,pe]=(0,U.useState)(null),[he,W]=(0,U.useState)(!1),[G,K]=(0,U.useState)(null),[ge,_e]=(0,U.useState)(``),[q,ve]=(0,U.useState)(null),[ye,be]=(0,U.useState)(!1),[xe,Se]=(0,U.useState)(!1),[Ce,we]=(0,U.useState)(null),[Te,Ee]=(0,U.useState)(!1),[De,Oe]=(0,U.useState)(!1),[ke,Ae]=(0,U.useState)(!1),[J,je]=(0,U.useState)(null),Me=u([`automations`,b],()=>B.list(b?{projectId:b}:void 0),{refreshInterval:15e3}),Z=u([`automation-runs`,b],()=>B.runs(50,void 0,b?{projectId:b}:void 0),{refreshInterval:1e4}),Pe=u(`automation-metrics`,()=>B.metrics(),{refreshInterval:15e3}),Fe=u(H?`automation-run-events:${H}`:null,()=>B.runEvents(H),{refreshInterval:5e3}),Ie=u(`automation-workflow-definitions`,ie),Le=u(`automation-chat-agents`,ne),ze=Me.isLoading&&!Me.data||Z.isLoading&&!Z.data||Pe.isLoading&&!Pe.data,Ve=Me.data?.automations??[],He=(0,U.useMemo)(()=>Ue(Z.data?.runs??[]),[Z.data?.runs]),Ke=(0,U.useMemo)(()=>Ve.filter(e=>!Be(e)),[Ve]),Je=(0,U.useMemo)(()=>Ve.filter(Be),[Ve]),Ye=(0,U.useMemo)(()=>new Set(Je.map(e=>e.id)),[Je]),Xe=(0,U.useMemo)(()=>He.filter(e=>!Ye.has(e.automationId)),[He,Ye]),Ze=(0,U.useMemo)(()=>{let e;for(let t of Ke){let n=t.state.nextRunAtMs;n&&(e==null||n<e)&&(e=n)}return e},[Ke]),Qe=(0,U.useMemo)(()=>He.find(e=>e.id===H)??null,[He,H]),nt=(0,U.useMemo)(()=>Ve.find(e=>e.id===G)??null,[Ve,G]),at=(0,U.useMemo)(()=>Ve.find(e=>e.id===re)??null,[Ve,re]),ot=(0,U.useMemo)(()=>He.filter(e=>e.automationId===G),[He,G]),lt=Fe.data?.events??[],ut=(0,U.useMemo)(()=>Xe.filter(Re),[Xe]),dt=Xe[0]??null,mt=(0,U.useMemo)(()=>Ie.data??[],[Ie.data]),ht=Le.data?.items??[],gt=(0,U.useMemo)(()=>mt.find(e=>e.id===R.workflowId.trim())??null,[R.workflowId,mt]),_t=R.actionMode===`workflow`&&(!R.workflowId.trim()||mt.length>0&&!mt.some(e=>e.id===R.workflowId)),vt=R.actionMode===`workflow`&&gt?!me(gt,R.workflowInput,R.workflowInputValid).valid:!1,yt=!!R.name.trim()&&(R.triggerMode!==`once`||Number.isFinite(new Date(R.onceAt).getTime()))&&(R.triggerMode!==`event`||!!R.eventType.trim()&&$e(R.eventPayloadMatch))&&(R.actionMode===`workflow`?!_t&&!vt:!!R.instruction.trim())&&(R.afterRunMode!==`webhook`||!!R.webhookUrl.trim()),bt=(0,U.useMemo)(()=>[{name:n.templates.dailyAgent.name,description:n.templates.dailyAgent.description,form:{...X,name:n.templates.dailyAgent.name,instruction:n.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:n.templates.morningWorkflow.name,description:n.templates.morningWorkflow.description,form:{...X,name:n.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:mt[0]?.id??``}},{name:n.templates.webhookAgent.name,description:n.templates.webhookAgent.description,form:{...X,name:n.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:n.templates.blockedGoal.name,description:n.templates.blockedGoal.description,form:{...X,name:n.templates.blockedGoal.formName,triggerMode:`goalBlocked`,instruction:n.templates.blockedGoal.instruction}},{name:n.templates.noteCreated.name,description:n.templates.noteCreated.description,form:{...X,name:n.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:n.templates.noteCreated.instruction}}],[n,mt]);(0,U.useEffect)(()=>{j!==`activity`||Xe.length===0||H&&Xe.some(e=>e.id===H)||pe(Xe[0].id)},[H,Xe,j]);let xt=(0,U.useCallback)(async()=>{await Promise.all([Me.mutate(),Z.mutate(),Pe.mutate(),Fe.mutate()])},[Me.mutate,Pe.mutate,Fe.mutate,Z.mutate]),Ct=(0,U.useCallback)(e=>{F(null),ce(!1),P(e),M(!0),e===`blank`&&z(X)},[]),Q=(0,U.useCallback)(e=>{z(et(e,mt)),F(e.id),ce(!1),K(null),P(`blank`),M(!0)},[mt]),$=(0,U.useCallback)(()=>{q&&(z(et(q.automation,mt)),F(null),ce(!0),P(`blank`))},[q,mt]),wt=(0,U.useCallback)(async()=>{Ae(!0),V(null);try{await xt()}catch(e){let t=e instanceof Error?e.message:String(e);V(t),C({type:`error`,title:n.feedback.actionFailed,message:t})}finally{Ae(!1)}},[n.feedback.actionFailed,xt]);(0,U.useEffect)(()=>{h&&(ee(`activity`),pe(h),k||W(!0))},[h,k]),(0,U.useEffect)(()=>{k&&W(!1)},[k]),(0,U.useEffect)(()=>{y===`create`&&(Ct(`blank`),p(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[y,Ct,p]),(0,U.useEffect)(()=>{if(!_)return;let t=`${e}:${x?`auto`:`seed`}:${_}`;O.current!==t&&(O.current=t,_e(_),ve(null),Se(!1),P(`draft`),M(!0),p(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t.delete(`insight`),t},{replace:!0}),x&&(V(null),be(!0),B.draft({prompt:_,language:e}).then(e=>{ve(e.draft),Se(!1),S&&B.completeInsightDraft(S)}).catch(e=>{V(e instanceof Error?e.message:String(e))}).finally(()=>{be(!1)})))},[x,_,S,e,p]);let Tt=(0,U.useCallback)(e=>{pe(e),k||W(!0),p(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[p,k]);(0,U.useEffect)(()=>{we(null),Oe(!1)},[H]);async function Et(){if(V(null),yt){if(I&&q){je(`draft:edit`);try{let e=qe(R,gt),{simulation:t}=await B.simulate(e);ve({...q,automation:e,simulation:t}),Se(!1),ce(!1),P(`draft`)}catch(e){let t=e instanceof Error?e.message:String(e);V(t),C({type:`error`,title:n.feedback.actionFailed,message:t})}finally{je(null)}return}if(at){let e=at.id;await Dt(`automation:${e}:edit`,()=>B.update(e,tt(at,R,gt)))&&(M(!1),F(null),K(e));return}try{await B.create({...qe(R,gt),...b?{projectId:b}:{}}),z(X),M(!1),await xt()}catch(e){let t=e instanceof Error?e.message:String(e);V(t),C({type:`error`,title:n.feedback.actionFailed,message:t})}}}async function Dt(e,t){V(null),je(e);try{return await t(),await xt(),!0}catch(e){let t=e instanceof Error?e.message:String(e);return V(t),C({type:`error`,title:n.feedback.actionFailed,message:t}),!1}finally{je(null)}}async function Ot(){let t=ge.trim();if(t){V(null),be(!0);try{ve((await B.draft({prompt:t,language:e})).draft),Se(!1)}catch(e){V(e instanceof Error?e.message:String(e))}finally{be(!1)}}}async function kt(){q&&await Dt(`draft:publish`,async()=>{await B.create({...q.automation,...b?{projectId:b}:{}}),ve(null),_e(``),Se(!1),M(!1)})}async function At(t){V(null),Ee(!0),we(null),Oe(!1);try{we((await B.repairDraft(t.id,{language:e})).repair)}catch(e){V(e instanceof Error?e.message:String(e))}finally{Ee(!1)}}async function jt(e){Ce&&await Dt(`run:${e.id}:repair`,async()=>{await B.update(e.automationId,Ce.patch),we(null),Oe(!1)})}let Mt=(0,U.useMemo)(()=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(se,{className:`size-9 shrink-0 p-0`,loading:ke,label:n.refresh,onClick:wt}),(0,Y.jsxs)(ue,{children:[(0,Y.jsx)(g,{asChild:!0,children:(0,Y.jsxs)(L,{variant:`primary`,children:[(0,Y.jsx)(oe,{className:`size-4`}),n.new]})}),(0,Y.jsx)(m,{children:(0,Y.jsxs)(de,{align:`end`,className:`z-70 min-w-52 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,Y.jsx)(A,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>Ct(`draft`),children:n.createMenu.draft}),(0,Y.jsx)(A,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>Ct(`template`),children:n.createMenu.template}),(0,Y.jsx)(A,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>Ct(`blank`),children:n.createMenu.blank})]})})]})]}),[n.createMenu.blank,n.createMenu.draft,n.createMenu.template,n.new,n.refresh,Ct,ke,wt]);return(0,U.useLayoutEffect)(()=>(a({startExtra:null,main:(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,Y.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:Mt}),()=>s()),[s,Mt,n.subtitle,n.title,a]),(0,Y.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,Y.jsxs)(`div`,{className:`flex w-full flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Y.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,Y.jsx)(rt,{label:n.dashboard.needsAttention,value:ut.length,tone:ut.length>0?`danger`:`neutral`}),(0,Y.jsx)(rt,{label:n.metrics.running,value:Xe.filter(e=>e.status===`running`).length}),(0,Y.jsx)(rt,{label:n.dashboard.latestResult,value:dt?n.status[dt.status]:n.none,tone:dt&&Re(dt)?`danger`:`neutral`}),(0,Y.jsx)(rt,{label:n.metrics.next,value:Ze?Ne(Ze,n,e):n.none})]}),(0,Y.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:Xe.length},{id:`automations`,label:n.dashboard.manage,count:Ke.length},{id:`system`,label:n.system.title,count:Je.length}].map(e=>(0,Y.jsxs)(`button`,{className:o(`inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium text-fg-muted`,j===e.id&&`bg-surface-hover text-fg`),onClick:()=>{ee(e.id),e.id!==`activity`&&W(!1)},children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.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))}),fe?(0,Y.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:fe}):null,ze?(0,Y.jsx)(Ge,{}):j===`activity`?(0,Y.jsxs)(`section`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(18rem,22rem)_minmax(0,1fr)]`,children:[(0,Y.jsx)(`div`,{className:`min-w-0`,children:(0,Y.jsx)(ct,{runs:Xe.slice(0,12),labels:n,cronLabels:r,language:e,selectedRunId:H,busyAction:J,className:`h-auto`,onSelectRun:Tt,onAction:Dt})}),(0,Y.jsx)(ft,{className:`hidden xl:sticky xl:top-4 xl:block`,run:Qe,events:lt,labels:n,cronLabels:r,language:e,loading:Fe.isLoading,repairDraft:Ce,repairLoading:Te,repairApproved:De,busyAction:J,onRepairApprovedChange:Oe,onSuggestRepair:At,onApplyRepair:jt})]}):j===`automations`?(0,Y.jsx)(`section`,{children:(0,Y.jsx)(st,{automations:Ke,runs:Xe,labels:n,cronLabels:r,language:e,busyAction:J,onOpenDetails:K,onAction:Dt})}):(0,Y.jsx)(`section`,{children:(0,Y.jsx)(st,{automations:Je,runs:He,labels:n,cronLabels:r,language:e,busyAction:J,readOnly:!0,onOpenDetails:K,onAction:Dt})})]}),(0,Y.jsx)(E,{open:te,onOpenChange:e=>{M(e),e||(F(null),ce(!1))},children:(0,Y.jsxs)(T,{children:[(0,Y.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Y.jsxs)(d,{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,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Y.jsx)(D,{className:`text-base font-semibold text-fg`,children:N===`draft`?n.draft.title:N===`template`?n.createMenu.templatesTitle:at?n.editTitle:I?n.draft.editTitle:n.createTitle}),(0,Y.jsx)(ae,{asChild:!0,children:(0,Y.jsx)(L,{variant:`ghost`,"aria-label":n.close,children:(0,Y.jsx)(le,{className:`size-4`})})})]}),N===`draft`?(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Y.jsx)(it,{labels:n,prompt:ge,draft:q,loading:ye,approved:xe,publishBusy:J===`draft:publish`,onPromptChange:_e,onGenerate:Ot,onEdit:$,onPublish:kt,onApprovedChange:Se,onDiscard:()=>{ve(null),Se(!1)}})}):N===`template`?(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,Y.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:bt.map(e=>(0,Y.jsxs)(`button`,{className:`rounded-lg bg-surface-base p-4 text-left hover:bg-surface-hover`,onClick:()=>{z(e.form),P(`blank`)},children:[(0,Y.jsx)(`div`,{className:`font-medium text-fg`,children:e.name}),(0,Y.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:e.description})]},e.name))})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(St,{form:R,labels:n,setForm:z,workflowDefinitions:mt,selectedWorkflow:gt,workflowsLoading:Ie.isLoading,agentOptions:ht,agentsLoading:Le.isLoading,language:e}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[I?(0,Y.jsx)(L,{variant:`ghost`,onClick:()=>{ce(!1),P(`draft`)},children:n.cancel}):(0,Y.jsx)(ae,{asChild:!0,children:(0,Y.jsx)(L,{variant:`ghost`,children:n.cancel})}),(0,Y.jsx)(L,{variant:`primary`,onClick:Et,disabled:!yt||J===`draft:edit`||!!(at&&J),children:J===`draft:edit`||at&&J===`automation:${at.id}:edit`?n.feedback.working:at||I?n.save:n.create})]})]})]})]})}),(0,Y.jsx)(pt,{automation:nt,runs:ot,labels:n,cronLabels:r,language:e,busyAction:J,onClose:()=>K(null),onSelectRun:e=>{Tt(e),K(null)},onEdit:Q,onAction:Dt}),(0,Y.jsx)(E,{open:!k&&he&&!!Qe,onOpenChange:W,children:(0,Y.jsxs)(T,{children:[(0,Y.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,Y.jsxs)(d,{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,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Y.jsx)(D,{className:`truncate text-base font-semibold text-fg`,children:Qe?.automationName??n.dashboard.result}),(0,Y.jsx)(ae,{asChild:!0,children:(0,Y.jsx)(L,{variant:`ghost`,"aria-label":n.close,children:(0,Y.jsx)(le,{className:`size-4`})})})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,Y.jsx)(ft,{className:`rounded-none border-0`,run:Qe,events:lt,labels:n,cronLabels:r,language:e,loading:Fe.isLoading,repairDraft:Ce,repairLoading:Te,repairApproved:De,busyAction:J,onRepairApprovedChange:Oe,onSuggestRepair:At,onApplyRepair:jt})})]})]})})]})}function rt(e){let t=(0,W.c)(13),{label:n,value:r,tone:i}=e,a=i===void 0?`neutral`:i,s=a===`danger`&&`bg-red-500/10`,c;t[0]===s?c=t[1]:(c=o(`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,Y.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[2]=n,t[3]=l);let u=a===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,d;t[4]===u?d=t[5]:(d=o(`mt-1 truncate text-lg font-semibold`,u),t[4]=u,t[5]=d);let f;t[6]!==d||t[7]!==r?(f=(0,Y.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,Y.jsxs)(`div`,{className:c,children:[l,f]}),t[9]=c,t[10]=l,t[11]=f,t[12]=p):p=t[12],p}function it(e){let t=(0,W.c)(49),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,onPromptChange:c,onGenerate:l,onEdit:u,onPublish:d,onApprovedChange:f,onDiscard:p}=e,m=s===void 0?!1:s,h=!!(i&&i.simulation.requiredConfirmations.length>0),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Y.jsx)(ee,{className:`size-4 text-accent`}),t[0]=g):g=t[0];let _;t[1]===n.draft.title?_=t[2]:(_=(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[g,n.draft.title]}),t[1]=n.draft.title,t[2]=_);let v;t[3]===n.draft.subtitle?v=t[4]:(v=(0,Y.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=v);let y;t[5]!==_||t[6]!==v?(y=(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[_,v]}),t[5]=_,t[6]=v,t[7]=y):y=t[7];let b;t[8]!==a||t[9]!==r?(b=a||!r.trim(),t[8]=a,t[9]=r,t[10]=b):b=t[10];let x;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Y.jsx)(ee,{className:`size-4`}),t[11]=x):x=t[11];let S=a?n.draft.generating:n.draft.generate,C;t[12]!==l||t[13]!==b||t[14]!==S?(C=(0,Y.jsxs)(L,{variant:`primary`,onClick:l,disabled:b,children:[x,S]}),t[12]=l,t[13]=b,t[14]=S,t[15]=C):C=t[15];let w;t[16]!==y||t[17]!==C?(w=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[y,C]}),t[16]=y,t[17]=C,t[18]=w):w=t[18];let T;t[19]===c?T=t[20]:(T=e=>c(e.target.value),t[19]=c,t[20]=T);let E;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==T?(E=(0,Y.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:T,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=T,t[24]=E):E=t[24];let D;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.edit||t[31]!==n.draft.publish||t[32]!==n.draft.review||t[33]!==n.draft.risks||t[34]!==n.draft.safety||t[35]!==n.feedback||t[36]!==n.info||t[37]!==n.none||t[38]!==f||t[39]!==p||t[40]!==u||t[41]!==d||t[42]!==m||t[43]!==h?(D=i?(0,Y.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,Y.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,Y.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,Y.jsx)(bt,{label:n.info.when,value:i.simulation.triggerSummary}),(0,Y.jsx)(bt,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,Y.jsx)(at,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,Y.jsx)(at,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,Y.jsx)(at,{title:n.draft.risks,items:i.risks,empty:n.none}),h?(0,Y.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,Y.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:o,onChange:e=>f(e.target.checked)}),(0,Y.jsx)(`span`,{children:n.draft.approval})]}):null,(0,Y.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Y.jsx)(L,{variant:`ghost`,onClick:p,children:n.draft.discard}),(0,Y.jsxs)(L,{variant:`secondary`,onClick:u,children:[(0,Y.jsx)(N,{className:`size-4`}),n.draft.edit]}),(0,Y.jsx)(L,{variant:`primary`,onClick:d,disabled:m||h&&!o,children:m?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.edit,t[31]=n.draft.publish,t[32]=n.draft.review,t[33]=n.draft.risks,t[34]=n.draft.safety,t[35]=n.feedback,t[36]=n.info,t[37]=n.none,t[38]=f,t[39]=p,t[40]=u,t[41]=d,t[42]=m,t[43]=h,t[44]=D):D=t[44];let O;return t[45]!==w||t[46]!==E||t[47]!==D?(O=(0,Y.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[w,E,D]}),t[45]=w,t[46]=E,t[47]=D,t[48]=O):O=t[48],O}function at(e){let t=(0,W.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,Y.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(ot):(0,Y.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,Y.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,Y.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function ot(e){return(0,Y.jsxs)(`li`,{children:[`- `,e]},e)}function st(e){let t=(0,W.c)(24),{automations:n,runs:r,labels:i,cronLabels:a,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,Y.jsx)(M,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.automations?n=t[2]:(n=(0,Y.jsx)(xt,{icon:e,title:i.empty.automations}),t[1]=i.empty.automations,t[2]=n),n}let m;if(t[3]!==n||t[4]!==c||t[5]!==a||t[6]!==i||t[7]!==s||t[8]!==d||t[9]!==u||t[10]!==p||t[11]!==r){let e;t[13]!==c||t[14]!==a||t[15]!==i||t[16]!==s||t[17]!==d||t[18]!==u||t[19]!==p||t[20]!==r?(e=e=>{let t=Ve(e),n=r.filter(t=>t.automationId===e.id),l=n.find(Le),m=n[0],h=c===`automation:${e.id}:run`,g=c===`automation:${e.id}:toggle`,_=c===`automation:${e.id}:delete`;return(0,Y.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,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),l?(0,Y.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-blue-500`}):null]}),t?(0,Y.jsx)(`div`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:t}):null]}),(0,Y.jsx)(`span`,{className:o(`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?i.enabled:i.paused})]}),(0,Y.jsxs)(`div`,{className:`mt-3 space-y-2 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase text-fg-muted`,children:i.info.when}),(0,Y.jsx)(`span`,{className:`truncate`,children:Ae(e.trigger,i,a,s)})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg-muted`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase`,children:i.info.run}),(0,Y.jsx)(`span`,{className:`truncate`,children:Z(e.action,i)})]})]}),(0,Y.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Y.jsxs)(`span`,{children:[i.last,`: `,Ne(e.state.lastRunAtMs,i,s)]}),(0,Y.jsxs)(`span`,{children:[i.next,`: `,Ne(e.state.nextRunAtMs,i,s)]}),(0,Y.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5`,Fe(e.state.lastRunStatus)),children:e.state.lastRunStatus?i.status[e.state.lastRunStatus]:i.status.notRun}),m?.error?(0,Y.jsx)(`p`,{className:`basis-full line-clamp-1 text-red-700 dark:text-red-300`,children:m.error}):null]}),p?null:(0,Y.jsx)(`div`,{className:`mt-auto flex justify-end pt-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(L,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":i.dashboard.runNow,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:run`,()=>B.runNow(e.id),i.feedback.rerunQueued)},children:(0,Y.jsx)(F,{className:o(`size-4`,h&&`animate-pulse`)})}),(0,Y.jsx)(L,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":e.enabled?i.dashboard.pause:i.dashboard.resume,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:toggle`,()=>e.enabled?B.pause(e.id):B.resume(e.id),e.enabled?i.feedback.paused:i.dashboard.resumed)},children:g?(0,Y.jsx)(R,{className:`size-4 animate-spin`}):e.enabled?(0,Y.jsx)(k,{className:`size-4`}):(0,Y.jsx)(F,{className:`size-4`})}),(0,Y.jsx)(L,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":i.dashboard.delete,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:delete`,()=>B.remove(e.id),i.dashboard.deleted)},children:_?(0,Y.jsx)(R,{className:`size-4 animate-spin`}):(0,Y.jsx)(f,{className:`size-4`})})]})})]},e.id)},t[13]=c,t[14]=a,t[15]=i,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]=a,t[6]=i,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,Y.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:m}),t[22]=m,t[23]=h),h}function ct(e){let t=(0,W.c)(25),{runs:n,labels:r,cronLabels:i,language:a,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,Y.jsx)(P,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===r.empty.runs?n=t[2]:(n=(0,Y.jsx)(xt,{icon:e,title:r.empty.runs}),t[1]=r.empty.runs,t[2]=n),n}let f;t[3]===l?f=t[4]:(f=o(`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]!==i||t[7]!==r||t[8]!==a||t[9]!==d||t[10]!==u||t[11]!==n||t[12]!==s){let e;t[14]!==c||t[15]!==i||t[16]!==r||t[17]!==a||t[18]!==d||t[19]!==u||t[20]!==s?(e=e=>(0,Y.jsxs)(`div`,{className:o(`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,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-fg`,children:e.automationName}),(0,Y.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs`,Fe(e.status)),children:r.status[e.status]}),e.workflowRunId?(0,Y.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[r.workflowPrefix,` `,e.workflowRunId.slice(0,8)]}):null]}),(0,Y.jsx)(`div`,{className:o(`mt-1 line-clamp-2 whitespace-pre-line text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||(Le(e)?r.runDetail.resultPending:r.runDetail.noResult)}),(0,Y.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[Ne(e.createdAtMs,r,a),` · `,e.manual?r.trigger.manual:Ae(e.triggerSnapshot,r,i,a)]})]}),e.status===`running`||e.status===`queued`?(0,Y.jsx)(L,{variant:`ghost`,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`run:${e.id}:cancel`,()=>B.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]=i,t[16]=r,t[17]=a,t[18]=d,t[19]=u,t[20]=s,t[21]=e):e=t[21],p=n.map(e),t[5]=c,t[6]=i,t[7]=r,t[8]=a,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,Y.jsx)(`div`,{className:f,children:p}),t[22]=f,t[23]=p,t[24]=m):m=t[24],m}function lt(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 ut(e){let t=(0,W.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[s,c]=(0,U.useState)(a===void 0?!1:a),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
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
3
  `).slice(0,10).join(`
4
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]!==i?(g=p?(0,Y.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(dt),"aria-expanded":s,children:[(0,Y.jsx)(`span`,{children:i}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-fg`,children:[s?r.details.hideDetails:r.details.showDetails,(0,Y.jsx)(re,{className:o(`size-3.5 transition-transform`,s&&`rotate-180`),"aria-hidden":!0})]})]}):(0,Y.jsx)(`div`,{className:`px-2.5 py-2 text-xs font-medium text-fg-muted`,children:i}),t[7]=s,t[8]=p,t[9]=r,t[10]=i,t[11]=g):g=t[11];let _=s||!p?u:h,v;t[12]===_?v=t[13]:(v=(0,Y.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,Y.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 dt(e){return!e}function ft(e){let t=(0,W.c)(148),{className:n,run:r,events:i,labels:c,cronLabels:l,language:u,loading:d,repairDraft:f,repairLoading:m,repairApproved:h,busyAction:g,onRepairApprovedChange:v,onSuggestRepair:y,onApplyRepair:x}=e;if(!r){let e;t[0]===n?e=t[1]:(e=o(`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,Y.jsx)(P,{className:`mx-auto size-5`}),t[2]=r):r=t[2];let i;t[3]===c.selectRun?i=t[4]:(i=(0,Y.jsx)(`div`,{className:`mt-2`,children:c.selectRun}),t[3]=c.selectRun,t[4]=i);let a;return t[5]!==e||t[6]!==i?(a=(0,Y.jsxs)(`aside`,{className:e,children:[r,i]}),t[5]=e,t[6]=i,t[7]=a):a=t[7],a}let S=r.error||r.summary,C=r.sessionKey?`/chat/${encodeURIComponent(r.sessionKey)}`:r.workflowRunId?`/workflows?run=${encodeURIComponent(r.workflowRunId)}`:null,w=r.sessionKey?c.runDetail.openConversation:c.runDetail.openWorkflow,T=r.sessionKey?_:ce,E=Le(r)?P:Re(r)?s:te,D;t[8]===n?D=t[9]:(D=o(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=D);let k;t[10]===r.automationName?k=t[11]:(k=(0,Y.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=k);let A;t[12]===r.id?A=t[13]:(A=r.id.slice(0,8),t[12]=r.id,t[13]=A);let j;t[14]===A?j=t[15]:(j=(0,Y.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:A}),t[14]=A,t[15]=j);let M;t[16]!==k||t[17]!==j?(M=(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[k,j]}),t[16]=k,t[17]=j,t[18]=M):M=t[18];let N;t[19]===r.status?N=t[20]:(N=o(`shrink-0 rounded-full px-2 py-0.5 text-xs`,Fe(r.status)),t[19]=r.status,t[20]=N);let ne=c.status[r.status],F;t[21]!==N||t[22]!==ne?(F=(0,Y.jsx)(`span`,{className:N,children:ne}),t[21]=N,t[22]=ne,t[23]=F):F=t[23];let ie;t[24]!==M||t[25]!==F?(ie=(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[M,F]}),t[24]=M,t[25]=F,t[26]=ie):ie=t[26];let ae;t[27]!==c||t[28]!==u||t[29]!==r.createdAtMs?(ae=Ne(r.createdAtMs,c,u),t[27]=c,t[28]=u,t[29]=r.createdAtMs,t[30]=ae):ae=t[30];let oe;t[31]===ae?oe=t[32]:(oe=(0,Y.jsx)(`span`,{children:ae}),t[31]=ae,t[32]=oe);let se;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=se):se=t[33];let R=c.details.duration,z;t[34]!==c||t[35]!==r.durationMs?(z=Ie(r.durationMs,c),t[34]=c,t[35]=r.durationMs,t[36]=z):z=t[36];let le;t[37]!==c.details.duration||t[38]!==z?(le=(0,Y.jsxs)(`span`,{children:[R,` `,z]}),t[37]=c.details.duration,t[38]=z,t[39]=le):le=t[39];let ue;t[40]!==oe||t[41]!==le?(ue=(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[oe,se,le]}),t[40]=oe,t[41]=le,t[42]=ue):ue=t[42];let B;t[43]!==c.repair||t[44]!==y||t[45]!==m||t[46]!==r?(B=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,Y.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Y.jsxs)(L,{variant:`secondary`,onClick:()=>y(r),disabled:m,children:[(0,Y.jsx)(ee,{className:`size-4`}),m?c.repair.generating:c.repair.suggest]})}):null,t[43]=c.repair,t[44]=y,t[45]=m,t[46]=r,t[47]=B):B=t[47];let de;t[48]!==ue||t[49]!==B||t[50]!==ie?(de=(0,Y.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[ie,ue,B]}),t[48]=ue,t[49]=B,t[50]=ie,t[51]=de):de=t[51];let fe;t[52]===r?fe=t[53]:(fe=Le(r)?`text-blue-500`:Re(r)?`text-red-500`:`text-emerald-500`,t[52]=r,t[53]=fe);let V;t[54]===fe?V=t[55]:(V=o(`size-4`,fe),t[54]=fe,t[55]=V);let H;t[56]!==E||t[57]!==V?(H=(0,Y.jsx)(E,{className:V}),t[56]=E,t[57]=V,t[58]=H):H=t[58];let pe;t[59]!==c.runDetail.resultTitle||t[60]!==H?(pe=(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[H,c.runDetail.resultTitle]}),t[59]=c.runDetail.resultTitle,t[60]=H,t[61]=pe):pe=t[61];let me;t[62]!==T||t[63]!==w||t[64]!==C?(me=C?(0,Y.jsx)(L,{asChild:!0,variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,children:(0,Y.jsxs)(a,{to:C,children:[(0,Y.jsx)(T,{className:`size-3.5`}),w,(0,Y.jsx)(O,{className:`size-3.5`})]})}):null,t[62]=T,t[63]=w,t[64]=C,t[65]=me):me=t[65];let he;t[66]!==pe||t[67]!==me?(he=(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[pe,me]}),t[66]=pe,t[67]=me,t[68]=he):he=t[68];let U=r.error&&`border-red-500/25 bg-red-500/5`,G;t[69]===U?G=t[70]:(G=o(`mt-3 max-h-80 overflow-y-auto rounded-lg border border-edge/70 bg-surface-muted/25 p-3`,U),t[69]=U,t[70]=G);let K;t[71]!==c.runDetail.noResult||t[72]!==c.runDetail.resultPending||t[73]!==S||t[74]!==r?(K=S?r.error?(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-red-700 dark:text-red-300`,children:S}):(0,Y.jsx)(b,{content:S,compact:!0,className:`text-sm`,openHttpLinksInNewTab:!0}):(0,Y.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:Le(r)?c.runDetail.resultPending:c.runDetail.noResult}),t[71]=c.runDetail.noResult,t[72]=c.runDetail.resultPending,t[73]=S,t[74]=r,t[75]=K):K=t[75];let ge;t[76]!==G||t[77]!==K?(ge=(0,Y.jsx)(`div`,{className:G,children:K}),t[76]=G,t[77]=K,t[78]=ge):ge=t[78];let _e;t[79]!==he||t[80]!==ge?(_e=(0,Y.jsxs)(`section`,{className:`border-b border-edge px-4 py-4`,children:[he,ge]}),t[79]=he,t[80]=ge,t[81]=_e):_e=t[81];let q;t[82]===c.runDetail.runInfo?q=t[83]:(q=(0,Y.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:c.runDetail.runInfo}),t[82]=c.runDetail.runInfo,t[83]=q);let ve;t[84]!==l||t[85]!==c||t[86]!==u||t[87]!==r.manual||t[88]!==r.triggerSnapshot?(ve=r.manual?c.trigger.manual:Ae(r.triggerSnapshot,c,l,u),t[84]=l,t[85]=c,t[86]=u,t[87]=r.manual,t[88]=r.triggerSnapshot,t[89]=ve):ve=t[89];let ye;t[90]!==c.explain.whyRan||t[91]!==ve?(ye=(0,Y.jsx)(vt,{label:c.explain.whyRan,value:ve}),t[90]=c.explain.whyRan,t[91]=ve,t[92]=ye):ye=t[92];let be=c.details.started,xe;t[93]!==c||t[94]!==u||t[95]!==r.startedAtMs?(xe=Ne(r.startedAtMs,c,u),t[93]=c,t[94]=u,t[95]=r.startedAtMs,t[96]=xe):xe=t[96];let Se;t[97]!==c.details.started||t[98]!==xe?(Se=(0,Y.jsx)(vt,{label:be,value:xe}),t[97]=c.details.started,t[98]=xe,t[99]=Se):Se=t[99];let Ce;t[100]!==c.details.model||t[101]!==r.model?(Ce=r.model?(0,Y.jsx)(vt,{label:c.details.model,value:r.model}):null,t[100]=c.details.model,t[101]=r.model,t[102]=Ce):Ce=t[102];let we;t[103]!==ye||t[104]!==Se||t[105]!==Ce?(we=(0,Y.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[ye,Se,Ce]}),t[103]=ye,t[104]=Se,t[105]=Ce,t[106]=we):we=t[106];let Te;t[107]!==q||t[108]!==we?(Te=(0,Y.jsxs)(`section`,{className:`border-b border-edge px-4 py-4`,children:[q,we]}),t[107]=q,t[108]=we,t[109]=Te):Te=t[109];let Ee;t[110]!==g||t[111]!==c||t[112]!==x||t[113]!==v||t[114]!==h||t[115]!==f||t[116]!==r?(Ee=f?(0,Y.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:c.repair.title}),(0,Y.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:f.explanation}),f.expectedEffect?(0,Y.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:f.expectedEffect}):null,(0,Y.jsx)(at,{title:c.repair.risks,items:f.risks,empty:c.none}),(0,Y.jsx)(ut,{value:f.patch,labels:c,title:c.details.repairPatch}),f.requiresApproval?(0,Y.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-sm text-fg`,children:[(0,Y.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:h,onChange:e=>v(e.target.checked)}),(0,Y.jsx)(`span`,{children:c.repair.approval})]}):null,(0,Y.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Y.jsx)(L,{variant:`primary`,onClick:()=>x(r),disabled:g===`run:${r.id}:repair`||f.requiresApproval&&!h,children:g===`run:${r.id}:repair`?c.feedback.working:c.repair.apply})})]}):null,t[110]=g,t[111]=c,t[112]=x,t[113]=v,t[114]=h,t[115]=f,t[116]=r,t[117]=Ee):Ee=t[117];let De;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,Y.jsx)(p,{className:`size-4 shrink-0`}),t[118]=De):De=t[118];let Oe;t[119]===c.runDetail.technicalEvents?Oe=t[120]:(Oe=(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium text-fg-muted`,children:[De,c.runDetail.technicalEvents]}),t[119]=c.runDetail.technicalEvents,t[120]=Oe);let ke;t[121]!==i.length||t[122]!==c.runDetail.eventCount?(ke=c.runDetail.eventCount.replace(`{count}`,String(i.length)),t[121]=i.length,t[122]=c.runDetail.eventCount,t[123]=ke):ke=t[123];let J;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Y.jsx)(re,{className:`size-4 transition-transform group-open:rotate-180`}),t[124]=J):J=t[124];let je;t[125]===ke?je=t[126]:(je=(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[ke,J]}),t[125]=ke,t[126]=je);let X;t[127]!==Oe||t[128]!==je?(X=(0,Y.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 rounded-md outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[Oe,je]}),t[127]=Oe,t[128]=je,t[129]=X):X=t[129];let Me;t[130]===c.runDetail.technicalEventsDescription?Me=t[131]:(Me=(0,Y.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:c.runDetail.technicalEventsDescription}),t[130]=c.runDetail.technicalEventsDescription,t[131]=Me);let Z;t[132]!==i||t[133]!==c||t[134]!==u||t[135]!==d?(Z=(0,Y.jsx)(`div`,{className:`mt-4`,children:d?(0,Y.jsxs)(`div`,{className:`space-y-3`,"aria-label":c.loading,children:[(0,Y.jsx)(I,{className:`h-10 w-full`}),(0,Y.jsx)(I,{className:`h-10 w-4/5`}),(0,Y.jsx)(I,{className:`h-10 w-11/12`})]}):i.length===0?(0,Y.jsx)(`div`,{className:`text-sm text-fg-muted`,children:c.empty.events}):(0,Y.jsx)(`ol`,{className:`space-y-3`,children:i.map(e=>(0,Y.jsxs)(`li`,{className:`grid grid-cols-[0.75rem_1fr] gap-3`,children:[(0,Y.jsx)(`span`,{className:o(`mt-1 size-2 rounded-full`,yt(e.type))}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm text-fg`,children:lt(e,c)}),(0,Y.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[Ne(e.createdAtMs,c,u),` · `,e.type]}),e.data&&typeof e.data==`object`?(0,Y.jsxs)(`details`,{className:`group/event mt-2 rounded-md border border-edge/70 bg-surface-muted/35`,children:[(0,Y.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-2.5 py-2 text-xs font-medium text-fg-muted outline-none hover:text-fg`,children:[c.details.eventData,(0,Y.jsx)(re,{className:`size-3.5 transition-transform group-open/event:rotate-180`})]}),(0,Y.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-all border-t border-edge/70 px-2.5 py-2 text-xs leading-relaxed text-fg-muted`,children:JSON.stringify(e.data,null,2)})]}):null]})]},e.id))})}),t[132]=i,t[133]=c,t[134]=u,t[135]=d,t[136]=Z):Z=t[136];let Pe;t[137]!==X||t[138]!==Me||t[139]!==Z?(Pe=(0,Y.jsxs)(`details`,{className:`group px-4 py-3`,children:[X,Me,Z]}),t[137]=X,t[138]=Me,t[139]=Z,t[140]=Pe):Pe=t[140];let ze;return t[141]!==D||t[142]!==de||t[143]!==_e||t[144]!==Te||t[145]!==Ee||t[146]!==Pe?(ze=(0,Y.jsxs)(`aside`,{className:D,children:[de,_e,Te,Ee,Pe]}),t[141]=D,t[142]=de,t[143]=_e,t[144]=Te,t[145]=Ee,t[146]=Pe,t[147]=ze):ze=t[147],ze}function pt(e){let t=(0,W.c)(23),{automation:n,runs:r,labels:i,cronLabels:s,language:c,busyAction:l,onClose:u,onEdit:p,onSelectRun:m,onAction:g}=e,_=n?l===`automation:${n.id}:run`:!1,v=n?l===`automation:${n.id}:toggle`:!1,y=n?l===`automation:${n.id}:delete`:!1,b=!!n,x;t[0]===u?x=t[1]:(x=e=>!e&&u(),t[0]=u,t[1]=x);let S;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Y.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[2]=S):S=t[2];let C;t[3]!==n||t[4]!==l||t[5]!==s||t[6]!==y||t[7]!==i||t[8]!==c||t[9]!==g||t[10]!==u||t[11]!==p||t[12]!==m||t[13]!==_||t[14]!==r||t[15]!==v?(C=n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(D,{className:`truncate text-base font-semibold text-fg`,children:n.name}),n.description?(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:n.description}):null]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:o(`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?i.enabled:i.paused}),(0,Y.jsx)(ae,{asChild:!0,children:(0,Y.jsx)(L,{variant:`ghost`,"aria-label":i.close,children:(0,Y.jsx)(le,{className:`size-4`})})})]})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Y.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[20rem_1fr]`,children:[(0,Y.jsx)(ht,{automation:n,labels:i,cronLabels:s,language:c}),(0,Y.jsxs)(`section`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.dashboard.runHistory}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.dashboard.runHistoryDescription})]}),(0,Y.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,Y.jsx)(xt,{icon:(0,Y.jsx)(P,{className:`size-5`}),title:i.empty.runs}):(0,Y.jsx)(`div`,{className:`grid gap-2`,children:r.map(e=>(0,Y.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Y.jsxs)(`button`,{className:`min-w-0 text-left outline-none`,onClick:()=>m(e.id),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.status===`succeeded`?(0,Y.jsx)(te,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,Y.jsx)(P,{className:`size-4 shrink-0 text-fg-muted`}),(0,Y.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:Ne(e.createdAtMs,i,c)}),(0,Y.jsx)(`span`,{className:o(`rounded-full px-2 py-0.5 text-xs`,Fe(e.status)),children:i.status[e.status]})]}),(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.error||e.summary||Z(e.actionSnapshot,i)})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1`,children:[e.sessionKey?(0,Y.jsx)(L,{asChild:!0,variant:`ghost`,className:`h-8 rounded-md px-2 text-xs`,children:(0,Y.jsxs)(a,{to:`/chat/${encodeURIComponent(e.sessionKey)}`,children:[(0,Y.jsx)(h,{className:`size-3.5`}),i.dashboard.openSession]})}):null,e.workflowRunId?(0,Y.jsx)(L,{asChild:!0,variant:`ghost`,className:`h-8 rounded-md px-2 text-xs`,children:(0,Y.jsxs)(a,{to:`/workflows?run=${encodeURIComponent(e.workflowRunId)}`,children:[(0,Y.jsx)(ce,{className:`size-3.5`}),i.feedback.workflow]})}):null]})]})},e.id))})]})]})}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-edge px-5 py-4`,children:[(0,Y.jsxs)(L,{variant:`ghost`,disabled:l!==null,onClick:()=>void g(`automation:${n.id}:delete`,()=>B.remove(n.id),i.dashboard.deleted).then(e=>{e&&u()}),children:[y?(0,Y.jsx)(R,{className:`size-4 animate-spin`}):(0,Y.jsx)(f,{className:`size-4`}),i.dashboard.delete]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[Be(n)?null:(0,Y.jsxs)(L,{variant:`secondary`,disabled:l!==null,onClick:()=>p(n),children:[(0,Y.jsx)(N,{className:`size-4`}),i.edit]}),(0,Y.jsxs)(L,{variant:`secondary`,disabled:l!==null,onClick:()=>void g(`automation:${n.id}:toggle`,()=>n.enabled?B.pause(n.id):B.resume(n.id),n.enabled?i.feedback.paused:i.dashboard.resumed),children:[v?(0,Y.jsx)(R,{className:`size-4 animate-spin`}):n.enabled?(0,Y.jsx)(k,{className:`size-4`}):(0,Y.jsx)(F,{className:`size-4`}),n.enabled?i.dashboard.pause:i.dashboard.resume]}),(0,Y.jsxs)(L,{variant:`primary`,disabled:l!==null,onClick:()=>void g(`automation:${n.id}:run`,()=>B.runNow(n.id),i.feedback.rerunQueued),children:[_?(0,Y.jsx)(R,{className:`size-4 animate-spin`}):(0,Y.jsx)(F,{className:`size-4`}),i.dashboard.runNow]})]})]})]}):null,t[3]=n,t[4]=l,t[5]=s,t[6]=y,t[7]=i,t[8]=c,t[9]=g,t[10]=u,t[11]=p,t[12]=m,t[13]=_,t[14]=r,t[15]=v,t[16]=C):C=t[16];let O;t[17]===C?O=t[18]:(O=(0,Y.jsxs)(T,{children:[S,(0,Y.jsx)(d,{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:C})]}),t[17]=C,t[18]=O);let A;return t[19]!==b||t[20]!==x||t[21]!==O?(A=(0,Y.jsx)(E,{open:b,onOpenChange:x,children:O}),t[19]=b,t[20]=x,t[21]=O,t[22]=A):A=t[22],A}function mt(e,t){return e===`suggest_only`?t.safety.suggestOnlyDescription:e===`ask_before_apply`?t.safety.askBeforeApplyDescription:t.safety.autoApplyDescription}function ht(e){let t=(0,W.c)(127),{automation:n,labels:r,cronLabels:i,language:a}=e,o,s,c,l,u,d,f,p,m,h,g;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e=Pe(n),_;t[15]!==n||t[16]!==r||t[17]!==a?(_=J(n,r,a),t[15]=n,t[16]=r,t[17]=a,t[18]=_):_=t[18];let v=_,y;t[19]!==n.state.nextRunAtMs||t[20]!==a?(y=n.state.nextRunAtMs?Ee(n.state.nextRunAtMs,a):void 0,t[19]=n.state.nextRunAtMs,t[20]=a,t[21]=y):y=t[21];let b=y;if(t[22]!==n.trigger.eventType||t[23]!==n.trigger.kind||t[24]!==n.trigger.schedule||t[25]!==n.trigger.secretId||t[26]!==n.trigger.source||t[27]!==r.info.anchor||t[28]!==r.info.calendarSchedule||t[29]!==r.info.eventSource||t[30]!==r.info.eventType||t[31]!==r.info.expression||t[32]!==r.info.fixedInterval||t[33]!==r.info.oneTimeSchedule||t[34]!==r.info.rawInterval||t[35]!==r.info.scheduleType||t[36]!==r.info.timezone||t[37]!==r.info.webhookSecret||t[38]!==a){if(g=[],n.trigger.kind===`schedule`){let e=n.trigger.schedule,i=e.kind===`interval`?r.info.fixedInterval:e.kind===`cron`?r.info.calendarSchedule:r.info.oneTimeSchedule,o;if(t[40]!==r.info.scheduleType||t[41]!==i?(o={label:r.info.scheduleType,value:i},t[40]=r.info.scheduleType,t[41]=i,t[42]=o):o=t[42],g.push(o),e.kind===`interval`){let n=`${e.everyMs} ms`,i;if(t[43]!==r.info.rawInterval||t[44]!==n?(i={label:r.info.rawInterval,value:n},t[43]=r.info.rawInterval,t[44]=n,t[45]=i):i=t[45],g.push(i),e.anchorMs){let n=r.info.anchor,i;t[46]!==a||t[47]!==e.anchorMs?(i=Ee(e.anchorMs,a),t[46]=a,t[47]=e.anchorMs,t[48]=i):i=t[48];let o;t[49]!==r.info.anchor||t[50]!==i?(o={label:n,value:i},t[49]=r.info.anchor,t[50]=i,t[51]=o):o=t[51],g.push(o)}}else if(e.kind===`cron`){let n;if(t[52]!==r.info.expression||t[53]!==e.expr?(n={label:r.info.expression,value:e.expr},t[52]=r.info.expression,t[53]=e.expr,t[54]=n):n=t[54],g.push(n),e.tz){let n;t[55]!==r.info.timezone||t[56]!==e.tz?(n={label:r.info.timezone,value:e.tz},t[55]=r.info.timezone,t[56]=e.tz,t[57]=n):n=t[57],g.push(n)}}else{let n;t[58]!==r.info.oneTimeSchedule||t[59]!==e.at?(n={label:r.info.oneTimeSchedule,value:e.at},t[58]=r.info.oneTimeSchedule,t[59]=e.at,t[60]=n):n=t[60],g.push(n)}}else if(n.trigger.kind===`event`){let e;if(t[61]!==n.trigger.eventType||t[62]!==r.info.eventType?(e={label:r.info.eventType,value:n.trigger.eventType},t[61]=n.trigger.eventType,t[62]=r.info.eventType,t[63]=e):e=t[63],g.push(e),n.trigger.source){let e;t[64]!==n.trigger.source||t[65]!==r.info.eventSource?(e={label:r.info.eventSource,value:n.trigger.source},t[64]=n.trigger.source,t[65]=r.info.eventSource,t[66]=e):e=t[66],g.push(e)}}else if(n.trigger.kind===`webhook`&&n.trigger.secretId){let e;t[67]!==n.trigger.secretId||t[68]!==r.info.webhookSecret?(e={label:r.info.webhookSecret,value:n.trigger.secretId},t[67]=n.trigger.secretId,t[68]=r.info.webhookSecret,t[69]=e):e=t[69],g.push(e)}t[22]=n.trigger.eventType,t[23]=n.trigger.kind,t[24]=n.trigger.schedule,t[25]=n.trigger.secretId,t[26]=n.trigger.source,t[27]=r.info.anchor,t[28]=r.info.calendarSchedule,t[29]=r.info.eventSource,t[30]=r.info.eventType,t[31]=r.info.expression,t[32]=r.info.fixedInterval,t[33]=r.info.oneTimeSchedule,t[34]=r.info.rawInterval,t[35]=r.info.scheduleType,t[36]=r.info.timezone,t[37]=r.info.webhookSecret,t[38]=a,t[39]=g}else g=t[39];m=`h-fit overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,t[70]===r.info.overview?h=t[71]:(h=(0,Y.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.info.overview})}),t[70]=r.info.overview,t[71]=h),d=`grid gap-4 p-4`;let S;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Y.jsx)(z,{className:`size-4`,"aria-hidden":!0}),t[72]=S):S=t[72];let C=r.info.schedule,w;t[73]!==n.trigger||t[74]!==i||t[75]!==r||t[76]!==a?(w=Ae(n.trigger,r,i,a),t[73]=n.trigger,t[74]=i,t[75]=r,t[76]=a,t[77]=w):w=t[77];let T=n.enabled?`${r.info.nextRun}:${v}`:v;t[78]!==r.info.schedule||t[79]!==b||t[80]!==w||t[81]!==T?(f=(0,Y.jsx)(_t,{icon:S,label:C,value:w,description:T,descriptionTitle:b}),t[78]=r.info.schedule,t[79]=b,t[80]=w,t[81]=T,t[82]=f):f=t[82];let E;t[83]===n.action.kind?E=t[84]:(E=n.action.kind===`workflow`?(0,Y.jsx)(ce,{className:`size-4`,"aria-hidden":!0}):(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":!0}),t[83]=n.action.kind,t[84]=E);let D=r.info.action,O;t[85]!==n.action||t[86]!==r?(O=Z(n.action,r),t[85]=n.action,t[86]=r,t[87]=O):O=t[87],t[88]!==r.info.action||t[89]!==E||t[90]!==O?(p=(0,Y.jsx)(_t,{icon:E,label:D,value:O}),t[88]=r.info.action,t[89]=E,t[90]=O,t[91]=p):p=t[91],o=_t,t[92]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0}),t[92]=s):s=t[92],c=r.info.permission,l=r.safety[e],u=mt(e,r),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14];let _;t[93]!==o||t[94]!==s||t[95]!==c||t[96]!==l||t[97]!==u?(_=(0,Y.jsx)(o,{icon:s,label:c,value:l,description:u}),t[93]=o,t[94]=s,t[95]=c,t[96]=l,t[97]=u,t[98]=_):_=t[98];let v;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Y.jsx)(P,{className:`size-4`,"aria-hidden":!0}),t[99]=v):v=t[99];let y=r.info.lastRun,b;t[100]!==n||t[101]!==r||t[102]!==a?(b=je(n,r,a),t[100]=n,t[101]=r,t[102]=a,t[103]=b):b=t[103];let S=n.state.lastRunStatus===`failed`||n.state.lastRunStatus===`timeout`?`danger`:`default`,C;t[104]!==r.info.lastRun||t[105]!==b||t[106]!==S?(C=(0,Y.jsx)(_t,{icon:v,label:y,value:b,valueTone:S}),t[104]=r.info.lastRun,t[105]=b,t[106]=S,t[107]=C):C=t[107];let w;t[108]!==n.state.consecutiveFailures||t[109]!==n.state.lastError||t[110]!==r.dashboard?(w=n.state.consecutiveFailures?(0,Y.jsxs)(`div`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:[r.dashboard.failures,`:`,n.state.consecutiveFailures,n.state.lastError?(0,Y.jsx)(`p`,{className:`mt-1 break-words text-xs`,children:n.state.lastError}):null]}):n.state.lastError?(0,Y.jsx)(`p`,{className:`break-words text-sm text-red-700 dark:text-red-300`,children:n.state.lastError}):null,t[108]=n.state.consecutiveFailures,t[109]=n.state.lastError,t[110]=r.dashboard,t[111]=w):w=t[111];let T;t[112]!==r.info.technicalDetails||t[113]!==g?(T=g.length>0?(0,Y.jsxs)(`details`,{className:`group border-t border-edge-subtle pt-3`,children:[(0,Y.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-sm text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Y.jsx)(`span`,{children:r.info.technicalDetails}),(0,Y.jsx)(re,{className:`size-4 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Y.jsx)(`div`,{className:`mt-3 grid gap-2`,children:g.map(gt)})]}):null,t[112]=r.info.technicalDetails,t[113]=g,t[114]=T):T=t[114];let E;t[115]!==_||t[116]!==C||t[117]!==w||t[118]!==T||t[119]!==d||t[120]!==f||t[121]!==p?(E=(0,Y.jsxs)(`div`,{className:d,children:[f,p,_,C,w,T]}),t[115]=_,t[116]=C,t[117]=w,t[118]=T,t[119]=d,t[120]=f,t[121]=p,t[122]=E):E=t[122];let D;return t[123]!==E||t[124]!==m||t[125]!==h?(D=(0,Y.jsxs)(`aside`,{className:m,children:[h,E]}),t[123]=E,t[124]=m,t[125]=h,t[126]=D):D=t[126],D}function gt(e){return(0,Y.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.label}),(0,Y.jsx)(`span`,{className:`break-all font-mono text-xs text-fg-muted`,children:e.value})]},`${e.label}:${e.value}`)}function _t(e){let t=(0,W.c)(19),{icon:n,label:r,value:i,description:a,descriptionTitle:s,valueTone:c}=e,l=c===void 0?`default`:c,u;t[0]===n?u=t[1]:(u=(0,Y.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:n}),t[0]=n,t[1]=u);let d;t[2]===r?d=t[3]:(d=(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=d);let f=l===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,p;t[4]===f?p=t[5]:(p=o(`mt-1 text-sm font-medium leading-5`,f),t[4]=f,t[5]=p);let m;t[6]!==p||t[7]!==i?(m=(0,Y.jsx)(`div`,{className:p,children:i}),t[6]=p,t[7]=i,t[8]=m):m=t[8];let h;t[9]!==a||t[10]!==s?(h=a?(0,Y.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,title:s,children:a}):null,t[9]=a,t[10]=s,t[11]=h):h=t[11];let g;t[12]!==d||t[13]!==m||t[14]!==h?(g=(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[d,m,h]}),t[12]=d,t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;return t[16]!==u||t[17]!==g?(_=(0,Y.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_1fr] gap-2.5`,children:[u,g]}),t[16]=u,t[17]=g,t[18]=_):_=t[18],_}function vt(e){let t=(0,W.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Y.jsx)(`span`,{children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Y.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,Y.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 yt(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function bt(e){let t=(0,W.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Y.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,Y.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,Y.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function xt(e){let t=(0,W.c)(5),{icon:n,title:r}=e,i;t[0]===r?i=t[1]:(i=(0,Y.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,Y.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 St(e){let t=(0,W.c)(242),{form:n,labels:r,setForm:i,workflowDefinitions:a,selectedWorkflow:s,workflowsLoading:l,agentOptions:u,agentsLoading:d,language:f}=e,p=c(f).agentsSettings,m;t[0]===i?m=t[1]:(m=e=>i(t=>({...t,...e})),t[0]=i,t[1]=m);let h=m,g=Se(n.intervalValue,n.intervalUnit),_=Date.now(),v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=[1,2,3],t[2]=v):v=t[2];let b;t[3]!==g||t[4]!==_||t[5]!==f?(b=v.map(e=>Oe(_+g*e,f,_)),t[3]=g,t[4]=_,t[5]=f,t[6]=b):b=t[6];let x=b,C,w;t[7]!==n.actionMode||t[8]!==n.workflowId||t[9]!==i||t[10]!==a?(C=()=>{if(n.actionMode!==`workflow`||n.workflowId.trim())return;let e=a[0]?.id;e&&i(t=>({...t,workflowId:e,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}))},w=[n.actionMode,n.workflowId,i,a],t[7]=n.actionMode,t[8]=n.workflowId,t[9]=i,t[10]=a,t[11]=C,t[12]=w):(C=t[11],w=t[12]),(0,U.useEffect)(C,w);let T;t[13]===h?T=t[14]:(T=e=>h({name:e.target.value}),t[13]=h,t[14]=T);let E;t[15]!==n.name||t[16]!==T?(E=(0,Y.jsx)(`input`,{className:Q,value:n.name,onChange:T}),t[15]=n.name,t[16]=T,t[17]=E):E=t[17];let D;t[18]!==r.form.name||t[19]!==E?(D=(0,Y.jsx)($,{label:r.form.name,children:E}),t[18]=r.form.name,t[19]=E,t[20]=D):D=t[20];let O;t[21]===h?O=t[22]:(O=e=>h({description:e.target.value}),t[21]=h,t[22]=O);let k;t[23]!==n.description||t[24]!==O?(k=(0,Y.jsx)(`input`,{className:Q,value:n.description,onChange:O}),t[23]=n.description,t[24]=O,t[25]=k):k=t[25];let A;t[26]!==r.form.description||t[27]!==k?(A=(0,Y.jsx)($,{label:r.form.description,children:k}),t[26]=r.form.description,t[27]=k,t[28]=A):A=t[28];let ee;t[29]===r.form.trigger?ee=t[30]:(ee=(0,Y.jsx)(wt,{title:r.form.trigger}),t[29]=r.form.trigger,t[30]=ee);let te;t[31]===h?te=t[32]:(te=e=>h({triggerMode:e.target.value}),t[31]=h,t[32]=te);let M;t[33]===r.trigger.manual?M=t[34]:(M=(0,Y.jsx)(S,{value:`manual`,children:r.trigger.manual}),t[33]=r.trigger.manual,t[34]=M);let N;t[35]===r.trigger.once?N=t[36]:(N=(0,Y.jsx)(S,{value:`once`,children:r.trigger.once}),t[35]=r.trigger.once,t[36]=N);let P;t[37]===r.trigger.daily?P=t[38]:(P=(0,Y.jsx)(S,{value:`daily`,children:r.trigger.daily}),t[37]=r.trigger.daily,t[38]=P);let ne;t[39]===r.trigger.weekly?ne=t[40]:(ne=(0,Y.jsx)(S,{value:`weekly`,children:r.trigger.weekly}),t[39]=r.trigger.weekly,t[40]=ne);let re;t[41]===r.trigger.interval?re=t[42]:(re=(0,Y.jsx)(S,{value:`interval`,children:r.trigger.interval}),t[41]=r.trigger.interval,t[42]=re);let F;t[43]===r.trigger.customCron?F=t[44]:(F=(0,Y.jsx)(S,{value:`cron`,children:r.trigger.customCron}),t[43]=r.trigger.customCron,t[44]=F);let ie;t[45]===r.trigger.webhook?ie=t[46]:(ie=(0,Y.jsx)(S,{value:`webhook`,children:r.trigger.webhook}),t[45]=r.trigger.webhook,t[46]=ie);let I;t[47]===r.trigger.goalBlocked?I=t[48]:(I=(0,Y.jsx)(S,{value:`goalBlocked`,children:r.trigger.goalBlocked}),t[47]=r.trigger.goalBlocked,t[48]=I);let ae;t[49]===r.trigger.noteCreated?ae=t[50]:(ae=(0,Y.jsx)(S,{value:`noteCreated`,children:r.trigger.noteCreated}),t[49]=r.trigger.noteCreated,t[50]=ae);let oe;t[51]===r.trigger.workflowFailed?oe=t[52]:(oe=(0,Y.jsx)(S,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[51]=r.trigger.workflowFailed,t[52]=oe);let L;t[53]===r.trigger.sessionUpdated?L=t[54]:(L=(0,Y.jsx)(S,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[53]=r.trigger.sessionUpdated,t[54]=L);let se;t[55]===r.trigger.customEvent?se=t[56]:(se=(0,Y.jsx)(S,{value:`event`,children:r.trigger.customEvent}),t[55]=r.trigger.customEvent,t[56]=se);let ce;t[57]!==n.triggerMode||t[58]!==te||t[59]!==M||t[60]!==N||t[61]!==P||t[62]!==ne||t[63]!==re||t[64]!==F||t[65]!==ie||t[66]!==I||t[67]!==ae||t[68]!==oe||t[69]!==L||t[70]!==se?(ce=(0,Y.jsxs)(j,{className:Q,value:n.triggerMode,onChange:te,children:[M,N,P,ne,re,F,ie,I,ae,oe,L,se]}),t[57]=n.triggerMode,t[58]=te,t[59]=M,t[60]=N,t[61]=P,t[62]=ne,t[63]=re,t[64]=F,t[65]=ie,t[66]=I,t[67]=ae,t[68]=oe,t[69]=L,t[70]=se,t[71]=ce):ce=t[71];let R;t[72]!==n.onceAt||t[73]!==n.triggerMode||t[74]!==r.form.onceAt||t[75]!==h?(R=n.triggerMode===`once`?(0,Y.jsx)($,{label:r.form.onceAt,children:(0,Y.jsx)(`input`,{className:Q,type:`datetime-local`,value:n.onceAt,onChange:e=>h({onceAt:e.target.value})})}):null,t[72]=n.onceAt,t[73]=n.triggerMode,t[74]=r.form.onceAt,t[75]=h,t[76]=R):R=t[76];let z;t[77]!==n.time||t[78]!==n.triggerMode||t[79]!==n.weekday||t[80]!==r.form.day||t[81]!==r.form.time||t[82]!==r.weekdays||t[83]!==h?(z=n.triggerMode===`daily`||n.triggerMode===`weekly`?(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsx)($,{label:r.form.time,children:(0,Y.jsx)(`input`,{className:Q,type:`time`,value:n.time,onChange:e=>h({time:e.target.value})})}),n.triggerMode===`weekly`?(0,Y.jsx)($,{label:r.form.day,children:(0,Y.jsxs)(j,{className:Q,value:n.weekday,onChange:e=>h({weekday:e.target.value}),children:[(0,Y.jsx)(S,{value:`1`,children:r.weekdays.monday}),(0,Y.jsx)(S,{value:`2`,children:r.weekdays.tuesday}),(0,Y.jsx)(S,{value:`3`,children:r.weekdays.wednesday}),(0,Y.jsx)(S,{value:`4`,children:r.weekdays.thursday}),(0,Y.jsx)(S,{value:`5`,children:r.weekdays.friday}),(0,Y.jsx)(S,{value:`6`,children:r.weekdays.saturday}),(0,Y.jsx)(S,{value:`0`,children:r.weekdays.sunday})]})}):null]}):null,t[77]=n.time,t[78]=n.triggerMode,t[79]=n.weekday,t[80]=r.form.day,t[81]=r.form.time,t[82]=r.weekdays,t[83]=h,t[84]=z):z=t[84];let le=n.triggerMode===`interval`?(0,Y.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Y.jsx)($,{label:r.form.intervalEvery,children:(0,Y.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,Y.jsx)(`input`,{className:Q,type:`number`,min:6e4/Se(1,n.intervalUnit),step:`any`,inputMode:`decimal`,value:n.intervalValue,onChange:e=>h({intervalValue:e.target.value})}),(0,Y.jsxs)(j,{className:Q,value:n.intervalUnit,onChange:e=>{let t=e.target.value;h({intervalValue:Ce(n.intervalValue,n.intervalUnit,t),intervalUnit:t})},children:[(0,Y.jsx)(S,{value:`minute`,children:r.form.intervalUnits.minute}),(0,Y.jsx)(S,{value:`hour`,children:r.form.intervalUnits.hour}),(0,Y.jsx)(S,{value:`day`,children:r.form.intervalUnits.day}),(0,Y.jsx)(S,{value:`week`,children:r.form.intervalUnits.week})]})]})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.form.commonIntervals}),(0,Y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:Me.map(e=>{let t=Se(e.value,e.unit),n=t===g;return(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":n,className:o(`rounded-full border px-2.5 py-1 text-xs transition-colors`,n?`border-accent bg-accent/10 text-accent`:`border-edge-subtle text-fg-muted hover:border-edge hover:bg-surface-hover hover:text-fg`),onClick:()=>h({intervalValue:e.value,intervalUnit:e.unit}),children:we(t,f)},`${e.value}:${e.unit}`)})})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:Te(g,f)}),(0,Y.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r.form.nextThreeRuns,`:`,x.join(f===`zh`?`、`:`, `)]}),(0,Y.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.form.fixedIntervalHint})]})]}):null,ue;t[85]!==n.cronExpr||t[86]!==n.triggerMode||t[87]!==r.form.expression||t[88]!==h?(ue=n.triggerMode===`cron`?(0,Y.jsx)($,{label:r.form.expression,children:(0,Y.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>h({cronExpr:e.target.value})})}):null,t[85]=n.cronExpr,t[86]=n.triggerMode,t[87]=r.form.expression,t[88]=h,t[89]=ue):ue=t[89];let B;t[90]!==n.triggerMode||t[91]!==n.webhookSecretId||t[92]!==r.form.secretId||t[93]!==h?(B=n.triggerMode===`webhook`?(0,Y.jsx)($,{label:r.form.secretId,children:(0,Y.jsx)(`input`,{className:Q,value:n.webhookSecretId,onChange:e=>h({webhookSecretId:e.target.value})})}):null,t[90]=n.triggerMode,t[91]=n.webhookSecretId,t[92]=r.form.secretId,t[93]=h,t[94]=B):B=t[94];let de;t[95]!==n.eventPayloadMatch||t[96]!==n.eventSource||t[97]!==n.eventType||t[98]!==n.triggerMode||t[99]!==r.form.eventPayloadMatch||t[100]!==r.form.eventSource||t[101]!==r.form.eventType||t[102]!==r.form.invalidJsonObject||t[103]!==h?(de=n.triggerMode===`event`?(0,Y.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Y.jsx)($,{label:r.form.eventType,children:(0,Y.jsx)(`input`,{className:Q,value:n.eventType,onChange:e=>h({eventType:e.target.value})})}),(0,Y.jsx)($,{label:r.form.eventSource,children:(0,Y.jsx)(`input`,{className:Q,value:n.eventSource,onChange:e=>h({eventSource:e.target.value})})})]}),(0,Y.jsxs)($,{label:r.form.eventPayloadMatch,children:[(0,Y.jsx)(`textarea`,{className:o(Q,`min-h-24 resize-y font-mono text-xs`),value:n.eventPayloadMatch,onChange:e=>h({eventPayloadMatch:e.target.value}),placeholder:`{