@xopcai/xopc 0.0.170 → 0.0.171

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 (185) 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-CkUp1qvf.js → activity-store-BLz30jWq.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DDuem4HM.js → agent-avatar-dicebear-BKZO0EFn.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-ZCIC8mhO.js +2 -0
  6. package/dist/gateway/static/root/assets/{api-BnuPQhJW.js → api-N2qKY-WI.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-DdZw8Hi1.js → app-management-settings-panel-CNZkpXCD.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-BN8Vk2bX.js → appearance-settings-Drf5a563.js} +1 -1
  9. package/dist/gateway/static/root/assets/{apps-page-CuL8Q4yF.js → apps-page-DJmgBaAm.js} +1 -1
  10. package/dist/gateway/static/root/assets/{archive-plugin-C82MaDQj.js → archive-plugin-ChVwOXE5.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-uilrwSdW.js → attachment-load-BVK3Y2d9.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-CkDZjAmy.js → automation-suggestion-card-DH4N0SYR.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-page-Ddot8-Md.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-B7NTL0_T.js → binary-plugins-CeHY6VVP.js} +1 -1
  15. package/dist/gateway/static/root/assets/block-editor-D3GIllO3.js +184 -0
  16. package/dist/gateway/static/root/assets/browser-settings-page-DvETvRcg.js +8 -0
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-UFVUzn4v.js → browser-workflow-inputs-femCtfpo.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-CGgC0N92.js → browser-workflows-page-o0GVE_aF.js} +2 -2
  19. package/dist/gateway/static/root/assets/capabilities-settings-panel-ChXIYbys.js +7 -0
  20. package/dist/gateway/static/root/assets/{capability-presets-api-DUIorGUd.js → capability-presets-api-Bx-JJC0R.js} +1 -1
  21. package/dist/gateway/static/root/assets/capability-presets-settings-panel-CUekXsJy.js +1 -0
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-BYwSB8c6.js → channel-recipient-api-CTw3ibx4.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-settings-CkhveNsQ.js +1 -0
  24. package/dist/gateway/static/root/assets/channels-status-swr-DRTb8DBk.js +1 -0
  25. package/dist/gateway/static/root/assets/{connector-logo-CsbegNqi.js → connector-logo-CQznQcd4.js} +1 -1
  26. package/dist/gateway/static/root/assets/connectors-page-DkSGIxWP.js +2 -0
  27. package/dist/gateway/static/root/assets/desktop-pet-BtP-xUQ9.js +1 -0
  28. package/dist/gateway/static/root/assets/{desktop-pet-settings-DkbIzdA3.js → desktop-pet-settings-CIeH4VyP.js} +1 -1
  29. package/dist/gateway/static/root/assets/{directory-picker-path-field-dBQvj1sG.js → directory-picker-path-field-Ddgt6c3K.js} +1 -1
  30. package/dist/gateway/static/root/assets/{dreaming-settings-DkdnKMZx.js → dreaming-settings-gd9W6SLj.js} +3 -3
  31. package/dist/gateway/static/root/assets/{extension-debug-page-BfxoIiNo.js → extension-debug-page-CJGwUaQX.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-EIJ3wIb7.js → extension-page-B3zHKJAB.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-DBBec51N.js → extension-settings-page-Cj9rrSr1.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-config-api-4_u53Ufq.js → gateway-config-api-BdmtlJRP.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-settings-v9kJM59H.js → gateway-settings-C2RwKIsl.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-startup-retry-CXITih5d.js → gateway-startup-retry-mcMq_uu_.js} +1 -1
  37. package/dist/gateway/static/root/assets/goal-create-dialog-5Ryd_rx4.js +1 -0
  38. package/dist/gateway/static/root/assets/goal-detail-page-DizZ6Cpl.js +4 -0
  39. package/dist/gateway/static/root/assets/{goals-config-api-D54YQPon.js → goals-config-api-CAO1J4jn.js} +1 -1
  40. package/dist/gateway/static/root/assets/goals-page-Dqry_hi2.js +2 -0
  41. package/dist/gateway/static/root/assets/{goals-settings-DDezXaVi.js → goals-settings-Boj2izKZ.js} +1 -1
  42. package/dist/gateway/static/root/assets/{heartbeat-settings-CRsIUeZN.js → heartbeat-settings-DbPC9a_y.js} +1 -1
  43. package/dist/gateway/static/root/assets/{image-generation-api-CY6cQUHL.js → image-generation-api-DrLCLTXn.js} +1 -1
  44. package/dist/gateway/static/root/assets/index-DEdyUjxM.css +1 -0
  45. package/dist/gateway/static/root/assets/{index-Dfq2laZe.js → index-vHb2z7VS.js} +7 -7
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D9k7EDdY.js → keyboard-shortcuts-settings-BrxfptgY.js} +1 -1
  47. package/dist/gateway/static/root/assets/local-app-workbench-page-BP0_Ih0e.js +2 -0
  48. package/dist/gateway/static/root/assets/{local-apps-page-DbaiBolh.js → local-apps-page-DNCRlfFs.js} +1 -1
  49. package/dist/gateway/static/root/assets/{locale-store-Dqp9H2Uf.js → locale-store-CzIfXqm8.js} +1 -1
  50. package/dist/gateway/static/root/assets/logs-page-mT48mcF4.js +7 -0
  51. package/dist/gateway/static/root/assets/{markdown-split-BGlQR-Be.js → markdown-split-CIUH9Lor.js} +1 -1
  52. package/dist/gateway/static/root/assets/{media-plugins-BpaeV6f_.js → media-plugins-DX4AgkCs.js} +1 -1
  53. package/dist/gateway/static/root/assets/messages-CKZuaOeG.js +3 -0
  54. package/dist/gateway/static/root/assets/{notes-page-Cd2HpciM.js → notes-page-D1KprtxL.js} +1 -1
  55. package/dist/gateway/static/root/assets/notes-workbench-wgt2Osyk.js +4 -0
  56. package/dist/gateway/static/root/assets/{page-tabs-DyimBUp_.js → page-tabs-DjZPJGf6.js} +1 -1
  57. package/dist/gateway/static/root/assets/{preview-open-alternatives-BKZulEYr.js → preview-open-alternatives-DNiJTpwZ.js} +1 -1
  58. package/dist/gateway/static/root/assets/{product-open-page-Bjz9BxBY.js → product-open-page-CNfR17-g.js} +1 -1
  59. package/dist/gateway/static/root/assets/project-detail-page-CDjHvxJm.js +1 -0
  60. package/dist/gateway/static/root/assets/projects-page-kJZwQXfC.js +1 -0
  61. package/dist/gateway/static/root/assets/remote-access-hub-MJdI9ek_.js +1 -0
  62. package/dist/gateway/static/root/assets/{save-bar-controls-BPTqb2_r.js → save-bar-controls-BGZFVO9S.js} +1 -1
  63. package/dist/gateway/static/root/assets/{schedule-field-YN0D81Dk.js → schedule-field-BAZiHtds.js} +1 -1
  64. package/dist/gateway/static/root/assets/{schema-form-BmY5PSS2.js → schema-form-CesBcwJH.js} +1 -1
  65. package/dist/gateway/static/root/assets/sessions-page-BqC7GDC_.js +1 -0
  66. package/dist/gateway/static/root/assets/settings-advanced-gate-CYwz8MfF.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-form-section-B-RhgD_p.js → settings-form-section-Bxc54BLj.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-loading-skeleton-DkPupX2B.js → settings-loading-skeleton-CYrho7Db.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-page-2QBMvaxj.js → settings-page-C03X5fkh.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-layout-CtrW-LD6.js → settings-page-layout-CZAJbv4E.js} +1 -1
  71. package/dist/gateway/static/root/assets/setup-status-panel-Jv8_bcOD.js +1 -0
  72. package/dist/gateway/static/root/assets/{share-preview-page-BezIW1n9.js → share-preview-page-DSC7tKKG.js} +1 -1
  73. package/dist/gateway/static/root/assets/shares-settings-h8tGDkA3.js +1 -0
  74. package/dist/gateway/static/root/assets/skill-reload-api-D2DGvRUn.js +1 -0
  75. package/dist/gateway/static/root/assets/skills-page-vqhjSMhZ.js +2 -0
  76. package/dist/gateway/static/root/assets/{system-settings-panel-WAFhKyAu.js → system-settings-panel-BO89zw5H.js} +1 -1
  77. package/dist/gateway/static/root/assets/{theme-store-BiC0gIBa.js → theme-store-1OkdVC8l.js} +1 -1
  78. package/dist/gateway/static/root/assets/time-picker-mtD64kFB.js +1 -0
  79. package/dist/gateway/static/root/assets/{typed-models-lib-WAQO3F_8.js → typed-models-lib-D-_vct_y.js} +1 -1
  80. package/dist/gateway/static/root/assets/{use-channel-catalog-CKlfsSeU.js → use-channel-catalog-VlFtjlET.js} +1 -1
  81. package/dist/gateway/static/root/assets/user-context-page-BgF0WxjM.js +1 -0
  82. package/dist/gateway/static/root/assets/{voice-api-key-field-BAFHF0_v.js → voice-api-key-field-BhDk-UV_.js} +1 -1
  83. package/dist/gateway/static/root/assets/work-discovery-page-CP0Daig-.js +1 -0
  84. package/dist/gateway/static/root/assets/work-item-detail-page-NEWZPKB_.js +1 -0
  85. package/dist/gateway/static/root/assets/work-page-BkWntcQh.js +1 -0
  86. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-1OP4HyvS.js → workflow-run-setup-panel-uVw4Yoej.js} +2 -2
  87. package/dist/gateway/static/root/assets/workflows-page-DRvhNQGe.js +11 -0
  88. package/dist/gateway/static/root/index.html +7 -7
  89. package/dist/package.js +1 -1
  90. package/dist/src/agent/embedded/run-for-session.js +71 -24
  91. package/dist/src/agent/embedded/run-turn.js +68 -4
  92. package/dist/src/agent/inbound/inbound-loop.d.ts +0 -2
  93. package/dist/src/agent/inbound/inbound-loop.js +0 -2
  94. package/dist/src/agent/memory/compaction-planner.d.ts +16 -0
  95. package/dist/src/agent/memory/compaction-planner.js +152 -0
  96. package/dist/src/agent/memory/compaction-policy.d.ts +10 -0
  97. package/dist/src/agent/memory/compaction-policy.js +24 -0
  98. package/dist/src/agent/memory/compaction.d.ts +21 -22
  99. package/dist/src/agent/memory/compaction.js +220 -194
  100. package/dist/src/agent/memory/context-budget.d.ts +40 -0
  101. package/dist/src/agent/memory/context-budget.js +106 -0
  102. package/dist/src/agent/orchestration/context-overflow.d.ts +1 -0
  103. package/dist/src/agent/orchestration/context-overflow.js +19 -0
  104. package/dist/src/agent/orchestration/loop-guard.js +13 -9
  105. package/dist/src/agent/reply/post-compaction-context.d.ts +4 -0
  106. package/dist/src/agent/reply/post-compaction-context.js +5 -3
  107. package/dist/src/agent/service/process-direct-one-shot.js +1 -2
  108. package/dist/src/agent/service/process-direct-streaming.js +1 -2
  109. package/dist/src/agent/service.d.ts +0 -2
  110. package/dist/src/agent/service.js +13 -44
  111. package/dist/src/agent/session/session-inspector.js +10 -2
  112. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  113. package/dist/src/config/schema.d.ts +17 -1
  114. package/dist/src/gateway/hono/lib/config-payload.d.ts +23 -0
  115. package/dist/src/gateway/hono/lib/config-payload.js +3 -0
  116. package/dist/src/gateway/hono/routes/config-patch/misc.d.ts +1 -1
  117. package/dist/src/gateway/hono/routes/config-patch/misc.js +28 -0
  118. package/dist/src/gateway/hono/routes/sessions.js +17 -42
  119. package/dist/src/gateway/service/sessions-api.d.ts +2 -3
  120. package/dist/src/gateway/service/sessions-api.js +4 -7
  121. package/dist/src/session/index.d.ts +1 -2
  122. package/dist/src/session/index.js +1 -2
  123. package/dist/src/session/init-session-turn.d.ts +0 -1
  124. package/dist/src/session/init-session-turn.js +1 -2
  125. package/dist/src/session/manager.d.ts +11 -17
  126. package/dist/src/session/manager.js +11 -14
  127. package/dist/src/session/session-context-for-llm.d.ts +19 -1
  128. package/dist/src/session/session-context-for-llm.js +87 -129
  129. package/dist/src/session/store.d.ts +28 -23
  130. package/dist/src/session/store.js +94 -83
  131. package/dist/src/session/transcript-format.d.ts +2 -8
  132. package/dist/src/session/types.d.ts +8 -6
  133. package/dist/src/session/user-round-delete.d.ts +3 -6
  134. package/dist/src/session/user-round-delete.js +12 -16
  135. package/dist/src/storage/sqlite/index.d.ts +1 -1
  136. package/dist/src/storage/sqlite/index.js +2 -2
  137. package/dist/src/storage/sqlite/migrations/060_remove_runtime_transcript_messages.sql +45 -0
  138. package/dist/src/storage/sqlite/migrations/061_drop_compaction_checkpoints.sql +2 -0
  139. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  140. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  141. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  142. package/dist/src/storage/sqlite/schema.js +1 -1
  143. package/dist/src/storage/sqlite/schema.sql +0 -19
  144. package/dist/src/storage/sqlite/transcript-repository.d.ts +6 -11
  145. package/dist/src/storage/sqlite/transcript-repository.js +90 -84
  146. package/dist/src/user-context/config.d.ts +67 -2
  147. package/dist/src/user-context/config.js +36 -3
  148. package/package.json +1 -1
  149. package/dist/gateway/static/root/assets/agents-BiaQhiQp.js +0 -2
  150. package/dist/gateway/static/root/assets/automations-page-TZOluRNp.js +0 -6
  151. package/dist/gateway/static/root/assets/block-editor-D_LDNlB-.js +0 -184
  152. package/dist/gateway/static/root/assets/browser-settings-page-C-l6O68Z.js +0 -8
  153. package/dist/gateway/static/root/assets/capabilities-settings-panel-BW8c0xPp.js +0 -7
  154. package/dist/gateway/static/root/assets/capability-presets-settings-panel-PTz00nR4.js +0 -1
  155. package/dist/gateway/static/root/assets/channels-settings-h9CsE0GT.js +0 -1
  156. package/dist/gateway/static/root/assets/channels-status-swr-C058Mcfr.js +0 -1
  157. package/dist/gateway/static/root/assets/connectors-page-BWALafGW.js +0 -2
  158. package/dist/gateway/static/root/assets/desktop-pet-CkT98fPT.js +0 -1
  159. package/dist/gateway/static/root/assets/goal-create-dialog-y2Y3p7_k.js +0 -1
  160. package/dist/gateway/static/root/assets/goal-detail-page-DuzL-alv.js +0 -4
  161. package/dist/gateway/static/root/assets/goals-page-OeLtfKI2.js +0 -2
  162. package/dist/gateway/static/root/assets/index-o4uaOGKT.css +0 -1
  163. package/dist/gateway/static/root/assets/local-app-workbench-page-3ssYIEK6.js +0 -2
  164. package/dist/gateway/static/root/assets/logs-page-DoCY0Mm9.js +0 -7
  165. package/dist/gateway/static/root/assets/messages-KEk-hTFt.js +0 -3
  166. package/dist/gateway/static/root/assets/notes-workbench-CatZNAPc.js +0 -4
  167. package/dist/gateway/static/root/assets/project-detail-page-DJUOgqm4.js +0 -1
  168. package/dist/gateway/static/root/assets/projects-page-BQQAD_nu.js +0 -1
  169. package/dist/gateway/static/root/assets/remote-access-hub-fIGXTTnA.js +0 -1
  170. package/dist/gateway/static/root/assets/sessions-page-BuU-8FCe.js +0 -1
  171. package/dist/gateway/static/root/assets/settings-advanced-gate-DlKoeZm3.js +0 -1
  172. package/dist/gateway/static/root/assets/setup-status-panel-BSUcDFnb.js +0 -1
  173. package/dist/gateway/static/root/assets/shares-settings-Bk2-SwGJ.js +0 -1
  174. package/dist/gateway/static/root/assets/skill-reload-api-e_Fx1kVC.js +0 -1
  175. package/dist/gateway/static/root/assets/skills-page-D_cCADfj.js +0 -2
  176. package/dist/gateway/static/root/assets/time-picker-fqRXpNJV.js +0 -1
  177. package/dist/gateway/static/root/assets/user-context-page-9Ov4htPW.js +0 -1
  178. package/dist/gateway/static/root/assets/work-discovery-page-DGN2FxWv.js +0 -1
  179. package/dist/gateway/static/root/assets/work-item-detail-page-HmyWSgUo.js +0 -1
  180. package/dist/gateway/static/root/assets/work-page-D3iKVjFq.js +0 -1
  181. package/dist/gateway/static/root/assets/workflows-page-B5L4SFw4.js +0 -11
  182. package/dist/src/agent/lifecycle/handlers/compaction.d.ts +0 -13
  183. package/dist/src/agent/lifecycle/handlers/compaction.js +0 -18
  184. package/dist/src/session/compaction-checkpoints.d.ts +0 -8
  185. package/dist/src/session/compaction-checkpoints.js +0 -19
