@xopcai/xopc 0.0.129 → 0.0.130

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 (91) hide show
  1. package/dist/browser-ext/icons/icon-128.png +0 -0
  2. package/dist/browser-ext/icons/icon-16.png +0 -0
  3. package/dist/browser-ext/icons/icon-32.png +0 -0
  4. package/dist/browser-ext/icons/icon-48.png +0 -0
  5. package/dist/browser-ext/manifest.json +1 -1
  6. package/dist/extensions/telegram/xopc.extension.json +1 -1
  7. package/dist/gateway/static/root/apple-touch-icon.png +0 -0
  8. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DHzfg5D-.js → agent-avatar-dicebear--iz8s0k-.js} +1 -1
  9. package/dist/gateway/static/root/assets/{agents-CMxKKFQD.js → agents-NxdjoWyZ.js} +1 -1
  10. package/dist/gateway/static/root/assets/{app-management-settings-panel-ptk9c5BN.js → app-management-settings-panel-DzSs6MPu.js} +1 -1
  11. package/dist/gateway/static/root/assets/{appearance-settings-bYeEj3IW.js → appearance-settings-9Y9ulFHw.js} +1 -1
  12. package/dist/gateway/static/root/assets/{apps-page-DdZvDf5B.js → apps-page-CPXB5VC2.js} +1 -1
  13. package/dist/gateway/static/root/assets/{archive-plugin-Dy6lsTHw.js → archive-plugin-DLWkp7gy.js} +1 -1
  14. package/dist/gateway/static/root/assets/{attachment-load-qOtBYR6Y.js → attachment-load-aDP5GIUn.js} +1 -1
  15. package/dist/gateway/static/root/assets/{automation-suggestion-card-BFH-RfaV.js → automation-suggestion-card-B1cByea5.js} +1 -1
  16. package/dist/gateway/static/root/assets/{automations-page-B8JTjkCr.js → automations-page-C3atGynq.js} +1 -1
  17. package/dist/gateway/static/root/assets/{binary-plugins-DJvi_thc.js → binary-plugins-DUisfrnF.js} +1 -1
  18. package/dist/gateway/static/root/assets/{block-editor-DlMnizlt.js → block-editor-D9aGvHMF.js} +1 -1
  19. package/dist/gateway/static/root/assets/{browser-settings-page-slHLiZgi.js → browser-settings-page-C7zmHlV-.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-presets-api-D4q7vHVJ.js → capability-presets-api-CaDTlpYK.js} +1 -1
  21. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-Dng8Grpv.js → capability-presets-settings-panel-BXDIjaXI.js} +1 -1
  22. package/dist/gateway/static/root/assets/{channels-settings-KIsISXw0.js → channels-settings-BxjagLJ_.js} +1 -1
  23. package/dist/gateway/static/root/assets/{connectors-page-C5fx4Qs9.js → connectors-page-B817lbgc.js} +1 -1
  24. package/dist/gateway/static/root/assets/{desktop-pet-Jmdn6q47.js → desktop-pet-DuRXndhI.js} +1 -1
  25. package/dist/gateway/static/root/assets/{desktop-pet-settings-B-u63N4e.js → desktop-pet-settings-iLgj-52b.js} +1 -1
  26. package/dist/gateway/static/root/assets/{directory-picker-path-field-8p1ehIHn.js → directory-picker-path-field-RtmB1V_x.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dreaming-settings-CCkKP-I4.js → dreaming-settings-C8abJcaI.js} +1 -1
  28. package/dist/gateway/static/root/assets/{extension-debug-page-DJ1ABK95.js → extension-debug-page-5-InZoH2.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-page-CP9P2lGM.js → extension-page-Bsai0Lgm.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-settings-page-DnhU-tx0.js → extension-settings-page-BI-cyHrx.js} +1 -1
  31. package/dist/gateway/static/root/assets/{gateway-config-api-CjxDn46s.js → gateway-config-api-DROtL9kG.js} +1 -1
  32. package/dist/gateway/static/root/assets/{gateway-settings-TING7224.js → gateway-settings-CyTSzCnt.js} +1 -1
  33. package/dist/gateway/static/root/assets/{goal-create-dialog-2lPbGfp3.js → goal-create-dialog-BNh1ojty.js} +1 -1
  34. package/dist/gateway/static/root/assets/{goal-detail-page-DHWVRafk.js → goal-detail-page-D5cZ4icP.js} +1 -1
  35. package/dist/gateway/static/root/assets/{goals-config-api-BqhuxG8P.js → goals-config-api-GqxVsoOo.js} +1 -1
  36. package/dist/gateway/static/root/assets/{goals-page-CMk-9ZYN.js → goals-page-CUznMB7d.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goals-settings-BHzOAU_l.js → goals-settings-dtOWKJda.js} +1 -1
  38. package/dist/gateway/static/root/assets/{heartbeat-settings-BQIm0P3V.js → heartbeat-settings-D5NztVps.js} +1 -1
  39. package/dist/gateway/static/root/assets/{index-C4k6QSXw.js → index-CxR00gsL.js} +6 -6
  40. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BrENZzM7.js → keyboard-shortcuts-settings-BHyCbDmv.js} +1 -1
  41. package/dist/gateway/static/root/assets/{logs-page-BiL302Ve.js → logs-page-DgEJ4PeH.js} +1 -1
  42. package/dist/gateway/static/root/assets/{markdown-split-BYF4ReGM.js → markdown-split-Cfv4fIaA.js} +1 -1
  43. package/dist/gateway/static/root/assets/{media-plugins-CpQDz-QJ.js → media-plugins-DHIecUIi.js} +1 -1
  44. package/dist/gateway/static/root/assets/{models-hub-panel-CFPpl3Cq.js → models-hub-panel-9zCYTThv.js} +1 -1
  45. package/dist/gateway/static/root/assets/{notes-page-BurgcdVZ.js → notes-page-D7iT2jV1.js} +1 -1
  46. package/dist/gateway/static/root/assets/{notes-workbench-BAELRM_O.js → notes-workbench-BuAkwok0.js} +2 -2
  47. package/dist/gateway/static/root/assets/{page-tabs-RnYYOIWO.js → page-tabs-xL5C9yyM.js} +1 -1
  48. package/dist/gateway/static/root/assets/{preview-open-alternatives-CTRt06Ri.js → preview-open-alternatives-Dlzt9LTH.js} +1 -1
  49. package/dist/gateway/static/root/assets/{project-detail-page-iXX1Ceo2.js → project-detail-page-BOKQPdB5.js} +1 -1
  50. package/dist/gateway/static/root/assets/{projects-page-GDVTFAY7.js → projects-page-ALHgCAPZ.js} +1 -1
  51. package/dist/gateway/static/root/assets/{remote-access-hub-BUrbUnwv.js → remote-access-hub-BnowluoZ.js} +1 -1
  52. package/dist/gateway/static/root/assets/{save-bar-controls-c4pZeikq.js → save-bar-controls-CxMWRml4.js} +1 -1
  53. package/dist/gateway/static/root/assets/{schedule-field-Cb6R7iuP.js → schedule-field-XCWPTiWa.js} +1 -1
  54. package/dist/gateway/static/root/assets/{schema-form-BqET_hEP.js → schema-form-BaQCsnUq.js} +1 -1
  55. package/dist/gateway/static/root/assets/{sessions-page-CiOreA2k.js → sessions-page-DnW0ohat.js} +1 -1
  56. package/dist/gateway/static/root/assets/settings-advanced-gate-N9Pc7kmG.js +1 -0
  57. package/dist/gateway/static/root/assets/{settings-collapsible-section-DuOvqNsI.js → settings-collapsible-section-D1SE9kRq.js} +1 -1
  58. package/dist/gateway/static/root/assets/{settings-form-section-DptSsbWd.js → settings-form-section-DnEPGUgO.js} +1 -1
  59. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BlVfBCb9.js → settings-loading-skeleton-DOvWEjHg.js} +1 -1
  60. package/dist/gateway/static/root/assets/{settings-page-layout-DVt69dJJ.js → settings-page-layout-CCjhhWJI.js} +1 -1
  61. package/dist/gateway/static/root/assets/{settings-page-xQx2Pkg5.js → settings-page-s-THg5D2.js} +1 -1
  62. package/dist/gateway/static/root/assets/{setup-status-panel-DWB8VdLK.js → setup-status-panel-UNMcmL2b.js} +1 -1
  63. package/dist/gateway/static/root/assets/{share-preview-page-8m_ACH0z.js → share-preview-page-CfO4RaVP.js} +1 -1
  64. package/dist/gateway/static/root/assets/{shares-settings-CgxfhNxI.js → shares-settings-Cv86ZsIh.js} +1 -1
  65. package/dist/gateway/static/root/assets/{skill-reload-api-BBFUOxmf.js → skill-reload-api-B-9sluy3.js} +1 -1
  66. package/dist/gateway/static/root/assets/{skills-page-bo695odu.js → skills-page-D4ifOU_G.js} +1 -1
  67. package/dist/gateway/static/root/assets/{system-settings-panel-CW22OkZ4.js → system-settings-panel-CMMpS4gB.js} +1 -1
  68. package/dist/gateway/static/root/assets/{typed-models-lib-BqpGAKxV.js → typed-models-lib-JlIzyeQ_.js} +1 -1
  69. package/dist/gateway/static/root/assets/{user-profile-settings-panel-CERVLuaW.js → user-profile-settings-panel-CZVtp4He.js} +1 -1
  70. package/dist/gateway/static/root/assets/{utils-BnmysurA.js → utils-Lv9XYntY.js} +1 -1
  71. package/dist/gateway/static/root/assets/{voice-api-key-field-Jr3jvPcB.js → voice-api-key-field-7ZjSxIDE.js} +1 -1
  72. package/dist/gateway/static/root/assets/{work-item-detail-page-B-8rex4u.js → work-item-detail-page-BYqDWx6I.js} +1 -1
  73. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Ci9GSPnS.js → workflow-run-setup-panel-BiygC8WQ.js} +1 -1
  74. package/dist/gateway/static/root/assets/{workflow-start-dialog-BhDj8pqH.js → workflow-start-dialog-CC47dSwh.js} +1 -1
  75. package/dist/gateway/static/root/assets/{workflows-page-Brb3UGvs.js → workflows-page-BP3hha0s.js} +1 -1
  76. package/dist/gateway/static/root/favicon-16x16.png +0 -0
  77. package/dist/gateway/static/root/favicon-32x32.png +0 -0
  78. package/dist/gateway/static/root/favicon-icon.svg +32 -1
  79. package/dist/gateway/static/root/favicon.ico +0 -0
  80. package/dist/gateway/static/root/favicon.png +0 -0
  81. package/dist/gateway/static/root/favicon.svg +29 -24
  82. package/dist/gateway/static/root/index.html +7 -6
  83. package/dist/gateway/static/root/logo-dark.svg +18 -23
  84. package/dist/gateway/static/root/logo.svg +18 -24
  85. package/dist/gateway/static/root/pwa-192x192.png +0 -0
  86. package/dist/gateway/static/root/pwa-512x512.png +0 -0
  87. package/dist/gateway/static/root/site.webmanifest +23 -0
  88. package/dist/package.js +1 -1
  89. package/dist/src/mcp/channel-bridge.js +1 -1
  90. package/package.json +5 -2
  91. package/dist/gateway/static/root/assets/settings-advanced-gate-C-qvptlu.js +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{n as s}from"./fetch-BMjlW0g1.js";import{t as c}from"./url-DFGNSBNT.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{Do as u,Dt as d,Fc as f,Ga as p,Ha as m,Ja as h,Ka as g,Ns as _,Ua as v,Va as y,Wa as b,_a as x,_o as S,oo as C,so as w,xo as T}from"./index-C4k6QSXw.js";import{n as E,t as D}from"./settings-page-layout-DVt69dJJ.js";import{r as O}from"./settings-loading-skeleton-BlVfBCb9.js";import{r as k,t as A}from"./settings-form-section-DptSsbWd.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,a]=(0,M.useReducer)(d,L),{info:o,loadError:s,actionError:c,copiedField:l,clearDialogOpen:h,clearConfirmChecked:x,clearConfirmText:E,uninstallDialogOpen:D,removeUserDataOnUninstall:k,busy:j}=r,R=(0,M.useCallback)(async()=>{if(e?.getUninstallInfo){a({type:`patch`,patch:{loadError:null}});try{a({type:`patch`,patch:{info:await e.getUninstallInfo()}})}catch(e){a({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}}},[e]);(0,M.useEffect)(()=>{R()},[R]);let z=async(e,n)=>{if(await S(e)){a({type:`patch`,patch:{actionError:null,copiedField:n}}),window.setTimeout(()=>a({type:`patch`,patch:{copiedField:null}}),2e3);return}a({type:`patch`,patch:{actionError:t.copyFailed}})},B=async()=>{if(e?.clearUserData){a({type:`patch`,patch:{busy:!0,actionError:null}});try{let n=await e.clearUserData();n.ok||a({type:`patch`,patch:{actionError:F(n.error,t.errors)}})}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.errors.generic}})}finally{a({type:`patch`,patch:{busy:!1,clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})}}},V=async()=>{if(e?.uninstallApp){a({type:`patch`,patch:{busy:!0,actionError:null}});try{let n=await e.uninstallApp({removeUserData:k});n.ok||a({type:`patch`,patch:{actionError:F(n.error,t.errors)}})}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.errors.generic}})}finally{a({type:`patch`,patch:{busy:!1,uninstallDialogOpen:!1}})}}};if(s)return(0,N.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:s});if(!o)return(0,N.jsx)(O,{rows:2});let H=!o.packaged,U=j||o.pendingUpdate||H,W=!H&&o.uninstallMode!==`unsupported`,G=I(o,t),K=x&&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)(_,{className:`size-4 text-accent`,strokeWidth:1.75}),t.title]}):null,c?(0,N.jsx)(`p`,{className:`mb-3 text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:c}):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,o.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:o.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`,T.press),onClick:()=>void z(o.appPath,`app`),children:[(0,N.jsx)(f,{className:`size-3`,"aria-hidden":!0}),l===`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:o.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`,T.press),onClick:()=>void z(o.dataPath,`data`),children:[(0,N.jsx)(f,{className:`size-3`,"aria-hidden":!0}),l===`data`?t.copied:t.copyPath]})]}),(0,N.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[t.dataSize,`: `,P(o.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`,T.press),onClick:()=>{a({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`,T.press),onClick:()=>{a({type:`patch`,patch:{removeUserDataOnUninstall:!1,uninstallDialogOpen:!0}})},children:t.uninstall})]}):null]})]}),(0,N.jsx)(p,{open:h,onOpenChange:e=>{e||a({type:`patch`,patch:{clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})},children:(0,N.jsxs)(b,{children:[(0,N.jsx)(v,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,N.jsxs)(y,{className:i(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,C,`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)(g,{className:`text-base font-semibold text-fg`,children:t.clearDataConfirmTitle}),(0,N.jsx)(m,{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:x,onChange:e=>a({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=>a({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)(u,{type:`button`,variant:`secondary`,disabled:j,onClick:()=>{a({type:`patch`,patch:{clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})},children:t.cancel}),(0,N.jsx)(u,{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)(p,{open:D,onOpenChange:e=>{e||a({type:`patch`,patch:{uninstallDialogOpen:!1}})},children:(0,N.jsxs)(b,{children:[(0,N.jsx)(v,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,N.jsxs)(y,{className:i(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,C,`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)(g,{className:`text-base font-semibold text-fg`,children:t.uninstallConfirmTitle}),(0,N.jsx)(m,{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=>a({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)(u,{type:`button`,variant:`secondary`,disabled:j,onClick:()=>a({type:`patch`,patch:{uninstallDialogOpen:!1}}),children:t.cancel}),(0,N.jsx)(u,{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 s(c(`/api/migrations/status`))).payload}async function B(){await s(c(`/api/migrations/apply`),{method:`POST`,body:`{}`})}function V({messages:e}){let{data:t,error:n,isLoading:r,mutate:i}=l(`settings-migration-status`,z,{refreshInterval:0,revalidateOnFocus:!1}),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(null);async function d(){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)(x,{className:`h-5 w-40 max-w-full`}),(0,N.jsx)(x,{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 f=t?.items??[],p=f.filter(e=>e.status===`conflict`||e.status===`error`),m=f.filter(e=>e.safety===`auto`&&e.status===`planned`),h=p.length>0||f.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:f.length===0?e.upToDate:h?e.manualAttention:e.safeRepairs.replace(`{{count}}`,String(m.length))})]}),m.length>0&&!h?(0,N.jsx)(u,{type:`button`,variant:`primary`,className:`px-3 py-1.5 text-xs`,onClick:()=>void d(),disabled:a,children:a?e.applying:e.apply}):null]}),f.length>0?(0,N.jsx)(`div`,{className:`mt-3 space-y-2`,children:f.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=o(U),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n.systemSettings,i=r.desktopApp,s=typeof window<`u`?window.electronAPI?.system:void 0;if(!h()||!s){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 c;e[18]===i.title?c=e[19]:(c=(0,N.jsx)(E,{title:i.title}),e[18]=i.title,e[19]=c);let l;e[20]===i.migrations?l=e[21]:(l=(0,N.jsx)(V,{messages:i.migrations}),e[20]=i.migrations,e[21]=l);let u;e[22]===i?u=e[23]:(u=(0,N.jsx)(R,{api:s,messages:i,embedded:!1}),e[22]=i,e[23]=u);let d;return e[24]!==c||e[25]!==l||e[26]!==u?(d=(0,N.jsxs)(D,{gap:`gap-6`,children:[c,l,u]}),e[24]=c,e[25]=l,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"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{n as s}from"./fetch-BMjlW0g1.js";import{t as c}from"./url-DFGNSBNT.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{Do as u,Dt as d,Fc as f,Ga as p,Ha as m,Ja as h,Ka as g,Ns as _,Ua as v,Va as y,Wa as b,_a as x,_o as S,oo as C,so as w,xo as T}from"./index-CxR00gsL.js";import{n as E,t as D}from"./settings-page-layout-CCjhhWJI.js";import{r as O}from"./settings-loading-skeleton-DOvWEjHg.js";import{r as k,t as A}from"./settings-form-section-DnEPGUgO.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,a]=(0,M.useReducer)(d,L),{info:o,loadError:s,actionError:c,copiedField:l,clearDialogOpen:h,clearConfirmChecked:x,clearConfirmText:E,uninstallDialogOpen:D,removeUserDataOnUninstall:k,busy:j}=r,R=(0,M.useCallback)(async()=>{if(e?.getUninstallInfo){a({type:`patch`,patch:{loadError:null}});try{a({type:`patch`,patch:{info:await e.getUninstallInfo()}})}catch(e){a({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}}},[e]);(0,M.useEffect)(()=>{R()},[R]);let z=async(e,n)=>{if(await S(e)){a({type:`patch`,patch:{actionError:null,copiedField:n}}),window.setTimeout(()=>a({type:`patch`,patch:{copiedField:null}}),2e3);return}a({type:`patch`,patch:{actionError:t.copyFailed}})},B=async()=>{if(e?.clearUserData){a({type:`patch`,patch:{busy:!0,actionError:null}});try{let n=await e.clearUserData();n.ok||a({type:`patch`,patch:{actionError:F(n.error,t.errors)}})}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.errors.generic}})}finally{a({type:`patch`,patch:{busy:!1,clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})}}},V=async()=>{if(e?.uninstallApp){a({type:`patch`,patch:{busy:!0,actionError:null}});try{let n=await e.uninstallApp({removeUserData:k});n.ok||a({type:`patch`,patch:{actionError:F(n.error,t.errors)}})}catch(e){a({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.errors.generic}})}finally{a({type:`patch`,patch:{busy:!1,uninstallDialogOpen:!1}})}}};if(s)return(0,N.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:s});if(!o)return(0,N.jsx)(O,{rows:2});let H=!o.packaged,U=j||o.pendingUpdate||H,W=!H&&o.uninstallMode!==`unsupported`,G=I(o,t),K=x&&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)(_,{className:`size-4 text-accent`,strokeWidth:1.75}),t.title]}):null,c?(0,N.jsx)(`p`,{className:`mb-3 text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:c}):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,o.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:o.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`,T.press),onClick:()=>void z(o.appPath,`app`),children:[(0,N.jsx)(f,{className:`size-3`,"aria-hidden":!0}),l===`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:o.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`,T.press),onClick:()=>void z(o.dataPath,`data`),children:[(0,N.jsx)(f,{className:`size-3`,"aria-hidden":!0}),l===`data`?t.copied:t.copyPath]})]}),(0,N.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[t.dataSize,`: `,P(o.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`,T.press),onClick:()=>{a({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`,T.press),onClick:()=>{a({type:`patch`,patch:{removeUserDataOnUninstall:!1,uninstallDialogOpen:!0}})},children:t.uninstall})]}):null]})]}),(0,N.jsx)(p,{open:h,onOpenChange:e=>{e||a({type:`patch`,patch:{clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})},children:(0,N.jsxs)(b,{children:[(0,N.jsx)(v,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,N.jsxs)(y,{className:i(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,C,`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)(g,{className:`text-base font-semibold text-fg`,children:t.clearDataConfirmTitle}),(0,N.jsx)(m,{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:x,onChange:e=>a({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=>a({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)(u,{type:`button`,variant:`secondary`,disabled:j,onClick:()=>{a({type:`patch`,patch:{clearDialogOpen:!1,clearConfirmChecked:!1,clearConfirmText:``}})},children:t.cancel}),(0,N.jsx)(u,{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)(p,{open:D,onOpenChange:e=>{e||a({type:`patch`,patch:{uninstallDialogOpen:!1}})},children:(0,N.jsxs)(b,{children:[(0,N.jsx)(v,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,w)}),(0,N.jsxs)(y,{className:i(`fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,C,`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)(g,{className:`text-base font-semibold text-fg`,children:t.uninstallConfirmTitle}),(0,N.jsx)(m,{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=>a({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)(u,{type:`button`,variant:`secondary`,disabled:j,onClick:()=>a({type:`patch`,patch:{uninstallDialogOpen:!1}}),children:t.cancel}),(0,N.jsx)(u,{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 s(c(`/api/migrations/status`))).payload}async function B(){await s(c(`/api/migrations/apply`),{method:`POST`,body:`{}`})}function V({messages:e}){let{data:t,error:n,isLoading:r,mutate:i}=l(`settings-migration-status`,z,{refreshInterval:0,revalidateOnFocus:!1}),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(null);async function d(){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)(x,{className:`h-5 w-40 max-w-full`}),(0,N.jsx)(x,{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 f=t?.items??[],p=f.filter(e=>e.status===`conflict`||e.status===`error`),m=f.filter(e=>e.safety===`auto`&&e.status===`planned`),h=p.length>0||f.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:f.length===0?e.upToDate:h?e.manualAttention:e.safeRepairs.replace(`{{count}}`,String(m.length))})]}),m.length>0&&!h?(0,N.jsx)(u,{type:`button`,variant:`primary`,className:`px-3 py-1.5 text-xs`,onClick:()=>void d(),disabled:a,children:a?e.applying:e.apply}):null]}),f.length>0?(0,N.jsx)(`div`,{className:`mt-3 space-y-2`,children:f.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=o(U),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n.systemSettings,i=r.desktopApp,s=typeof window<`u`?window.electronAPI?.system:void 0;if(!h()||!s){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 c;e[18]===i.title?c=e[19]:(c=(0,N.jsx)(E,{title:i.title}),e[18]=i.title,e[19]=c);let l;e[20]===i.migrations?l=e[21]:(l=(0,N.jsx)(V,{messages:i.migrations}),e[20]=i.migrations,e[21]=l);let u;e[22]===i?u=e[23]:(u=(0,N.jsx)(R,{api:s,messages:i,embedded:!1}),e[22]=i,e[23]=u);let d;return e[24]!==c||e[25]!==l||e[26]!==u?(d=(0,N.jsxs)(D,{gap:`gap-6`,children:[c,l,u]}),e[24]=c,e[25]=l,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-YzjnURPJ.js";import{n as i}from"./locale-store-Ba72bFmP.js";import{i as a}from"./theme-store-Bt6vAkSB.js";import{eo as o,it as s,xo as c}from"./index-C4k6QSXw.js";import{n as l,t as u}from"./settings-page-layout-DVt69dJJ.js";import{t as d}from"./settings-advanced-gate-C-qvptlu.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-YzjnURPJ.js";import{n as i}from"./locale-store-Ba72bFmP.js";import{i as a}from"./theme-store-Bt6vAkSB.js";import{eo as o,it as s,xo as c}from"./index-CxR00gsL.js";import{n as l,t as u}from"./settings-page-layout-CCjhhWJI.js";import{t as d}from"./settings-advanced-gate-N9Pc7kmG.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 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s,n as c,t as l}from"./fetch-BMjlW0g1.js";import{t as u}from"./url-DFGNSBNT.js";import{a as d,i as f}from"./vendor-swr-BIWyz7Rc.js";import{$c as p,Ca as m,Cl as h,Do as g,Dt as _,Ga as v,Gs as y,Ha as b,Ka as x,Ns as S,Ol as C,Sa as w,Ss as T,Ua as E,Va as D,Vo as O,Wa as k,_l as A,ba as j,il as M,kc as N,ko as P,os as F,qa as I,qn as L,si as ee,us as R,xa as z,ya as B}from"./index-C4k6QSXw.js";import{t as V}from"./page-tabs-RnYYOIWO.js";var H=e(t(),1),U=n();function W(e){return e===`builtin`||e===`user`?e:`marketplace`}async function G(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 te(e){let t=await l(u(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function K(e){let t=await l(u(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function q(e){let t=await l(u(`/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 G(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function J(e){let t=await l(u(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var Y=r();function X(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var ne={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function re({className:e}){let t=a(o(e=>e.language)).extensionsPage,n=s(e=>!!e.token),r=j(),{mutate:l}=d(),[m,h]=(0,H.useReducer)(_,ne),{q:g,debounced:v,detailPkg:b,rowBusy:x,actionError:C,restartHint:w}=m,T=n?`marketplace-${v}`:null;(0,H.useEffect)(()=>{let e=window.setTimeout(()=>h({type:`patch`,patch:{debounced:g.trim()}}),300);return()=>window.clearTimeout(e)},[g]);let{data:E,isLoading:D,error:k}=f(T,async()=>c(v.length>0?u(`/api/marketplace?q=${encodeURIComponent(v)}`):u(`/api/marketplace`)),{revalidateOnFocus:!1}),A=(0,H.useCallback)(()=>{l(`gateway-extensions-list`),L()},[l]),M=(0,H.useCallback)(async(e,n)=>{h({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await K({name:e,overwrite:n});A(),r.requiresGatewayRestart&&h({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw h({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{h({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,A]),N=(0,H.useCallback)(async e=>{h({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await J(e);A(),n.requiresGatewayRestart&&h({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw h({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{h({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,A]),P=E?.extensions??[];return(0,Y.jsxs)(`div`,{className:i(`flex flex-col gap-4`,e),children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(R,{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,Y.jsx)(`input`,{type:`search`,value:g,onChange:e=>h({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`})]}),k?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:k instanceof Error?k.message:t.marketplaceLoadFailed}):null,C?(0,Y.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null,w?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:w}):null,D&&!E?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-3`,children:P.length===0?(0,Y.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):P.map(e=>{let n=X(r,e.id),a=x===e.id;return(0,Y.jsx)(`li`,{className:`list-none`,children:(0,Y.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>h({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),h({type:`patch`,patch:{detailPkg:e.id}}))},className:i(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl bg-surface-panel p-4 text-left shadow-surface`,`transition-[transform,background-color,box-shadow] duration-150 ease-out`,`hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,Y.jsx)(p,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,Y.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,Y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,Y.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,Y.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Y.jsx)(S,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Y.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,Y.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,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,Y.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&N(e.id).catch(()=>{})},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[a?(0,Y.jsx)(y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(O,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,Y.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{M(e.id,!1).catch(()=>{})},className:i(`inline-flex w-full items-center justify-center rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white`,`shadow-surface transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:pointer-events-none disabled:opacity-50`),children:[a?(0,Y.jsx)(y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),b?(0,Y.jsx)(ie,{packageName:b,copy:t,extensions:r,onClose:()=>h({type:`patch`,patch:{detailPkg:null}}),onInstall:M,onUninstall:N}):null]})}function ie(e){let t=(0,U.c)(61),{packageName:n,copy:r,extensions:a,onClose:o,onInstall:c,onUninstall:l}=e,[u,d]=(0,H.useState)(!1),p=s(ce)?`ext-mp-detail-${n}`:null,m;t[0]===n?m=t[1]:(m=async()=>te(n),t[0]=n,t[1]=m);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},t[2]=g):g=t[2];let{data:_,error:b,isLoading:S}=f(p,m,g),C;t[3]!==a||t[4]!==n?(C=X(a,n),t[3]=a,t[4]=n,t[5]=C):C=t[5];let w=C,T=w===`user`,j;t[6]!==r.marketplaceNoReadme||t[7]!==_?(j=_?.readme?.trim()||(_?.description?.trim()?`### ${_.name}\n\n${_.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=_,t[8]=j):j=t[8];let M=j,N;t[9]===o?N=t[10]:(N=e=>!e&&o(),t[9]=o,t[10]=N);let F;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Y.jsx)(E,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=F):F=t[11];let I;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Y.jsx)(A,{className:`size-5`}),t[12]=I):I=t[12];let L;t[13]!==r.detailBack||t[14]!==o?(L=(0,Y.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:I}),t[13]=r.detailBack,t[14]=o,t[15]=L):L=t[15];let R;t[16]===r.marketplaceDetailTitle?R=t[17]:(R=(0,Y.jsx)(x,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=R);let z;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Y.jsx)(P,{className:`size-5`}),t[18]=z):z=t[18];let B;t[19]!==r.detailClose||t[20]!==o?(B=(0,Y.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:z}),t[19]=r.detailClose,t[20]=o,t[21]=B):B=t[21];let V;t[22]!==B||t[23]!==L||t[24]!==R?(V=(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[L,R,B]}),t[22]=B,t[23]=L,t[24]=R,t[25]=V):V=t[25];let W;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==_||t[32]!==b||t[33]!==S||t[34]!==M?(W=S&&!_?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):b?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):_?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:_.name}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,Y.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:_.id})}),(0,Y.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,Y.jsx)(`dd`,{children:_.author.username})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,Y.jsx)(`dd`,{children:_.latestVersion.version})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,Y.jsx)(`dd`,{children:_.downloads})]})]}),_.readme?.trim()?(0,Y.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,Y.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,Y.jsx)(ee,{content:M})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=_,t[32]=b,t[33]=S,t[34]=M,t[35]=W):W=t[35];let G;t[36]===W?G=t[37]:(G=(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:W}),t[36]=W,t[37]=G);let K;t[38]!==u||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==_||t[47]!==w||t[48]!==o||t[49]!==c||t[50]!==l||t[51]!==n||t[52]!==T?(K=_?(0,Y.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:w===`bundled`?(0,Y.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,Y.jsx)(h,{to:`/extensions?tab=builtin`,onClick:o,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{T&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),c(n,T).catch(oe).finally(()=>d(!1)))},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[u?(0,Y.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,T?r.marketplaceReinstall:r.marketplaceInstall]}),T?(0,Y.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),l(n).then(()=>o()).catch(ae).finally(()=>d(!1)))},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,Y.jsx)(O,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=u,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=_,t[47]=w,t[48]=o,t[49]=c,t[50]=l,t[51]=n,t[52]=T,t[53]=K):K=t[53];let q;t[54]!==V||t[55]!==G||t[56]!==K?(q=(0,Y.jsxs)(k,{children:[F,(0,Y.jsxs)(D,{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:se,children:[V,G,K]})]}),t[54]=V,t[55]=G,t[56]=K,t[57]=q):q=t[57];let J;return t[58]!==q||t[59]!==N?(J=(0,Y.jsx)(v,{defaultOpen:!0,onOpenChange:N,children:q}),t[58]=q,t[59]=N,t[60]=J):J=t[60],J}function ae(){}function oe(){}function se(e){return e.preventDefault()}function ce(e){return!!e.token}function le(){let e=o(e=>e.language),t=a(e),n=I(e=>e.setPageHeader),r=I(e=>e.clearPageHeader),i=j(),s=z(),[c,l]=C(),u=W(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,H.useState)(u),[m,h]=(0,H.useState)(d),[g,_]=(0,H.useState)(null),v=c.toString(),y=(0,H.useRef)(v);if(y.current!==v){y.current=v;let e=W(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,H.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let b=(0,H.useMemo)(()=>i.filter(e=>e.source===`bundled`),[i]),x=(0,H.useMemo)(()=>i.filter(e=>e.source!==`bundled`),[i]),S=f===`builtin`?b:x,w=(0,H.useMemo)(()=>{let t=m.trim().toLowerCase(),n=S;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)},[S,m,e]);if((0,H.useEffect)(()=>{_(e=>{if(!e)return e;let t=i.find(t=>t.id===e.id);return t?Z(e)===Z(t)&&e.active===t.active?e:t:null})},[i]),(0,H.useLayoutEffect)(()=>(n({startExtra:null,main:(0,Y.jsx)(`div`,{className:`min-w-0`,children:(0,Y.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.extensionsPage.title})}),end:null}),()=>r()),[r,t.extensionsPage.title,n]),s&&f!==`marketplace`)return(0,Y.jsx)(me,{});let T=f!==`marketplace`&&S.length>0;return(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:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[(0,Y.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,Y.jsx)(V,{items:[{id:`marketplace`,label:t.extensionsPage.tabMarketplace},{id:`builtin`,label:t.extensionsPage.tabBuiltin,count:b.length},{id:`user`,label:t.extensionsPage.tabUser,count:x.length}],activeTab:f,onChange:p,ariaLabel:t.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`}),T?(0,Y.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,Y.jsx)(R,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Y.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(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]}),f===`marketplace`?(0,Y.jsx)(re,{}):f===`builtin`&&b.length===0?(0,Y.jsx)(ge,{message:t.extensionsPage.emptyBuiltin}):f===`user`&&x.length===0?(0,Y.jsx)(ge,{message:t.extensionsPage.emptyUser}):w.length===0?(0,Y.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,Y.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:w.map(e=>(0,Y.jsx)(fe,{extension:e,copy:t.extensionsPage,showSourceBadge:f===`user`,onOpen:()=>_(e)},e.id))})]}),g?(0,Y.jsx)(pe,{extension:g,copy:t.extensionsPage,onClose:()=>_(null)},g.id):null]})}function Z(e){return e.activationEligible??e.active}function Q(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function ue(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function de(e,t){let n=Z(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function fe(e){let t=(0,U.c)(45),{extension:n,copy:r,showSourceBadge:a,onOpen:o}=e,s;t[0]===n?s=t[1]:(s=Z(n),t[0]=n,t[1]=s);let c=s,l=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`group flex w-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=u):u=t[2];let d=n.name||n.id,f;t[3]===d?f=t[4]:(f=d.charAt(0).toUpperCase(),t[3]=d,t[4]=f);let p;t[5]===f?p=t[6]:(p=(0,Y.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:f}),t[5]=f,t[6]=p);let m;t[7]===n.name?m=t[8]:(m=(0,Y.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=m);let h;t[9]===n.version?h=t[10]:(h=n.version?(0,Y.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=h);let g;t[11]!==m||t[12]!==h?(g=(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==r.statusEnabled||t[15]!==c?(_=c?(0,Y.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,Y.jsx)(M,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,Y.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,Y.jsx)(T,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=c,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;t[20]!==r.cardNoDescription||t[21]!==n.description?(y=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=y):y=t[22];let b;t[23]===y?b=t[24]:(b=(0,Y.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:y}),t[23]=y,t[24]=b);let x=n.hasUi?r.badgeKindUi:r.badgeKindBackend,S;t[25]!==x||t[26]!==l?(S=(0,Y.jsx)(`span`,{title:l,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:x}),t[25]=x,t[26]=l,t[27]=S):S=t[27];let C;t[28]!==r||t[29]!==n||t[30]!==a?(C=n.source===`bundled`?(0,Y.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):a?(0,Y.jsx)(`span`,{title:Q(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:ue(n,r)}):null,t[28]=r,t[29]=n,t[30]=a,t[31]=C):C=t[31];let w;t[32]!==S||t[33]!==C?(w=(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[S,C]}),t[32]=S,t[33]=C,t[34]=w):w=t[34];let E;t[35]!==v||t[36]!==b||t[37]!==w?(E=(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,b,w]}),t[35]=v,t[36]=b,t[37]=w,t[38]=E):E=t[38];let D;t[39]!==E||t[40]!==p?(D=(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[p,E]}),t[39]=E,t[40]=p,t[41]=D):D=t[41];let O;return t[42]!==o||t[43]!==D?(O=(0,Y.jsx)(`button`,{type:`button`,onClick:o,className:u,children:D}),t[42]=o,t[43]=D,t[44]=O):O=t[44],O}function pe({extension:e,copy:t,onClose:n}){let{mutate:r}=d(),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),f=e.activationEligible===!0,p=(0,H.useCallback)(async()=>{if(e.source===`bundled`){c(null),u(!1),o(!0);try{let{requiresGatewayRestart:t}=await q({extensionId:e.id,enabled:!f});await r(`gateway-extensions-list`),L(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{o(!1)}}},[f,t.builtinToggleFailed,e.id,e.source,r]),_=e.ui?.contributions?.pages??[],S=e.ui?.contributions?.settingsPanels??[],C=e.ui?.contributions?.chatWidgets??[],T=e.ui?.contributions?.sidebarPanels??[],O=_.find(e=>e.showInNav)??_[0],j=S[0],M=O?B(e.id,O):null,I=j?`/settings/ext/${e.id}/${j.id}`:e.hasConfigSchema||w(e)?`/settings/ext/${e.id}`:null;return(0,Y.jsx)(v,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,Y.jsxs)(D,{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,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,Y.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,Y.jsx)(A,{className:`size-5`})}),(0,Y.jsx)(x,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,Y.jsxs)(b,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,Y.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,Y.jsx)(P,{className:`size-5`})})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,Y.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,Q(e,t)]}),e.version?(0,Y.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,Y.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:de(e,t)}),e.source===`bundled`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,Y.jsx)(g,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void p(),className:`shrink-0 py-1.5 text-xs`,children:a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(y,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):f?t.builtinToggleDisable:t.builtinToggleEnable})]}),s?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:s}):null,l?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(_.length>0||S.length>0||C.length>0)?(0,Y.jsxs)(`section`,{className:`mt-8`,children:[(0,Y.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,Y.jsx)($,{template:t.badgePages,count:_.length,hidden:_.length===0}),(0,Y.jsx)($,{template:t.badgeSettings,count:S.length,hidden:S.length===0}),(0,Y.jsx)($,{template:t.badgeWidgets,count:C.length,hidden:C.length===0}),(0,Y.jsx)($,{template:t.badgeSidebar,count:T.length,hidden:T.length===0})]})]}):null,m(e)&&(M||I)?(0,Y.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[M?(0,Y.jsxs)(h,{to:M,onClick:n,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,Y.jsx)(N,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,I?(0,Y.jsxs)(h,{to:I,onClick:n,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,Y.jsx)(F,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,Y.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function $(e){let t=(0,U.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,Y.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function me(){let e=(0,U.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Y.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,Y.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,Y.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,Y.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Y.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,Y.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(he)})]})}),e[4]=a):a=e[4],a}function he(e){return(0,Y.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge-subtle bg-surface-base shadow-surface`},e)}function ge(e){let t=(0,U.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Y.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,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{le as ExtensionsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{a as s,n as c,t as l}from"./fetch-BMjlW0g1.js";import{t as u}from"./url-DFGNSBNT.js";import{a as d,i as f}from"./vendor-swr-BIWyz7Rc.js";import{$c as p,Ca as m,Cl as h,Do as g,Dt as _,Ga as v,Gs as y,Ha as b,Ka as x,Ns as S,Ol as C,Sa as w,Ss as T,Ua as E,Va as D,Vo as O,Wa as k,_l as A,ba as j,il as M,kc as N,ko as P,os as F,qa as I,qn as L,si as ee,us as R,xa as z,ya as B}from"./index-CxR00gsL.js";import{t as V}from"./page-tabs-xL5C9yyM.js";var H=e(t(),1),U=n();function W(e){return e===`builtin`||e===`user`?e:`marketplace`}async function G(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 te(e){let t=await l(u(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function K(e){let t=await l(u(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function q(e){let t=await l(u(`/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 G(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function J(e){let t=await l(u(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await G(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var Y=r();function X(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var ne={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function re({className:e}){let t=a(o(e=>e.language)).extensionsPage,n=s(e=>!!e.token),r=j(),{mutate:l}=d(),[m,h]=(0,H.useReducer)(_,ne),{q:g,debounced:v,detailPkg:b,rowBusy:x,actionError:C,restartHint:w}=m,T=n?`marketplace-${v}`:null;(0,H.useEffect)(()=>{let e=window.setTimeout(()=>h({type:`patch`,patch:{debounced:g.trim()}}),300);return()=>window.clearTimeout(e)},[g]);let{data:E,isLoading:D,error:k}=f(T,async()=>c(v.length>0?u(`/api/marketplace?q=${encodeURIComponent(v)}`):u(`/api/marketplace`)),{revalidateOnFocus:!1}),A=(0,H.useCallback)(()=>{l(`gateway-extensions-list`),L()},[l]),M=(0,H.useCallback)(async(e,n)=>{h({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await K({name:e,overwrite:n});A(),r.requiresGatewayRestart&&h({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw h({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{h({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,A]),N=(0,H.useCallback)(async e=>{h({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await J(e);A(),n.requiresGatewayRestart&&h({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw h({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{h({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,A]),P=E?.extensions??[];return(0,Y.jsxs)(`div`,{className:i(`flex flex-col gap-4`,e),children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(R,{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,Y.jsx)(`input`,{type:`search`,value:g,onChange:e=>h({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`})]}),k?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:k instanceof Error?k.message:t.marketplaceLoadFailed}):null,C?(0,Y.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null,w?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:w}):null,D&&!E?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-3`,children:P.length===0?(0,Y.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):P.map(e=>{let n=X(r,e.id),a=x===e.id;return(0,Y.jsx)(`li`,{className:`list-none`,children:(0,Y.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>h({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),h({type:`patch`,patch:{detailPkg:e.id}}))},className:i(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl bg-surface-panel p-4 text-left shadow-surface`,`transition-[transform,background-color,box-shadow] duration-150 ease-out`,`hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,Y.jsx)(p,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,Y.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,Y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,Y.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,Y.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,Y.jsx)(S,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Y.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,Y.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,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,Y.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&N(e.id).catch(()=>{})},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[a?(0,Y.jsx)(y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(O,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,Y.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{M(e.id,!1).catch(()=>{})},className:i(`inline-flex w-full items-center justify-center rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white`,`shadow-surface transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:pointer-events-none disabled:opacity-50`),children:[a?(0,Y.jsx)(y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),b?(0,Y.jsx)(ie,{packageName:b,copy:t,extensions:r,onClose:()=>h({type:`patch`,patch:{detailPkg:null}}),onInstall:M,onUninstall:N}):null]})}function ie(e){let t=(0,U.c)(61),{packageName:n,copy:r,extensions:a,onClose:o,onInstall:c,onUninstall:l}=e,[u,d]=(0,H.useState)(!1),p=s(ce)?`ext-mp-detail-${n}`:null,m;t[0]===n?m=t[1]:(m=async()=>te(n),t[0]=n,t[1]=m);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},t[2]=g):g=t[2];let{data:_,error:b,isLoading:S}=f(p,m,g),C;t[3]!==a||t[4]!==n?(C=X(a,n),t[3]=a,t[4]=n,t[5]=C):C=t[5];let w=C,T=w===`user`,j;t[6]!==r.marketplaceNoReadme||t[7]!==_?(j=_?.readme?.trim()||(_?.description?.trim()?`### ${_.name}\n\n${_.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=_,t[8]=j):j=t[8];let M=j,N;t[9]===o?N=t[10]:(N=e=>!e&&o(),t[9]=o,t[10]=N);let F;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Y.jsx)(E,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=F):F=t[11];let I;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Y.jsx)(A,{className:`size-5`}),t[12]=I):I=t[12];let L;t[13]!==r.detailBack||t[14]!==o?(L=(0,Y.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:I}),t[13]=r.detailBack,t[14]=o,t[15]=L):L=t[15];let R;t[16]===r.marketplaceDetailTitle?R=t[17]:(R=(0,Y.jsx)(x,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=R);let z;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Y.jsx)(P,{className:`size-5`}),t[18]=z):z=t[18];let B;t[19]!==r.detailClose||t[20]!==o?(B=(0,Y.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:z}),t[19]=r.detailClose,t[20]=o,t[21]=B):B=t[21];let V;t[22]!==B||t[23]!==L||t[24]!==R?(V=(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[L,R,B]}),t[22]=B,t[23]=L,t[24]=R,t[25]=V):V=t[25];let W;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==_||t[32]!==b||t[33]!==S||t[34]!==M?(W=S&&!_?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):b?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):_?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:_.name}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,Y.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:_.id})}),(0,Y.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,Y.jsx)(`dd`,{children:_.author.username})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,Y.jsx)(`dd`,{children:_.latestVersion.version})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,Y.jsx)(`dd`,{children:_.downloads})]})]}),_.readme?.trim()?(0,Y.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,Y.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,Y.jsx)(ee,{content:M})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=_,t[32]=b,t[33]=S,t[34]=M,t[35]=W):W=t[35];let G;t[36]===W?G=t[37]:(G=(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:W}),t[36]=W,t[37]=G);let K;t[38]!==u||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==_||t[47]!==w||t[48]!==o||t[49]!==c||t[50]!==l||t[51]!==n||t[52]!==T?(K=_?(0,Y.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:w===`bundled`?(0,Y.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,Y.jsx)(h,{to:`/extensions?tab=builtin`,onClick:o,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{T&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),c(n,T).catch(oe).finally(()=>d(!1)))},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[u?(0,Y.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,T?r.marketplaceReinstall:r.marketplaceInstall]}),T?(0,Y.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),l(n).then(()=>o()).catch(ae).finally(()=>d(!1)))},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,Y.jsx)(O,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=u,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=_,t[47]=w,t[48]=o,t[49]=c,t[50]=l,t[51]=n,t[52]=T,t[53]=K):K=t[53];let q;t[54]!==V||t[55]!==G||t[56]!==K?(q=(0,Y.jsxs)(k,{children:[F,(0,Y.jsxs)(D,{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:se,children:[V,G,K]})]}),t[54]=V,t[55]=G,t[56]=K,t[57]=q):q=t[57];let J;return t[58]!==q||t[59]!==N?(J=(0,Y.jsx)(v,{defaultOpen:!0,onOpenChange:N,children:q}),t[58]=q,t[59]=N,t[60]=J):J=t[60],J}function ae(){}function oe(){}function se(e){return e.preventDefault()}function ce(e){return!!e.token}function le(){let e=o(e=>e.language),t=a(e),n=I(e=>e.setPageHeader),r=I(e=>e.clearPageHeader),i=j(),s=z(),[c,l]=C(),u=W(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,H.useState)(u),[m,h]=(0,H.useState)(d),[g,_]=(0,H.useState)(null),v=c.toString(),y=(0,H.useRef)(v);if(y.current!==v){y.current=v;let e=W(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,H.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let b=(0,H.useMemo)(()=>i.filter(e=>e.source===`bundled`),[i]),x=(0,H.useMemo)(()=>i.filter(e=>e.source!==`bundled`),[i]),S=f===`builtin`?b:x,w=(0,H.useMemo)(()=>{let t=m.trim().toLowerCase(),n=S;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)},[S,m,e]);if((0,H.useEffect)(()=>{_(e=>{if(!e)return e;let t=i.find(t=>t.id===e.id);return t?Z(e)===Z(t)&&e.active===t.active?e:t:null})},[i]),(0,H.useLayoutEffect)(()=>(n({startExtra:null,main:(0,Y.jsx)(`div`,{className:`min-w-0`,children:(0,Y.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.extensionsPage.title})}),end:null}),()=>r()),[r,t.extensionsPage.title,n]),s&&f!==`marketplace`)return(0,Y.jsx)(me,{});let T=f!==`marketplace`&&S.length>0;return(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:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[(0,Y.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,Y.jsx)(V,{items:[{id:`marketplace`,label:t.extensionsPage.tabMarketplace},{id:`builtin`,label:t.extensionsPage.tabBuiltin,count:b.length},{id:`user`,label:t.extensionsPage.tabUser,count:x.length}],activeTab:f,onChange:p,ariaLabel:t.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`}),T?(0,Y.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,Y.jsx)(R,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Y.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(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]}),f===`marketplace`?(0,Y.jsx)(re,{}):f===`builtin`&&b.length===0?(0,Y.jsx)(ge,{message:t.extensionsPage.emptyBuiltin}):f===`user`&&x.length===0?(0,Y.jsx)(ge,{message:t.extensionsPage.emptyUser}):w.length===0?(0,Y.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,Y.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:w.map(e=>(0,Y.jsx)(fe,{extension:e,copy:t.extensionsPage,showSourceBadge:f===`user`,onOpen:()=>_(e)},e.id))})]}),g?(0,Y.jsx)(pe,{extension:g,copy:t.extensionsPage,onClose:()=>_(null)},g.id):null]})}function Z(e){return e.activationEligible??e.active}function Q(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function ue(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function de(e,t){let n=Z(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function fe(e){let t=(0,U.c)(45),{extension:n,copy:r,showSourceBadge:a,onOpen:o}=e,s;t[0]===n?s=t[1]:(s=Z(n),t[0]=n,t[1]=s);let c=s,l=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`group flex w-full flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=u):u=t[2];let d=n.name||n.id,f;t[3]===d?f=t[4]:(f=d.charAt(0).toUpperCase(),t[3]=d,t[4]=f);let p;t[5]===f?p=t[6]:(p=(0,Y.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:f}),t[5]=f,t[6]=p);let m;t[7]===n.name?m=t[8]:(m=(0,Y.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=m);let h;t[9]===n.version?h=t[10]:(h=n.version?(0,Y.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=h);let g;t[11]!==m||t[12]!==h?(g=(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==r.statusEnabled||t[15]!==c?(_=c?(0,Y.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,Y.jsx)(M,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,Y.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,Y.jsx)(T,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=c,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;t[20]!==r.cardNoDescription||t[21]!==n.description?(y=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=y):y=t[22];let b;t[23]===y?b=t[24]:(b=(0,Y.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:y}),t[23]=y,t[24]=b);let x=n.hasUi?r.badgeKindUi:r.badgeKindBackend,S;t[25]!==x||t[26]!==l?(S=(0,Y.jsx)(`span`,{title:l,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:x}),t[25]=x,t[26]=l,t[27]=S):S=t[27];let C;t[28]!==r||t[29]!==n||t[30]!==a?(C=n.source===`bundled`?(0,Y.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):a?(0,Y.jsx)(`span`,{title:Q(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:ue(n,r)}):null,t[28]=r,t[29]=n,t[30]=a,t[31]=C):C=t[31];let w;t[32]!==S||t[33]!==C?(w=(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[S,C]}),t[32]=S,t[33]=C,t[34]=w):w=t[34];let E;t[35]!==v||t[36]!==b||t[37]!==w?(E=(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,b,w]}),t[35]=v,t[36]=b,t[37]=w,t[38]=E):E=t[38];let D;t[39]!==E||t[40]!==p?(D=(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[p,E]}),t[39]=E,t[40]=p,t[41]=D):D=t[41];let O;return t[42]!==o||t[43]!==D?(O=(0,Y.jsx)(`button`,{type:`button`,onClick:o,className:u,children:D}),t[42]=o,t[43]=D,t[44]=O):O=t[44],O}function pe({extension:e,copy:t,onClose:n}){let{mutate:r}=d(),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),f=e.activationEligible===!0,p=(0,H.useCallback)(async()=>{if(e.source===`bundled`){c(null),u(!1),o(!0);try{let{requiresGatewayRestart:t}=await q({extensionId:e.id,enabled:!f});await r(`gateway-extensions-list`),L(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{o(!1)}}},[f,t.builtinToggleFailed,e.id,e.source,r]),_=e.ui?.contributions?.pages??[],S=e.ui?.contributions?.settingsPanels??[],C=e.ui?.contributions?.chatWidgets??[],T=e.ui?.contributions?.sidebarPanels??[],O=_.find(e=>e.showInNav)??_[0],j=S[0],M=O?B(e.id,O):null,I=j?`/settings/ext/${e.id}/${j.id}`:e.hasConfigSchema||w(e)?`/settings/ext/${e.id}`:null;return(0,Y.jsx)(v,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,Y.jsxs)(D,{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,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,Y.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,Y.jsx)(A,{className:`size-5`})}),(0,Y.jsx)(x,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,Y.jsxs)(b,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,Y.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,Y.jsx)(P,{className:`size-5`})})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,Y.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,Q(e,t)]}),e.version?(0,Y.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,Y.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,Y.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:de(e,t)}),e.source===`bundled`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,Y.jsx)(g,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void p(),className:`shrink-0 py-1.5 text-xs`,children:a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(y,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):f?t.builtinToggleDisable:t.builtinToggleEnable})]}),s?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:s}):null,l?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(_.length>0||S.length>0||C.length>0)?(0,Y.jsxs)(`section`,{className:`mt-8`,children:[(0,Y.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,Y.jsx)($,{template:t.badgePages,count:_.length,hidden:_.length===0}),(0,Y.jsx)($,{template:t.badgeSettings,count:S.length,hidden:S.length===0}),(0,Y.jsx)($,{template:t.badgeWidgets,count:C.length,hidden:C.length===0}),(0,Y.jsx)($,{template:t.badgeSidebar,count:T.length,hidden:T.length===0})]})]}):null,m(e)&&(M||I)?(0,Y.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[M?(0,Y.jsxs)(h,{to:M,onClick:n,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,Y.jsx)(N,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,I?(0,Y.jsxs)(h,{to:I,onClick:n,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,Y.jsx)(F,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,Y.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function $(e){let t=(0,U.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,Y.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function me(){let e=(0,U.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Y.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,Y.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,Y.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,Y.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Y.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,Y.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(he)})]})}),e[4]=a):a=e[4],a}function he(e){return(0,Y.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge-subtle bg-surface-base shadow-surface`},e)}function ge(e){let t=(0,U.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Y.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,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{le 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-YzjnURPJ.js";import{t as a}from"./jszip.min-DT31yWkU.js";import{t as o}from"./preview-open-alternatives-CTRt06Ri.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-YzjnURPJ.js";import{t as a}from"./jszip.min-DT31yWkU.js";import{t as o}from"./preview-open-alternatives-Dlzt9LTH.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{fa as t}from"./index-C4k6QSXw.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{fa as t}from"./index-CxR00gsL.js";async function n(n,r){let i,a=r||`unnamed`,o=`application/octet-stream`,s=0;if(typeof n==`string`){let e=await fetch(n);if(!e.ok)throw Error(`Failed to fetch file`);if(i=await e.arrayBuffer(),s=i.byteLength,o=e.headers.get(`content-type`)||o,!r){let e=n.split(`/`);a=e[e.length-1]||`document`}}else if(n instanceof File)i=await n.arrayBuffer(),s=n.size,o=n.type||o,a=r||n.name;else if(n instanceof Blob)i=await n.arrayBuffer(),s=n.size,o=n.type||o;else if(n instanceof ArrayBuffer)i=n,s=n.byteLength;else throw Error(`Invalid source type`);let c=new Uint8Array(i),l=``,u=32768;for(let e=0;e<c.length;e+=u){let t=c.slice(e,e+u);l+=String.fromCharCode(...t)}let d=btoa(l),f=`${a}_${Date.now()}_${Math.random()}`;if(o===`application/pdf`||a.toLowerCase().endsWith(`.pdf`)){let{processPdf:t}=await e(async()=>{let{processPdf:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPdf:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n,preview:r}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/pdf`,size:s,content:d,extractedText:n,preview:r}}if(o===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||a.toLowerCase().endsWith(`.docx`)){let{processDocx:t}=await e(async()=>{let{processDocx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processDocx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,size:s,content:d,extractedText:n}}if(o===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||a.toLowerCase().endsWith(`.pptx`)){let{processPptx:t}=await e(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,size:s,content:d,extractedText:n}}if([`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`].includes(o)||a.toLowerCase().endsWith(`.xlsx`)||a.toLowerCase().endsWith(`.xls`)){let{processExcel:t}=await e(async()=>{let{processExcel:e}=await import(`./attachment-process-heavy-RnGYy9bC.js`);return{processExcel:e}},__vite__mapDeps([0,1,2,3])),{extractedText:n}=await t(i,a);return{id:f,type:`document`,name:a,mimeType:o&&o.startsWith(`application/vnd`)?o:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,size:s,content:d,extractedText:n}}if(o?.startsWith(`image/`))return{id:f,type:`image`,name:a,mimeType:o,size:s,content:d,preview:d};if(o?.startsWith(`audio/`))return{id:f,type:`voice`,name:a,mimeType:o,size:s,content:d};if(t(a,o??``)){let e=new TextDecoder().decode(i);return{id:f,type:`document`,name:a,mimeType:o?.startsWith(`text/`)?o:`text/plain`,size:s,content:d,extractedText:e}}throw Error(`Unsupported file type: ${o}`)}export{n as loadAttachment};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{t as r}from"./messages-YzjnURPJ.js";import{n as i}from"./locale-store-Ba72bFmP.js";import{i as a}from"./vendor-swr-BIWyz7Rc.js";import{$s as o,Do as s,El as c,Qc as l,_ as u,es as d,g as f,v as p,y as m}from"./index-C4k6QSXw.js";var h=e(),g=t();function _(e){let t=(0,h.c)(45),{title:m,description:_,prompt:x,coverage:S,className:C,variant:w}=e,T=w===void 0?`card`:w,E=i(b),D=r(E).automations.suggestions,O=r(E).automations,k=c(),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=A):A=t[0];let{data:j}=a(S?`automation-suggestion-coverage`:null,y,A),M=S?j?.automations.find(e=>p(e,S)):void 0,N=M?f(M,O):[];if(T===`titleAction`){if(M){let e;t[1]===C?e=t[2]:(e=n(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,C),t[1]=C,t[2]=e);let r;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,g.jsx)(l,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=r):r=t[3];let i;return t[4]===k?i=t[5]:(i=()=>k(`/automations`),t[4]=k,t[5]=i),(0,g.jsxs)(`section`,{className:e,children:[r,(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:D.coveredTitle}),(0,g.jsx)(s,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:i,children:D.manage})]})}let e;t[6]===C?e=t[7]:(e=n(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,C),t[6]=C,t[7]=e);let r;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,g.jsx)(o,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=r):r=t[8];let i;t[9]!==_||t[10]!==m?(i=(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:_,children:m}),t[9]=_,t[10]=m,t[11]=i):i=t[11];let a;t[12]!==k||t[13]!==x?(a=()=>{k(`/automations?${new URLSearchParams({draft:x,autogenerate:`1`}).toString()}`)},t[12]=k,t[13]=x,t[14]=a):a=t[14];let c;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,g.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),t[15]=c):c=t[15],(0,g.jsxs)(`section`,{className:e,children:[r,i,(0,g.jsxs)(s,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:a,children:[c,D.create]})]})}if(M){let e;t[16]===C?e=t[17]:(e=n(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,C),t[16]=C,t[17]=e);let r;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,g.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=r):r=t[18];let i;t[19]===k?i=t[20]:(i=()=>k(`/automations`),t[19]=k,t[20]=i);let a;return t[21]!==D||t[22]!==i?(a=(0,g.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,g.jsx)(s,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:i,children:D.manage})}),t[21]=D,t[22]=i,t[23]=a):a=t[23],(0,g.jsxs)(`section`,{className:e,children:[(0,g.jsxs)(`div`,{className:`flex items-start gap-2`,children:[r,(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:D.coveredTitle}),(0,g.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:u(D.coveredDescription,{name:M.name})})]})]}),(0,g.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:O.explain.whyCovered}),(0,g.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:N.map(v)})]}),a]})}let P;t[24]===C?P=t[25]:(P=n(`rounded-lg bg-surface-panel p-3 shadow-surface`,C),t[24]=C,t[25]=P);let F;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,g.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=F):F=t[26];let I;t[27]===m?I=t[28]:(I=(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:m}),t[27]=m,t[28]=I);let L;t[29]===_?L=t[30]:(L=(0,g.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:_}),t[29]=_,t[30]=L);let R;t[31]!==I||t[32]!==L?(R=(0,g.jsxs)(`div`,{className:`flex items-start gap-2`,children:[F,(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[I,L]})]}),t[31]=I,t[32]=L,t[33]=R):R=t[33];let z;t[34]!==k||t[35]!==x?(z=()=>{k(`/automations?${new URLSearchParams({draft:x,autogenerate:`1`}).toString()}`)},t[34]=k,t[35]=x,t[36]=z):z=t[36];let B;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,g.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),t[37]=B):B=t[37];let V;t[38]!==D.create||t[39]!==z?(V=(0,g.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,g.jsxs)(s,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:z,children:[B,D.create]})}),t[38]=D.create,t[39]=z,t[40]=V):V=t[40];let H;return t[41]!==V||t[42]!==P||t[43]!==R?(H=(0,g.jsxs)(`section`,{className:P,children:[R,V]}),t[41]=V,t[42]=P,t[43]=R,t[44]=H):H=t[44],H}function v(e){return(0,g.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function y(){return m.list()}function b(e){return e.language}export{_ as t};
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-YzjnURPJ.js";import{n as i}from"./locale-store-Ba72bFmP.js";import{i as a}from"./vendor-swr-BIWyz7Rc.js";import{$s as o,Do as s,El as c,Qc as l,_ as u,es as d,g as f,v as p,y as m}from"./index-CxR00gsL.js";var h=e(),g=t();function _(e){let t=(0,h.c)(45),{title:m,description:_,prompt:x,coverage:S,className:C,variant:w}=e,T=w===void 0?`card`:w,E=i(b),D=r(E).automations.suggestions,O=r(E).automations,k=c(),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1,refreshInterval:15e3},t[0]=A):A=t[0];let{data:j}=a(S?`automation-suggestion-coverage`:null,y,A),M=S?j?.automations.find(e=>p(e,S)):void 0,N=M?f(M,O):[];if(T===`titleAction`){if(M){let e;t[1]===C?e=t[2]:(e=n(`flex min-w-0 items-center gap-2 rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5`,C),t[1]=C,t[2]=e);let r;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,g.jsx)(l,{className:`size-3.5 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[3]=r):r=t[3];let i;return t[4]===k?i=t[5]:(i=()=>k(`/automations`),t[4]=k,t[5]=i),(0,g.jsxs)(`section`,{className:e,children:[r,(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:D.coveredTitle}),(0,g.jsx)(s,{variant:`ghost`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:i,children:D.manage})]})}let e;t[6]===C?e=t[7]:(e=n(`flex min-w-0 items-center gap-2 rounded-lg bg-surface-panel px-2.5 py-1.5 shadow-surface`,C),t[6]=C,t[7]=e);let r;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,g.jsx)(o,{className:`size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),t[8]=r):r=t[8];let i;t[9]!==_||t[10]!==m?(i=(0,g.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,title:_,children:m}),t[9]=_,t[10]=m,t[11]=i):i=t[11];let a;t[12]!==k||t[13]!==x?(a=()=>{k(`/automations?${new URLSearchParams({draft:x,autogenerate:`1`}).toString()}`)},t[12]=k,t[13]=x,t[14]=a):a=t[14];let c;return t[15]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,g.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),t[15]=c):c=t[15],(0,g.jsxs)(`section`,{className:e,children:[r,i,(0,g.jsxs)(s,{variant:`secondary`,className:`h-7 shrink-0 rounded-md px-2 text-xs`,onClick:a,children:[c,D.create]})]})}if(M){let e;t[16]===C?e=t[17]:(e=n(`rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-3`,C),t[16]=C,t[17]=e);let r;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,g.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-emerald-700 dark:text-emerald-300`,"aria-hidden":!0}),t[18]=r):r=t[18];let i;t[19]===k?i=t[20]:(i=()=>k(`/automations`),t[19]=k,t[20]=i);let a;return t[21]!==D||t[22]!==i?(a=(0,g.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,g.jsx)(s,{variant:`ghost`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:i,children:D.manage})}),t[21]=D,t[22]=i,t[23]=a):a=t[23],(0,g.jsxs)(`section`,{className:e,children:[(0,g.jsxs)(`div`,{className:`flex items-start gap-2`,children:[r,(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:D.coveredTitle}),(0,g.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:u(D.coveredDescription,{name:M.name})})]})]}),(0,g.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-base/55 px-2.5 py-2`,children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:O.explain.whyCovered}),(0,g.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:N.map(v)})]}),a]})}let P;t[24]===C?P=t[25]:(P=n(`rounded-lg bg-surface-panel p-3 shadow-surface`,C),t[24]=C,t[25]=P);let F;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,g.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[26]=F):F=t[26];let I;t[27]===m?I=t[28]:(I=(0,g.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:m}),t[27]=m,t[28]=I);let L;t[29]===_?L=t[30]:(L=(0,g.jsx)(`p`,{className:`mt-1 break-words text-xs leading-5 text-fg-muted`,children:_}),t[29]=_,t[30]=L);let R;t[31]!==I||t[32]!==L?(R=(0,g.jsxs)(`div`,{className:`flex items-start gap-2`,children:[F,(0,g.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[I,L]})]}),t[31]=I,t[32]=L,t[33]=R):R=t[33];let z;t[34]!==k||t[35]!==x?(z=()=>{k(`/automations?${new URLSearchParams({draft:x,autogenerate:`1`}).toString()}`)},t[34]=k,t[35]=x,t[36]=z):z=t[36];let B;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,g.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),t[37]=B):B=t[37];let V;t[38]!==D.create||t[39]!==z?(V=(0,g.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,g.jsxs)(s,{variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,onClick:z,children:[B,D.create]})}),t[38]=D.create,t[39]=z,t[40]=V):V=t[40];let H;return t[41]!==V||t[42]!==P||t[43]!==R?(H=(0,g.jsxs)(`section`,{className:P,children:[R,V]}),t[41]=V,t[42]=P,t[43]=R,t[44]=H):H=t[44],H}function v(e){return(0,g.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function y(){return m.list()}function b(e){return e.language}export{_ as t};
@@ -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{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{r as s}from"./toast-z0toXu32.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{As as l,Ba as u,Cl as d,Do as f,Fr as p,Ga as m,Ir as h,Ka as g,Lr as _,Ol as v,Oo as y,Pr as b,Qc as x,Sl as S,Ss as C,Ua as w,Va as T,Vo as E,Wa as D,_a as O,_c as k,es as A,gs as ee,gt as j,io as M,kc as te,ko as ne,no as N,pa as P,qa as re,rl as F,ws as I,y as L,yi as ie,zr as ae}from"./index-C4k6QSXw.js";import{t as R}from"./format-cron-label-arqgGlVV.js";import{i as oe,n as z,r as se,t as ce}from"./workflow-run-setup-panel-Ci9GSPnS.js";var B=n(),V=e(t(),1),H=r(),U={name:``,description:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalMinutes:`60`,cronExpr:`0 9 * * *`,webhookSecretId:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,safetyMode:`suggest_only`,timeoutSeconds:`300`,afterRunMode:`none`,webhookUrl:``,disableAfterFailures:`3`};function W(e){return e===`zh`?`zh-CN`:`en-US`}function le(e,t,n){return e?new Intl.DateTimeFormat(W(n),{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e)):t.never}function G(e,t,n,r){if(e.kind===`manual`)return t.trigger.manual;if(e.kind===`webhook`)return t.trigger.webhook;if(e.kind===`event`)return t.trigger.eventWithType.replace(`{type}`,e.eventType);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,le(Date.parse(i.at),t,r)):i.kind===`interval`?t.trigger.everyMinutes.replace(`{minutes}`,String(Math.round(i.everyMs/6e4))):R(i.expr,W(r),n.scheduleBadge,{timezone:i.tz})}function ue(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 de(e){return e.safety?.mode??`auto_apply`}function K(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 fe(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 q(e){return e.status===`running`||e.status===`queued`}function pe(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function J(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function me(e){return!!J(e)}function Y(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function X(e){return q(e)?0:pe(e)?1:e.status===`succeeded`?2:3}function he(e){return[...e].sort((e,t)=>{let n=X(e)-X(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function ge(e){let t=(0,B.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,V.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,V.useEffect)(a,o),r}function _e(){let e=(0,B.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,H.jsx)(O,{className:`h-4 w-36`}),(0,H.jsx)(O,{className:`h-3 w-56 max-w-full`})]}),(0,H.jsx)(O,{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,H.jsxs)(`section`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:[t,(0,H.jsx)(`div`,{className:`mt-4 grid gap-2`,children:Array.from({length:6}).map(ve)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,H.jsx)(O,{className:`h-4 w-32`}),i=(0,H.jsx)(O,{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,H.jsx)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:(0,H.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[n,(0,H.jsxs)(`section`,{className:`hidden rounded-xl bg-surface-panel p-4 shadow-surface xl:block`,children:[r,i,(0,H.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,H.jsx)(O,{className:`h-12 rounded-lg`}),(0,H.jsx)(O,{className:`h-12 rounded-lg`}),(0,H.jsx)(O,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function ve(e,t){return(0,H.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(O,{className:`size-4 rounded-full`}),(0,H.jsx)(O,{className:`h-4 w-32`}),(0,H.jsx)(O,{className:`h-5 w-20 rounded-full`})]}),(0,H.jsx)(O,{className:`mt-3 h-4 w-full`}),(0,H.jsx)(O,{className:`mt-2 h-4 w-3/5`})]}),(0,H.jsx)(O,{className:`h-8 w-24 rounded-md`})]})},t)}function ye(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;o=e.triggerMode===`manual`?{kind:`manual`}:e.triggerMode===`webhook`?{kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}}:e.triggerMode===`goalBlocked`?{kind:`event`,eventType:`goal.status_changed`,source:`goals`,payloadMatch:{status:`blocked`}}:e.triggerMode===`noteCreated`?{kind:`event`,eventType:`note.created`,source:`notes`}:e.triggerMode===`workflowFailed`?{kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}}:e.triggerMode===`sessionUpdated`?{kind:`event`,eventType:`session.transcript.updated`,source:`sessions`}:e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:Math.max(1,Number.parseInt(e.intervalMinutes,10)||60)*6e4}}:e.triggerMode===`weekly`?{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * ${e.weekday}`}}:e.triggerMode===`cron`?{kind:`schedule`,schedule:{kind:`cron`,expr:e.cronExpr.trim()}}:{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * *`}};let s=z(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.safetyMode===`auto_apply`?e.afterRunMode:`none`,u=e.actionMode===`workflow`?{kind:`workflow`,workflowId:e.workflowId.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},...s===void 0?{}:{input:s},...c?{goal:c}:{},...e.workflowInput.concurrency.trim()?{concurrency:Math.max(1,Number.parseInt(e.workflowInput.concurrency,10)||1)}:{},...e.workflowInput.maxSubagents.trim()?{maxSubagents:Math.max(1,Number.parseInt(e.workflowInput.maxSubagents,10)||1)}:{},timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)};return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},trigger:o,action:u,safety:{mode:e.safetyMode},afterRun:l===`webhook`?{kind:`webhook`,url:e.webhookUrl.trim()}:{kind:l},reliability:{timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function be(){let e=o(e=>e.language),t=a(e),n=t.automations,r=t.cron,l=re(e=>e.setPageHeader),d=re(e=>e.clearPageHeader),[y,x]=v(),S=y.get(`run`)?.trim()??``,E=y.get(`draft`)?.trim()??``,O=y.get(`action`)?.trim()??``,k=y.get(`projectId`)?.trim()??``,A=y.get(`autogenerate`)===`1`,ee=(0,V.useRef)(``),M=ge(`(min-width: 1280px)`),[te,N]=(0,V.useState)(`activity`),[F,I]=(0,V.useState)(!1),[R,oe]=(0,V.useState)(`blank`),[z,ce]=(0,V.useState)(U),[B,W]=(0,V.useState)(null),[G,ue]=(0,V.useState)(null),[de,K]=(0,V.useState)(!1),[fe,q]=(0,V.useState)(null),[J,Y]=(0,V.useState)(``),[X,ve]=(0,V.useState)(null),[be,Ce]=(0,V.useState)(!1),[we,De]=(0,V.useState)(!1),[Oe,ke]=(0,V.useState)(null),[Z,Me]=(0,V.useState)(!1),[Ne,Pe]=(0,V.useState)(!1),[Ie,Le]=(0,V.useState)(!1),[Q,$]=(0,V.useState)(null),Re=c([`automations`,k],()=>L.list(k?{projectId:k}:void 0),{refreshInterval:15e3}),ze=c([`automation-runs`,k],()=>L.runs(50,void 0,k?{projectId:k}:void 0),{refreshInterval:1e4}),Be=c(`automation-metrics`,()=>L.metrics(),{refreshInterval:15e3}),Ve=c(G?`automation-run-events:${G}`:null,()=>L.runEvents(G),{refreshInterval:5e3}),He=c(`automation-workflow-definitions`,j),Ue=c(`automation-chat-agents`,P),We=Re.isLoading&&!Re.data||ze.isLoading&&!ze.data||Be.isLoading&&!Be.data,Ge=Re.data?.automations??[],Ke=(0,V.useMemo)(()=>he(ze.data?.runs??[]),[ze.data?.runs]),qe=(0,V.useMemo)(()=>Ge.filter(e=>!me(e)),[Ge]),Je=(0,V.useMemo)(()=>Ge.filter(me),[Ge]),Ye=(0,V.useMemo)(()=>new Set(Je.map(e=>e.id)),[Je]),Xe=(0,V.useMemo)(()=>Ke.filter(e=>!Ye.has(e.automationId)),[Ke,Ye]),Ze=(0,V.useMemo)(()=>{let e;for(let t of qe){let n=t.state.nextRunAtMs;n&&(e==null||n<e)&&(e=n)}return e},[qe]),Qe=(0,V.useMemo)(()=>Ke.find(e=>e.id===G)??null,[Ke,G]),$e=(0,V.useMemo)(()=>Ge.find(e=>e.id===fe)??null,[Ge,fe]),et=(0,V.useMemo)(()=>Ke.filter(e=>e.automationId===fe),[Ke,fe]),tt=Ve.data?.events??[],nt=(0,V.useMemo)(()=>Xe.filter(pe),[Xe]),rt=Xe[0]??null,it=(0,V.useMemo)(()=>He.data??[],[He.data]),at=Ue.data?.items??[],ot=(0,V.useMemo)(()=>it.find(e=>e.id===z.workflowId.trim())??null,[z.workflowId,it]),st=z.actionMode===`workflow`&&(!z.workflowId.trim()||it.length>0&&!it.some(e=>e.id===z.workflowId)),ct=z.actionMode===`workflow`&&ot?!se(ot,z.workflowInput,z.workflowInputValid).valid:!1,lt=!!z.name.trim()&&(z.actionMode===`workflow`?!st&&!ct:!!z.instruction.trim())&&(z.afterRunMode!==`webhook`||!!z.webhookUrl.trim()),ut=(0,V.useMemo)(()=>[{name:n.templates.dailyAgent.name,description:n.templates.dailyAgent.description,form:{...U,name:n.templates.dailyAgent.name,instruction:n.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:n.templates.morningWorkflow.name,description:n.templates.morningWorkflow.description,form:{...U,name:n.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:it[0]?.id??``}},{name:n.templates.webhookAgent.name,description:n.templates.webhookAgent.description,form:{...U,name:n.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:n.templates.blockedGoal.name,description:n.templates.blockedGoal.description,form:{...U,name:n.templates.blockedGoal.formName,triggerMode:`goalBlocked`,instruction:n.templates.blockedGoal.instruction}},{name:n.templates.noteCreated.name,description:n.templates.noteCreated.description,form:{...U,name:n.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:n.templates.noteCreated.instruction}}],[n,it]),dt=(0,V.useCallback)(async()=>{await Promise.all([Re.mutate(),ze.mutate(),Be.mutate(),Ve.mutate()])},[Re.mutate,Be.mutate,Ve.mutate,ze.mutate]),ft=(0,V.useCallback)(e=>{oe(e),I(!0),e===`blank`&&ce(U)},[]),pt=(0,V.useCallback)(async()=>{Le(!0),W(null);try{await dt()}catch(e){let t=e instanceof Error?e.message:String(e);W(t),s({type:`error`,title:n.feedback.actionFailed,message:t})}finally{Le(!1)}},[n.feedback.actionFailed,dt]);(0,V.useEffect)(()=>{S&&(N(`activity`),ue(S),M||K(!0))},[S,M]),(0,V.useEffect)(()=>{M&&K(!1)},[M]),(0,V.useEffect)(()=>{O===`create`&&(ft(`blank`),x(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[O,ft,x]),(0,V.useEffect)(()=>{if(!E)return;let t=`${e}:${A?`auto`:`seed`}:${E}`;ee.current!==t&&(ee.current=t,Y(E),ve(null),De(!1),oe(`draft`),I(!0),x(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),A&&(W(null),Ce(!0),L.draft({prompt:E,language:e}).then(e=>{ve(e.draft),De(!1)}).catch(e=>{W(e instanceof Error?e.message:String(e))}).finally(()=>{Ce(!1)})))},[A,E,e,x]);let mt=(0,V.useCallback)(e=>{ue(e),M||K(!0),x(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[x,M]);(0,V.useEffect)(()=>{ke(null),Pe(!1)},[G]);async function ht(){if(W(null),lt)try{await L.create({...ye(z,ot),...k?{projectId:k}:{}}),ce(U),I(!1),await dt(),s({type:`success`,title:n.dashboard.created})}catch(e){let t=e instanceof Error?e.message:String(e);W(t),s({type:`error`,title:n.feedback.actionFailed,message:t})}}async function gt(e,t,r){W(null),$(e);try{return await t(),await dt(),r&&s({type:`success`,title:r}),!0}catch(e){let t=e instanceof Error?e.message:String(e);return W(t),s({type:`error`,title:n.feedback.actionFailed,message:t}),!1}finally{$(null)}}async function _t(){let t=J.trim();if(t){W(null),Ce(!0);try{ve((await L.draft({prompt:t,language:e})).draft),De(!1)}catch(e){W(e instanceof Error?e.message:String(e))}finally{Ce(!1)}}}async function vt(){X&&await gt(`draft:publish`,async()=>{await L.create({...X.automation,...k?{projectId:k}:{}}),ve(null),Y(``),De(!1),I(!1)},n.dashboard.created)}async function yt(t){W(null),Me(!0),ke(null),Pe(!1);try{ke((await L.repairDraft(t.id,{language:e})).repair)}catch(e){W(e instanceof Error?e.message:String(e))}finally{Me(!1)}}async function bt(e){Oe&&await gt(`run:${e.id}:repair`,async()=>{await L.update(e.automationId,Oe.patch),ke(null),Pe(!1)},n.feedback.repairApplied)}let xt=(0,V.useMemo)(()=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(ie,{className:`size-9 shrink-0 p-0`,loading:Ie,label:n.refresh,onClick:pt}),(0,H.jsxs)(_,{children:[(0,H.jsx)(ae,{asChild:!0,children:(0,H.jsxs)(f,{variant:`primary`,children:[(0,H.jsx)(C,{className:`size-4`}),n.new]})}),(0,H.jsx)(h,{children:(0,H.jsxs)(b,{align:`end`,className:`z-70 min-w-52 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,H.jsx)(p,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>ft(`draft`),children:n.createMenu.draft}),(0,H.jsx)(p,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>ft(`template`),children:n.createMenu.template}),(0,H.jsx)(p,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>ft(`blank`),children:n.createMenu.blank})]})})]})]}),[n.createMenu.blank,n.createMenu.draft,n.createMenu.template,n.new,n.refresh,ft,Ie,pt]);return(0,V.useLayoutEffect)(()=>(l({startExtra:null,main:(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,H.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:xt}),()=>d()),[d,xt,n.subtitle,n.title,l]),(0,H.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,H.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,H.jsx)(xe,{label:n.dashboard.needsAttention,value:nt.length,tone:nt.length>0?`danger`:`neutral`}),(0,H.jsx)(xe,{label:n.metrics.running,value:Xe.filter(e=>e.status===`running`).length}),(0,H.jsx)(xe,{label:n.dashboard.latestResult,value:rt?n.status[rt.status]:n.none,tone:rt&&pe(rt)?`danger`:`neutral`}),(0,H.jsx)(xe,{label:n.metrics.next,value:Ze?le(Ze,n,e):n.none})]}),(0,H.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:qe.length},{id:`system`,label:n.system.title,count:Je.length}].map(e=>(0,H.jsxs)(`button`,{className:i(`inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium text-fg-muted`,te===e.id&&`bg-surface-hover text-fg`),onClick:()=>{N(e.id),e.id!==`activity`&&K(!1)},children:[(0,H.jsx)(`span`,{children:e.label}),(0,H.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))}),B?(0,H.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:B}):null,We?(0,H.jsx)(_e,{}):te===`activity`?(0,H.jsxs)(`section`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[(0,H.jsx)(`div`,{className:`min-w-0`,children:(0,H.jsx)(Ee,{runs:Xe.slice(0,12),labels:n,cronLabels:r,language:e,selectedRunId:G,busyAction:Q,className:`h-auto`,onSelectRun:mt,onAction:gt})}),(0,H.jsx)(Ae,{className:`hidden xl:block`,run:Qe,events:tt,labels:n,cronLabels:r,language:e,loading:Ve.isLoading,repairDraft:Oe,repairLoading:Z,repairApproved:Ne,busyAction:Q,onRepairApprovedChange:Pe,onSuggestRepair:yt,onApplyRepair:bt})]}):te===`automations`?(0,H.jsx)(`section`,{children:(0,H.jsx)(Te,{automations:qe,runs:Xe,labels:n,cronLabels:r,language:e,busyAction:Q,onOpenDetails:q,onAction:gt})}):(0,H.jsx)(`section`,{children:(0,H.jsx)(Te,{automations:Je,runs:Ke,labels:n,cronLabels:r,language:e,busyAction:Q,readOnly:!0,onOpenDetails:q,onAction:gt})})]}),(0,H.jsx)(m,{open:F,onOpenChange:I,children:(0,H.jsxs)(D,{children:[(0,H.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,H.jsxs)(T,{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,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,H.jsx)(g,{className:`text-base font-semibold text-fg`,children:R===`draft`?n.draft.title:R===`template`?n.createMenu.templatesTitle:n.createTitle}),(0,H.jsx)(u,{asChild:!0,children:(0,H.jsx)(f,{variant:`ghost`,"aria-label":n.close,children:(0,H.jsx)(ne,{className:`size-4`})})})]}),R===`draft`?(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,H.jsx)(Se,{labels:n,prompt:J,draft:X,loading:be,approved:we,publishBusy:Q===`draft:publish`,onPromptChange:Y,onGenerate:_t,onPublish:vt,onApprovedChange:De,onDiscard:()=>{ve(null),De(!1)}})}):R===`template`?(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:ut.map(e=>(0,H.jsxs)(`button`,{className:`rounded-lg bg-surface-base p-4 text-left hover:bg-surface-hover`,onClick:()=>{ce(e.form),oe(`blank`)},children:[(0,H.jsx)(`div`,{className:`font-medium text-fg`,children:e.name}),(0,H.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:e.description})]},e.name))})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Fe,{form:z,labels:n,setForm:ce,workflowDefinitions:it,selectedWorkflow:ot,workflowsLoading:He.isLoading,agentOptions:at,agentsLoading:Ue.isLoading,language:e}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,H.jsx)(u,{asChild:!0,children:(0,H.jsx)(f,{variant:`ghost`,children:n.cancel})}),(0,H.jsx)(f,{variant:`primary`,onClick:ht,disabled:!lt,children:n.create})]})]})]})]})}),(0,H.jsx)(je,{automation:$e,runs:et,labels:n,cronLabels:r,language:e,busyAction:Q,onClose:()=>q(null),onSelectRun:e=>{mt(e),q(null)},onAction:gt}),(0,H.jsx)(m,{open:!M&&de&&!!Qe,onOpenChange:K,children:(0,H.jsxs)(D,{children:[(0,H.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,H.jsxs)(T,{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,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,H.jsx)(g,{className:`truncate text-base font-semibold text-fg`,children:Qe?.automationName??n.dashboard.result}),(0,H.jsx)(u,{asChild:!0,children:(0,H.jsx)(f,{variant:`ghost`,"aria-label":n.close,children:(0,H.jsx)(ne,{className:`size-4`})})})]}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,H.jsx)(Ae,{className:`rounded-none border-0`,run:Qe,events:tt,labels:n,cronLabels:r,language:e,loading:Ve.isLoading,repairDraft:Oe,repairLoading:Z,repairApproved:Ne,busyAction:Q,onRepairApprovedChange:Pe,onSuggestRepair:yt,onApplyRepair:bt})})]})]})})]})}function xe(e){let t=(0,B.c)(13),{label:n,value:r,tone:a}=e,o=a===void 0?`neutral`:a,s=o===`danger`&&`bg-red-500/10`,c;t[0]===s?c=t[1]:(c=i(`rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 shadow-surface`,s),t[0]=s,t[1]=c);let l;t[2]===n?l=t[3]:(l=(0,H.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[2]=n,t[3]=l);let u=o===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,d;t[4]===u?d=t[5]:(d=i(`mt-1 truncate text-lg font-semibold`,u),t[4]=u,t[5]=d);let f;t[6]!==d||t[7]!==r?(f=(0,H.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,H.jsxs)(`div`,{className:c,children:[l,f]}),t[9]=c,t[10]=l,t[11]=f,t[12]=p):p=t[12],p}function Se(e){let t=(0,B.c)(47),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,onPromptChange:c,onGenerate:l,onPublish:u,onApprovedChange:d,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,H.jsx)(A,{className:`size-4 text-accent`}),t[0]=g):g=t[0];let _;t[1]===n.draft.title?_=t[2]:(_=(0,H.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,H.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,H.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,H.jsx)(A,{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,H.jsxs)(f,{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,H.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,H.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.publish||t[31]!==n.draft.review||t[32]!==n.draft.risks||t[33]!==n.draft.safety||t[34]!==n.feedback||t[35]!==n.info||t[36]!==n.none||t[37]!==d||t[38]!==p||t[39]!==u||t[40]!==m||t[41]!==h?(D=i?(0,H.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,H.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,H.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,H.jsx)(Ne,{label:n.info.when,value:i.simulation.triggerSummary}),(0,H.jsx)(Ne,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,H.jsx)(Ce,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,H.jsx)(Ce,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,H.jsx)(Ce,{title:n.draft.risks,items:i.risks,empty:n.none}),h?(0,H.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,H.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:o,onChange:e=>d(e.target.checked)}),(0,H.jsx)(`span`,{children:n.draft.approval})]}):null,(0,H.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,H.jsx)(f,{variant:`ghost`,onClick:p,children:n.draft.discard}),(0,H.jsx)(f,{variant:`primary`,onClick:u,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.publish,t[31]=n.draft.review,t[32]=n.draft.risks,t[33]=n.draft.safety,t[34]=n.feedback,t[35]=n.info,t[36]=n.none,t[37]=d,t[38]=p,t[39]=u,t[40]=m,t[41]=h,t[42]=D):D=t[42];let O;return t[43]!==w||t[44]!==E||t[45]!==D?(O=(0,H.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[w,E,D]}),t[43]=w,t[44]=E,t[45]=D,t[46]=O):O=t[46],O}function Ce(e){let t=(0,B.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,H.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(we):(0,H.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,H.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,H.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function we(e){return(0,H.jsxs)(`li`,{children:[`- `,e]},e)}function Te(e){let t=(0,B.c)(24),{automations:n,runs:r,labels:a,cronLabels:o,language:s,busyAction:c,readOnly:u,onOpenDetails:d,onAction:p}=e,m=u===void 0?!1:u;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(y,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===a.empty.automations?n=t[2]:(n=(0,H.jsx)(Pe,{icon:e,title:a.empty.automations}),t[1]=a.empty.automations,t[2]=n),n}let h;if(t[3]!==n||t[4]!==c||t[5]!==o||t[6]!==a||t[7]!==s||t[8]!==p||t[9]!==d||t[10]!==m||t[11]!==r){let e;t[13]!==c||t[14]!==o||t[15]!==a||t[16]!==s||t[17]!==p||t[18]!==d||t[19]!==m||t[20]!==r?(e=e=>{let t=Y(e),n=r.filter(t=>t.automationId===e.id),u=n.find(q),h=n[0],g=c===`automation:${e.id}:run`,_=c===`automation:${e.id}:toggle`,v=c===`automation:${e.id}:delete`;return(0,H.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:()=>d(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&d(e.id)},children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),u?(0,H.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-blue-500`}):null]}),t?(0,H.jsx)(`div`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:t}):null]}),(0,H.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs`,e.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:e.enabled?a.enabled:a.paused})]}),(0,H.jsxs)(`div`,{className:`mt-3 space-y-2 text-sm`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase text-fg-muted`,children:a.info.when}),(0,H.jsx)(`span`,{className:`truncate`,children:G(e.trigger,a,o,s)})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg-muted`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase`,children:a.info.run}),(0,H.jsx)(`span`,{className:`truncate`,children:ue(e.action,a)})]})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,H.jsxs)(`span`,{children:[a.last,`: `,le(e.state.lastRunAtMs,a,s)]}),(0,H.jsxs)(`span`,{children:[a.next,`: `,le(e.state.nextRunAtMs,a,s)]}),(0,H.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5`,K(e.state.lastRunStatus)),children:e.state.lastRunStatus?a.status[e.state.lastRunStatus]:a.status.notRun}),h?.error?(0,H.jsx)(`p`,{className:`basis-full line-clamp-1 text-red-700 dark:text-red-300`,children:h.error}):null]}),m?null:(0,H.jsx)(`div`,{className:`mt-auto flex justify-end pt-3`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(f,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":a.dashboard.runNow,disabled:c!==null,onClick:t=>{t.stopPropagation(),p(`automation:${e.id}:run`,()=>L.runNow(e.id),a.feedback.rerunQueued)},children:(0,H.jsx)(I,{className:i(`size-4`,g&&`animate-pulse`)})}),(0,H.jsx)(f,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":e.enabled?a.dashboard.pause:a.dashboard.resume,disabled:c!==null,onClick:t=>{t.stopPropagation(),p(`automation:${e.id}:toggle`,()=>e.enabled?L.pause(e.id):L.resume(e.id),e.enabled?a.feedback.paused:a.dashboard.resumed)},children:_?(0,H.jsx)(ee,{className:`size-4 animate-spin`}):e.enabled?(0,H.jsx)(l,{className:`size-4`}):(0,H.jsx)(I,{className:`size-4`})}),(0,H.jsx)(f,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":a.dashboard.delete,disabled:c!==null,onClick:t=>{t.stopPropagation(),p(`automation:${e.id}:delete`,()=>L.remove(e.id),a.dashboard.deleted)},children:v?(0,H.jsx)(ee,{className:`size-4 animate-spin`}):(0,H.jsx)(E,{className:`size-4`})})]})})]},e.id)},t[13]=c,t[14]=o,t[15]=a,t[16]=s,t[17]=p,t[18]=d,t[19]=m,t[20]=r,t[21]=e):e=t[21],h=n.map(e),t[3]=n,t[4]=c,t[5]=o,t[6]=a,t[7]=s,t[8]=p,t[9]=d,t[10]=m,t[11]=r,t[12]=h}else h=t[12];let g;return t[22]===h?g=t[23]:(g=(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:h}),t[22]=h,t[23]=g),g}function Ee(e){let t=(0,B.c)(25),{runs:n,labels:r,cronLabels:a,language:o,selectedRunId:s,busyAction:c,className:l,onSelectRun:u,onAction:d}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(S,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===r.empty.runs?n=t[2]:(n=(0,H.jsx)(Pe,{icon:e,title:r.empty.runs}),t[1]=r.empty.runs,t[2]=n),n}let p;t[3]===l?p=t[4]:(p=i(`overflow-hidden rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,l),t[3]=l,t[4]=p);let m;if(t[5]!==c||t[6]!==a||t[7]!==r||t[8]!==o||t[9]!==d||t[10]!==u||t[11]!==n||t[12]!==s){let e;t[14]!==c||t[15]!==a||t[16]!==r||t[17]!==o||t[18]!==d||t[19]!==u||t[20]!==s?(e=e=>(0,H.jsxs)(`div`,{className:i(`grid cursor-pointer gap-3 border-b border-edge p-4 outline-none last:border-b-0 hover:bg-surface-hover md:grid-cols-[1fr_auto]`,s===e.id&&`bg-surface-hover`),role:`button`,tabIndex:0,onClick:()=>u(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&u(e.id)},children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:e.automationName}),(0,H.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs`,K(e.status)),children:r.status[e.status]}),e.workflowRunId?(0,H.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[r.workflowPrefix,` `,e.workflowRunId.slice(0,8)]}):null]}),(0,H.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:e.error||e.summary||ue(e.actionSnapshot,r)}),(0,H.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[le(e.createdAtMs,r,o),` · `,e.manual?r.trigger.manual:G(e.triggerSnapshot,r,a,o)]})]}),e.status===`running`||e.status===`queued`?(0,H.jsx)(f,{variant:`ghost`,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`run:${e.id}:cancel`,()=>L.cancelRun(e.id),r.dashboard.cancelled)},children:c===`run:${e.id}:cancel`?r.feedback.working:r.cancel}):null]},e.id),t[14]=c,t[15]=a,t[16]=r,t[17]=o,t[18]=d,t[19]=u,t[20]=s,t[21]=e):e=t[21],m=n.map(e),t[5]=c,t[6]=a,t[7]=r,t[8]=o,t[9]=d,t[10]=u,t[11]=n,t[12]=s,t[13]=m}else m=t[13];let h;return t[22]!==p||t[23]!==m?(h=(0,H.jsx)(`div`,{className:p,children:m}),t[22]=p,t[23]=m,t[24]=h):h=t[24],h}function De(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 Oe(e){let t=(0,B.c)(17),{value:n,labels:r,title:a,defaultExpanded:o}=e,[s,c]=(0,V.useState)(o===void 0?!1:o),l;t[0]===n?l=t[1]:(l=JSON.stringify(n,null,2),t[0]=n,t[1]=l);let u=l,d;t[2]===u?d=t[3]:(d=u.split(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-YzjnURPJ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{r as s}from"./toast-z0toXu32.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{As as l,Ba as u,Cl as d,Do as f,Fr as p,Ga as m,Ir as h,Ka as g,Lr as _,Ol as v,Oo as y,Pr as b,Qc as x,Sl as S,Ss as C,Ua as w,Va as T,Vo as E,Wa as D,_a as O,_c as k,es as A,gs as ee,gt as j,io as M,kc as te,ko as ne,no as N,pa as P,qa as re,rl as F,ws as I,y as L,yi as ie,zr as ae}from"./index-CxR00gsL.js";import{t as R}from"./format-cron-label-arqgGlVV.js";import{i as oe,n as z,r as se,t as ce}from"./workflow-run-setup-panel-BiygC8WQ.js";var B=n(),V=e(t(),1),H=r(),U={name:``,description:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalMinutes:`60`,cronExpr:`0 9 * * *`,webhookSecretId:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,safetyMode:`suggest_only`,timeoutSeconds:`300`,afterRunMode:`none`,webhookUrl:``,disableAfterFailures:`3`};function W(e){return e===`zh`?`zh-CN`:`en-US`}function le(e,t,n){return e?new Intl.DateTimeFormat(W(n),{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e)):t.never}function G(e,t,n,r){if(e.kind===`manual`)return t.trigger.manual;if(e.kind===`webhook`)return t.trigger.webhook;if(e.kind===`event`)return t.trigger.eventWithType.replace(`{type}`,e.eventType);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,le(Date.parse(i.at),t,r)):i.kind===`interval`?t.trigger.everyMinutes.replace(`{minutes}`,String(Math.round(i.everyMs/6e4))):R(i.expr,W(r),n.scheduleBadge,{timezone:i.tz})}function ue(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 de(e){return e.safety?.mode??`auto_apply`}function K(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 fe(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 q(e){return e.status===`running`||e.status===`queued`}function pe(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function J(e){return(e.description?.match(/\[managed-by=([^\]]+)\]/))?.[1]?.trim()||null}function me(e){return!!J(e)}function Y(e){return e.description?.replace(/\s*\[managed-by=[^\]]+\]\s*/g,` `).trim()??``}function X(e){return q(e)?0:pe(e)?1:e.status===`succeeded`?2:3}function he(e){return[...e].sort((e,t)=>{let n=X(e)-X(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function ge(e){let t=(0,B.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,V.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,V.useEffect)(a,o),r}function _e(){let e=(0,B.c)(5),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,H.jsx)(O,{className:`h-4 w-36`}),(0,H.jsx)(O,{className:`h-3 w-56 max-w-full`})]}),(0,H.jsx)(O,{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,H.jsxs)(`section`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:[t,(0,H.jsx)(`div`,{className:`mt-4 grid gap-2`,children:Array.from({length:6}).map(ve)})]}),e[1]=n):n=e[1];let r,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,H.jsx)(O,{className:`h-4 w-32`}),i=(0,H.jsx)(O,{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,H.jsx)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:(0,H.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[n,(0,H.jsxs)(`section`,{className:`hidden rounded-xl bg-surface-panel p-4 shadow-surface xl:block`,children:[r,i,(0,H.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,H.jsx)(O,{className:`h-12 rounded-lg`}),(0,H.jsx)(O,{className:`h-12 rounded-lg`}),(0,H.jsx)(O,{className:`h-12 rounded-lg`})]})]})]})}),e[4]=a):a=e[4],a}function ve(e,t){return(0,H.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(O,{className:`size-4 rounded-full`}),(0,H.jsx)(O,{className:`h-4 w-32`}),(0,H.jsx)(O,{className:`h-5 w-20 rounded-full`})]}),(0,H.jsx)(O,{className:`mt-3 h-4 w-full`}),(0,H.jsx)(O,{className:`mt-2 h-4 w-3/5`})]}),(0,H.jsx)(O,{className:`h-8 w-24 rounded-md`})]})},t)}function ye(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;o=e.triggerMode===`manual`?{kind:`manual`}:e.triggerMode===`webhook`?{kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}}:e.triggerMode===`goalBlocked`?{kind:`event`,eventType:`goal.status_changed`,source:`goals`,payloadMatch:{status:`blocked`}}:e.triggerMode===`noteCreated`?{kind:`event`,eventType:`note.created`,source:`notes`}:e.triggerMode===`workflowFailed`?{kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}}:e.triggerMode===`sessionUpdated`?{kind:`event`,eventType:`session.transcript.updated`,source:`sessions`}:e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:Math.max(1,Number.parseInt(e.intervalMinutes,10)||60)*6e4}}:e.triggerMode===`weekly`?{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * ${e.weekday}`}}:e.triggerMode===`cron`?{kind:`schedule`,schedule:{kind:`cron`,expr:e.cronExpr.trim()}}:{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * *`}};let s=z(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.safetyMode===`auto_apply`?e.afterRunMode:`none`,u=e.actionMode===`workflow`?{kind:`workflow`,workflowId:e.workflowId.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},...s===void 0?{}:{input:s},...c?{goal:c}:{},...e.workflowInput.concurrency.trim()?{concurrency:Math.max(1,Number.parseInt(e.workflowInput.concurrency,10)||1)}:{},...e.workflowInput.maxSubagents.trim()?{maxSubagents:Math.max(1,Number.parseInt(e.workflowInput.maxSubagents,10)||1)}:{},timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)};return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},trigger:o,action:u,safety:{mode:e.safetyMode},afterRun:l===`webhook`?{kind:`webhook`,url:e.webhookUrl.trim()}:{kind:l},reliability:{timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function be(){let e=o(e=>e.language),t=a(e),n=t.automations,r=t.cron,l=re(e=>e.setPageHeader),d=re(e=>e.clearPageHeader),[y,x]=v(),S=y.get(`run`)?.trim()??``,E=y.get(`draft`)?.trim()??``,O=y.get(`action`)?.trim()??``,k=y.get(`projectId`)?.trim()??``,A=y.get(`autogenerate`)===`1`,ee=(0,V.useRef)(``),M=ge(`(min-width: 1280px)`),[te,N]=(0,V.useState)(`activity`),[F,I]=(0,V.useState)(!1),[R,oe]=(0,V.useState)(`blank`),[z,ce]=(0,V.useState)(U),[B,W]=(0,V.useState)(null),[G,ue]=(0,V.useState)(null),[de,K]=(0,V.useState)(!1),[fe,q]=(0,V.useState)(null),[J,Y]=(0,V.useState)(``),[X,ve]=(0,V.useState)(null),[be,Ce]=(0,V.useState)(!1),[we,De]=(0,V.useState)(!1),[Oe,ke]=(0,V.useState)(null),[Z,Me]=(0,V.useState)(!1),[Ne,Pe]=(0,V.useState)(!1),[Ie,Le]=(0,V.useState)(!1),[Q,$]=(0,V.useState)(null),Re=c([`automations`,k],()=>L.list(k?{projectId:k}:void 0),{refreshInterval:15e3}),ze=c([`automation-runs`,k],()=>L.runs(50,void 0,k?{projectId:k}:void 0),{refreshInterval:1e4}),Be=c(`automation-metrics`,()=>L.metrics(),{refreshInterval:15e3}),Ve=c(G?`automation-run-events:${G}`:null,()=>L.runEvents(G),{refreshInterval:5e3}),He=c(`automation-workflow-definitions`,j),Ue=c(`automation-chat-agents`,P),We=Re.isLoading&&!Re.data||ze.isLoading&&!ze.data||Be.isLoading&&!Be.data,Ge=Re.data?.automations??[],Ke=(0,V.useMemo)(()=>he(ze.data?.runs??[]),[ze.data?.runs]),qe=(0,V.useMemo)(()=>Ge.filter(e=>!me(e)),[Ge]),Je=(0,V.useMemo)(()=>Ge.filter(me),[Ge]),Ye=(0,V.useMemo)(()=>new Set(Je.map(e=>e.id)),[Je]),Xe=(0,V.useMemo)(()=>Ke.filter(e=>!Ye.has(e.automationId)),[Ke,Ye]),Ze=(0,V.useMemo)(()=>{let e;for(let t of qe){let n=t.state.nextRunAtMs;n&&(e==null||n<e)&&(e=n)}return e},[qe]),Qe=(0,V.useMemo)(()=>Ke.find(e=>e.id===G)??null,[Ke,G]),$e=(0,V.useMemo)(()=>Ge.find(e=>e.id===fe)??null,[Ge,fe]),et=(0,V.useMemo)(()=>Ke.filter(e=>e.automationId===fe),[Ke,fe]),tt=Ve.data?.events??[],nt=(0,V.useMemo)(()=>Xe.filter(pe),[Xe]),rt=Xe[0]??null,it=(0,V.useMemo)(()=>He.data??[],[He.data]),at=Ue.data?.items??[],ot=(0,V.useMemo)(()=>it.find(e=>e.id===z.workflowId.trim())??null,[z.workflowId,it]),st=z.actionMode===`workflow`&&(!z.workflowId.trim()||it.length>0&&!it.some(e=>e.id===z.workflowId)),ct=z.actionMode===`workflow`&&ot?!se(ot,z.workflowInput,z.workflowInputValid).valid:!1,lt=!!z.name.trim()&&(z.actionMode===`workflow`?!st&&!ct:!!z.instruction.trim())&&(z.afterRunMode!==`webhook`||!!z.webhookUrl.trim()),ut=(0,V.useMemo)(()=>[{name:n.templates.dailyAgent.name,description:n.templates.dailyAgent.description,form:{...U,name:n.templates.dailyAgent.name,instruction:n.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:n.templates.morningWorkflow.name,description:n.templates.morningWorkflow.description,form:{...U,name:n.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:it[0]?.id??``}},{name:n.templates.webhookAgent.name,description:n.templates.webhookAgent.description,form:{...U,name:n.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:n.templates.blockedGoal.name,description:n.templates.blockedGoal.description,form:{...U,name:n.templates.blockedGoal.formName,triggerMode:`goalBlocked`,instruction:n.templates.blockedGoal.instruction}},{name:n.templates.noteCreated.name,description:n.templates.noteCreated.description,form:{...U,name:n.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:n.templates.noteCreated.instruction}}],[n,it]),dt=(0,V.useCallback)(async()=>{await Promise.all([Re.mutate(),ze.mutate(),Be.mutate(),Ve.mutate()])},[Re.mutate,Be.mutate,Ve.mutate,ze.mutate]),ft=(0,V.useCallback)(e=>{oe(e),I(!0),e===`blank`&&ce(U)},[]),pt=(0,V.useCallback)(async()=>{Le(!0),W(null);try{await dt()}catch(e){let t=e instanceof Error?e.message:String(e);W(t),s({type:`error`,title:n.feedback.actionFailed,message:t})}finally{Le(!1)}},[n.feedback.actionFailed,dt]);(0,V.useEffect)(()=>{S&&(N(`activity`),ue(S),M||K(!0))},[S,M]),(0,V.useEffect)(()=>{M&&K(!1)},[M]),(0,V.useEffect)(()=>{O===`create`&&(ft(`blank`),x(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[O,ft,x]),(0,V.useEffect)(()=>{if(!E)return;let t=`${e}:${A?`auto`:`seed`}:${E}`;ee.current!==t&&(ee.current=t,Y(E),ve(null),De(!1),oe(`draft`),I(!0),x(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),A&&(W(null),Ce(!0),L.draft({prompt:E,language:e}).then(e=>{ve(e.draft),De(!1)}).catch(e=>{W(e instanceof Error?e.message:String(e))}).finally(()=>{Ce(!1)})))},[A,E,e,x]);let mt=(0,V.useCallback)(e=>{ue(e),M||K(!0),x(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[x,M]);(0,V.useEffect)(()=>{ke(null),Pe(!1)},[G]);async function ht(){if(W(null),lt)try{await L.create({...ye(z,ot),...k?{projectId:k}:{}}),ce(U),I(!1),await dt(),s({type:`success`,title:n.dashboard.created})}catch(e){let t=e instanceof Error?e.message:String(e);W(t),s({type:`error`,title:n.feedback.actionFailed,message:t})}}async function gt(e,t,r){W(null),$(e);try{return await t(),await dt(),r&&s({type:`success`,title:r}),!0}catch(e){let t=e instanceof Error?e.message:String(e);return W(t),s({type:`error`,title:n.feedback.actionFailed,message:t}),!1}finally{$(null)}}async function _t(){let t=J.trim();if(t){W(null),Ce(!0);try{ve((await L.draft({prompt:t,language:e})).draft),De(!1)}catch(e){W(e instanceof Error?e.message:String(e))}finally{Ce(!1)}}}async function vt(){X&&await gt(`draft:publish`,async()=>{await L.create({...X.automation,...k?{projectId:k}:{}}),ve(null),Y(``),De(!1),I(!1)},n.dashboard.created)}async function yt(t){W(null),Me(!0),ke(null),Pe(!1);try{ke((await L.repairDraft(t.id,{language:e})).repair)}catch(e){W(e instanceof Error?e.message:String(e))}finally{Me(!1)}}async function bt(e){Oe&&await gt(`run:${e.id}:repair`,async()=>{await L.update(e.automationId,Oe.patch),ke(null),Pe(!1)},n.feedback.repairApplied)}let xt=(0,V.useMemo)(()=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(ie,{className:`size-9 shrink-0 p-0`,loading:Ie,label:n.refresh,onClick:pt}),(0,H.jsxs)(_,{children:[(0,H.jsx)(ae,{asChild:!0,children:(0,H.jsxs)(f,{variant:`primary`,children:[(0,H.jsx)(C,{className:`size-4`}),n.new]})}),(0,H.jsx)(h,{children:(0,H.jsxs)(b,{align:`end`,className:`z-70 min-w-52 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,H.jsx)(p,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>ft(`draft`),children:n.createMenu.draft}),(0,H.jsx)(p,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>ft(`template`),children:n.createMenu.template}),(0,H.jsx)(p,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>ft(`blank`),children:n.createMenu.blank})]})})]})]}),[n.createMenu.blank,n.createMenu.draft,n.createMenu.template,n.new,n.refresh,ft,Ie,pt]);return(0,V.useLayoutEffect)(()=>(l({startExtra:null,main:(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,H.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:xt}),()=>d()),[d,xt,n.subtitle,n.title,l]),(0,H.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,H.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,H.jsx)(xe,{label:n.dashboard.needsAttention,value:nt.length,tone:nt.length>0?`danger`:`neutral`}),(0,H.jsx)(xe,{label:n.metrics.running,value:Xe.filter(e=>e.status===`running`).length}),(0,H.jsx)(xe,{label:n.dashboard.latestResult,value:rt?n.status[rt.status]:n.none,tone:rt&&pe(rt)?`danger`:`neutral`}),(0,H.jsx)(xe,{label:n.metrics.next,value:Ze?le(Ze,n,e):n.none})]}),(0,H.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:qe.length},{id:`system`,label:n.system.title,count:Je.length}].map(e=>(0,H.jsxs)(`button`,{className:i(`inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium text-fg-muted`,te===e.id&&`bg-surface-hover text-fg`),onClick:()=>{N(e.id),e.id!==`activity`&&K(!1)},children:[(0,H.jsx)(`span`,{children:e.label}),(0,H.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))}),B?(0,H.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:B}):null,We?(0,H.jsx)(_e,{}):te===`activity`?(0,H.jsxs)(`section`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[(0,H.jsx)(`div`,{className:`min-w-0`,children:(0,H.jsx)(Ee,{runs:Xe.slice(0,12),labels:n,cronLabels:r,language:e,selectedRunId:G,busyAction:Q,className:`h-auto`,onSelectRun:mt,onAction:gt})}),(0,H.jsx)(Ae,{className:`hidden xl:block`,run:Qe,events:tt,labels:n,cronLabels:r,language:e,loading:Ve.isLoading,repairDraft:Oe,repairLoading:Z,repairApproved:Ne,busyAction:Q,onRepairApprovedChange:Pe,onSuggestRepair:yt,onApplyRepair:bt})]}):te===`automations`?(0,H.jsx)(`section`,{children:(0,H.jsx)(Te,{automations:qe,runs:Xe,labels:n,cronLabels:r,language:e,busyAction:Q,onOpenDetails:q,onAction:gt})}):(0,H.jsx)(`section`,{children:(0,H.jsx)(Te,{automations:Je,runs:Ke,labels:n,cronLabels:r,language:e,busyAction:Q,readOnly:!0,onOpenDetails:q,onAction:gt})})]}),(0,H.jsx)(m,{open:F,onOpenChange:I,children:(0,H.jsxs)(D,{children:[(0,H.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,H.jsxs)(T,{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,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,H.jsx)(g,{className:`text-base font-semibold text-fg`,children:R===`draft`?n.draft.title:R===`template`?n.createMenu.templatesTitle:n.createTitle}),(0,H.jsx)(u,{asChild:!0,children:(0,H.jsx)(f,{variant:`ghost`,"aria-label":n.close,children:(0,H.jsx)(ne,{className:`size-4`})})})]}),R===`draft`?(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,H.jsx)(Se,{labels:n,prompt:J,draft:X,loading:be,approved:we,publishBusy:Q===`draft:publish`,onPromptChange:Y,onGenerate:_t,onPublish:vt,onApprovedChange:De,onDiscard:()=>{ve(null),De(!1)}})}):R===`template`?(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:ut.map(e=>(0,H.jsxs)(`button`,{className:`rounded-lg bg-surface-base p-4 text-left hover:bg-surface-hover`,onClick:()=>{ce(e.form),oe(`blank`)},children:[(0,H.jsx)(`div`,{className:`font-medium text-fg`,children:e.name}),(0,H.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:e.description})]},e.name))})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Fe,{form:z,labels:n,setForm:ce,workflowDefinitions:it,selectedWorkflow:ot,workflowsLoading:He.isLoading,agentOptions:at,agentsLoading:Ue.isLoading,language:e}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,H.jsx)(u,{asChild:!0,children:(0,H.jsx)(f,{variant:`ghost`,children:n.cancel})}),(0,H.jsx)(f,{variant:`primary`,onClick:ht,disabled:!lt,children:n.create})]})]})]})]})}),(0,H.jsx)(je,{automation:$e,runs:et,labels:n,cronLabels:r,language:e,busyAction:Q,onClose:()=>q(null),onSelectRun:e=>{mt(e),q(null)},onAction:gt}),(0,H.jsx)(m,{open:!M&&de&&!!Qe,onOpenChange:K,children:(0,H.jsxs)(D,{children:[(0,H.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,H.jsxs)(T,{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,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,H.jsx)(g,{className:`truncate text-base font-semibold text-fg`,children:Qe?.automationName??n.dashboard.result}),(0,H.jsx)(u,{asChild:!0,children:(0,H.jsx)(f,{variant:`ghost`,"aria-label":n.close,children:(0,H.jsx)(ne,{className:`size-4`})})})]}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,H.jsx)(Ae,{className:`rounded-none border-0`,run:Qe,events:tt,labels:n,cronLabels:r,language:e,loading:Ve.isLoading,repairDraft:Oe,repairLoading:Z,repairApproved:Ne,busyAction:Q,onRepairApprovedChange:Pe,onSuggestRepair:yt,onApplyRepair:bt})})]})]})})]})}function xe(e){let t=(0,B.c)(13),{label:n,value:r,tone:a}=e,o=a===void 0?`neutral`:a,s=o===`danger`&&`bg-red-500/10`,c;t[0]===s?c=t[1]:(c=i(`rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 shadow-surface`,s),t[0]=s,t[1]=c);let l;t[2]===n?l=t[3]:(l=(0,H.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[2]=n,t[3]=l);let u=o===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,d;t[4]===u?d=t[5]:(d=i(`mt-1 truncate text-lg font-semibold`,u),t[4]=u,t[5]=d);let f;t[6]!==d||t[7]!==r?(f=(0,H.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,H.jsxs)(`div`,{className:c,children:[l,f]}),t[9]=c,t[10]=l,t[11]=f,t[12]=p):p=t[12],p}function Se(e){let t=(0,B.c)(47),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,onPromptChange:c,onGenerate:l,onPublish:u,onApprovedChange:d,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,H.jsx)(A,{className:`size-4 text-accent`}),t[0]=g):g=t[0];let _;t[1]===n.draft.title?_=t[2]:(_=(0,H.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,H.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,H.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,H.jsx)(A,{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,H.jsxs)(f,{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,H.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,H.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.publish||t[31]!==n.draft.review||t[32]!==n.draft.risks||t[33]!==n.draft.safety||t[34]!==n.feedback||t[35]!==n.info||t[36]!==n.none||t[37]!==d||t[38]!==p||t[39]!==u||t[40]!==m||t[41]!==h?(D=i?(0,H.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,H.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,H.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,H.jsx)(Ne,{label:n.info.when,value:i.simulation.triggerSummary}),(0,H.jsx)(Ne,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,H.jsx)(Ce,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,H.jsx)(Ce,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,H.jsx)(Ce,{title:n.draft.risks,items:i.risks,empty:n.none}),h?(0,H.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,H.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:o,onChange:e=>d(e.target.checked)}),(0,H.jsx)(`span`,{children:n.draft.approval})]}):null,(0,H.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,H.jsx)(f,{variant:`ghost`,onClick:p,children:n.draft.discard}),(0,H.jsx)(f,{variant:`primary`,onClick:u,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.publish,t[31]=n.draft.review,t[32]=n.draft.risks,t[33]=n.draft.safety,t[34]=n.feedback,t[35]=n.info,t[36]=n.none,t[37]=d,t[38]=p,t[39]=u,t[40]=m,t[41]=h,t[42]=D):D=t[42];let O;return t[43]!==w||t[44]!==E||t[45]!==D?(O=(0,H.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[w,E,D]}),t[43]=w,t[44]=E,t[45]=D,t[46]=O):O=t[46],O}function Ce(e){let t=(0,B.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,H.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(we):(0,H.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,H.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,H.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function we(e){return(0,H.jsxs)(`li`,{children:[`- `,e]},e)}function Te(e){let t=(0,B.c)(24),{automations:n,runs:r,labels:a,cronLabels:o,language:s,busyAction:c,readOnly:u,onOpenDetails:d,onAction:p}=e,m=u===void 0?!1:u;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(y,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===a.empty.automations?n=t[2]:(n=(0,H.jsx)(Pe,{icon:e,title:a.empty.automations}),t[1]=a.empty.automations,t[2]=n),n}let h;if(t[3]!==n||t[4]!==c||t[5]!==o||t[6]!==a||t[7]!==s||t[8]!==p||t[9]!==d||t[10]!==m||t[11]!==r){let e;t[13]!==c||t[14]!==o||t[15]!==a||t[16]!==s||t[17]!==p||t[18]!==d||t[19]!==m||t[20]!==r?(e=e=>{let t=Y(e),n=r.filter(t=>t.automationId===e.id),u=n.find(q),h=n[0],g=c===`automation:${e.id}:run`,_=c===`automation:${e.id}:toggle`,v=c===`automation:${e.id}:delete`;return(0,H.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:()=>d(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&d(e.id)},children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),u?(0,H.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-blue-500`}):null]}),t?(0,H.jsx)(`div`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:t}):null]}),(0,H.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs`,e.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:e.enabled?a.enabled:a.paused})]}),(0,H.jsxs)(`div`,{className:`mt-3 space-y-2 text-sm`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase text-fg-muted`,children:a.info.when}),(0,H.jsx)(`span`,{className:`truncate`,children:G(e.trigger,a,o,s)})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg-muted`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase`,children:a.info.run}),(0,H.jsx)(`span`,{className:`truncate`,children:ue(e.action,a)})]})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,H.jsxs)(`span`,{children:[a.last,`: `,le(e.state.lastRunAtMs,a,s)]}),(0,H.jsxs)(`span`,{children:[a.next,`: `,le(e.state.nextRunAtMs,a,s)]}),(0,H.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5`,K(e.state.lastRunStatus)),children:e.state.lastRunStatus?a.status[e.state.lastRunStatus]:a.status.notRun}),h?.error?(0,H.jsx)(`p`,{className:`basis-full line-clamp-1 text-red-700 dark:text-red-300`,children:h.error}):null]}),m?null:(0,H.jsx)(`div`,{className:`mt-auto flex justify-end pt-3`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(f,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":a.dashboard.runNow,disabled:c!==null,onClick:t=>{t.stopPropagation(),p(`automation:${e.id}:run`,()=>L.runNow(e.id),a.feedback.rerunQueued)},children:(0,H.jsx)(I,{className:i(`size-4`,g&&`animate-pulse`)})}),(0,H.jsx)(f,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":e.enabled?a.dashboard.pause:a.dashboard.resume,disabled:c!==null,onClick:t=>{t.stopPropagation(),p(`automation:${e.id}:toggle`,()=>e.enabled?L.pause(e.id):L.resume(e.id),e.enabled?a.feedback.paused:a.dashboard.resumed)},children:_?(0,H.jsx)(ee,{className:`size-4 animate-spin`}):e.enabled?(0,H.jsx)(l,{className:`size-4`}):(0,H.jsx)(I,{className:`size-4`})}),(0,H.jsx)(f,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":a.dashboard.delete,disabled:c!==null,onClick:t=>{t.stopPropagation(),p(`automation:${e.id}:delete`,()=>L.remove(e.id),a.dashboard.deleted)},children:v?(0,H.jsx)(ee,{className:`size-4 animate-spin`}):(0,H.jsx)(E,{className:`size-4`})})]})})]},e.id)},t[13]=c,t[14]=o,t[15]=a,t[16]=s,t[17]=p,t[18]=d,t[19]=m,t[20]=r,t[21]=e):e=t[21],h=n.map(e),t[3]=n,t[4]=c,t[5]=o,t[6]=a,t[7]=s,t[8]=p,t[9]=d,t[10]=m,t[11]=r,t[12]=h}else h=t[12];let g;return t[22]===h?g=t[23]:(g=(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:h}),t[22]=h,t[23]=g),g}function Ee(e){let t=(0,B.c)(25),{runs:n,labels:r,cronLabels:a,language:o,selectedRunId:s,busyAction:c,className:l,onSelectRun:u,onAction:d}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(S,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===r.empty.runs?n=t[2]:(n=(0,H.jsx)(Pe,{icon:e,title:r.empty.runs}),t[1]=r.empty.runs,t[2]=n),n}let p;t[3]===l?p=t[4]:(p=i(`overflow-hidden rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,l),t[3]=l,t[4]=p);let m;if(t[5]!==c||t[6]!==a||t[7]!==r||t[8]!==o||t[9]!==d||t[10]!==u||t[11]!==n||t[12]!==s){let e;t[14]!==c||t[15]!==a||t[16]!==r||t[17]!==o||t[18]!==d||t[19]!==u||t[20]!==s?(e=e=>(0,H.jsxs)(`div`,{className:i(`grid cursor-pointer gap-3 border-b border-edge p-4 outline-none last:border-b-0 hover:bg-surface-hover md:grid-cols-[1fr_auto]`,s===e.id&&`bg-surface-hover`),role:`button`,tabIndex:0,onClick:()=>u(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&u(e.id)},children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`font-medium text-fg`,children:e.automationName}),(0,H.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs`,K(e.status)),children:r.status[e.status]}),e.workflowRunId?(0,H.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[r.workflowPrefix,` `,e.workflowRunId.slice(0,8)]}):null]}),(0,H.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:e.error||e.summary||ue(e.actionSnapshot,r)}),(0,H.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[le(e.createdAtMs,r,o),` · `,e.manual?r.trigger.manual:G(e.triggerSnapshot,r,a,o)]})]}),e.status===`running`||e.status===`queued`?(0,H.jsx)(f,{variant:`ghost`,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`run:${e.id}:cancel`,()=>L.cancelRun(e.id),r.dashboard.cancelled)},children:c===`run:${e.id}:cancel`?r.feedback.working:r.cancel}):null]},e.id),t[14]=c,t[15]=a,t[16]=r,t[17]=o,t[18]=d,t[19]=u,t[20]=s,t[21]=e):e=t[21],m=n.map(e),t[5]=c,t[6]=a,t[7]=r,t[8]=o,t[9]=d,t[10]=u,t[11]=n,t[12]=s,t[13]=m}else m=t[13];let h;return t[22]!==p||t[23]!==m?(h=(0,H.jsx)(`div`,{className:p,children:m}),t[22]=p,t[23]=m,t[24]=h):h=t[24],h}function De(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 Oe(e){let t=(0,B.c)(17),{value:n,labels:r,title:a,defaultExpanded:o}=e,[s,c]=(0,V.useState)(o===void 0?!1:o),l;t[0]===n?l=t[1]:(l=JSON.stringify(n,null,2),t[0]=n,t[1]=l);let u=l,d;t[2]===u?d=t[3]:(d=u.split(`
2
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]!==a?(g=p?(0,H.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(ke),"aria-expanded":s,children:[(0,H.jsx)(`span`,{children:a}),(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-fg`,children:[s?r.details.hideDetails:r.details.showDetails,(0,H.jsx)(F,{className:i(`size-3.5 transition-transform`,s&&`rotate-180`),"aria-hidden":!0})]})]}):(0,H.jsx)(`div`,{className:`px-2.5 py-2 text-xs font-medium text-fg-muted`,children:a}),t[7]=s,t[8]=p,t[9]=r,t[10]=a,t[11]=g):g=t[11];let _=s||!p?u:h,v;t[12]===_?v=t[13]:(v=(0,H.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,H.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 ke(e){return!e}function Ae(e){let t=(0,B.c)(125),{className:n,run:r,events:a,labels:o,cronLabels:s,language:c,loading:l,repairDraft:u,repairLoading:p,repairApproved:m,busyAction:h,onRepairApprovedChange:g,onSuggestRepair:_,onApplyRepair:v}=e;if(!r){let e;t[0]===n?e=t[1]:(e=i(`flex min-h-64 flex-col justify-center rounded-lg border border-edge-subtle bg-surface-base px-4 text-center text-sm text-fg-muted shadow-surface`,n),t[0]=n,t[1]=e);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,H.jsx)(S,{className:`mx-auto size-5`}),t[2]=r):r=t[2];let a;t[3]===o.selectRun?a=t[4]:(a=(0,H.jsx)(`div`,{className:`mt-2`,children:o.selectRun}),t[3]=o.selectRun,t[4]=a);let s;return t[5]!==e||t[6]!==a?(s=(0,H.jsxs)(`aside`,{className:e,children:[r,a]}),t[5]=e,t[6]=a,t[7]=s):s=t[7],s}let y;t[8]===n?y=t[9]:(y=i(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=y);let b;t[10]===r.automationName?b=t[11]:(b=(0,H.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=b);let x;t[12]===r.id?x=t[13]:(x=r.id.slice(0,8),t[12]=r.id,t[13]=x);let C;t[14]===x?C=t[15]:(C=(0,H.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:x}),t[14]=x,t[15]=C);let w;t[16]!==b||t[17]!==C?(w=(0,H.jsxs)(`div`,{className:`min-w-0`,children:[b,C]}),t[16]=b,t[17]=C,t[18]=w):w=t[18];let T;t[19]===r.status?T=t[20]:(T=i(`shrink-0 rounded-full px-2 py-0.5 text-xs`,K(r.status)),t[19]=r.status,t[20]=T);let E=o.status[r.status],D;t[21]!==T||t[22]!==E?(D=(0,H.jsx)(`span`,{className:T,children:E}),t[21]=T,t[22]=E,t[23]=D):D=t[23];let O;t[24]!==w||t[25]!==D?(O=(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[w,D]}),t[24]=w,t[25]=D,t[26]=O):O=t[26];let ee=o.details.created,j;t[27]!==o||t[28]!==c||t[29]!==r.createdAtMs?(j=le(r.createdAtMs,o,c),t[27]=o,t[28]=c,t[29]=r.createdAtMs,t[30]=j):j=t[30];let M;t[31]!==o.details.created||t[32]!==j?(M=(0,H.jsx)(Z,{label:ee,value:j}),t[31]=o.details.created,t[32]=j,t[33]=M):M=t[33];let ne=o.details.started,N;t[34]!==o||t[35]!==c||t[36]!==r.startedAtMs?(N=le(r.startedAtMs,o,c),t[34]=o,t[35]=c,t[36]=r.startedAtMs,t[37]=N):N=t[37];let P;t[38]!==o.details.started||t[39]!==N?(P=(0,H.jsx)(Z,{label:ne,value:N}),t[38]=o.details.started,t[39]=N,t[40]=P):P=t[40];let re=o.details.duration,F;t[41]!==o||t[42]!==r.durationMs?(F=fe(r.durationMs,o),t[41]=o,t[42]=r.durationMs,t[43]=F):F=t[43];let I;t[44]!==o.details.duration||t[45]!==F?(I=(0,H.jsx)(Z,{label:re,value:F}),t[44]=o.details.duration,t[45]=F,t[46]=I):I=t[46];let L;t[47]!==o.details.model||t[48]!==r.model?(L=r.model?(0,H.jsx)(Z,{label:o.details.model,value:r.model}):null,t[47]=o.details.model,t[48]=r.model,t[49]=L):L=t[49];let ie;t[50]!==M||t[51]!==P||t[52]!==I||t[53]!==L?(ie=(0,H.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[M,P,I,L]}),t[50]=M,t[51]=P,t[52]=I,t[53]=L,t[54]=ie):ie=t[54];let ae;t[55]===o.dashboard.result?ae=t[56]:(ae=(0,H.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.dashboard.result}),t[55]=o.dashboard.result,t[56]=ae);let R;t[57]===r?R=t[58]:(R=pe(r)?`text-red-700 dark:text-red-300`:`text-fg`,t[57]=r,t[58]=R);let oe;t[59]===R?oe=t[60]:(oe=i(`mt-1 break-words text-sm`,R),t[59]=R,t[60]=oe);let z;t[61]!==o||t[62]!==r.actionSnapshot||t[63]!==r.error||t[64]!==r.summary?(z=r.error||r.summary||ue(r.actionSnapshot,o),t[61]=o,t[62]=r.actionSnapshot,t[63]=r.error,t[64]=r.summary,t[65]=z):z=t[65];let se;t[66]!==oe||t[67]!==z?(se=(0,H.jsx)(`p`,{className:oe,children:z}),t[66]=oe,t[67]=z,t[68]=se):se=t[68];let ce;t[69]!==s||t[70]!==o||t[71]!==c||t[72]!==r.manual||t[73]!==r.triggerSnapshot?(ce=r.manual?o.trigger.manual:G(r.triggerSnapshot,o,s,c),t[69]=s,t[70]=o,t[71]=c,t[72]=r.manual,t[73]=r.triggerSnapshot,t[74]=ce):ce=t[74];let V;t[75]!==o.explain.whyRan||t[76]!==ce?(V=(0,H.jsx)(Z,{label:o.explain.whyRan,value:ce}),t[75]=o.explain.whyRan,t[76]=ce,t[77]=V):V=t[77];let U;t[78]!==o.dashboard.openSession||t[79]!==r.sessionKey?(U=r.sessionKey?(0,H.jsx)(f,{asChild:!0,variant:`secondary`,className:`h-8 justify-start rounded-md px-2 text-xs`,children:(0,H.jsxs)(d,{to:`/chat/${encodeURIComponent(r.sessionKey)}`,children:[(0,H.jsx)(te,{className:`size-3.5`}),o.dashboard.openSession]})}):null,t[78]=o.dashboard.openSession,t[79]=r.sessionKey,t[80]=U):U=t[80];let W;t[81]!==o.feedback||t[82]!==r.workflowRunId?(W=r.workflowRunId?(0,H.jsx)(f,{asChild:!0,variant:`secondary`,className:`h-8 justify-start rounded-md px-2 text-xs`,children:(0,H.jsxs)(d,{to:`/workflows?run=${encodeURIComponent(r.workflowRunId)}`,children:[(0,H.jsx)(k,{className:`size-3.5`}),o.feedback.workflow]})}):null,t[81]=o.feedback,t[82]=r.workflowRunId,t[83]=W):W=t[83];let de;t[84]!==V||t[85]!==U||t[86]!==W?(de=(0,H.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[V,U,W]}),t[84]=V,t[85]=U,t[86]=W,t[87]=de):de=t[87];let q;t[88]!==ae||t[89]!==se||t[90]!==de?(q=(0,H.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge/70 bg-surface-base/50 p-3`,children:[ae,se,de]}),t[88]=ae,t[89]=se,t[90]=de,t[91]=q):q=t[91];let J;t[92]!==o.repair||t[93]!==_||t[94]!==p||t[95]!==r?(J=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,H.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,H.jsxs)(f,{variant:`secondary`,onClick:()=>_(r),disabled:p,children:[(0,H.jsx)(A,{className:`size-4`}),p?o.repair.generating:o.repair.suggest]})}):null,t[92]=o.repair,t[93]=_,t[94]=p,t[95]=r,t[96]=J):J=t[96];let me;t[97]!==ie||t[98]!==q||t[99]!==J||t[100]!==O?(me=(0,H.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[O,ie,q,J]}),t[97]=ie,t[98]=q,t[99]=J,t[100]=O,t[101]=me):me=t[101];let Y;t[102]!==h||t[103]!==o||t[104]!==v||t[105]!==g||t[106]!==m||t[107]!==u||t[108]!==r?(Y=u?(0,H.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[(0,H.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.repair.title}),(0,H.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:u.explanation}),u.expectedEffect?(0,H.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:u.expectedEffect}):null,(0,H.jsx)(Ce,{title:o.repair.risks,items:u.risks,empty:o.none}),(0,H.jsx)(Oe,{value:u.patch,labels:o,title:o.details.repairPatch}),u.requiresApproval?(0,H.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-sm text-fg`,children:[(0,H.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:m,onChange:e=>g(e.target.checked)}),(0,H.jsx)(`span`,{children:o.repair.approval})]}):null,(0,H.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,H.jsx)(f,{variant:`primary`,onClick:()=>v(r),disabled:h===`run:${r.id}:repair`||u.requiresApproval&&!m,children:h===`run:${r.id}:repair`?o.feedback.working:o.repair.apply})})]}):null,t[102]=h,t[103]=o,t[104]=v,t[105]=g,t[106]=m,t[107]=u,t[108]=r,t[109]=Y):Y=t[109];let X;t[110]===o.timeline?X=t[111]:(X=(0,H.jsx)(`div`,{className:`mb-3 text-xs font-semibold uppercase text-fg-muted`,children:o.timeline}),t[110]=o.timeline,t[111]=X);let he;t[112]!==a||t[113]!==o||t[114]!==c||t[115]!==l?(he=l?(0,H.jsx)(`div`,{className:`text-sm text-fg-muted`,children:o.loading}):a.length===0?(0,H.jsx)(`div`,{className:`text-sm text-fg-muted`,children:o.empty.events}):(0,H.jsx)(`ol`,{className:`space-y-3`,children:a.map(e=>(0,H.jsxs)(`li`,{className:`grid grid-cols-[0.75rem_1fr] gap-3`,children:[(0,H.jsx)(`span`,{className:i(`mt-1 size-2 rounded-full`,Me(e.type))}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-sm text-fg`,children:De(e,o)}),(0,H.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[le(e.createdAtMs,o,c),` · `,e.type]}),e.data&&typeof e.data==`object`?(0,H.jsx)(Oe,{value:e.data,labels:o,title:o.details.eventData}):null]})]},e.id))}),t[112]=a,t[113]=o,t[114]=c,t[115]=l,t[116]=he):he=t[116];let ge;t[117]!==X||t[118]!==he?(ge=(0,H.jsxs)(`div`,{className:`px-4 py-3`,children:[X,he]}),t[117]=X,t[118]=he,t[119]=ge):ge=t[119];let _e;return t[120]!==y||t[121]!==me||t[122]!==Y||t[123]!==ge?(_e=(0,H.jsxs)(`aside`,{className:y,children:[me,Y,ge]}),t[120]=y,t[121]=me,t[122]=Y,t[123]=ge,t[124]=_e):_e=t[124],_e}function je(e){let t=(0,B.c)(25),{automation:n,runs:r,labels:a,cronLabels:o,language:s,busyAction:c,onClose:p,onSelectRun:h,onAction:_}=e,v;t[0]===n?v=t[1]:(v=n?de(n):`suggest_only`,t[0]=n,t[1]=v);let y=v,b=n?c===`automation:${n.id}:run`:!1,C=n?c===`automation:${n.id}:toggle`:!1,O=n?c===`automation:${n.id}:delete`:!1,A=!!n,j;t[2]===p?j=t[3]:(j=e=>!e&&p(),t[2]=p,t[3]=j);let M;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,H.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[4]=M):M=t[4];let N;t[5]!==n||t[6]!==c||t[7]!==o||t[8]!==O||t[9]!==a||t[10]!==s||t[11]!==y||t[12]!==_||t[13]!==p||t[14]!==h||t[15]!==b||t[16]!==r||t[17]!==C?(N=n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(g,{className:`truncate text-base font-semibold text-fg`,children:n.name}),n.description?(0,H.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:n.description}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs`,n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:n.enabled?a.enabled:a.paused}),(0,H.jsx)(u,{asChild:!0,children:(0,H.jsx)(f,{variant:`ghost`,"aria-label":a.close,children:(0,H.jsx)(ne,{className:`size-4`})})})]})]}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,H.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[18rem_1fr]`,children:[(0,H.jsxs)(`aside`,{className:`grid h-fit gap-3 rounded-lg bg-surface-base p-4`,children:[(0,H.jsx)(Ne,{label:a.info.when,value:G(n.trigger,a,o,s)}),(0,H.jsx)(Ne,{label:a.info.run,value:ue(n.action,a)}),(0,H.jsx)(Ne,{label:a.info.safety,value:a.safety[y]}),(0,H.jsx)(Z,{label:a.last,value:le(n.state.lastRunAtMs,a,s)}),(0,H.jsx)(Z,{label:a.next,value:le(n.state.nextRunAtMs,a,s)}),n.state.consecutiveFailures?(0,H.jsx)(Z,{label:a.dashboard.failures,value:String(n.state.consecutiveFailures)}):null,n.state.lastError?(0,H.jsx)(`p`,{className:`break-words text-sm text-red-700 dark:text-red-300`,children:n.state.lastError}):null]}),(0,H.jsxs)(`section`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.dashboard.runHistory}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.dashboard.runHistoryDescription})]}),(0,H.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,H.jsx)(Pe,{icon:(0,H.jsx)(S,{className:`size-5`}),title:a.empty.runs}):(0,H.jsx)(`div`,{className:`grid gap-2`,children:r.map(e=>(0,H.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,H.jsxs)(`button`,{className:`min-w-0 text-left outline-none`,onClick:()=>h(e.id),children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.status===`succeeded`?(0,H.jsx)(x,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,H.jsx)(S,{className:`size-4 shrink-0 text-fg-muted`}),(0,H.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:le(e.createdAtMs,a,s)}),(0,H.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs`,K(e.status)),children:a.status[e.status]})]}),(0,H.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.error||e.summary||ue(e.actionSnapshot,a)})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1`,children:[e.sessionKey?(0,H.jsx)(f,{asChild:!0,variant:`ghost`,className:`h-8 rounded-md px-2 text-xs`,children:(0,H.jsxs)(d,{to:`/chat/${encodeURIComponent(e.sessionKey)}`,children:[(0,H.jsx)(te,{className:`size-3.5`}),a.dashboard.openSession]})}):null,e.workflowRunId?(0,H.jsx)(f,{asChild:!0,variant:`ghost`,className:`h-8 rounded-md px-2 text-xs`,children:(0,H.jsxs)(d,{to:`/workflows?run=${encodeURIComponent(e.workflowRunId)}`,children:[(0,H.jsx)(k,{className:`size-3.5`}),a.feedback.workflow]})}):null]})]})},e.id))})]})]})}),(0,H.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-edge px-5 py-4`,children:[(0,H.jsxs)(f,{variant:`ghost`,disabled:c!==null,onClick:()=>void _(`automation:${n.id}:delete`,()=>L.remove(n.id),a.dashboard.deleted).then(e=>{e&&p()}),children:[O?(0,H.jsx)(ee,{className:`size-4 animate-spin`}):(0,H.jsx)(E,{className:`size-4`}),a.dashboard.delete]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(f,{variant:`secondary`,disabled:c!==null,onClick:()=>void _(`automation:${n.id}:toggle`,()=>n.enabled?L.pause(n.id):L.resume(n.id),n.enabled?a.feedback.paused:a.dashboard.resumed),children:[C?(0,H.jsx)(ee,{className:`size-4 animate-spin`}):n.enabled?(0,H.jsx)(l,{className:`size-4`}):(0,H.jsx)(I,{className:`size-4`}),n.enabled?a.dashboard.pause:a.dashboard.resume]}),(0,H.jsxs)(f,{variant:`primary`,disabled:c!==null,onClick:()=>void _(`automation:${n.id}:run`,()=>L.runNow(n.id),a.feedback.rerunQueued),children:[b?(0,H.jsx)(ee,{className:`size-4 animate-spin`}):(0,H.jsx)(I,{className:`size-4`}),a.dashboard.runNow]})]})]})]}):null,t[5]=n,t[6]=c,t[7]=o,t[8]=O,t[9]=a,t[10]=s,t[11]=y,t[12]=_,t[13]=p,t[14]=h,t[15]=b,t[16]=r,t[17]=C,t[18]=N):N=t[18];let P;t[19]===N?P=t[20]:(P=(0,H.jsxs)(D,{children:[M,(0,H.jsx)(T,{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:N})]}),t[19]=N,t[20]=P);let re;return t[21]!==A||t[22]!==j||t[23]!==P?(re=(0,H.jsx)(m,{open:A,onOpenChange:j,children:P}),t[21]=A,t[22]=j,t[23]=P,t[24]=re):re=t[24],re}function Z(e){let t=(0,B.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,H.jsx)(`span`,{children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,H.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,H.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 Me(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function Ne(e){let t=(0,B.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,H.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,H.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,H.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Pe(e){let t=(0,B.c)(5),{icon:n,title:r}=e,i;t[0]===r?i=t[1]:(i=(0,H.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,H.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 Fe(e){let t=(0,B.c)(218),{form:n,labels:r,setForm:a,workflowDefinitions:o,selectedWorkflow:s,workflowsLoading:c,agentOptions:l,agentsLoading:u,language:d}=e,f;t[0]===a?f=t[1]:(f=e=>a(t=>({...t,...e})),t[0]=a,t[1]=f);let p=f,m,h;t[2]!==n.actionMode||t[3]!==n.workflowId||t[4]!==a||t[5]!==o?(m=()=>{if(n.actionMode!==`workflow`||n.workflowId.trim())return;let e=o[0]?.id;e&&a(t=>({...t,workflowId:e,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}))},h=[n.actionMode,n.workflowId,a,o],t[2]=n.actionMode,t[3]=n.workflowId,t[4]=a,t[5]=o,t[6]=m,t[7]=h):(m=t[6],h=t[7]),(0,V.useEffect)(m,h);let g;t[8]===p?g=t[9]:(g=e=>p({name:e.target.value}),t[8]=p,t[9]=g);let _;t[10]!==n.name||t[11]!==g?(_=(0,H.jsx)(`input`,{className:Q,value:n.name,onChange:g}),t[10]=n.name,t[11]=g,t[12]=_):_=t[12];let v;t[13]!==r.form.name||t[14]!==_?(v=(0,H.jsx)($,{label:r.form.name,children:_}),t[13]=r.form.name,t[14]=_,t[15]=v):v=t[15];let y;t[16]===p?y=t[17]:(y=e=>p({description:e.target.value}),t[16]=p,t[17]=y);let b;t[18]!==n.description||t[19]!==y?(b=(0,H.jsx)(`input`,{className:Q,value:n.description,onChange:y}),t[18]=n.description,t[19]=y,t[20]=b):b=t[20];let x;t[21]!==r.form.description||t[22]!==b?(x=(0,H.jsx)($,{label:r.form.description,children:b}),t[21]=r.form.description,t[22]=b,t[23]=x):x=t[23];let S;t[24]===r.form.trigger?S=t[25]:(S=(0,H.jsx)(Re,{title:r.form.trigger}),t[24]=r.form.trigger,t[25]=S);let C;t[26]===p?C=t[27]:(C=e=>p({triggerMode:e.target.value}),t[26]=p,t[27]=C);let w;t[28]===r.trigger.manual?w=t[29]:(w=(0,H.jsx)(M,{value:`manual`,children:r.trigger.manual}),t[28]=r.trigger.manual,t[29]=w);let T;t[30]===r.trigger.daily?T=t[31]:(T=(0,H.jsx)(M,{value:`daily`,children:r.trigger.daily}),t[30]=r.trigger.daily,t[31]=T);let E;t[32]===r.trigger.weekly?E=t[33]:(E=(0,H.jsx)(M,{value:`weekly`,children:r.trigger.weekly}),t[32]=r.trigger.weekly,t[33]=E);let D;t[34]===r.trigger.interval?D=t[35]:(D=(0,H.jsx)(M,{value:`interval`,children:r.trigger.interval}),t[34]=r.trigger.interval,t[35]=D);let O;t[36]===r.trigger.customCron?O=t[37]:(O=(0,H.jsx)(M,{value:`cron`,children:r.trigger.customCron}),t[36]=r.trigger.customCron,t[37]=O);let k;t[38]===r.trigger.webhook?k=t[39]:(k=(0,H.jsx)(M,{value:`webhook`,children:r.trigger.webhook}),t[38]=r.trigger.webhook,t[39]=k);let A;t[40]===r.trigger.goalBlocked?A=t[41]:(A=(0,H.jsx)(M,{value:`goalBlocked`,children:r.trigger.goalBlocked}),t[40]=r.trigger.goalBlocked,t[41]=A);let ee;t[42]===r.trigger.noteCreated?ee=t[43]:(ee=(0,H.jsx)(M,{value:`noteCreated`,children:r.trigger.noteCreated}),t[42]=r.trigger.noteCreated,t[43]=ee);let j;t[44]===r.trigger.workflowFailed?j=t[45]:(j=(0,H.jsx)(M,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[44]=r.trigger.workflowFailed,t[45]=j);let te;t[46]===r.trigger.sessionUpdated?te=t[47]:(te=(0,H.jsx)(M,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[46]=r.trigger.sessionUpdated,t[47]=te);let ne;t[48]!==n.triggerMode||t[49]!==C||t[50]!==w||t[51]!==T||t[52]!==E||t[53]!==D||t[54]!==O||t[55]!==k||t[56]!==A||t[57]!==ee||t[58]!==j||t[59]!==te?(ne=(0,H.jsxs)(N,{className:Q,value:n.triggerMode,onChange:C,children:[w,T,E,D,O,k,A,ee,j,te]}),t[48]=n.triggerMode,t[49]=C,t[50]=w,t[51]=T,t[52]=E,t[53]=D,t[54]=O,t[55]=k,t[56]=A,t[57]=ee,t[58]=j,t[59]=te,t[60]=ne):ne=t[60];let P;t[61]!==n.time||t[62]!==n.triggerMode||t[63]!==n.weekday||t[64]!==r.form.day||t[65]!==r.form.time||t[66]!==r.weekdays||t[67]!==p?(P=n.triggerMode===`daily`||n.triggerMode===`weekly`?(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)($,{label:r.form.time,children:(0,H.jsx)(`input`,{className:Q,type:`time`,value:n.time,onChange:e=>p({time:e.target.value})})}),n.triggerMode===`weekly`?(0,H.jsx)($,{label:r.form.day,children:(0,H.jsxs)(N,{className:Q,value:n.weekday,onChange:e=>p({weekday:e.target.value}),children:[(0,H.jsx)(M,{value:`1`,children:r.weekdays.monday}),(0,H.jsx)(M,{value:`2`,children:r.weekdays.tuesday}),(0,H.jsx)(M,{value:`3`,children:r.weekdays.wednesday}),(0,H.jsx)(M,{value:`4`,children:r.weekdays.thursday}),(0,H.jsx)(M,{value:`5`,children:r.weekdays.friday}),(0,H.jsx)(M,{value:`6`,children:r.weekdays.saturday}),(0,H.jsx)(M,{value:`0`,children:r.weekdays.sunday})]})}):null]}):null,t[61]=n.time,t[62]=n.triggerMode,t[63]=n.weekday,t[64]=r.form.day,t[65]=r.form.time,t[66]=r.weekdays,t[67]=p,t[68]=P):P=t[68];let re;t[69]!==n.intervalMinutes||t[70]!==n.triggerMode||t[71]!==r.form.everyMinutes||t[72]!==p?(re=n.triggerMode===`interval`?(0,H.jsx)($,{label:r.form.everyMinutes,children:(0,H.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.intervalMinutes,onChange:e=>p({intervalMinutes:e.target.value})})}):null,t[69]=n.intervalMinutes,t[70]=n.triggerMode,t[71]=r.form.everyMinutes,t[72]=p,t[73]=re):re=t[73];let F;t[74]!==n.cronExpr||t[75]!==n.triggerMode||t[76]!==r.form.expression||t[77]!==p?(F=n.triggerMode===`cron`?(0,H.jsx)($,{label:r.form.expression,children:(0,H.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>p({cronExpr:e.target.value})})}):null,t[74]=n.cronExpr,t[75]=n.triggerMode,t[76]=r.form.expression,t[77]=p,t[78]=F):F=t[78];let I;t[79]!==n.triggerMode||t[80]!==n.webhookSecretId||t[81]!==r.form.secretId||t[82]!==p?(I=n.triggerMode===`webhook`?(0,H.jsx)($,{label:r.form.secretId,children:(0,H.jsx)(`input`,{className:Q,value:n.webhookSecretId,onChange:e=>p({webhookSecretId:e.target.value})})}):null,t[79]=n.triggerMode,t[80]=n.webhookSecretId,t[81]=r.form.secretId,t[82]=p,t[83]=I):I=t[83];let L;t[84]===r.form.action?L=t[85]:(L=(0,H.jsx)(Re,{title:r.form.action}),t[84]=r.form.action,t[85]=L);let ie;t[86]!==n.workflowId||t[87]!==p||t[88]!==o?(ie=e=>{let t=e.target.value;p({actionMode:t,...t===`workflow`&&!n.workflowId.trim()&&o[0]?{workflowId:o[0].id,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}:{}})},t[86]=n.workflowId,t[87]=p,t[88]=o,t[89]=ie):ie=t[89];let ae;t[90]===r.action.runAgent?ae=t[91]:(ae=(0,H.jsx)(M,{value:`agent`,children:r.action.runAgent}),t[90]=r.action.runAgent,t[91]=ae);let R;t[92]===r.action.runWorkflow?R=t[93]:(R=(0,H.jsx)(M,{value:`workflow`,children:r.action.runWorkflow}),t[92]=r.action.runWorkflow,t[93]=R);let z;t[94]!==n.actionMode||t[95]!==ie||t[96]!==ae||t[97]!==R?(z=(0,H.jsxs)(N,{className:Q,value:n.actionMode,onChange:ie,children:[ae,R]}),t[94]=n.actionMode,t[95]=ie,t[96]=ae,t[97]=R,t[98]=z):z=t[98];let se=r.form.agent,U=n.agentId,W;t[99]===p?W=t[100]:(W=e=>p({agentId:e.target.value}),t[99]=p,t[100]=W);let le=u?r.form.loadingAgents:r.form.defaultAgent,G;t[101]===le?G=t[102]:(G=(0,H.jsx)(M,{value:``,children:le}),t[101]=le,t[102]=G);let ue;t[103]===l?ue=t[104]:(ue=l.map(Le),t[103]=l,t[104]=ue);let de;t[105]!==n.agentId||t[106]!==W||t[107]!==G||t[108]!==ue?(de=(0,H.jsxs)(N,{className:Q,value:U,onChange:W,children:[G,ue]}),t[105]=n.agentId,t[106]=W,t[107]=G,t[108]=ue,t[109]=de):de=t[109];let K;t[110]!==r.form.agent||t[111]!==de?(K=(0,H.jsx)($,{label:se,children:de}),t[110]=r.form.agent,t[111]=de,t[112]=K):K=t[112];let fe;t[113]!==n.actionMode||t[114]!==n.agentId||t[115]!==n.description||t[116]!==n.instruction||t[117]!==n.name||t[118]!==n.triggerMode||t[119]!==n.workflowId||t[120]!==n.workflowInput||t[121]!==r.form.instruction||t[122]!==r.form.loadingWorkflows||t[123]!==r.form.noWorkflows||t[124]!==r.form.triggeredRun||t[125]!==r.form.workflow||t[126]!==d||t[127]!==s||t[128]!==p||t[129]!==o||t[130]!==c?(fe=n.actionMode===`agent`?(0,H.jsxs)($,{label:r.form.instruction,children:[(0,H.jsx)(`div`,{className:`flex justify-end`,children:(0,H.jsx)(oe,{value:n.instruction,onApply:e=>p({instruction:e}),fieldId:`automation.instruction`,fieldLabel:r.form.instruction,scenario:`automation.instruction`,locale:d,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,agentId:n.agentId},showLabel:!1})}),(0,H.jsx)(`textarea`,{className:i(Q,`min-h-32 resize-y`),value:n.instruction,onChange:e=>p({instruction:e.target.value})})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{label:r.form.workflow,children:(0,H.jsxs)(N,{className:Q,value:n.workflowId,onChange:e=>p({workflowId:e.target.value,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}),disabled:c||o.length===0,children:[c?(0,H.jsx)(M,{value:``,children:r.form.loadingWorkflows}):null,!c&&o.length===0?(0,H.jsx)(M,{value:``,children:r.form.noWorkflows}):null,o.map(Ie)]})}),s?(0,H.jsx)(ce,{definition:s,language:d,value:n.workflowInput,onChange:e=>p({workflowInput:e,workflowGoal:e.goal,workflowInputValid:!0}),mode:`automation`,badgeLabel:r.form.triggeredRun,onValidityChange:e=>p({workflowInputValid:e.valid}),aiAssist:{inputScenario:`automation.workflowInput`,goalScenario:`automation.workflowGoal`,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,workflowId:s.id,workflowTitle:s.title,workflowDescription:s.description}},inputClassName:`rounded-lg`}):null]}),t[113]=n.actionMode,t[114]=n.agentId,t[115]=n.description,t[116]=n.instruction,t[117]=n.name,t[118]=n.triggerMode,t[119]=n.workflowId,t[120]=n.workflowInput,t[121]=r.form.instruction,t[122]=r.form.loadingWorkflows,t[123]=r.form.noWorkflows,t[124]=r.form.triggeredRun,t[125]=r.form.workflow,t[126]=d,t[127]=s,t[128]=p,t[129]=o,t[130]=c,t[131]=fe):fe=t[131];let q;t[132]===r.form.safety?q=t[133]:(q=(0,H.jsx)(Re,{title:r.form.safety}),t[132]=r.form.safety,t[133]=q);let pe;t[134]!==n.afterRunMode||t[135]!==p?(pe=e=>{let t=e.target.value;p({safetyMode:t,...t!==`auto_apply`&&n.afterRunMode===`webhook`?{afterRunMode:`none`,webhookUrl:``}:{}})},t[134]=n.afterRunMode,t[135]=p,t[136]=pe):pe=t[136];let J;t[137]===r.safety.suggest_only?J=t[138]:(J=(0,H.jsx)(M,{value:`suggest_only`,children:r.safety.suggest_only}),t[137]=r.safety.suggest_only,t[138]=J);let me;t[139]===r.safety.ask_before_apply?me=t[140]:(me=(0,H.jsx)(M,{value:`ask_before_apply`,children:r.safety.ask_before_apply}),t[139]=r.safety.ask_before_apply,t[140]=me);let Y;t[141]===r.safety.auto_apply?Y=t[142]:(Y=(0,H.jsx)(M,{value:`auto_apply`,children:r.safety.auto_apply}),t[141]=r.safety.auto_apply,t[142]=Y);let X;t[143]!==n.safetyMode||t[144]!==pe||t[145]!==J||t[146]!==me||t[147]!==Y?(X=(0,H.jsxs)(N,{className:Q,value:n.safetyMode,onChange:pe,children:[J,me,Y]}),t[143]=n.safetyMode,t[144]=pe,t[145]=J,t[146]=me,t[147]=Y,t[148]=X):X=t[148];let he=n.safetyMode===`suggest_only`?r.safety.suggestOnlyDescription:n.safetyMode===`ask_before_apply`?r.safety.askBeforeApplyDescription:r.safety.autoApplyDescription,ge;t[149]===he?ge=t[150]:(ge=(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:he}),t[149]=he,t[150]=ge);let _e;t[151]!==r.form.safety||t[152]!==X||t[153]!==ge?(_e=(0,H.jsxs)($,{label:r.form.safety,children:[X,ge]}),t[151]=r.form.safety,t[152]=X,t[153]=ge,t[154]=_e):_e=t[154];let ve;t[155]===r.form.afterRun?ve=t[156]:(ve=(0,H.jsx)(Re,{title:r.form.afterRun}),t[155]=r.form.afterRun,t[156]=ve);let ye;t[157]===p?ye=t[158]:(ye=e=>p({afterRunMode:e.target.value}),t[157]=p,t[158]=ye);let be;t[159]===r.afterRun.none?be=t[160]:(be=(0,H.jsx)(M,{value:`none`,children:r.afterRun.none}),t[159]=r.afterRun.none,t[160]=be);let xe;t[161]===r.afterRun.saveToSession?xe=t[162]:(xe=(0,H.jsx)(M,{value:`saveToSession`,children:r.afterRun.saveToSession}),t[161]=r.afterRun.saveToSession,t[162]=xe);let Se=n.safetyMode!==`auto_apply`,Ce;t[163]!==r.afterRun.webhook||t[164]!==Se?(Ce=(0,H.jsx)(M,{value:`webhook`,disabled:Se,children:r.afterRun.webhook}),t[163]=r.afterRun.webhook,t[164]=Se,t[165]=Ce):Ce=t[165];let we;t[166]!==n.afterRunMode||t[167]!==ye||t[168]!==be||t[169]!==xe||t[170]!==Ce?(we=(0,H.jsxs)(N,{className:Q,value:n.afterRunMode,onChange:ye,children:[be,xe,Ce]}),t[166]=n.afterRunMode,t[167]=ye,t[168]=be,t[169]=xe,t[170]=Ce,t[171]=we):we=t[171];let Te;t[172]!==n.afterRunMode||t[173]!==n.webhookUrl||t[174]!==r.form.webhookUrl||t[175]!==p?(Te=n.afterRunMode===`webhook`?(0,H.jsx)($,{label:r.form.webhookUrl,children:(0,H.jsx)(`input`,{className:Q,value:n.webhookUrl,onChange:e=>p({webhookUrl:e.target.value})})}):null,t[172]=n.afterRunMode,t[173]=n.webhookUrl,t[174]=r.form.webhookUrl,t[175]=p,t[176]=Te):Te=t[176];let Ee;t[177]===r.form.reliability?Ee=t[178]:(Ee=(0,H.jsx)(Re,{title:r.form.reliability}),t[177]=r.form.reliability,t[178]=Ee);let De;t[179]===p?De=t[180]:(De=e=>p({timeoutSeconds:e.target.value}),t[179]=p,t[180]=De);let Oe;t[181]!==n.timeoutSeconds||t[182]!==De?(Oe=(0,H.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.timeoutSeconds,onChange:De}),t[181]=n.timeoutSeconds,t[182]=De,t[183]=Oe):Oe=t[183];let ke;t[184]!==r.form.timeoutSeconds||t[185]!==Oe?(ke=(0,H.jsx)($,{label:r.form.timeoutSeconds,children:Oe}),t[184]=r.form.timeoutSeconds,t[185]=Oe,t[186]=ke):ke=t[186];let Ae;t[187]===p?Ae=t[188]:(Ae=e=>p({disableAfterFailures:e.target.value}),t[187]=p,t[188]=Ae);let je;t[189]!==n.disableAfterFailures||t[190]!==Ae?(je=(0,H.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.disableAfterFailures,onChange:Ae}),t[189]=n.disableAfterFailures,t[190]=Ae,t[191]=je):je=t[191];let Z;t[192]!==r.form.disableAfterFailures||t[193]!==je?(Z=(0,H.jsx)($,{label:r.form.disableAfterFailures,children:je}),t[192]=r.form.disableAfterFailures,t[193]=je,t[194]=Z):Z=t[194];let Me;t[195]!==ke||t[196]!==Z?(Me=(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ke,Z]}),t[195]=ke,t[196]=Z,t[197]=Me):Me=t[197];let Ne;return t[198]!==S||t[199]!==ne||t[200]!==P||t[201]!==re||t[202]!==F||t[203]!==I||t[204]!==L||t[205]!==z||t[206]!==K||t[207]!==fe||t[208]!==q||t[209]!==_e||t[210]!==ve||t[211]!==we||t[212]!==Te||t[213]!==Ee||t[214]!==v||t[215]!==Me||t[216]!==x?(Ne=(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,H.jsxs)(`div`,{className:`grid gap-4`,children:[v,x,S,ne,P,re,F,I,L,z,K,fe,q,_e,ve,we,Te,Ee,Me]})}),t[198]=S,t[199]=ne,t[200]=P,t[201]=re,t[202]=F,t[203]=I,t[204]=L,t[205]=z,t[206]=K,t[207]=fe,t[208]=q,t[209]=_e,t[210]=ve,t[211]=we,t[212]=Te,t[213]=Ee,t[214]=v,t[215]=Me,t[216]=x,t[217]=Ne):Ne=t[217],Ne}function Ie(e){return(0,H.jsx)(M,{value:e.id,children:e.title||e.name},e.id)}function Le(e){return(0,H.jsx)(M,{value:e.id,children:e.name||e.id},e.id)}var Q=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`;function $(e){let t=(0,B.c)(5),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,H.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Re(e){let t=(0,B.c)(3),{title:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,H.jsx)(k,{className:`size-4 text-fg-muted`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,H.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 text-sm font-semibold text-fg`,children:[r,n]}),t[1]=n,t[2]=i),i}export{be as AutomationsPage};