@xopcai/xopc 0.0.131 → 0.0.132

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +23 -26
  2. package/README.zh-CN.md +25 -28
  3. package/dist/browser-ext/icons/icon-128.png +0 -0
  4. package/dist/browser-ext/icons/icon-16.png +0 -0
  5. package/dist/browser-ext/icons/icon-32.png +0 -0
  6. package/dist/browser-ext/icons/icon-48.png +0 -0
  7. package/dist/browser-ext/manifest.json +1 -1
  8. package/dist/extensions/telegram/xopc.extension.json +1 -1
  9. package/dist/extensions/weixin/src/messaging/process-message.js +5 -8
  10. package/dist/extensions/weixin/src/messaging/process-message.js.map +1 -1
  11. package/dist/extensions/weixin/src/plugin.js +11 -1
  12. package/dist/extensions/weixin/src/plugin.js.map +1 -1
  13. package/dist/extensions/weixin/src/routing-integration.d.ts +7 -0
  14. package/dist/extensions/weixin/src/routing-integration.js +17 -0
  15. package/dist/extensions/weixin/src/routing-integration.js.map +1 -0
  16. package/dist/gateway/static/root/apple-touch-icon.png +0 -0
  17. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BJYeTxQ9.js → agent-avatar-dicebear-CnZIdUyv.js} +1 -1
  18. package/dist/gateway/static/root/assets/agents-C-rdLOrb.js +2 -0
  19. package/dist/gateway/static/root/assets/{app-management-settings-panel-Bj8iJ-7d.js → app-management-settings-panel-BcvaXb7T.js} +1 -1
  20. package/dist/gateway/static/root/assets/{appearance-settings-6TjISbHB.js → appearance-settings-CuxzNz-I.js} +1 -1
  21. package/dist/gateway/static/root/assets/{apps-page-DC4YwXLL.js → apps-page-_VJm0o44.js} +1 -1
  22. package/dist/gateway/static/root/assets/{archive-plugin-2G62raBg.js → archive-plugin-CcXXh0X9.js} +1 -1
  23. package/dist/gateway/static/root/assets/{attachment-load-kLNJMEJh.js → attachment-load-BYhYBw17.js} +1 -1
  24. package/dist/gateway/static/root/assets/{automation-suggestion-card-CpcZSSD8.js → automation-suggestion-card-ByjDtlOw.js} +1 -1
  25. package/dist/gateway/static/root/assets/automations-page-DUFct5t3.js +4 -0
  26. package/dist/gateway/static/root/assets/{binary-plugins-C_zSrWow.js → binary-plugins-B1A5KhWX.js} +1 -1
  27. package/dist/gateway/static/root/assets/{block-editor-D_PMrT-l.js → block-editor-DWpXiVTf.js} +1 -1
  28. package/dist/gateway/static/root/assets/{browser-settings-page-C89wKfPd.js → browser-settings-page-Cff75b5Z.js} +1 -1
  29. package/dist/gateway/static/root/assets/{capability-presets-api-CPFtajl7.js → capability-presets-api-DFWL6PJ0.js} +1 -1
  30. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DWw31-4v.js → capability-presets-settings-panel-CBT89nI-.js} +1 -1
  31. package/dist/gateway/static/root/assets/{channel-recipient-api-BUi8syv2.js → channel-recipient-api-RANYrzfa.js} +1 -1
  32. package/dist/gateway/static/root/assets/channels-settings-DHBjZ2fa.js +1 -0
  33. package/dist/gateway/static/root/assets/channels-status-swr-BG_j4Ci-.js +1 -0
  34. package/dist/gateway/static/root/assets/{connectors-page-DCE-PgQF.js → connectors-page-B4CGNErH.js} +1 -1
  35. package/dist/gateway/static/root/assets/{desktop-pet-BYV16wez.js → desktop-pet-CDD29oYv.js} +1 -1
  36. package/dist/gateway/static/root/assets/{desktop-pet-settings-DGIaFqPR.js → desktop-pet-settings-CEkfvSnb.js} +1 -1
  37. package/dist/gateway/static/root/assets/{directory-picker-path-field-BEhDuShd.js → directory-picker-path-field-JbVQ2_md.js} +1 -1
  38. package/dist/gateway/static/root/assets/dreaming-settings-C-fzh8SN.js +3 -0
  39. package/dist/gateway/static/root/assets/{extension-debug-page-BIjLZMAQ.js → extension-debug-page-B4jZ0Yim.js} +1 -1
  40. package/dist/gateway/static/root/assets/{extension-page-Cxv4Bgj5.js → extension-page-Bi0GmOZ2.js} +1 -1
  41. package/dist/gateway/static/root/assets/{extension-settings-page-DNd0tRFl.js → extension-settings-page-BJpxz8Dq.js} +1 -1
  42. package/dist/gateway/static/root/assets/{fetch-Bl7zMnmd.js → fetch-6HXXdO77.js} +1 -1
  43. package/dist/gateway/static/root/assets/{gateway-config-api-BiqKIkkp.js → gateway-config-api-Ci1tJtJ4.js} +1 -1
  44. package/dist/gateway/static/root/assets/{gateway-settings-D_Cvasqi.js → gateway-settings-C-YBJHLX.js} +1 -1
  45. package/dist/gateway/static/root/assets/{gateway-startup-retry-CPOgTcpv.js → gateway-startup-retry-BE1M9fH_.js} +1 -1
  46. package/dist/gateway/static/root/assets/goal-create-dialog-DhfNsglx.js +1 -0
  47. package/dist/gateway/static/root/assets/{goal-detail-page-DF8QhTHH.js → goal-detail-page-9WeYgD-u.js} +1 -1
  48. package/dist/gateway/static/root/assets/{goals-config-api-h26_-2Vm.js → goals-config-api-DRJGqa_W.js} +1 -1
  49. package/dist/gateway/static/root/assets/{goals-page-BzBKHZJg.js → goals-page-DXEQqzEX.js} +1 -1
  50. package/dist/gateway/static/root/assets/{goals-settings-BFG1uTI8.js → goals-settings-5pFGRkD6.js} +1 -1
  51. package/dist/gateway/static/root/assets/heartbeat-settings-CGX78-fM.js +1 -0
  52. package/dist/gateway/static/root/assets/{index-DOetFpTt.js → index-BjGnv8uJ.js} +41 -41
  53. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Dpx1ovO6.js → keyboard-shortcuts-settings-D23eHsli.js} +1 -1
  54. package/dist/gateway/static/root/assets/{logs-page-3QO3elfx.js → logs-page-jMLLOxWk.js} +1 -1
  55. package/dist/gateway/static/root/assets/{markdown-split-Ba4EsPkV.js → markdown-split-Dn7rJV-v.js} +1 -1
  56. package/dist/gateway/static/root/assets/{media-plugins-lA5rvtCq.js → media-plugins-DOnTRGyE.js} +1 -1
  57. package/dist/gateway/static/root/assets/{messages-Bq4REfIj.js → messages-DR9ODkb8.js} +2 -2
  58. package/dist/gateway/static/root/assets/{models-hub-panel-BBG87CHZ.js → models-hub-panel-Br6l-Di9.js} +1 -1
  59. package/dist/gateway/static/root/assets/{notes-page-DrUGE-Hn.js → notes-page-BiXfX1he.js} +1 -1
  60. package/dist/gateway/static/root/assets/{notes-workbench-eAIE8iKV.js → notes-workbench-DjaTvXj3.js} +2 -2
  61. package/dist/gateway/static/root/assets/{page-tabs-Cy7bX7Ce.js → page-tabs-CYEVap7D.js} +1 -1
  62. package/dist/gateway/static/root/assets/{preview-open-alternatives-B9_iql49.js → preview-open-alternatives-Dk7Cjd6E.js} +1 -1
  63. package/dist/gateway/static/root/assets/project-detail-page-B6UccBNl.js +1 -0
  64. package/dist/gateway/static/root/assets/projects-page-B56s8p-Q.js +1 -0
  65. package/dist/gateway/static/root/assets/{remote-access-hub-C29EWM0P.js → remote-access-hub-D3ekwIaB.js} +1 -1
  66. package/dist/gateway/static/root/assets/{save-bar-controls-nMloZ0mp.js → save-bar-controls-D7FzAPOc.js} +1 -1
  67. package/dist/gateway/static/root/assets/{schedule-field-BuajpVNF.js → schedule-field-BZP1-U9M.js} +1 -1
  68. package/dist/gateway/static/root/assets/{schema-form-IeXV_yQk.js → schema-form-1NNFTrvK.js} +1 -1
  69. package/dist/gateway/static/root/assets/{sessions-page-DHHVDqsy.js → sessions-page-08vT4R9X.js} +1 -1
  70. package/dist/gateway/static/root/assets/settings-advanced-gate-IsaFJ6ZC.js +1 -0
  71. package/dist/gateway/static/root/assets/{settings-collapsible-section-ByixWwvu.js → settings-collapsible-section-CX5IUGk1.js} +1 -1
  72. package/dist/gateway/static/root/assets/{settings-form-section-C-5-n-jM.js → settings-form-section-a71ujXN4.js} +1 -1
  73. package/dist/gateway/static/root/assets/{settings-loading-skeleton-CTA5Gje4.js → settings-loading-skeleton-D4mq628A.js} +1 -1
  74. package/dist/gateway/static/root/assets/{settings-page-DzqxeemF.js → settings-page-DSQWZsZt.js} +1 -1
  75. package/dist/gateway/static/root/assets/{settings-page-layout-DgFTf6nM.js → settings-page-layout-BG-k3_CF.js} +1 -1
  76. package/dist/gateway/static/root/assets/{setup-status-panel-svpHcJ62.js → setup-status-panel-CFBgxLKm.js} +1 -1
  77. package/dist/gateway/static/root/assets/{share-preview-page-IOjU69FC.js → share-preview-page-Cz4X3Vcf.js} +1 -1
  78. package/dist/gateway/static/root/assets/shares-settings-BHjEkA9t.js +1 -0
  79. package/dist/gateway/static/root/assets/skill-reload-api-CfHG_ekm.js +1 -0
  80. package/dist/gateway/static/root/assets/{skills-page-DoonnYRs.js → skills-page-C0KVNC0o.js} +1 -1
  81. package/dist/gateway/static/root/assets/{system-settings-panel-BMDD7FXg.js → system-settings-panel-Bo9mLewC.js} +1 -1
  82. package/dist/gateway/static/root/assets/{typed-models-lib-DayamJ56.js → typed-models-lib-Bp6wXydR.js} +1 -1
  83. package/dist/gateway/static/root/assets/{use-channel-catalog-ChYwFiqo.js → use-channel-catalog-BCBfSoHx.js} +1 -1
  84. package/dist/gateway/static/root/assets/{user-profile-settings-panel-Dd0X3mPv.js → user-profile-settings-panel-NcG1KFUf.js} +1 -1
  85. package/dist/gateway/static/root/assets/{utils-D9v9ZpK4.js → utils-BNtcPshb.js} +1 -1
  86. package/dist/gateway/static/root/assets/{voice-api-key-field-QXGvjTwa.js → voice-api-key-field-ByppRAVD.js} +1 -1
  87. package/dist/gateway/static/root/assets/{work-item-detail-page-CP-5OUYI.js → work-item-detail-page-5wdg0Xmy.js} +1 -1
  88. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-IidqhbUI.js → workflow-run-setup-panel-eKBZIV-N.js} +1 -1
  89. package/dist/gateway/static/root/assets/{workflow-start-dialog-BQQkr8YD.js → workflow-start-dialog-B6qfU5GE.js} +1 -1
  90. package/dist/gateway/static/root/assets/{workflows-page-DtVIjVSX.js → workflows-page-BtLILZtw.js} +1 -1
  91. package/dist/gateway/static/root/favicon-16x16.png +0 -0
  92. package/dist/gateway/static/root/favicon-32x32.png +0 -0
  93. package/dist/gateway/static/root/favicon-icon.svg +179 -15
  94. package/dist/gateway/static/root/favicon.ico +0 -0
  95. package/dist/gateway/static/root/favicon.png +0 -0
  96. package/dist/gateway/static/root/favicon.svg +179 -15
  97. package/dist/gateway/static/root/index.html +4 -4
  98. package/dist/gateway/static/root/logo-dark.svg +179 -15
  99. package/dist/gateway/static/root/logo.svg +179 -15
  100. package/dist/gateway/static/root/pwa-192x192.png +0 -0
  101. package/dist/gateway/static/root/pwa-512x512.png +0 -0
  102. package/dist/package.js +1 -1
  103. package/dist/src/agent/starter-agents.d.ts +1 -0
  104. package/dist/src/agent/starter-agents.js +38 -11
  105. package/dist/src/agent/starter-agents.js.map +1 -1
  106. package/dist/src/commands/agents.config.d.ts +2 -0
  107. package/dist/src/commands/agents.config.js +1 -1
  108. package/dist/src/commands/agents.config.js.map +1 -1
  109. package/dist/src/config/agent-profile.js +1 -1
  110. package/dist/src/config/schema.js +4 -2
  111. package/dist/src/config/schema.js.map +1 -1
  112. package/dist/src/gateway/agents-admin.js +1 -1
  113. package/package.json +1 -1
  114. package/dist/gateway/static/root/assets/agents-kVsY4Iz_.js +0 -2
  115. package/dist/gateway/static/root/assets/automations-page-MZ8m4bYP.js +0 -4
  116. package/dist/gateway/static/root/assets/channels-settings-DOYzcMAE.js +0 -1
  117. package/dist/gateway/static/root/assets/dreaming-settings-BIkgLFDH.js +0 -3
  118. package/dist/gateway/static/root/assets/goal-create-dialog-DZ68qzpm.js +0 -1
  119. package/dist/gateway/static/root/assets/heartbeat-settings-5vV8vTva.js +0 -1
  120. package/dist/gateway/static/root/assets/project-detail-page-Cwct6pCV.js +0 -1
  121. package/dist/gateway/static/root/assets/projects-page-BXZlzV8t.js +0 -1
  122. package/dist/gateway/static/root/assets/settings-advanced-gate-hDvmobsT.js +0 -1
  123. package/dist/gateway/static/root/assets/shares-settings-Ddg8gHPN.js +0 -1
  124. package/dist/gateway/static/root/assets/skill-reload-api-DcNOEJsK.js +0 -1
