@xopcai/xopc 0.0.150 → 0.0.151

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 (145) 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-B3YP7y9d.js → activity-store-uu1xu9Pl.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BaP05tRU.js → agent-avatar-dicebear-BuO-OVfD.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-Bpv3h31T.js +2 -0
  6. package/dist/gateway/static/root/assets/{api-BirUfJgj.js → api-CwL38LEV.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-D5Cg_a6I.js → app-management-settings-panel-B6OU3Eol.js} +1 -1
  8. package/dist/gateway/static/root/assets/appearance-settings-BaP4GFvN.js +1 -0
  9. package/dist/gateway/static/root/assets/apps-page-DZKNIMRg.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-D3OmrvFx.js → archive-plugin-CJX3zIh_.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Cgkm_5mb.js → attachment-load-CI1ejk_l.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-CHvxSz-t.js → automation-suggestion-card-CjmhICbv.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-page-BtZl3B8m.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-dJR5UuzL.js → binary-plugins-CZ8nOXqK.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-v4_7o92L.js → block-editor-BoSfyS_j.js} +46 -46
  16. package/dist/gateway/static/root/assets/browser-settings-page-CL1UiPcb.js +8 -0
  17. package/dist/gateway/static/root/assets/{capability-presets-api-BcTjPLiD.js → capability-presets-api-XzDKxPZ8.js} +1 -1
  18. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-CddBf58y.js → capability-presets-settings-panel-Dc_uHYgl.js} +2 -2
  19. package/dist/gateway/static/root/assets/{channel-recipient-api-BbDlMRm5.js → channel-recipient-api-DYLBAhFF.js} +1 -1
  20. package/dist/gateway/static/root/assets/channels-settings-mALvXpJj.js +1 -0
  21. package/dist/gateway/static/root/assets/channels-status-swr-CZuEsO5b.js +1 -0
  22. package/dist/gateway/static/root/assets/{connector-logo-BNthqff-.js → connector-logo-BSjlInHT.js} +1 -1
  23. package/dist/gateway/static/root/assets/connectors-page-Cm_E3mmI.js +2 -0
  24. package/dist/gateway/static/root/assets/desktop-pet-DcJc91-C.js +1 -0
  25. package/dist/gateway/static/root/assets/desktop-pet-settings-CdeqTa3Q.js +1 -0
  26. package/dist/gateway/static/root/assets/{directory-picker-path-field-BdWd7m-p.js → directory-picker-path-field-Cp3fpm0k.js} +1 -1
  27. package/dist/gateway/static/root/assets/{dreaming-settings-CXDhu3Me.js → dreaming-settings-Bwj1O3zr.js} +3 -3
  28. package/dist/gateway/static/root/assets/{extension-debug-page-CLJTGozU.js → extension-debug-page-D_1xpKbZ.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-page-ClxpGfzA.js → extension-page-CqZNCj96.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-settings-page-CDA3ZJ8k.js → extension-settings-page-5MWbtQaQ.js} +1 -1
  31. package/dist/gateway/static/root/assets/{gateway-config-api-DpXL78pS.js → gateway-config-api-Co_IaS34.js} +1 -1
  32. package/dist/gateway/static/root/assets/gateway-settings-kmeWm2Pt.js +1 -0
  33. package/dist/gateway/static/root/assets/{gateway-startup-retry-D0SU7dte.js → gateway-startup-retry-BM_xvzl0.js} +1 -1
  34. package/dist/gateway/static/root/assets/goal-create-dialog-FoO-R4_U.js +1 -0
  35. package/dist/gateway/static/root/assets/goal-detail-page-CkJq7N5g.js +4 -0
  36. package/dist/gateway/static/root/assets/{goals-config-api-r71aDqix.js → goals-config-api-DrtsYjXz.js} +1 -1
  37. package/dist/gateway/static/root/assets/goals-page-DRAN-R64.js +2 -0
  38. package/dist/gateway/static/root/assets/{goals-settings-CZOLhkTH.js → goals-settings-wq9TKhIZ.js} +1 -1
  39. package/dist/gateway/static/root/assets/{heartbeat-settings-F9S1gIFo.js → heartbeat-settings-B5zDoHbo.js} +1 -1
  40. package/dist/gateway/static/root/assets/index-DIlxvrlG.css +1 -0
  41. package/dist/gateway/static/root/assets/index-apLU0Hun.js +196 -0
  42. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-3tC9iD21.js +1 -0
  43. package/dist/gateway/static/root/assets/local-app-workbench-page-CT-vDTLK.js +2 -0
  44. package/dist/gateway/static/root/assets/{local-apps-page-n7YJfRkU.js → local-apps-page-B9ruF9GV.js} +1 -1
  45. package/dist/gateway/static/root/assets/locale-store-GfSwnwIZ.js +1 -0
  46. package/dist/gateway/static/root/assets/logs-page-Ca1X8X2P.js +7 -0
  47. package/dist/gateway/static/root/assets/{markdown-split-1mnXr-JA.js → markdown-split-CzuhSQAB.js} +1 -1
  48. package/dist/gateway/static/root/assets/{media-plugins-D2bcxXrT.js → media-plugins-a3R4y-EL.js} +1 -1
  49. package/dist/gateway/static/root/assets/{messages-BH7paqYt.js → messages-B0B40tpO.js} +2 -2
  50. package/dist/gateway/static/root/assets/models-hub-panel-CbTlz9Of.js +2 -0
  51. package/dist/gateway/static/root/assets/{notes-page-Wjc2utlj.js → notes-page-BCxDy2dV.js} +1 -1
  52. package/dist/gateway/static/root/assets/notes-workbench-z6sBX9B2.js +4 -0
  53. package/dist/gateway/static/root/assets/{page-tabs-vdljrKuG.js → page-tabs-CJfk6M78.js} +1 -1
  54. package/dist/gateway/static/root/assets/{preview-open-alternatives-BHki0l-E.js → preview-open-alternatives-MFopTSgF.js} +1 -1
  55. package/dist/gateway/static/root/assets/project-detail-page-DU29deIr.js +1 -0
  56. package/dist/gateway/static/root/assets/projects-page-Ck3DLTlZ.js +1 -0
  57. package/dist/gateway/static/root/assets/remote-access-hub-gLsLyAyi.js +1 -0
  58. package/dist/gateway/static/root/assets/{save-bar-controls-Vy4EmvEh.js → save-bar-controls-D0uhU3Z8.js} +1 -1
  59. package/dist/gateway/static/root/assets/{schedule-field-CVcwC7k_.js → schedule-field-NGOH-7wV.js} +1 -1
  60. package/dist/gateway/static/root/assets/{schema-form-DhMA1vkR.js → schema-form-BJz5LoqG.js} +1 -1
  61. package/dist/gateway/static/root/assets/schemas-DgQq6Z5S.js +64 -0
  62. package/dist/gateway/static/root/assets/sessions-page-TmNoWpa_.js +1 -0
  63. package/dist/gateway/static/root/assets/settings-advanced-gate-CtPhh2m9.js +1 -0
  64. package/dist/gateway/static/root/assets/{settings-collapsible-section-C0xcL0vB.js → settings-collapsible-section-oDnUHnX_.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-form-section-Cgj4iVpx.js → settings-form-section-DND90dDt.js} +1 -1
  66. package/dist/gateway/static/root/assets/settings-loading-skeleton-CEJtaoQp.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-page-B7_JZ2rM.js → settings-page-B1LJlRi9.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-page-layout-CKuQT4SG.js → settings-page-layout-CsrLuDsW.js} +1 -1
  69. package/dist/gateway/static/root/assets/setup-status-panel-BPCJPHHY.js +1 -0
  70. package/dist/gateway/static/root/assets/{share-preview-page-BmVw-6SJ.js → share-preview-page-C1PwLh-p.js} +1 -1
  71. package/dist/gateway/static/root/assets/shares-settings-DCuqr7js.js +1 -0
  72. package/dist/gateway/static/root/assets/skill-reload-api-kn1Vypcy.js +1 -0
  73. package/dist/gateway/static/root/assets/skills-page-k6VIqTkK.js +2 -0
  74. package/dist/gateway/static/root/assets/{system-settings-panel-D6d8VAk8.js → system-settings-panel-BEsrEkSx.js} +1 -1
  75. package/dist/gateway/static/root/assets/{theme-store-EbMQ3TYi.js → theme-store-Bi6hMBDb.js} +1 -1
  76. package/dist/gateway/static/root/assets/{typed-models-lib-D63hJX-S.js → typed-models-lib-dOypdlMf.js} +1 -1
  77. package/dist/gateway/static/root/assets/{use-channel-catalog-D-I-qki9.js → use-channel-catalog-f8A-PVuq.js} +1 -1
  78. package/dist/gateway/static/root/assets/user-context-page-B9Y_Ciav.js +1 -0
  79. package/dist/gateway/static/root/assets/{user-profile-fields-editor-CPaoS8Zl.js → user-profile-fields-editor-DGC38Lx7.js} +1 -1
  80. package/dist/gateway/static/root/assets/{user-profile-settings-panel-Bs13qcx1.js → user-profile-settings-panel-DFkZ-tan.js} +1 -1
  81. package/dist/gateway/static/root/assets/{utils-3mnkFvPw.js → utils-CEIYZihF.js} +1 -1
  82. package/dist/gateway/static/root/assets/voice-api-key-field-DK6gaQsA.js +1 -0
  83. package/dist/gateway/static/root/assets/work-discovery-page-DSJb9Kq7.js +1 -0
  84. package/dist/gateway/static/root/assets/work-item-detail-page-DVavwV3D.js +1 -0
  85. package/dist/gateway/static/root/assets/work-page-foJDp0nz.js +1 -0
  86. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BYqZpFCC.js +3 -0
  87. package/dist/gateway/static/root/assets/workflows-page-DgO0WAzs.js +11 -0
  88. package/dist/gateway/static/root/index.html +8 -7
  89. package/dist/package.js +1 -1
  90. package/dist/src/agent/agent-manager.d.ts +1 -0
  91. package/dist/src/agent/agent-manager.js +1 -0
  92. package/dist/src/agent/service.js +1 -0
  93. package/dist/src/agent/service.types.d.ts +2 -0
  94. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  95. package/dist/src/agent/tool-manuals/xopc-use.js +41 -2
  96. package/dist/src/agent/tools/automation-tool.js +45 -6
  97. package/dist/src/agent/tools/factory.d.ts +2 -0
  98. package/dist/src/agent/tools/factory.js +3 -2
  99. package/dist/src/agent/tools/goal-tool.d.ts +7 -1
  100. package/dist/src/agent/tools/goal-tool.js +34 -5
  101. package/dist/src/agent/tools/workflow-tool.js +32 -2
  102. package/dist/src/agent/tools/write.js +23 -3
  103. package/dist/src/agent/tools/xopc-use-tool.d.ts +6 -2
  104. package/dist/src/agent/tools/xopc-use-tool.js +216 -6
  105. package/dist/src/gateway/service.js +1 -0
  106. package/package.json +3 -2
  107. package/dist/gateway/static/root/assets/agents-QArUBYV7.js +0 -2
  108. package/dist/gateway/static/root/assets/appearance-settings-BBsAkJ56.js +0 -1
  109. package/dist/gateway/static/root/assets/apps-page-D1uAUndU.js +0 -1
  110. package/dist/gateway/static/root/assets/automations-page-BWQk03Vu.js +0 -6
  111. package/dist/gateway/static/root/assets/browser-settings-page-SruFGuBP.js +0 -8
  112. package/dist/gateway/static/root/assets/channels-settings-WI5tQ5tn.js +0 -1
  113. package/dist/gateway/static/root/assets/channels-status-swr-Dt2EROlf.js +0 -1
  114. package/dist/gateway/static/root/assets/connectors-page-DavHJ6rR.js +0 -2
  115. package/dist/gateway/static/root/assets/desktop-pet-CVajXkdj.js +0 -1
  116. package/dist/gateway/static/root/assets/desktop-pet-settings-SHI66eIi.js +0 -1
  117. package/dist/gateway/static/root/assets/gateway-settings-Co-mXFP_.js +0 -1
  118. package/dist/gateway/static/root/assets/goal-create-dialog-BO6G--Ec.js +0 -1
  119. package/dist/gateway/static/root/assets/goal-detail-page-DK8eog4h.js +0 -4
  120. package/dist/gateway/static/root/assets/goals-page-AcROW97U.js +0 -2
  121. package/dist/gateway/static/root/assets/index-C46C7Xee.css +0 -1
  122. package/dist/gateway/static/root/assets/index-IPmCli0N.js +0 -259
  123. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-B3CUVfZ8.js +0 -1
  124. package/dist/gateway/static/root/assets/local-app-workbench-page-HVq6NUvQ.js +0 -2
  125. package/dist/gateway/static/root/assets/locale-store-BvcHGPHU.js +0 -1
  126. package/dist/gateway/static/root/assets/logs-page-Dgko6r04.js +0 -7
  127. package/dist/gateway/static/root/assets/models-hub-panel-DD0cEfmR.js +0 -2
  128. package/dist/gateway/static/root/assets/notes-workbench-BkA2yg9K.js +0 -4
  129. package/dist/gateway/static/root/assets/project-detail-page-CXwVNLgg.js +0 -1
  130. package/dist/gateway/static/root/assets/projects-page-DlfvNcLh.js +0 -1
  131. package/dist/gateway/static/root/assets/remote-access-hub-BQyEX2Ui.js +0 -1
  132. package/dist/gateway/static/root/assets/sessions-page-CqQEW8oT.js +0 -1
  133. package/dist/gateway/static/root/assets/settings-advanced-gate-M8fleFSc.js +0 -1
  134. package/dist/gateway/static/root/assets/settings-loading-skeleton-CC_NmD69.js +0 -1
  135. package/dist/gateway/static/root/assets/setup-status-panel-DvR8Y5YN.js +0 -1
  136. package/dist/gateway/static/root/assets/shares-settings-C0JYYhGx.js +0 -1
  137. package/dist/gateway/static/root/assets/skill-reload-api-DBFBczqN.js +0 -1
  138. package/dist/gateway/static/root/assets/skills-page-KAI9qBDD.js +0 -2
  139. package/dist/gateway/static/root/assets/user-context-page-Cuft-EbR.js +0 -1
  140. package/dist/gateway/static/root/assets/voice-api-key-field-C716UEi9.js +0 -1
  141. package/dist/gateway/static/root/assets/work-discovery-page-CFSkHa0v.js +0 -1
  142. package/dist/gateway/static/root/assets/work-item-detail-page-DaapBdoZ.js +0 -1
  143. package/dist/gateway/static/root/assets/work-page-DMtX92vs.js +0 -1
  144. package/dist/gateway/static/root/assets/workflow-run-setup-panel-B9FnZNWZ.js +0 -3
  145. package/dist/gateway/static/root/assets/workflows-page-BgvE0_Iv.js +0 -11
