@xopcai/xopc 0.0.92 → 0.0.94

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 (194) 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-OqhbJkMf.js +222 -0
  4. package/dist/gateway/static/root/assets/apps-page-OHXW9XP8.js +1 -0
  5. package/dist/gateway/static/root/assets/channels-settings-4N2R-jof.js +1 -0
  6. package/dist/gateway/static/root/assets/{channels-status-swr-XzddfJW2.js → channels-status-swr-Bv6f9kDq.js} +1 -1
  7. package/dist/gateway/static/root/assets/{cron-api--I8LJ44S.js → cron-api-BtaQaHJq.js} +1 -1
  8. package/dist/gateway/static/root/assets/cron-page-Dah32HJK.js +1 -0
  9. package/dist/gateway/static/root/assets/{dist-CYgHMQO0.js → dist-BJfD9Qvs.js} +1 -1
  10. package/dist/gateway/static/root/assets/{extension-debug-page-6cRP0nA9.js → extension-debug-page-DnYuMzmH.js} +1 -1
  11. package/dist/gateway/static/root/assets/{extension-page-DpwIkspI.js → extension-page-CJfc-6XV.js} +1 -1
  12. package/dist/gateway/static/root/assets/{extension-settings-page-DYbnQUxH.js → extension-settings-page-BxdfYQMG.js} +1 -1
  13. package/dist/gateway/static/root/assets/{fetch-DTN0w7rV.js → fetch-B0aeeY0q.js} +1 -1
  14. package/dist/gateway/static/root/assets/{field-primitives-CslW6HwD.js → field-primitives-DOLHwowi.js} +1 -1
  15. package/dist/gateway/static/root/assets/{heartbeat-config-api-2UiKevxG.js → heartbeat-config-api-Bj2INAf5.js} +1 -1
  16. package/dist/gateway/static/root/assets/index-Bj_l8QDp.css +1 -0
  17. package/dist/gateway/static/root/assets/{index-DnevRVa6.js → index-DuQ1XPoA.js} +99 -98
  18. package/dist/gateway/static/root/assets/logs-page-AsOgLNJE.js +2 -0
  19. package/dist/gateway/static/root/assets/{note-detail-page-DvW2qg4i.js → note-detail-page-24J4mVP-.js} +53 -53
  20. package/dist/gateway/static/root/assets/{note-time-BEiibLJv.js → note-time-JBszYV3s.js} +1 -1
  21. package/dist/gateway/static/root/assets/notes-page-BApAirFB.js +1 -0
  22. package/dist/gateway/static/root/assets/sessions-page-DX9huWsA.js +1 -0
  23. package/dist/gateway/static/root/assets/{settings-advanced-gate-BctKqHcf.js → settings-advanced-gate-DWvhsTuz.js} +1 -1
  24. package/dist/gateway/static/root/assets/{settings-form-section-QJh5ruel.js → settings-form-section-CxMjaMiy.js} +1 -1
  25. package/dist/gateway/static/root/assets/settings-page-4VmUTzQs.js +3 -0
  26. package/dist/gateway/static/root/assets/{share-preview-page-DBsvvbmD.js → share-preview-page-IX0TJvRd.js} +1 -1
  27. package/dist/gateway/static/root/assets/skills-page-CGKGKfwe.js +2 -0
  28. package/dist/gateway/static/root/assets/{theme-store-ht5iswWS.js → theme-store-Cg_SuBw0.js} +1 -1
  29. package/dist/gateway/static/root/assets/url-BHHmdJYc.js +3 -0
  30. package/dist/gateway/static/root/assets/{utils-DhPv9xoB.js → utils-BmlcxR2j.js} +1 -1
  31. package/dist/gateway/static/root/assets/voice-api-key-field-DaGm2N4J.js +1 -0
  32. package/dist/gateway/static/root/assets/{workflow-page.utils-CJqnPWkW.js → workflow-page.utils-D0vsIGHD.js} +1 -1
  33. package/dist/gateway/static/root/assets/workflows-page-BFCrD3nw.js +27 -0
  34. package/dist/gateway/static/root/index.html +5 -5
  35. package/dist/package.js +1 -1
  36. package/dist/src/agent/inbound/turn-dispatcher.d.ts +1 -0
  37. package/dist/src/agent/inbound/turn-dispatcher.js +3 -0
  38. package/dist/src/agent/inbound/turn-dispatcher.js.map +1 -1
  39. package/dist/src/agent/lifecycle/handlers/compaction.js +1 -1
  40. package/dist/src/agent/lifecycle/handlers/compaction.js.map +1 -1
  41. package/dist/src/agent/mcp/bundle-mcp-materialize.js +1 -1
  42. package/dist/src/agent/mcp/bundle-mcp-materialize.js.map +1 -1
  43. package/dist/src/agent/mcp/bundle-mcp-runtime.js +17 -4
  44. package/dist/src/agent/mcp/bundle-mcp-runtime.js.map +1 -1
  45. package/dist/src/agent/mcp/mcp-transport-config.js +10 -3
  46. package/dist/src/agent/mcp/mcp-transport-config.js.map +1 -1
  47. package/dist/src/agent/mcp/mcp-transport.js +1 -1
  48. package/dist/src/agent/mcp/mcp-transport.js.map +1 -1
  49. package/dist/src/agent/service/process-direct-streaming.d.ts +1 -0
  50. package/dist/src/agent/service/process-direct-streaming.js +15 -12
  51. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  52. package/dist/src/agent/service.d.ts +4 -2
  53. package/dist/src/agent/service.js +20 -4
  54. package/dist/src/agent/service.js.map +1 -1
  55. package/dist/src/agent/service.types.d.ts +3 -1
  56. package/dist/src/agent/tools/browser/tool/browser-use-tool.js +1 -1
  57. package/dist/src/agent/tools/browser/tool/browser-use-tool.js.map +1 -1
  58. package/dist/src/agent/tools/search/registry.js +1 -1
  59. package/dist/src/agent/tools/search/registry.js.map +1 -1
  60. package/dist/src/agent/tools/session-search-tool.js +1 -1
  61. package/dist/src/agent/tools/session-search-tool.js.map +1 -1
  62. package/dist/src/agent/tools/workflow-tool.js +1 -1
  63. package/dist/src/agent/tools/workflow-tool.js.map +1 -1
  64. package/dist/src/agent/workflow/progress-broker.js +1 -1
  65. package/dist/src/agent/workflow/progress-broker.js.map +1 -1
  66. package/dist/src/agent/workflow/subagent-runner.js +1 -1
  67. package/dist/src/agent/workflow/subagent-runner.js.map +1 -1
  68. package/dist/src/channels/pipeline.js +3 -2
  69. package/dist/src/channels/pipeline.js.map +1 -1
  70. package/dist/src/cli/cli-log-level-preset.d.ts +1 -1
  71. package/dist/src/cli/cli-log-level-preset.js +2 -2
  72. package/dist/src/cli/cli-log-level-preset.js.map +1 -1
  73. package/dist/src/cli/commands/logs.js +3 -3
  74. package/dist/src/cli/commands/logs.js.map +1 -1
  75. package/dist/src/cron/executor.js +7 -4
  76. package/dist/src/cron/executor.js.map +1 -1
  77. package/dist/src/gateway/hono/app.js +4 -1
  78. package/dist/src/gateway/hono/app.js.map +1 -1
  79. package/dist/src/gateway/hono/lib/route-logger.d.ts +6 -0
  80. package/dist/src/gateway/hono/lib/route-logger.js +31 -0
  81. package/dist/src/gateway/hono/lib/route-logger.js.map +1 -0
  82. package/dist/src/gateway/hono/middleware/auth.js +16 -3
  83. package/dist/src/gateway/hono/middleware/auth.js.map +1 -1
  84. package/dist/src/gateway/hono/middleware/logger.js +1 -1
  85. package/dist/src/gateway/hono/middleware/logger.js.map +1 -1
  86. package/dist/src/gateway/hono/middleware/route-errors.d.ts +5 -0
  87. package/dist/src/gateway/hono/middleware/route-errors.js +27 -0
  88. package/dist/src/gateway/hono/middleware/route-errors.js.map +1 -0
  89. package/dist/src/gateway/hono/routes/agent-stream.js +6 -0
  90. package/dist/src/gateway/hono/routes/agent-stream.js.map +1 -1
  91. package/dist/src/gateway/hono/routes/browser-install.js +2 -4
  92. package/dist/src/gateway/hono/routes/browser-install.js.map +1 -1
  93. package/dist/src/gateway/hono/routes/config.js +25 -11
  94. package/dist/src/gateway/hono/routes/config.js.map +1 -1
  95. package/dist/src/gateway/hono/routes/cron.js +5 -0
  96. package/dist/src/gateway/hono/routes/cron.js.map +1 -1
  97. package/dist/src/gateway/hono/routes/host-fs.js +2 -4
  98. package/dist/src/gateway/hono/routes/host-fs.js.map +1 -1
  99. package/dist/src/gateway/hono/routes/lazy-bundles.js +14 -1
  100. package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
  101. package/dist/src/gateway/hono/routes/lazy-fallback.js +3 -0
  102. package/dist/src/gateway/hono/routes/lazy-fallback.js.map +1 -1
  103. package/dist/src/gateway/hono/routes/logs.js +39 -7
  104. package/dist/src/gateway/hono/routes/logs.js.map +1 -1
  105. package/dist/src/gateway/hono/routes/mcp.d.ts +3 -0
  106. package/dist/src/gateway/hono/routes/mcp.js +107 -0
  107. package/dist/src/gateway/hono/routes/mcp.js.map +1 -0
  108. package/dist/src/gateway/hono/routes/notes.js +105 -1
  109. package/dist/src/gateway/hono/routes/notes.js.map +1 -1
  110. package/dist/src/gateway/hono/routes/sessions.js +6 -0
  111. package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
  112. package/dist/src/gateway/hono/routes/update.js +2 -4
  113. package/dist/src/gateway/hono/routes/update.js.map +1 -1
  114. package/dist/src/gateway/hono/routes/voice.js +2 -4
  115. package/dist/src/gateway/hono/routes/voice.js.map +1 -1
  116. package/dist/src/gateway/hono/routes/workspace.js +2 -4
  117. package/dist/src/gateway/hono/routes/workspace.js.map +1 -1
  118. package/dist/src/gateway/hono/sse.js +9 -2
  119. package/dist/src/gateway/hono/sse.js.map +1 -1
  120. package/dist/src/gateway/host.d.ts +2 -0
  121. package/dist/src/gateway/host.js +6 -3
  122. package/dist/src/gateway/host.js.map +1 -1
  123. package/dist/src/gateway/service/agent-runner.js +1 -1
  124. package/dist/src/gateway/service/agent-runner.js.map +1 -1
  125. package/dist/src/gateway/service/config-coordinator.js +14 -6
  126. package/dist/src/gateway/service/config-coordinator.js.map +1 -1
  127. package/dist/src/gateway/service/marketplace-service.js +1 -1
  128. package/dist/src/gateway/service/marketplace-service.js.map +1 -1
  129. package/dist/src/gateway/service/run-gateway-agent.js +22 -5
  130. package/dist/src/gateway/service/run-gateway-agent.js.map +1 -1
  131. package/dist/src/gateway/service/sse-hub.js +1 -1
  132. package/dist/src/gateway/service/sse-hub.js.map +1 -1
  133. package/dist/src/gateway/service.js +12 -5
  134. package/dist/src/gateway/service.js.map +1 -1
  135. package/dist/src/mcp/channel-bridge.js +26 -2
  136. package/dist/src/mcp/channel-bridge.js.map +1 -1
  137. package/dist/src/mcp/gateway-http-client.js +24 -2
  138. package/dist/src/mcp/gateway-http-client.js.map +1 -1
  139. package/dist/src/notes/service.d.ts +13 -1
  140. package/dist/src/notes/service.js +237 -0
  141. package/dist/src/notes/service.js.map +1 -1
  142. package/dist/src/notes/store.d.ts +3 -0
  143. package/dist/src/notes/store.js +6 -2
  144. package/dist/src/notes/store.js.map +1 -1
  145. package/dist/src/notes/types.d.ts +31 -0
  146. package/dist/src/session/config-store.js +10 -4
  147. package/dist/src/session/config-store.js.map +1 -1
  148. package/dist/src/session/index.d.ts +1 -1
  149. package/dist/src/session/index.js +2 -2
  150. package/dist/src/session/manager.js +8 -1
  151. package/dist/src/session/manager.js.map +1 -1
  152. package/dist/src/session/session-title.d.ts +19 -3
  153. package/dist/src/session/session-title.js +82 -7
  154. package/dist/src/session/session-title.js.map +1 -1
  155. package/dist/src/utils/index.js +4 -4
  156. package/dist/src/utils/logger/config.js +2 -6
  157. package/dist/src/utils/logger/config.js.map +1 -1
  158. package/dist/src/utils/logger/context.d.ts +3 -22
  159. package/dist/src/utils/logger/context.js +4 -32
  160. package/dist/src/utils/logger/context.js.map +1 -1
  161. package/dist/src/utils/logger/index.d.ts +4 -7
  162. package/dist/src/utils/logger/index.js +9 -28
  163. package/dist/src/utils/logger/index.js.map +1 -1
  164. package/dist/src/utils/logger/log-store.d.ts +14 -32
  165. package/dist/src/utils/logger/log-store.js +67 -118
  166. package/dist/src/utils/logger/log-store.js.map +1 -1
  167. package/dist/src/utils/logger/log-stream.d.ts +5 -70
  168. package/dist/src/utils/logger/log-stream.js +67 -178
  169. package/dist/src/utils/logger/log-stream.js.map +1 -1
  170. package/dist/src/utils/logger/pino-record.d.ts +8 -0
  171. package/dist/src/utils/logger/pino-record.js +83 -0
  172. package/dist/src/utils/logger/pino-record.js.map +1 -0
  173. package/dist/src/utils/logger/stats.d.ts +1 -1
  174. package/dist/src/utils/logger/stats.js +2 -2
  175. package/dist/src/utils/logger/stats.js.map +1 -1
  176. package/dist/src/utils/logger/streams.js +18 -0
  177. package/dist/src/utils/logger/streams.js.map +1 -1
  178. package/dist/src/utils/logger/types.d.ts +0 -9
  179. package/dist/src/utils/logger/types.js.map +1 -1
  180. package/dist/src/utils/logger.js +4 -4
  181. package/package.json +6 -1
  182. package/dist/gateway/static/root/assets/agents-uwPn7ZW9.js +0 -222
  183. package/dist/gateway/static/root/assets/apps-page-CWKdhSPU.js +0 -1
  184. package/dist/gateway/static/root/assets/channels-settings-hEhW7Mbk.js +0 -1
  185. package/dist/gateway/static/root/assets/cron-page-B0kvgZGR.js +0 -1
  186. package/dist/gateway/static/root/assets/index-BUKUv7QW.css +0 -1
  187. package/dist/gateway/static/root/assets/logs-page-sOP4TXJ4.js +0 -1
  188. package/dist/gateway/static/root/assets/notes-page-BFQaquHU.js +0 -1
  189. package/dist/gateway/static/root/assets/sessions-page-CptjDKAX.js +0 -1
  190. package/dist/gateway/static/root/assets/settings-page-V3p-hISB.js +0 -2
  191. package/dist/gateway/static/root/assets/skills-page-q2zPUJAR.js +0 -2
  192. package/dist/gateway/static/root/assets/url-CWWpfkq1.js +0 -3
  193. package/dist/gateway/static/root/assets/voice-api-key-field-DLSKUipa.js +0 -1
  194. package/dist/gateway/static/root/assets/workflows-page-DRRQ1A0l.js +0 -27