@@ -1,3 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-Bq4REfIj.js";import{a as o,n as s,o as c}from"./fetch-Bl7zMnmd.js";import{n as l}from"./locale-store-Ba72bFmP.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$a as d,El as f,Hs as p,Oo as m,Ps as h,Qo as g,Ss as _,Tt as v,Us as y,Wo as b,as as x,bl as S,bo as C,er as w,ic as T,ms as E,pa as D,to as O,us as k,wo as A,zo as j}from"./index-DOetFpTt.js";import{n as ee,r as M,t as te}from"./settings-page-layout-DgFTf6nM.js";import{n as ne,t as re}from"./settings-form-section-C-5-n-jM.js";import{t as N}from"./page-tabs-Cy7bX7Ce.js";import{n as P,t as F}from"./schedule-field-BuajpVNF.js";import{t as I}from"./format-cron-label-arqgGlVV.js";var L=e(t(),1),R=n();function z(e,t){let n=new URLSearchParams;e&&n.set(`agentId`,e);for(let[e,r]of Object.entries(t??{}))r!==void 0&&n.set(e,String(r));let r=n.toString();return r?`?${r}`:``}function B(e){return c(`/api/dreaming${z(e)}`)}async function V(e){let t=await s(e?.startsWith(`/api/`)||e?.includes(`/api/dreaming`)?e:B(e));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ie(e,t){await s(c(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e,agentId:t})})}async function ae(e=`deep`,t){let n=await s(c(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e,agentId:t})});if(n.ok===!1||!n.payload)throw Error(`Failed to run dreaming phase`);let r=n.payload.phase;return{agentId:typeof n.payload.agentId==`string`?n.payload.agentId:void 0,phase:r===`light`||r===`deep`||r===`rem`?r:e,result:n.payload.result}}async function oe(e,t){let n=await s(c(`/api/dreaming/preview${z(t,typeof e==`number`&&Number.isFinite(e)?{limit:e}:void 0)}`));if(!n.payload)throw Error(`Missing payload`);return n.payload}async function se(e=50,t){return(await s(c(`/api/dreaming/events${z(t,{limit:e})}`))).payload?.events??[]}function H(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var U={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},W={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,minUniqueQueries:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},G={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},K={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:U,deep:W,rem:G};function q(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function J(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function Y(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function ce(e){let t=H(e)?e:{},n=H(t.memory)?t.memory:{},r=H(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||H(t.phases)?t:{},a=H(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=H(a.phases)?a.phases:{},s=H(o.light)?o.light:{},c=H(o.deep)?o.deep:{},l=H(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():K.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:q(typeof c.minScore==`number`?c.minScore:Number(c.minScore),K.minScore),minRecallCount:Math.max(1,J(c.minRecallCount,K.minRecallCount)),limit:J(c.limit,K.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():U.cron,lookbackDays:Math.max(1,J(s.lookbackDays,U.lookbackDays)),limit:J(s.limit,U.limit),dedupeSimilarity:q(Y(s.dedupeSimilarity,U.dedupeSimilarity),U.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():W.cron,minScore:q(Y(c.minScore,W.minScore),W.minScore),minRecallCount:Math.max(1,J(c.minRecallCount,W.minRecallCount)),minUniqueQueries:Math.max(1,J(c.minUniqueQueries,W.minUniqueQueries)),limit:J(c.limit,W.limit),recencyHalfLifeDays:Math.max(1,Y(c.recencyHalfLifeDays,W.recencyHalfLifeDays)),maxAgeDays:Math.max(1,Y(c.maxAgeDays,W.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():G.cron,lookbackDays:Math.max(1,J(l.lookbackDays,G.lookbackDays)),limit:J(l.limit,G.limit),minPatternStrength:q(Y(l.minPatternStrength,G.minPatternStrength),G.minPatternStrength)}}}async function le(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await s(c(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({memory:{...n??{},mode:t.enabled?`confirmWrite`:typeof n?.mode==`string`?n.mode:`off`,sources:Array.isArray(n?.sources)?n.sources:[`session`,`curated`,`workspace`],writePolicy:H(n?.writePolicy)?n.writePolicy:{curated:`confirm`,workspace:`confirm`},dreaming:{enabled:!!t.enabled,...r?{frequency:r}:{},...i?{timezone:i}:{},phases:{light:{enabled:!!t.light.enabled,...t.light.cron.trim()?{cron:t.light.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.light.lookbackDays)),limit:Math.max(0,Math.floor(t.light.limit)),dedupeSimilarity:q(t.light.dedupeSimilarity,U.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:q(t.deep.minScore,W.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),minUniqueQueries:Math.max(1,Math.floor(t.deep.minUniqueQueries)),limit:Math.max(0,Math.floor(t.deep.limit)),recencyHalfLifeDays:Math.max(1,t.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,t.deep.maxAgeDays)},rem:{enabled:!!t.rem.enabled,...t.rem.cron.trim()?{cron:t.rem.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.rem.lookbackDays)),limit:Math.max(0,Math.floor(t.rem.limit)),minPatternStrength:q(t.rem.minPatternStrength,G.minPatternStrength)}}}}})}),D()}var ue=`p-4 sm:px-5`,de=`mb-3`,fe=`rounded-xl bg-surface-panel/60 p-3 shadow-surface sm:p-4`,X=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,C);function pe(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function me(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function he(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var Z=r(),ge=`text-xs font-medium text-fg-muted`,_e=`text-sm font-medium text-fg`;function Q(e){let t=(0,R.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:ge,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function $(e){let t=(0,R.c)(11),{label:n,children:r,className:a}=e,o;t[0]===a?o=t[1]:(o=i(`min-w-0`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:ge,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(_e,`mt-0.5`),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,Z.jsx)(`dd`,{className:c,children:r}),t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function ve(e){let t=(0,R.c)(5),{label:n,className:r}=e,a;t[0]===r?a=t[1]:(a=i(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,Z.jsx)(`h3`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function ye(e){let t=(0,R.c)(39),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,showEnabledControl:d,actions:f,status:p,enabledLabel:m,onLabel:h,offLabel:g,cronLabel:_,children:v}=e,y=d===void 0?!0:d,b;t[0]===n?b=t[1]:(b=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=b);let x;t[2]===r?x=t[3]:(x=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=x);let S;t[4]!==p||t[5]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[x,p]}),t[4]=p,t[5]=x,t[6]=S):S=t[6];let C;t[7]===i?C=t[8]:(C=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[7]=i,t[8]=C);let w;t[9]!==S||t[10]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[9]=S,t[10]=C,t[11]=w):w=t[11];let T;t[12]!==b||t[13]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[b,w]}),t[12]=b,t[13]=w,t[14]=T):T=t[14];let E;t[15]!==f||t[16]!==u||t[17]!==a||t[18]!==m||t[19]!==g||t[20]!==o||t[21]!==h||t[22]!==y?(E=f||y?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[f,y?(0,Z.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:e=>o(e.target.checked)}),(0,Z.jsx)(`span`,{children:m??(a?h:g)})]}):null]}):null,t[15]=f,t[16]=u,t[17]=a,t[18]=m,t[19]=g,t[20]=o,t[21]=h,t[22]=y,t[23]=E):E=t[23];let D;t[24]!==T||t[25]!==E?(D=(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 rounded-lg bg-surface-base/45 px-3 py-2.5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==_||t[29]!==u||t[30]!==c||t[31]!==l?(O=(0,Z.jsx)(F,{kind:`cron`,className:`mb-2.5`,label:_,value:s,onChange:c,labels:l,disabled:u}),t[27]=s,t[28]=_,t[29]=u,t[30]=c,t[31]=l,t[32]=O):O=t[32];let k;t[33]===v?k=t[34]:(k=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:v}),t[33]=v,t[34]=k);let A;return t[35]!==O||t[36]!==k||t[37]!==D?(A=(0,Z.jsxs)(`div`,{className:fe,children:[D,O,k]}),t[35]=O,t[36]=k,t[37]=D,t[38]=A):A=t[38],A}function be(e){let t=(0,R.c)(23),{icon:n,label:r,enabled:a,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(fe,`space-y-1`),t[0]=u):u=t[0];let d;t[1]===r?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=d);let f=a?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=i(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=a?l.on:l.off,h;t[5]!==p||t[6]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==n||t[9]!==d||t[10]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,d,h]}),t[8]=n,t[9]=d,t[10]=h,t[11]=g):g=t[11];let _;t[12]===s?_=t[13]:(_=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s}),t[12]=s,t[13]=_);let v;t[14]===o?v=t[15]:(v=(0,Z.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:o,children:o}),t[14]=o,t[15]=v);let y;t[16]===c?y=t[17]:(y=(0,Z.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:c}),t[16]=c,t[17]=y);let b;return t[18]!==y||t[19]!==g||t[20]!==_||t[21]!==v?(b=(0,Z.jsxs)(`div`,{className:u,children:[g,_,v,y]}),t[18]=y,t[19]=g,t[20]=_,t[21]=v,t[22]=b):b=t[22],b}function xe(e){let t=(0,R.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(ve,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-base/45 p-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function Se(e){let t=(0,R.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,Z.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,Z.jsx)($,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=me(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,Z.jsx)($,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,Z.jsx)($,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,Z.jsx)($,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,Z.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,Z.jsxs)($,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,Z.jsx)($,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,Z.jsx)($,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,Z.jsx)($,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function Ce(e){let t=(0,R.c)(56),{t:n,schedulePickerLabels:r,hasToken:a,cfgForm:o,cfgBaseline:s,cfgDirty:c,cfgSaving:l,runPhase:u,runBusy:d,setCfgForm:f,doRunNow:p}=e,m;t[0]!==c||t[1]!==o?.enabled||t[2]!==l||t[3]!==p||t[4]!==a||t[5]!==d||t[6]!==u||t[7]!==n?(m=(e,t)=>o?.enabled?(0,Z.jsx)(Ee,{t:n,busy:d&&u===e,disabled:!a||l||d||!t||c,title:c?n.runNowSaveFirstHint:n.runNowHint,onClick:()=>{p(e)}}):null,t[0]=c,t[1]=o?.enabled,t[2]=l,t[3]=p,t[4]=a,t[5]=d,t[6]=u,t[7]=n,t[8]=m):m=t[8];let _=m,v;t[9]!==s||t[10]!==o||t[11]!==n.phasePendingSave||t[12]!==n.phaseWillDisable||t[13]!==n.phaseWillEnable?(v=e=>{if(!o||!s)return null;let t=o[e],r=s[e];return JSON.stringify(t)===JSON.stringify(r)?null:t.enabled===r.enabled?n.phasePendingSave:t.enabled?n.phaseWillEnable:n.phaseWillDisable},t[9]=s,t[10]=o,t[11]=n.phasePendingSave,t[12]=n.phaseWillDisable,t[13]=n.phaseWillEnable,t[14]=v):v=t[14];let y=v,x;return t[15]!==c||t[16]!==o||t[17]!==l||t[18]!==a||t[19]!==y||t[20]!==_||t[21]!==r||t[22]!==f||t[23]!==n.configDeepHalfLife||t[24]!==n.configDeepLimit||t[25]!==n.configDeepMaxAge||t[26]!==n.configDeepMinRecallCount||t[27]!==n.configDeepMinScore||t[28]!==n.configDeepMinUniqueQueries||t[29]!==n.configFrequency||t[30]!==n.configLightDedupe||t[31]!==n.configLightLimit||t[32]!==n.configLightLookbackDays||t[33]!==n.configLoading||t[34]!==n.configPhaseCron||t[35]!==n.configPhaseDeep||t[36]!==n.configPhaseDeepHint||t[37]!==n.configPhaseLight||t[38]!==n.configPhaseLightHint||t[39]!==n.configPhaseRem||t[40]!==n.configPhaseRemHint||t[41]!==n.configRemLimit||t[42]!==n.configRemLookbackDays||t[43]!==n.configRemMinStrength||t[44]!==n.configTimezone||t[45]!==n.masterHint||t[46]!==n.masterOff||t[47]!==n.masterOn||t[48]!==n.masterTitle||t[49]!==n.off||t[50]!==n.on||t[51]!==n.phasesTitle||t[52]!==n.scheduleTitle||t[53]!==n.unsavedConfigHint||t[54]!==n.unsavedConfigTitle?(x=(0,Z.jsx)(re,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:i(fe,`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.masterTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.masterHint})]}),(0,Z.jsxs)(`label`,{className:i(`inline-flex w-fit cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,o.enabled?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o.enabled,disabled:!a||l,onChange:e=>f(t=>t&&{...t,enabled:e.target.checked})}),(0,Z.jsx)(`span`,{className:i(`text-xs font-semibold`,o.enabled?`text-emerald-600 dark:text-emerald-400`:``),children:o.enabled?n.masterOn:n.masterOff})]})]}),c?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-amber-900 dark:text-amber-100`,children:[(0,Z.jsx)(T,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-semibold`,children:n.unsavedConfigTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 leading-snug text-amber-800/90 dark:text-amber-100/80`,children:n.unsavedConfigHint})]})]}):null,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(we,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:fe,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,Z.jsx)(`div`,{className:`lg:col-span-9`,children:(0,Z.jsx)(F,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>f(t=>t&&{...t,frequency:e}),labels:r,disabled:!a||l})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:X,value:o.timezone,disabled:!a||l,onChange:e=>f(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(we,{title:n.phasesTitle}),(0,Z.jsxs)(ye,{icon:(0,Z.jsx)(b,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>f(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>f(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`light`,o.light.enabled),status:y(`light`)?(0,Z.jsx)(Te,{label:y(`light`)??``}):null,enabledLabel:y(`light`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configLightLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.light.lookbackDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.light.limit,disabled:!a||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightDedupe,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.light.dedupeSimilarity,disabled:!a||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(ye,{icon:(0,Z.jsx)(h,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>f(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>f(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`deep`,o.deep.enabled),status:y(`deep`)?(0,Z.jsx)(Te,{label:y(`deep`)??``}):null,enabledLabel:y(`deep`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configDeepMinScore,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.deep.minScore,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinRecallCount,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minRecallCount,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinUniqueQueries,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minUniqueQueries,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minUniqueQueries:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.deep.limit,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepHalfLife,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.recencyHalfLifeDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMaxAge,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.maxAgeDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(ye,{icon:(0,Z.jsx)(g,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>f(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>f(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`rem`,o.rem.enabled),status:y(`rem`)?(0,Z.jsx)(Te,{label:y(`rem`)??``}):null,enabledLabel:y(`rem`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configRemLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.rem.lookbackDays,disabled:!a||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.rem.limit,disabled:!a||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemMinStrength,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.rem.minPatternStrength,disabled:!a||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading})}),t[15]=c,t[16]=o,t[17]=l,t[18]=a,t[19]=y,t[20]=_,t[21]=r,t[22]=f,t[23]=n.configDeepHalfLife,t[24]=n.configDeepLimit,t[25]=n.configDeepMaxAge,t[26]=n.configDeepMinRecallCount,t[27]=n.configDeepMinScore,t[28]=n.configDeepMinUniqueQueries,t[29]=n.configFrequency,t[30]=n.configLightDedupe,t[31]=n.configLightLimit,t[32]=n.configLightLookbackDays,t[33]=n.configLoading,t[34]=n.configPhaseCron,t[35]=n.configPhaseDeep,t[36]=n.configPhaseDeepHint,t[37]=n.configPhaseLight,t[38]=n.configPhaseLightHint,t[39]=n.configPhaseRem,t[40]=n.configPhaseRemHint,t[41]=n.configRemLimit,t[42]=n.configRemLookbackDays,t[43]=n.configRemMinStrength,t[44]=n.configTimezone,t[45]=n.masterHint,t[46]=n.masterOff,t[47]=n.masterOn,t[48]=n.masterTitle,t[49]=n.off,t[50]=n.on,t[51]=n.phasesTitle,t[52]=n.scheduleTitle,t[53]=n.unsavedConfigHint,t[54]=n.unsavedConfigTitle,t[55]=x):x=t[55],x}function we(e){let t=(0,R.c)(2),{title:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`px-0.5 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Te(e){let t=(0,R.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`span`,{className:`inline-flex shrink-0 rounded-md border border-amber-500/25 bg-amber-500/10 px-1.5 py-0.5 text-[0.65rem] font-semibold text-amber-800 dark:text-amber-200`,children:n}),t[0]=n,t[1]=r),r}function Ee(e){let t=(0,R.c)(8),{t:n,busy:r,disabled:i,title:a,onClick:o}=e,s;t[0]===r?s=t[1]:(s=r?(0,Z.jsx)(y,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),t[0]=r,t[1]=s);let c;return t[2]!==i||t[3]!==o||t[4]!==n.runNow||t[5]!==s||t[6]!==a?(c=(0,Z.jsxs)(A,{type:`button`,variant:`secondary`,className:`h-7 gap-1.5 rounded-lg px-2 text-xs`,disabled:i,title:a,onClick:o,children:[s,n.runNow]}),t[2]=i,t[3]=o,t[4]=n.runNow,t[5]=s,t[6]=a,t[7]=c):c=t[7],c}function De(e){let t=(0,R.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(A,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,Z.jsx)(ne,{className:de,icon:S,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:a.map(Oe)}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,Z.jsxs)(re,{className:ue,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function Oe(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg bg-surface-panel/70 px-3 py-2 text-xs shadow-surface`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:i(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:me(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:pe(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function ke(e){let t=(0,R.c)(40),{t:n,hasToken:r,agents:i,selectedAgentId:a,onAgentChange:o,cfgForm:s,cfgSaving:c,enableAllBusy:l,cfgDirty:u,saveConfig:f,enableAllAgentsDreaming:p,doRefresh:m}=e,h;t[0]!==i||t[1]!==c||t[2]!==r||t[3]!==o||t[4]!==a?(h=i.length>0?(0,Z.jsx)(d,{className:`h-9 max-w-44 rounded-md border border-edge bg-surface-panel px-2 text-sm text-fg outline-none transition focus:border-accent`,value:a,disabled:!r||c,onChange:e=>o(e.currentTarget.value),"aria-label":`Agent`,children:i.map(Ae)}):null,t[0]=i,t[1]=c,t[2]=r,t[3]=o,t[4]=a,t[5]=h):h=t[5];let g=!r||c||l||i.length===0,_;t[6]===p?_=t[7]:(_=()=>void p(),t[6]=p,t[7]=_);let v;t[8]===l?v=t[9]:(v=l?(0,Z.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[8]=l,t[9]=v);let b;t[10]!==n.enableAllAgentsDreaming||t[11]!==g||t[12]!==_||t[13]!==v?(b=(0,Z.jsxs)(A,{type:`button`,variant:`secondary`,disabled:g,onClick:_,children:[v,n.enableAllAgentsDreaming]}),t[10]=n.enableAllAgentsDreaming,t[11]=g,t[12]=_,t[13]=v,t[14]=b):b=t[14];let x=!r||!s||c||l||!u,S;t[15]===f?S=t[16]:(S=()=>void f(),t[15]=f,t[16]=S);let C;t[17]===c?C=t[18]:(C=c?(0,Z.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[17]=c,t[18]=C);let w;t[19]!==n.saveConfig||t[20]!==x||t[21]!==S||t[22]!==C?(w=(0,Z.jsxs)(A,{type:`button`,variant:`primary`,disabled:x,onClick:S,children:[C,n.saveConfig]}),t[19]=n.saveConfig,t[20]=x,t[21]=S,t[22]=C,t[23]=w):w=t[23];let T=!r,D;t[24]===m?D=t[25]:(D=()=>void m(),t[24]=m,t[25]=D);let O;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(E,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[26]=O):O=t[26];let k;t[27]!==n.refresh||t[28]!==T||t[29]!==D?(k=(0,Z.jsx)(A,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:T,title:n.refresh,"aria-label":n.refresh,onClick:D,children:O}),t[27]=n.refresh,t[28]=T,t[29]=D,t[30]=k):k=t[30];let j;t[31]!==h||t[32]!==k||t[33]!==b||t[34]!==w?(j=(0,Z.jsxs)(Z.Fragment,{children:[h,b,w,k]}),t[31]=h,t[32]=k,t[33]=b,t[34]=w,t[35]=j):j=t[35];let M;return t[36]!==n.subtitle||t[37]!==n.title||t[38]!==j?(M=(0,Z.jsx)(ee,{title:n.title,subtitle:n.subtitle,actions:j}),t[36]=n.subtitle,t[37]=n.title,t[38]=j,t[39]=M):M=t[39],M}function Ae(e){return(0,Z.jsx)(O,{value:e.id,children:e.name||e.id},e.id)}function je(e){let t=(0,R.c)(30),{t:n,disabled:r,actionBusy:a,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`max-w-2xl`,ue),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(ne,{className:de,icon:m,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==n.confirmResetStore?(l=()=>{confirm(n.confirmResetStore)&&o(`reset_store`)},t[4]=o,t[5]=n.confirmResetStore,t[6]=l):l=t[6];let u;t[7]===a?u=t[8]:(u=a===`reset_store`?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(j,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=a,t[8]=u);let d;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(A,{variant:`secondary`,disabled:r,onClick:l,children:[u,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==o||t[15]!==n.confirmClearLock?(f=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=f):f=t[16];let h;t[17]===a?h=t[18]:(h=a===`clear_lock`?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(p,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=a,t[18]=h);let g;t[19]!==r||t[20]!==n.clearLock||t[21]!==f||t[22]!==h?(g=(0,Z.jsxs)(A,{variant:`secondary`,disabled:r,onClick:f,children:[h,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==d||t[25]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[d,g]}),t[24]=d,t[25]=g,t[26]=_):_=t[26];let v;return t[27]!==c||t[28]!==_?(v=(0,Z.jsxs)(re,{className:s,children:[c,_]}),t[27]=c,t[28]=_,t[29]=v):v=t[29],v}function Me(e){let t=(0,R.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(y,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(A,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,Z.jsx)(ne,{className:de,icon:k,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-2.5 py-2 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Z.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,Z.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,Z.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,Z.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,Z.jsxs)(re,{className:ue,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function Ne(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 null}}var Pe={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},Fe={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function Ie(e,t){return e.startsWith(`zh`)?Fe[t]:Pe[t]}function Le(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&P.has(r)){let e=Ne(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return Ie(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return Ie(t,`minute`).format(a);let o=Math.round(a/60);return Ie(t,`hour`).format(o)}function Re(e){let t=(0,R.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?I(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Le(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function ze(e){let t=(0,R.c)(100),{t:n,data:r,isLoading:a,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?he(r.lock,n):null,t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`min-w-0`,ue),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=a?(0,Z.jsx)(y,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=a,t[5]=d);let f;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==d?(f=(0,Z.jsx)(ne,{className:de,icon:S,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:d}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=d,t[9]=f):f=t[9];let p;t[10]===n.subsectionSchedule?p=t[11]:(p=(0,Z.jsx)(ve,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=p);let m=r?r.config.enabled?n.on:n.off:`—`,_;t[12]!==n.enabled||t[13]!==m?(_=(0,Z.jsx)($,{label:n.enabled,children:m}),t[12]=n.enabled,t[13]=m,t[14]=_):_=t[14];let v=l?.className,x=l?l.text:`—`,C;t[15]!==v||t[16]!==x?(C=(0,Z.jsx)(`span`,{className:v,children:x}),t[15]=v,t[16]=x,t[17]=C):C=t[17];let w;t[18]!==n.lock||t[19]!==C?(w=(0,Z.jsx)($,{label:n.lock,children:C}),t[18]=n.lock,t[19]=C,t[20]=w):w=t[20];let T=r&&r.config.timezone||`—`,E;t[21]!==n.timezone||t[22]!==T?(E=(0,Z.jsx)($,{label:n.timezone,children:T}),t[21]=n.timezone,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==r||t[25]!==o||t[26]!==s?(D=r?(0,Z.jsx)(Re,{kind:`cron`,expression:r.config.frequency,locale:o,labels:s,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=o,t[26]=s,t[27]=D):D=t[27];let O;t[28]===r?O=t[29]:(O=r?.config.frequency?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=O);let k;t[30]!==n.schedule||t[31]!==D||t[32]!==O?(k=(0,Z.jsxs)($,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[D,O]}),t[30]=n.schedule,t[31]=D,t[32]=O,t[33]=k):k=t[33];let A;t[34]!==w||t[35]!==E||t[36]!==k||t[37]!==_?(A=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[_,w,E,k]}),t[34]=w,t[35]=E,t[36]=k,t[37]=_,t[38]=A):A=t[38];let j;t[39]!==A||t[40]!==p?(j=(0,Z.jsxs)(`div`,{className:fe,children:[p,A]}),t[39]=A,t[40]=p,t[41]=j):j=t[41];let ee;t[42]===n.subsectionStore?ee=t[43]:(ee=(0,Z.jsx)(ve,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=ee);let M=r?String(r.store.entryCount):`—`,te;t[44]!==n.storeEntries||t[45]!==M?(te=(0,Z.jsx)($,{label:n.storeEntries,children:M}),t[44]=n.storeEntries,t[45]=M,t[46]=te):te=t[46];let N=r?String(r.store.promotedCount):`—`,P;t[47]!==n.storePromoted||t[48]!==N?(P=(0,Z.jsx)($,{label:n.storePromoted,children:N}),t[47]=n.storePromoted,t[48]=N,t[49]=P):P=t[49];let F;t[50]===r?F=t[51]:(F=r?pe(r.store.updatedAt):`—`,t[50]=r,t[51]=F);let L;t[52]!==n.storeUpdatedAt||t[53]!==F?(L=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:F}),t[52]=n.storeUpdatedAt,t[53]=F,t[54]=L):L=t[54];let z;t[55]===r?z=t[56]:(z=r?pe(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=z);let B;t[57]!==n.storeLastPromotedAt||t[58]!==z?(B=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:z}),t[57]=n.storeLastPromotedAt,t[58]=z,t[59]=B):B=t[59];let V;t[60]!==te||t[61]!==P||t[62]!==L||t[63]!==B?(V=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[te,P,L,B]}),t[60]=te,t[61]=P,t[62]=L,t[63]=B,t[64]=V):V=t[64];let ie;t[65]!==ee||t[66]!==V?(ie=(0,Z.jsxs)(`div`,{className:fe,children:[ee,V]}),t[65]=ee,t[66]=V,t[67]=ie):ie=t[67];let ae;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(ae=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(ve,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(be,{icon:(0,Z.jsx)(b,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:I(r.config.phases.light.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,Z.jsx)(be,{icon:(0,Z.jsx)(h,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:I(r.config.phases.deep.cron,o,s,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls>=${r.config.phases.deep.minRecallCount}, queries>=${r.config.phases.deep.minUniqueQueries}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(be,{icon:(0,Z.jsx)(g,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:I(r.config.phases.rem.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=o,t[70]=s,t[71]=n,t[72]=ae):ae=t[72];let oe;t[73]===n.subsectionLastRun?oe=t[74]:(oe=(0,Z.jsx)(ve,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=oe);let se;t[75]===n.lastRunBlockHint?se=t[76]:(se=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=se);let H;t[77]!==r||t[78]!==n?(H=r?.lastRun?.exists?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,Z.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 p-2.5 shadow-surface`,children:(0,Z.jsx)(Se,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=H):H=t[79];let U;t[80]!==oe||t[81]!==se||t[82]!==H?(U=(0,Z.jsxs)(`div`,{className:fe,children:[oe,se,H]}),t[80]=oe,t[81]=se,t[82]=H,t[83]=U):U=t[83];let W=r?.lightLastRun,G;t[84]!==n||t[85]!==W?(G=(0,Z.jsx)(xe,{label:n.subsectionLightLastRun,lastRun:W,t:n}),t[84]=n,t[85]=W,t[86]=G):G=t[86];let K=r?.remLastRun,q;t[87]!==n||t[88]!==K?(q=(0,Z.jsx)(xe,{label:n.subsectionRemLastRun,lastRun:K,t:n}),t[87]=n,t[88]=K,t[89]=q):q=t[89];let J;t[90]!==j||t[91]!==ie||t[92]!==ae||t[93]!==U||t[94]!==G||t[95]!==q?(J=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[j,ie,ae,U,G,q]}),t[90]=j,t[91]=ie,t[92]=ae,t[93]=U,t[94]=G,t[95]=q,t[96]=J):J=t[96];let Y;return t[97]!==J||t[98]!==f?(Y=(0,Z.jsxs)(re,{className:u,children:[f,J]}),t[97]=J,t[98]=f,t[99]=Y):Y=t[99],Y}var Be=[`config`,`runtime`,`insights`,`maintenance`],Ve={config:x,runtime:S,insights:k,maintenance:m};function He(e){return e&&Be.includes(e)?e:`config`}function Ue(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function We(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Ge(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var Ke={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,cfgOk:!1,cfgError:null,enableAllBusy:!1,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null},qe=900;function Je(){return typeof window>`u`||typeof window.requestAnimationFrame!=`function`?new Promise(e=>setTimeout(e,0)):new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}function Ye(e,t){typeof window>`u`||window.dispatchEvent(new CustomEvent(e,{detail:t}))}function Xe(){let e=l(e=>e.language),t=a(e),n=t.dreamingSettings,r=t.cron.schedulePicker,i=t.cron.scheduleBadge,s=e===`zh`?`zh-CN`:`en-US`,c=!!o(e=>e.token),[d,p]=f(),m=He(d.get(`tab`)),h=d.get(`agentId`)?.trim()||``,g=(0,L.useCallback)(e=>{p(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[p]),[_,y]=(0,L.useReducer)(v,Ke),{actionBusy:b,actionError:x,runBusy:S,runError:C,runPhase:T,cfgSaving:E,cfgError:D,enableAllBusy:O,previewLoading:k,previewError:A,previewItems:j,eventsLoading:ee,eventsError:M,events:ne}=_,[re,N]=(0,L.useReducer)(Ge,{form:null,baseline:null}),P=re.form,F=re.baseline,I=(0,L.useRef)(!1),R=u(c?`dreaming-settings-agents`:null,w,{revalidateOnFocus:!1}),z=R.data?.agents??[],H=h||R.data?.defaultId||``,U=(0,L.useMemo)(()=>z.find(e=>e.id===H),[z,H]),W=(0,L.useCallback)(e=>{I.current=!1,N({type:`reset`}),p(t=>{let n=new URLSearchParams(t);return e?n.set(`agentId`,e):n.delete(`agentId`),n},{replace:!0})},[p]),{data:G,error:K,isLoading:q,mutate:J}=u(c&&H?B(H):null,V,{revalidateOnFocus:!1}),Y=(0,L.useMemo)(()=>{let e=[];return K&&e.push(K instanceof Error?K.message:String(K)),x&&e.push(x),C&&e.push(C),A&&e.push(A),M&&e.push(M),D&&e.push(D),e},[K,x,C,A,M,D]),ue=(0,L.useCallback)(async()=>{y({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await J()},[J]),de=(0,L.useCallback)(async()=>{y({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{y({type:`patch`,patch:{previewItems:(await oe(20,H)).items??[]}})}catch(e){y({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{previewLoading:!1}})}},[H]),fe=(0,L.useCallback)(async()=>{y({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{y({type:`patch`,patch:{events:await se(50,H)}})}catch(e){y({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{eventsLoading:!1}})}},[H]),X=(0,L.useCallback)(async(e=`deep`)=>{let t=Date.now(),n=z.length>0?z.map(e=>({id:e.id,name:e.name,avatar:e.avatar})):[{id:H,name:U?.name,avatar:U?.avatar}].filter(e=>e.id),r=n.length>0?n:[{id:H}],i=[];y({type:`patch`,patch:{runPhase:e,runBusy:!0,runOk:!1,runError:null}});try{let t=r.map(t=>{let n={phase:e,...t.id?{agentId:t.id}:{},...t.name?{agentName:t.name}:{},...t.avatar?{avatar:t.avatar}:{}};return Ye(`dreaming-phase-start`,n),{target:t,detail:n}}).map(async({target:t,detail:n})=>{await Je();try{await ae(e,t.id||H)}catch(e){let n=t.name||t.id||H||`default`,r=e instanceof Error?e.message:String(e);i.push(`${n}: ${r}`)}finally{Ye(`dreaming-phase-end`,n)}});await Promise.all(t),y({type:`patch`,patch:i.length>0?{runError:i.join(`
2
- `)}:{runOk:!0}}),await J()}catch(e){y({type:`patch`,patch:{runError:e instanceof Error?e.message:String(e)}})}finally{let e=qe-(Date.now()-t);e>0&&await new Promise(t=>setTimeout(t,e)),y({type:`patch`,patch:{runBusy:!1}})}},[z,J,U?.avatar,U?.name,H]),pe=(0,L.useCallback)(async e=>{y({type:`patch`,patch:{actionBusy:e,actionError:null,actionOk:!1}});try{await ie(e,H),y({type:`patch`,patch:{actionOk:!0}}),await J()}catch(e){y({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{actionBusy:null}})}},[J,H]),me=!c||q||!!b,he=(0,L.useMemo)(()=>{let e=G?.config;return ce(e??{})},[G]),ge=G?.agentId||H||`main`,_e=G?.memory;(0,L.useEffect)(()=>{if(!c){N({type:`reset`}),I.current=!1;return}I.current||N({type:`sync`,value:he})},[he,c]);let Q=(0,L.useMemo)(()=>!P||!F?!1:JSON.stringify(P)!==JSON.stringify(F),[P,F]);return(0,Z.jsxs)(te,{children:[(0,Z.jsx)(ke,{t:n,hasToken:c,agents:z,selectedAgentId:H,onAgentChange:W,cfgForm:P,cfgSaving:E,enableAllBusy:O,cfgDirty:Q,saveConfig:(0,L.useCallback)(async()=>{if(P){y({type:`patch`,patch:{cfgSaving:!0,cfgOk:!1,cfgError:null}});try{await le(ge,P,_e),N({type:`saved`,value:P}),I.current=!1,y({type:`patch`,patch:{cfgOk:!0}}),await J()}catch(e){y({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{cfgSaving:!1}})}}},[ge,_e,P,J]),enableAllAgentsDreaming:(0,L.useCallback)(async()=>{let e=z.length>0?z:H?[{id:H,name:U?.name,avatar:U?.avatar}]:[];if(e.length===0)return;y({type:`patch`,patch:{enableAllBusy:!0,cfgOk:!1,cfgError:null}});let t=[];try{for(let n of e)try{let e=await V(n.id),t=ce(e.config);await le(n.id,{...t,enabled:!0,light:{...t.light,enabled:!0},deep:{...t.deep,enabled:!0},rem:{...t.rem,enabled:!0}},e.memory)}catch(e){let r=n.name||n.id;t.push(`${r}: ${e instanceof Error?e.message:String(e)}`)}t.length>0?y({type:`patch`,patch:{cfgError:t.join(`
3
- `)}}):y({type:`patch`,patch:{cfgOk:!0}}),await J()}finally{y({type:`patch`,patch:{enableAllBusy:!1}})}},[z,J,U?.avatar,U?.name,H]),doRefresh:ue}),Y.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-amber-500/20 bg-amber-500/5 px-4 py-3`,role:`alert`,children:Y.map(e=>(0,Z.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,(0,Z.jsx)(Ze,{t:n,activeTab:m,onChange:g}),(0,Z.jsx)(Qe,{t:n,id:`config`,activeTab:m,children:(0,Z.jsx)(Ce,{t:n,schedulePickerLabels:r,hasToken:c,cfgForm:P,cfgBaseline:F,cfgDirty:Q,cfgSaving:E,runPhase:T,runBusy:S,setCfgForm:e=>{I.current=!0;let t=typeof e==`function`?e(P):e;t&&N({type:`set`,value:t})},doRunNow:X})}),(0,Z.jsx)(Qe,{t:n,id:`runtime`,activeTab:m,children:(0,Z.jsx)(ze,{t:n,data:G,isLoading:q,localeTag:s,scheduleBadgeLabels:i})}),(0,Z.jsx)(Qe,{t:n,id:`insights`,activeTab:m,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsx)(Me,{t:n,hasToken:c,previewLoading:k,previewItems:j,loadPreview:de}),(0,Z.jsx)(De,{t:n,hasToken:c,eventsLoading:ee,events:ne,loadEvents:fe})]})}),(0,Z.jsx)(Qe,{t:n,id:`maintenance`,activeTab:m,children:(0,Z.jsx)(je,{t:n,disabled:me,actionBusy:b,doAction:pe})})]})}function Ze(e){let t=(0,R.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Be.map(e=>({id:e,label:Ue(n,e),icon:Ve[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(N,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function Qe(e){let t=(0,R.c)(13),{t:n,id:r,activeTab:i,children:a}=e,o=r!==`config`,s;t[0]!==r||t[1]!==n?(s=Ue(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n?(c=We(n,r),t[3]=r,t[4]=n,t[5]=c):c=t[5];let l;return t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,Z.jsx)(M,{id:r,activeTab:i,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`,title:s,hint:c,showHeading:o,children:a}),t[6]=i,t[7]=a,t[8]=r,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}export{Xe as DreamingSettingsPanel};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-BQ_8x0bT.js";import{$a as i,Ba as a,Do as o,Ha as s,Qo as c,Ua as l,Va as u,Wa as d,as as f,bs as p,eo as m,ks as h,kt as g,ot as _,tl as v,to as y,wo as b,za as x,zo as S}from"./index-DOetFpTt.js";var C=e(t(),1),w=n();function T(){return{title:``,objective:``,description:``,attachments:[],checklist:[``],scopeBoundary:``,evidencePlan:[``],priority:`normal`,deadlineMode:`none`,deadline:``,maxTurns:`10`,agentId:``,judgeModelRef:``}}function E(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function D(e){let t=e=>String(e).padStart(2,`0`);return[e.getFullYear(),`-`,t(e.getMonth()+1),`-`,t(e.getDate()),`T`,t(e.getHours()),`:`,t(e.getMinutes())].join(``)}function O(e){let t=new Date;return t.setDate(t.getDate()+e),t.setHours(23,59,0,0),D(t)}function k(){let e=new Date,t=e.getDay(),n=t<=5?5-t:7-t+5;return e.setDate(e.getDate()+n),e.setHours(23,59,0,0),D(e)}function A(e){if(e===`today`)return O(0);if(e===`tomorrow`)return O(1);if(e===`friday`)return k();if(e===`custom`){let e=new Date;return e.setHours(e.getHours()+1,0,0,0),D(e)}return``}function j(e){let t=new Set,n=[];for(let r of e){let e=r.trim();!e||t.has(e.toLowerCase())||(t.add(e.toLowerCase()),n.push(e))}return n}function M({open:e,t,chat:n,busy:D,options:O,onClose:k,onCreate:M,onDraftContract:N}){let[P,F]=(0,C.useState)(()=>T()),[I,L]=(0,C.useState)(!1),[R,z]=(0,C.useState)(null),[B,V]=(0,C.useState)(!1),H=_({chat:n});(0,C.useEffect)(()=>{e||(F(T()),L(!1),z(null),V(!1),H.clearAttachments())},[H.clearAttachments,e]),(0,C.useEffect)(()=>{!e||!O.defaultAgentId||F(e=>e.agentId?e:{...e,agentId:O.defaultAgentId})},[e,O.defaultAgentId]);let U=e=>F(t=>({...t,...e})),W=O.agents.length?O.agents:[{id:O.defaultAgentId||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],G=W.find(e=>e.id===P.agentId)??W.find(e=>e.id===O.defaultAgentId)??W[0],K=P.agentId||G?.id||`main`,q=[...G?.typedModels.effective??[]].sort((e,t)=>e.id===`judge`?-1:t.id===`judge`?1:e.id.localeCompare(t.id)),J=O.models.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t),Y=e=>{U({deadlineMode:e,deadline:A(e)})},X=(e,t)=>{F(n=>({...n,checklist:n.checklist.map((n,r)=>r===e?t:n)}))},Z=e=>{F(t=>({...t,checklist:t.checklist.filter((t,n)=>n!==e)}))},Q=(e,t)=>{F(n=>({...n,evidencePlan:n.evidencePlan.map((n,r)=>r===e?t:n)}))},$=e=>{F(t=>({...t,evidencePlan:t.evidencePlan.filter((t,n)=>n!==e)}))},ee=async()=>{z(null),V(!0);try{U(N?await N({...P,attachments:H.wireAttachmentsPayload()}):{objective:P.objective||P.title,scopeBoundary:P.scopeBoundary,evidencePlan:j(P.evidencePlan).length?P.evidencePlan:[...t.createDialog.defaultEvidencePlan],checklist:P.checklist})}catch(e){z(e instanceof Error?e.message:t.createDialog.draftFailed)}finally{V(!1)}},te=async()=>{if(z(null),!P.title.trim()){z(t.createDialog.titleRequired);return}try{await M({...P,attachments:H.wireAttachmentsPayload(),checklist:j(P.checklist)}),k()}catch(e){z(e instanceof Error?e.message:t.errors.create)}};return(0,w.jsx)(l,{open:e,onOpenChange:e=>!e&&k(),children:(0,w.jsxs)(s,{children:[(0,w.jsx)(u,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,w.jsxs)(x,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(92vh,46rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(d,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.createDialog.title}),(0,w.jsx)(a,{className:`mt-1 truncate text-sm text-fg-muted`,children:t.createDialog.description})]}),(0,w.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":t.closeDetails,onClick:k,children:(0,w.jsx)(o,{className:`size-5`,"aria-hidden":!0})})]}),(0,w.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,w.jsxs)(`div`,{className:`grid gap-4`,children:[(0,w.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalTitle}),(0,w.jsx)(`input`,{value:P.title,onChange:e=>U({title:e.target.value}),placeholder:t.newGoalPlaceholder,className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,autoFocus:!0})]}),(0,w.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalDescription}),(0,w.jsxs)(b,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>H.fileInputRef.current?.click(),children:[(0,w.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addAttachment]})]}),(0,w.jsx)(`textarea`,{value:P.description,onChange:e=>U({description:e.target.value}),placeholder:t.createDialog.descriptionPlaceholder,rows:4,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,w.jsx)(`input`,{ref:H.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,H.processFiles(t)}}),(0,w.jsx)(g,{attachments:H.attachments,topPadded:!1,onRemove:H.removeAttachment})]}),(0,w.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60 p-4`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.criteriaTitle}),(0,w.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.criteriaHint}),(0,w.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:O.checklistDecomposePolicy===`supplement_existing`?t.createDialog.checklistPolicySupplementExisting:t.createDialog.checklistPolicyEmptyOnly})]}),(0,w.jsxs)(b,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>void ee(),disabled:B||!P.title.trim()&&!P.description.trim(),children:[(0,w.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),B?t.createDialog.drafting:t.createDialog.aiDraft]})]}),(0,w.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[P.checklist.map((e,n)=>(0,w.jsxs)(`div`,{className:`flex gap-2`,children:[(0,w.jsx)(`input`,{value:e,onChange:e=>X(n,e.target.value),placeholder:E(t.createDialog.criteriaPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,w.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeCriteria,onClick:()=>Z(n),children:(0,w.jsx)(S,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,w.jsxs)(b,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>U({checklist:[...P.checklist,``]}),children:[(0,w.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addCriteria]})]})]}),(0,w.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60 p-4`,children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.contractTitle}),(0,w.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.contractHint}),(0,w.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.objective}),(0,w.jsx)(`textarea`,{value:P.objective,onChange:e=>U({objective:e.target.value}),placeholder:t.createDialog.objectivePlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,w.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.scopeBoundary}),(0,w.jsx)(`textarea`,{value:P.scopeBoundary,onChange:e=>U({scopeBoundary:e.target.value}),placeholder:t.createDialog.scopeBoundaryPlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,w.jsxs)(`div`,{className:`mt-3 grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.evidencePlan}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.createDialog.evidencePlanHint}),P.evidencePlan.map((e,n)=>(0,w.jsxs)(`div`,{className:`flex gap-2`,children:[(0,w.jsx)(`input`,{value:e,onChange:e=>Q(n,e.target.value),placeholder:E(t.createDialog.evidencePlanPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,w.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeEvidence,onClick:()=>$(n),children:(0,w.jsx)(S,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,w.jsxs)(b,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>U({evidencePlan:[...P.evidencePlan,``]}),children:[(0,w.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addEvidence]})]})]}),(0,w.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>L(e=>!e),children:[(0,w.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,w.jsx)(f,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t.createDialog.advanced]}),(0,w.jsx)(v,{className:r(`size-4 text-fg-muted transition-transform`,I&&`rotate-180`),"aria-hidden":!0})]}),I?(0,w.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 sm:grid-cols-2`,children:[(0,w.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.agentId}),(0,w.jsx)(i,{value:K,onChange:e=>U({agentId:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:W.map(e=>(0,w.jsx)(y,{value:e.id,children:(e.name?.trim()||e.id)+(e.isDefault?` · ${t.createDialog.defaultAgent}`:` · ${e.id}`)},e.id))}),G?.description?(0,w.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-muted`,children:G.description}):G?.model?.primary?(0,w.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:E(t.createDialog.agentPrimaryModel,{model:G.model.primary})}):null]}),(0,w.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.priority}),(0,w.jsxs)(i,{value:P.priority,onChange:e=>U({priority:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,w.jsx)(y,{value:`normal`,children:t.priorities.normal}),(0,w.jsx)(y,{value:`high`,children:t.priorities.high}),(0,w.jsx)(y,{value:`low`,children:t.priorities.low})]})]}),(0,w.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadline}),(0,w.jsxs)(i,{value:P.deadlineMode,onChange:e=>Y(e.target.value),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,w.jsx)(y,{value:`none`,children:t.createDialog.deadlineNone}),(0,w.jsx)(y,{value:`today`,children:t.createDialog.deadlineToday}),(0,w.jsx)(y,{value:`tomorrow`,children:t.createDialog.deadlineTomorrow}),(0,w.jsx)(y,{value:`friday`,children:t.createDialog.deadlineFriday}),(0,w.jsx)(y,{value:`custom`,children:t.createDialog.deadlineCustom})]})]}),P.deadlineMode===`none`?null:(0,w.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadlineAt}),(0,w.jsx)(`input`,{type:`datetime-local`,value:P.deadline,onChange:e=>U({deadline:e.target.value,deadlineMode:`custom`}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,w.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.maxTurns}),(0,w.jsx)(`input`,{type:`number`,min:1,max:500,value:P.maxTurns,onChange:e=>U({maxTurns:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,w.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.judgeModel}),(0,w.jsxs)(i,{value:P.judgeModelRef,onChange:e=>U({judgeModelRef:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,w.jsx)(y,{value:``,children:t.createDialog.judgeModelPlaceholder}),q.length?(0,w.jsx)(m,{label:t.createDialog.agentModelRoles,children:q.map(e=>(0,w.jsxs)(y,{value:e.model,children:[e.id===`judge`?t.createDialog.judgeRole:e.id,` · `,e.model]},`${e.id}:${e.model}`))}):null,(0,w.jsx)(m,{label:t.createDialog.configuredModels,children:J.map(e=>(0,w.jsxs)(y,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]})]})]}):null]}),R?(0,w.jsx)(`p`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:R}):null]})}),(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,w.jsx)(b,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:k,children:t.createDialog.cancel}),(0,w.jsxs)(b,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:D||!P.title.trim(),onClick:()=>void te(),children:[(0,w.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t.createDialog.create]})]})]})]})})}export{j as n,M as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-Bq4REfIj.js";import{a as o,n as s,o as c}from"./fetch-Bl7zMnmd.js";import{n as l}from"./locale-store-Ba72bFmP.js";import{i as u,o as d}from"./vendor-swr-BIWyz7Rc.js";import{$a as f,Cc as p,Co as m,El as h,Ja as g,La as _,Rs as v,So as y,Ss as b,Tt as x,Us as S,ma as C,ms as w,pa as T,to as E,uc as D,wo as O,xo as k,zc as A}from"./index-DOetFpTt.js";import{n as j,r as M,t as N}from"./settings-page-layout-DgFTf6nM.js";import{n as ee}from"./settings-loading-skeleton-CTA5Gje4.js";import{t as P}from"./page-tabs-Cy7bX7Ce.js";import{n as F,r as I,t as te}from"./channel-recipient-api-BUi8syv2.js";import{t as L}from"./schedule-field-BuajpVNF.js";import{n as ne,t as re}from"./save-bar-controls-nMloZ0mp.js";var R=e(t(),1),z=n();function ie(){return c(`/api/channels/status`)}var ae=F;function B(){return c(`/api/workspace/heartbeat-md`)}async function oe(){let e=await s(B());return typeof e.payload?.content==`string`?e.payload.content:``}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function se(e){let t=V(e)?e:{},n=V(t.gateway)?t.gateway:{},r=V(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=V(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 H(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 ce(e){await s(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:H(e)}})}),T()}async function le(e){await s(c(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:e})}),d(B())}async function ue(e){await s(c(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{reason:e}:{})})}var U=r();function W(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,m,`dark:border-edge`)}function de(){return i(y,k)}var G=[`schedule`,`delivery`,`prompt`,`document`],fe={schedule:A,delivery:v,prompt:D,document:p};function pe(e){return e&&G.includes(e)?e:`schedule`}function K(e,t){return t===`schedule`?e.tabSchedule:t===`delivery`?e.tabDelivery:t===`prompt`?e.tabPrompt:e.tabDocument}function q(e,t){return t===`schedule`?e.scheduleTabHint:t===`delivery`?e.deliveryTabHint:t===`prompt`?e.promptTabHint:e.documentTabHint}function me(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`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function he(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`discard`:return{...e,doc:e.baseline};case`saved`:return{doc:t.value,baseline:t.value}}}function ge(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 _e={saving:!1,error:null,triggerLoading:!1,triggerOk:!1,triggerError:null};function J(){let e=l(e=>e.language),t=a(e),n=t.heartbeatSettings,r=!!o(e=>e.token),[s,c]=h(),d=pe(s.get(`tab`)),f=(0,R.useCallback)(e=>{c(t=>{let n=new URLSearchParams(t);return e===`schedule`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[c]),[p,m]=(0,R.useReducer)(me,{form:null,baseline:null}),v=p.form,y=p.baseline,[w,T]=(0,R.useReducer)(he,{doc:``,baseline:``}),E=w.doc,D=w.baseline,[k,A]=(0,R.useReducer)(x,_e),{saving:M,error:P,triggerLoading:F,triggerOk:te,triggerError:L}=k,z=(0,R.useRef)(!1),V=(0,R.useRef)(!1),{data:H,error:G,isLoading:fe,mutate:K}=C(r),{data:q,error:J,isLoading:xe,mutate:Se}=u(r?B():null,oe,{revalidateOnFocus:!1}),{data:we=[]}=u(r?ie():null,ae,{revalidateOnFocus:!1}),Te=(0,R.useMemo)(()=>ge(H?.payload?.config),[H]),Ee=(0,R.useMemo)(()=>se(H?.payload?.config??{}),[H]),X=(0,R.useMemo)(()=>!v||!y?!1:JSON.stringify(v)!==JSON.stringify(y),[v,y]),Z=E!==D;(0,R.useEffect)(()=>{if(!r){m({type:`reset`}),z.current=!1;return}H!==void 0&&(z.current||m({type:`sync`,value:Ee}))},[r,H,Ee]),(0,R.useEffect)(()=>{if(!r){T({type:`reset`}),V.current=!1;return}q!==void 0&&(V.current||T({type:`sync`,value:q}))},[r,q]);let De=G instanceof Error?G.message:G?String(G):J instanceof Error?J.message:J?String(J):null,Oe=!!(r&&(H===void 0||q===void 0)&&!De&&(fe||xe)),Q=v?.target.trim()??``,{data:ke,setData:Ae}=_(()=>I(Q),[r,Q],{enabled:r&&Q.length>0,initial:[],errorData:[]}),je=(0,R.useCallback)(()=>{Q&&I(Q).then(Ae)},[Q,Ae]),Me=(0,R.useCallback)(async()=>{A({type:`patch`,patch:{triggerLoading:!0,triggerOk:!1,triggerError:null}});try{await ue(),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]),$=(0,R.useCallback)(e=>{z.current=!0,m({type:`patch`,patch:e})},[]),Ne=X||Z,Pe=(0,R.useCallback)(()=>{m({type:`discard`}),T({type:`discard`}),z.current=!1,V.current=!1,A({type:`patch`,patch:{error:null}})},[]);return ne({id:`heartbeat`,dirty:Ne,saving:M,save:(0,R.useCallback)(async()=>{if(!(!v||M)){A({type:`patch`,patch:{saving:!0,error:null}});try{X&&(await ce(v),m({type:`saved`,value:v}),z.current=!1),Z&&(await le(E),T({type:`saved`,value:E}),V.current=!1)}catch(e){let t=X?n.saveConfigError:n.saveDocError,r=e instanceof Error?e.message:t;throw A({type:`patch`,patch:{error:r}}),Error(r)}finally{A({type:`patch`,patch:{saving:!1}})}}},[X,Z,E,v,n.saveConfigError,n.saveDocError,M]),discard:Pe}),r?Oe?(0,U.jsx)(N,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,U.jsx)(ee,{sections:3})}):v?(0,U.jsxs)(N,{"aria-busy":M,"data-has-baseline":y?`1`:`0`,children:[(0,U.jsx)(j,{title:t.settingsSections.heartbeat,subtitle:n.subtitle,docsLink:g(e,`heartbeat`),docsLabel:n.docsLink,actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(O,{type:`button`,variant:`secondary`,className:`inline-flex items-center gap-2`,disabled:F,onClick:()=>void Me(),children:[F?(0,U.jsx)(S,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,U.jsx)(b,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),F?n.triggering:n.triggerNow]}),te?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.triggered}):null]})}),(0,U.jsx)(re,{}),Te?(0,U.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.workspaceLabel,`: `,(0,U.jsx)(`span`,{className:`font-mono text-fg-muted`,children:Te})]}):null,P?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:P}):null,L?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:L}):null,(0,U.jsx)(ve,{h:n,activeTab:d,onChange:f}),(0,U.jsx)(Y,{h:n,id:`schedule`,activeTab:d,children:(0,U.jsx)(ye,{h:n,form:v,update:$})}),(0,U.jsx)(Y,{h:n,id:`delivery`,activeTab:d,children:(0,U.jsx)(be,{h:n,cron:t.cron,form:v,channels:we,sessionChatIds:ke,onRefreshChatIds:je,update:$,inputClassName:W,selectClassName:de})}),(0,U.jsx)(Y,{h:n,id:`prompt`,activeTab:d,children:(0,U.jsx)(Ce,{h:n,form:v,update:$,inputClassName:W})}),(0,U.jsxs)(Y,{h:n,id:`document`,activeTab:d,children:[(0,U.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:n.docHint}),(0,U.jsx)(`textarea`,{className:i(W(),`min-h-72 resize-y font-mono text-xs leading-relaxed`),value:E,onChange:e=>{V.current=!0,T({type:`set`,value:e.target.value})},spellCheck:!1,"aria-label":n.docSection,"data-doc-in-sync":E===D?`true`:`false`})]})]}):(0,U.jsxs)(N,{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:P??De??n.loadError}),(0,U.jsx)(O,{type:`button`,variant:`secondary`,onClick:()=>{K(),Se()},children:n.retry})]}):(0,U.jsxs)(N,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(j,{title:t.settingsSections.heartbeat}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function ve(e){let t=(0,z.c)(7),{h:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=G.map(e=>({id:e,label:K(n,e),icon:fe[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)(P,{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 Y(e){let t=(0,z.c)(14),{h:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=K(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=q(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)(M,{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 ye(e){let t=(0,z.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)(L,{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)(L,{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 be(e){let t=(0,z.c)(51),{h:n,cron:r,form:a,channels:o,sessionChatIds:s,onRefreshChatIds:c,update:l,inputClassName:u,selectClassName:d}=e,p;t[0]===o?p=t[1]:(p=new Set(o.map(Se)),t[0]=o,t[1]=p);let m=p,h;t[2]===a.target?h=t[3]:(h=a.target.trim(),t[2]=a.target,t[3]=h);let g=h,_=!!(g&&!m.has(g)),v;t[4]===n.deliveryHint?v=t[5]:(v=(0,U.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.deliveryHint}),t[4]=n.deliveryHint,t[5]=v);let y;t[6]===r.channel?y=t[7]:(y=(0,U.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.channel}),t[6]=r.channel,t[7]=y);let b;t[8]===d?b=t[9]:(b=d(),t[8]=d,t[9]=b);let x;t[10]===l?x=t[11]:(x=e=>{l({target:e.target.value.trim(),targetChatId:``})},t[10]=l,t[11]=x);let S;t[12]===n.channelNone?S=t[13]:(S=(0,U.jsx)(E,{value:``,children:n.channelNone}),t[12]=n.channelNone,t[13]=S);let C;t[14]!==n.customChannelSuffix||t[15]!==_||t[16]!==g?(C=_?(0,U.jsxs)(E,{value:g,children:[g,` (`,n.customChannelSuffix,`)`]}):null,t[14]=n.customChannelSuffix,t[15]=_,t[16]=g,t[17]=C):C=t[17];let T;t[18]===o?T=t[19]:(T=o.map(xe),t[18]=o,t[19]=T);let D;t[20]!==b||t[21]!==x||t[22]!==S||t[23]!==C||t[24]!==T||t[25]!==g?(D=(0,U.jsxs)(f,{className:b,value:g,onChange:x,children:[S,C,T]}),t[20]=b,t[21]=x,t[22]=S,t[23]=C,t[24]=T,t[25]=g,t[26]=D):D=t[26];let k;t[27]!==D||t[28]!==y?(k=(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[y,D]}),t[27]=D,t[28]=y,t[29]=k):k=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]!==a.targetChatId||t[40]!==u||t[41]!==c||t[42]!==d||t[43]!==s||t[44]!==g||t[45]!==l?(A=g?(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)(O,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:r.refreshRecipientHint,onClick:c,children:[(0,U.jsx)(w,{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:i(u(),`min-w-0 flex-1`),value:a.targetChatId,onChange:e=>l({targetChatId:e.target.value}),placeholder:r.recipientPlaceholder,autoComplete:`off`}),(0,U.jsxs)(f,{className:i(d(),`max-w-40 shrink-0 text-xs`),value:a.targetChatId,onChange:e=>{let t=e.target.value;t&&l({targetChatId:t})},children:[(0,U.jsx)(E,{value:``,children:r.selectRecipient}),s.length>0?s.map(e=>(0,U.jsx)(E,{value:e.chatId,children:te(e,r.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,U.jsx)(E,{value:``,disabled:!0,children:r.noRecentChatsOption})]})]}),(0,U.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s.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]=a.targetChatId,t[40]=u,t[41]=c,t[42]=d,t[43]=s,t[44]=g,t[45]=l,t[46]=A):A=t[46];let j;return t[47]!==k||t[48]!==A||t[49]!==v?(j=(0,U.jsxs)(U.Fragment,{children:[v,k,A]}),t[47]=k,t[48]=A,t[49]=v,t[50]=j):j=t[50],j}function xe(e){return(0,U.jsxs)(E,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Se(e){return e.name}function Ce(e){let t=(0,z.c)(65),{h:n,form:r,update:a,inputClassName:o}=e,s;t[0]===a?s=t[1]:(s=e=>a({includeSystemPromptSection:e.target.checked}),t[0]=a,t[1]=s);let c;t[2]!==r.includeSystemPromptSection||t[3]!==s?(c=(0,U.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.includeSystemPromptSection,onChange:s}),t[2]=r.includeSystemPromptSection,t[3]=s,t[4]=c):c=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]!==c||t[11]!==u?(d=(0,U.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[c,u]}),t[10]=c,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]===o?p=t[16]:(p=i(o(),`min-h-36 resize-y font-mono text-xs`),t[15]=o,t[16]=p);let m;t[17]===a?m=t[18]:(m=e=>a({prompt:e.target.value}),t[17]=a,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]===o?y=t[33]:(y=o(),t[32]=o,t[33]=y);let b=r.ackMaxChars===``?``:r.ackMaxChars,x;t[34]===a?x=t[35]:(x=e=>{let t=e.target.value;if(t===``){a({ackMaxChars:``});return}let n=parseInt(t,10);a({ackMaxChars:Number.isFinite(n)?n:``})},t[34]=a,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]===a?T=t[48]:(T=e=>a({isolatedSession:e.target.checked}),t[47]=a,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{J as HeartbeatSettingsPanel};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-Bq4REfIj.js";import{a as o,t as s}from"./fetch-Bl7zMnmd.js";import{n as c}from"./locale-store-Ba72bFmP.js";import{$a as l,Ac as u,Ba as d,Bi as f,Cc as p,Dc as m,Do as h,Eo as g,Ga as _,Gi as v,Ha as y,Hi as b,Ji as x,L as S,Nc as C,Oc as w,Os as T,Qc as E,Qi as D,Ra as O,Sc as k,Ss as A,Tl as j,Ts as M,Ua as N,Ui as P,Uo as F,Va as I,Vi as L,Wa as R,Wi as z,Xc as B,Xi as V,Yi as H,Yo as ee,Ys as te,Zi as ne,_i as re,_n as ie,_t as ae,a as oe,aa as se,at as ce,bs as le,bt as ue,ca as de,ci as fe,co as pe,cs as me,d as he,di as ge,ds as _e,ea as ve,ec as ye,er as be,f as xe,fa as Se,fi as Ce,gi as we,ha as Te,hi as Ee,hl as De,ht as Oe,i as ke,ia as Ae,is as je,ks as Me,l as U,la as Ne,lc as Pe,li as Fe,lo as Ie,mi as Le,mo as Re,mt as ze,na as Be,nl as Ve,o as He,oo as Ue,p as We,pi as Ge,ps as W,qi as Ke,r as qe,ra as Je,s as Ye,so as Xe,st as Ze,ta as Qe,tl as $e,to as et,u as tt,ui as nt,vc as rt,vi as it,vl as at,vn as ot,wl as st,wo as G,ws as ct,xl as lt,y as ut,yc as dt,za as ft,zc as pt,zo as mt,zr as ht,zs as gt}from"./index-DOetFpTt.js";import{t as _t}from"./notes-workbench-eAIE8iKV.js";import{t as vt}from"./page-tabs-Cy7bX7Ce.js";import{t as yt}from"./directory-picker-path-field-BEhDuShd.js";import{t as bt}from"./goals-config-api-h26_-2Vm.js";import{n as xt,t as St}from"./goal-create-dialog-DZ68qzpm.js";import{t as Ct}from"./workflow-start-dialog-BQQkr8YD.js";var K=n(),q=e(t(),1),J=r(),wt=`application/x-xopc-work-item`,Tt=[`backlog`,`todo`,`in_progress`,`blocked`,`needs_input`,`in_review`,`done`],Et=[`low`,`normal`,`high`,`urgent`];function Dt(e){return e===`done`||e===`in_review`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`blocked`||e===`needs_input`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`in_progress`?`bg-accent-soft text-accent-fg`:e===`backlog`||e===`todo`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function Ot(e){return e?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e)):``}function kt(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(+(e<10*1024*1024))} MB`}function Y(e){return`${e.name}:${e.size}:${e.lastModified}`}function At(e,t){return fe(e,t)!==`unsupported`}function jt(e,t){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:t===`image`||t===`audio`||t===`video`?t:`document`}function Mt(e,t){return{id:e.id,name:e.fileName,type:jt(e.mimeType,e.type),mimeType:e.mimeType,size:e.size,...t?{content:t,preview:e.mimeType.startsWith(`image/`)?t:void 0}:{}}}async function Nt(e,t){let n=nt(e.name||`upload`,e.type||`application/octet-stream`),r=de(await e.arrayBuffer());return{id:t,name:e.name||`upload`,type:jt(n),mimeType:n,size:e.size,content:r,preview:n.startsWith(`image/`)?r:void 0}}function Pt(e){let t=(0,K.c)(3),[n,r]=(0,q.useState)(``),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{if(!e){r(``);return}let t=URL.createObjectURL(e);return r(t),()=>URL.revokeObjectURL(t)},a=[e],t[0]=e,t[1]=i,t[2]=a),(0,q.useEffect)(i,a),n}function Ft(e,t){let n=(0,K.c)(5),[r,i]=(0,q.useState)(``),a,o;return n[0]!==t.id||n[1]!==t.mimeType||n[2]!==e?(a=()=>{if(!e||!t.mimeType.startsWith(`image/`)){i(``);return}let n=!1,r=``;return(async()=>{let a=await s(We(e,t.id));if(!a.ok||n)return;let o=await a.blob();n||(r=URL.createObjectURL(o),i(r))})().catch(()=>{n||i(``)}),()=>{n=!0,r&&URL.revokeObjectURL(r)}},o=[t.id,t.mimeType,e],n[0]=t.id,n[1]=t.mimeType,n[2]=e,n[3]=a,n[4]=o):(a=n[3],o=n[4]),(0,q.useEffect)(a,o),r}function It(e){let t=(0,K.c)(11),{name:n,mimeType:r,thumbnailUrl:i,previewable:a,disabled:o,onOpen:s}=e,c;t[0]===r?c=t[1]:(c=r.startsWith(`image/`),t[0]=r,t[1]=c);let l=c,u;t[2]!==l||t[3]!==n||t[4]!==i?(u=l&&i?(0,J.jsx)(`img`,{src:i,alt:n,className:`size-10 rounded-md object-cover`}):(0,J.jsx)(`span`,{className:`inline-flex size-10 items-center justify-center rounded-md border border-edge bg-surface-muted`,children:(0,J.jsx)(p,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),t[2]=l,t[3]=n,t[4]=i,t[5]=u):u=t[5];let d=u;if(!a)return d;let f;return t[6]!==d||t[7]!==o||t[8]!==n||t[9]!==s?(f=(0,J.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel disabled:cursor-wait disabled:opacity-70`,title:n,"aria-label":n,disabled:o,onClick:s,children:d}),t[6]=d,t[7]=o,t[8]=n,t[9]=s,t[10]=f):f=t[10],f}function Lt(e){return e.kind===`chat`?`/chat/${encodeURIComponent(e.targetId)}`:e.kind===`goal`?`/goals/${encodeURIComponent(e.targetId)}`:e.kind===`workflow_run`?`/workflows?run=${encodeURIComponent(e.targetId)}`:e.kind===`automation`?`/automations?automationId=${encodeURIComponent(e.targetId)}`:`#`}function Rt(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}function zt(e,t){return e.nextAction||e.blockedReason||e.description||t.noNextAction}function Bt(e){let t=(0,K.c)(63),{item:n,dragging:r,onOpen:a,onToggleDone:o,onDragStart:s,onDragEnd:c,t:l}=e,u=n.status===`done`,d;t[0]!==n||t[1]!==s?(d=e=>s(n,e),t[0]=n,t[1]=s,t[2]=d):d=t[2];let f=l.dragToUpdate,p=r&&`opacity-50`,h;t[3]===p?h=t[4]:(h=i(`flex min-h-24 w-full min-w-0 max-w-full cursor-grab flex-col overflow-hidden rounded-lg bg-surface-panel px-3 py-3 shadow-surface transition-colors hover:bg-surface-hover active:cursor-grabbing`,p),t[3]=p,t[4]=h);let g=u?`border-success bg-success text-white`:`border-edge bg-surface-base hover:border-accent/50`,_;t[5]===g?_=t[6]:(_=i(`mt-0.5 inline-flex size-3.5 shrink-0 items-center justify-center rounded border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,g),t[5]=g,t[6]=_);let v=u?l.markTodo:l.markDone,y=u?l.markTodo:l.markDone,b;t[7]!==n||t[8]!==o?(b=()=>o(n),t[7]=n,t[8]=o,t[9]=b):b=t[9];let x;t[10]===u?x=t[11]:(x=u?(0,J.jsx)(B,{className:`size-3`,"aria-hidden":!0}):null,t[10]=u,t[11]=x);let S;t[12]!==x||t[13]!==_||t[14]!==v||t[15]!==y||t[16]!==b?(S=(0,J.jsx)(`button`,{type:`button`,className:_,"aria-label":v,title:y,onClick:b,children:x}),t[12]=x,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=S):S=t[17];let C;t[18]!==n||t[19]!==a?(C=()=>a(n),t[18]=n,t[19]=a,t[20]=C):C=t[20];let w;t[21]===n.title?w=t[22]:(w=(0,J.jsx)(`h4`,{className:`min-w-0 flex-1 basis-0 text-sm font-medium leading-5 text-fg line-clamp-2`,children:n.title}),t[21]=n.title,t[22]=w);let T;t[23]!==n||t[24]!==l?(T=zt(n,l),t[23]=n,t[24]=l,t[25]=T):T=t[25];let E;t[26]===T?E=t[27]:(E=(0,J.jsx)(`p`,{className:`mt-2 max-w-full break-words text-xs leading-5 text-fg-muted line-clamp-1`,children:T}),t[26]=T,t[27]=E);let D;t[28]!==C||t[29]!==w||t[30]!==E?(D=(0,J.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:C,children:[w,E]}),t[28]=C,t[29]=w,t[30]=E,t[31]=D):D=t[31];let O;t[32]!==S||t[33]!==D?(O=(0,J.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-start gap-2`,children:[S,D]}),t[32]=S,t[33]=D,t[34]=O):O=t[34];let k;t[35]===n.status?k=t[36]:(k=i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,Dt(n.status)),t[35]=n.status,t[36]=k);let A=l.statuses[n.status],j;t[37]!==k||t[38]!==A?(j=(0,J.jsx)(`span`,{className:k,children:A}),t[37]=k,t[38]=A,t[39]=j):j=t[39];let M=l.priorities[n.priority],N;t[40]===M?N=t[41]:(N=(0,J.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] text-fg-muted`,children:M}),t[40]=M,t[41]=N);let P;t[42]===n.attachments?P=t[43]:(P=n.attachments?.length?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] text-fg-muted`,children:[(0,J.jsx)(Me,{className:`size-3`,"aria-hidden":!0}),n.attachments.length]}):null,t[42]=n.attachments,t[43]=P);let F;t[44]===n.links?F=t[45]:(F=n.links?.length?(0,J.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] text-fg-muted`,children:n.links.length}):null,t[44]=n.links,t[45]=F);let I=`/work-items/${encodeURIComponent(n.id)}`,L;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,J.jsx)(m,{className:`size-3`,"aria-hidden":!0}),t[46]=L):L=t[46];let R;t[47]!==l.detail.openItem||t[48]!==I?(R=(0,J.jsxs)(lt,{to:I,className:`ml-auto inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium text-accent hover:bg-accent-soft hover:text-accent-fg`,children:[l.detail.openItem,L]}),t[47]=l.detail.openItem,t[48]=I,t[49]=R):R=t[49];let z;t[50]!==j||t[51]!==N||t[52]!==P||t[53]!==F||t[54]!==R?(z=(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[j,N,P,F,R]}),t[50]=j,t[51]=N,t[52]=P,t[53]=F,t[54]=R,t[55]=z):z=t[55];let V;return t[56]!==c||t[57]!==l.dragToUpdate||t[58]!==d||t[59]!==O||t[60]!==z||t[61]!==h?(V=(0,J.jsxs)(`article`,{draggable:!0,onDragStart:d,onDragEnd:c,title:f,className:h,children:[O,z]}),t[56]=c,t[57]=l.dragToUpdate,t[58]=d,t[59]=O,t[60]=z,t[61]=h,t[62]=V):V=t[62],V}function Vt(){let e=(0,K.c)(3),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`size-3.5 shrink-0 rounded-full bg-surface-muted`}),(0,J.jsx)(`div`,{className:`h-3 w-36 rounded bg-surface-muted`})]}),n=(0,J.jsx)(`div`,{className:`mt-3 h-3 w-48 rounded bg-surface-muted`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,J.jsxs)(`article`,{className:`flex h-24 w-full min-w-0 max-w-full flex-col overflow-hidden rounded-lg bg-surface-panel px-3 pt-3 pb-0 shadow-surface`,children:[t,n,(0,J.jsxs)(`div`,{className:`mt-3 flex gap-1.5`,children:[(0,J.jsx)(`div`,{className:`h-5 w-16 rounded-full bg-surface-muted`}),(0,J.jsx)(`div`,{className:`h-5 w-10 rounded-full bg-surface-muted`})]})]}),e[2]=r):r=e[2],r}function Ht(e){let t=(0,K.c)(44),{file:n,index:r,busy:a,previewBusy:o,t:s,onOpen:c,onRemove:l}=e,u,d,f,p;t[0]===n?(u=t[1],d=t[2],f=t[3],p=t[4]):(u=nt(n.name||`upload`,n.type||`application/octet-stream`),d=At(n.name||`upload`,u),f=Pt,p=u.startsWith(`image/`)?n:null,t[0]=n,t[1]=u,t[2]=d,t[3]=f,t[4]=p);let m=f(p),g=n.name||`upload`,_=a||o,v;t[5]!==n||t[6]!==c?(v=()=>c(n),t[5]=n,t[6]=c,t[7]=v):v=t[7];let y;t[8]!==u||t[9]!==d||t[10]!==g||t[11]!==_||t[12]!==v||t[13]!==m?(y=(0,J.jsx)(It,{name:g,mimeType:u,thumbnailUrl:m,previewable:d,disabled:_,onOpen:v}),t[8]=u,t[9]=d,t[10]=g,t[11]=_,t[12]=v,t[13]=m,t[14]=y):y=t[14];let b=d?`rounded-md hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`:`cursor-default`,x;t[15]===b?x=t[16]:(x=i(`min-w-0 flex-1 text-left`,b),t[15]=b,t[16]=x);let S=!d||a||o,C;t[17]!==n||t[18]!==c?(C=()=>c(n),t[17]=n,t[18]=c,t[19]=C):C=t[19];let w=n.name||`upload`,T;t[20]===w?T=t[21]:(T=(0,J.jsx)(`div`,{className:`truncate font-medium text-fg`,children:w}),t[20]=w,t[21]=T);let E;t[22]===n.size?E=t[23]:(E=kt(n.size),t[22]=n.size,t[23]=E);let D;t[24]===E?D=t[25]:(D=(0,J.jsx)(`div`,{className:`text-xs text-fg-subtle`,children:E}),t[24]=E,t[25]=D);let O;t[26]!==C||t[27]!==T||t[28]!==D||t[29]!==x||t[30]!==S?(O=(0,J.jsxs)(`button`,{type:`button`,className:x,disabled:S,onClick:C,children:[T,D]}),t[26]=C,t[27]=T,t[28]=D,t[29]=x,t[30]=S,t[31]=O):O=t[31];let k;t[32]!==r||t[33]!==l?(k=()=>l(r),t[32]=r,t[33]=l,t[34]=k):k=t[34];let A;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,J.jsx)(h,{className:`size-3.5`,"aria-hidden":!0}),t[35]=A):A=t[35];let j;t[36]!==a||t[37]!==s.attachments.remove||t[38]!==k?(j=(0,J.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:s.attachments.remove,"aria-label":s.attachments.remove,disabled:a,onClick:k,children:A}),t[36]=a,t[37]=s.attachments.remove,t[38]=k,t[39]=j):j=t[39];let M;return t[40]!==O||t[41]!==j||t[42]!==y?(M=(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 py-2 text-sm`,children:[y,O,j]}),t[40]=O,t[41]=j,t[42]=y,t[43]=M):M=t[43],M}function Ut(e){let t=(0,K.c)(56),{item:n,attachment:r,busy:a,previewBusy:o,t:s,onOpen:c,onDownload:l,onRemove:d}=e,f;t[0]!==r.fileName||t[1]!==r.mimeType?(f=At(r.fileName,r.mimeType),t[0]=r.fileName,t[1]=r.mimeType,t[2]=f):f=t[2];let p=f,m=Ft(n.id,r),h=a||o,g;t[3]!==r||t[4]!==n||t[5]!==c?(g=()=>c(n,r),t[3]=r,t[4]=n,t[5]=c,t[6]=g):g=t[6];let _;t[7]!==r.fileName||t[8]!==r.mimeType||t[9]!==p||t[10]!==h||t[11]!==g||t[12]!==m?(_=(0,J.jsx)(It,{name:r.fileName,mimeType:r.mimeType,thumbnailUrl:m,previewable:p,disabled:h,onOpen:g}),t[7]=r.fileName,t[8]=r.mimeType,t[9]=p,t[10]=h,t[11]=g,t[12]=m,t[13]=_):_=t[13];let v=p?`rounded-md hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`:`cursor-default`,y;t[14]===v?y=t[15]:(y=i(`min-w-0 flex-1 text-left`,v),t[14]=v,t[15]=y);let b=!p||a||o,x;t[16]!==r||t[17]!==n||t[18]!==c?(x=()=>c(n,r),t[16]=r,t[17]=n,t[18]=c,t[19]=x):x=t[19];let S;t[20]===r.fileName?S=t[21]:(S=(0,J.jsx)(`div`,{className:`truncate font-medium text-fg`,children:r.fileName}),t[20]=r.fileName,t[21]=S);let C=r.mimeType,w;t[22]===r.size?w=t[23]:(w=kt(r.size),t[22]=r.size,t[23]=w);let T;t[24]!==r.mimeType||t[25]!==w?(T=(0,J.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[C,` · `,w]}),t[24]=r.mimeType,t[25]=w,t[26]=T):T=t[26];let E;t[27]!==T||t[28]!==y||t[29]!==b||t[30]!==x||t[31]!==S?(E=(0,J.jsxs)(`button`,{type:`button`,className:y,disabled:b,onClick:x,children:[S,T]}),t[27]=T,t[28]=y,t[29]=b,t[30]=x,t[31]=S,t[32]=E):E=t[32];let D;t[33]!==r||t[34]!==n||t[35]!==l?(D=()=>l(n,r),t[33]=r,t[34]=n,t[35]=l,t[36]=D):D=t[36];let O;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,J.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),t[37]=O):O=t[37];let k;t[38]!==a||t[39]!==s.attachments.download||t[40]!==D?(k=(0,J.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,title:s.attachments.download,"aria-label":s.attachments.download,disabled:a,onClick:D,children:O}),t[38]=a,t[39]=s.attachments.download,t[40]=D,t[41]=k):k=t[41];let A;t[42]!==r||t[43]!==n||t[44]!==d?(A=()=>d(n,r),t[42]=r,t[43]=n,t[44]=d,t[45]=A):A=t[45];let j;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,J.jsx)(mt,{className:`size-3.5`,"aria-hidden":!0}),t[46]=j):j=t[46];let M;t[47]!==a||t[48]!==s.attachments.remove||t[49]!==A?(M=(0,J.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-danger`,title:s.attachments.remove,"aria-label":s.attachments.remove,disabled:a,onClick:A,children:j}),t[47]=a,t[48]=s.attachments.remove,t[49]=A,t[50]=M):M=t[50];let N;return t[51]!==E||t[52]!==k||t[53]!==M||t[54]!==_?(N=(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 py-2 text-sm`,children:[_,E,k,M]}),t[51]=E,t[52]=k,t[53]=M,t[54]=_,t[55]=N):N=t[55],N}function Wt({mode:e,item:t,pendingFiles:n,busy:r,t:a,onPendingFilesChange:c,onUpload:l,onRemove:u,onDownload:d,onPreviewError:f}){let p=(0,q.useRef)(null),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),S=o(e=>e.token),C=t?.attachments??[];function w(r){if(!r.length)return;if(e===`detail`&&t){l(t,r);return}let i=new Set(n.map(Y)),a=[...n];for(let e of r){let t=Y(e);i.has(t)||(i.add(t),a.push(e))}c(a)}function T(e){c(n.filter((t,n)=>n!==e))}async function E(e){let t=Y(e);x(`pending:${t}`);try{y(await Nt(e,`pending:${t}`)),_(!0)}catch(e){f(e instanceof Error?e.message:String(e))}finally{x(null)}}async function D(e,t){x(`saved:${t.id}`);try{let n=await s(We(e.id,t.id));if(!n.ok)throw Error(`HTTP ${n.status}`);y(Mt(t,de(await n.arrayBuffer()))),_(!0)}catch(e){f(e instanceof Error?e.message:String(e))}finally{x(null)}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`section`,{className:i(`grid gap-3 rounded-lg border border-edge bg-surface-base p-3`,m&&`border-accent bg-accent-soft/40`),onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||h(!1)},onDrop:e=>{e.preventDefault(),h(!1),w(Array.from(e.dataTransfer.files))},children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsxs)(`h3`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,J.jsx)(Me,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`truncate`,children:a.attachments.title})]}),(0,J.jsxs)(G,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:r,onClick:()=>p.current?.click(),children:[(0,J.jsx)(le,{className:`size-3.5`,"aria-hidden":!0}),a.attachments.add]}),(0,J.jsx)(`input`,{ref:p,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{w(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),n.length?(0,J.jsx)(`div`,{className:`grid gap-2`,children:n.map((e,t)=>(0,J.jsx)(Ht,{file:e,index:t,busy:r,previewBusy:b===`pending:${Y(e)}`,t:a,onOpen:e=>void E(e),onRemove:T},Y(e)))}):null,t&&C.length?(0,J.jsx)(`div`,{className:`grid gap-2`,children:C.map(e=>(0,J.jsx)(Ut,{item:t,attachment:e,busy:r,previewBusy:b===`saved:${e.id}`,t:a,onOpen:(e,t)=>void D(e,t),onDownload:d,onRemove:u},e.id))}):null,!n.length&&!C.length?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.attachments.empty}):null]}),(0,J.jsx)(ce,{open:g,attachment:v,authToken:S,layerClassName:`z-[100]`,onClose:()=>{_(!1),y(null)}})]})}function Gt(e){let t=(0,K.c)(170),{mode:n,item:r,initialStatus:a,events:o,busy:s,error:c,notice:u,t:f,onClose:p,onCreate:g,onSave:_,onStartChat:v,onCreateGoal:b,onAddAttachments:x,onRemoveAttachment:S,onDownloadAttachment:C,onPreviewError:w}=e,T=n!==null,[E,D]=(0,q.useState)(``),[k,A]=(0,q.useState)(``),[j,M]=(0,q.useState)(`todo`),[P,L]=(0,q.useState)(`normal`),[z,V]=(0,q.useState)(``),[H,ee]=(0,q.useState)(``),te;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(te=[],t[0]=te):te=t[0];let[ne,re]=(0,q.useState)(te),ie,ae;t[1]!==a||t[2]!==r||t[3]!==n?(ie=()=>{if(n===`create`){D(``),A(``),M(a),L(`normal`),V(``),ee(``),re([]);return}n===`detail`&&r&&(D(r.title),A(r.description??``),M(r.status),L(r.priority),V(r.nextAction??``),ee(r.blockedReason??``),re([]))},ae=[a,r,n],t[1]=a,t[2]=r,t[3]=n,t[4]=ie,t[5]=ae):(ie=t[4],ae=t[5]),(0,q.useEffect)(ie,ae);let oe;t[6]!==H||t[7]!==k||t[8]!==r||t[9]!==n||t[10]!==z||t[11]!==g||t[12]!==_||t[13]!==ne||t[14]!==P||t[15]!==j||t[16]!==E?(oe=function(e){e.preventDefault();let t=E.trim();if(t){if(n===`create`){g({title:t,description:k.trim()||void 0,priority:P,status:j,nextAction:z.trim()||void 0,blockedReason:H.trim()||void 0,attachments:ne});return}r&&_(r,{title:t,description:k.trim()||null,status:j,priority:P,nextAction:z.trim()||null,blockedReason:H.trim()||null})}},t[6]=H,t[7]=k,t[8]=r,t[9]=n,t[10]=z,t[11]=g,t[12]=_,t[13]=ne,t[14]=P,t[15]=j,t[16]=E,t[17]=oe):oe=t[17];let se=oe,ce;t[18]===p?ce=t[19]:(ce=e=>!e&&p(),t[18]=p,t[19]=ce);let ue;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,J.jsx)(I,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[20]=ue):ue=t[20];let de=n===`create`?f.create.title:r?.title||f.title,fe;t[21]===de?fe=t[22]:(fe=(0,J.jsx)(R,{className:`truncate text-base font-semibold text-fg`,children:de}),t[21]=de,t[22]=fe);let pe;t[23]===f.detail.description?pe=t[24]:(pe=(0,J.jsx)(d,{className:`mt-1 text-sm text-fg-muted`,children:f.detail.description}),t[23]=f.detail.description,t[24]=pe);let me;t[25]!==fe||t[26]!==pe?(me=(0,J.jsxs)(`div`,{className:`min-w-0`,children:[fe,pe]}),t[25]=fe,t[26]=pe,t[27]=me):me=t[27];let he;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,J.jsx)(h,{className:`size-4`,"aria-hidden":!0}),t[28]=he):he=t[28];let ge;t[29]===s?ge=t[30]:(ge=(0,J.jsx)(O,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,disabled:s,children:he})}),t[29]=s,t[30]=ge);let _e;t[31]!==me||t[32]!==ge?(_e=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[me,ge]}),t[31]=me,t[32]=ge,t[33]=_e):_e=t[33];let ve;t[34]===c?ve=t[35]:(ve=c?(0,J.jsx)(`div`,{className:`rounded-lg border border-danger/30 bg-danger-soft px-3 py-2 text-sm text-danger`,children:c}):null,t[34]=c,t[35]=ve);let ye;t[36]!==c||t[37]!==u?(ye=!c&&u?(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-success/30 bg-success-soft px-3 py-2 text-sm text-fg`,role:`status`,"aria-live":`polite`,children:[(0,J.jsx)(B,{className:`mt-0.5 size-4 shrink-0 text-success`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`font-medium text-success`,children:u.title}),(0,J.jsx)(`div`,{className:`mt-1 text-fg-muted`,children:u.message})]})]}):null,t[36]=c,t[37]=u,t[38]=ye):ye=t[38];let be;t[39]===f.create.titleLabel?be=t[40]:(be=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:f.create.titleLabel}),t[39]=f.create.titleLabel,t[40]=be);let xe;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(xe=e=>D(e.target.value),t[41]=xe):xe=t[41];let Se=n===`create`,Ce;t[42]!==Se||t[43]!==E?(Ce=(0,J.jsx)(`input`,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:E,onChange:xe,autoFocus:Se}),t[42]=Se,t[43]=E,t[44]=Ce):Ce=t[44];let we;t[45]!==be||t[46]!==Ce?(we=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[be,Ce]}),t[45]=be,t[46]=Ce,t[47]=we):we=t[47];let Te;t[48]===f.detail.status?Te=t[49]:(Te=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:f.detail.status}),t[48]=f.detail.status,t[49]=Te);let Ee;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>M(e.target.value),t[50]=Ee):Ee=t[50];let De;t[51]===f.statuses?De=t[52]:(De=Tt.map(e=>(0,J.jsx)(et,{value:e,children:f.statuses[e]},e)),t[51]=f.statuses,t[52]=De);let Oe;t[53]!==j||t[54]!==De?(Oe=(0,J.jsx)(l,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:j,onChange:Ee,children:De}),t[53]=j,t[54]=De,t[55]=Oe):Oe=t[55];let ke;t[56]!==Te||t[57]!==Oe?(ke=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[Te,Oe]}),t[56]=Te,t[57]=Oe,t[58]=ke):ke=t[58];let Ae;t[59]===f.create.priorityLabel?Ae=t[60]:(Ae=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:f.create.priorityLabel}),t[59]=f.create.priorityLabel,t[60]=Ae);let je;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(je=e=>L(e.target.value),t[61]=je):je=t[61];let Me;t[62]===f.priorities?Me=t[63]:(Me=Et.map(e=>(0,J.jsx)(et,{value:e,children:f.priorities[e]},e)),t[62]=f.priorities,t[63]=Me);let U;t[64]!==P||t[65]!==Me?(U=(0,J.jsx)(l,{className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:P,onChange:je,children:Me}),t[64]=P,t[65]=Me,t[66]=U):U=t[66];let Ne;t[67]!==Ae||t[68]!==U?(Ne=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[Ae,U]}),t[67]=Ae,t[68]=U,t[69]=Ne):Ne=t[69];let Pe;t[70]!==ke||t[71]!==Ne?(Pe=(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ke,Ne]}),t[70]=ke,t[71]=Ne,t[72]=Pe):Pe=t[72];let Fe;t[73]===f.create.descriptionLabel?Fe=t[74]:(Fe=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:f.create.descriptionLabel}),t[73]=f.create.descriptionLabel,t[74]=Fe);let Ie;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=e=>A(e.target.value),t[75]=Ie):Ie=t[75];let Le;t[76]===k?Le=t[77]:(Le=(0,J.jsx)(`textarea`,{className:`min-h-28 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:k,onChange:Ie}),t[76]=k,t[77]=Le);let Re;t[78]!==Fe||t[79]!==Le?(Re=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[Fe,Le]}),t[78]=Fe,t[79]=Le,t[80]=Re):Re=t[80];let ze;t[81]!==s||t[82]!==r||t[83]!==n||t[84]!==x||t[85]!==C||t[86]!==w||t[87]!==S||t[88]!==ne||t[89]!==f?(ze=(0,J.jsx)(Wt,{mode:n,item:r,pendingFiles:ne,busy:s,t:f,onPendingFilesChange:re,onUpload:x,onRemove:S,onDownload:C,onPreviewError:w}),t[81]=s,t[82]=r,t[83]=n,t[84]=x,t[85]=C,t[86]=w,t[87]=S,t[88]=ne,t[89]=f,t[90]=ze):ze=t[90];let Be;t[91]!==H||t[92]!==n||t[93]!==z||t[94]!==j||t[95]!==f.blockedReason||t[96]!==f.nextAction?(Be=n===`detail`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:f.nextAction}),(0,J.jsx)(`textarea`,{className:`min-h-20 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:z,onChange:e=>V(e.target.value)})]}),(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:i(`font-medium`,j===`blocked`||j===`needs_input`?`text-red-700 dark:text-red-300`:`text-fg-muted`),children:f.blockedReason}),(0,J.jsx)(`textarea`,{className:i(`min-h-20 rounded-lg border bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,j===`blocked`||j===`needs_input`?`border-red-500/40`:`border-edge`),value:H,onChange:e=>ee(e.target.value)})]})]}):null,t[91]=H,t[92]=n,t[93]=z,t[94]=j,t[95]=f.blockedReason,t[96]=f.nextAction,t[97]=Be):Be=t[97];let Ve;t[98]!==ve||t[99]!==ye||t[100]!==we||t[101]!==Pe||t[102]!==Re||t[103]!==ze||t[104]!==Be?(Ve=(0,J.jsxs)(`div`,{className:`grid content-start gap-4`,children:[ve,ye,we,Pe,Re,ze,Be]}),t[98]=ve,t[99]=ye,t[100]=we,t[101]=Pe,t[102]=Re,t[103]=ze,t[104]=Be,t[105]=Ve):Ve=t[105];let He;t[106]!==s||t[107]!==r||t[108]!==n||t[109]!==b||t[110]!==v||t[111]!==f.detail.actions||t[112]!==f.detail.createGoal||t[113]!==f.detail.openItem||t[114]!==f.detail.startChat?(He=n===`detail`&&r?(0,J.jsxs)(`section`,{children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:f.detail.actions}),(0,J.jsxs)(`div`,{className:`mt-2 grid gap-2`,children:[(0,J.jsxs)(G,{type:`button`,variant:`secondary`,className:`justify-start rounded-lg`,disabled:s,onClick:()=>v(r),children:[(0,J.jsx)(gt,{className:`size-4`,"aria-hidden":!0}),f.detail.startChat]}),(0,J.jsxs)(G,{type:`button`,variant:`secondary`,className:`justify-start rounded-lg`,disabled:s,onClick:()=>b(r),children:[(0,J.jsx)(F,{className:`size-4`,"aria-hidden":!0}),f.detail.createGoal]}),(0,J.jsx)(G,{asChild:!0,variant:`secondary`,className:`justify-start rounded-lg`,children:(0,J.jsxs)(lt,{to:`/work-items/${encodeURIComponent(r.id)}`,children:[(0,J.jsx)(m,{className:`size-4`,"aria-hidden":!0}),f.detail.openItem]})})]})]}):null,t[106]=s,t[107]=r,t[108]=n,t[109]=b,t[110]=v,t[111]=f.detail.actions,t[112]=f.detail.createGoal,t[113]=f.detail.openItem,t[114]=f.detail.startChat,t[115]=He):He=t[115];let Ue;t[116]===f.detail.links?Ue=t[117]:(Ue=(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:f.detail.links}),t[116]=f.detail.links,t[117]=Ue);let We;t[118]!==r||t[119]!==f.detail.noLinks||t[120]!==f.linkKinds?(We=r?.links?.length?r.links.slice(0,6).map(e=>(0,J.jsxs)(lt,{to:Lt(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[f.linkKinds[e.kind],(0,J.jsx)(m,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f.detail.noLinks}),t[118]=r,t[119]=f.detail.noLinks,t[120]=f.linkKinds,t[121]=We):We=t[121];let Ge;t[122]===We?Ge=t[123]:(Ge=(0,J.jsx)(`div`,{className:`mt-2 grid gap-2 text-sm`,children:We}),t[122]=We,t[123]=Ge);let W;t[124]!==Ue||t[125]!==Ge?(W=(0,J.jsxs)(`section`,{children:[Ue,Ge]}),t[124]=Ue,t[125]=Ge,t[126]=W):W=t[126];let Ke;t[127]===f.detail.activity?Ke=t[128]:(Ke=(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:f.detail.activity}),t[127]=f.detail.activity,t[128]=Ke);let qe;t[129]!==o||t[130]!==f.detail.noActivity||t[131]!==f.eventTypes?(qe=o.length?o.slice(0,5).map(e=>(0,J.jsxs)(`div`,{className:`text-sm`,children:[(0,J.jsx)(`div`,{className:`font-medium text-fg`,children:f.eventTypes[e.type]??e.type}),(0,J.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:Ot(e.createdAt)})]},e.id)):(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f.detail.noActivity}),t[129]=o,t[130]=f.detail.noActivity,t[131]=f.eventTypes,t[132]=qe):qe=t[132];let Je;t[133]===qe?Je=t[134]:(Je=(0,J.jsx)(`div`,{className:`mt-2 grid gap-2`,children:qe}),t[133]=qe,t[134]=Je);let Ye;t[135]!==Ke||t[136]!==Je?(Ye=(0,J.jsxs)(`section`,{children:[Ke,Je]}),t[135]=Ke,t[136]=Je,t[137]=Ye):Ye=t[137];let Xe;t[138]!==He||t[139]!==W||t[140]!==Ye?(Xe=(0,J.jsxs)(`aside`,{className:`grid content-start gap-5`,children:[He,W,Ye]}),t[138]=He,t[139]=W,t[140]=Ye,t[141]=Xe):Xe=t[141];let Ze;t[142]!==Ve||t[143]!==Xe?(Ze=(0,J.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-6 overflow-y-auto px-5 py-4 lg:grid-cols-[minmax(0,1fr)_16rem]`,children:[Ve,Xe]}),t[142]=Ve,t[143]=Xe,t[144]=Ze):Ze=t[144];let Qe;t[145]!==s||t[146]!==p||t[147]!==f.create.cancel?(Qe=(0,J.jsx)(G,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:p,disabled:s,children:f.create.cancel}),t[145]=s,t[146]=p,t[147]=f.create.cancel,t[148]=Qe):Qe=t[148];let $e;t[149]!==s||t[150]!==E?($e=s||!E.trim(),t[149]=s,t[150]=E,t[151]=$e):$e=t[151];let tt;t[152]===n?tt=t[153]:(tt=n===`create`?(0,J.jsx)(le,{className:`size-4`,"aria-hidden":!0}):null,t[152]=n,t[153]=tt);let nt=n===`create`?f.create.submit:f.detail.save,rt;t[154]!==$e||t[155]!==tt||t[156]!==nt?(rt=(0,J.jsxs)(G,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:$e,children:[tt,nt]}),t[154]=$e,t[155]=tt,t[156]=nt,t[157]=rt):rt=t[157];let it;t[158]!==Qe||t[159]!==rt?(it=(0,J.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[Qe,rt]}),t[158]=Qe,t[159]=rt,t[160]=it):it=t[160];let at;t[161]!==se||t[162]!==_e||t[163]!==Ze||t[164]!==it?(at=(0,J.jsxs)(y,{children:[ue,(0,J.jsx)(ft,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(86dvh,48rem)] w-[min(60rem,calc(100vw-2rem))] -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,J.jsxs)(`form`,{onSubmit:se,className:`flex min-h-0 flex-1 flex-col`,children:[_e,Ze,it]})})]}),t[161]=se,t[162]=_e,t[163]=Ze,t[164]=it,t[165]=at):at=t[165];let ot;return t[166]!==T||t[167]!==ce||t[168]!==at?(ot=(0,J.jsx)(N,{open:T,onOpenChange:ce,children:at}),t[166]=T,t[167]=ce,t[168]=at,t[169]=ot):ot=t[169],ot}function Kt({projectId:e,createRequestKey:t=0}){let n=st(),r=a(c(e=>e.language)).projectDetailPage.workItems,o=(0,q.useRef)(null),s=(0,q.useRef)(null),[l,u]=(0,q.useState)([]),[d,f]=(0,q.useState)(!0),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(null),[x,S]=(0,q.useState)(null),[C,T]=(0,q.useState)(!1),[E,D]=(0,q.useState)(!1),[O,k]=(0,q.useState)(!1),[A,j]=(0,q.useState)(`todo`),[M,N]=(0,q.useState)(null),[P,F]=(0,q.useState)([]),I=(0,q.useCallback)(async(t=`replace`,n=0)=>{f(!0),m(null);try{let r=await Ye(e,{limit:100,offset:n});u(e=>t===`append`?[...e,...r.items]:r.items),D(r.hasMore)}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}},[e]);(0,q.useEffect)(()=>{I(`replace`,0)},[I]),(0,q.useEffect)(()=>{t&&(N(null),F([]),m(null),g(null),j(`todo`),k(!0))},[t]);let L=(0,q.useMemo)(()=>Tt.map(e=>({status:e,title:r.statuses[e],items:l.filter(t=>t.status===e)})),[l,r.statuses]),R=(0,q.useCallback)(e=>{u(t=>t.map(t=>t.id===e.id?e:t)),N(t=>t?.id===e.id?e:t)},[]),z=(0,q.useCallback)(async(e,t)=>{v(!0),m(null),g(null);try{let n=await tt(e.id,t);n.item.archivedAt?(u(e=>e.filter(e=>e.id!==n.item.id)),N(null)):(R(n.item),g({title:r.feedback.savedTitle,message:r.feedback.savedNext}))}catch(e){m(e instanceof Error?e.message:String(e))}finally{v(!1)}},[r.feedback.savedNext,r.feedback.savedTitle,R]),B=(0,q.useCallback)(async e=>{N(e),F([]),m(null),g(null);let t=await U(e.id).catch(()=>null);t&&F(t.events)},[]),V=(0,q.useCallback)(async t=>{v(!0),m(null),g(null);try{let n=await qe(e,t);u(e=>[n.item,...e]),k(!1),N(n.item),F((await U(n.item.id).catch(()=>({events:[]}))).events),g({title:r.feedback.createdTitle,message:r.feedback.createdNext})}catch(e){m(e instanceof Error?e.message:String(e))}finally{v(!1)}},[e,r.feedback.createdNext,r.feedback.createdTitle]),H=(0,q.useCallback)(async(e,t)=>{if(t.length){v(!0),m(null),g(null);try{let n=await xe(e.id,t);R(n.item),F((await U(n.item.id).catch(()=>({events:[]}))).events)}catch(e){m(e instanceof Error?e.message:String(e))}finally{v(!1)}}},[R]),ee=(0,q.useCallback)(async(e,t)=>{v(!0),m(null),g(null);try{let n=await oe(e.id,t.id);R(n.item),F((await U(n.item.id).catch(()=>({events:[]}))).events)}catch(e){m(e instanceof Error?e.message:String(e))}finally{v(!1)}},[R]),te=(0,q.useCallback)(async(e,t)=>{m(null),g(null);try{await He(e.id,t)}catch(e){m(e instanceof Error?e.message:String(e))}},[]),ne=(0,q.useCallback)(async e=>{v(!0),m(null),g(null);try{let t=await he(e.id);R(t.item),await B(t.item),n(`/chat/${encodeURIComponent(t.session.key)}`)}catch(e){m(e instanceof Error?e.message:String(e))}finally{v(!1)}},[n,B,R]),re=(0,q.useCallback)(async e=>{v(!0),m(null),g(null);try{let t=await ke(e.id);R(t.item),await B(t.item),n(`/goals/${encodeURIComponent(t.goal.id)}`)}catch(e){m(e instanceof Error?e.message:String(e))}finally{v(!1)}},[n,B,R]),ie=(0,q.useCallback)((e,t)=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(wt,e.id),b(e.id)},[]),ae=(0,q.useCallback)((e,t)=>{t.preventDefault();let n=t.dataTransfer.getData(wt)||y;S(null),b(null);let r=l.find(e=>e.id===n);!r||r.status===e||z(r,{status:e})},[y,l,z]),se=(0,q.useCallback)(e=>{z(e,{status:e.status===`done`?`todo`:`done`})},[z]),ce=(0,q.useCallback)(e=>{N(null),F([]),m(null),g(null),j(e),k(!0)},[]),ue=(0,q.useCallback)(e=>{let t=s.current;!t||t.pointerId!==e.pointerId||(s.current=null,T(!1),e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),de=(0,q.useCallback)(e=>{if(e.button!==0||y||Rt(e.target))return;let t=o.current;t&&(s.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},[y]),fe=(0,q.useCallback)(e=>{let t=s.current,n=o.current;if(!t||!n||t.pointerId!==e.pointerId)return;let r=e.clientX-t.startX;!t.active&&Math.abs(r)<5||(t.active||(t.active=!0,T(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},[]);return(0,J.jsxs)(`section`,{id:`project-panel-work-items`,role:`tabpanel`,"aria-labelledby":`project-tab-work-items`,className:`flex h-full min-h-0 flex-col`,children:[p?(0,J.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:p}):null,(0,J.jsx)(`section`,{ref:o,className:i(`min-h-0 flex-1 overflow-x-auto rounded-lg px-2 py-2 transition-opacity`,d&&`opacity-60`,C?`cursor-grabbing select-none`:`cursor-grab`),"aria-label":r.boardAria,"aria-busy":d,onPointerDown:de,onPointerMove:fe,onPointerUp:ue,onPointerCancel:ue,onLostPointerCapture:e=>{s.current?.pointerId===e.pointerId&&(s.current=null,T(!1))},children:(0,J.jsx)(`div`,{className:`flex min-h-full min-w-max items-start gap-3 pr-4`,children:L.map(e=>(0,J.jsxs)(`section`,{className:i(`flex max-h-full w-72 min-w-72 max-w-72 shrink-0 flex-col overflow-y-auto rounded-lg bg-surface-base shadow-surface`,x===e.status&&`bg-surface-active`),"aria-label":e.title,onDragOver:t=>{y&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,S(e.status))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||S(null)},onDrop:t=>ae(e.status,t),children:[(0,J.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 px-3 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,J.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.title}),(0,J.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.items.length})]}),(0,J.jsx)(w,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),(0,J.jsxs)(`div`,{className:`mx-2 mt-3 grid min-h-0 min-w-0 content-start gap-2 pb-2 pr-1 [scrollbar-gutter:stable]`,children:[e.items.length?e.items.map(e=>(0,J.jsx)(Bt,{item:e,dragging:y===e.id,onOpen:B,onToggleDone:se,onDragStart:ie,onDragEnd:()=>{b(null),S(null)},t:r},e.id)):d?(0,J.jsxs)(`div`,{className:`grid gap-2 animate-pulse motion-reduce:animate-none`,children:[(0,J.jsx)(Vt,{}),(0,J.jsx)(Vt,{})]}):(0,J.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-6 text-center text-xs text-fg-subtle`,children:r.emptyColumn}),d?null:(0,J.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-full items-center justify-center rounded-lg bg-surface-panel/85 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-muted`,"aria-label":r.create.addToColumn.replace(`{{status}}`,e.title),title:r.create.addToColumn.replace(`{{status}}`,e.title),onClick:()=>ce(e.status),children:(0,J.jsx)(le,{className:`size-4`,"aria-hidden":!0})})]})]},e.status))})}),!d&&E?(0,J.jsx)(G,{type:`button`,variant:`secondary`,className:`justify-self-center`,onClick:()=>void I(`append`,l.length),children:r.loadMore}):null,(0,J.jsx)(Gt,{mode:O?`create`:M?`detail`:null,item:M,initialStatus:A,events:P,busy:_,error:p,notice:h,t:r,onClose:()=>{k(!1),N(null),F([]),m(null),g(null)},onCreate:V,onSave:(e,t)=>void z(e,t),onStartChat:ne,onCreateGoal:re,onAddAttachments:(e,t)=>void H(e,t),onRemoveAttachment:(e,t)=>void ee(e,t),onDownloadAttachment:(e,t)=>void te(e,t),onPreviewError:e=>{g(null),m(e)}})]})}var qt=[{id:`overview`,icon:ye},{id:`work-items`,icon:te},{id:`sessions`,icon:gt},{id:`goals`,icon:F},{id:`workflows`,icon:A},{id:`files`,icon:rt},{id:`activity`,icon:Pe},{id:`automations`,icon:g},{id:`notes`,icon:k},{id:`settings`,icon:je}],Jt=qt.map(e=>e.id),Yt=new Set(qt.map(e=>e.id)),Xt=`xopc.projectTabs.`,Zt=`xopc.projectFiles.panelWidthPx`,Qt=320,$t=220,en=560;function tn(e){return Math.min(en,Math.max($t,Math.round(e)))}function nn(){try{let e=window.localStorage.getItem(Zt);if(e==null)return Qt;let t=Number.parseInt(e,10);return Number.isFinite(t)?tn(t):Qt}catch{return Qt}}function rn(e){try{window.localStorage.setItem(Zt,String(tn(e)))}catch{}}function an(e){return!!(e&&Yt.has(e))}function on(e){return`${Xt}${e}`}function sn(e){let t=Array.isArray(e)?e:[],n=new Set,r=[];for(let e of t)!an(e)||n.has(e)||(n.add(e),r.push(e));for(let e of Jt)n.has(e)||r.push(e);return r}function cn(e){if(!e)return Jt;try{let t=window.localStorage.getItem(on(e));return sn(t?JSON.parse(t):null)}catch{return Jt}}function ln(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function un(e,t=``){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?String(e):new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(n)}function dn(e){return e===`active`?`bg-accent-soft text-accent-fg`:e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`paused`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`archived`?`bg-surface-muted text-fg-subtle`:`bg-surface-hover text-fg-muted`}function fn(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`||e===`cancelled`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-muted`}function pn(e){let t=(0,K.c)(8),{label:n,hint:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,J.jsx)(`span`,{className:`text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function mn(e=!1){return i(`w-full rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,e?`min-h-24 py-2 leading-5`:`min-h-10`)}function hn(e){let t=(0,K.c)(10),{label:n,value:r,mono:a}=e,o=a===void 0?!1:a,s;t[0]===n?s=t[1]:(s=(0,J.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=s);let c=o&&`font-mono text-xs`,l;t[2]===c?l=t[3]:(l=i(`mt-1 min-w-0 truncate text-sm text-fg`,c),t[2]=c,t[3]=l);let u;t[4]!==l||t[5]!==r?(u=(0,J.jsx)(`div`,{className:l,title:r,children:r}),t[4]=l,t[5]=r,t[6]=u):u=t[6];let d;return t[7]!==s||t[8]!==u?(d=(0,J.jsxs)(`div`,{className:`min-w-0 rounded-md bg-surface-base px-3 py-2`,children:[s,u]}),t[7]=s,t[8]=u,t[9]=d):d=t[9],d}function X(e){return[e.name,e.slug,e.workspaceRoot,e.description,e.brief].filter(Boolean).join(` `).toLowerCase()}function gn(e){let t=e.lastActiveAt??e.updatedAt??e.createdAt,n=t?new Date(t).getTime():0;return Number.isFinite(n)?n:0}function _n(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function vn(e){let t=e?.body;return t?.code===`workspace_root_missing`&&t.workspaceRoot?t.workspaceRoot:null}function yn(e){let t=e.actor;return t.name?t.name:t.agentId?t.agentId:t.id?t.id:t.sessionKey?t.sessionKey:t.kind}function bn(e){return e.primaryObject.title?.trim()||e.primaryObject.id}function xn(e){let t=e.source;return t.toolCallId?`${t.kind} · ${t.toolCallId}`:t.runId?`${t.kind} · ${t.runId}`:t.requestId?`${t.kind} · ${t.requestId}`:t.kind}function Sn(e){let t=e.payload.changes;if(Array.isArray(t)&&t.length)return t.filter(e=>typeof e==`string`).join(`, `);let n=e.payload.contentPreview;if(typeof n==`string`&&n.trim())return n.trim();let r=e.payload.title??e.payload.name;return typeof r==`string`&&r.trim()?r.trim():``}function Cn(e){return e.map(e=>({name:e.name,path:e.path,absolutePath:e.absolutePath,isDirectory:e.type===`directory`,children:e.type===`directory`?[]:void 0}))}function wn(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:wn(e.children,t,n)}:e)}function Tn({currentProject:e,pm:t,projectsText:n,wd:r}){let a=st(),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)([e]),[u,f]=(0,q.useState)(``),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(!1),[b,x]=(0,q.useState)(`new`),[S,C]=(0,q.useState)(``),[w,T]=(0,q.useState)(``),[E,k]=(0,q.useState)(!1),[A,j]=(0,q.useState)(null),[M,P]=(0,q.useState)(null),F=(0,q.useCallback)(async()=>{m(!0),g(null);try{let t=await D({limit:100});l(n=>{let r=new Map;r.set(e.id,e);for(let e of n)r.set(e.id,e);for(let e of t.items)r.set(e.id,e);return Array.from(r.values())})}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e]);(0,q.useEffect)(()=>{l(t=>[e,...t.filter(t=>t.id!==e.id)])},[e]),(0,q.useEffect)(()=>{o&&F()},[F,o]);let z=(0,q.useMemo)(()=>{let t=u.trim().toLowerCase().split(/\s+/).filter(Boolean);return c.filter(t=>t.id!==e.id).filter(e=>{if(t.length===0)return!0;let n=X(e);return t.every(e=>n.includes(e))}).sort((e,t)=>gn(t)-gn(e))},[e.id,c,u]),B=e=>t.statuses[e.status]??e.status,V=e=>e.workspaceRoot||e.effectiveWorkspaceRoot||e.description||e.brief||t.common.defaultWorkspace,H=e=>{x(e),C(``),T(``),j(null),v(!0),s(!1)},ee=(0,q.useCallback)(async(e={})=>{let t=w.trim(),n=S.trim()||(b===`directory`?_n(t):``);if(n){k(!0),j(null),P(null);try{let r=await L({name:n,...t?{workspaceRoot:t}:{},...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});v(!1),C(``),T(``),l(e=>[r,...e.filter(e=>e.id!==r.id)]),a(`/projects/${encodeURIComponent(r.id)}`)}catch(e){let t=vn(e);t?(P(t),v(!1)):j(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[b,S,a,w]),te=(0,q.useCallback)(e=>{e.preventDefault(),ee()},[ee]),ne=(0,q.useCallback)(()=>{ee({createWorkspaceRoot:!0})},[ee]),re=(0,q.useCallback)(()=>{P(null),v(!0)},[]),ie=e=>{T(e),b===`directory`&&!S.trim()&&C(_n(e))},ae=(e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:i(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,t&&`bg-accent-soft/55 hover:bg-accent-soft/70`),onClick:()=>{s(!1),t||a(`/projects/${encodeURIComponent(e.id)}`)},children:[(0,J.jsx)(Ve,{className:i(`size-4 text-accent-fg`,!t&&`invisible`),"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,J.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:V(e)})]}),(0,J.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,dn(e.status)),children:B(e)})]},e.id);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(pe,{open:o,onOpenChange:s,children:[(0,J.jsx)(Ie,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`group -ml-2 flex max-w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":t.projectSwitcher.switchProject,title:t.projectSwitcher.switchProject,children:[(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:e.name}),(0,J.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,dn(e.status)),children:B(e)})]}),(0,J.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:V(e)})]}),(0,J.jsx)($e,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":!0})]})}),(0,J.jsx)(Xe,{children:(0,J.jsxs)(Ue,{side:`bottom`,align:`start`,sideOffset:6,className:`z-[70] w-[min(26rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover outline-none`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,J.jsxs)(`label`,{className:`relative block`,children:[(0,J.jsx)(me,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,className:`h-9 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:u,onChange:e=>f(e.target.value),placeholder:t.projectSwitcher.searchPlaceholder,"aria-label":t.projectSwitcher.searchPlaceholder})]}),(0,J.jsxs)(`div`,{className:`mt-1 max-h-[min(54vh,24rem)] overflow-y-auto pr-0.5 [scrollbar-gutter:stable]`,children:[(0,J.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.current}),ae(e,!0),(0,J.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.recent}),h?(0,J.jsx)(`div`,{className:`px-2 py-2 text-xs text-red-600 dark:text-red-400`,children:h}):null,p&&z.length===0?(0,J.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.loading}):null,!p&&z.length===0?(0,J.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.noMatches}):null,z.map(e=>ae(e,!1))]}),(0,J.jsxs)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>H(`new`),children:[(0,J.jsx)(le,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.newProject})]}),(0,J.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>H(`directory`),children:[(0,J.jsx)(rt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.openDirectory})]}),(0,J.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>{s(!1),a(`/projects`)},children:[(0,J.jsx)(je,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.manageProjects})]})]})]})})]}),(0,J.jsx)(N,{open:_,onOpenChange:e=>!E&&v(e),children:(0,J.jsxs)(y,{children:[(0,J.jsx)(I,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(ft,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(32rem,calc(100vh-2rem))] w-[min(40rem,calc(100vw-2rem))] -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,J.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,J.jsx)(R,{className:`text-base font-semibold text-fg`,children:b===`directory`?t.projectSwitcher.createFromDirectoryTitle:n.createTitle}),(0,J.jsx)(d,{className:`mt-1 text-sm text-fg-muted`,children:b===`directory`?t.projectSwitcher.createFromDirectoryDescription:n.createDescription})]}),(0,J.jsxs)(`form`,{onSubmit:te,className:`flex min-h-0 flex-1 flex-col`,children:[(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[A?(0,J.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:A}):null,(0,J.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.projectName}),(0,J.jsx)(`input`,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:S,onChange:e=>C(e.target.value),placeholder:`xopc`,autoFocus:!0})]}),(0,J.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.workspaceRoot}),(0,J.jsx)(yt,{value:w,onChange:ie,disabled:E,wd:r,placeholder:n.workspacePlaceholder,inputClassName:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`}),(0,J.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.workspaceHint})]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(O,{asChild:!0,children:(0,J.jsx)(G,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:E,children:n.cancel})}),(0,J.jsxs)(G,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:E||!(S.trim()||b===`directory`&&_n(w)),children:[(0,J.jsx)(le,{className:`size-4`,"aria-hidden":!0}),n.create]})]})]})]})]})}),(0,J.jsx)(N,{open:!!M,onOpenChange:e=>{e||P(null)},children:(0,J.jsxs)(y,{children:[(0,J.jsx)(I,{className:`fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(ft,{className:`fixed left-1/2 top-1/2 z-[110] flex w-[min(30rem,calc(100vw-2rem))] -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,J.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,J.jsx)(R,{className:`text-base font-semibold text-fg`,children:n.workspaceMissingTitle}),(0,J.jsx)(d,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:M?ln(n.workspaceMissingDescription,{workspace:M}):null})]}),M?(0,J.jsx)(`div`,{className:`px-5 py-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,J.jsx)(rt,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:M})]})}):null,(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(G,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:re,disabled:E,children:n.workspaceMissingBack}),(0,J.jsxs)(G,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:ne,disabled:E,children:[(0,J.jsx)(dt,{className:`size-4`,"aria-hidden":!0}),n.workspaceMissingCreate]})]})]})]})})]})}function En(){let{projectId:e=``,tabId:t,noteId:n}=j(),r=st(),o=c(e=>e.language),s=a(o),u=s.chat.workingDirectory,p=s.projectDetailPage,m=s.projectsPage,w=_(e=>e.setPageHeader),D=_(e=>e.clearPageHeader),[F,L]=(0,q.useState)(null),[B,te]=(0,q.useState)(null),[oe,ce]=(0,q.useState)([]),[de,pe]=(0,q.useState)(``),[he,ye]=(0,q.useState)([]),[xe,ke]=(0,q.useState)([]),[je,Me]=(0,q.useState)([]),[U,Pe]=(0,q.useState)([]),[Ie,Ve]=(0,q.useState)([]),[He,Ue]=(0,q.useState)(!1),[We,qe]=(0,q.useState)(null),[Ye,Xe]=(0,q.useState)([]),[$e,tt]=(0,q.useState)(0),[nt,K]=(0,q.useState)(!1),[wt,Tt]=(0,q.useState)(!1),[Et,Dt]=(0,q.useState)(!1),[Ot,kt]=(0,q.useState)([]),Y=(0,q.useRef)(new Set),[At,jt]=(0,q.useState)(null),[Mt,Nt]=(0,q.useState)(nn),[Pt,Ft]=(0,q.useState)(!1),[It,Lt]=(0,q.useState)(!1),[Rt,zt]=(0,q.useState)(``),[Bt,Vt]=(0,q.useState)([]),[Ht,Ut]=(0,q.useState)(!1),[Wt,Gt]=(0,q.useState)(null),[Yt,Xt]=(0,q.useState)(!1),[Zt,Qt]=(0,q.useState)(null),[$t,en]=(0,q.useState)([]),[X,gn]=(0,q.useState)(``),[_n,En]=(0,q.useState)(!0),[Dn,On]=(0,q.useState)(!1),[kn,An]=(0,q.useState)(!1),[jn,Mn]=(0,q.useState)(null),[Nn,Pn]=(0,q.useState)(!1),[Fn,In]=(0,q.useState)(`fixed`),[Ln,Rn]=(0,q.useState)(``),[zn,Bn]=(0,q.useState)(null),[Vn,Hn]=(0,q.useState)(!1),[Un,Wn]=(0,q.useState)(!1),[Gn,Kn]=(0,q.useState)(0),[qn,Jn]=(0,q.useState)(!1),[Yn,Xn]=(0,q.useState)(!1),[Zn,Qn]=(0,q.useState)(null),[$n,er]=(0,q.useState)(null),[tr,nr]=(0,q.useState)(!1),[rr,ir]=(0,q.useState)(!1),[ar,or]=(0,q.useState)(!1),[sr,Z]=(0,q.useState)(null),[cr,lr]=(0,q.useState)({defaultAgentId:``,agents:[],models:[],checklistDecomposePolicy:`empty_only`}),[ur,dr]=(0,q.useState)({title:``,reason:``}),[fr,pr]=(0,q.useState)(()=>cn(e)),[Q,mr]=(0,q.useState)({name:``,description:``,status:`active`,defaultAgentId:``,workspaceRoot:``,brief:``,instructions:``}),hr=fr[0]??Jt[0],$=n?`notes`:an(t)?t:hr,gr=(0,q.useCallback)(t=>{e&&r(`/projects/${encodeURIComponent(e)}/${t}`)},[r,e]),_r=(0,q.useCallback)(t=>e?`/projects/${encodeURIComponent(e)}/${t}`:`/projects`,[e]),vr=(0,q.useCallback)(e=>{let t=_r(`goals`);return`/goals/${encodeURIComponent(e)}?returnTo=${encodeURIComponent(t)}`},[_r]),yr=(0,q.useCallback)(t=>{e&&r(_r(t),{replace:!0})},[r,e,_r]),br=(0,q.useCallback)((e,t)=>{yr(e),r(t)},[r,yr]),xr=(0,q.useCallback)(e=>t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||yr(e)},[yr]),Sr=(0,q.useCallback)(e=>e.startsWith(`/goals/`)?`goals`:e.startsWith(`/chat/`)?`sessions`:e.startsWith(`/workflows`)?`workflows`:e.startsWith(`/automations`)?`automations`:e.startsWith(`/notes`)?`notes`:$,[$]);(0,q.useEffect)(()=>{!e||!t||an(t)||r(`/projects/${encodeURIComponent(e)}/${hr}`,{replace:!0})},[hr,r,e,t]),(0,q.useEffect)(()=>{pr(cn(e))},[e]);let Cr=(0,q.useCallback)((t,n,r=`before`)=>{t!==n&&pr(i=>{let a=sn(i),o=a.indexOf(t),s=a.indexOf(n);if(o<0||s<0)return a;let[c]=a.splice(o,1),l=a.indexOf(n);return l<0?sn(i):(a.splice(r===`after`?l+1:l,0,c),e&&window.localStorage.setItem(on(e),JSON.stringify(a)),a)})},[e]);(0,q.useEffect)(()=>{if(!e)return;let t=!1;return En(!0),Z(null),Promise.all([V(e),ne(e),H(e),be().catch(()=>null)]).then(([e,n,r,i])=>{if(t)return;let a=e.project;L(a),te(e),ce(n),ye(r),en(i?.agents??[]),gn(a.defaultAgentId??``),mr({name:a.name,description:a.description??``,status:a.status,defaultAgentId:a.defaultAgentId??``,workspaceRoot:a.workspaceRoot??``,brief:a.brief??``,instructions:a.instructions??``})}).catch(e=>{t||Z(e instanceof Error?e.message:String(e))}).finally(()=>{t||En(!1)}),()=>{t=!0}},[e]),(0,q.useEffect)(()=>{let e=!1;async function t(){let[t,n,r]=await Promise.allSettled([be(),ie(),Se()]);e||lr(e=>{let i=t.status===`fulfilled`?t.value.defaultId:e.defaultAgentId,a=F?.defaultAgentId||X||i,o=t.status===`fulfilled`?t.value.agents:e.agents,s=n.status===`fulfilled`?n.value:e.models,c=r.status===`fulfilled`?bt(r.value.payload?.config).checklistDecomposePolicy:e.checklistDecomposePolicy;return{defaultAgentId:a,agents:o.length?o:[{id:a||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],models:s,checklistDecomposePolicy:c}})}return t(),()=>{e=!0}},[F?.defaultAgentId,X]);let wr=(0,q.useCallback)(async()=>{if(F){Jn(!0),Z(null);try{let[e,t]=await Promise.all([ze(),Oe(100,{ownerAgentId:X||void 0,projectId:F.id})]);ke(e),Me(t)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Jn(!1)}}},[F,X]);(0,q.useEffect)(()=>{F&&wr()},[F,wr]);let Tr=(0,q.useCallback)(async()=>{if(F){Ue(!0),Z(null);try{let[e,t]=await Promise.all([ut.list({projectId:F.id}),ut.runs(50,void 0,{projectId:F.id})]);Pe(e.automations),Ve(t.runs)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Ue(!1)}}},[F]);(0,q.useEffect)(()=>{$===`automations`&&Tr()},[Tr,$]);let Er=(0,q.useCallback)(async()=>{if(F){K(!0),Z(null);try{let e=await Ke(F.id,{includeRelated:wt,limit:100});Xe(e.items),tt(e.total)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{K(!1)}}},[F,wt]);(0,q.useEffect)(()=>{$===`activity`&&Er()},[Er,$]);let Dr=(0,q.useCallback)(async e=>{qe(`run:${e.id}`),Z(null);try{await ut.runNow(e.id),await Tr()}catch(e){Z(e instanceof Error?e.message:String(e))}finally{qe(null)}},[Tr]),Or=(0,q.useCallback)(async e=>{qe(`toggle:${e.id}`),Z(null);try{e.enabled?await ut.pause(e.id):await ut.resume(e.id),await Tr()}catch(e){Z(e instanceof Error?e.message:String(e))}finally{qe(null)}},[Tr]),kr=(0,q.useCallback)(async()=>{if(!F?.effectiveWorkspaceRoot?.trim()){kt([]),Y.current.clear(),Qt(null);return}Xt(!0),Qt(null),Y.current.clear();try{kt(Cn((await x(F.id,``)).entries)),Y.current.add(``)}catch(e){kt([]),Y.current.clear(),Qt(e instanceof Error?e.message:String(e))}finally{Xt(!1)}},[F]),Ar=(0,q.useCallback)(async e=>{if(!(!F?.effectiveWorkspaceRoot?.trim()||Y.current.has(e))){Y.current.add(e),Qt(null);try{let t=await x(F.id,e);kt(n=>wn(n,e,Cn(t.entries)))}catch(t){Y.current.delete(e),Qt(t instanceof Error?t.message:String(t))}}},[F]);(0,q.useEffect)(()=>{$===`files`&&kr()},[kr,$]);let jr=Rt.trim();(0,q.useEffect)(()=>{if($!==`files`||!F||!It||!jr){Vt([]),Ut(!1),Gt(null);return}let e=!1;Ut(!0),Gt(null),Vt([]);let t=window.setTimeout(()=>{Je(F.id,jr,50).then(t=>{e||Vt(t)}).catch(t=>{e||Gt(t instanceof Error?t.message:String(t))}).finally(()=>{e||Ut(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[jr,F,It,$]);let Mr=(0,q.useCallback)(async()=>{if(F){Wn(!0),Z(null);try{let e=await z(F.id);br(`sessions`,`/chat/${encodeURIComponent(e.key)}`)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Wn(!1)}}},[br,F]),Nr=(0,q.useCallback)(()=>{gr(`work-items`),Kn(e=>e+1)},[gr]),Pr=(0,q.useCallback)(async()=>{if(!F)return;let[e,t]=await Promise.all([V(F.id),H(F.id)]);te(e),L(e.project),ye(t)},[F]),Fr=(0,q.useCallback)(async e=>{if(!F||!e.title.trim())return;let t=Number.parseInt(e.maxTurns,10),n=e.deadline?new Date(e.deadline).getTime():void 0;nr(!0),Z(null);try{await P(F.id,{title:e.title.trim(),description:e.description.trim()||void 0,attachments:e.attachments.length?e.attachments:void 0,priority:e.priority,deadlineAt:Number.isFinite(n)?n:void 0,maxTurns:Number.isFinite(t)?t:void 0,agentId:e.agentId.trim()||void 0,judgeModelRef:e.judgeModelRef.trim()||void 0,contract:{objective:e.objective.trim()||e.title.trim(),scopeBoundary:e.scopeBoundary.trim()||void 0,evidencePlan:xt(e.evidencePlan),criteria:xt(e.checklist)}}),or(!1),gr(`goals`),await Pr()}catch(e){throw Z(e instanceof Error?e.message:String(e)),e}finally{nr(!1)}},[gr,F,Pr]),Ir=(0,q.useCallback)(async e=>{if(e.preventDefault(),!(!F||!ur.title.trim())){ir(!0),Z(null);try{await b(F.id,{title:ur.title.trim(),reason:ur.reason.trim()||void 0}),dr({title:``,reason:``}),await Pr()}catch(e){Z(e instanceof Error?e.message:String(e))}finally{ir(!1)}}},[ur.reason,ur.title,F,Pr]),Lr=(0,q.useCallback)(async e=>{if(!(!F||!$n)){Xn(!0),Z(null);try{let t=X||F.defaultAgentId||void 0,n=await ue({definitionId:$n.id,projectId:F.id,agentId:t,goal:e.goal,input:e.input,concurrency:e.concurrency,maxSubagents:e.maxSubagents});er(null),await wr(),br(`workflows`,S(n.runId,{ownerAgentId:t}))}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Xn(!1)}}},[br,F,wr,X,$n]),Rr=(0,q.useCallback)(async e=>{if(F){Qn(`retry:${e.id}`),Z(null);try{let t=await ae(e.id,{ownerAgentId:X||e.metadata?.agentId,projectId:e.metadata?.projectId||F.id});await wr(),br(`workflows`,S(t.runId,{ownerAgentId:X||e.metadata?.agentId||F.defaultAgentId}))}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Qn(null)}}},[br,F,wr,X]),zr=(0,q.useCallback)(async e=>{Qn(`cancel:${e.id}`),Z(null);try{await Ze(e.id,{ownerAgentId:X||e.metadata?.agentId}),await wr()}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Qn(null)}},[wr,X]),Br=(0,q.useMemo)(()=>(0,J.jsx)(lt,{to:`/projects`,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":p.backToProjects,children:(0,J.jsx)(De,{className:`size-4`,"aria-hidden":!0})}),[p.backToProjects]),Vr=(0,q.useMemo)(()=>F?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(G,{variant:`secondary`,className:`h-9 rounded-lg`,onClick:Nr,children:[(0,J.jsx)(le,{className:`size-4`,"aria-hidden":!0}),p.workItems.create.header]}),(0,J.jsxs)(G,{variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>void Mr(),disabled:Un,children:[(0,J.jsx)(gt,{className:`size-4`,"aria-hidden":!0}),p.common.newChat]})]}):null,[Nr,p.common.newChat,p.workItems.create.header,F,Mr,Un]);(0,q.useLayoutEffect)(()=>(w({startExtra:Br,main:F?(0,J.jsx)(Tn,{currentProject:F,pm:p,projectsText:m,wd:u}):(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:p.fallbackTitle}),(0,J.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:p.fallbackContext})]}),end:Vr}),()=>D()),[D,Vr,Br,p,F,m,w,u]);function Hr(e){L(t=>t?{...t,...e}:null),te(t=>t?{...t,project:{...t.project,...e}}:null),gn(e.defaultAgentId??``),mr(t=>({...t,name:e.name,description:e.description??``,status:e.status,defaultAgentId:e.defaultAgentId??``,workspaceRoot:e.workspaceRoot??``,brief:e.brief??``,instructions:e.instructions??``})),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}async function Ur(){if(!(!F||!Q.name.trim())){On(!0),Z(null),Mn(null);try{Hr(await se(F.id,{name:Q.name.trim(),status:Q.status,description:Q.description,defaultAgentId:Q.defaultAgentId,brief:Q.brief,instructions:Q.instructions}))}catch(e){let t=vn(e);t?Mn(t):Z(e instanceof Error?e.message:String(e))}finally{On(!1)}}}function Wr(e){e.preventDefault(),Ur()}let Gr=(0,q.useCallback)(()=>{if(!F)return;let e=F.workspaceRoot?.trim()??``;In(e?`fixed`:`follow`),Rn(e||F.effectiveWorkspaceRoot||``),Pn(!0)},[F]);async function Kr(e={}){if(!F)return;let t=Fn===`fixed`?Ln.trim():``;if(!(Fn===`fixed`&&!t)){On(!0),Z(null),Mn(null);try{Hr(await se(F.id,{workspaceRoot:t,...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}})),Pn(!1),Mn(null)}catch(e){let t=vn(e);t?(Mn(t),Pn(!1)):Z(e instanceof Error?e.message:String(e))}finally{On(!1)}}}async function qr(){if(!(!F||zn)){Bn(`pin`),Z(null);try{Hr(F.pinnedAt?await Ae(F.id):await ve(F.id))}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Bn(null)}}}async function Jr(){if(!(!F||zn)){Bn(`archive`),Z(null);try{Hr(F.status===`archived`?await Qe(F.id):await f(F.id))}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Bn(null)}}}async function Yr(){if(F){Hn(!0),Z(null);try{await v(F.id),An(!1),r(`/projects`)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Hn(!1)}}}async function Xr(){if(!(!F||Et)){Dt(!0),Z(null);try{await Be(F.id)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{Dt(!1)}}}let Zr=(0,q.useCallback)(e=>{jt(e)},[]),Qr=(0,q.useCallback)((e,t)=>{t||jt(e)},[]),$r=(0,q.useCallback)(async(e,t,n)=>{let r=F?.id;if(r)switch(e){case`preview`:t.isDirectory||jt(t.path);break;case`download`:if(t.isDirectory)return;try{let e=Fe(t.path);if(ge(fe(e))!==`text`){let n=await Le(t.path,{projectId:r}),i=Ne(e)??`application/octet-stream`;Ce(e,await n.arrayBuffer(),i)}else{let{content:n}=await Ee(t.path,{projectId:r});Ge(e,n)}}catch(e){it(`warning`,e instanceof Error?e.message:String(e),void 0,{duration:4e3})}break;case`copyPath`:try{await Re(t.absolutePath??t.path)&&it(`success`,s.workspace.pathCopied,void 0,{duration:2500})}catch{it(`warning`,s.clipboard.copyFailed,void 0,{duration:4e3})}break;case`openDefault`:if(!t.absolutePath||!window.electronAPI?.shell?.openPath)return;await window.electronAPI.shell.openPath(t.absolutePath);break;case`openWith`:if(!t.absolutePath||!window.electronAPI?.shell?.chooseAppAndOpenPath)return;await window.electronAPI.shell.chooseAppAndOpenPath(t.absolutePath);break;case`openWithApp`:if(!t.absolutePath||!n||!window.electronAPI?.shell?.openPathWithApp)return;await window.electronAPI.shell.openPathWithApp(t.absolutePath,n);break;case`revealInFolder`:if(!t.absolutePath||!window.electronAPI?.shell?.showItemInFolder)return;await window.electronAPI.shell.showItemInFolder(t.absolutePath);break;default:break}},[s.clipboard.copyFailed,s.workspace.pathCopied,F?.id]),ei=(0,q.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`[data-project-files-grid]`);if(!n)return;t.setPointerCapture(e.pointerId),Ft(!0);let r=e.clientX,i=Mt,a=e.pointerId,o=0,s=i,c=i,l=()=>{o=0,c=s,n.style.setProperty(`--project-files-panel-width`,`${c}px`)},u=e=>{s=tn(i+(e.clientX-r)),o===0&&(o=window.requestAnimationFrame(l))},d=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}Ft(!1),Nt(c),rn(c),window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},[Mt]);if((0,q.useEffect)(()=>{$!==`files`&&jt(null)},[e,$]),_n)return(0,J.jsx)(`main`,{className:`w-full flex-1 px-3 py-3 text-sm text-fg-muted sm:px-5 sm:py-4 xl:px-6`,children:p.loading});if(!F)return(0,J.jsxs)(`main`,{className:`w-full flex-1 px-3 py-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,J.jsxs)(lt,{to:`/projects`,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,J.jsx)(De,{className:`size-4`,"aria-hidden":!0}),p.backToProjects]}),(0,J.jsx)(`p`,{className:`mt-6 rounded-lg bg-surface-panel p-4 shadow-surface text-sm text-fg-muted`,children:sr||p.notFound})]});let ti=B?.recentSessions.length?B.recentSessions:F.recentSessions,ni=B?.attentionItems??[],ri=e=>p.statuses[e]??e,ii=e=>ln(p.common.messages,{count:e}),ai=de.trim().toLowerCase(),oi=ai?oe.filter(e=>{let t=un(e.updatedAt),n=e.routing?.agentId||e.agentId||p.common.agent,r=e.name?.trim()||p.sessions.fallbackTitle,i=ii(e.messageCount??0);return[r,e.key,n,t,i].filter(Boolean).join(` `).toLowerCase().includes(ai)}):oe,si=oe.length>0&&oi.length===0,ci=$t.find(e=>e.id===Q.defaultAgentId)?.name||Q.defaultAgentId||p.settings.globalDefaultAgent,li=$t.find(e=>e.id===Q.defaultAgentId),ui=F.workspaceRoot?.trim()||``,di=F.status===`archived`,fi=!!F.pinnedAt,pi=!ui,mi=ui||li?.workspace||F.effectiveWorkspaceRoot||p.common.defaultWorkspace,hi=Fn===`fixed`?Ln.trim()||p.settings.workspacePlaceholder:li?.workspace||F.effectiveWorkspaceRoot||p.common.defaultWorkspace,gi=(Fn===`fixed`?Ln.trim():``)!==ui&&(Fn===`follow`||!!Ln.trim()),_i=fr.map(e=>{let t=qt.find(t=>t.id===e);return{...t,label:t.id===`work-items`?p.workItems.tab:p.tabs[t.id]}});async function vi(){if(!mi)return;let e=await Re(mi);it(e?`success`:`warning`,e?s.workspace.pathCopied:s.clipboard.copyFailed,void 0,{duration:e?2500:4e3})}function yi(){Mn(null),Pn(!0)}return(0,J.jsxs)(`main`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden px-3 py-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,J.jsx)(vt,{items:_i,activeTab:$,onChange:gr,onReorder:Cr,ariaLabel:p.navAria,tabIdPrefix:`project-tab`,panelIdPrefix:`project-panel`,className:`shrink-0`}),sr?(0,J.jsx)(`p`,{className:`mt-3 shrink-0 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:sr}):null,(0,J.jsxs)(`div`,{className:i(`mt-3 min-h-0 flex-1`,$===`work-items`?`-mx-3 -mb-3 overflow-hidden sm:-mx-5 sm:-mb-4 xl:-mx-6`:$===`overview`?`overflow-y-auto pr-1 [scrollbar-gutter:stable] xl:overflow-hidden xl:pr-0`:`overflow-y-auto pr-1 [scrollbar-gutter:stable]`),children:[$===`overview`?(0,J.jsxs)(`section`,{id:`project-panel-overview`,role:`tabpanel`,"aria-labelledby":`project-tab-overview`,className:`grid min-h-full gap-4 xl:h-full xl:min-h-0 xl:grid-cols-[minmax(0,1fr)_20rem] xl:overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,J.jsx)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.directionTitle}),(0,J.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:B?.digest?.summary||B?.recommendedAction||F.description||F.brief||p.overview.directionFallback}),B?.digest?.nextAction?(0,J.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm font-medium leading-6 text-fg`,children:ln(p.overview.recommendedNext,{action:B.digest.nextAction})}):null]}),(0,J.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:(0,J.jsxs)(G,{type:`button`,variant:`secondary`,onClick:()=>void Xr(),disabled:Et,children:[(0,J.jsx)(_e,{className:`size-4`,"aria-hidden":!0}),Et?p.overview.savingDigest:p.overview.saveDigest]})})]})}),(0,J.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.nextActions}),(0,J.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,onClick:()=>or(!0),children:[(0,J.jsx)(le,{className:`size-4`,"aria-hidden":!0}),p.overview.goal]})]}),(0,J.jsx)(`div`,{className:`divide-y divide-edge`,children:B?.nextActions.length?B.nextActions.map(e=>(0,J.jsxs)(lt,{to:vr(e.goalId),onClick:xr(`goals`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,J.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,dn(e.status)),children:ri(e.status)})]}),(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.nextAction})]},e.goalId)):(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.overview.noNextActions})})]})]}),(0,J.jsxs)(`aside`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.attention}),ni.length?(0,J.jsx)(`div`,{className:`mt-3 grid gap-3`,children:ni.map(e=>{let t=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(E,{className:`size-4 text-amber-600 dark:text-amber-300`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title})]}),(0,J.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:[p.overview.attentionKinds[e.kind]??e.kind,e.detail?` · ${e.detail}`:e.status?` · ${ri(e.status)}`:``]})]});return e.href?(0,J.jsx)(lt,{to:e.href,onClick:xr(Sr(e.href)),className:`min-w-0 rounded-md bg-surface-base p-3 hover:bg-surface-hover`,children:t},e.id):(0,J.jsx)(`div`,{className:`min-w-0 rounded-md bg-surface-base p-3`,children:t},e.id)})}):(0,J.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:p.overview.noBlockedGoals}),(0,J.jsxs)(`form`,{onSubmit:Ir,className:`mt-4 flex gap-2 border-t border-edge pt-4`,children:[(0,J.jsx)(`input`,{className:`min-h-9 min-w-0 flex-1 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:ur.title,onChange:e=>dr(t=>({...t,title:e.target.value})),placeholder:p.overview.blockerTitlePlaceholder}),(0,J.jsx)(G,{type:`submit`,variant:`secondary`,className:`shrink-0 rounded-lg px-3`,disabled:rr||!ur.title.trim(),"aria-label":rr?p.overview.addingBlocker:p.overview.addBlocker,title:rr?p.overview.addingBlocker:p.overview.addBlocker,children:(0,J.jsx)(le,{className:`size-4`,"aria-hidden":!0})})]})]}),(0,J.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(pt,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:p.overview.recentSessions})]}),(0,J.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>gr(`sessions`),children:p.common.viewAll})]}),(0,J.jsx)(`div`,{className:`divide-y divide-edge`,children:ti.length?ti.map(e=>(0,J.jsxs)(lt,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:xr(`sessions`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.name||e.key}),(0,J.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:un(e.updatedAt)})]}),(0,J.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.agentId||p.common.agent})]},e.key)):(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.overview.noSessions})})]})]})]}):null,$===`work-items`?(0,J.jsx)(Kt,{projectId:F.id,createRequestKey:Gn}):null,$===`workflows`?(0,J.jsxs)(`section`,{id:`project-panel-workflows`,role:`tabpanel`,"aria-labelledby":`project-tab-workflows`,className:`grid h-full min-h-[28rem] gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,J.jsx)(`div`,{className:`min-h-0`,children:(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.workflows.runsTitle}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p.workflows.runsHint})]}),(0,J.jsxs)(G,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>void wr(),disabled:qn,children:[(0,J.jsx)(W,{className:`size-4`,"aria-hidden":!0}),p.common.refresh]})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 divide-y divide-edge overflow-y-auto`,children:qn&&je.length===0?(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.workflows.loadingRuns}):je.length?je.map(e=>{let t=e.status===`queued`||e.status===`running`,n=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,J.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`button`,{type:`button`,className:`min-w-0 truncate text-left text-sm font-medium text-fg hover:text-accent-fg`,onClick:()=>br(`workflows`,S(e.id,{ownerAgentId:X||e.metadata?.agentId||F.defaultAgentId})),children:e.title||e.definitionId}),(0,J.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,fn(e.status)),children:ri(e.status)})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:ln(p.workflows.runMeta,{definitionId:e.definitionId,done:e.metrics.doneAgentCount,total:e.metrics.agentCount,time:un(e.createdAtMs)})}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,onClick:()=>br(`workflows`,S(e.id,{ownerAgentId:X||e.metadata?.agentId||F.defaultAgentId})),children:p.common.open}),n?(0,J.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:Zn===`retry:${e.id}`,onClick:()=>void Rr(e),children:[(0,J.jsx)(W,{className:`size-3.5`,"aria-hidden":!0}),p.common.retry]}):null,t?(0,J.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:Zn===`cancel:${e.id}`,onClick:()=>void zr(e),children:[(0,J.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0}),p.common.cancel]}):null]})]})]},e.id)}):(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.workflows.emptyRuns})})]})}),(0,J.jsx)(`aside`,{className:`min-h-0`,children:(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-4 py-3`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.workflows.startTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:p.workflows.startHint})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:(0,J.jsx)(`div`,{className:`grid gap-2`,children:xe.length?xe.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`grid gap-1 rounded-md bg-surface-base p-3 text-left hover:bg-surface-hover focus:outline-none focus:ring-2 focus:ring-accent/30`,onClick:()=>er(e),children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,J.jsx)(A,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}),(0,J.jsx)(`span`,{className:`line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description||e.metadata.whenToUse||e.name})]},e.id)):(0,J.jsx)(`div`,{className:`px-1 py-3 text-sm text-fg-muted`,children:p.workflows.emptyDefinitions})})})]})})]}):null,$===`automations`?(0,J.jsxs)(`section`,{id:`project-panel-automations`,role:`tabpanel`,"aria-labelledby":`project-tab-automations`,className:`grid h-full min-h-[28rem] overflow-hidden gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.automations.title}),(0,J.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p.automations.hint})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(G,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>void Tr(),disabled:He,children:[(0,J.jsx)(W,{className:`size-4`,"aria-hidden":!0}),p.common.refresh]}),(0,J.jsxs)(G,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>br(`automations`,`/automations?projectId=${encodeURIComponent(F.id)}&action=create`),children:[(0,J.jsx)(le,{className:`size-4`,"aria-hidden":!0}),p.common.new]})]})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 divide-y divide-edge overflow-y-auto`,children:He&&U.length===0?(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.automations.loading}):U.length?U.map(e=>{let t=Ie.find(t=>t.automationId===e.id),n=e.state.runningRunId?Ie.find(t=>t.id===e.state.runningRunId):null;return(0,J.jsxs)(`div`,{className:`grid gap-2 px-4 py-3 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`button`,{type:`button`,className:`min-w-0 truncate text-left text-sm font-medium text-fg hover:text-accent-fg`,onClick:()=>br(`automations`,`/automations?automation=${encodeURIComponent(e.id)}`),children:e.name}),(0,J.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,e.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:e.enabled?p.automations.enabled:p.automations.paused})]}),(0,J.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.description||e.action.kind}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:ln(p.common.lastRun,{trigger:e.trigger.kind,action:e.action.kind,time:t?un(t.createdAtMs):p.common.never})}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:We===`run:${e.id}`||!!n,onClick:()=>void Dr(e),children:[(0,J.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),p.automations.run]}),(0,J.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2 py-1 text-xs`,disabled:We===`toggle:${e.id}`,onClick:()=>void Or(e),children:[e.enabled?(0,J.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}):(0,J.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),e.enabled?p.automations.pause:p.automations.resume]})]})]})]},e.id)}):(0,J.jsxs)(`div`,{className:`grid gap-3 px-4 py-6 text-sm text-fg-muted`,children:[(0,J.jsx)(`p`,{children:p.automations.empty}),(0,J.jsx)(`div`,{children:(0,J.jsxs)(G,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>br(`automations`,`/automations?projectId=${encodeURIComponent(F.id)}&action=create`),children:[(0,J.jsx)(g,{className:`size-4`,"aria-hidden":!0}),p.automations.create]})})]})})]}),(0,J.jsxs)(`aside`,{className:`grid min-h-0 min-w-0 content-start gap-4 overflow-y-auto pr-1 [scrollbar-gutter:stable]`,children:[(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-panel shadow-surface`,children:[(0,J.jsx)(`div`,{className:`border-b border-edge px-4 py-3`,children:(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.automations.recentRuns})}),(0,J.jsx)(`div`,{className:`divide-y divide-edge`,children:Ie.length?Ie.slice(0,8).map(e=>(0,J.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.automationName}),(0,J.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,fn(e.status)),children:ri(e.status)})]}),(0,J.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:un(e.createdAtMs)})]},e.id)):(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.automations.emptyRuns})})]}),(0,J.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.automations.contextTitle}),(0,J.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:p.automations.contextHint}),(0,J.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:F.workspaceRoot||F.effectiveWorkspaceRoot||p.common.defaultWorkspace})]})]})]}):null,$===`notes`?(0,J.jsx)(`section`,{id:`project-panel-notes`,role:`tabpanel`,"aria-labelledby":`project-tab-notes`,className:`flex h-full min-h-[28rem] overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,J.jsx)(_t,{selectedNoteId:n,basePath:`/projects/${encodeURIComponent(F.id)}/notes`,showLibrary:!1,allowMediaCapture:!1,listTag:`project:${F.id}`,captureTags:[`project:${F.id}`,F.slug],listTitle:p.notes.title,listDescription:p.notes.hint,emptyText:p.notes.emptyTitle,emptyDescription:p.notes.emptyDescription,listWidthStorageKey:`xopc.projectNotes.listWidth.${F.id}`})}):null,$===`files`?(0,J.jsx)(`section`,{id:`project-panel-files`,role:`tabpanel`,"aria-labelledby":`project-tab-files`,className:`h-full min-h-[28rem]`,children:(0,J.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:F.effectiveWorkspaceRoot?(0,J.jsxs)(`div`,{"data-project-files-grid":!0,className:i(`grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[var(--project-files-panel-width)_6px_minmax(0,1fr)]`,Pt&&`cursor-col-resize select-none`),style:{"--project-files-panel-width":`${Mt}px`},children:[(0,J.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-b border-edge lg:border-b-0 lg:border-r`,children:[(0,J.jsxs)(`div`,{className:`flex h-11 items-center gap-1 border-b border-edge bg-surface-muted/50 px-3 text-sm`,children:[(0,J.jsx)(ht,{workspacePath:mi}),(0,J.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,J.jsx)(`button`,{type:`button`,className:i(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,It&&`bg-surface-hover text-fg`),onClick:()=>Lt(!0),"aria-label":p.files.search,title:p.files.search,"aria-pressed":It,children:(0,J.jsx)(me,{className:`size-3.5`,"aria-hidden":!0})}),(0,J.jsx)(re,{className:`size-7 shrink-0 rounded-md p-0`,loading:Yt,label:s.cron.refresh,onClick:()=>void kr()})]})]}),It?(0,J.jsx)(`div`,{className:`shrink-0 border-b border-edge bg-surface-muted/40 px-3 py-2`,children:(0,J.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/20`,children:[(0,J.jsx)(me,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`text`,role:`searchbox`,value:Rt,onChange:e=>zt(e.target.value),placeholder:p.files.searchPlaceholder,"aria-label":p.files.searchPlaceholder,autoFocus:!0,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none placeholder:text-fg-subtle`}),(0,J.jsx)(`button`,{type:`button`,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":p.files.clearSearch,title:p.files.clearSearch,onClick:()=>{zt(``),Lt(!1)},children:(0,J.jsx)(h,{className:`size-3.5`,"aria-hidden":!0})})]})}):null,Zt?(0,J.jsx)(`div`,{className:`border-b border-edge bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:Zt}):null,jr?(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:Ht?(0,J.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,J.jsx)(Te,{className:`h-11 w-full`}),(0,J.jsx)(Te,{className:`h-11 w-full`}),(0,J.jsx)(Te,{className:`h-11 w-full`})]}):Wt?(0,J.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[s.workspace.loadError,`: `,Wt]}):Bt.length===0?(0,J.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:p.files.noSearchResults}):Bt.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:i(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-surface-hover`,At===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>jt(e.path),title:e.path,children:[(0,J.jsx)(k,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,J.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):Yt&&Ot.length===0?(0,J.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.files.loading}):(0,J.jsx)(we,{tree:Ot,selectedPath:At,onSelectFile:Zr,onSelectEntry:Qr,onExpandDir:e=>void Ar(e),onAction:$r,actionLabels:{preview:s.workspace.preview,download:s.workspace.download,copyPath:s.workspace.copyPath,openDefault:s.workspace.openSystemApp,openWith:s.workspace.openWith,revealInFolder:s.workspace.revealInFolder,recommendedApps:s.workspace.recommendedApps},emptyHint:p.files.emptyDirectory})]}),(0,J.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":p.files.resizeHandle,className:i(`hidden cursor-col-resize touch-none items-stretch justify-center bg-surface-panel transition-colors hover:bg-surface-hover lg:flex`,Pt&&`bg-surface-hover`),onPointerDown:ei,children:(0,J.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70`})}),(0,J.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden bg-surface-base`,children:At?(0,J.jsx)(ot,{filePath:At,projectId:F.id,onClose:()=>jt(null)}):(0,J.jsx)(`div`,{className:`flex h-full min-h-[18rem] items-center justify-center px-6 text-center`,children:(0,J.jsxs)(`div`,{className:`max-w-sm`,children:[(0,J.jsx)(rt,{className:`mx-auto size-8 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:p.files.previewEmptyTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.files.previewEmptyDescription})]})})})]}):(0,J.jsxs)(`div`,{className:`grid gap-3 px-4 py-8 text-sm text-fg-muted`,children:[(0,J.jsx)(`p`,{children:p.files.needWorkspace}),(0,J.jsx)(`div`,{children:(0,J.jsx)(G,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>gr(`settings`),children:p.files.openSettings})})]})})}):null,$===`sessions`?(0,J.jsxs)(`section`,{id:`project-panel-sessions`,role:`tabpanel`,"aria-labelledby":`project-tab-sessions`,className:`grid min-h-full content-start gap-3`,children:[oe.length?(0,J.jsxs)(`label`,{className:`relative flex min-h-9 w-full max-w-lg cursor-text items-center rounded-lg bg-surface-panel py-1.5 pl-9 pr-9 shadow-surface`,children:[(0,J.jsx)(me,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:de,onChange:e=>pe(e.currentTarget.value),placeholder:p.sessions.searchPlaceholder,"aria-label":p.sessions.searchPlaceholder,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),de?(0,J.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":p.sessions.clearSearch,onClick:()=>pe(``),children:(0,J.jsx)(h,{className:`size-3.5`,"aria-hidden":!0})}):null]}):null,oi.length?(0,J.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:oi.map(e=>{let t=un(e.updatedAt),n=e.routing?.agentId||e.agentId||p.common.agent,r=e.name?.trim()||p.sessions.fallbackTitle,i=ii(e.messageCount??0);return(0,J.jsxs)(lt,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:xr(`sessions`),className:`group flex min-h-[11rem] min-w-0 flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,J.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-base text-fg-muted`,children:(0,J.jsx)(gt,{className:`size-4`,"aria-hidden":!0})}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:r}),(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-muted`,title:e.key,children:e.key})]})]}),(0,J.jsxs)(`div`,{className:`mt-auto grid gap-2 pt-4 text-xs text-fg-muted`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[p.sessions.agent,`: `,n]}),(0,J.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:i})]}),t?(0,J.jsxs)(`span`,{className:`truncate rounded-md bg-surface-base px-2 py-1`,children:[p.sessions.updated,`: `,t]}):null]})]},e.key)})}):si?(0,J.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:p.sessions.noMatches})}):(0,J.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:p.sessions.emptyTitle}),(0,J.jsx)(`p`,{className:`mx-auto mt-1 max-w-md text-sm leading-6 text-fg-muted`,children:p.sessions.emptyDescription})]})})]}):null,$===`goals`?(0,J.jsxs)(`section`,{id:`project-panel-goals`,role:`tabpanel`,"aria-labelledby":`project-tab-goals`,className:`grid min-h-full content-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.goals.title})}),(0,J.jsxs)(G,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3`,disabled:tr,onClick:()=>or(!0),children:[(0,J.jsx)(le,{className:`size-4`,"aria-hidden":!0}),p.goals.new]})]}),(0,J.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:he.length?he.map(e=>(0,J.jsxs)(lt,{to:vr(e.id),onClick:xr(`goals`),className:`grid gap-1 border-b border-edge px-4 py-3 last:border-b-0 hover:bg-surface-hover`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,J.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,dn(e.status)),children:ri(e.status)})]}),(0,J.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:e.nextAction||e.description||p.goals.noNextAction})]},e.id)):(0,J.jsx)(`p`,{className:`p-4 text-sm text-fg-muted`,children:p.goals.empty})})]}):null,$===`activity`?(0,J.jsxs)(`section`,{id:`project-panel-activity`,role:`tabpanel`,"aria-labelledby":`project-tab-activity`,className:`grid min-h-full content-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.activity.title}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ln(p.activity.count,{count:$e})})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`label`,{className:`inline-flex min-h-9 items-center gap-2 rounded-lg bg-surface-panel px-3 text-sm text-fg-muted shadow-surface`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:wt,onChange:e=>Tt(e.currentTarget.checked),className:`size-4 rounded border-edge text-accent focus:ring-accent/30`}),p.activity.includeRelated]}),(0,J.jsxs)(G,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3`,onClick:()=>void Er(),disabled:nt,children:[(0,J.jsx)(W,{className:i(`size-4`,nt&&`animate-spin`),"aria-hidden":!0}),p.common.refresh]})]})]}),(0,J.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:nt&&Ye.length===0?(0,J.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:p.activity.loading}):Ye.length?(0,J.jsx)(`div`,{className:`divide-y divide-edge`,children:Ye.map(e=>{let t=p.activity.types[e.type]??e.type,n=p.activity.objectKinds[e.primaryObject.kind]??e.primaryObject.kind,r=Sn(e),i=e.relatedProjects.length>0&&!e.scopes.some(e=>e.scopeKind===`project`&&e.scopeId===F.id);return(0,J.jsxs)(`article`,{className:`grid gap-2 px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),i?(0,J.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:p.activity.related}):null]}),(0,J.jsxs)(`p`,{className:`mt-1 min-w-0 truncate text-sm text-fg-muted`,children:[n,`: `,bn(e)]})]}),(0,J.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,dateTime:new Date(e.createdAt).toISOString(),children:un(e.createdAt)})]}),r?(0,J.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:r}):null,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,J.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[p.activity.actor,`: `,yn(e)]}),(0,J.jsxs)(`span`,{className:`max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[p.activity.source,`: `,xn(e)]})]})]},e.id)})}):(0,J.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:p.activity.empty})})]}):null,$===`settings`?(0,J.jsxs)(`form`,{id:`project-panel-settings`,role:`tabpanel`,"aria-labelledby":`project-tab-settings`,onSubmit:Wr,className:`grid min-h-full content-start gap-4`,children:[(0,J.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.contextTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.settings.contextHint})]}),(0,J.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,dn(Q.status)),children:p.settings.statuses[Q.status]})]}),(0,J.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-5`,children:[(0,J.jsx)(hn,{label:p.settings.workspaceRoot,value:mi,mono:!0}),(0,J.jsx)(hn,{label:p.settings.defaultAgent,value:ci}),(0,J.jsx)(hn,{label:p.settings.pinState,value:fi?p.settings.pinned:p.settings.notPinned}),(0,J.jsx)(hn,{label:p.settings.createdAt,value:un(F.createdAt)||p.common.never}),(0,J.jsx)(hn,{label:p.settings.updatedAt,value:un(F.updatedAt)||p.common.never})]})]}),(0,J.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.detailsTitle})}),(0,J.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,J.jsx)(pn,{label:p.settings.name,children:(0,J.jsx)(`input`,{className:mn(),value:Q.name,onChange:e=>mr(t=>({...t,name:e.target.value}))})}),(0,J.jsx)(pn,{label:p.settings.defaultAgent,children:(0,J.jsxs)(l,{className:mn(),value:Q.defaultAgentId,onChange:e=>mr(t=>({...t,defaultAgentId:e.target.value})),children:[(0,J.jsx)(et,{value:``,children:p.settings.globalDefaultAgent}),$t.map(e=>(0,J.jsx)(et,{value:e.id,children:e.name||e.id},e.id))]})}),(0,J.jsx)(pn,{label:p.settings.status,children:di?(0,J.jsx)(`div`,{className:`grid min-h-10 content-center rounded-md border border-edge bg-surface-muted px-3 text-sm text-fg-muted`,children:p.settings.statuses.archived}):(0,J.jsxs)(l,{className:mn(),value:Q.status===`archived`?`active`:Q.status,onChange:e=>mr(t=>({...t,status:e.target.value})),children:[(0,J.jsx)(et,{value:`active`,children:p.settings.statuses.active}),(0,J.jsx)(et,{value:`paused`,children:p.settings.statuses.paused})]})}),(0,J.jsx)(pn,{label:p.settings.description,hint:p.settings.descriptionHint,children:(0,J.jsx)(`textarea`,{className:mn(!0),value:Q.description,onChange:e=>mr(t=>({...t,description:e.target.value}))})})]})]}),(0,J.jsx)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,J.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:p.settings.workspaceRoot}),(0,J.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base px-3 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,J.jsx)(`span`,{className:`rounded-md bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:pi?p.settings.workspaceModeFollow:p.settings.workspaceModeFixed})}),(0,J.jsx)(`div`,{className:`mt-2 break-all font-mono text-xs leading-5 text-fg`,title:mi,children:mi})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,J.jsxs)(G,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:()=>void vi(),children:[(0,J.jsx)(C,{className:`size-4`,"aria-hidden":!0}),p.settings.copyWorkspacePath]}),(0,J.jsx)(ht,{workspacePath:mi}),(0,J.jsxs)(G,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:Gr,children:[(0,J.jsx)(dt,{className:`size-4`,"aria-hidden":!0}),p.settings.migrateWorkspace]})]})]}),(0,J.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:p.settings.workspaceMigrationHint})]})]})}),(0,J.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.agentContextTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.settings.agentContextHint})]}),(0,J.jsx)(pn,{label:p.settings.brief,hint:p.settings.briefHint,children:(0,J.jsx)(`textarea`,{className:mn(!0),value:Q.brief,onChange:e=>mr(t=>({...t,brief:e.target.value}))})}),(0,J.jsx)(pn,{label:p.settings.instructions,hint:p.settings.instructionsHint,children:(0,J.jsx)(`textarea`,{className:mn(!0),value:Q.instructions,onChange:e=>mr(t=>({...t,instructions:e.target.value}))})})]}),(0,J.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.managementTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.settings.managementHint})]}),(0,J.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,J.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base px-3 py-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:fi?p.settings.pinnedTitle:p.settings.pinTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:p.settings.pinHint})]}),(0,J.jsxs)(G,{type:`button`,variant:`ghost`,className:`w-fit rounded-lg`,disabled:zn===`pin`,onClick:()=>void qr(),children:[fi?(0,J.jsx)(ct,{className:`size-4`,"aria-hidden":!0}):(0,J.jsx)(M,{className:`size-4`,"aria-hidden":!0}),fi?p.settings.unpinProject:p.settings.pinProject]})]}),(0,J.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base px-3 py-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:di?p.settings.restoreTitle:p.settings.archiveTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:di?p.settings.restoreHint:p.settings.archiveHint})]}),(0,J.jsxs)(G,{type:`button`,variant:di?`primary`:`ghost`,className:`w-fit rounded-lg`,disabled:zn===`archive`,onClick:()=>void Jr(),children:[di?(0,J.jsx)(W,{className:`size-4`,"aria-hidden":!0}):(0,J.jsx)(at,{className:`size-4`,"aria-hidden":!0}),di?p.settings.restoreProject:p.settings.archiveProject]})]})]})]}),(0,J.jsxs)(`section`,{className:`grid gap-3 rounded-lg border border-red-500/20 bg-red-500/5 p-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-red-700 dark:text-red-300`,children:p.settings.dangerTitle}),(0,J.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-red-700/80 dark:text-red-200/80`,children:p.settings.dangerHint})]}),(0,J.jsxs)(G,{type:`button`,variant:`ghost`,className:`w-fit text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>An(!0),children:[(0,J.jsx)(mt,{className:`size-4`,"aria-hidden":!0}),p.settings.deleteConfirmAction]})]}),(0,J.jsx)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-edge pt-4`,children:(0,J.jsxs)(G,{type:`submit`,variant:`primary`,disabled:Dn||!Q.name.trim(),children:[(0,J.jsx)(_e,{className:`size-4`,"aria-hidden":!0}),p.common.save]})})]}):null]}),(0,J.jsx)(N,{open:kn,onOpenChange:e=>{Vn||An(e)},children:(0,J.jsxs)(y,{children:[(0,J.jsx)(I,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(ft,{className:`fixed left-1/2 top-1/2 z-[90] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-5 shadow-float focus:outline-none`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-red-500/10 text-red-600 dark:text-red-400`,children:(0,J.jsx)(E,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(R,{className:`text-base font-semibold text-fg`,children:p.settings.deleteConfirmTitle}),(0,J.jsx)(d,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:F?ln(p.settings.deleteConfirm,{name:F.name}):p.settings.deleteConfirmFallback})]})]}),(0,J.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,J.jsx)(O,{asChild:!0,children:(0,J.jsx)(G,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:Vn,children:p.common.cancel})}),(0,J.jsxs)(G,{type:`button`,variant:`ghost`,className:`rounded-lg text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,disabled:Vn||!F,onClick:()=>void Yr(),children:[(0,J.jsx)(mt,{className:`size-4`,"aria-hidden":!0}),p.settings.deleteConfirmAction]})]})]})]})}),(0,J.jsx)(N,{open:Nn,onOpenChange:e=>{Dn||Pn(e)},children:(0,J.jsxs)(y,{children:[(0,J.jsx)(I,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(ft,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))] -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,J.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,J.jsx)(R,{className:`text-base font-semibold text-fg`,children:p.settings.workspaceMigrationTitle}),(0,J.jsx)(d,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.settings.workspaceMigrationDescription})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,J.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-fg-muted`,children:p.settings.workspaceMode}),(0,J.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,J.jsxs)(`label`,{className:i(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,Fn===`fixed`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,J.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:Fn===`fixed`,onChange:()=>In(`fixed`),disabled:Dn}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block font-medium`,children:p.settings.workspaceModeFixed}),(0,J.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:p.settings.workspaceMigrationFixedHint})]})]}),(0,J.jsxs)(`label`,{className:i(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,Fn===`follow`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,J.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:Fn===`follow`,onChange:()=>In(`follow`),disabled:Dn}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block font-medium`,children:p.settings.workspaceModeFollow}),(0,J.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:p.settings.workspaceHint})]})]})]})]}),Fn===`fixed`?(0,J.jsx)(yt,{value:Ln,onChange:Rn,disabled:Dn,wd:u,placeholder:p.settings.workspacePlaceholder,inputClassName:mn(),autoFocus:!0}):null,(0,J.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm leading-6 text-amber-800 dark:text-amber-200`,children:p.settings.workspaceMigrationImpact}),(0,J.jsx)(`div`,{className:`rounded-lg bg-surface-muted px-3 py-2 text-xs leading-5 text-fg-subtle`,children:ln(p.settings.workspaceCurrent,{workspace:hi})})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(O,{asChild:!0,children:(0,J.jsx)(G,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:Dn,children:p.common.cancel})}),(0,J.jsxs)(G,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:Dn||!gi,onClick:()=>void Kr(),children:[(0,J.jsx)(dt,{className:`size-4`,"aria-hidden":!0}),p.settings.workspaceMigrationConfirm]})]})]})]})}),(0,J.jsx)(N,{open:!!jn,onOpenChange:e=>{e||Mn(null)},children:(0,J.jsxs)(y,{children:[(0,J.jsx)(I,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,J.jsxs)(ft,{className:`fixed left-1/2 top-1/2 z-[90] flex w-[min(30rem,calc(100vw-2rem))] -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,J.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,J.jsx)(R,{className:`text-base font-semibold text-fg`,children:p.settings.workspaceMissingTitle}),(0,J.jsx)(d,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:jn?ln(p.settings.workspaceMissingDescription,{workspace:jn}):null})]}),jn?(0,J.jsx)(`div`,{className:`px-5 py-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,J.jsx)(rt,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:jn})]})}):null,(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,J.jsx)(G,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:yi,disabled:Dn,children:p.settings.workspaceMissingBack}),(0,J.jsxs)(G,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:()=>void Kr({createWorkspaceRoot:!0}),disabled:Dn,children:[(0,J.jsx)(dt,{className:`size-4`,"aria-hidden":!0}),p.settings.workspaceMissingCreate]})]})]})]})}),(0,J.jsx)(St,{open:ar,t:s.goalsPage,chat:s.chat,busy:tr,options:cr,onClose:()=>!tr&&or(!1),onCreate:Fr}),(0,J.jsx)(Ct,{open:!!$n,definition:$n,language:o,starting:Yn,onClose:()=>!Yn&&er(null),onStart:e=>void Lr(e)})]})}export{En as ProjectDetailPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-Bq4REfIj.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{$a as s,$i as c,Ba as l,Ga as u,Ha as d,Qi as f,Ra as p,Ua as m,Va as h,Vi as g,Wa as _,bs as v,cs as y,er as b,ml as x,to as S,wl as ee,wo as C,xc as te,xl as w,yc as ne,za as T}from"./index-DOetFpTt.js";import{t as re}from"./directory-picker-path-field-BEhDuShd.js";var ie=n(),E=e(t(),1),D=r(),ae=[`all`,`active`,`paused`,`archived`],O=`__auto__`,k=`__global__`;function A(e){return e===`active`?`bg-accent-soft text-accent-fg`:e===`paused`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-muted text-fg-subtle`}function j(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function oe(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function se(e){let t=e?.body;return t?.code===`workspace_already_bound`&&t.project?t.project:null}function ce(e){let t=e?.body;return t?.code===`workspace_root_missing`&&t.workspaceRoot?t.workspaceRoot:null}function M(e,t){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?e:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(n)}function le(e){let t=(0,ie.c)(37),{project:n,t:r}=e,a=r.statuses[n.status],o=`/projects/${encodeURIComponent(n.id)}`,s;t[0]===n.name?s=t[1]:(s=(0,D.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.name}),t[0]=n.name,t[1]=s);let c;t[2]===n.slug?c=t[3]:(c=(0,D.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.slug}),t[2]=n.slug,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,D.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===n.status?u=t[8]:(u=i(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,A(n.status)),t[7]=n.status,t[8]=u);let d;t[9]!==a||t[10]!==u?(d=(0,D.jsx)(`span`,{className:u,children:a}),t[9]=a,t[10]=u,t[11]=d):d=t[11];let f;t[12]!==l||t[13]!==d?(f=(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[l,d]}),t[12]=l,t[13]=d,t[14]=f):f=t[14];let p=n.description||n.brief||r.noDescription,m;t[15]===p?m=t[16]:(m=(0,D.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-10 text-sm leading-5 text-fg-muted`,children:p}),t[15]=p,t[16]=m);let h=n.workspaceRoot||n.effectiveWorkspaceRoot||r.agentDefault,g;t[17]!==r.workspaceLabel||t[18]!==h?(g=j(r.workspaceLabel,{workspace:h}),t[17]=r.workspaceLabel,t[18]=h,t[19]=g):g=t[19];let _;t[20]===g?_=t[21]:(_=(0,D.jsx)(`div`,{className:`truncate`,children:g}),t[20]=g,t[21]=_);let v;t[22]!==n.lastActiveAt||t[23]!==n.updatedAt||t[24]!==r.lastActive||t[25]!==r.never?(v=j(r.lastActive,{time:M(n.lastActiveAt??n.updatedAt,r.never)}),t[22]=n.lastActiveAt,t[23]=n.updatedAt,t[24]=r.lastActive,t[25]=r.never,t[26]=v):v=t[26];let y;t[27]===v?y=t[28]:(y=(0,D.jsx)(`div`,{children:v}),t[27]=v,t[28]=y);let b;t[29]!==_||t[30]!==y?(b=(0,D.jsxs)(`div`,{className:`mt-auto grid gap-1 pt-4 text-xs text-fg-subtle`,children:[_,y]}),t[29]=_,t[30]=y,t[31]=b):b=t[31];let x;return t[32]!==o||t[33]!==b||t[34]!==f||t[35]!==m?(x=(0,D.jsxs)(w,{to:o,className:`group flex min-h-36 flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[f,m,b]}),t[32]=o,t[33]=b,t[34]=f,t[35]=m,t[36]=x):x=t[36],x}function N(){let e=ee(),t=a(o(e=>e.language)),n=t.chat.workingDirectory,r=t.projectsPage,w=u(e=>e.setPageHeader),ie=u(e=>e.clearPageHeader),[A,M]=(0,E.useState)([]),[N,ue]=(0,E.useState)(`all`),[P,de]=(0,E.useState)(``),[fe,pe]=(0,E.useState)(!0),[me,F]=(0,E.useState)(null),[I,L]=(0,E.useState)(``),[he,ge]=(0,E.useState)(!1),[R,_e]=(0,E.useState)(``),[z,B]=(0,E.useState)(`fixed`),[V,ve]=(0,E.useState)(`auto`),[H,ye]=(0,E.useState)(O),[U,be]=(0,E.useState)([]),[xe,Se]=(0,E.useState)(),[W,Ce]=(0,E.useState)(),[we,Te]=(0,E.useState)(`unknown`),[G,K]=(0,E.useState)(!1),[q,Ee]=(0,E.useState)(!1),[J,Y]=(0,E.useState)(null),[X,Z]=(0,E.useState)(null),De=(0,E.useCallback)(e=>{L(e),ge(!!e.trim())},[]),Oe=(0,E.useCallback)(e=>{_e(e),he||L(oe(e))},[he]);(0,E.useEffect)(()=>{let e=!1;return pe(!0),F(null),f({...N===`all`?{}:{status:N},...P.trim()?{search:P}:{},limit:100}).then(t=>{e||M(t.items)}).catch(t=>{e||F(t instanceof Error?t.message:String(t))}).finally(()=>{e||pe(!1)}),()=>{e=!0}},[P,N]),(0,E.useEffect)(()=>{if(!G)return;let e=!1;return b().then(t=>{e||(be(t.agents),Se(t.defaultId))}).catch(()=>{e||(be([]),Se(void 0))}),()=>{e=!0}},[G]),(0,E.useEffect)(()=>{if(!G)return;let e=!1,t=window.setTimeout(()=>{c({...I.trim()?{name:I.trim()}:{},...z===`fixed`&&R.trim()?{workspaceRoot:R.trim()}:{},projectKind:V}).then(t=>{e||(Ce(t.defaultAgentId),Te(t.inference.kind))}).catch(()=>{e||(Ce(void 0),Te(`unknown`))})},250);return()=>{e=!0,window.clearTimeout(t)}},[G,I,V,z,R]);let Q=(0,E.useMemo)(()=>({active:A.filter(e=>e.status===`active`),paused:A.filter(e=>e.status===`paused`),archived:A.filter(e=>e.status===`archived`)}),[A]),$=(0,E.useCallback)(async(e={})=>{let t=I.trim(),n=z===`fixed`?R.trim():``;if(!(!t&&!n)){Ee(!0),F(null),Z(null);try{let r=await g({...t?{name:t}:{},...n?{workspaceRoot:n}:{},projectKind:V,...H===O?{}:{defaultAgentId:H===k?``:H},...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});M(e=>[r,...e]),L(``),ge(!1),_e(``),B(`fixed`),ve(`auto`),ye(O),K(!1)}catch(e){let t=se(e);if(t)M(e=>[t,...e.filter(e=>e.id!==t.id)]),Y(t),K(!1);else{let t=ce(e);t?(Z(t),K(!1)):F(e instanceof Error?e.message:String(e))}}finally{Ee(!1)}}},[H,I,V,z,R]),ke=(0,E.useCallback)(e=>{e.preventDefault(),$()},[$]),Ae=(0,E.useCallback)(()=>{if(!J)return;let t=J.id;Y(null),e(`/projects/${encodeURIComponent(t)}`)},[e,J]),je=(0,E.useCallback)(()=>{Y(null),K(!0)},[]),Me=(0,E.useCallback)(()=>{$({createWorkspaceRoot:!0})},[$]),Ne=(0,E.useCallback)(()=>{Z(null),K(!0)},[]),Pe=(0,E.useMemo)(()=>U.find(e=>e.id===W)?.name||W||``,[U,W]),Fe=(0,E.useMemo)(()=>H===k?xe:H===O?W||xe:H,[H,xe,W]),Ie=(0,E.useMemo)(()=>U.find(e=>e.id===Fe),[U,Fe]),Le=z===`fixed`?R.trim()||r.workspacePlaceholder:Ie?.workspace||r.workspacePlaceholder,Re=(0,E.useMemo)(()=>{if(H===k)return r.agentHintGlobal;if(H!==O){let e=U.find(e=>e.id===H);return j(r.agentHintSelected,{agent:e?.name||H})}return W?j(r.agentHintCoding,{agent:Pe}):we===`coding`?r.agentHintCoderUnavailable:V===`general`||we===`general`?r.agentHintGeneral:r.agentHintAuto},[H,U,Pe,W,we,V,r]),ze=(0,E.useMemo)(()=>(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`label`,{className:`relative block min-w-0`,children:[(0,D.jsx)(y,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,D.jsx)(`input`,{className:`h-9 w-40 rounded-lg border border-edge bg-surface-muted pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent sm:w-56 lg:w-72`,value:P,onChange:e=>de(e.target.value),placeholder:r.searchPlaceholder,"aria-label":r.searchPlaceholder})]}),(0,D.jsxs)(C,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>K(e=>!e),children:[(0,D.jsx)(v,{className:`size-4`,"aria-hidden":!0}),r.create]})]}),[P,r.create,r.searchPlaceholder]);(0,E.useLayoutEffect)(()=>(w({startExtra:null,main:(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r.title}),(0,D.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:j(r.summary,{count:A.length})})]}),end:ze}),()=>ie()),[ie,ze,A.length,w,r.summary,r.title]);let Be=N===`all`?[[r.statuses.active,Q.active],[r.statuses.paused,Q.paused],[r.statuses.archived,Q.archived]]:[[r.statuses[N],A]];return(0,D.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,D.jsx)(m,{open:G,onOpenChange:K,children:(0,D.jsxs)(d,{children:[(0,D.jsx)(h,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,D.jsxs)(T,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(32rem,calc(100vh-2rem))] w-[min(40rem,calc(100vw-2rem))] -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,D.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,D.jsx)(_,{className:`text-base font-semibold text-fg`,children:r.createTitle}),(0,D.jsx)(l,{className:`mt-1 text-sm text-fg-muted`,children:r.createDescription})]}),(0,D.jsxs)(`form`,{onSubmit:ke,className:`flex min-h-0 flex-1 flex-col`,children:[(0,D.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,D.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,D.jsx)(`span`,{className:`font-medium text-fg-muted`,children:r.workspaceRoot}),(0,D.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,D.jsxs)(`label`,{className:i(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2 text-sm`,z===`fixed`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,D.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:z===`fixed`,onChange:()=>B(`fixed`),disabled:q}),(0,D.jsxs)(`span`,{className:`min-w-0`,children:[(0,D.jsx)(`span`,{className:`block font-medium`,children:r.workspaceModeFixed}),(0,D.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:r.workspaceFixedHint})]})]}),(0,D.jsxs)(`label`,{className:i(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2 text-sm`,z===`follow`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,D.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:z===`follow`,onChange:()=>B(`follow`),disabled:q}),(0,D.jsxs)(`span`,{className:`min-w-0`,children:[(0,D.jsx)(`span`,{className:`block font-medium`,children:r.workspaceModeFollow}),(0,D.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:r.workspaceFollowHint})]})]})]}),z===`fixed`?(0,D.jsx)(re,{value:R,onChange:Oe,disabled:q,wd:n,placeholder:r.workspacePlaceholder,inputClassName:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,autoFocus:!0}):null,(0,D.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:j(r.workspaceCurrent,{workspace:Le})})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,D.jsx)(`span`,{className:`font-medium text-fg-muted`,children:r.projectName}),(0,D.jsx)(`input`,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:I,onChange:e=>De(e.target.value),placeholder:R.trim()&&oe(R)||`xopc`})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,D.jsx)(`span`,{className:`font-medium text-fg-muted`,children:r.projectType}),(0,D.jsxs)(s,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:V,onChange:e=>ve(e.target.value),disabled:q,children:[(0,D.jsx)(S,{value:`auto`,children:r.projectTypes.auto}),(0,D.jsx)(S,{value:`coding`,children:r.projectTypes.coding}),(0,D.jsx)(S,{value:`general`,children:r.projectTypes.general})]})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,D.jsx)(`span`,{className:`font-medium text-fg-muted`,children:r.defaultAgent}),(0,D.jsxs)(s,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:H,onChange:e=>ye(e.target.value),disabled:q,children:[(0,D.jsx)(S,{value:O,children:r.agentAuto}),(0,D.jsx)(S,{value:k,children:r.agentGlobalDefault}),U.map(e=>(0,D.jsx)(S,{value:e.id,children:e.name||e.id},e.id))]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:Re})]})]}),(0,D.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,D.jsx)(p,{asChild:!0,children:(0,D.jsx)(C,{type:`button`,variant:`ghost`,className:`rounded-lg`,children:r.cancel})}),(0,D.jsxs)(C,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:q||!I.trim()&&(z!==`fixed`||!R.trim()),children:[(0,D.jsx)(v,{className:`size-4`,"aria-hidden":!0}),r.create]})]})]})]})]})}),(0,D.jsx)(m,{open:!!J,onOpenChange:e=>{e||Y(null)},children:(0,D.jsxs)(d,{children:[(0,D.jsx)(h,{className:`fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,D.jsxs)(T,{className:`fixed left-1/2 top-1/2 z-[110] flex w-[min(30rem,calc(100vw-2rem))] -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,D.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,D.jsx)(_,{className:`text-base font-semibold text-fg`,children:r.workspaceConflictTitle}),(0,D.jsx)(l,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:J?j(r.workspaceConflictDescription,{projectName:J.name}):null})]}),J?(0,D.jsx)(`div`,{className:`space-y-3 px-5 py-4`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,D.jsx)(te,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,D.jsx)(`span`,{className:`min-w-0 truncate`,children:j(r.workspaceConflictPath,{workspace:J.workspaceRoot||r.agentDefault})})]})}):null,(0,D.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,D.jsx)(C,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:je,children:r.workspaceConflictBack}),(0,D.jsxs)(C,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:Ae,children:[(0,D.jsx)(x,{className:`size-4`,"aria-hidden":!0}),r.workspaceConflictOpen]})]})]})]})}),(0,D.jsx)(m,{open:!!X,onOpenChange:e=>{e||Z(null)},children:(0,D.jsxs)(d,{children:[(0,D.jsx)(h,{className:`fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,D.jsxs)(T,{className:`fixed left-1/2 top-1/2 z-[110] flex w-[min(30rem,calc(100vw-2rem))] -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,D.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,D.jsx)(_,{className:`text-base font-semibold text-fg`,children:r.workspaceMissingTitle}),(0,D.jsx)(l,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:X?j(r.workspaceMissingDescription,{workspace:X}):null})]}),X?(0,D.jsx)(`div`,{className:`px-5 py-4`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,D.jsx)(te,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,D.jsx)(`span`,{className:`min-w-0 truncate`,children:X})]})}):null,(0,D.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,D.jsx)(C,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:Ne,disabled:q,children:r.workspaceMissingBack}),(0,D.jsxs)(C,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:Me,disabled:q,children:[(0,D.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),r.workspaceMissingCreate]})]})]})]})}),(0,D.jsxs)(`section`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,D.jsx)(`div`,{className:`flex flex-wrap gap-1 rounded-lg bg-surface-panel p-1 shadow-surface`,children:ae.map(e=>(0,D.jsx)(`button`,{type:`button`,onClick:()=>ue(e),className:i(`rounded-md px-3 py-1.5 text-sm font-medium transition-colors`,N===e?`bg-accent text-white`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:e===`all`?r.all:r.statuses[e]},e))}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,D.jsx)(te,{className:`size-4`,"aria-hidden":!0}),r.optionalContext]})]}),me?(0,D.jsx)(`p`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:me}):null,fe?(0,D.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.loading}):null,!fe&&A.length===0?(0,D.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-8 text-center shadow-surface`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:r.emptyTitle}),(0,D.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.emptyHint})]}):null,Be.map(([e,t])=>t.length?(0,D.jsxs)(`section`,{className:`space-y-3`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wide text-fg-subtle`,children:e}),(0,D.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:t.map(e=>(0,D.jsx)(le,{project:e,t:r},e.id))})]},e):null)]})}export{N as ProjectsPage};
@@ -1 +0,0 @@
1
- import{pr as e}from"./index-DOetFpTt.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};