@xopcai/xopc 0.0.177 → 0.0.178

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 (112) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-Wu2ikfbM.js → activity-store-BzGX__8I.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B0_biISn.js → agent-avatar-dicebear-BzxntcaZ.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-TpIpJk59.js → agents-DC9F12Kw.js} +1 -1
  6. package/dist/gateway/static/root/assets/{api-DljBt-N5.js → api-hi6f2Xtp.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-CKoZRi7Y.js → app-management-settings-panel-fTY1F7ac.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-DOdXhNDo.js → appearance-settings-BZ-IxQfB.js} +1 -1
  9. package/dist/gateway/static/root/assets/{apps-page-Cxbn5hy8.js → apps-page-5bKr05Fa.js} +1 -1
  10. package/dist/gateway/static/root/assets/{archive-plugin-D18gyP76.js → archive-plugin-ZSLLG8wB.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-CZh9fc8u.js → attachment-load-D4YktqIF.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-DKrVoiiK.js → automation-suggestion-card-B7mxFRtf.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-DYv16QMU.js → automations-page-Dg6dmt5g.js} +1 -1
  14. package/dist/gateway/static/root/assets/{binary-plugins-DdSyGL6M.js → binary-plugins-BIkPxfxj.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-BOpNApiX.js → block-editor-Q3v_YQom.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-settings-page-DlcqaGu1.js → browser-settings-page-BHoo6Rpq.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-C0SnSj_R.js → browser-workflow-inputs-M5lTEW1I.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-CzlzH7HA.js → browser-workflows-page-B3T1KYk4.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capabilities-settings-panel-QPX4wsGZ.js → capabilities-settings-panel-BlsqN8Fu.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-presets-api-RM6S7ES5.js → capability-presets-api-DE09c0VB.js} +1 -1
  21. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DmCeusO8.js → capability-presets-settings-panel-DJeT8_B4.js} +1 -1
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-B4sha-30.js → channel-recipient-api-CFR5FBfS.js} +1 -1
  23. package/dist/gateway/static/root/assets/{channels-settings-HcKoP1wm.js → channels-settings-C4VVjYEm.js} +1 -1
  24. package/dist/gateway/static/root/assets/channels-status-swr-vdf8kB16.js +1 -0
  25. package/dist/gateway/static/root/assets/{connector-logo-BPsKIyoM.js → connector-logo-B1mD-3pM.js} +1 -1
  26. package/dist/gateway/static/root/assets/{connectors-page-DwbThFvd.js → connectors-page-DNcrDThX.js} +1 -1
  27. package/dist/gateway/static/root/assets/{desktop-pet-DjL1GWON.js → desktop-pet-B1urphOZ.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-settings-u_abAXh7.js → desktop-pet-settings-DTL6J3EP.js} +1 -1
  29. package/dist/gateway/static/root/assets/{directory-picker-path-field-BoZGualI.js → directory-picker-path-field-BYQJ2XUS.js} +1 -1
  30. package/dist/gateway/static/root/assets/{dreaming-settings-s3gn3f9h.js → dreaming-settings-BXcb8fwx.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-debug-page-DIbMngCF.js → extension-debug-page-O1Xu1r4Q.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-D94f2bWQ.js → extension-page-C2Jraq8l.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-B7TI13ex.js → extension-settings-page-DcXQDTpG.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-config-api-Do77rV8R.js → gateway-config-api-DmPIZrvg.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-settings-Dt1PNJmb.js → gateway-settings-DmObBx9b.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-startup-retry-WaXTw3fi.js → gateway-startup-retry-BZEkOdPm.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goal-create-dialog-DEiOOLGU.js → goal-create-dialog-BRhmmBe9.js} +1 -1
  38. package/dist/gateway/static/root/assets/{goal-detail-page-C1Qj4o1K.js → goal-detail-page-C1k7_s_O.js} +1 -1
  39. package/dist/gateway/static/root/assets/{goals-config-api-BL0fAEns.js → goals-config-api-Fwu1wjEP.js} +1 -1
  40. package/dist/gateway/static/root/assets/{goals-page-qJDcEDzc.js → goals-page-hOu9uA3q.js} +1 -1
  41. package/dist/gateway/static/root/assets/{goals-settings-DV3ZlrdI.js → goals-settings-DY-JjvHz.js} +1 -1
  42. package/dist/gateway/static/root/assets/{heartbeat-settings-C3kzg6ai.js → heartbeat-settings-BtKu2NWT.js} +1 -1
  43. package/dist/gateway/static/root/assets/{image-generation-api-BgISY8i-.js → image-generation-api-05Gg8wsU.js} +1 -1
  44. package/dist/gateway/static/root/assets/{index-C1h0zkNo.js → index-C0CGebQ1.js} +7 -7
  45. package/dist/gateway/static/root/assets/index-eqq25gvV.css +1 -0
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-0KSmaPu0.js → keyboard-shortcuts-settings-CfmDR9Sc.js} +1 -1
  47. package/dist/gateway/static/root/assets/{local-app-workbench-page-DcD4mVId.js → local-app-workbench-page-EjsNT7nJ.js} +1 -1
  48. package/dist/gateway/static/root/assets/{local-apps-page-BMrU8u7w.js → local-apps-page-Df8BW1A_.js} +1 -1
  49. package/dist/gateway/static/root/assets/{locale-store-DVGhFXRz.js → locale-store-CTwSy7yW.js} +1 -1
  50. package/dist/gateway/static/root/assets/{logs-page-CW5m9Cov.js → logs-page-Dswjlraa.js} +1 -1
  51. package/dist/gateway/static/root/assets/{markdown-split-BVqbtN9o.js → markdown-split-B3FvKbaP.js} +1 -1
  52. package/dist/gateway/static/root/assets/{media-plugins-Dr_wtkNJ.js → media-plugins-DsjrvvB6.js} +1 -1
  53. package/dist/gateway/static/root/assets/messages-DP6tPKk-.js +3 -0
  54. package/dist/gateway/static/root/assets/{notes-page-BWZRXsq6.js → notes-page-tuzIwy3c.js} +1 -1
  55. package/dist/gateway/static/root/assets/{notes-workbench-DdnwNz9x.js → notes-workbench-DSh3-hMY.js} +2 -2
  56. package/dist/gateway/static/root/assets/{page-tabs-DWWgy0bF.js → page-tabs-ke9s4nYi.js} +1 -1
  57. package/dist/gateway/static/root/assets/{preview-open-alternatives-Bnfs93ZP.js → preview-open-alternatives-Cp1eI4S9.js} +1 -1
  58. package/dist/gateway/static/root/assets/{product-open-page-BR7QFmT-.js → product-open-page-dXQCMAtH.js} +1 -1
  59. package/dist/gateway/static/root/assets/{project-detail-page-B8GeS4dl.js → project-detail-page-D0QPRHR_.js} +1 -1
  60. package/dist/gateway/static/root/assets/{projects-page-DOeu1Hk_.js → projects-page-CI5Vz62F.js} +1 -1
  61. package/dist/gateway/static/root/assets/{remote-access-hub-De94rxnE.js → remote-access-hub-S1jpzBS5.js} +1 -1
  62. package/dist/gateway/static/root/assets/{save-bar-controls-BzS-rRTP.js → save-bar-controls-Bl30zjHc.js} +1 -1
  63. package/dist/gateway/static/root/assets/{schedule-field-Cl2IIDAN.js → schedule-field-DqhmXQKo.js} +1 -1
  64. package/dist/gateway/static/root/assets/{schema-form-BjKjp5eZ.js → schema-form-DkUCy6vf.js} +1 -1
  65. package/dist/gateway/static/root/assets/{sessions-page-A7p8G0OJ.js → sessions-page-CTm66k7h.js} +1 -1
  66. package/dist/gateway/static/root/assets/settings-advanced-gate-CU52AUVD.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-form-section-BSDNBfHn.js → settings-form-section-C6ZbNpdy.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BD4peoAv.js → settings-loading-skeleton-Bk58_cr7.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-page-S-P3U7at.js → settings-page-k8iE_NdX.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-layout-BQTLh-86.js → settings-page-layout-DgFSya2e.js} +1 -1
  71. package/dist/gateway/static/root/assets/{setup-status-panel-W3p6kNyA.js → setup-status-panel-B_KDlyZA.js} +1 -1
  72. package/dist/gateway/static/root/assets/{share-preview-page-DQjMxyvw.js → share-preview-page-CV7nL_J9.js} +1 -1
  73. package/dist/gateway/static/root/assets/{shares-settings-Xo3N99PO.js → shares-settings-DK6XK95e.js} +1 -1
  74. package/dist/gateway/static/root/assets/skill-reload-api-Bvv_u4ii.js +1 -0
  75. package/dist/gateway/static/root/assets/{skills-page-C019Ml5q.js → skills-page-BGHvVbay.js} +1 -1
  76. package/dist/gateway/static/root/assets/{skills-page.utils-CXnpudm6.js → skills-page.utils-kahBIHg0.js} +1 -1
  77. package/dist/gateway/static/root/assets/{system-settings-panel-BhFwdYJP.js → system-settings-panel-JV3-MG5F.js} +1 -1
  78. package/dist/gateway/static/root/assets/{theme-store-DQI-HPL-.js → theme-store-DFLyzoLO.js} +1 -1
  79. package/dist/gateway/static/root/assets/{time-picker-C0DCya4U.js → time-picker-XwpxdZFr.js} +1 -1
  80. package/dist/gateway/static/root/assets/{typed-models-lib-C-M3Fv2N.js → typed-models-lib-60Aqo-UJ.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-channel-catalog-Bndq4y4I.js → use-channel-catalog-CnTkHDnw.js} +1 -1
  82. package/dist/gateway/static/root/assets/{user-context-page-fYBzpus-.js → user-context-page-DBCMk-Vn.js} +1 -1
  83. package/dist/gateway/static/root/assets/{voice-api-key-field-p_g4UI1-.js → voice-api-key-field-CNa8qUgS.js} +1 -1
  84. package/dist/gateway/static/root/assets/{work-discovery-page-DI0gCZRw.js → work-discovery-page-C1UIdsCl.js} +1 -1
  85. package/dist/gateway/static/root/assets/work-item-detail-page-DEAQepB8.js +1 -0
  86. package/dist/gateway/static/root/assets/{work-page-Z-nUaS_n.js → work-page-D5qYmCTq.js} +1 -1
  87. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CHEXVvhH.js → workflow-run-setup-panel-yV_x595t.js} +1 -1
  88. package/dist/gateway/static/root/assets/{workflows-page-BDfwnM-Y.js → workflows-page-yrK17ZZ5.js} +1 -1
  89. package/dist/gateway/static/root/index.html +7 -7
  90. package/dist/package.js +1 -1
  91. package/dist/src/agent/embedded/model-runtime.js +3 -0
  92. package/dist/src/agent/embedded/run-for-session.js +18 -5
  93. package/dist/src/agent/embedded/run-turn.js +6 -3
  94. package/dist/src/agent/embedded/types.d.ts +2 -0
  95. package/dist/src/config/agent-profile.js +1 -1
  96. package/dist/src/connectors/composio-sessions.js +1 -1
  97. package/dist/src/gateway/agents-admin.js +1 -1
  98. package/dist/src/gateway/heartbeat/service.js +1 -1
  99. package/dist/src/gateway/hono/routes/browser-install.js +1 -1
  100. package/dist/src/heartbeat/index.js +1 -1
  101. package/dist/src/providers/provider-auth-service.js +3 -0
  102. package/dist/src/providers/register-bundled-oauth-flows.d.ts +2 -0
  103. package/dist/src/providers/register-bundled-oauth-flows.js +16 -0
  104. package/dist/src/session/store.d.ts +2 -0
  105. package/dist/src/session/store.js +30 -0
  106. package/package.json +3 -11
  107. package/dist/gateway/static/root/assets/channels-status-swr-D3xr2enH.js +0 -1
  108. package/dist/gateway/static/root/assets/index-Da36E3WH.css +0 -1
  109. package/dist/gateway/static/root/assets/messages-r8L6Ur3A.js +0 -3
  110. package/dist/gateway/static/root/assets/settings-advanced-gate-BsGzjmqx.js +0 -1
  111. package/dist/gateway/static/root/assets/skill-reload-api-ByPEG5t1.js +0 -1
  112. package/dist/gateway/static/root/assets/work-item-detail-page-DnBRP2wI.js +0 -1
