@xopcai/xopc 0.0.104 → 0.0.105

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 (113) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/agents-XzgIVKcI.js +396 -0
  4. package/dist/gateway/static/root/assets/{apps-page-L-IwQTe0.js → apps-page-B7Us3RMl.js} +1 -1
  5. package/dist/gateway/static/root/assets/channels-settings-BgeV6fzw.js +1 -0
  6. package/dist/gateway/static/root/assets/cron-page-DKGHEeAU.js +1 -0
  7. package/dist/gateway/static/root/assets/{dist-C6vclgEL.js → dist-DJDkNhu5.js} +1 -1
  8. package/dist/gateway/static/root/assets/{extension-debug-page-D4JYAbsX.js → extension-debug-page-DI1XJTJi.js} +1 -1
  9. package/dist/gateway/static/root/assets/{extension-page-_T62gi6e.js → extension-page-SuafGTT_.js} +1 -1
  10. package/dist/gateway/static/root/assets/{extension-settings-page-CkJbjyM-.js → extension-settings-page-cKmGax9v.js} +1 -1
  11. package/dist/gateway/static/root/assets/{fetch-B5aiIguv.js → fetch-CkvRO30i.js} +1 -1
  12. package/dist/gateway/static/root/assets/{gateway-startup-retry-DqmLXhs6.js → gateway-startup-retry-BkKyRDrF.js} +1 -1
  13. package/dist/gateway/static/root/assets/{heartbeat-config-api-HwJV1K_Y.js → heartbeat-config-api-CRiDcxtt.js} +1 -1
  14. package/dist/gateway/static/root/assets/index-50FVtgXU.js +4845 -0
  15. package/dist/gateway/static/root/assets/{logs-page-DsjtTjBy.js → logs-page-DM8o5-Bm.js} +2 -2
  16. package/dist/gateway/static/root/assets/{note-detail-page-B2V7RhgD.js → note-detail-page-j53jtvq9.js} +54 -54
  17. package/dist/gateway/static/root/assets/{note-time-BG8GCTr4.js → note-time-Ck2H2Qpw.js} +1 -1
  18. package/dist/gateway/static/root/assets/{notes-page-xrcVBQ6Z.js → notes-page-CsWIw35Q.js} +1 -1
  19. package/dist/gateway/static/root/assets/{schema-form-S-QUvhul.js → schema-form-BvmGNxiJ.js} +1 -1
  20. package/dist/gateway/static/root/assets/sessions-page-CLPsbyOW.js +1 -0
  21. package/dist/gateway/static/root/assets/{settings-advanced-gate-DujQl9c7.js → settings-advanced-gate-DRdayl8P.js} +1 -1
  22. package/dist/gateway/static/root/assets/{settings-form-section-r1V7dRV6.js → settings-form-section-BlIYg2gZ.js} +1 -1
  23. package/dist/gateway/static/root/assets/settings-page-CRGHT_bm.js +3 -0
  24. package/dist/gateway/static/root/assets/{share-preview-page-DOFy0FNt.js → share-preview-page-BlT6Akvk.js} +1 -1
  25. package/dist/gateway/static/root/assets/skills-page-Ce-RIH2y.js +2 -0
  26. package/dist/gateway/static/root/assets/{theme-store-Bo3j5Ovv.js → theme-store-DYgVdRB4.js} +1 -1
  27. package/dist/gateway/static/root/assets/url-DPEStU4M.js +3 -0
  28. package/dist/gateway/static/root/assets/{voice-api-key-field-AjmUAlEQ.js → voice-api-key-field-CJGTidqc.js} +1 -1
  29. package/dist/gateway/static/root/assets/{workflow-page.utils-DLEJ92gK.js → workflow-page.utils-_sjXCMvi.js} +1 -1
  30. package/dist/gateway/static/root/assets/workflows-page-o63aaARK.js +27 -0
  31. package/dist/gateway/static/root/index.html +5 -5
  32. package/dist/package.js +1 -1
  33. package/dist/src/agent/context/workspace-seed.js +1 -1
  34. package/dist/src/agent/inbound/turn-dispatcher.d.ts +2 -0
  35. package/dist/src/agent/inbound/turn-dispatcher.js +1 -0
  36. package/dist/src/agent/inbound/turn-dispatcher.js.map +1 -1
  37. package/dist/src/agent/prompt/memory/index.js +30 -2
  38. package/dist/src/agent/prompt/memory/index.js.map +1 -1
  39. package/dist/src/agent/service/direct-turn-helpers.d.ts +2 -0
  40. package/dist/src/agent/service/direct-turn-helpers.js +5 -2
  41. package/dist/src/agent/service/direct-turn-helpers.js.map +1 -1
  42. package/dist/src/agent/service/process-direct-streaming.d.ts +2 -0
  43. package/dist/src/agent/service/process-direct-streaming.js +15 -1
  44. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  45. package/dist/src/agent/service.js +2 -1
  46. package/dist/src/agent/service.js.map +1 -1
  47. package/dist/src/agent/service.types.d.ts +3 -0
  48. package/dist/src/agent/skills/hub-pull.js +1 -1
  49. package/dist/src/agent/source-context/index.d.ts +2 -0
  50. package/dist/src/agent/source-context/index.js +3 -0
  51. package/dist/src/agent/source-context/injector.d.ts +3 -0
  52. package/dist/src/agent/source-context/injector.js +36 -0
  53. package/dist/src/agent/source-context/injector.js.map +1 -0
  54. package/dist/src/agent/source-context/types.d.ts +19 -0
  55. package/dist/src/agent/source-context/types.js +10 -0
  56. package/dist/src/agent/source-context/types.js.map +1 -0
  57. package/dist/src/agent/tools/factory.js +5 -5
  58. package/dist/src/agent/tools/index.js +3 -3
  59. package/dist/src/agent/tools/session-search-tool.js +1 -1
  60. package/dist/src/agent/tools/shell.js +1 -1
  61. package/dist/src/agent/tools/web-extract.js +2 -2
  62. package/dist/src/agent/tools/web.js +1 -1
  63. package/dist/src/browser/actions/extension-registry-bridge.js +1 -1
  64. package/dist/src/browser/actions/registry.js +2 -2
  65. package/dist/src/browser/cdp-local-launcher.js +1 -1
  66. package/dist/src/browser/index.js +3 -3
  67. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  68. package/dist/src/browser/providers/cloakbrowser.js +1 -1
  69. package/dist/src/cli/commands/browser-cli-helpers.js +1 -1
  70. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  71. package/dist/src/config/paths.d.ts +1 -0
  72. package/dist/src/config/paths.js +5 -1
  73. package/dist/src/config/paths.js.map +1 -1
  74. package/dist/src/document-understanding/extract.d.ts +13 -0
  75. package/dist/src/document-understanding/extract.js +63 -0
  76. package/dist/src/document-understanding/extract.js.map +1 -0
  77. package/dist/src/gateway/hono/routes/notes.js +46 -27
  78. package/dist/src/gateway/hono/routes/notes.js.map +1 -1
  79. package/dist/src/gateway/service.js +11 -0
  80. package/dist/src/gateway/service.js.map +1 -1
  81. package/dist/src/mcp/channel-bridge.js +1 -1
  82. package/dist/src/notes/agent-context.d.ts +40 -0
  83. package/dist/src/notes/agent-context.js +383 -0
  84. package/dist/src/notes/agent-context.js.map +1 -0
  85. package/dist/src/notes/index.d.ts +2 -0
  86. package/dist/src/notes/index.js +2 -1
  87. package/dist/src/notes/service.d.ts +5 -0
  88. package/dist/src/notes/service.js +22 -0
  89. package/dist/src/notes/service.js.map +1 -1
  90. package/dist/src/notes/store.js +2 -0
  91. package/dist/src/notes/store.js.map +1 -1
  92. package/dist/src/share/share-thumbnail.js +1 -1
  93. package/dist/src/storage/sqlite/index.d.ts +1 -0
  94. package/dist/src/storage/sqlite/index.js +2 -1
  95. package/dist/src/storage/sqlite/migrations/005_add_note_agent_contexts.sql +10 -0
  96. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  97. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  98. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  99. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  100. package/dist/src/storage/sqlite/note-agent-context-repository.d.ts +10 -0
  101. package/dist/src/storage/sqlite/note-agent-context-repository.js +35 -0
  102. package/dist/src/storage/sqlite/note-agent-context-repository.js.map +1 -0
  103. package/dist/src/storage/sqlite/schema.js +1 -1
  104. package/package.json +3 -3
  105. package/dist/gateway/static/root/assets/agents-CvsBrBfi.js +0 -396
  106. package/dist/gateway/static/root/assets/channels-settings-D95KuPeP.js +0 -1
  107. package/dist/gateway/static/root/assets/cron-page-CfkWXDAI.js +0 -1
  108. package/dist/gateway/static/root/assets/index-DvTb6wNR.js +0 -4845
  109. package/dist/gateway/static/root/assets/sessions-page-CrQer6Au.js +0 -1
  110. package/dist/gateway/static/root/assets/settings-page-C9nrONQ2.js +0 -3
  111. package/dist/gateway/static/root/assets/skills-page-DmTsrs_a.js +0 -2
  112. package/dist/gateway/static/root/assets/url-WgQIjFZu.js +0 -3
  113. package/dist/gateway/static/root/assets/workflows-page-BnjjKrM1.js +0 -27
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-WgQIjFZu.js";import{a as s,i as c}from"./vendor-swr-BIWyz7Rc.js";import{a as l,n as u,t as d}from"./fetch-B5aiIguv.js";import{Cr as f,Da as p,Er as m,Ir as h,P as g,Pn as _,Qo as v,Sr as y,To as b,Tr as x,Tt as S,Ui as C,Vo as w,_r as T,ci as E,gr as D,hr as O,jo as k,ma as A,mr as j,oa as M,qi as N,qo as P,si as F,so as I,ui as L,vr as R,wr as z,xi as B,xr as V}from"./index-DvTb6wNR.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 ee(e){let t=await d(o(`/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 d(o(`/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 d(o(`/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 d(o(`/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 Z={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function te({className:e}){let t=a(i(e=>e.language)).appsPage,n=l(e=>!!e.token),r=O(),{mutate:d}=s(),[f,m]=(0,H.useReducer)(g,Z),{q:h,debounced:_,detailPkg:v,rowBusy:y,actionError:x,restartHint:C}=f,w=n?`marketplace-${_}`:null;(0,H.useEffect)(()=>{let e=window.setTimeout(()=>m({type:`patch`,patch:{debounced:h.trim()}}),300);return()=>window.clearTimeout(e)},[h]);let{data:T,isLoading:D,error:k}=c(w,async()=>u(_.length>0?o(`/api/marketplace?q=${encodeURIComponent(_)}`):o(`/api/marketplace`)),{revalidateOnFocus:!1}),j=(0,H.useCallback)(()=>{d(`gateway-extensions-list`),S()},[d]),M=(0,H.useCallback)(async(e,n)=>{m({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await K({name:e,overwrite:n});j(),r.requiresGatewayRestart&&m({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw m({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{m({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,j]),P=(0,H.useCallback)(async e=>{m({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await J(e);j(),n.requiresGatewayRestart&&m({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw m({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{m({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,j]),F=T?.extensions??[];return(0,Y.jsxs)(`div`,{className:E(`flex flex-col gap-4`,e),children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(N,{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:h,onChange:e=>m({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),k?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:k instanceof Error?k.message:t.marketplaceLoadFailed}):null,x?(0,Y.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null,C?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:C}):null,D&&!T?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-3`,children:F.length===0?(0,Y.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):F.map(e=>{let n=X(r,e.id),i=y===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:()=>m({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),m({type:`patch`,patch:{detailPkg:e.id}}))},className:E(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl border border-edge bg-surface-base p-4 text-left shadow-surface`,`transition-[transform,background-color,border-color,box-shadow] duration-150 ease-out`,`hover:border-edge-subtle 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)(b,{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)(A,{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:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&P(e.id).catch(()=>{})},className:E(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,Y.jsx)(p,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(B,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,Y.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{M(e.id,!1).catch(()=>{})},className:E(`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:[i?(0,Y.jsx)(p,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),v?(0,Y.jsx)(ne,{packageName:v,copy:t,extensions:r,onClose:()=>m({type:`patch`,patch:{detailPkg:null}}),onInstall:M,onUninstall:P}):null]})}function ne(e){let t=(0,U.c)(61),{packageName:n,copy:r,extensions:i,onClose:a,onInstall:o,onUninstall:s}=e,[u,d]=(0,H.useState)(!1),h=l(oe)?`ext-mp-detail-${n}`:null,g;t[0]===n?g=t[1]:(g=async()=>ee(n),t[0]=n,t[1]=g);let v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},t[2]=v):v=t[2];let{data:y,error:b,isLoading:S}=c(h,g,v),C;t[3]!==i||t[4]!==n?(C=X(i,n),t[3]=i,t[4]=n,t[5]=C):C=t[5];let T=C,D=T===`user`,O;t[6]!==r.marketplaceNoReadme||t[7]!==y?(O=y?.readme?.trim()||(y?.description?.trim()?`### ${y.name}\n\n${y.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=y,t[8]=O):O=t[8];let k=O,A;t[9]===a?A=t[10]:(A=e=>!e&&a(),t[9]=a,t[10]=A);let j;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Y.jsx)(f,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=j):j=t[11];let M;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Y.jsx)(w,{className:`size-5`}),t[12]=M):M=t[12];let N;t[13]!==r.detailBack||t[14]!==a?(N=(0,Y.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:M}),t[13]=r.detailBack,t[14]=a,t[15]=N):N=t[15];let F;t[16]===r.marketplaceDetailTitle?F=t[17]:(F=(0,Y.jsx)(m,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=F);let I;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Y.jsx)(L,{className:`size-5`}),t[18]=I):I=t[18];let R;t[19]!==r.detailClose||t[20]!==a?(R=(0,Y.jsx)(`button`,{type:`button`,onClick:a,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:I}),t[19]=r.detailClose,t[20]=a,t[21]=R):R=t[21];let W;t[22]!==R||t[23]!==N||t[24]!==F?(W=(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[N,F,R]}),t[22]=R,t[23]=N,t[24]=F,t[25]=W):W=t[25];let G;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==y||t[32]!==b||t[33]!==S||t[34]!==k?(G=S&&!y?(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}):y?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:y.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:y.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:y.author.username})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,Y.jsx)(`dd`,{children:y.latestVersion.version})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,Y.jsx)(`dd`,{children:y.downloads})]})]}),y.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)(_,{content:k})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=y,t[32]=b,t[33]=S,t[34]=k,t[35]=G):G=t[35];let K;t[36]===G?K=t[37]:(K=(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:G}),t[36]=G,t[37]=K);let q;t[38]!==u||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==y||t[47]!==T||t[48]!==a||t[49]!==o||t[50]!==s||t[51]!==n||t[52]!==D?(q=y?(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:T===`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)(P,{to:`/apps?tab=builtin`,onClick:a,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:()=>{D&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),o(n,D).catch(ie).finally(()=>d(!1)))},className:E(`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)(p,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,D?r.marketplaceReinstall:r.marketplaceInstall]}),D?(0,Y.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),s(n).then(()=>a()).catch(re).finally(()=>d(!1)))},className:E(`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)(B,{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]=y,t[47]=T,t[48]=a,t[49]=o,t[50]=s,t[51]=n,t[52]=D,t[53]=q):q=t[53];let J;t[54]!==W||t[55]!==K||t[56]!==q?(J=(0,Y.jsxs)(z,{children:[j,(0,Y.jsxs)(V,{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:ae,children:[W,K,q]})]}),t[54]=W,t[55]=K,t[56]=q,t[57]=J):J=t[57];let Z;return t[58]!==J||t[59]!==A?(Z=(0,Y.jsx)(x,{defaultOpen:!0,onOpenChange:A,children:J}),t[58]=J,t[59]=A,t[60]=Z):Z=t[60],Z}function re(){}function ie(){}function ae(e){return e.preventDefault()}function oe(e){return!!e.token}function se(){let e=i(e=>e.language),t=a(e),n=h(e=>e.setPageHeader),r=h(e=>e.clearPageHeader),o=O(),s=D(),[c,l]=v(),u=W(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,H.useState)(u),[m,g]=(0,H.useState)(d),[_,y]=(0,H.useState)(null),b=c.toString(),x=(0,H.useRef)(b);if(x.current!==b){x.current=b;let e=W(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),g(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 S=(0,H.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),C=(0,H.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),w=f===`builtin`?S:C,T=(0,H.useMemo)(()=>{let t=m.trim().toLowerCase(),n=w;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[w,m,e]);if((0,H.useEffect)(()=>{y(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?Q(e)===Q(t)&&e.active===t.active?e:t:null})},[o]),(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.appsPage.title})}),end:null}),()=>r()),[r,t.appsPage.title,n]),s&&f!==`marketplace`)return(0,Y.jsx)(pe,{});let k=f!==`marketplace`&&w.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:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,Y.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-x-1 gap-y-1`,role:`tablist`,"aria-label":t.appsPage.appsNavAria,children:[(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`marketplace`,className:E(`relative max-w-full rounded-md px-3 py-2 text-left text-sm font-medium transition-colors sm:text-center`,f===`marketplace`?`text-fg`:`text-fg-muted hover:text-fg`,f===`marketplace`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`marketplace`),children:t.appsPage.tabMarketplace}),(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`builtin`,className:E(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`builtin`?`text-fg`:`text-fg-muted hover:text-fg`,f===`builtin`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`builtin`),children:[t.appsPage.tabBuiltin,(0,Y.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,S.length,`)`]})]}),(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`user`,className:E(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`user`?`text-fg`:`text-fg-muted hover:text-fg`,f===`user`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`user`),children:[t.appsPage.tabUser,(0,Y.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,C.length,`)`]})]})]}),k?(0,Y.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,Y.jsx)(N,{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=>g(e.target.value),placeholder:t.appsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),f===`marketplace`?(0,Y.jsx)(te,{}):f===`builtin`&&S.length===0?(0,Y.jsx)(he,{message:t.appsPage.emptyBuiltin}):f===`user`&&C.length===0?(0,Y.jsx)(he,{message:t.appsPage.emptyUser}):T.length===0?(0,Y.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-hover/30 px-4 py-8 text-center text-sm text-fg-muted dark:bg-surface-hover/15`,children:t.appsPage.noSearchResults}):(0,Y.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:T.map(e=>(0,Y.jsx)(de,{extension:e,copy:t.appsPage,showSourceBadge:f===`user`,onOpen:()=>y(e)},e.id))})]}),_?(0,Y.jsx)(fe,{extension:_,copy:t.appsPage,onClose:()=>y(null)},_.id):null]})}function Q(e){return e.activationEligible??e.active}function ce(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function le(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function ue(e,t){let n=Q(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function de(e){let t=(0,U.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,o;t[0]===n?o=t[1]:(o=Q(n),t[0]=n,t[1]=o);let s=o,c=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=E(`group flex w-full flex-col rounded-xl border border-edge bg-surface-base p-4 text-left shadow-sm transition-colors`,`hover:border-edge-subtle 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]=l):l=t[2];let u=n.name||n.id,d;t[3]===u?d=t[4]:(d=u.charAt(0).toUpperCase(),t[3]=u,t[4]=d);let f;t[5]===d?f=t[6]:(f=(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:d}),t[5]=d,t[6]=f);let p;t[7]===n.name?p=t[8]:(p=(0,Y.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=p);let m;t[9]===n.version?m=t[10]:(m=n.version?(0,Y.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=m);let h;t[11]!==p||t[12]!==m?(h=(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==r.statusEnabled||t[15]!==s?(g=s?(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)(k,{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)(M,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=s,t[16]=g):g=t[16];let _;t[17]!==h||t[18]!==g?(_=(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==r.cardNoDescription||t[21]!==n.description?(v=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=v):v=t[22];let y;t[23]===v?y=t[24]:(y=(0,Y.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:v}),t[23]=v,t[24]=y);let b=n.hasUi?r.badgeKindUi:r.badgeKindBackend,x;t[25]!==b||t[26]!==c?(x=(0,Y.jsx)(`span`,{title:c,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:b}),t[25]=b,t[26]=c,t[27]=x):x=t[27];let S;t[28]!==r||t[29]!==n||t[30]!==i?(S=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}):i?(0,Y.jsx)(`span`,{title:ce(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:le(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=S):S=t[31];let C;t[32]!==x||t[33]!==S?(C=(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[x,S]}),t[32]=x,t[33]=S,t[34]=C):C=t[34];let w;t[35]!==_||t[36]!==y||t[37]!==C?(w=(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,y,C]}),t[35]=_,t[36]=y,t[37]=C,t[38]=w):w=t[38];let T;t[39]!==w||t[40]!==f?(T=(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[f,w]}),t[39]=w,t[40]=f,t[41]=T):T=t[41];let D;return t[42]!==a||t[43]!==T?(D=(0,Y.jsx)(`button`,{type:`button`,onClick:a,className:l,children:T}),t[42]=a,t[43]=T,t[44]=D):D=t[44],D}function fe({extension:e,copy:t,onClose:n}){let{mutate:r}=s(),[i,a]=(0,H.useState)(!1),[o,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),d=e.activationEligible===!0,h=(0,H.useCallback)(async()=>{if(e.source===`bundled`){c(null),u(!1),a(!0);try{let{requiresGatewayRestart:t}=await q({extensionId:e.id,enabled:!d});await r(`gateway-extensions-list`),S(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{a(!1)}}},[d,t.builtinToggleFailed,e.id,e.source,r]),g=e.ui?.contributions?.pages??[],_=e.ui?.contributions?.settingsPanels??[],v=e.ui?.contributions?.chatWidgets??[],b=e.ui?.contributions?.sidebarPanels??[],D=g.find(e=>e.showInNav)??g[0],O=_[0],k=D?j(e.id,D):null,A=O?`/settings/ext/${e.id}/${O.id}`:e.hasConfigSchema||T(e)?`/settings/ext/${e.id}`:null;return(0,Y.jsx)(x,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,Y.jsxs)(z,{children:[(0,Y.jsx)(f,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,Y.jsxs)(V,{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)(w,{className:`size-5`})}),(0,Y.jsx)(m,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,Y.jsxs)(y,{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)(L,{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,` `,ce(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:ue(e,t)}),e.source===`bundled`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,Y.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-hover/40 p-3 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)(F,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void h(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(p,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):d?t.builtinToggleDisable:t.builtinToggleEnable})]}),o?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:o}):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 border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(g.length>0||_.length>0||v.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:g.length,hidden:g.length===0}),(0,Y.jsx)($,{template:t.badgeSettings,count:_.length,hidden:_.length===0}),(0,Y.jsx)($,{template:t.badgeWidgets,count:v.length,hidden:v.length===0}),(0,Y.jsx)($,{template:t.badgeSidebar,count:b.length,hidden:b.length===0})]})]}):null,R(e)&&(k||A)?(0,Y.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[k?(0,Y.jsxs)(P,{to:k,onClick:n,className:E(`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)(I,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,A?(0,Y.jsxs)(P,{to:A,onClick:n,className:E(`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)(C,{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 pe(){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:`mx-auto w-full max-w-app-main px-4 py-8`,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(me)})]})}),e[4]=a):a=e[4],a}function me(e){return(0,Y.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge bg-surface-base`},e)}function he(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-dashed border-edge-subtle bg-surface-hover/40 px-4 py-12 text-center dark:bg-surface-hover/20`,children:(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{se as AppsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-DPEStU4M.js";import{a as s,i as c}from"./vendor-swr-BIWyz7Rc.js";import{a as l,n as u,t as d}from"./fetch-CkvRO30i.js";import{Ci as f,Cr as p,Do as m,Dr as h,Dt as g,Er as _,Gi as v,In as y,No as b,Or as x,P as S,Rr as C,Tr as w,Uo as T,Yi as E,Yo as D,_r as O,br as k,ca as A,es as j,fi as M,ga as N,gr as P,ka as F,li as I,lo as L,ui as R,vr as z,wr as B,yr as V}from"./index-50FVtgXU.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 ee(e){let t=await d(o(`/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 d(o(`/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 d(o(`/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 d(o(`/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 Z={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function te({className:e}){let t=a(i(e=>e.language)).appsPage,n=l(e=>!!e.token),r=O(),{mutate:d}=s(),[p,h]=(0,H.useReducer)(S,Z),{q:_,debounced:v,detailPkg:y,rowBusy:b,actionError:x,restartHint:C}=p,w=n?`marketplace-${v}`:null;(0,H.useEffect)(()=>{let e=window.setTimeout(()=>h({type:`patch`,patch:{debounced:_.trim()}}),300);return()=>window.clearTimeout(e)},[_]);let{data:T,isLoading:D,error:k}=c(w,async()=>u(v.length>0?o(`/api/marketplace?q=${encodeURIComponent(v)}`):o(`/api/marketplace`)),{revalidateOnFocus:!1}),A=(0,H.useCallback)(()=>{d(`gateway-extensions-list`),g()},[d]),j=(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]),M=(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=T?.extensions??[];return(0,Y.jsxs)(`div`,{className:R(`flex flex-col gap-4`,e),children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(E,{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:_,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,x?(0,Y.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null,C?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:C}):null,D&&!T?(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),i=b===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:R(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl border border-edge bg-surface-base p-4 text-left shadow-surface`,`transition-[transform,background-color,border-color,box-shadow] duration-150 ease-out`,`hover:border-edge-subtle 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)(m,{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)(N,{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:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&M(e.id).catch(()=>{})},className:R(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,Y.jsx)(F,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(f,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,Y.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{j(e.id,!1).catch(()=>{})},className:R(`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:[i?(0,Y.jsx)(F,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),y?(0,Y.jsx)(ne,{packageName:y,copy:t,extensions:r,onClose:()=>h({type:`patch`,patch:{detailPkg:null}}),onInstall:j,onUninstall:M}):null]})}function ne(e){let t=(0,U.c)(61),{packageName:n,copy:r,extensions:i,onClose:a,onInstall:o,onUninstall:s}=e,[u,d]=(0,H.useState)(!1),m=l(oe)?`ext-mp-detail-${n}`:null,g;t[0]===n?g=t[1]:(g=async()=>ee(n),t[0]=n,t[1]=g);let v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},t[2]=v):v=t[2];let{data:b,error:S,isLoading:C}=c(m,g,v),E;t[3]!==i||t[4]!==n?(E=X(i,n),t[3]=i,t[4]=n,t[5]=E):E=t[5];let O=E,k=O===`user`,A;t[6]!==r.marketplaceNoReadme||t[7]!==b?(A=b?.readme?.trim()||(b?.description?.trim()?`### ${b.name}\n\n${b.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=b,t[8]=A):A=t[8];let j=A,N;t[9]===a?N=t[10]:(N=e=>!e&&a(),t[9]=a,t[10]=N);let P;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Y.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=P):P=t[11];let I;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Y.jsx)(T,{className:`size-5`}),t[12]=I):I=t[12];let L;t[13]!==r.detailBack||t[14]!==a?(L=(0,Y.jsx)(`button`,{type:`button`,onClick:a,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]=a,t[15]=L):L=t[15];let z;t[16]===r.marketplaceDetailTitle?z=t[17]:(z=(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]=z);let B;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Y.jsx)(M,{className:`size-5`}),t[18]=B):B=t[18];let V;t[19]!==r.detailClose||t[20]!==a?(V=(0,Y.jsx)(`button`,{type:`button`,onClick:a,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:B}),t[19]=r.detailClose,t[20]=a,t[21]=V):V=t[21];let W;t[22]!==V||t[23]!==L||t[24]!==z?(W=(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[L,z,V]}),t[22]=V,t[23]=L,t[24]=z,t[25]=W):W=t[25];let G;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==b||t[32]!==S||t[33]!==C||t[34]!==j?(G=C&&!b?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):S?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):b?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:b.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:b.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:b.author.username})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,Y.jsx)(`dd`,{children:b.latestVersion.version})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,Y.jsx)(`dd`,{children:b.downloads})]})]}),b.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)(y,{content:j})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=b,t[32]=S,t[33]=C,t[34]=j,t[35]=G):G=t[35];let K;t[36]===G?K=t[37]:(K=(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:G}),t[36]=G,t[37]=K);let q;t[38]!==u||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==b||t[47]!==O||t[48]!==a||t[49]!==o||t[50]!==s||t[51]!==n||t[52]!==k?(q=b?(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:O===`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)(D,{to:`/apps?tab=builtin`,onClick:a,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:()=>{k&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),o(n,k).catch(ie).finally(()=>d(!1)))},className:R(`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)(F,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,k?r.marketplaceReinstall:r.marketplaceInstall]}),k?(0,Y.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),s(n).then(()=>a()).catch(re).finally(()=>d(!1)))},className:R(`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)(f,{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]=b,t[47]=O,t[48]=a,t[49]=o,t[50]=s,t[51]=n,t[52]=k,t[53]=q):q=t[53];let J;t[54]!==W||t[55]!==K||t[56]!==q?(J=(0,Y.jsxs)(_,{children:[P,(0,Y.jsxs)(p,{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:ae,children:[W,K,q]})]}),t[54]=W,t[55]=K,t[56]=q,t[57]=J):J=t[57];let Z;return t[58]!==J||t[59]!==N?(Z=(0,Y.jsx)(h,{defaultOpen:!0,onOpenChange:N,children:J}),t[58]=J,t[59]=N,t[60]=Z):Z=t[60],Z}function re(){}function ie(){}function ae(e){return e.preventDefault()}function oe(e){return!!e.token}function se(){let e=i(e=>e.language),t=a(e),n=C(e=>e.setPageHeader),r=C(e=>e.clearPageHeader),o=O(),s=z(),[c,l]=j(),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)(()=>o.filter(e=>e.source===`bundled`),[o]),x=(0,H.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),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=o.find(t=>t.id===e.id);return t?Q(e)===Q(t)&&e.active===t.active?e:t:null})},[o]),(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.appsPage.title})}),end:null}),()=>r()),[r,t.appsPage.title,n]),s&&f!==`marketplace`)return(0,Y.jsx)(pe,{});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:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,Y.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-x-1 gap-y-1`,role:`tablist`,"aria-label":t.appsPage.appsNavAria,children:[(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`marketplace`,className:R(`relative max-w-full rounded-md px-3 py-2 text-left text-sm font-medium transition-colors sm:text-center`,f===`marketplace`?`text-fg`:`text-fg-muted hover:text-fg`,f===`marketplace`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`marketplace`),children:t.appsPage.tabMarketplace}),(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`builtin`,className:R(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`builtin`?`text-fg`:`text-fg-muted hover:text-fg`,f===`builtin`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`builtin`),children:[t.appsPage.tabBuiltin,(0,Y.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,b.length,`)`]})]}),(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`user`,className:R(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`user`?`text-fg`:`text-fg-muted hover:text-fg`,f===`user`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`user`),children:[t.appsPage.tabUser,(0,Y.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,x.length,`)`]})]})]}),T?(0,Y.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,Y.jsx)(E,{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.appsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),f===`marketplace`?(0,Y.jsx)(te,{}):f===`builtin`&&b.length===0?(0,Y.jsx)(he,{message:t.appsPage.emptyBuiltin}):f===`user`&&x.length===0?(0,Y.jsx)(he,{message:t.appsPage.emptyUser}):w.length===0?(0,Y.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-hover/30 px-4 py-8 text-center text-sm text-fg-muted dark:bg-surface-hover/15`,children:t.appsPage.noSearchResults}):(0,Y.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:w.map(e=>(0,Y.jsx)(de,{extension:e,copy:t.appsPage,showSourceBadge:f===`user`,onOpen:()=>_(e)},e.id))})]}),g?(0,Y.jsx)(fe,{extension:g,copy:t.appsPage,onClose:()=>_(null)},g.id):null]})}function Q(e){return e.activationEligible??e.active}function ce(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function le(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function ue(e,t){let n=Q(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function de(e){let t=(0,U.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,o;t[0]===n?o=t[1]:(o=Q(n),t[0]=n,t[1]=o);let s=o,c=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=R(`group flex w-full flex-col rounded-xl border border-edge bg-surface-base p-4 text-left shadow-sm transition-colors`,`hover:border-edge-subtle 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]=l):l=t[2];let u=n.name||n.id,d;t[3]===u?d=t[4]:(d=u.charAt(0).toUpperCase(),t[3]=u,t[4]=d);let f;t[5]===d?f=t[6]:(f=(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:d}),t[5]=d,t[6]=f);let p;t[7]===n.name?p=t[8]:(p=(0,Y.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=p);let m;t[9]===n.version?m=t[10]:(m=n.version?(0,Y.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=m);let h;t[11]!==p||t[12]!==m?(h=(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==r.statusEnabled||t[15]!==s?(g=s?(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)(b,{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)(A,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=s,t[16]=g):g=t[16];let _;t[17]!==h||t[18]!==g?(_=(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[h,g]}),t[17]=h,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==r.cardNoDescription||t[21]!==n.description?(v=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=v):v=t[22];let y;t[23]===v?y=t[24]:(y=(0,Y.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:v}),t[23]=v,t[24]=y);let x=n.hasUi?r.badgeKindUi:r.badgeKindBackend,S;t[25]!==x||t[26]!==c?(S=(0,Y.jsx)(`span`,{title:c,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]=c,t[27]=S):S=t[27];let C;t[28]!==r||t[29]!==n||t[30]!==i?(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}):i?(0,Y.jsx)(`span`,{title:ce(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:le(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,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 T;t[35]!==_||t[36]!==y||t[37]!==w?(T=(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,y,w]}),t[35]=_,t[36]=y,t[37]=w,t[38]=T):T=t[38];let E;t[39]!==T||t[40]!==f?(E=(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[f,T]}),t[39]=T,t[40]=f,t[41]=E):E=t[41];let D;return t[42]!==a||t[43]!==E?(D=(0,Y.jsx)(`button`,{type:`button`,onClick:a,className:l,children:E}),t[42]=a,t[43]=E,t[44]=D):D=t[44],D}function fe({extension:e,copy:t,onClose:n}){let{mutate:r}=s(),[i,a]=(0,H.useState)(!1),[o,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),d=e.activationEligible===!0,f=(0,H.useCallback)(async()=>{if(e.source===`bundled`){c(null),u(!1),a(!0);try{let{requiresGatewayRestart:t}=await q({extensionId:e.id,enabled:!d});await r(`gateway-extensions-list`),g(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{a(!1)}}},[d,t.builtinToggleFailed,e.id,e.source,r]),m=e.ui?.contributions?.pages??[],y=e.ui?.contributions?.settingsPanels??[],b=e.ui?.contributions?.chatWidgets??[],S=e.ui?.contributions?.sidebarPanels??[],C=m.find(e=>e.showInNav)??m[0],E=y[0],O=C?P(e.id,C):null,A=E?`/settings/ext/${e.id}/${E.id}`:e.hasConfigSchema||V(e)?`/settings/ext/${e.id}`:null;return(0,Y.jsx)(h,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,Y.jsxs)(_,{children:[(0,Y.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,Y.jsxs)(p,{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)(T,{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)(M,{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,` `,ce(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:ue(e,t)}),e.source===`bundled`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,Y.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-hover/40 p-3 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)(I,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void f(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(F,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):d?t.builtinToggleDisable:t.builtinToggleEnable})]}),o?(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:o}):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 border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(m.length>0||y.length>0||b.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:m.length,hidden:m.length===0}),(0,Y.jsx)($,{template:t.badgeSettings,count:y.length,hidden:y.length===0}),(0,Y.jsx)($,{template:t.badgeWidgets,count:b.length,hidden:b.length===0}),(0,Y.jsx)($,{template:t.badgeSidebar,count:S.length,hidden:S.length===0})]})]}):null,k(e)&&(O||A)?(0,Y.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[O?(0,Y.jsxs)(D,{to:O,onClick:n,className:R(`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)(L,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,A?(0,Y.jsxs)(D,{to:A,onClick:n,className:R(`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)(v,{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 pe(){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:`mx-auto w-full max-w-app-main px-4 py-8`,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(me)})]})}),e[4]=a):a=e[4],a}function me(e){return(0,Y.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge bg-surface-base`},e)}function he(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-dashed border-edge-subtle bg-surface-hover/40 px-4 py-12 text-center dark:bg-surface-hover/20`,children:(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{se as AppsPage};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-DPEStU4M.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{t as c}from"./circle-check-C23XjkUj.js";import{a as l,n as u,t as d}from"./fetch-CkvRO30i.js";import{$o as f,Cr as p,Dr as m,Er as h,Ki as g,Ni as _,Or as v,Qo as y,Rr as b,Sn as x,Sr as S,Tr as C,aa as w,an as T,ei as E,fi as D,hr as O,in as k,k as A,ka as j,li as M,lo as N,na as P,rn as F,ui as I,wr as L,xn as R}from"./index-50FVtgXU.js";import{t as z}from"./schema-form-BvmGNxiJ.js";import{t as B}from"./browser-BLJWD7WI.js";var V=n(),H=e(B(),1),U=e(t(),1),W=r();function ee(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}async function G(e){let t=await d(o(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function te(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function ne(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function re({entry:e,locale:t,messages:n,onChanged:r,autoStartPrimary:i=!1,compact:a=!1}){let o=(0,U.useMemo)(()=>ee(e),[e]),s=(0,U.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[l,u]=(0,U.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,U.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,U.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await G({channelId:e.id,actionId:n,locale:t,input:i});u(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,U.useEffect)(()=>{!i||!o||o[1].result!==`qr`||l.payload||l.busy||l.error||d(o[0])},[i,o,d,l.busy,l.error,l.payload]),(0,U.useEffect)(()=>{let t=q(l.payload,e.id);if(!t){u(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return u(e=>e.generatedQr?{...e,generatedQr:null}:e),H.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,l.payload]),(0,U.useEffect)(()=>{let n=l.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||G({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:te(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),te(e)&&window.clearInterval(a))}).catch(e=>{i||u(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,l.poll]);let f=o?.[1].label??(e.configured?n.reconnect:n.connect),p=e.actions?.[`doctor.run`]?.label??n.diagnose,m=K(l.payload),h=q(l.payload,e.id),g=h?l.generatedQr:ne(l.payload),v=l.payload?.type===`form`?l.payload:null,y=l.payload?.type===`diagnostics`?l.payload.checks:null;return(0,W.jsxs)(`div`,{className:a?`space-y-3`:`rounded-lg border border-edge-subtle bg-surface-panel p-4`,children:[(0,W.jsxs)(`div`,{className:I(`flex flex-wrap items-start gap-3`,a?`justify-end`:`justify-between`),children:[a?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?(0,W.jsxs)(M,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(o[0]),children:[l.busy?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(w,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(M,{type:`button`,variant:`secondary`,disabled:l.busy,onClick:()=>void d(`doctor.run`),children:[(0,W.jsx)(_,{className:`size-4`}),p]}):null]})]}),m?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:m}):null,l.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:l.error}):null,g?(0,W.jsxs)(`div`,{className:I(`flex flex-wrap items-start gap-4`,a?`justify-center`:`mt-4`),children:[(0,W.jsx)(`div`,{className:`rounded-lg border border-edge bg-white p-3`,children:(0,W.jsx)(`img`,{src:g,alt:`${e.label} setup QR`,className:`h-52 w-52 object-contain`})}),(0,W.jsxs)(`div`,{className:I(`max-w-sm text-sm text-fg-muted`,a&&`w-full text-center`),children:[(0,W.jsx)(`p`,{children:n.waitingConfirmation}),h?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:h,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(N,{className:`size-3.5`})]}):null]})]}):null,l.payload?.type===`poll`&&l.payload.phase===`done`?(0,W.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-sm`,children:[(0,W.jsx)(c,{className:l.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.jsx)(`span`,{className:l.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:l.payload.message??(l.payload.ok?n.complete:n.failed)})]}):null,v?(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(z,{schema:v.schema,values:l.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:l.busy,labels:s}),(0,W.jsx)(M,{type:`button`,variant:`primary`,disabled:l.busy,onClick:()=>void d(v.submitAction,l.formDraft),children:n.saveSetup})]}):null,y?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:y.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}function ie(e,t=!1){return e===`drawer`?I(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,R):I(`fixed left-1/2 top-1/2 flex max-h-[min(90vh,52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`max-h-[min(90vh,48rem)] w-[min(calc(100%-2rem),36rem)]`,R,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function ae(e){let t=(0,V.c)(30),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:u,footer:d,wide:f,headerExtra:g}=e,_=f===void 0?!1:f,y=n===`drawer`,b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,W.jsx)(C,{className:I(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,x)}),t[0]=b):b=t[0];let w;t[1]!==n||t[2]!==_?(w=ie(n,_),t[1]=n,t[2]=_,t[3]=w):w=t[3];let T;t[4]===s?T=t[5]:(T=s?(0,W.jsx)(v,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=T);let O;t[6]===c?O=t[7]:(O=c?(0,W.jsx)(L,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=O);let k;t[8]!==l||t[9]!==o||t[10]!==g||t[11]!==y||t[12]!==a?(k=y?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,W.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,W.jsx)(S,{asChild:!0,children:(0,W.jsx)(M,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,W.jsx)(D,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(S,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:I(E,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,W.jsx)(D,{className:`size-4`})})}),g]}),t[8]=l,t[9]=o,t[10]=g,t[11]=y,t[12]=a,t[13]=k):k=t[13];let A=y?`px-4 py-4`:`p-6`,j;t[14]===A?j=t[15]:(j=I(`min-h-0 flex-1 overflow-y-auto`,A),t[14]=A,t[15]=j);let N;t[16]!==u||t[17]!==j?(N=(0,W.jsx)(`div`,{className:j,children:u}),t[16]=u,t[17]=j,t[18]=N):N=t[18];let P;t[19]!==d||t[20]!==w||t[21]!==T||t[22]!==O||t[23]!==k||t[24]!==N?(P=(0,W.jsxs)(h,{children:[b,(0,W.jsxs)(p,{className:w,onOpenAutoFocus:J,children:[T,O,k,N,d]})]}),t[19]=d,t[20]=w,t[21]=T,t[22]=O,t[23]=k,t[24]=N,t[25]=P):P=t[25];let F;return t[26]!==i||t[27]!==r||t[28]!==P?(F=(0,W.jsx)(m,{open:r,onOpenChange:i,children:P}),t[26]=i,t[27]=r,t[28]=P,t[29]=F):F=t[29],F}function J(e){return e.preventDefault()}var oe=(0,U.memo)(function(e){let t=(0,V.c)(15),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,W.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s=n.refresh,c=n.refresh,l=r&&`animate-spin`,u;t[3]===l?u=t[4]:(u=I(`size-4`,l),t[3]=l,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,W.jsx)(P,{className:u,"aria-hidden":!0}),t[5]=u,t[6]=d);let f;t[7]!==n.refresh||t[8]!==a||t[9]!==r||t[10]!==d?(f=(0,W.jsx)(M,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:s,"aria-label":c,onClick:a,children:d}),t[7]=n.refresh,t[8]=a,t[9]=r,t[10]=d,t[11]=f):f=t[11];let p;return t[12]!==o||t[13]!==f?(p=(0,W.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,f]}),t[12]=o,t[13]=f,t[14]=p):p=t[14],p});function se(e){let t=(0,V.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,W.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,W.jsx)(M,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,W.jsx)(M,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,W.jsx)(M,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,W.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function Y(e){return o(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function X(e){return(await u(Y(e))).payload?.channels??[]}function ce(e,t){let n=(0,V.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Y(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>X(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:c,isLoading:l,isValidating:u,mutate:d}=s(r,i,a),f;n[6]===o?f=n[7]:(f=o??[],n[6]=o,n[7]=f);let p;return n[8]!==c||n[9]!==l||n[10]!==u||n[11]!==d||n[12]!==f?(p={entries:f,isLoading:l,isValidating:u,error:c,mutate:d},n[8]=c,n[9]=l,n[10]=u,n[11]=d,n[12]=f,n[13]=p):p=n[13],p}function le(e){return e?o(`/api/channels/${encodeURIComponent(e)}/config`):null}async function ue(e){return(await u(o(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}async function de(){return(await u(o(`/api/config`))).payload?.config?.channels??{}}function Z(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function fe(e,t){return e.enabled&&e.runtime===`loaded`?t.hubStatusRunning:e.enabled?t.hubStatusEnabled:e.configured?t.hubStatusConfigured:t.hubStatusNotConfigured}function pe(e){return e.enabled&&e.runtime===`loaded`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e.enabled||e.configured?`bg-accent-soft text-accent`:`bg-surface-hover text-fg-muted`}function me(e){if(!e)return[`enabled`];let t=e.uiHints??{},n=Object.entries(t).filter(([,e])=>!Q(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e);return n.length>0?n:[`enabled`]}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function he(e,t){let n={...$(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Q(r)||!Q(r[n]))break;let o=Q(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...$(r[n]),properties:{}}),e===t.length-1){o[n]=$(r[n]);break}i=r[n],a=o[n]}}return n}function ge(e){let t=e.properties;if(!Q(t))return!1;for(let[e,n]of Object.entries(t))Q(n)&&n.type===`object`&&ge(n)&&delete t[e];return Object.keys(t).length===0}function _e(e,t){let n=$(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Q(i))break;if(e===t.length-1){delete i[n];break}if(!Q(i[n]))break;r=i[n]}}return ge(n),n}function ve(e){return e.type===`object`&&Q(e.properties)&&Object.keys(e.properties).length>0}function ye(e,t){let n=e;for(let e of t.split(`.`)){if(!Q(n))return;n=n[e]}return n}function be(e){let t=e.accounts;return Q(t)?Object.values(t).filter(e=>Q(e)&&e.enabled!==!1).length:+(e.configured===!0)}function xe(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Se(e,t,n){let r=[];if(t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=xe(e,ye(t,e),n);i&&r.push(i)}let a=be(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,3):e.configured?[n.hubStatusConfigured]:[]}function Ce(e,t){let n=ee(e);return n?.[1].label?n[1].label:e.configured?t.manageChannel:t.startConfiguration}function we({entry:e}){let t=l(e=>e.token),[n,r]=(0,U.useState)(!1),i=(0,U.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(o(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Z(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,W.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,W.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,W.jsx)(O,{sourceChannel:e.id,className:`size-7`})})}function Te(e){let t=(0,V.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=I(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=I(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,W.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function Ee(e){let t=(0,V.c)(64),{entry:n,config:r,busy:i,ch:a,onOpen:o,onToggle:s}=e,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==a||t[2]!==r||t[3]!==n||t[4]!==o||t[5]!==s){let e=Se(n,r,a);p=`flex min-h-[15.5rem] flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-surface transition-colors hover:border-edge`;let h;t[13]===n?h=t[14]:(h=(0,W.jsx)(we,{entry:n}),t[13]=n,t[14]=h);let g;t[15]===n.label?g=t[16]:(g=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[15]=n.label,t[16]=g);let _;t[17]===n?_=t[18]:(_=I(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,pe(n)),t[17]=n,t[18]=_);let v;t[19]!==a||t[20]!==n?(v=fe(n,a),t[19]=a,t[20]=n,t[21]=v):v=t[21];let y;t[22]!==_||t[23]!==v?(y=(0,W.jsx)(`span`,{className:_,children:v}),t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==g?(b=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[g,y]}),t[25]=y,t[26]=g,t[27]=b):b=t[27];let x;t[28]!==b||t[29]!==h?(x=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,b]}),t[28]=b,t[29]=h,t[30]=x):x=t[30];let S=n.enabled===!0,C;t[31]!==a.toggleChannel||t[32]!==n.label?(C=a.toggleChannel.replace(`{{channel}}`,n.label),t[31]=a.toggleChannel,t[32]=n.label,t[33]=C):C=t[33];let w;t[34]!==i||t[35]!==s||t[36]!==S||t[37]!==C?(w=(0,W.jsx)(Te,{checked:S,disabled:i,label:C,onToggle:s}),t[34]=i,t[35]=s,t[36]=S,t[37]=C,t[38]=w):w=t[38],t[39]!==x||t[40]!==w?(m=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[x,w]}),t[39]=x,t[40]=w,t[41]=m):m=t[41],c=`button`,l=o,u=`mt-5 min-h-[4.5rem] text-left`;let T=n.description??n.id;t[42]===T?d=t[43]:(d=(0,W.jsx)(`p`,{className:`line-clamp-3 text-sm leading-6 text-fg-muted`,children:T}),t[42]=T,t[43]=d),f=e.length>0?(0,W.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(De)}):null,t[0]=i,t[1]=a,t[2]=r,t[3]=n,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=m}else c=t[6],l=t[7],u=t[8],d=t[9],f=t[10],p=t[11],m=t[12];let h;t[44]!==c||t[45]!==l||t[46]!==u||t[47]!==d||t[48]!==f?(h=(0,W.jsxs)(`button`,{type:c,onClick:l,className:u,children:[d,f]}),t[44]=c,t[45]=l,t[46]=u,t[47]=d,t[48]=f,t[49]=h):h=t[49];let g;t[50]===i?g=t[51]:(g=i?(0,W.jsx)(j,{className:`size-4 animate-spin`}):null,t[50]=i,t[51]=g);let _;t[52]!==a||t[53]!==n?(_=Ce(n,a),t[52]=a,t[53]=n,t[54]=_):_=t[54];let v;t[55]!==o||t[56]!==_||t[57]!==g?(v=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(M,{type:`button`,variant:`primary`,className:`w-full rounded-2xl py-2.5`,onClick:o,children:[g,_]})}),t[55]=o,t[56]=_,t[57]=g,t[58]=v):v=t[58];let y;return t[59]!==v||t[60]!==p||t[61]!==m||t[62]!==h?(y=(0,W.jsxs)(`article`,{className:p,children:[m,h,v]}),t[59]=v,t[60]=p,t[61]=m,t[62]=h,t[63]=y):y=t[63],y}function De(e){return(0,W.jsx)(`p`,{children:e},e)}function Oe(){let e=i(e=>e.language),t=a(e),n=l(e=>!!e.token),r=y(),{channelId:c}=f(),u=T(c),p=ce(n,e),m=p.entries,{data:h={},mutate:_}=s(n?`channels-config-map`:null,de,{revalidateOnFocus:!1}),v=b(e=>e.setPageHeader),x=b(e=>e.clearPageHeader),S=(0,U.useMemo)(()=>m.find(e=>e.id===u),[u,m]),{data:C,mutate:w}=s(n&&S?le(S.id):null,()=>ue(S.id)),[E,D]=(0,U.useState)(null),[O,j]=(0,U.useState)(!1),[M,P]=(0,U.useState)(null),[L,R]=(0,U.useState)(null),B=E??C??{},V=t.channelsSettings,H=(0,U.useMemo)(()=>S?.configSchema??{type:`object`,properties:{}},[S?.configSchema]),G=(0,U.useMemo)(()=>me(S),[S]),te=(0,U.useMemo)(()=>he(H,G),[G,H]),K=(0,U.useMemo)(()=>_e(H,G),[G,H]),q=(0,U.useMemo)(()=>({defaultBooleanLabel:V.schemaBooleanDefault,unsupportedArrayType:V.schemaUnsupportedArrayType,arrayAddPlaceholder:V.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>V.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[V]),ne=(0,U.useMemo)(()=>n?(0,W.jsx)(oe,{ch:V,refreshing:p.isValidating,saveOk:!1,onRefresh:()=>void p.mutate()}):null,[p,V,n]);(0,U.useLayoutEffect)(()=>(v({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:ne}),()=>x()),[x,ne,t.settingsSections.channels,v]);let ie=(0,U.useCallback)(e=>{r(k(e)),D(null),R(null)},[r]),J=(0,U.useCallback)(()=>{r(F),D(null),R(null)},[r]),Y=(0,U.useCallback)(async()=>{if(!S||!E)return!1;j(!0),R(null);try{let e=await d(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[S.id]:E}})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error?.message??e.statusText)}return await w(E,!1),await _(),await p.mutate(),D(null),!0}catch(e){return R(e instanceof Error?e.message:String(e)),!1}finally{j(!1)}},[S,p,E,_,w]),X=(0,U.useCallback)(async e=>{P(e.id),R(null);try{let t=await d(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[e.id]:{enabled:e.enabled!==!0}}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await p.mutate(),await _(),S?.id===e.id&&await w()}catch(e){R(e instanceof Error?e.message:String(e))}finally{P(null)}},[S?.id,p,_,w]),Z=S?.ui?.modal,Q=Z?.placement!==`replace-config`;return n?(0,W.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-6`,children:[p.isLoading?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:V.loadingChannels}):p.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(p.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:m.map(e=>(0,W.jsx)(Ee,{entry:e,config:h[e.id]?.config,busy:M===e.id,ch:V,onOpen:()=>ie(e.id),onToggle:()=>void X(e)},e.id))}),L?(0,W.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:L}):null,(0,W.jsx)(ae,{presentation:`modal`,open:!!S,onOpenChange:e=>{e||J()},closeAriaLabel:V.close,srTitle:S?.label??V.selectChannel,srDescription:S?.description,wide:!0,footer:S?(0,W.jsx)(se,{ch:V,dirty:!!E,saving:O,onCancel:J,onDiscard:()=>D(null),onSave:Y}):null,children:S?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-3`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,W.jsx)(we,{entry:S}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:S.label}),(0,W.jsx)(`span`,{className:I(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,pe(S)),children:fe(S,V)})]}),(0,W.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate`,children:ee(S)?.[1].result===`qr`?V.scanLoginHint.replace(`{{channel}}`,S.label):S.description}),S.docsPath?(0,W.jsxs)(`a`,{href:S.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[V.docs,(0,W.jsx)(N,{className:`size-3.5`})]}):null]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,W.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:V.enabledLabel}),(0,W.jsx)(Te,{checked:S.enabled===!0,disabled:M===S.id,label:V.toggleChannel.replace(`{{channel}}`,S.label),onToggle:()=>void X(S)})]})]})}),Z?.entrypoint&&Z.placement===`before-config`?(0,W.jsx)(A,{extensionId:S.extensionId,extensionName:S.label,entrypoint:Z.entrypoint,permissions:Z.permissions,minHeight:Z.minHeight,maxHeight:Z.maxHeight,initialData:{channelId:S.id,entry:S,config:B}}):null,Z?.placement===`replace-config`?null:(0,W.jsx)(re,{entry:S,locale:e,messages:V,autoStartPrimary:!0,compact:!0,onChanged:async()=>{await w(),await p.mutate(),await _()}},S.id),Z?.entrypoint&&Z.placement!==`before-config`?(0,W.jsx)(A,{extensionId:S.extensionId,extensionName:S.label,entrypoint:Z.entrypoint,permissions:Z.permissions,minHeight:Z.minHeight,maxHeight:Z.maxHeight,initialData:{channelId:S.id,entry:S,config:B}}):null,Q?(0,W.jsxs)(`section`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:V.basicConfiguration}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:V.basicConfigurationHint})]}),(0,W.jsx)(z,{schema:te,values:B,onChange:e=>D(e),disabled:O,labels:q})]}):null,Q&&ve(K)?(0,W.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(g,{className:`size-4 text-fg-muted`}),V.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`border-t border-edge-subtle p-4`,children:(0,W.jsx)(z,{schema:K,values:B,onChange:e=>D(e),disabled:O,labels:q})})]}):null,L?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:L}):null]}):null})]}):(0,W.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:V.tokenRequired})})}export{Oe as ChannelsSettingsPanel};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-DPEStU4M.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{i as l}from"./theme-store-DYgVdRB4.js";import{a as u,n as d}from"./fetch-CkvRO30i.js";import{i as f,n as p,r as m}from"./gateway-startup-retry-BkKyRDrF.js";import{Ao as h,Br as g,C as _,Ci as v,Cr as y,Dr as b,Er as x,F as S,Ga as C,I as w,Ii as T,In as E,Ki as D,L as O,Ln as k,Mo as A,No as j,Or as M,P as N,Po as P,Ra as F,Rr as I,Sr as L,Tr as R,Yi as z,Yo as B,Zr as V,ai as H,ca as U,ci as W,co as G,do as K,es as ee,fi as te,ii as q,j as ne,ka as re,kt as ie,li as J,mr as Y,na as ae,o as oe,pr as se,si as ce,ti as le,to as ue,ua as de,ui as X,ur as fe,wa as pe,wr as me,xr as he,yo as ge}from"./index-50FVtgXU.js";import{n as _e,t as ve}from"./settings-form-section-BlIYg2gZ.js";import{C as ye,E as be,S as xe,T as Se,_ as Ce,a as we,b as Te,c as Ee,d as De,f as Oe,g as ke,h as Ae,l as je,m as Me,n as Ne,o as Pe,p as Fe,r as Ie,s as Le,t as Re,u as ze,v as Be,w as Ve,x as He,y as Ue}from"./settings-advanced-gate-DRdayl8P.js";import{s as We,t as Ge}from"./heartbeat-config-api-CRiDcxtt.js";import{m as Ke,p as qe,t as Je}from"./workflow-page.utils-_sjXCMvi.js";import{i as Ye,n as Xe,o as Ze,r as Qe,t as $e}from"./dist-DJDkNhu5.js";var Z=e(t(),1),Q=n(),$=r();function et(e){let t=(0,Q.c)(25),{open:n,onOpenChange:r,action:i,c:a,onDismiss:o,onConfirm:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim`}),t[0]=c):c=t[0];let l=i===`delete`?a.delete:a.runNow,u;t[1]===l?u=t[2]:(u=(0,$.jsx)(M,{className:`text-base font-semibold text-fg`,children:l}),t[1]=l,t[2]=u);let d=i===`delete`?a.confirmDelete:a.confirmRun,f;t[3]===d?f=t[4]:(f=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:d}),t[3]=d,t[4]=f);let p;t[5]!==a.cancel||t[6]!==o?(p=(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:o,children:a.cancel}),t[5]=a.cancel,t[6]=o,t[7]=p):p=t[7];let m=i===`delete`?`bg-red-600 hover:bg-red-700`:void 0,h;t[8]===s?h=t[9]:(h=()=>void s(),t[8]=s,t[9]=h);let g=i===`delete`?a.delete:a.runNow,_;t[10]!==m||t[11]!==h||t[12]!==g?(_=(0,$.jsx)(J,{type:`button`,variant:`primary`,className:m,onClick:h,children:g}),t[10]=m,t[11]=h,t[12]=g,t[13]=_):_=t[13];let v;t[14]!==_||t[15]!==p?(v=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[p,_]}),t[14]=_,t[15]=p,t[16]=v):v=t[16];let S;t[17]!==v||t[18]!==u||t[19]!==f?(S=(0,$.jsxs)(x,{children:[c,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(y,{className:`xopc-dialog-content-pane pointer-events-auto relative w-full max-w-md rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,children:[u,f,v]})})]}),t[17]=v,t[18]=u,t[19]=f,t[20]=S):S=t[20];let C;return t[21]!==r||t[22]!==n||t[23]!==S?(C=(0,$.jsx)(b,{open:n,onOpenChange:r,children:S}),t[21]=r,t[22]=n,t[23]=S,t[24]=C):C=t[24],C}var tt={enabled:!0,maxConcurrentJobs:5,defaultTimezone:`UTC`,historyRetentionDays:7,enableMetrics:!0};function nt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rt(e){let t=nt(e)?e:{},n=nt(t.cron)?t.cron:{};return{enabled:n.enabled!==!1,maxConcurrentJobs:typeof n.maxConcurrentJobs==`number`&&Number.isFinite(n.maxConcurrentJobs)?Math.max(1,Math.min(100,Math.floor(n.maxConcurrentJobs))):tt.maxConcurrentJobs,defaultTimezone:typeof n.defaultTimezone==`string`&&n.defaultTimezone.trim()?n.defaultTimezone.trim():tt.defaultTimezone,historyRetentionDays:typeof n.historyRetentionDays==`number`&&Number.isFinite(n.historyRetentionDays)?Math.max(1,Math.min(365,Math.floor(n.historyRetentionDays))):tt.historyRetentionDays,enableMetrics:n.enableMetrics!==!1}}async function it(e){await d(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({cron:e})}),m()}function at(){return X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,W,`dark:border-edge`)}function ot(){return{form:null,baseline:null,saving:!1,error:null,saveOk:!1,dirty:!1}}function st(e,t){switch(t.type){case`sync`:return{...e,form:structuredClone(t.parsed),baseline:structuredClone(t.parsed),saveOk:!1,dirty:!1};case`patch`:return e.form?{...e,form:{...e.form,...t.patch},dirty:!0,saveOk:!1}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline),dirty:!1}:e;case`saveStart`:return{...e,saving:!0,error:null};case`saveSuccess`:return e.form?{...e,saving:!1,baseline:structuredClone(e.form),dirty:!1,saveOk:!0}:{...e,saving:!1};case`saveError`:return{...e,saving:!1,error:t.error};case`clearSaveOk`:return{...e,saveOk:!1}}}function ct(e){let t=(0,Q.c)(83),{hasToken:n}=e,r=i(lt),o;t[0]===r?o=t[1]:(o=a(r),t[0]=r,t[1]=o);let s=o.cron.globals,{data:c,isLoading:l}=f(n),u;t[2]===c?u=t[3]:(u=c?.payload?.config===void 0?null:structuredClone(rt(c.payload.config)),t[2]=c,t[3]=u);let d=u,[p,m]=(0,Z.useReducer)(st,void 0,ot),h=(0,Z.useRef)(null),g,_;t[4]!==n||t[5]!==d||t[6]!==p.dirty?(g=()=>{!n||d===null||p.dirty||h.current===d||(h.current=d,m({type:`sync`,parsed:d}))},_=[n,d,p.dirty],t[4]=n,t[5]=d,t[6]=p.dirty,t[7]=g,t[8]=_):(g=t[7],_=t[8]),(0,Z.useEffect)(g,_);let v;t[9]!==p.baseline||t[10]!==p.form?(v=p.form&&p.baseline&&JSON.stringify(p.form)!==JSON.stringify(p.baseline),t[9]=p.baseline,t[10]=p.form,t[11]=v):v=t[11];let y=!!v,b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{m({type:`patch`,patch:e})},t[12]=b):b=t[12];let x=b,S;t[13]!==s.saveError||t[14]!==p.form||t[15]!==p.saving?(S=async()=>{if(!(!p.form||p.saving)){m({type:`saveStart`});try{await it(p.form),m({type:`saveSuccess`}),window.setTimeout(()=>m({type:`clearSaveOk`}),2500)}catch(e){let t=e;m({type:`saveError`,error:t instanceof Error?t.message:s.saveError})}}},t[13]=s.saveError,t[14]=p.form,t[15]=p.saving,t[16]=S):S=t[16];let C=S;if(!n||!p.form){if(l){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(re,{className:`size-4 animate-spin`}),t[17]=e):e=t[17];let n;return t[18]===s.loading?n=t[19]:(n=(0,$.jsx)(ve,{children:(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[e,s.loading]})}),t[18]=s.loading,t[19]=n),n}return null}let w;t[20]!==s.hint||t[21]!==s.title?(w=(0,$.jsx)(_e,{icon:ge,title:s.title,subtitle:s.hint}),t[20]=s.hint,t[21]=s.title,t[22]=w):w=t[22];let T;t[23]!==s.saved||t[24]!==p.saveOk?(T=p.saveOk?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:s.saved}):null,t[23]=s.saved,t[24]=p.saveOk,t[25]=T):T=t[25];let E=!y||p.saving,D;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>m({type:`discard`}),t[26]=D):D=t[26];let O;t[27]!==s.discard||t[28]!==E?(O=(0,$.jsx)(J,{type:`button`,variant:`secondary`,disabled:E,onClick:D,children:s.discard}),t[27]=s.discard,t[28]=E,t[29]=O):O=t[29];let k=!y||p.saving,A;t[30]===C?A=t[31]:(A=()=>void C(),t[30]=C,t[31]=A);let j=p.saving?s.saving:s.save,M;t[32]!==k||t[33]!==A||t[34]!==j?(M=(0,$.jsx)(J,{type:`button`,variant:`primary`,disabled:k,onClick:A,children:j}),t[32]=k,t[33]=A,t[34]=j,t[35]=M):M=t[35];let N;t[36]!==O||t[37]!==M||t[38]!==T?(N=(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-end gap-2`,children:[T,O,M]}),t[36]=O,t[37]=M,t[38]=T,t[39]=N):N=t[39];let P;t[40]===p.error?P=t[41]:(P=p.error?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:p.error}):null,t[40]=p.error,t[41]=P);let F;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(F=e=>x({enabled:e.target.checked}),t[42]=F):F=t[42];let I;t[43]===p.form.enabled?I=t[44]:(I=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:p.form.enabled,onChange:F}),t[43]=p.form.enabled,t[44]=I);let L;t[45]!==s.enabled||t[46]!==I?(L=(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg sm:col-span-2`,children:[I,s.enabled]}),t[45]=s.enabled,t[46]=I,t[47]=L):L=t[47];let R=!p.form.enabled,z;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>x({maxConcurrentJobs:e}),t[48]=z):z=t[48];let B;t[49]!==s.maxConcurrent||t[50]!==R||t[51]!==p.form.maxConcurrentJobs?(B=(0,$.jsx)(ut,{label:s.maxConcurrent,value:p.form.maxConcurrentJobs,min:1,max:100,disabled:R,onChange:z}),t[49]=s.maxConcurrent,t[50]=R,t[51]=p.form.maxConcurrentJobs,t[52]=B):B=t[52];let V=!p.form.enabled,H;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>x({defaultTimezone:e}),t[53]=H):H=t[53];let U;t[54]!==s.timezone||t[55]!==V||t[56]!==p.form.defaultTimezone?(U=(0,$.jsx)(ut,{label:s.timezone,text:!0,value:p.form.defaultTimezone,disabled:V,onTextChange:H}),t[54]=s.timezone,t[55]=V,t[56]=p.form.defaultTimezone,t[57]=U):U=t[57];let W=!p.form.enabled,G;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>x({historyRetentionDays:e}),t[58]=G):G=t[58];let K;t[59]!==s.retentionDays||t[60]!==W||t[61]!==p.form.historyRetentionDays?(K=(0,$.jsx)(ut,{label:s.retentionDays,value:p.form.historyRetentionDays,min:1,max:365,disabled:W,onChange:G}),t[59]=s.retentionDays,t[60]=W,t[61]=p.form.historyRetentionDays,t[62]=K):K=t[62];let ee=!p.form.enabled,te;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>x({enableMetrics:e.target.checked}),t[63]=te):te=t[63];let q;t[64]!==ee||t[65]!==p.form.enableMetrics?(q=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:p.form.enableMetrics,disabled:ee,onChange:te}),t[64]=ee,t[65]=p.form.enableMetrics,t[66]=q):q=t[66];let ne;t[67]!==s.metrics||t[68]!==q?(ne=(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[q,s.metrics]}),t[67]=s.metrics,t[68]=q,t[69]=ne):ne=t[69];let ie;t[70]!==B||t[71]!==U||t[72]!==K||t[73]!==ne?(ie=(0,$.jsxs)(Re,{children:[B,U,K,ne]}),t[70]=B,t[71]=U,t[72]=K,t[73]=ne,t[74]=ie):ie=t[74];let Y;t[75]!==L||t[76]!==ie?(Y=(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[L,ie]}),t[75]=L,t[76]=ie,t[77]=Y):Y=t[77];let ae;return t[78]!==N||t[79]!==P||t[80]!==Y||t[81]!==w?(ae=(0,$.jsxs)(ve,{children:[w,N,P,Y]}),t[78]=N,t[79]=P,t[80]=Y,t[81]=w,t[82]=ae):ae=t[82],ae}function lt(e){return e.language}function ut(e){let t=(0,Q.c)(13),{label:n,value:r,min:i,max:a,disabled:o,text:s,onChange:c,onTextChange:l}=e,u;t[0]===n?u=t[1]:(u=(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==o||t[3]!==a||t[4]!==i||t[5]!==c||t[6]!==l||t[7]!==s||t[8]!==r?(d=s?(0,$.jsx)(`input`,{className:X(at(),`font-mono text-xs`),value:String(r),disabled:o,onChange:e=>l?.(e.target.value)}):(0,$.jsx)(`input`,{type:`number`,min:i,max:a,disabled:o,className:X(at(),`max-w-xs font-mono text-xs`),value:typeof r==`number`?r:0,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&c&&i!==void 0&&a!==void 0&&c(Math.max(i,Math.min(a,Math.floor(t))))}}),t[2]=o,t[3]=a,t[4]=i,t[5]=c,t[6]=l,t[7]=s,t[8]=r,t[9]=d):d=t[9];let f;return t[10]!==u||t[11]!==d?(f=(0,$.jsxs)(`div`,{children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12],f}var dt=`*/5 * * * *`,ft=2100*1e3;function pt(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function mt(e){let t=pt(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t}function ht(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function gt(e){let t=e?.trim();t&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:t},bubbles:!0}))}function _t(e){let t=e?.trim();t&&(window.location.hash=`/workflows?run=${encodeURIComponent(t)}`)}function vt(e){return X(`w-full rounded-md border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-disabled`,q,e&&`cursor-not-allowed opacity-60`)}function yt(){return X(ce,H)}var bt=X(ce,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`),xt=X(ce,`w-auto min-w-[9rem] max-w-[14rem] shrink-0 text-xs`);function St(e){return e===`settings`?`settings`:e===`system`||e===`systemTasks`?`systemTasks`:e===`history`?`history`:`myTasks`}function Ct(e){return e===`myTasks`?null:e===`systemTasks`?`system`:e===`history`?`history`:`settings`}function wt(e){switch(e){case`success`:return`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`;case`failed`:return`bg-red-500/15 text-red-800 dark:text-red-300`;case`running`:return`bg-accent/15 text-accent`;case`cancelled`:return`bg-surface-hover text-fg-muted`;default:return`bg-surface-hover text-fg-muted`}}function Tt(e,t){return e.payload.kind===`workflowRun`?t.taskKindWorkflowRun:e.payload.kind===`agentTurn`?t.taskKindMessage:t.modeDirectOption}function Et(e){return e.length===0?null:e.find(e=>e.status===`failed`)?.id??e[0]?.id??null}function Dt(e){let t=(0,Q.c)(56),{row:n,expanded:r,onToggle:i,c:a,statusLabels:o}=e,s=n.error||n.summary||n.output||``,c;t[0]===s?c=t[1]:(c=s.trim(),t[0]=s,t[1]=c);let l=c,u=l.length>0,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`div`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover`,children:(0,$.jsx)(ge,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0})}),t[2]=d):d=t[2];let f=n.startedAt,p;t[3]===n.startedAt?p=t[4]:(p=Se(n.startedAt),t[3]=n.startedAt,t[4]=p);let m;t[5]!==n.startedAt||t[6]!==p?(m=(0,$.jsx)(`time`,{className:`text-sm font-medium text-fg`,dateTime:f,children:p}),t[5]=n.startedAt,t[6]=p,t[7]=m):m=t[7];let h;t[8]===n.status?h=t[9]:(h=X(`inline-flex rounded-md px-2 py-0.5 text-xs font-medium`,wt(n.status)),t[8]=n.status,t[9]=h);let g;t[10]!==n.status||t[11]!==o?(g=Ue(n.status,o),t[10]=n.status,t[11]=o,t[12]=g):g=t[12];let _;t[13]!==h||t[14]!==g?(_=(0,$.jsx)(`span`,{className:h,children:g}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===n.duration?v=t[17]:(v=He(n.duration),t[16]=n.duration,t[17]=v);let y;t[18]===v?y=t[19]:(y=(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:v}),t[18]=v,t[19]=y);let b;t[20]!==y||t[21]!==m||t[22]!==_?(b=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[m,_,y]}),t[20]=y,t[21]=m,t[22]=_,t[23]=b):b=t[23];let x;t[24]!==l||t[25]!==r||t[26]!==u?(x=!r&&u?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:l}):null,t[24]=l,t[25]=r,t[26]=u,t[27]=x):x=t[27];let S;t[28]!==l||t[29]!==r||t[30]!==u?(S=r&&u?(0,$.jsx)(`pre`,{className:`mt-2 max-h-40 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-edge-subtle bg-surface-panel/80 p-2.5 font-mono text-xs leading-relaxed text-fg-muted`,children:l}):null,t[28]=l,t[29]=r,t[30]=u,t[31]=S):S=t[31];let C;t[32]!==b||t[33]!==x||t[34]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-3`,children:[d,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x,S]})]}),t[32]=b,t[33]=x,t[34]=S,t[35]=C):C=t[35];let w;t[36]!==a||t[37]!==r||t[38]!==u||t[39]!==i?(w=u?(0,$.jsxs)(J,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:i,children:[(0,$.jsx)(A,{className:X(`size-3.5 transition-transform`,r&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0}),r?a.detailCollapseRun:a.detailExpandRun]}):null,t[36]=a,t[37]=r,t[38]=u,t[39]=i,t[40]=w):w=t[40];let T;t[41]!==a||t[42]!==n.workflowRunId?(T=n.workflowRunId?.trim()?(0,$.jsxs)(J,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,title:a.openWorkflowTitle,onClick:()=>_t(n.workflowRunId),children:[(0,$.jsx)(ue,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),a.openWorkflow]}):null,t[41]=a,t[42]=n.workflowRunId,t[43]=T):T=t[43];let E;t[44]!==a||t[45]!==n.sessionKey?(E=n.sessionKey?.trim()?(0,$.jsxs)(J,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,title:a.openChatTitle,onClick:()=>gt(n.sessionKey),children:[(0,$.jsx)(pe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),a.openChat]}):null,t[44]=a,t[45]=n.sessionKey,t[46]=E):E=t[46];let D;t[47]!==T||t[48]!==E?(D=(0,$.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[T,E]}),t[47]=T,t[48]=E,t[49]=D):D=t[49];let O;t[50]!==w||t[51]!==D?(O=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-edge-subtle px-3 py-2 dark:border-edge-subtle`,children:[w,D]}),t[50]=w,t[51]=D,t[52]=O):O=t[52];let k;return t[53]!==C||t[54]!==O?(k=(0,$.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:[C,O]}),t[53]=C,t[54]=O,t[55]=k):k=t[55],k}function Ot(e){let t=(0,Q.c)(13),{icon:n,label:r,value:i,valueClassName:a}=e,o;t[0]===n?o=t[1]:(o=(0,$.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=o);let s;t[2]!==r||t[3]!==o?(s=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:[o,r]}),t[2]=r,t[3]=o,t[4]=s):s=t[4];let c;t[5]===a?c=t[6]:(c=X(`mt-1 truncate text-sm font-medium text-fg`,a),t[5]=a,t[6]=c);let l;t[7]!==c||t[8]!==i?(l=(0,$.jsx)(`p`,{className:c,children:i}),t[7]=c,t[8]=i,t[9]=l):l=t[9];let u;return t[10]!==s||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-edge-subtle bg-surface-base/80 px-3 py-2.5 dark:border-edge-subtle`,children:[s,l]}),t[10]=s,t[11]=l,t[12]=u):u=t[12],u}function kt({open:e,onDismiss:t,detailJob:n,detailLoading:r,detailHistory:i,c:a,localeTag:o,scheduleBadgeLabels:s,chatWorkingDirNotSet:l,statusLabels:u,onEdit:d,onRunNow:f,onToggle:p,onDelete:m}){let[h,g]=(0,Z.useState)(!1),[_,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),T=(0,Z.useMemo)(()=>{let e=0,t=0;for(let n of i)n.status===`success`&&(e+=1),n.status===`failed`&&(t+=1);return{success:e,failed:t}},[i]),O=i[0]??null;(0,Z.useEffect)(()=>{if(!e){g(!1),S(null),w(!1);return}S(Et(i))},[e,n?.id,i]);let k=(0,Z.useCallback)(async()=>{n?.schedule&&await V(n.schedule)&&(w(!0),window.setTimeout(()=>w(!1),1500))},[n?.schedule]),N=n?Ve(n,o,s):`—`;return(0,$.jsx)(b,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(x,{children:[(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,$.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(y,{className:X(`xopc-dialog-content-pane pointer-events-auto relative flex w-full max-w-lg flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,`max-h-[min(85vh,44rem)]`,`dark:border-edge`),"aria-describedby":void 0,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(M,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n?.name?.trim()||n?.id||`—`}),n?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:N}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n?(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n.enabled,"aria-label":n.enabled?a.enabled:a.disabled,className:X(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,n.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`),onClick:()=>p(n,!n.enabled),children:(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})}):null,(0,$.jsx)(L,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":a.close,children:(0,$.jsx)(te,{className:`size-5`,strokeWidth:1.75})})})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:r?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,$.jsx)(re,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.scheduleLabel}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base/80 px-3 py-3 dark:border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 text-sm font-medium leading-relaxed text-fg`,children:N}),(0,$.jsx)(J,{type:`button`,variant:`secondary`,className:`size-8 shrink-0 p-0`,title:a.detailCopySchedule,"aria-label":a.detailCopySchedule,onClick:()=>void k(),children:C?(0,$.jsx)(j,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75}):(0,$.jsx)(c,{className:`size-3.5`,strokeWidth:1.75})})]}),(0,$.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg-subtle`,children:[a.detailCronTechnical,`: `]}),(0,$.jsx)(`code`,{className:`font-mono`,children:n.schedule})]})]})]}),(0,$.jsxs)(`section`,{"aria-label":a.statsRegion,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(Ot,{icon:P,label:a.nextRun,value:n.next_run?xe(n.next_run,a.timeLabels):`—`}),(0,$.jsx)(Ot,{icon:ge,label:a.detailLastRun,value:O?Ue(O.status,u):a.detailNoRecentRuns,valueClassName:O?.status===`failed`?`text-red-700 dark:text-red-300`:O?.status===`success`?`text-emerald-800 dark:text-emerald-300`:void 0})]}),i.length>0?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:a.detailRunCount.replace(`{{success}}`,String(T.success)).replace(`{{failed}}`,String(T.failed))}):null]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailWhatItDoes}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base/80 p-3 dark:border-edge-subtle`,children:[(0,$.jsx)(`div`,{className:`mb-2 inline-flex rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:Tt(n,a)}),(0,$.jsx)(`div`,{className:`min-w-0 break-words text-fg [&_.markdown-body]:text-sm [&_.markdown-body]:leading-relaxed`,children:(0,$.jsx)(E,{content:Pe(n),compact:!0,className:`text-sm`})})]})]}),(0,$.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base/35`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left`,"aria-expanded":h,onClick:()=>g(e=>!e),children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(D,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailRunSettings})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.detailRunSettingsHint})]}),(0,$.jsx)(A,{className:X(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,h&&`rotate-180`),"aria-hidden":!0})]}),h?(0,$.jsxs)(`dl`,{className:`grid gap-3 border-t border-edge px-4 py-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.mode}),(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:n.sessionTarget===`isolated`?a.modeAgentOption:a.modeDirectOption})]}),n.sessionTarget===`isolated`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),(0,$.jsx)(`dd`,{className:`mt-1 font-mono text-sm text-fg`,children:n.agentId?.trim()?n.agentId.trim():a.agentProfileDefault})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.workingDirectoryLabel}),(0,$.jsx)(`dd`,{className:`mt-1 break-all font-mono text-xs text-fg`,children:n.workingDirectory?.trim()?n.workingDirectory.trim():l})]})]}):null,n.delivery?.channel===`local`||n.sessionTarget===`isolated`&&!n.delivery?.to?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.deliveryTarget}),(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:n.delivery?.channel===`local`?a.deliveryTargetLocalChannel:a.deliveryLocalOnly})]}):n.delivery?.to?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.deliveryTarget}),(0,$.jsxs)(`dd`,{className:`mt-1 break-words text-fg`,children:[(0,$.jsx)(`code`,{className:`text-xs`,children:n.delivery?.channel??``}),` → `,Te(n,a.channelLocal)]})]}):null,n.model?.trim()?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.model}),(0,$.jsx)(`dd`,{className:`mt-1 font-mono text-sm text-fg`,children:n.model.trim()})]}):null]}):null]}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailRunHistory}),i.length>0?(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.length}):null]}),i.length===0?(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-dashed border-edge-subtle px-4 py-8 text-center dark:border-edge-subtle`,children:[(0,$.jsx)(ge,{className:`mx-auto size-8 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:a.noRunsYet})]}):(0,$.jsx)(`ul`,{className:`mt-2 space-y-2`,children:i.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(Dt,{row:e,expanded:_===e.id,onToggle:()=>S(t=>t===e.id?null:e.id),c:a,statusLabels:u})},e.id))})]})]}):null}),n&&!r?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(J,{type:`button`,className:`gap-1.5`,onClick:()=>f(n),children:[(0,$.jsx)(de,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),a.runNow]}),(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:()=>d(n),children:a.edit}),(0,$.jsxs)(J,{type:`button`,variant:`secondary`,className:`ml-auto text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:()=>m(n),children:[(0,$.jsx)(v,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),a.delete]})]})}):null]})})]})})}function At(e){let t=(0,Q.c)(31),{value:n,onChange:r,disabled:i,wd:a,placeholder:o,title:s,maxWidthClass:c,clearLabel:l,onClear:u}=e,d;t[0]!==r||t[1]!==n?(d={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=d):d=t[2];let f=S(d),p;t[3]===n?p=t[4]:(p=n.trim(),t[3]=n,t[4]=p);let m=p,h=s??(m?`${m}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`),g=i||f.picking,_=o??a.notSet,v;t[5]!==c||t[6]!==f.pick||t[7]!==h||t[8]!==g||t[9]!==_||t[10]!==n?(v=(0,$.jsx)(w,{value:n,onPick:f.pick,disabled:g,placeholder:_,title:h,maxWidthClass:c}),t[5]=c,t[6]=f.pick,t[7]=h,t[8]=g,t[9]=_,t[10]=n,t[11]=v):v=t[11];let y;t[12]!==l||t[13]!==i||t[14]!==u||t[15]!==f.picking||t[16]!==m?(y=l&&m&&u?(0,$.jsx)(`button`,{type:`button`,disabled:i||f.picking,className:`text-xs font-medium text-accent hover:underline disabled:opacity-50`,onClick:u,children:l}):null,t[12]=l,t[13]=i,t[14]=u,t[15]=f.picking,t[16]=m,t[17]=y):y=t[17];let b;t[18]!==v||t[19]!==y?(b=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[18]=v,t[19]=y,t[20]=b):b=t[20];let x;t[21]!==f.confirmPick||t[22]!==f.hasNativePicker||t[23]!==f.modalOpen||t[24]!==f.setModalOpen||t[25]!==m||t[26]!==a?(x=f.hasNativePicker?null:(0,$.jsx)(ne,{open:f.modalOpen,onOpenChange:f.setModalOpen,initialAbsolutePath:m||void 0,onConfirm:f.confirmPick,wd:a}),t[21]=f.confirmPick,t[22]=f.hasNativePicker,t[23]=f.modalOpen,t[24]=f.setModalOpen,t[25]=m,t[26]=a,t[27]=x):x=t[27];let C;return t[28]!==b||t[29]!==x?(C=(0,$.jsxs)($.Fragment,{children:[b,x]}),t[28]=b,t[29]=x,t[30]=C):C=t[30],C}function jt(e,t){return e[t]??t}function Mt(e,t){let n=oe[e]??[];if(n.length===0)return{};let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{},i={};for(let e of n){let t=r[e.key];t!=null&&(i[e.key]=String(t))}return i}function Nt(e,t){return(oe[e]??[]).every(e=>!e.required||!!t[e.key]?.trim())}function Pt(e){let t=(0,Q.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function Ft(e){let t=(0,Q.c)(33),{workflowName:n,language:r,argValues:i,onArgValuesChange:o,goal:s,onGoalChange:c,examplePrompts:l,showGoal:u,inputClassName:d}=e,f;t[0]===l?f=t[1]:(f=l===void 0?[]:l,t[0]=l,t[1]=f);let p=f,m=u===void 0?!0:u,h,g,_,v,y,b,x;if(t[2]!==i||t[3]!==p||t[4]!==s||t[5]!==d||t[6]!==r||t[7]!==o||t[8]!==c||t[9]!==m||t[10]!==n){_=a(r).workflows;let e=oe[n]??[];g=e.length>0;let l=X(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,d),u;t[18]!==i||t[19]!==o||t[20]!==c?(u=e=>{qe(e,c,e=>{o(e(i))})},t[18]=i,t[19]=o,t[20]=c,t[21]=u):u=t[21],h=u,v=`flex flex-col gap-3`,y=e.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[jt(_.args,e.labelKey),e.required?` *`:``]}),e.multiline?(0,$.jsx)(`textarea`,{value:i[e.key]??``,onChange:t=>o({...i,[e.key]:t.target.value}),placeholder:jt(_.args,e.placeholderKey),className:X(l,`min-h-20 resize-y`)}):(0,$.jsx)(`input`,{value:i[e.key]??``,onChange:t=>o({...i,[e.key]:t.target.value}),placeholder:jt(_.args,e.placeholderKey),className:l})]},e.key)),b=g&&p.length>0?(0,$.jsx)(Pt,{examples:p,labels:_,onSelect:h}):null,x=m?(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:_.goalLabel}),(0,$.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:_.goalPlaceholder,className:X(l,`min-h-20 resize-y`)})]}):null,t[2]=i,t[3]=p,t[4]=s,t[5]=d,t[6]=r,t[7]=o,t[8]=c,t[9]=m,t[10]=n,t[11]=h,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=x}else h=t[11],g=t[12],_=t[13],v=t[14],y=t[15],b=t[16],x=t[17];let S;t[22]!==h||t[23]!==p||t[24]!==g||t[25]!==_?(S=!g&&p.length>0?(0,$.jsx)(Pt,{examples:p,labels:_,onSelect:h}):null,t[22]=h,t[23]=p,t[24]=g,t[25]=_,t[26]=S):S=t[26];let C;return t[27]!==v||t[28]!==y||t[29]!==b||t[30]!==x||t[31]!==S?(C=(0,$.jsxs)(`div`,{className:v,children:[y,b,x,S]}),t[27]=v,t[28]=y,t[29]=b,t[30]=x,t[31]=S,t[32]=C):C=t[32],C}function It(e){let t=(0,Q.c)(190),{open:n,onRequestClose:r,c:a,chatM:o,agentsMessages:s,isDark:c,channels:l,sessionChatIds:u,cronAgentSelectOptions:d,defaultModelResolver:f,formMode:p,formJobId:m,formName:h,onFormNameChange:g,formSchedule:_,onFormScheduleChange:v,formSubmitting:S,formTaskKind:C,onFormTaskKindChange:w,workflowDefinitions:D,workflowDefinitionsLoading:A,formWorkflowDefinitionId:j,onFormWorkflowDefinitionIdChange:N,formWorkflowGoal:P,onFormWorkflowGoalChange:F,formWorkflowArgValues:I,onFormWorkflowArgValuesChange:z,formSessionTarget:B,onFormSessionTargetChange:V,formAgentLocalOnly:H,onFormAgentLocalOnlyChange:U,formModel:W,onFormModelUserChange:K,formAgentId:ee,onFormAgentIdChange:q,formWorkingDirectory:ne,onFormWorkingDirectoryChange:re,formChannel:Y,onFormChannelChange:oe,formChatId:se,onFormChatIdChange:ce,formMessage:le,onFormMessageChange:ue,formMessageMdMode:de,onSetMessageMdMode:fe,messageEditorNonce:pe,needsDeliveryChat:me,showChannelPicker:he,canSubmit:ge,onSubmit:_e,onRefreshRecipients:ve}=e,be=i(Bt),xe,Se;if(t[0]!==j||t[1]!==be||t[2]!==D){let e;t[5]===j?e=t[6]:(e=e=>e.id===j.trim(),t[5]=j,t[6]=e),xe=D.find(e),Se=xe?Ke(xe,be):null,t[0]=j,t[1]=be,t[2]=D,t[3]=xe,t[4]=Se}else xe=t[3],Se=t[4];let Ce=Se,we;t[7]===r?we=t[8]:(we=e=>!e&&r(),t[7]=r,t[8]=we);let Te;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[9]=Te):Te=t[9];let Ee=p===`edit`?a.editJob:a.addJob,De;t[10]===Ee?De=t[11]:(De=(0,$.jsx)(M,{className:`text-base font-semibold text-fg`,children:Ee}),t[10]=Ee,t[11]=De);let Oe;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,$.jsx)(te,{className:`size-5`,strokeWidth:1.75}),t[12]=Oe):Oe=t[12];let ke;t[13]===a.close?ke=t[14]:(ke=(0,$.jsx)(L,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":a.close,children:Oe})}),t[13]=a.close,t[14]=ke);let Ae;t[15]!==De||t[16]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[De,ke]}),t[15]=De,t[16]=ke,t[17]=Ae):Ae=t[17];let je;t[18]===a.name?je=t[19]:(je=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.name}),t[18]=a.name,t[19]=je);let Me;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(Me=vt(),t[20]=Me):Me=t[20];let Ne;t[21]===g?Ne=t[22]:(Ne=e=>g(e.target.value),t[21]=g,t[22]=Ne);let Pe;t[23]!==a.namePlaceholder||t[24]!==h||t[25]!==Ne?(Pe=(0,$.jsx)(`input`,{type:`text`,className:Me,value:h,onChange:Ne,placeholder:a.namePlaceholder}),t[23]=a.namePlaceholder,t[24]=h,t[25]=Ne,t[26]=Pe):Pe=t[26];let Fe;t[27]!==Pe||t[28]!==je?(Fe=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[je,Pe]}),t[27]=Pe,t[28]=je,t[29]=Fe):Fe=t[29];let Ie;t[30]!==a.schedulePicker||t[31]!==_||t[32]!==S||t[33]!==v?(Ie=(0,$.jsx)(We,{value:_,onChange:v,disabled:S,labels:a.schedulePicker}),t[30]=a.schedulePicker,t[31]=_,t[32]=S,t[33]=v,t[34]=Ie):Ie=t[34];let Le;t[35]===a.taskKind?Le=t[36]:(Le=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.taskKind}),t[35]=a.taskKind,t[36]=Le);let Re;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(Re=yt(),t[37]=Re):Re=t[37];let ze;t[38]===w?ze=t[39]:(ze=e=>w(e.target.value),t[38]=w,t[39]=ze);let Be;t[40]===a.taskKindMessage?Be=t[41]:(Be=(0,$.jsx)(`option`,{value:`message`,children:a.taskKindMessage}),t[40]=a.taskKindMessage,t[41]=Be);let Ve;t[42]===a.taskKindWorkflowRun?Ve=t[43]:(Ve=(0,$.jsx)(`option`,{value:`workflowRun`,children:a.taskKindWorkflowRun}),t[42]=a.taskKindWorkflowRun,t[43]=Ve);let He;t[44]!==S||t[45]!==C||t[46]!==ze||t[47]!==Be||t[48]!==Ve?(He=(0,$.jsxs)(`select`,{className:Re,value:C,disabled:S,onChange:ze,children:[Be,Ve]}),t[44]=S,t[45]=C,t[46]=ze,t[47]=Be,t[48]=Ve,t[49]=He):He=t[49];let Ue;t[50]!==Le||t[51]!==He?(Ue=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[Le,He]}),t[50]=Le,t[51]=He,t[52]=Ue):Ue=t[52];let Ge;t[53]!==s||t[54]!==a.agentProfile||t[55]!==a.agentProfileDefault||t[56]!==a.agentProfileHint||t[57]!==a.channel||t[58]!==a.channelLocal||t[59]!==a.lastActiveLabels||t[60]!==a.noRecentChatsOption||t[61]!==a.recipient||t[62]!==a.recipientPlaceholder||t[63]!==a.refreshList||t[64]!==a.refreshRecipientHint||t[65]!==a.selectRecipient||t[66]!==a.workflowDefinition||t[67]!==a.workflowDefinitionCustom||t[68]!==a.workflowDefinitionMissing||t[69]!==a.workflowDefinitionPlaceholder||t[70]!==a.workflowDefinitionsEmpty||t[71]!==a.workflowDefinitionsLoading||t[72]!==a.workflowDeliveryHint||t[73]!==a.workflowLocalOnly||t[74]!==a.workflowLocalOnlyHint||t[75]!==l||t[76]!==d||t[77]!==ee||t[78]!==H||t[79]!==Y||t[80]!==se||t[81]!==S||t[82]!==C||t[83]!==I||t[84]!==j||t[85]!==P||t[86]!==be||t[87]!==me||t[88]!==q||t[89]!==U||t[90]!==oe||t[91]!==ce||t[92]!==z||t[93]!==N||t[94]!==F||t[95]!==ve||t[96]!==xe||t[97]!==Ce||t[98]!==u||t[99]!==he||t[100]!==D||t[101]!==A?(Ge=C===`workflowRun`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.workflowDefinition}),(0,$.jsxs)(`select`,{className:yt(),value:j,disabled:S||A,onChange:e=>N(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:A?a.workflowDefinitionsLoading:a.workflowDefinitionPlaceholder}),j.trim()&&!D.some(e=>e.id===j.trim())?(0,$.jsx)(`option`,{value:j,children:j}):null,D.map(e=>(0,$.jsxs)(`option`,{value:e.id,children:[e.title,e.metadata.source===`user`?` (${a.workflowDefinitionCustom})`:``]},e.id))]}),!A&&D.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workflowDefinitionsEmpty}):null,Ce?(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:Ce.description}):j.trim()&&!xe?(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:a.workflowDefinitionMissing}):null]}),j.trim()?(0,$.jsx)(Ft,{workflowName:j.trim(),language:be,argValues:I,onArgValuesChange:z,goal:P,onGoalChange:F,examplePrompts:Ce?.examplePrompts??[],inputClassName:vt()}):null,(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),(0,$.jsxs)(`select`,{className:yt(),value:ee,disabled:S,onChange:e=>q(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:a.agentProfileDefault}),d.map(e=>(0,$.jsx)(`option`,{value:e.id,children:`${e.id} — ${ie(e,s)}`},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.agentProfileHint})]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md bg-surface-hover/45 px-3 py-2 dark:bg-surface-hover/30`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:X(`ui-checkbox`,`mt-0.5`),checked:H,onChange:e=>U(e.target.checked),"aria-label":a.workflowLocalOnly}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.workflowLocalOnly}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.workflowLocalOnlyHint})]})]}),he?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.channel}),(0,$.jsxs)(`select`,{className:yt(),value:Y,onChange:e=>oe(e.target.value),children:[(0,$.jsx)(`option`,{value:`local`,children:a.channelLocal}),l.map(Rt)]})]}),me?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.recipient}),(0,$.jsxs)(J,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:a.refreshRecipientHint,onClick:()=>void ve(),children:[(0,$.jsx)(ae,{className:`size-3.5`,strokeWidth:1.75}),a.refreshList]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,className:X(vt(),`min-w-0 w-full sm:flex-1`),value:se,onChange:e=>ce(e.target.value),placeholder:a.recipientPlaceholder}),(0,$.jsxs)(`select`,{className:bt,value:se,onChange:e=>{let t=e.target.value;t&&ce(t)},children:[(0,$.jsx)(`option`,{value:``,children:a.selectRecipient}),u.length>0?u.map(e=>(0,$.jsx)(`option`,{value:e.chatId,children:ye(e,a.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,$.jsx)(`option`,{value:``,disabled:!0,children:a.noRecentChatsOption})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workflowDeliveryHint})]}):null]}):null]}):null,t[53]=s,t[54]=a.agentProfile,t[55]=a.agentProfileDefault,t[56]=a.agentProfileHint,t[57]=a.channel,t[58]=a.channelLocal,t[59]=a.lastActiveLabels,t[60]=a.noRecentChatsOption,t[61]=a.recipient,t[62]=a.recipientPlaceholder,t[63]=a.refreshList,t[64]=a.refreshRecipientHint,t[65]=a.selectRecipient,t[66]=a.workflowDefinition,t[67]=a.workflowDefinitionCustom,t[68]=a.workflowDefinitionMissing,t[69]=a.workflowDefinitionPlaceholder,t[70]=a.workflowDefinitionsEmpty,t[71]=a.workflowDefinitionsLoading,t[72]=a.workflowDeliveryHint,t[73]=a.workflowLocalOnly,t[74]=a.workflowLocalOnlyHint,t[75]=l,t[76]=d,t[77]=ee,t[78]=H,t[79]=Y,t[80]=se,t[81]=S,t[82]=C,t[83]=I,t[84]=j,t[85]=P,t[86]=be,t[87]=me,t[88]=q,t[89]=U,t[90]=oe,t[91]=ce,t[92]=z,t[93]=N,t[94]=F,t[95]=ve,t[96]=xe,t[97]=Ce,t[98]=u,t[99]=he,t[100]=D,t[101]=A,t[102]=Ge):Ge=t[102];let qe;t[103]!==s||t[104]!==a.agentLocalOnly||t[105]!==a.agentLocalOnlyHint||t[106]!==a.agentProfile||t[107]!==a.agentProfileDefault||t[108]!==a.agentProfileHint||t[109]!==a.channel||t[110]!==a.channelLocal||t[111]!==a.enterManuallyOrSelect||t[112]!==a.lastActiveLabels||t[113]!==a.message||t[114]!==a.messageEdit||t[115]!==a.messageMarkdownHint||t[116]!==a.messagePlaceholder||t[117]!==a.messagePreview||t[118]!==a.mode||t[119]!==a.modeAgent||t[120]!==a.modeAgentOption||t[121]!==a.modeDirect||t[122]!==a.modeDirectOption||t[123]!==a.model||t[124]!==a.noRecentChats||t[125]!==a.noRecentChatsOption||t[126]!==a.recipient||t[127]!==a.recipientPlaceholder||t[128]!==a.refreshList||t[129]!==a.refreshRecipientHint||t[130]!==a.selectRecipient||t[131]!==a.workingDirectoryHint||t[132]!==a.workingDirectoryLabel||t[133]!==a.workingDirectoryReset||t[134]!==l||t[135]!==o||t[136]!==d||t[137]!==f||t[138]!==ee||t[139]!==H||t[140]!==Y||t[141]!==se||t[142]!==m||t[143]!==le||t[144]!==de||t[145]!==W||t[146]!==B||t[147]!==S||t[148]!==C||t[149]!==ne||t[150]!==c||t[151]!==pe||t[152]!==me||t[153]!==q||t[154]!==U||t[155]!==oe||t[156]!==ce||t[157]!==ue||t[158]!==K||t[159]!==V||t[160]!==re||t[161]!==ve||t[162]!==fe||t[163]!==u||t[164]!==he?(qe=C===`message`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.mode}),(0,$.jsxs)(`select`,{className:yt(),value:B,onChange:e=>{let t=e.target.value;V(t,f,W.trim())},children:[(0,$.jsx)(`option`,{value:`main`,children:a.modeDirectOption}),(0,$.jsx)(`option`,{value:`isolated`,children:a.modeAgentOption})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:B===`main`?a.modeDirect:a.modeAgent})]}),B===`isolated`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.model}),(0,$.jsx)(O,{value:W,placeholder:o.modelPlaceholder,searchPlaceholder:o.modelSearchPlaceholder,noMatches:o.modelNoMatches,className:`w-full max-w-none min-w-0`,popoverContentClassName:`z-[70]`,onChange:K})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),(0,$.jsxs)(`select`,{className:yt(),value:ee,disabled:S,onChange:e=>q(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:a.agentProfileDefault}),d.map(e=>(0,$.jsx)(`option`,{value:e.id,children:`${e.id} — ${ie(e,s)}`},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.agentProfileHint})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.workingDirectoryLabel}),(0,$.jsx)(At,{value:ne,onChange:re,disabled:S,wd:o.workingDirectory,placeholder:o.workingDirectory.notSet,maxWidthClass:`max-w-[min(16rem,48vw)]`,clearLabel:a.workingDirectoryReset,onClear:()=>re(``)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workingDirectoryHint})]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md bg-surface-hover/45 px-3 py-2 dark:bg-surface-hover/30`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:X(`ui-checkbox`,`mt-0.5`),checked:H,onChange:e=>U(e.target.checked),"aria-label":a.agentLocalOnly}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.agentLocalOnly}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.agentLocalOnlyHint})]})]})]}):null,he?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.channel}),(0,$.jsxs)(`select`,{className:yt(),value:Y,onChange:e=>{let t=e.target.value;oe(t)},children:[(0,$.jsx)(`option`,{value:`local`,children:a.channelLocal}),l.map(Lt)]})]}),me?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.recipient}),(0,$.jsxs)(J,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:a.refreshRecipientHint,onClick:()=>void ve(),children:[(0,$.jsx)(ae,{className:`size-3.5`,strokeWidth:1.75}),a.refreshList]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,className:X(vt(),`min-w-0 w-full sm:flex-1`),value:se,onChange:e=>ce(e.target.value),placeholder:a.recipientPlaceholder}),(0,$.jsxs)(`select`,{className:bt,value:se,onChange:e=>{let t=e.target.value;t&&ce(t)},children:[(0,$.jsx)(`option`,{value:``,children:a.selectRecipient}),u.length>0?u.map(e=>(0,$.jsx)(`option`,{value:e.chatId,children:ye(e,a.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,$.jsx)(`option`,{value:``,disabled:!0,children:a.noRecentChatsOption})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:u.length>0?a.enterManuallyOrSelect:a.noRecentChats})]}):null]}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.message}),(0,$.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-base p-0.5 dark:border-edge`,children:[(0,$.jsxs)(`button`,{type:`button`,className:X(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,de===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>fe(`edit`),children:[(0,$.jsx)(T,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),a.messageEdit]}),(0,$.jsxs)(`button`,{type:`button`,className:X(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,de===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>fe(`preview`),children:[(0,$.jsx)(G,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),a.messagePreview]})]})]}),(0,$.jsx)(`div`,{className:X(`overflow-hidden rounded-md border border-edge bg-surface-base dark:border-edge`,S&&`pointer-events-none opacity-60`),children:de===`edit`?(0,$.jsx)(k,{initialContent:le,onChange:ue,isDark:c,className:`h-[min(18rem,40vh)] min-h-[12rem]`},`cron-msg-${m??`new`}-${pe}`):(0,$.jsx)(`div`,{className:`h-[min(18rem,40vh)] min-h-[12rem] max-h-[min(24rem,50vh)] overflow-y-auto px-3 py-2`,children:le.trim()?(0,$.jsx)(E,{content:le,compact:!0,className:`text-sm`}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.messagePlaceholder})})}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.messageMarkdownHint})]})]}):null,t[103]=s,t[104]=a.agentLocalOnly,t[105]=a.agentLocalOnlyHint,t[106]=a.agentProfile,t[107]=a.agentProfileDefault,t[108]=a.agentProfileHint,t[109]=a.channel,t[110]=a.channelLocal,t[111]=a.enterManuallyOrSelect,t[112]=a.lastActiveLabels,t[113]=a.message,t[114]=a.messageEdit,t[115]=a.messageMarkdownHint,t[116]=a.messagePlaceholder,t[117]=a.messagePreview,t[118]=a.mode,t[119]=a.modeAgent,t[120]=a.modeAgentOption,t[121]=a.modeDirect,t[122]=a.modeDirectOption,t[123]=a.model,t[124]=a.noRecentChats,t[125]=a.noRecentChatsOption,t[126]=a.recipient,t[127]=a.recipientPlaceholder,t[128]=a.refreshList,t[129]=a.refreshRecipientHint,t[130]=a.selectRecipient,t[131]=a.workingDirectoryHint,t[132]=a.workingDirectoryLabel,t[133]=a.workingDirectoryReset,t[134]=l,t[135]=o,t[136]=d,t[137]=f,t[138]=ee,t[139]=H,t[140]=Y,t[141]=se,t[142]=m,t[143]=le,t[144]=de,t[145]=W,t[146]=B,t[147]=S,t[148]=C,t[149]=ne,t[150]=c,t[151]=pe,t[152]=me,t[153]=q,t[154]=U,t[155]=oe,t[156]=ce,t[157]=ue,t[158]=K,t[159]=V,t[160]=re,t[161]=ve,t[162]=fe,t[163]=u,t[164]=he,t[165]=qe):qe=t[165];let Je;t[166]!==Fe||t[167]!==Ie||t[168]!==Ue||t[169]!==Ge||t[170]!==qe?(Je=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[Fe,Ie,Ue,Ge,qe]})}),t[166]=Fe,t[167]=Ie,t[168]=Ue,t[169]=Ge,t[170]=qe,t[171]=Je):Je=t[171];let Ye;t[172]!==a.cancel||t[173]!==r?(Ye=(0,$.jsx)(J,{type:`button`,variant:`secondary`,onClick:r,children:a.cancel}),t[172]=a.cancel,t[173]=r,t[174]=Ye):Ye=t[174];let Xe=S||!ge,Ze=S?a.loading:p===`edit`?a.save:a.create,Qe;t[175]!==_e||t[176]!==Xe||t[177]!==Ze?(Qe=(0,$.jsx)(J,{type:`button`,variant:`primary`,disabled:Xe,onClick:_e,children:Ze}),t[175]=_e,t[176]=Xe,t[177]=Ze,t[178]=Qe):Qe=t[178];let $e;t[179]!==Ye||t[180]!==Qe?($e=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[Ye,Qe]}),t[179]=Ye,t[180]=Qe,t[181]=$e):$e=t[181];let Z;t[182]!==Je||t[183]!==$e||t[184]!==Ae?(Z=(0,$.jsxs)(x,{children:[Te,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(y,{className:`xopc-dialog-content-pane pointer-events-auto relative flex h-[min(90vh,800px)] w-full max-w-md flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none sm:max-w-lg lg:max-w-xl dark:border-edge`,onOpenAutoFocus:zt,children:[Ae,Je,$e]})})]}),t[182]=Je,t[183]=$e,t[184]=Ae,t[185]=Z):Z=t[185];let et;return t[186]!==n||t[187]!==we||t[188]!==Z?(et=(0,$.jsx)($.Fragment,{children:(0,$.jsx)(b,{open:n,onOpenChange:we,children:Z})}),t[186]=n,t[187]=we,t[188]=Z,t[189]=et):et=t[189],et}function Lt(e){return(0,$.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Rt(e){return(0,$.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function zt(e){return e.preventDefault()}function Bt(e){return e.language}function Vt(e){let t=(0,Q.c)(76),{c:n,mainTab:r,onMainTabChange:i,jobSort:a,onJobSortChange:o,historyRange:s,onHistoryRangeChange:c,historyJobFilter:l,onHistoryJobFilterChange:u,historyStatusFilter:d,onHistoryStatusFilterChange:f,jobs:p}=e,m=n.title,h=r===`myTasks`,g=r===`myTasks`?`text-fg`:`text-fg-muted hover:text-fg`,_;t[0]===g?_=t[1]:(_=X(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,g),t[0]=g,t[1]=_);let v;t[2]===i?v=t[3]:(v=()=>i(`myTasks`),t[2]=i,t[3]=v);let y;t[4]!==n.tabMyTasks||t[5]!==h||t[6]!==_||t[7]!==v?(y=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":h,className:_,onClick:v,children:n.tabMyTasks}),t[4]=n.tabMyTasks,t[5]=h,t[6]=_,t[7]=v,t[8]=y):y=t[8];let b=r===`systemTasks`,x=r===`systemTasks`?`text-fg`:`text-fg-muted hover:text-fg`,S;t[9]===x?S=t[10]:(S=X(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,x),t[9]=x,t[10]=S);let C;t[11]===i?C=t[12]:(C=()=>i(`systemTasks`),t[11]=i,t[12]=C);let w;t[13]!==n.tabSystemTasks||t[14]!==C||t[15]!==b||t[16]!==S?(w=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":b,className:S,onClick:C,children:n.tabSystemTasks}),t[13]=n.tabSystemTasks,t[14]=C,t[15]=b,t[16]=S,t[17]=w):w=t[17];let T=r===`history`,E=r===`history`?`text-fg`:`text-fg-muted hover:text-fg`,D;t[18]===E?D=t[19]:(D=X(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,E),t[18]=E,t[19]=D);let O;t[20]===i?O=t[21]:(O=()=>i(`history`),t[20]=i,t[21]=O);let k;t[22]!==n.tabRunHistory||t[23]!==T||t[24]!==D||t[25]!==O?(k=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":T,className:D,onClick:O,children:n.tabRunHistory}),t[22]=n.tabRunHistory,t[23]=T,t[24]=D,t[25]=O,t[26]=k):k=t[26];let A=r===`settings`,j=r===`settings`?`text-fg`:`text-fg-muted hover:text-fg`,M;t[27]===j?M=t[28]:(M=X(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,j),t[27]=j,t[28]=M);let N;t[29]===i?N=t[30]:(N=()=>i(`settings`),t[29]=i,t[30]=N);let P;t[31]!==n.globals.title||t[32]!==A||t[33]!==M||t[34]!==N?(P=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":A,className:M,onClick:N,children:n.globals.title}),t[31]=n.globals.title,t[32]=A,t[33]=M,t[34]=N,t[35]=P):P=t[35];let F;t[36]!==n.title||t[37]!==w||t[38]!==k||t[39]!==P||t[40]!==y?(F=(0,$.jsxs)(`div`,{className:`flex gap-1`,role:`tablist`,"aria-label":m,children:[y,w,k,P]}),t[36]=n.title,t[37]=w,t[38]=k,t[39]=P,t[40]=y,t[41]=F):F=t[41];let I=r===`history`?`flex-nowrap overflow-x-auto pb-0.5 sm:justify-end`:`flex-wrap sm:justify-end`,L;t[42]===I?L=t[43]:(L=X(`flex min-w-0 items-center gap-2`,I),t[42]=I,t[43]=L);let R;t[44]!==n.sortCreatedAsc||t[45]!==n.sortCreatedDesc||t[46]!==a||t[47]!==r||t[48]!==o?(R=r===`myTasks`||r===`systemTasks`?(0,$.jsxs)(`select`,{className:xt,value:a,onChange:e=>o(e.target.value),"aria-label":n.sortCreatedDesc,children:[(0,$.jsx)(`option`,{value:`created_desc`,children:n.sortCreatedDesc}),(0,$.jsx)(`option`,{value:`created_asc`,children:n.sortCreatedAsc})]}):null,t[44]=n.sortCreatedAsc,t[45]=n.sortCreatedDesc,t[46]=a,t[47]=r,t[48]=o,t[49]=R):R=t[49];let z;t[50]!==n.execStatusCancelled||t[51]!==n.execStatusFailed||t[52]!==n.execStatusRunning||t[53]!==n.execStatusSuccess||t[54]!==n.filterAllStatuses||t[55]!==n.filterAllTasks||t[56]!==n.historyRangeDay||t[57]!==n.historyRangeMonth||t[58]!==n.historyRangeWeek||t[59]!==n.runHistoryTitle||t[60]!==l||t[61]!==s||t[62]!==d||t[63]!==p||t[64]!==r||t[65]!==u||t[66]!==c||t[67]!==f?(z=r===`history`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:X(Y,`shrink-0`),role:`group`,"aria-label":n.runHistoryTitle,children:[`day`,`week`,`month`].map(e=>(0,$.jsx)(`button`,{type:`button`,className:X(se,`px-2.5 py-1`,s===e&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,s===e&&`text-fg`),onClick:()=>c(e),children:e===`day`?n.historyRangeDay:e===`week`?n.historyRangeWeek:n.historyRangeMonth},e))}),(0,$.jsxs)(`select`,{className:xt,value:l,onChange:e=>u(e.target.value),"aria-label":n.filterAllTasks,children:[(0,$.jsx)(`option`,{value:``,children:n.filterAllTasks}),p.map(Ht)]}),(0,$.jsxs)(`select`,{className:xt,value:d,onChange:e=>f(e.target.value),"aria-label":n.filterAllStatuses,children:[(0,$.jsx)(`option`,{value:``,children:n.filterAllStatuses}),(0,$.jsx)(`option`,{value:`success`,children:n.execStatusSuccess}),(0,$.jsx)(`option`,{value:`failed`,children:n.execStatusFailed}),(0,$.jsx)(`option`,{value:`cancelled`,children:n.execStatusCancelled}),(0,$.jsx)(`option`,{value:`running`,children:n.execStatusRunning})]})]}):null,t[50]=n.execStatusCancelled,t[51]=n.execStatusFailed,t[52]=n.execStatusRunning,t[53]=n.execStatusSuccess,t[54]=n.filterAllStatuses,t[55]=n.filterAllTasks,t[56]=n.historyRangeDay,t[57]=n.historyRangeMonth,t[58]=n.historyRangeWeek,t[59]=n.runHistoryTitle,t[60]=l,t[61]=s,t[62]=d,t[63]=p,t[64]=r,t[65]=u,t[66]=c,t[67]=f,t[68]=z):z=t[68];let B;t[69]!==L||t[70]!==R||t[71]!==z?(B=(0,$.jsxs)(`div`,{className:L,children:[R,z]}),t[69]=L,t[70]=R,t[71]=z,t[72]=B):B=t[72];let V;return t[73]!==F||t[74]!==B?(V=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[F,B]}),t[73]=F,t[74]=B,t[75]=V):V=t[75],V}function Ht(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id)}function Ut(e){let t=(0,Q.c)(23),{c:n,loading:r,runHistoryLoading:i,onRefresh:a,onOpenTemplatePicker:o,onAddJob:s}=e,c=r||i,l=n.refresh,u=n.refresh,d;t[0]===a?d=t[1]:(d=()=>void a(),t[0]=a,t[1]=d);let f=c&&`animate-spin`,p;t[2]===f?p=t[3]:(p=X(`size-4`,f),t[2]=f,t[3]=p);let m;t[4]===p?m=t[5]:(m=(0,$.jsx)(ae,{className:p,strokeWidth:1.75}),t[4]=p,t[5]=m);let h;t[6]!==c||t[7]!==n.refresh||t[8]!==d||t[9]!==m?(h=(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:c,title:l,"aria-label":u,onClick:d,children:m}),t[6]=c,t[7]=n.refresh,t[8]=d,t[9]=m,t[10]=h):h=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(F,{className:`size-4`,strokeWidth:1.75}),t[11]=g):g=t[11];let _;t[12]!==n.fromTemplate||t[13]!==o?(_=(0,$.jsxs)(J,{type:`button`,variant:`secondary`,className:`gap-2`,onClick:o,children:[g,n.fromTemplate]}),t[12]=n.fromTemplate,t[13]=o,t[14]=_):_=t[14];let v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(U,{className:`size-4`,strokeWidth:1.75}),t[15]=v):v=t[15];let y;t[16]!==n.addJob||t[17]!==s?(y=(0,$.jsxs)(J,{type:`button`,variant:`primary`,className:`gap-2`,onClick:s,children:[v,n.addJob]}),t[16]=n.addJob,t[17]=s,t[18]=y):y=t[18];let b;return t[19]!==y||t[20]!==h||t[21]!==_?(b=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[h,_,y]}),t[19]=y,t[20]=h,t[21]=_,t[22]=b):b=t[22],b}function Wt(e){let t=(0,Q.c)(46),{c:n,runHistoryLoading:r,runHistory:i,filteredRunHistory:a,jobs:o,onRefreshHistory:s,onOpenJobDetail:c,statusLabels:l}=e,u;t[0]===n.tabRunHistory?u=t[1]:(u=(0,$.jsx)(`h2`,{id:`cron-history-panel`,className:`sr-only`,children:n.tabRunHistory}),t[0]=n.tabRunHistory,t[1]=u);let d;t[2]===n.runHistoryHint?d=t[3]:(d=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.runHistoryHint}),t[2]=n.runHistoryHint,t[3]=d);let f;t[4]!==u||t[5]!==d?(f=(0,$.jsxs)(`div`,{children:[u,d]}),t[4]=u,t[5]=d,t[6]=f):f=t[6];let p=n.refresh,m=n.refresh,h;t[7]===s?h=t[8]:(h=()=>void s(),t[7]=s,t[8]=h);let g=r&&`animate-spin`,_;t[9]===g?_=t[10]:(_=X(`size-4`,g),t[9]=g,t[10]=_);let v;t[11]===_?v=t[12]:(v=(0,$.jsx)(ae,{className:_,strokeWidth:1.75}),t[11]=_,t[12]=v);let y;t[13]!==n.refresh||t[14]!==r||t[15]!==h||t[16]!==v?(y=(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:p,"aria-label":m,onClick:h,children:v}),t[13]=n.refresh,t[14]=r,t[15]=h,t[16]=v,t[17]=y):y=t[17];let b;t[18]!==y||t[19]!==f?(b=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[f,y]}),t[18]=y,t[19]=f,t[20]=b):b=t[20];let x;t[21]!==n.colChat||t[22]!==n.colDetail||t[23]!==n.colDuration||t[24]!==n.colJob||t[25]!==n.colStarted||t[26]!==n.colWorkflow||t[27]!==n.emptyHistoryHint||t[28]!==n.emptyHistoryTitle||t[29]!==n.noRunsYet||t[30]!==n.openChat||t[31]!==n.openChatTitle||t[32]!==n.openWorkflow||t[33]!==n.openWorkflowTitle||t[34]!==n.runHistoryHint||t[35]!==n.status||t[36]!==a||t[37]!==o||t[38]!==c||t[39]!==i||t[40]!==r||t[41]!==l?(x=r&&i.length===0?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,$.jsx)(re,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):a.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center rounded-2xl border border-dashed border-edge-subtle px-6 py-16 text-center dark:border-edge-subtle`,children:[(0,$.jsx)(ge,{className:`mb-4 size-14 text-fg-disabled`,strokeWidth:1.1,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:i.length===0?n.emptyHistoryTitle:n.noRunsYet}),(0,$.jsx)(`p`,{className:`mt-2 max-w-sm text-sm text-fg-muted`,children:i.length===0?n.emptyHistoryHint:n.runHistoryHint})]}):(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:(0,$.jsxs)(`table`,{className:`w-full min-w-[700px] border-collapse text-left text-sm`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-edge text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colStarted}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colJob}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.status}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDuration}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDetail}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colWorkflow}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colChat})]})}),(0,$.jsx)(`tbody`,{children:a.map(e=>(0,$.jsxs)(`tr`,{className:`border-b border-edge/60 last:border-0`,children:[(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg`,children:(0,$.jsx)(`time`,{dateTime:e.startedAt,children:Se(e.startedAt)})}),(0,$.jsx)(`td`,{className:`max-w-[10rem] truncate px-3 py-2.5`,children:o.some(t=>t.id===e.jobId)?(0,$.jsx)(`button`,{type:`button`,className:`text-left text-accent hover:underline`,onClick:()=>{let t=o.find(t=>t.id===e.jobId);t&&c(t)},children:e.jobName||e.jobId}):(0,$.jsx)(`span`,{className:`text-fg-muted`,children:e.jobName||e.jobId})}),(0,$.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,$.jsx)(`span`,{className:X(`inline-flex rounded-md px-2 py-0.5 text-xs font-medium`,e.status===`success`&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`,e.status===`failed`&&`bg-red-500/15 text-red-800 dark:text-red-300`,e.status===`running`&&`bg-accent/15 text-accent`,e.status===`cancelled`&&`bg-surface-hover text-fg-muted`),children:Ue(e.status,l)})}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg-muted`,children:He(e.duration)}),(0,$.jsx)(`td`,{className:`max-w-xs truncate px-3 py-2.5 text-fg-muted`,title:e.summary||e.error||``,children:be(e.summary||e.error,96)}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5`,children:e.workflowRunId?.trim()?(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openWorkflowTitle,"aria-label":n.openWorkflowTitle,onClick:()=>_t(e.workflowRunId),children:n.openWorkflow}):(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5`,children:e.sessionKey?.trim()?(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openChatTitle,"aria-label":n.openChatTitle,onClick:()=>gt(e.sessionKey),children:n.openChat}):(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})})]},e.id))})]})}),t[21]=n.colChat,t[22]=n.colDetail,t[23]=n.colDuration,t[24]=n.colJob,t[25]=n.colStarted,t[26]=n.colWorkflow,t[27]=n.emptyHistoryHint,t[28]=n.emptyHistoryTitle,t[29]=n.noRunsYet,t[30]=n.openChat,t[31]=n.openChatTitle,t[32]=n.openWorkflow,t[33]=n.openWorkflowTitle,t[34]=n.runHistoryHint,t[35]=n.status,t[36]=a,t[37]=o,t[38]=c,t[39]=i,t[40]=r,t[41]=l,t[42]=x):x=t[42];let S;return t[43]!==b||t[44]!==x?(S=(0,$.jsxs)(`section`,{"aria-labelledby":`cron-history-panel`,className:`flex flex-col gap-3`,children:[b,x]}),t[43]=b,t[44]=x,t[45]=S):S=t[45],S}function Gt(e){let t=(0,Q.c)(77),{job:n,c:r,localeTag:i,scheduleBadgeLabels:a,absorbCardClickJobIdRef:o,scheduleAbsorbNextMenuCardClick:s,onOpenDetail:c,onToggle:l,onEdit:u,onRunNow:d,onDelete:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=X(`flex h-full min-h-0 cursor-pointer flex-col rounded-xl border border-edge-subtle bg-surface-base text-left transition-colors duration-150 ease-out dark:border-edge-subtle`,`hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[0]=p):p=t[0];let m,h;t[1]!==o||t[2]!==n||t[3]!==c?(m=()=>{if(o.current===n.id){o.current=null;return}c(n)},h=e=>{if(e.key===`Enter`||e.key===` `){if(e.preventDefault(),o.current===n.id){o.current=null;return}c(n)}},t[1]=o,t[2]=n,t[3]=c,t[4]=m,t[5]=h):(m=t[4],h=t[5]);let g=n.enabled,_=n.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`,v;t[6]===_?v=t[7]:(v=X(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,_),t[6]=_,t[7]=v);let y;t[8]!==n||t[9]!==l?(y=e=>{e.stopPropagation(),l(n,!n.enabled)},t[8]=n,t[9]=l,t[10]=y):y=t[10];let b;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[11]=b):b=t[11];let x;t[12]!==n.enabled||t[13]!==v||t[14]!==y?(x=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":g,className:v,onClick:y,children:b}),t[12]=n.enabled,t[13]=v,t[14]=y,t[15]=x):x=t[15];let S;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(K,{className:`size-4`,strokeWidth:1.75}),t[16]=S):S=t[16];let C;t[17]===r.jobCardMenuAria?C=t[18]:(C=(0,$.jsx)(Ze,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":r.jobCardMenuAria,onClick:qt,children:S})}),t[17]=r.jobCardMenuAria,t[18]=C);let w;t[19]!==n||t[20]!==u||t[21]!==s?(w=()=>{s(n.id),u(n)},t[19]=n,t[20]=u,t[21]=s,t[22]=w):w=t[22];let T;t[23]!==r.edit||t[24]!==w?(T=(0,$.jsx)(Xe,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:w,children:r.edit}),t[23]=r.edit,t[24]=w,t[25]=T):T=t[25];let D;t[26]!==n||t[27]!==d||t[28]!==s?(D=()=>{s(n.id),d(n)},t[26]=n,t[27]=d,t[28]=s,t[29]=D):D=t[29];let O;t[30]!==r.runNow||t[31]!==D?(O=(0,$.jsx)(Xe,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:D,children:r.runNow}),t[30]=r.runNow,t[31]=D,t[32]=O):O=t[32];let k;t[33]!==n||t[34]!==f||t[35]!==s?(k=()=>{s(n.id),f(n)},t[33]=n,t[34]=f,t[35]=s,t[36]=k):k=t[36];let A;t[37]!==r.delete||t[38]!==k?(A=(0,$.jsx)(Xe,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-red-600 outline-none data-highlighted:bg-red-500/10 dark:text-red-400`,onSelect:k,children:r.delete}),t[37]=r.delete,t[38]=k,t[39]=A):A=t[39];let j;t[40]!==T||t[41]!==O||t[42]!==A?(j=(0,$.jsx)(Qe,{children:(0,$.jsxs)($e,{className:`z-50 min-w-[10rem] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,sideOffset:4,align:`end`,onCloseAutoFocus:Kt,children:[T,O,A]})}),t[40]=T,t[41]=O,t[42]=A,t[43]=j):j=t[43];let M;t[44]!==C||t[45]!==j?(M=(0,$.jsxs)(Ye,{children:[C,j]}),t[44]=C,t[45]=j,t[46]=M):M=t[46];let N;t[47]!==M||t[48]!==x?(N=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 px-4 pt-3`,children:[x,M]}),t[47]=M,t[48]=x,t[49]=N):N=t[49];let P=n.name||n.id,F;t[50]===P?F=t[51]:(F=(0,$.jsx)(`h3`,{className:`line-clamp-2 font-semibold text-fg`,children:P}),t[50]=P,t[51]=F);let I;t[52]===n?I=t[53]:(I=Pe(n),t[52]=n,t[53]=I);let L;t[54]===n?L=t[55]:(L=Pe(n),t[54]=n,t[55]=L);let R;t[56]===L?R=t[57]:(R=(0,$.jsx)(E,{content:L,compact:!0}),t[56]=L,t[57]=R);let z;t[58]!==I||t[59]!==R?(z=(0,$.jsx)(`div`,{className:`max-h-[4.5rem] overflow-hidden text-sm text-fg-muted [&_.markdown-body]:text-sm [&_.markdown-body]:leading-snug`,title:I,children:R}),t[58]=I,t[59]=R,t[60]=z):z=t[60];let B;t[61]!==F||t[62]!==z?(B=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 px-4 pb-3 pt-2`,children:[F,z]}),t[61]=F,t[62]=z,t[63]=B):B=t[63];let V;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(ge,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[64]=V):V=t[64];let H;t[65]!==n||t[66]!==i||t[67]!==a?(H=Ve(n,i,a),t[65]=n,t[66]=i,t[67]=a,t[68]=H):H=t[68];let U;t[69]===H?U=t[70]:(U=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t border-edge-subtle/90 px-4 py-2.5 text-xs text-fg-muted dark:border-edge-subtle`,children:[V,(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:H})]}),t[69]=H,t[70]=U);let W;return t[71]!==m||t[72]!==N||t[73]!==B||t[74]!==h||t[75]!==U?(W=(0,$.jsxs)(`article`,{role:`button`,tabIndex:0,className:p,onClick:m,onKeyDown:h,children:[N,B,U]}),t[71]=m,t[72]=N,t[73]=B,t[74]=h,t[75]=U,t[76]=W):W=t[76],W}function Kt(e){return e.preventDefault()}function qt(e){return e.stopPropagation()}function Jt(e){let t=(0,Q.c)(134),{c:n,language:r,localeTag:i,scheduleBadgeLabels:o,loading:s,sortedSystemJobs:c,heartbeat:l,keepAwake:u,wakeSupported:d,onWakeUnsupportedClick:f,onKeepAwakeToggle:p,absorbCardClickJobIdRef:m,scheduleAbsorbNextMenuCardClick:g,onOpenDetail:_,onToggle:v,onEdit:y,onRunNow:b,onDelete:x}=e,S,w,T,E,D,O,k,A,j,M,N,P;if(t[0]!==n.disabled||t[1]!==n.enabled||t[2]!==n.keepAwake||t[3]!==n.systemHeartbeatEvery||t[4]!==n.systemHeartbeatHint||t[5]!==n.systemHeartbeatInterval||t[6]!==n.systemHeartbeatSettingsLink||t[7]!==n.systemHeartbeatStatus||t[8]!==n.systemHeartbeatTitle||t[9]!==n.systemTasksIntro||t[10]!==n.tabSystemTasks||t[11]!==n.wakeBanner||t[12]!==n.wakeLockUnavailable||t[13]!==l.enabled||t[14]!==l.intervalMs||t[15]!==u||t[16]!==r||t[17]!==i||t[18]!==p||t[19]!==f||t[20]!==d){let e=Ie(l.intervalMs,i,a(r).heartbeatSettings.intervalPresets);N=`cron-system-tasks-panel`,P=`flex flex-col gap-4`,t[33]===n.tabSystemTasks?w=t[34]:(w=(0,$.jsx)(`h2`,{id:`cron-system-tasks-panel`,className:`sr-only`,children:n.tabSystemTasks}),t[33]=n.tabSystemTasks,t[34]=w),t[35]===n.systemTasksIntro?T=t[36]:(T=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.systemTasksIntro}),t[35]=n.systemTasksIntro,t[36]=T);let o;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(C,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[37]=o):o=t[37];let s;t[38]===n.wakeBanner?s=t[39]:(s=(0,$.jsxs)(`div`,{className:`flex gap-3 text-sm text-fg`,children:[o,(0,$.jsx)(`p`,{className:`text-pretty text-fg-muted`,children:n.wakeBanner})]}),t[38]=n.wakeBanner,t[39]=s);let c;t[40]===n.keepAwake?c=t[41]:(c=(0,$.jsx)(`span`,{className:`text-sm text-fg`,children:n.keepAwake}),t[40]=n.keepAwake,t[41]=c);let m=!d,g=d?void 0:n.wakeLockUnavailable,_=u?`justify-end bg-accent`:`justify-start bg-surface-hover`,v=!d&&`cursor-not-allowed opacity-50`,y;t[42]!==_||t[43]!==v?(y=X(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,_,v),t[42]=_,t[43]=v,t[44]=y):y=t[44];let b;t[45]!==p||t[46]!==f||t[47]!==d?(b=()=>{d?p():f()},t[45]=p,t[46]=f,t[47]=d,t[48]=b):b=t[48];let x;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[49]=x):x=t[49];let F;t[50]!==u||t[51]!==m||t[52]!==g||t[53]!==y||t[54]!==b?(F=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":u,disabled:m,title:g,className:y,onClick:b,children:x}),t[50]=u,t[51]=m,t[52]=g,t[53]=y,t[54]=b,t[55]=F):F=t[55];let I;t[56]!==c||t[57]!==F?(I=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:pl-4`,children:[c,F]}),t[56]=c,t[57]=F,t[58]=I):I=t[58],t[59]!==s||t[60]!==I?(E=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10 sm:flex-row sm:items-center sm:justify-between`,children:[s,I]}),t[59]=s,t[60]=I,t[61]=E):E=t[61],j=`rounded-xl border border-edge bg-surface-base p-4 dark:bg-surface-hover/20`;let L;t[62]===n.systemHeartbeatTitle?L=t[63]:(L=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemHeartbeatTitle}),t[62]=n.systemHeartbeatTitle,t[63]=L);let R;t[64]===n.systemHeartbeatHint?R=t[65]:(R=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.systemHeartbeatHint}),t[64]=n.systemHeartbeatHint,t[65]=R);let z;t[66]!==L||t[67]!==R?(z=(0,$.jsxs)(`div`,{children:[L,R]}),t[66]=L,t[67]=R,t[68]=z):z=t[68];let V;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(h,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[69]=V):V=t[69];let H;t[70]===n.systemHeartbeatSettingsLink?H=t[71]:(H=(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,$.jsxs)(B,{to:`/settings/heartbeat`,children:[n.systemHeartbeatSettingsLink,V]})}),t[70]=n.systemHeartbeatSettingsLink,t[71]=H),t[72]!==z||t[73]!==H?(M=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between`,children:[z,H]}),t[72]=z,t[73]=H,t[74]=M):M=t[74],k=`mt-3 grid gap-2 text-sm sm:grid-cols-2`;let U;t[75]===n.systemHeartbeatStatus?U=t[76]:(U=(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatStatus}),t[75]=n.systemHeartbeatStatus,t[76]=U);let W=l.enabled?n.enabled:n.disabled,G;t[77]===W?G=t[78]:(G=(0,$.jsx)(`dd`,{className:`text-fg`,children:W}),t[77]=W,t[78]=G),t[79]!==U||t[80]!==G?(A=(0,$.jsxs)(`div`,{children:[U,G]}),t[79]=U,t[80]=G,t[81]=A):A=t[81],t[82]===n.systemHeartbeatInterval?O=t[83]:(O=(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatInterval}),t[82]=n.systemHeartbeatInterval,t[83]=O),S=`text-fg`;let K;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(K=/\{\{value\}\}/g,t[84]=K):K=t[84],D=n.systemHeartbeatEvery.replace(K,e),t[0]=n.disabled,t[1]=n.enabled,t[2]=n.keepAwake,t[3]=n.systemHeartbeatEvery,t[4]=n.systemHeartbeatHint,t[5]=n.systemHeartbeatInterval,t[6]=n.systemHeartbeatSettingsLink,t[7]=n.systemHeartbeatStatus,t[8]=n.systemHeartbeatTitle,t[9]=n.systemTasksIntro,t[10]=n.tabSystemTasks,t[11]=n.wakeBanner,t[12]=n.wakeLockUnavailable,t[13]=l.enabled,t[14]=l.intervalMs,t[15]=u,t[16]=r,t[17]=i,t[18]=p,t[19]=f,t[20]=d,t[21]=S,t[22]=w,t[23]=T,t[24]=E,t[25]=D,t[26]=O,t[27]=k,t[28]=A,t[29]=j,t[30]=M,t[31]=N,t[32]=P}else S=t[21],w=t[22],T=t[23],E=t[24],D=t[25],O=t[26],k=t[27],A=t[28],j=t[29],M=t[30],N=t[31],P=t[32];let F;t[85]!==S||t[86]!==D?(F=(0,$.jsx)(`dd`,{className:S,children:D}),t[85]=S,t[86]=D,t[87]=F):F=t[87];let I;t[88]!==F||t[89]!==O?(I=(0,$.jsxs)(`div`,{children:[O,F]}),t[88]=F,t[89]=O,t[90]=I):I=t[90];let L;t[91]!==I||t[92]!==k||t[93]!==A?(L=(0,$.jsxs)(`dl`,{className:k,children:[A,I]}),t[91]=I,t[92]=k,t[93]=A,t[94]=L):L=t[94];let R;t[95]!==L||t[96]!==j||t[97]!==M?(R=(0,$.jsxs)(`div`,{className:j,children:[M,L]}),t[95]=L,t[96]=j,t[97]=M,t[98]=R):R=t[98];let z;t[99]===n.systemDreamingTitle?z=t[100]:(z=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemDreamingTitle}),t[99]=n.systemDreamingTitle,t[100]=z);let V;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(h,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[101]=V):V=t[101];let H;t[102]===n.systemDreamingSettingsLink?H=t[103]:(H=(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,$.jsxs)(B,{to:`/settings/dreams`,children:[n.systemDreamingSettingsLink,V]})}),t[102]=n.systemDreamingSettingsLink,t[103]=H);let U;t[104]!==z||t[105]!==H?(U=(0,$.jsxs)(`div`,{className:`mb-2 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[z,H]}),t[104]=z,t[105]=H,t[106]=U):U=t[106];let W;t[107]===n.systemDreamingHint?W=t[108]:(W=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-muted`,children:n.systemDreamingHint}),t[107]=n.systemDreamingHint,t[108]=W);let G;t[109]!==m||t[110]!==n||t[111]!==s||t[112]!==i||t[113]!==x||t[114]!==y||t[115]!==_||t[116]!==b||t[117]!==v||t[118]!==g||t[119]!==o||t[120]!==c?(G=s&&c.length===0?(0,$.jsx)(`div`,{className:`flex justify-center py-12`,"aria-busy":`true`,children:(0,$.jsx)(re,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):c.length===0?(0,$.jsx)(`p`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/30 px-3 py-4 text-sm text-fg-muted dark:border-edge-subtle`,children:n.systemDreamingEmpty}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,children:c.map(e=>(0,$.jsx)(Gt,{job:e,c:n,localeTag:i,scheduleBadgeLabels:o,absorbCardClickJobIdRef:m,scheduleAbsorbNextMenuCardClick:g,onOpenDetail:_,onToggle:v,onEdit:y,onRunNow:b,onDelete:x},e.id))}),t[109]=m,t[110]=n,t[111]=s,t[112]=i,t[113]=x,t[114]=y,t[115]=_,t[116]=b,t[117]=v,t[118]=g,t[119]=o,t[120]=c,t[121]=G):G=t[121];let K;t[122]!==U||t[123]!==W||t[124]!==G?(K=(0,$.jsxs)(`div`,{children:[U,W,G]}),t[122]=U,t[123]=W,t[124]=G,t[125]=K):K=t[125];let ee;return t[126]!==w||t[127]!==T||t[128]!==E||t[129]!==R||t[130]!==K||t[131]!==N||t[132]!==P?(ee=(0,$.jsxs)(`section`,{"aria-labelledby":N,className:P,children:[w,T,E,R,K]}),t[126]=w,t[127]=T,t[128]=E,t[129]=R,t[130]=K,t[131]=N,t[132]=P,t[133]=ee):ee=t[133],ee}function Yt(e,t){let n=e.templates;if(!n||typeof n!=`object`)return;let r=n[t];if(!r||typeof r!=`object`)return;let i=r.title?.trim(),a=r.prompt?.trim();if(!(!i||!a))return{title:i,description:(r.description??``).trim(),prompt:a}}var Xt=[`daily`,`monitoring`,`reports`,`automation`],Zt=[{templateId:`morning_briefing`,category:`daily`,defaultSchedule:`0 7 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`standup_prep`,category:`daily`,defaultSchedule:`0 8 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`meeting_prep`,category:`daily`,defaultSchedule:`0 9 * * 1-5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`meeting_prep`},{templateId:`end_of_day_wrap_up`,category:`daily`,defaultSchedule:`0 18 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`inbox_triage`,category:`daily`,defaultSchedule:`30 8 * * 1-5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`inbox_triage`},{templateId:`competitor_watch`,category:`monitoring`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`competitor_scan`},{templateId:`trending_topics_monitor`,category:`monitoring`,defaultSchedule:`0 10 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`tech_radar_stack`,category:`monitoring`,defaultSchedule:`0 11 * * 3`,defaultSessionTarget:`isolated`},{templateId:`dependency_check_audit`,category:`monitoring`,defaultSchedule:`0 9 * * 0`,defaultSessionTarget:`isolated`},{templateId:`weekly_review`,category:`reports`,defaultSchedule:`0 17 * * 5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`weekly_review`},{templateId:`code_quality_report`,category:`reports`,defaultSchedule:`0 14 * * 1`,defaultSessionTarget:`isolated`},{templateId:`git_activity_summary`,category:`reports`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`},{templateId:`user_feedback_digest`,category:`reports`,defaultSchedule:`0 16 * * 5`,defaultSessionTarget:`isolated`},{templateId:`content_repurpose`,category:`reports`,defaultSchedule:`0 11 * * 4`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`content_repurpose`},{templateId:`stale_todo_or_issue_sweep`,category:`automation`,defaultSchedule:`0 10 * * 2`,defaultSessionTarget:`isolated`},{templateId:`release_notes_or_changelog_draft`,category:`automation`,defaultSchedule:`0 10 * * 4`,defaultSessionTarget:`isolated`},{templateId:`client_proposal`,category:`automation`,defaultSchedule:`0 10 * * 2`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`client_proposal`},{templateId:`offer_design`,category:`automation`,defaultSchedule:`0 14 1 * *`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`offer_design`},{templateId:`decision_compare`,category:`automation`,defaultSchedule:`0 15 * * 3`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`decision_compare`},{templateId:`workspace_cleanup_suggestions`,category:`automation`,defaultSchedule:`30 18 * * 5`,defaultSessionTarget:`isolated`},{templateId:`smoke_or_ci_health_reminder`,category:`automation`,defaultSchedule:`0 8 * * 1`,defaultSessionTarget:`isolated`}];function Qt(e){return Zt.find(t=>t.templateId===e)}function $t(e,t,n){let r=t.trim().toLowerCase();return Zt.filter(t=>{if(n!==`all`&&t.category!==n)return!1;if(!r)return!0;let i=Yt(e,t.templateId);return[t.templateId,i?.title,i?.description,e.templateCategories[t.category]].filter(Boolean).join(` `).toLowerCase().includes(r)})}function en(e){let t=new Map;for(let n of e){let e=t.get(n.category)??[];e.push(n),t.set(n.category,e)}return Xt.flatMap(e=>{let n=t.get(e);return n?.length?[{category:e,items:n}]:[]})}function tn(e){let t=(0,Q.c)(23),{template:n,cron:r,localeTag:i,scheduleBadgeLabels:a,onSelectTemplate:o}=e,s;t[0]!==r||t[1]!==n.templateId?(s=Yt(r,n.templateId),t[0]=r,t[1]=n.templateId,t[2]=s):s=t[2];let c=s;if(!c)return null;let l;t[3]!==i||t[4]!==a||t[5]!==n.defaultSchedule?(l=Ve({schedule:n.defaultSchedule,timezone:void 0,next_run:void 0},i,a),t[3]=i,t[4]=a,t[5]=n.defaultSchedule,t[6]=l):l=t[6];let u=l,d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=X(`flex h-full flex-col gap-1.5 rounded-xl border border-edge-subtle bg-surface-base p-4 text-left transition-colors`,`hover:border-accent/40 hover:bg-surface-hover`,le.focusRingPanel),t[7]=d):d=t[7];let f;t[8]!==o||t[9]!==n.templateId?(f=()=>o(n.templateId),t[8]=o,t[9]=n.templateId,t[10]=f):f=t[10];let p=`${r.templateCategories[n.category]} — ${c.title}`,m;t[11]===c.title?m=t[12]:(m=(0,$.jsx)(`span`,{className:`font-semibold text-fg`,children:c.title}),t[11]=c.title,t[12]=m);let h;t[13]===c.description?h=t[14]:(h=(0,$.jsx)(`span`,{className:`line-clamp-2 text-sm text-fg-muted`,children:c.description}),t[13]=c.description,t[14]=h);let g;t[15]===u?g=t[16]:(g=(0,$.jsx)(`span`,{className:`mt-auto flex items-center gap-1 pt-1 text-xs text-fg-muted`,children:(0,$.jsx)(`span`,{className:`tabular-nums`,children:u})}),t[15]=u,t[16]=g);let _;return t[17]!==f||t[18]!==p||t[19]!==m||t[20]!==h||t[21]!==g?(_=(0,$.jsxs)(`button`,{type:`button`,className:d,onClick:f,"aria-label":p,children:[m,h,g]}),t[17]=f,t[18]=p,t[19]=m,t[20]=h,t[21]=g,t[22]=_):_=t[22],_}function nn(e){let t=(0,Q.c)(49),{cron:n,localeTag:r,scheduleBadgeLabels:i,categoryFilter:a,onCategoryFilterChange:o,onSelectTemplate:s,variant:c}=e,l=c===void 0?`embedded`:c,[u,d]=(0,Z.useState)(``),f;t[0]!==a||t[1]!==n||t[2]!==u?(f=$t(n,u,a),t[0]=a,t[1]=n,t[2]=u,t[3]=f):f=t[3];let p=f,m;t[4]===p?m=t[5]:(m=en(p),t[4]=p,t[5]=m);let h=m,g;t[6]!==a||t[7]!==u?(g=a===`all`&&!u.trim(),t[6]=a,t[7]=u,t[8]=g):g=t[8];let _=g,v;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(z,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=v):v=t[9];let y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>d(e.target.value),t[10]=y):y=t[10];let b=n.templateSearchPlaceholder,x;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(x=X(`h-10 w-full rounded-xl border border-edge bg-surface-base py-2 pl-10 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,le.focusRingPanel),t[11]=x):x=t[11];let S;t[12]!==n.templateSearchPlaceholder||t[13]!==u?(S=(0,$.jsxs)(`div`,{className:`relative`,children:[v,(0,$.jsx)(`input`,{value:u,onChange:y,placeholder:b,className:x})]}),t[12]=n.templateSearchPlaceholder,t[13]=u,t[14]=S):S=t[14];let C=n.fromTemplate,w=a===`all`?`secondary`:`ghost`,T;t[15]===o?T=t[16]:(T=()=>o(`all`),t[15]=o,t[16]=T);let E;t[17]!==n.templateFilterAll||t[18]!==w||t[19]!==T?(E=(0,$.jsx)(J,{type:`button`,variant:w,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:T,children:n.templateFilterAll}),t[17]=n.templateFilterAll,t[18]=w,t[19]=T,t[20]=E):E=t[20];let D;t[21]!==a||t[22]!==n.templateCategories||t[23]!==o?(D=Xt.map(e=>(0,$.jsx)(J,{type:`button`,variant:a===e?`secondary`:`ghost`,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:()=>o(e),children:n.templateCategories[e]},e)),t[21]=a,t[22]=n.templateCategories,t[23]=o,t[24]=D):D=t[24];let O;t[25]!==n.fromTemplate||t[26]!==E||t[27]!==D?(O=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":C,children:[E,D]}),t[25]=n.fromTemplate,t[26]=E,t[27]=D,t[28]=O):O=t[28];let k;t[29]!==O||t[30]!==S?(k=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4`,children:[S,O]}),t[29]=O,t[30]=S,t[31]=k):k=t[31];let A=k,j;t[32]!==n||t[33]!==p||t[34]!==h||t[35]!==r||t[36]!==s||t[37]!==i||t[38]!==_||t[39]!==l?(j=p.length===0?(0,$.jsx)(`div`,{className:X(`text-center text-sm text-fg-muted`,l===`dialog`&&`flex h-full flex-col items-center justify-center px-4 py-12`),children:n.templatesEmptyHint}):_?(0,$.jsx)(`div`,{className:`flex flex-col gap-6 pb-1`,children:h.map(e=>(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n.templateCategories[e.category]}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:e.items.map(e=>(0,$.jsx)(tn,{template:e,cron:n,localeTag:r,scheduleBadgeLabels:i,onSelectTemplate:s},e.templateId))})]},e.category))}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 pb-1 sm:grid-cols-2 xl:grid-cols-3`,children:p.map(e=>(0,$.jsx)(tn,{template:e,cron:n,localeTag:r,scheduleBadgeLabels:i,onSelectTemplate:s},e.templateId))}),t[32]=n,t[33]=p,t[34]=h,t[35]=r,t[36]=s,t[37]=i,t[38]=_,t[39]=l,t[40]=j):j=t[40];let M=j;if(l===`dialog`){let e;t[41]===M?e=t[42]:(e=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:M}),t[41]=M,t[42]=e);let n;return t[43]!==A||t[44]!==e?(n=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4`,children:[A,e]}),t[43]=A,t[44]=e,t[45]=n):n=t[45],n}let N;return t[46]!==A||t[47]!==M?(N=(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[A,M]}),t[46]=A,t[47]=M,t[48]=N):N=t[48],N}function rn(e){let t=(0,Q.c)(49),{c:n,localeTag:r,scheduleBadgeLabels:i,loading:a,jobsCount:o,sortedJobs:s,templateCategoryFilter:c,onTemplateCategoryFilterChange:l,onSelectTemplate:u,keepAwake:d,wakeSupported:f,onWakeUnsupportedClick:p,onKeepAwakeToggle:m,absorbCardClickJobIdRef:h,scheduleAbsorbNextMenuCardClick:g,onOpenDetail:_,onToggle:v,onEdit:y,onAddJob:b,onRunNow:x,onDelete:S}=e,w;t[0]===n.tabMyTasks?w=t[1]:(w=(0,$.jsx)(`h2`,{id:`cron-tasks-panel`,className:`sr-only`,children:n.tabMyTasks}),t[0]=n.tabMyTasks,t[1]=w);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(C,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=T):T=t[2];let E;t[3]===n.wakeBanner?E=t[4]:(E=(0,$.jsxs)(`div`,{className:`flex gap-3 text-sm text-fg`,children:[T,(0,$.jsx)(`p`,{className:`text-pretty text-fg-muted`,children:n.wakeBanner})]}),t[3]=n.wakeBanner,t[4]=E);let D;t[5]===n.keepAwake?D=t[6]:(D=(0,$.jsx)(`span`,{className:`text-sm text-fg`,children:n.keepAwake}),t[5]=n.keepAwake,t[6]=D);let O=!f,k=f?void 0:n.wakeLockUnavailable,A=d?`justify-end bg-accent`:`justify-start bg-surface-hover`,j=!f&&`cursor-not-allowed opacity-50`,M;t[7]!==A||t[8]!==j?(M=X(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,A,j),t[7]=A,t[8]=j,t[9]=M):M=t[9];let N;t[10]!==m||t[11]!==p||t[12]!==f?(N=()=>{f?m():p()},t[10]=m,t[11]=p,t[12]=f,t[13]=N):N=t[13];let P;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[14]=P):P=t[14];let F;t[15]!==d||t[16]!==N||t[17]!==O||t[18]!==k||t[19]!==M?(F=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":d,disabled:O,title:k,className:M,onClick:N,children:P}),t[15]=d,t[16]=N,t[17]=O,t[18]=k,t[19]=M,t[20]=F):F=t[20];let I;t[21]!==F||t[22]!==D?(I=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:pl-4`,children:[D,F]}),t[21]=F,t[22]=D,t[23]=I):I=t[23];let L;t[24]!==I||t[25]!==E?(L=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10 sm:flex-row sm:items-center sm:justify-between`,children:[E,I]}),t[24]=I,t[25]=E,t[26]=L):L=t[26];let R;t[27]!==h||t[28]!==n||t[29]!==o||t[30]!==a||t[31]!==r||t[32]!==b||t[33]!==S||t[34]!==y||t[35]!==_||t[36]!==x||t[37]!==u||t[38]!==l||t[39]!==v||t[40]!==g||t[41]!==i||t[42]!==s||t[43]!==c?(R=a&&o===0?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,"aria-busy":`true`,children:(0,$.jsx)(re,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):o===0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-6 rounded-2xl bg-surface-base px-4 py-8 dark:bg-surface-hover/25 sm:px-6 sm:py-10`,children:[(0,$.jsx)(`div`,{className:`w-full max-w-6xl`,children:(0,$.jsx)(nn,{cron:n,localeTag:r,scheduleBadgeLabels:i,categoryFilter:c,onCategoryFilterChange:l,onSelectTemplate:u})}),(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(J,{type:`button`,variant:`primary`,onClick:b,children:n.emptyStateCta})})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,children:s.map(e=>(0,$.jsx)(Gt,{job:e,c:n,localeTag:r,scheduleBadgeLabels:i,absorbCardClickJobIdRef:h,scheduleAbsorbNextMenuCardClick:g,onOpenDetail:e=>void _(e),onToggle:(e,t)=>void v(e,t),onEdit:y,onRunNow:x,onDelete:S},e.id))}),t[27]=h,t[28]=n,t[29]=o,t[30]=a,t[31]=r,t[32]=b,t[33]=S,t[34]=y,t[35]=_,t[36]=x,t[37]=u,t[38]=l,t[39]=v,t[40]=g,t[41]=i,t[42]=s,t[43]=c,t[44]=R):R=t[44];let z;return t[45]!==w||t[46]!==L||t[47]!==R?(z=(0,$.jsxs)(`section`,{"aria-labelledby":`cron-tasks-panel`,className:`flex flex-col gap-4`,children:[w,L,R]}),t[45]=w,t[46]=L,t[47]=R,t[48]=z):z=t[48],z}function an(e){let t=(0,Q.c)(29),{open:n,onOpenChange:r,c:i,localeTag:a,scheduleBadgeLabels:o,categoryFilter:s,onCategoryFilterChange:c,onSelectTemplate:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(R,{className:`xopc-dialog-overlay fixed inset-0 z-[62] bg-scrim`}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=X(`xopc-dialog-content-pane pointer-events-auto relative flex h-[min(90vh,840px)] w-full max-w-5xl flex-col`,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,le.focusRingPanel),t[1]=d):d=t[1];let f;t[2]===i.fromTemplate?f=t[3]:(f=(0,$.jsx)(M,{className:`text-lg font-semibold text-fg`,children:i.fromTemplate}),t[2]=i.fromTemplate,t[3]=f);let p;t[4]===i.templatePickerHint?p=t[5]:(p=(0,$.jsx)(me,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.templatePickerHint}),t[4]=i.templatePickerHint,t[5]=p);let m;t[6]!==f||t[7]!==p?(m=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[f,p]}),t[6]=f,t[7]=p,t[8]=m):m=t[8];let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(te,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=h):h=t[9];let g;t[10]===i.close?g=t[11]:(g=(0,$.jsx)(L,{asChild:!0,children:(0,$.jsx)(J,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":i.close,children:h})}),t[10]=i.close,t[11]=g);let _;t[12]!==m||t[13]!==g?(_=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge-subtle px-6 py-5`,children:[m,g]}),t[12]=m,t[13]=g,t[14]=_):_=t[14];let v;t[15]!==i||t[16]!==s||t[17]!==a||t[18]!==c||t[19]!==l||t[20]!==o?(v=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-6 py-5`,children:(0,$.jsx)(nn,{variant:`dialog`,cron:i,localeTag:a,scheduleBadgeLabels:o,categoryFilter:s,onCategoryFilterChange:c,onSelectTemplate:l})}),t[15]=i,t[16]=s,t[17]=a,t[18]=c,t[19]=l,t[20]=o,t[21]=v):v=t[21];let S;t[22]!==_||t[23]!==v?(S=(0,$.jsxs)(x,{children:[u,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[62] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(y,{className:d,onOpenAutoFocus:on,children:[_,v]})})]}),t[22]=_,t[23]=v,t[24]=S):S=t[24];let C;return t[25]!==r||t[26]!==n||t[27]!==S?(C=(0,$.jsx)(b,{open:n,onOpenChange:r,children:S}),t[25]=r,t[26]=n,t[27]=S,t[28]=C):C=t[28],C}function on(e){return e.preventDefault()}function sn(){return{formOpen:!1,formMode:`add`,formJobId:null,formName:``,formSchedule:dt,formChannel:`local`,formChatId:``,formMessage:``,formMessageMdMode:`edit`,formTaskKind:`message`,formWorkflowDefinitionId:``,formWorkflowGoal:``,formWorkflowArgValues:{},messageEditorNonce:0,formSessionTarget:`main`,formAgentId:``,formAgentLocalOnly:!1,formWorkingDirectory:``,formModel:``,formSubmitting:!1}}function cn(e,t){switch(t.type){case`patch`:return{...e,...t.patch};case`replace`:return t.state;case`setMessageMdMode`:return{...e,formMessageMdMode:t.mode,messageEditorNonce:t.mode===`edit`?e.messageEditorNonce+1:e.messageEditorNonce}}}function ln(e,t){let n=sn();if(n.formOpen=!0,n.formMode=e?`edit`:`add`,n.formJobId=e?.id??null,!e)return n.formModel=t(),n;n.formName=e.name||``,n.formSchedule=e.schedule&&String(e.schedule).trim()||`*/5 * * * *`;let r=Pe(e);if(n.formMessage=r??``,e.payload.kind===`workflowRun`){n.formTaskKind=`workflowRun`,n.formWorkflowDefinitionId=e.payload.definitionId,n.formWorkflowGoal=e.payload.goal||``,n.formWorkflowArgValues=Mt(e.payload.definitionId,e.payload.inputEnvelope?.payload??e.payload.input??{});let t=e.payload.agentId?.trim().toLowerCase();t&&(n.formAgentId=t)}n.formSessionTarget=e.sessionTarget||`main`,n.formAgentId=(e.sessionTarget||`main`)===`isolated`&&e.agentId?.trim()?e.agentId.trim().toLowerCase():``,n.formWorkingDirectory=(e.sessionTarget||`main`)===`isolated`&&e.workingDirectory?.trim()?e.workingDirectory.trim():``;let i=e.payload?.kind===`agentTurn`&&e.payload.model?.trim()?e.payload.model.trim():``;n.formModel=e.model?.trim()||i||t();let a=e.delivery?.channel===`local`,o=(e.sessionTarget||`main`)===`isolated`&&!a&&(!e.delivery?.to||e.delivery.mode===`none`);if(n.formAgentLocalOnly=o,a)n.formChannel=`local`,n.formChatId=``;else if(e.delivery&&e.delivery.mode!==`none`&&e.delivery.to)n.formChannel=e.delivery.channel||`telegram`,n.formChatId=e.delivery.to||``;else if(o)n.formChannel=`telegram`,n.formChatId=``;else{let e=r.split(`:`);e.length>=3&&[`telegram`,`cli`,`gateway`,`local`].includes(e[0])?(n.formChannel=e[0],n.formChatId=e[1],n.formMessage=e.slice(2).join(`:`)):(n.formChannel=`telegram`,n.formChatId=``)}return n.formMessageMdMode=`edit`,n.messageEditorNonce=1,n}function un(e){let{m:t,defaultModelForForm:n,channels:r,chatAgents:i}=e,[a,o]=(0,Z.useReducer)(cn,void 0,sn),s=(0,Z.useRef)(!1),c=(0,Z.useMemo)(()=>new Set([`local`,...r.map(e=>e.name)]),[r]);if(a.formOpen&&a.formMode===`add`&&!c.has(a.formChannel)&&o({type:`patch`,patch:{formChannel:`local`}}),a.formOpen&&a.formMode===`add`&&!s.current){let e=n();e&&e!==a.formModel&&o({type:`patch`,patch:{formModel:e}})}let l=he(()=>Fe(a.formChannel),[a.formChannel],{enabled:a.formOpen&&a.formChannel!==`local`,initial:[],errorData:[]}),u=a.formChannel===`local`?[]:l.data,d=(0,Z.useMemo)(()=>{let e=new Set(i.map(e=>e.id)),t=[...i],n=a.formAgentId.trim().toLowerCase();return n&&!e.has(n)&&t.push({id:n}),t},[i,a.formAgentId]),f=a.formChannel!==`local`&&(a.formTaskKind===`message`&&(a.formSessionTarget===`main`||a.formSessionTarget===`isolated`&&!a.formAgentLocalOnly)||a.formTaskKind===`workflowRun`&&!a.formAgentLocalOnly),p=a.formTaskKind===`workflowRun`?!a.formAgentLocalOnly:a.formTaskKind===`message`&&(a.formSessionTarget===`main`||a.formSessionTarget===`isolated`&&!a.formAgentLocalOnly),m=a.formTaskKind===`workflowRun`?!!a.formWorkflowDefinitionId.trim()&&Nt(a.formWorkflowDefinitionId.trim(),a.formWorkflowArgValues):!!a.formMessage.trim(),h=!!a.formName.trim()&&!!a.formSchedule.trim()&&m&&(!f||!!a.formChatId.trim()),g=(0,Z.useCallback)(e=>{s.current=!1,o({type:`replace`,state:ln(e,n)})},[n]),_=(0,Z.useCallback)(e=>{o({type:`setMessageMdMode`,mode:e})},[]),v=(0,Z.useCallback)(e=>{let r=Qt(e),i=r?Yt(t.cron,e):void 0;if(!r||!i)return!1;let a=r.taskKind===`workflowRun`&&!!r.workflowDefinitionId;return s.current=!1,o({type:`replace`,state:{...sn(),formOpen:!0,formMode:`add`,formName:i.title,formSchedule:r.defaultSchedule,formMessage:a?``:i.prompt,formTaskKind:a?`workflowRun`:`message`,formWorkflowDefinitionId:a?r.workflowDefinitionId:``,formWorkflowGoal:a?i.description:``,formSessionTarget:r.defaultSessionTarget,formModel:n(),formAgentLocalOnly:a,messageEditorNonce:1}}),!0},[n,t.cron]),y=(0,Z.useCallback)(()=>{s.current=!1,o({type:`replace`,state:sn()})},[]),b=(0,Z.useCallback)((e,t,n)=>{let r={formSessionTarget:e};e===`main`?(r.formAgentLocalOnly=!1,r.formAgentId=``,r.formWorkingDirectory=``):e===`isolated`&&!n&&(r.formModel=t()),o({type:`patch`,patch:r})},[]),x=(0,Z.useCallback)(e=>{o({type:`patch`,patch:{formChannel:e,formChatId:``,...e===`local`?{formAgentLocalOnly:!1}:{}}})},[]),S=(0,Z.useCallback)(e=>{s.current=!0,o({type:`patch`,patch:{formModel:e}})},[]),C=(0,Z.useCallback)(()=>{Fe(a.formChannel).then(l.setData)},[a.formChannel,l.setData]),w=(0,Z.useCallback)(e=>{o({type:`patch`,patch:e})},[]);return{formOpen:a.formOpen,formMode:a.formMode,formJobId:a.formJobId,formName:a.formName,formSchedule:a.formSchedule,formChannel:a.formChannel,formChatId:a.formChatId,formMessage:a.formMessage,formMessageMdMode:a.formMessageMdMode,formTaskKind:a.formTaskKind,formWorkflowDefinitionId:a.formWorkflowDefinitionId,formWorkflowGoal:a.formWorkflowGoal,formWorkflowArgValues:a.formWorkflowArgValues,messageEditorNonce:a.messageEditorNonce,formSessionTarget:a.formSessionTarget,formAgentId:a.formAgentId,formAgentLocalOnly:a.formAgentLocalOnly,formWorkingDirectory:a.formWorkingDirectory,formModel:a.formModel,formSubmitting:a.formSubmitting,sessionChatIds:u,setFormName:e=>w({formName:e}),setFormSchedule:e=>w({formSchedule:e}),setFormChatId:e=>w({formChatId:e}),setFormMessage:e=>w({formMessage:e}),setFormTaskKind:e=>w(e===`workflowRun`?{formTaskKind:e,formSessionTarget:`isolated`,formAgentLocalOnly:!1}:{formTaskKind:e}),setFormWorkflowDefinitionId:e=>w({formWorkflowDefinitionId:e,formWorkflowArgValues:{}}),setFormWorkflowGoal:e=>w({formWorkflowGoal:e}),setFormWorkflowArgValues:e=>w({formWorkflowArgValues:e}),setFormAgentId:e=>w({formAgentId:e}),setFormAgentLocalOnly:e=>w({formAgentLocalOnly:e}),setFormWorkingDirectory:e=>w({formWorkingDirectory:e}),setFormSubmitting:e=>w({formSubmitting:e}),canSubmit:h,needsDeliveryChat:f,showChannelPicker:p,cronAgentSelectOptions:d,openForm:g,closeForm:y,applyCronTemplate:v,setMessageMdMode:_,handleFormSessionTargetChange:b,handleFormChannelChange:x,handleFormModelUserChange:S,refreshRecipientsList:C}}function dn(e){let{onUnavailable:t}=e,[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(null),a=(0,Z.useRef)(`none`),o=(0,Z.useRef)(n),s=typeof navigator<`u`&&`wakeLock`in navigator,c=s||g(),l=(0,Z.useCallback)(async()=>{if(a.current===`electron`){try{await window.electronAPI?.cron?.setDisplaySleepPrevented?.(!1)}catch{}a.current=`none`;return}try{await i.current?.release()}catch{}i.current=null,a.current=`none`},[]),u=(0,Z.useCallback)(async()=>{let e=typeof window<`u`?window.electronAPI?.cron?.setDisplaySleepPrevented:void 0;if(e)try{await e(!0),a.current=`electron`;return}catch{t(),r(!1);return}if(s)try{let e=await navigator.wakeLock.request(`screen`);i.current=e,a.current=`navigator`,e.addEventListener(`release`,()=>{i.current=null,a.current=`none`})}catch{t(),r(!1)}},[t,s]);return o.current=n,(0,Z.useEffect)(()=>{if(!n){l();return}u();let e=()=>{document.visibilityState===`visible`&&o.current&&u()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),l()}},[n,u,l]),{keepAwake:n,setKeepAwake:r,featureAvailable:c}}function fn(e){let{hasToken:t,failMessages:n,isHistoryTab:r}=e,[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(``),[f,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),T=(0,Z.useCallback)(async()=>{S(!0),w(null);try{a(await Me())}catch(e){w(e instanceof Error?e.message:n.failedToLoadJobs)}finally{S(!1)}},[n.failedToLoadJobs]),E=(0,Z.useCallback)(async()=>{try{let[e,t,n,r,i]=await Promise.all([Ee(),Oe(),je(),p(),fe().catch(()=>null)]);s(e),l(t),d(n.model||``),g(r.payload?.config??null),i&&m(i.items)}catch{}},[]),D=(0,Z.useCallback)(async()=>{b(!0);try{v(await Le(400))}catch{}finally{b(!1)}},[]);return(0,Z.useEffect)(()=>{t&&(T(),E())},[t,T,E]),(0,Z.useEffect)(()=>{if(!t)return;let e=()=>{p().then(e=>{g(e.payload?.config??null)})};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[t]),(0,Z.useEffect)(()=>{!t||!r||D()},[t,r,D]),{jobs:i,channels:o,availableModels:c,defaultModel:u,chatAgents:f,gatewayConfigRaw:h,runHistory:_,runHistoryLoading:y,loading:x,error:C,setError:w,userCronJobs:(0,Z.useMemo)(()=>i.filter(e=>!Ne(e)),[i]),systemCronJobs:(0,Z.useMemo)(()=>i.filter(e=>Ne(e)),[i]),heartbeatFromConfig:(0,Z.useMemo)(()=>Ge(h),[h]),loadJobs:T,loadAux:E,loadRunHistoryOnly:D,refreshAll:(0,Z.useCallback)(()=>{T(),E(),D()},[T,E,D])}}function pn(e,t){let n=[...e];return n.sort((e,n)=>{let r=new Date(e.created_at).getTime(),i=new Date(n.created_at).getTime();return t===`created_desc`?i-r:r-i}),n}function mn(e,t,n,r){let i=new Date,a=t===`day`?pt(i):t===`week`?mt(i):ht(i);return e.filter(e=>!(new Date(e.startedAt)<a||n&&e.jobId!==n||r&&e.status!==r))}var hn={mainTab:`myTasks`,jobSort:`created_desc`,historyRange:`day`,historyJobFilter:``,historyStatusFilter:``,detailOpen:!1,detailJob:null,detailHistory:[],detailLoading:!1,confirmOpen:!1,templatePickerOpen:!1,templateCategoryFilter:`all`};function gn(){let e=i(e=>e.language),t=a(e),n=t.cron,r=t.chat,o=u(e=>e.token),c=!!o,d=l(e=>e.resolved)===`dark`,f=e===`zh`?`zh-CN`:`en-US`,[p,m]=ee(),[h,g]=(0,Z.useReducer)(N,p,e=>({...hn,mainTab:St(e.get(`tab`))})),{mainTab:v,jobSort:y,historyRange:b,historyJobFilter:x,historyStatusFilter:S,detailOpen:C,detailJob:w,detailHistory:T,detailLoading:E,confirmOpen:D,templatePickerOpen:O,templateCategoryFilter:k}=h,A=St(p.get(`tab`));(0,Z.useEffect)(()=>{A!==v&&g({type:`patch`,patch:{mainTab:A}})},[A,v]);let j=(0,Z.useCallback)(e=>{g({type:`patch`,patch:{mainTab:e}}),m(t=>{let n=new URLSearchParams(t),r=Ct(e);return r?n.set(`tab`,r):n.delete(`tab`),n},{replace:!0})},[m]),M=fn({hasToken:c,failMessages:{failedToLoadJobs:n.failedToLoadJobs},isHistoryTab:v===`history`}),{setError:P}=M,F=dn({onUnavailable:()=>P(n.wakeLockUnavailable)}),I=(0,Z.useCallback)(()=>M.defaultModel||(M.availableModels.length>0?M.availableModels[0].id:``),[M.defaultModel,M.availableModels]),L=un({m:t,defaultModelForForm:I,channels:M.channels,chatAgents:M.chatAgents}),R=s(c&&L.formOpen?[`workflow-definitions-cron`,o]:null,_,{revalidateOnFocus:!1}),z=R.data??[],B=(0,Z.useRef)(null),V=(0,Z.useRef)(null),H=(0,Z.useCallback)((e,t)=>{B.current=e,V.current=t,g({type:`patch`,patch:{confirmOpen:!0}})},[]),U=(0,Z.useCallback)(()=>{g({type:`patch`,patch:{confirmOpen:!1}}),V.current=null,B.current=null},[]),W=(0,Z.useRef)(null),G=(0,Z.useCallback)(e=>{W.current=e,window.setTimeout(()=>{W.current===e&&(W.current=null)},400)},[]),K=(0,Z.useCallback)(e=>{L.applyCronTemplate(e)&&g({type:`patch`,patch:{templatePickerOpen:!1}})},[L]),te=async()=>{if(!L.formName.trim()){P(n.nameRequired);return}if(!L.formSchedule.trim()){P(n.scheduleRequired);return}if(L.formTaskKind===`message`&&!L.formMessage.trim()){P(n.scheduleRequired);return}if(L.formTaskKind===`workflowRun`&&!L.formWorkflowDefinitionId.trim()){P(n.workflowDefinitionRequired);return}if(L.formTaskKind===`workflowRun`&&!Nt(L.formWorkflowDefinitionId.trim(),L.formWorkflowArgValues)){P(n.workflowArgsRequired);return}if(L.needsDeliveryChat&&!L.formChatId.trim()){P(n.chatIdRequired);return}L.setFormSubmitting(!0),P(null);try{let e=L.formMessage.trim(),t=L.formModel.trim(),n=L.formAgentId.trim().toLowerCase(),r=L.formWorkingDirectory.trim(),i=L.formTaskKind===`workflowRun`,a=L.formTaskKind===`message`&&L.formSessionTarget===`isolated`,o=i?`isolated`:L.formSessionTarget,s;s=i?L.formAgentLocalOnly?{mode:`none`}:L.formChannel===`local`?{mode:`direct`,channel:`local`}:{mode:`direct`,channel:L.formChannel,to:L.formChatId.trim()}:L.formSessionTarget===`isolated`&&L.formAgentLocalOnly?{mode:`none`}:L.formChannel===`local`?{mode:`direct`,channel:`local`}:{mode:`direct`,channel:L.formChannel,to:L.formChatId.trim()};let c;if(i){let e=L.formWorkflowDefinitionId.trim(),t=Je(L.formWorkflowArgValues);c={kind:`workflowRun`,definitionId:e,...t===void 0?{}:{inputEnvelope:{payload:t}},...L.formWorkflowGoal.trim()?{goal:L.formWorkflowGoal.trim()}:{},...n?{agentId:n}:{}}}else c=a?{kind:`agentTurn`,message:e,...t?{model:t}:{}}:{kind:`systemEvent`,text:e};let l=o===`main`?null:n||null,u={name:L.formName.trim(),schedule:L.formSchedule.trim(),sessionTarget:o,model:a&&t?t:void 0,...i?{timeout:ft}:{},delivery:s,payload:c,...L.formMode===`edit`?{agentId:l,workingDirectory:a&&r||null}:{...o===`isolated`&&n?{agentId:n}:{},...a&&r?{workingDirectory:r}:{}}};if(L.formMode===`edit`&&L.formJobId)await Be(L.formJobId,u);else{let{schedule:e,agentId:t,workingDirectory:n,...r}=u;await we(e,{...r,...t==null?{}:{agentId:t},...n?{workingDirectory:n}:{}})}L.closeForm(),await M.loadJobs()}catch(e){P(e instanceof Error?e.message:L.formMode===`edit`?n.failedToUpdateJob:n.failedToCreateJob)}finally{L.setFormSubmitting(!1)}},q=async e=>{g({type:`patch`,patch:{detailOpen:!0,detailJob:e,detailLoading:!0,detailHistory:[]}});try{let t=await De(e.id);t&&g({type:`patch`,patch:{detailJob:t,detailHistory:await ze(e.id,20)}})}catch{}finally{g({type:`patch`,patch:{detailLoading:!1}})}},ne=(0,Z.useCallback)(()=>{g({type:`patch`,patch:{detailOpen:!1,detailJob:null}})},[]),re=(0,Z.useCallback)(()=>{g({type:`patch`,patch:{templateCategoryFilter:`all`,templatePickerOpen:!0}})},[]),ie=async(e,t)=>{try{await Ce(e.id,t),w?.id===e.id&&g({type:`patch`,patch:{detailJob:{...w,enabled:t}}}),await Promise.all([M.loadJobs(),M.loadAux()])}catch(e){P(e instanceof Error?e.message:n.failedToToggleJob)}},J=async()=>{let e=V.current,t=B.current;if(!(!e||!t)){U();try{t===`run`?await ke(e):(await Ae(e),w?.id===e&&g({type:`patch`,patch:{detailOpen:!1,detailJob:null}})),await Promise.all([M.loadJobs(),M.loadAux(),M.loadRunHistoryOnly()])}catch(e){P(e instanceof Error?e.message:n.actionFailed)}}};(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(L.formOpen?L.closeForm():C&&g({type:`patch`,patch:{detailOpen:!1,detailJob:null}}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[L,C]);let Y=(0,Z.useMemo)(()=>({running:n.execStatusRunning,success:n.execStatusSuccess,failed:n.execStatusFailed,cancelled:n.execStatusCancelled}),[n.execStatusCancelled,n.execStatusFailed,n.execStatusRunning,n.execStatusSuccess]),ae=(0,Z.useMemo)(()=>pn(M.userCronJobs,y),[M.userCronJobs,y]),oe=(0,Z.useMemo)(()=>pn(M.systemCronJobs,y),[M.systemCronJobs,y]),se=(0,Z.useMemo)(()=>mn(M.runHistory,b,x,S),[M.runHistory,b,x,S]),ce=n.scheduleBadge;return c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_n,{hasToken:c,c:n,loading:M.loading,runHistoryLoading:M.runHistoryLoading,onRefresh:M.refreshAll,onOpenTemplatePicker:re,onAddJob:()=>L.openForm()}),(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6 sm:px-8`,children:[M.error?(0,$.jsx)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,role:`alert`,children:M.error}):null,(0,$.jsx)(Vt,{c:n,mainTab:v,onMainTabChange:j,jobSort:y,onJobSortChange:e=>g({type:`patch`,patch:{jobSort:e}}),historyRange:b,onHistoryRangeChange:e=>g({type:`patch`,patch:{historyRange:e}}),historyJobFilter:x,onHistoryJobFilterChange:e=>g({type:`patch`,patch:{historyJobFilter:e}}),historyStatusFilter:S,onHistoryStatusFilterChange:e=>g({type:`patch`,patch:{historyStatusFilter:e}}),jobs:M.jobs}),v===`myTasks`?(0,$.jsx)(rn,{c:n,localeTag:f,scheduleBadgeLabels:ce,loading:M.loading,jobsCount:M.userCronJobs.length,sortedJobs:ae,templateCategoryFilter:k,onTemplateCategoryFilterChange:e=>g({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:K,keepAwake:F.keepAwake,wakeSupported:F.featureAvailable,onWakeUnsupportedClick:()=>P(n.wakeLockUnavailable),onKeepAwakeToggle:()=>F.setKeepAwake(e=>!e),absorbCardClickJobIdRef:W,scheduleAbsorbNextMenuCardClick:G,onOpenDetail:e=>void q(e),onToggle:(e,t)=>void ie(e,t),onEdit:e=>L.openForm(e),onAddJob:()=>L.openForm(),onRunNow:e=>H(`run`,e.id),onDelete:e=>H(`delete`,e.id)}):v===`systemTasks`?(0,$.jsx)(Jt,{c:n,language:e,localeTag:f,scheduleBadgeLabels:ce,loading:M.loading,sortedSystemJobs:oe,heartbeat:M.heartbeatFromConfig,keepAwake:F.keepAwake,wakeSupported:F.featureAvailable,onWakeUnsupportedClick:()=>P(n.wakeLockUnavailable),onKeepAwakeToggle:()=>F.setKeepAwake(e=>!e),absorbCardClickJobIdRef:W,scheduleAbsorbNextMenuCardClick:G,onOpenDetail:e=>void q(e),onToggle:(e,t)=>void ie(e,t),onEdit:e=>L.openForm(e),onRunNow:e=>H(`run`,e.id),onDelete:e=>H(`delete`,e.id)}):v===`history`?(0,$.jsx)(Wt,{c:n,runHistoryLoading:M.runHistoryLoading,runHistory:M.runHistory,filteredRunHistory:se,jobs:M.jobs,onRefreshHistory:()=>void M.loadRunHistoryOnly(),onOpenJobDetail:e=>void q(e),statusLabels:Y}):(0,$.jsx)(ct,{hasToken:c})]}),(0,$.jsx)(It,{open:L.formOpen,onRequestClose:L.closeForm,c:n,chatM:r,agentsMessages:t.agentsSettings,isDark:d,channels:M.channels,sessionChatIds:L.sessionChatIds,cronAgentSelectOptions:L.cronAgentSelectOptions,defaultModelResolver:I,formMode:L.formMode,formJobId:L.formJobId,formName:L.formName,onFormNameChange:L.setFormName,formSchedule:L.formSchedule,onFormScheduleChange:L.setFormSchedule,formSubmitting:L.formSubmitting,formTaskKind:L.formTaskKind,onFormTaskKindChange:L.setFormTaskKind,workflowDefinitions:z,workflowDefinitionsLoading:R.isLoading,formWorkflowDefinitionId:L.formWorkflowDefinitionId,onFormWorkflowDefinitionIdChange:L.setFormWorkflowDefinitionId,formWorkflowGoal:L.formWorkflowGoal,onFormWorkflowGoalChange:L.setFormWorkflowGoal,formWorkflowArgValues:L.formWorkflowArgValues,onFormWorkflowArgValuesChange:L.setFormWorkflowArgValues,formSessionTarget:L.formSessionTarget,onFormSessionTargetChange:L.handleFormSessionTargetChange,formAgentLocalOnly:L.formAgentLocalOnly,onFormAgentLocalOnlyChange:L.setFormAgentLocalOnly,formModel:L.formModel,onFormModelUserChange:L.handleFormModelUserChange,formAgentId:L.formAgentId,onFormAgentIdChange:L.setFormAgentId,formWorkingDirectory:L.formWorkingDirectory,onFormWorkingDirectoryChange:L.setFormWorkingDirectory,formChannel:L.formChannel,onFormChannelChange:L.handleFormChannelChange,formChatId:L.formChatId,onFormChatIdChange:L.setFormChatId,formMessage:L.formMessage,onFormMessageChange:L.setFormMessage,formMessageMdMode:L.formMessageMdMode,onSetMessageMdMode:L.setMessageMdMode,messageEditorNonce:L.messageEditorNonce,needsDeliveryChat:L.needsDeliveryChat,showChannelPicker:L.showChannelPicker,canSubmit:L.canSubmit,onSubmit:()=>void te(),onRefreshRecipients:L.refreshRecipientsList}),(0,$.jsx)(an,{open:O,onOpenChange:e=>{g({type:`patch`,patch:{templatePickerOpen:e,...e?{templateCategoryFilter:`all`}:{}}})},c:n,localeTag:f,scheduleBadgeLabels:ce,categoryFilter:k,onCategoryFilterChange:e=>g({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:K}),(0,$.jsx)(kt,{open:C,onDismiss:ne,detailJob:w,detailLoading:E,detailHistory:T,c:n,localeTag:f,scheduleBadgeLabels:ce,chatWorkingDirNotSet:r.workingDirectory.notSet,statusLabels:Y,onEdit:e=>{ne(),L.openForm(e)},onRunNow:e=>H(`run`,e.id),onToggle:(e,t)=>void ie(e,t),onDelete:e=>H(`delete`,e.id)}),(0,$.jsx)(et,{open:D,onOpenChange:e=>g({type:`patch`,patch:{confirmOpen:e}}),action:B.current,c:n,onDismiss:U,onConfirm:J})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_n,{hasToken:c,c:n,loading:M.loading,runHistoryLoading:M.runHistoryLoading,onRefresh:M.refreshAll,onOpenTemplatePicker:re,onAddJob:()=>L.openForm()}),(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-16 text-center text-sm text-fg-muted sm:px-8`,children:n.needToken})]})}function _n(e){let t=(0,Q.c)(14),{hasToken:n,c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}=e,l=I(yn),u=I(vn),d;t[0]!==r||t[1]!==i||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==a?(d=(0,$.jsx)(Ut,{c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}),t[0]=r,t[1]=i,t[2]=c,t[3]=s,t[4]=o,t[5]=a,t[6]=d):d=t[6];let f=d,p,m;return t[7]!==r.title||t[8]!==u||t[9]!==f||t[10]!==n||t[11]!==l?(p=()=>n?(l({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r.title})}),end:f}),()=>u()):(u(),()=>u()),m=[r.title,u,f,n,l],t[7]=r.title,t[8]=u,t[9]=f,t[10]=n,t[11]=l,t[12]=p,t[13]=m):(p=t[12],m=t[13]),(0,Z.useLayoutEffect)(p,m),null}function vn(e){return e.clearPageHeader}function yn(e){return e.setPageHeader}export{gn as CronPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{_ as r,a as i,b as a,c as o,d as s,f as c,i as l,l as u,m as d,n as f,o as p,p as m,r as h,t as g,u as _,v,y}from"./Combination-HAlzriaz.js";import{Fr as b,Mr as x,Nr as ee,Pr as S,jr as C}from"./index-DvTb6wNR.js";var w=e(t(),1),T=n();function E(e){let t=e+`CollectionProvider`,[n,i]=r(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=e=>{let{scope:t,children:n}=e,r=w.useRef(null),i=w.useRef(new Map).current;return(0,T.jsx)(o,{scope:t,itemMap:i,collectionRef:r,children:n})};c.displayName=t;let l=e+`CollectionSlot`,u=d(l),f=w.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,T.jsx)(u,{ref:a(t,s(l,n).collectionRef),children:r})});f.displayName=l;let p=e+`CollectionItemSlot`,m=`data-radix-collection-item`,h=d(p),g=w.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=w.useRef(null),c=a(t,o),l=s(p,n);return w.useEffect(()=>(l.itemMap.set(o,{ref:o,...i}),()=>void l.itemMap.delete(o))),(0,T.jsx)(h,{[m]:``,ref:c,children:r})});g.displayName=p;function _(t){let n=s(e+`CollectionConsumer`,t);return w.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${m}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:c,Slot:f,ItemSlot:g},_,i]}var D=w.createContext(void 0);function O(e){let t=w.useContext(D);return e||t||`ltr`}var k=`rovingFocusGroup.onEntryFocus`,te={bubbles:!1,cancelable:!0},A=`RovingFocusGroup`,[j,M,N]=E(A),[ne,P]=r(A,[N]),[re,F]=ne(A),I=w.forwardRef((e,t)=>(0,T.jsx)(j.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,T.jsx)(j.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,T.jsx)(ie,{...e,ref:t})})}));I.displayName=A;var ie=w.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...m}=e,g=w.useRef(null),_=a(t,g),y=O(o),[b,x]=h({prop:l,defaultProp:u??null,onChange:d,caller:A}),[ee,S]=w.useState(!1),C=s(f),E=M(n),D=w.useRef(!1),[j,N]=w.useState(0);return w.useEffect(()=>{let e=g.current;if(e)return e.addEventListener(k,C),()=>e.removeEventListener(k,C)},[C]),(0,T.jsx)(re,{scope:n,orientation:r,dir:y,loop:i,currentTabStopId:b,onItemFocus:w.useCallback(e=>x(e),[x]),onItemShiftTab:w.useCallback(()=>S(!0),[]),onFocusableItemAdd:w.useCallback(()=>N(e=>e+1),[]),onFocusableItemRemove:w.useCallback(()=>N(e=>e-1),[]),children:(0,T.jsx)(c.div,{tabIndex:ee||j===0?-1:0,"data-orientation":r,...m,ref:_,style:{outline:`none`,...e.style},onMouseDown:v(e.onMouseDown,()=>{D.current=!0}),onFocus:v(e.onFocus,e=>{let t=!D.current;if(e.target===e.currentTarget&&t&&!ee){let t=new CustomEvent(k,te);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=E().filter(e=>e.focusable);ce([e.find(e=>e.active),e.find(e=>e.id===b),...e].filter(Boolean).map(e=>e.ref.current),p)}}D.current=!1}),onBlur:v(e.onBlur,()=>S(!1))})})}),L=`RovingFocusGroupItem`,R=w.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,l=p(),u=a||l,d=F(L,n),f=d.currentTabStopId===u,m=M(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:_}=d;return w.useEffect(()=>{if(r)return h(),()=>g()},[r,h,g]),(0,T.jsx)(j.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:(0,T.jsx)(c.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...s,ref:t,onMouseDown:v(e.onMouseDown,e=>{r?d.onItemFocus(u):e.preventDefault()}),onFocus:v(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:v(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){d.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=se(e,d.orientation,d.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=m().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=d.loop?le(n,r+1):n.slice(r+1)}setTimeout(()=>ce(n))}}),children:typeof o==`function`?o({isCurrentTabStop:f,hasTabStop:_!=null}):o})})});R.displayName=L;var ae={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function oe(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function se(e,t,n){let r=oe(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return ae[r]}function ce(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function le(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ue=I,de=R,fe=[`Enter`,` `],pe=[`ArrowDown`,`PageUp`,`Home`],me=[`ArrowUp`,`PageDown`,`End`],he=[...pe,...me],ge={ltr:[...fe,`ArrowRight`],rtl:[...fe,`ArrowLeft`]},_e={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},z=`Menu`,[B,ve,ye]=E(z),[V,be]=r(z,[ye,b,P]),H=b(),xe=P(),[Se,U]=V(z),[Ce,W]=V(z),we=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,c=H(t),[l,u]=w.useState(null),d=w.useRef(!1),f=s(a),p=O(i);return w.useEffect(()=>{let e=()=>{d.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>d.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,T.jsx)(S,{...c,children:(0,T.jsx)(Se,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:(0,T.jsx)(Ce,{scope:t,onClose:w.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:o,children:r})})})};we.displayName=z;var Te=`MenuAnchor`,Ee=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=H(n);return(0,T.jsx)(C,{...i,...r,ref:t})});Ee.displayName=Te;var De=`MenuPortal`,[Oe,ke]=V(De,{forceMount:void 0}),Ae=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:a}=e,o=U(De,t);return(0,T.jsx)(Oe,{scope:t,forceMount:n,children:(0,T.jsx)(l,{present:n||o.open,children:(0,T.jsx)(i,{asChild:!0,container:a,children:r})})})};Ae.displayName=De;var G=`MenuContent`,[je,Me]=V(G),Ne=w.forwardRef((e,t)=>{let n=ke(G,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=U(G,e.__scopeMenu),o=W(G,e.__scopeMenu);return(0,T.jsx)(B.Provider,{scope:e.__scopeMenu,children:(0,T.jsx)(l,{present:r||a.open,children:(0,T.jsx)(B.Slot,{scope:e.__scopeMenu,children:o.modal?(0,T.jsx)(Pe,{...i,ref:t}):(0,T.jsx)(Fe,{...i,ref:t})})})})}),Pe=w.forwardRef((e,t)=>{let n=U(G,e.__scopeMenu),r=w.useRef(null),i=a(t,r);return w.useEffect(()=>{let e=r.current;if(e)return f(e)},[]),(0,T.jsx)(Le,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:v(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Fe=w.forwardRef((e,t)=>{let n=U(G,e.__scopeMenu);return(0,T.jsx)(Le,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ie=d(`MenuContent.ScrollLock`),Le=w.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:c,disableOutsidePointerEvents:l,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:h,onDismiss:y,disableOutsideScroll:b,...x}=e,S=U(G,n),C=W(G,n),E=H(n),D=xe(n),O=ve(n),[k,te]=w.useState(null),A=w.useRef(null),j=a(t,A,S.onContentChange),M=w.useRef(0),N=w.useRef(``),ne=w.useRef(0),P=w.useRef(null),re=w.useRef(`right`),F=w.useRef(0),I=b?g:w.Fragment,ie=b?{as:Ie,allowPinchZoom:!0}:void 0,L=e=>{let t=N.current+e,n=O().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=gt(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){N.current=t,window.clearTimeout(M.current),t!==``&&(M.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};w.useEffect(()=>()=>window.clearTimeout(M.current),[]),u();let R=w.useCallback(e=>re.current===P.current?.side&&vt(e,P.current?.area),[]);return(0,T.jsx)(je,{scope:n,searchRef:N,onItemEnter:w.useCallback(e=>{R(e)&&e.preventDefault()},[R]),onItemLeave:w.useCallback(e=>{R(e)||(A.current?.focus(),te(null))},[R]),onTriggerLeave:w.useCallback(e=>{R(e)&&e.preventDefault()},[R]),pointerGraceTimerRef:ne,onPointerGraceIntentChange:w.useCallback(e=>{P.current=e},[]),children:(0,T.jsx)(I,{...ie,children:(0,T.jsx)(o,{asChild:!0,trapped:i,onMountAutoFocus:v(s,e=>{e.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:(0,T.jsx)(_,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:h,onDismiss:y,children:(0,T.jsx)(ue,{asChild:!0,...D,dir:C.dir,orientation:`vertical`,loop:r,currentTabStopId:k,onCurrentTabStopIdChange:te,onEntryFocus:v(d,e=>{C.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,T.jsx)(ee,{role:`menu`,"aria-orientation":`vertical`,"data-state":pt(S.open),"data-radix-menu-content":``,dir:C.dir,...E,...x,ref:j,style:{outline:`none`,...x.style},onKeyDown:v(x.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&L(e.key));let i=A.current;if(e.target!==i||!he.includes(e.key))return;e.preventDefault();let a=O().filter(e=>!e.disabled).map(e=>e.ref.current);me.includes(e.key)&&a.reverse(),mt(a)}),onBlur:v(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(M.current),N.current=``)}),onPointerMove:v(e.onPointerMove,Z(e=>{let t=e.target,n=F.current!==e.clientX;e.currentTarget.contains(t)&&n&&(re.current=e.clientX>F.current?`right`:`left`,F.current=e.clientX)}))})})})})})})});Ne.displayName=G;var Re=`MenuGroup`,ze=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(c.div,{role:`group`,...r,ref:t})});ze.displayName=Re;var Be=`MenuLabel`,Ve=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(c.div,{...r,ref:t})});Ve.displayName=Be;var K=`MenuItem`,He=`menu.itemSelect`,q=w.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,o=w.useRef(null),s=W(K,e.__scopeMenu),c=Me(K,e.__scopeMenu),l=a(t,o),u=w.useRef(!1),d=()=>{let e=o.current;if(!n&&e){let t=new CustomEvent(He,{bubbles:!0,cancelable:!0});e.addEventListener(He,e=>r?.(e),{once:!0}),m(e,t),t.defaultPrevented?u.current=!1:s.onClose()}};return(0,T.jsx)(Ue,{...i,ref:l,disabled:n,onClick:v(e.onClick,d),onPointerDown:t=>{e.onPointerDown?.(t),u.current=!0},onPointerUp:v(e.onPointerUp,e=>{u.current||e.currentTarget?.click()}),onKeyDown:v(e.onKeyDown,e=>{let t=c.searchRef.current!==``;n||t&&e.key===` `||fe.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});q.displayName=K;var Ue=w.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,s=Me(K,n),l=xe(n),u=w.useRef(null),d=a(t,u),[f,p]=w.useState(!1),[m,h]=w.useState(``);return w.useEffect(()=>{let e=u.current;e&&h((e.textContent??``).trim())},[o.children]),(0,T.jsx)(B.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:(0,T.jsx)(de,{asChild:!0,...l,focusable:!r,children:(0,T.jsx)(c.div,{role:`menuitem`,"data-highlighted":f?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...o,ref:d,onPointerMove:v(e.onPointerMove,Z(e=>{r?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:v(e.onPointerLeave,Z(e=>s.onItemLeave(e))),onFocus:v(e.onFocus,()=>p(!0)),onBlur:v(e.onBlur,()=>p(!1))})})})}),We=`MenuCheckboxItem`,Ge=w.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,T.jsx)($e,{scope:e.__scopeMenu,checked:n,children:(0,T.jsx)(q,{role:`menuitemcheckbox`,"aria-checked":Y(n)?`mixed`:n,...i,ref:t,"data-state":X(n),onSelect:v(i.onSelect,()=>r?.(Y(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Ge.displayName=We;var Ke=`MenuRadioGroup`,[qe,Je]=V(Ke,{value:void 0,onValueChange:()=>{}}),Ye=w.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=s(r);return(0,T.jsx)(qe,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,T.jsx)(ze,{...i,ref:t})})});Ye.displayName=Ke;var Xe=`MenuRadioItem`,Ze=w.forwardRef((e,t)=>{let{value:n,...r}=e,i=Je(Xe,e.__scopeMenu),a=n===i.value;return(0,T.jsx)($e,{scope:e.__scopeMenu,checked:a,children:(0,T.jsx)(q,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":X(a),onSelect:v(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Ze.displayName=Xe;var Qe=`MenuItemIndicator`,[$e,et]=V(Qe,{checked:!1}),tt=w.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=et(Qe,n);return(0,T.jsx)(l,{present:r||Y(a.checked)||a.checked===!0,children:(0,T.jsx)(c.span,{...i,ref:t,"data-state":X(a.checked)})})});tt.displayName=Qe;var nt=`MenuSeparator`,rt=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(c.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});rt.displayName=nt;var it=`MenuArrow`,at=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=H(n);return(0,T.jsx)(x,{...i,...r,ref:t})});at.displayName=it;var ot=`MenuSub`,[st,ct]=V(ot),lt=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=U(ot,t),o=H(t),[c,l]=w.useState(null),[u,d]=w.useState(null),f=s(i);return w.useEffect(()=>(a.open===!1&&f(!1),()=>f(!1)),[a.open,f]),(0,T.jsx)(S,{...o,children:(0,T.jsx)(Se,{scope:t,open:r,onOpenChange:f,content:u,onContentChange:d,children:(0,T.jsx)(st,{scope:t,contentId:p(),triggerId:p(),trigger:c,onTriggerChange:l,children:n})})})};lt.displayName=ot;var J=`MenuSubTrigger`,ut=w.forwardRef((e,t)=>{let n=U(J,e.__scopeMenu),r=W(J,e.__scopeMenu),i=ct(J,e.__scopeMenu),a=Me(J,e.__scopeMenu),o=w.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=w.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return w.useEffect(()=>u,[u]),w.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,T.jsx)(Ee,{asChild:!0,...l,children:(0,T.jsx)(Ue,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":pt(n.open),...e,ref:y(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:v(e.onPointerMove,Z(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:v(e.onPointerLeave,Z(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:v(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||ge[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});ut.displayName=J;var dt=`MenuSubContent`,ft=w.forwardRef((e,t)=>{let n=ke(G,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=U(G,e.__scopeMenu),s=W(G,e.__scopeMenu),c=ct(dt,e.__scopeMenu),u=w.useRef(null),d=a(t,u);return(0,T.jsx)(B.Provider,{scope:e.__scopeMenu,children:(0,T.jsx)(l,{present:r||o.open,children:(0,T.jsx)(B.Slot,{scope:e.__scopeMenu,children:(0,T.jsx)(Le,{id:c.contentId,"aria-labelledby":c.triggerId,...i,ref:d,align:`start`,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&u.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:v(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:v(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:v(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=_e[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});ft.displayName=dt;function pt(e){return e?`open`:`closed`}function Y(e){return e===`indeterminate`}function X(e){return Y(e)?`indeterminate`:e?`checked`:`unchecked`}function mt(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ht(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function gt(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ht(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function _t(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function vt(e,t){return t?_t({x:e.clientX,y:e.clientY},t):!1}function Z(e){return t=>t.pointerType===`mouse`?e(t):void 0}var yt=we,bt=Ee,xt=Ae,St=Ne,Ct=ze,wt=Ve,Tt=q,Et=Ge,Dt=Ye,Ot=Ze,kt=tt,At=rt,jt=at,Mt=ut,Nt=ft,Q=`DropdownMenu`,[Pt,Ft]=r(Q,[be]),$=be(),[It,Lt]=Pt(Q),Rt=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=$(t),l=w.useRef(null),[u,d]=h({prop:i,defaultProp:a??!1,onChange:o,caller:Q});return(0,T.jsx)(It,{scope:t,triggerId:p(),triggerRef:l,contentId:p(),open:u,onOpenChange:d,onOpenToggle:w.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,T.jsx)(yt,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};Rt.displayName=Q;var zt=`DropdownMenuTrigger`,Bt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Lt(zt,n),o=$(n);return(0,T.jsx)(bt,{asChild:!0,...o,children:(0,T.jsx)(c.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:y(t,a.triggerRef),onPointerDown:v(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:v(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});Bt.displayName=zt;var Vt=`DropdownMenuPortal`,Ht=e=>{let{__scopeDropdownMenu:t,...n}=e,r=$(t);return(0,T.jsx)(xt,{...r,...n})};Ht.displayName=Vt;var Ut=`DropdownMenuContent`,Wt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Lt(Ut,n),a=$(n),o=w.useRef(!1);return(0,T.jsx)(St,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:v(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:v(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Wt.displayName=Ut;var Gt=`DropdownMenuGroup`,Kt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Ct,{...i,...r,ref:t})});Kt.displayName=Gt;var qt=`DropdownMenuLabel`,Jt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(wt,{...i,...r,ref:t})});Jt.displayName=qt;var Yt=`DropdownMenuItem`,Xt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Tt,{...i,...r,ref:t})});Xt.displayName=Yt;var Zt=`DropdownMenuCheckboxItem`,Qt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Et,{...i,...r,ref:t})});Qt.displayName=Zt;var $t=`DropdownMenuRadioGroup`,en=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Dt,{...i,...r,ref:t})});en.displayName=$t;var tn=`DropdownMenuRadioItem`,nn=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Ot,{...i,...r,ref:t})});nn.displayName=tn;var rn=`DropdownMenuItemIndicator`,an=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(kt,{...i,...r,ref:t})});an.displayName=rn;var on=`DropdownMenuSeparator`,sn=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(At,{...i,...r,ref:t})});sn.displayName=on;var cn=`DropdownMenuArrow`,ln=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(jt,{...i,...r,ref:t})});ln.displayName=cn;var un=`DropdownMenuSubTrigger`,dn=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Mt,{...i,...r,ref:t})});dn.displayName=un;var fn=`DropdownMenuSubContent`,pn=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Nt,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});pn.displayName=fn;var mn=Rt,hn=Bt,gn=Ht,_n=Wt,vn=Xt,yn=sn;export{yn as a,mn as i,vn as n,hn as o,gn as r,_n as t};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{_ as r,a as i,b as a,c as o,d as s,f as c,i as l,l as u,m as d,n as f,o as p,p as m,r as h,t as g,u as _,v,y}from"./Combination-HAlzriaz.js";import{Fr as ee,Ir as b,Lr as x,Nr as S,Pr as C}from"./index-50FVtgXU.js";var w=e(t(),1),T=n();function E(e){let t=e+`CollectionProvider`,[n,i]=r(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=e=>{let{scope:t,children:n}=e,r=w.useRef(null),i=w.useRef(new Map).current;return(0,T.jsx)(o,{scope:t,itemMap:i,collectionRef:r,children:n})};c.displayName=t;let l=e+`CollectionSlot`,u=d(l),f=w.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,T.jsx)(u,{ref:a(t,s(l,n).collectionRef),children:r})});f.displayName=l;let p=e+`CollectionItemSlot`,m=`data-radix-collection-item`,h=d(p),g=w.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=w.useRef(null),c=a(t,o),l=s(p,n);return w.useEffect(()=>(l.itemMap.set(o,{ref:o,...i}),()=>void l.itemMap.delete(o))),(0,T.jsx)(h,{[m]:``,ref:c,children:r})});g.displayName=p;function _(t){let n=s(e+`CollectionConsumer`,t);return w.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${m}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:c,Slot:f,ItemSlot:g},_,i]}var D=w.createContext(void 0);function O(e){let t=w.useContext(D);return e||t||`ltr`}var k=`rovingFocusGroup.onEntryFocus`,te={bubbles:!1,cancelable:!0},A=`RovingFocusGroup`,[j,M,N]=E(A),[ne,P]=r(A,[N]),[re,F]=ne(A),I=w.forwardRef((e,t)=>(0,T.jsx)(j.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,T.jsx)(j.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,T.jsx)(ie,{...e,ref:t})})}));I.displayName=A;var ie=w.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...m}=e,g=w.useRef(null),_=a(t,g),y=O(o),[ee,b]=h({prop:l,defaultProp:u??null,onChange:d,caller:A}),[x,S]=w.useState(!1),C=s(f),E=M(n),D=w.useRef(!1),[j,N]=w.useState(0);return w.useEffect(()=>{let e=g.current;if(e)return e.addEventListener(k,C),()=>e.removeEventListener(k,C)},[C]),(0,T.jsx)(re,{scope:n,orientation:r,dir:y,loop:i,currentTabStopId:ee,onItemFocus:w.useCallback(e=>b(e),[b]),onItemShiftTab:w.useCallback(()=>S(!0),[]),onFocusableItemAdd:w.useCallback(()=>N(e=>e+1),[]),onFocusableItemRemove:w.useCallback(()=>N(e=>e-1),[]),children:(0,T.jsx)(c.div,{tabIndex:x||j===0?-1:0,"data-orientation":r,...m,ref:_,style:{outline:`none`,...e.style},onMouseDown:v(e.onMouseDown,()=>{D.current=!0}),onFocus:v(e.onFocus,e=>{let t=!D.current;if(e.target===e.currentTarget&&t&&!x){let t=new CustomEvent(k,te);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=E().filter(e=>e.focusable);ce([e.find(e=>e.active),e.find(e=>e.id===ee),...e].filter(Boolean).map(e=>e.ref.current),p)}}D.current=!1}),onBlur:v(e.onBlur,()=>S(!1))})})}),L=`RovingFocusGroupItem`,R=w.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,l=p(),u=a||l,d=F(L,n),f=d.currentTabStopId===u,m=M(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:_}=d;return w.useEffect(()=>{if(r)return h(),()=>g()},[r,h,g]),(0,T.jsx)(j.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:(0,T.jsx)(c.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...s,ref:t,onMouseDown:v(e.onMouseDown,e=>{r?d.onItemFocus(u):e.preventDefault()}),onFocus:v(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:v(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){d.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=se(e,d.orientation,d.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=m().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=d.loop?le(n,r+1):n.slice(r+1)}setTimeout(()=>ce(n))}}),children:typeof o==`function`?o({isCurrentTabStop:f,hasTabStop:_!=null}):o})})});R.displayName=L;var ae={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function oe(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function se(e,t,n){let r=oe(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return ae[r]}function ce(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function le(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ue=I,de=R,fe=[`Enter`,` `],pe=[`ArrowDown`,`PageUp`,`Home`],me=[`ArrowUp`,`PageDown`,`End`],he=[...pe,...me],ge={ltr:[...fe,`ArrowRight`],rtl:[...fe,`ArrowLeft`]},_e={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},z=`Menu`,[B,ve,ye]=E(z),[V,be]=r(z,[ye,x,P]),H=x(),xe=P(),[Se,U]=V(z),[Ce,W]=V(z),we=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,c=H(t),[l,u]=w.useState(null),d=w.useRef(!1),f=s(a),p=O(i);return w.useEffect(()=>{let e=()=>{d.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>d.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,T.jsx)(b,{...c,children:(0,T.jsx)(Se,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:(0,T.jsx)(Ce,{scope:t,onClose:w.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:o,children:r})})})};we.displayName=z;var Te=`MenuAnchor`,Ee=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=H(n);return(0,T.jsx)(S,{...i,...r,ref:t})});Ee.displayName=Te;var De=`MenuPortal`,[Oe,ke]=V(De,{forceMount:void 0}),Ae=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:a}=e,o=U(De,t);return(0,T.jsx)(Oe,{scope:t,forceMount:n,children:(0,T.jsx)(l,{present:n||o.open,children:(0,T.jsx)(i,{asChild:!0,container:a,children:r})})})};Ae.displayName=De;var G=`MenuContent`,[je,Me]=V(G),Ne=w.forwardRef((e,t)=>{let n=ke(G,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=U(G,e.__scopeMenu),o=W(G,e.__scopeMenu);return(0,T.jsx)(B.Provider,{scope:e.__scopeMenu,children:(0,T.jsx)(l,{present:r||a.open,children:(0,T.jsx)(B.Slot,{scope:e.__scopeMenu,children:o.modal?(0,T.jsx)(Pe,{...i,ref:t}):(0,T.jsx)(Fe,{...i,ref:t})})})})}),Pe=w.forwardRef((e,t)=>{let n=U(G,e.__scopeMenu),r=w.useRef(null),i=a(t,r);return w.useEffect(()=>{let e=r.current;if(e)return f(e)},[]),(0,T.jsx)(Le,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:v(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Fe=w.forwardRef((e,t)=>{let n=U(G,e.__scopeMenu);return(0,T.jsx)(Le,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ie=d(`MenuContent.ScrollLock`),Le=w.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:c,disableOutsidePointerEvents:l,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:h,onDismiss:y,disableOutsideScroll:b,...x}=e,S=U(G,n),C=W(G,n),E=H(n),D=xe(n),O=ve(n),[k,te]=w.useState(null),A=w.useRef(null),j=a(t,A,S.onContentChange),M=w.useRef(0),N=w.useRef(``),ne=w.useRef(0),P=w.useRef(null),re=w.useRef(`right`),F=w.useRef(0),I=b?g:w.Fragment,ie=b?{as:Ie,allowPinchZoom:!0}:void 0,L=e=>{let t=N.current+e,n=O().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=gt(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){N.current=t,window.clearTimeout(M.current),t!==``&&(M.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};w.useEffect(()=>()=>window.clearTimeout(M.current),[]),u();let R=w.useCallback(e=>re.current===P.current?.side&&vt(e,P.current?.area),[]);return(0,T.jsx)(je,{scope:n,searchRef:N,onItemEnter:w.useCallback(e=>{R(e)&&e.preventDefault()},[R]),onItemLeave:w.useCallback(e=>{R(e)||(A.current?.focus(),te(null))},[R]),onTriggerLeave:w.useCallback(e=>{R(e)&&e.preventDefault()},[R]),pointerGraceTimerRef:ne,onPointerGraceIntentChange:w.useCallback(e=>{P.current=e},[]),children:(0,T.jsx)(I,{...ie,children:(0,T.jsx)(o,{asChild:!0,trapped:i,onMountAutoFocus:v(s,e=>{e.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:(0,T.jsx)(_,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:f,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:h,onDismiss:y,children:(0,T.jsx)(ue,{asChild:!0,...D,dir:C.dir,orientation:`vertical`,loop:r,currentTabStopId:k,onCurrentTabStopIdChange:te,onEntryFocus:v(d,e=>{C.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,T.jsx)(ee,{role:`menu`,"aria-orientation":`vertical`,"data-state":pt(S.open),"data-radix-menu-content":``,dir:C.dir,...E,...x,ref:j,style:{outline:`none`,...x.style},onKeyDown:v(x.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&L(e.key));let i=A.current;if(e.target!==i||!he.includes(e.key))return;e.preventDefault();let a=O().filter(e=>!e.disabled).map(e=>e.ref.current);me.includes(e.key)&&a.reverse(),mt(a)}),onBlur:v(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(M.current),N.current=``)}),onPointerMove:v(e.onPointerMove,Z(e=>{let t=e.target,n=F.current!==e.clientX;e.currentTarget.contains(t)&&n&&(re.current=e.clientX>F.current?`right`:`left`,F.current=e.clientX)}))})})})})})})});Ne.displayName=G;var Re=`MenuGroup`,ze=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(c.div,{role:`group`,...r,ref:t})});ze.displayName=Re;var Be=`MenuLabel`,Ve=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(c.div,{...r,ref:t})});Ve.displayName=Be;var K=`MenuItem`,He=`menu.itemSelect`,q=w.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,o=w.useRef(null),s=W(K,e.__scopeMenu),c=Me(K,e.__scopeMenu),l=a(t,o),u=w.useRef(!1),d=()=>{let e=o.current;if(!n&&e){let t=new CustomEvent(He,{bubbles:!0,cancelable:!0});e.addEventListener(He,e=>r?.(e),{once:!0}),m(e,t),t.defaultPrevented?u.current=!1:s.onClose()}};return(0,T.jsx)(Ue,{...i,ref:l,disabled:n,onClick:v(e.onClick,d),onPointerDown:t=>{e.onPointerDown?.(t),u.current=!0},onPointerUp:v(e.onPointerUp,e=>{u.current||e.currentTarget?.click()}),onKeyDown:v(e.onKeyDown,e=>{let t=c.searchRef.current!==``;n||t&&e.key===` `||fe.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});q.displayName=K;var Ue=w.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,s=Me(K,n),l=xe(n),u=w.useRef(null),d=a(t,u),[f,p]=w.useState(!1),[m,h]=w.useState(``);return w.useEffect(()=>{let e=u.current;e&&h((e.textContent??``).trim())},[o.children]),(0,T.jsx)(B.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:(0,T.jsx)(de,{asChild:!0,...l,focusable:!r,children:(0,T.jsx)(c.div,{role:`menuitem`,"data-highlighted":f?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...o,ref:d,onPointerMove:v(e.onPointerMove,Z(e=>{r?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:v(e.onPointerLeave,Z(e=>s.onItemLeave(e))),onFocus:v(e.onFocus,()=>p(!0)),onBlur:v(e.onBlur,()=>p(!1))})})})}),We=`MenuCheckboxItem`,Ge=w.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,T.jsx)($e,{scope:e.__scopeMenu,checked:n,children:(0,T.jsx)(q,{role:`menuitemcheckbox`,"aria-checked":Y(n)?`mixed`:n,...i,ref:t,"data-state":X(n),onSelect:v(i.onSelect,()=>r?.(Y(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Ge.displayName=We;var Ke=`MenuRadioGroup`,[qe,Je]=V(Ke,{value:void 0,onValueChange:()=>{}}),Ye=w.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=s(r);return(0,T.jsx)(qe,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,T.jsx)(ze,{...i,ref:t})})});Ye.displayName=Ke;var Xe=`MenuRadioItem`,Ze=w.forwardRef((e,t)=>{let{value:n,...r}=e,i=Je(Xe,e.__scopeMenu),a=n===i.value;return(0,T.jsx)($e,{scope:e.__scopeMenu,checked:a,children:(0,T.jsx)(q,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":X(a),onSelect:v(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Ze.displayName=Xe;var Qe=`MenuItemIndicator`,[$e,et]=V(Qe,{checked:!1}),tt=w.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=et(Qe,n);return(0,T.jsx)(l,{present:r||Y(a.checked)||a.checked===!0,children:(0,T.jsx)(c.span,{...i,ref:t,"data-state":X(a.checked)})})});tt.displayName=Qe;var nt=`MenuSeparator`,rt=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(c.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});rt.displayName=nt;var it=`MenuArrow`,at=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=H(n);return(0,T.jsx)(C,{...i,...r,ref:t})});at.displayName=it;var ot=`MenuSub`,[st,ct]=V(ot),lt=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=U(ot,t),o=H(t),[c,l]=w.useState(null),[u,d]=w.useState(null),f=s(i);return w.useEffect(()=>(a.open===!1&&f(!1),()=>f(!1)),[a.open,f]),(0,T.jsx)(b,{...o,children:(0,T.jsx)(Se,{scope:t,open:r,onOpenChange:f,content:u,onContentChange:d,children:(0,T.jsx)(st,{scope:t,contentId:p(),triggerId:p(),trigger:c,onTriggerChange:l,children:n})})})};lt.displayName=ot;var J=`MenuSubTrigger`,ut=w.forwardRef((e,t)=>{let n=U(J,e.__scopeMenu),r=W(J,e.__scopeMenu),i=ct(J,e.__scopeMenu),a=Me(J,e.__scopeMenu),o=w.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=w.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return w.useEffect(()=>u,[u]),w.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,T.jsx)(Ee,{asChild:!0,...l,children:(0,T.jsx)(Ue,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":pt(n.open),...e,ref:y(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:v(e.onPointerMove,Z(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:v(e.onPointerLeave,Z(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:v(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||ge[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});ut.displayName=J;var dt=`MenuSubContent`,ft=w.forwardRef((e,t)=>{let n=ke(G,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=U(G,e.__scopeMenu),s=W(G,e.__scopeMenu),c=ct(dt,e.__scopeMenu),u=w.useRef(null),d=a(t,u);return(0,T.jsx)(B.Provider,{scope:e.__scopeMenu,children:(0,T.jsx)(l,{present:r||o.open,children:(0,T.jsx)(B.Slot,{scope:e.__scopeMenu,children:(0,T.jsx)(Le,{id:c.contentId,"aria-labelledby":c.triggerId,...i,ref:d,align:`start`,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&u.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:v(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:v(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:v(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=_e[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});ft.displayName=dt;function pt(e){return e?`open`:`closed`}function Y(e){return e===`indeterminate`}function X(e){return Y(e)?`indeterminate`:e?`checked`:`unchecked`}function mt(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ht(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function gt(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ht(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function _t(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function vt(e,t){return t?_t({x:e.clientX,y:e.clientY},t):!1}function Z(e){return t=>t.pointerType===`mouse`?e(t):void 0}var yt=we,bt=Ee,xt=Ae,St=Ne,Ct=ze,wt=Ve,Tt=q,Et=Ge,Dt=Ye,Ot=Ze,kt=tt,At=rt,jt=at,Mt=ut,Nt=ft,Q=`DropdownMenu`,[Pt,Ft]=r(Q,[be]),$=be(),[It,Lt]=Pt(Q),Rt=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=$(t),l=w.useRef(null),[u,d]=h({prop:i,defaultProp:a??!1,onChange:o,caller:Q});return(0,T.jsx)(It,{scope:t,triggerId:p(),triggerRef:l,contentId:p(),open:u,onOpenChange:d,onOpenToggle:w.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,T.jsx)(yt,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};Rt.displayName=Q;var zt=`DropdownMenuTrigger`,Bt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Lt(zt,n),o=$(n);return(0,T.jsx)(bt,{asChild:!0,...o,children:(0,T.jsx)(c.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:y(t,a.triggerRef),onPointerDown:v(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:v(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});Bt.displayName=zt;var Vt=`DropdownMenuPortal`,Ht=e=>{let{__scopeDropdownMenu:t,...n}=e,r=$(t);return(0,T.jsx)(xt,{...r,...n})};Ht.displayName=Vt;var Ut=`DropdownMenuContent`,Wt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Lt(Ut,n),a=$(n),o=w.useRef(!1);return(0,T.jsx)(St,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:v(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:v(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Wt.displayName=Ut;var Gt=`DropdownMenuGroup`,Kt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Ct,{...i,...r,ref:t})});Kt.displayName=Gt;var qt=`DropdownMenuLabel`,Jt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(wt,{...i,...r,ref:t})});Jt.displayName=qt;var Yt=`DropdownMenuItem`,Xt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Tt,{...i,...r,ref:t})});Xt.displayName=Yt;var Zt=`DropdownMenuCheckboxItem`,Qt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Et,{...i,...r,ref:t})});Qt.displayName=Zt;var $t=`DropdownMenuRadioGroup`,en=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Dt,{...i,...r,ref:t})});en.displayName=$t;var tn=`DropdownMenuRadioItem`,nn=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Ot,{...i,...r,ref:t})});nn.displayName=tn;var rn=`DropdownMenuItemIndicator`,an=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(kt,{...i,...r,ref:t})});an.displayName=rn;var on=`DropdownMenuSeparator`,sn=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(At,{...i,...r,ref:t})});sn.displayName=on;var cn=`DropdownMenuArrow`,ln=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(jt,{...i,...r,ref:t})});ln.displayName=cn;var un=`DropdownMenuSubTrigger`,dn=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Mt,{...i,...r,ref:t})});dn.displayName=un;var fn=`DropdownMenuSubContent`,pn=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(Nt,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});pn.displayName=fn;var mn=Rt,hn=Bt,gn=Ht,_n=Wt,vn=Xt,yn=sn;export{yn as a,mn as i,vn as n,hn as o,gn as r,_n as t};