@xopcai/xopc 0.0.206 → 0.0.207
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.
- package/README.md +7 -7
- package/README.zh-CN.md +7 -7
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-URW-e_me.js → activity-store-BmpM0zwM.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BLK6kRCJ.js → agent-avatar-dicebear-DhK5wi6_.js} +1 -1
- package/dist/gateway/static/root/assets/agents-Bc3Lc-n2.js +68 -0
- package/dist/gateway/static/root/assets/{api-C_MS4arC.js → api-CzaAcDOn.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CnUN6BJk.js → app-management-settings-panel-Dqj5G_cd.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-C8Nx8hZE.js → appearance-settings-Bm1uLGMi.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BKtwU47-.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-C7FqeJZD.js → archive-plugin-CgnzBplN.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DCYQgsYE.js → attachment-load-Cuybcmhn.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-ilGeRLDN.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-Bf1WROsh.js → binary-plugins-D6BBx6Ps.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BPK08Pjv.js → block-editor-Dk1c3Spa.js} +3 -3
- package/dist/gateway/static/root/assets/browser-settings-page-BCu8AZbs.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-cqVoDHyp.js → browser-workflow-inputs-DvfIzCgV.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-Des1UTsS.js → browser-workflows-page-DZScuPlF.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BbWQBtTe.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-D4MjqV2a.js → capability-presets-api-hoA8R_J1.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-BTVU46Yn.js +3 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-CcimZduy.js → channel-recipient-api-BS8I65NT.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-BEQsC9a9.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-DRwbgtOT.js +1 -0
- package/dist/gateway/static/root/assets/chat-terminal-dock-BIPhWBDI.js +36 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-B1njb2Cr.css → chat-terminal-dock-uQUnjRtf.css} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-CUvFu8jh.js → connectors-api-B_78jmvM.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-BJoHjWnu.js → connectors-page-w_3kpqbc.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-expression-hFSZZpvM.js → cron-expression-BBheaBIr.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-CKZ0gc-Y.js → date-picker-CDwj7UrT.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-zv1oHtg4.js → dependency-picker-Dnrc2qZe.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DY9ykMtD.js → desktop-pet-Bj_vUjXp.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-XiSmmt26.js → desktop-pet-settings-uiCwJJk4.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-CZkgk15r.js → directory-picker-path-field-D0zUQ-TO.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CTppsTEi.js → extension-debug-page-_GZ4y2da.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CHRTUvAa.js → extension-page-scR96Edg.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-z2UBx25A.js → extension-settings-page-CILsAwxx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-DzFPJTnm.js → gateway-config-api-984O_4wM.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-CGpoH1gU.js → gateway-config-swr-D4hvsdJA.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DBa2I6VM.js → gateway-settings-aF4eQHo3.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-Te-TREBt.js → gateway-startup-retry-Deo5-O87.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DyQGGdBu.js → heartbeat-settings-D5DrFWH6.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-EkT4eGeP.js → home-page-DiMWxngC.js} +2 -2
- package/dist/gateway/static/root/assets/{index-CrwXzRpA.js → index-DzKLVgY-.js} +47 -47
- package/dist/gateway/static/root/assets/index-wR5jX-lw.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-fb0zS8pk.js → keyboard-shortcuts-settings-DGmOlNcB.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-De8vuwu1.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-DFdheruU.js → local-apps-page-CzS2sCxg.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CieddUjx.js → locale-store-C7xtkP3D.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-BI9stsVO.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-D3PsQ612.js → management-settings-Cpxs43JB.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-x5K52Thz.js → markdown-split-CQvFHxUa.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-Cjjey5Y6.js → markdown-view-BRwrSbwM.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DNtEkRAh.js → media-plugins-Bs9MsiaM.js} +1 -1
- package/dist/gateway/static/root/assets/messages-Dxk5Rzj_.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-nWEqlwDw.js → notes-page-Dux_g6aZ.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-CGafcgJ8.js +4 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CXcIKVi9.js → preview-open-alternatives-fvhtN4Y2.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CZLJudPk.js → product-open-page-f_jbg-9N.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-Cf1v94LO.js → project-detail-page-C6mNsjYr.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-BRMZkNht.js → projects-page-D1G6VIxR.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CIez6X0x.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-RYjduQV6.js → runtime-tools-settings-panel-zapSiJrv.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form--1ZXg4qC.js → schema-form-CFyz8y5v.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-6irxQjHb.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CRb0QTG2.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-71-8j3zt.js → settings-form-section-DCiK4TIq.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-C5Jn1l0q.js → settings-loading-skeleton-DFUJEv4G.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-TYYGe6kZ.js → settings-page-Cnp9Bdd0.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-jA5I-17g.js → setup-status-panel-BFMGTGBO.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BMUQIGfk.js → share-preview-page-DA8nA4cz.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CaKfvJzQ.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BOBUcYr5.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-BzZT1SKg.js → skills-page-BJJACxzz.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-DnaBw5Ji.js → skills-page.utils--1-vOg3V.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DqiPQgVI.js → system-settings-panel-DY0lIaXY.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-Ciuwe7AG.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-BP3_RpaY.js → theme-store-DoyRfkoi.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-BJkQ-vpu.js → use-autosave-DzIR5Lxf.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-BP8-sOPi.js → user-context-page-yf18T_BZ.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-C6c8e7Mx.js → voice-api-key-field-B7MZS8tS.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CCNjWKql.js → work-discovery-overlay-zyX6yxxF.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-2e5J0sIp.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-Cj1vPWRM.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-D37zWlWY.js +5 -0
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-vWi33CZJ.js → working-directory-picker-modal-Bm7cox3y.js} +1 -1
- package/dist/gateway/static/root/index.html +10 -10
- package/dist/package.js +1 -1
- package/dist/src/agent/embedded/transcript-runtime.d.ts +2 -1
- package/dist/src/agent/embedded/transcript-runtime.js +38 -4
- package/dist/src/agent/inbound/inbound-loop.d.ts +1 -1
- package/dist/src/agent/memory/compaction-ledger.d.ts +11 -0
- package/dist/src/agent/memory/compaction-ledger.js +108 -0
- package/dist/src/agent/memory/compaction-serializer.d.ts +2 -0
- package/dist/src/agent/memory/compaction-serializer.js +52 -0
- package/dist/src/agent/memory/compaction-source-planner.d.ts +20 -0
- package/dist/src/agent/memory/compaction-source-planner.js +67 -0
- package/dist/src/agent/memory/compaction.d.ts +11 -5
- package/dist/src/agent/memory/compaction.js +245 -153
- package/dist/src/agent/prompt/sections/behavior.js +1 -1
- package/dist/src/agent/prompt/sections/memory-skills.js +4 -2
- package/dist/src/agent/prompt/sections/tooling.js +2 -0
- package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
- package/dist/src/agent/tool-manuals/xopc-use.js +1 -1
- package/dist/src/agent/tools/factory.js +5 -0
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/agent/tools/session-recall-tool.d.ts +7 -0
- package/dist/src/agent/tools/session-recall-tool.js +82 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/schema.d.ts +1 -0
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -0
- package/dist/src/gateway/service/run-gateway-agent.js +3 -3
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/session/compaction-types.d.ts +30 -0
- package/dist/src/session/compaction-types.js +35 -0
- package/dist/src/session/manager.d.ts +3 -0
- package/dist/src/session/session-context-for-llm.d.ts +4 -2
- package/dist/src/session/session-context-for-llm.js +2 -1
- package/dist/src/session/store.d.ts +10 -1
- package/dist/src/session/store.js +55 -23
- package/dist/src/session/types.d.ts +3 -2
- package/dist/src/storage/sqlite/index.d.ts +1 -1
- package/dist/src/storage/sqlite/index.js +2 -2
- package/dist/src/storage/sqlite/migrations/123_remove_v2_compaction_boundaries.sql +25 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/transcript-repository.d.ts +24 -1
- package/dist/src/storage/sqlite/transcript-repository.js +78 -29
- package/dist/src/user-context/config.d.ts +4 -0
- package/dist/src/user-context/config.js +2 -0
- package/package.json +3 -3
- package/skills/THIRD_PARTY_NOTICES.md +1 -1
- package/skills/engineering/define-task/SKILL.md +48 -0
- package/skills/engineering/define-task/references/task-contract-rubric.md +15 -0
- package/dist/gateway/static/root/assets/agents-D5HVmdNx.js +0 -68
- package/dist/gateway/static/root/assets/apps-page-DKCA_LFY.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-BEOE4ZKM.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CLRmMdU9.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BNcVi4ar.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-uFwW2ah5.js +0 -3
- package/dist/gateway/static/root/assets/channels-settings-DSLP8OjS.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-D0OR6Ylw.js +0 -1
- package/dist/gateway/static/root/assets/chat-terminal-dock-wpi7abPg.js +0 -38
- package/dist/gateway/static/root/assets/index-BpLqHdfz.css +0 -2
- package/dist/gateway/static/root/assets/local-app-workbench-page-CCC3Cvb8.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-B6jfkNDF.js +0 -2
- package/dist/gateway/static/root/assets/messages-CySMn8WL.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-QstkgWsW.js +0 -4
- package/dist/gateway/static/root/assets/remote-access-hub-D55FTXZw.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-C5Yy6eIn.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BqO_8bUh.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-Dru1a2rZ.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-C8iqS6kF.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-DQP5vDr-.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-DL_Ie0s2.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-DLO-dMSN.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-B4-k2FHB.js +0 -5
- package/dist/src/agent/memory/compaction-planner.d.ts +0 -16
- package/dist/src/agent/memory/compaction-planner.js +0 -168
- package/dist/src/agent/memory/summary-generator.d.ts +0 -46
- package/dist/src/agent/memory/summary-generator.js +0 -229
- package/skills/engineering/define-goal/SKILL.md +0 -41
- package/skills/engineering/define-goal/references/objective-rubric.md +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as a,r as o}from"./popover-select-BzdnTy3h.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./button-CSEbl4zT.js";import{a as u,o as d,r as f,s as p}from"./form-field-width-DJw_jULe.js";import{t as m}from"./messages-CySMn8WL.js";import{l as h,n as g,r as _,s as v}from"./locale-store-CieddUjx.js";import{i as y,o as b}from"./vendor-swr-BIWyz7Rc.js";import{n as x,r as S}from"./gateway-config-swr-CGpoH1gU.js";import{r as C}from"./settings-form-draft-Dy10ldo8.js";import{Ba as w,Fo as T,Hs as E,Kc as D,Mc as O,Ps as k,cl as A,ic as j}from"./index-CrwXzRpA.js";import{n as ee,r as M,t as te}from"./settings-page-layout-BRQNel6r.js";import{n as ne}from"./settings-loading-skeleton-C5Jn1l0q.js";import{n as re,t as ie}from"./use-autosave-BJkQ-vpu.js";import{t as N}from"./page-tabs-BaEQMYm_.js";import{r as ae,t as P}from"./channel-recipient-api-CcimZduy.js";import{n as oe,t as se}from"./channels-status-swr-D0OR6Ylw.js";import{n as F,o as I,t as L}from"./cron-expression-hFSZZpvM.js";import{t as R}from"./date-picker-CKZ0gc-Y.js";var z=e(t(),1),B=n();function V(){return _(`/api/workspace/heartbeat-md`)}async function ce(){let e=await v(V());return typeof e.payload?.content==`string`?e.payload.content:``}function H(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function le(e){let t=H(e)?e:{},n=H(t.gateway)?t.gateway:{},r=H(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=H(i)?i:null,o=a&&typeof a.start==`string`&&typeof a.end==`string`&&a.start&&a.end?{start:a.start,end:a.end,timezone:typeof a.timezone==`string`?a.timezone:``}:null;return{enabled:!!(r.enabled??!0),intervalMs:typeof r.intervalMs==`number`&&Number.isFinite(r.intervalMs)?r.intervalMs:18e5,includeSystemPromptSection:r.includeSystemPromptSection===!0,target:typeof r.target==`string`?r.target:``,targetChatId:typeof r.targetChatId==`string`?r.targetChatId:``,prompt:typeof r.prompt==`string`?r.prompt:``,ackMaxChars:typeof r.ackMaxChars==`number`&&Number.isFinite(r.ackMaxChars)?r.ackMaxChars:``,isolatedSession:!!r.isolatedSession,activeHours:o}}function ue(e){let t={enabled:e.enabled,intervalMs:e.intervalMs,includeSystemPromptSection:e.includeSystemPromptSection};return e.target.trim()?t.target=e.target.trim():t.target=null,e.targetChatId.trim()?t.targetChatId=e.targetChatId.trim():t.targetChatId=null,e.prompt.trim()?t.prompt=e.prompt.trim():t.prompt=null,e.ackMaxChars===``||e.ackMaxChars===void 0?t.ackMaxChars=null:t.ackMaxChars=e.ackMaxChars,e.isolatedSession?t.isolatedSession=!0:t.isolatedSession=null,e.activeHours?.start?.trim()&&e.activeHours?.end?.trim()?t.activeHours={start:e.activeHours.start.trim(),end:e.activeHours.end.trim(),...e.activeHours.timezone.trim()?{timezone:e.activeHours.timezone.trim()}:{}}:t.activeHours=null,t}async function de(e){await v(_(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:ue(e)}})}),x()}async function fe(e){await v(_(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:e})}),b(V())}async function pe(e){await v(_(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{reason:e}:{})})}var U=r(),W=Array.from({length:60},(e,t)=>t),G=c(d,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),K=c(`h-9 w-14 shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-center text-sm tabular-nums text-fg`,f),me=c(`min-h-[2.5rem] w-full rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 font-mono text-xs text-fg`,f);function he(e){return{...e,intervalMinutesDraft:null,intervalHoursDraft:null}}function q(e){let{intervalMinutesDraft:t,intervalHoursDraft:n,...r}=e;return r}function ge(e,t){switch(t.type){case`reset`:return he(t.state);case`replace`:return t.state}}function J({value:e,onChange:t,labels:n,disabled:r,showHeading:i=!0}){let s=(0,z.useMemo)(()=>F(e),[e]),[l,u]=(0,z.useReducer)(ge,s,he),d=(0,z.useRef)(e);d.current!==e&&(d.current=e,u({type:`reset`,state:s}));let f=(0,z.useCallback)(e=>{let n={...l,...e};u({type:`replace`,state:n});let r=q(n),i=q(l);Object.keys(r).some(e=>r[e]!==i[e])&&t(L(r))},[t,l]),{mode:p,intervalKind:m,onceDate:h,intervalMinutes:g,intervalHours:_,minute:v,hour:y,weekDays:b,dayOfMonth:x,rawCron:S,intervalMinutesDraft:C,intervalHoursDraft:w}=l,T=`${String(y).padStart(2,`0`)}:${String(v).padStart(2,`0`)}`,E=e=>{if(!e)return;let[t,n]=e.split(`:`).map(e=>parseInt(e,10));Number.isNaN(t)||Number.isNaN(n)||f({minute:n,hour:t})},D=(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,U.jsxs)(a,{className:G,disabled:r,value:p,onChange:e=>{let t=e.target.value;f({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,U.jsx)(o,{value:`no_repeat`,children:n.modeNoRepeat}),(0,U.jsx)(o,{value:`interval`,children:n.modeInterval}),(0,U.jsx)(o,{value:`hourly`,children:n.modeHourly}),(0,U.jsx)(o,{value:`daily`,children:n.modeDaily}),(0,U.jsx)(o,{value:`weekly`,children:n.modeWeekly}),(0,U.jsx)(o,{value:`monthly`,children:n.modeMonthly}),(0,U.jsx)(o,{value:`custom`,children:n.modeCustom})]}),p===`no_repeat`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(R,{disabled:r,className:`h-9 min-w-[9.5rem] shrink-0 bg-surface-panel px-2`,value:h,onChange:e=>f({onceDate:e}),ariaLabel:n.modeNoRepeat}),(0,U.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),p===`interval`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(a,{className:c(G,`w-auto min-w-[5rem]`),disabled:r,value:m,onChange:e=>{let t=e.target.value;f({intervalKind:t,intervalMinutesDraft:null,intervalHoursDraft:null})},"aria-label":n.modeInterval,children:[(0,U.jsx)(o,{value:`minutes`,children:n.intervalKindMinutes}),(0,U.jsx)(o,{value:`hours`,children:n.intervalKindHours})]}),m===`minutes`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{type:`number`,min:1,max:59,disabled:r,className:K,value:C??String(g),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalMinutesDraft:t};Number.isFinite(n)&&n>=1&&n<=59&&(r.intervalMinutes=n),f(r)},onBlur:()=>{if(C===null)return;let e=parseInt(C,10);f({intervalMinutes:!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e))),intervalMinutesDraft:null})},"aria-label":n.intervalMinutes}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{type:`number`,min:1,max:23,disabled:r,className:K,value:w??String(_),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalHoursDraft:t};Number.isFinite(n)&&n>=1&&n<=23&&(r.intervalHours=n),f(r)},onBlur:()=>{if(w===null)return;let e=parseInt(w,10);f({intervalHours:!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e))),intervalHoursDraft:null})},"aria-label":n.intervalHours}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,U.jsx)(a,{className:c(G,`w-auto min-w-[4rem]`),disabled:r,value:v,onChange:e=>{f({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:W.map(e=>(0,U.jsx)(o,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),p===`daily`&&(0,U.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),p===`weekly`&&(0,U.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),p===`monthly`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(a,{className:c(G,`w-auto min-w-[4.5rem]`),disabled:r,value:x,onChange:e=>{f({dayOfMonth:parseInt(e.target.value,10)})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,U.jsx)(o,{value:e,children:e},e))}),(0,U.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),p===`hourly`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(a,{className:c(G,`w-auto min-w-[4rem]`),disabled:r,value:v,onChange:e=>{f({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:W.map(e=>(0,U.jsx)(o,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),O=p===`weekly`?(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,role:`group`,"aria-label":n.modeWeekly,children:n.weekdays.map((e,t)=>{let n=b[t];return(0,U.jsx)(`button`,{type:`button`,disabled:r,className:c(`flex size-9 select-none items-center justify-center rounded-full border text-xs font-medium transition-colors`,n?`border-fg bg-fg text-surface-panel`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),"aria-pressed":n,onClick:()=>{let e=[...b];e[t]=!e[t],f({weekDays:e})},children:e},e)})}):null,k=p===`custom`?(0,U.jsxs)(`div`,{className:`pt-1`,children:[(0,U.jsx)(`textarea`,{disabled:r,className:me,rows:2,spellCheck:!1,value:S,placeholder:`*/5 * * * *`,onChange:e=>{f({rawCron:e.target.value})},"aria-label":n.modeCustom}),(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i?(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}):null,D,O,k]})}var Y=[3e4,6e4,3e5,6e5,9e5,18e5,36e5,72e5];new Set(Y);var _e=c(`h-9 min-w-0 flex-1 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm tabular-nums text-fg`,f),ve=c(d,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function X(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return String(e)}}function ye({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=Y,minSeconds:s=1}){let c=(0,z.useMemo)(()=>new Set(i),[i]),l=(0,z.useMemo)(()=>c.has(e)?String(e):``,[c,e]),[u,d]=(0,z.useState)(null),f=(0,z.useRef)(e);f.current!==e&&(f.current=e,d(null));let p=Math.max(s,Math.round(e/1e3)),m=u===null?String(p):u;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`input`,{type:`number`,min:s,step:1,disabled:r,className:_e,value:m,onChange:e=>{let n=e.target.value;d(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=s&&t(r*1e3)},onBlur:()=>{if(u===null)return;let e=parseInt(u,10);t(!Number.isFinite(e)||e<s?s*1e3:e*1e3),d(null)}}),(0,U.jsxs)(a,{className:ve,disabled:r,value:l,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),d(null))},children:[(0,U.jsx)(o,{value:``,children:n.presets.custom}),i.map(e=>(0,U.jsx)(o,{value:String(e),children:X(e,n.presets)},e))]})]})]})}var be=c(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,f),xe=()=>({start:`09:00`,end:`22:00`,timezone:``});function Se(e){let t=(0,B.c)(57),{value:n,onChange:r,labels:i,disabled:a}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(xe()),t[0]=r,t[1]=e);let n;return t[2]!==a||t[3]!==i.add||t[4]!==e?(n=(0,U.jsx)(l,{type:`button`,variant:`secondary`,className:`text-sm`,disabled:a,onClick:e,children:i.add}),t[2]=a,t[3]=i.add,t[4]=e,t[5]=n):n=t[5],n}let o;t[6]===i.start?o=t[7]:(o=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=o);let s;t[8]!==r||t[9]!==n?(s=e=>r({...n,start:e}),t[8]=r,t[9]=n,t[10]=s):s=t[10];let c;t[11]!==a||t[12]!==i.start||t[13]!==s||t[14]!==n.start?(c=(0,U.jsx)(I,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.start,onChange:s,ariaLabel:i.start}),t[11]=a,t[12]=i.start,t[13]=s,t[14]=n.start,t[15]=c):c=t[15];let u;t[16]!==o||t[17]!==c?(u=(0,U.jsxs)(`label`,{className:`block min-w-0`,children:[o,c]}),t[16]=o,t[17]=c,t[18]=u):u=t[18];let d;t[19]===i.end?d=t[20]:(d=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[19]=i.end,t[20]=d);let f;t[21]!==r||t[22]!==n?(f=e=>r({...n,end:e}),t[21]=r,t[22]=n,t[23]=f):f=t[23];let p;t[24]!==a||t[25]!==i.end||t[26]!==f||t[27]!==n.end?(p=(0,U.jsx)(I,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.end,onChange:f,ariaLabel:i.end}),t[24]=a,t[25]=i.end,t[26]=f,t[27]=n.end,t[28]=p):p=t[28];let m;t[29]!==d||t[30]!==p?(m=(0,U.jsxs)(`label`,{className:`block min-w-0`,children:[d,p]}),t[29]=d,t[30]=p,t[31]=m):m=t[31];let h;t[32]===i.timezone?h=t[33]:(h=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[32]=i.timezone,t[33]=h);let g;t[34]!==r||t[35]!==n?(g=e=>r({...n,timezone:e.target.value}),t[34]=r,t[35]=n,t[36]=g):g=t[36];let _;t[37]!==a||t[38]!==g||t[39]!==n.timezone?(_=(0,U.jsx)(`input`,{type:`text`,disabled:a,className:be,value:n.timezone,onChange:g,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[37]=a,t[38]=g,t[39]=n.timezone,t[40]=_):_=t[40];let v;t[41]!==_||t[42]!==h?(v=(0,U.jsxs)(`label`,{className:`block min-w-0`,children:[h,_]}),t[41]=_,t[42]=h,t[43]=v):v=t[43];let y;t[44]!==v||t[45]!==u||t[46]!==m?(y=(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,m,v]}),t[44]=v,t[45]=u,t[46]=m,t[47]=y):y=t[47];let b;t[48]===r?b=t[49]:(b=()=>r(null),t[48]=r,t[49]=b);let x;t[50]!==a||t[51]!==i.clear||t[52]!==b?(x=(0,U.jsx)(l,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:a,onClick:b,children:i.clear}),t[50]=a,t[51]=i.clear,t[52]=b,t[53]=x):x=t[53];let S;return t[54]!==y||t[55]!==x?(S=(0,U.jsxs)(`div`,{className:`space-y-2`,children:[y,x]}),t[54]=y,t[55]=x,t[56]=S):S=t[56],S}function Z(e){let t=(0,B.c)(34),{disabled:n,label:r,hint:i,className:a}=e,o;t[0]===a?o=t[1]:(o=c(`flex flex-col gap-2`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=r?(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r}):null,t[2]=r,t[3]=s);let l;t[4]!==n||t[5]!==r||t[6]!==e.kind||t[7]!==e.labels||t[8]!==e.onChange||t[9]!==e.value?(l=e.kind===`cron`?(0,U.jsx)(J,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n,showHeading:!r}):null,t[4]=n,t[5]=r,t[6]=e.kind,t[7]=e.labels,t[8]=e.onChange,t[9]=e.value,t[10]=l):l=t[10];let u;t[11]!==n||t[12]!==e.kind||t[13]!==e.labels||t[14]!==e.minSeconds||t[15]!==e.onChangeMs||t[16]!==e.presets||t[17]!==e.valueMs?(u=e.kind===`interval`?(0,U.jsx)(ye,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??Y,minSeconds:e.minSeconds}):null,t[11]=n,t[12]=e.kind,t[13]=e.labels,t[14]=e.minSeconds,t[15]=e.onChangeMs,t[16]=e.presets,t[17]=e.valueMs,t[18]=u):u=t[18];let d;t[19]!==n||t[20]!==e.kind||t[21]!==e.labels||t[22]!==e.onChange||t[23]!==e.value?(d=e.kind===`active-hours`?(0,U.jsx)(Se,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n}):null,t[19]=n,t[20]=e.kind,t[21]=e.labels,t[22]=e.onChange,t[23]=e.value,t[24]=d):d=t[24];let f;t[25]===i?f=t[26]:(f=i?(0,U.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}):null,t[25]=i,t[26]=f);let p;return t[27]!==o||t[28]!==s||t[29]!==l||t[30]!==u||t[31]!==d||t[32]!==f?(p=(0,U.jsxs)(`div`,{className:o,children:[s,l,u,d,f]}),t[27]=o,t[28]=s,t[29]=l,t[30]=u,t[31]=d,t[32]=f,t[33]=p):p=t[33],p}function Ce(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,p,`dark:border-edge`)}function we(){return c(d,u)}var Te=[`schedule`,`delivery`,`prompt`,`document`],Q={schedule:A,delivery:j,prompt:O,document:D};function Ee(e){return e&&Te.includes(e)?e:`schedule`}function De(e,t){return t===`schedule`?e.tabSchedule:t===`delivery`?e.tabDelivery:t===`prompt`?e.tabPrompt:e.tabDocument}function Oe(e,t){return t===`schedule`?e.scheduleTabHint:t===`delivery`?e.deliveryTabHint:t===`prompt`?e.promptTabHint:e.documentTabHint}function ke(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`saved`:{let n=structuredClone(t.value);return{form:e.form&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function Ae(e,t){switch(t.type){case`reset`:return{doc:``,baseline:``};case`sync`:return{doc:t.value,baseline:t.value};case`set`:return{...e,doc:t.value};case`saved`:return{doc:e.doc===t.value?t.value:e.doc,baseline:t.value}}}function je(e){if(!e||typeof e!=`object`||Array.isArray(e))return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t;if(!Array.isArray(n.list))return``;let r=typeof n.default==`string`?n.default:``,i=n.list.find(e=>!e||typeof e!=`object`||Array.isArray(e)?!1:r?e.id===r:!0)??n.list[0];if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.workspace;if(!a||typeof a!=`object`||Array.isArray(a))return``;let o=a.root;return typeof o==`string`?o:``}var Me={triggerLoading:!1,triggerOk:!1,triggerError:null};function Ne(){let e=g(e=>e.language),t=m(e),n=t.heartbeatSettings,r=!!h(e=>e.token),[a,o]=i(),u=Ee(a.get(`tab`)),d=(0,z.useCallback)(e=>{o(t=>{let n=new URLSearchParams(t);return e===`schedule`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[o]),[f,p]=(0,z.useReducer)(ke,{form:null,baseline:null}),_=f.form,v=f.baseline,[b,x]=(0,z.useReducer)(Ae,{doc:``,baseline:``}),D=b.doc,O=b.baseline,[k,A]=(0,z.useReducer)(C,Me),{triggerLoading:j,triggerOk:te,triggerError:N}=k,P=(0,z.useRef)(!1),F=(0,z.useRef)(!1),I=(0,z.useRef)(_),L=(0,z.useRef)(D);I.current=_,L.current=D;let{data:R,error:B,isLoading:H,mutate:ue}=S(r),{data:W,error:G,isLoading:K,mutate:me}=y(r?V():null,ce,{revalidateOnFocus:!1}),{data:he=[]}=y(r?se():null,oe,{revalidateOnFocus:!1}),q=(0,z.useMemo)(()=>je(R?.payload?.config),[R]),ge=(0,z.useMemo)(()=>le(R?.payload?.config??{}),[R]),J=(0,z.useMemo)(()=>!_||!v?!1:JSON.stringify(_)!==JSON.stringify(v),[_,v]),Y=D!==O;(0,z.useEffect)(()=>{if(!r){p({type:`reset`}),P.current=!1;return}R!==void 0&&(P.current||p({type:`sync`,value:ge}))},[r,R,ge]),(0,z.useEffect)(()=>{if(!r){x({type:`reset`}),F.current=!1;return}W!==void 0&&(F.current||x({type:`sync`,value:W}))},[r,W]);let _e=B instanceof Error?B.message:B?String(B):G instanceof Error?G.message:G?String(G):null,ve=!!(r&&(R===void 0||W===void 0)&&!_e&&(H||K)),X=_?.target.trim()??``,{data:ye,setData:be}=w(()=>ae(X),[r,X],{enabled:r&&X.length>0,initial:[],errorData:[]}),xe=(0,z.useCallback)(()=>{X&&ae(X).then(be)},[X,be]),Se=(0,z.useCallback)(async()=>{A({type:`patch`,patch:{triggerLoading:!0,triggerOk:!1,triggerError:null}});try{await pe(),A({type:`patch`,patch:{triggerOk:!0}}),window.setTimeout(()=>A({type:`patch`,patch:{triggerOk:!1}}),3e3)}catch(e){A({type:`patch`,patch:{triggerError:e instanceof Error?e.message:n.triggerError}})}finally{A({type:`patch`,patch:{triggerLoading:!1}})}},[n.triggerError]),Z=(0,z.useCallback)(e=>{P.current=!0,p({type:`patch`,patch:e})},[]),Te=J||Y,Q=ie({value:(0,z.useMemo)(()=>_?{form:_,doc:D,saveConfig:J,saveDoc:Y}:null,[J,Y,D,_]),dirty:Te,onSave:(0,z.useCallback)(async e=>{try{e.saveConfig&&(await de(e.form),p({type:`saved`,value:e.form}),P.current=!!(I.current&&JSON.stringify(I.current)!==JSON.stringify(e.form))),e.saveDoc&&(await fe(e.doc),x({type:`saved`,value:e.doc}),F.current=L.current!==e.doc)}catch(t){throw Error(t instanceof Error?t.message:e.saveConfig?n.saveConfigError:n.saveDocError)}},[n.saveConfigError,n.saveDocError]),delayMs:Y?900:500});return r?ve?(0,U.jsx)(M,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,U.jsx)(ne,{sections:3})}):_?(0,U.jsxs)(M,{"aria-busy":Q.status===`saving`,"data-has-baseline":v?`1`:`0`,onBlurCapture:Q.onBlurCapture,children:[(0,U.jsx)(ee,{title:t.settingsSections.heartbeat,subtitle:n.subtitle,docsLink:T(e,`heartbeat`),docsLabel:n.docsLink,actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(re,{status:Q.status,error:Q.error}),(0,U.jsxs)(l,{type:`button`,variant:`secondary`,className:`inline-flex items-center gap-2`,disabled:j,onClick:()=>void Se(),children:[j?(0,U.jsx)(s,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,U.jsx)(E,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),j?n.triggering:n.triggerNow]}),te?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.triggered}):null]})}),q?(0,U.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.workspaceLabel,`: `,(0,U.jsx)(`span`,{className:`font-mono text-fg-muted`,children:q})]}):null,Q.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:Q.error}):null,N?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:N}):null,(0,U.jsx)(Pe,{h:n,activeTab:u,onChange:d}),(0,U.jsx)($,{h:n,id:`schedule`,activeTab:u,children:(0,U.jsx)(Fe,{h:n,form:_,update:Z})}),(0,U.jsx)($,{h:n,id:`delivery`,activeTab:u,children:(0,U.jsx)(Ie,{h:n,cron:t.cron,form:_,channels:he,sessionChatIds:ye,onRefreshChatIds:xe,update:Z,inputClassName:Ce,selectClassName:we})}),(0,U.jsx)($,{h:n,id:`prompt`,activeTab:u,children:(0,U.jsx)(ze,{h:n,form:_,update:Z,inputClassName:Ce})}),(0,U.jsxs)($,{h:n,id:`document`,activeTab:u,children:[(0,U.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:n.docHint}),(0,U.jsx)(`textarea`,{className:c(Ce(),`min-h-72 resize-y font-mono text-xs leading-relaxed`),value:D,onChange:e=>{F.current=!0,x({type:`set`,value:e.target.value})},spellCheck:!1,"aria-label":n.docSection,"data-doc-in-sync":D===O?`true`:`false`})]})]}):(0,U.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_e??n.loadError}),(0,U.jsx)(l,{type:`button`,variant:`secondary`,onClick:()=>{ue(),me()},children:n.retry})]}):(0,U.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(ee,{title:t.settingsSections.heartbeat}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Pe(e){let t=(0,B.c)(7),{h:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Te.map(e=>({id:e,label:De(n,e),icon:Q[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==n.tabsAriaLabel||t[4]!==o||t[5]!==i?(s=(0,U.jsx)(N,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`}),t[2]=r,t[3]=n.tabsAriaLabel,t[4]=o,t[5]=i,t[6]=s):s=t[6],s}function $(e){let t=(0,B.c)(14),{h:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=De(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Oe(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,U.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,U.jsx)(te,{id:r,activeTab:i,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`,title:o,hint:s,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Fe(e){let t=(0,B.c)(37),{h:n,form:r,update:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.enable||t[6]!==o?(s=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.enable]}),t[5]=n.enable,t[6]=o,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=e=>i({intervalMs:e}),t[8]=i,t[9]=c);let l;t[10]!==n.intervalPresets||t[11]!==n.intervalSecondsLabel?(l={secondsLabel:n.intervalSecondsLabel,presets:n.intervalPresets},t[10]=n.intervalPresets,t[11]=n.intervalSecondsLabel,t[12]=l):l=t[12];let u=`${n.intervalHintPreset} ${n.intervalHint}`,d;t[13]!==r.intervalMs||t[14]!==n.interval||t[15]!==c||t[16]!==l||t[17]!==u?(d=(0,U.jsx)(Z,{kind:`interval`,label:n.interval,valueMs:r.intervalMs,onChangeMs:c,labels:l,hint:u}),t[13]=r.intervalMs,t[14]=n.interval,t[15]=c,t[16]=l,t[17]=u,t[18]=d):d=t[18];let f;t[19]===i?f=t[20]:(f=e=>i({activeHours:e}),t[19]=i,t[20]=f);let p;t[21]!==n.activeEnd||t[22]!==n.activeStart||t[23]!==n.activeTimezone||t[24]!==n.addActiveHours||t[25]!==n.clearActiveHours?(p={start:n.activeStart,end:n.activeEnd,timezone:n.activeTimezone,add:n.addActiveHours,clear:n.clearActiveHours},t[21]=n.activeEnd,t[22]=n.activeStart,t[23]=n.activeTimezone,t[24]=n.addActiveHours,t[25]=n.clearActiveHours,t[26]=p):p=t[26];let m;t[27]!==r.activeHours||t[28]!==n.activeHoursHint||t[29]!==n.activeHoursTitle||t[30]!==f||t[31]!==p?(m=(0,U.jsx)(Z,{kind:`active-hours`,label:n.activeHoursTitle,value:r.activeHours,onChange:f,labels:p,hint:n.activeHoursHint}),t[27]=r.activeHours,t[28]=n.activeHoursHint,t[29]=n.activeHoursTitle,t[30]=f,t[31]=p,t[32]=m):m=t[32];let h;return t[33]!==m||t[34]!==s||t[35]!==d?(h=(0,U.jsxs)(U.Fragment,{children:[s,d,m]}),t[33]=m,t[34]=s,t[35]=d,t[36]=h):h=t[36],h}function Ie(e){let t=(0,B.c)(51),{h:n,cron:r,form:i,channels:s,sessionChatIds:u,onRefreshChatIds:d,update:f,inputClassName:p,selectClassName:m}=e,h;t[0]===s?h=t[1]:(h=new Set(s.map(Re)),t[0]=s,t[1]=h);let g=h,_;t[2]===i.target?_=t[3]:(_=i.target.trim(),t[2]=i.target,t[3]=_);let v=_,y=!!(v&&!g.has(v)),b;t[4]===n.deliveryHint?b=t[5]:(b=(0,U.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.deliveryHint}),t[4]=n.deliveryHint,t[5]=b);let x;t[6]===r.channel?x=t[7]:(x=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.channel}),t[6]=r.channel,t[7]=x);let S;t[8]===m?S=t[9]:(S=m(),t[8]=m,t[9]=S);let C;t[10]===f?C=t[11]:(C=e=>{f({target:e.target.value.trim(),targetChatId:``})},t[10]=f,t[11]=C);let w;t[12]===n.channelNone?w=t[13]:(w=(0,U.jsx)(o,{value:``,children:n.channelNone}),t[12]=n.channelNone,t[13]=w);let T;t[14]!==n.customChannelSuffix||t[15]!==y||t[16]!==v?(T=y?(0,U.jsxs)(o,{value:v,children:[v,` (`,n.customChannelSuffix,`)`]}):null,t[14]=n.customChannelSuffix,t[15]=y,t[16]=v,t[17]=T):T=t[17];let E;t[18]===s?E=t[19]:(E=s.map(Le),t[18]=s,t[19]=E);let D;t[20]!==S||t[21]!==C||t[22]!==w||t[23]!==T||t[24]!==E||t[25]!==v?(D=(0,U.jsxs)(a,{className:S,value:v,onChange:C,children:[w,T,E]}),t[20]=S,t[21]=C,t[22]=w,t[23]=T,t[24]=E,t[25]=v,t[26]=D):D=t[26];let O;t[27]!==D||t[28]!==x?(O=(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[x,D]}),t[27]=D,t[28]=x,t[29]=O):O=t[29];let A;t[30]!==r.enterManuallyOrSelect||t[31]!==r.lastActiveLabels||t[32]!==r.noRecentChats||t[33]!==r.noRecentChatsOption||t[34]!==r.recipient||t[35]!==r.recipientPlaceholder||t[36]!==r.refreshList||t[37]!==r.refreshRecipientHint||t[38]!==r.selectRecipient||t[39]!==i.targetChatId||t[40]!==p||t[41]!==d||t[42]!==m||t[43]!==u||t[44]!==v||t[45]!==f?(A=v?(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.recipient}),(0,U.jsxs)(l,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:r.refreshRecipientHint,onClick:d,children:[(0,U.jsx)(k,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),r.refreshList]})]}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`input`,{type:`text`,className:c(p(),`min-w-0 flex-1`),value:i.targetChatId,onChange:e=>f({targetChatId:e.target.value}),placeholder:r.recipientPlaceholder,autoComplete:`off`}),(0,U.jsxs)(a,{className:c(m(),`max-w-40 shrink-0 text-xs`),value:i.targetChatId,onChange:e=>{let t=e.target.value;t&&f({targetChatId:t})},children:[(0,U.jsx)(o,{value:``,children:r.selectRecipient}),u.length>0?u.map(e=>(0,U.jsx)(o,{value:e.chatId,children:P(e,r.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,U.jsx)(o,{value:``,disabled:!0,children:r.noRecentChatsOption})]})]}),(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:u.length>0?r.enterManuallyOrSelect:r.noRecentChats})]}):null,t[30]=r.enterManuallyOrSelect,t[31]=r.lastActiveLabels,t[32]=r.noRecentChats,t[33]=r.noRecentChatsOption,t[34]=r.recipient,t[35]=r.recipientPlaceholder,t[36]=r.refreshList,t[37]=r.refreshRecipientHint,t[38]=r.selectRecipient,t[39]=i.targetChatId,t[40]=p,t[41]=d,t[42]=m,t[43]=u,t[44]=v,t[45]=f,t[46]=A):A=t[46];let j;return t[47]!==O||t[48]!==A||t[49]!==b?(j=(0,U.jsxs)(U.Fragment,{children:[b,O,A]}),t[47]=O,t[48]=A,t[49]=b,t[50]=j):j=t[50],j}function Le(e){return(0,U.jsxs)(o,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Re(e){return e.name}function ze(e){let t=(0,B.c)(65),{h:n,form:r,update:i,inputClassName:a}=e,o;t[0]===i?o=t[1]:(o=e=>i({includeSystemPromptSection:e.target.checked}),t[0]=i,t[1]=o);let s;t[2]!==r.includeSystemPromptSection||t[3]!==o?(s=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.includeSystemPromptSection,onChange:o}),t[2]=r.includeSystemPromptSection,t[3]=o,t[4]=s):s=t[4];let l;t[5]===n.includeSystemPromptSectionHint?l=t[6]:(l=(0,U.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.includeSystemPromptSectionHint}),t[5]=n.includeSystemPromptSectionHint,t[6]=l);let u;t[7]!==n.includeSystemPromptSection||t[8]!==l?(u=(0,U.jsxs)(`span`,{children:[n.includeSystemPromptSection,l]}),t[7]=n.includeSystemPromptSection,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==s||t[11]!==u?(d=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[10]=s,t[11]=u,t[12]=d):d=t[12];let f;t[13]===n.prompt?f=t[14]:(f=(0,U.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.prompt}),t[13]=n.prompt,t[14]=f);let p;t[15]===a?p=t[16]:(p=c(a(),`min-h-36 resize-y font-mono text-xs`),t[15]=a,t[16]=p);let m;t[17]===i?m=t[18]:(m=e=>i({prompt:e.target.value}),t[17]=i,t[18]=m);let h;t[19]!==r.prompt||t[20]!==n.promptPlaceholder||t[21]!==p||t[22]!==m?(h=(0,U.jsx)(`textarea`,{className:p,value:r.prompt,onChange:m,placeholder:n.promptPlaceholder}),t[19]=r.prompt,t[20]=n.promptPlaceholder,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]===n.promptHint?g=t[25]:(g=(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.promptHint}),t[24]=n.promptHint,t[25]=g);let _;t[26]!==g||t[27]!==f||t[28]!==h?(_=(0,U.jsxs)(`div`,{children:[f,h,g]}),t[26]=g,t[27]=f,t[28]=h,t[29]=_):_=t[29];let v;t[30]===n.ackMaxChars?v=t[31]:(v=(0,U.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.ackMaxChars}),t[30]=n.ackMaxChars,t[31]=v);let y;t[32]===a?y=t[33]:(y=a(),t[32]=a,t[33]=y);let b=r.ackMaxChars===``?``:r.ackMaxChars,x;t[34]===i?x=t[35]:(x=e=>{let t=e.target.value;if(t===``){i({ackMaxChars:``});return}let n=parseInt(t,10);i({ackMaxChars:Number.isFinite(n)?n:``})},t[34]=i,t[35]=x);let S;t[36]!==n.ackDefaultPlaceholder||t[37]!==y||t[38]!==b||t[39]!==x?(S=(0,U.jsx)(`input`,{type:`number`,min:1,className:y,value:b,onChange:x,placeholder:n.ackDefaultPlaceholder}),t[36]=n.ackDefaultPlaceholder,t[37]=y,t[38]=b,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n.ackMaxCharsHint?C=t[42]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.ackMaxCharsHint}),t[41]=n.ackMaxCharsHint,t[42]=C);let w;t[43]!==v||t[44]!==S||t[45]!==C?(w=(0,U.jsxs)(`div`,{children:[v,S,C]}),t[43]=v,t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]===i?T=t[48]:(T=e=>i({isolatedSession:e.target.checked}),t[47]=i,t[48]=T);let E;t[49]!==r.isolatedSession||t[50]!==T?(E=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.isolatedSession,onChange:T}),t[49]=r.isolatedSession,t[50]=T,t[51]=E):E=t[51];let D;t[52]===n.isolatedSessionHint?D=t[53]:(D=(0,U.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.isolatedSessionHint}),t[52]=n.isolatedSessionHint,t[53]=D);let O;t[54]!==n.isolatedSession||t[55]!==D?(O=(0,U.jsxs)(`span`,{children:[n.isolatedSession,D]}),t[54]=n.isolatedSession,t[55]=D,t[56]=O):O=t[56];let k;t[57]!==E||t[58]!==O?(k=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[E,O]}),t[57]=E,t[58]=O,t[59]=k):k=t[59];let A;return t[60]!==_||t[61]!==w||t[62]!==k||t[63]!==d?(A=(0,U.jsxs)(U.Fragment,{children:[d,_,w,k]}),t[60]=_,t[61]=w,t[62]=k,t[63]=d,t[64]=A):A=t[64],A}export{Ne as HeartbeatSettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as a,r as o}from"./popover-select-BzdnTy3h.js";import{t as s}from"./loader-circle-CifKLtgG.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./button-CSEbl4zT.js";import{a as u,o as d,r as f,s as p}from"./form-field-width-DJw_jULe.js";import{t as m}from"./messages-Dxk5Rzj_.js";import{l as h,n as g,r as _,s as v}from"./locale-store-C7xtkP3D.js";import{i as y,o as b}from"./vendor-swr-BIWyz7Rc.js";import{n as x,r as S}from"./gateway-config-swr-D4hvsdJA.js";import{r as C}from"./settings-form-draft-Dy10ldo8.js";import{Ba as w,Fo as T,Hs as E,Kc as D,Mc as O,Ps as k,ic as A,sl as j}from"./index-DzKLVgY-.js";import{n as ee,r as M,t as te}from"./settings-page-layout-BRQNel6r.js";import{n as ne}from"./settings-loading-skeleton-DFUJEv4G.js";import{n as re,t as ie}from"./use-autosave-DzIR5Lxf.js";import{t as N}from"./page-tabs-BaEQMYm_.js";import{r as ae,t as P}from"./channel-recipient-api-BS8I65NT.js";import{n as oe,t as se}from"./channels-status-swr-DRwbgtOT.js";import{n as F,o as I,t as L}from"./cron-expression-BBheaBIr.js";import{t as R}from"./date-picker-CDwj7UrT.js";var z=e(t(),1),B=n();function V(){return _(`/api/workspace/heartbeat-md`)}async function ce(){let e=await v(V());return typeof e.payload?.content==`string`?e.payload.content:``}function H(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function le(e){let t=H(e)?e:{},n=H(t.gateway)?t.gateway:{},r=H(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=H(i)?i:null,o=a&&typeof a.start==`string`&&typeof a.end==`string`&&a.start&&a.end?{start:a.start,end:a.end,timezone:typeof a.timezone==`string`?a.timezone:``}:null;return{enabled:!!(r.enabled??!0),intervalMs:typeof r.intervalMs==`number`&&Number.isFinite(r.intervalMs)?r.intervalMs:18e5,includeSystemPromptSection:r.includeSystemPromptSection===!0,target:typeof r.target==`string`?r.target:``,targetChatId:typeof r.targetChatId==`string`?r.targetChatId:``,prompt:typeof r.prompt==`string`?r.prompt:``,ackMaxChars:typeof r.ackMaxChars==`number`&&Number.isFinite(r.ackMaxChars)?r.ackMaxChars:``,isolatedSession:!!r.isolatedSession,activeHours:o}}function ue(e){let t={enabled:e.enabled,intervalMs:e.intervalMs,includeSystemPromptSection:e.includeSystemPromptSection};return e.target.trim()?t.target=e.target.trim():t.target=null,e.targetChatId.trim()?t.targetChatId=e.targetChatId.trim():t.targetChatId=null,e.prompt.trim()?t.prompt=e.prompt.trim():t.prompt=null,e.ackMaxChars===``||e.ackMaxChars===void 0?t.ackMaxChars=null:t.ackMaxChars=e.ackMaxChars,e.isolatedSession?t.isolatedSession=!0:t.isolatedSession=null,e.activeHours?.start?.trim()&&e.activeHours?.end?.trim()?t.activeHours={start:e.activeHours.start.trim(),end:e.activeHours.end.trim(),...e.activeHours.timezone.trim()?{timezone:e.activeHours.timezone.trim()}:{}}:t.activeHours=null,t}async function de(e){await v(_(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:ue(e)}})}),x()}async function fe(e){await v(_(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:e})}),b(V())}async function pe(e){await v(_(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{reason:e}:{})})}var U=r(),W=Array.from({length:60},(e,t)=>t),G=c(d,`min-w-0 shrink text-xs sm:min-w-[7rem] sm:max-w-[11rem]`),K=c(`h-9 w-14 shrink-0 rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1.5 text-center text-sm tabular-nums text-fg`,f),me=c(`min-h-[2.5rem] w-full rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 font-mono text-xs text-fg`,f);function he(e){return{...e,intervalMinutesDraft:null,intervalHoursDraft:null}}function q(e){let{intervalMinutesDraft:t,intervalHoursDraft:n,...r}=e;return r}function ge(e,t){switch(t.type){case`reset`:return he(t.state);case`replace`:return t.state}}function J({value:e,onChange:t,labels:n,disabled:r,showHeading:i=!0}){let s=(0,z.useMemo)(()=>F(e),[e]),[l,u]=(0,z.useReducer)(ge,s,he),d=(0,z.useRef)(e);d.current!==e&&(d.current=e,u({type:`reset`,state:s}));let f=(0,z.useCallback)(e=>{let n={...l,...e};u({type:`replace`,state:n});let r=q(n),i=q(l);Object.keys(r).some(e=>r[e]!==i[e])&&t(L(r))},[t,l]),{mode:p,intervalKind:m,onceDate:h,intervalMinutes:g,intervalHours:_,minute:v,hour:y,weekDays:b,dayOfMonth:x,rawCron:S,intervalMinutesDraft:C,intervalHoursDraft:w}=l,T=`${String(y).padStart(2,`0`)}:${String(v).padStart(2,`0`)}`,E=e=>{if(!e)return;let[t,n]=e.split(`:`).map(e=>parseInt(e,10));Number.isNaN(t)||Number.isNaN(n)||f({minute:n,hour:t})},D=(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto pb-0.5`,children:[(0,U.jsxs)(a,{className:G,disabled:r,value:p,onChange:e=>{let t=e.target.value;f({mode:t})},"aria-label":n.scheduleTimeLabel,children:[(0,U.jsx)(o,{value:`no_repeat`,children:n.modeNoRepeat}),(0,U.jsx)(o,{value:`interval`,children:n.modeInterval}),(0,U.jsx)(o,{value:`hourly`,children:n.modeHourly}),(0,U.jsx)(o,{value:`daily`,children:n.modeDaily}),(0,U.jsx)(o,{value:`weekly`,children:n.modeWeekly}),(0,U.jsx)(o,{value:`monthly`,children:n.modeMonthly}),(0,U.jsx)(o,{value:`custom`,children:n.modeCustom})]}),p===`no_repeat`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(R,{disabled:r,className:`h-9 min-w-[9.5rem] shrink-0 bg-surface-panel px-2`,value:h,onChange:e=>f({onceDate:e}),ariaLabel:n.modeNoRepeat}),(0,U.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),p===`interval`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(a,{className:c(G,`w-auto min-w-[5rem]`),disabled:r,value:m,onChange:e=>{let t=e.target.value;f({intervalKind:t,intervalMinutesDraft:null,intervalHoursDraft:null})},"aria-label":n.modeInterval,children:[(0,U.jsx)(o,{value:`minutes`,children:n.intervalKindMinutes}),(0,U.jsx)(o,{value:`hours`,children:n.intervalKindHours})]}),m===`minutes`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{type:`number`,min:1,max:59,disabled:r,className:K,value:C??String(g),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalMinutesDraft:t};Number.isFinite(n)&&n>=1&&n<=59&&(r.intervalMinutes=n),f(r)},onBlur:()=>{if(C===null)return;let e=parseInt(C,10);f({intervalMinutes:!Number.isFinite(e)||e<1?5:Math.min(59,Math.max(1,Math.round(e))),intervalMinutesDraft:null})},"aria-label":n.intervalMinutes}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{type:`number`,min:1,max:23,disabled:r,className:K,value:w??String(_),onChange:e=>{let t=e.target.value,n=parseInt(t,10),r={intervalHoursDraft:t};Number.isFinite(n)&&n>=1&&n<=23&&(r.intervalHours=n),f(r)},onBlur:()=>{if(w===null)return;let e=parseInt(w,10);f({intervalHours:!Number.isFinite(e)||e<1?2:Math.min(23,Math.max(1,Math.round(e))),intervalHoursDraft:null})},"aria-label":n.intervalHours}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.hourUnit}),(0,U.jsx)(a,{className:c(G,`w-auto min-w-[4rem]`),disabled:r,value:v,onChange:e=>{f({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:W.map(e=>(0,U.jsx)(o,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),p===`daily`&&(0,U.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),p===`weekly`&&(0,U.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel}),p===`monthly`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(a,{className:c(G,`w-auto min-w-[4.5rem]`),disabled:r,value:x,onChange:e=>{f({dayOfMonth:parseInt(e.target.value,10)})},"aria-label":n.dayOfMonth,children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,U.jsx)(o,{value:e,children:e},e))}),(0,U.jsx)(I,{disabled:r,className:`min-w-[6.5rem] shrink-0`,triggerClassName:`h-9 border-edge-subtle px-2`,value:T,onChange:E,ariaLabel:n.scheduleTimeLabel})]}),p===`hourly`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(a,{className:c(G,`w-auto min-w-[4rem]`),disabled:r,value:v,onChange:e=>{f({minute:parseInt(e.target.value,10)})},"aria-label":n.minuteAtHour,children:W.map(e=>(0,U.jsx)(o,{value:e,children:String(e).padStart(2,`0`)},e))}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-fg-muted`,children:n.minuteUnit})]})]}),O=p===`weekly`?(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,role:`group`,"aria-label":n.modeWeekly,children:n.weekdays.map((e,t)=>{let n=b[t];return(0,U.jsx)(`button`,{type:`button`,disabled:r,className:c(`flex size-9 select-none items-center justify-center rounded-full border text-xs font-medium transition-colors`,n?`border-fg bg-fg text-surface-panel`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge`),"aria-pressed":n,onClick:()=>{let e=[...b];e[t]=!e[t],f({weekDays:e})},children:e},e)})}):null,k=p===`custom`?(0,U.jsxs)(`div`,{className:`pt-1`,children:[(0,U.jsx)(`textarea`,{disabled:r,className:me,rows:2,spellCheck:!1,value:S,placeholder:`*/5 * * * *`,onChange:e=>{f({rawCron:e.target.value})},"aria-label":n.modeCustom}),(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.customCronHint})]}):null;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[i?(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.scheduleTimeLabel}):null,D,O,k]})}var Y=[3e4,6e4,3e5,6e5,9e5,18e5,36e5,72e5];new Set(Y);var _e=c(`h-9 min-w-0 flex-1 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm tabular-nums text-fg`,f),ve=c(d,`h-9 max-w-[11rem] shrink-0 text-xs sm:max-w-[12rem]`);function X(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return String(e)}}function ye({valueMs:e,onChangeMs:t,labels:n,disabled:r,presets:i=Y,minSeconds:s=1}){let c=(0,z.useMemo)(()=>new Set(i),[i]),l=(0,z.useMemo)(()=>c.has(e)?String(e):``,[c,e]),[u,d]=(0,z.useState)(null),f=(0,z.useRef)(e);f.current!==e&&(f.current=e,d(null));let p=Math.max(s,Math.round(e/1e3)),m=u===null?String(p):u;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n.secondsLabel}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`input`,{type:`number`,min:s,step:1,disabled:r,className:_e,value:m,onChange:e=>{let n=e.target.value;d(n);let r=parseInt(n,10);Number.isFinite(r)&&r>=s&&t(r*1e3)},onBlur:()=>{if(u===null)return;let e=parseInt(u,10);t(!Number.isFinite(e)||e<s?s*1e3:e*1e3),d(null)}}),(0,U.jsxs)(a,{className:ve,disabled:r,value:l,onChange:e=>{let n=e.target.value;n&&(t(parseInt(n,10)),d(null))},children:[(0,U.jsx)(o,{value:``,children:n.presets.custom}),i.map(e=>(0,U.jsx)(o,{value:String(e),children:X(e,n.presets)},e))]})]})]})}var be=c(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,f),xe=()=>({start:`09:00`,end:`22:00`,timezone:``});function Se(e){let t=(0,B.c)(57),{value:n,onChange:r,labels:i,disabled:a}=e;if(!n){let e;t[0]===r?e=t[1]:(e=()=>r(xe()),t[0]=r,t[1]=e);let n;return t[2]!==a||t[3]!==i.add||t[4]!==e?(n=(0,U.jsx)(l,{type:`button`,variant:`secondary`,className:`text-sm`,disabled:a,onClick:e,children:i.add}),t[2]=a,t[3]=i.add,t[4]=e,t[5]=n):n=t[5],n}let o;t[6]===i.start?o=t[7]:(o=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.start}),t[6]=i.start,t[7]=o);let s;t[8]!==r||t[9]!==n?(s=e=>r({...n,start:e}),t[8]=r,t[9]=n,t[10]=s):s=t[10];let c;t[11]!==a||t[12]!==i.start||t[13]!==s||t[14]!==n.start?(c=(0,U.jsx)(I,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.start,onChange:s,ariaLabel:i.start}),t[11]=a,t[12]=i.start,t[13]=s,t[14]=n.start,t[15]=c):c=t[15];let u;t[16]!==o||t[17]!==c?(u=(0,U.jsxs)(`label`,{className:`block min-w-0`,children:[o,c]}),t[16]=o,t[17]=c,t[18]=u):u=t[18];let d;t[19]===i.end?d=t[20]:(d=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.end}),t[19]=i.end,t[20]=d);let f;t[21]!==r||t[22]!==n?(f=e=>r({...n,end:e}),t[21]=r,t[22]=n,t[23]=f):f=t[23];let p;t[24]!==a||t[25]!==i.end||t[26]!==f||t[27]!==n.end?(p=(0,U.jsx)(I,{disabled:a,className:`mt-1 w-full`,triggerClassName:`h-9 border-edge-subtle px-2.5`,value:n.end,onChange:f,ariaLabel:i.end}),t[24]=a,t[25]=i.end,t[26]=f,t[27]=n.end,t[28]=p):p=t[28];let m;t[29]!==d||t[30]!==p?(m=(0,U.jsxs)(`label`,{className:`block min-w-0`,children:[d,p]}),t[29]=d,t[30]=p,t[31]=m):m=t[31];let h;t[32]===i.timezone?h=t[33]:(h=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:i.timezone}),t[32]=i.timezone,t[33]=h);let g;t[34]!==r||t[35]!==n?(g=e=>r({...n,timezone:e.target.value}),t[34]=r,t[35]=n,t[36]=g):g=t[36];let _;t[37]!==a||t[38]!==g||t[39]!==n.timezone?(_=(0,U.jsx)(`input`,{type:`text`,disabled:a,className:be,value:n.timezone,onChange:g,placeholder:`Asia/Shanghai`,autoComplete:`off`}),t[37]=a,t[38]=g,t[39]=n.timezone,t[40]=_):_=t[40];let v;t[41]!==_||t[42]!==h?(v=(0,U.jsxs)(`label`,{className:`block min-w-0`,children:[h,_]}),t[41]=_,t[42]=h,t[43]=v):v=t[43];let y;t[44]!==v||t[45]!==u||t[46]!==m?(y=(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[u,m,v]}),t[44]=v,t[45]=u,t[46]=m,t[47]=y):y=t[47];let b;t[48]===r?b=t[49]:(b=()=>r(null),t[48]=r,t[49]=b);let x;t[50]!==a||t[51]!==i.clear||t[52]!==b?(x=(0,U.jsx)(l,{type:`button`,variant:`secondary`,className:`text-xs`,disabled:a,onClick:b,children:i.clear}),t[50]=a,t[51]=i.clear,t[52]=b,t[53]=x):x=t[53];let S;return t[54]!==y||t[55]!==x?(S=(0,U.jsxs)(`div`,{className:`space-y-2`,children:[y,x]}),t[54]=y,t[55]=x,t[56]=S):S=t[56],S}function Z(e){let t=(0,B.c)(34),{disabled:n,label:r,hint:i,className:a}=e,o;t[0]===a?o=t[1]:(o=c(`flex flex-col gap-2`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=r?(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r}):null,t[2]=r,t[3]=s);let l;t[4]!==n||t[5]!==r||t[6]!==e.kind||t[7]!==e.labels||t[8]!==e.onChange||t[9]!==e.value?(l=e.kind===`cron`?(0,U.jsx)(J,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n,showHeading:!r}):null,t[4]=n,t[5]=r,t[6]=e.kind,t[7]=e.labels,t[8]=e.onChange,t[9]=e.value,t[10]=l):l=t[10];let u;t[11]!==n||t[12]!==e.kind||t[13]!==e.labels||t[14]!==e.minSeconds||t[15]!==e.onChangeMs||t[16]!==e.presets||t[17]!==e.valueMs?(u=e.kind===`interval`?(0,U.jsx)(ye,{valueMs:e.valueMs,onChangeMs:e.onChangeMs,labels:e.labels,disabled:n,presets:e.presets??Y,minSeconds:e.minSeconds}):null,t[11]=n,t[12]=e.kind,t[13]=e.labels,t[14]=e.minSeconds,t[15]=e.onChangeMs,t[16]=e.presets,t[17]=e.valueMs,t[18]=u):u=t[18];let d;t[19]!==n||t[20]!==e.kind||t[21]!==e.labels||t[22]!==e.onChange||t[23]!==e.value?(d=e.kind===`active-hours`?(0,U.jsx)(Se,{value:e.value,onChange:e.onChange,labels:e.labels,disabled:n}):null,t[19]=n,t[20]=e.kind,t[21]=e.labels,t[22]=e.onChange,t[23]=e.value,t[24]=d):d=t[24];let f;t[25]===i?f=t[26]:(f=i?(0,U.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}):null,t[25]=i,t[26]=f);let p;return t[27]!==o||t[28]!==s||t[29]!==l||t[30]!==u||t[31]!==d||t[32]!==f?(p=(0,U.jsxs)(`div`,{className:o,children:[s,l,u,d,f]}),t[27]=o,t[28]=s,t[29]=l,t[30]=u,t[31]=d,t[32]=f,t[33]=p):p=t[33],p}function Ce(){return c(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,p,`dark:border-edge`)}function we(){return c(d,u)}var Te=[`schedule`,`delivery`,`prompt`,`document`],Q={schedule:j,delivery:A,prompt:O,document:D};function Ee(e){return e&&Te.includes(e)?e:`schedule`}function De(e,t){return t===`schedule`?e.tabSchedule:t===`delivery`?e.tabDelivery:t===`prompt`?e.tabPrompt:e.tabDocument}function Oe(e,t){return t===`schedule`?e.scheduleTabHint:t===`delivery`?e.deliveryTabHint:t===`prompt`?e.promptTabHint:e.documentTabHint}function ke(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`saved`:{let n=structuredClone(t.value);return{form:e.form&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function Ae(e,t){switch(t.type){case`reset`:return{doc:``,baseline:``};case`sync`:return{doc:t.value,baseline:t.value};case`set`:return{...e,doc:t.value};case`saved`:return{doc:e.doc===t.value?t.value:e.doc,baseline:t.value}}}function je(e){if(!e||typeof e!=`object`||Array.isArray(e))return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t;if(!Array.isArray(n.list))return``;let r=typeof n.default==`string`?n.default:``,i=n.list.find(e=>!e||typeof e!=`object`||Array.isArray(e)?!1:r?e.id===r:!0)??n.list[0];if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.workspace;if(!a||typeof a!=`object`||Array.isArray(a))return``;let o=a.root;return typeof o==`string`?o:``}var Me={triggerLoading:!1,triggerOk:!1,triggerError:null};function Ne(){let e=g(e=>e.language),t=m(e),n=t.heartbeatSettings,r=!!h(e=>e.token),[a,o]=i(),u=Ee(a.get(`tab`)),d=(0,z.useCallback)(e=>{o(t=>{let n=new URLSearchParams(t);return e===`schedule`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[o]),[f,p]=(0,z.useReducer)(ke,{form:null,baseline:null}),_=f.form,v=f.baseline,[b,x]=(0,z.useReducer)(Ae,{doc:``,baseline:``}),D=b.doc,O=b.baseline,[k,A]=(0,z.useReducer)(C,Me),{triggerLoading:j,triggerOk:te,triggerError:N}=k,P=(0,z.useRef)(!1),F=(0,z.useRef)(!1),I=(0,z.useRef)(_),L=(0,z.useRef)(D);I.current=_,L.current=D;let{data:R,error:B,isLoading:H,mutate:ue}=S(r),{data:W,error:G,isLoading:K,mutate:me}=y(r?V():null,ce,{revalidateOnFocus:!1}),{data:he=[]}=y(r?se():null,oe,{revalidateOnFocus:!1}),q=(0,z.useMemo)(()=>je(R?.payload?.config),[R]),ge=(0,z.useMemo)(()=>le(R?.payload?.config??{}),[R]),J=(0,z.useMemo)(()=>!_||!v?!1:JSON.stringify(_)!==JSON.stringify(v),[_,v]),Y=D!==O;(0,z.useEffect)(()=>{if(!r){p({type:`reset`}),P.current=!1;return}R!==void 0&&(P.current||p({type:`sync`,value:ge}))},[r,R,ge]),(0,z.useEffect)(()=>{if(!r){x({type:`reset`}),F.current=!1;return}W!==void 0&&(F.current||x({type:`sync`,value:W}))},[r,W]);let _e=B instanceof Error?B.message:B?String(B):G instanceof Error?G.message:G?String(G):null,ve=!!(r&&(R===void 0||W===void 0)&&!_e&&(H||K)),X=_?.target.trim()??``,{data:ye,setData:be}=w(()=>ae(X),[r,X],{enabled:r&&X.length>0,initial:[],errorData:[]}),xe=(0,z.useCallback)(()=>{X&&ae(X).then(be)},[X,be]),Se=(0,z.useCallback)(async()=>{A({type:`patch`,patch:{triggerLoading:!0,triggerOk:!1,triggerError:null}});try{await pe(),A({type:`patch`,patch:{triggerOk:!0}}),window.setTimeout(()=>A({type:`patch`,patch:{triggerOk:!1}}),3e3)}catch(e){A({type:`patch`,patch:{triggerError:e instanceof Error?e.message:n.triggerError}})}finally{A({type:`patch`,patch:{triggerLoading:!1}})}},[n.triggerError]),Z=(0,z.useCallback)(e=>{P.current=!0,p({type:`patch`,patch:e})},[]),Te=J||Y,Q=ie({value:(0,z.useMemo)(()=>_?{form:_,doc:D,saveConfig:J,saveDoc:Y}:null,[J,Y,D,_]),dirty:Te,onSave:(0,z.useCallback)(async e=>{try{e.saveConfig&&(await de(e.form),p({type:`saved`,value:e.form}),P.current=!!(I.current&&JSON.stringify(I.current)!==JSON.stringify(e.form))),e.saveDoc&&(await fe(e.doc),x({type:`saved`,value:e.doc}),F.current=L.current!==e.doc)}catch(t){throw Error(t instanceof Error?t.message:e.saveConfig?n.saveConfigError:n.saveDocError)}},[n.saveConfigError,n.saveDocError]),delayMs:Y?900:500});return r?ve?(0,U.jsx)(M,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,U.jsx)(ne,{sections:3})}):_?(0,U.jsxs)(M,{"aria-busy":Q.status===`saving`,"data-has-baseline":v?`1`:`0`,onBlurCapture:Q.onBlurCapture,children:[(0,U.jsx)(ee,{title:t.settingsSections.heartbeat,subtitle:n.subtitle,docsLink:T(e,`heartbeat`),docsLabel:n.docsLink,actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(re,{status:Q.status,error:Q.error}),(0,U.jsxs)(l,{type:`button`,variant:`secondary`,className:`inline-flex items-center gap-2`,disabled:j,onClick:()=>void Se(),children:[j?(0,U.jsx)(s,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,U.jsx)(E,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),j?n.triggering:n.triggerNow]}),te?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.triggered}):null]})}),q?(0,U.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.workspaceLabel,`: `,(0,U.jsx)(`span`,{className:`font-mono text-fg-muted`,children:q})]}):null,Q.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:Q.error}):null,N?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:N}):null,(0,U.jsx)(Pe,{h:n,activeTab:u,onChange:d}),(0,U.jsx)($,{h:n,id:`schedule`,activeTab:u,children:(0,U.jsx)(Fe,{h:n,form:_,update:Z})}),(0,U.jsx)($,{h:n,id:`delivery`,activeTab:u,children:(0,U.jsx)(Ie,{h:n,cron:t.cron,form:_,channels:he,sessionChatIds:ye,onRefreshChatIds:xe,update:Z,inputClassName:Ce,selectClassName:we})}),(0,U.jsx)($,{h:n,id:`prompt`,activeTab:u,children:(0,U.jsx)(ze,{h:n,form:_,update:Z,inputClassName:Ce})}),(0,U.jsxs)($,{h:n,id:`document`,activeTab:u,children:[(0,U.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:n.docHint}),(0,U.jsx)(`textarea`,{className:c(Ce(),`min-h-72 resize-y font-mono text-xs leading-relaxed`),value:D,onChange:e=>{F.current=!0,x({type:`set`,value:e.target.value})},spellCheck:!1,"aria-label":n.docSection,"data-doc-in-sync":D===O?`true`:`false`})]})]}):(0,U.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_e??n.loadError}),(0,U.jsx)(l,{type:`button`,variant:`secondary`,onClick:()=>{ue(),me()},children:n.retry})]}):(0,U.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(ee,{title:t.settingsSections.heartbeat}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function Pe(e){let t=(0,B.c)(7),{h:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Te.map(e=>({id:e,label:De(n,e),icon:Q[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==n.tabsAriaLabel||t[4]!==o||t[5]!==i?(s=(0,U.jsx)(N,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`}),t[2]=r,t[3]=n.tabsAriaLabel,t[4]=o,t[5]=i,t[6]=s):s=t[6],s}function $(e){let t=(0,B.c)(14),{h:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=De(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Oe(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,U.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,U.jsx)(te,{id:r,activeTab:i,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`,title:o,hint:s,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Fe(e){let t=(0,B.c)(37),{h:n,form:r,update:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.enable||t[6]!==o?(s=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.enable]}),t[5]=n.enable,t[6]=o,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=e=>i({intervalMs:e}),t[8]=i,t[9]=c);let l;t[10]!==n.intervalPresets||t[11]!==n.intervalSecondsLabel?(l={secondsLabel:n.intervalSecondsLabel,presets:n.intervalPresets},t[10]=n.intervalPresets,t[11]=n.intervalSecondsLabel,t[12]=l):l=t[12];let u=`${n.intervalHintPreset} ${n.intervalHint}`,d;t[13]!==r.intervalMs||t[14]!==n.interval||t[15]!==c||t[16]!==l||t[17]!==u?(d=(0,U.jsx)(Z,{kind:`interval`,label:n.interval,valueMs:r.intervalMs,onChangeMs:c,labels:l,hint:u}),t[13]=r.intervalMs,t[14]=n.interval,t[15]=c,t[16]=l,t[17]=u,t[18]=d):d=t[18];let f;t[19]===i?f=t[20]:(f=e=>i({activeHours:e}),t[19]=i,t[20]=f);let p;t[21]!==n.activeEnd||t[22]!==n.activeStart||t[23]!==n.activeTimezone||t[24]!==n.addActiveHours||t[25]!==n.clearActiveHours?(p={start:n.activeStart,end:n.activeEnd,timezone:n.activeTimezone,add:n.addActiveHours,clear:n.clearActiveHours},t[21]=n.activeEnd,t[22]=n.activeStart,t[23]=n.activeTimezone,t[24]=n.addActiveHours,t[25]=n.clearActiveHours,t[26]=p):p=t[26];let m;t[27]!==r.activeHours||t[28]!==n.activeHoursHint||t[29]!==n.activeHoursTitle||t[30]!==f||t[31]!==p?(m=(0,U.jsx)(Z,{kind:`active-hours`,label:n.activeHoursTitle,value:r.activeHours,onChange:f,labels:p,hint:n.activeHoursHint}),t[27]=r.activeHours,t[28]=n.activeHoursHint,t[29]=n.activeHoursTitle,t[30]=f,t[31]=p,t[32]=m):m=t[32];let h;return t[33]!==m||t[34]!==s||t[35]!==d?(h=(0,U.jsxs)(U.Fragment,{children:[s,d,m]}),t[33]=m,t[34]=s,t[35]=d,t[36]=h):h=t[36],h}function Ie(e){let t=(0,B.c)(51),{h:n,cron:r,form:i,channels:s,sessionChatIds:u,onRefreshChatIds:d,update:f,inputClassName:p,selectClassName:m}=e,h;t[0]===s?h=t[1]:(h=new Set(s.map(Re)),t[0]=s,t[1]=h);let g=h,_;t[2]===i.target?_=t[3]:(_=i.target.trim(),t[2]=i.target,t[3]=_);let v=_,y=!!(v&&!g.has(v)),b;t[4]===n.deliveryHint?b=t[5]:(b=(0,U.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.deliveryHint}),t[4]=n.deliveryHint,t[5]=b);let x;t[6]===r.channel?x=t[7]:(x=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.channel}),t[6]=r.channel,t[7]=x);let S;t[8]===m?S=t[9]:(S=m(),t[8]=m,t[9]=S);let C;t[10]===f?C=t[11]:(C=e=>{f({target:e.target.value.trim(),targetChatId:``})},t[10]=f,t[11]=C);let w;t[12]===n.channelNone?w=t[13]:(w=(0,U.jsx)(o,{value:``,children:n.channelNone}),t[12]=n.channelNone,t[13]=w);let T;t[14]!==n.customChannelSuffix||t[15]!==y||t[16]!==v?(T=y?(0,U.jsxs)(o,{value:v,children:[v,` (`,n.customChannelSuffix,`)`]}):null,t[14]=n.customChannelSuffix,t[15]=y,t[16]=v,t[17]=T):T=t[17];let E;t[18]===s?E=t[19]:(E=s.map(Le),t[18]=s,t[19]=E);let D;t[20]!==S||t[21]!==C||t[22]!==w||t[23]!==T||t[24]!==E||t[25]!==v?(D=(0,U.jsxs)(a,{className:S,value:v,onChange:C,children:[w,T,E]}),t[20]=S,t[21]=C,t[22]=w,t[23]=T,t[24]=E,t[25]=v,t[26]=D):D=t[26];let O;t[27]!==D||t[28]!==x?(O=(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[x,D]}),t[27]=D,t[28]=x,t[29]=O):O=t[29];let A;t[30]!==r.enterManuallyOrSelect||t[31]!==r.lastActiveLabels||t[32]!==r.noRecentChats||t[33]!==r.noRecentChatsOption||t[34]!==r.recipient||t[35]!==r.recipientPlaceholder||t[36]!==r.refreshList||t[37]!==r.refreshRecipientHint||t[38]!==r.selectRecipient||t[39]!==i.targetChatId||t[40]!==p||t[41]!==d||t[42]!==m||t[43]!==u||t[44]!==v||t[45]!==f?(A=v?(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.recipient}),(0,U.jsxs)(l,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:r.refreshRecipientHint,onClick:d,children:[(0,U.jsx)(k,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),r.refreshList]})]}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`input`,{type:`text`,className:c(p(),`min-w-0 flex-1`),value:i.targetChatId,onChange:e=>f({targetChatId:e.target.value}),placeholder:r.recipientPlaceholder,autoComplete:`off`}),(0,U.jsxs)(a,{className:c(m(),`max-w-40 shrink-0 text-xs`),value:i.targetChatId,onChange:e=>{let t=e.target.value;t&&f({targetChatId:t})},children:[(0,U.jsx)(o,{value:``,children:r.selectRecipient}),u.length>0?u.map(e=>(0,U.jsx)(o,{value:e.chatId,children:P(e,r.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,U.jsx)(o,{value:``,disabled:!0,children:r.noRecentChatsOption})]})]}),(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:u.length>0?r.enterManuallyOrSelect:r.noRecentChats})]}):null,t[30]=r.enterManuallyOrSelect,t[31]=r.lastActiveLabels,t[32]=r.noRecentChats,t[33]=r.noRecentChatsOption,t[34]=r.recipient,t[35]=r.recipientPlaceholder,t[36]=r.refreshList,t[37]=r.refreshRecipientHint,t[38]=r.selectRecipient,t[39]=i.targetChatId,t[40]=p,t[41]=d,t[42]=m,t[43]=u,t[44]=v,t[45]=f,t[46]=A):A=t[46];let j;return t[47]!==O||t[48]!==A||t[49]!==b?(j=(0,U.jsxs)(U.Fragment,{children:[b,O,A]}),t[47]=O,t[48]=A,t[49]=b,t[50]=j):j=t[50],j}function Le(e){return(0,U.jsxs)(o,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Re(e){return e.name}function ze(e){let t=(0,B.c)(65),{h:n,form:r,update:i,inputClassName:a}=e,o;t[0]===i?o=t[1]:(o=e=>i({includeSystemPromptSection:e.target.checked}),t[0]=i,t[1]=o);let s;t[2]!==r.includeSystemPromptSection||t[3]!==o?(s=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.includeSystemPromptSection,onChange:o}),t[2]=r.includeSystemPromptSection,t[3]=o,t[4]=s):s=t[4];let l;t[5]===n.includeSystemPromptSectionHint?l=t[6]:(l=(0,U.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.includeSystemPromptSectionHint}),t[5]=n.includeSystemPromptSectionHint,t[6]=l);let u;t[7]!==n.includeSystemPromptSection||t[8]!==l?(u=(0,U.jsxs)(`span`,{children:[n.includeSystemPromptSection,l]}),t[7]=n.includeSystemPromptSection,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==s||t[11]!==u?(d=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[10]=s,t[11]=u,t[12]=d):d=t[12];let f;t[13]===n.prompt?f=t[14]:(f=(0,U.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.prompt}),t[13]=n.prompt,t[14]=f);let p;t[15]===a?p=t[16]:(p=c(a(),`min-h-36 resize-y font-mono text-xs`),t[15]=a,t[16]=p);let m;t[17]===i?m=t[18]:(m=e=>i({prompt:e.target.value}),t[17]=i,t[18]=m);let h;t[19]!==r.prompt||t[20]!==n.promptPlaceholder||t[21]!==p||t[22]!==m?(h=(0,U.jsx)(`textarea`,{className:p,value:r.prompt,onChange:m,placeholder:n.promptPlaceholder}),t[19]=r.prompt,t[20]=n.promptPlaceholder,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]===n.promptHint?g=t[25]:(g=(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.promptHint}),t[24]=n.promptHint,t[25]=g);let _;t[26]!==g||t[27]!==f||t[28]!==h?(_=(0,U.jsxs)(`div`,{children:[f,h,g]}),t[26]=g,t[27]=f,t[28]=h,t[29]=_):_=t[29];let v;t[30]===n.ackMaxChars?v=t[31]:(v=(0,U.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.ackMaxChars}),t[30]=n.ackMaxChars,t[31]=v);let y;t[32]===a?y=t[33]:(y=a(),t[32]=a,t[33]=y);let b=r.ackMaxChars===``?``:r.ackMaxChars,x;t[34]===i?x=t[35]:(x=e=>{let t=e.target.value;if(t===``){i({ackMaxChars:``});return}let n=parseInt(t,10);i({ackMaxChars:Number.isFinite(n)?n:``})},t[34]=i,t[35]=x);let S;t[36]!==n.ackDefaultPlaceholder||t[37]!==y||t[38]!==b||t[39]!==x?(S=(0,U.jsx)(`input`,{type:`number`,min:1,className:y,value:b,onChange:x,placeholder:n.ackDefaultPlaceholder}),t[36]=n.ackDefaultPlaceholder,t[37]=y,t[38]=b,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n.ackMaxCharsHint?C=t[42]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.ackMaxCharsHint}),t[41]=n.ackMaxCharsHint,t[42]=C);let w;t[43]!==v||t[44]!==S||t[45]!==C?(w=(0,U.jsxs)(`div`,{children:[v,S,C]}),t[43]=v,t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]===i?T=t[48]:(T=e=>i({isolatedSession:e.target.checked}),t[47]=i,t[48]=T);let E;t[49]!==r.isolatedSession||t[50]!==T?(E=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.isolatedSession,onChange:T}),t[49]=r.isolatedSession,t[50]=T,t[51]=E):E=t[51];let D;t[52]===n.isolatedSessionHint?D=t[53]:(D=(0,U.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.isolatedSessionHint}),t[52]=n.isolatedSessionHint,t[53]=D);let O;t[54]!==n.isolatedSession||t[55]!==D?(O=(0,U.jsxs)(`span`,{children:[n.isolatedSession,D]}),t[54]=n.isolatedSession,t[55]=D,t[56]=O):O=t[56];let k;t[57]!==E||t[58]!==O?(k=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[E,O]}),t[57]=E,t[58]=O,t[59]=k):k=t[59];let A;return t[60]!==_||t[61]!==w||t[62]!==k||t[63]!==d?(A=(0,U.jsxs)(U.Fragment,{children:[d,_,w,k]}),t[60]=_,t[61]=w,t[62]=k,t[63]=d,t[64]=A):A=t[64],A}export{Ne as HeartbeatSettingsPanel};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{c as i,l as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./loader-circle-CifKLtgG.js";import{t as l}from"./plus-Q2yW6OE7.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./button-CSEbl4zT.js";import{t as p}from"./messages-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{c as i,l as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./loader-circle-CifKLtgG.js";import{t as l}from"./plus-Q2yW6OE7.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./button-CSEbl4zT.js";import{t as p}from"./messages-Dxk5Rzj_.js";import{n as m,o as h,r as g}from"./locale-store-C7xtkP3D.js";import{a as _,i as v,n as y,o as b,r as x,s as S,t as C}from"./dist-BPoKqzeH.js";import{n as w}from"./activity-store-BmpM0zwM.js";import{Aa as T,B as E,El as D,I as O,Kl as k,N as A,P as j,Sl as M,Tc as N,U as P,V as F,Va as I,as as ee,cl as L,is as R,j as te,q as ne,rn as re,sc as ie,si as z,tn as ae,xl as oe,yl as se,ys as ce,z as le}from"./index-DzKLVgY-.js";var B=e(t(),1),V=n();function H(e){try{return decodeURIComponent(e).trim()||null}catch{return null}}function U(e){if(!e)return null;let t=e.split(/[?#]/,1)[0],n=/^\/chat\/([^/]+)\/?$/.exec(t);if(n){let e=H(n[1]);return!e||e===`new`?null:{kind:`session`,id:e}}return null}async function W(e,t){let n=`/api/sessions/${encodeURIComponent(e.id)}?limit=1`;try{return(await h(g(n),{signal:t})).status===404?`missing`:`available`}catch(e){if(t?.aborted)throw e;return`available`}}var G=r(),K=3,q={info:{Icon:N,className:`text-accent-fg bg-accent-soft`},success:{Icon:se,className:`text-success bg-success-soft`},warning:{Icon:R,className:`text-warning bg-warning-soft`},error:{Icon:oe,className:`text-danger bg-danger-soft`}};function ue(e,t){let n=Math.max(0,Math.round((Date.now()-e)/1e3));if(n<60)return t===`zh`?`刚刚`:`Just now`;let r=Math.round(n/60);if(r<60)return t===`zh`?`${r} 分钟前`:`${r}m ago`;let i=Math.round(r/60);if(i<24)return t===`zh`?`${i} 小时前`:`${i}h ago`;let a=Math.round(i/24);return t===`zh`?`${a} 天前`:`${a}d ago`}function J(e){let t=(0,V.c)(55),{item:n,targetAvailability:r}=e,i=m(fe),a;t[0]===i?a=t[1]:(a=p(i),t[0]=i,t[1]=a);let s=a.projectsPage.home,l=w(de),{Icon:f,className:h}=q[n.tone],g;t[2]===h?g=t[3]:(g=d(`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg`,h),t[2]=h,t[3]=g);let _;t[4]!==f||t[5]!==n.status?(_=n.status===`running`?(0,G.jsx)(c,{className:`size-3.5 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,G.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[4]=f,t[5]=n.status,t[6]=_):_=t[6];let v;t[7]!==g||t[8]!==_?(v=(0,G.jsx)(`div`,{className:g,children:_}),t[7]=g,t[8]=_,t[9]=v):v=t[9];let y;t[10]===n.title?y=t[11]:(y=(0,G.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-medium leading-5 text-fg`,children:n.title}),t[10]=n.title,t[11]=y);let b;t[12]!==s.activityUnread||t[13]!==n.read?(b=n.read?null:(0,G.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-accent`,"aria-label":s.activityUnread}),t[12]=s.activityUnread,t[13]=n.read,t[14]=b):b=t[14];let x;t[15]!==y||t[16]!==b?(x=(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[y,b]}),t[15]=y,t[16]=b,t[17]=x):x=t[17];let S;t[18]===n.message?S=t[19]:(S=n.message?(0,G.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.message}):null,t[18]=n.message,t[19]=S);let C;t[20]===n.source?C=t[21]:(C=n.source?(0,G.jsx)(`span`,{className:`max-w-48 truncate`,children:n.source}):null,t[20]=n.source,t[21]=C);let E;t[22]!==n.updatedAt||t[23]!==i?(E=ue(n.updatedAt,i),t[22]=n.updatedAt,t[23]=i,t[24]=E):E=t[24];let D;t[25]===E?D=t[26]:(D=(0,G.jsx)(`span`,{children:E}),t[25]=E,t[26]=D);let O;t[27]===n.occurrences?O=t[28]:(O=n.occurrences>1?(0,G.jsxs)(`span`,{children:[`×`,n.occurrences]}):null,t[27]=n.occurrences,t[28]=O);let k;t[29]!==s.activityCheckingRelated||t[30]!==s.activityRelatedMissing||t[31]!==s.activityViewRelated||t[32]!==n.href||t[33]!==r?(k=n.href&&r===`available`?(0,G.jsxs)(o,{to:n.href,className:`inline-flex items-center gap-0.5 font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[s.activityViewRelated,(0,G.jsx)(M,{className:`size-3`,"aria-hidden":!0})]}):n.href&&r===`checking`?(0,G.jsx)(T,{className:`h-3 w-20 rounded`,"aria-label":s.activityCheckingRelated}):n.href&&r===`missing`?(0,G.jsx)(`span`,{className:`font-medium text-fg-subtle`,role:`status`,children:s.activityRelatedMissing}):null,t[29]=s.activityCheckingRelated,t[30]=s.activityRelatedMissing,t[31]=s.activityViewRelated,t[32]=n.href,t[33]=r,t[34]=k):k=t[34];let A;t[35]!==D||t[36]!==O||t[37]!==k||t[38]!==C?(A=(0,G.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] text-fg-subtle`,children:[C,D,O,k]}),t[35]=D,t[36]=O,t[37]=k,t[38]=C,t[39]=A):A=t[39];let j;t[40]!==A||t[41]!==x||t[42]!==S?(j=(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,S,A]}),t[40]=A,t[41]=x,t[42]=S,t[43]=j):j=t[43];let N;t[44]!==n.id||t[45]!==l?(N=()=>l(n.id),t[44]=n.id,t[45]=l,t[46]=N):N=t[46];let P;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,G.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),t[47]=P):P=t[47];let F;t[48]!==s.activityRemove||t[49]!==N?(F=(0,G.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-hover hover:text-fg group-hover:opacity-100 focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":s.activityRemove,onClick:N,children:P}),t[48]=s.activityRemove,t[49]=N,t[50]=F):F=t[50];let I;return t[51]!==j||t[52]!==F||t[53]!==v?(I=(0,G.jsxs)(`article`,{className:`group flex items-start gap-3 border-t border-edge-subtle px-1 py-3 first:border-t-0`,children:[v,j,F]}),t[51]=j,t[52]=F,t[53]=v,t[54]=I):I=t[54],I}function de(e){return e.remove}function fe(e){return e.language}function pe(){let e=(0,V.c)(14),t=p(m(be)).projectsPage.home,n=w(ye),r=w(ve),i=w(_e),[a,o]=(0,B.useState)(!1),l;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={},e[0]=l):l=e[0];let[u,d]=(0,B.useState)(l),h;e[1]===n?h=e[2]:(h=n.filter($),e[1]=n,e[2]=h);let g=h.length,_;e[3]===n?_=e[4]:(_=n.filter(Q),e[3]=n,e[4]=_);let v=_.length,y;e[5]!==a||e[6]!==n?(y=a?n:n.slice(0,K),e[5]=a,e[6]=n,e[7]=y):y=e[7];let b=y,x;e[8]===n?x=e[9]:(x=[...new Set(n.flatMap(ge))].sort().join(`
|
|
2
2
|
`),e[8]=n,e[9]=x);let S=x,C,T;e[10]===S?(C=e[11],T=e[12]):(C=()=>{let e=new AbortController,t=new Map((S?S.split(`
|
|
3
|
-
`):[]).flatMap(he));return d(Object.fromEntries([...t.keys()].map(me))),Promise.all([...t].map(async t=>{let[n,r]=t,i=await W(r,e.signal);e.signal.aborted||d(e=>({...e,[n]:i}))})).catch(Z),()=>e.abort()},T=[S],e[10]=S,e[11]=C,e[12]=T),(0,B.useEffect)(C,T);let E;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,G.jsx)(z,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),e[13]=E):E=e[13],(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,"aria-labelledby":`workbench-activity-title`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsx)(`div`,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,(0,G.jsx)(`h2`,{id:`workbench-activity-title`,className:`text-sm font-semibold text-fg`,children:t.activityTitle}),g>0?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:[(0,G.jsx)(c,{className:`size-3 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),g,` `,t.running]}):v>0?(0,G.jsxs)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[v,` `,t.activityNew]}):null]})}),a&&n.length>0?(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[v>0?(0,G.jsxs)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:r,children:[(0,G.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),t.activityMarkRead]}):null,n.some(X)?(0,G.jsxs)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-fg-muted`,onClick:i,children:[(0,G.jsx)(L,{className:`size-3.5`,"aria-hidden":!0}),t.activityClearFinished]}):null]}):null]}),n.length>0?(0,G.jsxs)(`div`,{className:`mt-3 px-1`,children:[b.map(e=>(0,G.jsx)(J,{item:e,targetAvailability:e.href&&U(e.href)?u[e.href]??`checking`:`available`},e.id)),n.length>K?(0,G.jsx)(`div`,{className:`border-t border-edge-subtle py-2 text-center`,children:(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>o(Y),children:a?t.activityShowLess:t.activityShowAll.replace(`{{count}}`,String(n.length))})}):null]}):(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(R,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,G.jsx)(`p`,{children:t.activityEmpty})]})]})}function Y(e){return!e}function X(e){return e.status===`done`}function Z(){}function me(e){return[e,`checking`]}function he(e){let t=U(e);return t?[[e,t]]:[]}function ge(e){return e.href&&U(e.href)?[e.href]:[]}function Q(e){return!e.read}function $(e){return e.status===`running`}function _e(e){return e.clearFinished}function ve(e){return e.markAllRead}function ye(e){return e.items}function be(e){return e.language}function xe(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Se(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:oe(n)}function Ce(e){let t=(0,V.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,G.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function we(e){let t=(0,V.c)(18),{task:n,statusLabel:r,backgroundPath:i}=e,a;t[0]!==i||t[1]!==n.id?(a=ie(i,n.id),t[0]=i,t[1]=n.id,t[2]=a):a=t[2];let s;t[3]===n.title?s=t[4]:(s=(0,G.jsx)(`h3`,{className:`line-clamp-2 text-sm font-semibold text-fg`,children:n.title}),t[3]=n.title,t[4]=s);let c;t[5]===n.updatedAt?c=t[6]:(c=Se(n.updatedAt,``),t[5]=n.updatedAt,t[6]=c);let l;t[7]===c?l=t[8]:(l=(0,G.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:c}),t[7]=c,t[8]=l);let u;t[9]!==s||t[10]!==l?(u=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[s,l]}),t[9]=s,t[10]=l,t[11]=u):u=t[11];let d;t[12]===r?d=t[13]:(d=(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[12]=r,t[13]=d);let f;return t[14]!==a||t[15]!==u||t[16]!==d?(f=(0,G.jsxs)(o,{to:a,className:`group flex items-start justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,d]}),t[14]=a,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function Te(e){let t=(0,V.c)(12),{receipt:n,evidenceLabel:r,remainingLabel:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,G.jsx)(ee,{className:`mt-0.5 size-4 shrink-0 text-success`,"aria-hidden":!0}),t[0]=a):a=t[0];let o,s;t[1]===n.summary?(o=t[2],s=t[3]):(o=(0,G.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:n.summary}),s=(0,G.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.summary}),t[1]=n.summary,t[2]=o,t[3]=s);let c=n.remainingWork.length>0?` · ${n.remainingWork.length} ${i}`:``,l;t[4]!==r||t[5]!==n.evidence.length||t[6]!==c?(l=(0,G.jsxs)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:[n.evidence.length,` `,r,c]}),t[4]=r,t[5]=n.evidence.length,t[6]=c,t[7]=l):l=t[7];let u;return t[8]!==o||t[9]!==s||t[10]!==l?(u=(0,G.jsx)(`div`,{className:`block rounded-xl border border-edge-subtle px-3 py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[a,(0,G.jsxs)(`div`,{className:`min-w-0`,children:[o,s,l]})]})}),t[8]=o,t[9]=s,t[10]=l,t[11]=u):u=t[11],u}function Ee(){let e=(0,V.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,G.jsx)(T,{className:`h-20 rounded-2xl`}),(0,G.jsx)(T,{className:`h-72 rounded-2xl`}),(0,G.jsx)(T,{className:`h-44 rounded-2xl`})]}),e[0]=t):t=e[0],t}function De(e){let t=(0,V.c)(15),{chat:n,statusLabel:r}=e,i=`/chat/${encodeURIComponent(n.key)}`,a;t[0]===n.name?a=t[1]:(a=(0,G.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.name}),t[0]=n.name,t[1]=a);let s;t[2]===r?s=t[3]:(s=(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===n.updatedAt?l=t[8]:(l=Se(n.updatedAt,``),t[7]=n.updatedAt,t[8]=l);let u;t[9]===l?u=t[10]:(u=(0,G.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:l}),t[9]=l,t[10]=u);let d;return t[11]!==i||t[12]!==c||t[13]!==u?(d=(0,G.jsxs)(o,{to:i,className:`group block rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[c,u]}),t[11]=i,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function Oe(e){let t=(0,V.c)(27),{item:n,href:r,kindLabel:i,reasonLabel:a,approveLabel:s,denyLabel:c,busy:l,onRespond:u}=e,d;t[0]===n.title?d=t[1]:(d=(0,G.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=d);let p=n.projectName||i,m;t[2]===p?m=t[3]:(m=(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:p}),t[2]=p,t[3]=m);let h;t[4]!==d||t[5]!==m?(h=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[d,m]}),t[4]=d,t[5]=m,t[6]=h):h=t[6];let g;t[7]===a?g=t[8]:(g=(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[7]=a,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[h,g]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===n.detail?v=t[13]:(v=n.detail?(0,G.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.detail}):null,t[12]=n.detail,t[13]=v);let y;t[14]!==r||t[15]!==_||t[16]!==v?(y=(0,G.jsxs)(o,{to:r,className:`group block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[_,v]}),t[14]=r,t[15]=_,t[16]=v,t[17]=y):y=t[17];let b;t[18]!==s||t[19]!==l||t[20]!==c||t[21]!==n.response||t[22]!==u?(b=n.response?(0,G.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2 border-t border-warning/20 pt-3`,children:[(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:()=>u(`deny`),children:c}),(0,G.jsx)(f,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:l,onClick:()=>u(`approve`),children:s})]}):null,t[18]=s,t[19]=l,t[20]=c,t[21]=n.response,t[22]=u,t[23]=b):b=t[23];let x;return t[24]!==y||t[25]!==b?(x=(0,G.jsxs)(`article`,{className:`rounded-xl border border-warning/35 bg-warning-soft/25 p-3.5 transition-colors hover:bg-warning-soft/40`,children:[y,b]}),t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function ke(e){let t=(0,V.c)(74),{item:n,labels:r,busy:i,onDecide:a,onSnooze:o,onDismiss:s,onInstruct:c}=e,[l,u]=(0,B.useState)(``),d=n.judgment,p;t[0]===n.title?p=t[1]:(p=(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=p);let m;t[2]===n.detail?m=t[3]:(m=(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[2]=n.detail,t[3]=m);let h;t[4]!==p||t[5]!==m?(h=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[p,m]}),t[4]=p,t[5]=m,t[6]=h):h=t[6];let g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,G.jsx)(ce,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[7]=g):g=t[7];let _;t[8]===h?_=t[9]:(_=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[h,g]}),t[8]=h,t[9]=_);let v;t[10]!==d.whyNow||t[11]!==r.whyNow?(v=[r.whyNow,d.whyNow],t[10]=d.whyNow,t[11]=r.whyNow,t[12]=v):v=t[12];let y;t[13]!==d.impact||t[14]!==r.impact?(y=[r.impact,d.impact],t[13]=d.impact,t[14]=r.impact,t[15]=y):y=t[15];let b;t[16]!==d.workDone||t[17]!==r.workDone?(b=[r.workDone,d.workDone],t[16]=d.workDone,t[17]=r.workDone,t[18]=b):b=t[18];let x;t[19]!==d.recommendation||t[20]!==r.recommendation?(x=[r.recommendation,d.recommendation],t[19]=d.recommendation,t[20]=r.recommendation,t[21]=x):x=t[21];let S;t[22]!==v||t[23]!==y||t[24]!==b||t[25]!==x?(S=(0,G.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[v,y,b,x].map(Ae)}),t[22]=v,t[23]=y,t[24]=b,t[25]=x,t[26]=S):S=t[26];let C;t[27]!==d.actionError||t[28]!==d.actionStatus||t[29]!==d.dispositionReason||t[30]!==d.proposedActionTitle||t[31]!==r.actionStates||t[32]!==r.policyReason||t[33]!==r.proposedAction?(C=d.dispositionReason?(0,G.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-panel/70 p-3 text-xs leading-5`,children:[(0,G.jsx)(`p`,{className:`font-medium text-fg-subtle`,children:r.policyReason}),(0,G.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:d.dispositionReason}),d.proposedActionTitle?(0,G.jsxs)(`p`,{className:`mt-2 text-fg`,children:[(0,G.jsxs)(`span`,{className:`font-medium`,children:[r.proposedAction,`:`]}),d.proposedActionTitle,d.actionStatus?` · ${r.actionStates[d.actionStatus]}`:``]}):null,d.actionError?(0,G.jsx)(`p`,{className:`mt-1 text-danger`,children:d.actionError}):null]}):null,t[27]=d.actionError,t[28]=d.actionStatus,t[29]=d.dispositionReason,t[30]=d.proposedActionTitle,t[31]=r.actionStates,t[32]=r.policyReason,t[33]=r.proposedAction,t[34]=C):C=t[34];let w;t[35]!==i||t[36]!==d.decision||t[37]!==a?(w=d.decision?(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:d.decision.question}),(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:d.decision.options.map(e=>(0,G.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-auto min-h-9 flex-col items-start px-3 py-2 text-left`,disabled:i,title:e.consequence,onClick:()=>a(e.id),children:[(0,G.jsx)(`span`,{children:e.label}),(0,G.jsx)(`span`,{className:`text-[10px] font-normal text-fg-muted`,children:e.consequence})]},e.id))})]}):null,t[35]=i,t[36]=d.decision,t[37]=a,t[38]=w):w=t[38];let T;t[39]!==i||t[40]!==r.snooze||t[41]!==o?(T=(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:i,onClick:o,children:r.snooze}),t[39]=i,t[40]=r.snooze,t[41]=o,t[42]=T):T=t[42];let E;t[43]!==i||t[44]!==r.dismiss||t[45]!==s?(E=(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:i,onClick:s,children:r.dismiss}),t[43]=i,t[44]=r.dismiss,t[45]=s,t[46]=E):E=t[46];let D;t[47]!==T||t[48]!==E?(D=(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 border-t border-edge-subtle pt-3`,children:[T,E]}),t[47]=T,t[48]=E,t[49]=D):D=t[49];let O;t[50]!==l||t[51]!==c?(O=e=>{e.preventDefault();let t=l.trim();t&&(c(t),u(``))},t[50]=l,t[51]=c,t[52]=O):O=t[52];let k;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>u(e.target.value),t[53]=k):k=t[53];let A;t[54]!==l||t[55]!==r.feedbackPlaceholder?(A=(0,G.jsx)(`input`,{className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-base px-3 py-2 text-xs text-fg outline-none focus:border-accent`,value:l,onChange:k,placeholder:r.feedbackPlaceholder}),t[54]=l,t[55]=r.feedbackPlaceholder,t[56]=A):A=t[56];let j;t[57]!==i||t[58]!==l?(j=i||!l.trim(),t[57]=i,t[58]=l,t[59]=j):j=t[59];let M;t[60]!==r.applyFeedback||t[61]!==j?(M=(0,G.jsx)(f,{type:`submit`,variant:`secondary`,className:`h-9 px-3`,disabled:j,children:r.applyFeedback}),t[60]=r.applyFeedback,t[61]=j,t[62]=M):M=t[62];let N;t[63]!==O||t[64]!==A||t[65]!==M?(N=(0,G.jsxs)(`form`,{className:`mt-3 flex gap-2`,onSubmit:O,children:[A,M]}),t[63]=O,t[64]=A,t[65]=M,t[66]=N):N=t[66];let P;return t[67]!==S||t[68]!==C||t[69]!==w||t[70]!==D||t[71]!==N||t[72]!==_?(P=(0,G.jsxs)(`article`,{className:`rounded-xl border border-accent/25 bg-accent-soft/15 p-4`,children:[_,S,C,w,D,N]}),t[67]=S,t[68]=C,t[69]=w,t[70]=D,t[71]=N,t[72]=_,t[73]=P):P=t[73],P}function Ae(e){let[t,n]=e;return(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 p-3`,children:[(0,G.jsx)(`p`,{className:`text-[11px] font-medium text-fg-subtle`,children:t}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg`,children:n})]},t)}function je(e){let t=(0,V.c)(32),{item:n,href:r,statusLabel:i,retryLabel:a,viewLabel:s,acknowledgeLabel:c,busy:l,onView:u,onRetry:d,onAcknowledge:p}=e,m;t[0]===n.title?m=t[1]:(m=(0,G.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=m);let h;t[2]===i?h=t[3]:(h=(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-danger`,children:i}),t[2]=i,t[3]=h);let g;t[4]!==m||t[5]!==h?(g=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[m,h]}),t[4]=m,t[5]=h,t[6]=g):g=t[6];let _;t[7]===n.detail?_=t[8]:(_=(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[7]=n.detail,t[8]=_);let v;t[9]!==r||t[10]!==g||t[11]!==_?(v=(0,G.jsxs)(o,{to:r,className:`block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[g,_]}),t[9]=r,t[10]=g,t[11]=_,t[12]=v):v=t[12];let y;t[13]!==c||t[14]!==l||t[15]!==p?(y=(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:p,children:c}),t[13]=c,t[14]=l,t[15]=p,t[16]=y):y=t[16];let b;t[17]!==l||t[18]!==u||t[19]!==s?(b=(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:u,children:s}),t[17]=l,t[18]=u,t[19]=s,t[20]=b):b=t[20];let x;t[21]!==l||t[22]!==d||t[23]!==a?(x=(0,G.jsx)(f,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:l,onClick:d,children:a}),t[21]=l,t[22]=d,t[23]=a,t[24]=x):x=t[24];let S;t[25]!==y||t[26]!==b||t[27]!==x?(S=(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2 border-t border-danger/15 pt-3`,children:[y,b,x]}),t[25]=y,t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;return t[29]!==v||t[30]!==S?(C=(0,G.jsxs)(`article`,{className:`rounded-xl border border-danger/25 bg-danger-soft/35 p-3.5`,children:[v,S]}),t[29]=v,t[30]=S,t[31]=C):C=t[31],C}function Me(){let e=m(e=>e.language),t=p(e).projectsPage,n=re(e),r=a(),s=i(),c=`${s.pathname}${s.search}`,d=I(e=>e.setPageHeader),h=I(e=>e.clearPageHeader),[g,w]=(0,B.useState)(null),[T,D]=(0,B.useState)(!0),[N,L]=(0,B.useState)(null),[te,R]=(0,B.useState)(!1),[z,oe]=(0,B.useState)(``),[V,H]=(0,B.useState)(()=>crypto.randomUUID()),[U,W]=(0,B.useState)(!1),[K,q]=(0,B.useState)(null),[ue,J]=(0,B.useState)(null),[de,fe]=(0,B.useState)(null),Y=(0,B.useCallback)(async(t=!1)=>{t&&D(!0),L(null);try{w(await k(e))}catch(e){L(e instanceof Error?e.message:String(e))}finally{D(!1)}},[e]);(0,B.useEffect)(()=>{Y(!0)},[Y]),(0,B.useEffect)(()=>{let e,t=t=>{e!==void 0&&window.clearTimeout(e),e=window.setTimeout(()=>{e=void 0,Y()},t)},n=()=>t(100),r=()=>t(750),i=[`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`],a=[`session-updated`,`session-transcript-updated`];return i.forEach(e=>window.addEventListener(e,n)),a.forEach(e=>window.addEventListener(e,r)),()=>{i.forEach(e=>window.removeEventListener(e,n)),a.forEach(e=>window.removeEventListener(e,r)),e!==void 0&&window.clearTimeout(e)}},[Y]);let X=(0,B.useMemo)(()=>g?.decisions??[],[g]),Z=(0,B.useMemo)(()=>g?.attention??[],[g]),me=(0,B.useCallback)(async t=>{t.preventDefault();let n=z.trim();if(!(!n||U)){W(!0),q(null);try{let t=await A({idempotencyKey:V,title:n,locale:e,priority:`normal`,contract:{objective:n,expectedOutputs:[],acceptanceCriteria:[],constraints:[],approvalRequired:[],assumptions:[],risks:[],acceptancePolicy:`manual`,outputDestinations:[]},dependencies:[],context:[],authorityGrants:[],activation:{mode:`start`}});R(!1),oe(``),H(crypto.randomUUID()),r(ie(c,t.task.id))}catch(e){q(e instanceof Error?e.message:String(e))}finally{W(!1)}}},[c,V,U,e,r,z]),he=(0,B.useMemo)(()=>(0,G.jsxs)(f,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>R(!0),children:[(0,G.jsx)(l,{className:`size-4`,"aria-hidden":!0}),n.newWork]}),[n.newWork]),ge=(0,B.useCallback)(async(e,t)=>{if(e.response){J(e.id),L(null);try{await E(e.response,t),await Y()}catch(e){L(e instanceof Error?e.message:String(e))}finally{J(null)}}},[Y]),Q=(0,B.useCallback)(async(e,t)=>{J(e.id),L(null);try{await t(),await Y()}catch(e){L(e instanceof Error?e.message:String(e))}finally{J(null)}},[Y]),$=(0,B.useCallback)(async(e,t)=>{fe(e.id),L(null);try{await t({kind:e.kind,runId:e.runId}),await Y()}catch(e){L(e instanceof Error?e.message:String(e))}finally{fe(null)}},[Y]);return(0,B.useLayoutEffect)(()=>(d({startExtra:null,main:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,G.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.home.subtitle})]}),end:he}),()=>h()),[h,he,d,t.title,t.home.subtitle]),(0,G.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1200px] flex-1 flex-col gap-7 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,G.jsx)(C,{open:te,onOpenChange:e=>{U||R(e),e&&(q(null),H(crypto.randomUUID()))},children:(0,G.jsxs)(b,{children:[(0,G.jsx)(_,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,G.jsxs)(x,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,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-float focus:outline-none`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(S,{className:`text-base font-semibold text-fg`,children:n.dialogTitle}),(0,G.jsx)(v,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:n.dialogDescription})]}),(0,G.jsx)(y,{asChild:!0,children:(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:t.cancel,"aria-label":t.cancel,children:(0,G.jsx)(u,{className:`size-4`,"aria-hidden":!0})})})]}),(0,G.jsxs)(`form`,{onSubmit:me,className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,children:[(0,G.jsx)(`label`,{htmlFor:`new-work-task`,className:`mb-2 shrink-0 text-sm font-medium text-fg`,children:n.intentLabel}),(0,G.jsx)(`textarea`,{id:`new-work-task`,className:`min-h-32 w-full flex-1 resize-none rounded-xl border border-edge bg-surface-base p-3 text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,value:z,onChange:e=>{oe(e.target.value),H(crypto.randomUUID())},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:n.intentPlaceholder,maxLength:12e3,autoFocus:!0}),(0,G.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,G.jsx)(`span`,{children:t.home.submitShortcut}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[z.length.toLocaleString(),` / `,12e3.toLocaleString()]})]}),K?(0,G.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:K}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,G.jsx)(y,{asChild:!0,children:(0,G.jsx)(f,{type:`button`,variant:`ghost`,disabled:U,children:t.cancel})}),(0,G.jsxs)(f,{type:`submit`,variant:`primary`,className:`min-w-32`,disabled:!z.trim()||U,children:[(0,G.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),U?n.starting:n.submit]})]})]})]})]})}),N?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,G.jsx)(`span`,{children:N}),(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Y(),children:t.home.retry})]}):null,T?(0,G.jsx)(Ee,{}):g?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`section`,{className:`border-b border-edge-subtle pb-5`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.home.briefingTitle}),(0,G.jsx)(`h2`,{className:`mt-1 text-xl font-semibold tracking-tight text-fg`,children:g.decisions.length+g.attention.length>0?xe(t.home.todaySummary,{attention:g.decisions.length+g.attention.length,moving:g.briefing.progress.movingCount+g.chats.running.length}):xe(t.home.todaySummaryClear,{moving:g.briefing.progress.movingCount+g.chats.running.length})}),g.briefing.summary?(0,G.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-fg-muted`,children:g.briefing.summary}):null]}),g.tasks.running.length===0&&g.workflowRuns.active.length===0&&g.decisions.length===0&&g.attention.length===0&&g.chats.running.length===0&&g.chats.recent.length===0&&g.upcomingAutomations.length===0?(0,G.jsxs)(`section`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,G.jsx)(ae,{className:`mx-auto size-6 text-accent`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:t.home.emptyTitle}),(0,G.jsx)(`p`,{className:`mx-auto mt-1 max-w-lg text-sm leading-6 text-fg-muted`,children:t.home.emptyBody}),(0,G.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,G.jsx)(f,{type:`button`,variant:`primary`,onClick:()=>r(`/chat/new`),children:t.home.startChat}),(0,G.jsx)(f,{type:`button`,variant:`secondary`,onClick:()=>R(!0),children:n.newWork})]})]}):null,(0,G.jsxs)(`div`,{className:`grid items-start gap-6 xl:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[Z.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(M,{className:`size-4 text-danger`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.runAttention}),(0,G.jsx)(Ce,{children:Z.length.toLocaleString()})]}),(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:Z.map(e=>(0,G.jsx)(je,{item:e,href:se(c,e.href),statusLabel:e.reason===`run_timeout`?t.home.attentionTimeout:t.home.attentionFailed,retryLabel:t.home.attentionRetry,viewLabel:t.home.attentionView,acknowledgeLabel:t.home.attentionAcknowledge,busy:de===e.id,onView:()=>r(se(c,e.href)),onRetry:()=>void $(e,F),onAcknowledge:()=>void $(e,ne)},e.id))})]}):null,X.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(M,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.needsAttention}),(0,G.jsx)(Ce,{children:X.length.toLocaleString()})]}),(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:X.map(e=>e.kind===`agent_judgment`&&e.judgment?(0,G.jsx)(ke,{item:e,labels:n,busy:ue===e.id,onDecide:t=>void Q(e,()=>j(e.judgment.inboxItemId,t)),onSnooze:()=>void Q(e,()=>P(e.judgment.inboxItemId,`snoozed`)),onDismiss:()=>void Q(e,()=>P(e.judgment.inboxItemId,`resolved`)),onInstruct:t=>void Q(e,()=>le(e.judgment.inboxItemId,t))},e.id):(0,G.jsx)(Oe,{item:e,href:se(c,e.href),kindLabel:t.home.decisionKinds[e.kind],reasonLabel:t.home.decisionReasons[e.reason],approveLabel:t.home.approve,denyLabel:t.home.deny,busy:ue===e.id,onRespond:t=>void ge(e,t)},e.id))})]}):(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-success-soft text-xs text-success`,"aria-hidden":!0,children:`✓`}),t.home.nothingNeedsYou]}),(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ce,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.running}),(0,G.jsx)(Ce,{children:g.tasks.running.length.toLocaleString()})]}),(0,G.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[g.tasks.running.map(e=>(0,G.jsx)(we,{task:e,statusLabel:n.taskStatuses.running,backgroundPath:c},e.id)),g.tasks.running.length===0?(0,G.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:n.emptyRunning}):null]})]}),g.chats.recent.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.recent})}),(0,G.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:g.chats.recent.slice(0,6).map(e=>(0,G.jsx)(De,{chat:e,statusLabel:n.openChat},e.key))})]}):null]}),(0,G.jsxs)(`aside`,{className:`min-w-0 space-y-4`,"aria-label":t.home.nowTitle,children:[(0,G.jsx)(`div`,{className:`px-1`,children:(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.home.nowTitle})}),g.upcomingAutomations.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(O,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.home.scheduled})]}),(0,G.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle`,children:g.upcomingAutomations.slice(0,3).map(e=>(0,G.jsxs)(o,{to:`/automations`,className:`flex items-center justify-between gap-3 rounded-lg px-1 py-3 text-sm hover:bg-surface-hover/55`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.name||e.action}),(0,G.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:Se(e.nextRunAt,t.never)})]},e.id))})]}):null,g.recentTasks.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ee,{className:`size-4 text-success`,"aria-hidden":!0}),(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.recentTasks})]}),(0,G.jsx)(`div`,{className:`mt-3 space-y-2`,children:g.recentTasks.slice(0,3).map(e=>(0,G.jsx)(Te,{receipt:e,evidenceLabel:n.evidenceCount,remainingLabel:n.remainingCount},e.runId))})]}):null,(0,G.jsx)(pe,{}),g.briefing.wins.length>0?(0,G.jsxs)(o,{to:g.briefing.wins[0].href,className:`flex items-center justify-between gap-3 rounded-xl px-2 py-2 text-sm text-fg-muted hover:bg-surface-hover/55 hover:text-fg`,children:[(0,G.jsx)(`span`,{children:xe(t.home.completedSummary,{count:g.briefing.wins.length})}),(0,G.jsxs)(`span`,{className:`shrink-0 text-xs font-medium text-accent`,children:[t.home.viewLatestResult,` →`]})]}):null]})]})]}):null]})}export{Me as HomePage};
|
|
3
|
+
`):[]).flatMap(he));return d(Object.fromEntries([...t.keys()].map(me))),Promise.all([...t].map(async t=>{let[n,r]=t,i=await W(r,e.signal);e.signal.aborted||d(e=>({...e,[n]:i}))})).catch(Z),()=>e.abort()},T=[S],e[10]=S,e[11]=C,e[12]=T),(0,B.useEffect)(C,T);let E;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,G.jsx)(k,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),e[13]=E):E=e[13],(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,"aria-labelledby":`workbench-activity-title`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsx)(`div`,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,(0,G.jsx)(`h2`,{id:`workbench-activity-title`,className:`text-sm font-semibold text-fg`,children:t.activityTitle}),g>0?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:[(0,G.jsx)(c,{className:`size-3 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),g,` `,t.running]}):v>0?(0,G.jsxs)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[v,` `,t.activityNew]}):null]})}),a&&n.length>0?(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[v>0?(0,G.jsxs)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:r,children:[(0,G.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),t.activityMarkRead]}):null,n.some(X)?(0,G.jsxs)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-fg-muted`,onClick:i,children:[(0,G.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0}),t.activityClearFinished]}):null]}):null]}),n.length>0?(0,G.jsxs)(`div`,{className:`mt-3 px-1`,children:[b.map(e=>(0,G.jsx)(J,{item:e,targetAvailability:e.href&&U(e.href)?u[e.href]??`checking`:`available`},e.id)),n.length>K?(0,G.jsx)(`div`,{className:`border-t border-edge-subtle py-2 text-center`,children:(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>o(Y),children:a?t.activityShowLess:t.activityShowAll.replace(`{{count}}`,String(n.length))})}):null]}):(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(L,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,G.jsx)(`p`,{children:t.activityEmpty})]})]})}function Y(e){return!e}function X(e){return e.status===`done`}function Z(){}function me(e){return[e,`checking`]}function he(e){let t=U(e);return t?[[e,t]]:[]}function ge(e){return e.href&&U(e.href)?[e.href]:[]}function Q(e){return!e.read}function $(e){return e.status===`running`}function _e(e){return e.clearFinished}function ve(e){return e.markAllRead}function ye(e){return e.items}function be(e){return e.language}function xe(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Se(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:z(n)}function Ce(e){let t=(0,V.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,G.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function we(e){let t=(0,V.c)(18),{task:n,statusLabel:r,backgroundPath:i}=e,a;t[0]!==i||t[1]!==n.id?(a=re(i,n.id),t[0]=i,t[1]=n.id,t[2]=a):a=t[2];let s;t[3]===n.title?s=t[4]:(s=(0,G.jsx)(`h3`,{className:`line-clamp-2 text-sm font-semibold text-fg`,children:n.title}),t[3]=n.title,t[4]=s);let c;t[5]===n.updatedAt?c=t[6]:(c=Se(n.updatedAt,``),t[5]=n.updatedAt,t[6]=c);let l;t[7]===c?l=t[8]:(l=(0,G.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:c}),t[7]=c,t[8]=l);let u;t[9]!==s||t[10]!==l?(u=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[s,l]}),t[9]=s,t[10]=l,t[11]=u):u=t[11];let d;t[12]===r?d=t[13]:(d=(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[12]=r,t[13]=d);let f;return t[14]!==a||t[15]!==u||t[16]!==d?(f=(0,G.jsxs)(o,{to:a,className:`group flex items-start justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,d]}),t[14]=a,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function Te(e){let t=(0,V.c)(12),{receipt:n,evidenceLabel:r,remainingLabel:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,G.jsx)(se,{className:`mt-0.5 size-4 shrink-0 text-success`,"aria-hidden":!0}),t[0]=a):a=t[0];let o,s;t[1]===n.summary?(o=t[2],s=t[3]):(o=(0,G.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:n.summary}),s=(0,G.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.summary}),t[1]=n.summary,t[2]=o,t[3]=s);let c=n.remainingWork.length>0?` · ${n.remainingWork.length} ${i}`:``,l;t[4]!==r||t[5]!==n.evidence.length||t[6]!==c?(l=(0,G.jsxs)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:[n.evidence.length,` `,r,c]}),t[4]=r,t[5]=n.evidence.length,t[6]=c,t[7]=l):l=t[7];let u;return t[8]!==o||t[9]!==s||t[10]!==l?(u=(0,G.jsx)(`div`,{className:`block rounded-xl border border-edge-subtle px-3 py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[a,(0,G.jsxs)(`div`,{className:`min-w-0`,children:[o,s,l]})]})}),t[8]=o,t[9]=s,t[10]=l,t[11]=u):u=t[11],u}function Ee(){let e=(0,V.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,G.jsx)(T,{className:`h-20 rounded-2xl`}),(0,G.jsx)(T,{className:`h-72 rounded-2xl`}),(0,G.jsx)(T,{className:`h-44 rounded-2xl`})]}),e[0]=t):t=e[0],t}function De(e){let t=(0,V.c)(15),{chat:n,statusLabel:r}=e,i=`/chat/${encodeURIComponent(n.key)}`,a;t[0]===n.name?a=t[1]:(a=(0,G.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.name}),t[0]=n.name,t[1]=a);let s;t[2]===r?s=t[3]:(s=(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===n.updatedAt?l=t[8]:(l=Se(n.updatedAt,``),t[7]=n.updatedAt,t[8]=l);let u;t[9]===l?u=t[10]:(u=(0,G.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:l}),t[9]=l,t[10]=u);let d;return t[11]!==i||t[12]!==c||t[13]!==u?(d=(0,G.jsxs)(o,{to:i,className:`group block rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[c,u]}),t[11]=i,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function Oe(e){let t=(0,V.c)(27),{item:n,href:r,kindLabel:i,reasonLabel:a,approveLabel:s,denyLabel:c,busy:l,onRespond:u}=e,d;t[0]===n.title?d=t[1]:(d=(0,G.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=d);let p=n.projectName||i,m;t[2]===p?m=t[3]:(m=(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:p}),t[2]=p,t[3]=m);let h;t[4]!==d||t[5]!==m?(h=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[d,m]}),t[4]=d,t[5]=m,t[6]=h):h=t[6];let g;t[7]===a?g=t[8]:(g=(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[7]=a,t[8]=g);let _;t[9]!==h||t[10]!==g?(_=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[h,g]}),t[9]=h,t[10]=g,t[11]=_):_=t[11];let v;t[12]===n.detail?v=t[13]:(v=n.detail?(0,G.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.detail}):null,t[12]=n.detail,t[13]=v);let y;t[14]!==r||t[15]!==_||t[16]!==v?(y=(0,G.jsxs)(o,{to:r,className:`group block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[_,v]}),t[14]=r,t[15]=_,t[16]=v,t[17]=y):y=t[17];let b;t[18]!==s||t[19]!==l||t[20]!==c||t[21]!==n.response||t[22]!==u?(b=n.response?(0,G.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2 border-t border-warning/20 pt-3`,children:[(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:()=>u(`deny`),children:c}),(0,G.jsx)(f,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:l,onClick:()=>u(`approve`),children:s})]}):null,t[18]=s,t[19]=l,t[20]=c,t[21]=n.response,t[22]=u,t[23]=b):b=t[23];let x;return t[24]!==y||t[25]!==b?(x=(0,G.jsxs)(`article`,{className:`rounded-xl border border-warning/35 bg-warning-soft/25 p-3.5 transition-colors hover:bg-warning-soft/40`,children:[y,b]}),t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function ke(e){let t=(0,V.c)(74),{item:n,labels:r,busy:i,onDecide:a,onSnooze:o,onDismiss:s,onInstruct:c}=e,[l,u]=(0,B.useState)(``),d=n.judgment,p;t[0]===n.title?p=t[1]:(p=(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=p);let m;t[2]===n.detail?m=t[3]:(m=(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[2]=n.detail,t[3]=m);let h;t[4]!==p||t[5]!==m?(h=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[p,m]}),t[4]=p,t[5]=m,t[6]=h):h=t[6];let g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,G.jsx)(ce,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[7]=g):g=t[7];let _;t[8]===h?_=t[9]:(_=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[h,g]}),t[8]=h,t[9]=_);let v;t[10]!==d.whyNow||t[11]!==r.whyNow?(v=[r.whyNow,d.whyNow],t[10]=d.whyNow,t[11]=r.whyNow,t[12]=v):v=t[12];let y;t[13]!==d.impact||t[14]!==r.impact?(y=[r.impact,d.impact],t[13]=d.impact,t[14]=r.impact,t[15]=y):y=t[15];let b;t[16]!==d.workDone||t[17]!==r.workDone?(b=[r.workDone,d.workDone],t[16]=d.workDone,t[17]=r.workDone,t[18]=b):b=t[18];let x;t[19]!==d.recommendation||t[20]!==r.recommendation?(x=[r.recommendation,d.recommendation],t[19]=d.recommendation,t[20]=r.recommendation,t[21]=x):x=t[21];let S;t[22]!==v||t[23]!==y||t[24]!==b||t[25]!==x?(S=(0,G.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[v,y,b,x].map(Ae)}),t[22]=v,t[23]=y,t[24]=b,t[25]=x,t[26]=S):S=t[26];let C;t[27]!==d.actionError||t[28]!==d.actionStatus||t[29]!==d.dispositionReason||t[30]!==d.proposedActionTitle||t[31]!==r.actionStates||t[32]!==r.policyReason||t[33]!==r.proposedAction?(C=d.dispositionReason?(0,G.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-panel/70 p-3 text-xs leading-5`,children:[(0,G.jsx)(`p`,{className:`font-medium text-fg-subtle`,children:r.policyReason}),(0,G.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:d.dispositionReason}),d.proposedActionTitle?(0,G.jsxs)(`p`,{className:`mt-2 text-fg`,children:[(0,G.jsxs)(`span`,{className:`font-medium`,children:[r.proposedAction,`:`]}),d.proposedActionTitle,d.actionStatus?` · ${r.actionStates[d.actionStatus]}`:``]}):null,d.actionError?(0,G.jsx)(`p`,{className:`mt-1 text-danger`,children:d.actionError}):null]}):null,t[27]=d.actionError,t[28]=d.actionStatus,t[29]=d.dispositionReason,t[30]=d.proposedActionTitle,t[31]=r.actionStates,t[32]=r.policyReason,t[33]=r.proposedAction,t[34]=C):C=t[34];let w;t[35]!==i||t[36]!==d.decision||t[37]!==a?(w=d.decision?(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:d.decision.question}),(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:d.decision.options.map(e=>(0,G.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-auto min-h-9 flex-col items-start px-3 py-2 text-left`,disabled:i,title:e.consequence,onClick:()=>a(e.id),children:[(0,G.jsx)(`span`,{children:e.label}),(0,G.jsx)(`span`,{className:`text-[10px] font-normal text-fg-muted`,children:e.consequence})]},e.id))})]}):null,t[35]=i,t[36]=d.decision,t[37]=a,t[38]=w):w=t[38];let T;t[39]!==i||t[40]!==r.snooze||t[41]!==o?(T=(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:i,onClick:o,children:r.snooze}),t[39]=i,t[40]=r.snooze,t[41]=o,t[42]=T):T=t[42];let E;t[43]!==i||t[44]!==r.dismiss||t[45]!==s?(E=(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:i,onClick:s,children:r.dismiss}),t[43]=i,t[44]=r.dismiss,t[45]=s,t[46]=E):E=t[46];let D;t[47]!==T||t[48]!==E?(D=(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 border-t border-edge-subtle pt-3`,children:[T,E]}),t[47]=T,t[48]=E,t[49]=D):D=t[49];let O;t[50]!==l||t[51]!==c?(O=e=>{e.preventDefault();let t=l.trim();t&&(c(t),u(``))},t[50]=l,t[51]=c,t[52]=O):O=t[52];let k;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>u(e.target.value),t[53]=k):k=t[53];let A;t[54]!==l||t[55]!==r.feedbackPlaceholder?(A=(0,G.jsx)(`input`,{className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-base px-3 py-2 text-xs text-fg outline-none focus:border-accent`,value:l,onChange:k,placeholder:r.feedbackPlaceholder}),t[54]=l,t[55]=r.feedbackPlaceholder,t[56]=A):A=t[56];let j;t[57]!==i||t[58]!==l?(j=i||!l.trim(),t[57]=i,t[58]=l,t[59]=j):j=t[59];let M;t[60]!==r.applyFeedback||t[61]!==j?(M=(0,G.jsx)(f,{type:`submit`,variant:`secondary`,className:`h-9 px-3`,disabled:j,children:r.applyFeedback}),t[60]=r.applyFeedback,t[61]=j,t[62]=M):M=t[62];let N;t[63]!==O||t[64]!==A||t[65]!==M?(N=(0,G.jsxs)(`form`,{className:`mt-3 flex gap-2`,onSubmit:O,children:[A,M]}),t[63]=O,t[64]=A,t[65]=M,t[66]=N):N=t[66];let P;return t[67]!==S||t[68]!==C||t[69]!==w||t[70]!==D||t[71]!==N||t[72]!==_?(P=(0,G.jsxs)(`article`,{className:`rounded-xl border border-accent/25 bg-accent-soft/15 p-4`,children:[_,S,C,w,D,N]}),t[67]=S,t[68]=C,t[69]=w,t[70]=D,t[71]=N,t[72]=_,t[73]=P):P=t[73],P}function Ae(e){let[t,n]=e;return(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 p-3`,children:[(0,G.jsx)(`p`,{className:`text-[11px] font-medium text-fg-subtle`,children:t}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg`,children:n})]},t)}function je(e){let t=(0,V.c)(32),{item:n,href:r,statusLabel:i,retryLabel:a,viewLabel:s,acknowledgeLabel:c,busy:l,onView:u,onRetry:d,onAcknowledge:p}=e,m;t[0]===n.title?m=t[1]:(m=(0,G.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=m);let h;t[2]===i?h=t[3]:(h=(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-danger`,children:i}),t[2]=i,t[3]=h);let g;t[4]!==m||t[5]!==h?(g=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[m,h]}),t[4]=m,t[5]=h,t[6]=g):g=t[6];let _;t[7]===n.detail?_=t[8]:(_=(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[7]=n.detail,t[8]=_);let v;t[9]!==r||t[10]!==g||t[11]!==_?(v=(0,G.jsxs)(o,{to:r,className:`block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[g,_]}),t[9]=r,t[10]=g,t[11]=_,t[12]=v):v=t[12];let y;t[13]!==c||t[14]!==l||t[15]!==p?(y=(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:p,children:c}),t[13]=c,t[14]=l,t[15]=p,t[16]=y):y=t[16];let b;t[17]!==l||t[18]!==u||t[19]!==s?(b=(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:u,children:s}),t[17]=l,t[18]=u,t[19]=s,t[20]=b):b=t[20];let x;t[21]!==l||t[22]!==d||t[23]!==a?(x=(0,G.jsx)(f,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:l,onClick:d,children:a}),t[21]=l,t[22]=d,t[23]=a,t[24]=x):x=t[24];let S;t[25]!==y||t[26]!==b||t[27]!==x?(S=(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2 border-t border-danger/15 pt-3`,children:[y,b,x]}),t[25]=y,t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;return t[29]!==v||t[30]!==S?(C=(0,G.jsxs)(`article`,{className:`rounded-xl border border-danger/25 bg-danger-soft/35 p-3.5`,children:[v,S]}),t[29]=v,t[30]=S,t[31]=C):C=t[31],C}function Me(){let e=m(e=>e.language),t=p(e).projectsPage,n=ne(e),r=a(),s=i(),c=`${s.pathname}${s.search}`,d=I(e=>e.setPageHeader),h=I(e=>e.clearPageHeader),[g,w]=(0,B.useState)(null),[T,k]=(0,B.useState)(!0),[M,N]=(0,B.useState)(null),[ee,L]=(0,B.useState)(!1),[R,z]=(0,B.useState)(``),[V,H]=(0,B.useState)(()=>crypto.randomUUID()),[U,W]=(0,B.useState)(!1),[K,q]=(0,B.useState)(null),[ue,J]=(0,B.useState)(null),[de,fe]=(0,B.useState)(null),Y=(0,B.useCallback)(async(t=!1)=>{t&&k(!0),N(null);try{w(await O(e))}catch(e){N(e instanceof Error?e.message:String(e))}finally{k(!1)}},[e]);(0,B.useEffect)(()=>{Y(!0)},[Y]),(0,B.useEffect)(()=>{let e,t=t=>{e!==void 0&&window.clearTimeout(e),e=window.setTimeout(()=>{e=void 0,Y()},t)},n=()=>t(100),r=()=>t(750),i=[`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`],a=[`session-updated`,`session-transcript-updated`];return i.forEach(e=>window.addEventListener(e,n)),a.forEach(e=>window.addEventListener(e,r)),()=>{i.forEach(e=>window.removeEventListener(e,n)),a.forEach(e=>window.removeEventListener(e,r)),e!==void 0&&window.clearTimeout(e)}},[Y]);let X=(0,B.useMemo)(()=>g?.decisions??[],[g]),Z=(0,B.useMemo)(()=>g?.attention??[],[g]),me=(0,B.useCallback)(async t=>{t.preventDefault();let n=R.trim();if(!(!n||U)){W(!0),q(null);try{let t=await A({idempotencyKey:V,title:n,locale:e,priority:`normal`,contract:{objective:n,expectedOutputs:[],acceptanceCriteria:[],constraints:[],approvalRequired:[],assumptions:[],risks:[],acceptancePolicy:`manual`,outputDestinations:[]},dependencies:[],context:[],authorityGrants:[],activation:{mode:`start`}});L(!1),z(``),H(crypto.randomUUID()),r(re(c,t.task.id))}catch(e){q(e instanceof Error?e.message:String(e))}finally{W(!1)}}},[c,V,U,e,r,R]),he=(0,B.useMemo)(()=>(0,G.jsxs)(f,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>L(!0),children:[(0,G.jsx)(l,{className:`size-4`,"aria-hidden":!0}),n.newWork]}),[n.newWork]),ge=(0,B.useCallback)(async(e,t)=>{if(e.response){J(e.id),N(null);try{await E(e.response,t),await Y()}catch(e){N(e instanceof Error?e.message:String(e))}finally{J(null)}}},[Y]),Q=(0,B.useCallback)(async(e,t)=>{J(e.id),N(null);try{await t(),await Y()}catch(e){N(e instanceof Error?e.message:String(e))}finally{J(null)}},[Y]),$=(0,B.useCallback)(async(e,t)=>{fe(e.id),N(null);try{await t({kind:e.kind,runId:e.runId}),await Y()}catch(e){N(e instanceof Error?e.message:String(e))}finally{fe(null)}},[Y]);return(0,B.useLayoutEffect)(()=>(d({startExtra:null,main:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,G.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.home.subtitle})]}),end:he}),()=>h()),[h,he,d,t.title,t.home.subtitle]),(0,G.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1200px] flex-1 flex-col gap-7 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,G.jsx)(C,{open:ee,onOpenChange:e=>{U||L(e),e&&(q(null),H(crypto.randomUUID()))},children:(0,G.jsxs)(b,{children:[(0,G.jsx)(_,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,G.jsxs)(x,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,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-float focus:outline-none`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(S,{className:`text-base font-semibold text-fg`,children:n.dialogTitle}),(0,G.jsx)(v,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:n.dialogDescription})]}),(0,G.jsx)(y,{asChild:!0,children:(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:t.cancel,"aria-label":t.cancel,children:(0,G.jsx)(u,{className:`size-4`,"aria-hidden":!0})})})]}),(0,G.jsxs)(`form`,{onSubmit:me,className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,children:[(0,G.jsx)(`label`,{htmlFor:`new-work-task`,className:`mb-2 shrink-0 text-sm font-medium text-fg`,children:n.intentLabel}),(0,G.jsx)(`textarea`,{id:`new-work-task`,className:`min-h-32 w-full flex-1 resize-none rounded-xl border border-edge bg-surface-base p-3 text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,value:R,onChange:e=>{z(e.target.value),H(crypto.randomUUID())},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:n.intentPlaceholder,maxLength:12e3,autoFocus:!0}),(0,G.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,G.jsx)(`span`,{children:t.home.submitShortcut}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[R.length.toLocaleString(),` / `,12e3.toLocaleString()]})]}),K?(0,G.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:K}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,G.jsx)(y,{asChild:!0,children:(0,G.jsx)(f,{type:`button`,variant:`ghost`,disabled:U,children:t.cancel})}),(0,G.jsxs)(f,{type:`submit`,variant:`primary`,className:`min-w-32`,disabled:!R.trim()||U,children:[(0,G.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),U?n.starting:n.submit]})]})]})]})]})}),M?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,G.jsx)(`span`,{children:M}),(0,G.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Y(),children:t.home.retry})]}):null,T?(0,G.jsx)(Ee,{}):g?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`section`,{className:`border-b border-edge-subtle pb-5`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.home.briefingTitle}),(0,G.jsx)(`h2`,{className:`mt-1 text-xl font-semibold tracking-tight text-fg`,children:g.decisions.length+g.attention.length>0?xe(t.home.todaySummary,{attention:g.decisions.length+g.attention.length,moving:g.briefing.progress.movingCount+g.chats.running.length}):xe(t.home.todaySummaryClear,{moving:g.briefing.progress.movingCount+g.chats.running.length})}),g.briefing.summary?(0,G.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-fg-muted`,children:g.briefing.summary}):null]}),g.tasks.running.length===0&&g.workflowRuns.active.length===0&&g.decisions.length===0&&g.attention.length===0&&g.chats.running.length===0&&g.chats.recent.length===0&&g.upcomingAutomations.length===0?(0,G.jsxs)(`section`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,G.jsx)(ie,{className:`mx-auto size-6 text-accent`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:t.home.emptyTitle}),(0,G.jsx)(`p`,{className:`mx-auto mt-1 max-w-lg text-sm leading-6 text-fg-muted`,children:t.home.emptyBody}),(0,G.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,G.jsx)(f,{type:`button`,variant:`primary`,onClick:()=>r(`/chat/new`),children:t.home.startChat}),(0,G.jsx)(f,{type:`button`,variant:`secondary`,onClick:()=>L(!0),children:n.newWork})]})]}):null,(0,G.jsxs)(`div`,{className:`grid items-start gap-6 xl:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[Z.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(oe,{className:`size-4 text-danger`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.runAttention}),(0,G.jsx)(Ce,{children:Z.length.toLocaleString()})]}),(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:Z.map(e=>(0,G.jsx)(je,{item:e,href:ae(c,e.href),statusLabel:e.reason===`run_timeout`?t.home.attentionTimeout:t.home.attentionFailed,retryLabel:t.home.attentionRetry,viewLabel:t.home.attentionView,acknowledgeLabel:t.home.attentionAcknowledge,busy:de===e.id,onView:()=>r(ae(c,e.href)),onRetry:()=>void $(e,F),onAcknowledge:()=>void $(e,te)},e.id))})]}):null,X.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(oe,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.needsAttention}),(0,G.jsx)(Ce,{children:X.length.toLocaleString()})]}),(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:X.map(e=>e.kind===`agent_judgment`&&e.judgment?(0,G.jsx)(ke,{item:e,labels:n,busy:ue===e.id,onDecide:t=>void Q(e,()=>j(e.judgment.inboxItemId,t)),onSnooze:()=>void Q(e,()=>P(e.judgment.inboxItemId,`snoozed`)),onDismiss:()=>void Q(e,()=>P(e.judgment.inboxItemId,`resolved`)),onInstruct:t=>void Q(e,()=>le(e.judgment.inboxItemId,t))},e.id):(0,G.jsx)(Oe,{item:e,href:ae(c,e.href),kindLabel:t.home.decisionKinds[e.kind],reasonLabel:t.home.decisionReasons[e.reason],approveLabel:t.home.approve,denyLabel:t.home.deny,busy:ue===e.id,onRespond:t=>void ge(e,t)},e.id))})]}):(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-success-soft text-xs text-success`,"aria-hidden":!0,children:`✓`}),t.home.nothingNeedsYou]}),(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ce,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.running}),(0,G.jsx)(Ce,{children:g.tasks.running.length.toLocaleString()})]}),(0,G.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[g.tasks.running.map(e=>(0,G.jsx)(we,{task:e,statusLabel:n.taskStatuses.running,backgroundPath:c},e.id)),g.tasks.running.length===0?(0,G.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:n.emptyRunning}):null]})]}),g.chats.recent.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.recent})}),(0,G.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:g.chats.recent.slice(0,6).map(e=>(0,G.jsx)(De,{chat:e,statusLabel:n.openChat},e.key))})]}):null]}),(0,G.jsxs)(`aside`,{className:`min-w-0 space-y-4`,"aria-label":t.home.nowTitle,children:[(0,G.jsx)(`div`,{className:`px-1`,children:(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.home.nowTitle})}),g.upcomingAutomations.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(D,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.home.scheduled})]}),(0,G.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle`,children:g.upcomingAutomations.slice(0,3).map(e=>(0,G.jsxs)(o,{to:`/automations`,className:`flex items-center justify-between gap-3 rounded-lg px-1 py-3 text-sm hover:bg-surface-hover/55`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.name||e.action}),(0,G.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:Se(e.nextRunAt,t.never)})]},e.id))})]}):null,g.recentTasks.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(se,{className:`size-4 text-success`,"aria-hidden":!0}),(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.recentTasks})]}),(0,G.jsx)(`div`,{className:`mt-3 space-y-2`,children:g.recentTasks.slice(0,3).map(e=>(0,G.jsx)(Te,{receipt:e,evidenceLabel:n.evidenceCount,remainingLabel:n.remainingCount},e.runId))})]}):null,(0,G.jsx)(pe,{}),g.briefing.wins.length>0?(0,G.jsxs)(o,{to:g.briefing.wins[0].href,className:`flex items-center justify-between gap-3 rounded-xl px-2 py-2 text-sm text-fg-muted hover:bg-surface-hover/55 hover:text-fg`,children:[(0,G.jsx)(`span`,{children:xe(t.home.completedSummary,{count:g.briefing.wins.length})}),(0,G.jsxs)(`span`,{className:`shrink-0 text-xs font-medium text-accent`,children:[t.home.viewLatestResult,` →`]})]}):null]})]})]}):null]})}export{Me as HomePage};
|