@@ -1 +1 @@
1
- import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{r as i,s as a}from"./locale-store-DVGhFXRz.js";import{to as o,xs as s}from"./index-C1h0zkNo.js";e();var c=t();function l(){return{enabled:!0,provider:`xopc-local`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},providers:{"xopc-local":{model:`sensevoice-small`}},fallback:{enabled:!1,order:[`xopc-local`]}}}function u(){return{enabled:!0,provider:`edge`,trigger:`inbound`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function d(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function p(e,t,n){let r=d(e.providers)?e.providers:void 0,i=r&&d(r[t])?r[t]:void 0;return{...n,...i??{}}}function m(e){let t=l();if(!d(e))return t;let n=f(e.provider),r=p(e,`alibaba`,t.alibaba??{}),i=p(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(d(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=d(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,d(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function h(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function g(e){let t=u();if(!d(e))return t;let n=h(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=d(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,d(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:p(e,`alibaba`,t.alibaba??{}),openai:p(e,`openai`,t.openai??{}),edge:p(e,`edge`,t.edge??{}),minimax:p(e,`minimax`,t.minimax??{}),"tts-local-cli":p(e,`tts-local-cli`,i)}}function _(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function v(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function y(e){let t=d(e)?e:{},n=d(t.voice)?t.voice:{},r=d(n.input)?n.input:{},i=d(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:m(t.stt),tts:g(t.tts),voice:{languageMode:n.languageMode===`manual`?`manual`:`auto`,language:n.language===`zh`?`zh`:`en`,input:{refinement:{mode:a,...typeof i.model==`string`&&i.model.trim()?{model:i.model.trim()}:{},...typeof i.customInstruction==`string`?{customInstruction:i.customInstruction}:{}}}}}}async function b(){return y((await a(i(`/api/config`))).payload?.config??{})}async function x(e){await a(i(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:_(e.stt),tts:v(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await a(i(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),o()}async function S(){let e=await a(i(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function C(){let e=await a(i(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function w(){let e=await a(i(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function T(){let e=await a(i(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function E(e){await a(i(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function D(e){await a(i(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function O(e){let t=await a(i(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function k(e){let t=await a(i(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}var A=n();function j(e){let t=(0,c.c)(15),{kind:n,providerId:i,fieldId:a,value:o,onChange:l,labels:u,placeholder:d,className:f}=e,p=d===void 0?`sk-...`:d,m;t[0]!==n||t[1]!==i?(m=()=>k({kind:n,provider:i}).then(M),t[0]=n,t[1]=i,t[2]=m):m=t[2];let h=m,g;t[3]===f?g=t[4]:(g=r(`flex min-w-0 flex-col gap-1.5`,f),t[3]=f,t[4]=g);let _;t[5]!==a||t[6]!==u||t[7]!==l||t[8]!==p||t[9]!==h||t[10]!==o?(_=(0,A.jsx)(s,{id:a,value:o,onChange:l,placeholder:p,labels:u,reveal:h,loadFailedLabel:u.loadFailed,maskedHelp:u.maskedHelp,notInConfigFile:u.notInConfigFile,inputClassName:`text-xs`}),t[5]=a,t[6]=u,t[7]=l,t[8]=p,t[9]=h,t[10]=o,t[11]=_):_=t[11];let v;return t[12]!==g||t[13]!==_?(v=(0,A.jsx)(`div`,{className:g,children:_}),t[12]=g,t[13]=_,t[14]=v):v=t[14],v}function M(e){return e.apiKey??null}export{b as a,y as c,O as d,C as i,x as l,T as n,w as o,S as r,E as s,j as t,D as u};
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{r as i,s as a}from"./locale-store-CTwSy7yW.js";import{to as o,xs as s}from"./index-C0CGebQ1.js";e();var c=t();function l(){return{enabled:!0,provider:`xopc-local`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},providers:{"xopc-local":{model:`sensevoice-small`}},fallback:{enabled:!1,order:[`xopc-local`]}}}function u(){return{enabled:!0,provider:`edge`,trigger:`inbound`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function d(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function p(e,t,n){let r=d(e.providers)?e.providers:void 0,i=r&&d(r[t])?r[t]:void 0;return{...n,...i??{}}}function m(e){let t=l();if(!d(e))return t;let n=f(e.provider),r=p(e,`alibaba`,t.alibaba??{}),i=p(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(d(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=d(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,d(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function h(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function g(e){let t=u();if(!d(e))return t;let n=h(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=d(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,d(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:p(e,`alibaba`,t.alibaba??{}),openai:p(e,`openai`,t.openai??{}),edge:p(e,`edge`,t.edge??{}),minimax:p(e,`minimax`,t.minimax??{}),"tts-local-cli":p(e,`tts-local-cli`,i)}}function _(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function v(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function y(e){let t=d(e)?e:{},n=d(t.voice)?t.voice:{},r=d(n.input)?n.input:{},i=d(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:m(t.stt),tts:g(t.tts),voice:{languageMode:n.languageMode===`manual`?`manual`:`auto`,language:n.language===`zh`?`zh`:`en`,input:{refinement:{mode:a,...typeof i.model==`string`&&i.model.trim()?{model:i.model.trim()}:{},...typeof i.customInstruction==`string`?{customInstruction:i.customInstruction}:{}}}}}}async function b(){return y((await a(i(`/api/config`))).payload?.config??{})}async function x(e){await a(i(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:_(e.stt),tts:v(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await a(i(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),o()}async function S(){let e=await a(i(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function C(){let e=await a(i(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function w(){let e=await a(i(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function T(){let e=await a(i(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function E(e){await a(i(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function D(e){await a(i(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function O(e){let t=await a(i(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function k(e){let t=await a(i(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}var A=n();function j(e){let t=(0,c.c)(15),{kind:n,providerId:i,fieldId:a,value:o,onChange:l,labels:u,placeholder:d,className:f}=e,p=d===void 0?`sk-...`:d,m;t[0]!==n||t[1]!==i?(m=()=>k({kind:n,provider:i}).then(M),t[0]=n,t[1]=i,t[2]=m):m=t[2];let h=m,g;t[3]===f?g=t[4]:(g=r(`flex min-w-0 flex-col gap-1.5`,f),t[3]=f,t[4]=g);let _;t[5]!==a||t[6]!==u||t[7]!==l||t[8]!==p||t[9]!==h||t[10]!==o?(_=(0,A.jsx)(s,{id:a,value:o,onChange:l,placeholder:p,labels:u,reveal:h,loadFailedLabel:u.loadFailed,maskedHelp:u.maskedHelp,notInConfigFile:u.notInConfigFile,inputClassName:`text-xs`}),t[5]=a,t[6]=u,t[7]=l,t[8]=p,t[9]=h,t[10]=o,t[11]=_):_=t[11];let v;return t[12]!==g||t[13]!==_?(v=(0,A.jsx)(`div`,{className:g,children:_}),t[12]=g,t[13]=_,t[14]=v):v=t[14],v}function M(e){return e.apiKey??null}export{b as a,y as c,O as d,C as i,x as l,T as n,w as o,S as r,E as s,j as t,D as u};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{f as r,l as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./messages-r8L6Ur3A.js";import{n as ee}from"./locale-store-DVGhFXRz.js";import{Al as te,Ao as ne,As as s,At as re,Do as ie,Eo as c,Fo as ae,Io as oe,Lo as l,Mo as u,No as se,Ns as ce,Oo as le,Pl as d,Po as ue,Pt as de,Rl as fe,Ro as pe,_u as me,hu as f,jo as p,js as he,ko as ge,ro as m,ru as _e,tl as h,uc as g}from"./index-C1h0zkNo.js";var _=e(t(),1),v=new Set([`completed`,`failed`,`canceled`]);function ve(){return new Promise(e=>window.setTimeout(e,1200))}async function ye(e,t){let n=[],r=t.wait??ve;for(let i=0;i<e.length&&!t.shouldStop?.();i+=1){let a=e[i];if(a)try{await t.grantDirectory(a.rootPath);let o=await t.startRun(a.rootPath);for(t.onRun(o,i,e.length);!v.has(o.status)&&!t.shouldStop?.();)await r(),o=await t.fetchRun(o.id),t.onRun(o,i,e.length);if(n.push(o),o.status===`canceled`||t.shouldStop?.())break}catch(e){if(t.onError?.(e,a,i),t.shouldStop?.())break}}return n}var y=n(),be=[`folder_structure`,`recent_progress`,`next_steps`];function b(e){return e instanceof Error?e.message:String(e)}function x(){let e=ee(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,v=i(),[ve]=r(),x=ve.get(`new`)===`1`,[S,C]=(0,_.useState)(`loading`),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(!1),[A,j]=(0,_.useState)(null),[xe,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)(``),[F,I]=(0,_.useState)(!1),[L,R]=(0,_.useState)(()=>new Set),[z,Se]=(0,_.useState)([]),[B,V]=(0,_.useState)(()=>new Set),[Ce,H]=(0,_.useState)([]),[U,W]=(0,_.useState)(!1),[G,K]=(0,_.useState)({current:0,total:0}),q=(0,_.useRef)(!1),J=(0,_.useCallback)(e=>{c.getState().updateDirectoryRun(e),D(e),e.status===`completed`?(R(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),C(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`)):e.status===`failed`||e.status===`canceled`?C(`error`):C(`running`)},[]),we=async()=>{k(!0),j(null);try{let e=await le();if(!e.length){j(t.noCandidates);return}Se(e),V(new Set([e[0].rootPath])),C(`candidates`)}catch(e){j(b(e))}finally{k(!1)}},Te=e=>{V(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ee=(0,_.useCallback)((e,t,n)=>{c.getState().updateDirectoryRun(e),D(e),K({current:t+1,total:n}),H(n=>{let r=[...n];return r[t]=e,r}),C(`running`)},[]),De=(0,_.useCallback)(e=>{H(t=>t.map(t=>t?.id===e.id?e:t))},[]),Oe=async()=>{let e=z.filter(e=>B.has(e.rootPath));if(!e.length)return;k(!0),j(null),H([]),K({current:1,total:e.length}),W(!0),q.current=!1;let n=!1;try{let r=await ye(e,{grantDirectory:u,startRun:oe,fetchRun:p,shouldStop:()=>q.current,onRun:(e,t,r)=>{Ee(e,t,r),n||(n=!0,c.getState().scanPersonalContext(e.id))},onError:(n,r,i)=>{K({current:i+1,total:e.length}),j(t.folderAnalysisFailed.replace(`{{folder}}`,r.displayName).replace(`{{error}}`,b(n)))}});if(q.current)return;let i=r.find(e=>e.status===`completed`)??r.at(-1);i?J(i):C(`candidates`)}catch(e){j(b(e)),C(`candidates`)}finally{W(!1),k(!1)}},Y=de({onPicked:(0,_.useCallback)(async e=>{k(!0),j(null);try{T(await se(e)),C(`consent`)}catch(e){j(b(e)),C(`intro`)}finally{k(!1)}},[])});(0,_.useEffect)(()=>{let e=!1;return ne().then(async({enabled:t,state:n})=>{if(!e){if(!t){v(`/chat`,{replace:!0});return}if(!x&&n.activeRunId)try{let t=await p(n.activeRunId);e||J(t);return}catch{}e||C(`intro`)}}).catch(t=>{e||(j(b(t)),C(`intro`))}),()=>{e=!0}},[J,v,x]),(0,_.useEffect)(()=>{if(!E||S!==`running`||U)return;let e=!1,t=async()=>{try{let t=await p(E.id);e||J(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===E.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[J,U,S,E]);let ke=async()=>{k(!0);try{await ge()}finally{v(`/chat`,{replace:!0})}},Ae=async()=>{if(w){k(!0),j(null),H([]),K({current:0,total:0});try{await u(w.canonicalRootPath);let e=await oe(w.canonicalRootPath);J(e),c.getState().scanPersonalContext(e.id)}catch(e){j(b(e)),C(`consent`)}finally{k(!1)}}},X=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;v(`/chat/${encodeURIComponent(e)}${n}`)},je=e=>{D(e),M(!1),I(!1),R(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),e.status===`completed`?C(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?C(`error`):C(`running`)},Me=async()=>{E&&(q.current=!0,J(await ie(E.id)))},Z=async(t,n)=>{if(!E)return;await ae(E.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;X(E.sessionKey,r)},Ne=async()=>{if(E){k(!0),j(null);try{let e=E.result?.profileCandidates??[],t=await l((e.length>0?await pe(E.id,e.map(e=>({id:e.id,status:L.has(e.id)?`accepted`:`rejected`}))):E).id,`confirmed`);D(t),De(t),C(`recommendation`)}catch(e){j(b(e))}finally{k(!1)}}},Q=async e=>{if(!(!E||!N.trim())){k(!0),j(null);try{let t=await l(E.id,e,N.trim());D(t),X(t.sessionKey,N.trim())}catch(e){j(b(e)),k(!1)}}},Pe=async()=>{if(E){k(!0);try{X((await l(E.id,`dismissed`)).sessionKey)}catch(e){j(b(e)),k(!1)}}},$=E?.result?.suggestions.find(e=>e.id===E.result?.primarySuggestionId)??E?.result?.suggestions[0],Fe=E?.result?.suggestions.filter(e=>e.id!==$?.id)??[],Ie=e=>e===`command`?t.riskCommand:e===`file_write`?t.riskFileWrite:t.riskAnalysis,Le=Ce.filter(e=>e?.status===`completed`),Re=Le.length>1?(0,y.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,y.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:t.analysisResults}),(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Le.map(e=>{let t=z.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,y.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===E?.id?`bg-accent text-white`:`bg-surface-muted text-fg hover:bg-surface-hover`}`,onClick:()=>je(e),children:t},e.id)})})]}):null;return(0,y.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,y.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[(0,y.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,y.jsx)(he,{className:`size-11`})}),S===`loading`?(0,y.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,y.jsx)(m,{className:`mx-auto h-8 w-64`}),(0,y.jsx)(m,{className:`mx-auto h-4 w-full max-w-lg`}),(0,y.jsx)(m,{className:`mx-auto size-4/5 max-w-md`}),(0,y.jsx)(m,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,S===`intro`?(0,y.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,y.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,y.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,y.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,y.jsxs)(s,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void we(),disabled:O||Y.picking,children:[O?(0,y.jsx)(h,{className:`size-4 animate-spin`}):(0,y.jsx)(g,{className:`size-4`}),t.quickScan]}),(0,y.jsxs)(s,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:Y.pick,disabled:O||Y.picking,children:[Y.picking?(0,y.jsx)(h,{className:`size-4 animate-spin`}):(0,y.jsx)(d,{className:`size-4`}),t.chooseFolderManually]}),(0,y.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,y.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,y.jsx)(`span`,{children:t.quickScanNote})]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null]}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void ke(),disabled:O,children:t.skip})]}):null,S===`candidates`?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-candidates-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.candidatesTitle}),(0,y.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.candidatesSubtitle})]}),(0,y.jsx)(`div`,{className:`mt-7 space-y-2`,children:z.map((e,n)=>{let r=B.has(e.rootPath);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":r,className:`flex w-full items-start gap-3 rounded-xl border p-4 text-left transition ${r?`border-accent bg-accent-soft/45`:`border-edge bg-surface-panel hover:border-edge-strong`}`,onClick:()=>Te(e.rootPath),children:[(0,y.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-md border ${r?`border-accent bg-accent text-white`:`border-edge bg-surface-base text-transparent`}`,children:(0,y.jsx)(a,{className:`size-3.5`})}),(0,y.jsx)(d,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),n===0?(0,y.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:t.recommendedCandidate}):null]}),(0,y.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,y.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,y.jsx)(`span`,{children:e.projectKind===`coding`?t.codingProject:e.projectKind===`general`?t.generalProject:t.unknownProject}),e.branch?(0,y.jsx)(`span`,{children:t.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,y.jsx)(`span`,{children:t.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,y.jsxs)(`div`,{className:`mt-5 flex items-start gap-2 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 text-xs leading-5 text-fg-muted`,children:[(0,y.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,y.jsx)(`span`,{children:t.multiFolderPrivacyNote})]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null,(0,y.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsxs)(s,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:O||B.size===0,onClick:()=>void Oe(),children:[O?(0,y.jsx)(h,{className:`mr-2 size-4 animate-spin`}):null,t.analyzeSelected.replace(`{{count}}`,String(B.size))]}),(0,y.jsx)(s,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:O,onClick:Y.pick,children:t.chooseFolderManually})]}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>C(`intro`),children:t.back})]}):null,S===`consent`&&w?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,y.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,y.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,y.jsx)(d,{className:`size-5 shrink-0 text-accent-fg`}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:w.displayName}),(0,y.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:w.canonicalRootPath})]}),(0,y.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:w.projectKind===`coding`?t.codingProject:w.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,y.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.localFingerprint}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:w.fingerprint.branch?t.branchValue.replace(`{{branch}}`,w.fingerprint.branch):t.noGitBranch})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentActivity}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:t.changedFiles.replace(`{{count}}`,String(w.fingerprint.changedFileCount))})]}),w.fingerprint.recentAreas.length>0?(0,y.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentAreas}),(0,y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:w.fingerprint.recentAreas.map(e=>(0,y.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,y.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,y.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,y.jsx)(fe,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,y.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,y.jsx)(ce,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,y.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,y.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,y.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:w.remoteModel?t.providerDisclosure.replace(`{{provider}}`,w.provider):t.localDisclosure})]})]})]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null,(0,y.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsxs)(s,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:O,onClick:()=>void Ae(),children:[O?(0,y.jsx)(h,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,y.jsx)(s,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:O,onClick:Y.pick,children:t.changeFolder})]}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void ke(),children:t.skip})]}):null,S===`running`&&E?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,y.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle}),G.total>1?(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:t.analyzingFolderProgress.replace(`{{current}}`,String(G.current)).replace(`{{total}}`,String(G.total))}):null]}),(0,y.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:be.map((e,n)=>{let r=Math.max(0,be.indexOf(E.stage??`folder_structure`)),i=n<r,o=n===r;return(0,y.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,y.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${i?`bg-accent text-white`:o?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:i?(0,y.jsx)(a,{className:`size-4`}):o?(0,y.jsx)(h,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,y.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,y.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,y.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:E.rootPath}),(0,y.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3`,children:[(0,y.jsx)(s,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:()=>v(`/chat`),children:t.continueInBackground}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void Me(),children:t.cancelAnalysis})]})]}):null,S===`recognition`&&E?.result?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.recognitionEyebrow}),(0,y.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:E.result.lowConfidence?t.lowConfidenceTitle:t.recognitionTitle})]}),Re,(0,y.jsxs)(`div`,{className:`mt-7 rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/45 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,y.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:E.result.projectSummary}),(0,y.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:E.result.currentState}),!E.result.lowConfidence&&$?.evidence.length?(0,y.jsx)(`ul`,{className:`mt-5 space-y-2 border-t border-edge-subtle pt-4`,children:$.evidence.slice(0,3).map((e,t)=>(0,y.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,y.jsx)(te,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,y.jsxs)(`span`,{children:[e.path?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${$.id}-recognition-${t}`))}):null]}),E.result.workThreads?.length?(0,y.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.workThreadsTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.workThreadsSubtitle}),(0,y.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:E.result.workThreads.map(e=>(0,y.jsxs)(`div`,{className:`py-3 first:pt-0 last:pb-0`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:e.horizon===`current`?t.workThreadCurrent:e.horizon===`ongoing`?t.workThreadOngoing:t.workThreadLongTerm}),(0,y.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title})]}),(0,y.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:e.summary})]},e.id))})]}):null,E.result.profileCandidates?.length?(0,y.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.profileCandidatesTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.profileCandidatesSubtitle}),(0,y.jsx)(`div`,{className:`mt-3 space-y-2`,children:E.result.profileCandidates.map(e=>(0,y.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg px-2 py-2 hover:bg-surface-muted`,children:[(0,y.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 rounded border-edge accent-accent`,checked:L.has(e.id),onChange:()=>R(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}),(0,y.jsx)(`span`,{className:`text-sm leading-5 text-fg`,children:e.statement})]},e.id))})]}):null,E.result.lowConfidence?(0,y.jsxs)(`div`,{className:`mt-5`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:E.result.contextQuestion}),(0,y.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,y.jsx)(s,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:O||!N.trim(),onClick:()=>void Q(`different_goal`),children:t.continueWithCorrection})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsxs)(s,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:O,onClick:()=>void Ne(),children:[O?(0,y.jsx)(h,{className:`size-4 animate-spin`}):(0,y.jsx)(a,{className:`size-4`}),t.confirmUnderstanding]}),(0,y.jsx)(s,{variant:`secondary`,className:`h-11 flex-1`,disabled:O,onClick:()=>M(e=>!e),children:t.notQuiteRight})]}),xe?(0,y.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,y.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:t.correctionLabel}),(0,y.jsx)(`textarea`,{id:`work-discovery-correction`,value:N,onChange:e=>P(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-2 min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,y.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,y.jsx)(s,{variant:`ghost`,disabled:O||!N.trim(),onClick:()=>void Q(`different_goal`),children:t.differentGoal}),(0,y.jsx)(s,{variant:`primary`,disabled:O||!N.trim(),onClick:()=>void Q(`corrected`),children:t.useCorrection})]})]}):null]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null,(0,y.jsx)(`button`,{type:`button`,disabled:O,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void Pe(),children:t.openConversation})]}):null,S===`recommendation`&&E?.result&&$?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.understandingConfirmed}),(0,y.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:t.primaryRecommendationTitle})]}),Re,(0,y.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,y.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,y.jsx)(f,{className:`size-5`})}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:$.title}),(0,y.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:$.rationale}),(0,y.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:[(0,y.jsx)(_e,{className:`size-3.5`}),t.estimatedMinutes.replace(`{{count}}`,String($.estimatedMinutes))]}),(0,y.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:Ie($.risk)})]}),(0,y.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.expectedOutcome}),(0,y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:$.expectedOutcome})]}),(0,y.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,y.jsx)(s,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void Z($,!1),children:t.startRecommendedAction}),(0,y.jsx)(s,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void Z($,!0),children:t.explainFirst})]})]})]})}),Fe.length>0?(0,y.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>I(e=>!e),children:[t.otherDirections,(0,y.jsx)(me,{className:`size-4 transition-transform ${F?`rotate-180`:``}`})]}),F?(0,y.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:Fe.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void Z(e,!0),children:[(0,y.jsx)(f,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,y.jsxs)(`span`,{children:[(0,y.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,y.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedOutcome})]})]},e.id))}):null]}):null,(0,y.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,y.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>X(E.sessionKey),children:t.doSomethingElse}),(0,y.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{M(!0),C(`recognition`)},children:t.correctUnderstanding})]})]}):null,S===`error`&&E?(0,y.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,y.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,y.jsx)(ce,{className:`size-5`})}),(0,y.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,y.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:E.errorMessage}),(0,y.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsx)(s,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void ue(E.id).then(J),children:t.retry}),(0,y.jsx)(s,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{D(null),T(null),C(`intro`)},children:t.chooseDifferent})]}),(0,y.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>X(E.sessionKey),children:t.openConversation})]}):null]}),Y.hasNativePicker?null:(0,y.jsx)(re,{open:Y.modalOpen,onOpenChange:Y.setModalOpen,initialAbsolutePath:w?.canonicalRootPath,onConfirm:Y.confirmPick,wd:n})]})}export{x as WorkDiscoveryPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{f as r,l as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./messages-DP6tPKk-.js";import{n as ee}from"./locale-store-CTwSy7yW.js";import{Al as te,Ao as ne,As as s,At as re,Do as ie,Eo as c,Fo as ae,Io as oe,Lo as l,Mo as u,No as se,Ns as ce,Oo as le,Pl as d,Po as ue,Pt as de,Rl as fe,Ro as pe,_u as me,hu as f,jo as p,js as he,ko as ge,ro as m,ru as _e,tl as h,uc as g}from"./index-C0CGebQ1.js";var _=e(t(),1),v=new Set([`completed`,`failed`,`canceled`]);function ve(){return new Promise(e=>window.setTimeout(e,1200))}async function ye(e,t){let n=[],r=t.wait??ve;for(let i=0;i<e.length&&!t.shouldStop?.();i+=1){let a=e[i];if(a)try{await t.grantDirectory(a.rootPath);let o=await t.startRun(a.rootPath);for(t.onRun(o,i,e.length);!v.has(o.status)&&!t.shouldStop?.();)await r(),o=await t.fetchRun(o.id),t.onRun(o,i,e.length);if(n.push(o),o.status===`canceled`||t.shouldStop?.())break}catch(e){if(t.onError?.(e,a,i),t.shouldStop?.())break}}return n}var y=n(),be=[`folder_structure`,`recent_progress`,`next_steps`];function b(e){return e instanceof Error?e.message:String(e)}function x(){let e=ee(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,v=i(),[ve]=r(),x=ve.get(`new`)===`1`,[S,C]=(0,_.useState)(`loading`),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(!1),[A,j]=(0,_.useState)(null),[xe,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)(``),[F,I]=(0,_.useState)(!1),[L,R]=(0,_.useState)(()=>new Set),[z,Se]=(0,_.useState)([]),[B,V]=(0,_.useState)(()=>new Set),[Ce,H]=(0,_.useState)([]),[U,W]=(0,_.useState)(!1),[G,K]=(0,_.useState)({current:0,total:0}),q=(0,_.useRef)(!1),J=(0,_.useCallback)(e=>{c.getState().updateDirectoryRun(e),D(e),e.status===`completed`?(R(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),C(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`)):e.status===`failed`||e.status===`canceled`?C(`error`):C(`running`)},[]),we=async()=>{k(!0),j(null);try{let e=await le();if(!e.length){j(t.noCandidates);return}Se(e),V(new Set([e[0].rootPath])),C(`candidates`)}catch(e){j(b(e))}finally{k(!1)}},Te=e=>{V(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ee=(0,_.useCallback)((e,t,n)=>{c.getState().updateDirectoryRun(e),D(e),K({current:t+1,total:n}),H(n=>{let r=[...n];return r[t]=e,r}),C(`running`)},[]),De=(0,_.useCallback)(e=>{H(t=>t.map(t=>t?.id===e.id?e:t))},[]),Oe=async()=>{let e=z.filter(e=>B.has(e.rootPath));if(!e.length)return;k(!0),j(null),H([]),K({current:1,total:e.length}),W(!0),q.current=!1;let n=!1;try{let r=await ye(e,{grantDirectory:u,startRun:oe,fetchRun:p,shouldStop:()=>q.current,onRun:(e,t,r)=>{Ee(e,t,r),n||(n=!0,c.getState().scanPersonalContext(e.id))},onError:(n,r,i)=>{K({current:i+1,total:e.length}),j(t.folderAnalysisFailed.replace(`{{folder}}`,r.displayName).replace(`{{error}}`,b(n)))}});if(q.current)return;let i=r.find(e=>e.status===`completed`)??r.at(-1);i?J(i):C(`candidates`)}catch(e){j(b(e)),C(`candidates`)}finally{W(!1),k(!1)}},Y=de({onPicked:(0,_.useCallback)(async e=>{k(!0),j(null);try{T(await se(e)),C(`consent`)}catch(e){j(b(e)),C(`intro`)}finally{k(!1)}},[])});(0,_.useEffect)(()=>{let e=!1;return ne().then(async({enabled:t,state:n})=>{if(!e){if(!t){v(`/chat`,{replace:!0});return}if(!x&&n.activeRunId)try{let t=await p(n.activeRunId);e||J(t);return}catch{}e||C(`intro`)}}).catch(t=>{e||(j(b(t)),C(`intro`))}),()=>{e=!0}},[J,v,x]),(0,_.useEffect)(()=>{if(!E||S!==`running`||U)return;let e=!1,t=async()=>{try{let t=await p(E.id);e||J(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===E.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[J,U,S,E]);let ke=async()=>{k(!0);try{await ge()}finally{v(`/chat`,{replace:!0})}},Ae=async()=>{if(w){k(!0),j(null),H([]),K({current:0,total:0});try{await u(w.canonicalRootPath);let e=await oe(w.canonicalRootPath);J(e),c.getState().scanPersonalContext(e.id)}catch(e){j(b(e)),C(`consent`)}finally{k(!1)}}},X=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;v(`/chat/${encodeURIComponent(e)}${n}`)},je=e=>{D(e),M(!1),I(!1),R(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),e.status===`completed`?C(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?C(`error`):C(`running`)},Me=async()=>{E&&(q.current=!0,J(await ie(E.id)))},Z=async(t,n)=>{if(!E)return;await ae(E.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;X(E.sessionKey,r)},Ne=async()=>{if(E){k(!0),j(null);try{let e=E.result?.profileCandidates??[],t=await l((e.length>0?await pe(E.id,e.map(e=>({id:e.id,status:L.has(e.id)?`accepted`:`rejected`}))):E).id,`confirmed`);D(t),De(t),C(`recommendation`)}catch(e){j(b(e))}finally{k(!1)}}},Q=async e=>{if(!(!E||!N.trim())){k(!0),j(null);try{let t=await l(E.id,e,N.trim());D(t),X(t.sessionKey,N.trim())}catch(e){j(b(e)),k(!1)}}},Pe=async()=>{if(E){k(!0);try{X((await l(E.id,`dismissed`)).sessionKey)}catch(e){j(b(e)),k(!1)}}},$=E?.result?.suggestions.find(e=>e.id===E.result?.primarySuggestionId)??E?.result?.suggestions[0],Fe=E?.result?.suggestions.filter(e=>e.id!==$?.id)??[],Ie=e=>e===`command`?t.riskCommand:e===`file_write`?t.riskFileWrite:t.riskAnalysis,Le=Ce.filter(e=>e?.status===`completed`),Re=Le.length>1?(0,y.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,y.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:t.analysisResults}),(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Le.map(e=>{let t=z.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,y.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===E?.id?`bg-accent text-white`:`bg-surface-muted text-fg hover:bg-surface-hover`}`,onClick:()=>je(e),children:t},e.id)})})]}):null;return(0,y.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,y.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[40rem] flex-1 flex-col px-5 py-10 sm:px-8 sm:py-16`,children:[(0,y.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,y.jsx)(he,{className:`size-11`})}),S===`loading`?(0,y.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,y.jsx)(m,{className:`mx-auto h-8 w-64`}),(0,y.jsx)(m,{className:`mx-auto h-4 w-full max-w-lg`}),(0,y.jsx)(m,{className:`mx-auto size-4/5 max-w-md`}),(0,y.jsx)(m,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,S===`intro`?(0,y.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,y.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,y.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,y.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,y.jsxs)(s,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void we(),disabled:O||Y.picking,children:[O?(0,y.jsx)(h,{className:`size-4 animate-spin`}):(0,y.jsx)(g,{className:`size-4`}),t.quickScan]}),(0,y.jsxs)(s,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:Y.pick,disabled:O||Y.picking,children:[Y.picking?(0,y.jsx)(h,{className:`size-4 animate-spin`}):(0,y.jsx)(d,{className:`size-4`}),t.chooseFolderManually]}),(0,y.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,y.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,y.jsx)(`span`,{children:t.quickScanNote})]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null]}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void ke(),disabled:O,children:t.skip})]}):null,S===`candidates`?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-candidates-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.candidatesTitle}),(0,y.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.candidatesSubtitle})]}),(0,y.jsx)(`div`,{className:`mt-7 space-y-2`,children:z.map((e,n)=>{let r=B.has(e.rootPath);return(0,y.jsxs)(`button`,{type:`button`,"aria-pressed":r,className:`flex w-full items-start gap-3 rounded-xl border p-4 text-left transition ${r?`border-accent bg-accent-soft/45`:`border-edge bg-surface-panel hover:border-edge-strong`}`,onClick:()=>Te(e.rootPath),children:[(0,y.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-md border ${r?`border-accent bg-accent text-white`:`border-edge bg-surface-base text-transparent`}`,children:(0,y.jsx)(a,{className:`size-3.5`})}),(0,y.jsx)(d,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),n===0?(0,y.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:t.recommendedCandidate}):null]}),(0,y.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,y.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,y.jsx)(`span`,{children:e.projectKind===`coding`?t.codingProject:e.projectKind===`general`?t.generalProject:t.unknownProject}),e.branch?(0,y.jsx)(`span`,{children:t.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,y.jsx)(`span`,{children:t.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,y.jsxs)(`div`,{className:`mt-5 flex items-start gap-2 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 text-xs leading-5 text-fg-muted`,children:[(0,y.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,y.jsx)(`span`,{children:t.multiFolderPrivacyNote})]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null,(0,y.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsxs)(s,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:O||B.size===0,onClick:()=>void Oe(),children:[O?(0,y.jsx)(h,{className:`mr-2 size-4 animate-spin`}):null,t.analyzeSelected.replace(`{{count}}`,String(B.size))]}),(0,y.jsx)(s,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:O,onClick:Y.pick,children:t.chooseFolderManually})]}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>C(`intro`),children:t.back})]}):null,S===`consent`&&w?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,y.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,y.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,y.jsx)(d,{className:`size-5 shrink-0 text-accent-fg`}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:w.displayName}),(0,y.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:w.canonicalRootPath})]}),(0,y.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:w.projectKind===`coding`?t.codingProject:w.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,y.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.localFingerprint}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:w.fingerprint.branch?t.branchValue.replace(`{{branch}}`,w.fingerprint.branch):t.noGitBranch})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentActivity}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:t.changedFiles.replace(`{{count}}`,String(w.fingerprint.changedFileCount))})]}),w.fingerprint.recentAreas.length>0?(0,y.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentAreas}),(0,y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:w.fingerprint.recentAreas.map(e=>(0,y.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,y.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,y.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,y.jsx)(fe,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,y.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,y.jsx)(ce,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,y.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,y.jsx)(g,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,y.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:w.remoteModel?t.providerDisclosure.replace(`{{provider}}`,w.provider):t.localDisclosure})]})]})]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null,(0,y.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsxs)(s,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:O,onClick:()=>void Ae(),children:[O?(0,y.jsx)(h,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,y.jsx)(s,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:O,onClick:Y.pick,children:t.changeFolder})]}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void ke(),children:t.skip})]}):null,S===`running`&&E?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,y.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle}),G.total>1?(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:t.analyzingFolderProgress.replace(`{{current}}`,String(G.current)).replace(`{{total}}`,String(G.total))}):null]}),(0,y.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:be.map((e,n)=>{let r=Math.max(0,be.indexOf(E.stage??`folder_structure`)),i=n<r,o=n===r;return(0,y.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,y.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full ${i?`bg-accent text-white`:o?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-subtle`}`,children:i?(0,y.jsx)(a,{className:`size-4`}):o?(0,y.jsx)(h,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,y.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,y.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,y.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:E.rootPath}),(0,y.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3`,children:[(0,y.jsx)(s,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:()=>v(`/chat`),children:t.continueInBackground}),(0,y.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void Me(),children:t.cancelAnalysis})]})]}):null,S===`recognition`&&E?.result?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.recognitionEyebrow}),(0,y.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:E.result.lowConfidence?t.lowConfidenceTitle:t.recognitionTitle})]}),Re,(0,y.jsxs)(`div`,{className:`mt-7 rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/45 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,y.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:E.result.projectSummary}),(0,y.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:E.result.currentState}),!E.result.lowConfidence&&$?.evidence.length?(0,y.jsx)(`ul`,{className:`mt-5 space-y-2 border-t border-edge-subtle pt-4`,children:$.evidence.slice(0,3).map((e,t)=>(0,y.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,y.jsx)(te,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,y.jsxs)(`span`,{children:[e.path?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${$.id}-recognition-${t}`))}):null]}),E.result.workThreads?.length?(0,y.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.workThreadsTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.workThreadsSubtitle}),(0,y.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:E.result.workThreads.map(e=>(0,y.jsxs)(`div`,{className:`py-3 first:pt-0 last:pb-0`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:e.horizon===`current`?t.workThreadCurrent:e.horizon===`ongoing`?t.workThreadOngoing:t.workThreadLongTerm}),(0,y.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title})]}),(0,y.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:e.summary})]},e.id))})]}):null,E.result.profileCandidates?.length?(0,y.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.profileCandidatesTitle}),(0,y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.profileCandidatesSubtitle}),(0,y.jsx)(`div`,{className:`mt-3 space-y-2`,children:E.result.profileCandidates.map(e=>(0,y.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg px-2 py-2 hover:bg-surface-muted`,children:[(0,y.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 rounded border-edge accent-accent`,checked:L.has(e.id),onChange:()=>R(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}),(0,y.jsx)(`span`,{className:`text-sm leading-5 text-fg`,children:e.statement})]},e.id))})]}):null,E.result.lowConfidence?(0,y.jsxs)(`div`,{className:`mt-5`,children:[(0,y.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:E.result.contextQuestion}),(0,y.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-panel px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,y.jsx)(s,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:O||!N.trim(),onClick:()=>void Q(`different_goal`),children:t.continueWithCorrection})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsxs)(s,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:O,onClick:()=>void Ne(),children:[O?(0,y.jsx)(h,{className:`size-4 animate-spin`}):(0,y.jsx)(a,{className:`size-4`}),t.confirmUnderstanding]}),(0,y.jsx)(s,{variant:`secondary`,className:`h-11 flex-1`,disabled:O,onClick:()=>M(e=>!e),children:t.notQuiteRight})]}),xe?(0,y.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,y.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:t.correctionLabel}),(0,y.jsx)(`textarea`,{id:`work-discovery-correction`,value:N,onChange:e=>P(e.target.value),placeholder:t.correctionPlaceholder,className:`mt-2 min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,y.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,y.jsx)(s,{variant:`ghost`,disabled:O||!N.trim(),onClick:()=>void Q(`different_goal`),children:t.differentGoal}),(0,y.jsx)(s,{variant:`primary`,disabled:O||!N.trim(),onClick:()=>void Q(`corrected`),children:t.useCorrection})]})]}):null]}),A?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:A}):null,(0,y.jsx)(`button`,{type:`button`,disabled:O,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void Pe(),children:t.openConversation})]}):null,S===`recommendation`&&E?.result&&$?(0,y.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.understandingConfirmed}),(0,y.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:t.primaryRecommendationTitle})]}),Re,(0,y.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,y.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,y.jsx)(f,{className:`size-5`})}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:$.title}),(0,y.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:$.rationale}),(0,y.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:[(0,y.jsx)(_e,{className:`size-3.5`}),t.estimatedMinutes.replace(`{{count}}`,String($.estimatedMinutes))]}),(0,y.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:Ie($.risk)})]}),(0,y.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,y.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.expectedOutcome}),(0,y.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:$.expectedOutcome})]}),(0,y.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,y.jsx)(s,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void Z($,!1),children:t.startRecommendedAction}),(0,y.jsx)(s,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void Z($,!0),children:t.explainFirst})]})]})]})}),Fe.length>0?(0,y.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>I(e=>!e),children:[t.otherDirections,(0,y.jsx)(me,{className:`size-4 transition-transform ${F?`rotate-180`:``}`})]}),F?(0,y.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:Fe.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void Z(e,!0),children:[(0,y.jsx)(f,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,y.jsxs)(`span`,{children:[(0,y.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,y.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedOutcome})]})]},e.id))}):null]}):null,(0,y.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,y.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>X(E.sessionKey),children:t.doSomethingElse}),(0,y.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{M(!0),C(`recognition`)},children:t.correctUnderstanding})]})]}):null,S===`error`&&E?(0,y.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,y.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,y.jsx)(ce,{className:`size-5`})}),(0,y.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,y.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:E.errorMessage}),(0,y.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,y.jsx)(s,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void ue(E.id).then(J),children:t.retry}),(0,y.jsx)(s,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{D(null),T(null),C(`intro`)},children:t.chooseDifferent})]}),(0,y.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>X(E.sessionKey),children:t.openConversation})]}):null]}),Y.hasNativePicker?null:(0,y.jsx)(re,{open:Y.modalOpen,onOpenChange:Y.setModalOpen,initialAbsolutePath:w?.canonicalRootPath,onConfirm:Y.confirmPick,wd:n})]})}export{x as WorkDiscoveryPage};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-DP6tPKk-.js";import{n as ee}from"./locale-store-CTwSy7yW.js";import{A as te,Ac as ne,Al as re,As as l,Cc as ie,Fa as u,Gs as ae,Jl as oe,Ks as se,Nu as d,Rl as f,Sc as ce,To as p,Wl as le,Xc as m,Xs as ue,a as h,bu as de,f as fe,is as g,l as _,m as v,ns as y,o as pe,p as me,pu as he,ro as b,s as ge,u as x,vt as S,zc as _e}from"./index-C0CGebQ1.js";var C=n(),w=e(t(),1),T=r();function ve(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 E(e){return e?S(new Date(e)):``}function ye(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 D(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)}`:e.kind===`note`?`/notes/${encodeURIComponent(e.targetId)}`:`#`}function O(e){let t=(0,C.c)(7),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,T.jsx)(`dt`,{className:`text-xs leading-5 text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,T.jsx)(`dd`,{className:`min-w-0 overflow-hidden break-words text-sm leading-5 text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,T.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[5rem_minmax(0,1fr)] items-start gap-3 py-2.5 first:pt-0 last:pb-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function k(e){let t=(0,C.c)(9),{events:n,t:r}=e;if(!n.length){let e;return t[0]===r.detail.noActivity?e=t[1]:(e=(0,T.jsx)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-4 py-8 text-center text-sm text-fg-muted`,children:r.detail.noActivity}),t[0]=r.detail.noActivity,t[1]=e),e}let i;if(t[2]!==n||t[3]!==r){let e;t[5]===r?e=t[6]:(e=e=>(0,T.jsxs)(`article`,{className:`relative grid grid-cols-[0.75rem_minmax(0,1fr)] gap-3 py-3 first:pt-1`,children:[(0,T.jsx)(`span`,{className:`relative z-10 mt-1.5 size-3 rounded-full border-2 border-surface-base bg-fg-disabled`,"aria-hidden":!0}),(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline justify-between gap-x-4 gap-y-0.5`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r.eventTypes[e.type]??e.type}),(0,T.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:E(e.createdAt)})]})]},e.id),t[5]=r,t[6]=e),i=n.map(e),t[2]=n,t[3]=r,t[4]=i}else i=t[4];let a;return t[7]===i?a=t[8]:(a=(0,T.jsx)(`div`,{className:`relative grid gap-0 before:absolute before:bottom-3 before:left-[5px] before:top-3 before:w-px before:bg-edge`,children:i}),t[7]=i,t[8]=a),a}function A(e){return new Set(e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fff]+/).filter(e=>e.length>=2))}function j(e,t,n){let r=t?.projectKind,i=[e.title,e.description,e.nextAction,e.blockedReason,e.status,e.priority,t?.name,t?.description,r].filter(Boolean).join(` `),a=[n.title,n.description,n.metadata.whenToUse,...n.metadata.tags??[]].filter(Boolean).join(` `),o=A(i),s=0;for(let e of A(a))o.has(e)&&(s+=3);let c=a.toLowerCase();return(e.status===`blocked`||e.status===`needs_input`)&&/debug|diagnos|review|audit|fix|检查|排查|修复/.test(c)&&(s+=8),e.status===`in_review`&&/review|audit|check|验收|评审|检查/.test(c)&&(s+=6),e.attachments?.length&&/analy|extract|summar|review|整理|分析|总结/.test(c)&&(s+=5),r===`coding`&&/code|repo|test|pr|review|代码|仓库|测试/.test(c)&&(s+=5),s}function M(e,t,n){return[...n].sort((n,r)=>j(e,t,r)-j(e,t,n)||n.title.localeCompare(r.title))}function N(){let{workItemId:e=``}=i(),t=a(),n=c(ee(e=>e.language)).projectDetailPage.workItems,[r,S]=(0,w.useState)(null),[C,A]=(0,w.useState)(null),[N,P]=(0,w.useState)([]),[F,be]=(0,w.useState)([]),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(!0),[H,U]=(0,w.useState)(!1),[W,G]=(0,w.useState)(null),K=(0,w.useRef)(null),q=p(e=>e.setPageHeader),J=p(e=>e.clearPageHeader),Y=(0,w.useMemo)(()=>r?`/projects/${encodeURIComponent(r.projectId)}/work-items`:`/projects`,[r]),X=(0,w.useCallback)(async()=>{if(e){V(!0),G(null);try{let[t,n]=await Promise.all([_(e),x(e).catch(()=>({events:[]}))]);S(t.item),z(t.item.nextAction||t.item.title),P(n.events);let[r,i]=await Promise.all([u(t.item.projectId).catch(()=>null),te().catch(()=>[])]),a=M(t.item,r,i);A(r),be(a),L(e=>e||a[0]?.id||``)}catch(e){G(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[e]);(0,w.useEffect)(()=>{X()},[X]);let xe=(0,w.useCallback)(async()=>{if(r){U(!0),G(null);try{let e=await fe(r.id);S(e.item),t(`/chat/${encodeURIComponent(e.session.key)}`)}catch(e){G(e instanceof Error?e.message:String(e))}finally{U(!1)}}},[r,t]),Se=(0,w.useCallback)(async()=>{if(r){U(!0),G(null);try{let e=await h(r.id);S(e.item),t(`/goals/${encodeURIComponent(e.goal.id)}`)}catch(e){G(e instanceof Error?e.message:String(e))}finally{U(!1)}}},[r,t]),Z=(0,w.useCallback)(async e=>{P((await x(e).catch(()=>({events:[]}))).events)},[]),Ce=(0,w.useCallback)(async()=>{if(!(!r||!I)){U(!0),G(null);try{let e=await me(r.id,{definitionId:I,goal:R.trim()||r.nextAction||r.title});S(e.item),await Z(e.item.id),t(`/workflows?run=${encodeURIComponent(e.runId)}`)}catch(e){G(e instanceof Error?e.message:String(e))}finally{U(!1)}}},[r,t,Z,I,R]),we=(0,w.useCallback)(async e=>{if(!(!r||!e.length)){U(!0),G(null);try{let t=await v(r.id,e);S(t.item),await Z(t.item.id)}catch(e){G(e instanceof Error?e.message:String(e))}finally{U(!1)}}},[r,Z]),Te=(0,w.useCallback)(async e=>{if(r){U(!0),G(null);try{let t=await pe(r.id,e.id);S(t.item),await Z(t.item.id)}catch(e){G(e instanceof Error?e.message:String(e))}finally{U(!1)}}},[r,Z]),Ee=(0,w.useCallback)(async e=>{if(r){G(null);try{await ge(r.id,e)}catch(e){G(e instanceof Error?e.message:String(e))}}},[r]),Q=(0,w.useMemo)(()=>r?F.filter(e=>j(r,C,e)>0).slice(0,3):[],[r,C,F]),$=(0,w.useMemo)(()=>(0,T.jsxs)(l,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void X(),children:[(0,T.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:n.refreshShort})]}),[X,n.refreshShort]);return(0,w.useLayoutEffect)(()=>(q({startExtra:(0,T.jsx)(o,{to:Y,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":C?.name?n.detail.backToProject.replace(`{{name}}`,C.name):n.detail.backToProjects,children:(0,T.jsx)(d,{className:`size-4`,"aria-hidden":!0})}),main:(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(de,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:C?.name||r?.projectId||n.detail.loading})]}),(0,T.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.detail.description})]}),end:$}),()=>J()),[J,$,r?.projectId,B,C?.name,Y,q,n]),B?(0,T.jsxs)(`main`,{className:`mx-auto grid w-full max-w-6xl flex-1 gap-6 px-4 py-6 sm:px-6 lg:grid-cols-[minmax(0,1fr)_17rem] lg:px-8`,"aria-busy":!0,children:[(0,T.jsxs)(`div`,{className:`grid content-start gap-5`,children:[(0,T.jsx)(b,{className:`h-7 w-3/4`}),(0,T.jsx)(b,{className:`h-24 w-full`}),(0,T.jsx)(b,{className:`h-48 w-full`})]}),(0,T.jsx)(b,{className:`hidden h-72 w-full lg:block`})]}):r?(0,T.jsxs)(`main`,{className:`mx-auto grid w-full max-w-6xl flex-1 content-start gap-6 px-4 py-6 sm:px-6 lg:grid-cols-[minmax(0,1fr)_17rem] lg:px-8 lg:py-8`,children:[(0,T.jsxs)(`article`,{className:`min-w-0 rounded-lg border border-edge-subtle bg-surface-panel p-5 shadow-surface sm:p-7 lg:col-start-1 lg:row-start-1`,children:[W?(0,T.jsx)(`div`,{className:`mb-5 rounded-md border border-danger/30 bg-danger-soft px-3 py-2 text-sm text-danger`,children:W}):null,(0,T.jsx)(`h1`,{className:`break-words text-xl font-semibold tracking-tight text-fg`,children:r.title}),(0,T.jsxs)(`section`,{className:`mt-7`,children:[(0,T.jsx)(`h2`,{className:`text-xs font-medium text-fg-subtle`,children:n.create.descriptionLabel}),(0,T.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:r.description||n.detail.noDescription})]}),r.blockedReason?(0,T.jsxs)(`section`,{className:`mt-7 rounded-lg border border-red-500/20 bg-red-500/[0.06] px-4 py-3.5`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-red-700 dark:text-red-300`,children:[(0,T.jsx)(ae,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,T.jsx)(`h2`,{children:n.blockedReason})]}),(0,T.jsx)(`p`,{className:`mt-2 pl-6 text-sm leading-relaxed text-fg`,children:r.blockedReason})]}):null,(0,T.jsxs)(`section`,{className:`mt-7 border-t border-edge-subtle pt-6`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.nextAction}),(0,T.jsx)(`p`,{className:`mt-2 text-base leading-relaxed text-fg`,children:r.nextAction||n.noNextAction}),(0,T.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,T.jsxs)(l,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-sm`,disabled:H,onClick:xe,children:[(0,T.jsx)(m,{className:`size-4`,"aria-hidden":!0}),n.detail.startChat]}),(0,T.jsxs)(l,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3 text-sm`,disabled:H,onClick:Se,children:[(0,T.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),n.detail.createGoal]})]})]}),(0,T.jsxs)(`details`,{className:`group mt-6 border-t border-edge-subtle pt-5`,children:[(0,T.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-start gap-3 rounded-md px-1 py-1 text-left hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,T.jsx)(re,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.detail.workflowTitle}),(0,T.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:n.detail.workflowHint})]}),(0,T.jsx)(`span`,{className:`mt-0.5 text-xs text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0,children:`⌄`})]}),(0,T.jsxs)(`div`,{className:`ml-7 mt-4 grid max-w-xl gap-3`,children:[(0,T.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowTemplate,(0,T.jsxs)(y,{className:`h-9 rounded-md border border-edge bg-surface-base px-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:I,disabled:H||F.length===0,onChange:e=>L(e.target.value),children:[F.length===0?(0,T.jsx)(g,{value:``,children:n.detail.noWorkflowTemplates}):null,F.map(e=>(0,T.jsx)(g,{value:e.id,children:e.title},e.id))]})]}),Q.length?(0,T.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[n.detail.recommendedWorkflows,`: `,Q.map(e=>e.title).join(` · `)]}):null,(0,T.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowGoal,(0,T.jsx)(`textarea`,{className:`min-h-20 resize-y rounded-md border border-edge bg-surface-base p-2.5 text-sm font-normal leading-relaxed text-fg outline-none focus:border-accent`,value:R,disabled:H,onChange:e=>z(e.target.value)})]}),(0,T.jsx)(`div`,{children:(0,T.jsxs)(l,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3 text-sm`,disabled:H||!I,onClick:Ce,children:[(0,T.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),n.detail.startWorkflow]})}),F.length?null:(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.detail.noWorkflowTemplates})]})]})]}),(0,T.jsxs)(`aside`,{className:`min-w-0 self-start rounded-lg border border-edge-subtle bg-surface-panel px-4 py-4 lg:sticky lg:top-20 lg:col-start-2 lg:row-span-2 lg:row-start-1`,children:[(0,T.jsxs)(`section`,{children:[(0,T.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n.detail.properties}),(0,T.jsxs)(`dl`,{className:`mt-3 divide-y divide-edge-subtle`,children:[(0,T.jsx)(O,{label:n.detail.status,children:(0,T.jsx)(`span`,{className:s(`inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,ve(r.status)),children:n.statuses[r.status]})}),(0,T.jsx)(O,{label:n.create.priorityLabel,children:n.priorities[r.priority]}),(0,T.jsx)(O,{label:n.detail.project,children:(0,T.jsxs)(o,{to:Y,className:`flex w-full min-w-0 max-w-full items-center gap-1.5 overflow-hidden font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(he,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`block min-w-0 flex-1 truncate`,children:C?.name||r.projectId})]})}),(0,T.jsx)(O,{label:n.updated,children:E(r.updatedAt)}),r.archivedAt?(0,T.jsx)(O,{label:n.detail.archived,children:E(r.archivedAt)}):null]})]}),(0,T.jsxs)(`section`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsxs)(`h2`,{className:`inline-flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,T.jsx)(_e,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.attachments.title}),r.attachments?.length?(0,T.jsx)(`span`,{className:`text-xs font-normal text-fg-subtle`,children:r.attachments.length}):null]}),(0,T.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`,disabled:H,title:n.attachments.add,"aria-label":n.attachments.add,onClick:()=>K.current?.click(),children:(0,T.jsx)(ne,{className:`size-4`,"aria-hidden":!0})}),(0,T.jsx)(`input`,{ref:K,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{we(Array.from(e.target.files??[])),e.currentTarget.value=``}})]}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-2`,children:r.attachments?.length?r.attachments.map(e=>(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md bg-surface-base px-2 py-2 text-sm`,children:[(0,T.jsx)(f,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`div`,{className:`truncate font-medium text-fg`,children:e.fileName}),(0,T.jsx)(`div`,{className:`truncate text-xs text-fg-subtle`,children:ye(e.size)})]}),(0,T.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:n.attachments.download,"aria-label":n.attachments.download,disabled:H,onClick:()=>void Ee(e),children:(0,T.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0})}),(0,T.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:n.attachments.remove,"aria-label":n.attachments.remove,disabled:H,onClick:()=>void Te(e),children:(0,T.jsx)(se,{className:`size-3.5`,"aria-hidden":!0})})]},e.id)):(0,T.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:n.attachments.empty})})]}),(0,T.jsxs)(`section`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.links}),(0,T.jsx)(`div`,{className:`mt-2 grid gap-1 text-sm`,children:r.links?.length?r.links.map(e=>(0,T.jsxs)(o,{to:D(e),className:`flex min-w-0 items-center justify-between gap-2 rounded-md px-1 py-1.5 hover:bg-surface-hover`,children:[(0,T.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title||e.targetId}),(0,T.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[n.linkKinds[e.kind],(0,T.jsx)(le,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,T.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:n.detail.noLinks})})]})]}),(0,T.jsxs)(`section`,{className:`min-w-0 lg:col-start-1 lg:row-start-2`,children:[(0,T.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,T.jsx)(f,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.activity})]}),(0,T.jsx)(k,{events:N,t:n})]})]}):(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-6 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(o,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(d,{className:`size-4`,"aria-hidden":!0}),n.detail.backToProjects]}),(0,T.jsx)(`div`,{className:`mt-5 rounded-lg border border-danger/30 bg-danger-soft px-4 py-3 text-sm text-danger`,children:W||n.detail.notFound})]})}export{N as WorkItemDetailPage};
@@ -1,3 +1,3 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./circle-alert-BEjgurr2.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-r8L6Ur3A.js";import{n as u,o as d,r as f,s as p}from"./locale-store-DVGhFXRz.js";import{n as m}from"./activity-store-Wu2ikfbM.js";import{Ac as h,As as g,Bo as _,Fl as v,Go as y,Gs as b,Ho as x,Ks as S,Mu as C,Ns as w,Qc as T,Ru as E,To as D,Uo as O,Va as k,Vo as A,Wo as j,gc as M,hu as N,oc as P,pu as ee,ro as F,ru as te,tl as I,tt as ne,vl as L,vt as R,vu as re,zo as ie}from"./index-C1h0zkNo.js";var z=e(t(),1),B=n();function V(e){try{return decodeURIComponent(e).trim()||null}catch{return null}}function H(e){if(!e)return null;let t=e.split(/[?#]/,1)[0],n=/^\/goals\/([^/]+)\/?$/.exec(t);if(n){let e=V(n[1]);return e?{kind:`goal`,id:e}:null}let r=/^\/chat\/([^/]+)\/?$/.exec(t);if(r){let e=V(r[1]);return!e||e===`new`?null:{kind:`session`,id:e}}return null}async function U(e,t){let n=e.kind===`goal`?`/api/goals/${encodeURIComponent(e.id)}`:`/api/sessions/${encodeURIComponent(e.id)}?limit=1`;try{return(await d(f(n),{signal:t})).status===404?`missing`:`available`}catch(e){if(t?.aborted)throw e;return`available`}}var W=r(),G=3,K={info:{Icon:L,className:`text-accent-fg bg-accent-soft`},success:{Icon:ee,className:`text-success bg-success-soft`},warning:{Icon:b,className:`text-warning bg-warning-soft`},error:{Icon:s,className:`text-danger bg-danger-soft`}};function q(e,t){let n=Math.max(0,Math.round((Date.now()-e)/1e3));if(n<60)return t===`zh`?`刚刚`:`Just now`;let r=Math.round(n/60);if(r<60)return t===`zh`?`${r} 分钟前`:`${r}m ago`;let i=Math.round(r/60);if(i<24)return t===`zh`?`${i} 小时前`:`${i}h ago`;let a=Math.round(i/24);return t===`zh`?`${a} 天前`:`${a}d ago`}function J(e){let t=(0,B.c)(55),{item:n,targetAvailability:r}=e,i=u(ae),o;t[0]===i?o=t[1]:(o=l(i),t[0]=i,t[1]=o);let s=o.projectsPage.workHome,d=m(Y),{Icon:f,className:p}=K[n.tone],h;t[2]===p?h=t[3]:(h=c(`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg`,p),t[2]=p,t[3]=h);let g;t[4]!==f||t[5]!==n.status?(g=n.status===`running`?(0,W.jsx)(I,{className:`size-3.5 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,W.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[4]=f,t[5]=n.status,t[6]=g):g=t[6];let _;t[7]!==h||t[8]!==g?(_=(0,W.jsx)(`div`,{className:h,children:g}),t[7]=h,t[8]=g,t[9]=_):_=t[9];let v;t[10]===n.title?v=t[11]:(v=(0,W.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-medium leading-5 text-fg`,children:n.title}),t[10]=n.title,t[11]=v);let y;t[12]!==s.activityUnread||t[13]!==n.read?(y=n.read?null:(0,W.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-accent`,"aria-label":s.activityUnread}),t[12]=s.activityUnread,t[13]=n.read,t[14]=y):y=t[14];let b;t[15]!==v||t[16]!==y?(b=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[v,y]}),t[15]=v,t[16]=y,t[17]=b):b=t[17];let x;t[18]===n.message?x=t[19]:(x=n.message?(0,W.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.message}):null,t[18]=n.message,t[19]=x);let S;t[20]===n.source?S=t[21]:(S=n.source?(0,W.jsx)(`span`,{className:`max-w-48 truncate`,children:n.source}):null,t[20]=n.source,t[21]=S);let C;t[22]!==n.updatedAt||t[23]!==i?(C=q(n.updatedAt,i),t[22]=n.updatedAt,t[23]=i,t[24]=C):C=t[24];let T;t[25]===C?T=t[26]:(T=(0,W.jsx)(`span`,{children:C}),t[25]=C,t[26]=T);let E;t[27]===n.occurrences?E=t[28]:(E=n.occurrences>1?(0,W.jsxs)(`span`,{children:[`×`,n.occurrences]}):null,t[27]=n.occurrences,t[28]=E);let D;t[29]!==s.activityCheckingRelated||t[30]!==s.activityRelatedMissing||t[31]!==s.activityViewRelated||t[32]!==n.href||t[33]!==r?(D=n.href&&r===`available`?(0,W.jsxs)(a,{to:n.href,className:`inline-flex items-center gap-0.5 font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[s.activityViewRelated,(0,W.jsx)(N,{className:`size-3`,"aria-hidden":!0})]}):n.href&&r===`checking`?(0,W.jsx)(F,{className:`h-3 w-20 rounded`,"aria-label":s.activityCheckingRelated}):n.href&&r===`missing`?(0,W.jsx)(`span`,{className:`font-medium text-fg-subtle`,role:`status`,children:s.activityRelatedMissing}):null,t[29]=s.activityCheckingRelated,t[30]=s.activityRelatedMissing,t[31]=s.activityViewRelated,t[32]=n.href,t[33]=r,t[34]=D):D=t[34];let O;t[35]!==T||t[36]!==E||t[37]!==D||t[38]!==S?(O=(0,W.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] text-fg-subtle`,children:[S,T,E,D]}),t[35]=T,t[36]=E,t[37]=D,t[38]=S,t[39]=O):O=t[39];let k;t[40]!==O||t[41]!==b||t[42]!==x?(k=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x,O]}),t[40]=O,t[41]=b,t[42]=x,t[43]=k):k=t[43];let A;t[44]!==n.id||t[45]!==d?(A=()=>d(n.id),t[44]=n.id,t[45]=d,t[46]=A):A=t[46];let j;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,W.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t[47]=j):j=t[47];let M;t[48]!==s.activityRemove||t[49]!==A?(M=(0,W.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-hover hover:text-fg group-hover:opacity-100 focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":s.activityRemove,onClick:A,children:j}),t[48]=s.activityRemove,t[49]=A,t[50]=M):M=t[50];let P;return t[51]!==k||t[52]!==M||t[53]!==_?(P=(0,W.jsxs)(`article`,{className:`group flex items-start gap-3 border-t border-edge-subtle px-1 py-3 first:border-t-0`,children:[_,k,M]}),t[51]=k,t[52]=M,t[53]=_,t[54]=P):P=t[54],P}function Y(e){return e.remove}function ae(e){return e.language}function oe(){let e=(0,B.c)(14),t=l(u(he)).projectsPage.workHome,n=m(me),r=m(pe),i=m(fe),[a,s]=(0,z.useState)(!1),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={},e[0]=c):c=e[0];let[d,f]=(0,z.useState)(c),p;e[1]===n?p=e[2]:(p=n.filter(de),e[1]=n,e[2]=p);let h=p.length,_;e[3]===n?_=e[4]:(_=n.filter(ue),e[3]=n,e[4]=_);let v=_.length,y;e[5]!==a||e[6]!==n?(y=a?n:n.slice(0,G),e[5]=a,e[6]=n,e[7]=y):y=e[7];let b=y,x;e[8]===n?x=e[9]:(x=[...new Set(n.flatMap(le))].sort().join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./circle-alert-BEjgurr2.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-DP6tPKk-.js";import{n as u,o as d,r as f,s as p}from"./locale-store-CTwSy7yW.js";import{n as m}from"./activity-store-BzGX__8I.js";import{Ac as h,As as g,Bo as _,Fl as v,Go as y,Gs as b,Ho as x,Ks as S,Mu as C,Ns as w,Qc as T,Ru as E,To as D,Uo as O,Va as k,Vo as A,Wo as j,gc as M,hu as N,oc as P,pu as ee,ro as F,ru as te,tl as I,tt as ne,vl as L,vt as R,vu as re,zo as ie}from"./index-C0CGebQ1.js";var z=e(t(),1),B=n();function V(e){try{return decodeURIComponent(e).trim()||null}catch{return null}}function H(e){if(!e)return null;let t=e.split(/[?#]/,1)[0],n=/^\/goals\/([^/]+)\/?$/.exec(t);if(n){let e=V(n[1]);return e?{kind:`goal`,id:e}:null}let r=/^\/chat\/([^/]+)\/?$/.exec(t);if(r){let e=V(r[1]);return!e||e===`new`?null:{kind:`session`,id:e}}return null}async function U(e,t){let n=e.kind===`goal`?`/api/goals/${encodeURIComponent(e.id)}`:`/api/sessions/${encodeURIComponent(e.id)}?limit=1`;try{return(await d(f(n),{signal:t})).status===404?`missing`:`available`}catch(e){if(t?.aborted)throw e;return`available`}}var W=r(),G=3,K={info:{Icon:L,className:`text-accent-fg bg-accent-soft`},success:{Icon:ee,className:`text-success bg-success-soft`},warning:{Icon:b,className:`text-warning bg-warning-soft`},error:{Icon:s,className:`text-danger bg-danger-soft`}};function q(e,t){let n=Math.max(0,Math.round((Date.now()-e)/1e3));if(n<60)return t===`zh`?`刚刚`:`Just now`;let r=Math.round(n/60);if(r<60)return t===`zh`?`${r} 分钟前`:`${r}m ago`;let i=Math.round(r/60);if(i<24)return t===`zh`?`${i} 小时前`:`${i}h ago`;let a=Math.round(i/24);return t===`zh`?`${a} 天前`:`${a}d ago`}function J(e){let t=(0,B.c)(55),{item:n,targetAvailability:r}=e,i=u(ae),o;t[0]===i?o=t[1]:(o=l(i),t[0]=i,t[1]=o);let s=o.projectsPage.workHome,d=m(Y),{Icon:f,className:p}=K[n.tone],h;t[2]===p?h=t[3]:(h=c(`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg`,p),t[2]=p,t[3]=h);let g;t[4]!==f||t[5]!==n.status?(g=n.status===`running`?(0,W.jsx)(I,{className:`size-3.5 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,W.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[4]=f,t[5]=n.status,t[6]=g):g=t[6];let _;t[7]!==h||t[8]!==g?(_=(0,W.jsx)(`div`,{className:h,children:g}),t[7]=h,t[8]=g,t[9]=_):_=t[9];let v;t[10]===n.title?v=t[11]:(v=(0,W.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-medium leading-5 text-fg`,children:n.title}),t[10]=n.title,t[11]=v);let y;t[12]!==s.activityUnread||t[13]!==n.read?(y=n.read?null:(0,W.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-accent`,"aria-label":s.activityUnread}),t[12]=s.activityUnread,t[13]=n.read,t[14]=y):y=t[14];let b;t[15]!==v||t[16]!==y?(b=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[v,y]}),t[15]=v,t[16]=y,t[17]=b):b=t[17];let x;t[18]===n.message?x=t[19]:(x=n.message?(0,W.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.message}):null,t[18]=n.message,t[19]=x);let S;t[20]===n.source?S=t[21]:(S=n.source?(0,W.jsx)(`span`,{className:`max-w-48 truncate`,children:n.source}):null,t[20]=n.source,t[21]=S);let C;t[22]!==n.updatedAt||t[23]!==i?(C=q(n.updatedAt,i),t[22]=n.updatedAt,t[23]=i,t[24]=C):C=t[24];let T;t[25]===C?T=t[26]:(T=(0,W.jsx)(`span`,{children:C}),t[25]=C,t[26]=T);let E;t[27]===n.occurrences?E=t[28]:(E=n.occurrences>1?(0,W.jsxs)(`span`,{children:[`×`,n.occurrences]}):null,t[27]=n.occurrences,t[28]=E);let D;t[29]!==s.activityCheckingRelated||t[30]!==s.activityRelatedMissing||t[31]!==s.activityViewRelated||t[32]!==n.href||t[33]!==r?(D=n.href&&r===`available`?(0,W.jsxs)(a,{to:n.href,className:`inline-flex items-center gap-0.5 font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[s.activityViewRelated,(0,W.jsx)(N,{className:`size-3`,"aria-hidden":!0})]}):n.href&&r===`checking`?(0,W.jsx)(F,{className:`h-3 w-20 rounded`,"aria-label":s.activityCheckingRelated}):n.href&&r===`missing`?(0,W.jsx)(`span`,{className:`font-medium text-fg-subtle`,role:`status`,children:s.activityRelatedMissing}):null,t[29]=s.activityCheckingRelated,t[30]=s.activityRelatedMissing,t[31]=s.activityViewRelated,t[32]=n.href,t[33]=r,t[34]=D):D=t[34];let O;t[35]!==T||t[36]!==E||t[37]!==D||t[38]!==S?(O=(0,W.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] text-fg-subtle`,children:[S,T,E,D]}),t[35]=T,t[36]=E,t[37]=D,t[38]=S,t[39]=O):O=t[39];let k;t[40]!==O||t[41]!==b||t[42]!==x?(k=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x,O]}),t[40]=O,t[41]=b,t[42]=x,t[43]=k):k=t[43];let A;t[44]!==n.id||t[45]!==d?(A=()=>d(n.id),t[44]=n.id,t[45]=d,t[46]=A):A=t[46];let j;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,W.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t[47]=j):j=t[47];let M;t[48]!==s.activityRemove||t[49]!==A?(M=(0,W.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-hover hover:text-fg group-hover:opacity-100 focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":s.activityRemove,onClick:A,children:j}),t[48]=s.activityRemove,t[49]=A,t[50]=M):M=t[50];let P;return t[51]!==k||t[52]!==M||t[53]!==_?(P=(0,W.jsxs)(`article`,{className:`group flex items-start gap-3 border-t border-edge-subtle px-1 py-3 first:border-t-0`,children:[_,k,M]}),t[51]=k,t[52]=M,t[53]=_,t[54]=P):P=t[54],P}function Y(e){return e.remove}function ae(e){return e.language}function oe(){let e=(0,B.c)(14),t=l(u(he)).projectsPage.workHome,n=m(me),r=m(pe),i=m(fe),[a,s]=(0,z.useState)(!1),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={},e[0]=c):c=e[0];let[d,f]=(0,z.useState)(c),p;e[1]===n?p=e[2]:(p=n.filter(de),e[1]=n,e[2]=p);let h=p.length,_;e[3]===n?_=e[4]:(_=n.filter(ue),e[3]=n,e[4]=_);let v=_.length,y;e[5]!==a||e[6]!==n?(y=a?n:n.slice(0,G),e[5]=a,e[6]=n,e[7]=y):y=e[7];let b=y,x;e[8]===n?x=e[9]:(x=[...new Set(n.flatMap(le))].sort().join(`
2
2
  `),e[8]=n,e[9]=x);let C=x,w,T;e[10]===C?(w=e[11],T=e[12]):(w=()=>{let e=new AbortController,t=new Map((C?C.split(`
3
3
  `):[]).flatMap(ce));return f(Object.fromEntries([...t.keys()].map(Q))),Promise.all([...t].map(async t=>{let[n,r]=t,i=await U(r,e.signal);e.signal.aborted||f(e=>({...e,[n]:i}))})).catch(Z),()=>e.abort()},T=[C],e[10]=C,e[11]=w,e[12]=T),(0,z.useEffect)(w,T);let D;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,W.jsx)(E,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),e[13]=D):D=e[13],(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,"aria-labelledby":`workbench-activity-title`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsx)(`div`,{children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,(0,W.jsx)(`h2`,{id:`workbench-activity-title`,className:`text-sm font-semibold text-fg`,children:t.activityTitle}),h>0?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:[(0,W.jsx)(I,{className:`size-3 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),h,` `,t.running]}):v>0?(0,W.jsxs)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[v,` `,t.activityNew]}):null]})}),a&&n.length>0?(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[v>0?(0,W.jsxs)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:r,children:[(0,W.jsx)(o,{className:`size-3.5`,"aria-hidden":!0}),t.activityMarkRead]}):null,n.some(se)?(0,W.jsxs)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-fg-muted`,onClick:i,children:[(0,W.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),t.activityClearFinished]}):null]}):null]}),n.length>0?(0,W.jsxs)(`div`,{className:`mt-3 px-1`,children:[b.map(e=>(0,W.jsx)(J,{item:e,targetAvailability:e.href&&H(e.href)?d[e.href]??`checking`:`available`},e.id)),n.length>G?(0,W.jsx)(`div`,{className:`border-t border-edge-subtle py-2 text-center`,children:(0,W.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>s(X),children:a?t.activityShowLess:t.activityShowAll.replace(`{{count}}`,String(n.length))})}):null]}):(0,W.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-fg-muted`,children:[(0,W.jsx)(te,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,W.jsx)(`p`,{children:t.activityEmpty})]})]})}function X(e){return!e}function se(e){return e.status===`done`}function Z(){}function Q(e){return[e,`checking`]}function ce(e){let t=H(e);return t?[[e,t]]:[]}function le(e){return e.href&&H(e.href)?[e.href]:[]}function ue(e){return!e.read}function de(e){return e.status===`running`}function fe(e){return e.clearFinished}function pe(e){return e.markAllRead}function me(e){return e.items}function he(e){return e.language}function ge(e){return p(f(`/api/home${e?`?locale=${encodeURIComponent(e)}`:``}`))}function _e(e,t){return p(f(`/api/home/decisions/respond`),{method:`POST`,body:JSON.stringify({...e,decision:t})})}function ve(e){return p(f(`/api/home/attention/acknowledge`),{method:`POST`,body:JSON.stringify(e)})}function ye(e,t){return p(f(`/api/inbox/judgments/${encodeURIComponent(e)}/decisions`),{method:`POST`,body:JSON.stringify({choice:t})})}function be(e,t){return p(f(`/api/inbox/judgments/${encodeURIComponent(e)}/transition`),{method:`POST`,body:JSON.stringify(t===`snoozed`?{status:t,snoozedUntil:new Date(Date.now()+1440*60*1e3).toISOString()}:t===`resolved`?{status:t,resolution:`dismissed`}:{status:t})})}function xe(e,t){return p(f(`/api/inbox/judgments/${encodeURIComponent(e)}/instructions`),{method:`POST`,body:JSON.stringify({instruction:t})})}function Se(e){return p(f(`/api/home/attention/retry`),{method:`POST`,body:JSON.stringify(e)})}function Ce(e){return e===`zh`?{newWork:`交给 xopc`,dialogTitle:`现在想完成什么?`,dialogDescription:`发送后会直接进入对话,xopc 会立即开始处理。`,intentLabel:`告诉 xopc 你要做什么`,intentPlaceholder:`例如:整理这周的会议记录,提炼待办并给出下周优先级`,submit:`进入对话`,needsAttention:`需要你处理`,runAttention:`运行异常`,running:`xopc 正在处理`,continue:`继续推进`,recent:`最近对话`,projects:`长期项目`,emptyRunning:`当前没有正在处理的对话`,emptyContinue:`还没有需要继续推进的事项`,openChat:`打开对话`,whyNow:`为什么现在`,impact:`影响`,workDone:`AI 已完成`,recommendation:`建议`,snooze:`明天再看`,dismiss:`忽略`,feedbackPlaceholder:`告诉 AI:以后遇到这类情况应该怎样判断…`,applyFeedback:`调整后续判断`}:{newWork:`Ask xopc`,dialogTitle:`What do you want to get done?`,dialogDescription:`You will enter a conversation immediately and xopc will start working.`,intentLabel:`Tell xopc what you need`,intentPlaceholder:`For example: summarize this week’s meeting notes and suggest next week’s priorities`,submit:`Open conversation`,needsAttention:`Needs your attention`,runAttention:`Run issues`,running:`xopc is working`,continue:`Continue`,recent:`Recent conversations`,projects:`Long-term projects`,emptyRunning:`No conversations are running`,emptyContinue:`No ongoing items yet`,openChat:`Open conversation`,whyNow:`Why now`,impact:`Impact`,workDone:`AI checked`,recommendation:`Recommendation`,snooze:`Tomorrow`,dismiss:`Dismiss`,feedbackPlaceholder:`Tell AI how to judge this kind of event next time…`,applyFeedback:`Update future judgments`}}function we(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Te(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:R(n)}function $(e){let t=(0,B.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,W.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Ee(){let e=(0,B.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,W.jsx)(F,{className:`h-20 rounded-2xl`}),(0,W.jsx)(F,{className:`h-72 rounded-2xl`}),(0,W.jsx)(F,{className:`h-44 rounded-2xl`})]}),e[0]=t):t=e[0],t}function De(e){let t=(0,B.c)(19),{item:n,statusLabel:r}=e,i=`/work-items/${encodeURIComponent(n.id)}`,o;t[0]===n.title?o=t[1]:(o=(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=o);let s;t[2]===n.projectName?s=t[3]:(s=(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.projectName}),t[2]=n.projectName,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]===r?l=t[8]:(l=(0,W.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:r}),t[7]=r,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==n.blockedReason||t[13]!==n.nextAction?(d=n.blockedReason||n.nextAction?(0,W.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.blockedReason||n.nextAction}):null,t[12]=n.blockedReason,t[13]=n.nextAction,t[14]=d):d=t[14];let f;return t[15]!==i||t[16]!==u||t[17]!==d?(f=(0,W.jsxs)(a,{to:i,className:`group block rounded-lg px-1 py-2.5 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,d]}),t[15]=i,t[16]=u,t[17]=d,t[18]=f):f=t[18],f}function Oe(e){let t=(0,B.c)(15),{chat:n,statusLabel:r}=e,i=`/chat/${encodeURIComponent(n.key)}`,o;t[0]===n.name?o=t[1]:(o=(0,W.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.name}),t[0]=n.name,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]===n.updatedAt?l=t[8]:(l=Te(n.updatedAt,``),t[7]=n.updatedAt,t[8]=l);let u;t[9]===l?u=t[10]:(u=(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:l}),t[9]=l,t[10]=u);let d;return t[11]!==i||t[12]!==c||t[13]!==u?(d=(0,W.jsxs)(a,{to:i,className:`group block rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[c,u]}),t[11]=i,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function ke(e){let t=(0,B.c)(27),{item:n,kindLabel:r,reasonLabel:i,approveLabel:o,denyLabel:s,busy:c,onRespond:l}=e,u;t[0]===n.title?u=t[1]:(u=(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=u);let d=n.projectName||r,f;t[2]===d?f=t[3]:(f=(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:d}),t[2]=d,t[3]=f);let p;t[4]!==u||t[5]!==f?(p=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[u,f]}),t[4]=u,t[5]=f,t[6]=p):p=t[6];let m;t[7]===i?m=t[8]:(m=(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:i}),t[7]=i,t[8]=m);let h;t[9]!==p||t[10]!==m?(h=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let _;t[12]===n.detail?_=t[13]:(_=n.detail?(0,W.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.detail}):null,t[12]=n.detail,t[13]=_);let v;t[14]!==n.href||t[15]!==h||t[16]!==_?(v=(0,W.jsxs)(a,{to:n.href,className:`group block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[h,_]}),t[14]=n.href,t[15]=h,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==o||t[19]!==c||t[20]!==s||t[21]!==n.response||t[22]!==l?(y=n.response?(0,W.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2 border-t border-warning/20 pt-3`,children:[(0,W.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:c,onClick:()=>l(`deny`),children:s}),(0,W.jsx)(g,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:c,onClick:()=>l(`approve`),children:o})]}):null,t[18]=o,t[19]=c,t[20]=s,t[21]=n.response,t[22]=l,t[23]=y):y=t[23];let b;return t[24]!==v||t[25]!==y?(b=(0,W.jsxs)(`article`,{className:`rounded-xl border border-warning/35 bg-warning-soft/25 p-3.5 transition-colors hover:bg-warning-soft/40`,children:[v,y]}),t[24]=v,t[25]=y,t[26]=b):b=t[26],b}function Ae(e){let t=(0,B.c)(65),{item:n,labels:r,busy:i,onDecide:a,onSnooze:o,onDismiss:s,onInstruct:c}=e,[l,u]=(0,z.useState)(``),d=n.judgment,f;t[0]===n.title?f=t[1]:(f=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=f);let p;t[2]===n.detail?p=t[3]:(p=(0,W.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[2]=n.detail,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,W.jsx)(P,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[7]=h):h=t[7];let _;t[8]===m?_=t[9]:(_=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[m,h]}),t[8]=m,t[9]=_);let v;t[10]!==d.whyNow||t[11]!==r.whyNow?(v=[r.whyNow,d.whyNow],t[10]=d.whyNow,t[11]=r.whyNow,t[12]=v):v=t[12];let y;t[13]!==d.impact||t[14]!==r.impact?(y=[r.impact,d.impact],t[13]=d.impact,t[14]=r.impact,t[15]=y):y=t[15];let b;t[16]!==d.workDone||t[17]!==r.workDone?(b=[r.workDone,d.workDone],t[16]=d.workDone,t[17]=r.workDone,t[18]=b):b=t[18];let x;t[19]!==d.recommendation||t[20]!==r.recommendation?(x=[r.recommendation,d.recommendation],t[19]=d.recommendation,t[20]=r.recommendation,t[21]=x):x=t[21];let S;t[22]!==v||t[23]!==y||t[24]!==b||t[25]!==x?(S=(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[v,y,b,x].map(je)}),t[22]=v,t[23]=y,t[24]=b,t[25]=x,t[26]=S):S=t[26];let C;t[27]!==i||t[28]!==d.decision||t[29]!==a?(C=d.decision?(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:d.decision.question}),(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:d.decision.options.map(e=>(0,W.jsxs)(g,{type:`button`,variant:`secondary`,className:`h-auto min-h-9 flex-col items-start px-3 py-2 text-left`,disabled:i,title:e.consequence,onClick:()=>a(e.id),children:[(0,W.jsx)(`span`,{children:e.label}),(0,W.jsx)(`span`,{className:`text-[10px] font-normal text-fg-muted`,children:e.consequence})]},e.id))})]}):null,t[27]=i,t[28]=d.decision,t[29]=a,t[30]=C):C=t[30];let w;t[31]!==i||t[32]!==r.snooze||t[33]!==o?(w=(0,W.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:i,onClick:o,children:r.snooze}),t[31]=i,t[32]=r.snooze,t[33]=o,t[34]=w):w=t[34];let T;t[35]!==i||t[36]!==r.dismiss||t[37]!==s?(T=(0,W.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:i,onClick:s,children:r.dismiss}),t[35]=i,t[36]=r.dismiss,t[37]=s,t[38]=T):T=t[38];let E;t[39]!==w||t[40]!==T?(E=(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 border-t border-edge-subtle pt-3`,children:[w,T]}),t[39]=w,t[40]=T,t[41]=E):E=t[41];let D;t[42]!==l||t[43]!==c?(D=e=>{e.preventDefault();let t=l.trim();t&&(c(t),u(``))},t[42]=l,t[43]=c,t[44]=D):D=t[44];let O;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>u(e.target.value),t[45]=O):O=t[45];let k;t[46]!==l||t[47]!==r.feedbackPlaceholder?(k=(0,W.jsx)(`input`,{className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-base px-3 py-2 text-xs text-fg outline-none focus:border-accent`,value:l,onChange:O,placeholder:r.feedbackPlaceholder}),t[46]=l,t[47]=r.feedbackPlaceholder,t[48]=k):k=t[48];let A;t[49]!==i||t[50]!==l?(A=i||!l.trim(),t[49]=i,t[50]=l,t[51]=A):A=t[51];let j;t[52]!==r.applyFeedback||t[53]!==A?(j=(0,W.jsx)(g,{type:`submit`,variant:`secondary`,className:`h-9 px-3`,disabled:A,children:r.applyFeedback}),t[52]=r.applyFeedback,t[53]=A,t[54]=j):j=t[54];let M;t[55]!==D||t[56]!==k||t[57]!==j?(M=(0,W.jsxs)(`form`,{className:`mt-3 flex gap-2`,onSubmit:D,children:[k,j]}),t[55]=D,t[56]=k,t[57]=j,t[58]=M):M=t[58];let N;return t[59]!==S||t[60]!==C||t[61]!==E||t[62]!==M||t[63]!==_?(N=(0,W.jsxs)(`article`,{className:`rounded-xl border border-accent/25 bg-accent-soft/15 p-4`,children:[_,S,C,E,M]}),t[59]=S,t[60]=C,t[61]=E,t[62]=M,t[63]=_,t[64]=N):N=t[64],N}function je(e){let[t,n]=e;return(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 p-3`,children:[(0,W.jsx)(`p`,{className:`text-[11px] font-medium text-fg-subtle`,children:t}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg`,children:n})]},t)}function Me(e){let t=(0,B.c)(32),{item:n,statusLabel:r,retryLabel:i,viewLabel:o,acknowledgeLabel:s,busy:c,onView:l,onRetry:u,onAcknowledge:d}=e,f;t[0]===n.title?f=t[1]:(f=(0,W.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=f);let p;t[2]===r?p=t[3]:(p=(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-danger`,children:r}),t[2]=r,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]===n.detail?h=t[8]:(h=(0,W.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[7]=n.detail,t[8]=h);let _;t[9]!==n.href||t[10]!==m||t[11]!==h?(_=(0,W.jsxs)(a,{to:n.href,className:`block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[m,h]}),t[9]=n.href,t[10]=m,t[11]=h,t[12]=_):_=t[12];let v;t[13]!==s||t[14]!==c||t[15]!==d?(v=(0,W.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:c,onClick:d,children:s}),t[13]=s,t[14]=c,t[15]=d,t[16]=v):v=t[16];let y;t[17]!==c||t[18]!==l||t[19]!==o?(y=(0,W.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:c,onClick:l,children:o}),t[17]=c,t[18]=l,t[19]=o,t[20]=y):y=t[20];let b;t[21]!==c||t[22]!==u||t[23]!==i?(b=(0,W.jsx)(g,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:c,onClick:u,children:i}),t[21]=c,t[22]=u,t[23]=i,t[24]=b):b=t[24];let x;t[25]!==v||t[26]!==y||t[27]!==b?(x=(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2 border-t border-danger/15 pt-3`,children:[v,y,b]}),t[25]=v,t[26]=y,t[27]=b,t[28]=x):x=t[28];let S;return t[29]!==_||t[30]!==x?(S=(0,W.jsxs)(`article`,{className:`rounded-xl border border-danger/25 bg-danger-soft/35 p-3.5`,children:[_,x]}),t[29]=_,t[30]=x,t[31]=S):S=t[31],S}function Ne(e){let t=(0,B.c)(19),{project:n,openLabel:r,noDescription:i}=e,o=`/projects/${encodeURIComponent(n.id)}`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,W.jsx)(v,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[0]=s):s=t[0];let c;t[1]===n.name?c=t[2]:(c=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.name})]}),t[1]=n.name,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,W.jsx)(C,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-label":r}),t[3]=r,t[4]=l);let u;t[5]!==c||t[6]!==l?(u=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[c,l]}),t[5]=c,t[6]=l,t[7]=u):u=t[7];let d=n.description||n.brief||i,f;t[8]===d?f=t[9]:(f=(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-5 text-fg-muted`,children:d}),t[8]=d,t[9]=f);let p=n.lastActiveAt??n.updatedAt,m;t[10]===p?m=t[11]:(m=Te(p,``),t[10]=p,t[11]=m);let h;t[12]===m?h=t[13]:(h=(0,W.jsx)(`p`,{className:`mt-auto pt-3 text-[11px] text-fg-subtle`,children:m}),t[12]=m,t[13]=h);let g;return t[14]!==o||t[15]!==h||t[16]!==u||t[17]!==f?(g=(0,W.jsxs)(a,{to:o,className:`group flex min-h-32 flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,f,h]}),t[14]=o,t[15]=h,t[16]=u,t[17]=f,t[18]=g):g=t[18],g}function Pe(){let e=u(e=>e.language),t=l(e),n=t.projectsPage,r=Ce(e),o=i(),c=D(e=>e.setPageHeader),d=D(e=>e.clearPageHeader),[f,p]=(0,z.useState)(null),[m,v]=(0,z.useState)([]),[b,S]=(0,z.useState)(!0),[C,E]=(0,z.useState)(null),[N,ee]=(0,z.useState)(``),[F,I]=(0,z.useState)(!1),[L,R]=(0,z.useState)(``),[B,V]=(0,z.useState)(null),[H,U]=(0,z.useState)(null),G=(0,z.useCallback)(async(t=!1)=>{t&&S(!0),E(null);try{let[t,n]=await Promise.all([ge(e),k({limit:100,sortBy:`updatedAt`,sortOrder:`desc`})]);p(t),v(n.items)}catch(e){E(e instanceof Error?e.message:String(e))}finally{S(!1)}},[e]);(0,z.useEffect)(()=>{G(!0)},[G]),(0,z.useEffect)(()=>{let e,t=t=>{e!==void 0&&window.clearTimeout(e),e=window.setTimeout(()=>{e=void 0,G()},t)},n=()=>t(100),r=()=>t(750),i=[`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`],a=[`session-updated`,`session-transcript-updated`];return i.forEach(e=>window.addEventListener(e,n)),a.forEach(e=>window.addEventListener(e,r)),()=>{i.forEach(e=>window.removeEventListener(e,n)),a.forEach(e=>window.removeEventListener(e,r)),e!==void 0&&window.clearTimeout(e)}},[G]);let K=(0,z.useMemo)(()=>{let e=N.trim().toLocaleLowerCase(),t=m.filter(e=>e.status!==`archived`);return e?t.filter(t=>[t.name,t.description,t.brief].filter(Boolean).some(t=>t.toLocaleLowerCase().includes(e))):t.slice(0,6)},[m,N]),q=(0,z.useMemo)(()=>f?.decisions??[],[f]),J=(0,z.useMemo)(()=>f?.attention??[],[f]),Y=(0,z.useMemo)(()=>f?.work.current.filter(e=>e.status!==`needs_input`&&e.status!==`in_review`&&e.status!==`blocked`).slice(0,10)??[],[f]),ae=(0,z.useCallback)(e=>{e.preventDefault();let t=L.trim();t&&(R(``),I(!1),o({pathname:`/chat/new`,search:`?${new URLSearchParams({draft:t,autoSend:`1`}).toString()}`},{state:{forceNewChat:!0}}))},[o,L]),X=(0,z.useMemo)(()=>(0,W.jsxs)(g,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>I(!0),children:[(0,W.jsx)(h,{className:`size-4`,"aria-hidden":!0}),r.newWork]}),[r.newWork]),se=(0,z.useCallback)(async(e,t)=>{if(e.response){V(e.id),E(null);try{await _e(e.response,t),await G()}catch(e){E(e instanceof Error?e.message:String(e))}finally{V(null)}}},[G]),Z=(0,z.useCallback)(async(e,t)=>{V(e.id),E(null);try{await t(),await G()}catch(e){E(e instanceof Error?e.message:String(e))}finally{V(null)}},[G]),Q=(0,z.useCallback)(async(e,t)=>{U(e.id),E(null);try{await t({kind:e.kind,runId:e.runId}),await G()}catch(e){E(e instanceof Error?e.message:String(e))}finally{U(null)}},[G]);return(0,z.useLayoutEffect)(()=>(c({startExtra:null,main:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,W.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.workHome.subtitle})]}),end:X}),()=>d()),[d,X,c,n.title,n.workHome.subtitle]),(0,W.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1200px] flex-1 flex-col gap-7 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,W.jsx)(ie,{open:F,onOpenChange:I,children:(0,W.jsxs)(j,{children:[(0,W.jsx)(O,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,W.jsxs)(A,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(y,{className:`text-base font-semibold text-fg`,children:r.dialogTitle}),(0,W.jsx)(x,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:r.dialogDescription})]}),(0,W.jsx)(_,{asChild:!0,children:(0,W.jsx)(g,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:n.cancel,"aria-label":n.cancel,children:(0,W.jsx)(w,{className:`size-4`,"aria-hidden":!0})})})]}),(0,W.jsxs)(`form`,{onSubmit:ae,className:`flex min-h-0 flex-1 flex-col`,children:[(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,children:[(0,W.jsx)(`label`,{htmlFor:`new-work-outcome`,className:`mb-2 shrink-0 text-sm font-medium text-fg`,children:r.intentLabel}),(0,W.jsx)(`textarea`,{id:`new-work-outcome`,className:`min-h-32 w-full flex-1 resize-none rounded-xl border border-edge bg-surface-base p-3 text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,value:L,onChange:e=>R(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:r.intentPlaceholder,maxLength:12e3,autoFocus:!0}),(0,W.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,W.jsx)(`span`,{children:n.workHome.submitShortcut}),(0,W.jsxs)(`span`,{className:`tabular-nums`,children:[L.length.toLocaleString(),` / `,12e3.toLocaleString()]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,W.jsx)(_,{asChild:!0,children:(0,W.jsx)(g,{type:`button`,variant:`ghost`,children:n.cancel})}),(0,W.jsxs)(g,{type:`submit`,variant:`primary`,className:`min-w-32`,disabled:!L.trim(),children:[(0,W.jsx)(P,{className:`size-4`,"aria-hidden":!0}),r.submit]})]})]})]})]})}),C?(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,W.jsx)(`span`,{children:C}),(0,W.jsx)(g,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void G(),children:n.workHome.retry})]}):null,b?(0,W.jsx)(Ee,{}):f?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`section`,{className:`border-b border-edge-subtle pb-5`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:n.workHome.briefingTitle}),(0,W.jsx)(`h2`,{className:`mt-1 text-xl font-semibold tracking-tight text-fg`,children:f.decisions.length+f.attention.length>0?we(n.workHome.todaySummary,{attention:f.decisions.length+f.attention.length,moving:f.briefing.progress.movingCount+f.chats.running.length}):we(n.workHome.todaySummaryClear,{moving:f.briefing.progress.movingCount+f.chats.running.length})}),f.briefing.summary?(0,W.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-fg-muted`,children:f.briefing.summary}):null]}),f.work.current.length===0&&f.workflowRuns.active.length===0&&f.decisions.length===0&&f.attention.length===0&&f.chats.running.length===0&&f.chats.recent.length===0&&f.upcomingAutomations.length===0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,W.jsx)(T,{className:`mx-auto size-6 text-accent`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:n.workHome.emptyTitle}),(0,W.jsx)(`p`,{className:`mx-auto mt-1 max-w-lg text-sm leading-6 text-fg-muted`,children:n.workHome.emptyBody}),(0,W.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,W.jsx)(g,{type:`button`,variant:`primary`,onClick:()=>o(`/chat/new`),children:n.workHome.startChat}),(0,W.jsx)(g,{type:`button`,variant:`secondary`,onClick:()=>I(!0),children:r.newWork})]})]}):null,(0,W.jsxs)(`div`,{className:`grid items-start gap-6 xl:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[J.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(s,{className:`size-4 text-danger`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r.runAttention}),(0,W.jsx)($,{children:J.length.toLocaleString()})]}),(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:J.map(e=>(0,W.jsx)(Me,{item:e,statusLabel:e.reason===`run_timeout`?n.workHome.attentionTimeout:n.workHome.attentionFailed,retryLabel:n.workHome.attentionRetry,viewLabel:n.workHome.attentionView,acknowledgeLabel:n.workHome.attentionAcknowledge,busy:H===e.id,onView:()=>o(e.href),onRetry:()=>void Q(e,Se),onAcknowledge:()=>void Q(e,ve)},e.id))})]}):null,q.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(s,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r.needsAttention}),(0,W.jsx)($,{children:q.length.toLocaleString()})]}),(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:q.map(e=>e.kind===`agent_judgment`&&e.judgment?(0,W.jsx)(Ae,{item:e,labels:r,busy:B===e.id,onDecide:t=>void Z(e,()=>ye(e.judgment.inboxItemId,t)),onSnooze:()=>void Z(e,()=>be(e.judgment.inboxItemId,`snoozed`)),onDismiss:()=>void Z(e,()=>be(e.judgment.inboxItemId,`resolved`)),onInstruct:t=>void Z(e,()=>xe(e.judgment.inboxItemId,t))},e.id):(0,W.jsx)(ke,{item:e,kindLabel:n.workHome.decisionKinds[e.kind],reasonLabel:n.workHome.decisionReasons[e.reason],approveLabel:n.workHome.approve,denyLabel:n.workHome.deny,busy:B===e.id,onRespond:t=>void se(e,t)},e.id))})]}):(0,W.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,W.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-success-soft text-xs text-success`,"aria-hidden":!0,children:`✓`}),n.workHome.nothingNeedsYou]}),(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(P,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r.running}),(0,W.jsx)($,{children:(f.chats.running.length+f.workflowRuns.active.length).toLocaleString()})]}),(0,W.jsxs)(`div`,{className:`mt-4 divide-y divide-edge-subtle px-1`,children:[f.chats.running.map(e=>(0,W.jsx)(`div`,{className:`py-1`,children:(0,W.jsx)(Oe,{chat:e,statusLabel:n.workHome.running})},e.key)),f.workflowRuns.active.map(e=>(0,W.jsxs)(a,{to:ne(e.id),className:`flex items-center justify-between gap-3 rounded-lg px-2 py-3 text-sm hover:bg-surface-hover/55`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-accent`,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.title})]}),(0,W.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.workHome.running})]},e.id)),f.chats.running.length===0&&f.workflowRuns.active.length===0?(0,W.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:r.emptyRunning}):null]})]}),(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(te,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r.continue}),(0,W.jsx)($,{children:Y.length.toLocaleString()})]}),(0,W.jsxs)(`div`,{className:`mt-4 divide-y divide-edge-subtle px-1`,children:[Y.map(e=>(0,W.jsx)(`div`,{className:`py-1`,children:(0,W.jsx)(De,{item:e,statusLabel:t.projectDetailPage.workItems.statuses[e.status]})},e.id)),Y.length===0?(0,W.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:r.emptyContinue}):null]})]}),f.chats.recent.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,W.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r.recent})}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:f.chats.recent.slice(0,6).map(e=>(0,W.jsx)(Oe,{chat:e,statusLabel:r.openChat},e.key))})]}):null]}),(0,W.jsxs)(`aside`,{className:`min-w-0 space-y-4`,"aria-label":n.workHome.nowTitle,children:[(0,W.jsx)(`div`,{className:`px-1`,children:(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.workHome.nowTitle})}),f.upcomingAutomations.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(re,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.workHome.scheduled})]}),(0,W.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle`,children:f.upcomingAutomations.slice(0,3).map(e=>(0,W.jsxs)(a,{to:`/automations`,className:`flex items-center justify-between gap-3 rounded-lg px-1 py-3 text-sm hover:bg-surface-hover/55`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.name||e.action}),(0,W.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:Te(e.nextRunAt,n.never)})]},e.id))})]}):null,(0,W.jsx)(oe,{}),f.briefing.wins.length>0?(0,W.jsxs)(a,{to:f.briefing.wins[0].href,className:`flex items-center justify-between gap-3 rounded-xl px-2 py-2 text-sm text-fg-muted hover:bg-surface-hover/55 hover:text-fg`,children:[(0,W.jsx)(`span`,{children:we(n.workHome.completedSummary,{count:f.briefing.wins.length})}),(0,W.jsxs)(`span`,{className:`shrink-0 text-xs font-medium text-accent`,children:[n.workHome.viewLatestResult,` →`]})]}):null]})]})]}):null,(0,W.jsxs)(`section`,{className:`border-t border-edge-subtle pt-7`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.projects}),(0,W.jsx)(a,{to:`/projects`,className:`text-xs font-medium text-accent hover:underline`,children:n.management.viewAll})]}),m.filter(e=>e.status!==`archived`).length>6?(0,W.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,W.jsxs)(`label`,{className:`relative block min-w-0`,children:[(0,W.jsx)(M,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,W.jsx)(`input`,{className:`h-9 w-52 rounded-lg border border-edge bg-surface-panel pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:N,onChange:e=>ee(e.target.value),placeholder:n.searchPlaceholder,"aria-label":n.searchPlaceholder})]})}):null,(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:K.map(e=>(0,W.jsx)(Ne,{project:e,openLabel:n.workHome.openSpace,noDescription:n.noDescription},e.id))}),!b&&K.length===0?(0,W.jsx)(`p`,{className:`py-8 text-center text-sm text-fg-muted`,children:n.workHome.noSpaces}):null]})]})}export{Pe as WorkPage};
@@ -1,3 +1,3 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-r8L6Ur3A.js";import{o,r as s}from"./locale-store-DVGhFXRz.js";import{As as c,Bo as l,Bs as u,Cc as d,G as f,Go as p,Ji as m,Ns as h,Ul as g,Uo as _,Vo as v,Wo as y,X as b,Xs as x,_u as S,cc as C,gt as w,hl as T,ht as E,ic as D,is as O,ns as k,oc as A,ot as j,zo as M}from"./index-C1h0zkNo.js";var N=e(t(),1),P=n();function F(e){if(!e.trim())return null;try{return JSON.parse(e)}catch{return null}}function I(e){return typeof e.message==`string`&&e.message.trim()?e.message:typeof e.error==`string`&&e.error.trim()?e.error:e.error&&typeof e.error==`object`&&typeof e.error.message==`string`?e.error.message:`AI suggestion failed`}function L(e,t={}){let n=F(e.split(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-DP6tPKk-.js";import{o,r as s}from"./locale-store-CTwSy7yW.js";import{As as c,Bo as l,Bs as u,Cc as d,G as f,Go as p,Ji as m,Ns as h,Ul as g,Uo as _,Vo as v,Wo as y,X as b,Xs as x,_u as S,cc as C,gt as w,hl as T,ht as E,ic as D,is as O,ns as k,oc as A,ot as j,zo as M}from"./index-C0CGebQ1.js";var N=e(t(),1),P=n();function F(e){if(!e.trim())return null;try{return JSON.parse(e)}catch{return null}}function I(e){return typeof e.message==`string`&&e.message.trim()?e.message:typeof e.error==`string`&&e.error.trim()?e.error:e.error&&typeof e.error==`object`&&typeof e.error.message==`string`?e.error.message:`AI suggestion failed`}function L(e,t={}){let n=F(e.split(`
2
2
  `).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
3
3
  `));if(!n)return null;if(n.type===`text_delta`&&typeof n.delta==`string`)return t.onDelta?.(n.delta),null;if(n.type===`thinking_delta`&&typeof n.delta==`string`)return t.onThinkingDelta?.(n.delta),null;if(n.type===`done`&&typeof n.text==`string`)return n.text;if(n.type===`error`)throw Error(I(n));return null}async function R(e,t={}){let n=await o(s(`/api/ai/text-assist`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify(e)});if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message;throw Error(t||`AI suggestion failed (${n.status})`)}if(!n.body){let e=await n.json().catch(()=>null);if(e?.text)return e;throw Error(`AI suggestion stream is empty`)}let r=n.body.getReader(),i=new TextDecoder,a=``,c=``,l=``;for(;;){let{done:e,value:n}=await r.read();if(n){a+=i.decode(n,{stream:!e});let r=a.split(/\r?\n\r?\n/);a=r.pop()??``;for(let e of r){let n=L(e,{onDelta:e=>{c+=e,t.onDelta?.(e)},onThinkingDelta:e=>{l+=e,t.onThinkingDelta?.(e)}});n!==null&&(c=n)}}if(e)break}if(a.trim()){let e=L(a,{onDelta:e=>{c+=e,t.onDelta?.(e)},onThinkingDelta:e=>{l+=e,t.onThinkingDelta?.(e)}});e!==null&&(c=e)}let u=c.trim();if(!u)throw Error(`AI returned an empty suggestion`);return{text:u,thinking:l.trim()||void 0}}function ee(){let[e,t]=(0,N.useState)(``),[n,r]=(0,N.useState)(``),[i,a]=(0,N.useState)(!1),[o,s]=(0,N.useState)(null);return{suggestion:e,thinking:n,loading:i,error:o,generate:(0,N.useCallback)(async e=>{a(!0),s(null),t(``),r(``);try{let n=await R(e,{onDelta:e=>{t(t=>t+e)},onThinkingDelta:e=>{r(t=>t+e)}});return t(n.text),r(n.thinking??``),n.text}catch(e){return s(e instanceof Error?e.message:`AI suggestion failed`),null}finally{a(!1)}},[]),reset:(0,N.useCallback)(()=>{t(``),r(``),s(null),a(!1)},[])}}var z=r(),te=5;function ne(e){return e.startsWith(`zh`)?{title:`AI 优化文案`,buttonTitle:`优化文案`,current:`当前内容`,suggestion:`AI 建议`,editedSuggestion:`审核并编辑建议`,thinking:`模型思考`,thinkingLoading:`思考中`,edit:`编辑`,preview:`预览`,loading:`正在生成建议...`,empty:`暂无内容`,generate:`生成建议`,regenerate:`重新生成`,applyCurrent:`应用当前内容`,replace:`替换`,append:`追加`,cancel:`取消`,close:`关闭`}:{title:`AI text assist`,buttonTitle:`Improve text`,current:`Current`,suggestion:`Suggestion`,editedSuggestion:`Review and edit suggestion`,thinking:`Model thinking`,thinkingLoading:`Thinking`,edit:`Edit`,preview:`Preview`,loading:`Generating suggestion...`,empty:`No content`,generate:`Generate suggestion`,regenerate:`Regenerate`,applyCurrent:`Apply current`,replace:`Replace`,append:`Append`,cancel:`Cancel`,close:`Close`}}function B(e){let t=(0,P.c)(239),{value:n,onApply:r,fieldId:a,fieldLabel:o,scenario:s,format:u,intent:f,locale:b,context:x,disabled:C,className:w,showLabel:T}=e,E=s===void 0?`generic.text`:s,O=u===void 0?`plain`:u,k=f===void 0?`improve`:f,j=T===void 0?!0:T,[F,I]=(0,N.useState)(!1),[L,R]=(0,N.useState)(n),[B,V]=(0,N.useState)(`preview`),[H,U]=(0,N.useState)(``),[W,ae]=(0,N.useState)(`edit`),[G,K]=(0,N.useState)(!0),[oe,se]=(0,N.useState)(!1),[ce,q]=(0,N.useState)(null),le=(0,N.useRef)(null),ue=(0,N.useRef)(!0),{suggestion:de,thinking:J,loading:Y,error:X,generate:fe,reset:pe}=ee(),me;t[0]===b?me=t[1]:(me=ne(b),t[0]=b,t[1]=me);let Z=me,he;t[2]!==Y||t[3]!==J?(he=Y&&J.trim().length>0,t[2]=Y,t[3]=J,t[4]=he):he=t[4];let Q=he,ge,_e;t[5]!==F||t[6]!==n?(ge=()=>{F||R(n)},_e=[F,n],t[5]=F,t[6]=n,t[7]=ge,t[8]=_e):(ge=t[7],_e=t[8]),(0,N.useEffect)(ge,_e);let ve,ye;t[9]===de?(ve=t[10],ye=t[11]):(ye=()=>{U(de)},ve=[de],t[9]=de,t[10]=ve,t[11]=ye),(0,N.useEffect)(ye,ve);let be,xe;t[12]===J?(be=t[13],xe=t[14]):(be=()=>{J.trim()&&K(!0)},xe=[J],t[12]=J,t[13]=be,t[14]=xe),(0,N.useEffect)(be,xe);let Se;t[15]!==Q||t[16]!==G?(Se=()=>{let e=le.current;!e||!Q||!G||ue.current&&(e.scrollTop=e.scrollHeight)},t[15]=Q,t[16]=G,t[17]=Se):Se=t[17];let Ce;t[18]!==Q||t[19]!==J||t[20]!==G?(Ce=[Q,J,G],t[18]=Q,t[19]=J,t[20]=G,t[21]=Ce):Ce=t[21],(0,N.useLayoutEffect)(Se,Ce);let we;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(we=()=>{let e=le.current;e&&(ue.current=e.scrollHeight-e.scrollTop-e.clientHeight<=te)},t[22]=we):we=t[22];let Te=we,Ee;t[23]!==x||t[24]!==a||t[25]!==o||t[26]!==O||t[27]!==fe||t[28]!==k||t[29]!==b||t[30]!==E?(Ee=async e=>{ae(`edit`),K(!0),ue.current=!0,await fe({intent:k,scenario:E,input:e,locale:b,field:{id:a,label:o,format:O},context:x})},t[23]=x,t[24]=a,t[25]=o,t[26]=O,t[27]=fe,t[28]=k,t[29]=b,t[30]=E,t[31]=Ee):Ee=t[31];let De=Ee,Oe;t[32]!==pe||t[33]!==n?(Oe=e=>{se(!!e.currentTarget.closest(`[role="dialog"]`)),q(document.querySelector(`.app-main-surface`)),R(n),V(`preview`),U(``),ae(`edit`),K(!0),pe(),I(!0)},t[32]=pe,t[33]=n,t[34]=Oe):Oe=t[34];let ke=Oe,Ae;t[35]!==L||t[36]!==De?(Ae=async()=>{await De(L)},t[35]=L,t[36]=De,t[37]=Ae):Ae=t[37];let je=Ae,Me;t[38]!==pe||t[39]!==n?(Me=()=>{I(!1),R(n),V(`preview`),U(``),ae(`edit`),K(!0),pe()},t[38]=pe,t[39]=n,t[40]=Me):Me=t[40];let $=Me,Ne;t[41]!==$||t[42]!==L||t[43]!==r?(Ne=()=>{r(L),$()},t[41]=$,t[42]=L,t[43]=r,t[44]=Ne):Ne=t[44];let Pe=Ne,Fe;t[45]!==$||t[46]!==H||t[47]!==r?(Fe=()=>{H.trim()&&(r(H),$())},t[45]=$,t[46]=H,t[47]=r,t[48]=Fe):Fe=t[48];let Ie=Fe,Le;t[49]!==$||t[50]!==L||t[51]!==H||t[52]!==r?(Le=()=>{if(!H.trim())return;let e=L.trimEnd();r(e?`${e}\n\n${H}`:H),$()},t[49]=$,t[50]=L,t[51]=H,t[52]=r,t[53]=Le):Le=t[53];let Re=Le,ze;t[54]!==H||t[55]!==X||t[56]!==Y?(ze=!Y&&!X&&H.trim().length>0,t[54]=H,t[55]=X,t[56]=Y,t[57]=ze):ze=t[57];let Be=ze,Ve=L!==n,He;t[58]!==H||t[59]!==X||t[60]!==J?(He=H.trim().length>0||J.trim().length>0||!!X,t[58]=H,t[59]=X,t[60]=J,t[61]=He):He=t[61];let Ue=He,We=!j&&`size-7 p-0`,Ge;t[62]!==w||t[63]!==We?(Ge=i(`h-7 gap-1 px-2 text-xs`,We,w),t[62]=w,t[63]=We,t[64]=Ge):Ge=t[64];let Ke=C||Y,qe;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,z.jsx)(A,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[65]=qe):qe=t[65];let Je=j?Z.buttonTitle:null,Ye;t[66]!==Z.buttonTitle||t[67]!==ke||t[68]!==Ge||t[69]!==Ke||t[70]!==Je?(Ye=(0,z.jsxs)(c,{type:`button`,variant:`ghost`,className:Ge,title:Z.buttonTitle,"aria-label":Z.buttonTitle,disabled:Ke,onClick:ke,children:[qe,Je]}),t[66]=Z.buttonTitle,t[67]=ke,t[68]=Ge,t[69]=Ke,t[70]=Je,t[71]=Ye):Ye=t[71];let Xe;t[72]===$?Xe=t[73]:(Xe=e=>e?I(!0):$(),t[72]=$,t[73]=Xe);let Ze=ce??void 0,Qe=oe?`bg-transparent`:`bg-scrim`,$e;t[74]===Qe?$e=t[75]:($e=i(`xopc-dialog-overlay absolute inset-0 z-[80]`,Qe),t[74]=Qe,t[75]=$e);let et;t[76]===$e?et=t[77]:(et=(0,z.jsx)(_,{className:$e}),t[76]=$e,t[77]=et);let tt;t[78]===Z.title?tt=t[79]:(tt=(0,z.jsx)(p,{className:`text-base font-semibold text-fg`,children:Z.title}),t[78]=Z.title,t[79]=tt);let nt;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(nt=(0,z.jsx)(h,{className:`size-5`,strokeWidth:1.75}),t[80]=nt):nt=t[80];let rt;t[81]===Z.close?rt=t[82]:(rt=(0,z.jsx)(l,{asChild:!0,children:(0,z.jsx)(c,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":Z.close,children:nt})}),t[81]=Z.close,t[82]=rt);let it;t[83]!==tt||t[84]!==rt?(it=(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[tt,rt]}),t[83]=tt,t[84]=rt,t[85]=it):it=t[85];let at;t[86]===Z.current?at=t[87]:(at=(0,z.jsx)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:Z.current}),t[86]=Z.current,t[87]=at);let ot=B===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,st;t[88]===ot?st=t[89]:(st=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,ot),t[88]=ot,t[89]=st);let ct,lt;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(ct=()=>V(`edit`),lt=(0,z.jsx)(D,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[90]=ct,t[91]=lt):(ct=t[90],lt=t[91]);let ut;t[92]!==Z.edit||t[93]!==st?(ut=(0,z.jsxs)(`button`,{type:`button`,className:st,onClick:ct,children:[lt,Z.edit]}),t[92]=Z.edit,t[93]=st,t[94]=ut):ut=t[94];let dt=B===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,ft;t[95]===dt?ft=t[96]:(ft=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,dt),t[95]=dt,t[96]=ft);let pt,mt;t[97]===Symbol.for(`react.memo_cache_sentinel`)?(pt=()=>V(`preview`),mt=(0,z.jsx)(g,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[97]=pt,t[98]=mt):(pt=t[97],mt=t[98]);let ht;t[99]!==Z.preview||t[100]!==ft?(ht=(0,z.jsxs)(`button`,{type:`button`,className:ft,onClick:pt,children:[mt,Z.preview]}),t[99]=Z.preview,t[100]=ft,t[101]=ht):ht=t[101];let gt;t[102]!==ut||t[103]!==ht?(gt=(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[ut,ht]}),t[102]=ut,t[103]=ht,t[104]=gt):gt=t[104];let _t;t[105]!==at||t[106]!==gt?(_t=(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[at,gt]}),t[105]=at,t[106]=gt,t[107]=_t):_t=t[107];let vt;t[108]!==L||t[109]!==B||t[110]!==O||t[111]!==Z.current||t[112]!==Z.empty?(vt=B===`preview`?(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:O===`markdown`?(0,z.jsx)(m,{content:L||Z.empty,compact:!0,className:`text-sm`}):(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:L||Z.empty})}):(0,z.jsx)(`textarea`,{className:`min-h-0 flex-1 resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25`,value:L,onChange:e=>R(e.currentTarget.value),placeholder:Z.empty,"aria-label":Z.current}),t[108]=L,t[109]=B,t[110]=O,t[111]=Z.current,t[112]=Z.empty,t[113]=vt):vt=t[113];let yt;t[114]!==_t||t[115]!==vt?(yt=(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[_t,vt]}),t[114]=_t,t[115]=vt,t[116]=yt):yt=t[116];let bt;t[117]===Z.editedSuggestion?bt=t[118]:(bt=(0,z.jsx)(`span`,{children:Z.editedSuggestion}),t[117]=Z.editedSuggestion,t[118]=bt);let xt;t[119]!==Z.loading||t[120]!==Y?(xt=Y?(0,z.jsx)(`span`,{className:`ml-2 font-normal`,children:Z.loading}):null,t[119]=Z.loading,t[120]=Y,t[121]=xt):xt=t[121];let St;t[122]!==bt||t[123]!==xt?(St=(0,z.jsxs)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:[bt,xt]}),t[122]=bt,t[123]=xt,t[124]=St):St=t[124];let Ct=W===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,wt;t[125]===Ct?wt=t[126]:(wt=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,Ct),t[125]=Ct,t[126]=wt);let Tt,Et;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(Tt=()=>ae(`edit`),Et=(0,z.jsx)(D,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[127]=Tt,t[128]=Et):(Tt=t[127],Et=t[128]);let Dt;t[129]!==Z.edit||t[130]!==wt?(Dt=(0,z.jsxs)(`button`,{type:`button`,className:wt,onClick:Tt,children:[Et,Z.edit]}),t[129]=Z.edit,t[130]=wt,t[131]=Dt):Dt=t[131];let Ot=W===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,kt;t[132]===Ot?kt=t[133]:(kt=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,Ot),t[132]=Ot,t[133]=kt);let At,jt;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(At=()=>ae(`preview`),jt=(0,z.jsx)(g,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[134]=At,t[135]=jt):(At=t[134],jt=t[135]);let Mt;t[136]!==Z.preview||t[137]!==kt?(Mt=(0,z.jsxs)(`button`,{type:`button`,className:kt,onClick:At,children:[jt,Z.preview]}),t[136]=Z.preview,t[137]=kt,t[138]=Mt):Mt=t[138];let Nt;t[139]!==Dt||t[140]!==Mt?(Nt=(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[Dt,Mt]}),t[139]=Dt,t[140]=Mt,t[141]=Nt):Nt=t[141];let Pt;t[142]!==St||t[143]!==Nt?(Pt=(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[St,Nt]}),t[142]=St,t[143]=Nt,t[144]=Pt):Pt=t[144];let Ft=Q?`opacity-100`:`pointer-events-none opacity-0`,It;t[145]===Ft?It=t[146]:(It=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Ft),t[145]=Ft,t[146]=It);let Lt=!Q,Rt;t[147]===Symbol.for(`react.memo_cache_sentinel`)?(Rt=()=>K(re),t[147]=Rt):Rt=t[147];let zt;t[148]!==Z.thinkingLoading||t[149]!==Y?(zt=Y?(0,z.jsxs)(`span`,{className:`ml-1 font-normal`,children:[`· `,Z.thinkingLoading]}):null,t[148]=Z.thinkingLoading,t[149]=Y,t[150]=zt):zt=t[150];let Bt;t[151]!==Z.thinking||t[152]!==zt?(Bt=(0,z.jsxs)(`span`,{className:`min-w-0 truncate`,children:[Z.thinking,zt]}),t[151]=Z.thinking,t[152]=zt,t[153]=Bt):Bt=t[153];let Vt=G&&`rotate-180`,Ht;t[154]===Vt?Ht=t[155]:(Ht=i(`size-3.5 shrink-0 transition-transform`,Vt),t[154]=Vt,t[155]=Ht);let Ut;t[156]===Ht?Ut=t[157]:(Ut=(0,z.jsx)(S,{className:Ht,strokeWidth:1.75,"aria-hidden":!0}),t[156]=Ht,t[157]=Ut);let Wt;t[158]!==Bt||t[159]!==Ut?(Wt=(0,z.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center justify-between gap-2 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:text-fg`,onClick:Rt,children:[Bt,Ut]}),t[158]=Bt,t[159]=Ut,t[160]=Wt):Wt=t[160];let Gt;t[161]!==J||t[162]!==G?(Gt=G?(0,z.jsx)(`pre`,{ref:le,className:`min-h-0 flex-1 overflow-auto border-t border-edge px-2.5 py-2 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,onScroll:Te,children:J}):null,t[161]=J,t[162]=G,t[163]=Gt):Gt=t[163];let Kt;t[164]!==Wt||t[165]!==Gt?(Kt=(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col rounded-lg border border-edge bg-surface-muted/70`,children:[Wt,Gt]}),t[164]=Wt,t[165]=Gt,t[166]=Kt):Kt=t[166];let qt;t[167]!==It||t[168]!==Lt||t[169]!==Kt?(qt=(0,z.jsx)(`div`,{className:It,"aria-hidden":Lt,children:Kt}),t[167]=It,t[168]=Lt,t[169]=Kt,t[170]=qt):qt=t[170];let Jt=Q?`pointer-events-none opacity-0`:`opacity-100`,Yt;t[171]===Jt?Yt=t[172]:(Yt=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Jt),t[171]=Jt,t[172]=Yt);let Xt;t[173]!==H||t[174]!==X||t[175]!==O||t[176]!==Z.empty||t[177]!==Z.loading||t[178]!==Z.suggestion||t[179]!==Y||t[180]!==W?(Xt=X?(0,z.jsx)(`pre`,{className:`h-full min-h-0 overflow-auto whitespace-pre-wrap rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg-muted`,children:X}):W===`preview`?(0,z.jsx)(`div`,{className:`h-full min-h-0 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:Y&&!H.trim()?(0,z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Z.loading}):O===`markdown`?(0,z.jsx)(m,{content:H||Z.empty,compact:!0,className:`text-sm`}):(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:H||Z.empty})}):(0,z.jsx)(`textarea`,{className:`h-full min-h-0 w-full resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25 disabled:text-fg-muted`,value:H,onChange:e=>U(e.currentTarget.value),disabled:Y,placeholder:Y?Z.loading:Z.empty,"aria-label":Z.suggestion}),t[173]=H,t[174]=X,t[175]=O,t[176]=Z.empty,t[177]=Z.loading,t[178]=Z.suggestion,t[179]=Y,t[180]=W,t[181]=Xt):Xt=t[181];let Zt;t[182]!==Yt||t[183]!==Xt?(Zt=(0,z.jsx)(`div`,{className:Yt,children:Xt}),t[182]=Yt,t[183]=Xt,t[184]=Zt):Zt=t[184];let Qt;t[185]!==qt||t[186]!==Zt?(Qt=(0,z.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[qt,Zt]}),t[185]=qt,t[186]=Zt,t[187]=Qt):Qt=t[187];let $t;t[188]!==Pt||t[189]!==Qt?($t=(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[Pt,Qt]}),t[188]=Pt,t[189]=Qt,t[190]=$t):$t=t[190];let en;t[191]!==yt||t[192]!==$t?(en=(0,z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-3 overflow-hidden p-4 md:grid-cols-2`,children:[yt,$t]}),t[191]=yt,t[192]=$t,t[193]=en):en=t[193];let tn;t[194]!==$||t[195]!==Z.cancel?(tn=(0,z.jsx)(c,{type:`button`,variant:`secondary`,onClick:$,children:Z.cancel}),t[194]=$,t[195]=Z.cancel,t[196]=tn):tn=t[196];let nn=!Ve,rn;t[197]!==Pe||t[198]!==Z.applyCurrent||t[199]!==nn?(rn=(0,z.jsx)(c,{type:`button`,variant:`secondary`,disabled:nn,onClick:Pe,children:Z.applyCurrent}),t[197]=Pe,t[198]=Z.applyCurrent,t[199]=nn,t[200]=rn):rn=t[200];let an;t[201]===je?an=t[202]:(an=()=>void je(),t[201]=je,t[202]=an);let on;t[203]===Ue?on=t[204]:(on=Ue?(0,z.jsx)(d,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,z.jsx)(A,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[203]=Ue,t[204]=on);let sn=Ue?Z.regenerate:Z.generate,cn;t[205]!==Y||t[206]!==an||t[207]!==on||t[208]!==sn?(cn=(0,z.jsxs)(c,{type:`button`,variant:`secondary`,disabled:Y,onClick:an,children:[on,sn]}),t[205]=Y,t[206]=an,t[207]=on,t[208]=sn,t[209]=cn):cn=t[209];let ln=!Be,un;t[210]!==Re||t[211]!==Z.append||t[212]!==ln?(un=(0,z.jsx)(c,{type:`button`,variant:`secondary`,disabled:ln,onClick:Re,children:Z.append}),t[210]=Re,t[211]=Z.append,t[212]=ln,t[213]=un):un=t[213];let dn=!Be,fn;t[214]!==Ie||t[215]!==Z.replace||t[216]!==dn?(fn=(0,z.jsx)(c,{type:`button`,variant:`primary`,disabled:dn,onClick:Ie,children:Z.replace}),t[214]=Ie,t[215]=Z.replace,t[216]=dn,t[217]=fn):fn=t[217];let pn;t[218]!==fn||t[219]!==tn||t[220]!==rn||t[221]!==cn||t[222]!==un?(pn=(0,z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[tn,rn,cn,un,fn]}),t[218]=fn,t[219]=tn,t[220]=rn,t[221]=cn,t[222]=un,t[223]=pn):pn=t[223];let mn;t[224]!==pn||t[225]!==it||t[226]!==en?(mn=(0,z.jsx)(`div`,{className:`absolute inset-0 z-[80] flex items-center justify-center p-4 pointer-events-none`,children:(0,z.jsxs)(v,{className:`xopc-dialog-content-pane pointer-events-auto flex h-[min(78vh,38rem)] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,onOpenAutoFocus:ie,children:[it,en,pn]})}),t[224]=pn,t[225]=it,t[226]=en,t[227]=mn):mn=t[227];let hn;t[228]!==mn||t[229]!==Ze||t[230]!==et?(hn=(0,z.jsxs)(y,{container:Ze,children:[et,mn]}),t[228]=mn,t[229]=Ze,t[230]=et,t[231]=hn):hn=t[231];let gn;t[232]!==F||t[233]!==hn||t[234]!==Xe?(gn=(0,z.jsx)(M,{open:F,onOpenChange:Xe,children:hn}),t[232]=F,t[233]=hn,t[234]=Xe,t[235]=gn):gn=t[235];let _n;return t[236]!==gn||t[237]!==Ye?(_n=(0,z.jsxs)(z.Fragment,{children:[Ye,gn]}),t[236]=gn,t[237]=Ye,t[238]=_n):_n=t[238],_n}function re(e){return!e}function ie(e){return e.preventDefault()}function V(e){return!!(e&&e.type===`object`&&e.properties&&!Array.isArray(e.properties))}function H(e){let t=e.properties??{},n=new Set(e.required??[]);return Object.entries(t).map(([e,t])=>({key:e,schema:t,required:n.has(e)}))}function U(e,t){return!V(e)||!e?!0:H(e).every(e=>{if(!e.required)return!0;let n=t[e.key];return n==null?!1:typeof n==`string`?n.trim().length>0:!0})}function W(e,t){if(e)return V(e.inputSchema)?Object.keys(t.schemaInput).length>0?t.schemaInput:void 0:f(t.argValues)}function ae(e,t,n){let r=a(t).workflows;if(!e)return r.noInputSummary;let i=w(e,t);if(V(e.inputSchema)&&Object.keys(n.schemaInput).length>0)return Object.entries(n.schemaInput).map(([e,t])=>`${e}: ${String(t)}`).join(` · `);let o=Object.values(n.argValues).map(e=>e.trim()).filter(Boolean),s=n.goal.trim()||i.description;return s&&o.unshift(s),o.length>0?o.join(` · `):r.noInputSummary}function G(e,t,n=!0){return e?n?V(e.inputSchema)?U(e.inputSchema,t.schemaInput)?{valid:!0}:{valid:!1,reason:`schema-required`}:{valid:(j[e.name]??[]).every(e=>!e.required||!!t.argValues[e.key]?.trim())}:{valid:!1,reason:`raw-json`}:{valid:!1}}function K(e,t){return e[t]??t}function oe(e,t){let n=j[e]??[];if(n.length===0)return{};let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{},i={};for(let e of n){let t=r[e.key];t!=null&&(i[e.key]=String(t))}return i}function se(e){let t=(0,P.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,z.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,z.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function ce(e){let t=(0,P.c)(34),{workflowName:n,language:r,argValues:o,onArgValuesChange:s,goal:c,onGoalChange:l,examplePrompts:u,showGoal:d,inputClassName:f,aiAssist:p}=e,m;t[0]===u?m=t[1]:(m=u===void 0?[]:u,t[0]=u,t[1]=m);let h=m,g=d===void 0?!0:d,_,v,y,b,x,S,C;if(t[2]!==p||t[3]!==o||t[4]!==h||t[5]!==c||t[6]!==f||t[7]!==r||t[8]!==s||t[9]!==l||t[10]!==g||t[11]!==n){y=a(r).workflows;let e=j[n]??[];v=e.length>0;let u=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,f),d;t[19]!==o||t[20]!==s||t[21]!==l?(d=e=>{E(e,l,e=>{s(e(o))})},t[19]=o,t[20]=s,t[21]=l,t[22]=d):d=t[22],_=d,b=`flex flex-col gap-3`,x=e.map(e=>{let t=K(y.args,e.labelKey),a=K(y.args,e.placeholderKey),c=o[e.key]??``;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[t,e.required?` *`:``]}),e.multiline&&p?(0,z.jsx)(B,{value:c,onApply:t=>s({...o,[e.key]:t}),fieldId:`workflow.arg.${e.key}`,fieldLabel:t,scenario:p.argScenario??`workflow.arg`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o,fieldKey:e.key},disabled:p.disabled,showLabel:!1}):null]}),e.multiline?(0,z.jsx)(`textarea`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:i(u,`min-h-20 resize-y`)}):(0,z.jsx)(`input`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:u})]},e.key)}),S=v&&h.length>0?(0,z.jsx)(se,{examples:h,labels:y,onSelect:_}):null,C=g?(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:y.goalLabel}),p?(0,z.jsx)(B,{value:c,onApply:l,fieldId:`workflow.goal`,fieldLabel:y.goalLabel,scenario:p.goalScenario??`cron.workflowGoal`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o},disabled:p.disabled,showLabel:!1}):null]}),(0,z.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:y.goalPlaceholder,className:i(u,`min-h-20 resize-y`)})]}):null,t[2]=p,t[3]=o,t[4]=h,t[5]=c,t[6]=f,t[7]=r,t[8]=s,t[9]=l,t[10]=g,t[11]=n,t[12]=_,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S,t[18]=C}else _=t[12],v=t[13],y=t[14],b=t[15],x=t[16],S=t[17],C=t[18];let w;t[23]!==_||t[24]!==h||t[25]!==v||t[26]!==y?(w=!v&&h.length>0?(0,z.jsx)(se,{examples:h,labels:y,onSelect:_}):null,t[23]=_,t[24]=h,t[25]=v,t[26]=y,t[27]=w):w=t[27];let T;return t[28]!==b||t[29]!==x||t[30]!==S||t[31]!==C||t[32]!==w?(T=(0,z.jsxs)(`div`,{className:b,children:[x,S,C,w]}),t[28]=b,t[29]=x,t[30]=S,t[31]=C,t[32]=w,t[33]=T):T=t[33],T}var q=`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`;function le({schema:e,value:t,onChange:n,labels:r,aiAssist:a,onValidChange:o}){let s=(0,N.useMemo)(()=>H(e),[e]),[c,l]=(0,N.useState)(!1),[u,d]=(0,N.useState)(()=>JSON.stringify(t,null,2)),[f,p]=(0,N.useState)(null);if(s.length===0)return null;let m=(e,r)=>{let i={...t,[e]:r};(r===``||r===void 0)&&delete i[e],n(i),c&&d(JSON.stringify(i,null,2))},h=e=>{d(e);try{let t=e.trim()?JSON.parse(e):{};if(!t||typeof t!=`object`||Array.isArray(t)){p(r.rawJsonInvalid),o?.(!1);return}p(null),n(t),o?.(!0,t)}catch{p(r.rawJsonInvalid),o?.(!1)}};return(0,z.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel/70 p-4 shadow-surface`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.inputSchemaHeading}),(0,z.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent-fg hover:underline`,onClick:()=>{let e=!c;l(e),e&&(d(JSON.stringify(t,null,2)),p(null),o?.(!0))},children:r.rawJson})]}),c?(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsx)(`textarea`,{value:u,onChange:e=>h(e.target.value),spellCheck:!1,className:i(q,`min-h-40 font-mono text-xs leading-5`)}),f?(0,z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-300`,children:f}):null]}):(0,z.jsx)(`div`,{className:`mt-3 grid gap-3`,children:s.map(e=>(0,z.jsx)(ue,{field:e,value:t[e.key],labels:r,aiAssist:a,allValues:t,onChange:t=>m(e.key,t)},e.key))})]})}function ue(e){let t=(0,P.c)(30),{field:n,value:r,labels:a,aiAssist:o,allValues:s,onChange:c}=e,l=n.schema.title||n.key,u=typeof n.schema.description==`string`?n.schema.description:void 0,d=Array.isArray(n.schema.type)?n.schema.type[0]:n.schema.type,f;t[0]===n.schema.enum?f=t[1]:(f=Array.isArray(n.schema.enum)?n.schema.enum:[],t[0]=n.schema.enum,t[1]=f);let p=f,m=!!o&&!p.length&&(d===`string`||!d),h=String(l),g=n.required?` *`:``,_;t[2]!==h||t[3]!==g?(_=(0,z.jsxs)(`span`,{className:`text-xs font-medium text-fg`,children:[h,g]}),t[2]=h,t[3]=g,t[4]=_):_=t[4];let v;t[5]!==o||t[6]!==s||t[7]!==n.key||t[8]!==n.schema||t[9]!==c||t[10]!==m||t[11]!==l||t[12]!==r?(v=m&&o?(0,z.jsx)(B,{value:typeof r==`string`?r:r==null?``:String(r),onApply:c,fieldId:`workflow.schema.${n.key}`,fieldLabel:String(l),scenario:o.scenario??`workflow.arg`,locale:o.locale,context:{...o.context,fieldKey:n.key,fieldSchema:n.schema,inputValues:s},disabled:o.disabled,showLabel:!1}):null,t[5]=o,t[6]=s,t[7]=n.key,t[8]=n.schema,t[9]=c,t[10]=m,t[11]=l,t[12]=r,t[13]=v):v=t[13];let y;t[14]!==_||t[15]!==v?(y=(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===u?b=t[18]:(b=u?(0,z.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-subtle`,children:u}):null,t[17]=u,t[18]=b);let x;t[19]!==u||t[20]!==p||t[21]!==a||t[22]!==c||t[23]!==d||t[24]!==r?(x=p.length>0?(0,z.jsxs)(k,{value:r==null?``:String(r),onChange:e=>c(e.target.value),className:q,children:[(0,z.jsx)(O,{value:``}),p.map(de)]}):d===`boolean`?(0,z.jsxs)(k,{value:typeof r==`boolean`?String(r):``,onChange:e=>c(e.target.value===``?void 0:e.target.value===`true`),className:q,children:[(0,z.jsx)(O,{value:``}),(0,z.jsx)(O,{value:`true`,children:a.booleanTrue}),(0,z.jsx)(O,{value:`false`,children:a.booleanFalse})]}):d===`number`||d===`integer`?(0,z.jsx)(`input`,{type:`number`,value:typeof r==`number`||typeof r==`string`?String(r):``,onChange:e=>c(e.target.value===``?void 0:Number(e.target.value)),className:q}):(0,z.jsx)(`textarea`,{value:typeof r==`string`?r:r==null?``:String(r),onChange:e=>c(e.target.value),className:i(q,u&&u.length>80?`min-h-20 resize-y`:`min-h-10 resize-y`)}),t[19]=u,t[20]=p,t[21]=a,t[22]=c,t[23]=d,t[24]=r,t[25]=x):x=t[25];let S;return t[26]!==y||t[27]!==b||t[28]!==x?(S=(0,z.jsxs)(`div`,{className:`block`,children:[y,b,x]}),t[26]=y,t[27]=b,t[28]=x,t[29]=S):S=t[29],S}function de(e){return(0,z.jsx)(O,{value:String(e),children:String(e)},String(e))}function J(e){let t=(0,P.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,z.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,z.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function Y(e){let t=(0,P.c)(114),{definition:n,language:r,value:o,onChange:s,aiAssist:c,inputClassName:l,onValidityChange:u}=e,d;t[0]===r?d=t[1]:(d=a(r),t[0]=r,t[1]=d);let f=d.workflows,p;t[2]!==n||t[3]!==r?(p=w(n,r),t[2]=n,t[3]=r,t[4]=p):p=t[4];let m=p,[h,g]=(0,N.useState)(!0),_;t[5]===m.examplePrompts?_=t[6]:(_=m.examplePrompts??[],t[5]=m.examplePrompts,t[6]=_);let v=_,y;t[7]===n.inputSchema?y=t[8]:(y=V(n.inputSchema),t[7]=n.inputSchema,t[8]=y);let b=y,x,S,C,T,E,D,O,k,A,j;if(t[9]!==c||t[10]!==n||t[11]!==v||t[12]!==b||t[13]!==l||t[14]!==f||t[15]!==r||t[16]!==m.description||t[17]!==s||t[18]!==u||t[19]!==h||t[20]!==o){E=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,l),a;t[31]!==n||t[32]!==s||t[33]!==u||t[34]!==h?(a=(e,t)=>{let r=t===void 0?h:t;s(e),u?.(G(n,e,r))},t[31]=n,t[32]=s,t[33]=u,t[34]=h,t[35]=a):a=t[35];let d=a,p;t[36]!==d||t[37]!==o?(p=e=>d({...o,goal:e}),t[36]=d,t[37]=o,t[38]=p):p=t[38];let _=p,y;t[39]!==d||t[40]!==o?(y=e=>d({...o,schemaInput:e}),t[39]=d,t[40]=o,t[41]=y):y=t[41];let w=y,M;t[42]!==d||t[43]!==o?(M=e=>d({...o,argValues:e}),t[42]=d,t[43]=o,t[44]=M):M=t[44];let N=M,P;if(t[45]!==_||t[46]!==w||t[47]!==o.schemaInput?(P=e=>{if(e.field===`goal`){_(e.text);return}w({...o.schemaInput,[e.field]:e.text})},t[45]=_,t[46]=w,t[47]=o.schemaInput,t[48]=P):P=t[48],x=P,!b){let e;t[49]!==c||t[50]!==n.id||t[51]!==n.name||t[52]!==n.title||t[53]!==m.description?(e=c?{disabled:c.disabled,argScenario:c.inputScenario??`workflow.arg`,goalScenario:c.goalScenario??`workflow.goal`,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description}}:void 0,t[49]=c,t[50]=n.id,t[51]=n.name,t[52]=n.title,t[53]=m.description,t[54]=e):e=t[54];let i;t[55]!==n.name||t[56]!==v||t[57]!==l||t[58]!==r||t[59]!==N||t[60]!==_||t[61]!==e||t[62]!==o.argValues||t[63]!==o.goal?(i=(0,z.jsx)(ce,{workflowName:n.name,language:r,argValues:o.argValues,onArgValuesChange:N,goal:o.goal,onGoalChange:_,examplePrompts:v,inputClassName:l,aiAssist:e}),t[55]=n.name,t[56]=v,t[57]=l,t[58]=r,t[59]=N,t[60]=_,t[61]=e,t[62]=o.argValues,t[63]=o.goal,t[64]=i):i=t[64],E=i;break bb0}C=`flex flex-col gap-3`,t[65]!==c||t[66]!==n||t[67]!==f.booleanFalse||t[68]!==f.booleanTrue||t[69]!==f.inputSchemaHeading||t[70]!==f.rawJson||t[71]!==f.rawJsonInvalid||t[72]!==r||t[73]!==m.description||t[74]!==u||t[75]!==w||t[76]!==o?(T=n.inputSchema?(0,z.jsx)(le,{schema:n.inputSchema,value:o.schemaInput,onChange:w,onValidChange:(e,t)=>{g(e),u?.(G(n,t?{...o,schemaInput:t}:o,e))},aiAssist:c?{locale:r,disabled:c.disabled,scenario:c.inputScenario??`workflow.arg`,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description}}:void 0,labels:{inputSchemaHeading:f.inputSchemaHeading,rawJson:f.rawJson,rawJsonInvalid:f.rawJsonInvalid,booleanTrue:f.booleanTrue,booleanFalse:f.booleanFalse}}):null,t[65]=c,t[66]=n,t[67]=f.booleanFalse,t[68]=f.booleanTrue,t[69]=f.inputSchemaHeading,t[70]=f.rawJson,t[71]=f.rawJsonInvalid,t[72]=r,t[73]=m.description,t[74]=u,t[75]=w,t[76]=o,t[77]=T):T=t[77],j=`flex flex-col gap-1`;let F;t[78]===f.goalLabel?F=t[79]:(F=(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:f.goalLabel}),t[78]=f.goalLabel,t[79]=F);let I;t[80]!==c||t[81]!==n.id||t[82]!==n.name||t[83]!==n.title||t[84]!==f.goalLabel||t[85]!==r||t[86]!==m.description||t[87]!==_||t[88]!==o.goal||t[89]!==o.schemaInput?(I=c?(0,z.jsx)(B,{value:o.goal,onApply:_,fieldId:`workflow.goal`,fieldLabel:f.goalLabel,scenario:c.goalScenario??`workflow.goal`,locale:r,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description,workflowInput:o.schemaInput},disabled:c.disabled,showLabel:!1}):null,t[80]=c,t[81]=n.id,t[82]=n.name,t[83]=n.title,t[84]=f.goalLabel,t[85]=r,t[86]=m.description,t[87]=_,t[88]=o.goal,t[89]=o.schemaInput,t[90]=I):I=t[90],t[91]!==F||t[92]!==I?(S=(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[F,I]}),t[91]=F,t[92]=I,t[93]=S):S=t[93],D=o.goal,t[94]===_?O=t[95]:(O=e=>_(e.target.value),t[94]=_,t[95]=O),k=f.goalPlaceholder,A=i(e,`min-h-20 resize-y`)}t[9]=c,t[10]=n,t[11]=v,t[12]=b,t[13]=l,t[14]=f,t[15]=r,t[16]=m.description,t[17]=s,t[18]=u,t[19]=h,t[20]=o,t[21]=x,t[22]=S,t[23]=C,t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A,t[30]=j}else x=t[21],S=t[22],C=t[23],T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29],j=t[30];if(E!==Symbol.for(`react.early_return_sentinel`))return E;let M;t[96]!==D||t[97]!==O||t[98]!==k||t[99]!==A?(M=(0,z.jsx)(`textarea`,{value:D,onChange:O,placeholder:k,className:A}),t[96]=D,t[97]=O,t[98]=k,t[99]=A,t[100]=M):M=t[100];let F;t[101]!==S||t[102]!==M||t[103]!==j?(F=(0,z.jsxs)(`div`,{className:j,children:[S,M]}),t[101]=S,t[102]=M,t[103]=j,t[104]=F):F=t[104];let I;t[105]!==x||t[106]!==v||t[107]!==f?(I=(0,z.jsx)(J,{examples:v,labels:f,onSelect:x}),t[105]=x,t[106]=v,t[107]=f,t[108]=I):I=t[108];let L;return t[109]!==C||t[110]!==T||t[111]!==F||t[112]!==I?(L=(0,z.jsxs)(`div`,{className:C,children:[T,F,I]}),t[109]=C,t[110]=T,t[111]=F,t[112]=I,t[113]=L):L=t[113],L}function X(e,t){let n=e.metadata.estimatedAgents;return n?n.min===n.max?b(t.agentScaleExact,{count:n.min}):b(t.agentScaleRange,{min:n.min,max:n.max}):b(t.agentScaleExact,{count:e.defaults.maxSubagents})}function fe(e){let t=(0,P.c)(41),{definition:n,language:r,value:o,onChange:s,mode:c,badgeLabel:l,aiAssist:d,inputClassName:f,showTimeout:p,defaultAdvancedOpen:m,onValidityChange:h}=e,g=p===void 0?!1:p,_=m===void 0?!1:m,v=a(r).workflows,[y,E]=(0,N.useState)(_),D;t[0]!==n||t[1]!==r?(D=w(n,r),t[0]=n,t[1]=r,t[2]=D):D=t[2];let O=D,k;t[3]!==n.defaults||t[4]!==o.concurrency?(k=o.concurrency.trim()?Number(o.concurrency):n.defaults.concurrency,t[3]=n.defaults,t[4]=o.concurrency,t[5]=k):k=t[5];let A=k,j;t[6]!==n.defaults||t[7]!==o.maxSubagents?(j=o.maxSubagents.trim()?Number(o.maxSubagents):n.defaults.maxSubagents,t[6]=n.defaults,t[7]=o.maxSubagents,t[8]=j):j=t[8];let M=j,F;t[9]!==n||t[10]!==r||t[11]!==o?(F=ae(n,r,o),t[9]=n,t[10]=r,t[11]=o,t[12]=F):F=t[12];let I=F,L=l??v.readyToStart,R;t[13]!==s||t[14]!==o?(R=e=>s({...o,...e}),t[13]=s,t[14]=o,t[15]=R):R=t[15];let ee=R,te=c===`automation`&&`rounded-xl bg-surface-panel/70 p-3 shadow-surface`,ne;t[16]===te?ne=t[17]:(ne=i(`space-y-4`,te),t[16]=te,t[17]=ne);let B=I||O.description,re;t[18]===B?re=t[19]:(re=(0,z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:B}),t[18]=B,t[19]=re);let ie;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,z.jsx)(T,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[20]=ie):ie=t[20];let V;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,z.jsx)(u,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[21]=V):V=t[21];let H;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,z.jsx)(C,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[22]=H):H=t[22];let U;t[23]!==s||t[24]!==o?(U=e=>s({...o,...e}),t[23]=s,t[24]=o,t[25]=U):U=t[25];let W;t[26]===h?W=t[27]:(W=e=>{h?.(e)},t[26]=h,t[27]=W);let G;t[28]!==d||t[29]!==n||t[30]!==f||t[31]!==r||t[32]!==U||t[33]!==W||t[34]!==o?(G=(0,z.jsx)(Y,{definition:n,language:r,value:o,onChange:U,onValidityChange:W,aiAssist:d,inputClassName:f}),t[28]=d,t[29]=n,t[30]=f,t[31]=r,t[32]=U,t[33]=W,t[34]=o,t[35]=G):G=t[35];let K;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>E(pe),t[36]=K):K=t[36];let oe=v.advancedSettings,se=y&&`rotate-180`,ce;t[37]===se?ce=t[38]:(ce=i(`size-4 transition-transform`,se),t[37]=se,t[38]=ce);let q;return t[39]===ce?q=t[40]:(q=(0,z.jsx)(S,{className:ce}),t[39]=ce,t[40]=q),(0,z.jsxs)(`div`,{className:ne,children:[(0,z.jsxs)(`section`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:v.runPlanPreview}),re]}),(0,z.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2 py-1 text-[11px] font-medium text-accent-fg`,children:L})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-2 text-xs text-fg-muted sm:grid-cols-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[ie,(0,z.jsx)(`span`,{children:b(v.phaseCount,{count:n.phases.length})})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[V,(0,z.jsx)(`span`,{children:X(n,v)})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-surface-panel px-2.5 py-2`,children:[H,(0,z.jsx)(`span`,{children:b(v.runLimitsSummary,{concurrency:A,max:M})})]})]}),n.phases.length>0?(0,z.jsxs)(`div`,{className:`mt-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:[(0,z.jsx)(x,{className:`size-3.5`,"aria-hidden":!0}),v.startPlanPhases]}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:n.phases.map(me)})]}):null]}),G,(0,z.jsxs)(`div`,{className:`rounded-xl border border-edge`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between px-3 py-2.5 text-left text-sm text-fg`,onClick:K,children:[oe,q]}),y?(0,z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge px-3 pb-3 pt-3 sm:grid-cols-2`,children:[(0,z.jsx)(`input`,{value:o.concurrency,onChange:e=>ee({concurrency:e.target.value}),placeholder:b(v.concurrencyPlaceholder,{default:n.defaults.concurrency}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,z.jsx)(`input`,{value:o.maxSubagents,onChange:e=>ee({maxSubagents:e.target.value}),placeholder:b(v.maxSubagentsPlaceholder,{default:n.defaults.maxSubagents}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}),g?(0,z.jsx)(`input`,{value:o.timeoutSeconds??``,onChange:e=>ee({timeoutSeconds:e.target.value}),placeholder:b(v.timeoutSecondsPlaceholder,{default:n.defaults.timeoutSec}),inputMode:`numeric`,className:`rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`}):null]}):null]})]})}function pe(e){return!e}function me(e,t){return(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t>0?(0,z.jsx)(`span`,{className:`text-fg-subtle`,children:`→`}):null,(0,z.jsx)(`span`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-2 py-1 text-[11px] text-fg-muted`,children:e.title})]},e.id)}export{B as a,G as i,oe as n,W as r,fe as t};