@@ -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{t as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{l as o,r as s,s as c}from"./locale-store-GfSwnwIZ.js";import{o as l}from"./vendor-swr-BIWyz7Rc.js";import{Ml as u,Uc as d,Xt as f,Yo as p,Yt as m,Zo as h,au as g,cc as _,co as v,qn as y,so as b,us as x,vs as S,ys as ee}from"./index-apLU0Hun.js";var C=`/api/image/providers`;async function te(){return(await c(s(`/api/image/providers`)))?.payload?.providers??[]}var w=e(t(),1),ne=n();function T(){return{apiKey:``,region:``,baseUrl:``,imageBaseUrl:``}}function re(e){return e?.apiKey?`••••••••••••`:``}function E(e,t){let n=(()=>{if(!e||typeof e!=`object`||!(`providersConfig`in e))return;let t=e.providersConfig;if(!(!t||typeof t!=`object`||Array.isArray(t)))return t})(),r={};for(let e of t){let t=n?.[e];r[e]={apiKey:re(t),region:t?.region??``,baseUrl:t?.baseUrl??``,imageBaseUrl:t?.imageBaseUrl??``}}return r}function D(e,t,n){let r=e[n].trim();if(r!==t[n].trim())return r||null}function O(e,t){let n=e.trim(),r=t.trim();if(n!==r&&!(y(n)&&y(r)))return n||(r?null:void 0)}function ie(e,t,n){let r={};for(let i of e){let e=t[i]??T(),a=n[i]??T();if(JSON.stringify(e)===JSON.stringify(a))continue;let o={},s=O(e.apiKey,a.apiKey);s!==void 0&&(o.apiKey=s);let c=D(e,a,`region`);c!==void 0&&(o.region=c);let l=D(e,a,`baseUrl`);l!==void 0&&(o.baseUrl=l);let u=D(e,a,`imageBaseUrl`);u!==void 0&&(o.imageBaseUrl=u),Object.keys(o).length>0&&(r[i]=o)}return r}async function k(e){let t=await c(s(`/api/image/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function ae(e){Object.keys(e).length!==0&&(await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:e})}),await b())}var A=r();function oe(e){let t=(0,ne.c)(18),{providerId:n,value:r,onChange:i,labels:a,apiKeyLinks:o,apiKeyLinkLabels:s}=e,c;t[0]===n?c=t[1]:(c=()=>k(n).then(j),t[0]=n,t[1]=c);let l=c,d=`img-cred-key-${n}`,p;t[2]!==a.apiKeyLabel||t[3]!==d?(p=(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:d,children:a.apiKeyLabel}),t[2]=a.apiKeyLabel,t[3]=d,t[4]=p):p=t[4];let m;t[5]!==s||t[6]!==o?(m=o.length>0?(0,A.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,A.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[f(e.kind,s),(0,A.jsx)(u,{className:`size-3`,"aria-hidden":!0})]},`${e.kind}-${e.href}`))}):null,t[5]=s,t[6]=o,t[7]=m):m=t[7];let h=`img-cred-key-${n}`,g;t[8]!==a||t[9]!==i||t[10]!==l||t[11]!==h||t[12]!==r?(g=(0,A.jsx)(x,{id:h,value:r,onChange:i,placeholder:a.optionalPlaceholder,labels:a,reveal:l,loadFailedLabel:a.loadFailed,maskedHelp:a.maskedHelp,notInConfigFile:a.notInConfigFile}),t[8]=a,t[9]=i,t[10]=l,t[11]=h,t[12]=r,t[13]=g):g=t[13];let _;return t[14]!==p||t[15]!==m||t[16]!==g?(_=(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[p,m,g]}),t[14]=p,t[15]=m,t[16]=g,t[17]=_):_=t[17],_}function j(e){return e.apiKey??null}function M(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,S)}function se(){return a(M(),`appearance-none bg-[length:1rem] bg-[right_0.5rem_center] bg-no-repeat pr-9`)}var N=`__custom__`;function ce(e,t){if(!e.region.trim()&&!e.imageBaseUrl.trim())return``;let n=e.region.trim().toLowerCase();return t.some(e=>e.value===n)?n:N}function le(e,t){let n=e.baseUrl.trim().replace(/\/+$/,``);if(!n)return``;let r=t.map(e=>e.value.replace(/\/+$/,``)).indexOf(n);return r>=0?t[r].value:N}function ue(e,t,n){return t===`beijing`?e.dashscopeRegion_beijing:t===`singapore`?e.dashscopeRegion_singapore:t===`us`?e.dashscopeRegion_us:n}function de(e,t){return t===`minimax`?e.minimaxClusterLabel:t===`fal`?e.falQueueBaseLabel:e.baseUrlLabel}function fe(e,t){return t===`minimax`?e.minimaxClusterHint:t===`fal`?e.falQueueBaseHint:null}function pe(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function me(e,t){return t===1?e.modelCountOne:e.modelCountMany.replace(`{count}`,String(t))}function P(e){let t=(0,ne.c)(76),{summaries:n,credDraft:r,credBaseline:o,credDirty:s,credSaving:c,credError:l,credSavedFlash:f,credNoopFlash:v,updateCredRow:y,onDiscardCredentials:b,onSaveCredentials:x,extensionIds:S,showExtensionLinks:C,showImageModelsLink:te,hideActions:re,language:E,apiKeyLinkLabels:D,messages:O}=e,ie=re===void 0?!1:re,k;t[0]===n?k=t[1]:(k=n.some(ye),t[0]=n,t[1]=k);let ae=k,j;t[2]===n?j=t[3]:(j=n.some(ve),t[2]=n,t[3]=j);let P=j,[F,be]=(0,w.useState)(_e),[I,L]=(0,w.useState)(ge),R;if(t[4]!==o||t[5]!==r||t[6]!==n){R=new Set;for(let e of n)pe(r[e.id]??T(),o[e.id]??T())&&R.add(e.id);t[4]=o,t[5]=r,t[6]=n,t[7]=R}else R=t[7];let z=R,B;t[8]!==z||t[9]!==I||t[10]!==F?(B=e=>I.has(e)?!1:F.has(e)?!0:z.has(e),t[8]=z,t[9]=I,t[10]=F,t[11]=B):B=t[11];let V=B,H;t[12]===V?H=t[13]:(H=e=>{if(V(e)){L(t=>new Set(t).add(e)),be(t=>{let n=new Set(t);return n.delete(e),n});return}L(t=>{let n=new Set(t);return n.delete(e),n}),be(t=>new Set(t).add(e))},t[12]=V,t[13]=H);let U=H;if(n.length===0)return null;let W;t[14]===O.credentialsIntro?W=t[15]:(W=(0,A.jsx)(`p`,{children:O.credentialsIntro}),t[14]=O.credentialsIntro,t[15]=W);let G;t[16]!==ae||t[17]!==O.regionHint?(G=ae?(0,A.jsx)(`p`,{className:`text-fg-subtle`,children:O.regionHint}):null,t[16]=ae,t[17]=O.regionHint,t[18]=G):G=t[18];let K;t[19]!==P||t[20]!==O.endpointPresetsHint?(K=P?(0,A.jsx)(`p`,{className:`text-fg-subtle`,children:O.endpointPresetsHint}):null,t[19]=P,t[20]=O.endpointPresetsHint,t[21]=K):K=t[21];let q;t[22]!==te||t[23]!==O.imageModelsLinkTitle||t[24]!==O.openImageModelsPage?(q=te?(0,A.jsx)(`p`,{children:(0,A.jsx)(i,{to:`/settings/credentials?tab=image-models`,className:`font-medium text-accent hover:underline`,title:O.imageModelsLinkTitle,children:O.openImageModelsPage})}):null,t[22]=te,t[23]=O.imageModelsLinkTitle,t[24]=O.openImageModelsPage,t[25]=q):q=t[25];let J;t[26]!==W||t[27]!==G||t[28]!==K||t[29]!==q?(J=(0,A.jsxs)(`div`,{className:`flex flex-col gap-1 text-xs leading-relaxed text-fg-muted`,children:[W,G,K,q]}),t[26]=W,t[27]=G,t[28]=K,t[29]=q,t[30]=J):J=t[30];let Y;t[31]===l?Y=t[32]:(Y=l?(0,A.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:l}):null,t[31]=l,t[32]=Y);let X;t[33]!==s||t[34]!==v||t[35]!==f||t[36]!==c||t[37]!==ie||t[38]!==b||t[39]!==x||t[40]!==O.credentialsNothingToSave||t[41]!==O.credentialsSaved||t[42]!==O.discardCredentials||t[43]!==O.saveCredentials||t[44]!==O.savingCredentials?(X=ie?null:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[f?(0,A.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsSaved}):null,v?(0,A.jsx)(`span`,{className:`text-sm text-fg-muted`,children:O.credentialsNothingToSave}):null,(0,A.jsx)(ee,{type:`button`,variant:`secondary`,onClick:b,disabled:!s||c,children:O.discardCredentials}),(0,A.jsx)(ee,{type:`button`,variant:`primary`,onClick:x,disabled:!s||c,children:c?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{className:`size-3.5 animate-spin`}),(0,A.jsx)(`span`,{className:`ml-1.5`,children:O.savingCredentials})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(_,{className:`size-3.5`}),(0,A.jsx)(`span`,{className:`ml-1.5`,children:O.saveCredentials})]})})]}),t[33]=s,t[34]=v,t[35]=f,t[36]=c,t[37]=ie,t[38]=b,t[39]=x,t[40]=O.credentialsNothingToSave,t[41]=O.credentialsSaved,t[42]=O.discardCredentials,t[43]=O.saveCredentials,t[44]=O.savingCredentials,t[45]=X):X=t[45];let Z;if(t[46]!==D||t[47]!==o||t[48]!==r||t[49]!==S||t[50]!==V||t[51]!==E||t[52]!==C||t[53]!==n||t[54]!==O||t[55]!==U||t[56]!==y){let e;t[58]!==D||t[59]!==o||t[60]!==r||t[61]!==S||t[62]!==V||t[63]!==E||t[64]!==C||t[65]!==O||t[66]!==U||t[67]!==y?(e=e=>{let t=r[e.id]??T(),n=e.ui,s=C&&S.has(e.id)?`/settings/ext/${encodeURIComponent(e.id)}`:null,c=pe(t,o[e.id]??T()),l=V(e.id),d=e.label??e.id,f=me(O,e.models.length);return(0,A.jsxs)(`section`,{className:a(`overflow-hidden rounded-xl bg-surface-panel/80 shadow-surface transition-colors`,c&&`ring-1 ring-accent/50`),children:[(0,A.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left hover:bg-surface-hover/70`,"aria-expanded":l,"aria-controls":`img-provider-credentials-${e.id}`,onClick:()=>U(e.id),children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`truncate text-sm font-semibold text-fg`,children:d}),(0,A.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.id}),c?(0,A.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.unsavedChanges}):null,e.configured?(0,A.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:O.configured}):(0,A.jsx)(`span`,{className:`rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:O.missingKey})]}),(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,A.jsx)(`span`,{children:f}),e.defaultModel?(0,A.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,A.jsxs)(`span`,{className:`text-fg-muted`,children:[O.defaultModel,`:`]}),` `,e.id,`/`,e.defaultModel]}):null]})]}),(0,A.jsx)(g,{className:a(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,l?`rotate-180`:`rotate-0`),"aria-hidden":`true`}),(0,A.jsx)(`span`,{className:`sr-only`,children:l?O.collapseProvider:O.expandProvider})]}),l?(0,A.jsxs)(`div`,{id:`img-provider-credentials-${e.id}`,className:`bg-surface-base/45 p-4`,children:[s?(0,A.jsxs)(i,{to:s,className:`mb-3 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,title:O.extensionSettingsLinkTitle,children:[(0,A.jsx)(u,{className:`size-3`}),O.openExtensionSettings]}):null,e.models.length>0?(0,A.jsxs)(`p`,{className:`mb-3 text-xs leading-relaxed text-fg-subtle`,children:[(0,A.jsxs)(`span`,{className:`text-fg-muted`,children:[O.modelsLabel,`:`]}),` `,e.models.map(t=>`${e.id}/${t}`).join(`, `)]}):null,(0,A.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,A.jsx)(oe,{providerId:e.id,value:t.apiKey,onChange:t=>y(e.id,{apiKey:t}),apiKeyLinks:m(e.id,E),apiKeyLinkLabels:D,labels:{apiKeyLabel:O.apiKeyLabel,optionalPlaceholder:O.optionalPlaceholder,maskedHelp:O.apiKeyMaskedHelp,copy:O.apiKeyCopy,copied:O.apiKeyCopied,show:O.apiKeyShow,hide:O.apiKeyHide,notInConfigFile:O.apiKeyNotInConfigFile,loadFailed:O.apiKeyRevealFailed}}),n?.regions?.length?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-region-preset-${e.id}`,children:O.regionLabel}),(0,A.jsxs)(p,{id:`img-cred-region-preset-${e.id}`,className:se(),value:ce(t,n.regions),onChange:t=>{let r=t.target.value;if(r===``){y(e.id,{region:``,imageBaseUrl:``});return}if(r===N){y(e.id,{region:``,imageBaseUrl:``});return}let i=n.regions.find(e=>e.value===r);i&&y(e.id,{region:i.value,imageBaseUrl:i.imageBaseUrl})},children:[(0,A.jsx)(h,{value:``,children:O.regionPresetDefault}),n.regions.map(e=>(0,A.jsx)(h,{value:e.value,children:ue(O,e.value,e.label)},e.value)),(0,A.jsx)(h,{value:N,children:O.regionPresetCustom})]}),ce(t,n.regions)===N?(0,A.jsxs)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,A.jsx)(`input`,{type:`text`,className:M(),value:t.region,placeholder:`region`,onChange:t=>y(e.id,{region:t.target.value})}),(0,A.jsx)(`input`,{type:`url`,className:M(),value:t.imageBaseUrl,placeholder:O.imageBaseUrlLabel,onChange:t=>y(e.id,{imageBaseUrl:t.target.value})})]}):null]}):null,n?.baseUrlPresets?.length?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-base-preset-${e.id}`,children:de(O,n.baseUrlPresetKind)}),fe(O,n.baseUrlPresetKind)?(0,A.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:fe(O,n.baseUrlPresetKind)}):null,(0,A.jsxs)(p,{id:`img-cred-base-preset-${e.id}`,className:se(),value:le(t,n.baseUrlPresets),onChange:t=>{let n=t.target.value;if(n===``){y(e.id,{baseUrl:``});return}if(n===N){y(e.id,{baseUrl:``});return}y(e.id,{baseUrl:n.replace(/\/+$/,``)})},children:[(0,A.jsx)(h,{value:``,children:O.baseUrlPresetDefault}),n.baseUrlPresets.map(he),(0,A.jsx)(h,{value:N,children:O.baseUrlPresetCustom})]}),le(t,n.baseUrlPresets)===N?(0,A.jsx)(`input`,{type:`url`,className:a(M(),`mt-2`),value:t.baseUrl,placeholder:`https://…`,onChange:t=>y(e.id,{baseUrl:t.target.value})}):null]}):null,n?.regions?.length&&ce(t,n.regions)!==N?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 sm:col-span-2`,children:[(0,A.jsx)(`label`,{className:`text-xs font-medium text-fg-muted`,htmlFor:`img-cred-imgbase-ro-${e.id}`,children:O.imageBaseUrlLabel}),(0,A.jsx)(`input`,{id:`img-cred-imgbase-ro-${e.id}`,type:`url`,readOnly:!0,className:a(M(),`cursor-not-allowed opacity-90`),value:t.imageBaseUrl,title:O.imageBaseUrlPresetHint}),(0,A.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:O.imageBaseUrlPresetHint})]}):null]})]}):null]},e.id)},t[58]=D,t[59]=o,t[60]=r,t[61]=S,t[62]=V,t[63]=E,t[64]=C,t[65]=O,t[66]=U,t[67]=y,t[68]=e):e=t[68],Z=n.map(e),t[46]=D,t[47]=o,t[48]=r,t[49]=S,t[50]=V,t[51]=E,t[52]=C,t[53]=n,t[54]=O,t[55]=U,t[56]=y,t[57]=Z}else Z=t[57];let Q;t[69]===Z?Q=t[70]:(Q=(0,A.jsx)(`div`,{className:`flex flex-col gap-4`,children:Z}),t[69]=Z,t[70]=Q);let $;return t[71]!==J||t[72]!==Y||t[73]!==X||t[74]!==Q?($=(0,A.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[J,Y,X,Q]}),t[71]=J,t[72]=Y,t[73]=X,t[74]=Q,t[75]=$):$=t[75],$}function he(e){return(0,A.jsx)(h,{value:e.value,children:e.label},e.value)}function ge(){return new Set}function _e(){return new Set}function ve(e){return(e.ui?.baseUrlPresets?.length??0)>0}function ye(e){return(e.ui?.regions?.length??0)>0}function F(e){let t=v(o(e=>!!e.token)),n=t.data,r=(0,w.useMemo)(()=>e.map(e=>e.id),[e]),i=(0,w.useRef)(!1),[a,c]=(0,w.useState)(null),[u,d]=(0,w.useState)(!1),[f,p]=(0,w.useState)(null),[m,h]=(0,w.useState)(!1),[g,_]=(0,w.useState)(!1),y=(0,w.useMemo)(()=>E(n?.payload?.config,r),[n?.payload?.config,r]),b=a??y,x=y;return{gwSwr:t,credDraft:b,credBaseline:x,credDirty:(0,w.useMemo)(()=>JSON.stringify(b)!==JSON.stringify(x),[b,x]),credSaving:u,credError:f,credSavedFlash:m,credNoopFlash:g,updateCredRow:(0,w.useCallback)((e,t)=>{i.current=!0,c(n=>{let r=n??y,i=r[e]??T();return{...r,[e]:{...i,...t}}})},[y]),onDiscardCredentials:(0,w.useCallback)(()=>{i.current=!1,c(null),p(null),h(!1),_(!1)},[]),saveCredentials:(0,w.useCallback)(async e=>{let n=ie(r,b,x);if(Object.keys(n).length===0){_(!0),window.setTimeout(()=>_(!1),2200);return}d(!0),p(null),h(!1);try{await ae(n),await t.mutate?.(),l(s(C)),i.current=!1,c(null),h(!0),window.setTimeout(()=>h(!1),2e3)}catch(t){p(t instanceof Error?t.message:e)}finally{d(!1)}},[r,b,x,t])}}function be(){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 I(){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 L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function z(e,t,n){let r=L(e.providers)?e.providers:void 0,i=r&&L(r[t])?r[t]:void 0;return{...n,...i??{}}}function B(e){let t=be();if(!L(e))return t;let n=R(e.provider),r=z(e,`alibaba`,t.alibaba??{}),i=z(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(L(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=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function V(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function H(e){let t=I();if(!L(e))return t;let n=V(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=L(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,L(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:z(e,`alibaba`,t.alibaba??{}),openai:z(e,`openai`,t.openai??{}),edge:z(e,`edge`,t.edge??{}),minimax:z(e,`minimax`,t.minimax??{}),"tts-local-cli":z(e,`tts-local-cli`,i)}}function U(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 W(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 G(e){let t=L(e)?e:{},n=L(t.voice)?t.voice:{},r=L(n.input)?n.input:{},i=L(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:B(t.stt),tts:H(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 K(){return G((await c(s(`/api/config`))).payload?.config??{})}async function q(e){await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:U(e.stt),tts:W(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await c(s(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),b()}async function J(){let e=await c(s(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function Y(){let e=await c(s(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function X(){let e=await c(s(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function Z(){let e=await c(s(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function Q(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function $(e){await c(s(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function xe(e){let t=await c(s(`/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 Se(e){let t=await c(s(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}function Ce(e){let t=(0,ne.c)(15),{kind:n,providerId:r,fieldId:i,value:o,onChange:s,labels:c,placeholder:l,className:u}=e,d=l===void 0?`sk-...`:l,f;t[0]!==n||t[1]!==r?(f=()=>Se({kind:n,provider:r}).then(we),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p=f,m;t[3]===u?m=t[4]:(m=a(`flex min-w-0 flex-col gap-1.5`,u),t[3]=u,t[4]=m);let h;t[5]!==i||t[6]!==c||t[7]!==s||t[8]!==d||t[9]!==p||t[10]!==o?(h=(0,A.jsx)(x,{id:i,value:o,onChange:s,placeholder:d,labels:c,reveal:p,loadFailedLabel:c.loadFailed,maskedHelp:c.maskedHelp,notInConfigFile:c.notInConfigFile,inputClassName:`text-xs`}),t[5]=i,t[6]=c,t[7]=s,t[8]=d,t[9]=p,t[10]=o,t[11]=h):h=t[11];let g;return t[12]!==m||t[13]!==h?(g=(0,A.jsx)(`div`,{className:m,children:h}),t[12]=m,t[13]=h,t[14]=g):g=t[14],g}function we(e){return e.apiKey??null}export{K as a,G as c,xe as d,F as f,C as h,Y as i,q as l,te as m,Z as n,X as o,P as p,J as r,Q as s,Ce as t,$ as u};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r,l as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./check-BODqo66o.js";import{t as o}from"./messages-B0B40tpO.js";import{n as s}from"./locale-store-GfSwnwIZ.js";import{$s as c,At as ee,Bt as te,Cs as l,El as u,Gt as d,Ht as f,Kt as p,Pt as m,Sl as h,Uc as g,Ut as _,Vt as ne,Wl as re,Wt as ie,au as ae,bs as oe,lo as v,qt as y,ru as b,vl as x,ys as S,zt as se}from"./index-apLU0Hun.js";var C=e(t(),1),w=n(),T=[`folder_structure`,`recent_progress`,`next_steps`];function E(e){return e instanceof Error?e.message:String(e)}function D(){let e=s(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,D=i(),[O]=r(),k=O.get(`new`)===`1`,[A,j]=(0,C.useState)(`loading`),[M,N]=(0,C.useState)(null),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(!1),[R,z]=(0,C.useState)(null),[B,V]=(0,C.useState)(!1),[H,U]=(0,C.useState)(``),[W,G]=(0,C.useState)(!1),K=(0,C.useCallback)(e=>{F(e),e.status===`completed`?j(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?j(`error`):j(`running`)},[]),q=m({onPicked:(0,C.useCallback)(async e=>{L(!0),z(null);try{N(await _(e)),j(`consent`)}catch(e){z(E(e)),j(`intro`)}finally{L(!1)}},[])});(0,C.useEffect)(()=>{let e=!1;return ne().then(async({enabled:t,state:n})=>{if(!e){if(!t){D(`/chat`,{replace:!0});return}if(!k&&n.activeRunId)try{let t=await f(n.activeRunId);e||K(t);return}catch{}e||j(`intro`)}}).catch(t=>{e||(z(E(t)),j(`intro`))}),()=>{e=!0}},[K,D,k]),(0,C.useEffect)(()=>{if(!P||A!==`running`)return;let e=!1,t=async()=>{try{let t=await f(P.id);e||K(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===P.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)}},[K,A,P]);let J=async()=>{L(!0);try{await te()}finally{D(`/chat`,{replace:!0})}},ce=async()=>{if(M){L(!0),z(null);try{K(await p(M.canonicalRootPath))}catch(e){z(E(e)),j(`consent`)}finally{L(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;D(`/chat/${encodeURIComponent(e)}${n}`)},X=async(t,n)=>{if(!P)return;await d(P.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;Y(P.sessionKey,r)},le=async()=>{if(P){L(!0),z(null);try{F(await y(P.id,`confirmed`)),j(`recommendation`)}catch(e){z(E(e))}finally{L(!1)}}},Z=async e=>{if(!(!P||!H.trim())){L(!0),z(null);try{let t=await y(P.id,e,H.trim());F(t),Y(t.sessionKey,H.trim())}catch(e){z(E(e)),L(!1)}}},ue=async()=>{if(P){L(!0);try{Y((await y(P.id,`dismissed`)).sessionKey)}catch(e){z(E(e)),L(!1)}}},Q=P?.result?.suggestions.find(e=>e.id===P.result?.primarySuggestionId)??P?.result?.suggestions[0],$=P?.result?.suggestions.filter(e=>e.id!==Q?.id)??[];return(0,w.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,w.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,w.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,w.jsx)(oe,{className:`size-11`})}),A===`loading`?(0,w.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,w.jsx)(v,{className:`mx-auto h-8 w-64`}),(0,w.jsx)(v,{className:`mx-auto h-4 w-full max-w-lg`}),(0,w.jsx)(v,{className:`mx-auto size-4/5 max-w-md`}),(0,w.jsx)(v,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,A===`intro`?(0,w.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,w.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,w.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,w.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,w.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,w.jsxs)(S,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:q.pick,disabled:I||q.picking,children:[I||q.picking?(0,w.jsx)(g,{className:`size-4 animate-spin`}):(0,w.jsx)(h,{className:`size-4`}),t.chooseFolder]}),(0,w.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,w.jsx)(c,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,w.jsx)(`span`,{children:t.readOnlyNote})]}),R?(0,w.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null]}),(0,w.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),disabled:I,children:t.skip})]}):null,A===`consent`&&M?(0,w.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,w.jsxs)(`div`,{className:`text-center`,children:[(0,w.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,w.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,w.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,w.jsx)(h,{className:`size-5 shrink-0 text-accent-fg`}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:M.displayName}),(0,w.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:M.canonicalRootPath})]}),(0,w.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:M.projectKind===`coding`?t.codingProject:M.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,w.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.localFingerprint}),(0,w.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:M.fingerprint.branch?t.branchValue.replace(`{{branch}}`,M.fingerprint.branch):t.noGitBranch})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentActivity}),(0,w.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:t.changedFiles.replace(`{{count}}`,String(M.fingerprint.changedFileCount))})]}),M.fingerprint.recentAreas.length>0?(0,w.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,w.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentAreas}),(0,w.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:M.fingerprint.recentAreas.map(e=>(0,w.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,w.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,w.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,w.jsx)(u,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,w.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,w.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,w.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,w.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,w.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,w.jsx)(c,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,w.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:M.remoteModel?t.providerDisclosure.replace(`{{provider}}`,M.provider):t.localDisclosure})]})]})]}),R?(0,w.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null,(0,w.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,w.jsxs)(S,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:I,onClick:()=>void ce(),children:[I?(0,w.jsx)(g,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,w.jsx)(S,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:I,onClick:q.pick,children:t.changeFolder})]}),(0,w.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void J(),children:t.skip})]}):null,A===`running`&&P?(0,w.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,w.jsxs)(`div`,{className:`text-center`,children:[(0,w.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,w.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle})]}),(0,w.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:T.map((e,n)=>{let r=Math.max(0,T.indexOf(P.stage??`folder_structure`)),i=n<r,o=n===r;return(0,w.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,w.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,w.jsx)(a,{className:`size-4`}):o?(0,w.jsx)(g,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,w.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,w.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,w.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:P.rootPath}),(0,w.jsx)(`button`,{type:`button`,className:`mx-auto mt-7 block text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void se(P.id).then(K),children:t.cancelAnalysis})]}):null,A===`recognition`&&P?.result?(0,w.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,w.jsxs)(`div`,{className:`text-center`,children:[(0,w.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.recognitionEyebrow}),(0,w.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:P.result.lowConfidence?t.lowConfidenceTitle:t.recognitionTitle})]}),(0,w.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,w.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:P.result.projectSummary}),(0,w.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:P.result.currentState}),!P.result.lowConfidence&&Q?.evidence.length?(0,w.jsx)(`ul`,{className:`mt-5 space-y-2 border-t border-edge-subtle pt-4`,children:Q.evidence.slice(0,3).map((e,t)=>(0,w.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,w.jsx)(x,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,w.jsxs)(`span`,{children:[e.path?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${Q.id}-recognition-${t}`))}):null]}),P.result.lowConfidence?(0,w.jsxs)(`div`,{className:`mt-5`,children:[(0,w.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:P.result.contextQuestion}),(0,w.jsx)(`textarea`,{value:H,onChange:e=>U(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,w.jsx)(S,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:I||!H.trim(),onClick:()=>void Z(`different_goal`),children:t.continueWithCorrection})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,w.jsxs)(S,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:I,onClick:()=>void le(),children:[I?(0,w.jsx)(g,{className:`size-4 animate-spin`}):(0,w.jsx)(a,{className:`size-4`}),t.confirmUnderstanding]}),(0,w.jsx)(S,{variant:`secondary`,className:`h-11 flex-1`,disabled:I,onClick:()=>V(e=>!e),children:t.notQuiteRight})]}),B?(0,w.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,w.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:t.correctionLabel}),(0,w.jsx)(`textarea`,{id:`work-discovery-correction`,value:H,onChange:e=>U(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,w.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,w.jsx)(S,{variant:`ghost`,disabled:I||!H.trim(),onClick:()=>void Z(`different_goal`),children:t.differentGoal}),(0,w.jsx)(S,{variant:`primary`,disabled:I||!H.trim(),onClick:()=>void Z(`corrected`),children:t.useCorrection})]})]}):null]}),R?(0,w.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:R}):null,(0,w.jsx)(`button`,{type:`button`,disabled:I,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void ue(),children:t.openConversation})]}):null,A===`recommendation`&&P?.result&&Q?(0,w.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,w.jsxs)(`div`,{className:`text-center`,children:[(0,w.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.understandingConfirmed}),(0,w.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:t.primaryRecommendationTitle})]}),(0,w.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,w.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,w.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,w.jsx)(b,{className:`size-5`})}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Q.title}),(0,w.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Q.rationale}),(0,w.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,w.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,w.jsx)(re,{className:`size-3.5`}),t.estimatedMinutes.replace(`{{count}}`,String(Q.estimatedMinutes))]}),(0,w.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:(e=>e===`command`?t.riskCommand:e===`file_write`?t.riskFileWrite:t.riskAnalysis)(Q.risk)})]}),(0,w.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,w.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.expectedOutcome}),(0,w.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:Q.expectedOutcome})]}),(0,w.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,w.jsx)(S,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void X(Q,!1),children:t.startRecommendedAction}),(0,w.jsx)(S,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void X(Q,!0),children:t.explainFirst})]})]})]})}),$.length>0?(0,w.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,w.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:()=>G(e=>!e),children:[t.otherDirections,(0,w.jsx)(ae,{className:`size-4 transition-transform ${W?`rotate-180`:``}`})]}),W?(0,w.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:$.map(e=>(0,w.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void X(e,!0),children:[(0,w.jsx)(b,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,w.jsxs)(`span`,{children:[(0,w.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,w.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedOutcome})]})]},e.id))}):null]}):null,(0,w.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,w.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(P.sessionKey),children:t.doSomethingElse}),(0,w.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{V(!0),j(`recognition`)},children:t.correctUnderstanding})]})]}):null,A===`error`&&P?(0,w.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,w.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,w.jsx)(l,{className:`size-5`})}),(0,w.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,w.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:P.errorMessage}),(0,w.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,w.jsx)(S,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void ie(P.id).then(K),children:t.retry}),(0,w.jsx)(S,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{F(null),N(null),j(`intro`)},children:t.chooseDifferent})]}),(0,w.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(P.sessionKey),children:t.openConversation})]}):null]}),q.hasNativePicker?null:(0,w.jsx)(ee,{open:q.modalOpen,onOpenChange:q.setModalOpen,initialAbsolutePath:M?.canonicalRootPath,onConfirm:q.confirmPick,wd:n})]})}export{D 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{l as i,t as a,u as o}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as s}from"./cn-BQ_8x0bT.js";import{t as c}from"./messages-B0B40tpO.js";import{n as l}from"./locale-store-GfSwnwIZ.js";import{Bo as u,El as d,Fl as ee,Fs as te,Ml as ne,Oc as re,Rc as f,Va as ie,Yo as ae,Zo as p,a as oe,bu as m,cu as h,dc as g,et as _,f as se,fc as ce,l as le,m as ue,o as de,p as fe,s as pe,tu as me,u as v,vl as y,yc as b,ys as x,yt as he,zs as S}from"./index-apLU0Hun.js";var C=n(),w=e(t(),1),T=r();function ge(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?_(new Date(e)):``}function _e(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 ve(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 D(e){let t=(0,C.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,T.jsx)(`dt`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a=r||`-`,o;t[2]===a?o=t[3]:(o=(0,T.jsx)(`dd`,{className:`min-w-0 break-words text-sm text-fg`,children:a}),t[2]=a,t[3]=o);let s;return t[4]!==i||t[5]!==o?(s=(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[i,o]}),t[4]=i,t[5]=o,t[6]=s):s=t[6],s}function ye(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 bg-surface-panel px-4 py-8 text-center text-sm text-fg-muted shadow-surface`,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.jsx)(`article`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,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:`grid gap-3`,children:i}),t[7]=i,t[8]=a),a}function O(e){return new Set(e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fff]+/).filter(e=>e.length>=2))}function k(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=O(i),s=0;for(let e of O(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 A(e,t,n){return[...n].sort((n,r)=>k(e,t,r)-k(e,t,n)||n.title.localeCompare(r.title))}function j(){let{workItemId:e=``}=o(),t=i(),n=c(l(e=>e.language)).projectDetailPage.workItems,[r,_]=(0,w.useState)(null),[C,O]=(0,w.useState)(null),[j,M]=(0,w.useState)([]),[N,be]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(!0),[B,V]=(0,w.useState)(!1),[H,U]=(0,w.useState)(null),W=(0,w.useRef)(null),G=u(e=>e.setPageHeader),K=u(e=>e.clearPageHeader),q=(0,w.useMemo)(()=>r?`/projects/${encodeURIComponent(r.projectId)}/work-items`:`/projects`,[r]),J=(0,w.useCallback)(async()=>{if(e){z(!0),U(null);try{let[t,n]=await Promise.all([le(e),v(e).catch(()=>({events:[]}))]);_(t.item),L(t.item.nextAction||t.item.title),M(n.events);let[r,i]=await Promise.all([ie(t.item.projectId).catch(()=>null),he().catch(()=>[])]),a=A(t.item,r,i);O(r),be(a),F(e=>e||a[0]?.id||``)}catch(e){U(e instanceof Error?e.message:String(e))}finally{z(!1)}}},[e]);(0,w.useEffect)(()=>{J()},[J]);let Y=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await se(r.id);_(e.item),t(`/chat/${encodeURIComponent(e.session.key)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),X=(0,w.useCallback)(async()=>{if(r){V(!0),U(null);try{let e=await oe(r.id);_(e.item),t(`/goals/${encodeURIComponent(e.goal.id)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t]),Z=(0,w.useCallback)(async e=>{M((await v(e).catch(()=>({events:[]}))).events)},[]),xe=(0,w.useCallback)(async()=>{if(!(!r||!P)){V(!0),U(null);try{let e=await fe(r.id,{definitionId:P,goal:I.trim()||r.nextAction||r.title});_(e.item),await Z(e.item.id),t(`/workflows?run=${encodeURIComponent(e.runId)}`)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,t,Z,P,I]),Se=(0,w.useCallback)(async e=>{if(!(!r||!e.length)){V(!0),U(null);try{let t=await ue(r.id,e);_(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),Ce=(0,w.useCallback)(async e=>{if(r){V(!0),U(null);try{let t=await de(r.id,e.id);_(t.item),await Z(t.item.id)}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},[r,Z]),we=(0,w.useCallback)(async e=>{if(r){U(null);try{await pe(r.id,e)}catch(e){U(e instanceof Error?e.message:String(e))}}},[r]),Q=(0,w.useMemo)(()=>r?N.filter(e=>k(r,C,e)>0).slice(0,3):[],[r,C,N]),$=(0,w.useMemo)(()=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(x,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void J(),children:[(0,T.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:n.refreshShort})]}),r?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.startChat})]}),(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.createGoal})]})]}):null]}),[B,X,Y,r,J,n.detail.createGoal,n.detail.startChat,n.refreshShort]);return(0,w.useLayoutEffect)(()=>(G({startExtra:(0,T.jsx)(a,{to:q,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)(m,{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)(h,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r?.title??(R?n.detail.loading:n.detail.notFound)})]}),r?(0,T.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[n.statuses[r.status],` · `,n.priorities[r.priority],` · `,C?.name||r.projectId,` · `,n.updated,`: `,E(r.updatedAt)]}):null]}),end:$}),()=>K()),[K,$,r,R,C?.name,q,G,n,C]),R?(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`,"aria-busy":!0,children:[(0,T.jsx)(`div`,{className:`h-8 w-40 animate-pulse rounded-md bg-surface-hover`}),(0,T.jsx)(`div`,{className:`mt-5 h-44 animate-pulse rounded-xl bg-surface-hover`})]}):H||!r?(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)(a,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(m,{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:H||n.detail.notFound})]}):(0,T.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[var(--max-width-app-main)] flex-1 flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface sm:px-5`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(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)(h,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,T.jsx)(`h1`,{className:`min-w-0 break-words text-lg font-semibold leading-7 text-fg`,children:r.title})]}),(0,T.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,T.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 font-medium`,ge(r.status)),children:n.statuses[r.status]}),(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.priorities[r.priority]}),r.archivedAt?(0,T.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-fg-muted`,children:n.detail.archived}):null]})]}),(0,T.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startChat]}),(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),n.detail.createGoal]})]})]}),(0,T.jsxs)(`dl`,{className:`mt-5 grid gap-4 border-t border-edge pt-4 sm:grid-cols-2`,children:[(0,T.jsx)(D,{label:n.create.descriptionLabel,value:r.description||n.detail.noDescription}),(0,T.jsx)(D,{label:n.nextAction,value:r.nextAction||n.noNextAction}),(0,T.jsx)(D,{label:n.blockedReason,value:r.blockedReason||n.detail.noBlockedReason}),(0,T.jsx)(D,{label:n.updated,value:E(r.updatedAt)})]})]}),(0,T.jsxs)(`div`,{className:`mt-4 grid min-h-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,T.jsxs)(`section`,{className:`min-w-0`,children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,T.jsx)(d,{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)(ye,{events:j,t:n})]}),(0,T.jsxs)(`aside`,{className:`grid content-start gap-4`,children:[(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`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)(y,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.detail.workflowTitle})]})}),(0,T.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.detail.workflowHint}),(0,T.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,T.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-subtle`,children:[n.detail.workflowTemplate,(0,T.jsxs)(ae,{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:P,disabled:B||N.length===0,onChange:e=>F(e.target.value),children:[N.length===0?(0,T.jsx)(p,{value:``,children:n.detail.noWorkflowTemplates}):null,N.map(e=>(0,T.jsx)(p,{value:e.id,children:e.title},e.id))]})]}),Q.length?(0,T.jsxs)(`div`,{className:`grid gap-1`,children:[(0,T.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n.detail.recommendedWorkflows}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Q.map(e=>(0,T.jsx)(`button`,{type:`button`,className:s(`min-w-0 rounded-md border px-2 py-1 text-left text-xs transition-colors`,P===e.id?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg`),disabled:B,onClick:()=>F(e.id),children:(0,T.jsx)(`span`,{className:`block max-w-48 truncate`,children:e.title})},e.id))})]}):null,(0,T.jsxs)(`label`,{className:`grid gap-1 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 text-sm font-normal text-fg outline-none focus:border-accent`,value:I,disabled:B,onChange:e=>L(e.target.value)})]}),(0,T.jsxs)(x,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-xs`,disabled:B||!P,onClick:xe,children:[(0,T.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startWorkflow]}),N.length?null:(0,T.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.detail.noWorkflowTemplates})]})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,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)(re,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.attachments.title})]}),(0,T.jsxs)(x,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:()=>W.current?.click(),children:[(0,T.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),n.attachments.add]}),(0,T.jsx)(`input`,{ref:W,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Se(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 border border-edge bg-surface-base p-2 text-sm`,children:[(0,T.jsx)(d,{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.jsxs)(`div`,{className:`truncate text-xs text-fg-subtle`,children:[e.mimeType,` · `,_e(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:B,onClick:()=>void we(e),children:(0,T.jsx)(ee,{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:B,onClick:()=>void Ce(e),children:(0,T.jsx)(te,{className:`size-3.5`,"aria-hidden":!0})})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.attachments.empty})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.links}),(0,T.jsx)(`div`,{className:`mt-3 grid gap-1 text-sm`,children:r.links?.length?r.links.map(e=>(0,T.jsxs)(a,{to:ve(e),className:`flex min-w-0 items-center justify-between gap-3 rounded-md px-2 py-1.5 hover:bg-surface-hover`,children:[(0,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)(ne,{className:`size-3.5`,"aria-hidden":!0})]})]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.detail.noLinks})})]}),(0,T.jsxs)(`section`,{className:`rounded-lg bg-surface-panel px-4 py-3 shadow-surface`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.detail.project}),(0,T.jsxs)(a,{to:q,className:`mt-2 inline-flex min-w-0 items-center gap-2 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(me,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`min-w-0 truncate`,children:C?.name||r.projectId})]})]})]})]})]})}export{j as WorkItemDetailPage};
@@ -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{l as i,t as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./check-BODqo66o.js";import{t as c}from"./circle-alert-RzVebuX2.js";import{t as l}from"./messages-B0B40tpO.js";import{n as u,r as d,s as f}from"./locale-store-GfSwnwIZ.js";import{n as p}from"./activity-store-uu1xu9Pl.js";import{Bc as m,Bo as h,Cl as g,Cs as _,Fo as v,Fs as y,Io as b,Lo as x,No as S,Po as C,Ps as w,R as T,Ro as E,Tu as D,Uc as O,Wl as k,Xc as A,Ys as j,ac as M,et as N,jl as ee,lo as P,ol as F,ou as te,qa as ne,ru as re,tu as ie,yc as ae,ys as I,yu as L,za as oe,zo as se}from"./index-apLU0Hun.js";var R=n(),z=e(t(),1),B=r(),V=6,H={info:{Icon:F,className:`text-accent-fg bg-accent-soft`},success:{Icon:ie,className:`text-success bg-success-soft`},warning:{Icon:w,className:`text-warning bg-warning-soft`},error:{Icon:c,className:`text-danger bg-danger-soft`}};function U(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 W(e){let t=(0,R.c)(52),{item:n}=e,r=u(K),i;t[0]===r?i=t[1]:(i=l(r),t[0]=r,t[1]=i);let s=i.projectsPage.workHome,c=p(G),{Icon:d,className:f}=H[n.tone],m;t[2]===f?m=t[3]:(m=o(`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg`,f),t[2]=f,t[3]=m);let h;t[4]!==d||t[5]!==n.status?(h=n.status===`running`?(0,B.jsx)(O,{className:`size-3.5 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,B.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),t[4]=d,t[5]=n.status,t[6]=h):h=t[6];let g;t[7]!==m||t[8]!==h?(g=(0,B.jsx)(`div`,{className:m,children:h}),t[7]=m,t[8]=h,t[9]=g):g=t[9];let v;t[10]===n.title?v=t[11]:(v=(0,B.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,B.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,B.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,B.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,B.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]!==r?(C=U(n.updatedAt,r),t[22]=n.updatedAt,t[23]=r,t[24]=C):C=t[24];let w;t[25]===C?w=t[26]:(w=(0,B.jsx)(`span`,{children:C}),t[25]=C,t[26]=w);let T;t[27]===n.occurrences?T=t[28]:(T=n.occurrences>1?(0,B.jsxs)(`span`,{children:[`×`,n.occurrences]}):null,t[27]=n.occurrences,t[28]=T);let E;t[29]!==s.activityViewRelated||t[30]!==n.href?(E=n.href?(0,B.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,B.jsx)(re,{className:`size-3`,"aria-hidden":!0})]}):null,t[29]=s.activityViewRelated,t[30]=n.href,t[31]=E):E=t[31];let D;t[32]!==w||t[33]!==T||t[34]!==E||t[35]!==S?(D=(0,B.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] text-fg-subtle`,children:[S,w,T,E]}),t[32]=w,t[33]=T,t[34]=E,t[35]=S,t[36]=D):D=t[36];let k;t[37]!==D||t[38]!==b||t[39]!==x?(k=(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x,D]}),t[37]=D,t[38]=b,t[39]=x,t[40]=k):k=t[40];let A;t[41]!==n.id||t[42]!==c?(A=()=>c(n.id),t[41]=n.id,t[42]=c,t[43]=A):A=t[43];let j;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,B.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),t[44]=j):j=t[44];let M;t[45]!==s.activityRemove||t[46]!==A?(M=(0,B.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[45]=s.activityRemove,t[46]=A,t[47]=M):M=t[47];let N;return t[48]!==k||t[49]!==M||t[50]!==g?(N=(0,B.jsxs)(`article`,{className:`group flex items-start gap-3 border-t border-edge-subtle px-1 py-3 first:border-t-0`,children:[g,k,M]}),t[48]=k,t[49]=M,t[50]=g,t[51]=N):N=t[51],N}function G(e){return e.remove}function K(e){return e.language}function ce(){let e=(0,R.c)(8),t=l(u(ue)).projectsPage.workHome,n=p($),r=p(Q),i=p(le),[a,o]=(0,z.useState)(!1),c;e[0]===n?c=e[1]:(c=n.filter(Z),e[0]=n,e[1]=c);let d=c.length,f;e[2]===n?f=e[3]:(f=n.filter(X),e[2]=n,e[3]=f);let m=f.length,h;e[4]!==a||e[5]!==n?(h=a?n:n.slice(0,V),e[4]=a,e[5]=n,e[6]=h):h=e[6];let g=h,_;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,B.jsx)(D,{className:`size-4 text-accent`,"aria-hidden":!0}),e[7]=_):_=e[7],(0,B.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,"aria-labelledby":`workbench-activity-title`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_,(0,B.jsx)(`h2`,{id:`workbench-activity-title`,className:`text-sm font-semibold text-fg`,children:t.activityTitle}),d>0?(0,B.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,B.jsx)(O,{className:`size-3 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),d,` `,t.running]}):m>0?(0,B.jsxs)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[m,` `,t.activityNew]}):null]}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.activityHint})]}),n.length>0?(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[m>0?(0,B.jsxs)(I,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:r,children:[(0,B.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),t.activityMarkRead]}):null,n.some(Y)?(0,B.jsxs)(I,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-fg-muted`,onClick:i,children:[(0,B.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),t.activityClearFinished]}):null]}):null]}),n.length>0?(0,B.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-panel px-3`,children:[g.map(J),n.length>V?(0,B.jsx)(`div`,{className:`border-t border-edge-subtle py-2 text-center`,children:(0,B.jsx)(I,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>o(q),children:a?t.activityShowLess:t.activityShowAll.replace(`{{count}}`,String(n.length))})}):null]}):(0,B.jsxs)(`div`,{className:`mt-4 flex min-h-28 flex-col items-center justify-center rounded-xl bg-surface-panel px-6 text-center`,children:[(0,B.jsx)(k,{className:`size-5 text-fg-subtle`,"aria-hidden":!0}),(0,B.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:t.activityEmpty}),(0,B.jsx)(`p`,{className:`mt-1 max-w-lg text-xs leading-5 text-fg-muted`,children:t.activityEmptyBody})]})]})}function q(e){return!e}function J(e){return(0,B.jsx)(W,{item:e},e.id)}function Y(e){return e.status===`done`}function X(e){return!e.read}function Z(e){return e.status===`running`}function le(e){return e.clearFinished}function Q(e){return e.markAllRead}function $(e){return e.items}function ue(e){return e.language}function de(e){return f(d(`/api/home${e?`?locale=${encodeURIComponent(e)}`:``}`))}function fe(e,t){return f(d(`/api/home/decisions/respond`),{method:`POST`,body:JSON.stringify({...e,decision:t})})}function pe(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function me(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:N(n)}function he(){let e=(0,R.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,B.jsx)(P,{className:`h-32 rounded-2xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,B.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[t,(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,B.jsx)(P,{className:`h-64 rounded-2xl`}),(0,B.jsx)(P,{className:`h-64 rounded-2xl`})]}),(0,B.jsx)(P,{className:`h-44 rounded-2xl`})]}),e[1]=n):n=e[1],n}function ge(e){let t=(0,R.c)(22),{item:n,statusLabel:r,needsAttention:i}=e,s=i===void 0?!1:i,c=`/work-items/${encodeURIComponent(n.id)}`,l=s?`border-warning/35 bg-warning-soft/25 hover:bg-warning-soft/40`:`border-edge-subtle bg-surface-panel hover:bg-surface-hover/55`,u;t[0]===l?u=t[1]:(u=o(`group block rounded-xl border p-3.5 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,l),t[0]=l,t[1]=u);let d;t[2]===n.title?d=t[3]:(d=(0,B.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[2]=n.title,t[3]=d);let f;t[4]===n.projectName?f=t[5]:(f=(0,B.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.projectName}),t[4]=n.projectName,t[5]=f);let p;t[6]!==d||t[7]!==f?(p=(0,B.jsxs)(`div`,{className:`min-w-0`,children:[d,f]}),t[6]=d,t[7]=f,t[8]=p):p=t[8];let m;t[9]===r?m=t[10]:(m=(0,B.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[9]=r,t[10]=m);let h;t[11]!==p||t[12]!==m?(h=(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==n.blockedReason||t[15]!==n.nextAction?(g=n.blockedReason||n.nextAction?(0,B.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.blockedReason||n.nextAction}):null,t[14]=n.blockedReason,t[15]=n.nextAction,t[16]=g):g=t[16];let _;return t[17]!==g||t[18]!==c||t[19]!==u||t[20]!==h?(_=(0,B.jsxs)(a,{to:c,className:u,children:[h,g]}),t[17]=g,t[18]=c,t[19]=u,t[20]=h,t[21]=_):_=t[21],_}function _e(e){let t=(0,R.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,B.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,B.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,B.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,B.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,B.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 g;t[12]===n.detail?g=t[13]:(g=n.detail?(0,B.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]=g);let _;t[14]!==n.href||t[15]!==h||t[16]!==g?(_=(0,B.jsxs)(a,{to:n.href,className:`group block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[h,g]}),t[14]=n.href,t[15]=h,t[16]=g,t[17]=_):_=t[17];let v;t[18]!==o||t[19]!==c||t[20]!==s||t[21]!==n.response||t[22]!==l?(v=n.response?(0,B.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2 border-t border-warning/20 pt-3`,children:[(0,B.jsx)(I,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:c,onClick:()=>l(`deny`),children:s}),(0,B.jsx)(I,{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]=v):v=t[23];let y;return t[24]!==_||t[25]!==v?(y=(0,B.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]}),t[24]=_,t[25]=v,t[26]=y):y=t[26],y}function ve(e){let t=(0,R.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,B.jsx)(g,{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,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,(0,B.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,B.jsx)(L,{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,B.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,B.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=me(p,``),t[10]=p,t[11]=m);let h;t[12]===m?h=t[13]:(h=(0,B.jsx)(`p`,{className:`mt-auto pt-3 text-[11px] text-fg-subtle`,children:m}),t[12]=m,t[13]=h);let _;return t[14]!==o||t[15]!==h||t[16]!==u||t[17]!==f?(_=(0,B.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]=_):_=t[18],_}function ye(){let e=u(e=>e.language),t=l(e),n=t.projectsPage,r=i(),o=h(e=>e.setPageHeader),s=h(e=>e.clearPageHeader),[d,f]=(0,z.useState)(null),[p,g]=(0,z.useState)([]),[_,y]=(0,z.useState)(!0),[w,D]=(0,z.useState)(null),[O,N]=(0,z.useState)(null),[P,F]=(0,z.useState)(``),[re,L]=(0,z.useState)(!1),[R,V]=(0,z.useState)(`delegate`),[H,U]=(0,z.useState)(``),[W,G]=(0,z.useState)(!1),[K,q]=(0,z.useState)(null),J=(0,z.useCallback)(async()=>{y(!0),D(null);try{let[t,n]=await Promise.all([de(e),ne({limit:100,sortBy:`updatedAt`,sortOrder:`desc`})]);f(t),g(n.items)}catch(e){D(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e]);(0,z.useEffect)(()=>{J()},[J]);let Y=(0,z.useMemo)(()=>{let e=P.trim().toLocaleLowerCase(),t=p.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,12)},[p,P]),X=(0,z.useMemo)(()=>d?.decisions??[],[d]),Z=(0,z.useMemo)(()=>d?.work.current.filter(e=>e.status!==`needs_input`&&e.status!==`in_review`&&e.status!==`blocked`).slice(0,10)??[],[d]),le=(0,z.useCallback)(async t=>{t.preventDefault();let n=H.trim();if(!(!n||W)){if(R===`watch`){let t=e===`zh`?`持续关注以下事项,在发生有意义的变化时通知我:\n${n}`:`Keep watching the following and notify me when something meaningfully changes:\n${n}`;U(``),L(!1),r(`/automations?draft=${encodeURIComponent(t)}&autogenerate=1`);return}G(!0),N(null);try{let t=await oe({outcome:n,uiLocale:e});U(``),L(!1),r(`/projects/${encodeURIComponent(t.project.id)}`)}catch(e){N(e instanceof Error?e.message:String(e))}finally{G(!1)}}},[R,W,e,r,H]),Q=(0,z.useMemo)(()=>(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsxs)(I,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:()=>{V(`watch`),L(!0)},children:[(0,B.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),n.workHome.watch]}),(0,B.jsxs)(I,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>{V(`delegate`),L(!0)},children:[(0,B.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),n.workHome.delegate]})]}),[n.workHome.delegate,n.workHome.watch]),$=(0,z.useCallback)(async(e,t)=>{if(e.response){q(e.id),D(null);try{await fe(e.response,t),await J()}catch(e){D(e instanceof Error?e.message:String(e))}finally{q(null)}}},[J]);return(0,z.useLayoutEffect)(()=>(o({startExtra:null,main:(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,B.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.workHome.subtitle})]}),end:Q}),()=>s()),[s,Q,o,n.title,n.workHome.subtitle]),(0,B.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,B.jsx)(S,{open:re,onOpenChange:e=>{L(e),e||N(null)},children:(0,B.jsxs)(E,{children:[(0,B.jsx)(x,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,B.jsxs)(v,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(26rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,B.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,B.jsx)(se,{className:`text-base font-semibold text-fg`,children:R===`watch`?n.workHome.watchTitle:n.workHome.delegateTitle}),(0,B.jsx)(b,{className:`mt-1 text-sm text-fg-muted`,children:R===`watch`?n.workHome.watchDescription:n.workHome.delegateDescription})]}),(0,B.jsxs)(`form`,{onSubmit:le,className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 px-5 py-4`,children:[(0,B.jsxs)(`label`,{className:`grid gap-2 text-sm font-medium text-fg`,children:[R===`watch`?n.workHome.watchLabel:n.workHome.outcomeLabel,(0,B.jsx)(`textarea`,{className:`min-h-40 w-full 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:H,onChange:e=>U(e.target.value),placeholder:R===`watch`?n.workHome.watchPlaceholder:n.workHome.outcomePlaceholder,maxLength:12e3,disabled:W})]}),O?(0,B.jsx)(`p`,{className:`mt-3 rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:O}):null]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-5 py-4`,children:[(0,B.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:R===`watch`?n.workHome.watchSetupHint:n.workHome.autoSetupHint}),(0,B.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,B.jsx)(C,{asChild:!0,children:(0,B.jsx)(I,{type:`button`,variant:`ghost`,children:n.cancel})}),(0,B.jsxs)(I,{type:`submit`,variant:`primary`,disabled:W||!H.trim(),children:[(0,B.jsx)(j,{className:`size-4`,"aria-hidden":!0}),W?n.workHome.delegating:R===`watch`?n.workHome.designWatch:n.workHome.delegate]})]})]})]})]})]})}),w?(0,B.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,B.jsx)(`span`,{children:w}),(0,B.jsx)(I,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void J(),children:n.workHome.retry})]}):null,_?(0,B.jsx)(he,{}):d?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{className:`relative overflow-hidden rounded-2xl border border-accent/15 bg-gradient-to-br from-accent-soft/70 via-surface-panel to-surface-panel p-5 sm:p-6`,children:[(0,B.jsx)(`div`,{className:`absolute -right-8 -top-12 size-40 rounded-full bg-accent/10 blur-3xl`,"aria-hidden":!0}),(0,B.jsxs)(`div`,{className:`relative flex flex-wrap items-end justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,B.jsx)(`div`,{className:`mb-3 flex size-10 items-center justify-center rounded-xl bg-accent text-white`,children:(0,B.jsx)(A,{className:`size-5`,"aria-hidden":!0})}),(0,B.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-accent`,children:n.workHome.briefingTitle}),(0,B.jsx)(`h2`,{className:`mt-1 text-xl font-semibold tracking-tight text-fg`,children:n.workHome.heroTitle}),(0,B.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:d.briefing.summary})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs`,children:[(0,B.jsx)(`span`,{className:`rounded-full bg-surface-panel/80 px-3 py-1.5 text-fg-muted`,children:pe(n.workHome.activeCount,{count:d.briefing.progress.movingCount})}),d.decisions.length>0?(0,B.jsx)(`span`,{className:`rounded-full bg-warning-soft px-3 py-1.5 text-fg`,children:pe(n.workHome.attentionCount,{count:d.decisions.length})}):null]})]})]}),d.work.current.length===0&&d.workflowRuns.active.length===0?(0,B.jsxs)(`section`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,B.jsx)(m,{className:`mx-auto size-6 text-accent`,"aria-hidden":!0}),(0,B.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:n.workHome.emptyTitle}),(0,B.jsx)(`p`,{className:`mx-auto mt-1 max-w-lg text-sm leading-6 text-fg-muted`,children:n.workHome.emptyBody}),(0,B.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,B.jsx)(I,{type:`button`,variant:`primary`,onClick:()=>r(`/chat/new`),children:n.workHome.startChat}),(0,B.jsx)(I,{type:`button`,variant:`secondary`,onClick:()=>{V(`delegate`),L(!0)},children:n.workHome.startLongWork})]})]}):null,(0,B.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,B.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(c,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,B.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.needsYou})]}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.workHome.needsYouHint}),(0,B.jsx)(`div`,{className:`mt-4 space-y-2`,children:X.length?X.map(e=>(0,B.jsx)(_e,{item:e,kindLabel:n.workHome.decisionKinds[e.kind],reasonLabel:n.workHome.decisionReasons[e.reason],approveLabel:n.workHome.approve,denyLabel:n.workHome.deny,busy:K===e.id,onRespond:t=>void $(e,t)},e.id)):(0,B.jsx)(`p`,{className:`rounded-xl bg-surface-panel px-4 py-6 text-center text-sm text-fg-muted`,children:n.workHome.nothingNeedsYou})})]}),(0,B.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(k,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,B.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.continueTitle})]}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.workHome.continueHint}),(0,B.jsx)(`div`,{className:`mt-4 space-y-2`,children:Z.length?Z.map(e=>(0,B.jsx)(ge,{item:e,statusLabel:t.projectDetailPage.workItems.statuses[e.status]},e.id)):(0,B.jsx)(`p`,{className:`rounded-xl bg-surface-panel px-4 py-6 text-center text-sm text-fg-muted`,children:n.workHome.noCurrentWork})})]})]}),d.workflowRuns.active.length>0||d.upcomingAutomations.length>0?(0,B.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,B.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(j,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,B.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.processing})]}),(0,B.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[d.workflowRuns.active.map(e=>(0,B.jsxs)(a,{to:T(e.id),className:`flex items-center justify-between gap-3 rounded-xl bg-surface-panel p-3 text-sm hover:bg-surface-hover`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.title}),(0,B.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.workHome.running})]},e.id)),d.workflowRuns.active.length===0?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.workHome.nothingRunning}):null]})]}),(0,B.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(te,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,B.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.scheduled})]}),(0,B.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[d.upcomingAutomations.map(e=>(0,B.jsxs)(a,{to:`/automations`,className:`flex items-center justify-between gap-3 rounded-xl bg-surface-panel p-3 text-sm hover:bg-surface-hover`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.name||e.action}),(0,B.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:me(e.nextRunAt,n.never)})]},e.id)),d.upcomingAutomations.length===0?(0,B.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.workHome.noScheduled}):null]})]})]}):null,d.briefing.wins.length>0?(0,B.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(ie,{className:`size-4 text-success`,"aria-hidden":!0}),(0,B.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.completed})]}),(0,B.jsx)(`div`,{className:`mt-3 grid gap-2 md:grid-cols-2 xl:grid-cols-3`,children:d.briefing.wins.map(e=>(0,B.jsxs)(a,{to:e.href,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3.5 transition-colors hover:bg-surface-hover/55`,children:[(0,B.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.workHome.winKinds[e.kind]})]},e.id))})]}):null,(0,B.jsx)(ce,{})]}):null,(0,B.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.spacesTitle}),(0,B.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.workHome.spacesHint})]}),(0,B.jsx)(a,{to:`/projects`,className:`text-xs font-medium text-accent hover:underline`,children:n.management.viewAll})]}),(0,B.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,B.jsxs)(`label`,{className:`relative block min-w-0`,children:[(0,B.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,B.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:P,onChange:e=>F(e.target.value),placeholder:n.searchPlaceholder,"aria-label":n.searchPlaceholder})]})}),(0,B.jsx)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:Y.map(e=>(0,B.jsx)(ve,{project:e,openLabel:n.workHome.openSpace,noDescription:n.noDescription},e.id))}),!_&&Y.length===0?(0,B.jsx)(`p`,{className:`py-8 text-center text-sm text-fg-muted`,children:n.workHome.noSpaces}):null]})]})}export{ye as WorkPage};
@@ -0,0 +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-BQ_8x0bT.js";import{t as a}from"./messages-B0B40tpO.js";import{o,r as s}from"./locale-store-GfSwnwIZ.js";import{$i as c,Cs as l,D as u,Fo as d,H as f,Lo as p,M as m,No as h,Po as g,Q as _,Ro as v,Yo as y,Ys as b,Z as x,Zo as S,Zs as C,au as w,fc as T,jl as E,ks as D,qs as O,rl as k,ys as A,zo as j,zs as M}from"./index-apLU0Hun.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
+ `).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
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)(232),{value:n,onApply:r,fieldId:a,fieldLabel:o,scenario:s,format:u,intent:f,locale:m,context:_,disabled:y,className:x,showLabel:S}=e,C=s===void 0?`generic.text`:s,D=u===void 0?`plain`:u,k=f===void 0?`improve`:f,M=S===void 0?!0:S,[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=(0,N.useRef)(null),se=(0,N.useRef)(!0),{suggestion:q,thinking:J,loading:Y,error:X,generate:ce,reset:le}=ee(),ue;t[0]===m?ue=t[1]:(ue=ne(m),t[0]=m,t[1]=ue);let Z=ue,de;t[2]!==Y||t[3]!==J?(de=Y&&J.trim().length>0,t[2]=Y,t[3]=J,t[4]=de):de=t[4];let Q=de,fe,pe;t[5]!==F||t[6]!==n?(fe=()=>{F||R(n)},pe=[F,n],t[5]=F,t[6]=n,t[7]=fe,t[8]=pe):(fe=t[7],pe=t[8]),(0,N.useEffect)(fe,pe);let me,he;t[9]===q?(me=t[10],he=t[11]):(he=()=>{U(q)},me=[q],t[9]=q,t[10]=me,t[11]=he),(0,N.useEffect)(he,me);let ge,_e;t[12]===J?(ge=t[13],_e=t[14]):(ge=()=>{J.trim()&&K(!0)},_e=[J],t[12]=J,t[13]=ge,t[14]=_e),(0,N.useEffect)(ge,_e);let ve;t[15]!==Q||t[16]!==G?(ve=()=>{let e=oe.current;!e||!Q||!G||se.current&&(e.scrollTop=e.scrollHeight)},t[15]=Q,t[16]=G,t[17]=ve):ve=t[17];let ye;t[18]!==Q||t[19]!==J||t[20]!==G?(ye=[Q,J,G],t[18]=Q,t[19]=J,t[20]=G,t[21]=ye):ye=t[21],(0,N.useLayoutEffect)(ve,ye);let be;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>{let e=oe.current;e&&(se.current=e.scrollHeight-e.scrollTop-e.clientHeight<=te)},t[22]=be):be=t[22];let xe=be,Se;t[23]!==_||t[24]!==a||t[25]!==o||t[26]!==D||t[27]!==ce||t[28]!==k||t[29]!==m||t[30]!==C?(Se=async e=>{ae(`edit`),K(!0),se.current=!0,await ce({intent:k,scenario:C,input:e,locale:m,field:{id:a,label:o,format:D},context:_})},t[23]=_,t[24]=a,t[25]=o,t[26]=D,t[27]=ce,t[28]=k,t[29]=m,t[30]=C,t[31]=Se):Se=t[31];let Ce=Se,we;t[32]!==le||t[33]!==n?(we=()=>{R(n),V(`preview`),U(``),ae(`edit`),K(!0),le(),I(!0)},t[32]=le,t[33]=n,t[34]=we):we=t[34];let Te=we,Ee;t[35]!==L||t[36]!==Ce?(Ee=async()=>{await Ce(L)},t[35]=L,t[36]=Ce,t[37]=Ee):Ee=t[37];let De=Ee,Oe;t[38]!==le||t[39]!==n?(Oe=()=>{I(!1),R(n),V(`preview`),U(``),ae(`edit`),K(!0),le()},t[38]=le,t[39]=n,t[40]=Oe):Oe=t[40];let $=Oe,ke;t[41]!==$||t[42]!==L||t[43]!==r?(ke=()=>{r(L),$()},t[41]=$,t[42]=L,t[43]=r,t[44]=ke):ke=t[44];let Ae=ke,je;t[45]!==$||t[46]!==H||t[47]!==r?(je=()=>{H.trim()&&(r(H),$())},t[45]=$,t[46]=H,t[47]=r,t[48]=je):je=t[48];let Me=je,Ne;t[49]!==$||t[50]!==L||t[51]!==H||t[52]!==r?(Ne=()=>{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]=Ne):Ne=t[53];let Pe=Ne,Fe;t[54]!==H||t[55]!==X||t[56]!==Y?(Fe=!Y&&!X&&H.trim().length>0,t[54]=H,t[55]=X,t[56]=Y,t[57]=Fe):Fe=t[57];let Ie=Fe,Le=L!==n,Re;t[58]!==H||t[59]!==X||t[60]!==J?(Re=H.trim().length>0||J.trim().length>0||!!X,t[58]=H,t[59]=X,t[60]=J,t[61]=Re):Re=t[61];let ze=Re,Be=!M&&`size-7 p-0`,Ve;t[62]!==x||t[63]!==Be?(Ve=i(`h-7 gap-1 px-2 text-xs`,Be,x),t[62]=x,t[63]=Be,t[64]=Ve):Ve=t[64];let He=y||Y,Ue;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,z.jsx)(b,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[65]=Ue):Ue=t[65];let We=M?Z.buttonTitle:null,Ge;t[66]!==Z.buttonTitle||t[67]!==Te||t[68]!==Ve||t[69]!==He||t[70]!==We?(Ge=(0,z.jsxs)(A,{type:`button`,variant:`ghost`,className:Ve,title:Z.buttonTitle,"aria-label":Z.buttonTitle,disabled:He,onClick:Te,children:[Ue,We]}),t[66]=Z.buttonTitle,t[67]=Te,t[68]=Ve,t[69]=He,t[70]=We,t[71]=Ge):Ge=t[71];let Ke;t[72]===$?Ke=t[73]:(Ke=e=>e?I(!0):$(),t[72]=$,t[73]=Ke);let qe;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(qe=(0,z.jsx)(p,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim`}),t[74]=qe):qe=t[74];let Je;t[75]===Z.title?Je=t[76]:(Je=(0,z.jsx)(j,{className:`text-base font-semibold text-fg`,children:Z.title}),t[75]=Z.title,t[76]=Je);let Ye;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(Ye=(0,z.jsx)(l,{className:`size-5`,strokeWidth:1.75}),t[77]=Ye):Ye=t[77];let Xe;t[78]===Z.close?Xe=t[79]:(Xe=(0,z.jsx)(g,{asChild:!0,children:(0,z.jsx)(A,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":Z.close,children:Ye})}),t[78]=Z.close,t[79]=Xe);let Ze;t[80]!==Je||t[81]!==Xe?(Ze=(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[Je,Xe]}),t[80]=Je,t[81]=Xe,t[82]=Ze):Ze=t[82];let Qe;t[83]===Z.current?Qe=t[84]:(Qe=(0,z.jsx)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:Z.current}),t[83]=Z.current,t[84]=Qe);let $e=B===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,et;t[85]===$e?et=t[86]:(et=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,$e),t[85]=$e,t[86]=et);let tt,nt;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(tt=()=>V(`edit`),nt=(0,z.jsx)(O,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[87]=tt,t[88]=nt):(tt=t[87],nt=t[88]);let rt;t[89]!==Z.edit||t[90]!==et?(rt=(0,z.jsxs)(`button`,{type:`button`,className:et,onClick:tt,children:[nt,Z.edit]}),t[89]=Z.edit,t[90]=et,t[91]=rt):rt=t[91];let it=B===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,at;t[92]===it?at=t[93]:(at=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,it),t[92]=it,t[93]=at);let ot,st;t[94]===Symbol.for(`react.memo_cache_sentinel`)?(ot=()=>V(`preview`),st=(0,z.jsx)(E,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[94]=ot,t[95]=st):(ot=t[94],st=t[95]);let ct;t[96]!==Z.preview||t[97]!==at?(ct=(0,z.jsxs)(`button`,{type:`button`,className:at,onClick:ot,children:[st,Z.preview]}),t[96]=Z.preview,t[97]=at,t[98]=ct):ct=t[98];let lt;t[99]!==rt||t[100]!==ct?(lt=(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[rt,ct]}),t[99]=rt,t[100]=ct,t[101]=lt):lt=t[101];let ut;t[102]!==Qe||t[103]!==lt?(ut=(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[Qe,lt]}),t[102]=Qe,t[103]=lt,t[104]=ut):ut=t[104];let dt;t[105]!==L||t[106]!==B||t[107]!==D||t[108]!==Z.current||t[109]!==Z.empty?(dt=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:D===`markdown`?(0,z.jsx)(c,{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[105]=L,t[106]=B,t[107]=D,t[108]=Z.current,t[109]=Z.empty,t[110]=dt):dt=t[110];let ft;t[111]!==ut||t[112]!==dt?(ft=(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[ut,dt]}),t[111]=ut,t[112]=dt,t[113]=ft):ft=t[113];let pt;t[114]===Z.editedSuggestion?pt=t[115]:(pt=(0,z.jsx)(`span`,{children:Z.editedSuggestion}),t[114]=Z.editedSuggestion,t[115]=pt);let mt;t[116]!==Z.loading||t[117]!==Y?(mt=Y?(0,z.jsx)(`span`,{className:`ml-2 font-normal`,children:Z.loading}):null,t[116]=Z.loading,t[117]=Y,t[118]=mt):mt=t[118];let ht;t[119]!==pt||t[120]!==mt?(ht=(0,z.jsxs)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:[pt,mt]}),t[119]=pt,t[120]=mt,t[121]=ht):ht=t[121];let gt=W===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,_t;t[122]===gt?_t=t[123]:(_t=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,gt),t[122]=gt,t[123]=_t);let vt,yt;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(vt=()=>ae(`edit`),yt=(0,z.jsx)(O,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[124]=vt,t[125]=yt):(vt=t[124],yt=t[125]);let bt;t[126]!==Z.edit||t[127]!==_t?(bt=(0,z.jsxs)(`button`,{type:`button`,className:_t,onClick:vt,children:[yt,Z.edit]}),t[126]=Z.edit,t[127]=_t,t[128]=bt):bt=t[128];let xt=W===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,St;t[129]===xt?St=t[130]:(St=i(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,xt),t[129]=xt,t[130]=St);let Ct,wt;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(Ct=()=>ae(`preview`),wt=(0,z.jsx)(E,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[131]=Ct,t[132]=wt):(Ct=t[131],wt=t[132]);let Tt;t[133]!==Z.preview||t[134]!==St?(Tt=(0,z.jsxs)(`button`,{type:`button`,className:St,onClick:Ct,children:[wt,Z.preview]}),t[133]=Z.preview,t[134]=St,t[135]=Tt):Tt=t[135];let Et;t[136]!==bt||t[137]!==Tt?(Et=(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-muted p-0.5`,children:[bt,Tt]}),t[136]=bt,t[137]=Tt,t[138]=Et):Et=t[138];let Dt;t[139]!==ht||t[140]!==Et?(Dt=(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[ht,Et]}),t[139]=ht,t[140]=Et,t[141]=Dt):Dt=t[141];let Ot=Q?`opacity-100`:`pointer-events-none opacity-0`,kt;t[142]===Ot?kt=t[143]:(kt=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Ot),t[142]=Ot,t[143]=kt);let At=!Q,jt;t[144]===Symbol.for(`react.memo_cache_sentinel`)?(jt=()=>K(re),t[144]=jt):jt=t[144];let Mt;t[145]!==Z.thinkingLoading||t[146]!==Y?(Mt=Y?(0,z.jsxs)(`span`,{className:`ml-1 font-normal`,children:[`· `,Z.thinkingLoading]}):null,t[145]=Z.thinkingLoading,t[146]=Y,t[147]=Mt):Mt=t[147];let Nt;t[148]!==Z.thinking||t[149]!==Mt?(Nt=(0,z.jsxs)(`span`,{className:`min-w-0 truncate`,children:[Z.thinking,Mt]}),t[148]=Z.thinking,t[149]=Mt,t[150]=Nt):Nt=t[150];let Pt=G&&`rotate-180`,Ft;t[151]===Pt?Ft=t[152]:(Ft=i(`size-3.5 shrink-0 transition-transform`,Pt),t[151]=Pt,t[152]=Ft);let It;t[153]===Ft?It=t[154]:(It=(0,z.jsx)(w,{className:Ft,strokeWidth:1.75,"aria-hidden":!0}),t[153]=Ft,t[154]=It);let Lt;t[155]!==Nt||t[156]!==It?(Lt=(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:jt,children:[Nt,It]}),t[155]=Nt,t[156]=It,t[157]=Lt):Lt=t[157];let Rt;t[158]!==J||t[159]!==G?(Rt=G?(0,z.jsx)(`pre`,{ref:oe,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:xe,children:J}):null,t[158]=J,t[159]=G,t[160]=Rt):Rt=t[160];let zt;t[161]!==Lt||t[162]!==Rt?(zt=(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col rounded-lg border border-edge bg-surface-muted/70`,children:[Lt,Rt]}),t[161]=Lt,t[162]=Rt,t[163]=zt):zt=t[163];let Bt;t[164]!==kt||t[165]!==At||t[166]!==zt?(Bt=(0,z.jsx)(`div`,{className:kt,"aria-hidden":At,children:zt}),t[164]=kt,t[165]=At,t[166]=zt,t[167]=Bt):Bt=t[167];let Vt=Q?`pointer-events-none opacity-0`:`opacity-100`,Ht;t[168]===Vt?Ht=t[169]:(Ht=i(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Vt),t[168]=Vt,t[169]=Ht);let Ut;t[170]!==H||t[171]!==X||t[172]!==D||t[173]!==Z.empty||t[174]!==Z.loading||t[175]!==Z.suggestion||t[176]!==Y||t[177]!==W?(Ut=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}):D===`markdown`?(0,z.jsx)(c,{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[170]=H,t[171]=X,t[172]=D,t[173]=Z.empty,t[174]=Z.loading,t[175]=Z.suggestion,t[176]=Y,t[177]=W,t[178]=Ut):Ut=t[178];let Wt;t[179]!==Ht||t[180]!==Ut?(Wt=(0,z.jsx)(`div`,{className:Ht,children:Ut}),t[179]=Ht,t[180]=Ut,t[181]=Wt):Wt=t[181];let Gt;t[182]!==Bt||t[183]!==Wt?(Gt=(0,z.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[Bt,Wt]}),t[182]=Bt,t[183]=Wt,t[184]=Gt):Gt=t[184];let Kt;t[185]!==Dt||t[186]!==Gt?(Kt=(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[Dt,Gt]}),t[185]=Dt,t[186]=Gt,t[187]=Kt):Kt=t[187];let qt;t[188]!==ft||t[189]!==Kt?(qt=(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:[ft,Kt]}),t[188]=ft,t[189]=Kt,t[190]=qt):qt=t[190];let Jt;t[191]!==$||t[192]!==Z.cancel?(Jt=(0,z.jsx)(A,{type:`button`,variant:`secondary`,onClick:$,children:Z.cancel}),t[191]=$,t[192]=Z.cancel,t[193]=Jt):Jt=t[193];let Yt=!Le,Xt;t[194]!==Ae||t[195]!==Z.applyCurrent||t[196]!==Yt?(Xt=(0,z.jsx)(A,{type:`button`,variant:`secondary`,disabled:Yt,onClick:Ae,children:Z.applyCurrent}),t[194]=Ae,t[195]=Z.applyCurrent,t[196]=Yt,t[197]=Xt):Xt=t[197];let Zt;t[198]===De?Zt=t[199]:(Zt=()=>void De(),t[198]=De,t[199]=Zt);let Qt;t[200]===ze?Qt=t[201]:(Qt=ze?(0,z.jsx)(T,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,z.jsx)(b,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[200]=ze,t[201]=Qt);let $t=ze?Z.regenerate:Z.generate,en;t[202]!==Y||t[203]!==Zt||t[204]!==Qt||t[205]!==$t?(en=(0,z.jsxs)(A,{type:`button`,variant:`secondary`,disabled:Y,onClick:Zt,children:[Qt,$t]}),t[202]=Y,t[203]=Zt,t[204]=Qt,t[205]=$t,t[206]=en):en=t[206];let tn=!Ie,nn;t[207]!==Pe||t[208]!==Z.append||t[209]!==tn?(nn=(0,z.jsx)(A,{type:`button`,variant:`secondary`,disabled:tn,onClick:Pe,children:Z.append}),t[207]=Pe,t[208]=Z.append,t[209]=tn,t[210]=nn):nn=t[210];let rn=!Ie,an;t[211]!==Me||t[212]!==Z.replace||t[213]!==rn?(an=(0,z.jsx)(A,{type:`button`,variant:`primary`,disabled:rn,onClick:Me,children:Z.replace}),t[211]=Me,t[212]=Z.replace,t[213]=rn,t[214]=an):an=t[214];let on;t[215]!==Jt||t[216]!==Xt||t[217]!==en||t[218]!==nn||t[219]!==an?(on=(0,z.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[Jt,Xt,en,nn,an]}),t[215]=Jt,t[216]=Xt,t[217]=en,t[218]=nn,t[219]=an,t[220]=on):on=t[220];let sn;t[221]!==Ze||t[222]!==qt||t[223]!==on?(sn=(0,z.jsxs)(v,{children:[qe,(0,z.jsx)(`div`,{className:`fixed inset-0 z-[80] flex items-center justify-center p-4 pointer-events-none`,children:(0,z.jsxs)(d,{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:[Ze,qt,on]})})]}),t[221]=Ze,t[222]=qt,t[223]=on,t[224]=sn):sn=t[224];let cn;t[225]!==F||t[226]!==Ke||t[227]!==sn?(cn=(0,z.jsx)(h,{open:F,onOpenChange:Ke,children:sn}),t[225]=F,t[226]=Ke,t[227]=sn,t[228]=cn):cn=t[228];let ln;return t[229]!==cn||t[230]!==Ge?(ln=(0,z.jsxs)(z.Fragment,{children:[Ge,cn]}),t[229]=cn,t[230]=Ge,t[231]=ln):ln=t[231],ln}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:u(t.argValues)}function ae(e,t,n){let r=a(t).workflows;if(!e)return r.noInputSummary;let i=_(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:(f[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=f[e]??[];if(n.length===0)return{};let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{},i={};for(let e of n){let t=r[e.key];t!=null&&(i[e.key]=String(t))}return i}function 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 q(e){let t=(0,P.c)(34),{workflowName:n,language:r,argValues:o,onArgValuesChange:s,goal:c,onGoalChange:l,examplePrompts:u,showGoal:d,inputClassName:p,aiAssist:m}=e,h;t[0]===u?h=t[1]:(h=u===void 0?[]:u,t[0]=u,t[1]=h);let g=h,_=d===void 0?!0:d,v,y,b,S,C,w,T;if(t[2]!==m||t[3]!==o||t[4]!==g||t[5]!==c||t[6]!==p||t[7]!==r||t[8]!==s||t[9]!==l||t[10]!==_||t[11]!==n){b=a(r).workflows;let e=f[n]??[];y=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`,p),d;t[19]!==o||t[20]!==s||t[21]!==l?(d=e=>{x(e,l,e=>{s(e(o))})},t[19]=o,t[20]=s,t[21]=l,t[22]=d):d=t[22],v=d,S=`flex flex-col gap-3`,C=e.map(e=>{let t=K(b.args,e.labelKey),a=K(b.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&&m?(0,z.jsx)(B,{value:c,onApply:t=>s({...o,[e.key]:t}),fieldId:`workflow.arg.${e.key}`,fieldLabel:t,scenario:m.argScenario??`workflow.arg`,locale:r,context:{...m.context,workflowName:n,workflowArgs:o,fieldKey:e.key},disabled:m.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)}),w=y&&g.length>0?(0,z.jsx)(se,{examples:g,labels:b,onSelect:v}):null,T=_?(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:b.goalLabel}),m?(0,z.jsx)(B,{value:c,onApply:l,fieldId:`workflow.goal`,fieldLabel:b.goalLabel,scenario:m.goalScenario??`cron.workflowGoal`,locale:r,context:{...m.context,workflowName:n,workflowArgs:o},disabled:m.disabled,showLabel:!1}):null]}),(0,z.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:b.goalPlaceholder,className:i(u,`min-h-20 resize-y`)})]}):null,t[2]=m,t[3]=o,t[4]=g,t[5]=c,t[6]=p,t[7]=r,t[8]=s,t[9]=l,t[10]=_,t[11]=n,t[12]=v,t[13]=y,t[14]=b,t[15]=S,t[16]=C,t[17]=w,t[18]=T}else v=t[12],y=t[13],b=t[14],S=t[15],C=t[16],w=t[17],T=t[18];let E;t[23]!==v||t[24]!==g||t[25]!==y||t[26]!==b?(E=!y&&g.length>0?(0,z.jsx)(se,{examples:g,labels:b,onSelect:v}):null,t[23]=v,t[24]=g,t[25]=y,t[26]=b,t[27]=E):E=t[27];let D;return t[28]!==S||t[29]!==C||t[30]!==w||t[31]!==T||t[32]!==E?(D=(0,z.jsxs)(`div`,{className:S,children:[C,w,T,E]}),t[28]=S,t[29]=C,t[30]=w,t[31]=T,t[32]=E,t[33]=D):D=t[33],D}var J=`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 Y({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(J,`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)(X,{field:e,value:t[e.key],labels:r,aiAssist:a,allValues:t,onChange:t=>m(e.key,t)},e.key))})]})}function X(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 b;t[14]!==_||t[15]!==v?(b=(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[_,v]}),t[14]=_,t[15]=v,t[16]=b):b=t[16];let x;t[17]===u?x=t[18]:(x=u?(0,z.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-subtle`,children:u}):null,t[17]=u,t[18]=x);let C;t[19]!==u||t[20]!==p||t[21]!==a||t[22]!==c||t[23]!==d||t[24]!==r?(C=p.length>0?(0,z.jsxs)(y,{value:r==null?``:String(r),onChange:e=>c(e.target.value),className:J,children:[(0,z.jsx)(S,{value:``}),p.map(ce)]}):d===`boolean`?(0,z.jsxs)(y,{value:typeof r==`boolean`?String(r):``,onChange:e=>c(e.target.value===``?void 0:e.target.value===`true`),className:J,children:[(0,z.jsx)(S,{value:``}),(0,z.jsx)(S,{value:`true`,children:a.booleanTrue}),(0,z.jsx)(S,{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:J}):(0,z.jsx)(`textarea`,{value:typeof r==`string`?r:r==null?``:String(r),onChange:e=>c(e.target.value),className:i(J,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]=C):C=t[25];let w;return t[26]!==b||t[27]!==x||t[28]!==C?(w=(0,z.jsxs)(`div`,{className:`block`,children:[b,x,C]}),t[26]=b,t[27]=x,t[28]=C,t[29]=w):w=t[29],w}function ce(e){return(0,z.jsx)(S,{value:String(e),children:String(e)},String(e))}function le(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 ue(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=_(n,r),t[2]=n,t[3]=r,t[4]=p):p=t[4];let m=p,[h,g]=(0,N.useState)(!0),v;t[5]===m.examplePrompts?v=t[6]:(v=m.examplePrompts??[],t[5]=m.examplePrompts,t[6]=v);let y=v,b;t[7]===n.inputSchema?b=t[8]:(b=V(n.inputSchema),t[7]=n.inputSchema,t[8]=b);let x=b,S,C,w,T,E,D,O,k,A,j;if(t[9]!==c||t[10]!==n||t[11]!==y||t[12]!==x||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,v;t[39]!==d||t[40]!==o?(v=e=>d({...o,schemaInput:e}),t[39]=d,t[40]=o,t[41]=v):v=t[41];let b=v,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]!==b||t[47]!==o.schemaInput?(P=e=>{if(e.field===`goal`){_(e.text);return}b({...o.schemaInput,[e.field]:e.text})},t[45]=_,t[46]=b,t[47]=o.schemaInput,t[48]=P):P=t[48],S=P,!x){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]!==y||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)(q,{workflowName:n.name,language:r,argValues:o.argValues,onArgValuesChange:N,goal:o.goal,onGoalChange:_,examplePrompts:y,inputClassName:l,aiAssist:e}),t[55]=n.name,t[56]=y,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}w=`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]!==b||t[76]!==o?(T=n.inputSchema?(0,z.jsx)(Y,{schema:n.inputSchema,value:o.schemaInput,onChange:b,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]=b,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?(C=(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[F,I]}),t[91]=F,t[92]=I,t[93]=C):C=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]=y,t[12]=x,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]=S,t[22]=C,t[23]=w,t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A,t[30]=j}else S=t[21],C=t[22],w=t[23],T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29],j=t[30];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]!==C||t[102]!==M||t[103]!==j?(F=(0,z.jsxs)(`div`,{className:j,children:[C,M]}),t[101]=C,t[102]=M,t[103]=j,t[104]=F):F=t[104];let I;t[105]!==S||t[106]!==y||t[107]!==f?(I=(0,z.jsx)(le,{examples:y,labels:f,onSelect:S}),t[105]=S,t[106]=y,t[107]=f,t[108]=I):I=t[108];let L;return t[109]!==w||t[110]!==T||t[111]!==F||t[112]!==I?(L=(0,z.jsxs)(`div`,{className:w,children:[T,F,I]}),t[109]=w,t[110]=T,t[111]=F,t[112]=I,t[113]=L):L=t[113],L}function Z(e,t){let n=e.metadata.estimatedAgents;return n?n.min===n.max?m(t.agentScaleExact,{count:n.min}):m(t.agentScaleRange,{min:n.min,max:n.max}):m(t.agentScaleExact,{count:e.defaults.maxSubagents})}function de(e){let t=(0,P.c)(41),{definition:n,language:r,value:o,onChange:s,mode:c,badgeLabel:l,aiAssist:u,inputClassName:d,showTimeout:f,defaultAdvancedOpen:p,onValidityChange:h}=e,g=f===void 0?!1:f,v=p===void 0?!1:p,y=a(r).workflows,[b,x]=(0,N.useState)(v),S;t[0]!==n||t[1]!==r?(S=_(n,r),t[0]=n,t[1]=r,t[2]=S):S=t[2];let T=S,E;t[3]!==n.defaults||t[4]!==o.concurrency?(E=o.concurrency.trim()?Number(o.concurrency):n.defaults.concurrency,t[3]=n.defaults,t[4]=o.concurrency,t[5]=E):E=t[5];let O=E,A;t[6]!==n.defaults||t[7]!==o.maxSubagents?(A=o.maxSubagents.trim()?Number(o.maxSubagents):n.defaults.maxSubagents,t[6]=n.defaults,t[7]=o.maxSubagents,t[8]=A):A=t[8];let j=A,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??y.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||T.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)(k,{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)(D,{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]!==u||t[29]!==n||t[30]!==d||t[31]!==r||t[32]!==U||t[33]!==W||t[34]!==o?(G=(0,z.jsx)(ue,{definition:n,language:r,value:o,onChange:U,onValidityChange:W,aiAssist:u,inputClassName:d}),t[28]=u,t[29]=n,t[30]=d,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=()=>x(Q),t[36]=K):K=t[36];let oe=y.advancedSettings,se=b&&`rotate-180`,q;t[37]===se?q=t[38]:(q=i(`size-4 transition-transform`,se),t[37]=se,t[38]=q);let J;return t[39]===q?J=t[40]:(J=(0,z.jsx)(w,{className:q}),t[39]=q,t[40]=J),(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:y.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:m(y.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:Z(n,y)})]}),(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:m(y.runLimitsSummary,{concurrency:O,max:j})})]})]}),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)(M,{className:`size-3.5`,"aria-hidden":!0}),y.startPlanPhases]}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:n.phases.map(fe)})]}):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,J]}),b?(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:m(y.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:m(y.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:m(y.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 Q(e){return!e}function fe(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,de as t};