@@ -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{f as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-CKZuaOeG.js";import{n as l}from"./locale-store-CzIfXqm8.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$s as d,$t as f,Ds as p,El as m,Go as h,Gs as g,Gt as _,Ht as v,Is as y,Jo as b,Jt as x,Ko as S,Ks as C,Kt as w,Nc as T,Ns as E,Ol as D,Ql as O,Qt as k,To as A,Uo as j,Ut as M,Vs as N,Wo as P,Wt as F,Xt as I,Yo as L,Ys as R,Yt as z,Zl as B,Zo as V,Zt as H,an as ee,cn as U,cs as W,du as G,en as te,fn as ne,hn as re,in as ie,ku as ae,lc as K,ln as oe,mn as se,ms as q,nn as ce,on as le,os as ue,pc as de,pl as fe,ps as pe,pu as me,qo as he,qt as ge,rn as _e,ro as ve,sn as ye,tn as be,tr as xe,un as Se,vt as Ce,vu as we,wu as Te,zc as Ee}from"./index-vHb2z7VS.js";import{t as De}from"./page-tabs-DjZPJGf6.js";import{t as Oe}from"./time-picker-mtD64kFB.js";import{t as ke}from"./connector-logo-CQznQcd4.js";var J=n(),Y=e(t(),1),X=r();function Ae(e){let t=(0,J.c)(104),{value:n,onChange:r,labels:i,language:a,inputClassName:o}=e,c;t[0]===n.timezone?c=t[1]:(c=()=>se.some(e=>e.value===n.timezone)?``:n.timezone,t[0]=n.timezone,t[1]=c);let[l,u]=(0,Y.useState)(c),d;t[2]===n.timezone?d=t[3]:(d=()=>!!n.timezone&&!se.some(e=>e.value===n.timezone),t[2]=n.timezone,t[3]=d);let[f,m]=(0,Y.useState)(d),h;t[4]===n.pronouns?h=t[5]:(h=()=>!!n.pronouns&&!ne.some(e=>e.value===n.pronouns),t[4]=n.pronouns,t[5]=h);let[g,_]=(0,Y.useState)(h),v;bb0:{if(f){v=`__custom__`;break bb0}v=se.some(e=>e.value===n.timezone)?n.timezone:`__custom__`}let y=v,b;t[6]!==r||t[7]!==n?(b=e=>r({...n,...e}),t[6]=r,t[7]=n,t[8]=b):b=t[8];let x=b,S;t[9]===a?S=t[10]:(S=(e,t)=>a===`zh`?t:e,t[9]=a,t[10]=S);let C=S,w;t[11]===i.callName?w=t[12]:(w=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:i.callName}),t[11]=i.callName,t[12]=w);let T;t[13]===x?T=t[14]:(T=e=>x({callName:e.target.value}),t[13]=x,t[14]=T);let E;t[15]!==o||t[16]!==i.callNamePlaceholder||t[17]!==T||t[18]!==n.callName?(E=(0,X.jsx)(`input`,{className:o,value:n.callName,onChange:T,placeholder:i.callNamePlaceholder,autoComplete:`off`}),t[15]=o,t[16]=i.callNamePlaceholder,t[17]=T,t[18]=n.callName,t[19]=E):E=t[19];let D;t[20]!==w||t[21]!==E?(D=(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[w,E]}),t[20]=w,t[21]=E,t[22]=D):D=t[22];let O;t[23]===i.pronouns?O=t[24]:(O=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:i.pronouns}),t[23]=i.pronouns,t[24]=O);let k=g?`__custom__`:n.pronouns,A;t[25]!==x||t[26]!==n.pronouns?(A=e=>{if(e.target.value===`__custom__`){_(!0),ne.some(e=>e.value===n.pronouns)&&x({pronouns:``});return}_(!1),x({pronouns:e.target.value})},t[25]=x,t[26]=n.pronouns,t[27]=A):A=t[27];let j;t[28]===i.pronounsPlaceholder?j=t[29]:(j=(0,X.jsx)(W,{value:``,children:i.pronounsPlaceholder}),t[28]=i.pronounsPlaceholder,t[29]=j);let M;t[30]===C?M=t[31]:(M=ne.map(e=>(0,X.jsx)(W,{value:e.value,children:C(e.labelEn,e.labelZh)},e.value)),t[30]=C,t[31]=M);let N;t[32]===i.custom?N=t[33]:(N=(0,X.jsx)(W,{value:`__custom__`,children:i.custom}),t[32]=i.custom,t[33]=N);let P;t[34]!==o||t[35]!==k||t[36]!==A||t[37]!==j||t[38]!==M||t[39]!==N?(P=(0,X.jsxs)(ue,{className:o,value:k,onChange:A,children:[j,M,N]}),t[34]=o,t[35]=k,t[36]=A,t[37]=j,t[38]=M,t[39]=N,t[40]=P):P=t[40];let F;t[41]!==o||t[42]!==i.pronounsPlaceholder||t[43]!==g||t[44]!==x||t[45]!==n.pronouns?(F=g?(0,X.jsx)(`input`,{className:s(o,`mt-1 text-xs`),value:n.pronouns,onChange:e=>x({pronouns:e.target.value}),placeholder:i.pronounsPlaceholder,autoComplete:`off`}):null,t[41]=o,t[42]=i.pronounsPlaceholder,t[43]=g,t[44]=x,t[45]=n.pronouns,t[46]=F):F=t[46];let I;t[47]!==O||t[48]!==P||t[49]!==F?(I=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[O,P,F]}),t[47]=O,t[48]=P,t[49]=F,t[50]=I):I=t[50];let L;t[51]===i.timezone?L=t[52]:(L=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:i.timezone}),t[51]=i.timezone,t[52]=L);let R;t[53]===o?R=t[54]:(R=s(o,`min-w-0 flex-1`),t[53]=o,t[54]=R);let z;t[55]===x?z=t[56]:(z=e=>{if(e.target.value===`__custom__`){m(!0);return}m(!1),u(``),x({timezone:e.target.value})},t[55]=x,t[56]=z);let B;t[57]===C?B=t[58]:(B=se.map(e=>(0,X.jsx)(W,{value:e.value,children:C(e.labelEn,e.labelZh)},e.value)),t[57]=C,t[58]=B);let V;t[59]===i.timezoneCustom?V=t[60]:(V=(0,X.jsx)(W,{value:`__custom__`,children:i.timezoneCustom}),t[59]=i.timezoneCustom,t[60]=V);let H;t[61]!==R||t[62]!==z||t[63]!==B||t[64]!==V||t[65]!==y?(H=(0,X.jsxs)(ue,{className:R,value:y,onChange:z,children:[B,V]}),t[61]=R,t[62]=z,t[63]=B,t[64]=V,t[65]=y,t[66]=H):H=t[66];let ee;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ee=s(`shrink-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,p.press),t[67]=ee):ee=t[67];let U;t[68]===x?U=t[69]:(U=()=>{let e=re();if(!e)return;let t=se.some(t=>t.value===e);m(!t),u(t?``:e),x({timezone:e})},t[68]=x,t[69]=U);let G;t[70]!==i.timezoneDetect||t[71]!==U?(G=(0,X.jsx)(`button`,{type:`button`,className:ee,onClick:U,children:i.timezoneDetect}),t[70]=i.timezoneDetect,t[71]=U,t[72]=G):G=t[72];let te;t[73]!==H||t[74]!==G?(te=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[H,G]}),t[73]=H,t[74]=G,t[75]=te):te=t[75];let ie;t[76]!==l||t[77]!==o||t[78]!==f||t[79]!==x?(ie=f?(0,X.jsx)(`input`,{className:s(o,`mt-1 font-mono text-xs`),value:l,onChange:e=>{u(e.target.value),x({timezone:e.target.value})},placeholder:`e.g. Asia/Shanghai`,autoComplete:`off`}):null,t[76]=l,t[77]=o,t[78]=f,t[79]=x,t[80]=ie):ie=t[80];let ae;t[81]!==L||t[82]!==te||t[83]!==ie?(ae=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[L,te,ie]}),t[81]=L,t[82]=te,t[83]=ie,t[84]=ae):ae=t[84];let K;t[85]===i.notes?K=t[86]:(K=(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:i.notes}),t[85]=i.notes,t[86]=K);let oe;t[87]===o?oe=t[88]:(oe=s(o,`min-h-28 resize-y text-sm leading-relaxed`),t[87]=o,t[88]=oe);let q;t[89]===x?q=t[90]:(q=e=>x({notes:e.target.value}),t[89]=x,t[90]=q);let ce;t[91]!==i.notesPlaceholder||t[92]!==oe||t[93]!==q||t[94]!==n.notes?(ce=(0,X.jsx)(`textarea`,{className:oe,value:n.notes,onChange:q,placeholder:i.notesPlaceholder,rows:5,spellCheck:!0}),t[91]=i.notesPlaceholder,t[92]=oe,t[93]=q,t[94]=n.notes,t[95]=ce):ce=t[95];let le;t[96]!==K||t[97]!==ce?(le=(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[K,ce]}),t[96]=K,t[97]=ce,t[98]=le):le=t[98];let de;return t[99]!==D||t[100]!==I||t[101]!==ae||t[102]!==le?(de=(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[D,I,ae,le]}),t[99]=D,t[100]=I,t[101]=ae,t[102]=le,t[103]=de):de=t[103],de}var je={"composio-gmail":`gmail`,"composio-googledrive":`google-drive`,"composio-notion":`notion`,"composio-slack":`slack`,memory:`memory`};function Me(e){if(e.branding?.logoUrl)return e.branding;let t=je[e.id];return t?{...e.branding,logoUrl:`/connector-icons/${t}.svg`}:e.branding}function Ne(e){let t=(0,J.c)(57),{open:n,t:r,onOpenChange:i,onNavigate:a}=e,o;t[0]!==r.helpLearningBody||t[1]!==r.helpLearningTitle?(o={icon:Te,title:r.helpLearningTitle,body:r.helpLearningBody},t[0]=r.helpLearningBody,t[1]=r.helpLearningTitle,t[2]=o):o=t[2];let c;t[3]!==r.helpSharingBody||t[4]!==r.helpSharingTitle?(c={icon:N,title:r.helpSharingTitle,body:r.helpSharingBody},t[3]=r.helpSharingBody,t[4]=r.helpSharingTitle,t[5]=c):c=t[5];let l;t[6]!==r.helpSourcesBody||t[7]!==r.helpSourcesTitle?(l={icon:O,title:r.helpSourcesTitle,body:r.helpSourcesBody},t[6]=r.helpSourcesBody,t[7]=r.helpSourcesTitle,t[8]=l):l=t[8];let u;t[9]!==r.helpControlBody||t[10]!==r.helpControlTitle?(u={icon:de,title:r.helpControlTitle,body:r.helpControlBody},t[9]=r.helpControlBody,t[10]=r.helpControlTitle,t[11]=u):u=t[11];let d;t[12]!==o||t[13]!==c||t[14]!==l||t[15]!==u?(d=[o,c,l,u],t[12]=o,t[13]=c,t[14]=l,t[15]=u,t[16]=d):d=t[16];let f=d,p;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,X.jsx)(he,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,q)}),t[17]=p):p=t[17];let m;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(m=s(`fixed right-3 top-1/2 flex h-[min(44rem,calc(100dvh-1.5rem))] w-[min(30rem,calc(100vw-1.5rem))] -translate-y-1/2 flex-col overflow-hidden`,pe,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`),t[18]=m):m=t[18];let g;t[19]===r.helpTitle?g=t[20]:(g=(0,X.jsx)(L,{className:`text-base font-semibold text-fg`,children:r.helpTitle}),t[19]=r.helpTitle,t[20]=g);let _;t[21]===r.helpSubtitle?_=t[22]:(_=(0,X.jsx)(S,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r.helpSubtitle}),t[21]=r.helpSubtitle,t[22]=_);let v;t[23]!==g||t[24]!==_?(v=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[g,_]}),t[23]=g,t[24]=_,t[25]=v):v=t[25];let x;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,X.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t[26]=x):x=t[26];let C;t[27]===r.close?C=t[28]:(C=(0,X.jsx)(P,{asChild:!0,children:(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":r.close,children:x})}),t[27]=r.close,t[28]=C);let w;t[29]!==v||t[30]!==C?(w=(0,X.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[v,C]}),t[29]=v,t[30]=C,t[31]=w):w=t[31];let T;t[32]===f?T=t[33]:(T=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-2`,children:f.map(Pe)}),t[32]=f,t[33]=T);let D;t[34]!==a||t[35]!==i?(D=()=>{i(!1),a(`sources`)},t[34]=a,t[35]=i,t[36]=D):D=t[36];let k;t[37]!==r.tabs.sources||t[38]!==D?(k=(0,X.jsx)(E,{type:`button`,variant:`ghost`,onClick:D,children:r.tabs.sources}),t[37]=r.tabs.sources,t[38]=D,t[39]=k):k=t[39];let A;t[40]!==a||t[41]!==i?(A=()=>{i(!1),a(`controls`)},t[40]=a,t[41]=i,t[42]=A):A=t[42];let M;t[43]!==r.openPrivacyControls||t[44]!==A?(M=(0,X.jsx)(E,{type:`button`,variant:`secondary`,onClick:A,children:r.openPrivacyControls}),t[43]=r.openPrivacyControls,t[44]=A,t[45]=M):M=t[45];let F;t[46]!==k||t[47]!==M?(F=(0,X.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge px-5 py-4`,children:[k,M]}),t[46]=k,t[47]=M,t[48]=F):F=t[48];let I;t[49]!==w||t[50]!==T||t[51]!==F?(I=(0,X.jsxs)(b,{children:[p,(0,X.jsxs)(h,{className:m,children:[w,T,F]})]}),t[49]=w,t[50]=T,t[51]=F,t[52]=I):I=t[52];let R;return t[53]!==i||t[54]!==n||t[55]!==I?(R=(0,X.jsx)(j,{open:n,onOpenChange:i,children:I}),t[53]=i,t[54]=n,t[55]=I,t[56]=R):R=t[56],R}function Pe(e){let{icon:t,title:n,body:r}=e;return(0,X.jsxs)(`section`,{className:`flex gap-3 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-muted text-fg-muted`,children:(0,X.jsx)(t,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),(0,X.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r})]})]},n)}function Fe(e){let t=(0,J.c)(33),{source:n,language:r,busy:i,onOpenChange:a,onConfirm:o}=e,l=c(r).you,[u,d]=(0,Y.useState)(!1),f=n?.accountLabel??(n?.accountCount&&n.accountCount>1&&n.accountOrdinal?l.sourceAccountFallback.replace(`{{index}}`,String(n.accountOrdinal)).replace(`{{count}}`,String(n.accountCount)):void 0),p,m;t[0]===n?(p=t[1],m=t[2]):(p=()=>{n&&d(!1)},m=[n],t[0]=n,t[1]=p,t[2]=m),(0,Y.useEffect)(p,m);let g;t[3]!==i||t[4]!==a?(g=e=>!i&&a(e),t[3]=i,t[4]=a,t[5]=g):g=t[5];let _;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,X.jsx)(he,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[6]=_):_=t[6];let v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,X.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t[7]=v):v=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>d(!1),t[8]=x):x=t[8];let w=u?`border-edge-subtle hover:bg-surface-hover`:`border-accent/40 bg-accent-soft/35`,T;t[9]===w?T=t[10]:(T=s(`flex w-full items-start gap-3 rounded-xl border p-4 text-left`,w),t[9]=w,t[10]=T);let D;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,X.jsx)(O,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[11]=D):D=t[11];let k;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>d(!0),t[12]=k):k=t[12];let A=u?`border-danger/40 bg-danger-soft`:`border-edge-subtle hover:bg-surface-hover`,M;t[13]===A?M=t[14]:(M=s(`flex w-full items-start gap-3 rounded-xl border p-4 text-left disabled:cursor-not-allowed disabled:opacity-55`,A),t[13]=A,t[14]=M);let N;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.jsx)(R,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),t[15]=N):N=t[15];let F=l.disconnectDeleteBody.replace(`{{count}}`,String(n?.derivedUnderstandingCount??0)),I;t[16]===F?I=t[17]:(I=(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:F}),t[16]=F,t[17]=I);let z;t[18]!==i||t[19]!==l.cancel?(z=(0,X.jsx)(P,{asChild:!0,children:(0,X.jsx)(E,{type:`button`,variant:`ghost`,disabled:i,children:l.cancel})}),t[18]=i,t[19]=l.cancel,t[20]=z):z=t[20];let B=u?`border-danger/35 text-danger hover:bg-danger-soft`:void 0,V;t[21]!==u||t[22]!==o?(V=()=>o(u),t[21]=u,t[22]=o,t[23]=V):V=t[23];let H;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,X.jsx)(C,{className:`size-4`,"aria-hidden":!0}),t[24]=H):H=t[24];let ee=i?l.disconnecting:l.disconnectAction,U;t[25]!==i||t[26]!==B||t[27]!==V||t[28]!==ee?(U=(0,X.jsxs)(E,{type:`button`,variant:`secondary`,className:B,disabled:i,onClick:V,children:[H,ee]}),t[25]=i,t[26]=B,t[27]=V,t[28]=ee,t[29]=U):U=t[29];let W;return t[30]!==z||t[31]!==U?(W=(0,X.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[z,U]}),t[30]=z,t[31]=U,t[32]=W):W=t[32],(0,X.jsx)(j,{open:n!==null,onOpenChange:g,children:(0,X.jsxs)(b,{children:[_,(0,X.jsxs)(h,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(31rem,calc(100dvh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(L,{className:`text-base font-semibold text-fg`,children:l.disconnectTitle}),(0,X.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:l.disconnectBody.replace(`{{source}}`,n?.displayName??``)})]}),(0,X.jsx)(P,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":l.cancel,disabled:i,children:v})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-5`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-muted px-4 py-3 text-xs leading-5 text-fg-muted`,children:[f?(0,X.jsx)(`p`,{className:`font-medium text-fg`,children:l.disconnectAccount.replace(`{{account}}`,f)}):null,(0,X.jsx)(`p`,{children:l.disconnectImpact.replace(`{{items}}`,String(n?.knowledgeItemCount??0)).replace(`{{understandings}}`,String(n?.derivedUnderstandingCount??0))})]}),(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":!u,onClick:x,className:T,children:[D,(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectKeepTitle}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:l.disconnectKeepBody})]})]}),(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":u,onClick:k,disabled:!n?.derivedUnderstandingCount,className:M,children:[N,(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:l.disconnectDeleteTitle}),I]})]})]}),W]})]})})}var Ie=new Set([`overview`,`profile`,`understanding`,`sources`,`controls`]),Le=[`collaboration`,`priorities`,`boundaries`,`people`,`current`,`basics`],Re=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent/50 focus:ring-2 focus:ring-accent/20`;function ze(e,t){return e.replace(`{{count}}`,String(t))}function Be(e){let t=(0,J.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`span`,{className:`inline-flex rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Z(e,t){let n=Date.parse(e);return Number.isFinite(n)?Ce(n,t):e}function Ve(e){return e===`review`?`understanding`:e===`privacy`?`controls`:e&&Ie.has(e)?e:`overview`}function He(){let e=(0,J.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(ve,{className:`h-24 rounded-2xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[t,(0,X.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,X.jsx)(ve,{className:`h-64 rounded-2xl`}),(0,X.jsx)(ve,{className:`h-64 rounded-2xl`})]})]}),e[1]=n):n=e[1],n}function Ue(e,t){return e.origin===`connected_source`?t.origins.connected_source.replace(`{{source}}`,e.sourceName):t.origins[e.origin]}function We(e){let t=(0,J.c)(19),{item:n,language:r,t:i,busy:a,onConfirm:c,onReject:l,onUpdate:u,onForget:d}=e,[f,p]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(n.statement),[_,v]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(!1),S=n.status!==`active`,C=S?`border-warning/35 bg-warning-soft/35`:`border-edge-subtle bg-surface-panel`,w;t[0]===C?w=t[1]:(w=s(`rounded-xl border p-3.5`,C),t[0]=C,t[1]=w);let T;t[2]!==a||t[3]!==h||t[4]!==f||t[5]!==_||t[6]!==b||t[7]!==n||t[8]!==r||t[9]!==S||t[10]!==c||t[11]!==d||t[12]!==l||t[13]!==u||t[14]!==i?(T=f?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`textarea`,{className:s(Re,`min-h-20 resize-y`),value:h,onChange:e=>g(e.target.value),placeholder:i.updatePlaceholder}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>{g(n.statement),p(!1)},children:i.cancel}),(0,X.jsx)(E,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:a||!h.trim(),onClick:()=>{u(h.trim()),p(!1)},children:i.save})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:n.statement}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(K,{className:`size-3 text-accent`,"aria-hidden":!0}),Ue(n,i)]}),(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.stability[n.stability]}),n.evidenceCount>1?(0,X.jsx)(`span`,{children:ze(i.evidenceCount,n.evidenceCount)}):null,n.latestEvidenceAt?(0,X.jsx)(`span`,{children:i.observedAt.replace(`{{time}}`,Z(n.latestEvidenceAt,r))}):null]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[S?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:c,children:[(0,X.jsx)(o,{className:`size-3.5`,"aria-hidden":!0}),i.confirm]}),(0,X.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:l,children:[(0,X.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),i.notTrue]})]}):null,(0,X.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:()=>p(!0),children:[(0,X.jsx)(Ee,{className:`size-3.5`,"aria-hidden":!0}),i.change]}),(0,X.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:b,onClick:()=>{if(_){v(null);return}x(!0),z(n.id).then(e=>v(e.history)).finally(()=>x(!1))},children:[(0,X.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),i.history]}),(0,X.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:a,onClick:d,children:[(0,X.jsx)(R,{className:`size-3.5`,"aria-hidden":!0}),i.forget]})]})]}),(0,X.jsxs)(`details`,{className:`mt-2 rounded-lg bg-surface-muted/70 px-3 py-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer font-medium text-fg-muted`,children:i.viewEvidence}),(0,X.jsxs)(`dl`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSource}),(0,X.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourceName})]}),n.sourcePath?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidencePath}),(0,X.jsx)(`dd`,{className:`mt-0.5 break-all text-fg-muted`,children:n.sourcePath})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceUpdated}),(0,X.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:Z(n.updatedAt,r)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceSupport}),(0,X.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:ze(i.evidenceCount,n.evidenceCount)})]}),n.confidence===void 0?null:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceConfidence}),(0,X.jsxs)(`dd`,{className:`mt-0.5 text-fg-muted`,children:[Math.round(n.confidence*100),`%`]})]}),n.validTo?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceValidUntil}),(0,X.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:Z(n.validTo,r)})]}):null,n.expiresAt?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-fg-subtle`,children:i.evidenceExpires}),(0,X.jsx)(`dd`,{className:`mt-0.5 text-fg-muted`,children:Z(n.expiresAt,r)})]}):null]})]}),_?(0,X.jsxs)(`div`,{className:`mt-2 space-y-2 border-t border-edge pt-2`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.historyTitle}),_.map(e=>(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3 text-xs`,children:[(0,X.jsx)(`p`,{className:`min-w-0 text-fg-muted`,children:e.statement}),(0,X.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:Z(e.updatedAt,r)})]},e.id))]}):null]}),t[2]=a,t[3]=h,t[4]=f,t[5]=_,t[6]=b,t[7]=n,t[8]=r,t[9]=S,t[10]=c,t[11]=d,t[12]=l,t[13]=u,t[14]=i,t[15]=T):T=t[15];let D;return t[16]!==w||t[17]!==T?(D=(0,X.jsx)(`article`,{className:w,children:T}),t[16]=w,t[17]=T,t[18]=D):D=t[18],D}function Ge(e){let t=(0,J.c)(84),{source:n,language:r,t:i,onConfigure:a,onDisconnect:o}=e,c=n.installed?n.enabled?i.connected:i.paused:i.available,l;t[0]!==n.accountCount||t[1]!==n.accountLabel||t[2]!==n.accountOrdinal||t[3]!==i.sourceAccountFallback?(l=n.accountLabel??(n.accountCount&&n.accountCount>1&&n.accountOrdinal?i.sourceAccountFallback.replace(`{{index}}`,String(n.accountOrdinal)).replace(`{{count}}`,String(n.accountCount)):void 0),t[0]=n.accountCount,t[1]=n.accountLabel,t[2]=n.accountOrdinal,t[3]=i.sourceAccountFallback,t[4]=l):l=t[4];let u=l,d;t[5]!==n.lastHealthStatus||t[6]!==i.healthIssue||t[7]!==i.healthOk||t[8]!==i.sourceHealth?(d=n.lastHealthStatus?i.sourceHealth.replace(`{{status}}`,n.lastHealthStatus===`ok`?i.healthOk:i.healthIssue):null,t[5]=n.lastHealthStatus,t[6]=i.healthIssue,t[7]=i.healthOk,t[8]=i.sourceHealth,t[9]=d):d=t[9];let f=d,p=`${i.manageSources}: ${n.displayName}`,m;t[10]===a?m=t[11]:(m=e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a()))},t[10]=a,t[11]=m);let h=n.displayName,g;t[12]===n?g=t[13]:(g=Me(n),t[12]=n,t[13]=g);let _;t[14]!==n.displayName||t[15]!==g?(_=(0,X.jsx)(ke,{connector:{displayName:h,branding:g},size:`sm`}),t[14]=n.displayName,t[15]=g,t[16]=_):_=t[16];let v;t[17]===n.displayName?v=t[18]:(v=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.displayName}),t[17]=n.displayName,t[18]=v);let y;t[19]===u?y=t[20]:(y=u?(0,X.jsx)(`p`,{className:`mt-0.5 truncate text-xs font-medium text-fg-muted`,children:u}):null,t[19]=u,t[20]=y);let b;t[21]===n.description?b=t[22]:(b=(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.description}),t[21]=n.description,t[22]=b);let x;t[23]!==b||t[24]!==v||t[25]!==y?(x=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[v,y,b]}),t[23]=b,t[24]=v,t[25]=y,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==_?(S=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[_,x]}),t[27]=x,t[28]=_,t[29]=S):S=t[29];let C=n.installed&&n.enabled?`bg-success-soft text-fg`:`bg-surface-hover text-fg-muted`,w;t[30]===C?w=t[31]:(w=s(`shrink-0 rounded-full px-2 py-1 text-[11px] font-medium`,C),t[30]=C,t[31]=w);let T;t[32]!==c||t[33]!==w?(T=(0,X.jsx)(`span`,{className:w,children:c}),t[32]=c,t[33]=w,t[34]=T):T=t[34];let D;t[35]!==S||t[36]!==T?(D=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[S,T]}),t[35]=S,t[36]=T,t[37]=D):D=t[37];let O;t[38]!==n.access.context||t[39]!==i.sourceContext?(O=n.access.context?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceContext}):null,t[38]=n.access.context,t[39]=i.sourceContext,t[40]=O):O=t[40];let k;t[41]!==n.access.memory||t[42]!==i.sourceMemory?(k=n.access.memory?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceMemory}):null,t[41]=n.access.memory,t[42]=i.sourceMemory,t[43]=k):k=t[43];let A;t[44]!==n.access.read||t[45]!==i.sourceRead?(A=n.access.read?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5`,children:i.sourceRead}):null,t[44]=n.access.read,t[45]=i.sourceRead,t[46]=A):A=t[46];let j;t[47]!==n.access.write||t[48]!==i.sourceWrite?(j=n.access.write?(0,X.jsx)(`span`,{className:`rounded-full bg-warning-soft px-2 py-0.5 text-fg`,children:i.sourceWrite}):null,t[47]=n.access.write,t[48]=i.sourceWrite,t[49]=j):j=t[49];let M;t[50]!==O||t[51]!==k||t[52]!==A||t[53]!==j?(M=(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[O,k,A,j]}),t[50]=O,t[51]=k,t[52]=A,t[53]=j,t[54]=M):M=t[54];let N;t[55]!==f||t[56]!==r||t[57]!==n.derivedUnderstandingCount||t[58]!==n.installed||t[59]!==n.knowledgeItemCount||t[60]!==n.lastActivityAt||t[61]!==n.lastSyncAt||t[62]!==n.lastSyncError||t[63]!==n.lastSyncStatus||t[64]!==i.sourceDerivedCount||t[65]!==i.sourceKnowledgeCount||t[66]!==i.sourceLastSync||t[67]!==i.sourceLastUsed||t[68]!==i.sourceNeverUsed||t[69]!==i.sourceSyncFailed?(N=n.installed?(0,X.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-edge-subtle pt-3 text-xs text-fg-muted`,children:[f?(0,X.jsx)(`p`,{children:f}):null,(0,X.jsx)(`p`,{children:n.lastActivityAt?i.sourceLastUsed.replace(`{{time}}`,Z(n.lastActivityAt,r)):i.sourceNeverUsed}),n.lastSyncAt?(0,X.jsx)(`p`,{children:i.sourceLastSync.replace(`{{time}}`,Z(n.lastSyncAt,r))}):null,n.lastSyncStatus===`failed`&&n.lastSyncError?(0,X.jsx)(`p`,{className:`text-danger`,children:i.sourceSyncFailed.replace(`{{error}}`,n.lastSyncError)}):null,(0,X.jsx)(`p`,{children:i.sourceKnowledgeCount.replace(`{{count}}`,String(n.knowledgeItemCount))}),(0,X.jsx)(`p`,{children:i.sourceDerivedCount.replace(`{{count}}`,String(n.derivedUnderstandingCount))})]}):null,t[55]=f,t[56]=r,t[57]=n.derivedUnderstandingCount,t[58]=n.installed,t[59]=n.knowledgeItemCount,t[60]=n.lastActivityAt,t[61]=n.lastSyncAt,t[62]=n.lastSyncError,t[63]=n.lastSyncStatus,t[64]=i.sourceDerivedCount,t[65]=i.sourceKnowledgeCount,t[66]=i.sourceLastSync,t[67]=i.sourceLastUsed,t[68]=i.sourceNeverUsed,t[69]=i.sourceSyncFailed,t[70]=N):N=t[70];let P;t[71]!==o||t[72]!==n.installed||t[73]!==n.instanceId||t[74]!==i.disconnect?(P=n.installed&&n.instanceId?(0,X.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-danger hover:bg-danger-soft hover:text-danger`,onClick:e=>{e.stopPropagation(),o()},children:i.disconnect})}):null,t[71]=o,t[72]=n.installed,t[73]=n.instanceId,t[74]=i.disconnect,t[75]=P):P=t[75];let F;return t[76]!==a||t[77]!==D||t[78]!==M||t[79]!==N||t[80]!==P||t[81]!==p||t[82]!==m?(F=(0,X.jsxs)(`article`,{role:`button`,tabIndex:0,"aria-label":p,className:`cursor-pointer rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:border-accent/30 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:a,onKeyDown:m,children:[D,M,N,P]}),t[76]=a,t[77]=D,t[78]=M,t[79]=N,t[80]=P,t[81]=p,t[82]=m,t[83]=F):F=t[83],F}function Ke(e){let t=(0,J.c)(70),{playbook:n,busy:r,t:i,onToggleGroup:a,onCreate:o,onUpdate:c,onDelete:l,onRollback:u}=e,[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(``),_=n.enabled?`border-edge-subtle bg-surface-panel`:`border-edge-subtle bg-surface-muted`,v;t[0]===_?v=t[1]:(v=s(`rounded-xl border p-4`,_),t[0]=_,t[1]=v);let y=i.playbookNames[n.id],b;t[2]===y?b=t[3]:(b=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:y}),t[2]=y,t[3]=b);let x;t[4]!==n.rules||t[5]!==i.playbookRuleCount?(x=ze(i.playbookRuleCount,n.rules.filter(Ye).length),t[4]=n.rules,t[5]=i.playbookRuleCount,t[6]=x):x=t[6];let S;t[7]===x?S=t[8]:(S=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:x}),t[7]=x,t[8]=S);let C;t[9]!==b||t[10]!==S?(C=(0,X.jsxs)(`div`,{children:[b,S]}),t[9]=b,t[10]=S,t[11]=C):C=t[11];let w=n.enabled?i.pausePlaybook:i.resumePlaybook,T;t[12]!==r||t[13]!==a||t[14]!==w?(T=(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:r,onClick:a,children:w}),t[12]=r,t[13]=a,t[14]=w,t[15]=T):T=t[15];let D;t[16]!==C||t[17]!==T?(D=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[C,T]}),t[16]=C,t[17]=T,t[18]=D):D=t[18];let O;t[19]!==r||t[20]!==p||t[21]!==h||t[22]!==l||t[23]!==u||t[24]!==c||t[25]!==n.rules||t[26]!==i.cancel||t[27]!==i.deleteRule||t[28]!==i.disableRule||t[29]!==i.edit||t[30]!==i.enableRule||t[31]!==i.moveDown||t[32]!==i.moveUp||t[33]!==i.rollbackRule||t[34]!==i.ruleChannelContext||t[35]!==i.ruleContextAny||t[36]!==i.ruleHistory||t[37]!==i.ruleSupportContext||t[38]!==i.ruleSupportNeeds||t[39]!==i.save?(O=n.rules.map((e,t)=>(0,X.jsx)(`li`,{className:s(`rounded-lg border border-edge-subtle p-2.5`,!e.enabled&&`opacity-60`),children:p===e.id?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`textarea`,{className:s(Re,`min-h-16 resize-y`),value:h,onChange:e=>g(e.target.value)}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`h-7 px-2`,onClick:()=>m(null),children:i.cancel}),(0,X.jsx)(E,{type:`button`,variant:`primary`,className:`h-7 px-2`,disabled:!h.trim(),onClick:()=>{c(e.id,{statement:h.trim()}),m(null)},children:i.save})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:e.statement}),(0,X.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-1`,children:[(0,X.jsxs)(`label`,{className:`grid gap-1 text-[10px] text-fg-subtle`,children:[i.ruleSupportContext,(0,X.jsxs)(ue,{value:e.context.supportNeed??``,disabled:r,onChange:t=>c(e.id,{context:{supportNeed:t.target.value||null}}),children:[(0,X.jsx)(W,{value:``,children:i.ruleContextAny}),[`listen`,`clarify`,`advise`,`act`,`unknown`].map(e=>(0,X.jsx)(W,{value:e,children:i.ruleSupportNeeds[e]},e))]})]}),(0,X.jsxs)(`label`,{className:`grid gap-1 text-[10px] text-fg-subtle`,children:[i.ruleChannelContext,(0,X.jsxs)(ue,{value:e.context.channel??``,disabled:r,onChange:t=>c(e.id,{context:{channel:t.target.value||null}}),children:[(0,X.jsx)(W,{value:``,children:i.ruleContextAny}),[`webchat`,`telegram`,`weixin`,`feishu`,`cli`].map(Je)]})]})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1`,children:[(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===0,onClick:()=>c(e.id,{order:n.rules[t-1].order-1}),children:i.moveUp}),(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r||t===n.rules.length-1,onClick:()=>c(e.id,{order:n.rules[t+1].order+1}),children:i.moveDown}),(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>c(e.id,{enabled:!e.enabled}),children:e.enabled?i.disableRule:i.enableRule}),(0,X.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-7 px-2`,disabled:r,onClick:()=>{m(e.id),g(e.statement)},children:[(0,X.jsx)(Ee,{className:`size-3`,"aria-hidden":!0}),i.edit]}),(0,X.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-7 px-2 text-danger`,disabled:r,onClick:()=>l(e.id),children:[(0,X.jsx)(R,{className:`size-3`,"aria-hidden":!0}),i.deleteRule]})]}),e.versions.length>1?(0,X.jsxs)(`details`,{className:`mt-2 border-t border-edge-subtle pt-2`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-fg-subtle`,children:i.ruleHistory}),(0,X.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.versions.filter(qe).map(t=>(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2 text-[11px]`,children:[(0,X.jsx)(`p`,{className:`line-clamp-2 text-fg-muted`,children:t.statement}),(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`h-7 shrink-0 px-2`,disabled:r,onClick:()=>u(e.id,t.id),children:i.rollbackRule})]},t.id))})]}):null]})},e.id)),t[19]=r,t[20]=p,t[21]=h,t[22]=l,t[23]=u,t[24]=c,t[25]=n.rules,t[26]=i.cancel,t[27]=i.deleteRule,t[28]=i.disableRule,t[29]=i.edit,t[30]=i.enableRule,t[31]=i.moveDown,t[32]=i.moveUp,t[33]=i.rollbackRule,t[34]=i.ruleChannelContext,t[35]=i.ruleContextAny,t[36]=i.ruleHistory,t[37]=i.ruleSupportContext,t[38]=i.ruleSupportNeeds,t[39]=i.save,t[40]=O):O=t[40];let k;t[41]===O?k=t[42]:(k=(0,X.jsx)(`ul`,{className:`mt-3 space-y-2`,children:O}),t[41]=O,t[42]=k);let A;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>f(e.target.value),t[43]=A):A=t[43];let j;t[44]!==d||t[45]!==i.newRulePlaceholder?(j=(0,X.jsx)(`input`,{className:Re,value:d,onChange:A,placeholder:i.newRulePlaceholder}),t[44]=d,t[45]=i.newRulePlaceholder,t[46]=j):j=t[46];let M;t[47]!==r||t[48]!==d?(M=r||!d.trim(),t[47]=r,t[48]=d,t[49]=M):M=t[49];let N;t[50]!==d||t[51]!==o?(N=()=>{o(d.trim()),f(``)},t[50]=d,t[51]=o,t[52]=N):N=t[52];let P;t[53]!==i.addRule||t[54]!==M||t[55]!==N?(P=(0,X.jsx)(E,{type:`button`,variant:`secondary`,disabled:M,onClick:N,children:i.addRule}),t[53]=i.addRule,t[54]=M,t[55]=N,t[56]=P):P=t[56];let F;t[57]!==j||t[58]!==P?(F=(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[j,P]}),t[57]=j,t[58]=P,t[59]=F):F=t[59];let I=i.playbookRuleExamples[n.id],L;t[60]===I?L=t[61]:(L=(0,X.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-5 text-fg-subtle`,children:I}),t[60]=I,t[61]=L);let z;t[62]!==F||t[63]!==L?(z=(0,X.jsxs)(`div`,{className:`mt-3`,children:[F,L]}),t[62]=F,t[63]=L,t[64]=z):z=t[64];let B;return t[65]!==D||t[66]!==k||t[67]!==v||t[68]!==z?(B=(0,X.jsxs)(`article`,{className:v,children:[D,k,z]}),t[65]=D,t[66]=k,t[67]=v,t[68]=z,t[69]=B):B=t[69],B}function qe(e){return!e.current}function Je(e){return(0,X.jsx)(W,{value:e,children:e},e)}function Ye(e){return e.enabled}function Xe(e){let t=(0,J.c)(46),{suggestion:n,draft:r,busy:i,onDraftChange:a,onSave:o,onLater:c,t:l}=e,u;t[0]!==n||t[1]!==l.meetSuggestedTitle||t[2]!==l.meetTitle?(u=n?l.meetSuggestedTitle.replace(`{{name}}`,n.value):l.meetTitle,t[0]=n,t[1]=l.meetSuggestedTitle,t[2]=l.meetTitle,t[3]=u):u=t[3];let d;t[4]===u?d=t[5]:(d=(0,X.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-fg`,children:u}),t[4]=u,t[5]=d);let f=n?l.meetSuggestedBody:l.meetBody,p;t[6]===f?p=t[7]:(p=(0,X.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:f}),t[6]=f,t[7]=p);let m;t[8]===l.callName?m=t[9]:(m=(0,X.jsx)(`label`,{className:`sr-only`,htmlFor:`you-call-name`,children:l.callName}),t[8]=l.callName,t[9]=m);let h;t[10]===a?h=t[11]:(h=e=>a(e.target.value),t[10]=a,t[11]=h);let g;t[12]!==i||t[13]!==r||t[14]!==o?(g=e=>{e.key===`Enter`&&r.trim()&&!i&&o()},t[12]=i,t[13]=r,t[14]=o,t[15]=g):g=t[15];let _=l.meetPlaceholder,v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=s(Re,`h-10 flex-1 bg-surface-base/90`),t[16]=v):v=t[16];let y;t[17]!==r||t[18]!==l.meetPlaceholder||t[19]!==h||t[20]!==g?(y=(0,X.jsx)(`input`,{id:`you-call-name`,value:r,maxLength:80,onChange:h,onKeyDown:g,placeholder:_,className:v}),t[17]=r,t[18]=l.meetPlaceholder,t[19]=h,t[20]=g,t[21]=y):y=t[21];let b;t[22]!==i||t[23]!==r?(b=i||!r.trim(),t[22]=i,t[23]=r,t[24]=b):b=t[24];let x=i?l.meetSaving:l.meetSave,S;t[25]!==o||t[26]!==b||t[27]!==x?(S=(0,X.jsx)(E,{type:`button`,variant:`primary`,className:`h-10 shrink-0`,disabled:b,onClick:o,children:x}),t[25]=o,t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;t[29]!==y||t[30]!==S||t[31]!==m?(C=(0,X.jsxs)(`div`,{className:`mt-5 flex max-w-xl flex-col gap-2 sm:flex-row`,children:[m,y,S]}),t[29]=y,t[30]=S,t[31]=m,t[32]=C):C=t[32];let w;t[33]!==n||t[34]!==l.meetSource?(w=n?(0,X.jsxs)(`p`,{className:`mt-3 flex items-start gap-1.5 text-xs leading-5 text-fg-subtle`,children:[(0,X.jsx)(de,{className:`mt-0.5 size-3.5 shrink-0 text-accent`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:l.meetSource})]}):null,t[33]=n,t[34]=l.meetSource,t[35]=w):w=t[35];let T;t[36]!==i||t[37]!==c||t[38]!==l.meetLater?(T=(0,X.jsx)(`button`,{type:`button`,disabled:i,className:`mt-3 text-xs font-medium text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:c,children:l.meetLater}),t[36]=i,t[37]=c,t[38]=l.meetLater,t[39]=T):T=t[39];let D;return t[40]!==C||t[41]!==w||t[42]!==T||t[43]!==d||t[44]!==p?(D=(0,X.jsx)(`section`,{className:`relative overflow-hidden rounded-2xl border border-accent/25 bg-gradient-to-br from-accent-soft/80 via-surface-panel to-surface-panel p-5 sm:p-6`,children:(0,X.jsxs)(`div`,{className:`relative max-w-2xl`,children:[d,p,C,w,T]})}),t[40]=C,t[41]=w,t[42]=T,t[43]=d,t[44]=p,t[45]=D):D=t[45],D}function Ze(){let e=l(e=>e.language),t=c(e).you,n=a(),[r,p]=i(),m=Ve(r.get(`tab`)),h=A(e=>e.setPageHeader),y=A(e=>e.clearPageHeader),{data:b,error:S,isLoading:C,mutate:j}=u(`/api/you`,I),[N,P]=(0,Y.useState)(null),[L,R]=(0,Y.useState)(!1),[z,ne]=(0,Y.useState)(``),[K,se]=(0,Y.useState)(`preference`),[q,pe]=(0,Y.useState)(null),[he,ve]=(0,Y.useState)(!1),[Ce,ke]=(0,Y.useState)(null),[J,je]=(0,Y.useState)(!1),[Me,Pe]=(0,Y.useState)(``),[Ie,qe]=(0,Y.useState)(!1),[Je,Ye]=(0,Y.useState)(null),[Ze,Qe]=(0,Y.useState)(!1),[$e,et]=(0,Y.useState)(!1),[tt,nt]=(0,Y.useState)(!1),[rt,it]=(0,Y.useState)(null),[at,ot]=(0,Y.useState)(!1),[st,ct]=(0,Y.useState)(null),[lt,ut]=(0,Y.useState)(null),[dt,ft]=(0,Y.useState)(!1),[pt,mt]=(0,Y.useState)(null),ht=(0,Y.useRef)(null),gt=(0,Y.useRef)(null),Q=b?.profile??{callName:``,pronouns:``,timezone:``,notes:``},_t=(0,Y.useMemo)(()=>b?.understanding.filter(e=>e.status===`active`)??[],[b]),vt=(0,Y.useMemo)(()=>b?.understanding.filter(e=>e.status!==`active`)??[],[b]),yt=(0,Y.useMemo)(()=>new Map(Le.map(e=>[e,_t.filter(t=>t.facet===e)])),[_t]),bt=Je??b?.controls??null,xt=b?.sources.filter(e=>e.installed&&e.enabled)??[],St=xt.filter(e=>[`failed`,`unauthorized`,`degraded`,`not_configured`].includes(e.status));async function Ct(e){if(!(!b||tt)){nt(!0);try{let t=await ee(e);await j({...b,relationship:t.relationship},{revalidate:!1})}catch{V({type:`error`,title:t.supportModeTitle,message:t.saveError})}finally{nt(!1)}}}let $=(e,t)=>{let n=new URLSearchParams(r);e===`overview`?n.delete(`tab`):n.set(`tab`,e),t?n.set(`status`,t):n.delete(`status`),p(n,{replace:!0})},wt=e=>{let t=new URLSearchParams({connector:e.id});e.instanceId&&t.set(`instance`,e.instanceId),n(`/connectors?${t.toString()}`)};(0,Y.useLayoutEffect)(()=>(h({startExtra:null,main:(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,X.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:(0,X.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2.5 text-xs`,onClick:()=>ot(!0),children:[(0,X.jsx)(me,{className:`size-3.5`,"aria-hidden":!0}),t.howItWorks]})}),()=>y()),[y,h,t.howItWorks,t.subtitle,t.title]),(0,Y.useEffect)(()=>{!b||b.profile.callName||Pe(b.profileSetup.callNameSuggestion?.value??``)},[b,b?.profile.callName,b?.profileSetup.callNameSuggestion?.id]);async function Tt(e,n,r){P(e.id);try{let t=await le(e.id,{action:n,content:r});await j(r=>r&&{...r,understanding:n===`reject`?r.understanding.filter(t=>t.id!==e.id):r.understanding.map(n=>n.id===e.id?t:n)},{revalidate:!1}),j()}catch{V({type:`error`,title:t.title,message:t.saveError})}finally{P(null)}}async function Et(e,n){P(`consent:${e}`);try{await _(e,n),await j(),V({type:`success`,title:t.title,message:t.saved})}catch{V({type:`error`,title:t.title,message:t.saveError})}finally{P(null)}}async function Dt(){let e=z.trim();if(e){P(`understanding:new`);try{await F({content:e,kind:K}),ne(``),R(!1),await j(),V({type:`success`,title:t.understandingTitle,message:t.saved})}catch{V({type:`error`,title:t.understandingTitle,message:t.saveError})}finally{P(null)}}}async function Ot(){if(vt.length){P(`understanding:batch`);try{await v(vt.map(e=>e.id),`confirm`),await j()}catch{V({type:`error`,title:t.reviewTitle,message:t.saveError})}finally{P(null)}}}async function kt(e,n){P(`conflict:${e}`);try{await f(e,n),await j()}catch{V({type:`error`,title:t.conflictsTitle,message:t.saveError})}finally{P(null)}}async function At(e){P(`grant:${e}`);try{await te(e),await j()}catch{V({type:`error`,title:t.grantsTitle,message:t.saveError})}finally{P(null)}}async function jt(r,i){P(`insight:${r.id}`);try{let t=await _e(r.id,{action:i,uiLocale:e});await j(),i===`apply`&&t.href&&n(t.href)}catch{V({type:`error`,title:t.insightsTitle,message:t.saveError})}finally{P(null)}}async function Mt(e){P(`playbook:${e.id}`);try{await ce(e.id,!e.enabled),await j()}catch{V({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{P(null)}}async function Nt(e,n){P(`playbook:${e}`);try{await n(),await j()}catch{V({type:`error`,title:t.playbooksTitle,message:t.saveError})}finally{P(null)}}async function Pt(){if(q){P(q.id);try{await H(q.id);let e=q.id;pe(null),await j(t=>t&&{...t,understanding:t.understanding.filter(t=>t.id!==e)},{revalidate:!1}),j()}catch{V({type:`error`,title:t.title,message:t.saveError})}finally{P(null)}}}async function Ft(){if(Ce){je(!0);try{let e=await U(Ce);ve(!1),ke(null),await j(t=>t&&{...t,...e},{revalidate:!1})}catch{V({type:`error`,title:t.title,message:t.saveError})}finally{je(!1)}}}async function It(){let e=Me.trim();if(!(!e||Ie)){qe(!0);try{let t=await U({callName:e,timezone:Q.timezone||re()});await j(e=>e&&{...e,...t},{revalidate:!1})}catch{V({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}async function Lt(){if(!Ie){qe(!0);try{let e=await oe(`snooze`);await j(t=>t&&{...t,profileSetup:e.profileSetup},{revalidate:!1})}catch{V({type:`error`,title:t.title,message:t.saveError})}finally{qe(!1)}}}function Rt(){ke(Q),ve(!0),$(`profile`),requestAnimationFrame(()=>ht.current?.scrollIntoView({behavior:`smooth`,block:`start`}))}function zt(e){se(e),R(!0),$(`understanding`)}async function Bt(){if(bt){Qe(!0);try{Ye(await ye(bt)),await j(),V({type:`success`,title:t.title,message:t.saved})}catch{V({type:`error`,title:t.title,message:t.saveError})}finally{Qe(!1)}}}async function Vt(e){if(!($e||e===b?.trust.defaultActionLevel)){et(!0);try{let t=await Se(e);await j(e=>e&&{...e,trust:t},{revalidate:!1})}catch{V({type:`error`,title:t.trustTitle,message:t.saveError})}finally{et(!1),it(null)}}}async function Ht(e){if(!(!lt?.instanceId||dt)){ft(!0);try{let n=await ge(lt.instanceId,e);ut(null),await j(),V({type:`success`,title:t.sourcesTitle,message:e?t.disconnectDeleted.replace(`{{count}}`,String(n.deletedUnderstandingCount)):t.disconnectSuccess})}catch{V({type:`error`,title:t.sourcesTitle,message:t.saveError})}finally{ft(!1)}}}async function Ut(){if(!pt){mt(`export`);try{let e=await x(),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`xopc-about-you-${e.exportedAt.slice(0,10)}.json`,n.click(),URL.revokeObjectURL(t)}catch{V({type:`error`,title:t.transferTitle,message:t.saveError})}finally{mt(null)}}}async function Wt(e){if(!(!e||pt)){mt(`import`);try{if(e.size>2*1024*1024)throw Error(`file too large`);let n=await k(JSON.parse(await e.text()));await j(),$(`understanding`,`review`),V({type:`success`,title:t.transferTitle,message:t.importSuccess.replace(`{{count}}`,String(n.importedCount)).replace(`{{skipped}}`,String(n.skippedCount))})}catch{V({type:`error`,title:t.transferTitle,message:t.importError})}finally{gt.current&&(gt.current.value=``),ct(null),mt(null)}}}function Gt(){ct(null),gt.current&&(gt.current.value=``)}return(0,X.jsxs)(`main`,{className:`flex w-full flex-1 flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(De,{items:[{id:`overview`,label:t.tabs.overview,icon:D},{id:`profile`,label:t.tabs.profile,icon:G},{id:`understanding`,label:t.tabs.understanding,icon:Te,count:vt.length||void 0},{id:`sources`,label:t.tabs.sources,icon:O},{id:`controls`,label:t.tabs.controls,icon:de}],activeTab:m,onChange:$,ariaLabel:t.title,tabIdPrefix:`you-tab`,panelIdPrefix:`you-panel`,className:`pr-8 sm:pr-1`,buttonClassName:`px-2.5 sm:px-3`}),(0,X.jsx)(`div`,{className:`pointer-events-none absolute inset-y-1 right-0 w-8 bg-gradient-to-l from-surface-panel to-transparent sm:hidden`,"aria-hidden":!0})]}),C?(0,X.jsx)(He,{}):S||!b?(0,X.jsx)(`div`,{className:`rounded-2xl border border-danger/25 bg-danger-soft p-5 text-sm text-danger`,children:t.loadError}):null,b&&m===`overview`?(0,X.jsxs)(`div`,{id:`you-panel-overview`,role:`tabpanel`,"aria-labelledby":`you-tab-overview`,className:`space-y-4`,children:[!Q.callName&&b.profileSetup.shouldPrompt?(0,X.jsx)(Xe,{suggestion:b.profileSetup.callNameSuggestion,draft:Me,busy:Ie,onDraftChange:Pe,onSave:()=>void It(),onLater:()=>void Lt(),t}):null,vt.length>0||St.length>0||!Q.callName?(0,X.jsxs)(`section`,{className:`rounded-2xl border border-warning/25 bg-warning-soft/35 p-5`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.attentionTitle}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[vt.length>0?(0,X.jsxs)(E,{type:`button`,variant:`secondary`,onClick:()=>$(`understanding`,`review`),children:[ze(t.reviewCount,vt.length),(0,X.jsx)(we,{className:`size-4`,"aria-hidden":!0})]}):null,St.length>0?(0,X.jsxs)(E,{type:`button`,variant:`secondary`,onClick:()=>$(`sources`),children:[ze(t.sourceIssues,St.length),(0,X.jsx)(we,{className:`size-4`,"aria-hidden":!0})]}):null,Q.callName?null:(0,X.jsxs)(E,{type:`button`,variant:`secondary`,onClick:Rt,children:[t.completeProfile,(0,X.jsx)(we,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,(0,X.jsx)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-4`,children:(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>$(`understanding`),children:[(0,X.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:_t.length}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.knownSummary})]}),(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>$(`sources`),children:[(0,X.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:xt.length}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.connectedSources})]}),(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>$(`understanding`,`review`),children:[(0,X.jsx)(`span`,{className:`text-xl font-semibold text-fg`,children:vt.length}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.waitingReview})]})]})}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,X.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(D,{className:`size-4 text-accent`,"aria-hidden":!0}),t.supportModeTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.supportModeHint})]}),(0,X.jsxs)(`label`,{className:`grid min-w-48 gap-1 text-xs font-medium text-fg-muted`,children:[(0,X.jsx)(`span`,{className:`sr-only`,children:t.supportModeTitle}),(0,X.jsx)(ue,{value:b.relationship.supportMode,disabled:tt,onChange:e=>void Ct({supportMode:e.target.value}),children:Object.entries(t.supportModes).map(([e,t])=>(0,X.jsx)(W,{value:e,children:t},e))})]})]}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 border-t border-edge-subtle pt-4 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:b.relationship.proactiveEnabled,disabled:tt,onChange:e=>void Ct({proactiveEnabled:e.target.checked})}),t.proactiveEnabled]}),(0,X.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.quietStart,(0,X.jsx)(Oe,{value:b.relationship.quietStart??``,disabled:tt,allowEmpty:!0,clearLabel:t.clearTime,ariaLabel:t.quietStart,onChange:e=>void Ct({quietStart:e||null})})]}),(0,X.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.quietEnd,(0,X.jsx)(Oe,{value:b.relationship.quietEnd??``,disabled:tt,allowEmpty:!0,clearLabel:t.clearTime,ariaLabel:t.quietEnd,onChange:e=>void Ct({quietEnd:e||null})})]}),(0,X.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.blockedTopics,(0,X.jsx)(`input`,{className:Re,defaultValue:b.relationship.blockedTopics.join(`, `),disabled:tt,onBlur:e=>void Ct({blockedTopics:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})})]})]})]}),b.insights.length>0?(0,X.jsxs)(`section`,{className:`rounded-2xl border border-accent/15 bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(fe,{className:`size-4 text-accent`,"aria-hidden":!0}),t.insightsTitle]}),(0,X.jsx)(Be,{children:t.confirmedContextBadge})]}),(0,X.jsx)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-2`,children:b.insights.map(e=>(0,X.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.insight}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:e.evidenceCount>1?ze(t.insightEvidence,e.evidenceCount):t.insightReason}),(0,X.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:N===`insight:${e.id}`,onClick:()=>void jt(e,`dismiss`),children:t.notNow}),(0,X.jsx)(E,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:N===`insight:${e.id}`,onClick:()=>void jt(e,`apply`),children:t.insightActions[e.action]})]})]},e.id))})]}):null,(0,X.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(G,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.profileHint})]}),(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`profile`),children:(0,X.jsx)(we,{className:`size-4`,"aria-hidden":!0})})]}),(0,X.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.callName||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.timezone||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.pronouns||`—`})]}),Q.notes?(0,X.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,X.jsx)(`dd`,{className:`mt-1 line-clamp-2 text-sm leading-6 text-fg`,children:Q.notes})]}):null]})]}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(Te,{className:`size-4 text-accent`,"aria-hidden":!0}),t.understandingTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.understandingHint})]}),(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>$(`understanding`),children:(0,X.jsx)(we,{className:`size-4`,"aria-hidden":!0})})]}),(0,X.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[_t.slice(0,4).map(e=>(0,X.jsx)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5 text-sm leading-5 text-fg`,children:e.statement},e.id)),_t.length===0?(0,X.jsx)(`p`,{className:`py-5 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]})]})]})]}):null,b&&m===`profile`?(0,X.jsxs)(`div`,{id:`you-panel-profile`,role:`tabpanel`,"aria-labelledby":`you-tab-profile`,className:`space-y-5`,children:[(0,X.jsxs)(`section`,{ref:ht,id:`you-profile-card`,className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,X.jsx)(G,{className:`size-4 text-accent`,"aria-hidden":!0}),t.profileTitle]}),(0,X.jsx)(Be,{children:t.onlyYouEditBadge})]}),(0,X.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-fg-muted`,children:t.profileHint})]}),he?null:(0,X.jsxs)(E,{type:`button`,variant:`secondary`,onClick:Rt,children:[(0,X.jsx)(Ee,{className:`size-3.5`,"aria-hidden":!0}),t.edit]})]}),he&&Ce?(0,X.jsxs)(`div`,{className:`mt-5`,children:[(0,X.jsx)(Ae,{value:Ce,onChange:ke,language:e,inputClassName:Re,labels:{callName:t.callName,callNamePlaceholder:t.meetPlaceholder,pronouns:t.pronouns,pronounsPlaceholder:t.pronounsPlaceholder,timezone:t.timezone,timezoneCustom:t.timezoneCustom,timezoneDetect:t.timezoneDetect,custom:t.custom,notes:t.notes,notesPlaceholder:t.notesPlaceholder}}),(0,X.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,X.jsx)(E,{type:`button`,variant:`ghost`,onClick:()=>{ve(!1),ke(null)},children:t.cancel}),(0,X.jsx)(E,{type:`button`,variant:`primary`,disabled:J,onClick:()=>void Ft(),children:J?t.saving:t.save})]})]}):(0,X.jsxs)(`dl`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.callName}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.callName||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.timezone}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.timezone||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.pronouns}),(0,X.jsx)(`dd`,{className:`mt-1 text-sm text-fg`,children:Q.pronouns||`—`})]}),(0,X.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,X.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:t.notes}),(0,X.jsx)(`dd`,{className:`mt-1 whitespace-pre-wrap text-sm leading-6 text-fg`,children:Q.notes||`—`})]})]})]}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.structuredContextTitle}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>zt(`preference`),children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addPreference}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addPreferenceHint})]}),(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>zt(`boundary`),children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addBoundary}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addBoundaryHint})]}),(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-4 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>zt(`current_state`),children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:t.addCurrentFocus}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.addCurrentFocusHint})]})]})]}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[(0,X.jsx)(ae,{className:`size-4 text-accent`,"aria-hidden":!0}),t.playbooksTitle]}),(0,X.jsx)(Be,{children:t.affectsAgentsBadge})]}),b.playbooks.length>0?(0,X.jsx)(`div`,{className:`mt-4 grid gap-3 xl:grid-cols-3`,children:b.playbooks.map(e=>(0,X.jsx)(Ke,{playbook:e,busy:N===`playbook:${e.id}`,t,onToggleGroup:()=>void Mt(e),onCreate:t=>void Nt(e.id,()=>M(e.id,t,(e.rules.at(-1)?.order??0)+10)),onUpdate:(t,n)=>void Nt(e.id,()=>ie(e.id,t,n)),onDelete:t=>void Nt(e.id,()=>w(e.id,t)),onRollback:(t,n)=>void Nt(e.id,()=>be(e.id,t,n))},e.id))}):(0,X.jsx)(`p`,{className:`mt-4 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.emptyPlaybooks})]})]}):null,b&&m===`understanding`?(0,X.jsxs)(`div`,{id:`you-panel-understanding`,role:`tabpanel`,"aria-labelledby":`you-tab-understanding`,className:`space-y-6`,children:[(0,X.jsxs)(`section`,{className:`border-b border-edge pb-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.addUnderstanding}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.addUnderstandingHint})]}),L?null:(0,X.jsxs)(E,{type:`button`,variant:`secondary`,onClick:()=>R(!0),children:[(0,X.jsx)(T,{className:`size-4`,"aria-hidden":!0}),t.add]})]}),L?(0,X.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,X.jsx)(`textarea`,{className:s(Re,`min-h-24 resize-y`),value:z,onChange:e=>ne(e.target.value),placeholder:t.understandingPlaceholder}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end justify-between gap-3`,children:[(0,X.jsxs)(`label`,{className:`grid min-w-48 gap-1 text-xs font-medium text-fg-muted`,children:[t.understandingKind,(0,X.jsx)(ue,{value:K,onChange:e=>se(e.target.value),children:Object.entries(t.understandingKinds).map(([e,t])=>(0,X.jsx)(W,{value:e,children:t},e))})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(E,{type:`button`,variant:`ghost`,onClick:()=>{R(!1),ne(``)},children:t.cancel}),(0,X.jsx)(E,{type:`button`,variant:`primary`,disabled:!z.trim()||N===`understanding:new`,onClick:()=>void Dt(),children:t.add})]})]})]}):null]}),b.conflictGroups.some(e=>e.unresolved)?(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.conflictsTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.conflictsHint}),(0,X.jsx)(`div`,{className:`mt-3 space-y-3`,children:b.conflictGroups.filter(e=>e.unresolved).map(n=>(0,X.jsx)(`div`,{className:`divide-y divide-edge overflow-hidden rounded-xl border border-warning/35 bg-warning-soft/25`,children:n.records.filter(e=>e.storedStatus!==`archived`&&e.storedStatus!==`rejected`).map(r=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:r.statement}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[Ue(r,t),` · `,Z(r.updatedAt,e)]})]}),(0,X.jsx)(E,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2.5`,disabled:N===`conflict:${n.id}`,onClick:()=>void kt(n.id,r.id),children:t.useThis})]},r.id))},n.id))})]}):null,b.consentRequests.length>0?(0,X.jsxs)(`section`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.consentTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.consentHint})]}),b.consentRequests.map(e=>(0,X.jsxs)(`article`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/20 p-4`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-6 text-fg`,children:e.statement}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.consentPurpose.replace(`{{purpose}}`,e.purpose)}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,X.jsx)(E,{type:`button`,variant:`ghost`,disabled:N===`consent:${e.id}`,onClick:()=>void Et(e.id,`deny`),children:t.consentDeny}),(0,X.jsx)(E,{type:`button`,variant:`secondary`,disabled:N===`consent:${e.id}`,onClick:()=>void Et(e.id,`once`),children:t.consentOnce}),(0,X.jsx)(E,{type:`button`,variant:`secondary`,disabled:N===`consent:${e.id}`,onClick:()=>void Et(e.id,`session`),children:t.consentSession}),(0,X.jsx)(E,{type:`button`,variant:`primary`,disabled:N===`consent:${e.id}`,onClick:()=>void Et(e.id,`always`),children:t.consentAlways})]})]},e.id))]}):null,vt.length>0?(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.reviewTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.reviewHint})]}),(0,X.jsx)(E,{type:`button`,variant:`secondary`,disabled:N===`understanding:batch`,onClick:()=>void Ot(),children:t.reviewAll})]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:vt.map(n=>(0,X.jsx)(We,{item:n,language:e,t,busy:N===n.id,onConfirm:()=>void Tt(n,`confirm`),onReject:()=>void Tt(n,`reject`),onUpdate:e=>void Tt(n,`update`,e),onForget:()=>pe(n)},n.id))})]}):_t.length>0?(0,X.jsxs)(`div`,{className:`rounded-2xl border border-success/20 bg-success-soft p-6 text-center`,children:[(0,X.jsx)(o,{className:`mx-auto size-5 text-success`,"aria-hidden":!0}),(0,X.jsx)(`h2`,{className:`mt-2 text-sm font-semibold text-fg`,children:t.nothingToReview}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.nothingToReviewHint})]}):null,Le.map(n=>{let r=yt.get(n)??[];return r.length===0?null:(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.facets[n]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:r.map(n=>(0,X.jsx)(We,{item:n,language:e,t,busy:N===n.id,onConfirm:()=>void Tt(n,`confirm`),onReject:()=>void Tt(n,`reject`),onUpdate:e=>void Tt(n,`update`,e),onForget:()=>pe(n)},n.id))})]},n)}),b.understanding.length===0?(0,X.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-10 text-center text-sm text-fg-muted`,children:t.emptyUnderstanding}):null]}):null,b&&m===`sources`?(0,X.jsxs)(`div`,{id:`you-panel-sources`,role:`tabpanel`,"aria-labelledby":`you-tab-sources`,className:`space-y-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsx)(`div`,{children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.sourcesTitle}),(0,X.jsx)(Be,{children:t.personalContextBadge})]})}),(0,X.jsxs)(E,{type:`button`,variant:`primary`,onClick:()=>n(`/connectors?tab=connected&personalContext=1`),children:[t.manageSources,(0,X.jsx)(we,{className:`size-4`,"aria-hidden":!0})]})]}),b.sourceRecommendations.length>0?(0,X.jsxs)(`section`,{className:`rounded-2xl border border-accent/20 bg-accent-soft/25 p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(d,{className:`size-4 text-accent`,"aria-hidden":!0}),t.recommendationsTitle]}),(0,X.jsx)(Be,{children:t.permissionsBeforeConnectBadge})]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 lg:grid-cols-3`,children:b.sourceRecommendations.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge-subtle bg-surface-panel p-3 text-left hover:border-accent/30 hover:bg-surface-hover`,onClick:()=>wt({id:e.sourceId}),children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:e.sourceName}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.recommendationReason.replace(`{{goal}}`,e.goalTitle)})]},e.sourceId))})]}):null,(0,X.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:b.sources.map(n=>(0,X.jsx)(Ge,{source:n,language:e,t,onConfigure:()=>wt(n),onDisconnect:()=>ut(n)},`${n.id}:${n.instanceId??`catalog`}`))}),b.sources.length===0?(0,X.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.noSources}):null]}):null,b&&m===`controls`&&bt?(0,X.jsxs)(`div`,{id:`you-panel-controls`,role:`tabpanel`,"aria-labelledby":`you-tab-controls`,className:`space-y-6`,children:[(0,X.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-2`,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.controlTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.controlHint}),(0,X.jsxs)(`div`,{className:`mt-4 space-y-3 rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.learningMode,(0,X.jsx)(ue,{value:bt.mode,onChange:e=>Ye({...bt,mode:e.target.value}),children:Object.entries(t.learningModes).map(([e,t])=>(0,X.jsx)(W,{value:e,children:t},e))})]}),(0,X.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[t.sensitive,(0,X.jsx)(ue,{value:bt.sensitiveWritePolicy,onChange:e=>Ye({...bt,sensitiveWritePolicy:e.target.value}),children:Object.entries(t.sensitiveOptions).map(([e,t])=>(0,X.jsx)(W,{value:e,children:t},e))}),(0,X.jsx)(`span`,{className:`font-normal leading-5 text-fg-subtle`,children:t.sensitiveOptionHints[bt.sensitiveWritePolicy]})]}),(0,X.jsx)(`div`,{className:`flex justify-end pt-2`,children:(0,X.jsx)(E,{type:`button`,variant:`primary`,disabled:Ze,onClick:()=>void Bt(),children:Ze?t.saving:t.save})})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.trustTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.trustHint}),(0,X.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:b.trust.levels.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":e===b.trust.defaultActionLevel,disabled:$e,onClick:()=>{e!==b.trust.defaultActionLevel&&(e===`auto`?it(e):Vt(e))},className:s(`rounded-xl border p-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-70`,e===b.trust.defaultActionLevel?`border-accent/35 bg-accent-soft/35`:`border-edge-subtle bg-surface-panel hover:border-accent/25 hover:bg-surface-hover`),children:[(0,X.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:t.trustLevels[e]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustLevelHints[e]}),e===b.trust.defaultActionLevel?(0,X.jsx)(`span`,{className:`mt-2 inline-block rounded-full bg-accent-soft px-2 py-0.5 text-[11px] text-accent-fg`,children:t.defaultTrust}):null]},e))})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.grantsTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.grantsHint}),b.referenceGrants.length>0?(0,X.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:b.referenceGrants.map(n=>(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`truncate text-sm text-fg`,children:n.statement}),(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[n.grantScope?t.grantScopes[n.grantScope]:``,n.expiresAt?` · ${Z(n.expiresAt,e)}`:``]})]}),(0,X.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2.5`,disabled:N===`grant:${n.id}`,onClick:()=>void At(n.id),children:t.revoke})]},n.id))}):(0,X.jsx)(`p`,{className:`mt-3 rounded-xl bg-surface-muted px-4 py-3 text-sm text-fg-muted`,children:t.noGrants})]}),(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.transferTitle}),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,X.jsxs)(E,{type:`button`,variant:`secondary`,disabled:pt!==null,onClick:()=>void Ut(),children:[(0,X.jsx)(B,{className:`size-4`,"aria-hidden":!0}),pt===`export`?t.exporting:t.exportAction]}),(0,X.jsxs)(E,{type:`button`,variant:`secondary`,disabled:pt!==null,onClick:()=>gt.current?.click(),children:[(0,X.jsx)(g,{className:`size-4`,"aria-hidden":!0}),pt===`import`?t.importing:t.importAction]}),(0,X.jsx)(`input`,{ref:gt,type:`file`,accept:`application/json,.json`,className:`sr-only`,onChange:e=>ct(e.target.files?.[0]??null)})]})]})]}):null,(0,X.jsx)(xe,{open:q!==null,title:t.forgetTitle,description:t.forgetBody,confirmLabel:t.forget,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void Pt(),onCancel:()=>pe(null)}),(0,X.jsx)(xe,{open:rt===`auto`,title:t.autoConfirmTitle,description:t.autoConfirmBody,confirmLabel:t.autoConfirmAction,cancelLabel:t.cancel,onConfirm:()=>void Vt(`auto`),onCancel:()=>it(null)}),(0,X.jsx)(xe,{open:st!==null,title:t.importConfirmTitle,description:t.importConfirmBody.replace(`{{name}}`,st?.name??``),confirmLabel:t.importConfirmAction,cancelLabel:t.cancel,onConfirm:()=>{let e=st;ct(null),Wt(e)},onCancel:Gt}),(0,X.jsx)(Fe,{source:lt,language:e,busy:dt,onOpenChange:e=>{e||ut(null)},onConfirm:e=>void Ht(e)}),(0,X.jsx)(Ne,{open:at,t,onOpenChange:ot,onNavigate:$})]})}export{Ze as UserContextPage};
@@ -1 +1 @@
1
- import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{r as i,s as a}from"./locale-store-Dqp9H2Uf.js";import{to as o,ws as s}from"./index-Dfq2laZe.js";e();var c=t();function l(){return{enabled:!0,provider:`xopc-local`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},providers:{"xopc-local":{model:`sensevoice-small`}},fallback:{enabled:!1,order:[`xopc-local`]}}}function u(){return{enabled:!0,provider:`edge`,trigger:`inbound`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function d(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function p(e,t,n){let r=d(e.providers)?e.providers:void 0,i=r&&d(r[t])?r[t]:void 0;return{...n,...i??{}}}function m(e){let t=l();if(!d(e))return t;let n=f(e.provider),r=p(e,`alibaba`,t.alibaba??{}),i=p(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(d(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=d(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,d(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function h(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function g(e){let t=u();if(!d(e))return t;let n=h(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=d(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,d(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:p(e,`alibaba`,t.alibaba??{}),openai:p(e,`openai`,t.openai??{}),edge:p(e,`edge`,t.edge??{}),minimax:p(e,`minimax`,t.minimax??{}),"tts-local-cli":p(e,`tts-local-cli`,i)}}function _(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function v(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function y(e){let t=d(e)?e:{},n=d(t.voice)?t.voice:{},r=d(n.input)?n.input:{},i=d(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:m(t.stt),tts:g(t.tts),voice:{languageMode:n.languageMode===`manual`?`manual`:`auto`,language:n.language===`zh`?`zh`:`en`,input:{refinement:{mode:a,...typeof i.model==`string`&&i.model.trim()?{model:i.model.trim()}:{},...typeof i.customInstruction==`string`?{customInstruction:i.customInstruction}:{}}}}}}async function b(){return y((await a(i(`/api/config`))).payload?.config??{})}async function x(e){await a(i(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:_(e.stt),tts:v(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await a(i(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),o()}async function S(){let e=await a(i(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function C(){let e=await a(i(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function w(){let e=await a(i(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function T(){let e=await a(i(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function E(e){await a(i(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function D(e){await a(i(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function O(e){let t=await a(i(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function k(e){let t=await a(i(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}var A=n();function j(e){let t=(0,c.c)(15),{kind:n,providerId:i,fieldId:a,value:o,onChange:l,labels:u,placeholder:d,className:f}=e,p=d===void 0?`sk-...`:d,m;t[0]!==n||t[1]!==i?(m=()=>k({kind:n,provider:i}).then(M),t[0]=n,t[1]=i,t[2]=m):m=t[2];let h=m,g;t[3]===f?g=t[4]:(g=r(`flex min-w-0 flex-col gap-1.5`,f),t[3]=f,t[4]=g);let _;t[5]!==a||t[6]!==u||t[7]!==l||t[8]!==p||t[9]!==h||t[10]!==o?(_=(0,A.jsx)(s,{id:a,value:o,onChange:l,placeholder:p,labels:u,reveal:h,loadFailedLabel:u.loadFailed,maskedHelp:u.maskedHelp,notInConfigFile:u.notInConfigFile,inputClassName:`text-xs`}),t[5]=a,t[6]=u,t[7]=l,t[8]=p,t[9]=h,t[10]=o,t[11]=_):_=t[11];let v;return t[12]!==g||t[13]!==_?(v=(0,A.jsx)(`div`,{className:g,children:_}),t[12]=g,t[13]=_,t[14]=v):v=t[14],v}function M(e){return e.apiKey??null}export{b as a,y as c,O as d,C as i,x as l,T as n,w as o,S as r,E as s,j as t,D as u};
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-JdwAhgNB.js";import{r as i,s as a}from"./locale-store-CzIfXqm8.js";import{to as o,ws as s}from"./index-vHb2z7VS.js";e();var c=t();function l(){return{enabled:!0,provider:`xopc-local`,alibaba:{model:`paraformer-v2`},openai:{model:`whisper-1`},providers:{"xopc-local":{model:`sensevoice-small`}},fallback:{enabled:!1,order:[`xopc-local`]}}}function u(){return{enabled:!0,provider:`edge`,trigger:`inbound`,maxTextLength:512,timeoutMs:6e4,alibaba:{model:`qwen-tts`,voice:`Cherry`},openai:{model:`tts-1`,voice:`alloy`},edge:{voice:`zh-CN-XiaoxiaoNeural`,lang:`zh-CN`},minimax:{model:`speech-2.8-hd`,voice:`male-qn-qingse`},"tts-local-cli":{command:``,outputFormat:`wav`}}}function d(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f(e){return typeof e==`string`&&e.trim().length>0?e.trim():`xopc-local`}function p(e,t,n){let r=d(e.providers)?e.providers:void 0,i=r&&d(r[t])?r[t]:void 0;return{...n,...i??{}}}function m(e){let t=l();if(!d(e))return t;let n=f(e.provider),r=p(e,`alibaba`,t.alibaba??{}),i=p(e,`openai`,t.openai??{}),a=t.fallback??{enabled:!1,order:[`xopc-local`]};if(d(e.fallback)){let t=Array.isArray(e.fallback.order)?e.fallback.order.filter(e=>typeof e==`string`&&e.trim().length>0):a.order;a={enabled:typeof e.fallback.enabled==`boolean`?e.fallback.enabled:a.enabled,order:t.length?t:a.order}}let o=d(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,d(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,alibaba:r,openai:i,...o?{providers:o}:{},fallback:a}}function h(e){return typeof e==`string`&&e.trim().length>0?e.trim():`edge`}function g(e){let t=u();if(!d(e))return t;let n=h(e.provider),r=e.trigger===`off`||e.trigger===`always`||e.trigger===`inbound`||e.trigger===`tagged`?e.trigger:`inbound`,i=t[`tts-local-cli`]??{},a=d(e.providers)?Object.fromEntries(Object.entries(e.providers).map(([e,t])=>[e,d(t)?{...t}:{}])):void 0;return{enabled:!!e.enabled,provider:n,trigger:r,maxTextLength:typeof e.maxTextLength==`number`&&Number.isFinite(e.maxTextLength)?e.maxTextLength:t.maxTextLength,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)?e.timeoutMs:t.timeoutMs,...a?{providers:a}:{},alibaba:p(e,`alibaba`,t.alibaba??{}),openai:p(e,`openai`,t.openai??{}),edge:p(e,`edge`,t.edge??{}),minimax:p(e,`minimax`,t.minimax??{}),"tts-local-cli":p(e,`tts-local-cli`,i)}}function _(e){let{alibaba:t,openai:n,providers:r,...i}=e,a={...r??{}};return t&&(a.alibaba={...a.alibaba??{},...t}),n&&(a.openai={...a.openai??{},...n}),{...i,...Object.keys(a).length>0?{providers:a}:{}}}function v(e){let{alibaba:t,openai:n,edge:r,minimax:i,"tts-local-cli":a,providers:o,...s}=e,c={...o??{}};return t&&(c.alibaba={...c.alibaba??{},...t}),n&&(c.openai={...c.openai??{},...n}),r&&(c.edge={...c.edge??{},...r}),i&&(c.minimax={...c.minimax??{},...i}),a&&(c[`tts-local-cli`]={...c[`tts-local-cli`]??{},...a}),{...s,...Object.keys(c).length>0?{providers:c}:{}}}function y(e){let t=d(e)?e:{},n=d(t.voice)?t.voice:{},r=d(n.input)?n.input:{},i=d(r.refinement)?r.refinement:{},a=i.mode===`punctuation`||i.mode===`light`||i.mode===`custom`?i.mode:`off`;return{stt:m(t.stt),tts:g(t.tts),voice:{languageMode:n.languageMode===`manual`?`manual`:`auto`,language:n.language===`zh`?`zh`:`en`,input:{refinement:{mode:a,...typeof i.model==`string`&&i.model.trim()?{model:i.model.trim()}:{},...typeof i.customInstruction==`string`?{customInstruction:i.customInstruction}:{}}}}}}async function b(){return y((await a(i(`/api/config`))).payload?.config??{})}async function x(e){await a(i(`/api/config`),{method:`PATCH`,body:JSON.stringify({stt:_(e.stt),tts:v(e.tts),voice:e.voice})}),e.voice.languageMode===`auto`&&await a(i(`/api/voice/language`),{method:`POST`,body:JSON.stringify({language:e.voice.language})}),typeof window<`u`&&window.dispatchEvent(new Event(`voice-config-changed`)),o()}async function S(){let e=await a(i(`/api/voice/models`));if(!e.payload?.models)throw Error(`Missing voice models payload`);return e.payload.models}async function C(){let e=await a(i(`/api/voice/providers`));if(!e.payload?.providers)throw Error(`Missing voice providers payload`);return e.payload}async function w(){let e=await a(i(`/api/voice/stt-providers`));if(!e.payload?.providers)throw Error(`Missing STT providers payload`);return e.payload}async function T(){let e=await a(i(`/api/voice/local/status`));if(!e.payload)throw Error(`Missing local voice status payload`);return e.payload}async function E(e){await a(i(`/api/voice/local/models/${encodeURIComponent(e)}/install`),{method:`POST`,body:`{}`})}async function D(e){await a(i(`/api/voice/local/models/${encodeURIComponent(e)}`),{method:`DELETE`})}async function O(e){let t=await a(i(`/api/voice/tts-test`),{method:`POST`,body:JSON.stringify(e)});if(t.ok===!1){let e=typeof t.error==`string`?t.error:t.error?.message;throw Error(e||`TTS test failed`)}if(!t.payload||typeof t.payload.audio!=`string`||!t.payload.audio.trim())throw Error(`TTS test returned no audio. Check the selected voice engine and try again.`);return t.payload}async function k(e){let t=await a(i(`/api/voice/reveal-api-key`),{method:`POST`,body:JSON.stringify(e)});if(!t.payload)throw Error(`Missing reveal payload`);return t.payload}var A=n();function j(e){let t=(0,c.c)(15),{kind:n,providerId:i,fieldId:a,value:o,onChange:l,labels:u,placeholder:d,className:f}=e,p=d===void 0?`sk-...`:d,m;t[0]!==n||t[1]!==i?(m=()=>k({kind:n,provider:i}).then(M),t[0]=n,t[1]=i,t[2]=m):m=t[2];let h=m,g;t[3]===f?g=t[4]:(g=r(`flex min-w-0 flex-col gap-1.5`,f),t[3]=f,t[4]=g);let _;t[5]!==a||t[6]!==u||t[7]!==l||t[8]!==p||t[9]!==h||t[10]!==o?(_=(0,A.jsx)(s,{id:a,value:o,onChange:l,placeholder:p,labels:u,reveal:h,loadFailedLabel:u.loadFailed,maskedHelp:u.maskedHelp,notInConfigFile:u.notInConfigFile,inputClassName:`text-xs`}),t[5]=a,t[6]=u,t[7]=l,t[8]=p,t[9]=h,t[10]=o,t[11]=_):_=t[11];let v;return t[12]!==g||t[13]!==_?(v=(0,A.jsx)(`div`,{className:g,children:_}),t[12]=g,t[13]=_,t[14]=v):v=t[14],v}function M(e){return e.apiKey??null}export{b as a,y as c,O as d,C as i,x as l,T as n,w as o,S as r,E as s,j as t,D as u};
@@ -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{f as r,l as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./messages-CKZuaOeG.js";import{n as ee}from"./locale-store-CzIfXqm8.js";import{Ao as te,At as ne,Bo as s,Do as re,Eo as c,Ho as l,Io as ie,Is as ae,Kl as oe,Ll as u,Lo as se,Mo as ce,Nl as le,No as d,Ns as f,Oo as ue,Po as de,Ps as fe,Pt as pe,Ro as me,Vl as he,Vo as ge,bu as _e,il as p,ko as ve,ou as ye,pc as m,ro as h,vu as be,zo as xe}from"./index-vHb2z7VS.js";var g=e(t(),1),_=new Set([`completed`,`failed`,`canceled`]);function Se(){return new Promise(e=>window.setTimeout(e,1200))}async function Ce(e,t){let n=[],r=t.wait??Se;for(let i=0;i<e.length&&!t.shouldStop?.();i+=1){let a=e[i];if(a)try{await t.grantDirectory(a.rootPath);let o=await t.startRun(a.rootPath);for(t.onRun(o,i,e.length);!_.has(o.status)&&!t.shouldStop?.();)await r(),o=await t.fetchRun(o.id),t.onRun(o,i,e.length);if(n.push(o),o.status===`canceled`||t.shouldStop?.())break}catch(e){if(t.onError?.(e,a,i),t.shouldStop?.())break}}return n}var v=n(),we=[`folder_structure`,`recent_progress`,`next_steps`];function y(e){return e instanceof Error?e.message:String(e)}function b(){let e=ee(e=>e.language),t=o(e).onboarding.workDiscovery,n=o(e).chat.workingDirectory,_=i(),[Se]=r(),b=Se.get(`new`)===`1`,[x,S]=(0,g.useState)(`loading`),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(null),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(null),[Te,j]=(0,g.useState)(!1),[M,N]=(0,g.useState)(``),[P,F]=(0,g.useState)(!1),[I,L]=(0,g.useState)(()=>new Set),[R,z]=(0,g.useState)(!1),[B,Ee]=(0,g.useState)([]),[V,De]=(0,g.useState)(()=>new Set),[Oe,H]=(0,g.useState)([]),[ke,Ae]=(0,g.useState)(!1),[U,W]=(0,g.useState)({current:0,total:0}),G=(0,g.useRef)(!1),K=(0,g.useCallback)(e=>{c.getState().updateDirectoryRun(e),E(e),e.status===`completed`?(L(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),S(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`)):e.status===`failed`||e.status===`canceled`?S(`error`):S(`running`)},[]),je=async()=>{O(!0),A(null);try{let e=await ve();if(!e.length){A(t.noCandidates);return}Ee(e),De(new Set([e[0].rootPath])),S(`candidates`)}catch(e){A(y(e))}finally{O(!1)}},Me=e=>{De(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ne=(0,g.useCallback)((e,t,n)=>{c.getState().updateDirectoryRun(e),E(e),W({current:t+1,total:n}),H(n=>{let r=[...n];return r[t]=e,r}),S(`running`)},[]),Pe=(0,g.useCallback)(e=>{H(t=>t.map(t=>t?.id===e.id?e:t))},[]),Fe=async()=>{let e=B.filter(e=>V.has(e.rootPath));if(!e.length)return;O(!0),A(null),H([]),W({current:1,total:e.length}),Ae(!0),G.current=!1;let n=!1;try{let r=await Ce(e,{grantDirectory:de,startRun:xe,fetchRun:d,shouldStop:()=>G.current,onRun:(e,t,r)=>{Ne(e,t,r),n||(n=!0,c.getState().scanPersonalContext(e.id))},onError:(n,r,i)=>{W({current:i+1,total:e.length}),A(t.folderAnalysisFailed.replace(`{{folder}}`,r.displayName).replace(`{{error}}`,y(n)))}});if(G.current)return;let i=r.find(e=>e.status===`completed`)??r.at(-1);i?K(i):S(`candidates`)}catch(e){A(y(e)),S(`candidates`)}finally{Ae(!1),O(!1)}},q=pe({onPicked:(0,g.useCallback)(async e=>{O(!0),A(null);try{w(await ie(e)),S(`consent`)}catch(e){A(y(e)),S(`intro`)}finally{O(!1)}},[])});(0,g.useEffect)(()=>{let e=!1;return ce().then(async({enabled:t,state:n})=>{if(!e){if(!t){_(`/chat`,{replace:!0});return}if(!b&&n.activeRunId)try{let t=await d(n.activeRunId);e||K(t);return}catch{}e||S(`intro`)}}).catch(t=>{e||(A(y(t)),S(`intro`))}),()=>{e=!0}},[K,_,b]),(0,g.useEffect)(()=>{if(!T||x!==`running`||ke)return;let e=!1,t=async()=>{try{let t=await d(T.id);e||K(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===T.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,ke,x,T]);let J=async()=>{O(!0);try{await te()}finally{_(`/chat`,{replace:!0})}},Ie=async()=>{if(C){O(!0),A(null),H([]),W({current:0,total:0});try{await de(C.canonicalRootPath);let e=await xe(C.canonicalRootPath);K(e),c.getState().scanPersonalContext(e.id)}catch(e){A(y(e)),S(`consent`)}finally{O(!1)}}},Y=(e,t)=>{let n=t?`?draft=${encodeURIComponent(t)}`:``;_(`/chat/${encodeURIComponent(e)}${n}`)},Le=e=>{E(e),z(!1),j(!1),F(!1),L(new Set(e.result?.profileCandidates?.filter(e=>e.status===`pending`).map(e=>e.id)??[])),e.status===`completed`?S(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?S(`error`):S(`running`)},Re=async()=>{T&&(G.current=!0,K(await ue(T.id)))},X=async(t,n)=>{if(!T)return;await me(T.id,t.id).catch(()=>{});let r=n?`${e===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${t.actionPrompt}`:t.actionPrompt;Y(T.sessionKey,r)},ze=async()=>{if(T){O(!0),A(null);try{let e=T.result?.profileCandidates??[],t=e.length>0?await ge(T.id,e.map(e=>({id:e.id,status:I.has(e.id)?`accepted`:`rejected`}))):T;await Promise.all((t.result?.workThreads??[]).filter(e=>e.userStatus===`unreviewed`).map(e=>l(e.id,{decision:`confirmed`})));let n=await s(t.id,`confirmed`);E(n),Pe(n),S(`recommendation`)}catch(e){A(y(e))}finally{O(!1)}}},Z=async e=>{if(!(!T||!M.trim())){O(!0),A(null);try{let t=T.result?.workThreads?.find(e=>e.horizon===`current`)??T.result?.workThreads?.[0];t&&await l(t.id,{decision:`corrected`,correctedSummary:M.trim()});let n=await s(T.id,e,M.trim());E(n),Y(n.sessionKey,M.trim())}catch(e){A(y(e)),O(!1)}}},Be=async()=>{if(T){O(!0);try{Y((await s(T.id,`dismissed`)).sessionKey)}catch(e){A(y(e)),O(!1)}}},Ve=async()=>{let e=T?.result?.workThreads?.find(e=>e.horizon===`current`)??T?.result?.workThreads?.[0];if(e){O(!0),A(null);try{await re(e.id),z(!0)}catch(e){A(y(e))}finally{O(!1)}}},Q=T?.result?.suggestions.find(e=>e.id===T.result?.primarySuggestionId)??T?.result?.suggestions[0],He=T?.result?.suggestions.filter(e=>e.id!==Q?.id)??[],Ue=e=>e===`command`?t.riskCommand:e===`file_write`?t.riskFileWrite:t.riskAnalysis,We=Oe.filter(e=>e?.status===`completed`),$=We.length>1?(0,v.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,v.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:t.analysisResults}),(0,v.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:We.map(e=>{let t=B.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,v.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===T?.id?`bg-accent text-white`:`bg-surface-muted text-fg hover:bg-surface-hover`}`,onClick:()=>Le(e),children:t},e.id)})})]}):null;return(0,v.jsxs)(`div`,{className:`flex min-h-full flex-1 flex-col bg-surface-base`,children:[(0,v.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,v.jsx)(`div`,{className:`mb-10 flex items-center justify-center`,children:(0,v.jsx)(fe,{className:`size-11`})}),x===`loading`?(0,v.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,v.jsx)(h,{className:`mx-auto h-8 w-64`}),(0,v.jsx)(h,{className:`mx-auto h-4 w-full max-w-lg`}),(0,v.jsx)(h,{className:`mx-auto size-4/5 max-w-md`}),(0,v.jsx)(h,{className:`mt-8 h-12 w-full rounded-xl`})]}):null,x===`intro`?(0,v.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,v.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,v.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.title}),(0,v.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:t.subtitle})]}),(0,v.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[(0,v.jsxs)(f,{type:`button`,className:`h-12 w-full gap-2 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void je(),disabled:D||q.picking,children:[D?(0,v.jsx)(p,{className:`size-4 animate-spin`}):(0,v.jsx)(m,{className:`size-4`}),t.quickScan]}),(0,v.jsxs)(f,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:q.pick,disabled:D||q.picking,children:[q.picking?(0,v.jsx)(p,{className:`size-4 animate-spin`}):(0,v.jsx)(u,{className:`size-4`}),t.chooseFolderManually]}),(0,v.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,v.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,v.jsx)(`span`,{children:t.quickScanNote})]}),k?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:k}):null]}),(0,v.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:D,children:t.skip})]}):null,x===`candidates`?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-candidates-title`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.candidatesTitle}),(0,v.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.candidatesSubtitle})]}),(0,v.jsx)(`div`,{className:`mt-7 space-y-2`,children:B.map((e,n)=>{let r=V.has(e.rootPath);return(0,v.jsxs)(`button`,{type:`button`,"aria-pressed":r,className:`flex w-full items-start gap-3 rounded-xl border p-4 text-left transition ${r?`border-accent bg-accent-soft/45`:`border-edge bg-surface-panel hover:border-edge-strong`}`,onClick:()=>Me(e.rootPath),children:[(0,v.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-md border ${r?`border-accent bg-accent text-white`:`border-edge bg-surface-base text-transparent`}`,children:(0,v.jsx)(a,{className:`size-3.5`})}),(0,v.jsx)(u,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,v.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,v.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),n===0?(0,v.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:t.recommendedCandidate}):null]}),(0,v.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,v.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,v.jsx)(`span`,{children:e.projectKind===`coding`?t.codingProject:e.projectKind===`general`?t.generalProject:t.unknownProject}),e.branch?(0,v.jsx)(`span`,{children:t.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,v.jsx)(`span`,{children:t.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,v.jsxs)(`div`,{className:`mt-5 flex items-start gap-2 rounded-xl border border-edge-subtle bg-surface-panel px-4 py-3 text-xs leading-5 text-fg-muted`,children:[(0,v.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,v.jsx)(`span`,{children:t.multiFolderPrivacyNote})]}),k?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:k}):null,(0,v.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,v.jsxs)(f,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:D||V.size===0,onClick:()=>void Fe(),children:[D?(0,v.jsx)(p,{className:`mr-2 size-4 animate-spin`}):null,t.analyzeSelected.replace(`{{count}}`,String(V.size))]}),(0,v.jsx)(f,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:D,onClick:q.pick,children:t.chooseFolderManually})]}),(0,v.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>S(`intro`),children:t.back})]}):null,x===`consent`&&C?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.selectedTitle}),(0,v.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.selectedSubtitle})]}),(0,v.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,v.jsx)(u,{className:`size-5 shrink-0 text-accent-fg`}),(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:C.displayName}),(0,v.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:C.canonicalRootPath})]}),(0,v.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:C.projectKind===`coding`?t.codingProject:C.projectKind===`general`?t.generalProject:t.unknownProject})]}),(0,v.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle bg-surface-base/60 p-4 sm:grid-cols-2`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.localFingerprint}),(0,v.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:C.fingerprint.branch?t.branchValue.replace(`{{branch}}`,C.fingerprint.branch):t.noGitBranch})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentActivity}),(0,v.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:t.changedFiles.replace(`{{count}}`,String(C.fingerprint.changedFileCount))})]}),C.fingerprint.recentAreas.length>0?(0,v.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.recentAreas}),(0,v.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:C.fingerprint.recentAreas.map(e=>(0,v.jsx)(`code`,{className:`rounded-md bg-surface-muted px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,v.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,v.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,v.jsx)(he,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willRead}),(0,v.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willReadValue})]})]}),(0,v.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,v.jsx)(ae,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.willIgnore}),(0,v.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.willIgnoreValue})]})]}),(0,v.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,v.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,v.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:C.remoteModel?t.providerDisclosure.replace(`{{provider}}`,C.provider):t.localDisclosure})]})]})]}),k?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:k}):null,(0,v.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,v.jsxs)(f,{type:`button`,className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:D,onClick:()=>void Ie(),children:[D?(0,v.jsx)(p,{className:`mr-2 size-4 animate-spin`}):null,t.startAnalysis]}),(0,v.jsx)(f,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:D,onClick:q.pick,children:t.changeFolder})]}),(0,v.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,x===`running`&&T?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:t.analyzingTitle}),(0,v.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:t.analyzingSubtitle}),U.total>1?(0,v.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:t.analyzingFolderProgress.replace(`{{current}}`,String(U.current)).replace(`{{total}}`,String(U.total))}):null]}),(0,v.jsx)(`div`,{className:`mt-9 rounded-xl border border-edge bg-surface-panel px-5 py-2`,children:we.map((e,n)=>{let r=Math.max(0,we.indexOf(T.stage??`folder_structure`)),i=n<r,o=n===r;return(0,v.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-edge-subtle py-4 last:border-b-0`,children:[(0,v.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,v.jsx)(a,{className:`size-4`}):o?(0,v.jsx)(p,{className:`size-4 animate-spin motion-reduce:animate-none`}):(0,v.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`})}),(0,v.jsx)(`span`,{className:o||i?`text-sm font-medium text-fg`:`text-sm text-fg-muted`,children:t.stages[e]})]},e)})}),(0,v.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:T.rootPath}),(0,v.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3`,children:[(0,v.jsx)(f,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:()=>_(`/chat`),children:t.continueInBackground}),(0,v.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void Re(),children:t.cancelAnalysis})]})]}):null,x===`recognition`&&T?.result?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-recognition-title`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.recognitionEyebrow}),(0,v.jsx)(`h1`,{id:`work-discovery-recognition-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:T.result.lowConfidence?t.lowConfidenceTitle:t.recognitionTitle})]}),$,(0,v.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,v.jsx)(`p`,{className:`text-base font-medium leading-7 text-fg`,children:T.result.projectSummary}),(0,v.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:T.result.currentState}),!T.result.lowConfidence&&Q?.evidence.length?(0,v.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,v.jsxs)(`li`,{className:`flex gap-2 text-xs leading-5 text-fg-muted`,children:[(0,v.jsx)(le,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,v.jsxs)(`span`,{children:[e.path?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${Q.id}-recognition-${t}`))}):null]}),T.result.workThreads?.length?(0,v.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.workThreadsTitle}),(0,v.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.workThreadsSubtitle}),(0,v.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle`,children:T.result.workThreads.map(e=>(0,v.jsxs)(`div`,{className:`py-3 first:pt-0 last:pb-0`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:e.horizon===`current`?t.workThreadCurrent:e.horizon===`ongoing`?t.workThreadOngoing:t.workThreadLongTerm}),(0,v.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title})]}),(0,v.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:e.summary})]},e.id))})]}):null,T.result.profileCandidates?.length?(0,v.jsxs)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.profileCandidatesTitle}),(0,v.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.profileCandidatesSubtitle}),(0,v.jsx)(`div`,{className:`mt-3 space-y-2`,children:T.result.profileCandidates.map(e=>(0,v.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg px-2 py-2 hover:bg-surface-muted`,children:[(0,v.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 rounded border-edge accent-accent`,checked:I.has(e.id),onChange:()=>L(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})}),(0,v.jsx)(`span`,{className:`text-sm leading-5 text-fg`,children:e.statement})]},e.id))})]}):null,T.result.lowConfidence?(0,v.jsxs)(`div`,{className:`mt-5`,children:[(0,v.jsx)(`p`,{className:`text-sm font-medium leading-6 text-fg`,children:T.result.contextQuestion}),(0,v.jsx)(`textarea`,{value:M,onChange:e=>N(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,v.jsx)(f,{className:`mt-3 w-full bg-accent text-white hover:bg-accent-hover`,disabled:D||!M.trim(),onClick:()=>void Z(`different_goal`),children:t.continueWithCorrection})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,v.jsxs)(f,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,disabled:D,onClick:()=>void ze(),children:[D?(0,v.jsx)(p,{className:`size-4 animate-spin`}):(0,v.jsx)(a,{className:`size-4`}),t.confirmUnderstanding]}),(0,v.jsx)(f,{variant:`secondary`,className:`h-11 flex-1`,disabled:D,onClick:()=>j(e=>!e),children:t.notQuiteRight})]}),Te?(0,v.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,v.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`work-discovery-correction`,children:t.correctionLabel}),(0,v.jsx)(`textarea`,{id:`work-discovery-correction`,value:M,onChange:e=>N(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,v.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,v.jsx)(f,{variant:`ghost`,disabled:D||!M.trim(),onClick:()=>void Z(`different_goal`),children:t.differentGoal}),(0,v.jsx)(f,{variant:`primary`,disabled:D||!M.trim(),onClick:()=>void Z(`corrected`),children:t.useCorrection})]})]}):null]}),k?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:k}):null,(0,v.jsx)(`button`,{type:`button`,disabled:D,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline disabled:opacity-60`,onClick:()=>void Be(),children:t.openConversation})]}):null,x===`recommendation`&&T?.result&&Q?(0,v.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:t.understandingConfirmed}),(0,v.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:t.primaryRecommendationTitle})]}),$,(0,v.jsx)(`article`,{className:`mt-7 rounded-2xl border border-accent/30 bg-surface-panel p-5 sm:p-6`,children:(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,v.jsx)(be,{className:`size-5`})}),(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Q.title}),(0,v.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Q.rationale}),(0,v.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,v.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,v.jsx)(ye,{className:`size-3.5`}),t.estimatedMinutes.replace(`{{count}}`,String(Q.estimatedMinutes))]}),(0,v.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2.5 py-1 text-fg-muted`,children:Ue(Q.risk)})]}),(0,v.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:t.expectedOutcome}),(0,v.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:Q.expectedOutcome})]}),(0,v.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,v.jsx)(f,{className:`h-10 bg-accent px-4 text-white hover:bg-accent-hover`,onClick:()=>void X(Q,!1),children:t.startRecommendedAction}),(0,v.jsx)(f,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void X(Q,!0),children:t.explainFirst})]})]})]})}),T.result.workThreads?.length?(0,v.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge bg-surface-panel p-4`,children:(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:R?(0,v.jsx)(a,{className:`size-4`}):(0,v.jsx)(oe,{className:`size-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:R?t.focusTrialActive:t.focusTrialTitle}),(0,v.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:R?t.focusTrialActiveDescription:t.focusTrialDescription}),R?null:(0,v.jsxs)(f,{className:`mt-3 h-9`,variant:`secondary`,disabled:D,onClick:()=>void Ve(),children:[D?(0,v.jsx)(p,{className:`size-4 animate-spin`}):(0,v.jsx)(oe,{className:`size-4`}),t.activateFocusTrial]})]})]})}):null,He.length>0?(0,v.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,v.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:()=>F(e=>!e),children:[t.otherDirections,(0,v.jsx)(_e,{className:`size-4 transition-transform ${P?`rotate-180`:``}`})]}),P?(0,v.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:He.map(e=>(0,v.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void X(e,!0),children:[(0,v.jsx)(be,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,v.jsxs)(`span`,{children:[(0,v.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,v.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedOutcome})]})]},e.id))}):null]}):null,(0,v.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,v.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(T.sessionKey),children:t.doSomethingElse}),(0,v.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>{j(!0),S(`recognition`)},children:t.correctUnderstanding})]})]}):null,x===`error`&&T?(0,v.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,v.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,v.jsx)(ae,{className:`size-5`})}),(0,v.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:t.errorTitle}),(0,v.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:T.errorMessage}),(0,v.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,v.jsx)(f,{className:`h-11 flex-1 bg-accent text-white hover:bg-accent-hover`,onClick:()=>void se(T.id).then(K),children:t.retry}),(0,v.jsx)(f,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{E(null),w(null),S(`intro`)},children:t.chooseDifferent})]}),(0,v.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Y(T.sessionKey),children:t.openConversation})]}):null]}),q.hasNativePicker?null:(0,v.jsx)(ne,{open:q.modalOpen,onOpenChange:q.setModalOpen,initialAbsolutePath:C?.canonicalRootPath,onConfirm:q.confirmPick,wd:n})]})}export{b as WorkDiscoveryPage};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-CKZuaOeG.js";import{n as ee}from"./locale-store-CzIfXqm8.js";import{$c as l,$s as u,A as te,Cu as d,Ec as ne,Fa as re,Hc as f,Iu as p,Nc as ie,Nl as ae,Ns as m,Tc as oe,To as h,Vl as g,Ys as _,Zl as se,a as ce,cs as v,f as le,gu as ue,l as de,m as fe,o as pe,os as y,p as me,ql as b,s as he,u as x,vt as S}from"./index-vHb2z7VS.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?S(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=``}=i(),t=a(),n=c(ee(e=>e.language)).projectDetailPage.workItems,[r,S]=(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=h(e=>e.setPageHeader),K=h(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([de(e),x(e).catch(()=>({events:[]}))]);S(t.item),L(t.item.nextAction||t.item.title),M(n.events);let[r,i]=await Promise.all([re(t.item.projectId).catch(()=>null),te().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 le(r.id);S(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 ce(r.id);S(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 x(e).catch(()=>({events:[]}))).events)},[]),xe=(0,w.useCallback)(async()=>{if(!(!r||!P)){V(!0),U(null);try{let e=await me(r.id,{definitionId:P,goal:I.trim()||r.nextAction||r.title});S(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 fe(r.id,e);S(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 pe(r.id,e.id);S(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 he(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)(m,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:()=>void J(),children:[(0,T.jsx)(ne,{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)(m,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`hidden md:inline`,children:n.detail.startChat})]}),(0,T.jsxs)(m,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(u,{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)(o,{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)(p,{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)(d,{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)(o,{to:`/projects`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:text-accent-fg`,children:[(0,T.jsx)(p,{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)(d,{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)(m,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:Y,children:[(0,T.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),n.detail.startChat]}),(0,T.jsxs)(m,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:X,children:[(0,T.jsx)(u,{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)(g,{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)(ae,{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)(y,{className:`h-9 rounded-md border border-edge bg-surface-base px-2 text-sm font-normal text-fg outline-none focus:border-accent`,value:P,disabled:B||N.length===0,onChange:e=>F(e.target.value),children:[N.length===0?(0,T.jsx)(v,{value:``,children:n.detail.noWorkflowTemplates}):null,N.map(e=>(0,T.jsx)(v,{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)(m,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3 text-xs`,disabled:B||!P,onClick:xe,children:[(0,T.jsx)(oe,{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)(f,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`truncate`,children:n.attachments.title})]}),(0,T.jsxs)(m,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:B,onClick:()=>W.current?.click(),children:[(0,T.jsx)(ie,{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)(g,{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)(se,{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)(_,{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)(o,{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)(b,{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)(o,{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)(ue,{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-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./circle-alert-BEjgurr2.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-CKZuaOeG.js";import{n as u,o as d,r as f,s as p}from"./locale-store-CzIfXqm8.js";import{n as m}from"./activity-store-BLz30jWq.js";import{Do as h,Fo as g,Fu as _,Go as v,Is as y,Jo as b,Js as x,Kl as S,Ko as C,Na as w,Nc as T,Ns as E,Rl as D,To as O,Uo as k,Va as A,Vu as j,Wo as M,Yo as N,Ys as P,gu as F,il as I,jo as L,lc as ee,ou as te,qo as ne,ro as R,tl as re,tt as ie,vt as z,vu as ae,xl as oe,xu as se,yc as ce}from"./index-vHb2z7VS.js";var B=e(t(),1),V=n();function H(e){try{return decodeURIComponent(e).trim()||null}catch{return null}}function U(e){if(!e)return null;let t=e.split(/[?#]/,1)[0],n=/^\/goals\/([^/]+)\/?$/.exec(t);if(n){let e=H(n[1]);return e?{kind:`goal`,id:e}:null}let r=/^\/chat\/([^/]+)\/?$/.exec(t);if(r){let e=H(r[1]);return!e||e===`new`?null:{kind:`session`,id:e}}return null}async function W(e,t){let n=e.kind===`goal`?`/api/goals/${encodeURIComponent(e.id)}`:`/api/sessions/${encodeURIComponent(e.id)}?limit=1`;try{return(await d(f(n),{signal:t})).status===404?`missing`:`available`}catch(e){if(t?.aborted)throw e;return`available`}}var G=r(),K=3,le={info:{Icon:oe,className:`text-accent-fg bg-accent-soft`},success:{Icon:F,className:`text-success bg-success-soft`},warning:{Icon:x,className:`text-warning bg-warning-soft`},error:{Icon:s,className:`text-danger bg-danger-soft`}};function q(e,t){let n=Math.max(0,Math.round((Date.now()-e)/1e3));if(n<60)return t===`zh`?`刚刚`:`Just now`;let r=Math.round(n/60);if(r<60)return t===`zh`?`${r} 分钟前`:`${r}m ago`;let i=Math.round(r/60);if(i<24)return t===`zh`?`${i} 小时前`:`${i}h ago`;let a=Math.round(i/24);return t===`zh`?`${a} 天前`:`${a}d ago`}function J(e){let t=(0,V.c)(55),{item:n,targetAvailability:r}=e,i=u(X),o;t[0]===i?o=t[1]:(o=l(i),t[0]=i,t[1]=o);let s=o.projectsPage.workHome,d=m(Y),{Icon:f,className:p}=le[n.tone],h;t[2]===p?h=t[3]:(h=c(`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg`,p),t[2]=p,t[3]=h);let g;t[4]!==f||t[5]!==n.status?(g=n.status===`running`?(0,G.jsx)(I,{className:`size-3.5 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,G.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[4]=f,t[5]=n.status,t[6]=g):g=t[6];let _;t[7]!==h||t[8]!==g?(_=(0,G.jsx)(`div`,{className:h,children:g}),t[7]=h,t[8]=g,t[9]=_):_=t[9];let v;t[10]===n.title?v=t[11]:(v=(0,G.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-medium leading-5 text-fg`,children:n.title}),t[10]=n.title,t[11]=v);let b;t[12]!==s.activityUnread||t[13]!==n.read?(b=n.read?null:(0,G.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-accent`,"aria-label":s.activityUnread}),t[12]=s.activityUnread,t[13]=n.read,t[14]=b):b=t[14];let x;t[15]!==v||t[16]!==b?(x=(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[v,b]}),t[15]=v,t[16]=b,t[17]=x):x=t[17];let S;t[18]===n.message?S=t[19]:(S=n.message?(0,G.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.message}):null,t[18]=n.message,t[19]=S);let C;t[20]===n.source?C=t[21]:(C=n.source?(0,G.jsx)(`span`,{className:`max-w-48 truncate`,children:n.source}):null,t[20]=n.source,t[21]=C);let w;t[22]!==n.updatedAt||t[23]!==i?(w=q(n.updatedAt,i),t[22]=n.updatedAt,t[23]=i,t[24]=w):w=t[24];let T;t[25]===w?T=t[26]:(T=(0,G.jsx)(`span`,{children:w}),t[25]=w,t[26]=T);let E;t[27]===n.occurrences?E=t[28]:(E=n.occurrences>1?(0,G.jsxs)(`span`,{children:[`×`,n.occurrences]}):null,t[27]=n.occurrences,t[28]=E);let D;t[29]!==s.activityCheckingRelated||t[30]!==s.activityRelatedMissing||t[31]!==s.activityViewRelated||t[32]!==n.href||t[33]!==r?(D=n.href&&r===`available`?(0,G.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,G.jsx)(ae,{className:`size-3`,"aria-hidden":!0})]}):n.href&&r===`checking`?(0,G.jsx)(R,{className:`h-3 w-20 rounded`,"aria-label":s.activityCheckingRelated}):n.href&&r===`missing`?(0,G.jsx)(`span`,{className:`font-medium text-fg-subtle`,role:`status`,children:s.activityRelatedMissing}):null,t[29]=s.activityCheckingRelated,t[30]=s.activityRelatedMissing,t[31]=s.activityViewRelated,t[32]=n.href,t[33]=r,t[34]=D):D=t[34];let O;t[35]!==T||t[36]!==E||t[37]!==D||t[38]!==C?(O=(0,G.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] text-fg-subtle`,children:[C,T,E,D]}),t[35]=T,t[36]=E,t[37]=D,t[38]=C,t[39]=O):O=t[39];let k;t[40]!==O||t[41]!==x||t[42]!==S?(k=(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,S,O]}),t[40]=O,t[41]=x,t[42]=S,t[43]=k):k=t[43];let A;t[44]!==n.id||t[45]!==d?(A=()=>d(n.id),t[44]=n.id,t[45]=d,t[46]=A):A=t[46];let j;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,G.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),t[47]=j):j=t[47];let M;t[48]!==s.activityRemove||t[49]!==A?(M=(0,G.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-hover hover:text-fg group-hover:opacity-100 focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":s.activityRemove,onClick:A,children:j}),t[48]=s.activityRemove,t[49]=A,t[50]=M):M=t[50];let N;return t[51]!==k||t[52]!==M||t[53]!==_?(N=(0,G.jsxs)(`article`,{className:`group flex items-start gap-3 border-t border-edge-subtle px-1 py-3 first:border-t-0`,children:[_,k,M]}),t[51]=k,t[52]=M,t[53]=_,t[54]=N):N=t[54],N}function Y(e){return e.remove}function X(e){return e.language}function ue(){let e=(0,V.c)(12),t=l(u(ve)).projectsPage.workHome,n=m(_e),r=m(ge),i=m(he),[a,s]=(0,B.useState)(!1),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={},e[0]=c):c=e[0];let[d,f]=(0,B.useState)(c),p;e[1]===n?p=e[2]:(p=n.filter(me),e[1]=n,e[2]=p);let h=p.length,g;e[3]===n?g=e[4]:(g=n.filter(pe),e[3]=n,e[4]=g);let _=g.length,v;e[5]!==a||e[6]!==n?(v=a?n:n.slice(0,K),e[5]=a,e[6]=n,e[7]=v):v=e[7];let y=v,b,x;e[8]===n?(b=e[9],x=e[10]):(b=()=>{let e=new AbortController,t=new Map(n.flatMap(fe));return f(Object.fromEntries([...t.keys()].map(de))),Promise.all([...t].map(async t=>{let[n,r]=t,i=await W(r,e.signal);e.signal.aborted||f(e=>({...e,[n]:i}))})).catch($),()=>e.abort()},x=[n],e[8]=n,e[9]=b,e[10]=x),(0,B.useEffect)(b,x);let S;return e[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,G.jsx)(j,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),e[11]=S):S=e[11],(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,"aria-labelledby":`workbench-activity-title`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsx)(`div`,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,(0,G.jsx)(`h2`,{id:`workbench-activity-title`,className:`text-sm font-semibold text-fg`,children:t.activityTitle}),h>0?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:[(0,G.jsx)(I,{className:`size-3 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),h,` `,t.running]}):_>0?(0,G.jsxs)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[_,` `,t.activityNew]}):null]})}),a&&n.length>0?(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[_>0?(0,G.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:r,children:[(0,G.jsx)(o,{className:`size-3.5`,"aria-hidden":!0}),t.activityMarkRead]}):null,n.some(Q)?(0,G.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-fg-muted`,onClick:i,children:[(0,G.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),t.activityClearFinished]}):null]}):null]}),n.length>0?(0,G.jsxs)(`div`,{className:`mt-3 px-1`,children:[y.map(e=>(0,G.jsx)(J,{item:e,targetAvailability:e.href&&U(e.href)?d[e.href]??`checking`:`available`},e.id)),n.length>K?(0,G.jsx)(`div`,{className:`border-t border-edge-subtle py-2 text-center`,children:(0,G.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>s(Z),children:a?t.activityShowLess:t.activityShowAll.replace(`{{count}}`,String(n.length))})}):null]}):(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(te,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,G.jsx)(`p`,{children:t.activityEmpty})]})]})}function Z(e){return!e}function Q(e){return e.status===`done`}function $(){}function de(e){return[e,`checking`]}function fe(e){let t=U(e.href);return e.href&&t?[[e.href,t]]:[]}function pe(e){return!e.read}function me(e){return e.status===`running`}function he(e){return e.clearFinished}function ge(e){return e.markAllRead}function _e(e){return e.items}function ve(e){return e.language}function ye(e){return p(f(`/api/home${e?`?locale=${encodeURIComponent(e)}`:``}`))}function be(e,t){return p(f(`/api/proactive/insights/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t})})}function xe(e){return p(f(`/api/proactive/insights/${encodeURIComponent(e)}/approve`),{method:`POST`})}function Se(e,t){return p(f(`/api/focuses/${encodeURIComponent(e)}/calendar/${encodeURIComponent(t)}/prepare`),{method:`POST`})}function Ce(e,t){return p(f(`/api/home/decisions/respond`),{method:`POST`,body:JSON.stringify({...e,decision:t})})}function we(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Te(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:z(n)}function Ee(e){let t=(0,V.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,G.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function De(){let e=(0,V.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,G.jsx)(R,{className:`h-20 rounded-2xl`}),(0,G.jsx)(R,{className:`h-72 rounded-2xl`}),(0,G.jsx)(R,{className:`h-44 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Oe(e){let t=(0,V.c)(19),{item:n,statusLabel:r}=e,i=`/work-items/${encodeURIComponent(n.id)}`,o;t[0]===n.title?o=t[1]:(o=(0,G.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=o);let s;t[2]===n.projectName?s=t[3]:(s=(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:n.projectName}),t[2]=n.projectName,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[o,s]}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l;t[7]===r?l=t[8]:(l=(0,G.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:r}),t[7]=r,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==n.blockedReason||t[13]!==n.nextAction?(d=n.blockedReason||n.nextAction?(0,G.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.blockedReason||n.nextAction}):null,t[12]=n.blockedReason,t[13]=n.nextAction,t[14]=d):d=t[14];let f;return t[15]!==i||t[16]!==u||t[17]!==d?(f=(0,G.jsxs)(a,{to:i,className:`group block rounded-lg px-1 py-2.5 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,d]}),t[15]=i,t[16]=u,t[17]=d,t[18]=f):f=t[18],f}function ke(e){let t=(0,V.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,G.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,G.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,G.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,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:i}),t[7]=i,t[8]=m);let h;t[9]!==p||t[10]!==m?(h=(0,G.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,G.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.detail}):null,t[12]=n.detail,t[13]=g);let _;t[14]!==n.href||t[15]!==h||t[16]!==g?(_=(0,G.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,G.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2 border-t border-warning/20 pt-3`,children:[(0,G.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:c,onClick:()=>l(`deny`),children:s}),(0,G.jsx)(E,{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,G.jsxs)(`article`,{className:`rounded-xl border border-warning/35 bg-warning-soft/25 p-3.5 transition-colors hover:bg-warning-soft/40`,children:[_,v]}),t[24]=_,t[25]=v,t[26]=y):y=t[26],y}function Ae(e){let t=(0,V.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,G.jsx)(D,{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,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[s,(0,G.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,G.jsx)(_,{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,G.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,G.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-5 text-fg-muted`,children:d}),t[8]=d,t[9]=f);let p=n.lastActiveAt??n.updatedAt,m;t[10]===p?m=t[11]:(m=Te(p,``),t[10]=p,t[11]=m);let h;t[12]===m?h=t[13]:(h=(0,G.jsx)(`p`,{className:`mt-auto pt-3 text-[11px] text-fg-subtle`,children:m}),t[12]=m,t[13]=h);let g;return t[14]!==o||t[15]!==h||t[16]!==u||t[17]!==f?(g=(0,G.jsxs)(a,{to:o,className:`group flex min-h-32 flex-col rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,f,h]}),t[14]=o,t[15]=h,t[16]=u,t[17]=f,t[18]=g):g=t[18],g}function je(){let e=u(e=>e.language),t=l(e),n=t.projectsPage,r=i(),o=O(e=>e.setPageHeader),c=O(e=>e.clearPageHeader),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)([]),[_,x]=(0,B.useState)([]),[D,j]=(0,B.useState)(!0),[P,F]=(0,B.useState)(null),[I,R]=(0,B.useState)(null),[z,ae]=(0,B.useState)(``),[oe,V]=(0,B.useState)(!1),[H,U]=(0,B.useState)(``),[W,K]=(0,B.useState)(!1),[le,q]=(0,B.useState)(null),[J,Y]=(0,B.useState)(null),[X,Z]=(0,B.useState)(null),Q=(0,B.useCallback)(async()=>{j(!0),F(null);try{let[t,n,r]=await Promise.all([ye(e),A({limit:100,sortBy:`updatedAt`,sortOrder:`desc`}),L()]);f(t),m(n.items),x(r)}catch(e){F(e instanceof Error?e.message:String(e))}finally{j(!1)}},[e]);(0,B.useEffect)(()=>{Q()},[Q]);let $=(0,B.useMemo)(()=>{let e=z.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,6)},[p,z]),de=(0,B.useMemo)(()=>d?.decisions??[],[d]),fe=(0,B.useMemo)(()=>d?.work.current.filter(e=>e.status!==`needs_input`&&e.status!==`in_review`&&e.status!==`blocked`).slice(0,10)??[],[d]),pe=(0,B.useCallback)(async t=>{t.preventDefault();let n=H.trim();if(!(!n||W)){K(!0),R(null);try{let t=await w({outcome:n,uiLocale:e});U(``),V(!1),r(`/projects/${encodeURIComponent(t.project.id)}`)}catch(e){R(e instanceof Error?e.message:String(e))}finally{K(!1)}}},[W,e,r,H]),me=(0,B.useMemo)(()=>(0,G.jsxs)(E,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>V(!0),children:[(0,G.jsx)(T,{className:`size-4`,"aria-hidden":!0}),n.workHome.newWork]}),[n.workHome.newWork]),he=(0,B.useCallback)(async(e,t)=>{if(e.response){q(e.id),F(null);try{await Ce(e.response,t),await Q()}catch(e){F(e instanceof Error?e.message:String(e))}finally{q(null)}}},[Q]),ge=(0,B.useCallback)(async(e,t)=>{Y(e.id),F(null);try{let n=e.watches.find(e=>e.kind===t&&e.status===`active`);n?await g(e.id,n.id):await h(e.id,t),x(await L())}catch(e){F(e instanceof Error?e.message:String(e))}finally{Y(null)}},[]),_e=(0,B.useCallback)(async(e,t)=>{Z(e),F(null);try{t===`approved`?await xe(e):await be(e,`dismissed`),f(t=>t&&{...t,proactiveInsights:t.proactiveInsights.filter(t=>t.id!==e)})}catch(e){F(e instanceof Error?e.message:String(e))}finally{Z(null)}},[]),ve=(0,B.useCallback)(async(e,t)=>{Y(e),F(null);try{await Se(e,t),x(await L())}catch(e){F(e instanceof Error?e.message:String(e))}finally{Y(null)}},[]);return(0,B.useLayoutEffect)(()=>(o({startExtra:null,main:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,G.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.workHome.subtitle})]}),end:me}),()=>c()),[c,me,o,n.title,n.workHome.subtitle]),(0,G.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1200px] flex-1 flex-col gap-7 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,G.jsx)(k,{open:oe,onOpenChange:e=>{!e&&W||(V(e),e||R(null))},children:(0,G.jsxs)(b,{children:[(0,G.jsx)(ne,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,G.jsxs)(v,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(N,{className:`text-base font-semibold text-fg`,children:n.workHome.delegateTitle}),(0,G.jsx)(C,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:n.workHome.delegateDescription})]}),(0,G.jsx)(M,{asChild:!0,children:(0,G.jsx)(E,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:n.cancel,"aria-label":n.cancel,disabled:W,children:(0,G.jsx)(y,{className:`size-4`,"aria-hidden":!0})})})]}),(0,G.jsxs)(`form`,{onSubmit:pe,className:`flex min-h-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,children:[(0,G.jsx)(`label`,{htmlFor:`new-work-outcome`,className:`mb-2 shrink-0 text-sm font-medium text-fg`,children:n.workHome.outcomeLabel}),(0,G.jsx)(`textarea`,{id:`new-work-outcome`,className:`min-h-32 w-full flex-1 resize-none rounded-xl border border-edge bg-surface-base p-3 text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,value:H,onChange:e=>U(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:n.workHome.outcomePlaceholder,maxLength:12e3,disabled:W,autoFocus:!0}),(0,G.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,G.jsx)(`span`,{children:n.workHome.submitShortcut}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[H.length.toLocaleString(),` / `,12e3.toLocaleString()]})]}),I?(0,G.jsx)(`p`,{className:`mt-3 rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:I}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,G.jsx)(M,{asChild:!0,children:(0,G.jsx)(E,{type:`button`,variant:`ghost`,disabled:W,children:n.cancel})}),(0,G.jsxs)(E,{type:`submit`,variant:`primary`,className:`min-w-32`,disabled:W||!H.trim(),children:[(0,G.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),W?n.workHome.delegating:n.workHome.delegate]})]})]})]})]})}),P?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,G.jsx)(`span`,{children:P}),(0,G.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void Q(),children:n.workHome.retry})]}):null,D?(0,G.jsx)(De,{}):d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`section`,{className:`border-b border-edge-subtle pb-5`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:n.workHome.briefingTitle}),(0,G.jsx)(`h2`,{className:`mt-1 text-xl font-semibold tracking-tight text-fg`,children:d.decisions.length>0?we(n.workHome.todaySummary,{attention:d.decisions.length,moving:d.briefing.progress.movingCount}):we(n.workHome.todaySummaryClear,{moving:d.briefing.progress.movingCount})}),d.briefing.summary?(0,G.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-fg-muted`,children:d.briefing.summary}):null]}),d.proactiveInsights.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl border border-accent/20 bg-accent-soft/20 p-5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(ee,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.workHome.insightsTitle}),(0,G.jsx)(Ee,{children:n.workHome.insightsBadge})]}),(0,G.jsx)(`div`,{className:`mt-4 space-y-3`,children:d.proactiveInsights.map(e=>(0,G.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.title}),(0,G.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:e.summary}),(0,G.jsxs)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:[(0,G.jsxs)(`span`,{className:`font-medium text-fg`,children:[n.workHome.whyItMatters,`: `]}),e.whyItMatters]}),(0,G.jsxs)(`p`,{className:`mt-2 rounded-lg bg-surface-base px-3 py-2 text-xs leading-5 text-fg-muted`,children:[(0,G.jsxs)(`span`,{className:`font-medium text-fg`,children:[n.workHome.suggestedNext,`: `]}),e.nextAction]}),(0,G.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:e.evidence.map((e,t)=>(0,G.jsxs)(`span`,{className:`rounded-full border border-edge-subtle px-2 py-1 text-[11px] text-fg-subtle`,children:[e.label,e.source?` · ${e.source}`:``]},`${e.label}-${t}`))}),(0,G.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2 border-t border-edge-subtle pt-3`,children:[(0,G.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:X===e.id,onClick:()=>void _e(e.id,`dismissed`),children:n.workHome.dismissInsight}),(0,G.jsx)(E,{type:`button`,variant:`primary`,className:`h-8 px-2 text-xs`,disabled:X===e.id,onClick:()=>void _e(e.id,`approved`),children:n.workHome.investigateInsight})]})]},e.id))})]}):null,d.calendarSignals.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(se,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.workHome.relatedCalendarTitle}),(0,G.jsx)(Ee,{children:n.workHome.relatedCalendarBadge})]}),(0,G.jsx)(`div`,{className:`mt-4 divide-y divide-edge-subtle`,children:d.calendarSignals.map(e=>(0,G.jsxs)(`article`,{className:`flex flex-col gap-3 py-3 first:pt-0 last:pb-0 sm:flex-row sm:items-center sm:justify-between`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.title}),(0,G.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[e.focusTitle,` · `,Te(e.startsAt,``)]})]}),(0,G.jsx)(E,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-2 text-xs`,disabled:J===e.focusId,onClick:()=>void ve(e.focusId,e.id),children:J===e.focusId?n.workHome.focusWatchUpdating:n.workHome.prepareForEvent})]},e.id))})]}):null,_.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(S,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.workHome.focusesTitle}),(0,G.jsx)(Ee,{children:n.workHome.focusesBadge})]}),(0,G.jsx)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2`,children:_.slice(0,6).map(e=>{let t=e.watches.some(e=>e.kind===`progress`&&e.status===`active`),r=e.watches.some(e=>e.kind===`intelligence`&&e.status===`active`),i=t||r;return(0,G.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-panel p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.title}),(0,G.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.summary})]}),(0,G.jsx)(`span`,{className:`mt-0.5 size-2 shrink-0 rounded-full ${i?`bg-success`:`bg-fg-subtle/40`}`,"aria-hidden":!0})]}),e.blockedReason||e.nextAction?(0,G.jsx)(`p`,{className:`mt-3 line-clamp-2 border-t border-edge-subtle pt-3 text-xs leading-5 text-fg-muted`,children:e.blockedReason||e.nextAction}):null,(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-fg-subtle`,children:i?n.workHome.focusWatchActive:n.workHome.focusWatchInactive}),(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[(0,G.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:J===e.id,onClick:()=>void ge(e,`progress`),children:J===e.id?n.workHome.focusWatchUpdating:t?n.workHome.pauseProgressWatch:n.workHome.startFocusWatch}),(0,G.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:J===e.id,onClick:()=>void ge(e,`intelligence`),children:J===e.id?n.workHome.focusWatchUpdating:r?n.workHome.pauseNewsWatch:n.workHome.startNewsWatch})]})]})]},e.id)})})]}):null,d.work.current.length===0&&d.workflowRuns.active.length===0&&d.decisions.length===0&&d.upcomingAutomations.length===0&&_.length===0?(0,G.jsxs)(`section`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,G.jsx)(re,{className:`mx-auto size-6 text-accent`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:n.workHome.emptyTitle}),(0,G.jsx)(`p`,{className:`mx-auto mt-1 max-w-lg text-sm leading-6 text-fg-muted`,children:n.workHome.emptyBody}),(0,G.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,G.jsx)(E,{type:`button`,variant:`primary`,onClick:()=>r(`/chat/new`),children:n.workHome.startChat}),(0,G.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>V(!0),children:n.workHome.startLongWork})]})]}):null,(0,G.jsxs)(`div`,{className:`grid items-start gap-6 xl:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[de.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(s,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.workHome.needsYou})]}),(0,G.jsx)(`div`,{className:`mt-4 space-y-2`,children:de.map(e=>(0,G.jsx)(ke,{item:e,kindLabel:n.workHome.decisionKinds[e.kind],reasonLabel:n.workHome.decisionReasons[e.reason],approveLabel:n.workHome.approve,denyLabel:n.workHome.deny,busy:le===e.id,onRespond:t=>void he(e,t)},e.id))})]}):(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-success-soft text-xs text-success`,"aria-hidden":!0,children:`✓`}),n.workHome.nothingNeedsYou]}),(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(te,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.workHome.continueTitle})]}),(0,G.jsxs)(`div`,{className:`mt-4 divide-y divide-edge-subtle px-1`,children:[d.workflowRuns.active.map(e=>(0,G.jsxs)(a,{to:ie(e.id),className:`flex items-center justify-between gap-3 rounded-lg px-2 py-3 text-sm hover:bg-surface-hover/55`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-accent`,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.title})]}),(0,G.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.workHome.running})]},e.id)),fe.map(e=>(0,G.jsx)(`div`,{className:`py-1`,children:(0,G.jsx)(Oe,{item:e,statusLabel:t.projectDetailPage.workItems.statuses[e.status]})},e.id)),d.workflowRuns.active.length===0&&fe.length===0?(0,G.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:n.workHome.noCurrentWork}):null]})]})]}),(0,G.jsxs)(`aside`,{className:`min-w-0 space-y-4`,"aria-label":n.workHome.nowTitle,children:[(0,G.jsx)(`div`,{className:`px-1`,children:(0,G.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.workHome.nowTitle})}),d.upcomingAutomations.length>0?(0,G.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(se,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.workHome.scheduled})]}),(0,G.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle`,children:d.upcomingAutomations.slice(0,3).map(e=>(0,G.jsxs)(a,{to:`/automations`,className:`flex items-center justify-between gap-3 rounded-lg px-1 py-3 text-sm hover:bg-surface-hover/55`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.name||e.action}),(0,G.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:Te(e.nextRunAt,n.never)})]},e.id))})]}):null,(0,G.jsx)(ue,{}),d.briefing.wins.length>0?(0,G.jsxs)(a,{to:d.briefing.wins[0].href,className:`flex items-center justify-between gap-3 rounded-xl px-2 py-2 text-sm text-fg-muted hover:bg-surface-hover/55 hover:text-fg`,children:[(0,G.jsx)(`span`,{children:we(n.workHome.completedSummary,{count:d.briefing.wins.length})}),(0,G.jsxs)(`span`,{className:`shrink-0 text-xs font-medium text-accent`,children:[n.workHome.viewLatestResult,` →`]})]}):null]})]})]}):null,(0,G.jsxs)(`section`,{className:`border-t border-edge-subtle pt-7`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.workHome.spacesTitle}),(0,G.jsx)(a,{to:`/projects`,className:`text-xs font-medium text-accent hover:underline`,children:n.management.viewAll})]}),p.filter(e=>e.status!==`archived`).length>6?(0,G.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,G.jsxs)(`label`,{className:`relative block min-w-0`,children:[(0,G.jsx)(ce,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,G.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:z,onChange:e=>ae(e.target.value),placeholder:n.searchPlaceholder,"aria-label":n.searchPlaceholder})]})}):null,(0,G.jsx)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:$.map(e=>(0,G.jsx)(Ae,{project:e,openLabel:n.workHome.openSpace,noDescription:n.noDescription},e.id))}),!D&&$.length===0?(0,G.jsx)(`p`,{className:`py-8 text-center text-sm text-fg-muted`,children:n.workHome.noSpaces}):null]})]})}export{je as WorkPage};
@@ -1,3 +1,3 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-KEk-hTFt.js";import{o,r as s}from"./locale-store-Dqp9H2Uf.js";import{$s as c,Ec as l,G as u,Gl as d,Go as f,Is as p,Jo as m,Ns as h,Uo as g,Us as _,Wo as v,X as y,Yo as b,_l as x,cs as S,dc as C,gt as w,ht as T,lc as E,os as D,ot as O,qi as k,qo as A,sc as j,yu as M}from"./index-Dfq2laZe.js";var N=e(t(),1),P=n();function F(e){if(!e.trim())return null;try{return JSON.parse(e)}catch{return null}}function I(e){return typeof e.message==`string`&&e.message.trim()?e.message:typeof e.error==`string`&&e.error.trim()?e.error:e.error&&typeof e.error==`object`&&typeof e.error.message==`string`?e.error.message:`AI suggestion failed`}function L(e,t={}){let n=F(e.split(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-CKZuaOeG.js";import{o,r as s}from"./locale-store-CzIfXqm8.js";import{$s as c,Ec as l,G as u,Go as d,Is as f,Jo as p,Kl as m,Ns as h,Uo as g,Us as _,Wo as v,X as y,Yo as b,bu as x,cs as S,dc as C,gt as w,ht as T,lc as E,os as D,ot as O,qi as k,qo as A,sc as j,vl as M}from"./index-vHb2z7VS.js";var N=e(t(),1),P=n();function F(e){if(!e.trim())return null;try{return JSON.parse(e)}catch{return null}}function I(e){return typeof e.message==`string`&&e.message.trim()?e.message:typeof e.error==`string`&&e.error.trim()?e.error:e.error&&typeof e.error==`object`&&typeof e.error.message==`string`?e.error.message:`AI suggestion failed`}function L(e,t={}){let n=F(e.split(`
2
2
  `).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
3
- `));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:c,intent:u,locale:_,context:y,disabled:x,className:S,showLabel:C}=e,w=s===void 0?`generic.text`:s,T=c===void 0?`plain`:c,D=u===void 0?`improve`:u,O=C===void 0?!0:C,[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]===_?ue=t[1]:(ue=ne(_),t[0]=_,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]!==y||t[24]!==a||t[25]!==o||t[26]!==T||t[27]!==ce||t[28]!==D||t[29]!==_||t[30]!==w?(Se=async e=>{ae(`edit`),K(!0),se.current=!0,await ce({intent:D,scenario:w,input:e,locale:_,field:{id:a,label:o,format:T},context:y})},t[23]=y,t[24]=a,t[25]=o,t[26]=T,t[27]=ce,t[28]=D,t[29]=_,t[30]=w,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=!O&&`size-7 p-0`,Ve;t[62]!==S||t[63]!==Be?(Ve=i(`h-7 gap-1 px-2 text-xs`,Be,S),t[62]=S,t[63]=Be,t[64]=Ve):Ve=t[64];let He=x||Y,Ue;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,z.jsx)(E,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[65]=Ue):Ue=t[65];let We=O?Z.buttonTitle:null,Ge;t[66]!==Z.buttonTitle||t[67]!==Te||t[68]!==Ve||t[69]!==He||t[70]!==We?(Ge=(0,z.jsxs)(h,{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)(A,{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)(b,{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)(p,{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)(v,{asChild:!0,children:(0,z.jsx)(h,{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)(j,{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)(d,{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]!==T||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:T===`markdown`?(0,z.jsx)(k,{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]=T,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)(j,{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)(d,{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)(M,{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]!==T||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}):T===`markdown`?(0,z.jsx)(k,{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]=T,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)(h,{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)(h,{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)(l,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,z.jsx)(E,{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)(h,{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)(h,{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)(h,{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)(m,{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)(f,{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)(g,{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=w(e,t);if(V(e.inputSchema)&&Object.keys(n.schemaInput).length>0)return Object.entries(n.schemaInput).map(([e,t])=>`${e}: ${String(t)}`).join(` · `);let o=Object.values(n.argValues).map(e=>e.trim()).filter(Boolean),s=n.goal.trim()||i.description;return s&&o.unshift(s),o.length>0?o.join(` · `):r.noInputSummary}function G(e,t,n=!0){return e?n?V(e.inputSchema)?U(e.inputSchema,t.schemaInput)?{valid:!0}:{valid:!1,reason:`schema-required`}:{valid:(O[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=O[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:f,aiAssist:p}=e,m;t[0]===u?m=t[1]:(m=u===void 0?[]:u,t[0]=u,t[1]=m);let h=m,g=d===void 0?!0:d,_,v,y,b,x,S,C;if(t[2]!==p||t[3]!==o||t[4]!==h||t[5]!==c||t[6]!==f||t[7]!==r||t[8]!==s||t[9]!==l||t[10]!==g||t[11]!==n){y=a(r).workflows;let e=O[n]??[];v=e.length>0;let u=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,f),d;t[19]!==o||t[20]!==s||t[21]!==l?(d=e=>{T(e,l,e=>{s(e(o))})},t[19]=o,t[20]=s,t[21]=l,t[22]=d):d=t[22],_=d,b=`flex flex-col gap-3`,x=e.map(e=>{let t=K(y.args,e.labelKey),a=K(y.args,e.placeholderKey),c=o[e.key]??``;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[t,e.required?` *`:``]}),e.multiline&&p?(0,z.jsx)(B,{value:c,onApply:t=>s({...o,[e.key]:t}),fieldId:`workflow.arg.${e.key}`,fieldLabel:t,scenario:p.argScenario??`workflow.arg`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o,fieldKey:e.key},disabled:p.disabled,showLabel:!1}):null]}),e.multiline?(0,z.jsx)(`textarea`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:i(u,`min-h-20 resize-y`)}):(0,z.jsx)(`input`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:u})]},e.key)}),S=v&&h.length>0?(0,z.jsx)(se,{examples:h,labels:y,onSelect:_}):null,C=g?(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:y.goalLabel}),p?(0,z.jsx)(B,{value:c,onApply:l,fieldId:`workflow.goal`,fieldLabel:y.goalLabel,scenario:p.goalScenario??`cron.workflowGoal`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o},disabled:p.disabled,showLabel:!1}):null]}),(0,z.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:y.goalPlaceholder,className:i(u,`min-h-20 resize-y`)})]}):null,t[2]=p,t[3]=o,t[4]=h,t[5]=c,t[6]=f,t[7]=r,t[8]=s,t[9]=l,t[10]=g,t[11]=n,t[12]=_,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S,t[18]=C}else _=t[12],v=t[13],y=t[14],b=t[15],x=t[16],S=t[17],C=t[18];let w;t[23]!==_||t[24]!==h||t[25]!==v||t[26]!==y?(w=!v&&h.length>0?(0,z.jsx)(se,{examples:h,labels:y,onSelect:_}):null,t[23]=_,t[24]=h,t[25]=v,t[26]=y,t[27]=w):w=t[27];let E;return t[28]!==b||t[29]!==x||t[30]!==S||t[31]!==C||t[32]!==w?(E=(0,z.jsxs)(`div`,{className:b,children:[x,S,C,w]}),t[28]=b,t[29]=x,t[30]=S,t[31]=C,t[32]=w,t[33]=E):E=t[33],E}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 y;t[14]!==_||t[15]!==v?(y=(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===u?b=t[18]:(b=u?(0,z.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-subtle`,children:u}):null,t[17]=u,t[18]=b);let x;t[19]!==u||t[20]!==p||t[21]!==a||t[22]!==c||t[23]!==d||t[24]!==r?(x=p.length>0?(0,z.jsxs)(D,{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)(D,{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]=x):x=t[25];let C;return t[26]!==y||t[27]!==b||t[28]!==x?(C=(0,z.jsxs)(`div`,{className:`block`,children:[y,b,x]}),t[26]=y,t[27]=b,t[28]=x,t[29]=C):C=t[29],C}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=w(n,r),t[2]=n,t[3]=r,t[4]=p):p=t[4];let m=p,[h,g]=(0,N.useState)(!0),_;t[5]===m.examplePrompts?_=t[6]:(_=m.examplePrompts??[],t[5]=m.examplePrompts,t[6]=_);let v=_,y;t[7]===n.inputSchema?y=t[8]:(y=V(n.inputSchema),t[7]=n.inputSchema,t[8]=y);let b=y,x,S,C,T,E,D,O,k,A,j;if(t[9]!==c||t[10]!==n||t[11]!==v||t[12]!==b||t[13]!==l||t[14]!==f||t[15]!==r||t[16]!==m.description||t[17]!==s||t[18]!==u||t[19]!==h||t[20]!==o){E=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,l),a;t[31]!==n||t[32]!==s||t[33]!==u||t[34]!==h?(a=(e,t)=>{let r=t===void 0?h:t;s(e),u?.(G(n,e,r))},t[31]=n,t[32]=s,t[33]=u,t[34]=h,t[35]=a):a=t[35];let d=a,p;t[36]!==d||t[37]!==o?(p=e=>d({...o,goal:e}),t[36]=d,t[37]=o,t[38]=p):p=t[38];let _=p,y;t[39]!==d||t[40]!==o?(y=e=>d({...o,schemaInput:e}),t[39]=d,t[40]=o,t[41]=y):y=t[41];let w=y,M;t[42]!==d||t[43]!==o?(M=e=>d({...o,argValues:e}),t[42]=d,t[43]=o,t[44]=M):M=t[44];let N=M,P;if(t[45]!==_||t[46]!==w||t[47]!==o.schemaInput?(P=e=>{if(e.field===`goal`){_(e.text);return}w({...o.schemaInput,[e.field]:e.text})},t[45]=_,t[46]=w,t[47]=o.schemaInput,t[48]=P):P=t[48],x=P,!b){let e;t[49]!==c||t[50]!==n.id||t[51]!==n.name||t[52]!==n.title||t[53]!==m.description?(e=c?{disabled:c.disabled,argScenario:c.inputScenario??`workflow.arg`,goalScenario:c.goalScenario??`workflow.goal`,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description}}:void 0,t[49]=c,t[50]=n.id,t[51]=n.name,t[52]=n.title,t[53]=m.description,t[54]=e):e=t[54];let i;t[55]!==n.name||t[56]!==v||t[57]!==l||t[58]!==r||t[59]!==N||t[60]!==_||t[61]!==e||t[62]!==o.argValues||t[63]!==o.goal?(i=(0,z.jsx)(q,{workflowName:n.name,language:r,argValues:o.argValues,onArgValuesChange:N,goal:o.goal,onGoalChange:_,examplePrompts:v,inputClassName:l,aiAssist:e}),t[55]=n.name,t[56]=v,t[57]=l,t[58]=r,t[59]=N,t[60]=_,t[61]=e,t[62]=o.argValues,t[63]=o.goal,t[64]=i):i=t[64],E=i;break bb0}C=`flex flex-col gap-3`,t[65]!==c||t[66]!==n||t[67]!==f.booleanFalse||t[68]!==f.booleanTrue||t[69]!==f.inputSchemaHeading||t[70]!==f.rawJson||t[71]!==f.rawJsonInvalid||t[72]!==r||t[73]!==m.description||t[74]!==u||t[75]!==w||t[76]!==o?(T=n.inputSchema?(0,z.jsx)(Y,{schema:n.inputSchema,value:o.schemaInput,onChange:w,onValidChange:(e,t)=>{g(e),u?.(G(n,t?{...o,schemaInput:t}:o,e))},aiAssist:c?{locale:r,disabled:c.disabled,scenario:c.inputScenario??`workflow.arg`,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description}}:void 0,labels:{inputSchemaHeading:f.inputSchemaHeading,rawJson:f.rawJson,rawJsonInvalid:f.rawJsonInvalid,booleanTrue:f.booleanTrue,booleanFalse:f.booleanFalse}}):null,t[65]=c,t[66]=n,t[67]=f.booleanFalse,t[68]=f.booleanTrue,t[69]=f.inputSchemaHeading,t[70]=f.rawJson,t[71]=f.rawJsonInvalid,t[72]=r,t[73]=m.description,t[74]=u,t[75]=w,t[76]=o,t[77]=T):T=t[77],j=`flex flex-col gap-1`;let F;t[78]===f.goalLabel?F=t[79]:(F=(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:f.goalLabel}),t[78]=f.goalLabel,t[79]=F);let I;t[80]!==c||t[81]!==n.id||t[82]!==n.name||t[83]!==n.title||t[84]!==f.goalLabel||t[85]!==r||t[86]!==m.description||t[87]!==_||t[88]!==o.goal||t[89]!==o.schemaInput?(I=c?(0,z.jsx)(B,{value:o.goal,onApply:_,fieldId:`workflow.goal`,fieldLabel:f.goalLabel,scenario:c.goalScenario??`workflow.goal`,locale:r,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description,workflowInput:o.schemaInput},disabled:c.disabled,showLabel:!1}):null,t[80]=c,t[81]=n.id,t[82]=n.name,t[83]=n.title,t[84]=f.goalLabel,t[85]=r,t[86]=m.description,t[87]=_,t[88]=o.goal,t[89]=o.schemaInput,t[90]=I):I=t[90],t[91]!==F||t[92]!==I?(S=(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[F,I]}),t[91]=F,t[92]=I,t[93]=S):S=t[93],D=o.goal,t[94]===_?O=t[95]:(O=e=>_(e.target.value),t[94]=_,t[95]=O),k=f.goalPlaceholder,A=i(e,`min-h-20 resize-y`)}t[9]=c,t[10]=n,t[11]=v,t[12]=b,t[13]=l,t[14]=f,t[15]=r,t[16]=m.description,t[17]=s,t[18]=u,t[19]=h,t[20]=o,t[21]=x,t[22]=S,t[23]=C,t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A,t[30]=j}else x=t[21],S=t[22],C=t[23],T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29],j=t[30];if(E!==Symbol.for(`react.early_return_sentinel`))return E;let M;t[96]!==D||t[97]!==O||t[98]!==k||t[99]!==A?(M=(0,z.jsx)(`textarea`,{value:D,onChange:O,placeholder:k,className:A}),t[96]=D,t[97]=O,t[98]=k,t[99]=A,t[100]=M):M=t[100];let F;t[101]!==S||t[102]!==M||t[103]!==j?(F=(0,z.jsxs)(`div`,{className:j,children:[S,M]}),t[101]=S,t[102]=M,t[103]=j,t[104]=F):F=t[104];let I;t[105]!==x||t[106]!==v||t[107]!==f?(I=(0,z.jsx)(le,{examples:v,labels:f,onSelect:x}),t[105]=x,t[106]=v,t[107]=f,t[108]=I):I=t[108];let L;return t[109]!==C||t[110]!==T||t[111]!==F||t[112]!==I?(L=(0,z.jsxs)(`div`,{className:C,children:[T,F,I]}),t[109]=C,t[110]=T,t[111]=F,t[112]=I,t[113]=L):L=t[113],L}function Z(e,t){let n=e.metadata.estimatedAgents;return n?n.min===n.max?y(t.agentScaleExact,{count:n.min}):y(t.agentScaleRange,{min:n.min,max:n.max}):y(t.agentScaleExact,{count:e.defaults.maxSubagents})}function de(e){let t=(0,P.c)(41),{definition:n,language:r,value:o,onChange:s,mode:l,badgeLabel:u,aiAssist:d,inputClassName:f,showTimeout:p,defaultAdvancedOpen:m,onValidityChange:h}=e,g=p===void 0?!1:p,v=m===void 0?!1:m,b=a(r).workflows,[S,T]=(0,N.useState)(v),E;t[0]!==n||t[1]!==r?(E=w(n,r),t[0]=n,t[1]=r,t[2]=E):E=t[2];let D=E,O;t[3]!==n.defaults||t[4]!==o.concurrency?(O=o.concurrency.trim()?Number(o.concurrency):n.defaults.concurrency,t[3]=n.defaults,t[4]=o.concurrency,t[5]=O):O=t[5];let k=O,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=u??b.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=l===`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||D.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)(x,{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)(_,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[21]=V):V=t[21];let H;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,z.jsx)(C,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[22]=H):H=t[22];let U;t[23]!==s||t[24]!==o?(U=e=>s({...o,...e}),t[23]=s,t[24]=o,t[25]=U):U=t[25];let W;t[26]===h?W=t[27]:(W=e=>{h?.(e)},t[26]=h,t[27]=W);let G;t[28]!==d||t[29]!==n||t[30]!==f||t[31]!==r||t[32]!==U||t[33]!==W||t[34]!==o?(G=(0,z.jsx)(ue,{definition:n,language:r,value:o,onChange:U,onValidityChange:W,aiAssist:d,inputClassName:f}),t[28]=d,t[29]=n,t[30]=f,t[31]=r,t[32]=U,t[33]=W,t[34]=o,t[35]=G):G=t[35];let K;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>T(Q),t[36]=K):K=t[36];let oe=b.advancedSettings,se=S&&`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)(M,{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:b.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:y(b.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,b)})]}),(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:y(b.runLimitsSummary,{concurrency:k,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)(c,{className:`size-3.5`,"aria-hidden":!0}),b.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]}),S?(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:y(b.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:y(b.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:y(b.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};
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:c,intent:u,locale:_,context:y,disabled:S,className:C,showLabel:w}=e,T=s===void 0?`generic.text`:s,D=c===void 0?`plain`:c,O=u===void 0?`improve`:u,M=w===void 0?!0:w,[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]===_?ue=t[1]:(ue=ne(_),t[0]=_,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]!==y||t[24]!==a||t[25]!==o||t[26]!==D||t[27]!==ce||t[28]!==O||t[29]!==_||t[30]!==T?(Se=async e=>{ae(`edit`),K(!0),se.current=!0,await ce({intent:O,scenario:T,input:e,locale:_,field:{id:a,label:o,format:D},context:y})},t[23]=y,t[24]=a,t[25]=o,t[26]=D,t[27]=ce,t[28]=O,t[29]=_,t[30]=T,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]!==C||t[63]!==Be?(Ve=i(`h-7 gap-1 px-2 text-xs`,Be,C),t[62]=C,t[63]=Be,t[64]=Ve):Ve=t[64];let He=S||Y,Ue;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,z.jsx)(E,{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)(h,{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)(A,{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)(b,{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)(f,{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)(v,{asChild:!0,children:(0,z.jsx)(h,{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)(j,{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)(m,{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)(k,{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)(j,{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)(m,{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)(x,{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)(k,{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)(h,{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)(h,{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)(l,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,z.jsx)(E,{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)(h,{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)(h,{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)(h,{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)(p,{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)(g,{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=w(e,t);if(V(e.inputSchema)&&Object.keys(n.schemaInput).length>0)return Object.entries(n.schemaInput).map(([e,t])=>`${e}: ${String(t)}`).join(` · `);let o=Object.values(n.argValues).map(e=>e.trim()).filter(Boolean),s=n.goal.trim()||i.description;return s&&o.unshift(s),o.length>0?o.join(` · `):r.noInputSummary}function G(e,t,n=!0){return e?n?V(e.inputSchema)?U(e.inputSchema,t.schemaInput)?{valid:!0}:{valid:!1,reason:`schema-required`}:{valid:(O[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=O[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:f,aiAssist:p}=e,m;t[0]===u?m=t[1]:(m=u===void 0?[]:u,t[0]=u,t[1]=m);let h=m,g=d===void 0?!0:d,_,v,y,b,x,S,C;if(t[2]!==p||t[3]!==o||t[4]!==h||t[5]!==c||t[6]!==f||t[7]!==r||t[8]!==s||t[9]!==l||t[10]!==g||t[11]!==n){y=a(r).workflows;let e=O[n]??[];v=e.length>0;let u=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,f),d;t[19]!==o||t[20]!==s||t[21]!==l?(d=e=>{T(e,l,e=>{s(e(o))})},t[19]=o,t[20]=s,t[21]=l,t[22]=d):d=t[22],_=d,b=`flex flex-col gap-3`,x=e.map(e=>{let t=K(y.args,e.labelKey),a=K(y.args,e.placeholderKey),c=o[e.key]??``;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[t,e.required?` *`:``]}),e.multiline&&p?(0,z.jsx)(B,{value:c,onApply:t=>s({...o,[e.key]:t}),fieldId:`workflow.arg.${e.key}`,fieldLabel:t,scenario:p.argScenario??`workflow.arg`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o,fieldKey:e.key},disabled:p.disabled,showLabel:!1}):null]}),e.multiline?(0,z.jsx)(`textarea`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:i(u,`min-h-20 resize-y`)}):(0,z.jsx)(`input`,{value:c,onChange:t=>s({...o,[e.key]:t.target.value}),placeholder:a,className:u})]},e.key)}),S=v&&h.length>0?(0,z.jsx)(se,{examples:h,labels:y,onSelect:_}):null,C=g?(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:y.goalLabel}),p?(0,z.jsx)(B,{value:c,onApply:l,fieldId:`workflow.goal`,fieldLabel:y.goalLabel,scenario:p.goalScenario??`cron.workflowGoal`,locale:r,context:{...p.context,workflowName:n,workflowArgs:o},disabled:p.disabled,showLabel:!1}):null]}),(0,z.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),placeholder:y.goalPlaceholder,className:i(u,`min-h-20 resize-y`)})]}):null,t[2]=p,t[3]=o,t[4]=h,t[5]=c,t[6]=f,t[7]=r,t[8]=s,t[9]=l,t[10]=g,t[11]=n,t[12]=_,t[13]=v,t[14]=y,t[15]=b,t[16]=x,t[17]=S,t[18]=C}else _=t[12],v=t[13],y=t[14],b=t[15],x=t[16],S=t[17],C=t[18];let w;t[23]!==_||t[24]!==h||t[25]!==v||t[26]!==y?(w=!v&&h.length>0?(0,z.jsx)(se,{examples:h,labels:y,onSelect:_}):null,t[23]=_,t[24]=h,t[25]=v,t[26]=y,t[27]=w):w=t[27];let E;return t[28]!==b||t[29]!==x||t[30]!==S||t[31]!==C||t[32]!==w?(E=(0,z.jsxs)(`div`,{className:b,children:[x,S,C,w]}),t[28]=b,t[29]=x,t[30]=S,t[31]=C,t[32]=w,t[33]=E):E=t[33],E}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 y;t[14]!==_||t[15]!==v?(y=(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===u?b=t[18]:(b=u?(0,z.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-subtle`,children:u}):null,t[17]=u,t[18]=b);let x;t[19]!==u||t[20]!==p||t[21]!==a||t[22]!==c||t[23]!==d||t[24]!==r?(x=p.length>0?(0,z.jsxs)(D,{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)(D,{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]=x):x=t[25];let C;return t[26]!==y||t[27]!==b||t[28]!==x?(C=(0,z.jsxs)(`div`,{className:`block`,children:[y,b,x]}),t[26]=y,t[27]=b,t[28]=x,t[29]=C):C=t[29],C}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=w(n,r),t[2]=n,t[3]=r,t[4]=p):p=t[4];let m=p,[h,g]=(0,N.useState)(!0),_;t[5]===m.examplePrompts?_=t[6]:(_=m.examplePrompts??[],t[5]=m.examplePrompts,t[6]=_);let v=_,y;t[7]===n.inputSchema?y=t[8]:(y=V(n.inputSchema),t[7]=n.inputSchema,t[8]=y);let b=y,x,S,C,T,E,D,O,k,A,j;if(t[9]!==c||t[10]!==n||t[11]!==v||t[12]!==b||t[13]!==l||t[14]!==f||t[15]!==r||t[16]!==m.description||t[17]!==s||t[18]!==u||t[19]!==h||t[20]!==o){E=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,l),a;t[31]!==n||t[32]!==s||t[33]!==u||t[34]!==h?(a=(e,t)=>{let r=t===void 0?h:t;s(e),u?.(G(n,e,r))},t[31]=n,t[32]=s,t[33]=u,t[34]=h,t[35]=a):a=t[35];let d=a,p;t[36]!==d||t[37]!==o?(p=e=>d({...o,goal:e}),t[36]=d,t[37]=o,t[38]=p):p=t[38];let _=p,y;t[39]!==d||t[40]!==o?(y=e=>d({...o,schemaInput:e}),t[39]=d,t[40]=o,t[41]=y):y=t[41];let w=y,M;t[42]!==d||t[43]!==o?(M=e=>d({...o,argValues:e}),t[42]=d,t[43]=o,t[44]=M):M=t[44];let N=M,P;if(t[45]!==_||t[46]!==w||t[47]!==o.schemaInput?(P=e=>{if(e.field===`goal`){_(e.text);return}w({...o.schemaInput,[e.field]:e.text})},t[45]=_,t[46]=w,t[47]=o.schemaInput,t[48]=P):P=t[48],x=P,!b){let e;t[49]!==c||t[50]!==n.id||t[51]!==n.name||t[52]!==n.title||t[53]!==m.description?(e=c?{disabled:c.disabled,argScenario:c.inputScenario??`workflow.arg`,goalScenario:c.goalScenario??`workflow.goal`,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description}}:void 0,t[49]=c,t[50]=n.id,t[51]=n.name,t[52]=n.title,t[53]=m.description,t[54]=e):e=t[54];let i;t[55]!==n.name||t[56]!==v||t[57]!==l||t[58]!==r||t[59]!==N||t[60]!==_||t[61]!==e||t[62]!==o.argValues||t[63]!==o.goal?(i=(0,z.jsx)(q,{workflowName:n.name,language:r,argValues:o.argValues,onArgValuesChange:N,goal:o.goal,onGoalChange:_,examplePrompts:v,inputClassName:l,aiAssist:e}),t[55]=n.name,t[56]=v,t[57]=l,t[58]=r,t[59]=N,t[60]=_,t[61]=e,t[62]=o.argValues,t[63]=o.goal,t[64]=i):i=t[64],E=i;break bb0}C=`flex flex-col gap-3`,t[65]!==c||t[66]!==n||t[67]!==f.booleanFalse||t[68]!==f.booleanTrue||t[69]!==f.inputSchemaHeading||t[70]!==f.rawJson||t[71]!==f.rawJsonInvalid||t[72]!==r||t[73]!==m.description||t[74]!==u||t[75]!==w||t[76]!==o?(T=n.inputSchema?(0,z.jsx)(Y,{schema:n.inputSchema,value:o.schemaInput,onChange:w,onValidChange:(e,t)=>{g(e),u?.(G(n,t?{...o,schemaInput:t}:o,e))},aiAssist:c?{locale:r,disabled:c.disabled,scenario:c.inputScenario??`workflow.arg`,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description}}:void 0,labels:{inputSchemaHeading:f.inputSchemaHeading,rawJson:f.rawJson,rawJsonInvalid:f.rawJsonInvalid,booleanTrue:f.booleanTrue,booleanFalse:f.booleanFalse}}):null,t[65]=c,t[66]=n,t[67]=f.booleanFalse,t[68]=f.booleanTrue,t[69]=f.inputSchemaHeading,t[70]=f.rawJson,t[71]=f.rawJsonInvalid,t[72]=r,t[73]=m.description,t[74]=u,t[75]=w,t[76]=o,t[77]=T):T=t[77],j=`flex flex-col gap-1`;let F;t[78]===f.goalLabel?F=t[79]:(F=(0,z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:f.goalLabel}),t[78]=f.goalLabel,t[79]=F);let I;t[80]!==c||t[81]!==n.id||t[82]!==n.name||t[83]!==n.title||t[84]!==f.goalLabel||t[85]!==r||t[86]!==m.description||t[87]!==_||t[88]!==o.goal||t[89]!==o.schemaInput?(I=c?(0,z.jsx)(B,{value:o.goal,onApply:_,fieldId:`workflow.goal`,fieldLabel:f.goalLabel,scenario:c.goalScenario??`workflow.goal`,locale:r,context:{...c.context,workflowId:n.id,workflowName:n.name,workflowTitle:n.title,workflowDescription:m.description,workflowInput:o.schemaInput},disabled:c.disabled,showLabel:!1}):null,t[80]=c,t[81]=n.id,t[82]=n.name,t[83]=n.title,t[84]=f.goalLabel,t[85]=r,t[86]=m.description,t[87]=_,t[88]=o.goal,t[89]=o.schemaInput,t[90]=I):I=t[90],t[91]!==F||t[92]!==I?(S=(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[F,I]}),t[91]=F,t[92]=I,t[93]=S):S=t[93],D=o.goal,t[94]===_?O=t[95]:(O=e=>_(e.target.value),t[94]=_,t[95]=O),k=f.goalPlaceholder,A=i(e,`min-h-20 resize-y`)}t[9]=c,t[10]=n,t[11]=v,t[12]=b,t[13]=l,t[14]=f,t[15]=r,t[16]=m.description,t[17]=s,t[18]=u,t[19]=h,t[20]=o,t[21]=x,t[22]=S,t[23]=C,t[24]=T,t[25]=E,t[26]=D,t[27]=O,t[28]=k,t[29]=A,t[30]=j}else x=t[21],S=t[22],C=t[23],T=t[24],E=t[25],D=t[26],O=t[27],k=t[28],A=t[29],j=t[30];if(E!==Symbol.for(`react.early_return_sentinel`))return E;let M;t[96]!==D||t[97]!==O||t[98]!==k||t[99]!==A?(M=(0,z.jsx)(`textarea`,{value:D,onChange:O,placeholder:k,className:A}),t[96]=D,t[97]=O,t[98]=k,t[99]=A,t[100]=M):M=t[100];let F;t[101]!==S||t[102]!==M||t[103]!==j?(F=(0,z.jsxs)(`div`,{className:j,children:[S,M]}),t[101]=S,t[102]=M,t[103]=j,t[104]=F):F=t[104];let I;t[105]!==x||t[106]!==v||t[107]!==f?(I=(0,z.jsx)(le,{examples:v,labels:f,onSelect:x}),t[105]=x,t[106]=v,t[107]=f,t[108]=I):I=t[108];let L;return t[109]!==C||t[110]!==T||t[111]!==F||t[112]!==I?(L=(0,z.jsxs)(`div`,{className:C,children:[T,F,I]}),t[109]=C,t[110]=T,t[111]=F,t[112]=I,t[113]=L):L=t[113],L}function Z(e,t){let n=e.metadata.estimatedAgents;return n?n.min===n.max?y(t.agentScaleExact,{count:n.min}):y(t.agentScaleRange,{min:n.min,max:n.max}):y(t.agentScaleExact,{count:e.defaults.maxSubagents})}function de(e){let t=(0,P.c)(41),{definition:n,language:r,value:o,onChange:s,mode:l,badgeLabel:u,aiAssist:d,inputClassName:f,showTimeout:p,defaultAdvancedOpen:m,onValidityChange:h}=e,g=p===void 0?!1:p,v=m===void 0?!1:m,b=a(r).workflows,[S,T]=(0,N.useState)(v),E;t[0]!==n||t[1]!==r?(E=w(n,r),t[0]=n,t[1]=r,t[2]=E):E=t[2];let D=E,O;t[3]!==n.defaults||t[4]!==o.concurrency?(O=o.concurrency.trim()?Number(o.concurrency):n.defaults.concurrency,t[3]=n.defaults,t[4]=o.concurrency,t[5]=O):O=t[5];let k=O,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=u??b.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=l===`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||D.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)(M,{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)(_,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[21]=V):V=t[21];let H;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,z.jsx)(C,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[22]=H):H=t[22];let U;t[23]!==s||t[24]!==o?(U=e=>s({...o,...e}),t[23]=s,t[24]=o,t[25]=U):U=t[25];let W;t[26]===h?W=t[27]:(W=e=>{h?.(e)},t[26]=h,t[27]=W);let G;t[28]!==d||t[29]!==n||t[30]!==f||t[31]!==r||t[32]!==U||t[33]!==W||t[34]!==o?(G=(0,z.jsx)(ue,{definition:n,language:r,value:o,onChange:U,onValidityChange:W,aiAssist:d,inputClassName:f}),t[28]=d,t[29]=n,t[30]=f,t[31]=r,t[32]=U,t[33]=W,t[34]=o,t[35]=G):G=t[35];let K;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>T(Q),t[36]=K):K=t[36];let oe=b.advancedSettings,se=S&&`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)(x,{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:b.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:y(b.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,b)})]}),(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:y(b.runLimitsSummary,{concurrency:k,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)(c,{className:`size-3.5`,"aria-hidden":!0}),b.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]}),S?(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:y(b.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:y(b.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:y(b.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};