@@ -1 +0,0 @@
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-CWWpfkq1.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-DTN0w7rV.js";import{An as f,Co as p,Cr as m,Ct as h,Fr as g,Hi as _,Mo as v,N as y,Ri as b,Ro as x,Sr as S,Tr as C,Uo as w,_o as T,_r as E,ai as D,ba as O,br as k,ca as A,ci as j,ea as M,eo as N,gr as P,hr as F,mr as I,oi as L,pr as R,wr as z,xr as B,yi as V}from"./index-DnevRVa6.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=I(),{mutate:d}=s(),[f,p]=(0,H.useReducer)(y,Z),{q:m,debounced:g,detailPkg:v,rowBusy:b,actionError:x,restartHint:S}=f,C=n?`marketplace-${g}`:null;(0,H.useEffect)(()=>{let e=window.setTimeout(()=>p({type:`patch`,patch:{debounced:m.trim()}}),300);return()=>window.clearTimeout(e)},[m]);let{data:w,isLoading:E,error:D}=c(C,async()=>u(g.length>0?o(`/api/marketplace?q=${encodeURIComponent(g)}`):o(`/api/marketplace`)),{revalidateOnFocus:!1}),k=(0,H.useCallback)(()=>{d(`gateway-extensions-list`),h()},[d]),j=(0,H.useCallback)(async(e,n)=>{p({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await K({name:e,overwrite:n});k(),r.requiresGatewayRestart&&p({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw p({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{p({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,k]),M=(0,H.useCallback)(async e=>{p({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await J(e);k(),n.requiresGatewayRestart&&p({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw p({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{p({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,k]),N=w?.extensions??[];return(0,Y.jsxs)(`div`,{className:L(`flex flex-col gap-4`,e),children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(_,{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:m,onChange:e=>p({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),D?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:D instanceof Error?D.message:t.marketplaceLoadFailed}):null,x?(0,Y.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null,S?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:S}):null,E&&!w?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,Y.jsx)(`ul`,{className:`flex flex-col gap-3`,children:N.length===0?(0,Y.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):N.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:()=>p({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),p({type:`patch`,patch:{detailPkg:e.id}}))},className:L(`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)(T,{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)&&M(e.id).catch(()=>{})},className:L(`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)(O,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(V,{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:L(`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)(O,{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:()=>p({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),p=l(oe)?`ext-mp-detail-${n}`:null,h;t[0]===n?h=t[1]:(h=async()=>ee(n),t[0]=n,t[1]=h);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},t[2]=g):g=t[2];let{data:_,error:y,isLoading:b}=c(p,h,g),w;t[3]!==i||t[4]!==n?(w=X(i,n),t[3]=i,t[4]=n,t[5]=w):w=t[5];let T=w,E=T===`user`,D;t[6]!==r.marketplaceNoReadme||t[7]!==_?(D=_?.readme?.trim()||(_?.description?.trim()?`### ${_.name}\n\n${_.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=_,t[8]=D):D=t[8];let A=D,M;t[9]===a?M=t[10]:(M=e=>!e&&a(),t[9]=a,t[10]=M);let N;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Y.jsx)(S,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=N):N=t[11];let P;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Y.jsx)(v,{className:`size-5`}),t[12]=P):P=t[12];let F;t[13]!==r.detailBack||t[14]!==a?(F=(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:P}),t[13]=r.detailBack,t[14]=a,t[15]=F):F=t[15];let I;t[16]===r.marketplaceDetailTitle?I=t[17]:(I=(0,Y.jsx)(C,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=I);let R;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Y.jsx)(j,{className:`size-5`}),t[18]=R):R=t[18];let B;t[19]!==r.detailClose||t[20]!==a?(B=(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:R}),t[19]=r.detailClose,t[20]=a,t[21]=B):B=t[21];let W;t[22]!==B||t[23]!==F||t[24]!==I?(W=(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[F,I,B]}),t[22]=B,t[23]=F,t[24]=I,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]!==_||t[32]!==y||t[33]!==b||t[34]!==A?(G=b&&!_?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):y?(0,Y.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):_?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:_.name}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,Y.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:_.id})}),(0,Y.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,Y.jsx)(`dd`,{children:_.author.username})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,Y.jsx)(`dd`,{children:_.latestVersion.version})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,Y.jsx)(`dd`,{children:_.downloads})]})]}),_.readme?.trim()?(0,Y.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,Y.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,Y.jsx)(f,{content:A})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=_,t[32]=y,t[33]=b,t[34]=A,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]!==_||t[47]!==T||t[48]!==a||t[49]!==o||t[50]!==s||t[51]!==n||t[52]!==E?(q=_?(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)(x,{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:()=>{E&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),o(n,E).catch(ie).finally(()=>d(!1)))},className:L(`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)(O,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,E?r.marketplaceReinstall:r.marketplaceInstall]}),E?(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:L(`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)(V,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=u,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=_,t[47]=T,t[48]=a,t[49]=o,t[50]=s,t[51]=n,t[52]=E,t[53]=q):q=t[53];let J;t[54]!==W||t[55]!==K||t[56]!==q?(J=(0,Y.jsxs)(m,{children:[N,(0,Y.jsxs)(k,{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]!==M?(Z=(0,Y.jsx)(z,{defaultOpen:!0,onOpenChange:M,children:J}),t[58]=J,t[59]=M,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=g(e=>e.setPageHeader),r=g(e=>e.clearPageHeader),o=I(),s=F(),[c,l]=w(),u=W(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,H.useState)(u),[m,h]=(0,H.useState)(d),[v,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),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 S=(0,H.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),C=(0,H.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),T=f===`builtin`?S:C,E=(0,H.useMemo)(()=>{let t=m.trim().toLowerCase(),n=T;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[T,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:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,Y.jsx)(`h1`,{className:`min-w-0 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 D=f!==`marketplace`&&T.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)(`header`,{className:`mb-6`,children:[(0,Y.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:t.appsPage.title}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.appsPage.subtitle})]}),(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:L(`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:L(`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:L(`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,`)`]})]})]}),D?(0,Y.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,Y.jsx)(_,{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`&&S.length===0?(0,Y.jsx)(he,{message:t.appsPage.emptyBuiltin}):f===`user`&&C.length===0?(0,Y.jsx)(he,{message:t.appsPage.emptyUser}):E.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:E.map(e=>(0,Y.jsx)(de,{extension:e,copy:t.appsPage,showSourceBadge:f===`user`,onOpen:()=>y(e)},e.id))})]}),v?(0,Y.jsx)(fe,{extension:v,copy:t.appsPage,onClose:()=>y(null)},v.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=L(`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 m;t[7]===n.name?m=t[8]:(m=(0,Y.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=m);let h;t[9]===n.version?h=t[10]:(h=n.version?(0,Y.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=h);let g;t[11]!==m||t[12]!==h?(g=(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==r.statusEnabled||t[15]!==s?(_=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)(p,{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]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;t[20]!==r.cardNoDescription||t[21]!==n.description?(y=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=y):y=t[22];let b;t[23]===y?b=t[24]:(b=(0,Y.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:y}),t[23]=y,t[24]=b);let x=n.hasUi?r.badgeKindUi:r.badgeKindBackend,S;t[25]!==x||t[26]!==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]!==v||t[36]!==b||t[37]!==w?(T=(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,b,w]}),t[35]=v,t[36]=b,t[37]=w,t[38]=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`),h(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{a(!1)}}},[d,t.builtinToggleFailed,e.id,e.source,r]),p=e.ui?.contributions?.pages??[],g=e.ui?.contributions?.settingsPanels??[],_=e.ui?.contributions?.chatWidgets??[],y=e.ui?.contributions?.sidebarPanels??[],w=p.find(e=>e.showInNav)??p[0],T=g[0],A=w?R(e.id,w):null,M=T?`/settings/ext/${e.id}/${T.id}`:e.hasConfigSchema||P(e)?`/settings/ext/${e.id}`:null;return(0,Y.jsx)(z,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,Y.jsxs)(m,{children:[(0,Y.jsx)(S,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,Y.jsxs)(k,{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)(v,{className:`size-5`})}),(0,Y.jsx)(C,{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)(j,{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)(D,{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)(O,{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&&(p.length>0||g.length>0||_.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:p.length,hidden:p.length===0}),(0,Y.jsx)($,{template:t.badgeSettings,count:g.length,hidden:g.length===0}),(0,Y.jsx)($,{template:t.badgeWidgets,count:_.length,hidden:_.length===0}),(0,Y.jsx)($,{template:t.badgeSidebar,count:y.length,hidden:y.length===0})]})]}):null,E(e)&&(A||M)?(0,Y.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[A?(0,Y.jsxs)(x,{to:A,onClick:n,className:L(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,Y.jsx)(N,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,M?(0,Y.jsxs)(x,{to:M,onClick:n,className:L(`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)(b,{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 +0,0 @@
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-CWWpfkq1.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{a as l,n as u}from"./fetch-DTN0w7rV.js";import{$a as d,$t as f,B as p,Br as m,Co as h,Cr as g,Fr as _,Gr as v,Ho as y,Jr as b,Qa as x,So as S,Sr as C,Tr as w,Tt as T,Uo as E,Vo as D,Xr as O,Yi as k,Zr as A,ai as j,br as M,ci as N,en as P,eo as F,fr as I,ir as L,nn as R,oi as z,qr as B,sr as ee,ti as V,tn as te,vr as H,wr as U,xr as W,yr as G,z as K}from"./index-DnevRVa6.js";import{a as q,c as ne,i as re,o as ie,r as ae,s as oe,t as J}from"./utils-DhPv9xoB.js";import{n as Y,r as se,t as ce}from"./field-primitives-CslW6HwD.js";import{_ as le,a as ue,c as de,d as fe,f as pe,g as me,h as he,i as ge,l as _e,m as ve,n as ye,o as be,p as xe,r as X,s as Se,t as Ce,u as we,v as Te,y as Ee}from"./channels-status-swr-XzddfJW2.js";var Z=e(t(),1),Q=n(),$=r();function De(e){switch(e){case`running`:return`bg-success-soft text-success`;case`offline`:return`bg-amber-100 text-amber-900 dark:bg-amber-950/60 dark:text-amber-200`;case`disabled`:return`bg-surface-hover text-fg-muted`;default:return`bg-surface-hover text-fg-muted`}}function Oe(e,t){switch(t){case`running`:return e.hubStatusRunning;case`offline`:return e.hubStatusOffline;case`disabled`:return e.hubStatusDisabled;default:return e.hubStatusNotConfigured}}function ke(e,t){switch(t){case`setup`:return e.hubSetupButton;case`fix`:return e.hubFixButton;case`pairing`:return e.hubPairingButton;default:return e.hubManageButton}}function Ae(e){let t=(0,Q.c)(62),{channelId:n,title:r,subtitle:i,vm:a,toggleDisabled:o,onOpen:s,onReviewPairing:c,onToggle:l,ch:u}=e,d=a.configured&&a.manageable,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=z(`flex h-full min-h-0 flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm transition-colors`,`hover:border-edge`),t[0]=f):f=t[0];let p=a.status===`running`?`bg-accent-soft`:`bg-surface-base`,m;t[1]===p?m=t[2]:(m=z(`flex size-11 shrink-0 items-center justify-center rounded-xl ring-1 ring-edge-subtle/40`,p),t[1]=p,t[2]=m);let h;t[3]===n?h=t[4]:(h=(0,$.jsx)(I,{sourceChannel:n,className:`size-5`}),t[3]=n,t[4]=h);let g;t[5]!==m||t[6]!==h?(g=(0,$.jsx)(`div`,{className:m,"aria-hidden":!0,children:h}),t[5]=m,t[6]=h,t[7]=g):g=t[7];let _;t[8]===r?_=t[9]:(_=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r}),t[8]=r,t[9]=_);let v;t[10]===a.status?v=t[11]:(v=z(`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium`,De(a.status)),t[10]=a.status,t[11]=v);let y;t[12]!==u||t[13]!==a.status?(y=Oe(u,a.status),t[12]=u,t[13]=a.status,t[14]=y):y=t[14];let b;t[15]!==v||t[16]!==y?(b=(0,$.jsx)(`span`,{className:v,children:y}),t[15]=v,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==u||t[19]!==c||t[20]!==a.pendingPairing?(x=a.pendingPairing>0?(0,$.jsx)(`button`,{type:`button`,className:z(`inline-flex items-center rounded-full bg-amber-100 px-2 py-0.5 text-xs font-medium text-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,A.press),onClick:e=>{e.stopPropagation(),c()},children:u.hubPairingPendingBadge.replace(`{{count}}`,String(a.pendingPairing))}):null,t[18]=u,t[19]=c,t[20]=a.pendingPairing,t[21]=x):x=t[21];let S;t[22]!==x||t[23]!==b?(S=(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[b,x]}),t[22]=x,t[23]=b,t[24]=S):S=t[24];let C;t[25]!==S||t[26]!==_?(C=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,S]}),t[25]=S,t[26]=_,t[27]=C):C=t[27];let w;t[28]!==u||t[29]!==l||t[30]!==d||t[31]!==r||t[32]!==o||t[33]!==a.enabled?(w=d?(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a.enabled,"aria-label":`${r} — ${u.enableChannelAria}`,disabled:o,className:z(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,A.press,a.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`,o&&`cursor-not-allowed opacity-50`),onClick:e=>{e.stopPropagation(),l(!a.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,t[28]=u,t[29]=l,t[30]=d,t[31]=r,t[32]=o,t[33]=a.enabled,t[34]=w):w=t[34];let T;t[35]!==C||t[36]!==w||t[37]!==g?(T=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[g,C,w]}),t[35]=C,t[36]=w,t[37]=g,t[38]=T):T=t[38];let E;t[39]===i?E=t[40]:(E=(0,$.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:i}),t[39]=i,t[40]=E);let D;t[41]===a.summaryLines?D=t[42]:(D=a.summaryLines.length>0?(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-0.5`,children:a.summaryLines.map(je)}):null,t[41]=a.summaryLines,t[42]=D);let O;t[43]!==E||t[44]!==D?(O=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[E,D]}),t[43]=E,t[44]=D,t[45]=O):O=t[45];let k;t[46]!==s||t[47]!==c||t[48]!==a.manageable||t[49]!==a.pendingPairing||t[50]!==a.primaryAction?(k=()=>{if(a.manageable&&(a.primaryAction===`pairing`||a.pendingPairing>0)){c();return}s()},t[46]=s,t[47]=c,t[48]=a.manageable,t[49]=a.pendingPairing,t[50]=a.primaryAction,t[51]=k):k=t[51];let M;t[52]!==u||t[53]!==a.primaryAction?(M=ke(u,a.primaryAction),t[52]=u,t[53]=a.primaryAction,t[54]=M):M=t[54];let N;t[55]!==k||t[56]!==M?(N=(0,$.jsx)(`div`,{className:`mt-auto`,children:(0,$.jsx)(j,{type:`button`,variant:`primary`,className:`w-full`,onClick:k,children:M})}),t[55]=k,t[56]=M,t[57]=N):N=t[57];let P;return t[58]!==T||t[59]!==O||t[60]!==N?(P=(0,$.jsxs)(`article`,{className:f,children:[T,O,N]}),t[58]=T,t[59]=O,t[60]=N,t[61]=P):P=t[61],P}function je(e){return(0,$.jsx)(`li`,{className:`text-xs text-fg-muted`,children:e},e)}function Me(e){let t=(0,Q.c)(17),{catalog:n,cards:r,ch:i,saving:a,onOpenChannel:o,onToggleChannel:s}=e,c;t[0]===r?c=t[1]:(c=new Map(r.map(Ne)),t[0]=r,t[1]=c);let l=c,u;if(t[2]!==l||t[3]!==n||t[4]!==i||t[5]!==o||t[6]!==s||t[7]!==a){let e;t[9]!==l||t[10]!==i||t[11]!==o||t[12]!==s||t[13]!==a?(e=e=>{let t=l.get(e.id);return t?(0,$.jsx)(`li`,{className:`h-full min-h-0`,children:(0,$.jsx)(Ae,{channelId:e.id,title:e.title,subtitle:e.subtitle,vm:t,toggleDisabled:a||!t.manageable,onOpen:()=>o(e.id),onReviewPairing:()=>o(e.id,{scrollToPairing:!0}),onToggle:t=>s(e.id,t),ch:i})},e.id):null},t[9]=l,t[10]=i,t[11]=o,t[12]=s,t[13]=a,t[14]=e):e=t[14],u=n.map(e),t[2]=l,t[3]=n,t[4]=i,t[5]=o,t[6]=s,t[7]=a,t[8]=u}else u=t[8];let d;return t[15]===u?d=t[16]:(d=(0,$.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,role:`list`,children:u}),t[15]=u,t[16]=d),d}function Ne(e){return[e.id,e]}var Pe=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function Fe(){let e=(0,Q.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:z(`size-11 shrink-0 rounded-xl`,Pe)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:z(`h-4 w-2/5`,Pe)}),(0,$.jsx)(`div`,{className:z(`h-5 w-16 rounded-full`,Pe)})]}),(0,$.jsx)(`div`,{className:z(`h-6 w-10 shrink-0 rounded-full`,Pe)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:z(`h-3 w-full`,Pe)}),(0,$.jsx)(`div`,{className:z(`h-3 w-[88%]`,Pe)})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex h-full min-h-[13.5rem] flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm dark:border-edge-subtle`,"aria-hidden":!0,children:[n,r,(0,$.jsx)(`div`,{className:`mt-auto`,children:(0,$.jsx)(`div`,{className:z(`h-10 w-full rounded-lg`,Pe)})})]}),e[3]=i):i=e[3],i}function Ie(e){let t=(0,Q.c)(2),{count:n}=e,r=n===void 0?3:n,i;return t[0]===r?i=t[1]:(i=(0,$.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,role:`list`,"aria-busy":!0,children:Array.from({length:r},Le)}),t[0]=r,t[1]=i),i}function Le(e,t){return(0,$.jsx)(`li`,{className:`h-full min-h-0`,children:(0,$.jsx)(Fe,{})},t)}function Re(e,t=!1){return e===`drawer`?z(`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`,K):z(`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)]`,K,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function ze(e){let t=(0,Q.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:m}=e,h=f===void 0?!1:f,_=n===`drawer`,v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(C,{className:z(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,p)}),t[0]=v):v=t[0];let y;t[1]!==n||t[2]!==h?(y=Re(n,h),t[1]=n,t[2]=h,t[3]=y):y=t[3];let b;t[4]===s?b=t[5]:(b=s?(0,$.jsx)(w,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=b);let x;t[6]===c?x=t[7]:(x=c?(0,$.jsx)(W,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=x);let S;t[8]!==l||t[9]!==o||t[10]!==m||t[11]!==_||t[12]!==a?(S=_?(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:[a?(0,$.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,$.jsx)(N,{className:`size-5`,strokeWidth:1.75})})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:z(O,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,$.jsx)(N,{className:`size-4`})})}),m]}),t[8]=l,t[9]=o,t[10]=m,t[11]=_,t[12]=a,t[13]=S):S=t[13];let T=_?`px-4 py-4`:`p-6`,E;t[14]===T?E=t[15]:(E=z(`min-h-0 flex-1 overflow-y-auto`,T),t[14]=T,t[15]=E);let D;t[16]!==u||t[17]!==E?(D=(0,$.jsx)(`div`,{className:E,children:u}),t[16]=u,t[17]=E,t[18]=D):D=t[18];let k;t[19]!==d||t[20]!==y||t[21]!==b||t[22]!==x||t[23]!==S||t[24]!==D?(k=(0,$.jsxs)(g,{children:[v,(0,$.jsxs)(M,{className:y,onOpenAutoFocus:Be,children:[b,x,S,D,d]})]}),t[19]=d,t[20]=y,t[21]=b,t[22]=x,t[23]=S,t[24]=D,t[25]=k):k=t[25];let A;return t[26]!==i||t[27]!==r||t[28]!==k?(A=(0,$.jsx)(U,{open:r,onOpenChange:i,children:k}),t[26]=i,t[27]=r,t[28]=k,t[29]=A):A=t[29],A}function Be(e){return e.preventDefault()}function Ve(e){let t=(0,Q.c)(52),{open:n,onOpenChange:r,entry:i,vm:a,ch:o,language:s}=e,c=a.status===`running`?o.hubStatusRunning:a.status===`offline`?o.hubStatusOffline:a.status===`disabled`?o.hubStatusDisabled:o.hubStatusNotConfigured,l=i.title,u=i.subtitle,d=o.modalCancel,f;t[0]===i.title?f=t[1]:(f=(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:i.title}),t[0]=i.title,t[1]=f);let p;t[2]===i.subtitle?p=t[3]:(p=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.subtitle}),t[2]=i.subtitle,t[3]=p);let h;t[4]!==f||t[5]!==p?(h=(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-6 pb-4 pt-6 dark:border-edge-subtle`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=h):h=t[6];let g;t[7]===o.hubExtensionManageHint?g=t[8]:(g=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hubExtensionManageHint}),t[7]=o.hubExtensionManageHint,t[8]=g);let _;t[9]===o.hubExtensionStatusLabel?_=t[10]:(_=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionStatusLabel}),t[9]=o.hubExtensionStatusLabel,t[10]=_);let v;t[11]===c?v=t[12]:(v=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:c}),t[11]=c,t[12]=v);let y;t[13]!==_||t[14]!==v?(y=(0,$.jsxs)(`div`,{children:[_,v]}),t[13]=_,t[14]=v,t[15]=y):y=t[15];let b;t[16]===o.hubExtensionEnabledLabel?b=t[17]:(b=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionEnabledLabel}),t[16]=o.hubExtensionEnabledLabel,t[17]=b);let x=a.enabled?o.hubExtensionYes:o.hubExtensionNo,S;t[18]===x?S=t[19]:(S=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:x}),t[18]=x,t[19]=S);let C;t[20]!==b||t[21]!==S?(C=(0,$.jsxs)(`div`,{children:[b,S]}),t[20]=b,t[21]=S,t[22]=C):C=t[22];let w;t[23]===o.hubExtensionConnectedLabel?w=t[24]:(w=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionConnectedLabel}),t[23]=o.hubExtensionConnectedLabel,t[24]=w);let T=a.connected?o.hubExtensionYes:o.hubExtensionNo,E;t[25]===T?E=t[26]:(E=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:T}),t[25]=T,t[26]=E);let D;t[27]!==w||t[28]!==E?(D=(0,$.jsxs)(`div`,{children:[w,E]}),t[27]=w,t[28]=E,t[29]=D):D=t[29];let O;t[30]!==y||t[31]!==C||t[32]!==D?(O=(0,$.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[y,C,D]}),t[30]=y,t[31]=C,t[32]=D,t[33]=O):O=t[33];let k;t[34]===s?k=t[35]:(k=m(s,`channels`),t[34]=s,t[35]=k);let A;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(F,{className:`ml-2 size-3.5`}),t[36]=A):A=t[36];let M;t[37]!==o.hubViewDocs||t[38]!==k?(M=(0,$.jsx)(j,{type:`button`,variant:`secondary`,asChild:!0,children:(0,$.jsxs)(`a`,{href:k,target:`_blank`,rel:`noreferrer`,children:[o.hubViewDocs,A]})}),t[37]=o.hubViewDocs,t[38]=k,t[39]=M):M=t[39];let N;t[40]!==O||t[41]!==M||t[42]!==g?(N=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[g,O,M]}),t[40]=O,t[41]=M,t[42]=g,t[43]=N):N=t[43];let P;return t[44]!==o.modalCancel||t[45]!==i.subtitle||t[46]!==i.title||t[47]!==r||t[48]!==n||t[49]!==N||t[50]!==h?(P=(0,$.jsx)(ze,{presentation:`modal`,open:n,onOpenChange:r,srTitle:l,srDescription:u,closeAriaLabel:d,headerExtra:h,children:N}),t[44]=o.modalCancel,t[45]=i.subtitle,t[46]=i.title,t[47]=r,t[48]=n,t[49]=N,t[50]=h,t[51]=P):P=t[51],P}var He=(0,Z.memo)(function(e){let t=(0,Q.c)(15),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,$.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=z(`size-4`,l),t[3]=l,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(k,{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,$.jsx)(j,{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,$.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 Ue(e){let t=(0,Q.c)(27),{accountIds:n,routes:r,defaultAgentId:o,agentItems:s,disabled:c,onChange:l,ch:u}=e,d=i(We),f,p,m,h,g;if(t[0]!==n||t[1]!==s||t[2]!==u||t[3]!==o||t[4]!==c||t[5]!==d||t[6]!==l||t[7]!==r){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a(d).agentsSettings;if(n.length===0){g=null;break bb0}let i=s.length>0?s:[{id:o}];m=`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`;let _;t[13]===u.agentRoutingTitle?_=t[14]:(_=(0,$.jsx)(Y,{children:u.agentRoutingTitle}),t[13]=u.agentRoutingTitle,t[14]=_);let v;t[15]===u.agentRoutingHint?v=t[16]:(v=(0,$.jsx)(ce,{children:u.agentRoutingHint}),t[15]=u.agentRoutingHint,t[16]=v),t[17]!==_||t[18]!==v?(h=(0,$.jsxs)(`div`,{children:[_,v]}),t[17]=_,t[18]=v,t[19]=h):h=t[19],f=`space-y-2`,p=n.map(t=>(0,$.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2.5 sm:grid-cols-2 sm:items-center dark:border-edge`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.agentRoutingAccountLabel}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:t,children:t})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${t}`,children:u.agentRoutingAgentLabel}),(0,$.jsx)(`select`,{id:`agent-route-${t}`,className:z(J(),V),disabled:c,value:(r[t]??o).toLowerCase(),onChange:e=>l(t,e.target.value),children:i.map(t=>(0,$.jsx)(`option`,{value:t.id,children:`${T(t,e)} (${t.id})`},t.id))})]})]},t))}t[0]=n,t[1]=s,t[2]=u,t[3]=o,t[4]=c,t[5]=d,t[6]=l,t[7]=r,t[8]=f,t[9]=p,t[10]=m,t[11]=h,t[12]=g}else f=t[8],p=t[9],m=t[10],h=t[11],g=t[12];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[20]!==f||t[21]!==p?(_=(0,$.jsx)(`div`,{className:f,children:p}),t[20]=f,t[21]=p,t[22]=_):_=t[22];let v;return t[23]!==m||t[24]!==h||t[25]!==_?(v=(0,$.jsxs)(`div`,{className:m,children:[h,_]}),t[23]=m,t[24]=h,t[25]=_,t[26]=v):v=t[26],v}function We(e){return e.language}function Ge(e){return e===`telegram`?`pairing`:`open`}function Ke(e,t,n){return n?.dmPolicy?n.dmPolicy:t??Ge(e)}function qe(e,t){if(e===`telegram`){let e=Te(t);return e.length>0?e:[`default`]}if(e===`weixin`){let e=Ee(t);return e.length>0?e:[`default`]}let n=le(t);return n.length>0?n:[`default`]}function Je(e){return e?.enabled!==!1}function Ye(e,t,n){let r=t.accounts?.[n];return Ke(e,t.dmPolicy,r)}function Xe(e,t){return qe(e,t).some(n=>{let r=t.accounts?.[n];return Je(r)?Ye(e,t,n)===`pairing`:!1})}function Ze(e){return!e.configured||!e.channelEnabled||!e.usesPairing?0:e.summaryPending}function Qe(e){let{channel:t,accountId:n,messages:r,mutate:i,setCodeBySender:a,setBusySender:o,setFeedback:s}=e,c=(0,Z.useCallback)(async(e,t)=>{o(e),s(null);try{let n=await t();a(t=>{let n={...t};return delete n[e],n}),s({kind:`ok`,text:r.pairingApproved.replace(`{{id}}`,n.senderId)}),await i()}catch(e){let t=e instanceof Error?e.message:r.pairingInvalid;s({kind:`err`,text:t.includes(`PAIRING`)?r.pairingInvalid:t})}finally{o(null)}},[r.pairingApproved,r.pairingInvalid,i,o,a,s]);return{approveByCode:(0,Z.useCallback)((e,r)=>{let i=r.trim().toUpperCase();i&&c(e,()=>ue({channel:t,accountId:n,code:i}))},[n,t,c]),quickApprove:(0,Z.useCallback)(e=>{c(e,()=>ge({channel:t,accountId:n,senderId:e}))},[n,t,c])}}var $e=[`channels-pairing-requested`,`channels-pairing-refreshed`,`channels-pairing-approved`,`channels-pairing-revoked`,`channels-pairing-dismissed`],et=`channel-pairing-summary`;function tt(e){let t=()=>e();for(let e of $e)window.addEventListener(e,t);return()=>{for(let e of $e)window.removeEventListener(e,t)}}function nt(e,t){let n=(0,Q.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return tt(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,Z.useEffect)(i,a)}function rt(e){return`channel-pairing-${e}`}function it(e){requestAnimationFrame(()=>{document.getElementById(rt(e))?.scrollIntoView({behavior:`smooth`,block:`start`})})}function at(e,t){let n=Date.parse(e)-Date.now();if(!Number.isFinite(n))return e;let r=Math.max(1,Math.round(Math.abs(n)/6e4));if(n<=0)return t.startsWith(`zh`)?`已过期`:`expired`;if(r<60)return t.startsWith(`zh`)?`${r} 分钟后`:`in ${r} min`;let i=Math.round(r/60);return t.startsWith(`zh`)?`${i} 小时后`:`in ${i} h`}function ot(e,t){return`channel-pairing-${e}-${t}`}var st={codeBySender:{},busySender:null,dismissingId:null,revokingId:null,feedback:null};function ct(e,t){switch(t.type){case`setCodeBySender`:return{...e,codeBySender:t.updater(e.codeBySender)};case`setBusySender`:return{...e,busySender:t.value};case`setDismissingId`:return{...e,dismissingId:t.value};case`setRevokingId`:return{...e,revokingId:t.value};case`setFeedback`:return{...e,feedback:t.value};case`clearSenderCode`:{let n={...e.codeBySender};return delete n[t.senderId],{...e,codeBySender:n}}}}function lt({channel:e,accountIds:t,channelConfig:n,active:r,ch:i,language:a,onPairedChange:o}){let c=J,l=(0,Z.useMemo)(()=>{let e=(t??[`default`]).filter(Boolean);return e.length>0?e:[`default`]},[t]),u=(0,Z.useMemo)(()=>Xe(e,n),[e,n]),d=(0,Z.useCallback)(t=>Ye(e,n,t),[e,n]),[f,p]=(0,Z.useState)(l[0]??`default`),[m,h]=(0,Z.useState)(l);l!==m&&(h(l),l.includes(f)||p(l[0]??`default`));let[g,_]=(0,Z.useReducer)(ct,st),{codeBySender:v,busySender:y,dismissingId:b,revokingId:x,feedback:S}=g,C=d(f)===`pairing`,w=(0,Z.useRef)(o);w.current=o;let{data:T,error:E,isLoading:D,mutate:O}=s(r&&u&&C?ot(e,f):null,()=>de(e,f),{revalidateOnFocus:!0,onSuccess:e=>{w.current?.(e.paired.fromCredentials.length)}});nt((0,Z.useCallback)(()=>{O()},[O]),r&&u&&C);let A=T?.paired.fromCredentials??[],M=(0,Z.useCallback)(e=>{_({type:`setCodeBySender`,updater:typeof e==`function`?e:()=>e})},[]),P=(0,Z.useCallback)(e=>{_({type:`setBusySender`,value:typeof e==`function`?e(g.busySender):e})},[g.busySender]),F=(0,Z.useCallback)(e=>{_({type:`setFeedback`,value:typeof e==`function`?e(g.feedback):e})},[g.feedback]),{approveByCode:I,quickApprove:L}=Qe({channel:e,accountId:f,messages:{pairingApproved:i.pairingApproved,pairingInvalid:i.pairingInvalid},mutate:O,setCodeBySender:M,setBusySender:P,setFeedback:F}),R=(0,Z.useCallback)(async t=>{_({type:`setDismissingId`,value:t}),_({type:`setFeedback`,value:null});try{await be({channel:e,accountId:f,senderId:t}),_({type:`clearSenderCode`,senderId:t}),_({type:`setFeedback`,value:{kind:`ok`,text:i.pairingDismissed.replace(`{{id}}`,t)}}),await O()}catch(e){_({type:`setFeedback`,value:{kind:`err`,text:e instanceof Error?e.message:i.pairingDismissError}})}finally{_({type:`setDismissingId`,value:null})}},[f,e,i.pairingDismissed,i.pairingDismissError,O]),B=(0,Z.useCallback)(async t=>{_({type:`setRevokingId`,value:t}),_({type:`setFeedback`,value:null});try{await me({channel:e,accountId:f,senderId:t}),_({type:`setFeedback`,value:{kind:`ok`,text:i.pairingRevoked.replace(`{{id}}`,t)}}),await O()}catch(e){_({type:`setFeedback`,value:{kind:`err`,text:e instanceof Error?e.message:i.pairingRevokeError}})}finally{_({type:`setRevokingId`,value:null})}},[f,e,i.pairingRevoked,i.pairingRevokeError,O]);if(!u)return null;if(!C)return(0,$.jsxs)(`div`,{id:rt(e),className:`space-y-2 rounded-xl border border-edge-subtle bg-surface-base/50 p-4 dark:border-edge`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.pairingTitle}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.pairingAccountNotPairing.replace(`{{account}}`,f)}),l.length>1?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:i.pairingAccountLabel}),(0,$.jsx)(`select`,{className:c(),value:f,onChange:e=>p(e.target.value),children:l.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}):null]});let ee=T?.pending??[],V=T?.paired.fromConfig??[];return(0,$.jsxs)(`div`,{id:rt(e),className:`space-y-3 rounded-xl border border-edge-subtle bg-surface-base/50 p-4 dark:border-edge`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.pairingTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i.pairingSubtitle})]}),(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":i.pairingRefresh,disabled:D,onClick:()=>void O(),children:(0,$.jsx)(k,{className:z(`size-4 text-fg-muted`,D&&`animate-spin`)})})]}),l.length>1?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:i.pairingAccountLabel}),(0,$.jsx)(`select`,{className:c(),value:f,onChange:e=>p(e.target.value),children:l.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,$.jsx)(ce,{children:i.pairingSetupHint}),E?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:i.pairingLoadError}):null,S?(0,$.jsx)(`p`,{className:z(`text-xs`,S.kind===`ok`?`text-success`:`text-red-600 dark:text-red-400`),children:S.text}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{children:i.pairingPendingTitle}),ee.length>0?(0,$.jsx)(ce,{children:i.pairingQuickApproveHint}):null,ee.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.pairingPendingEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:ee.map(e=>{let t=v[e.senderId]??``,n=y===e.senderId,r=b===e.senderId;return(0,$.jsxs)(`li`,{className:z(`rounded-lg border bg-surface-panel p-3 dark:border-edge`,e.isStale?`border-amber-300/50 dark:border-amber-800/50`:`border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-xs text-fg`,children:e.senderId}),(0,$.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[e.isStale?(0,$.jsx)(`span`,{className:`text-amber-800 dark:text-amber-200`,children:i.pairingStaleItem}):null,e.isStale?` · `:null,i.pairingExpiresHint.replace(`{{time}}`,at(e.expiresAt,a))]})]}),e.codeLast4?(0,$.jsx)(`p`,{className:`mt-1 text-[11px] text-fg-muted`,children:i.pairingCodeHint.replace(`{{suffix}}`,e.codeLast4)}):null,(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,$.jsx)(j,{type:`button`,variant:`secondary`,className:`shrink-0 text-xs`,disabled:n||r,onClick:()=>void L(e.senderId),children:n?i.pairingApproving:i.pairingQuickApprove}),(0,$.jsx)(`input`,{className:z(c(),`min-w-0 flex-1 font-mono text-xs uppercase`),value:t,autoComplete:`off`,spellCheck:!1,maxLength:8,placeholder:i.pairingCodePlaceholder,onChange:t=>M(n=>({...n,[e.senderId]:t.target.value.toUpperCase()})),onKeyDown:n=>{n.key===`Enter`&&I(e.senderId,t)}}),(0,$.jsx)(j,{type:`button`,variant:`primary`,className:`shrink-0 text-xs`,disabled:n||r||!t.trim(),onClick:()=>I(e.senderId,t),children:n?i.pairingApproving:i.pairingApprove}),(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`shrink-0 text-xs text-fg-muted hover:text-danger`,disabled:n||r,onClick:()=>void R(e.senderId),children:r?i.pairingDismissing:i.pairingDismiss})]})]},e.senderId)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-3 dark:border-edge-subtle`,children:[(0,$.jsx)(Y,{children:i.pairedTitle}),(0,$.jsxs)(`div`,{className:`grid gap-3 text-xs sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.pairedFromConfig}),(0,$.jsx)(`p`,{className:`mt-0.5 font-mono text-fg`,children:V.length?V.join(`, `):i.pairedEmpty})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.pairedFromCredentials}),A.length===0?(0,$.jsx)(`p`,{className:`mt-0.5 font-mono text-fg`,children:i.pairedEmpty}):(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:A.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-fg`,children:e}),(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`size-7 shrink-0 p-0 text-fg-muted hover:text-danger`,"aria-label":i.pairingRevokeAria.replace(`{{id}}`,e),disabled:x===e,onClick:()=>void B(e),children:(0,$.jsx)(N,{className:`size-3.5`})})]},e))})]})]})]})]})}function ut(e){let t=(0,Q.c)(347),{ch:n,form:r,baseline:i,showFeishuWebhookSecrets:a,setShowFeishuWebhookSecrets:o,feishuWebhookCopied:s,copyFeishuWebhookConfig:l,updateFeishu:u,updateChannelAgentRoute:f,feishuAccountsDraft:p,setFeishuAccountsDraft:m,feishuAccountsError:g,onFeishuAccountsBlur:_,dmOpts:y,groupOpts:b,chatAgents:C,saving:w,language:T,dialogOpen:E,pairingFocus:D}=e,O=D===void 0?!1:D,k=r.feishu,A;t[0]===k?A=t[1]:(A=le(k),t[0]=k,t[1]=A);let M=A,N;t[2]===M?N=t[3]:(N=M.length>0?M:[`default`],t[2]=M,t[3]=N);let P=N,F=i?.feishu?.appSecret??``,I;t[4]!==n.copied||t[5]!==n.copy||t[6]!==n.hide||t[7]!==n.show?(I=v({show:n.show,hide:n.hide,copy:n.copy,copied:n.copied}),t[4]=n.copied,t[5]=n.copy,t[6]=n.hide,t[7]=n.show,t[8]=I):I=t[8];let L=I,R=(0,Z.useRef)(null),ee,V;t[9]===O?(ee=t[10],V=t[11]):(ee=()=>{if(!O)return;let e=R.current;e&&(e.open=!0);let t=window.setTimeout(pt,80);return()=>window.clearTimeout(t)},V=[O],t[9]=O,t[10]=ee,t[11]=V),(0,Z.useEffect)(ee,V);let te;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(S,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[12]=te):te=t[12];let H;t[13]===n.advancedShow?H=t[14]:(H=(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[te,n.advancedShow]})}),t[13]=n.advancedShow,t[14]=H);let U;t[15]===n.feishuAdvancedHint?U=t[16]:(U=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.feishuAdvancedHint}),t[15]=n.feishuAdvancedHint,t[16]=U);let W;t[17]===u?W=t[18]:(W=e=>u({enabled:e.target.checked}),t[17]=u,t[18]=W);let G;t[19]!==k.enabled||t[20]!==W?(G=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:k.enabled,onChange:W}),t[19]=k.enabled,t[20]=W,t[21]=G):G=t[21];let K;t[22]===n.enableFeishuAria?K=t[23]:(K=(0,$.jsx)(`span`,{children:n.enableFeishuAria}),t[22]=n.enableFeishuAria,t[23]=K);let q;t[24]!==G||t[25]!==K?(q=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[G,K]}),t[24]=G,t[25]=K,t[26]=q):q=t[26];let ne;t[27]===u?ne=t[28]:(ne=e=>u({dmPolicy:e}),t[27]=u,t[28]=ne);let re;t[29]!==n.dmPolicy||t[30]!==y||t[31]!==k.dmPolicy||t[32]!==ne?(re=(0,$.jsx)(se,{label:n.dmPolicy,value:k.dmPolicy,onChange:ne,options:y}),t[29]=n.dmPolicy,t[30]=y,t[31]=k.dmPolicy,t[32]=ne,t[33]=re):re=t[33];let ae;t[34]!==n||t[35]!==E||t[36]!==k||t[37]!==T||t[38]!==P?(ae=(0,$.jsx)(lt,{channel:`feishu`,accountIds:P,channelConfig:k,active:E,ch:n,language:T}),t[34]=n,t[35]=E,t[36]=k,t[37]=T,t[38]=P,t[39]=ae):ae=t[39];let ue;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[40]=ue):ue=t[40];let de;t[41]===n.feishuAppId?de=t[42]:(de=(0,$.jsxs)(Y,{children:[n.feishuAppId,ue]}),t[41]=n.feishuAppId,t[42]=de);let fe;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(fe=z(J(),`min-w-0 flex-1 font-mono text-xs`),t[43]=fe):fe=t[43];let pe;t[44]===u?pe=t[45]:(pe=e=>u({appId:e.target.value}),t[44]=u,t[45]=pe);let me;t[46]!==k.appId||t[47]!==pe?(me=(0,$.jsx)(`input`,{className:fe,value:k.appId,onChange:pe,placeholder:`cli_xxx`}),t[46]=k.appId,t[47]=pe,t[48]=me):me=t[48];let he;t[49]===n.feishuAppIdDesc?he=t[50]:(he=(0,$.jsx)(ce,{children:n.feishuAppIdDesc}),t[49]=n.feishuAppIdDesc,t[50]=he);let ge;t[51]!==de||t[52]!==me||t[53]!==he?(ge=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[de,me,he]}),t[51]=de,t[52]=me,t[53]=he,t[54]=ge):ge=t[54];let _e;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[55]=_e):_e=t[55];let ve;t[56]===n.feishuAppSecret?ve=t[57]:(ve=(0,$.jsxs)(Y,{children:[n.feishuAppSecret,_e]}),t[56]=n.feishuAppSecret,t[57]=ve);let ye=k.appSecret,be;t[58]===u?be=t[59]:(be=e=>u({appSecret:e}),t[58]=u,t[59]=be);let xe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(xe=z(J(),`text-xs`),t[60]=xe):xe=t[60];let X;t[61]!==F||t[62]!==k.appSecret||t[63]!==L||t[64]!==be?(X=(0,$.jsx)(B,{value:ye,onChange:be,placeholder:`••••••••`,labels:L,baselineValue:F,inputClassName:xe}),t[61]=F,t[62]=k.appSecret,t[63]=L,t[64]=be,t[65]=X):X=t[65];let Se;t[66]===n.feishuAppSecretDesc?Se=t[67]:(Se=(0,$.jsx)(ce,{children:n.feishuAppSecretDesc}),t[66]=n.feishuAppSecretDesc,t[67]=Se);let Ce;t[68]!==ve||t[69]!==X||t[70]!==Se?(Ce=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ve,X,Se]}),t[68]=ve,t[69]=X,t[70]=Se,t[71]=Ce):Ce=t[71];let we;t[72]===n.feishuDomain?we=t[73]:(we=(0,$.jsx)(Y,{children:n.feishuDomain}),t[72]=n.feishuDomain,t[73]=we);let Te;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(Te=J(),t[74]=Te):Te=t[74];let Ee=String(k.domain||`feishu`),De;t[75]===u?De=t[76]:(De=e=>u({domain:e.target.value}),t[75]=u,t[76]=De);let Oe,ke;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,$.jsx)(`option`,{value:`feishu`,children:`feishu`}),ke=(0,$.jsx)(`option`,{value:`lark`,children:`lark`}),t[77]=Oe,t[78]=ke):(Oe=t[77],ke=t[78]);let Ae;t[79]!==Ee||t[80]!==De?(Ae=(0,$.jsxs)(`select`,{className:Te,value:Ee,onChange:De,children:[Oe,ke]}),t[79]=Ee,t[80]=De,t[81]=Ae):Ae=t[81];let je;t[82]!==we||t[83]!==Ae?(je=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[we,Ae]}),t[82]=we,t[83]=Ae,t[84]=je):je=t[84];let Me;t[85]===n.connectionMode?Me=t[86]:(Me=(0,$.jsx)(Y,{children:n.connectionMode}),t[85]=n.connectionMode,t[86]=Me);let Ne;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=J(),t[87]=Ne):Ne=t[87];let Pe;t[88]===u?Pe=t[89]:(Pe=e=>u({connectionMode:e.target.value}),t[88]=u,t[89]=Pe);let Fe,Ie;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=(0,$.jsx)(`option`,{value:`websocket`,children:`websocket`}),Ie=(0,$.jsx)(`option`,{value:`webhook`,children:`webhook`}),t[90]=Fe,t[91]=Ie):(Fe=t[90],Ie=t[91]);let Le;t[92]!==k.connectionMode||t[93]!==Pe?(Le=(0,$.jsxs)(`select`,{className:Ne,value:k.connectionMode,onChange:Pe,children:[Fe,Ie]}),t[92]=k.connectionMode,t[93]=Pe,t[94]=Le):Le=t[94];let Re;t[95]===n.connectionModeDesc?Re=t[96]:(Re=(0,$.jsx)(ce,{children:n.connectionModeDesc}),t[95]=n.connectionModeDesc,t[96]=Re);let ze;t[97]!==Me||t[98]!==Le||t[99]!==Re?(ze=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Me,Le,Re]}),t[97]=Me,t[98]=Le,t[99]=Re,t[100]=ze):ze=t[100];let Be;t[101]!==je||t[102]!==ze?(Be=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[je,ze]}),t[101]=je,t[102]=ze,t[103]=Be):Be=t[103];let Ve;t[104]!==n.copied||t[105]!==n.copy||t[106]!==n.encryptKey||t[107]!==n.encryptKeyDesc||t[108]!==n.hide||t[109]!==n.show||t[110]!==n.verificationToken||t[111]!==n.verificationTokenDesc||t[112]!==n.webhookHost||t[113]!==n.webhookPath||t[114]!==n.webhookPathDesc||t[115]!==n.webhookPort||t[116]!==n.webhookTitle||t[117]!==l||t[118]!==s||t[119]!==k.connectionMode||t[120]!==k.encryptKey||t[121]!==k.verificationToken||t[122]!==k.webhookHost||t[123]!==k.webhookPath||t[124]!==k.webhookPort||t[125]!==o||t[126]!==a||t[127]!==u?(Ve=k.connectionMode===`webhook`?(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.webhookTitle}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(j,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>o(ft),children:[a?(0,$.jsx)(d,{className:`size-3.5`}):(0,$.jsx)(x,{className:`size-3.5`}),a?n.hide:n.show]}),(0,$.jsxs)(j,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void l(),children:[s?(0,$.jsx)(h,{className:`size-3.5`}):(0,$.jsx)(c,{className:`size-3.5`}),s?n.copied:n.copy]})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.verificationToken}),(0,$.jsx)(`input`,{className:z(J(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:k.verificationToken??``,onChange:e=>u({verificationToken:e.target.value})}),(0,$.jsx)(ce,{children:n.verificationTokenDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.encryptKey}),(0,$.jsx)(`input`,{className:z(J(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:k.encryptKey??``,onChange:e=>u({encryptKey:e.target.value})}),(0,$.jsx)(ce,{children:n.encryptKeyDesc})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(Y,{children:n.webhookHost}),(0,$.jsx)(`input`,{className:z(J(),`min-w-0 flex-1 font-mono text-xs`),value:k.webhookHost??``,onChange:e=>u({webhookHost:e.target.value}),placeholder:`127.0.0.1`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.webhookPort}),(0,$.jsx)(`input`,{className:z(J(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(k.webhookPort??``),onChange:e=>u({webhookPort:Number(e.target.value||`0`)||0}),placeholder:`3000`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.webhookPath}),(0,$.jsx)(`input`,{className:z(J(),`min-w-0 flex-1 font-mono text-xs`),value:k.webhookPath??``,onChange:e=>u({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,$.jsx)(ce,{children:n.webhookPathDesc})]})]}):null,t[104]=n.copied,t[105]=n.copy,t[106]=n.encryptKey,t[107]=n.encryptKeyDesc,t[108]=n.hide,t[109]=n.show,t[110]=n.verificationToken,t[111]=n.verificationTokenDesc,t[112]=n.webhookHost,t[113]=n.webhookPath,t[114]=n.webhookPathDesc,t[115]=n.webhookPort,t[116]=n.webhookTitle,t[117]=l,t[118]=s,t[119]=k.connectionMode,t[120]=k.encryptKey,t[121]=k.verificationToken,t[122]=k.webhookHost,t[123]=k.webhookPath,t[124]=k.webhookPort,t[125]=o,t[126]=a,t[127]=u,t[128]=Ve):Ve=t[128];let He;t[129]===n.renderMode?He=t[130]:(He=(0,$.jsx)(Y,{children:n.renderMode}),t[129]=n.renderMode,t[130]=He);let We;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(We=J(),t[131]=We):We=t[131];let Ge;t[132]===u?Ge=t[133]:(Ge=e=>u({renderMode:e.target.value}),t[132]=u,t[133]=Ge);let Ke,qe,Je;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,$.jsx)(`option`,{value:`auto`,children:`auto`}),qe=(0,$.jsx)(`option`,{value:`raw`,children:`raw`}),Je=(0,$.jsx)(`option`,{value:`card`,children:`card`}),t[134]=Ke,t[135]=qe,t[136]=Je):(Ke=t[134],qe=t[135],Je=t[136]);let Ye;t[137]!==k.renderMode||t[138]!==Ge?(Ye=(0,$.jsxs)(`select`,{className:We,value:k.renderMode,onChange:Ge,children:[Ke,qe,Je]}),t[137]=k.renderMode,t[138]=Ge,t[139]=Ye):Ye=t[139];let Xe;t[140]!==He||t[141]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[He,Ye]}),t[140]=He,t[141]=Ye,t[142]=Xe):Xe=t[142];let Ze;t[143]===n.reactionNotifications?Ze=t[144]:(Ze=(0,$.jsx)(Y,{children:n.reactionNotifications}),t[143]=n.reactionNotifications,t[144]=Ze);let Qe;t[145]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=J(),t[145]=Qe):Qe=t[145];let $e;t[146]===u?$e=t[147]:($e=e=>u({reactionNotifications:e.target.value}),t[146]=u,t[147]=$e);let et,tt,nt;t[148]===Symbol.for(`react.memo_cache_sentinel`)?(et=(0,$.jsx)(`option`,{value:`off`,children:`off`}),tt=(0,$.jsx)(`option`,{value:`own`,children:`own`}),nt=(0,$.jsx)(`option`,{value:`all`,children:`all`}),t[148]=et,t[149]=tt,t[150]=nt):(et=t[148],tt=t[149],nt=t[150]);let rt;t[151]!==k.reactionNotifications||t[152]!==$e?(rt=(0,$.jsxs)(`select`,{className:Qe,value:k.reactionNotifications,onChange:$e,children:[et,tt,nt]}),t[151]=k.reactionNotifications,t[152]=$e,t[153]=rt):rt=t[153];let it;t[154]!==Ze||t[155]!==rt?(it=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ze,rt]}),t[154]=Ze,t[155]=rt,t[156]=it):it=t[156];let at;t[157]!==Xe||t[158]!==it?(at=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Xe,it]}),t[157]=Xe,t[158]=it,t[159]=at):at=t[159];let ot;t[160]===u?ot=t[161]:(ot=e=>u({streaming:e.target.checked}),t[160]=u,t[161]=ot);let st;t[162]!==k.streaming||t[163]!==ot?(st=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:k.streaming,onChange:ot}),t[162]=k.streaming,t[163]=ot,t[164]=st):st=t[164];let ct;t[165]!==n.enableStreaming||t[166]!==st?(ct=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[st,n.enableStreaming]}),t[165]=n.enableStreaming,t[166]=st,t[167]=ct):ct=t[167];let ut;t[168]===n.groupPolicy?ut=t[169]:(ut=(0,$.jsx)(Y,{children:n.groupPolicy}),t[168]=n.groupPolicy,t[169]=ut);let mt;t[170]===Symbol.for(`react.memo_cache_sentinel`)?(mt=J(),t[170]=mt):mt=t[170];let ht=k.groupPolicy,gt;t[171]===u?gt=t[172]:(gt=e=>u({groupPolicy:e.target.value}),t[171]=u,t[172]=gt);let _t;t[173]===b?_t=t[174]:(_t=b.map(dt),t[173]=b,t[174]=_t);let vt;t[175]!==k.groupPolicy||t[176]!==gt||t[177]!==_t?(vt=(0,$.jsx)(`select`,{className:mt,value:ht,onChange:gt,children:_t}),t[175]=k.groupPolicy,t[176]=gt,t[177]=_t,t[178]=vt):vt=t[178];let yt;t[179]!==ut||t[180]!==vt?(yt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ut,vt]}),t[179]=ut,t[180]=vt,t[181]=yt):yt=t[181];let bt;t[182]===u?bt=t[183]:(bt=e=>u({requireMention:e.target.checked}),t[182]=u,t[183]=bt);let xt;t[184]!==k.requireMention||t[185]!==bt?(xt=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:k.requireMention,onChange:bt}),t[184]=k.requireMention,t[185]=bt,t[186]=xt):xt=t[186];let St;t[187]!==n.requireMention||t[188]!==xt?(St=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[xt,n.requireMention]}),t[187]=n.requireMention,t[188]=xt,t[189]=St):St=t[189];let Ct;t[190]===n.allowFromDm?Ct=t[191]:(Ct=(0,$.jsx)(Y,{children:n.allowFromDm}),t[190]=n.allowFromDm,t[191]=Ct);let wt;t[192]===Symbol.for(`react.memo_cache_sentinel`)?(wt=z(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[192]=wt):wt=t[192];let Tt;t[193]===k.allowFrom?Tt=t[194]:(Tt=ie(k.allowFrom),t[193]=k.allowFrom,t[194]=Tt);let Et;t[195]===u?Et=t[196]:(Et=e=>u({allowFrom:oe(e.target.value)}),t[195]=u,t[196]=Et);let Dt;t[197]!==Tt||t[198]!==Et?(Dt=(0,$.jsx)(`textarea`,{className:wt,rows:2,placeholder:`ou_xxx, on_xxx`,value:Tt,onChange:Et}),t[197]=Tt,t[198]=Et,t[199]=Dt):Dt=t[199];let Ot;t[200]===n.allowFromDmDesc?Ot=t[201]:(Ot=(0,$.jsx)(ce,{children:n.allowFromDmDesc}),t[200]=n.allowFromDmDesc,t[201]=Ot);let kt;t[202]!==Ct||t[203]!==Dt||t[204]!==Ot?(kt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ct,Dt,Ot]}),t[202]=Ct,t[203]=Dt,t[204]=Ot,t[205]=kt):kt=t[205];let At;t[206]===n.allowFromGroups?At=t[207]:(At=(0,$.jsx)(Y,{children:n.allowFromGroups}),t[206]=n.allowFromGroups,t[207]=At);let jt;t[208]===Symbol.for(`react.memo_cache_sentinel`)?(jt=z(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[208]=jt):jt=t[208];let Mt;t[209]===k.groupAllowFrom?Mt=t[210]:(Mt=ie(k.groupAllowFrom),t[209]=k.groupAllowFrom,t[210]=Mt);let Nt;t[211]===u?Nt=t[212]:(Nt=e=>u({groupAllowFrom:oe(e.target.value)}),t[211]=u,t[212]=Nt);let Pt;t[213]!==Mt||t[214]!==Nt?(Pt=(0,$.jsx)(`textarea`,{className:jt,rows:2,placeholder:`oc_xxx, oc_yyy`,value:Mt,onChange:Nt}),t[213]=Mt,t[214]=Nt,t[215]=Pt):Pt=t[215];let Ft;t[216]===n.allowFromGroupsDesc?Ft=t[217]:(Ft=(0,$.jsx)(ce,{children:n.allowFromGroupsDesc}),t[216]=n.allowFromGroupsDesc,t[217]=Ft);let It;t[218]!==At||t[219]!==Pt||t[220]!==Ft?(It=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[At,Pt,Ft]}),t[218]=At,t[219]=Pt,t[220]=Ft,t[221]=It):It=t[221];let Lt;t[222]===n.historyLimit?Lt=t[223]:(Lt=(0,$.jsx)(Y,{children:n.historyLimit}),t[222]=n.historyLimit,t[223]=Lt);let Rt;t[224]===Symbol.for(`react.memo_cache_sentinel`)?(Rt=z(J(),`min-w-0 flex-1 font-mono text-xs`),t[224]=Rt):Rt=t[224];let zt=String(k.historyLimit),Bt;t[225]===u?Bt=t[226]:(Bt=e=>u({historyLimit:Number(e.target.value||`0`)||0}),t[225]=u,t[226]=Bt);let Vt;t[227]!==zt||t[228]!==Bt?(Vt=(0,$.jsx)(`input`,{className:Rt,type:`number`,inputMode:`numeric`,value:zt,onChange:Bt}),t[227]=zt,t[228]=Bt,t[229]=Vt):Vt=t[229];let Ht;t[230]!==Lt||t[231]!==Vt?(Ht=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Lt,Vt]}),t[230]=Lt,t[231]=Vt,t[232]=Ht):Ht=t[232];let Ut;t[233]===n.textChunkLimit?Ut=t[234]:(Ut=(0,$.jsx)(Y,{children:n.textChunkLimit}),t[233]=n.textChunkLimit,t[234]=Ut);let Wt;t[235]===Symbol.for(`react.memo_cache_sentinel`)?(Wt=z(J(),`min-w-0 flex-1 font-mono text-xs`),t[235]=Wt):Wt=t[235];let Gt=String(k.textChunkLimit),Kt;t[236]===u?Kt=t[237]:(Kt=e=>u({textChunkLimit:Number(e.target.value||`0`)||0}),t[236]=u,t[237]=Kt);let qt;t[238]!==Gt||t[239]!==Kt?(qt=(0,$.jsx)(`input`,{className:Wt,type:`number`,inputMode:`numeric`,value:Gt,onChange:Kt}),t[238]=Gt,t[239]=Kt,t[240]=qt):qt=t[240];let Jt;t[241]!==Ut||t[242]!==qt?(Jt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ut,qt]}),t[241]=Ut,t[242]=qt,t[243]=Jt):Jt=t[243];let Yt;t[244]!==Jt||t[245]!==Ht?(Yt=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Ht,Jt]}),t[244]=Jt,t[245]=Ht,t[246]=Yt):Yt=t[246];let Xt;t[247]===n.feishuToolsTitle?Xt=t[248]:(Xt=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuToolsTitle}),t[247]=n.feishuToolsTitle,t[248]=Xt);let Zt;t[249]===n.feishuToolDoc?Zt=t[250]:(Zt=[`doc`,n.feishuToolDoc],t[249]=n.feishuToolDoc,t[250]=Zt);let Qt;t[251]===n.feishuToolWiki?Qt=t[252]:(Qt=[`wiki`,n.feishuToolWiki],t[251]=n.feishuToolWiki,t[252]=Qt);let $t;t[253]===n.feishuToolDrive?$t=t[254]:($t=[`drive`,n.feishuToolDrive],t[253]=n.feishuToolDrive,t[254]=$t);let en;t[255]===n.feishuToolPerm?en=t[256]:(en=[`perm`,n.feishuToolPerm],t[255]=n.feishuToolPerm,t[256]=en);let tn;t[257]===n.feishuToolBitable?tn=t[258]:(tn=[`bitable`,n.feishuToolBitable],t[257]=n.feishuToolBitable,t[258]=tn);let nn;t[259]===n.feishuToolScopes?nn=t[260]:(nn=[`scopes`,n.feishuToolScopes],t[259]=n.feishuToolScopes,t[260]=nn);let rn;t[261]!==Zt||t[262]!==Qt||t[263]!==$t||t[264]!==en||t[265]!==tn||t[266]!==nn?(rn=[Zt,Qt,$t,en,tn,nn],t[261]=Zt,t[262]=Qt,t[263]=$t,t[264]=en,t[265]=tn,t[266]=nn,t[267]=rn):rn=t[267];let an=rn,on;t[268]!==k.tools||t[269]!==an||t[270]!==u?(on=(0,$.jsx)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:an.map(e=>{let[t,n]=e;return(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!k.tools?.[t],onChange:e=>u({tools:{...k.tools,[t]:e.target.checked}})}),n]},t)})}),t[268]=k.tools,t[269]=an,t[270]=u,t[271]=on):on=t[271];let sn;t[272]===n.feishuToolsDesc?sn=t[273]:(sn=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(ce,{children:n.feishuToolsDesc})}),t[272]=n.feishuToolsDesc,t[273]=sn);let cn;t[274]!==Xt||t[275]!==on||t[276]!==sn?(cn=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[Xt,on,sn]}),t[274]=Xt,t[275]=on,t[276]=sn,t[277]=cn):cn=t[277];let ln;t[278]===n.feishuActionsTitle?ln=t[279]:(ln=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuActionsTitle}),t[278]=n.feishuActionsTitle,t[279]=ln);let un=!!k.actions?.reactions,dn;t[280]!==k.actions||t[281]!==u?(dn=e=>u({actions:{...k.actions,reactions:e.target.checked}}),t[280]=k.actions,t[281]=u,t[282]=dn):dn=t[282];let fn;t[283]!==un||t[284]!==dn?(fn=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:un,onChange:dn}),t[283]=un,t[284]=dn,t[285]=fn):fn=t[285];let pn;t[286]!==n.feishuActionReactions||t[287]!==fn?(pn=(0,$.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[fn,n.feishuActionReactions]}),t[286]=n.feishuActionReactions,t[287]=fn,t[288]=pn):pn=t[288];let mn;t[289]!==ln||t[290]!==pn?(mn=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[ln,pn]}),t[289]=ln,t[290]=pn,t[291]=mn):mn=t[291];let hn;t[292]===k?hn=t[293]:(hn=le(k),t[292]=k,t[293]=hn);let gn;t[294]===C?.items?gn=t[295]:(gn=C?.items??[],t[294]=C?.items,t[295]=gn);let _n;t[296]===f?_n=t[297]:(_n=(e,t)=>f(`feishu`,e,t),t[296]=f,t[297]=_n);let vn;t[298]!==n||t[299]!==r.channelAgentRoutes.feishu||t[300]!==r.defaultAgentId||t[301]!==w||t[302]!==hn||t[303]!==gn||t[304]!==_n?(vn=(0,$.jsx)(Ue,{accountIds:hn,routes:r.channelAgentRoutes.feishu,defaultAgentId:r.defaultAgentId,agentItems:gn,disabled:w,onChange:_n,ch:n}),t[298]=n,t[299]=r.channelAgentRoutes.feishu,t[300]=r.defaultAgentId,t[301]=w,t[302]=hn,t[303]=gn,t[304]=_n,t[305]=vn):vn=t[305];let yn;t[306]===n.multiAccountJson?yn=t[307]:(yn=(0,$.jsx)(Y,{children:n.multiAccountJson}),t[306]=n.multiAccountJson,t[307]=yn);let bn;t[308]===Symbol.for(`react.memo_cache_sentinel`)?(bn=z(J(),`min-h-[140px] resize-y font-mono text-xs`),t[308]=bn):bn=t[308];let xn;t[309]===m?xn=t[310]:(xn=e=>m(e.target.value),t[309]=m,t[310]=xn);let Sn;t[311]!==p||t[312]!==_||t[313]!==xn?(Sn=(0,$.jsx)(`textarea`,{className:bn,spellCheck:!1,value:p,onChange:xn,onBlur:_,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),t[311]=p,t[312]=_,t[313]=xn,t[314]=Sn):Sn=t[314];let Cn;t[315]!==n.multiAccountJsonDesc||t[316]!==g?(Cn=g?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:g}):(0,$.jsx)(ce,{children:n.multiAccountJsonDesc}),t[315]=n.multiAccountJsonDesc,t[316]=g,t[317]=Cn):Cn=t[317];let wn;t[318]!==yn||t[319]!==Sn||t[320]!==Cn?(wn=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[yn,Sn,Cn]}),t[318]=yn,t[319]=Sn,t[320]=Cn,t[321]=wn):wn=t[321];let Tn;t[322]!==Yt||t[323]!==cn||t[324]!==mn||t[325]!==vn||t[326]!==wn||t[327]!==ge||t[328]!==Ce||t[329]!==Be||t[330]!==Ve||t[331]!==at||t[332]!==ct||t[333]!==yt||t[334]!==St||t[335]!==kt||t[336]!==It?(Tn=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ge,Ce,Be,Ve,at,ct,yt,St,kt,It,Yt,cn,mn,vn,wn]}),t[322]=Yt,t[323]=cn,t[324]=mn,t[325]=vn,t[326]=wn,t[327]=ge,t[328]=Ce,t[329]=Be,t[330]=Ve,t[331]=at,t[332]=ct,t[333]=yt,t[334]=St,t[335]=kt,t[336]=It,t[337]=Tn):Tn=t[337];let En;t[338]!==q||t[339]!==Tn||t[340]!==re||t[341]!==ae||t[342]!==U?(En=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[U,q,re,ae,Tn]}),t[338]=q,t[339]=Tn,t[340]=re,t[341]=ae,t[342]=U,t[343]=En):En=t[343];let Dn;return t[344]!==En||t[345]!==H?(Dn=(0,$.jsxs)(`details`,{ref:R,className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[H,En]}),t[344]=En,t[345]=H,t[346]=Dn):Dn=t[346],Dn}function dt(e){return(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value)}function ft(e){return!e}function pt(){return it(`feishu`)}var mt=e(X(),1);function ht(e){let t=(0,Q.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,$.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,$.jsx)(j,{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,$.jsx)(j,{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,$.jsx)(j,{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,$.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,$.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}var gt={width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}},_t={sessionKey:null,qrUrl:null};function vt({ch:e,onSetupSuccess:t,onOpenChange:n,closeOnSetupSuccess:r,moreSettings:i}){let[a,o]=(0,Z.useState)(`feishu`),[s,c]=(0,Z.useState)(0),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(t),f=(0,Z.useRef)(n);d.current=t,f.current=n;let p=H(()=>we({domain:a}).then(e=>({sessionKey:e.sessionKey,qrUrl:e.qrUrl})),[s,a],{initial:_t,errorData:_t}),m=p.data.sessionKey,h=p.data.qrUrl,g=p.loading,_=p.error instanceof Error?p.error.message:p.error?String(p.error):null,v=l??_,y=(0,Z.useCallback)(e=>{u(null),o(e),c(e=>e+1)},[]);(0,Z.useEffect)(()=>{if(!m)return;let e=!1,t,n=async()=>{try{let n=await fe(m);if(e||n.phase===`polling`)return;if(n.phase===`done`){t!==void 0&&(window.clearInterval(t),t=void 0),p.setData(_t),n.ok?(r&&f.current(!1),d.current({appId:n.appId,domain:n.domain,openId:n.openId})):u(n.message);return}n.phase===`unknown`&&(t!==void 0&&window.clearInterval(t),u(n.message),p.setData(_t))}catch(n){e||(t!==void 0&&window.clearInterval(t),u(n instanceof Error?n.message:`Request failed`),p.setData(_t))}};return t=window.setInterval(()=>void n(),3e3),n(),()=>{e=!0,t!==void 0&&window.clearInterval(t)}},[m,r,p.setData]);let b=H(()=>mt.toDataURL(h,gt),[h],{enabled:!!h,initial:null,errorData:null}),x=b.data,S=b.error!==null&&!b.loading,C=!!(h&&m),w=!v&&!C;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`text-base font-semibold tracking-tight text-fg`,children:e.feishuQrModalTitle}),(0,$.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:e.feishuQrModalSubtitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[v?(0,$.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:v}):null,!v&&(C||w)?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:w?e.feishuQrStarting:e.feishuQrScanHint}),(0,$.jsxs)(`div`,{className:z(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,w&&`bg-surface-muted/40 dark:bg-surface-base`),children:[w?(0,$.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,C&&h&&!v&&x&&!S?(0,$.jsx)(`img`,{src:x,alt:``,className:`relative z-[1] size-full object-contain`}):null,C&&h&&!v&&!x&&!S&&!w?(0,$.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:e.feishuQrEncoding}):null,C&&h&&!v&&S?(0,$.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,$.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:e.feishuQrImageError}),(0,$.jsxs)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,$.jsx)(F,{className:`size-3 shrink-0`}),e.feishuQrOpenLink]})]}):null]})]}):null]}),(0,$.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[20rem] justify-center px-1`,role:`group`,"aria-label":e.feishuRegionSwitchAria,children:(0,$.jsxs)(`div`,{className:`inline-flex w-full rounded-full border border-edge bg-surface-muted/60 p-1 dark:border-edge dark:bg-surface-base`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:g,className:z(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,A.press,a===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>y(`feishu`),children:e.feishuRegionChina}),(0,$.jsx)(`button`,{type:`button`,disabled:g,className:z(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,A.press,a===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>y(`lark`),children:e.feishuRegionInternational})]})}),(0,$.jsx)(`div`,{className:`mt-6`,children:(0,$.jsx)(j,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:g,onClick:()=>y(a),children:g?e.feishuQrStarting:e.feishuQrRegenerate})}),i?(0,$.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})}function yt(e){let t=(0,Q.c)(26),{open:n,onOpenChange:r,ch:i,onSetupSuccess:a,moreSettings:o,settingsDirty:s,settingsSaving:c,onSettingsDiscard:l,onSettingsSave:u,presentation:d,closeOnSetupSuccess:f}=e,p=s===void 0?!1:s,m=c===void 0?!1:c,h=d===void 0?`modal`:d,g=f===void 0?!0:f,_;t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==l||t[4]!==u||t[5]!==p||t[6]!==m?(_=o&&l&&u?(0,$.jsx)(ht,{ch:i,dirty:p,saving:m,showCancel:!1,onCancel:()=>r(!1),onDiscard:l,onSave:u}):void 0,t[0]=i,t[1]=o,t[2]=r,t[3]=l,t[4]=u,t[5]=p,t[6]=m,t[7]=_):_=t[7];let v;t[8]!==i||t[9]!==g||t[10]!==o||t[11]!==r||t[12]!==a||t[13]!==n?(v=n?(0,$.jsx)(vt,{ch:i,onSetupSuccess:a,onOpenChange:r,closeOnSetupSuccess:g,moreSettings:o},`active`):null,t[8]=i,t[9]=g,t[10]=o,t[11]=r,t[12]=a,t[13]=n,t[14]=v):v=t[14];let y;return t[15]!==i.feishuQrCloseAria||t[16]!==i.feishuQrModalSubtitle||t[17]!==i.feishuQrModalTitle||t[18]!==i.feishuSubtitle||t[19]!==i.feishuTitle||t[20]!==r||t[21]!==n||t[22]!==h||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(ze,{presentation:h,open:n,onOpenChange:r,title:i.feishuTitle,description:i.feishuSubtitle,srTitle:i.feishuQrModalTitle,srDescription:i.feishuQrModalSubtitle,closeAriaLabel:i.feishuQrCloseAria,wide:!0,footer:_,children:v}),t[15]=i.feishuQrCloseAria,t[16]=i.feishuQrModalSubtitle,t[17]=i.feishuQrModalTitle,t[18]=i.feishuSubtitle,t[19]=i.feishuTitle,t[20]=r,t[21]=n,t[22]=h,t[23]=_,t[24]=v,t[25]=y):y=t[25],y}function bt(e){let t=(0,Q.c)(25),{ch:n,usesPairing:r,tokenReady:i,pairingComplete:a}=e;if(!r)return null;let o=i,s=a,c=!o,l=o&&!s,u;t[0]!==c||t[1]!==o?(u=(0,$.jsx)(xt,{done:o,current:c,index:1}),t[0]=c,t[1]=o,t[2]=u):u=t[2];let d=o&&`text-fg-muted`,f;t[3]===d?f=t[4]:(f=z(`text-fg`,d),t[3]=d,t[4]=f);let p;t[5]!==n.telegramSetupStepToken||t[6]!==f?(p=(0,$.jsx)(`span`,{className:f,children:n.telegramSetupStepToken}),t[5]=n.telegramSetupStepToken,t[6]=f,t[7]=p):p=t[7];let m;t[8]!==u||t[9]!==p?(m=(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[u,p]}),t[8]=u,t[9]=p,t[10]=m):m=t[10];let h;t[11]!==l||t[12]!==s?(h=(0,$.jsx)(xt,{done:s,current:l,index:2}),t[11]=l,t[12]=s,t[13]=h):h=t[13];let g=s&&`text-fg-muted`,_;t[14]===g?_=t[15]:(_=z(`text-fg`,g),t[14]=g,t[15]=_);let v;t[16]!==n.telegramSetupStepPairing||t[17]!==_?(v=(0,$.jsx)(`span`,{className:_,children:n.telegramSetupStepPairing}),t[16]=n.telegramSetupStepPairing,t[17]=_,t[18]=v):v=t[18];let y;t[19]!==h||t[20]!==v?(y=(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[h,v]}),t[19]=h,t[20]=v,t[21]=y):y=t[21];let b;return t[22]!==y||t[23]!==m?(b=(0,$.jsxs)(`ol`,{className:`space-y-2 rounded-xl border border-accent/25 bg-accent-soft/20 px-4 py-3 text-xs`,children:[m,y]}),t[22]=y,t[23]=m,t[24]=b):b=t[24],b}function xt(e){let t=(0,Q.c)(7),{done:n,current:r,index:i}=e,a=n&&`border-success bg-success text-white`,o=!n&&r&&`border-accent bg-accent text-white`,s=!n&&!r&&`border-edge text-fg-muted`,c;t[0]!==a||t[1]!==o||t[2]!==s?(c=z(`mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border text-[10px] font-semibold`,a,o,s),t[0]=a,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l=n?`✓`:String(i),u;return t[4]!==c||t[5]!==l?(u=(0,$.jsx)(`span`,{className:c,"aria-hidden":!0,children:l}),t[4]=c,t[5]=l,t[6]=u):u=t[6],u}function St(e){let t=(0,Q.c)(115),{tg:n,updateTelegram:r,ch:i,groupOpts:a,replyOpts:o,streamOpts:s,tgAccountsDraft:c,setTgAccountsDraft:l,tgAccountsError:u,onTgAccountsBlur:d}=e,f;t[0]===i.apiRoot?f=t[1]:(f=(0,$.jsx)(Y,{children:i.apiRoot}),t[0]=i.apiRoot,t[1]=f);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=J(),t[2]=p):p=t[2];let m;t[3]===r?m=t[4]:(m=e=>r({apiRoot:e.target.value}),t[3]=r,t[4]=m);let h;t[5]!==m||t[6]!==n.apiRoot?(h=(0,$.jsx)(`input`,{className:p,value:n.apiRoot,onChange:m,placeholder:`https://api.telegram.org`}),t[5]=m,t[6]=n.apiRoot,t[7]=h):h=t[7];let g;t[8]!==f||t[9]!==h?(g=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[f,h]}),t[8]=f,t[9]=h,t[10]=g):g=t[10];let _;t[11]===i.proxy?_=t[12]:(_=(0,$.jsx)(Y,{children:i.proxy}),t[11]=i.proxy,t[12]=_);let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=J(),t[13]=v):v=t[13];let y;t[14]===r?y=t[15]:(y=e=>r({proxy:e.target.value}),t[14]=r,t[15]=y);let b;t[16]!==y||t[17]!==n.proxy?(b=(0,$.jsx)(`input`,{className:v,value:n.proxy,onChange:y,placeholder:`http://proxy.example.com:8080`}),t[16]=y,t[17]=n.proxy,t[18]=b):b=t[18];let x;t[19]!==_||t[20]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[_,b]}),t[19]=_,t[20]=b,t[21]=x):x=t[21];let S;t[22]===r?S=t[23]:(S=e=>r({groupPolicy:e}),t[22]=r,t[23]=S);let C;t[24]!==i.groupPolicy||t[25]!==a||t[26]!==S||t[27]!==n.groupPolicy?(C=(0,$.jsx)(se,{label:i.groupPolicy,value:n.groupPolicy,onChange:S,options:a}),t[24]=i.groupPolicy,t[25]=a,t[26]=S,t[27]=n.groupPolicy,t[28]=C):C=t[28];let w;t[29]===r?w=t[30]:(w=e=>r({replyToMode:e}),t[29]=r,t[30]=w);let T;t[31]!==i.replyToMode||t[32]!==o||t[33]!==w||t[34]!==n.replyToMode?(T=(0,$.jsx)(se,{label:i.replyToMode,value:n.replyToMode,onChange:w,options:o}),t[31]=i.replyToMode,t[32]=o,t[33]=w,t[34]=n.replyToMode,t[35]=T):T=t[35];let E;t[36]===r?E=t[37]:(E=e=>r({streamMode:e}),t[36]=r,t[37]=E);let D;t[38]!==i.streamMode||t[39]!==s||t[40]!==E||t[41]!==n.streamMode?(D=(0,$.jsx)(se,{label:i.streamMode,value:n.streamMode,onChange:E,options:s}),t[38]=i.streamMode,t[39]=s,t[40]=E,t[41]=n.streamMode,t[42]=D):D=t[42];let O;t[43]===i.allowFromGroups?O=t[44]:(O=(0,$.jsx)(Y,{children:i.allowFromGroups}),t[43]=i.allowFromGroups,t[44]=O);let k;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(k=z(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[45]=k):k=t[45];let A;t[46]===n.groupAllowFrom?A=t[47]:(A=ie(n.groupAllowFrom),t[46]=n.groupAllowFrom,t[47]=A);let j;t[48]===r?j=t[49]:(j=e=>r({groupAllowFrom:oe(e.target.value)}),t[48]=r,t[49]=j);let M;t[50]!==A||t[51]!==j?(M=(0,$.jsx)(`textarea`,{className:k,rows:2,placeholder:`-1001234567890`,value:A,onChange:j}),t[50]=A,t[51]=j,t[52]=M):M=t[52];let N;t[53]!==O||t[54]!==M?(N=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[O,M]}),t[53]=O,t[54]=M,t[55]=N):N=t[55];let P;t[56]===i.historyLimit?P=t[57]:(P=(0,$.jsx)(Y,{children:i.historyLimit}),t[56]=i.historyLimit,t[57]=P);let F;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(F=J(),t[58]=F):F=t[58];let I;t[59]===r?I=t[60]:(I=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[59]=r,t[60]=I);let L;t[61]!==I||t[62]!==n.historyLimit?(L=(0,$.jsx)(`input`,{type:`number`,min:10,max:200,className:F,value:n.historyLimit,onChange:I}),t[61]=I,t[62]=n.historyLimit,t[63]=L):L=t[63];let R;t[64]!==P||t[65]!==L?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[P,L]}),t[64]=P,t[65]=L,t[66]=R):R=t[66];let B;t[67]===i.textChunkLimit?B=t[68]:(B=(0,$.jsx)(Y,{children:i.textChunkLimit}),t[67]=i.textChunkLimit,t[68]=B);let ee;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(ee=J(),t[69]=ee):ee=t[69];let V;t[70]===r?V=t[71]:(V=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[70]=r,t[71]=V);let te;t[72]!==V||t[73]!==n.textChunkLimit?(te=(0,$.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:ee,value:n.textChunkLimit,onChange:V}),t[72]=V,t[73]=n.textChunkLimit,t[74]=te):te=t[74];let H;t[75]!==B||t[76]!==te?(H=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[B,te]}),t[75]=B,t[76]=te,t[77]=H):H=t[77];let U;t[78]!==R||t[79]!==H?(U=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[R,H]}),t[78]=R,t[79]=H,t[80]=U):U=t[80];let W;t[81]===r?W=t[82]:(W=e=>r({debug:e.target.checked}),t[81]=r,t[82]=W);let G;t[83]!==W||t[84]!==n.debug?(G=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:W}),t[83]=W,t[84]=n.debug,t[85]=G):G=t[85];let K;t[86]!==i.telegramDebug||t[87]!==G?(K=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[G,i.telegramDebug]}),t[86]=i.telegramDebug,t[87]=G,t[88]=K):K=t[88];let q;t[89]===i.multiAccountJson?q=t[90]:(q=(0,$.jsx)(Y,{children:i.multiAccountJson}),t[89]=i.multiAccountJson,t[90]=q);let ne;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(ne=z(J(),`min-h-[140px] resize-y font-mono text-xs`),t[91]=ne):ne=t[91];let re;t[92]===l?re=t[93]:(re=e=>l(e.target.value),t[92]=l,t[93]=re);let ae;t[94]!==d||t[95]!==re||t[96]!==c?(ae=(0,$.jsx)(`textarea`,{className:ne,spellCheck:!1,value:c,onChange:re,onBlur:d,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),t[94]=d,t[95]=re,t[96]=c,t[97]=ae):ae=t[97];let le;t[98]!==i.multiAccountJsonDesc||t[99]!==u?(le=u?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:u}):(0,$.jsx)(ce,{children:i.multiAccountJsonDesc}),t[98]=i.multiAccountJsonDesc,t[99]=u,t[100]=le):le=t[100];let ue;t[101]!==q||t[102]!==ae||t[103]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[q,ae,le]}),t[101]=q,t[102]=ae,t[103]=le,t[104]=ue):ue=t[104];let de;return t[105]!==x||t[106]!==C||t[107]!==T||t[108]!==D||t[109]!==N||t[110]!==U||t[111]!==K||t[112]!==ue||t[113]!==g?(de=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[g,x,C,T,D,N,U,K,ue]}),t[105]=x,t[106]=C,t[107]=T,t[108]=D,t[109]=N,t[110]=U,t[111]=K,t[112]=ue,t[113]=g,t[114]=de):de=t[114],de}function Ct(e){let t=(0,Q.c)(151),{open:n,onOpenChange:r,presentation:i,ch:a,form:o,baseline:s,tgAdvanced:c,setTgAdvanced:l,updateTelegram:u,updateChannelAgentRoute:d,tgAccountsDraft:f,setTgAccountsDraft:p,tgAccountsError:m,onTgAccountsBlur:h,dmOpts:g,groupOpts:_,replyOpts:y,streamOpts:b,chatAgents:x,saving:C,dirty:w,save:T,discard:E,language:D,scrollToPairingOnOpen:O,closeOnSave:k}=e,A=i===void 0?`modal`:i,M=O===void 0?!1:O,N=k===void 0?!0:k,P=o.telegram,F;t[0]===s?F=t[1]:(F=s?ne(s.telegram):``,t[0]=s,t[1]=F);let I=F,L=ne(P),R;t[2]!==a.copied||t[3]!==a.copy||t[4]!==a.hide||t[5]!==a.show?(R=v({show:a.show,hide:a.hide,copy:a.copy,copied:a.copied}),t[2]=a.copied,t[3]=a.copy,t[4]=a.hide,t[5]=a.show,t[6]=R):R=t[6];let ee=R,[V,te]=(0,Z.useState)(0),H=!!L.trim()&&P.enabled,U;t[7]===P?U=t[8]:(U=Te(P),t[7]=P,t[8]=U);let W=U,G,K;t[9]!==n||t[10]!==M?(G=()=>{if(!n||!M)return;let e=window.setTimeout(Tt,80);return()=>window.clearTimeout(e)},K=[n,M],t[9]=n,t[10]=M,t[11]=G,t[12]=K):(G=t[11],K=t[12]),(0,Z.useEffect)(G,K);let q=a.telegramTitle,re=a.telegramSubtitle,ae=a.telegramTitle,le=a.telegramSubtitle,ue=a.modalCancel,de;t[13]!==a.telegramSubtitle||t[14]!==a.telegramTitle||t[15]!==A?(de=A===`modal`?(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-6 pb-4 pt-6 dark:border-edge-subtle`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:a.telegramTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.telegramSubtitle})]}):void 0,t[13]=a.telegramSubtitle,t[14]=a.telegramTitle,t[15]=A,t[16]=de):de=t[16];let fe;t[17]===r?fe=t[18]:(fe=()=>r(!1),t[17]=r,t[18]=fe);let pe;t[19]!==N||t[20]!==r||t[21]!==T?(pe=async()=>{await T()&&N&&r(!1)},t[19]=N,t[20]=r,t[21]=T,t[22]=pe):pe=t[22];let me;t[23]!==a||t[24]!==w||t[25]!==E||t[26]!==C||t[27]!==fe||t[28]!==pe?(me=(0,$.jsx)(ht,{ch:a,dirty:w,saving:C,onCancel:fe,onDiscard:E,onSave:pe}),t[23]=a,t[24]=w,t[25]=E,t[26]=C,t[27]=fe,t[28]=pe,t[29]=me):me=t[29];let he;t[30]===u?he=t[31]:(he=e=>u({enabled:e.target.checked}),t[30]=u,t[31]=he);let ge;t[32]!==he||t[33]!==P.enabled?(ge=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:P.enabled,onChange:he}),t[32]=he,t[33]=P.enabled,t[34]=ge):ge=t[34];let _e;t[35]===a.enableTelegramAria?_e=t[36]:(_e=(0,$.jsx)(`span`,{children:a.enableTelegramAria}),t[35]=a.enableTelegramAria,t[36]=_e);let ve;t[37]!==ge||t[38]!==_e?(ve=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ge,_e]}),t[37]=ge,t[38]=_e,t[39]=ve):ve=t[39];let ye;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[40]=ye):ye=t[40];let be;t[41]===a.telegramToken?be=t[42]:(be=(0,$.jsxs)(Y,{children:[a.telegramToken,ye]}),t[41]=a.telegramToken,t[42]=be);let xe;t[43]!==P.accounts||t[44]!==u?(xe=e=>{let t=P.accounts?.default??Se(`default`);u({accounts:{...P.accounts,default:{...t,accountId:`default`,botToken:e}}})},t[43]=P.accounts,t[44]=u,t[45]=xe):xe=t[45];let X;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(X=z(J(),`text-xs`),t[46]=X):X=t[46];let Ce;t[47]!==ee||t[48]!==xe||t[49]!==I||t[50]!==L?(Ce=(0,$.jsx)(B,{value:L,onChange:xe,placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`,labels:ee,baselineValue:I,inputClassName:X}),t[47]=ee,t[48]=xe,t[49]=I,t[50]=L,t[51]=Ce):Ce=t[51];let we;t[52]===a.telegramTokenDesc?we=t[53]:(we=(0,$.jsx)(ce,{children:a.telegramTokenDesc}),t[52]=a.telegramTokenDesc,t[53]=we);let Ee;t[54]!==be||t[55]!==Ce||t[56]!==we?(Ee=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[be,Ce,we]}),t[54]=be,t[55]=Ce,t[56]=we,t[57]=Ee):Ee=t[57];let De;t[58]===P?De=t[59]:(De=Xe(`telegram`,P),t[58]=P,t[59]=De);let Oe=V>0,ke;t[60]!==a||t[61]!==De||t[62]!==Oe||t[63]!==H?(ke=(0,$.jsx)(bt,{ch:a,usesPairing:De,tokenReady:H,pairingComplete:Oe}),t[60]=a,t[61]=De,t[62]=Oe,t[63]=H,t[64]=ke):ke=t[64];let Ae;t[65]===u?Ae=t[66]:(Ae=e=>u({dmPolicy:e}),t[65]=u,t[66]=Ae);let je;t[67]!==a.dmPolicy||t[68]!==g||t[69]!==Ae||t[70]!==P.dmPolicy?(je=(0,$.jsx)(se,{label:a.dmPolicy,value:P.dmPolicy,onChange:Ae,options:g}),t[67]=a.dmPolicy,t[68]=g,t[69]=Ae,t[70]=P.dmPolicy,t[71]=je):je=t[71];let Me;t[72]!==a||t[73]!==D||t[74]!==n||t[75]!==te||t[76]!==P||t[77]!==W?(Me=(0,$.jsx)(lt,{channel:`telegram`,accountIds:W,channelConfig:P,active:n,ch:a,language:D,onPairedChange:te}),t[72]=a,t[73]=D,t[74]=n,t[75]=te,t[76]=P,t[77]=W,t[78]=Me):Me=t[78];let Ne;t[79]===a.allowFromDm?Ne=t[80]:(Ne=(0,$.jsx)(Y,{children:a.allowFromDm}),t[79]=a.allowFromDm,t[80]=Ne);let Pe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=z(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[81]=Pe):Pe=t[81];let Fe;t[82]===P.allowFrom?Fe=t[83]:(Fe=ie(P.allowFrom),t[82]=P.allowFrom,t[83]=Fe);let Ie;t[84]===u?Ie=t[85]:(Ie=e=>u({allowFrom:oe(e.target.value)}),t[84]=u,t[85]=Ie);let Le;t[86]!==Fe||t[87]!==Ie?(Le=(0,$.jsx)(`textarea`,{className:Pe,rows:2,placeholder:`123456789, 987654321`,value:Fe,onChange:Ie}),t[86]=Fe,t[87]=Ie,t[88]=Le):Le=t[88];let Re;t[89]===a.allowFromDmDesc?Re=t[90]:(Re=(0,$.jsx)(ce,{children:a.allowFromDmDesc}),t[89]=a.allowFromDmDesc,t[90]=Re);let Be;t[91]!==Ne||t[92]!==Le||t[93]!==Re?(Be=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ne,Le,Re]}),t[91]=Ne,t[92]=Le,t[93]=Re,t[94]=Be):Be=t[94];let Ve;t[95]===P?Ve=t[96]:(Ve=Te(P),t[95]=P,t[96]=Ve);let He;t[97]===x?.items?He=t[98]:(He=x?.items??[],t[97]=x?.items,t[98]=He);let We;t[99]===d?We=t[100]:(We=(e,t)=>d(`telegram`,e,t),t[99]=d,t[100]=We);let Ge;t[101]!==a||t[102]!==o.channelAgentRoutes.telegram||t[103]!==o.defaultAgentId||t[104]!==C||t[105]!==Ve||t[106]!==He||t[107]!==We?(Ge=(0,$.jsx)(Ue,{accountIds:Ve,routes:o.channelAgentRoutes.telegram,defaultAgentId:o.defaultAgentId,agentItems:He,disabled:C,onChange:We,ch:a}),t[101]=a,t[102]=o.channelAgentRoutes.telegram,t[103]=o.defaultAgentId,t[104]=C,t[105]=Ve,t[106]=He,t[107]=We,t[108]=Ge):Ge=t[108];let Ke;t[109]===l?Ke=t[110]:(Ke=()=>l(wt),t[109]=l,t[110]=Ke);let qe=c&&`rotate-180`,Je;t[111]===qe?Je=t[112]:(Je=z(`mr-1 size-4 transition-transform`,qe),t[111]=qe,t[112]=Je);let Ye;t[113]===Je?Ye=t[114]:(Ye=(0,$.jsx)(S,{className:Je}),t[113]=Je,t[114]=Ye);let Ze=c?a.advancedHide:a.advancedShow,Qe;t[115]!==Ke||t[116]!==Ye||t[117]!==Ze?(Qe=(0,$.jsxs)(j,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:Ke,children:[Ye,Ze]}),t[115]=Ke,t[116]=Ye,t[117]=Ze,t[118]=Qe):Qe=t[118];let $e;t[119]!==a||t[120]!==_||t[121]!==h||t[122]!==y||t[123]!==p||t[124]!==b||t[125]!==P||t[126]!==f||t[127]!==m||t[128]!==c||t[129]!==u?($e=c?(0,$.jsx)(St,{tg:P,updateTelegram:u,ch:a,groupOpts:_,replyOpts:y,streamOpts:b,tgAccountsDraft:f,setTgAccountsDraft:p,tgAccountsError:m,onTgAccountsBlur:h}):null,t[119]=a,t[120]=_,t[121]=h,t[122]=y,t[123]=p,t[124]=b,t[125]=P,t[126]=f,t[127]=m,t[128]=c,t[129]=u,t[130]=$e):$e=t[130];let et;t[131]!==Ee||t[132]!==ke||t[133]!==je||t[134]!==Me||t[135]!==Be||t[136]!==Ge||t[137]!==Qe||t[138]!==$e?(et=(0,$.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[Ee,ke,je,Me,Be,Ge,Qe,$e]}),t[131]=Ee,t[132]=ke,t[133]=je,t[134]=Me,t[135]=Be,t[136]=Ge,t[137]=Qe,t[138]=$e,t[139]=et):et=t[139];let tt;return t[140]!==a.modalCancel||t[141]!==a.telegramSubtitle||t[142]!==a.telegramTitle||t[143]!==r||t[144]!==n||t[145]!==A||t[146]!==de||t[147]!==me||t[148]!==ve||t[149]!==et?(tt=(0,$.jsxs)(ze,{presentation:A,open:n,onOpenChange:r,title:q,description:re,srTitle:ae,srDescription:le,closeAriaLabel:ue,wide:!0,headerExtra:de,footer:me,children:[ve,et]}),t[140]=a.modalCancel,t[141]=a.telegramSubtitle,t[142]=a.telegramTitle,t[143]=r,t[144]=n,t[145]=A,t[146]=de,t[147]=me,t[148]=ve,t[149]=et,t[150]=tt):tt=t[150],tt}function wt(e){return!e}function Tt(){return it(`telegram`)}var Et=[{id:`telegram`,titleKey:`telegramTitle`,subtitleKey:`telegramSubtitle`},{id:`weixin`,titleKey:`weixinTitle`,subtitleKey:`weixinSubtitle`},{id:`feishu`,titleKey:`feishuTitle`,subtitleKey:`feishuSubtitle`}];function Dt(){return o(`/api/channels/meta`)}async function Ot(){return(await u(Dt())).payload?.channels??[]}var kt=new Map(Et.map(e=>[e.id,e])),At=new Map(Et.map((e,t)=>[e.id,t]));function jt(e,t){return{title:t[e.titleKey],subtitle:t[e.subtitleKey]}}function Mt(e,t){let n=new Map;for(let r of e??[]){let e=kt.get(r.id),i=e?jt(e,t):{title:r.label,subtitle:r.description||t.hubExtensionSubtitle};n.set(r.id,{id:r.id,title:i.title,subtitle:i.subtitle,manageable:r.manageable,order:r.order})}if(n.size===0)return Et.map((e,n)=>{let r=jt(e,t);return{id:e.id,title:r.title,subtitle:r.subtitle,manageable:!0,order:n}});for(let e of Et){if(n.has(e.id))continue;let r=jt(e,t);n.set(e.id,{id:e.id,title:r.title,subtitle:r.subtitle,manageable:!0,order:At.get(e.id)??0})}return Array.from(n.values()).sort((e,t)=>e.order===t.order?e.id.localeCompare(t.id):e.order-t.order)}function Nt(e,t){let n=(0,Q.c)(11),r;n[0]===e?r=n[1]:(r=e?Dt():null,n[0]=e,n[1]=r);let i;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},n[2]=i):i=n[2];let{data:a,error:o,isLoading:c,mutate:l}=s(r,Ot,i),u;n[3]!==t||n[4]!==a?(u=Mt(a,t),n[3]=t,n[4]=a,n[5]=u):u=n[5];let d=u,f;return n[6]!==d||n[7]!==o||n[8]!==c||n[9]!==l?(f={entries:d,isLoading:c,error:o,mutate:l},n[6]=d,n[7]=o,n[8]=c,n[9]=l,n[10]=f):f=n[10],f}function Pt(e,t){return e.find(e=>e.name===t)?.connected??!1}function Ft(e,t){return e.find(e=>e.name===t)?.enabled??!1}function It(e,t){let n=e&&typeof e==`object`?e.channels:void 0,r=n&&typeof n==`object`&&!Array.isArray(n)?n[t]:void 0;return!r||typeof r!=`object`?!1:Object.keys(r).length>0}function Lt(e,t,n){return e?t?n?`running`:`offline`:`disabled`:`not_configured`}function Rt(e,t,n){return n?e===`not_configured`?`setup`:t>0?`pairing`:e===`offline`?`fix`:`manage`:`manage`}function zt(e,t){return e.policy.dm[t]}function Bt(e,t){return e.hubSummaryAccountCount.replace(`{{count}}`,String(t))}function Vt(e,t){let n=t.telegram,r=[e.hubSummaryDm.replace(`{{policy}}`,zt(e,n.dmPolicy))],i=Te(n).length;return i>0&&r.push(Bt(e,i)),r}function Ht(e,t){let n=t.weixin,r=[e.hubSummaryDm.replace(`{{policy}}`,zt(e,n.dmPolicy))];r.push(e.hubSummaryStream.replace(`{{mode}}`,e.policy.stream[n.streamMode]));let i=Ee(n).length;return i>0&&r.push(Bt(e,i)),r}function Ut(e,t){let n=t.feishu,r=n.connectionMode===`webhook`?e.hubConnectionWebhook:e.hubConnectionWebsocket,i=[e.hubSummaryConnection.replace(`{{mode}}`,r)],a=le(n).length;return a>0&&i.push(Bt(e,a)),i}function Wt(e,t){return t[e]}function Gt(e){let{id:t,form:n,connected:r,pairingSummary:i,ch:a}=e,o=n.telegram,s=n.weixin,c=n.feishu,l=t===`telegram`?re(o):t===`weixin`?q(s):ae(c),u=t===`telegram`?o.enabled:t===`weixin`?s.enabled:c.enabled,d=Ze({configured:l,channelEnabled:u,usesPairing:Xe(t,t===`telegram`?o:t===`weixin`?s:c),summaryPending:Wt(t,i).pending}),f=Lt(l,u,r);return{id:t,manageable:!0,configured:l,enabled:u,connected:r,status:f,summaryLines:l?t===`telegram`?Vt(a,n):t===`weixin`?Ht(a,n):Ut(a,n):[],pendingPairing:d,primaryAction:Rt(f,d,!0)}}function Kt(e){let{id:t,config:n,statuses:r,ch:i}=e,a=It(n,t),o=Ft(r,t),s=Pt(r,t);return{id:t,manageable:!1,configured:a,enabled:o,connected:s,status:Lt(a,o,s),summaryLines:a?[i.hubExtensionConfiguredHint]:[],pendingPairing:0,primaryAction:`manage`}}function qt(e){return te(e.id)?Gt({id:e.id,form:e.form,connected:Pt(e.statuses,e.id),pairingSummary:e.pairingSummary,ch:e.ch}):Kt({id:e.id,config:e.config,statuses:e.statuses,ch:e.ch})}function Jt(e){return e.catalogIds.map(t=>qt({id:t,form:e.form,config:e.config,statuses:e.statuses,pairingSummary:e.pairingSummary,ch:e.ch}))}var Yt=`channels-status`;function Xt(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Zt(e){let t=t=>e(t.detail);return window.addEventListener(Yt,t),()=>window.removeEventListener(Yt,t)}function Qt(e,t){let n=(0,Q.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Zt(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,Z.useEffect)(i,a)}var $t={telegram:{pending:0,stale:0,atCapacity:!1},feishu:{pending:0,stale:0,atCapacity:!1},weixin:{pending:0,stale:0,atCapacity:!1}};function en(e){let t=(0,Q.c)(8),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={revalidateOnFocus:!0},t[0]=n):n=t[0];let{data:r,mutate:i,isLoading:a,error:o}=s(e?et:null,_e,n),c;t[1]===i?c=t[2]:(c=()=>{i()},t[1]=i,t[2]=c);let l=c;nt(l,e);let u=r??$t,d;return t[3]!==o||t[4]!==a||t[5]!==l||t[6]!==u?(d={summary:u,isLoading:a,error:o,refresh:l},t[3]=o,t[4]=a,t[5]=l,t[6]=u,t[7]=d):d=t[7],d}var tn=3e4;function nn(e){let t=(0,Q.c)(25),{hasToken:n,form:r,ch:i}=e,{data:a,mutate:o}=ee(n),{entries:c,mutate:l}=Nt(n,i),u;t[0]===n?u=t[1]:(u=n?Ce():null,t[0]=n,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!0,refreshInterval:tn},t[2]=d):d=t[2];let{data:f,mutate:p}=s(u,ye,d),m;t[3]===f?m=t[4]:(m=f===void 0?[]:f,t[3]=f,t[4]=m);let h=m,g;t[5]===p?g=t[6]:(g=e=>{let t=Xt(e);if(t){p(t,{revalidate:!1});return}p()},t[5]=p,t[6]=g),Qt(g,n);let{summary:_,refresh:v}=en(n),y;t[7]===c?y=t[8]:(y=c.map(rn),t[7]=c,t[8]=y);let b=y,x=a?.payload?.config,S;bb0:{if(!r||b.length===0){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[9]=e):e=t[9],S=e;break bb0}let e;t[10]!==b||t[11]!==i||t[12]!==x||t[13]!==r||t[14]!==_||t[15]!==h?(e=Jt({catalogIds:b,form:r,config:x,statuses:h,pairingSummary:_,ch:i}),t[10]=b,t[11]=i,t[12]=x,t[13]=r,t[14]=_,t[15]=h,t[16]=e):e=t[16],S=e}let C=S,w;t[17]!==l||t[18]!==o||t[19]!==p||t[20]!==v?(w=()=>{p(),l(),o(),v()},t[17]=l,t[18]=o,t[19]=p,t[20]=v,t[21]=w):w=t[21];let T=w,E;return t[22]!==C||t[23]!==T?(E={cards:C,refreshAll:T},t[22]=C,t[23]=T,t[24]=E):E=t[24],E}function rn(e){return e.id}var an={form:null,baseline:null,tgAccountsDraft:``,tgAccountsError:``,wxAccountsDraft:``,wxAccountsError:``,feishuAccountsDraft:``,feishuAccountsError:``};function on(e){return{tgAccountsDraft:JSON.stringify(e.telegram.accounts??{},null,2),tgAccountsError:``,wxAccountsDraft:JSON.stringify(e.weixin.accounts??{},null,2),wxAccountsError:``,feishuAccountsDraft:JSON.stringify(e.feishu?.accounts??{},null,2),feishuAccountsError:``}}function sn(e,t){switch(t.type){case`reset`:return an;case`load`:{let e=structuredClone(t.payload);return{form:e,baseline:structuredClone(e),...on(e)}}case`commitSaved`:{let e=structuredClone(t.payload);return{form:e,baseline:structuredClone(e),...on(e)}}case`discard`:{if(!e.baseline)return e;let t=structuredClone(e.baseline);return{form:t,baseline:e.baseline,...on(t)}}case`updateTelegram`:return e.form?{...e,form:{...e.form,telegram:{...e.form.telegram,...t.patch}}}:e;case`updateWeixin`:return e.form?{...e,form:{...e.form,weixin:{...e.form.weixin,...t.patch}}}:e;case`updateFeishu`:return e.form?{...e,form:{...e.form,feishu:{...e.form.feishu,...t.patch}}}:e;case`updateChannelAgentRoute`:{if(!e.form)return e;let n=t.channel===`telegram`?`telegram`:t.channel===`weixin`?`weixin`:`feishu`;return{...e,form:{...e.form,channelAgentRoutes:{...e.form.channelAgentRoutes,[n]:{...e.form.channelAgentRoutes[n],[t.accountId]:t.agentId.trim().toLowerCase()}}}}}case`setTgAccountsDraft`:return{...e,tgAccountsDraft:t.value};case`setWxAccountsDraft`:return{...e,wxAccountsDraft:t.value};case`setFeishuAccountsDraft`:return{...e,feishuAccountsDraft:t.value};case`setTgAccountsError`:return{...e,tgAccountsError:t.value};case`setWxAccountsError`:return{...e,wxAccountsError:t.value};case`setFeishuAccountsError`:return{...e,feishuAccountsError:t.value};case`applyTgAccounts`:return e.form?{...e,form:{...e.form,telegram:{...e.form.telegram,accounts:t.accounts}},tgAccountsError:``}:e;case`applyWxAccounts`:return e.form?{...e,form:{...e.form,weixin:{...e.form.weixin,accounts:t.accounts}},wxAccountsError:``}:e;case`applyFeishuAccounts`:return e.form?{...e,form:{...e.form,feishu:{...e.form.feishu,accounts:t.accounts}},feishuAccountsError:``}:e;case`restoreForm`:return{...e,form:structuredClone(t.payload)}}}function cn(){let e=i(e=>e.language),t=a(e),n=t.channelsSettings,r=!!l(e=>e.token),o=(0,Z.useRef)(!1),[c,u]=(0,Z.useReducer)(sn,an),[d,f]=(0,Z.useState)({hasToken:r,parsed:null}),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(!1),[I,R]=(0,Z.useState)(!1),{data:z}=s(r?`gateway-chat-agents-ch`:null,L,{revalidateOnFocus:!1}),{data:B,error:V,isLoading:te,mutate:H}=ee(r),U=(0,Z.useMemo)(()=>B?.payload?.config===void 0?null:ve(B.payload.config),[B]);(r!==d.hasToken||U!==d.parsed)&&(f({hasToken:r,parsed:U}),r?U!==null&&!o.current&&(u({type:`load`,payload:U}),v(!1)):(o.current=!1,u({type:`reset`}),v(!1)));let{form:W,baseline:G,tgAccountsDraft:K,tgAccountsError:q,wxAccountsDraft:re,wxAccountsError:ie,feishuAccountsDraft:ae,feishuAccountsError:oe}=c,J=(0,Z.useMemo)(()=>!W||!G?!1:JSON.stringify(W)!==JSON.stringify(G),[W,G]),Y=!!(r&&te&&B===void 0&&!V),se=V instanceof Error?V.message:V?String(V):null,ce=(0,Z.useCallback)((e,t,n)=>{o.current=!0,u({type:`updateChannelAgentRoute`,channel:e,accountId:t,agentId:n})},[]),le=(0,Z.useCallback)(e=>{o.current=!0,u({type:`updateTelegram`,patch:e})},[]),ue=(0,Z.useCallback)(e=>{o.current=!0,u({type:`updateWeixin`,patch:e})},[]),de=(0,Z.useCallback)(e=>{o.current=!0,u({type:`updateFeishu`,patch:e})},[]),fe=(0,Z.useCallback)(async()=>{if(!W||p)return!1;m(!0),g(null),v(!1);try{let e=await he(W);return o.current=!1,u({type:`commitSaved`,payload:e}),v(!0),window.setTimeout(()=>v(!1),2500),!0}catch(e){return g(e instanceof Error?e.message:n.saveError),!1}finally{m(!1)}},[W,p,n.saveError]),pe=(0,Z.useCallback)(()=>{G&&(o.current=!1,u({type:`discard`}),g(null),v(!1))},[G]),me=(0,Z.useCallback)(async(e,t)=>{if(!W||p)return;let r=W,i=e===`weixin`?{...W,weixin:{...W.weixin,enabled:t}}:e===`telegram`?{...W,telegram:{...W.telegram,enabled:t}}:{...W,feishu:{...W.feishu,enabled:t}};o.current=!0,u(e===`weixin`?{type:`updateWeixin`,patch:{enabled:t}}:e===`telegram`?{type:`updateTelegram`,patch:{enabled:t}}:{type:`updateFeishu`,patch:{enabled:t}}),m(!0),g(null);try{let e=await he(i);o.current=!1,u({type:`commitSaved`,payload:e})}catch(e){g(e instanceof Error?e.message:n.saveError),o.current=!0,u({type:`restoreForm`,payload:r})}finally{m(!1)}},[W,p,n.saveError]),ge=(0,Z.useCallback)(async()=>{let e=W?ne(W.telegram):``;e&&await b(e)&&(N(!0),window.setTimeout(()=>N(!1),2e3))},[W]),_e=(0,Z.useCallback)(e=>{de({appId:e.appId,domain:e.domain,enabled:!0}),H(),C(n.feishuQrSetupSuccess),window.setTimeout(()=>C(null),4e3)},[de,H,n.feishuQrSetupSuccess]),ye=(0,Z.useCallback)(async()=>{let e=W?.feishu?.appSecret;e&&await b(e)&&(F(!0),window.setTimeout(()=>F(!1),2e3))},[W]),be=(0,Z.useCallback)(async()=>{let e=W?.feishu;if(!e)return;let t={connectionMode:e.connectionMode,verificationToken:e.verificationToken||``,encryptKey:e.encryptKey||``,webhookHost:e.webhookHost||``,webhookPort:e.webhookPort||0,webhookPath:e.webhookPath||``};await b(JSON.stringify(t,null,2))&&(R(!0),window.setTimeout(()=>R(!1),2e3))},[W]);return{language:e,m:t,ch:n,hasToken:r,loading:Y,fetchError:se,mutate:H,form:W,baseline:G,dirty:J,saving:p,error:h,saveOk:_,weixinSuccessBanner:y,setWeixinSuccessBanner:x,feishuSetupSuccessBanner:S,tgAdvanced:w,setTgAdvanced:T,showToken:E,setShowToken:D,showFeishuSecret:O,setShowFeishuSecret:k,showFeishuWebhookSecrets:A,setShowFeishuWebhookSecrets:j,copied:M,feishuCopied:P,feishuWebhookCopied:I,tgAccountsDraft:K,setTgAccountsDraft:(0,Z.useCallback)(e=>{u({type:`setTgAccountsDraft`,value:e})},[]),tgAccountsError:q,wxAccountsDraft:re,setWxAccountsDraft:(0,Z.useCallback)(e=>{u({type:`setWxAccountsDraft`,value:e})},[]),wxAccountsError:ie,feishuAccountsDraft:ae,setFeishuAccountsDraft:(0,Z.useCallback)(e=>{u({type:`setFeishuAccountsDraft`,value:e})},[]),feishuAccountsError:oe,chatAgents:z,updateChannelAgentRoute:ce,updateTelegram:le,updateWeixin:ue,updateFeishu:de,save:fe,discard:pe,toggleChannelEnabled:me,copyToken:ge,handleFeishuQrSetupSuccess:_e,copyFeishuSecret:ye,copyFeishuWebhookConfig:be,onTgAccountsBlur:(0,Z.useCallback)(()=>{if(!W)return;let e=K.trim();if(!e){o.current=!0,u({type:`applyTgAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,u({type:`applyTgAccounts`,accounts:t})}catch(e){u({type:`setTgAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[W,K,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,Z.useCallback)(()=>{if(!W)return;let e=re.trim();if(!e){o.current=!0,u({type:`applyWxAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,u({type:`applyWxAccounts`,accounts:t})}catch(e){u({type:`setWxAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[W,re,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,Z.useCallback)(()=>{if(!W)return;let e=ae.trim();if(!e){o.current=!0,u({type:`applyFeishuAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,u({type:`applyFeishuAccounts`,accounts:t})}catch(e){u({type:`setFeishuAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[W,ae,n.jsonObjectAccounts,n.jsonInvalid]),dmOpts:(0,Z.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:n.policy.dm[e]})),[n.policy.dm]),groupOpts:(0,Z.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:n.policy.group[e]})),[n.policy.group]),replyOpts:(0,Z.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:n.policy.reply[e]})),[n.policy.reply]),streamOpts:(0,Z.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:n.policy.stream[e]})),[n.policy.stream])}}var ln={width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}},un={sessionKey:null,qrcodeUrl:null};function dn({ch:e,onLoginSuccess:t,onOpenChange:n,closeOnLoginSuccess:r,moreSettings:i}){let[a,o]=(0,Z.useState)(0),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(t),f=(0,Z.useRef)(n);d.current=t,f.current=n;let p=H(()=>pe().then(e=>({sessionKey:e.sessionKey,qrcodeUrl:e.qrcodeUrl})),[a],{initial:un,errorData:un}),m=p.data.sessionKey,h=p.data.qrcodeUrl,g=p.loading,_=p.error instanceof Error?p.error.message:p.error?String(p.error):null,v=l??_,y=(0,Z.useCallback)(()=>{u(null),c(null),o(e=>e+1)},[]);(0,Z.useEffect)(()=>{if(!m)return;let t=!1,n,i=async()=>{try{let i=await xe(m);if(t)return;if(i.phase===`polling`){p.setData(e=>({...e,qrcodeUrl:i.qrcodeUrl})),c(i.qrStatus===`scaned`?e.weixinQrLoginScanned:null);return}if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),p.setData(un),i.ok?(r&&f.current(!1),await d.current()):u(i.message);return}i.phase===`unknown`&&c(null)}catch(e){t||(n!==void 0&&window.clearInterval(n),u(e instanceof Error?e.message:`Request failed`),p.setData(un))}};return n=window.setInterval(()=>void i(),2e3),i(),()=>{t=!0,n!==void 0&&window.clearInterval(n)}},[m,e.weixinQrLoginScanned,r,p.setData]);let b=H(()=>mt.toDataURL(h,ln),[h],{enabled:!!h,initial:null,errorData:null}),x=b.data,S=b.error!==null&&!b.loading,C=!!(h&&m),w=!v&&!C;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`text-base font-semibold tracking-tight text-fg`,children:e.weixinQrModalTitle}),(0,$.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:e.weixinQrModalSubtitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[v?(0,$.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:v}):null,!v&&(C||w)?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:z(`min-h-[1.25rem] text-center text-sm`,s&&!w?`text-accent`:`text-fg-muted`),children:w?e.weixinQrLoginBusy:s??`\xA0`}),(0,$.jsxs)(`div`,{className:z(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,w&&`bg-surface-muted/40 dark:bg-surface-base`),children:[w?(0,$.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,C&&h&&!v&&x&&!S?(0,$.jsx)(`img`,{src:x,alt:``,className:`relative z-[1] size-full object-contain`}):null,C&&h&&!v&&!x&&!S&&!w?(0,$.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:e.weixinQrEncoding}):null,C&&h&&!v&&S?(0,$.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,$.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:e.weixinQrImageError}),(0,$.jsxs)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,$.jsx)(F,{className:`size-3 shrink-0`}),e.weixinQrOpenLink]})]}):null]})]}):null]}),(0,$.jsx)(`div`,{className:`mt-6`,children:(0,$.jsx)(j,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:g,onClick:y,children:g?e.weixinQrLoginBusy:e.weixinQrRegenerate})}),i?(0,$.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})}function fn(e){let t=(0,Q.c)(26),{open:n,onOpenChange:r,ch:i,onLoginSuccess:a,moreSettings:o,settingsDirty:s,settingsSaving:c,onSettingsDiscard:l,onSettingsSave:u,presentation:d,closeOnLoginSuccess:f}=e,p=s===void 0?!1:s,m=c===void 0?!1:c,h=d===void 0?`modal`:d,g=f===void 0?!0:f,_;t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==l||t[4]!==u||t[5]!==p||t[6]!==m?(_=o&&l&&u?(0,$.jsx)(ht,{ch:i,dirty:p,saving:m,showCancel:!1,onCancel:()=>r(!1),onDiscard:l,onSave:u}):void 0,t[0]=i,t[1]=o,t[2]=r,t[3]=l,t[4]=u,t[5]=p,t[6]=m,t[7]=_):_=t[7];let v;t[8]!==i||t[9]!==g||t[10]!==o||t[11]!==a||t[12]!==r||t[13]!==n?(v=n?(0,$.jsx)(dn,{ch:i,onLoginSuccess:a,onOpenChange:r,closeOnLoginSuccess:g,moreSettings:o},`active`):null,t[8]=i,t[9]=g,t[10]=o,t[11]=a,t[12]=r,t[13]=n,t[14]=v):v=t[14];let y;return t[15]!==i.weixinQrModalCloseAria||t[16]!==i.weixinQrModalSubtitle||t[17]!==i.weixinQrModalTitle||t[18]!==i.weixinSubtitle||t[19]!==i.weixinTitle||t[20]!==r||t[21]!==n||t[22]!==h||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(ze,{presentation:h,open:n,onOpenChange:r,title:i.weixinTitle,description:i.weixinSubtitle,srTitle:i.weixinQrModalTitle,srDescription:i.weixinQrModalSubtitle,closeAriaLabel:i.weixinQrModalCloseAria,wide:!0,footer:_,children:v}),t[15]=i.weixinQrModalCloseAria,t[16]=i.weixinQrModalSubtitle,t[17]=i.weixinQrModalTitle,t[18]=i.weixinSubtitle,t[19]=i.weixinTitle,t[20]=r,t[21]=n,t[22]=h,t[23]=_,t[24]=v,t[25]=y):y=t[25],y}function pn(e){let t=(0,Q.c)(108),{wx:n,updateWeixin:r,ch:i,streamOpts:a,wxAccountsDraft:o,setWxAccountsDraft:s,wxAccountsError:c,onWxAccountsBlur:l,channelAgentRoutesWx:u,defaultAgentId:d,agentItems:f,onAgentRouteChange:p,routingDisabled:m}=e,h;t[0]===i.weixinAllowFrom?h=t[1]:(h=(0,$.jsx)(Y,{children:i.weixinAllowFrom}),t[0]=i.weixinAllowFrom,t[1]=h);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=z(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[2]=g):g=t[2];let _;t[3]===n.allowFrom?_=t[4]:(_=n.allowFrom.join(`, `),t[3]=n.allowFrom,t[4]=_);let v;t[5]===r?v=t[6]:(v=e=>r({allowFrom:e.target.value.split(/[,\n]/).flatMap(mn)}),t[5]=r,t[6]=v);let y;t[7]!==_||t[8]!==v?(y=(0,$.jsx)(`textarea`,{className:g,rows:2,placeholder:`wxid_..., openid_...`,value:_,onChange:v}),t[7]=_,t[8]=v,t[9]=y):y=t[9];let b;t[10]===i.weixinAllowFromDesc?b=t[11]:(b=(0,$.jsx)(ce,{children:i.weixinAllowFromDesc}),t[10]=i.weixinAllowFromDesc,t[11]=b);let x;t[12]!==h||t[13]!==y||t[14]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,y,b]}),t[12]=h,t[13]=y,t[14]=b,t[15]=x):x=t[15];let S;t[16]===r?S=t[17]:(S=e=>r({streamMode:e}),t[16]=r,t[17]=S);let C;t[18]!==i.streamMode||t[19]!==a||t[20]!==S||t[21]!==n.streamMode?(C=(0,$.jsx)(se,{label:i.streamMode,value:n.streamMode,onChange:S,options:a}),t[18]=i.streamMode,t[19]=a,t[20]=S,t[21]=n.streamMode,t[22]=C):C=t[22];let w;t[23]===i.historyLimit?w=t[24]:(w=(0,$.jsx)(Y,{children:i.historyLimit}),t[23]=i.historyLimit,t[24]=w);let T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=J(),t[25]=T):T=t[25];let E;t[26]===r?E=t[27]:(E=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[26]=r,t[27]=E);let D;t[28]!==E||t[29]!==n.historyLimit?(D=(0,$.jsx)(`input`,{type:`number`,min:10,max:200,className:T,value:n.historyLimit,onChange:E}),t[28]=E,t[29]=n.historyLimit,t[30]=D):D=t[30];let O;t[31]!==w||t[32]!==D?(O=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[w,D]}),t[31]=w,t[32]=D,t[33]=O):O=t[33];let k;t[34]===i.textChunkLimit?k=t[35]:(k=(0,$.jsx)(Y,{children:i.textChunkLimit}),t[34]=i.textChunkLimit,t[35]=k);let A;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(A=J(),t[36]=A):A=t[36];let j;t[37]===r?j=t[38]:(j=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[37]=r,t[38]=j);let M;t[39]!==j||t[40]!==n.textChunkLimit?(M=(0,$.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:A,value:n.textChunkLimit,onChange:j}),t[39]=j,t[40]=n.textChunkLimit,t[41]=M):M=t[41];let N;t[42]!==k||t[43]!==M?(N=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[k,M]}),t[42]=k,t[43]=M,t[44]=N):N=t[44];let P;t[45]!==O||t[46]!==N?(P=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[O,N]}),t[45]=O,t[46]=N,t[47]=P):P=t[47];let F;t[48]===i.weixinRouteTag?F=t[49]:(F=(0,$.jsx)(Y,{children:i.weixinRouteTag}),t[48]=i.weixinRouteTag,t[49]=F);let I;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(I=J(),t[50]=I):I=t[50];let L;t[51]===r?L=t[52]:(L=e=>r({routeTag:e.target.value}),t[51]=r,t[52]=L);let R;t[53]!==i.routeTagPlaceholder||t[54]!==L||t[55]!==n.routeTag?(R=(0,$.jsx)(`input`,{className:I,value:n.routeTag,onChange:L,placeholder:i.routeTagPlaceholder}),t[53]=i.routeTagPlaceholder,t[54]=L,t[55]=n.routeTag,t[56]=R):R=t[56];let B;t[57]===i.weixinRouteTagDesc?B=t[58]:(B=(0,$.jsx)(ce,{children:i.weixinRouteTagDesc}),t[57]=i.weixinRouteTagDesc,t[58]=B);let ee;t[59]!==F||t[60]!==R||t[61]!==B?(ee=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[F,R,B]}),t[59]=F,t[60]=R,t[61]=B,t[62]=ee):ee=t[62];let V;t[63]===r?V=t[64]:(V=e=>r({debug:e.target.checked}),t[63]=r,t[64]=V);let te;t[65]!==V||t[66]!==n.debug?(te=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:V}),t[65]=V,t[66]=n.debug,t[67]=te):te=t[67];let H;t[68]!==i.weixinDebug||t[69]!==te?(H=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[te,i.weixinDebug]}),t[68]=i.weixinDebug,t[69]=te,t[70]=H):H=t[70];let U;t[71]===i.weixinDebugDesc?U=t[72]:(U=(0,$.jsx)(ce,{children:i.weixinDebugDesc}),t[71]=i.weixinDebugDesc,t[72]=U);let W;t[73]===i.weixinAccountsJson?W=t[74]:(W=(0,$.jsx)(Y,{children:i.weixinAccountsJson}),t[73]=i.weixinAccountsJson,t[74]=W);let G;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(G=z(J(),`min-h-[140px] resize-y font-mono text-xs`),t[75]=G):G=t[75];let K;t[76]===s?K=t[77]:(K=e=>s(e.target.value),t[76]=s,t[77]=K);let q;t[78]!==l||t[79]!==K||t[80]!==o?(q=(0,$.jsx)(`textarea`,{className:G,spellCheck:!1,value:o,onChange:K,onBlur:l,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),t[78]=l,t[79]=K,t[80]=o,t[81]=q):q=t[81];let ne;t[82]!==i.weixinAccountsJsonDesc||t[83]!==c?(ne=c?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:c}):(0,$.jsx)(ce,{children:i.weixinAccountsJsonDesc}),t[82]=i.weixinAccountsJsonDesc,t[83]=c,t[84]=ne):ne=t[84];let re;t[85]!==W||t[86]!==q||t[87]!==ne?(re=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[W,q,ne]}),t[85]=W,t[86]=q,t[87]=ne,t[88]=re):re=t[88];let ie;t[89]===n?ie=t[90]:(ie=Ee(n),t[89]=n,t[90]=ie);let ae;t[91]!==f||t[92]!==i||t[93]!==u||t[94]!==d||t[95]!==p||t[96]!==m||t[97]!==ie?(ae=(0,$.jsx)(Ue,{accountIds:ie,routes:u,defaultAgentId:d,agentItems:f,disabled:m,onChange:p,ch:i}),t[91]=f,t[92]=i,t[93]=u,t[94]=d,t[95]=p,t[96]=m,t[97]=ie,t[98]=ae):ae=t[98];let oe;return t[99]!==P||t[100]!==ee||t[101]!==H||t[102]!==U||t[103]!==re||t[104]!==ae||t[105]!==x||t[106]!==C?(oe=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[x,C,P,ee,H,U,re,ae]}),t[99]=P,t[100]=ee,t[101]=H,t[102]=U,t[103]=re,t[104]=ae,t[105]=x,t[106]=C,t[107]=oe):oe=t[107],oe}function mn(e){let t=e.trim();return t?[t]:[]}function hn(e){let t=(0,Q.c)(60),{ch:n,wx:r,updateWeixin:i,dmOpts:a,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:u,form:d,chatAgents:f,onAgentRouteChange:p,saving:m,language:h,dialogOpen:g,pairingFocus:_}=e,v=_===void 0?!1:_,y;t[0]===r?y=t[1]:(y=Ee(r),t[0]=r,t[1]=y);let b=y,x;t[2]===b?x=t[3]:(x=b.length>0?b:[`default`],t[2]=b,t[3]=x);let C=x,w=(0,Z.useRef)(null),T,E;t[4]===v?(T=t[5],E=t[6]):(T=()=>{if(!v)return;let e=w.current;e&&(e.open=!0);let t=window.setTimeout(gn,80);return()=>window.clearTimeout(t)},E=[v],t[4]=v,t[5]=T,t[6]=E),(0,Z.useEffect)(T,E);let D;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(S,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[7]=D):D=t[7];let O;t[8]===n.advancedShow?O=t[9]:(O=(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[D,n.advancedShow]})}),t[8]=n.advancedShow,t[9]=O);let k;t[10]===n.weixinAdvancedHint?k=t[11]:(k=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.weixinAdvancedHint}),t[10]=n.weixinAdvancedHint,t[11]=k);let A;t[12]===i?A=t[13]:(A=e=>i({enabled:e.target.checked}),t[12]=i,t[13]=A);let j;t[14]!==A||t[15]!==r.enabled?(j=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.enabled,onChange:A}),t[14]=A,t[15]=r.enabled,t[16]=j):j=t[16];let M;t[17]===n.enableWeixinAria?M=t[18]:(M=(0,$.jsx)(`span`,{children:n.enableWeixinAria}),t[17]=n.enableWeixinAria,t[18]=M);let N;t[19]!==j||t[20]!==M?(N=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[j,M]}),t[19]=j,t[20]=M,t[21]=N):N=t[21];let P;t[22]===i?P=t[23]:(P=e=>i({dmPolicy:e}),t[22]=i,t[23]=P);let F;t[24]!==n.dmPolicy||t[25]!==a||t[26]!==P||t[27]!==r.dmPolicy?(F=(0,$.jsx)(se,{label:n.dmPolicy,value:r.dmPolicy,onChange:P,options:a}),t[24]=n.dmPolicy,t[25]=a,t[26]=P,t[27]=r.dmPolicy,t[28]=F):F=t[28];let I;t[29]!==n||t[30]!==g||t[31]!==h||t[32]!==C||t[33]!==r?(I=(0,$.jsx)(lt,{channel:`weixin`,accountIds:C,channelConfig:r,active:g,ch:n,language:h}),t[29]=n,t[30]=g,t[31]=h,t[32]=C,t[33]=r,t[34]=I):I=t[34];let L;t[35]===f?.items?L=t[36]:(L=f?.items??[],t[35]=f?.items,t[36]=L);let R;t[37]!==n||t[38]!==d.channelAgentRoutes.weixin||t[39]!==d.defaultAgentId||t[40]!==p||t[41]!==u||t[42]!==m||t[43]!==c||t[44]!==o||t[45]!==L||t[46]!==i||t[47]!==r||t[48]!==s||t[49]!==l?(R=(0,$.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,$.jsx)(pn,{wx:r,updateWeixin:i,ch:n,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:u,channelAgentRoutesWx:d.channelAgentRoutes.weixin,defaultAgentId:d.defaultAgentId,agentItems:L,onAgentRouteChange:p,routingDisabled:m})}),t[37]=n,t[38]=d.channelAgentRoutes.weixin,t[39]=d.defaultAgentId,t[40]=p,t[41]=u,t[42]=m,t[43]=c,t[44]=o,t[45]=L,t[46]=i,t[47]=r,t[48]=s,t[49]=l,t[50]=R):R=t[50];let z;t[51]!==N||t[52]!==F||t[53]!==I||t[54]!==R||t[55]!==k?(z=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[k,N,F,I,R]}),t[51]=N,t[52]=F,t[53]=I,t[54]=R,t[55]=k,t[56]=z):z=t[56];let B;return t[57]!==z||t[58]!==O?(B=(0,$.jsxs)(`details`,{ref:w,className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[O,z]}),t[57]=z,t[58]=O,t[59]=B):B=t[59],B}function gn(){return it(`weixin`)}function _n(){let e=D(),{channelId:t}=y(),[n]=E(),{language:r,m:i,ch:a,hasToken:o,loading:s,fetchError:c,mutate:l,form:u,baseline:d,dirty:p,saving:h,error:g,saveOk:_,weixinSuccessBanner:v,setWeixinSuccessBanner:b,feishuSetupSuccessBanner:x,tgAdvanced:S,setTgAdvanced:C,showToken:w,setShowToken:T,showFeishuSecret:O,setShowFeishuSecret:k,showFeishuWebhookSecrets:A,setShowFeishuWebhookSecrets:M,copied:N,feishuCopied:I,feishuWebhookCopied:L,tgAccountsDraft:z,setTgAccountsDraft:B,tgAccountsError:ee,wxAccountsDraft:V,setWxAccountsDraft:H,wxAccountsError:U,feishuAccountsDraft:W,setFeishuAccountsDraft:G,feishuAccountsError:K,chatAgents:q,updateChannelAgentRoute:ne,updateTelegram:re,updateWeixin:ie,updateFeishu:ae,save:oe,discard:J,toggleChannelEnabled:Y,copyToken:se,handleFeishuQrSetupSuccess:ce,copyFeishuSecret:le,copyFeishuWebhookConfig:ue,onTgAccountsBlur:de,onWxAccountsBlur:fe,onFeishuAccountsBlur:pe,dmOpts:me,groupOpts:he,replyOpts:ge,streamOpts:_e}=cn(),[ve,ye]=(0,Z.useState)(!1),{entries:be}=Nt(o,a),xe=(0,Z.useMemo)(()=>new Map(be.map(e=>[e.id,e])),[be]),X=R(t),Se=n.get(`pairing`)===`1`,Ce=!!(X&&xe.has(X)),{cards:we,refreshAll:Te}=nn({hasToken:o,form:u,ch:a}),Ee=X?xe.get(X):void 0,Q=X?we.find(e=>e.id===X):void 0;(0,Z.useEffect)(()=>{!X||be.length===0||xe.has(X)||e(f,{replace:!0})},[X,xe,be.length,e]);let De=(0,Z.useCallback)((t,n)=>{e(P(t,{pairing:n?.scrollToPairing}))},[e]),Oe=(0,Z.useCallback)(()=>{e(f)},[e]),ke=(0,Z.useCallback)(e=>{e||Oe()},[Oe]),Ae=(0,Z.useCallback)(async()=>{await l(),b(a.weixinQrLoginSuccess),window.setTimeout(()=>b(null),4e3)},[a.weixinQrLoginSuccess,l,b]),je=(0,Z.useCallback)(async()=>{ye(!0);try{Te(),await l()}finally{ye(!1)}},[l,Te]);if(!o)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:_,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:i.settingsSections.channels}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.needToken})]})]});if(s)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:_,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`h-7 w-40 animate-pulse rounded-md bg-surface-hover motion-reduce:animate-none dark:bg-surface-active/50`}),(0,$.jsx)(`div`,{className:`h-4 w-full max-w-md animate-pulse rounded-md bg-surface-hover motion-reduce:animate-none dark:bg-surface-active/50`})]}),(0,$.jsx)(Ie,{}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.loading})]})]});if(!u)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:_,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g??c??a.loadError}),(0,$.jsx)(j,{type:`button`,variant:`secondary`,onClick:()=>void l(),children:a.retry})]})]});let Ne=u.weixin,Pe=Se&&X===`weixin`,Fe=Se&&X===`feishu`,Le=(0,$.jsx)(hn,{ch:a,wx:Ne,updateWeixin:ie,dmOpts:me,streamOpts:_e,wxAccountsDraft:V,setWxAccountsDraft:H,wxAccountsError:U,onWxAccountsBlur:fe,form:u,chatAgents:q,onAgentRouteChange:(e,t)=>ne(`weixin`,e,t),saving:h,language:r,dialogOpen:Ce&&X===`weixin`,pairingFocus:Pe}),Re=(0,$.jsx)(ut,{ch:a,form:u,baseline:d,showFeishuSecret:O,setShowFeishuSecret:k,showFeishuWebhookSecrets:A,setShowFeishuWebhookSecrets:M,feishuCopied:I,feishuWebhookCopied:L,copyFeishuSecret:le,copyFeishuWebhookConfig:ue,updateFeishu:ae,updateChannelAgentRoute:ne,feishuAccountsDraft:W,setFeishuAccountsDraft:G,feishuAccountsError:K,onFeishuAccountsBlur:pe,dmOpts:me,groupOpts:he,chatAgents:q,saving:h,language:r,dialogOpen:Ce&&X===`feishu`,pairingFocus:Fe});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{hasToken:o,ch:a,refreshing:ve,saveOk:_,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,$.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:i.settingsSections.channels}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.subtitle}),(0,$.jsxs)(`a`,{href:m(r,`channels`),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[a.docsLink,(0,$.jsx)(F,{className:`size-3.5`})]})]}),g?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:g}):null,v?(0,$.jsx)(`p`,{className:`text-xs text-accent`,children:v}):null,x?(0,$.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:x}):null,ve?(0,$.jsx)(Ie,{count:Math.max(be.length,3)}):(0,$.jsx)(Me,{catalog:be,cards:we,ch:a,saving:h,onOpenChannel:De,onToggleChannel:(e,t)=>{te(e)&&Y(e,t)}}),X===`weixin`?(0,$.jsx)(fn,{open:Ce,onOpenChange:ke,ch:a,onLoginSuccess:Ae,moreSettings:Le,settingsDirty:p,settingsSaving:h,onSettingsDiscard:J,onSettingsSave:oe}):null,X===`telegram`?(0,$.jsx)(Ct,{open:Ce,onOpenChange:e=>{e||Oe()},ch:a,form:u,baseline:d,tgAdvanced:S,setTgAdvanced:C,showToken:w,setShowToken:T,copied:N,copyToken:se,updateTelegram:re,updateChannelAgentRoute:ne,tgAccountsDraft:z,setTgAccountsDraft:B,tgAccountsError:ee,onTgAccountsBlur:de,dmOpts:me,groupOpts:he,replyOpts:ge,streamOpts:_e,chatAgents:q,saving:h,dirty:p,save:oe,discard:J,language:r,scrollToPairingOnOpen:Se,closeOnSave:!1}):null,X===`feishu`?(0,$.jsx)(yt,{open:Ce,onOpenChange:e=>{e||Oe()},ch:a,onSetupSuccess:ce,moreSettings:Re,settingsDirty:p,settingsSaving:h,onSettingsDiscard:J,onSettingsSave:oe}):null,Ee&&Q&&!Ee.manageable?(0,$.jsx)(Ve,{open:Ce,onOpenChange:e=>{e||Oe()},entry:Ee,vm:Q,ch:a,language:r}):null]})]})}function vn(e){let t=(0,Q.c)(11),{hasToken:n,ch:r,refreshing:i,saveOk:a,onRefresh:o}=e,s=_(bn),c=_(yn),l;t[0]!==r||t[1]!==o||t[2]!==i||t[3]!==a?(l=(0,$.jsx)(He,{ch:r,refreshing:i,saveOk:a,onRefresh:o}),t[0]=r,t[1]=o,t[2]=i,t[3]=a,t[4]=l):l=t[4];let u=l,d,f;return t[5]!==u||t[6]!==c||t[7]!==n||t[8]!==s?(d=()=>n?(s({startExtra:null,main:null,end:u}),()=>c()):(c(),()=>c()),f=[u,c,n,s],t[5]=u,t[6]=c,t[7]=n,t[8]=s,t[9]=d,t[10]=f):(d=t[9],f=t[10]),(0,Z.useLayoutEffect)(d,f),null}function yn(e){return e.clearPageHeader}function bn(e){return e.setPageHeader}export{_n as ChannelsSettingsPanel};
@@ -1 +0,0 @@
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-CWWpfkq1.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-ht5iswWS.js";import{a as u,n as d}from"./fetch-DTN0w7rV.js";import{A as f,An as p,Co as m,Cr as h,F as g,Fr as _,Hi as v,I as y,Ia as b,Jr as x,Ka as S,Lr as C,N as w,P as T,Qa as E,Ro as D,So as O,Sr as k,Tr as A,Tt as j,Uo as M,Yi as N,Zr as P,a as F,ai as I,ar as L,ba as R,bo as z,br as B,ci as V,dr as H,ea as U,ei as W,ga as G,h as K,ii as q,ir as J,jn as ee,ka as te,ki as ne,na as re,no as ie,oi as Y,or as ae,ri as X,sr as oe,ti as se,uo as ce,ur as le,vr as ue,wo as de,wr as fe,xr as pe,yi as me,yr as he,zi as ge}from"./index-DnevRVa6.js";import{n as _e,t as ve}from"./settings-form-section-QJh5ruel.js";import{a as ye,c as be,d as xe,f as Se,l as Ce,n as we,o as Te,r as Ee,s as De,t as Oe,u as ke}from"./settings-advanced-gate-BctKqHcf.js";import{a as Ae,c as je,d as Me,f as Ne,i as Pe,l as Fe,m as Ie,n as Le,o as Re,p as ze,r as Be,s as Ve,t as He,u as Ue}from"./cron-api--I8LJ44S.js";import{s as We,t as Ge}from"./heartbeat-config-api-2UiKevxG.js";import{m as Ke,p as qe,t as Je}from"./workflow-page.utils-CJqnPWkW.js";import{i as Ye,n as Xe,o as Ze,r as Qe,t as $e}from"./dist-CYgHMQO0.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)(k,{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)(A,{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)(I,{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,g;t[8]===s?g=t[9]:(g=()=>void s(),t[8]=s,t[9]=g);let _=i===`delete`?a.delete:a.runNow,v;t[10]!==m||t[11]!==g||t[12]!==_?(v=(0,$.jsx)(I,{type:`button`,variant:`primary`,className:m,onClick:g,children:_}),t[10]=m,t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]!==v||t[15]!==p?(y=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[p,v]}),t[14]=v,t[15]=p,t[16]=y):y=t[16];let b;t[17]!==y||t[18]!==u||t[19]!==f?(b=(0,$.jsxs)(h,{children:[c,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(B,{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,y]})})]}),t[17]=y,t[18]=u,t[19]=f,t[20]=b):b=t[20];let x;return t[21]!==r||t[22]!==n||t[23]!==b?(x=(0,$.jsx)(fe,{open:n,onOpenChange:r,children:b}),t[21]=r,t[22]=n,t[23]=b,t[24]=x):x=t[24],x}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})}),ae()}function at(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,q,`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({hasToken:e}){let t=a(i(e=>e.language)).cron.globals,{data:n,isLoading:r}=oe(e),o=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(rt(n.payload.config)),[n]),[s,c]=(0,Z.useReducer)(st,void 0,ot),l=(0,Z.useRef)(o);e&&o!==null&&!s.dirty&&l.current!==o&&(l.current=o,c({type:`sync`,parsed:o}));let u=(0,Z.useMemo)(()=>!!(s.form&&s.baseline&&JSON.stringify(s.form)!==JSON.stringify(s.baseline)),[s.form,s.baseline]),d=(0,Z.useCallback)(e=>{c({type:`patch`,patch:e})},[]),f=(0,Z.useCallback)(async()=>{if(!(!s.form||s.saving)){c({type:`saveStart`});try{await it(s.form),c({type:`saveSuccess`}),window.setTimeout(()=>c({type:`clearSaveOk`}),2500)}catch(e){c({type:`saveError`,error:e instanceof Error?e.message:t.saveError})}}},[t.saveError,s.form,s.saving]);return!e||!s.form?r?(0,$.jsx)(ve,{children:(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(R,{className:`size-4 animate-spin`}),t.loading]})}):null:(0,$.jsxs)(ve,{children:[(0,$.jsx)(_e,{icon:ce,title:t.title,subtitle:t.hint}),(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-end gap-2`,children:[s.saveOk?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.saved}):null,(0,$.jsx)(I,{type:`button`,variant:`secondary`,disabled:!u||s.saving,onClick:()=>c({type:`discard`}),children:t.discard}),(0,$.jsx)(I,{type:`button`,variant:`primary`,disabled:!u||s.saving,onClick:()=>void f(),children:s.saving?t.saving:t.save})]}),s.error?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg sm:col-span-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:s.form.enabled,onChange:e=>d({enabled:e.target.checked})}),t.enabled]}),(0,$.jsxs)(Oe,{children:[(0,$.jsx)(lt,{label:t.maxConcurrent,value:s.form.maxConcurrentJobs,min:1,max:100,disabled:!s.form.enabled,onChange:e=>d({maxConcurrentJobs:e})}),(0,$.jsx)(lt,{label:t.timezone,text:!0,value:s.form.defaultTimezone,disabled:!s.form.enabled,onTextChange:e=>d({defaultTimezone:e})}),(0,$.jsx)(lt,{label:t.retentionDays,value:s.form.historyRetentionDays,min:1,max:365,disabled:!s.form.enabled,onChange:e=>d({historyRetentionDays:e})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:s.form.enableMetrics,disabled:!s.form.enabled,onChange:e=>d({enableMetrics:e.target.checked})}),t.metrics]})]})]})]})}function lt(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:Y(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:Y(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 ut=`*/5 * * * *`,dt=2100*1e3;function ft(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function pt(e){let t=ft(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t}function mt(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function ht(e){let t=e?.trim();t&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:t},bubbles:!0}))}function gt(e){let t=e?.trim();t&&(window.location.hash=`/workflows?run=${encodeURIComponent(t)}`)}function _t(e){return Y(`w-full rounded-md border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-disabled`,W,e&&`cursor-not-allowed opacity-60`)}function vt(){return Y(X,se)}var yt=Y(X,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`),bt=Y(X,`w-auto min-w-[9rem] max-w-[14rem] shrink-0 text-xs`);function xt(e){return e===`settings`?`settings`:e===`system`||e===`systemTasks`?`systemTasks`:e===`history`?`history`:`myTasks`}function St(e){return e===`myTasks`?null:e===`systemTasks`?`system`:e===`history`?`history`:`settings`}function Ct(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 wt(e,t){return e.payload.kind===`workflowRun`?t.taskKindWorkflowRun:e.payload.kind===`agentTurn`?t.taskKindMessage:t.modeDirectOption}function Tt(e){return e.length===0?null:e.find(e=>e.status===`failed`)?.id??e[0]?.id??null}function Et(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)(ce,{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=xe(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=Y(`inline-flex rounded-md px-2 py-0.5 text-xs font-medium`,Ct(n.status)),t[8]=n.status,t[9]=h);let g;t[10]!==n.status||t[11]!==o?(g=ye(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=De(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 C;t[28]!==l||t[29]!==r||t[30]!==u?(C=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]=C):C=t[31];let w;t[32]!==b||t[33]!==x||t[34]!==C?(w=(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,C]})]}),t[32]=b,t[33]=x,t[34]=C,t[35]=w):w=t[35];let T;t[36]!==a||t[37]!==r||t[38]!==u||t[39]!==i?(T=u?(0,$.jsxs)(I,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:i,children:[(0,$.jsx)(O,{className:Y(`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]=T):T=t[40];let E;t[41]!==a||t[42]!==n.workflowRunId?(E=n.workflowRunId?.trim()?(0,$.jsxs)(I,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,title:a.openWorkflowTitle,onClick:()=>gt(n.workflowRunId),children:[(0,$.jsx)(S,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),a.openWorkflow]}):null,t[41]=a,t[42]=n.workflowRunId,t[43]=E):E=t[43];let D;t[44]!==a||t[45]!==n.sessionKey?(D=n.sessionKey?.trim()?(0,$.jsxs)(I,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,title:a.openChatTitle,onClick:()=>ht(n.sessionKey),children:[(0,$.jsx)(G,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),a.openChat]}):null,t[44]=a,t[45]=n.sessionKey,t[46]=D):D=t[46];let k;t[47]!==E||t[48]!==D?(k=(0,$.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[E,D]}),t[47]=E,t[48]=D,t[49]=k):k=t[49];let A;t[50]!==T||t[51]!==k?(A=(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:[T,k]}),t[50]=T,t[51]=k,t[52]=A):A=t[52];let j;return t[53]!==w||t[54]!==A?(j=(0,$.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:[w,A]}),t[53]=w,t[54]=A,t[55]=j):j=t[55],j}function Dt(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=Y(`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 Ot({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:g,onDelete:_}){let[v,y]=(0,Z.useState)(!1),[b,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]),E=i[0]??null;(0,Z.useEffect)(()=>{if(!e){y(!1),S(null),w(!1);return}S(Tt(i))},[e,n?.id,i]);let D=(0,Z.useCallback)(async()=>{n?.schedule&&await x(n.schedule)&&(w(!0),window.setTimeout(()=>w(!1),1500))},[n?.schedule]),j=n?ke(n,o,s):`—`;return(0,$.jsx)(fe,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(h,{children:[(0,$.jsx)(k,{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)(B,{className:Y(`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)(A,{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:j}):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:Y(`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:()=>g(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)(he,{asChild:!0,children:(0,$.jsx)(I,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":a.close,children:(0,$.jsx)(V,{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)(R,{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:j}),(0,$.jsx)(I,{type:`button`,variant:`secondary`,className:`size-8 shrink-0 p-0`,title:a.detailCopySchedule,"aria-label":a.detailCopySchedule,onClick:()=>void D(),children:C?(0,$.jsx)(m,{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)(Dt,{icon:de,label:a.nextRun,value:n.next_run?be(n.next_run,a.timeLabels):`—`}),(0,$.jsx)(Dt,{icon:ce,label:a.detailLastRun,value:E?ye(E.status,u):a.detailNoRecentRuns,valueClassName:E?.status===`failed`?`text-red-700 dark:text-red-300`:E?.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:wt(n,a)}),(0,$.jsx)(`div`,{className:`min-w-0 break-words text-fg [&_.markdown-body]:text-sm [&_.markdown-body]:leading-relaxed`,children:(0,$.jsx)(p,{content:Le(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":v,onClick:()=>y(e=>!e),children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ge,{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)(O,{className:Y(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,v&&`rotate-180`),"aria-hidden":!0})]}),v?(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)(ce,{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)(Et,{row:e,expanded:b===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)(I,{type:`button`,className:`gap-1.5`,onClick:()=>f(n),children:[(0,$.jsx)(re,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),a.runNow]}),(0,$.jsx)(I,{type:`button`,variant:`secondary`,onClick:()=>d(n),children:a.edit}),(0,$.jsxs)(I,{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:()=>_(n),children:[(0,$.jsx)(me,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),a.delete]})]})}):null]})})]})})}function kt(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 p=T(d),m;t[3]===n?m=t[4]:(m=n.trim(),t[3]=n,t[4]=m);let h=m,_=s??(h?`${h}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`),v=i||p.picking,y=o??a.notSet,b;t[5]!==c||t[6]!==p.pick||t[7]!==_||t[8]!==v||t[9]!==y||t[10]!==n?(b=(0,$.jsx)(g,{value:n,onPick:p.pick,disabled:v,placeholder:y,title:_,maxWidthClass:c}),t[5]=c,t[6]=p.pick,t[7]=_,t[8]=v,t[9]=y,t[10]=n,t[11]=b):b=t[11];let x;t[12]!==l||t[13]!==i||t[14]!==u||t[15]!==p.picking||t[16]!==h?(x=l&&h&&u?(0,$.jsx)(`button`,{type:`button`,disabled:i||p.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]=p.picking,t[16]=h,t[17]=x):x=t[17];let S;t[18]!==b||t[19]!==x?(S=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[b,x]}),t[18]=b,t[19]=x,t[20]=S):S=t[20];let C;t[21]!==p.confirmPick||t[22]!==p.hasNativePicker||t[23]!==p.modalOpen||t[24]!==p.setModalOpen||t[25]!==h||t[26]!==a?(C=p.hasNativePicker?null:(0,$.jsx)(f,{open:p.modalOpen,onOpenChange:p.setModalOpen,initialAbsolutePath:h||void 0,onConfirm:p.confirmPick,wd:a}),t[21]=p.confirmPick,t[22]=p.hasNativePicker,t[23]=p.modalOpen,t[24]=p.setModalOpen,t[25]=h,t[26]=a,t[27]=C):C=t[27];let w;return t[28]!==S||t[29]!==C?(w=(0,$.jsxs)($.Fragment,{children:[S,C]}),t[28]=S,t[29]=C,t[30]=w):w=t[30],w}function At(e,t){return e[t]??t}function jt(e,t){let n=F[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 Mt(e,t){return(F[e]??[]).every(e=>!e.required||!!t[e.key]?.trim())}function Nt(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 Pt(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=F[n]??[];g=e.length>0;let l=Y(`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:[At(_.args,e.labelKey),e.required?` *`:``]}),e.multiline?(0,$.jsx)(`textarea`,{value:i[e.key]??``,onChange:t=>o({...i,[e.key]:t.target.value}),placeholder:At(_.args,e.placeholderKey),className:Y(l,`min-h-20 resize-y`)}):(0,$.jsx)(`input`,{value:i[e.key]??``,onChange:t=>o({...i,[e.key]:t.target.value}),placeholder:At(_.args,e.placeholderKey),className:l})]},e.key)),b=g&&p.length>0?(0,$.jsx)(Nt,{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:Y(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)(Nt,{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 Ft(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:m,formJobId:g,formName:_,onFormNameChange:v,formSchedule:b,onFormScheduleChange:x,formSubmitting:S,formTaskKind:C,onFormTaskKindChange:w,workflowDefinitions:T,workflowDefinitionsLoading:D,formWorkflowDefinitionId:O,onFormWorkflowDefinitionIdChange:M,formWorkflowGoal:P,onFormWorkflowGoalChange:F,formWorkflowArgValues:L,onFormWorkflowArgValuesChange:R,formSessionTarget:z,onFormSessionTargetChange:H,formAgentLocalOnly:U,onFormAgentLocalOnlyChange:W,formModel:G,onFormModelUserChange:K,formAgentId:q,onFormAgentIdChange:J,formWorkingDirectory:te,onFormWorkingDirectoryChange:re,formChannel:ie,onFormChannelChange:ae,formChatId:X,onFormChatIdChange:oe,formMessage:se,onFormMessageChange:ce,formMessageMdMode:le,onSetMessageMdMode:ue,messageEditorNonce:de,needsDeliveryChat:pe,showChannelPicker:me,canSubmit:ge,onSubmit:_e,onRefreshRecipients:ve}=e,ye=i(zt),be,xe;if(t[0]!==O||t[1]!==ye||t[2]!==T){let e;t[5]===O?e=t[6]:(e=e=>e.id===O.trim(),t[5]=O,t[6]=e),be=T.find(e),xe=be?Ke(be,ye):null,t[0]=O,t[1]=ye,t[2]=T,t[3]=be,t[4]=xe}else be=t[3],xe=t[4];let Se=xe,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)(k,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[9]=Te):Te=t[9];let Ee=m===`edit`?a.editJob:a.addJob,De;t[10]===Ee?De=t[11]:(De=(0,$.jsx)(A,{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)(V,{className:`size-5`,strokeWidth:1.75}),t[12]=Oe):Oe=t[12];let ke;t[13]===a.close?ke=t[14]:(ke=(0,$.jsx)(he,{asChild:!0,children:(0,$.jsx)(I,{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=_t(),t[20]=Me):Me=t[20];let Ne;t[21]===v?Ne=t[22]:(Ne=e=>v(e.target.value),t[21]=v,t[22]=Ne);let Pe;t[23]!==a.namePlaceholder||t[24]!==_||t[25]!==Ne?(Pe=(0,$.jsx)(`input`,{type:`text`,className:Me,value:_,onChange:Ne,placeholder:a.namePlaceholder}),t[23]=a.namePlaceholder,t[24]=_,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]!==b||t[32]!==S||t[33]!==x?(Ie=(0,$.jsx)(We,{value:b,onChange:x,disabled:S,labels:a.schedulePicker}),t[30]=a.schedulePicker,t[31]=b,t[32]=S,t[33]=x,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=vt(),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]!==q||t[78]!==U||t[79]!==ie||t[80]!==X||t[81]!==S||t[82]!==C||t[83]!==L||t[84]!==O||t[85]!==P||t[86]!==ye||t[87]!==pe||t[88]!==J||t[89]!==W||t[90]!==ae||t[91]!==oe||t[92]!==R||t[93]!==M||t[94]!==F||t[95]!==ve||t[96]!==be||t[97]!==Se||t[98]!==u||t[99]!==me||t[100]!==T||t[101]!==D?(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:vt(),value:O,disabled:S||D,onChange:e=>M(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:D?a.workflowDefinitionsLoading:a.workflowDefinitionPlaceholder}),O.trim()&&!T.some(e=>e.id===O.trim())?(0,$.jsx)(`option`,{value:O,children:O}):null,T.map(e=>(0,$.jsxs)(`option`,{value:e.id,children:[e.title,e.metadata.source===`user`?` (${a.workflowDefinitionCustom})`:``]},e.id))]}),!D&&T.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workflowDefinitionsEmpty}):null,Se?(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:Se.description}):O.trim()&&!be?(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:a.workflowDefinitionMissing}):null]}),O.trim()?(0,$.jsx)(Pt,{workflowName:O.trim(),language:ye,argValues:L,onArgValuesChange:R,goal:P,onGoalChange:F,examplePrompts:Se?.examplePrompts??[],inputClassName:_t()}):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:vt(),value:q,disabled:S,onChange:e=>J(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:a.agentProfileDefault}),d.map(e=>(0,$.jsx)(`option`,{value:e.id,children:`${e.id} — ${j(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:Y(`ui-checkbox`,`mt-0.5`),checked:U,onChange:e=>W(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})]})]}),me?(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:vt(),value:ie,onChange:e=>ae(e.target.value),children:[(0,$.jsx)(`option`,{value:`local`,children:a.channelLocal}),l.map(Lt)]})]}),pe?(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)(I,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:a.refreshRecipientHint,onClick:()=>void ve(),children:[(0,$.jsx)(N,{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:Y(_t(),`min-w-0 w-full sm:flex-1`),value:X,onChange:e=>oe(e.target.value),placeholder:a.recipientPlaceholder}),(0,$.jsxs)(`select`,{className:yt,value:X,onChange:e=>{let t=e.target.value;t&&oe(t)},children:[(0,$.jsx)(`option`,{value:``,children:a.selectRecipient}),u.length>0?u.map(e=>(0,$.jsx)(`option`,{value:e.chatId,children:Ce(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]=q,t[78]=U,t[79]=ie,t[80]=X,t[81]=S,t[82]=C,t[83]=L,t[84]=O,t[85]=P,t[86]=ye,t[87]=pe,t[88]=J,t[89]=W,t[90]=ae,t[91]=oe,t[92]=R,t[93]=M,t[94]=F,t[95]=ve,t[96]=be,t[97]=Se,t[98]=u,t[99]=me,t[100]=T,t[101]=D,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]!==q||t[139]!==U||t[140]!==ie||t[141]!==X||t[142]!==g||t[143]!==se||t[144]!==le||t[145]!==G||t[146]!==z||t[147]!==S||t[148]!==C||t[149]!==te||t[150]!==c||t[151]!==de||t[152]!==pe||t[153]!==J||t[154]!==W||t[155]!==ae||t[156]!==oe||t[157]!==ce||t[158]!==K||t[159]!==H||t[160]!==re||t[161]!==ve||t[162]!==ue||t[163]!==u||t[164]!==me?(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:vt(),value:z,onChange:e=>{let t=e.target.value;H(t,f,G.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:z===`main`?a.modeDirect:a.modeAgent})]}),z===`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)(y,{value:G,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:vt(),value:q,disabled:S,onChange:e=>J(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:a.agentProfileDefault}),d.map(e=>(0,$.jsx)(`option`,{value:e.id,children:`${e.id} — ${j(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)(kt,{value:te,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:Y(`ui-checkbox`,`mt-0.5`),checked:U,onChange:e=>W(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,me?(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:vt(),value:ie,onChange:e=>{let t=e.target.value;ae(t)},children:[(0,$.jsx)(`option`,{value:`local`,children:a.channelLocal}),l.map(It)]})]}),pe?(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)(I,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:a.refreshRecipientHint,onClick:()=>void ve(),children:[(0,$.jsx)(N,{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:Y(_t(),`min-w-0 w-full sm:flex-1`),value:X,onChange:e=>oe(e.target.value),placeholder:a.recipientPlaceholder}),(0,$.jsxs)(`select`,{className:yt,value:X,onChange:e=>{let t=e.target.value;t&&oe(t)},children:[(0,$.jsx)(`option`,{value:``,children:a.selectRecipient}),u.length>0?u.map(e=>(0,$.jsx)(`option`,{value:e.chatId,children:Ce(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:Y(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,le===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>ue(`edit`),children:[(0,$.jsx)(ne,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),a.messageEdit]}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,le===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>ue(`preview`),children:[(0,$.jsx)(E,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),a.messagePreview]})]})]}),(0,$.jsx)(`div`,{className:Y(`overflow-hidden rounded-md border border-edge bg-surface-base dark:border-edge`,S&&`pointer-events-none opacity-60`),children:le===`edit`?(0,$.jsx)(ee,{initialContent:se,onChange:ce,isDark:c,className:`h-[min(18rem,40vh)] min-h-[12rem]`},`cron-msg-${g??`new`}-${de}`):(0,$.jsx)(`div`,{className:`h-[min(18rem,40vh)] min-h-[12rem] max-h-[min(24rem,50vh)] overflow-y-auto px-3 py-2`,children:se.trim()?(0,$.jsx)(p,{content:se,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]=q,t[139]=U,t[140]=ie,t[141]=X,t[142]=g,t[143]=se,t[144]=le,t[145]=G,t[146]=z,t[147]=S,t[148]=C,t[149]=te,t[150]=c,t[151]=de,t[152]=pe,t[153]=J,t[154]=W,t[155]=ae,t[156]=oe,t[157]=ce,t[158]=K,t[159]=H,t[160]=re,t[161]=ve,t[162]=ue,t[163]=u,t[164]=me,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)(I,{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:m===`edit`?a.save:a.create,Qe;t[175]!==_e||t[176]!==Xe||t[177]!==Ze?(Qe=(0,$.jsx)(I,{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)(h,{children:[Te,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(B,{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:Rt,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)(fe,{open:n,onOpenChange:we,children:Z})}),t[186]=n,t[187]=we,t[188]=Z,t[189]=et):et=t[189],et}function It(e){return(0,$.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}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 e.preventDefault()}function zt(e){return e.language}function Bt(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]:(_=Y(`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=Y(`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=Y(`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=Y(`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=Y(`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:bt,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:Y(H,`shrink-0`),role:`group`,"aria-label":n.runHistoryTitle,children:[`day`,`week`,`month`].map(e=>(0,$.jsx)(`button`,{type:`button`,className:Y(le,`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:bt,value:l,onChange:e=>u(e.target.value),"aria-label":n.filterAllTasks,children:[(0,$.jsx)(`option`,{value:``,children:n.filterAllTasks}),p.map(Vt)]}),(0,$.jsxs)(`select`,{className:bt,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 Vt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id)}function Ht(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=Y(`size-4`,f),t[2]=f,t[3]=p);let m;t[4]===p?m=t[5]:(m=(0,$.jsx)(N,{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)(I,{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)(te,{className:`size-4`,strokeWidth:1.75}),t[11]=g):g=t[11];let _;t[12]!==n.fromTemplate||t[13]!==o?(_=(0,$.jsxs)(I,{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)(I,{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 Ut(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]:(_=Y(`size-4`,g),t[9]=g,t[10]=_);let v;t[11]===_?v=t[12]:(v=(0,$.jsx)(N,{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)(I,{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)(R,{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)(ce,{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:xe(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:Y(`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:ye(e.status,l)})}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg-muted`,children:De(e.duration)}),(0,$.jsx)(`td`,{className:`max-w-xs truncate px-3 py-2.5 text-fg-muted`,title:e.summary||e.error||``,children:Se(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:()=>gt(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:()=>ht(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 Wt(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,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`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]=m):m=t[0];let h,g;t[1]!==o||t[2]!==n||t[3]!==c?(h=()=>{if(o.current===n.id){o.current=null;return}c(n)},g=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]=h,t[5]=g):(h=t[4],g=t[5]);let _=n.enabled,v=n.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`,y;t[6]===v?y=t[7]:(y=Y(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,v),t[6]=v,t[7]=y);let b;t[8]!==n||t[9]!==l?(b=e=>{e.stopPropagation(),l(n,!n.enabled)},t[8]=n,t[9]=l,t[10]=b):b=t[10];let x;t[11]===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[11]=x):x=t[11];let S;t[12]!==n.enabled||t[13]!==y||t[14]!==b?(S=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":_,className:y,onClick:b,children:x}),t[12]=n.enabled,t[13]=y,t[14]=b,t[15]=S):S=t[15];let C;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(ie,{className:`size-4`,strokeWidth:1.75}),t[16]=C):C=t[16];let w;t[17]===r.jobCardMenuAria?w=t[18]:(w=(0,$.jsx)(Ze,{asChild:!0,children:(0,$.jsx)(I,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":r.jobCardMenuAria,onClick:Kt,children:C})}),t[17]=r.jobCardMenuAria,t[18]=w);let T;t[19]!==n||t[20]!==u||t[21]!==s?(T=()=>{s(n.id),u(n)},t[19]=n,t[20]=u,t[21]=s,t[22]=T):T=t[22];let E;t[23]!==r.edit||t[24]!==T?(E=(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:T,children:r.edit}),t[23]=r.edit,t[24]=T,t[25]=E):E=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]!==E||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:Gt,children:[E,O,A]})}),t[40]=E,t[41]=O,t[42]=A,t[43]=j):j=t[43];let M;t[44]!==w||t[45]!==j?(M=(0,$.jsxs)(Ye,{children:[w,j]}),t[44]=w,t[45]=j,t[46]=M):M=t[46];let N;t[47]!==M||t[48]!==S?(N=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 px-4 pt-3`,children:[S,M]}),t[47]=M,t[48]=S,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 L;t[52]===n?L=t[53]:(L=Le(n),t[52]=n,t[53]=L);let R;t[54]===n?R=t[55]:(R=Le(n),t[54]=n,t[55]=R);let z;t[56]===R?z=t[57]:(z=(0,$.jsx)(p,{content:R,compact:!0}),t[56]=R,t[57]=z);let B;t[58]!==L||t[59]!==z?(B=(0,$.jsx)(`div`,{className:`max-h-[4.5rem] overflow-hidden text-sm text-fg-muted [&_.markdown-body]:text-sm [&_.markdown-body]:leading-snug`,title:L,children:z}),t[58]=L,t[59]=z,t[60]=B):B=t[60];let V;t[61]!==F||t[62]!==B?(V=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 px-4 pb-3 pt-2`,children:[F,B]}),t[61]=F,t[62]=B,t[63]=V):V=t[63];let H;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(ce,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[64]=H):H=t[64];let U;t[65]!==n||t[66]!==i||t[67]!==a?(U=ke(n,i,a),t[65]=n,t[66]=i,t[67]=a,t[68]=U):U=t[68];let W;t[69]===U?W=t[70]:(W=(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:[H,(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:U})]}),t[69]=U,t[70]=W);let G;return t[71]!==h||t[72]!==N||t[73]!==V||t[74]!==g||t[75]!==W?(G=(0,$.jsxs)(`article`,{role:`button`,tabIndex:0,className:m,onClick:h,onKeyDown:g,children:[N,V,W]}),t[71]=h,t[72]=N,t[73]=V,t[74]=g,t[75]=W,t[76]=G):G=t[76],G}function Gt(e){return e.preventDefault()}function Kt(e){return e.stopPropagation()}function qt(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:h,onOpenDetail:g,onToggle:_,onEdit:v,onRunNow:y,onDelete:x}=e,S,C,w,T,E,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=Ee(l.intervalMs,i,a(r).heartbeatSettings.intervalPresets);N=`cron-system-tasks-panel`,P=`flex flex-col gap-4`,t[33]===n.tabSystemTasks?C=t[34]:(C=(0,$.jsx)(`h2`,{id:`cron-system-tasks-panel`,className:`sr-only`,children:n.tabSystemTasks}),t[33]=n.tabSystemTasks,t[34]=C),t[35]===n.systemTasksIntro?w=t[36]:(w=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.systemTasksIntro}),t[35]=n.systemTasksIntro,t[36]=w);let o;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(b,{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,h=d?void 0:n.wakeLockUnavailable,g=u?`justify-end bg-accent`:`justify-start bg-surface-hover`,_=!d&&`cursor-not-allowed opacity-50`,v;t[42]!==g||t[43]!==_?(v=Y(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,g,_),t[42]=g,t[43]=_,t[44]=v):v=t[44];let y;t[45]!==p||t[46]!==f||t[47]!==d?(y=()=>{d?p():f()},t[45]=p,t[46]=f,t[47]=d,t[48]=y):y=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]!==h||t[53]!==v||t[54]!==y?(F=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":u,disabled:m,title:h,className:v,onClick:y,children:x}),t[50]=u,t[51]=m,t[52]=h,t[53]=v,t[54]=y,t[55]=F):F=t[55];let L;t[56]!==c||t[57]!==F?(L=(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]=L):L=t[58],t[59]!==s||t[60]!==L?(T=(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,L]}),t[59]=s,t[60]=L,t[61]=T):T=t[61],j=`rounded-xl border border-edge bg-surface-base p-4 dark:bg-surface-hover/20`;let R;t[62]===n.systemHeartbeatTitle?R=t[63]:(R=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemHeartbeatTitle}),t[62]=n.systemHeartbeatTitle,t[63]=R);let B;t[64]===n.systemHeartbeatHint?B=t[65]:(B=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.systemHeartbeatHint}),t[64]=n.systemHeartbeatHint,t[65]=B);let V;t[66]!==R||t[67]!==B?(V=(0,$.jsxs)(`div`,{children:[R,B]}),t[66]=R,t[67]=B,t[68]=V):V=t[68];let H;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(z,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[69]=H):H=t[69];let U;t[70]===n.systemHeartbeatSettingsLink?U=t[71]:(U=(0,$.jsx)(I,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,$.jsxs)(D,{to:`/settings/heartbeat`,children:[n.systemHeartbeatSettingsLink,H]})}),t[70]=n.systemHeartbeatSettingsLink,t[71]=U),t[72]!==V||t[73]!==U?(M=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between`,children:[V,U]}),t[72]=V,t[73]=U,t[74]=M):M=t[74],k=`mt-3 grid gap-2 text-sm sm:grid-cols-2`;let W;t[75]===n.systemHeartbeatStatus?W=t[76]:(W=(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatStatus}),t[75]=n.systemHeartbeatStatus,t[76]=W);let G=l.enabled?n.enabled:n.disabled,K;t[77]===G?K=t[78]:(K=(0,$.jsx)(`dd`,{className:`text-fg`,children:G}),t[77]=G,t[78]=K),t[79]!==W||t[80]!==K?(A=(0,$.jsxs)(`div`,{children:[W,K]}),t[79]=W,t[80]=K,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 q;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(q=/\{\{value\}\}/g,t[84]=q):q=t[84],E=n.systemHeartbeatEvery.replace(q,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]=C,t[23]=w,t[24]=T,t[25]=E,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],C=t[22],w=t[23],T=t[24],E=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]!==E?(F=(0,$.jsx)(`dd`,{className:S,children:E}),t[85]=S,t[86]=E,t[87]=F):F=t[87];let L;t[88]!==F||t[89]!==O?(L=(0,$.jsxs)(`div`,{children:[O,F]}),t[88]=F,t[89]=O,t[90]=L):L=t[90];let B;t[91]!==L||t[92]!==k||t[93]!==A?(B=(0,$.jsxs)(`dl`,{className:k,children:[A,L]}),t[91]=L,t[92]=k,t[93]=A,t[94]=B):B=t[94];let V;t[95]!==B||t[96]!==j||t[97]!==M?(V=(0,$.jsxs)(`div`,{className:j,children:[M,B]}),t[95]=B,t[96]=j,t[97]=M,t[98]=V):V=t[98];let H;t[99]===n.systemDreamingTitle?H=t[100]:(H=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemDreamingTitle}),t[99]=n.systemDreamingTitle,t[100]=H);let U;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(z,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[101]=U):U=t[101];let W;t[102]===n.systemDreamingSettingsLink?W=t[103]:(W=(0,$.jsx)(I,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,$.jsxs)(D,{to:`/settings/dreams`,children:[n.systemDreamingSettingsLink,U]})}),t[102]=n.systemDreamingSettingsLink,t[103]=W);let G;t[104]!==H||t[105]!==W?(G=(0,$.jsxs)(`div`,{className:`mb-2 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[H,W]}),t[104]=H,t[105]=W,t[106]=G):G=t[106];let K;t[107]===n.systemDreamingHint?K=t[108]:(K=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-muted`,children:n.systemDreamingHint}),t[107]=n.systemDreamingHint,t[108]=K);let q;t[109]!==m||t[110]!==n||t[111]!==s||t[112]!==i||t[113]!==x||t[114]!==v||t[115]!==g||t[116]!==y||t[117]!==_||t[118]!==h||t[119]!==o||t[120]!==c?(q=s&&c.length===0?(0,$.jsx)(`div`,{className:`flex justify-center py-12`,"aria-busy":`true`,children:(0,$.jsx)(R,{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)(Wt,{job:e,c:n,localeTag:i,scheduleBadgeLabels:o,absorbCardClickJobIdRef:m,scheduleAbsorbNextMenuCardClick:h,onOpenDetail:g,onToggle:_,onEdit:v,onRunNow:y,onDelete:x},e.id))}),t[109]=m,t[110]=n,t[111]=s,t[112]=i,t[113]=x,t[114]=v,t[115]=g,t[116]=y,t[117]=_,t[118]=h,t[119]=o,t[120]=c,t[121]=q):q=t[121];let J;t[122]!==G||t[123]!==K||t[124]!==q?(J=(0,$.jsxs)(`div`,{children:[G,K,q]}),t[122]=G,t[123]=K,t[124]=q,t[125]=J):J=t[125];let ee;return t[126]!==C||t[127]!==w||t[128]!==T||t[129]!==V||t[130]!==J||t[131]!==N||t[132]!==P?(ee=(0,$.jsxs)(`section`,{"aria-labelledby":N,className:P,children:[C,w,T,V,J]}),t[126]=C,t[127]=w,t[128]=T,t[129]=V,t[130]=J,t[131]=N,t[132]=P,t[133]=ee):ee=t[133],ee}function Jt(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 Yt=[`daily`,`monitoring`,`reports`,`automation`],Xt=[{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 Zt(e){return Xt.find(t=>t.templateId===e)}function Qt(e,t,n){let r=t.trim().toLowerCase();return Xt.filter(t=>{if(n!==`all`&&t.category!==n)return!1;if(!r)return!0;let i=Jt(e,t.templateId);return[t.templateId,i?.title,i?.description,e.templateCategories[t.category]].filter(Boolean).join(` `).toLowerCase().includes(r)})}function $t(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 Yt.flatMap(e=>{let n=t.get(e);return n?.length?[{category:e,items:n}]:[]})}function en(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=Jt(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=ke({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=Y(`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`,P.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 tn(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=Qt(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=$t(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,y;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(v,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=y):y=t[9];let b;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>d(e.target.value),t[10]=b):b=t[10];let x=n.templateSearchPlaceholder,S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=Y(`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`,P.focusRingPanel),t[11]=S):S=t[11];let C;t[12]!==n.templateSearchPlaceholder||t[13]!==u?(C=(0,$.jsxs)(`div`,{className:`relative`,children:[y,(0,$.jsx)(`input`,{value:u,onChange:b,placeholder:x,className:S})]}),t[12]=n.templateSearchPlaceholder,t[13]=u,t[14]=C):C=t[14];let w=n.fromTemplate,T=a===`all`?`secondary`:`ghost`,E;t[15]===o?E=t[16]:(E=()=>o(`all`),t[15]=o,t[16]=E);let D;t[17]!==n.templateFilterAll||t[18]!==T||t[19]!==E?(D=(0,$.jsx)(I,{type:`button`,variant:T,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:E,children:n.templateFilterAll}),t[17]=n.templateFilterAll,t[18]=T,t[19]=E,t[20]=D):D=t[20];let O;t[21]!==a||t[22]!==n.templateCategories||t[23]!==o?(O=Yt.map(e=>(0,$.jsx)(I,{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]=O):O=t[24];let k;t[25]!==n.fromTemplate||t[26]!==D||t[27]!==O?(k=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":w,children:[D,O]}),t[25]=n.fromTemplate,t[26]=D,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==k||t[30]!==C?(A=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4`,children:[C,k]}),t[29]=k,t[30]=C,t[31]=A):A=t[31];let j=A,M;t[32]!==n||t[33]!==p||t[34]!==h||t[35]!==r||t[36]!==s||t[37]!==i||t[38]!==_||t[39]!==l?(M=p.length===0?(0,$.jsx)(`div`,{className:Y(`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)(en,{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)(en,{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]=M):M=t[40];let N=M;if(l===`dialog`){let e;t[41]===N?e=t[42]:(e=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:N}),t[41]=N,t[42]=e);let n;return t[43]!==j||t[44]!==e?(n=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4`,children:[j,e]}),t[43]=j,t[44]=e,t[45]=n):n=t[45],n}let F;return t[46]!==j||t[47]!==N?(F=(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[j,N]}),t[46]=j,t[47]=N,t[48]=F):F=t[48],F}function nn(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:x,onRunNow:S,onDelete:C}=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)(b,{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=Y(`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 L;t[21]!==F||t[22]!==D?(L=(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]=L):L=t[23];let z;t[24]!==L||t[25]!==E?(z=(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,L]}),t[24]=L,t[25]=E,t[26]=z):z=t[26];let B;t[27]!==h||t[28]!==n||t[29]!==o||t[30]!==a||t[31]!==r||t[32]!==x||t[33]!==C||t[34]!==y||t[35]!==_||t[36]!==S||t[37]!==u||t[38]!==l||t[39]!==v||t[40]!==g||t[41]!==i||t[42]!==s||t[43]!==c?(B=a&&o===0?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,"aria-busy":`true`,children:(0,$.jsx)(R,{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)(tn,{cron:n,localeTag:r,scheduleBadgeLabels:i,categoryFilter:c,onCategoryFilterChange:l,onSelectTemplate:u})}),(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(I,{type:`button`,variant:`primary`,onClick:x,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)(Wt,{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:S,onDelete:C},e.id))}),t[27]=h,t[28]=n,t[29]=o,t[30]=a,t[31]=r,t[32]=x,t[33]=C,t[34]=y,t[35]=_,t[36]=S,t[37]=u,t[38]=l,t[39]=v,t[40]=g,t[41]=i,t[42]=s,t[43]=c,t[44]=B):B=t[44];let V;return t[45]!==w||t[46]!==z||t[47]!==B?(V=(0,$.jsxs)(`section`,{"aria-labelledby":`cron-tasks-panel`,className:`flex flex-col gap-4`,children:[w,z,B]}),t[45]=w,t[46]=z,t[47]=B,t[48]=V):V=t[48],V}function rn(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)(k,{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=Y(`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`,P.focusRingPanel),t[1]=d):d=t[1];let f;t[2]===i.fromTemplate?f=t[3]:(f=(0,$.jsx)(A,{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)(pe,{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 g;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(V,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=g):g=t[9];let _;t[10]===i.close?_=t[11]:(_=(0,$.jsx)(he,{asChild:!0,children:(0,$.jsx)(I,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":i.close,children:g})}),t[10]=i.close,t[11]=_);let v;t[12]!==m||t[13]!==_?(v=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge-subtle px-6 py-5`,children:[m,_]}),t[12]=m,t[13]=_,t[14]=v):v=t[14];let y;t[15]!==i||t[16]!==s||t[17]!==a||t[18]!==c||t[19]!==l||t[20]!==o?(y=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-6 py-5`,children:(0,$.jsx)(tn,{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]=y):y=t[21];let b;t[22]!==v||t[23]!==y?(b=(0,$.jsxs)(h,{children:[u,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[62] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(B,{className:d,onOpenAutoFocus:an,children:[v,y]})})]}),t[22]=v,t[23]=y,t[24]=b):b=t[24];let x;return t[25]!==r||t[26]!==n||t[27]!==b?(x=(0,$.jsx)(fe,{open:n,onOpenChange:r,children:b}),t[25]=r,t[26]=n,t[27]=b,t[28]=x):x=t[28],x}function an(e){return e.preventDefault()}function on(){return{formOpen:!1,formMode:`add`,formJobId:null,formName:``,formSchedule:ut,formChannel:`local`,formChatId:``,formMessage:``,formMessageMdMode:`edit`,formTaskKind:`message`,formWorkflowDefinitionId:``,formWorkflowGoal:``,formWorkflowArgValues:{},messageEditorNonce:0,formSessionTarget:`main`,formAgentId:``,formAgentLocalOnly:!1,formWorkingDirectory:``,formModel:``,formSubmitting:!1}}function sn(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 cn(e,t){let n=on();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=Le(e);if(n.formMessage=r??``,e.payload.kind===`workflowRun`){n.formTaskKind=`workflowRun`,n.formWorkflowDefinitionId=e.payload.definitionId,n.formWorkflowGoal=e.payload.goal||``,n.formWorkflowArgValues=jt(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 ln(e){let{m:t,defaultModelForForm:n,channels:r,chatAgents:i}=e,[a,o]=(0,Z.useReducer)(sn,void 0,on),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=ue(()=>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()&&Mt(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:cn(e,n)})},[n]),_=(0,Z.useCallback)(e=>{o({type:`setMessageMdMode`,mode:e})},[]),v=(0,Z.useCallback)(e=>{let r=Zt(e),i=r?Jt(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:{...on(),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:on()})},[]),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 un(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||C(),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 dn(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,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)([]),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(null),w=(0,Z.useCallback)(async()=>{x(!0),C(null);try{a(await Ue())}catch(e){C(e instanceof Error?e.message:n.failedToLoadJobs)}finally{x(!1)}},[n.failedToLoadJobs]),T=(0,Z.useCallback)(async()=>{try{let[e,t,n,r,i]=await Promise.all([Pe(),je(),Ae(),L(),J().catch(()=>null)]);s(e),l(t),d(n.model||``),h(r.payload?.config??null),i&&p(i.items)}catch{}},[]),E=(0,Z.useCallback)(async()=>{y(!0);try{_(await Be(400))}catch{}finally{y(!1)}},[]);return(0,Z.useEffect)(()=>{t&&(w(),T())},[t,w,T]),(0,Z.useEffect)(()=>{if(!t)return;let e=()=>{L().then(e=>{h(e.payload?.config??null)})};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[t]),(0,Z.useEffect)(()=>{!t||!r||E()},[t,r,E]),{jobs:i,channels:o,availableModels:c,defaultModel:u,chatAgents:f,gatewayConfigRaw:m,runHistory:g,runHistoryLoading:v,loading:b,error:S,setError:C,userCronJobs:(0,Z.useMemo)(()=>i.filter(e=>!we(e)),[i]),systemCronJobs:(0,Z.useMemo)(()=>i.filter(e=>we(e)),[i]),heartbeatFromConfig:(0,Z.useMemo)(()=>Ge(m),[m]),loadJobs:w,loadAux:T,loadRunHistoryOnly:E,refreshAll:(0,Z.useCallback)(()=>{w(),T(),E()},[w,T,E])}}function fn(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 pn(e,t,n,r){let i=new Date,a=t===`day`?ft(i):t===`week`?pt(i):mt(i);return e.filter(e=>!(new Date(e.startedAt)<a||n&&e.jobId!==n||r&&e.status!==r))}var mn={mainTab:`myTasks`,jobSort:`created_desc`,historyRange:`day`,historyJobFilter:``,historyStatusFilter:``,detailOpen:!1,detailJob:null,detailHistory:[],detailLoading:!1,confirmOpen:!1,templatePickerOpen:!1,templateCategoryFilter:`all`};function hn(){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]=M(),[h,g]=(0,Z.useReducer)(w,p,e=>({...mn,mainTab:xt(e.get(`tab`))})),{mainTab:_,jobSort:v,historyRange:y,historyJobFilter:b,historyStatusFilter:x,detailOpen:S,detailJob:C,detailHistory:T,detailLoading:E,confirmOpen:D,templatePickerOpen:O,templateCategoryFilter:k}=h,A=xt(p.get(`tab`));(0,Z.useEffect)(()=>{A!==_&&g({type:`patch`,patch:{mainTab:A}})},[A,_]);let j=(0,Z.useCallback)(e=>{g({type:`patch`,patch:{mainTab:e}}),m(t=>{let n=new URLSearchParams(t),r=St(e);return r?n.set(`tab`,r):n.delete(`tab`),n},{replace:!0})},[m]),N=dn({hasToken:c,failMessages:{failedToLoadJobs:n.failedToLoadJobs},isHistoryTab:_===`history`}),{setError:P}=N,F=un({onUnavailable:()=>P(n.wakeLockUnavailable)}),I=(0,Z.useCallback)(()=>N.defaultModel||(N.availableModels.length>0?N.availableModels[0].id:``),[N.defaultModel,N.availableModels]),L=ln({m:t,defaultModelForForm:I,channels:N.channels,chatAgents:N.chatAgents}),R=s(c&&L.formOpen?[`workflow-definitions-cron`,o]:null,K,{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)},[]),q=(0,Z.useCallback)(e=>{L.applyCronTemplate(e)&&g({type:`patch`,patch:{templatePickerOpen:!1}})},[L]),J=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`&&!Mt(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:dt}:{},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 Ie(L.formJobId,u);else{let{schedule:e,agentId:t,workingDirectory:n,...r}=u;await He(e,{...r,...t==null?{}:{agentId:t},...n?{workingDirectory:n}:{}})}L.closeForm(),await N.loadJobs()}catch(e){P(e instanceof Error?e.message:L.formMode===`edit`?n.failedToUpdateJob:n.failedToCreateJob)}finally{L.setFormSubmitting(!1)}},ee=async e=>{g({type:`patch`,patch:{detailOpen:!0,detailJob:e,detailLoading:!0,detailHistory:[]}});try{let t=await Ve(e.id);t&&g({type:`patch`,patch:{detailJob:t,detailHistory:await Re(e.id,20)}})}catch{}finally{g({type:`patch`,patch:{detailLoading:!1}})}},te=(0,Z.useCallback)(()=>{g({type:`patch`,patch:{detailOpen:!1,detailJob:null}})},[]),ne=(0,Z.useCallback)(()=>{g({type:`patch`,patch:{templateCategoryFilter:`all`,templatePickerOpen:!0}})},[]),re=async(e,t)=>{try{await ze(e.id,t),C?.id===e.id&&g({type:`patch`,patch:{detailJob:{...C,enabled:t}}}),await Promise.all([N.loadJobs(),N.loadAux()])}catch(e){P(e instanceof Error?e.message:n.failedToToggleJob)}},ie=async()=>{let e=V.current,t=B.current;if(!(!e||!t)){U();try{t===`run`?await Ne(e):(await Me(e),C?.id===e&&g({type:`patch`,patch:{detailOpen:!1,detailJob:null}})),await Promise.all([N.loadJobs(),N.loadAux(),N.loadRunHistoryOnly()])}catch(e){P(e instanceof Error?e.message:n.actionFailed)}}};(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(L.formOpen?L.closeForm():S&&g({type:`patch`,patch:{detailOpen:!1,detailJob:null}}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[L,S]);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)(()=>fn(N.userCronJobs,v),[N.userCronJobs,v]),X=(0,Z.useMemo)(()=>fn(N.systemCronJobs,v),[N.systemCronJobs,v]),oe=(0,Z.useMemo)(()=>pn(N.runHistory,y,b,x),[N.runHistory,y,b,x]),se=n.scheduleBadge;return c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(gn,{hasToken:c,c:n,loading:N.loading,runHistoryLoading:N.runHistoryLoading,onRefresh:N.refreshAll,onOpenTemplatePicker:ne,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:[N.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:N.error}):null,(0,$.jsx)(`header`,{className:`flex flex-col gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:n.subtitle})]})}),(0,$.jsx)(Bt,{c:n,mainTab:_,onMainTabChange:j,jobSort:v,onJobSortChange:e=>g({type:`patch`,patch:{jobSort:e}}),historyRange:y,onHistoryRangeChange:e=>g({type:`patch`,patch:{historyRange:e}}),historyJobFilter:b,onHistoryJobFilterChange:e=>g({type:`patch`,patch:{historyJobFilter:e}}),historyStatusFilter:x,onHistoryStatusFilterChange:e=>g({type:`patch`,patch:{historyStatusFilter:e}}),jobs:N.jobs}),_===`myTasks`?(0,$.jsx)(nn,{c:n,localeTag:f,scheduleBadgeLabels:se,loading:N.loading,jobsCount:N.userCronJobs.length,sortedJobs:ae,templateCategoryFilter:k,onTemplateCategoryFilterChange:e=>g({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:q,keepAwake:F.keepAwake,wakeSupported:F.featureAvailable,onWakeUnsupportedClick:()=>P(n.wakeLockUnavailable),onKeepAwakeToggle:()=>F.setKeepAwake(e=>!e),absorbCardClickJobIdRef:W,scheduleAbsorbNextMenuCardClick:G,onOpenDetail:e=>void ee(e),onToggle:(e,t)=>void re(e,t),onEdit:e=>L.openForm(e),onAddJob:()=>L.openForm(),onRunNow:e=>H(`run`,e.id),onDelete:e=>H(`delete`,e.id)}):_===`systemTasks`?(0,$.jsx)(qt,{c:n,language:e,localeTag:f,scheduleBadgeLabels:se,loading:N.loading,sortedSystemJobs:X,heartbeat:N.heartbeatFromConfig,keepAwake:F.keepAwake,wakeSupported:F.featureAvailable,onWakeUnsupportedClick:()=>P(n.wakeLockUnavailable),onKeepAwakeToggle:()=>F.setKeepAwake(e=>!e),absorbCardClickJobIdRef:W,scheduleAbsorbNextMenuCardClick:G,onOpenDetail:e=>void ee(e),onToggle:(e,t)=>void re(e,t),onEdit:e=>L.openForm(e),onRunNow:e=>H(`run`,e.id),onDelete:e=>H(`delete`,e.id)}):_===`history`?(0,$.jsx)(Ut,{c:n,runHistoryLoading:N.runHistoryLoading,runHistory:N.runHistory,filteredRunHistory:oe,jobs:N.jobs,onRefreshHistory:()=>void N.loadRunHistoryOnly(),onOpenJobDetail:e=>void ee(e),statusLabels:Y}):(0,$.jsx)(ct,{hasToken:c})]}),(0,$.jsx)(Ft,{open:L.formOpen,onRequestClose:L.closeForm,c:n,chatM:r,agentsMessages:t.agentsSettings,isDark:d,channels:N.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 J(),onRefreshRecipients:L.refreshRecipientsList}),(0,$.jsx)(rn,{open:O,onOpenChange:e=>{g({type:`patch`,patch:{templatePickerOpen:e,...e?{templateCategoryFilter:`all`}:{}}})},c:n,localeTag:f,scheduleBadgeLabels:se,categoryFilter:k,onCategoryFilterChange:e=>g({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:q}),(0,$.jsx)(Ot,{open:S,onDismiss:te,detailJob:C,detailLoading:E,detailHistory:T,c:n,localeTag:f,scheduleBadgeLabels:se,chatWorkingDirNotSet:r.workingDirectory.notSet,statusLabels:Y,onEdit:e=>{te(),L.openForm(e)},onRunNow:e=>H(`run`,e.id),onToggle:(e,t)=>void re(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:ie})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(gn,{hasToken:c,c:n,loading:N.loading,runHistoryLoading:N.runHistoryLoading,onRefresh:N.refreshAll,onOpenTemplatePicker:ne,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 gn(e){let t=(0,Q.c)(13),{hasToken:n,c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}=e,l=_(vn),u=_(_n),d;t[0]!==r||t[1]!==i||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==a?(d=(0,$.jsx)(Ht,{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]!==u||t[8]!==f||t[9]!==n||t[10]!==l?(p=()=>n?(l({startExtra:null,main:null,end:f}),()=>u()):(u(),()=>u()),m=[u,f,n,l],t[7]=u,t[8]=f,t[9]=n,t[10]=l,t[11]=p,t[12]=m):(p=t[11],m=t[12]),(0,Z.useLayoutEffect)(p,m),null}function _n(e){return e.clearPageHeader}function vn(e){return e.setPageHeader}export{hn as CronPage};