@cats-inc/cats-platform 0.2.8 → 0.3.5

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 (205) hide show
  1. package/README.md +25 -1
  2. package/build/desktop/bootstrapPage.d.ts.map +1 -1
  3. package/build/desktop/bootstrapPage.js +26 -129
  4. package/build/desktop/bootstrapPage.js.map +1 -1
  5. package/build/desktop/cliInventoryProbe.d.ts +6 -0
  6. package/build/desktop/cliInventoryProbe.d.ts.map +1 -1
  7. package/build/desktop/cliInventoryProbe.js +6 -3
  8. package/build/desktop/cliInventoryProbe.js.map +1 -1
  9. package/build/desktop/contracts.d.ts +2 -0
  10. package/build/desktop/contracts.d.ts.map +1 -1
  11. package/build/desktop/contracts.js.map +1 -1
  12. package/build/desktop/main.js +95 -41
  13. package/build/desktop/main.js.map +1 -1
  14. package/build/desktop/preload.cjs +8 -6
  15. package/build/desktop/preload.cjs.map +1 -1
  16. package/build/desktop/providerManager.d.ts +46 -0
  17. package/build/desktop/providerManager.d.ts.map +1 -0
  18. package/build/desktop/providerManager.js +220 -0
  19. package/build/desktop/providerManager.js.map +1 -0
  20. package/build/desktop/providerSelection.d.ts +1 -0
  21. package/build/desktop/providerSelection.d.ts.map +1 -1
  22. package/build/desktop/providerSelection.js +7 -1
  23. package/build/desktop/providerSelection.js.map +1 -1
  24. package/build/desktop/setupAssets.d.ts.map +1 -1
  25. package/build/desktop/setupAssets.js +12 -0
  26. package/build/desktop/setupAssets.js.map +1 -1
  27. package/build/desktop/setupAudit.d.ts +3 -1
  28. package/build/desktop/setupAudit.d.ts.map +1 -1
  29. package/build/desktop/setupAudit.js +12 -8
  30. package/build/desktop/setupAudit.js.map +1 -1
  31. package/build/desktop/setupBridge.js +1 -1
  32. package/build/desktop/setupBridge.js.map +1 -1
  33. package/build/desktop/setupPrerequisites.d.ts +11 -0
  34. package/build/desktop/setupPrerequisites.d.ts.map +1 -0
  35. package/build/desktop/setupPrerequisites.js +47 -0
  36. package/build/desktop/setupPrerequisites.js.map +1 -0
  37. package/build/renderer/assets/ActiveSessionPermissionChip-BugyYoVY.js +1 -0
  38. package/build/renderer/assets/{App-BZA23O2J.js → App-1MFRMMld.js} +1 -1
  39. package/build/renderer/assets/{App-YqprEL2n.js → App-BWgnfutX.js} +1 -1
  40. package/build/renderer/assets/{App-rGw9J8PZ.js → App-Cm_tok6f.js} +1 -1
  41. package/build/renderer/assets/{WorkspaceAppRoutes-BCHCikmJ.js → WorkspaceAppRoutes-B8U5FWao.js} +1 -1
  42. package/build/renderer/assets/app-CqnsY5ed.css +1 -0
  43. package/build/renderer/assets/app-DTDTNtih.js +85 -0
  44. package/build/renderer/assets/{client-BdGHAUoK.js → client-DREGSZqQ.js} +1 -1
  45. package/build/renderer/assets/conversationSidebarRecentEntries-y_bEg3Cp.js +6 -0
  46. package/build/renderer/assets/{screenshotOverlay-DfBcolX-.js → screenshotOverlay-EF07cXvw.js} +1 -1
  47. package/build/renderer/assets/{useDraftSessionChips-D9BX6X92.js → useDraftSessionChips-BD6ZGG_y.js} +1 -1
  48. package/build/renderer/desktop/overlay/index.html +2 -2
  49. package/build/renderer/index.html +3 -3
  50. package/build/server/app/renderer/auth/api.d.ts.map +1 -1
  51. package/build/server/app/renderer/auth/api.js +4 -1
  52. package/build/server/app/renderer/auth/api.js.map +1 -1
  53. package/build/server/app/renderer/providerCatalogClient.d.ts.map +1 -1
  54. package/build/server/app/renderer/providerCatalogClient.js +19 -6
  55. package/build/server/app/renderer/providerCatalogClient.js.map +1 -1
  56. package/build/server/app/renderer/providerClientInvalidation.d.ts +6 -0
  57. package/build/server/app/renderer/providerClientInvalidation.d.ts.map +1 -0
  58. package/build/server/app/renderer/providerClientInvalidation.js +12 -0
  59. package/build/server/app/renderer/providerClientInvalidation.js.map +1 -0
  60. package/build/server/app/renderer/providerReadLoop.d.ts +5 -0
  61. package/build/server/app/renderer/providerReadLoop.d.ts.map +1 -0
  62. package/build/server/app/renderer/providerReadLoop.js +52 -0
  63. package/build/server/app/renderer/providerReadLoop.js.map +1 -0
  64. package/build/server/app/renderer/providerRegistryClient.d.ts +2 -1
  65. package/build/server/app/renderer/providerRegistryClient.d.ts.map +1 -1
  66. package/build/server/app/renderer/providerRegistryClient.js +33 -17
  67. package/build/server/app/renderer/providerRegistryClient.js.map +1 -1
  68. package/build/server/app/server/authGatePolicy.js +7 -0
  69. package/build/server/app/server/authGatePolicy.js.map +1 -1
  70. package/build/server/app/server/shutdown.d.ts.map +1 -1
  71. package/build/server/app/server/shutdown.js +3 -1
  72. package/build/server/app/server/shutdown.js.map +1 -1
  73. package/build/server/app/server/startup.d.ts +4 -3
  74. package/build/server/app/server/startup.d.ts.map +1 -1
  75. package/build/server/app/server/startup.js +8 -0
  76. package/build/server/app/server/startup.js.map +1 -1
  77. package/build/server/app/server/subscribeRoutes.d.ts.map +1 -1
  78. package/build/server/app/server/subscribeRoutes.js +5 -3
  79. package/build/server/app/server/subscribeRoutes.js.map +1 -1
  80. package/build/server/design/components/providerModelFieldsSupport.d.ts +2 -21
  81. package/build/server/design/components/providerModelFieldsSupport.d.ts.map +1 -1
  82. package/build/server/design/components/providerModelFieldsSupport.js +32 -36
  83. package/build/server/design/components/providerModelFieldsSupport.js.map +1 -1
  84. package/build/server/design/components/useProviderCatalogState.d.ts +1 -2
  85. package/build/server/design/components/useProviderCatalogState.d.ts.map +1 -1
  86. package/build/server/design/components/useProviderCatalogState.js +71 -152
  87. package/build/server/design/components/useProviderCatalogState.js.map +1 -1
  88. package/build/server/design/components/useProviderModelFieldActions.js +2 -2
  89. package/build/server/design/components/useProviderModelFieldActions.js.map +1 -1
  90. package/build/server/design/components/useProviderRegistryState.d.ts +1 -7
  91. package/build/server/design/components/useProviderRegistryState.d.ts.map +1 -1
  92. package/build/server/design/components/useProviderRegistryState.js +41 -91
  93. package/build/server/design/components/useProviderRegistryState.js.map +1 -1
  94. package/build/server/design/components/useProviderTargetReconciliation.d.ts +1 -0
  95. package/build/server/design/components/useProviderTargetReconciliation.d.ts.map +1 -1
  96. package/build/server/design/components/useProviderTargetReconciliation.js +1 -1
  97. package/build/server/design/components/useProviderTargetReconciliation.js.map +1 -1
  98. package/build/server/index.js +30 -0
  99. package/build/server/index.js.map +1 -1
  100. package/build/server/platform/orchestration/entitySubscriptions/channel.d.ts +2 -1
  101. package/build/server/platform/orchestration/entitySubscriptions/channel.d.ts.map +1 -1
  102. package/build/server/platform/orchestration/entitySubscriptions/channel.js +3 -18
  103. package/build/server/platform/orchestration/entitySubscriptions/channel.js.map +1 -1
  104. package/build/server/platform/orchestration/entitySubscriptions/index.d.ts +1 -0
  105. package/build/server/platform/orchestration/entitySubscriptions/index.d.ts.map +1 -1
  106. package/build/server/platform/orchestration/entitySubscriptions/index.js.map +1 -1
  107. package/build/server/products/chat/api/routeSupport.d.ts +9 -1
  108. package/build/server/products/chat/api/routeSupport.d.ts.map +1 -1
  109. package/build/server/products/chat/api/routeSupport.js +22 -0
  110. package/build/server/products/chat/api/routeSupport.js.map +1 -1
  111. package/build/server/products/chat/state/model/readModels.d.ts +1 -0
  112. package/build/server/products/chat/state/model/readModels.d.ts.map +1 -1
  113. package/build/server/products/chat/state/model/readModels.js +2 -1
  114. package/build/server/products/chat/state/model/readModels.js.map +1 -1
  115. package/build/server/products/shared/renderer/api/appShell.d.ts +1 -0
  116. package/build/server/products/shared/renderer/api/appShell.d.ts.map +1 -1
  117. package/build/server/products/shared/renderer/api/appShell.js +9 -0
  118. package/build/server/products/shared/renderer/api/appShell.js.map +1 -1
  119. package/build/server/runtime/client.d.ts.map +1 -1
  120. package/build/server/runtime/client.js +5 -1
  121. package/build/server/runtime/client.js.map +1 -1
  122. package/build/server/runtime/setup.d.ts +4 -0
  123. package/build/server/runtime/setup.d.ts.map +1 -1
  124. package/build/server/runtime/setup.js +3 -1
  125. package/build/server/runtime/setup.js.map +1 -1
  126. package/build/server/server/routes/providers.d.ts.map +1 -1
  127. package/build/server/server/routes/providers.js +21 -50
  128. package/build/server/server/routes/providers.js.map +1 -1
  129. package/build/server/shared/cliInteraction.d.ts +17 -0
  130. package/build/server/shared/cliInteraction.d.ts.map +1 -0
  131. package/build/server/shared/cliInteraction.js +102 -0
  132. package/build/server/shared/cliInteraction.js.map +1 -0
  133. package/build/server/shared/desktopRecoveryBridge.d.ts +2 -1
  134. package/build/server/shared/desktopRecoveryBridge.d.ts.map +1 -1
  135. package/build/server/shared/desktopRecoveryBridge.js.map +1 -1
  136. package/build/server/shared/providerCatalogData.d.ts +168 -96
  137. package/build/server/shared/providerCatalogData.d.ts.map +1 -1
  138. package/build/server/shared/providerCatalogData.js +68 -42
  139. package/build/server/shared/providerCatalogData.js.map +1 -1
  140. package/build/server/shared/providerRegistryWarnings.d.ts +4 -0
  141. package/build/server/shared/providerRegistryWarnings.d.ts.map +1 -1
  142. package/build/server/shared/providerRegistryWarnings.js +7 -0
  143. package/build/server/shared/providerRegistryWarnings.js.map +1 -1
  144. package/package.json +13 -6
  145. package/packages/provider-setup/manager.d.ts +79 -0
  146. package/packages/provider-setup/manager.js +441 -0
  147. package/scripts/README.md +23 -0
  148. package/scripts/build-desktop-installer.mjs +124 -16
  149. package/scripts/dev-server.mjs +4 -1
  150. package/scripts/linux/install-github-cli.sh +5 -0
  151. package/scripts/linux/install-node.sh +9 -3
  152. package/scripts/linux/node-cli-common.sh +87 -48
  153. package/scripts/linux/provider-cli-common.sh +80 -105
  154. package/scripts/linux/provider-version-common.sh +247 -0
  155. package/scripts/linux/test-linux-package-smoke.sh +2 -0
  156. package/scripts/linux/verified-npm-update.sh +20 -0
  157. package/scripts/macos/install-github-cli.sh +5 -0
  158. package/scripts/macos/install-node.sh +9 -3
  159. package/scripts/macos/node-cli-common.sh +87 -48
  160. package/scripts/macos/provider-cli-common.sh +80 -105
  161. package/scripts/macos/provider-version-common.sh +247 -0
  162. package/scripts/macos/test-macos-package-smoke.sh +2 -0
  163. package/scripts/macos/verified-npm-update.sh +20 -0
  164. package/scripts/testing/conversation-navigation-smoke-electron.cjs +134 -0
  165. package/scripts/testing/conversation-navigation-smoke-renderer.tsx +102 -0
  166. package/scripts/testing/conversation-navigation-smoke.mjs +67 -0
  167. package/scripts/validate-release-assets.mjs +4 -1
  168. package/scripts/windows/Install-Antigravity.ps1 +26 -3
  169. package/scripts/windows/Install-ClaudeCode.ps1 +25 -7
  170. package/scripts/windows/Install-CursorAgent.ps1 +45 -30
  171. package/scripts/windows/Install-Devin.ps1 +16 -47
  172. package/scripts/windows/Install-GitHubCli.ps1 +4 -0
  173. package/scripts/windows/Install-Goose.ps1 +18 -1
  174. package/scripts/windows/Install-Grok.ps1 +14 -1
  175. package/scripts/windows/Install-Junie.ps1 +32 -11
  176. package/scripts/windows/Install-KiroCli.ps1 +37 -13
  177. package/scripts/windows/Install-MetaCli.ps1 +8 -1
  178. package/scripts/windows/Install-Node.ps1 +6 -1
  179. package/scripts/windows/Setup-NodeGlobalPrefix.ps1 +10 -0
  180. package/scripts/windows/Test-WindowsInstallerSmoke.ps1 +2 -0
  181. package/scripts/windows/_HiddenProcess.ps1 +14 -3
  182. package/scripts/windows/_NativeInstallerSupport.ps1 +308 -0
  183. package/scripts/windows/_NpmCliInstaller.ps1 +35 -14
  184. package/scripts/windows/_PackagedUninstall.ps1 +9 -1
  185. package/scripts/windows/_VerifiedNpmUpdate.ps1 +25 -0
  186. package/build/renderer/assets/ActiveSessionPermissionChip-CAgN-tXv.js +0 -1
  187. package/build/renderer/assets/app-BV3UAQkR.css +0 -1
  188. package/build/renderer/assets/app-CVPqqfZo.js +0 -45
  189. package/build/renderer/assets/conversationSidebarRecentEntries-iqaLqA1n.js +0 -6
  190. package/build/server/app/renderer/settings/runtimeLifecycleHelpers.d.ts +0 -48
  191. package/build/server/app/renderer/settings/runtimeLifecycleHelpers.d.ts.map +0 -1
  192. package/build/server/app/renderer/settings/runtimeLifecycleHelpers.js +0 -535
  193. package/build/server/app/renderer/settings/runtimeLifecycleHelpers.js.map +0 -1
  194. package/build/server/design/components/useProviderRegistryAutoRecheck.d.ts +0 -13
  195. package/build/server/design/components/useProviderRegistryAutoRecheck.d.ts.map +0 -1
  196. package/build/server/design/components/useProviderRegistryAutoRecheck.js +0 -70
  197. package/build/server/design/components/useProviderRegistryAutoRecheck.js.map +0 -1
  198. package/build/server/products/shared/renderer/api/providerCatalogRefreshStore.d.ts +0 -19
  199. package/build/server/products/shared/renderer/api/providerCatalogRefreshStore.d.ts.map +0 -1
  200. package/build/server/products/shared/renderer/api/providerCatalogRefreshStore.js +0 -53
  201. package/build/server/products/shared/renderer/api/providerCatalogRefreshStore.js.map +0 -1
  202. package/build/server/products/shared/renderer/api/providers.d.ts +0 -17
  203. package/build/server/products/shared/renderer/api/providers.d.ts.map +0 -1
  204. package/build/server/products/shared/renderer/api/providers.js +0 -50
  205. package/build/server/products/shared/renderer/api/providers.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{r as m,j as e}from"./client-BdGHAUoK.js";import{r as Ms,N as Os,C as zt,w as Xe,a as Ks,A as Fs,c as $s,d as Us,e as Gs}from"./conversationSidebarRecentEntries-iqaLqA1n.js";import{S as Jt,d as St,e as X,f as We,g as Te,h as Me,j as tt,k as Rt,t as Qs,l as Ce,o as Hs,q as qs,v as It,w as Ke,x as Pt,y as Vs,z as ht,A as U,C as Ys,D as zs,r as Xt,E as Js,F as Xs,u as N,G as Zs,H as ea,m as p,I as K,W as ta,J as Zt,K as mt,L as es,M as sa,O as ts,P as Fe,Q as aa,T as ra,U as na,V as pt,X as z,Y as oa,Z as ia,_ as B,$ as xe,a0 as la,a1 as ca,a2 as da,a3 as oe,a4 as ua,a5 as ha,a6 as kt,a7 as ma,a8 as pa,a9 as Ct,aa as wt,c as H,ab as ka,ac as wa,ad as _a,ae as ja,af as ss,ag as xa,ah as ga,n as ba,ai as ya,aj as Na}from"./app-CVPqqfZo.js";import{A as fa}from"./ActiveSessionPermissionChip-CAgN-tXv.js";import{N as Ta,W as La}from"./WorkspaceAppRoutes-BCHCikmJ.js";var va=class extends Jt{constructor(t,s){super(),this.options=s,this.#s=t,this.#i=null,this.#o=St(),this.bindMethods(),this.setOptions(s)}#s;#e=void 0;#a=void 0;#t=void 0;#r;#n;#o;#i;#k;#h;#m;#c;#d;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Bt(this.#e,this.options)?this.#u():this.updateResult(),this.#x())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return st(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return st(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#g(),this.#b(),this.#e.removeObserver(this)}setOptions(t){const s=this.options,a=this.#e;if(this.options=this.#s.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof X(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#y(),this.#e.setOptions(this.options),s._defaulted&&!We(this.options,s)&&this.#s.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Et(this.#e,a,this.options,s)&&this.#u(),this.updateResult(),r&&(this.#e!==a||X(this.options.enabled,this.#e)!==X(s.enabled,this.#e)||Te(this.options.staleTime,this.#e)!==Te(s.staleTime,this.#e))&&this.#w();const n=this.#_();r&&(this.#e!==a||X(this.options.enabled,this.#e)!==X(s.enabled,this.#e)||n!==this.#l)&&this.#j(n)}getOptimisticResult(t){const s=this.#s.getQueryCache().build(this.#s,t),a=this.createResult(s,t);return Sa(this,a)&&(this.#t=a,this.#n=this.options,this.#r=this.#e.state),a}getCurrentResult(){return this.#t}trackResult(t,s){return new Proxy(t,{get:(a,r)=>(this.trackProp(r),s?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(a,r))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=this.#s.defaultQueryOptions(t),a=this.#s.getQueryCache().build(this.#s,s);return a.fetch().then(()=>this.createResult(a,s))}fetch(t){return this.#u({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#t))}#u(t){this.#y();let s=this.#e.fetch(this.options,t);return t?.throwOnError||(s=s.catch(Me)),s}#w(){this.#g();const t=Te(this.options.staleTime,this.#e);if(tt.isServer()||this.#t.isStale||!Rt(t))return;const a=Qs(this.#t.dataUpdatedAt,t)+1;this.#c=Ce.setTimeout(()=>{this.#t.isStale||this.updateResult()},a)}#_(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#j(t){this.#b(),this.#l=t,!(tt.isServer()||X(this.options.enabled,this.#e)===!1||!Rt(this.#l)||this.#l===0)&&(this.#d=Ce.setInterval(()=>{(this.options.refetchIntervalInBackground||Hs.isFocused())&&this.#u()},this.#l))}#x(){this.#w(),this.#j(this.#_())}#g(){this.#c!==void 0&&(Ce.clearTimeout(this.#c),this.#c=void 0)}#b(){this.#d!==void 0&&(Ce.clearInterval(this.#d),this.#d=void 0)}createResult(t,s){const a=this.#e,r=this.options,n=this.#t,o=this.#r,i=this.#n,c=t!==a?t.state:this.#a,{state:h}=t;let u={...h},d=!1,w;if(s._optimisticResults){const I=this.hasListeners(),b=!I&&Bt(t,s),T=I&&Et(t,a,s,r);(b||T)&&(u={...u,...qs(h.data,t.options)}),s._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:y,errorUpdatedAt:j,status:_}=u;w=u.data;let x=!1;if(s.placeholderData!==void 0&&w===void 0&&_==="pending"){let I;n?.isPlaceholderData&&s.placeholderData===i?.placeholderData?(I=n.data,x=!0):I=typeof s.placeholderData=="function"?s.placeholderData(this.#m?.state.data,this.#m):s.placeholderData,I!==void 0&&(_="success",w=It(n?.data,I,s),d=!0)}if(s.select&&w!==void 0&&!x)if(n&&w===o?.data&&s.select===this.#k)w=this.#h;else try{this.#k=s.select,w=s.select(w),w=It(n?.data,w,s),this.#h=w,this.#i=null}catch(I){this.#i=I}this.#i&&(y=this.#i,w=this.#h,j=Date.now(),_="error");const L=u.fetchStatus==="fetching",g=_==="pending",k=_==="error",R=g&&L,D=w!==void 0,C={status:_,fetchStatus:u.fetchStatus,isPending:g,isSuccess:_==="success",isError:k,isInitialLoading:R,isLoading:R,data:w,dataUpdatedAt:u.dataUpdatedAt,error:y,errorUpdatedAt:j,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:L,isRefetching:L&&!g,isLoadingError:k&&!D,isPaused:u.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:k&&D,isStale:_t(t,s),refetch:this.refetch,promise:this.#o,isEnabled:X(s.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const I=C.data!==void 0,b=C.status==="error"&&!I,T=P=>{b?P.reject(C.error):I&&P.resolve(C.data)},v=()=>{const P=this.#o=C.promise=St();T(P)},O=this.#o;switch(O.status){case"pending":t.queryHash===a.queryHash&&T(O);break;case"fulfilled":(b||C.data!==O.value)&&v();break;case"rejected":(!b||C.error!==O.reason)&&v();break}}return C}updateResult(){const t=this.#t,s=this.createResult(this.#e,this.options);if(this.#r=this.#e.state,this.#n=this.options,this.#r.data!==void 0&&(this.#m=this.#e),We(s,t))return;this.#t=s;const a=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,n=typeof r=="function"?r():r;if(n==="all"||!n&&!this.#p.size)return!0;const o=new Set(n??this.#p);return this.options.throwOnError&&o.add("error"),Object.keys(this.#t).some(i=>{const l=i;return this.#t[l]!==t[l]&&o.has(l)})};this.#N({listeners:a()})}#y(){const t=this.#s.getQueryCache().build(this.#s,this.options);if(t===this.#e)return;const s=this.#e;this.#e=t,this.#a=t.state,this.hasListeners()&&(s?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#x()}#N(t){Ke.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(this.#t)}),this.#s.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Da(t,s){return X(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&X(s.retryOnMount,t)===!1)}function Bt(t,s){return Da(t,s)||t.state.data!==void 0&&st(t,s,s.refetchOnMount)}function st(t,s,a){if(X(s.enabled,t)!==!1&&Te(s.staleTime,t)!=="static"){const r=typeof a=="function"?a(t):a;return r==="always"||r!==!1&&_t(t,s)}return!1}function Et(t,s,a,r){return(t!==s||X(r.enabled,t)===!1)&&(!a.suspense||t.state.status!=="error")&&_t(t,a)}function _t(t,s){return X(s.enabled,t)!==!1&&t.isStaleByTime(Te(s.staleTime,t))}function Sa(t,s){return!We(t.getCurrentResult(),s)}var Ra=class extends Jt{#s;#e=void 0;#a;#t;constructor(t,s){super(),this.#s=t,this.setOptions(s),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const s=this.options;this.options=this.#s.defaultMutationOptions(t),We(this.options,s)||this.#s.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#a,observer:this}),s?.mutationKey&&this.options.mutationKey&&Pt(s.mutationKey)!==Pt(this.options.mutationKey)?this.reset():this.#a?.state.status==="pending"&&this.#a.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#a?.removeObserver(this)}onMutationUpdate(t){this.#r(),this.#n(t)}getCurrentResult(){return this.#e}reset(){this.#a?.removeObserver(this),this.#a=void 0,this.#r(),this.#n()}mutate(t,s){return this.#t=s,this.#a?.removeObserver(this),this.#a=this.#s.getMutationCache().build(this.#s,this.options),this.#a.addObserver(this),this.#a.execute(t)}#r(){const t=this.#a?.state??Vs();this.#e={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#n(t){Ke.batch(()=>{if(this.#t&&this.hasListeners()){const s=this.#e.variables,a=this.#e.context,r={client:this.#s,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#t.onSuccess?.(t.data,s,a,r)}catch(n){Promise.reject(n)}try{this.#t.onSettled?.(t.data,null,s,a,r)}catch(n){Promise.reject(n)}}else if(t?.type==="error"){try{this.#t.onError?.(t.error,s,a,r)}catch(n){Promise.reject(n)}try{this.#t.onSettled?.(void 0,t.error,s,a,r)}catch(n){Promise.reject(n)}}}this.listeners.forEach(s=>{s(this.#e)})})}},as=m.createContext(!1),Ia=()=>m.useContext(as);as.Provider;function Pa(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Ca=m.createContext(Pa()),Ba=()=>m.useContext(Ca),Ea=(t,s,a)=>{const r=a?.state.error&&typeof t.throwOnError=="function"?ht(t.throwOnError,[a.state.error,a]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(s.isReset()||(t.retryOnMount=!1))},Aa=t=>{m.useEffect(()=>{t.clearReset()},[t])},Wa=({result:t,errorResetBoundary:s,throwOnError:a,query:r,suspense:n})=>t.isError&&!s.isReset()&&!t.isFetching&&r&&(n&&t.data===void 0||ht(a,[t.error,r])),Ma=t=>{if(t.suspense){const a=n=>n==="static"?n:Math.max(n??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...n)=>a(r(...n)):a(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Oa=(t,s)=>t.isLoading&&t.isFetching&&!s,Ka=(t,s)=>t?.suspense&&s.isPending,At=(t,s,a)=>s.fetchOptimistic(t).catch(()=>{a.clearReset()});function Fa(t,s,a){const r=Ia(),n=Ba(),o=U(),i=o.defaultQueryOptions(t);o.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const l=o.getQueryCache().get(i.queryHash);i._optimisticResults=r?"isRestoring":"optimistic",Ma(i),Ea(i,n,l),Aa(n);const c=!o.getQueryCache().get(i.queryHash),[h]=m.useState(()=>new s(o,i)),u=h.getOptimisticResult(i),d=!r&&t.subscribed!==!1;if(m.useSyncExternalStore(m.useCallback(w=>{const y=d?h.subscribe(Ke.batchCalls(w)):Me;return h.updateResult(),y},[h,d]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),m.useEffect(()=>{h.setOptions(i)},[i,h]),Ka(i,u))throw At(i,h,n);if(Wa({result:u,errorResetBoundary:n,throwOnError:i.throwOnError,query:l,suspense:i.suspense}))throw u.error;return o.getDefaultOptions().queries?._experimental_afterQuery?.(i,u),i.experimental_prefetchInRender&&!tt.isServer()&&Oa(u,r)&&(c?At(i,h,n):l?.promise)?.catch(Me).finally(()=>{h.updateResult()}),i.notifyOnChangeProps?u:h.trackResult(u)}function te(t,s){return Fa(t,va)}function $(t,s){const a=U(),[r]=m.useState(()=>new Ra(a,t));m.useEffect(()=>{r.setOptions(t)},[r,t]);const n=m.useSyncExternalStore(m.useCallback(i=>r.subscribe(Ke.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=m.useCallback((i,l)=>{r.mutate(i,l).catch(Me)},[r]);if(n.error&&ht(r.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:o,mutateAsync:n.mutate}}const $e=Xt("work");function $a(t){return zs($e,t)}function rs(t){return Xs($e,t)}function jt(t){return Js($e,t)}function Ua(t,s){return Ys($e,t,s,"work")}function ns(){const{t}=N();return Zs("Work",t)}const Ga=[{id:"work-start-project",labelKey:p.workNewChatDraftStartProjectChipLabel,promptKey:p.workNewChatDraftStartProjectPrompt},{id:"work-add-task",labelKey:p.workNewChatDraftAddTaskChipLabel,promptKey:p.workNewChatDraftAddTaskPrompt},{id:"work-plan-sprint",labelKey:p.workNewChatDraftPlanSprintChipLabel,promptKey:p.workNewChatDraftPlanSprintPrompt},{id:"work-schedule-review",labelKey:p.workNewChatDraftScheduleReviewChipLabel,promptKey:p.workNewChatDraftScheduleReviewPrompt},{id:"work-triage-backlog",labelKey:p.workNewChatDraftTriageBacklogChipLabel,promptKey:p.workNewChatDraftTriageBacklogPrompt}];function Qa(t,s){return Ga.map(a=>({id:a.id,label:s(a.labelKey),onClick:()=>t.onComposerChange(s(a.promptKey))}))}function os(t){return e.jsx(zt,{surface:t.draftSurface,onDismiss:t.draftSurface!=="work"?()=>t.onDraftSurfaceChange("work"):void 0})}function Ha(t){const{t:s}=N(),a=ea(t.payload.chat.advancedDraftControls,"work"),r=Ms({advancedDraftControlsEnabled:a,entryPreset:t.entryPreset??"default",showStructuredDraftControls:!0,hasVisibleParallelDraftTargets:(t.parallelTargets?.length??0)>1});return e.jsx(Os,{...t,draftChrome:{surfaceTag:os(t)},builderControls:r,starterChips:{leading:Qa(t,s)}})}function qa(t){const s=t.greeting??void 0;return e.jsx(Ta,{...t,greeting:s,surfaceTag:os(t)})}function Va(t){return t.draftDefaultRecipientCatId?e.jsx(qa,{...t}):e.jsx(Ha,{...t})}async function Ya(t,s,a){const r=await fetch(Zt,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function is(t,s,a){const r=await fetch(sa(t),{method:"DELETE",signal:a});return K(r,s)}async function za(t,s,a){const r=await fetch(es,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function Ja(t,s,a){const r=await fetch(aa(t),{method:"DELETE",signal:a});return K(r,s)}async function Xa(t,s,a){const r=await fetch(ts,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function ls(t,s,a){const r=await fetch(ts,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function Za(t,s,a){const r=await fetch(ta,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function er(t,s,a){const r=await fetch(mt,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function tr(t,s,a){const r=await fetch(Fe(t),{method:"DELETE",signal:a});return K(r,s)}async function sr(t,s,a,r){const n=await fetch("/api/core/approvals",{method:"POST",headers:{"content-type":"application/json",Accept:"application/json"},body:JSON.stringify({taskId:t,status:s.action==="approve"?"approved":"rejected",action:s.action,decidedByActorId:s.decidedByActorId??null,notes:s.notes??null,taskStatus:s.action==="approve"?"approved":"cancelled"}),signal:r});return K(n,a)}async function ar(t,s,a){const r=await fetch(`${Fe(t)}/supervised-run`,{method:"POST",headers:{Accept:"application/json"},signal:a});return K(r,s)}async function rr(t,s,a){const r=await fetch(`${Fe(t)}/golden-path/lifecycle/${s}`,{method:"POST",headers:{Accept:"application/json"},signal:a});return K(r,"The run lifecycle action failed.")}async function nr(t,s){const a=await fetch(`${Fe(t)}/golden-path/retry-delivery`,{method:"POST",headers:{Accept:"application/json"},signal:s});return K(a,"Retrying the transport delivery failed.")}async function or(t,s,a){const r=await fetch(t.path,{method:t.method,headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t.body),signal:a});return K(r,s)}const Wt="actor-cat-";function ir(t){if(!t||!t.startsWith(Wt))return null;const s=t.slice(Wt.length);return s.length>0?s:null}function cs(t){return t.flatMap(s=>{const a=ir(s.actorId);return a?[{...s,catId:a}]:[]})}async function lr(t,s){const a=await fetch(ra,{signal:s});return K(a,t)}const De=["workDashboard"];function cr(t){return te({queryKey:De,queryFn:({signal:s})=>lr(t,s)})}function me(t,s){const a=t.statusText.trim();return new Error(a?s(p.workQueryHttpErrorWithStatusText,{status:t.status,statusText:a}):s(p.workQueryHttpError,{status:t.status}))}const we=["tasks"];async function dr(t){const s=await fetch(mt,{headers:{accept:"application/json"}});if(!s.ok)throw me(s,t);return await s.json()}function Se(){const{t}=N();return te({queryKey:we,queryFn:()=>dr(t)})}const Y=["workGraph"],pe={objects:[],evidenceAttachments:[],gateDecorators:[],links:[],linksByEndpoint:{},diagnostics:[]};async function ur(t){const s=await fetch(na);return K(s,t)}function ke(t){return te({queryKey:Y,queryFn:()=>ur(t)})}function hr(t){switch(t){case"chat":return"Chat";case"code":return"Code";default:return"Work"}}const de=pt("en"),mr={acknowledge:p.workExecutionActionAcknowledge,approve:p.workExecutionActionApprove,approval_pending:p.workExecutionReasonApprovalPending,approved:p.workExecutionApprovalStatusApproved,artifact_only:p.workExecutionDeliveryModeArtifactOnly,child_tasks_in_progress:p.workExecutionReasonChildTasksInProgress,commit_only:p.workExecutionDeliveryModeCommitOnly,complete:p.workExecutionActionComplete,create_commit:p.workExecutionActionCreateCommit,deploy_preview:p.workExecutionDeliveryModeDeployPreview,dispatch:p.workExecutionActionDispatch,failed:p.workExecutionReplayStateFailed,in_progress:p.workExecutionReplayStateInProgress,max_dispatches:p.workExecutionReasonMaxDispatches,no_valid_targets:p.workExecutionReasonNoValidTargets,not_requested:p.workExecutionApprovalStatusNotRequested,open_pull_request:p.workExecutionActionOpenPullRequest,orchestrator_replay:p.workExecutionReplaySourceOrchestratorReplay,orchestrator_startup_recovery:p.workExecutionReplaySourceOrchestratorStartupRecovery,pdca:p.workExecutionStrategyPdca,pending:p.workExecutionReplayStatePending,plan_and_execute:p.workExecutionStrategyPlanAndExecute,pr_with_checks:p.workExecutionDeliveryModePrWithChecks,publish_preview:p.workExecutionActionPublishPreview,push_branch:p.workExecutionDeliveryModePushBranch,ready:p.workExecutionReplayStateReady,react:p.workExecutionStrategyReact,reflexion:p.workExecutionStrategyReflexion,reject:p.workExecutionActionReject,rejected:p.workExecutionApprovalStatusRejected,request_review:p.workExecutionActionRequestReview,retry:p.workExecutionActionRetry,retry_available:p.workExecutionReasonRetryAvailable,reroute:p.workExecutionActionReroute,run_blocked:p.workExecutionReasonRunBlocked,run_failed:p.workExecutionReasonRunFailed,user_cancelled:p.workExecutionReasonUserCancelled,wait:p.workExecutionActionWait,wait_for_checks:p.workExecutionActionWaitForChecks,workflow_continuation_replay:p.workExecutionReplaySourceWorkflowContinuationReplay,workflow_review_required:p.workExecutionReasonWorkflowReviewRequired};function ds(t){return t.trim().toLowerCase().replace(/-/gu,"_")}function Re(t,s,a){const r=t?.trim();if(!r)return s;const n=mr[ds(r)];return n?a(n):r.replace(/[_-]+/gu," ").replace(/\s+/gu," ").replace(/\b\w/gu,o=>o.toUpperCase())}function at(t,s=de,a){const r=typeof s=="function"?s:de,n=typeof s=="string"?s:a??r(p.workWarRoomMetaValueNone),o=(t??[]).map(i=>Re(i,"",r)).filter(i=>i.length>0);return o.length>0?o.join(", "):n}function se(t,s=de,a){return Re(t,a??s(p.workWarRoomMetaValueNotSpecified),s)}function pr(t,s=de){return ds(t??"")==="pending"?s(p.workExecutionApprovalStatusPending):se(t,s)}function us(t,s=de){return t?.trim()?t==="chat"||t==="work"||t==="code"?hr(t):Re(t,t,s):s(p.workWarRoomMetaValueUnassigned)}function hs(t,s=de){return Re(t,s(p.workWarRoomMetaValueNotSpecified),s)}function xt(t,s=de){return Re(t,s(p.workWarRoomMetaValueNotSpecified),s)}function Ue(t){return`${t.recordFamily}:${t.recordId}`}const kr={agent:"workObjectKindAgent",container:"workObjectKindContainer",conversation:"workObjectKindConversation",turn:"workObjectKindTurn",lane:"workObjectKindLane",project:"workObjectKindProject",work_item:"workObjectKindWorkItem",task:"workObjectKindTask",mission:"workObjectKindMission",run:"workObjectKindRun",artifact:"workObjectKindArtifact",activity:"workObjectKindActivity",outcome:"workObjectKindOutcome",approval_binding:"workObjectKindApprovalBinding"},wr={decision_needed:"workObjectAttentionDecisionNeeded",blocked:"workObjectAttentionBlocked",failed:"workObjectAttentionFailed",ready_to_review:"workObjectAttentionReadyToReview",recently_shipped:"workObjectAttentionRecentlyShipped"},_r={artifact:"workObjectKindArtifact",activity:"workObjectKindActivity",outcome:"workObjectKindOutcome"},jr={interaction:"workTopdownSystemMapLayerInteractionLabel",planning:"workTopdownSystemMapLayerPlanningLabel",execution:"workTopdownSystemMapLayerExecutionLabel"},xr={work:"platformProductWorkSettingsLabel",code:"platformProductCodeSettingsLabel",chat:"platformProductChatSettingsLabel",unbound:"workTopdownTaskProductBindingUnbound"},gr={error:"workTopdownBrokenLinksSeverityErrorLabel",warning:"workTopdownBrokenLinksSeverityWarningLabel",info:"workTopdownBrokenLinksSeverityInfoLabel"},br={broken_fk:"workTopdownDiagnosticKindBrokenFk",missing_project_anchor:"workTopdownDiagnosticKindMissingProjectAnchor",missing_planning_execution_bridge:"workTopdownDiagnosticKindMissingPlanningExecutionBridge",unanchored_run:"workTopdownDiagnosticKindUnanchoredRun",unanchored_evidence:"workTopdownDiagnosticKindUnanchoredEvidence",missing_gate_subject:"workTopdownDiagnosticKindMissingGateSubject",orphan_link:"workTopdownDiagnosticKindOrphanLink",link_cycle:"workTopdownDiagnosticKindLinkCycle"},yr={assistant:"workActorRoleAssistant",boss:"workActorRoleBoss",coder:"workActorRoleCoder",coordinator:"workActorRoleCoordinator",critic:"workActorRoleCritic",drafter:"workActorRoleDrafter",main_coder:"workActorRoleMainCoder",orchestrator:"workActorRoleOrchestrator",owner:"workActorRoleOwner",planner:"workActorRolePlanner",reviewer:"workActorRoleReviewer",summarizer:"workActorRoleSummarizer"},Nr={github:"GitHub",gitlab:"GitLab",gitea:"Gitea",redmine:"Redmine",bugzilla:"Bugzilla"};function ae(t,s){const a=kr[t];return a?s(a):s("workObjectKindUnknown",{kind:t.replace(/_/g," ")})}function re(t,s){const a=wr[t];return a?s(a):t==="none"?null:s("workObjectAttentionUnknown",{attention:t.replace(/_/g," ")})}function fr(t,s){return s(_r[t])}function rt(t,s){return s(jr[t])}function gt(t,s){return s(xr[t])}function Tr(t,s){return s(gr[t])}function ms(t,s){return s(br[t])}function ge(t,s){const a=t.trim().toLowerCase(),r=yr[a];return r?s(r):t}function ps(t,s){const a=String(t).replace(/_/g," ");return t==="not_requested"?s("workObjectGateStateNotRequested"):t==="pending"?s("workObjectGateStatePending"):t==="approved"?s("workObjectGateStateApproved"):t==="rejected"?s("workObjectGateStateRejected"):s("workObjectGateStateUnknown",{state:a})}function ee(t){const s=Nr[t.provider]??t.provider;return t.externalType==="issue"?`${s} #${t.externalId}`:`${s} ${t.externalType} ${t.externalId}`}function bt(t){if(!t)return!1;try{const s=new URL(t);return s.protocol==="http:"||s.protocol==="https:"}catch{return!1}}function be(t){const s=new Map,a=new Map;for(const o of t.objects)s.set(o.id,o),a.set(`${o.sourceRecordFamily}:${o.sourceRecordId}`,o);const r=new Map;for(const o of t.evidenceAttachments){const i=r.get(o.anchorObjectId)??[];i.push(o),r.set(o.anchorObjectId,i)}const n=new Map;for(const o of t.gateDecorators){const i=n.get(o.subjectObjectId)??[];i.push(o),n.set(o.subjectObjectId,i)}return{objectsById:s,objectsByCoreRef:a,evidenceByAnchor:r,gatesBySubject:n}}function Lr(t,s,a,r){if(r<=0)return[];const n=`${t.recordFamily}:${t.recordId}`,o=new Set([n]),i=[],l=[{key:n,depth:0}],c=new Map;for(const h of s){if(h.kind!=="blocks")continue;const u=`${h.targetRecordFamily}:${h.targetRecordId}`,d=c.get(u)??[];d.push(h),c.set(u,d)}for(;l.length>0;){const{key:h,depth:u}=l.shift();if(u>=r)continue;const d=c.get(h)??[];for(const w of d){const y=`${w.sourceRecordFamily}:${w.sourceRecordId}`;if(o.has(y))continue;o.add(y);const j=a.get(y);j&&(i.push(j),l.push({key:y,depth:u+1}))}}return i}function W(t,s){const a=Date.parse(t);if(Number.isNaN(a))return t;const r=Date.now()-a;if(r<0)return s("workTopdownRelativeJustNow");const n=Math.round(r/6e4);if(n<1)return s("workTopdownRelativeJustNow");if(n<60)return s("workTopdownRelativeMinutesAgo",{count:`${n}`});const o=Math.round(n/60);if(o<48)return s("workTopdownRelativeHoursAgo",{count:`${o}`});const i=Math.round(o/24);return s("workTopdownRelativeDaysAgo",{count:`${i}`})}function Ge({object:t,evidence:s,gates:a,selected:r,onSelect:n}){const{t:o}=N(),i=ae(t.kind,o),l=t.attention==="none"?null:re(t.attention,o),c=M(t.status,o),h=t.kind==="task"&&t.productBinding?gt(t.productBinding,o):null,u=t.kind==="run"?o("workTopdownParentTaskOwningLabel"):o("workTopdownParentTaskLabel"),d=t.kind==="work_item"&&t.linkedWorkItemTitle?o("workTopdownParentWorkItemLabel",{parentWorkItemTitle:t.linkedWorkItemTitle}):null,w=t.externalBindings??[];return e.jsxs("article",{className:`topDownCard topDownCard--${t.kind} topDownCard--attention-${t.attention}`+(r?" topDownCard--selected":""),role:"button",tabIndex:0,onClick:()=>n(t.id),onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),n(t.id))},children:[e.jsxs("header",{className:"topDownCard__head",children:[e.jsx("span",{className:"topDownCard__kind",children:i}),t.kind==="task"&&t.productBinding&&h?e.jsx("span",{className:`topDownCard__binding topDownCard__binding--${t.productBinding}`,title:o("workTopdownTaskProductBindingTitle",{productBinding:h}),children:h}):null,l?e.jsx("span",{className:`topDownCard__attention topDownCard__attention--${t.attention}`,children:l}):null,e.jsx("span",{className:"topDownCard__status",children:c})]}),e.jsx("h4",{className:"topDownCard__title",children:t.title}),t.summary?e.jsx("p",{className:"topDownCard__summary",children:t.summary}):null,t.nextAction?e.jsxs("p",{className:"topDownCard__next",children:["→ ",t.nextAction]}):null,s.total>0||a.length>0||w.length>0||t.ownerRole||(t.kind==="run"||t.kind==="task")&&t.linkedTaskTitle||t.kind==="work_item"&&t.linkedWorkItemTitle?e.jsxs("footer",{className:"topDownCard__foot",children:[t.ownerRole?e.jsx("span",{className:"topDownCard__role",children:ge(t.ownerRole,o)}):null,(t.kind==="run"||t.kind==="task")&&t.linkedTaskTitle?e.jsxs("span",{className:"topDownCard__chip topDownCard__chip--parentTask",title:o("workTopdownParentTaskTooltip",{linkedTaskTitle:t.linkedTaskTitle,linkType:t.kind==="run"?o("workTopdownParentTaskOwningLabel"):o("workTopdownParentTaskLabel")}),children:[u,": ",t.linkedTaskTitle]}):null,t.kind==="work_item"&&t.linkedWorkItemTitle?e.jsx("span",{className:"topDownCard__chip topDownCard__chip--parentTask",title:o("workTopdownParentWorkItemLabel",{parentWorkItemTitle:t.linkedWorkItemTitle}),children:d}):null,w.map(y=>e.jsx("span",{className:"topDownCard__chip topDownCard__chip--external",title:o("workTopdownExternalBindingTooltip",{externalBinding:ee(y)}),children:ee(y)},`${y.provider}:${y.externalType}:${y.externalId}`)),s.artifact>0?e.jsxs("span",{className:"topDownCard__chip topDownCard__chip--artifact",children:["📎 ",s.artifact]}):null,s.activity>0?e.jsxs("span",{className:"topDownCard__chip topDownCard__chip--activity",children:["📜 ",s.activity]}):null,s.outcome>0?e.jsxs("span",{className:"topDownCard__chip topDownCard__chip--outcome",children:["🎯 ",s.outcome]}):null,a.map(y=>e.jsxs("span",{className:`topDownCard__chip topDownCard__chip--gate-${y.state}`,children:["⊘ ",ps(y.state,o)]},y.gateObjectId))]}):null]})}function Qe(t,s){const a=t.evidenceByAnchor.get(s),r={artifact:0,activity:0,outcome:0,total:0};if(!a)return r;for(const n of a)r[n.relation]+=1,r.total+=1;return r}function M(t,s){return t==="draft"?s("workObjectStatusDraft"):t==="planned"?s("workObjectStatusPlanned"):t==="active"?s("workObjectStatusActive"):t==="paused"?s("workObjectStatusPaused"):t==="archived"?s("workObjectStatusArchived"):t==="ready"?s("workObjectStatusReady"):t==="in_progress"?s("workObjectStatusInProgress"):t==="blocked"?s("workObjectStatusBlocked"):t==="completed"?s("workObjectStatusCompleted"):t==="cancelled"?s("workObjectStatusCancelled"):t==="running"?s("workObjectStatusRunning"):t==="queued"?s("workObjectStatusQueued"):s("workObjectStatusUnknown",{status:t.replace(/_/g," ")})}const vr=pt("en"),Dr={"Approval requested":p.workTimelineTitleApprovalRequested,"Approval decided":p.workTimelineTitleApprovalDecided,"Operator action":p.workTimelineTitleOperatorAction,"Artifact recorded":p.workTimelineTitleArtifactRecorded,"Checkpoint recorded":p.workTimelineTitleCheckpointRecorded,"Work item updated":p.workTimelineTitleWorkItemUpdated,"Status changed":p.workTimelineTitleStatusChanged,Note:p.workTimelineTitleNote};function Sr(t,s){switch(t){case"approval":return s(p.sharedOperatorTraceKindApproval);case"checkpoint":return s(p.sharedOperatorTraceKindCheckpoint);case"dispatch":return s(p.sharedOperatorTraceKindDispatch);case"error":return s(p.sharedOperatorTraceKindError);case"outcome":return s(p.sharedOperatorTraceKindOutcome);case"status":return s(p.sharedOperatorTraceKindStatus);case"note":return s(p.sharedOperatorTraceKindNote);default:return t}}function Rr(t,s){switch(t){case"provider-agent run loop":return s(p.workTimelineEvidenceProviderAgentRunLoop);case"supervision evidence":return s(p.workTimelineEvidenceSupervision);default:return t}}function Ir(t,s=vr){const a=Dr[t];if(a)return s(a);const r=/^Approval binding \((.+)\)$/u.exec(t);if(r)return s(p.workTimelineTitleApprovalBinding,{kind:r[1]});const n=/^Trace \((.+)\)$/u.exec(t);if(n)return s(p.workTimelineTitleTrace,{kind:Sr(n[1]??"",s)});const o=/^Checkpoint: (.+)$/u.exec(t);if(o)return s(p.workTimelineTitleCheckpoint,{label:o[1]});const i=/^Provider-agent plan: (.+)$/u.exec(t);if(i)return s(p.workTimelineTitleProviderAgentPlan,{planId:i[1]});const l=/^Evidence: (.+)$/u.exec(t);return l?s(p.workTimelineTitleEvidence,{source:Rr(l[1]??"",s)}):t}function Pr(t,s){const a=t.trim();if(a.length===0)return null;switch(a){case"title is required.":return s("workCrudErrorTitleRequired");case"Invalid input":return s("workCrudErrorInvalidInput");case"Project id is required.":return s("workCrudErrorProjectIdRequired");case"Work item id is required.":return s("workCrudErrorWorkItemIdRequired");case"Task id is required.":return s("workCrudErrorTaskIdRequired");case"must be a string when provided.":return s("workCrudErrorMustBeStringWhenProvided");case"metadata must be an object when provided.":return s("workCrudErrorMetadataObjectRequired")}let r=/^No project with id (.+)\.$/u.exec(a);return r?s("workCrudErrorProjectNotFound",{id:r[1]??""}):(r=/^No work item with id (.+)\.$/u.exec(a),r?s("workCrudErrorWorkItemNotFound",{id:r[1]??""}):(r=/^No task with id (.+)\.$/u.exec(a),r?s("workCrudErrorTaskNotFound",{id:r[1]??""}):(r=/^(.+) must be a string or null\.$/u.exec(a),r?s("workCrudErrorFieldStringOrNull",{fieldName:r[1]??""}):(r=/^(.+) must be a string\[\]\.$/u.exec(a),r?s("workCrudErrorFieldStringArray",{fieldName:r[1]??""}):(r=/^must be one of: (.+)\.$/u.exec(a),r?s("workCrudErrorMustBeOneOf",{values:r[1]??""}):null)))))}function V(t,s,a){return t instanceof Error?Pr(t.message,a)??t.message:s}function He(t,s){if(!t)return s("workWarRoomNotRecorded");const a=new Date(t);return Number.isNaN(a.getTime())?t:a.toLocaleString()}function qe(t,s){return t.length>0?t.join(", "):s("workWarRoomNone")}function ks(t){switch(t){case"attention":return"operatorStatusBadge isAttention";case"error":return"operatorStatusBadge isError";case"progress":return"operatorStatusBadge isProgress";case"success":return"operatorStatusBadge isSuccess";default:return"operatorStatusBadge isMuted"}}function ws(t,s){return t==="attention"?s("workWarRoomAttentionAttention"):t==="error"?s("workWarRoomAttentionError"):t==="progress"?s("workWarRoomAttentionProgress"):t==="success"?s("workWarRoomAttentionSuccess"):t==="muted"?s("workWarRoomAttentionMuted"):s("workWarRoomAttentionFallback",{severity:t})}function Ie(t,s){if(!t)return s("workWarRoomNoStatus");const a=M(t,s);return a===t?s("workWarRoomStatusFallback",{status:t}):a}function Pe(t){switch(t){case"blocked":case"paused":case"cancelled":return"operatorStatusBadge isError";case"ready":case"pending_approval":case"planned":return"operatorStatusBadge isAttention";case"active":case"in_progress":return"operatorStatusBadge isProgress";case"completed":case"archived":return"operatorStatusBadge isSuccess";default:return"operatorStatusBadge isMuted"}}function Be({label:t,value:s,helper:a}){return e.jsxs("article",{className:"operatorCard workWarRoomSummaryCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:t}),e.jsx("span",{className:"operatorStatusBadge isMuted",children:s})]}),e.jsx("p",{children:a})]})}function ue({eyebrow:t,title:s,summary:a}){return e.jsxs("div",{className:"operatorPanelHeader",children:[e.jsxs("div",{children:[e.jsx("p",{className:"operatorEyebrow",children:t}),e.jsx("h2",{children:s})]}),e.jsx("span",{className:"operatorStatusBadge isMuted",children:a})]})}function Cr({taskId:t,t:s}){const a=z();return e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{a(`/work/tasks/${encodeURIComponent(t)}`)})},children:s("workWarRoomOpenTask")})}function yt({taskId:t,taskContext:s,nextActions:a=[],isTaskActionPending:r=!1,onTaskAction:n,t:o}){const i=z(),l=n,c=l?a.filter(Br):[];return e.jsxs("div",{className:"workWarRoomHeaderActions",children:[c.map(h=>e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>l?.(h.action),disabled:r,children:r?o("workWarRoomActionBusy"):se(h.kind,o)},`${t}:${h.kind}`)),e.jsx(Cr,{taskId:t,t:o}),s.projectId?e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{i(`/work/projects/${encodeURIComponent(s.projectId)}`)})},children:o("workWarRoomOpenProject")}):null,s.workItemId?e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{i(`/work/work-items/${encodeURIComponent(s.workItemId)}`)})},children:o("workWarRoomOpenWorkItem")}):null,s.conversationSourceChannelId?e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{i(jt(s.conversationSourceChannelId))})},children:o("workWarRoomOpenBriefingThread")}):null,cs(s.assignedActors).map(h=>e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{i(rs(h.catId))})},children:o("workWarRoomOpenActor",{actorName:h.displayName})},h.actorId))]})}function Br(t){return(t.kind==="approve"||t.kind==="reject")&&t.action!==null}function Er({items:t,totalAvailable:s,isTaskActionPending:a,onTaskAction:r,t:n}){return e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:n("workWarRoomOperateEyebrow"),title:n("workWarRoomOperatorInbox"),summary:n("workWarRoomCountSummary",{count:t.length,total:s})}),t.length===0?e.jsxs("article",{className:"operatorCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:n("workWarRoomOperatorInboxEmptyTitle")}),e.jsx("span",{className:"operatorStatusBadge isMuted",children:n("workWarRoomOperatorInboxEmptyBadge")})]}),e.jsx("p",{children:n("workWarRoomOperatorInboxEmptyBody")})]}):e.jsx("div",{className:"workWarRoomTaskGrid",children:t.map(o=>e.jsxs("article",{className:"operatorCard workWarRoomTaskCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:o.taskTitle}),e.jsxs("div",{className:"workWarRoomBadgeRow",children:[e.jsx("span",{className:ks(o.attention.severity),children:ws(o.attention.severity,n)}),e.jsx("span",{className:Pe(o.taskStatus),children:Ie(o.taskStatus,n)})]})]}),e.jsx("p",{children:o.summary??n("workWarRoomNoTaskSummary")}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelReasons"),":"," ",at(o.attention.reasons,n)]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelActions"),":"," ",at(o.nextActions.map(i=>i.kind),n)]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelProduct"),":"," ",us(o.planning.effectiveProduct,n)]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelStrategy"),":"," ",hs(o.runtimeBridge.request.requestedStrategy,n)]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelDelivery"),":"," ",xt(o.runtimeDeliveryIntent?.mode,n)]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelWorkflow"),":"," ",se(o.workflowContinuation?.blockedReason,n,n("workWarRoomMetaValueNoReplayBlock"))]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelLatest"),":"," ",o.latestTimelineItem?Ir(o.latestTimelineItem.title,n):n("workWarRoomMetaValueNoTimelineItem")]}),e.jsx("span",{children:He(o.latestTimelineItem?.timestamp,n)})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelProject"),": ",o.taskContext.projectTitle??n("workWarRoomNoLinkedProject")]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelWorkItem"),":"," ",o.taskContext.workItemTitle??n("workWarRoomNoLinkedWorkItem")]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelConversation"),":"," ",o.taskContext.conversationTitle??n("workWarRoomNoLinkedConversation")]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelActors"),":"," ",qe(o.taskContext.assignedActors.map(i=>i.displayName),n)]})]}),e.jsx(yt,{taskId:o.taskId,taskContext:o.taskContext,nextActions:o.nextActions,isTaskActionPending:a,onTaskAction:r,t:n})]},o.taskId))})]})}function Ar({items:t,totalAvailable:s,isTaskActionPending:a,onTaskAction:r,t:n}){return e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:n("workWarRoomGovernanceEyebrow"),title:n("workWarRoomControlPlane"),summary:n("workWarRoomCountSummary",{count:t.length,total:s})}),t.length===0?e.jsxs("article",{className:"operatorCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:n("workWarRoomControlPlaneEmptyTitle")}),e.jsx("span",{className:"operatorStatusBadge isMuted",children:n("workWarRoomControlPlaneEmptyBadge")})]}),e.jsx("p",{children:n("workWarRoomControlPlaneEmptyBody")})]}):e.jsx("div",{className:"workWarRoomTaskGrid",children:t.map(o=>e.jsxs("article",{className:"operatorCard workWarRoomTaskCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:o.taskId}),e.jsxs("div",{className:"workWarRoomBadgeRow",children:[e.jsx("span",{className:ks(o.attention.severity),children:ws(o.attention.severity,n)}),e.jsx("span",{className:Pe(o.taskStatus),children:Ie(o.taskStatus,n)})]})]}),e.jsx("p",{children:o.workflowContinuation?.targetNames.length?n("workWarRoomControlPlaneTargets",{targets:o.workflowContinuation.targetNames.join(", ")}):o.workflowContinuation?.blockedReason?n("workWarRoomControlPlaneBlockedBy",{reason:se(o.workflowContinuation.blockedReason,n)}):n("workWarRoomControlPlaneNoTargets")}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelProduct"),":"," ",us(o.planning.effectiveProduct,n)]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelStrategy"),":"," ",hs(o.planning.effectiveStrategy,n)]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelNext"),":"," ",at(o.nextActions.map(i=>i.kind),n)]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelDelivery"),":"," ",xt(o.runtimeDeliveryIntent?.mode,n)]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelReplay"),":"," ",se(o.workflowContinuation?.replayState,n,n("workWarRoomMetaValueNotRecorded"))]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelBlocked"),":"," ",se(o.workflowContinuation?.blockedReason,n,n("workWarRoomMetaValueNo"))]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelProject"),":"," ",o.taskContext.projectTitle??n("workWarRoomNoLinkedProject")]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelWorkItem"),":"," ",o.taskContext.workItemTitle??n("workWarRoomNoLinkedWorkItem")]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelConversation"),":"," ",o.taskContext.conversationTitle??n("workWarRoomNoLinkedConversation")]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelActors"),":"," ",qe(o.taskContext.assignedActors.map(i=>i.displayName),n)]})]}),e.jsx(yt,{taskId:o.taskId,taskContext:o.taskContext,nextActions:o.nextActions,isTaskActionPending:a,onTaskAction:r,t:n})]},o.taskId))})]})}function Wr({items:t,totalAvailable:s,t:a}){const r=z();return e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:a("workWarRoomPortfolioEyebrow"),title:a("workWarRoomProjects"),summary:a("workWarRoomCountSummary",{count:t.length,total:s})}),t.length===0?e.jsxs("article",{className:"operatorCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:a("workWarRoomProjectsEmptyTitle")}),e.jsx("span",{className:"operatorStatusBadge isMuted",children:a("workWarRoomProjectsEmptyBadge")})]}),e.jsx("p",{children:a("workWarRoomProjectsEmptyBody")})]}):e.jsx("div",{className:"workWarRoomTaskGrid",children:t.map(n=>e.jsxs("article",{className:"operatorCard workWarRoomTaskCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:n.title}),e.jsx("span",{className:Pe(n.status),children:Ie(n.status,a)})]}),e.jsx("p",{children:n.summary??a("workWarRoomNoProjectSummary")}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelOwner"),": ",n.ownerName]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelRepo"),": ",n.repoPath??a("workWarRoomMetaValueNotBound")]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelWorkItems"),": ",n.linkedWorkItemCount]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelTasks"),": ",n.linkedTaskCount]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelConversation"),": ",n.primaryConversationTitle??a("workWarRoomNoPrimaryConversation")]}),e.jsx("span",{children:He(n.updatedAt,a)})]}),e.jsxs("div",{className:"workWarRoomHeaderActions",children:[e.jsx(Kr,{projectId:n.id,t:a}),n.primaryConversationSourceChannelId?e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{r(jt(n.primaryConversationSourceChannelId))})},children:a("workWarRoomOpenBriefingThread")}):null]})]},n.id))})]})}function Mr({items:t,totalAvailable:s,t:a}){const r=z();return e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:a("workWarRoomManagedWorkEyebrow"),title:a("workWarRoomWorkItems"),summary:a("workWarRoomCountSummary",{count:t.length,total:s})}),t.length===0?e.jsxs("article",{className:"operatorCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:a("workWarRoomWorkItemsEmptyTitle")}),e.jsx("span",{className:"operatorStatusBadge isMuted",children:a("workWarRoomWorkItemsEmptyBadge")})]}),e.jsx("p",{children:a("workWarRoomWorkItemsEmptyBody")})]}):e.jsx("div",{className:"workWarRoomTaskGrid",children:t.map(n=>e.jsxs("article",{className:"operatorCard workWarRoomTaskCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:n.title}),e.jsx("span",{className:Pe(n.status),children:Ie(n.status,a)})]}),e.jsx("p",{children:n.summary??a("workWarRoomNoWorkItemSummary")}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelProject"),":"," ",n.projectTitle??a("workWarRoomNoLinkedProject")]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelTask"),":"," ",n.taskTitle??a("workWarRoomNoLinkedTask")]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelOwner"),": ",n.ownerName]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelActors"),":"," ",qe(n.assignedActors.map(o=>o.displayName),a)]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelConversation"),": ",n.conversationTitle??a("workWarRoomNoLinkedConversation")]}),e.jsx("span",{children:He(n.updatedAt,a)})]}),e.jsxs("div",{className:"workWarRoomHeaderActions",children:[e.jsx(Fr,{workItemId:n.id,t:a}),n.conversationSourceChannelId?e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{r(jt(n.conversationSourceChannelId))})},children:a("workWarRoomOpenBriefingThread")}):null,cs(n.assignedActors).map(o=>e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{r(rs(o.catId))})},children:a("workWarRoomOpenActor",{actorName:o.displayName})},o.actorId))]})]},n.id))})]})}function Or({items:t,totalAvailable:s,t:a}){return e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:a("workWarRoomRecoveryEyebrow"),title:a("workWarRoomRecovery"),summary:a("workWarRoomCountSummary",{count:t.length,total:s})}),t.length===0?e.jsxs("article",{className:"operatorCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:a("workWarRoomRecoveryEmptyTitle")}),e.jsx("span",{className:"operatorStatusBadge isSuccess",children:a("workWarRoomRecoveryEmptyBadge")})]}),e.jsx("p",{children:a("workWarRoomRecoveryEmptyBody")})]}):e.jsx("div",{className:"workWarRoomTaskGrid",children:t.map(r=>e.jsxs("article",{className:"operatorCard workWarRoomTaskCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:r.taskId}),e.jsxs("div",{className:"workWarRoomBadgeRow",children:[e.jsx("span",{className:r.canRetry?"operatorStatusBadge isAttention":"operatorStatusBadge isMuted",children:r.canRetry?a("workWarRoomMetaLabelRetryAvailable"):a("workWarRoomMetaLabelWatch")}),e.jsx("span",{className:Pe(r.taskStatus),children:Ie(r.taskStatus,a)})]})]}),e.jsx("p",{children:r.latestActivity?.message??(r.workflowContinuationReplay?.blockedReason?se(r.workflowContinuationReplay.blockedReason,a):null)??r.dispatchReplay?.replayError??a("workWarRoomRecoveryNoRecoveryNote")}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelDelivery"),": ",xt(r.context?.deliveryMode,a)]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelApproval"),":"," ",pr(r.approval.status,a)]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelReplay"),":"," ",se(r.workflowContinuationReplay?.replayState??r.dispatchReplay?.replayState,a,a("workWarRoomMetaValueNone"))]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelBlocked"),":"," ",se(r.workflowContinuationReplay?.blockedReason,a,a("workWarRoomMetaValueNo"))]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelLatestSource"),":"," ",se(r.latestActivity?.source,a,a("workWarRoomMetaValueNotRecorded"))]}),e.jsx("span",{children:He(r.latestActivity?.createdAt,a)})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelProject"),": ",r.taskContext.projectTitle??a("workWarRoomNoLinkedProject")]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelWorkItem"),":"," ",r.taskContext.workItemTitle??a("workWarRoomNoLinkedWorkItem")]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelConversation"),":"," ",r.taskContext.conversationTitle??a("workWarRoomNoLinkedConversation")]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelActors"),":"," ",qe(r.taskContext.assignedActors.map(n=>n.displayName),a)]})]}),e.jsx(yt,{taskId:r.taskId,taskContext:r.taskContext,t:a})]},r.taskId))})]})}function Kr({projectId:t,t:s}){const a=z();return e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{a(`/work/projects/${encodeURIComponent(t)}`)})},children:s("workWarRoomOpenProject")})}function Fr({workItemId:t,t:s}){const a=z();return e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{a(`/work/work-items/${encodeURIComponent(t)}`)})},children:s("workWarRoomOpenWorkItem")})}function $r(){const{t}=N(),s=U(),a=cr(t("workWarRoomLoadError")),r=$({mutationFn:async l=>or(l,t("workWarRoomActionError")),onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:De}),s.invalidateQueries({queryKey:we}),s.invalidateQueries({queryKey:Y})])}}),n=a.data??null,o=a.error?a.error instanceof Error?a.error.message:t("workWarRoomLoadError"):"",i=r.error?V(r.error,t("workWarRoomActionError"),t):"";return e.jsxs("div",{className:"workWarRoomView",children:[e.jsx("div",{className:"codeBuilderHeader",children:e.jsxs("div",{children:[e.jsx("p",{className:"operatorEyebrow",children:t("workWarRoomPageEyebrow")}),e.jsx("h1",{className:"codeBuilderTitle",children:t("workWarRoomPageTitle")})]})}),o||i?e.jsx("div",{className:"codeBuilderFeedback",children:o||i}):null,a.isPending&&!n?e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:t("workWarRoomLoadingEyebrow"),title:t("workWarRoomPageTitle"),summary:t("workWarRoomLoadingSummary")}),e.jsxs("article",{className:"operatorCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:t("workWarRoomLoadingTitle")}),e.jsx("span",{className:"operatorStatusBadge isProgress",children:t("workWarRoomLoadingBadge")})]}),e.jsx("p",{children:t("workWarRoomLoadingBody")})]})]}):null,n?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:t("workWarRoomSnapshotEyebrow"),title:t("workWarRoomSnapshotTitle"),summary:t("workWarRoomSnapshotSummary",{ownerActorId:n.summary.ownerActorId})}),e.jsxs("div",{className:"workWarRoomSummaryGrid",children:[e.jsx(Be,{label:t("workWarRoomSummaryLabelProjects"),value:n.summary.projectCount,helper:t("workWarRoomSummaryInProgressBlocked",{inProgress:n.summary.inProgressCount,blocked:n.summary.blockedCount})}),e.jsx(Be,{label:t("workWarRoomSummaryLabelTasks"),value:n.summary.taskCount,helper:t("workWarRoomSummaryInProgressBlocked",{inProgress:n.summary.inProgressCount,blocked:n.summary.blockedCount})}),e.jsx(Be,{label:t("workWarRoomSummaryLabelAttention"),value:n.summary.operatorAttentionCount,helper:t("workWarRoomSummaryAttention",{count:n.sections.operatorInbox.summary.returned})}),e.jsx(Be,{label:t("workWarRoomSummaryLabelRecovery"),value:n.summary.recoveryCount,helper:t("workWarRoomSummaryRecovery",{count:n.sections.recovery.summary.returned})})]})]}),e.jsx(Wr,{items:n.sections.projects.items,totalAvailable:n.sections.projects.summary.totalAvailable,t}),e.jsx(Mr,{items:n.sections.workItems.items,totalAvailable:n.sections.workItems.summary.totalAvailable,t}),e.jsx(Er,{items:n.sections.operatorInbox.items,totalAvailable:n.sections.operatorInbox.summary.totalAvailable,isTaskActionPending:r.isPending,onTaskAction:l=>r.mutate(l),t}),e.jsx(Ar,{items:n.sections.controlPlane.items,totalAvailable:n.sections.controlPlane.summary.totalAvailable,isTaskActionPending:r.isPending,onTaskAction:l=>r.mutate(l),t}),e.jsx(Or,{items:n.sections.recovery.items,totalAvailable:n.sections.recovery.summary.totalAvailable,t})]}):null]})}const Z=Xt("work"),_s=`${Z}/war-room`,ne=`${Z}/projects`,Q=`${Z}/tasks`,he=`${Z}/work-items`,nt=`${Z}/runs`,ie=`${Z}/missions`,le=`${Z}/schedules`,js=`${Z}/system-map`,xs=`${Z}/cockpit`,gs=`${Z}/broken-links`;function Ur(t){const s=t?.trim();return s?`${ne}/${encodeURIComponent(s)}`:ne}function Nt(t){const s=t?.trim();return s?`${Q}/${encodeURIComponent(s)}`:Q}function Ve(t){const s=t?.trim();return s?`${he}/${encodeURIComponent(s)}`:he}function ye(t,s){const a=t.trim()||"orphan",r=s.trim();return`${Q}/${encodeURIComponent(a)}/runs/${encodeURIComponent(r)}`}function bs(t){const s=t?.trim();return s?`${ie}/${encodeURIComponent(s)}`:ie}function Gr(t){const s=t?.trim();return s?`${le}/${encodeURIComponent(s)}`:le}function Qr(t){return t.startsWith(_s)}function Hr(t){return t===Q||t.startsWith(`${Q}/`)}function qr(t){return t.startsWith(ne)}function Vr(t){return t.startsWith(he)}function Yr(t){return t.startsWith(js)}function zr(t){return t.startsWith(xs)}function Jr(t){return t.startsWith(gs)}function Mt(t){return t===nt||t.startsWith(`${nt}/`)?!0:t.startsWith(`${Q}/`)&&/\/runs\//.test(t)}function Xr(t){return t===ie||t.startsWith(`${ie}/`)}function Zr(t){return t===le||t.startsWith(`${le}/`)}async function en(t,s,a){const r=await fetch(ia,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function tn(t,s,a){const r=await fetch(oa(t),{method:"DELETE",signal:a});return K(r,s)}const Ot=[{value:"blocks",label:"workTopdownLinkageViewKindBlocksLabel",help:"workTopdownLinkKindBlocksHelp"},{value:"blocked_by",label:"workTopdownLinkageViewKindBlockedByLabel",help:"workTopdownLinkKindBlockedByHelp"},{value:"related_to",label:"workTopdownLinkageViewKindRelatedToLabel",help:"workTopdownLinkKindRelatedToHelp"},{value:"duplicate_of",label:"workTopdownLinkageViewKindDuplicateOfLabel",help:"workTopdownLinkKindDuplicateOfHelp"},{value:"follows",label:"workTopdownLinkageViewKindFollowsLabel",help:"workTopdownLinkKindFollowsHelp"}],sn=new Set(["project","work_item","task"]),Ee=280;function Kt(t){return sn.has(t.kind)}function an({selfRef:t,graph:s,onClose:a,onCreated:r}){const n=m.useId(),o=m.useId(),i=m.useId(),l=m.useId(),c=m.useRef(null),h=U(),[u,d]=m.useState("blocks"),[w,y]=m.useState(""),[j,_]=m.useState(null),[x,L]=m.useState(""),[g,k]=m.useState(!1),[R,D]=m.useState(null),{t:S}=N();m.useEffect(()=>{c.current?.focus()},[]),m.useEffect(()=>{function P(A){A.key==="Escape"&&!g&&(A.stopPropagation(),a())}return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[a,g]);const C=m.useMemo(()=>{const P=Ue(t),A=w.trim().toLowerCase();return s.objects.filter(Kt).filter(F=>`${F.kind}:${F.sourceRecordId}`!==P).filter(F=>A.length===0?!0:F.title.toLowerCase().includes(A)||F.sourceRecordId.toLowerCase().includes(A)).slice(0,25)},[s.objects,t,w]),I=j?s.objects.find(P=>P.id===j)??null:null,b=Ot.find(P=>P.value===u);function T(P){P.target===P.currentTarget&&!g&&a()}async function v(P){if(P.preventDefault(),!I||g)return;if(!Kt(I)){D(S("workTopdownNewLinkErrorInvalidTarget"));return}const A=I.kind;if(A===t.recordFamily&&I.sourceRecordId===t.recordId){D(S("workTopdownNewLinkErrorSelfLink"));return}const F=x.trim();if(F.length>Ee){D(S("workTopdownNewLinkErrorNoteTooLong",{max:`${Ee}`}));return}k(!0),D(null);try{const f=await en({kind:u,source:t,target:{recordFamily:A,recordId:I.sourceRecordId},note:F.length===0?null:F},S("workTopdownNewLinkErrorFailed"));await h.invalidateQueries({queryKey:Y}),r?.(f.link.id),a()}catch(f){D(f instanceof Error?f.message:S("workTopdownNewLinkErrorFailed"))}finally{k(!1)}}const O=!I||g;return e.jsx("div",{className:"newLinkDialog__backdrop",role:"presentation",onClick:T,children:e.jsxs("div",{className:"newLinkDialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":n,children:[e.jsxs("header",{className:"newLinkDialog__header",children:[e.jsx("h2",{id:n,className:"newLinkDialog__heading",children:S("workTopdownNewLinkDialogTitle")}),e.jsx("button",{type:"button",className:"newLinkDialog__close","aria-label":S("workTopdownNewLinkClose"),onClick:a,disabled:g,children:"×"})]}),e.jsxs("form",{className:"newLinkDialog__form",onSubmit:v,children:[e.jsxs("p",{className:"newLinkDialog__sourceLine",children:[S("workTopdownNewLinkSourcePrefix")," ",e.jsx("strong",{children:ae(t.recordFamily,S)})," ",e.jsx("code",{children:t.recordId})]}),e.jsxs("label",{className:"newLinkDialog__field",htmlFor:o,children:[e.jsx("span",{className:"newLinkDialog__label",children:S("workTopdownNewLinkRelationLabel")}),e.jsx("select",{id:o,className:"newLinkDialog__select",value:u,onChange:P=>d(P.target.value),children:Ot.map(P=>e.jsx("option",{value:P.value,children:S(P.label)},P.value))}),e.jsx("span",{className:"newLinkDialog__hint",children:b?S(b.help):""})]}),e.jsxs("div",{className:"newLinkDialog__field",children:[e.jsx("label",{className:"newLinkDialog__label",htmlFor:i,children:S("workTopdownNewLinkTargetLabel")}),e.jsx("input",{ref:c,id:i,type:"text",className:"newLinkDialog__input",value:w,onChange:P=>{y(P.target.value),_(null)},placeholder:S("workTopdownNewLinkTargetSearchPlaceholder",{project:S("workTopdownAnchorProject"),workItem:S("workTopdownAnchorWorkItem"),task:S("workTopdownAnchorTask")}),autoComplete:"off"}),C.length===0?e.jsx("p",{className:"newLinkDialog__empty",children:S("workTopdownNewLinkNoMatches")}):e.jsx("ul",{className:"newLinkDialog__candidates",children:C.map(P=>{const A=j===P.id;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"newLinkDialog__candidate"+(A?" newLinkDialog__candidate--selected":""),onClick:()=>_(P.id),children:[e.jsx("span",{className:"newLinkDialog__candidateKind",children:ae(P.kind,S)}),e.jsx("span",{className:"newLinkDialog__candidateTitle",children:P.title})]})},P.id)})})]}),e.jsxs("label",{className:"newLinkDialog__field",htmlFor:l,children:[e.jsx("span",{className:"newLinkDialog__label",children:S("workTopdownNewLinkNoteLabel")}),e.jsx("textarea",{id:l,className:"newLinkDialog__textarea",value:x,onChange:P=>L(P.target.value),placeholder:S("workTopdownNewLinkNotePlaceholder"),rows:2,maxLength:Ee}),e.jsxs("span",{className:"newLinkDialog__charCount",children:[x.length,"/",Ee]})]}),R?e.jsx("p",{className:"newLinkDialog__error",role:"alert",children:R}):null,e.jsxs("footer",{className:"newLinkDialog__footer",children:[e.jsx("button",{type:"button",className:"newLinkDialog__cancelBtn",onClick:a,disabled:g,children:S("workTopdownNewLinkCancel")}),e.jsx("button",{type:"submit",className:"newLinkDialog__submitBtn",disabled:O,children:S(g?"workTopdownNewLinkSaving":"workTopdownLinkageAddAction")})]})]})]})})}const Ft={blocks:"workTopdownLinkageViewKindBlocksLabel",blocked_by:"workTopdownLinkageViewKindBlockedByLabel",related_to:"workTopdownLinkageViewKindRelatedToLabel",duplicate_of:"workTopdownLinkageViewKindDuplicateOfLabel",follows:"workTopdownLinkageViewKindFollowsLabel"},rn=["blocks","blocked_by","related_to","duplicate_of","follows"],nn={blocks:"workTopdownLinkageViewKindBlocksEmpty",blocked_by:"workTopdownLinkageViewKindBlockedByEmpty",related_to:"workTopdownLinkageViewKindRelatedToEmpty",duplicate_of:"workTopdownLinkageViewKindDuplicateOfEmpty",follows:"workTopdownLinkageViewKindFollowsEmpty"};function on(t){switch(t.recordFamily){case"project":return Ur(t.recordId);case"work_item":return Ve(t.recordId);case"task":return Nt(t.recordId)}}function ft({selfRef:t,graph:s,indexes:a}){const{t:r}=N(),[n,o]=m.useState(!1),i=Ue(t),l=s.linksByEndpoint[i]??[],c=new Map;for(const u of l){const d=c.get(u.kind)??[];d.push(u),c.set(u.kind,d)}const h=rn.filter(u=>c.has(u));return e.jsxs("section",{className:"linkageSection",children:[e.jsxs("header",{className:"linkageSection__header",children:[e.jsx("h2",{children:r("workTopdownLinkageTitle")}),e.jsx("span",{className:"linkageSection__count",children:l.length}),e.jsxs("button",{type:"button",className:"linkageSection__addBtn",onClick:()=>o(!0),children:["+ ",r("workTopdownLinkageAddAction")]})]}),l.length===0?e.jsxs("p",{className:"linkageSection__empty",children:[r("workTopdownLinkageNoLinksYetPrefix")," ",e.jsx("strong",{children:r("workTopdownLinkageAddAction")})," ",r("workTopdownLinkageNoLinksYetSuffix")]}):h.map(u=>e.jsx(ln,{views:c.get(u)??[],kind:u,indexes:a},u)),n?e.jsx(an,{selfRef:t,graph:s,onClose:()=>o(!1)}):null]})}function ln({views:t,kind:s,indexes:a}){const{t:r}=N();return t.length===0?e.jsxs("div",{className:`linkageSection__group linkageSection__group--${s}`,children:[e.jsx("h3",{className:"linkageSection__groupLabel",children:r(Ft[s])}),e.jsx("p",{className:"linkageSection__groupEmpty",children:r(nn[s])})]}):e.jsxs("div",{className:`linkageSection__group linkageSection__group--${s}`,children:[e.jsx("h3",{className:"linkageSection__groupLabel",children:r(Ft[s])}),e.jsx("ul",{className:"linkageSection__list",children:t.map(n=>{const o=Ue(n.otherEndpoint),i=a.objectsByCoreRef.get(o);return i?e.jsxs("li",{className:"linkageSection__row",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--small projectsList__dot--${i.status}`,"aria-hidden":"true"}),e.jsx(B,{className:"linkageSection__title",to:on(n.otherEndpoint),children:i.title}),e.jsx("span",{className:"linkageSection__kindBadge",children:ae(i.kind,r)}),n.note?e.jsx("span",{className:"linkageSection__note",children:n.note}):null]},n.linkId):null})})]})}const _e=["projects"];async function cn(t){const s=await fetch(Zt,{headers:{accept:"application/json"}});if(!s.ok)throw me(s,t);return await s.json()}function Ne(){const{t}=N();return te({queryKey:_e,queryFn:()=>cn(t)})}function ys(t,s){const a=mn(t);if(!a)return null;const r=a.hostname.toLowerCase(),n=a.pathname.split("/").filter(Boolean),o=dn(r);if(o==="github")return Le(n,"github",["issues"]);if(o==="gitlab")return $t(n);const i=hn(a);if(i)return{externalId:i,externalType:"ticket",provider:"bugzilla"};const l=o??s;return l==="redmine"?un(n):l==="gitea"?Le(n,"gitea",["issues"]):l==="gitlab"?$t(n):l==="github"?Le(n,"github",["issues"]):null}function dn(t){return t==="github.com"||t.endsWith(".github.com")?"github":t==="gitlab.com"||t.endsWith(".gitlab.com")?"gitlab":t.includes("bugzilla")?"bugzilla":t.includes("redmine")?"redmine":t.includes("gitea")?"gitea":null}function $t(t){const s=t.indexOf("-");if(s>=0&&t[s+1]==="issues"){const a=t[s+2];return a?{externalId:a,externalType:"issue",provider:"gitlab"}:null}return Le(t,"gitlab",["issues"])}function un(t){const s=Le(t,"redmine",["issues"]);if(s)return{...s,externalType:"ticket"};const a=t.indexOf("projects"),r=a>=0?t[a+1]:null;return r?{externalId:r,externalType:"project",provider:"redmine"}:null}function Le(t,s,a){const r=t.findIndex(o=>a.includes(o)),n=r>=0?t[r+1]:null;return n?{externalId:n,externalType:"issue",provider:s}:null}function hn(t){return!t.pathname.endsWith("/show_bug.cgi")&&t.pathname!=="/show_bug.cgi"?null:t.searchParams.get("id")?.trim()||null}function mn(t){try{const s=t.trim();if(!s)return null;const a=new URL(s);return(a.protocol==="http:"||a.protocol==="https:")&&a.username===""&&a.password===""?a:null}catch{return null}}function Ns({localKind:t,localId:s,defaultExternalType:a="issue",errorFallback:r,invalidateQueryKeys:n,onClose:o,title:i}){const{t:l}=N(),c=U(),h=m.useId(),u=m.useId(),d=m.useId(),w=m.useId(),y=m.useId(),j=m.useId(),_=m.useRef(null),[x,L]=m.useState("github"),[g,k]=m.useState(a),[R,D]=m.useState(""),[S,C]=m.useState(""),[I,b]=m.useState("pull"),T=$({mutationFn:()=>Xa({localKind:t,localId:s,provider:x,externalType:g,externalId:R.trim(),externalUrl:S.trim()||null,syncDirection:I},r),onSuccess:async()=>{await Promise.all(n.map(f=>c.invalidateQueries({queryKey:f}))),o()}}),v=T.isPending,O=T.error?V(T.error,r,l):null;m.useEffect(()=>{_.current?.focus()},[]),m.useEffect(()=>{function f(G){G.key==="Escape"&&(G.stopPropagation(),o())}return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[o]);function P(f){f.target===f.currentTarget&&o()}function A(f){C(f);const G=ys(f,x);G&&(G.provider&&L(G.provider),G.externalType&&k(G.externalType),G.externalId&&R.trim().length===0&&D(G.externalId))}function F(f){f.preventDefault(),!(!R.trim()||v)&&T.mutate()}return e.jsx("div",{className:"newProjectDialog__backdrop",role:"presentation",onClick:P,children:e.jsxs("div",{className:"newProjectDialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":`${h}-heading`,children:[e.jsxs("header",{className:"newProjectDialog__header",children:[e.jsx("h2",{id:`${h}-heading`,className:"newProjectDialog__heading",children:i}),e.jsx("button",{type:"button",className:"newProjectDialog__close","aria-label":l("workExternalLinkCloseLabel"),onClick:o,children:"×"})]}),e.jsxs("form",{className:"newProjectDialog__form",onSubmit:F,children:[e.jsxs("label",{className:"newProjectDialog__field",htmlFor:u,children:[e.jsx("span",{className:"newProjectDialog__label",children:l("workExternalProviderLabel")}),e.jsxs("select",{id:u,className:"newProjectDialog__select",value:x,onChange:f=>L(f.target.value),children:[e.jsx("option",{value:"github",children:l("workExternalProviderGithub")}),e.jsx("option",{value:"gitlab",children:l("workExternalProviderGitlab")}),e.jsx("option",{value:"gitea",children:l("workExternalProviderGitea")}),e.jsx("option",{value:"redmine",children:l("workExternalProviderRedmine")}),e.jsx("option",{value:"bugzilla",children:l("workExternalProviderBugzilla")})]})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:d,children:[e.jsx("span",{className:"newProjectDialog__label",children:l("workExternalTypeLabel")}),e.jsxs("select",{id:d,className:"newProjectDialog__select",value:g,onChange:f=>k(f.target.value),children:[e.jsx("option",{value:"issue",children:l("workExternalTypeIssue")}),e.jsx("option",{value:"ticket",children:l("workExternalTypeTicket")}),e.jsx("option",{value:"project",children:l("workExternalTypeProject")})]})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:w,children:[e.jsxs("span",{className:"newProjectDialog__label",children:[l("workExternalIdLabel"),e.jsx("span",{className:"newProjectDialog__required","aria-hidden":"true",children:"*"})]}),e.jsx("input",{ref:_,id:w,type:"text",className:"newProjectDialog__input",value:R,onChange:f=>D(f.target.value),placeholder:l("workExternalIdPlaceholder"),required:!0,maxLength:200})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:y,children:[e.jsx("span",{className:"newProjectDialog__label",children:l("workExternalUrlLabel")}),e.jsx("input",{id:y,type:"url",className:"newProjectDialog__input",value:S,onChange:f=>A(f.target.value),placeholder:l("workExternalUrlPlaceholder"),maxLength:1e3})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:j,children:[e.jsx("span",{className:"newProjectDialog__label",children:l("workExternalSyncDirectionLabel")}),e.jsxs("select",{id:j,className:"newProjectDialog__select",value:I,onChange:f=>b(f.target.value),children:[e.jsx("option",{value:"pull",children:l("workExternalSyncPull")}),e.jsx("option",{value:"push",children:l("workExternalSyncPush")}),e.jsx("option",{value:"bidirectional",children:l("workExternalSyncBidirectional")})]})]}),O?e.jsx("p",{className:"newProjectDialog__error",role:"alert",children:O}):null,e.jsxs("footer",{className:"newProjectDialog__footer",children:[e.jsx("button",{type:"button",className:"newProjectDialog__cancelBtn",onClick:o,disabled:v,children:l("workExternalCancelButton")}),e.jsx("button",{type:"submit",className:"newProjectDialog__submitBtn",disabled:R.trim().length===0||v,children:l(v?"workExternalSubmitBusyLabel":"workExternalSubmitLabel")})]})]})]})})}function pn({projectId:t,onClose:s}){const{t:a}=N();return e.jsx(Ns,{localKind:"project",localId:t,defaultExternalType:"project",errorFallback:a("workExternalLinkError"),invalidateQueryKeys:[_e,Y],onClose:s,title:a("workExternalLinkDialogTitle")})}function kn({addLabel:t,bindings:s,emptyLabel:a,onAddClick:r,onRemoveBinding:n,removeDisabled:o}){const{t:i}=N();return s.length===0&&!r?null:e.jsxs("section",{className:"projectDetail__section projectDetail__external",children:[e.jsxs("header",{className:"projectDetail__sectionHeader",children:[e.jsx("h2",{children:i("workTopdownExternalTitle")}),e.jsx("span",{className:"projectDetail__sectionCount",children:s.length}),r?e.jsx("button",{type:"button",className:"projectDetail__sectionAction",onClick:r,children:t??i("workExternalLinkTrackerAction")}):null]}),s.length===0?e.jsx("p",{className:"projectDetail__empty",children:a??i("workExternalEmpty")}):e.jsx("ul",{className:"projectDetail__externalRefs",children:s.map(l=>{const c=ee(l),h=bt(l.externalUrl)?l.externalUrl:null;return e.jsxs("li",{className:"projectDetail__externalRef",children:[e.jsx("span",{className:"projectDetail__externalProvider",children:l.provider}),e.jsxs("span",{className:"projectDetail__externalMain",children:[h?e.jsx("a",{className:"projectDetail__externalLink",href:h,target:"_blank",rel:"noreferrer",children:c}):e.jsx("span",{className:"projectDetail__externalLabel",children:c}),e.jsxs("span",{className:"projectDetail__externalMeta",children:[i("workTopdownExternalSyncLabel",{syncDirection:l.syncDirection}),l.externalUpdatedAt?` - ${i("workTopdownExternalUpdatedLabel",{updatedAt:W(l.externalUpdatedAt,i)})}`:""]}),n?e.jsx("button",{type:"button",className:"projectDetail__externalRemove",onClick:()=>n(l),disabled:o,"aria-label":i("workExternalUnlinkAriaLabel",{label:c}),children:i("workExternalUnlinkAction")}):null]})]},`${l.provider}:${l.externalType}:${l.externalId}`)})})]})}function wn(){const{t}=N(),{projectId:s}=xe(),a=z(),r=U(),[n,o]=m.useState(!1),i=ke(t("workGraphLoadErrorFallback")).data??pe,l=m.useMemo(()=>be(i),[i]),c=Ne(),h=s?c.data?.projects.find(k=>k.id===s):void 0,u=$({mutationFn:async k=>{await is(k,t("workProjectDeleteError"))},onSuccess:async()=>{await r.invalidateQueries({queryKey:_e}),a(ne)}}),d=$({mutationFn:async k=>{await ls({localKind:"project",localId:k.projectId,provider:k.binding.provider,externalType:k.binding.externalType,externalId:k.binding.externalId},t("workExternalUnlinkError"))},onSuccess:async()=>{await Promise.all([r.invalidateQueries({queryKey:_e}),r.invalidateQueries({queryKey:Y})])}}),w=()=>{h&&window.confirm(t("workProjectDeleteConfirmation",{projectTitle:h.title}))&&u.mutate(h.id)},y=k=>{if(!h)return;const R=ee(k);window.confirm(t("workExternalUnlinkConfirmation",{label:R}))&&d.mutate({binding:k,projectId:h.id})};if(c.isPending)return e.jsx(_n,{});if(!h)return e.jsx(jn,{projectId:s??null});const j=u.error?V(u.error,t("workProjectDeleteError"),t):null,_=d.error?V(d.error,t("workExternalUnlinkError"),t):null,x=i.objects.filter(k=>k.kind==="work_item"&&k.linkedProjectId===h.id),L=i.objects.filter(k=>k.kind==="task"&&k.linkedProjectId===h.id),g=i.objects.filter(k=>k.kind==="activity"&&k.linkedProjectId===h.id).sort((k,R)=>R.updatedAt.localeCompare(k.updatedAt));return e.jsxs("div",{className:"projectDetail",children:[e.jsxs("header",{className:"channelTopBar projectDetailTopBar",children:[e.jsx("div",{className:"channelTopBarStart projectDetailTopBar__start",children:e.jsxs(B,{to:"..",relative:"path",className:"projectDetailTopBar__back","aria-label":t("workProjectBackArrowLabel"),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M7.5 2L3.5 6l4 4"})}),e.jsx("span",{children:t("workProjectBackLabel")})]})}),e.jsxs("div",{className:"channelTopBarCenter projectDetailTopBar__center",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--${h.status}`,"aria-hidden":"true"}),e.jsx("h1",{className:"channelTopBarTitle projectDetailTopBar__title",children:h.title})]}),e.jsxs("div",{className:"channelTopBarEnd projectDetailTopBar__end",children:[re(h.attention,t)?e.jsx("span",{className:`projectDetail__attention projectDetail__attention--${h.attention}`,children:re(h.attention,t)}):null,e.jsx("span",{className:`projectsList__statusPill projectsList__statusPill--${h.status}`,children:M(h.status,t)}),e.jsx("span",{className:"projectDetailTopBar__updated",children:t("workProjectUpdatedAtPrefix",{updatedAt:W(h.updatedAt,t)})}),e.jsx("button",{type:"button",className:"projectDetailTopBar__action projectDetailTopBar__action--destructive",onClick:w,disabled:u.isPending,"aria-label":t("workProjectDeleteLabel"),children:u.isPending?t("workProjectDeleteLabelBusy"):t("workProjectDeleteLabel")})]})]}),e.jsxs("main",{className:"projectDetail__main",children:[j?e.jsx("p",{className:"projectDetail__error",role:"alert",children:j}):null,_?e.jsx("p",{className:"projectDetail__error",role:"alert",children:_}):null,e.jsxs("section",{className:"projectDetail__section projectDetail__overview",children:[e.jsx("header",{className:"projectDetail__sectionHeader",children:e.jsx("h2",{children:t("workProjectOverviewTitle")})}),e.jsxs("dl",{className:"projectDetail__overviewList",children:[h.summary?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:t("workProjectSummaryLabel")}),e.jsx("dd",{children:h.summary})]}):null,e.jsx("dt",{children:t("workProjectOwnerLabel")}),e.jsx("dd",{children:h.ownerName}),h.primaryConversationId?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:t("workProjectConversationLabel")}),e.jsx("dd",{children:e.jsx("span",{className:"projectDetail__convoTitle",children:h.primaryConversationTitle??h.primaryConversationId})})]}):null]})]}),e.jsx(kn,{bindings:h.externalBindings??[],onAddClick:()=>o(!0),onRemoveBinding:y,removeDisabled:d.isPending}),e.jsx(Ut,{title:t("workProjectWorkItemsTitle"),items:x,emptyLabel:t("workProjectNoWorkItems")}),e.jsx(Ut,{title:t("workProjectTasksTitle"),items:L,emptyLabel:t("workProjectNoTasks")}),e.jsx(ft,{selfRef:{recordFamily:"project",recordId:h.id},graph:i,indexes:l}),e.jsxs("section",{className:"projectDetail__section",children:[e.jsxs("header",{className:"projectDetail__sectionHeader",children:[e.jsx("h2",{children:t("workProjectActivityTitle")}),e.jsx("span",{className:"projectDetail__sectionCount",children:g.length})]}),g.length===0?e.jsx("p",{className:"projectDetail__empty",children:t("workProjectNoActivity")}):e.jsx("ul",{className:"projectDetail__activity",children:g.map(k=>e.jsxs("li",{className:"projectDetail__activityRow",children:[e.jsx("span",{className:"projectDetail__activityWhen",children:W(k.updatedAt,t)}),e.jsx("span",{className:"projectDetail__activityTitle",children:k.title}),k.summary?e.jsx("span",{className:"projectDetail__activitySummary",children:k.summary}):null]},k.id))})]})]}),n?e.jsx(pn,{projectId:h.id,onClose:()=>o(!1)}):null]})}function Ut({title:t,items:s,emptyLabel:a}){const{t:r}=N();return e.jsxs("section",{className:"projectDetail__section",children:[e.jsxs("header",{className:"projectDetail__sectionHeader",children:[e.jsx("h2",{children:t}),e.jsx("span",{className:"projectDetail__sectionCount",children:s.length})]}),s.length===0?e.jsx("p",{className:"projectDetail__empty",children:a}):e.jsx("ul",{className:"projectDetail__items",children:s.map(n=>e.jsxs("li",{className:"projectDetail__item",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--small projectsList__dot--${n.status}`,"aria-hidden":"true"}),e.jsx("span",{className:"projectDetail__itemKind",children:ae(n.kind,r)}),e.jsx("span",{className:"projectDetail__itemTitle",children:n.title}),re(n.attention,r)?e.jsx("span",{className:`projectDetail__itemAttention projectDetail__itemAttention--${n.attention}`,children:re(n.attention,r)}):null,e.jsx("span",{className:"projectDetail__itemStatus",children:M(n.status,r)}),n.ownerRole?e.jsx("span",{className:"projectDetail__itemOwner",children:ge(n.ownerRole,r)}):null]},n.id))})]})}function _n(){const{t}=N();return e.jsxs("div",{className:"projectDetail",children:[e.jsx("header",{className:"channelTopBar projectDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart projectDetailTopBar__start",children:e.jsx(B,{to:"..",relative:"path",className:"projectDetailTopBar__back",children:e.jsx("span",{children:t("workProjectBackArrowLabel")})})})}),e.jsx("main",{className:"projectDetail__main",children:e.jsx("p",{className:"projectDetail__empty",children:t("workProjectLoadingLabel")})})]})}function jn({projectId:t}){const{t:s}=N(),a=t??s("workProjectMissingIdLabel");return e.jsxs("div",{className:"projectDetail",children:[e.jsx("header",{className:"channelTopBar projectDetailTopBar",children:e.jsxs("div",{className:"channelTopBarStart projectDetailTopBar__start",children:[e.jsx(B,{to:"..",relative:"path",className:"projectDetailTopBar__back",children:e.jsx("span",{children:s("workProjectBackArrowLabel")})}),e.jsx("span",{className:"projectDetailTopBar__separator","aria-hidden":"true",children:"/"}),e.jsx("h1",{className:"channelTopBarTitle projectDetailTopBar__title",children:s("workProjectNotFoundTitle")})]})}),e.jsx("main",{className:"projectDetail__main",children:e.jsxs("p",{className:"projectDetail__empty",children:[s("workProjectNotFoundPrefix")," ",e.jsx("code",{children:a})," ",s("workProjectNotFoundSuffix")]})})]})}async function xn(t,s){return{id:(await Ya({title:t.title,summary:t.summary,status:t.status},s)).project.id}}const gn=["planned","active","paused","archived"];function bn({onClose:t}){const{t:s}=N(),a=z(),r=U(),n=m.useId(),o=m.useId(),i=m.useId(),l=m.useRef(null),[c,h]=m.useState(""),[u,d]=m.useState(""),[w,y]=m.useState("planned"),j=$({mutationFn:k=>xn(k,s("workNewProjectCreateError")),onSuccess:async k=>{await r.invalidateQueries({queryKey:_e}),t(),a(`${ne}/${k.id}`)}}),_=j.isPending,x=j.error?V(j.error,s("workNewProjectCreateError"),s):null;m.useEffect(()=>{l.current?.focus()},[]),m.useEffect(()=>{function k(R){R.key==="Escape"&&(R.stopPropagation(),t())}return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[t]);function L(k){k.target===k.currentTarget&&t()}function g(k){k.preventDefault();const R=c.trim();!R||_||j.mutate({title:R,summary:u.trim()||null,status:w})}return e.jsx("div",{className:"newProjectDialog__backdrop",role:"presentation",onClick:L,children:e.jsxs("div",{className:"newProjectDialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":`${n}-heading`,children:[e.jsxs("header",{className:"newProjectDialog__header",children:[e.jsx("h2",{id:`${n}-heading`,className:"newProjectDialog__heading",children:s("workNewProjectTitle")}),e.jsx("button",{type:"button",className:"newProjectDialog__close","aria-label":s("workNewProjectCloseLabel"),onClick:t,children:"×"})]}),e.jsxs("form",{className:"newProjectDialog__form",onSubmit:g,children:[e.jsxs("label",{className:"newProjectDialog__field",htmlFor:n,children:[e.jsxs("span",{className:"newProjectDialog__label",children:[s("workNewProjectTitleLabel"),e.jsx("span",{className:"newProjectDialog__required","aria-hidden":"true",children:"*"})]}),e.jsx("input",{ref:l,id:n,type:"text",className:"newProjectDialog__input",value:c,onChange:k=>h(k.target.value),placeholder:s("workNewProjectTitlePlaceholder"),required:!0,maxLength:120})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:o,children:[e.jsx("span",{className:"newProjectDialog__label",children:s("workNewProjectSummaryLabel")}),e.jsx("textarea",{id:o,className:"newProjectDialog__textarea",value:u,onChange:k=>d(k.target.value),placeholder:s("workNewProjectSummaryPlaceholder"),rows:3,maxLength:400})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:i,children:[e.jsx("span",{className:"newProjectDialog__label",children:s("workNewProjectStatusLabel")}),e.jsx("select",{id:i,className:"newProjectDialog__select",value:w,onChange:k=>y(k.target.value),children:gn.map(k=>e.jsx("option",{value:k,children:M(k,s)},k))})]}),x?e.jsx("p",{className:"newProjectDialog__error",role:"alert",children:x}):null,e.jsxs("footer",{className:"newProjectDialog__footer",children:[e.jsx("button",{type:"button",className:"newProjectDialog__cancelBtn",onClick:t,disabled:_,children:s("workNewProjectCancelButton")}),e.jsx("button",{type:"submit",className:"newProjectDialog__submitBtn",disabled:c.trim().length===0||_,children:s(_?"workNewProjectSubmitBusyLabel":"workNewProjectSubmitLabel")})]})]})]})})}function yn(){const{t}=N(),s=Ne(),a=s.data?.projects??[],[r,n]=m.useState(!1);return e.jsxs("div",{className:"projectsList",children:[e.jsxs("header",{className:"channelTopBar projectsListTopBar",children:[e.jsxs("div",{className:"channelTopBarStart projectsListTopBar__start",children:[e.jsx("h1",{className:"channelTopBarTitle projectsListTopBar__title",children:t("workProjectsListTitle")}),e.jsx("span",{className:"projectsListTopBar__count",children:a.length})]}),e.jsx("div",{className:"channelTopBarCenter projectsListTopBar__center"}),e.jsx("div",{className:"channelTopBarEnd projectsListTopBar__end",children:e.jsxs("button",{type:"button",className:"projectsListTopBar__addBtn",onClick:()=>n(!0),"aria-label":t("workProjectsCreateNewProjectAriaLabel"),children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M7 2v10"}),e.jsx("path",{d:"M2 7h10"})]}),e.jsx("span",{children:t("workProjectsNewAction")})]})})]}),e.jsx("main",{className:"projectsList__main",children:s.isPending?e.jsx("p",{className:"projectsList__empty",children:t("workProjectsListLoading")}):s.isError?e.jsx("p",{className:"projectsList__empty",children:t("workProjectsListLoadError",{errorMessage:String(s.error.message)})}):a.length===0?e.jsxs("p",{className:"projectsList__empty",children:[t("workProjectsListEmptyIntro")," ",e.jsx("strong",{children:t("workProjectsNewAction")})," ",t("workProjectsListEmptySuffix")]}):e.jsx("ul",{className:"projectsList__list",children:a.map(o=>e.jsx("li",{className:"projectsList__row",children:e.jsxs(B,{to:o.id,className:"projectsList__rowLink","aria-label":t("workProjectsOpenProjectAriaLabel",{projectTitle:o.title}),children:[e.jsxs("div",{className:"projectsList__rowMain",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--${o.status}`,"aria-hidden":"true"}),e.jsxs("div",{className:"projectsList__rowText",children:[e.jsx("span",{className:"projectsList__rowTitle",children:o.title}),o.summary?e.jsx("span",{className:"projectsList__rowSummary",children:o.summary}):null]})]}),e.jsxs("div",{className:"projectsList__rowMeta",children:[o.attentionDecisionCount>0?e.jsx("span",{className:"projectsList__pip projectsList__pip--decision",children:t("workProjectsDecisionPill",{count:o.attentionDecisionCount,pluralSuffix:o.attentionDecisionCount===1?"":"s"})}):null,o.attentionBlockedCount>0?e.jsx("span",{className:"projectsList__pip projectsList__pip--blocked",children:t("workProjectsBlockedPill",{count:o.attentionBlockedCount})}):null,(o.externalBindings??[]).slice(0,2).map(i=>e.jsx("span",{className:"projectsList__externalChip",title:t("workTopdownExternalBindingTooltip",{externalBinding:ee(i)}),children:ee(i)},`${i.provider}:${i.externalType}:${i.externalId}`)),(o.externalBindings?.length??0)>2?e.jsxs("span",{className:"projectsList__externalChip",children:["+",(o.externalBindings?.length??0)-2]}):null,e.jsxs("span",{className:"projectsList__metric",children:[e.jsx("strong",{children:o.linkedWorkItemCount})," ",t("workProjectsWorkItemsAbbrev")]}),e.jsxs("span",{className:"projectsList__metric",children:[e.jsx("strong",{children:o.linkedTaskCount})," ",t("workProjectsTasksLabel")]}),e.jsx("span",{className:"projectsList__metric projectsList__metric--muted",children:W(o.updatedAt,t)}),e.jsx("span",{className:`projectsList__statusPill projectsList__statusPill--${o.status}`,children:M(o.status,t)})]})]})},o.id))})}),r?e.jsx(bn,{onClose:()=>n(!1)}):null]})}const ot=["task-golden-path"];async function Nn(t,s){const a=await fetch(`${mt}/${encodeURIComponent(t)}`,{headers:{accept:"application/json"}});if(!a.ok)throw me(a,s);return(await a.json()).goldenPath}function fn(t){const{t:s}=N();return te({queryKey:[...ot,t],queryFn:()=>Nn(t,s),enabled:typeof t=="string"&&t.length>0})}const Tn={received:p.workTaskGoldenPathStageReceived,scope_proposed:p.workTaskGoldenPathStageScopeproposed,execution_authorized:p.workTaskGoldenPathStageExecutionauthorized,admitted:p.workTaskGoldenPathStageAdmitted,running:p.workTaskGoldenPathStageRunning,decision_needed:p.workTaskGoldenPathStageDecisionneeded,result_ready:p.workTaskGoldenPathStageResultready,publish_authorized:p.workTaskGoldenPathStagePublishauthorized,delivered:p.workTaskGoldenPathStageDelivered,failed:p.workTaskGoldenPathStageFailed,cancelled:p.workTaskGoldenPathStageCancelled};function J({label:t,children:s}){return e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function Ln({attempt:t}){const{t:s}=N();return e.jsxs("li",{className:"taskDetail__goldenPathAttempt",children:[e.jsx("span",{children:s("workTaskGoldenPathAttempt",{purpose:t.purpose,state:t.state,count:String(t.attemptCount)})}),t.lastErrorCode?e.jsx("span",{className:"taskDetail__goldenPathError",children:t.lastErrorCode}):null]})}function vn({taskId:t}){const{t:s}=N(),a=U(),r=fn(t),[n,o]=m.useState(!1),[i,l]=m.useState(null),c=r.data??null;if(c===null)return null;const h=c.recoveryActions.includes("retry_delivery"),u=c.recoveryActions.includes("retry_run"),d=c.recoveryActions.includes("resume_run");async function w(k){o(!0),l(null);try{const R=await rr(t,k);R.status!=="redrivable"&&l(s("workTaskGoldenPathLifecycleFailed",{reason:R.reason??R.status})),await a.invalidateQueries({queryKey:ot})}catch(R){l(R instanceof Error?R.message:String(R))}finally{o(!1)}}async function y(){o(!0),l(null);try{const k=await nr(t);k.status!=="delivered"&&l(s("workTaskGoldenPathRetryFailed",{reason:k.reason??k.status})),await a.invalidateQueries({queryKey:ot})}catch(k){l(k instanceof Error?k.message:String(k))}finally{o(!1)}}const{scope:j,source:_,authorization:x,evidence:L,delivery:g}=c;return e.jsxs("section",{className:"taskDetail__section taskDetail__goldenPath",children:[e.jsxs("header",{className:"taskDetail__sectionHeader",children:[e.jsx("h2",{children:s("workTaskGoldenPathTitle")}),e.jsx("span",{className:"taskDetail__sectionCount",children:s(Tn[c.stage])})]}),e.jsx("p",{className:"taskDetail__goldenPathRationale",children:c.stageRationale}),e.jsxs("dl",{className:"taskDetail__overviewList",children:[e.jsxs(J,{label:s("workTaskGoldenPathBinding"),children:[_.transport," · ",_.bindingId,_.present?null:e.jsxs("span",{className:"taskDetail__goldenPathError",children:[" ","(",s("workTaskGoldenPathBindingMissing"),")"]})]}),e.jsxs(J,{label:s("workTaskGoldenPathRevision"),children:[j.revision," · ",e.jsx("code",{children:j.digest.slice(0,12)})]}),e.jsx(J,{label:s("workTaskGoldenPathTarget"),children:j.targetLabel}),j.workspacePath?e.jsx(J,{label:s("workTaskGoldenPathWorkspace"),children:e.jsx("code",{children:j.workspacePath})}):null,e.jsx(J,{label:s("workTaskGoldenPathDoneWhen"),children:j.acceptanceCriteria.join("; ")}),e.jsx(J,{label:s("workTaskGoldenPathDelivery"),children:j.deliveryMode}),c.outstandingGates.length>0?e.jsx(J,{label:s("workTaskGoldenPathGates"),children:c.outstandingGates.join(", ")}):null,e.jsx(J,{label:s("workTaskGoldenPathAuthorizationTitle"),children:x.authorizedByActorId&&x.authorizedAt?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:s("workTaskGoldenPathAuthorizedBy",{actor:x.authorizedByActorId,at:x.authorizedAt})}),e.jsx("br",{}),e.jsx("span",{children:s("workTaskGoldenPathAuthorizedFrom",{binding:x.bindingId??_.bindingId,revision:String(x.proposalRevision??j.revision)})})]}):s("workTaskGoldenPathNotAuthorized")})]}),c.permissionDenial?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:s("workTaskGoldenPathPermissionDenial")}),e.jsx("p",{className:"taskDetail__goldenPathError",children:s("workTaskGoldenPathPermissionDenialDetail",{tool:c.permissionDenial.toolName,code:c.permissionDenial.code})})]}):null,c.blockers.length>0?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:s("workTaskGoldenPathBlockers")}),e.jsx("ul",{className:"taskDetail__goldenPathBlockers",children:c.blockers.map(k=>e.jsx("li",{children:k},k))})]}):null,e.jsx("h3",{children:s("workTaskGoldenPathEvidenceTitle")}),L.outcomeStatus===null&&L.artifacts.length===0?e.jsx("p",{className:"taskDetail__empty",children:s("workTaskGoldenPathNoEvidence")}):e.jsxs("dl",{className:"taskDetail__overviewList",children:[L.commitId?e.jsxs(J,{label:s("workTaskGoldenPathCommit"),children:[e.jsx("code",{children:L.commitId}),L.changeSummary?` — ${L.changeSummary}`:null]}):null,L.validation?e.jsxs(J,{label:s("workTaskGoldenPathValidation"),children:[L.validation.command," — ",L.validation.passed?s("workTaskGoldenPathValidationPassed"):s("workTaskGoldenPathValidationFailed")]}):null,L.artifacts.length>0?e.jsx(J,{label:s("workTaskGoldenPathArtifacts"),children:L.artifacts.map(k=>`${k.title} (${k.status})`).join(", ")}):null,L.unmetCriteria.length>0?e.jsx(J,{label:s("workTaskGoldenPathUnmet"),children:L.unmetCriteria.join("; ")}):null]}),e.jsx("h3",{children:s("workTaskGoldenPathDeliveryTitle")}),g.attempts.length===0?e.jsx("p",{className:"taskDetail__empty",children:s("workTaskGoldenPathNoAttempts")}):e.jsx("ul",{className:"taskDetail__goldenPathAttempts",children:g.attempts.map(k=>e.jsx(Ln,{attempt:k},k.idempotencyKey))}),g.receipt?.externalMessageRef&&g.receipt.sentAt?e.jsx("p",{className:"taskDetail__goldenPathReceipt",children:s("workTaskGoldenPathReceipt",{messageId:g.receipt.externalMessageRef,at:g.receipt.sentAt})}):null,e.jsxs("div",{className:"taskDetail__goldenPathActions",children:[h?e.jsx("button",{type:"button",className:"taskDetailTopBar__action",onClick:()=>{y()},disabled:n,children:s(n?"workTaskGoldenPathRetrying":"workTaskGoldenPathRetryDelivery")}):null,u?e.jsx("button",{type:"button",className:"taskDetailTopBar__action",onClick:()=>{w("retry")},disabled:n,children:s("workTaskGoldenPathRetryRun")}):null,d?e.jsx("button",{type:"button",className:"taskDetailTopBar__action",onClick:()=>{w("resume")},disabled:n,children:s("workTaskGoldenPathResumeRun")}):null]}),i?e.jsx("p",{className:"taskDetail__error",role:"alert",children:i}):null]})}const Ye=["runs"];async function Dn(t){const s=await fetch(la,{headers:{accept:"application/json"}});if(!s.ok)throw me(s,t);return await s.json()}function ze(){const{t}=N();return te({queryKey:Ye,queryFn:()=>Dn(t)})}const je=["workItems"];async function Sn(t){const s=await fetch(es,{headers:{accept:"application/json"}});if(!s.ok)throw me(s,t);return await s.json()}function Je(){const{t}=N();return te({queryKey:je,queryFn:()=>Sn(t)})}function Rn(){const{taskId:t}=xe(),s=z(),a=U(),{t:r}=N(),n=ke(r("workGraphLoadErrorFallback")).data??pe,o=m.useMemo(()=>be(n),[n]),i=Se(),l=Ne(),c=Je(),h=ze(),u=i.data?.tasks??[],d=t?u.find(f=>f.id===t):void 0,w=$({mutationFn:async f=>{await tr(f,r("workTaskDeleteError"))},onSuccess:async()=>{await a.invalidateQueries({queryKey:we}),s(Q)}}),y=$({mutationFn:async f=>{await sr(f.taskId,{action:f.action,decidedByActorId:f.decidedByActorId},r("workTaskApprovalDecisionError"))},onSuccess:async()=>{await Promise.all([a.invalidateQueries({queryKey:we}),a.invalidateQueries({queryKey:De}),a.invalidateQueries({queryKey:Y})])}}),j=$({mutationFn:async f=>ar(f,r("workTaskStartRunError")),onSuccess:async f=>{await Promise.all([a.invalidateQueries({queryKey:we}),a.invalidateQueries({queryKey:Ye}),a.invalidateQueries({queryKey:De}),a.invalidateQueries({queryKey:Y})]),s(ye(f.run.taskId??f.task.id,f.run.id))}}),_=()=>{d&&window.confirm(r("workTaskDeleteConfirmation",{taskTitle:d.title}))&&w.mutate(d.id)},x=f=>{d&&y.mutate({taskId:d.id,action:f,decidedByActorId:d.ownerActorId})},L=()=>{!d||d.status!=="approved"||j.mutate(d.id)};if(i.isPending)return e.jsx(Cn,{});if(!d)return e.jsx(Bn,{taskId:t??null});const g=w.error?V(w.error,r("workTaskDeleteError"),r):null,k=y.error?V(y.error,r("workTaskApprovalDecisionError"),r):null,R=j.error?V(j.error,r("workTaskStartRunError"),r):null,D=d.projectId?l.data?.projects.find(f=>f.id===d.projectId):void 0,S=d.workItemId?c.data?.workItems.find(f=>f.id===d.workItemId):void 0,C=d.parentTaskId?u.find(f=>f.id===d.parentTaskId):void 0,I=u.filter(f=>f.parentTaskId===d.id),b=(h.data?.runs??[]).filter(f=>f.taskId===d.id).sort((f,G)=>G.updatedAt.localeCompare(f.updatedAt)),T=d.productBinding?gt(d.productBinding,r):null,v=n.objects.filter(f=>f.kind==="activity"&&f.linkedTaskId===d.id).sort((f,G)=>G.updatedAt.localeCompare(f.updatedAt)),O=d.assignedActors.map(f=>f.displayName),P=d.status==="pending_approval",A=y.isPending,F=d.status==="approved"&&b.length===0;return e.jsxs("div",{className:"taskDetail",children:[e.jsxs("header",{className:"channelTopBar taskDetailTopBar",children:[e.jsx("div",{className:"channelTopBarStart taskDetailTopBar__start",children:e.jsxs(B,{to:"..",relative:"path",className:"taskDetailTopBar__back","aria-label":r("workTaskBackLabel"),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M7.5 2L3.5 6l4 4"})}),e.jsx("span",{children:r("workTaskBackArrowLabel")})]})}),e.jsxs("div",{className:"channelTopBarCenter taskDetailTopBar__center",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--${d.status}`,"aria-hidden":"true"}),e.jsx("h1",{className:"channelTopBarTitle taskDetailTopBar__title",children:d.title})]}),e.jsxs("div",{className:"channelTopBarEnd taskDetailTopBar__end",children:[d.attention!=="none"?e.jsx("span",{className:`taskDetail__attention taskDetail__attention--${d.attention}`,children:re(d.attention,r)}):null,d.priority?e.jsx("span",{className:`tasksList__priority tasksList__priority--${d.priority}`,title:r("workTaskPriorityTooltip",{priority:Gt(d.priority,r)}),children:Gt(d.priority,r)}):null,d.productBinding?e.jsx("span",{className:`tasksList__binding tasksList__binding--${d.productBinding}`,title:r("workTopdownTaskProductBindingTitle",{productBinding:T??""}),children:T}):null,e.jsx("span",{className:`tasksList__statusPill tasksList__statusPill--${d.status}`,children:fs(d.status,r)}),e.jsx("span",{className:"taskDetailTopBar__updated",children:r("workTaskUpdatedAtPrefix",{updatedAt:W(d.updatedAt,r)})}),P?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"taskDetailTopBar__action taskDetailTopBar__action--primary",onClick:()=>x("approve"),disabled:A,"aria-label":r("workTaskApproveLabel"),children:r(A?"workTaskApproveBusyLabel":"workTaskApproveLabel")}),e.jsx("button",{type:"button",className:"taskDetailTopBar__action",onClick:()=>x("reject"),disabled:A,"aria-label":r("workTaskRejectLabel"),children:r(A?"workTaskRejectBusyLabel":"workTaskRejectLabel")})]}):null,F?e.jsx("button",{type:"button",className:"taskDetailTopBar__action taskDetailTopBar__action--primary",onClick:L,disabled:j.isPending,"aria-label":r("workTaskNoRunsActionLabel"),children:j.isPending?r("workTaskStartRunBusyLabel"):r("workTaskNoRunsActionLabel")}):null,e.jsx("button",{type:"button",className:"taskDetailTopBar__action taskDetailTopBar__action--destructive",onClick:_,disabled:w.isPending||A||j.isPending,"aria-label":r("workTaskDeleteLabel"),children:w.isPending?r("workTaskDeleteLabelBusy"):r("workTaskDeleteLabel")})]})]}),e.jsxs("main",{className:"taskDetail__main",children:[g||k||R?e.jsx("p",{className:"taskDetail__error",role:"alert",children:g??k??R}):null,e.jsxs("section",{className:"taskDetail__section taskDetail__overview",children:[e.jsx("header",{className:"taskDetail__sectionHeader",children:e.jsx("h2",{children:r("workTaskOverviewTitle")})}),e.jsxs("dl",{className:"taskDetail__overviewList",children:[d.summary?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:r("workTaskSummaryLabel")}),e.jsx("dd",{children:d.summary})]}):null,e.jsx("dt",{children:r("workTaskProjectLabel")}),e.jsx("dd",{children:D?e.jsx(B,{className:"taskDetail__refLink",to:`${ne}/${D.id}`,children:D.title}):d.projectTitle?e.jsx("span",{children:d.projectTitle}):e.jsx("em",{children:r("workTaskOrphanProjectFallback")})}),e.jsx("dt",{children:r("workTaskWorkItemLabel")}),e.jsx("dd",{children:S?e.jsx(B,{className:"taskDetail__refLink",to:`${he}/${S.id}`,children:S.title}):d.workItemTitle?e.jsx("span",{children:d.workItemTitle}):e.jsx("em",{children:r("workTaskNoWorkItemFallback")})}),C?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:r("workTaskParentTaskLabel")}),e.jsx("dd",{children:e.jsx(B,{className:"taskDetail__refLink",to:`${Q}/${C.id}`,children:C.title})})]}):null,e.jsx("dt",{children:r("workTaskOwnerLabel")}),e.jsx("dd",{children:d.ownerName}),e.jsx("dt",{children:r("workTaskAssigneeLabel")}),e.jsx("dd",{children:d.assigneeName??e.jsx("em",{children:r("workTaskNoAssigneeFallback")})}),e.jsx("dt",{children:r("workTaskAssignedActorsLabel")}),e.jsx("dd",{children:O.length>0?O.join(", "):e.jsx("em",{children:r("workTaskNoActorsAssignedFallback")})}),d.acceptanceCriteria?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:r("workTaskAcceptanceCriteriaLabel")}),e.jsx("dd",{children:d.acceptanceCriteria})]}):null,d.conversationId?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:r("workTaskConversationLabel")}),e.jsx("dd",{children:e.jsx("span",{className:"taskDetail__convoTitle",children:d.conversationTitle??d.conversationId})})]}):null]})]}),e.jsx(In,{subTasks:I}),e.jsx(Pn,{taskId:d.id,runs:b,canStartRun:F,isStartingRun:j.isPending,onStartRun:L}),e.jsx(ft,{selfRef:{recordFamily:"task",recordId:d.id},graph:n,indexes:o}),e.jsx(vn,{taskId:d.id}),e.jsxs("section",{className:"taskDetail__section",children:[e.jsxs("header",{className:"taskDetail__sectionHeader",children:[e.jsx("h2",{children:r("workTaskActivityTitle")}),e.jsx("span",{className:"taskDetail__sectionCount",children:v.length})]}),v.length===0?e.jsx("p",{className:"taskDetail__empty",children:r("workTaskNoActivity")}):e.jsx("ul",{className:"taskDetail__activity",children:v.map(f=>e.jsxs("li",{className:"taskDetail__activityRow",children:[e.jsx("span",{className:"taskDetail__activityWhen",children:W(f.updatedAt,r)}),e.jsx("span",{className:"taskDetail__activityTitle",children:f.title}),f.summary?e.jsx("span",{className:"taskDetail__activitySummary",children:f.summary}):null]},f.id))})]})]})]})}function In({subTasks:t}){const{t:s}=N();return e.jsxs("section",{className:"taskDetail__section",children:[e.jsxs("header",{className:"taskDetail__sectionHeader",children:[e.jsx("h2",{children:s("workTaskSubTasksTitle")}),e.jsx("span",{className:"taskDetail__sectionCount",children:t.length})]}),t.length===0?e.jsx("p",{className:"taskDetail__empty",children:s("workTaskNoSubTasksLabel")}):e.jsx("ul",{className:"taskDetail__subTasks",children:t.map(a=>e.jsxs("li",{className:"taskDetail__subTaskRow",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--small projectsList__dot--${a.status}`,"aria-hidden":"true"}),e.jsx(B,{to:`${Q}/${a.id}`,className:"taskDetail__subTaskTitle",children:a.title}),e.jsx("span",{className:`tasksList__statusPill tasksList__statusPill--${a.status}`,children:fs(a.status,s)})]},a.id))})]})}function Pn({taskId:t,runs:s,canStartRun:a,isStartingRun:r,onStartRun:n}){const{t:o}=N();return e.jsxs("section",{className:"taskDetail__section",children:[e.jsxs("header",{className:"taskDetail__sectionHeader",children:[e.jsx("h2",{children:o("workTaskRunsTitle")}),e.jsx("span",{className:"taskDetail__sectionCount",children:s.length})]}),s.length===0?e.jsxs("div",{className:"taskDetail__emptyAction",children:[e.jsxs("p",{className:"taskDetail__empty",children:[o("workTaskNoRunsIntro")," ",e.jsx("strong",{children:o("workTaskNoRunsActionLabel")})," ",o("workTaskNoRunsSuffix")]}),e.jsx("button",{type:"button",className:"taskDetail__inlineAction",onClick:n,disabled:!a||r,children:o(r?"workTaskStartRunBusyLabel":"workTaskNoRunsActionLabel")})]}):e.jsx("ul",{className:"taskDetail__subTasks",children:s.map(i=>e.jsxs("li",{className:"taskDetail__subTaskRow",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--small projectsList__dot--${i.status}`,"aria-hidden":"true"}),e.jsx(B,{to:ye(t,i.id),className:"taskDetail__subTaskTitle",children:i.title}),e.jsx("span",{className:`tasksList__statusPill tasksList__statusPill--${i.status}`,children:En(i.status,o)}),e.jsx("span",{className:"taskDetail__activityWhen",children:W(i.updatedAt,o)})]},i.id))})]})}function Cn(){const{t}=N();return e.jsxs("div",{className:"taskDetail",children:[e.jsx("header",{className:"channelTopBar taskDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart taskDetailTopBar__start",children:e.jsx(B,{to:"..",relative:"path",className:"taskDetailTopBar__back",children:e.jsx("span",{children:t("workTaskBackArrowLabel")})})})}),e.jsx("main",{className:"taskDetail__main",children:e.jsx("p",{className:"taskDetail__empty",children:t("workTaskLoadingLabel")})})]})}function Bn({taskId:t}){const{t:s}=N();return e.jsxs("div",{className:"taskDetail",children:[e.jsx("header",{className:"channelTopBar taskDetailTopBar",children:e.jsxs("div",{className:"channelTopBarStart taskDetailTopBar__start",children:[e.jsx(B,{to:"..",relative:"path",className:"taskDetailTopBar__back",children:e.jsx("span",{children:s("workTaskBackArrowLabel")})}),e.jsx("span",{className:"taskDetailTopBar__separator","aria-hidden":"true",children:"/"}),e.jsx("h1",{className:"channelTopBarTitle taskDetailTopBar__title",children:s("workTaskNotFoundTitle")})]})}),e.jsx("main",{className:"taskDetail__main",children:e.jsx("p",{className:"taskDetail__empty",children:s("workTaskNotFoundText",{taskId:t??s("workTaskNotFoundCodeLabel")})})})]})}function fs(t,s){return t==="pending_approval"?s("workTaskStatusPendingApproval"):t==="approved"?s("workTaskStatusApproved"):t==="archived"?s("workTaskStatusArchived"):M(t,s)}function En(t,s){return t==="pending_approval"?s("workTaskStatusPendingApproval"):M(t,s)}function Gt(t,s){return t==="urgent"?s("workTaskPriorityUrgent"):t==="high"?s("workTaskPriorityHigh"):t==="medium"?s("workTaskPriorityMedium"):t==="low"?s("workTaskPriorityLow"):t}const An="workRenderer";async function Wn(t,s){const a={};t.priority&&(a.priority=t.priority),t.assigneeName&&(a.assigneeName=t.assigneeName),t.acceptanceCriteria&&(a.acceptanceCriteria=t.acceptanceCriteria);const r=Object.keys(a).length>0?{[An]:a}:void 0;return{id:(await er({title:t.title,summary:t.summary,status:t.status,parentTaskId:t.parentTaskId,metadata:r},s)).task.id}}function Mn({onClose:t,defaultParentTaskId:s}){const{t:a}=N(),r=z(),n=U(),o=m.useId(),i=m.useId(),l=m.useId(),c=m.useId(),h=m.useId(),u=m.useId(),d=m.useId(),w=m.useRef(null),y=Se(),[j,_]=m.useState(""),[x,L]=m.useState(""),[g,k]=m.useState(s??""),[R,D]=m.useState(""),[S,C]=m.useState("draft"),[I,b]=m.useState(""),[T,v]=m.useState(""),O=$({mutationFn:E=>Wn(E,a("workNewTaskCreateError")),onSuccess:async E=>{await n.invalidateQueries({queryKey:we}),t(),r(`${Q}/${E.id}`)}}),P=O.isPending,A=O.error?V(O.error,a("workNewTaskCreateError"),a):null;m.useEffect(()=>{w.current?.focus()},[]),m.useEffect(()=>{function E(fe){fe.key==="Escape"&&(fe.stopPropagation(),t())}return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[t]);function F(E){E.target===E.currentTarget&&t()}function f(E){E.preventDefault();const fe=j.trim();!fe||P||O.mutate({title:fe,summary:x.trim()||null,status:S,priority:I||null,assigneeName:R.trim()||null,acceptanceCriteria:T.trim()||null,parentTaskId:g||null})}const G=[{value:"draft",label:a("workNewTaskStatusDraft")},{value:"pending_approval",label:a("workNewTaskStatusPendingApproval")},{value:"approved",label:a("workNewTaskStatusApproved")},{value:"in_progress",label:a("workNewTaskStatusInProgress")},{value:"blocked",label:a("workNewTaskStatusBlocked")},{value:"completed",label:a("workNewTaskStatusCompleted")}],As=[{value:"",label:a("workNewTaskNoPriority")},{value:"urgent",label:a("workNewTaskPriorityUrgent")},{value:"high",label:a("workNewTaskPriorityHigh")},{value:"medium",label:a("workNewTaskPriorityMedium")},{value:"low",label:a("workNewTaskPriorityLow")}],Ws=y.data?.tasks??[];return e.jsx("div",{className:"newProjectDialog__backdrop",role:"presentation",onClick:F,children:e.jsxs("div",{className:"newProjectDialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":`${o}-heading`,children:[e.jsxs("header",{className:"newProjectDialog__header",children:[e.jsx("h2",{id:`${o}-heading`,className:"newProjectDialog__heading",children:a("workNewTaskTitle")}),e.jsx("button",{type:"button",className:"newProjectDialog__close","aria-label":a("workNewTaskCloseLabel"),onClick:t,children:"×"})]}),e.jsxs("form",{className:"newProjectDialog__form",onSubmit:f,children:[e.jsxs("label",{className:"newProjectDialog__field",htmlFor:o,children:[e.jsxs("span",{className:"newProjectDialog__label",children:[a("workNewTaskTitleLabel"),e.jsx("span",{className:"newProjectDialog__required","aria-hidden":"true",children:"*"})]}),e.jsx("input",{ref:w,id:o,type:"text",className:"newProjectDialog__input",value:j,onChange:E=>_(E.target.value),placeholder:a("workNewTaskTitlePlaceholder"),required:!0,maxLength:120})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:i,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workNewTaskSummaryLabel")}),e.jsx("textarea",{id:i,className:"newProjectDialog__textarea",value:x,onChange:E=>L(E.target.value),placeholder:a("workNewTaskSummaryPlaceholder"),rows:3,maxLength:400})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:l,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workNewTaskParentTaskLabel")}),e.jsxs("select",{id:l,className:"newProjectDialog__select",value:g,onChange:E=>k(E.target.value),children:[e.jsx("option",{value:"",children:a("workNewTaskNoParentTask")}),Ws.map(E=>e.jsx("option",{value:E.id,children:E.title},E.id))]})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:c,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workNewTaskAssigneeLabel")}),e.jsx("input",{id:c,type:"text",className:"newProjectDialog__input",value:R,onChange:E=>D(E.target.value),placeholder:a("workNewTaskAssigneePlaceholder"),maxLength:60})]}),e.jsxs("div",{className:"newProjectDialog__row",children:[e.jsxs("label",{className:"newProjectDialog__field",htmlFor:h,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workNewTaskStatusLabel")}),e.jsx("select",{id:h,className:"newProjectDialog__select",value:S,onChange:E=>C(E.target.value),children:G.map(E=>e.jsx("option",{value:E.value,children:E.label},E.value))})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:u,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workNewTaskPriorityLabel")}),e.jsx("select",{id:u,className:"newProjectDialog__select",value:I,onChange:E=>b(E.target.value),children:As.map(E=>e.jsx("option",{value:E.value,children:E.label},E.value))})]})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:d,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workNewTaskAcceptanceCriteriaLabel")}),e.jsx("textarea",{id:d,className:"newProjectDialog__textarea",value:T,onChange:E=>v(E.target.value),placeholder:a("workNewTaskAcceptanceCriteriaPlaceholder"),rows:2,maxLength:280})]}),A?e.jsx("p",{className:"newProjectDialog__error",role:"alert",children:A}):null,e.jsxs("footer",{className:"newProjectDialog__footer",children:[e.jsx("button",{type:"button",className:"newProjectDialog__cancelBtn",onClick:t,disabled:P,children:a("workNewTaskCancelButton")}),e.jsx("button",{type:"submit",className:"newProjectDialog__submitBtn",disabled:j.trim().length===0||P,children:a(P?"workNewTaskSubmittingLabel":"workNewTaskSubmitLabel")})]})]})]})})}function On(){const t=Se(),s=t.data?.tasks??[],[a,r]=m.useState(!1),{t:n}=N();return e.jsxs("div",{className:"tasksList",children:[e.jsxs("header",{className:"channelTopBar tasksListTopBar",children:[e.jsxs("div",{className:"channelTopBarStart tasksListTopBar__start",children:[e.jsx("h1",{className:"channelTopBarTitle tasksListTopBar__title",children:n("workTasksListTitle")}),e.jsx("span",{className:"tasksListTopBar__count",children:s.length})]}),e.jsx("div",{className:"channelTopBarCenter tasksListTopBar__center"}),e.jsx("div",{className:"channelTopBarEnd tasksListTopBar__end",children:e.jsxs("button",{type:"button",className:"tasksListTopBar__addBtn",onClick:()=>r(!0),"aria-label":n("workTasksListCreateNewTaskAriaLabel"),children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M7 2v10"}),e.jsx("path",{d:"M2 7h10"})]}),e.jsx("span",{children:n("workTasksListNewAction")})]})})]}),e.jsx("main",{className:"tasksList__main",children:t.isPending?e.jsx("p",{className:"tasksList__empty",children:n("workTasksListLoading")}):t.isError?e.jsx("p",{className:"tasksList__empty",children:n("workTasksListLoadError",{errorMessage:String(t.error.message)})}):s.length===0?e.jsxs("p",{className:"tasksList__empty",children:[n("workTasksListEmptyIntro")," ",e.jsx("strong",{children:n("workTasksListEmptyActionLabel")})," ",n("workTasksListEmptySuffix")]}):e.jsx("ul",{className:"tasksList__list",children:s.map(o=>{const i=o.productBinding?gt(o.productBinding,n):null;return e.jsx("li",{className:"tasksList__row",children:e.jsxs(B,{to:o.id,className:"tasksList__rowLink","aria-label":n("workTasksListOpenTaskAria",{title:o.title}),children:[e.jsxs("div",{className:"tasksList__rowMain",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--${o.status}`,"aria-hidden":"true"}),e.jsxs("div",{className:"tasksList__rowText",children:[e.jsx("span",{className:"tasksList__rowTitle",children:o.title}),o.summary?e.jsx("span",{className:"tasksList__rowSummary",children:o.summary}):null]})]}),e.jsxs("div",{className:"tasksList__rowMeta",children:[o.productBinding?e.jsx("span",{className:`tasksList__binding tasksList__binding--${o.productBinding}`,title:n("workTopdownTaskProductBindingTitle",{productBinding:i??""}),children:i}):null,o.projectTitle?e.jsx("span",{className:"tasksList__chip tasksList__chip--project",children:o.projectTitle}):null,o.workItemTitle?e.jsx("span",{className:"tasksList__chip tasksList__chip--workItem",children:o.workItemTitle}):null,o.priority?e.jsx("span",{className:`tasksList__priority tasksList__priority--${o.priority}`,title:Fn(o.priority,n),children:Ts(o.priority,n)}):null,o.attention==="decision_needed"?e.jsx("span",{className:"tasksList__pip tasksList__pip--decision",children:n("workObjectAttentionDecisionNeeded")}):null,o.attention==="blocked"||o.attention==="failed"?e.jsx("span",{className:"tasksList__pip tasksList__pip--blocked",children:re(o.attention,n)}):null,o.assigneeName?e.jsx("span",{className:"tasksList__assignee",children:o.assigneeName}):o.ownerRole?e.jsx("span",{className:"tasksList__assignee tasksList__assignee--role",children:ge(o.ownerRole,n)}):null,e.jsx("span",{className:"tasksList__metric tasksList__metric--muted",children:W(o.updatedAt,n)}),e.jsx("span",{className:`tasksList__statusPill tasksList__statusPill--${o.status}`,children:Kn(o.status,n)})]})]})},o.id)})})}),a?e.jsx(Mn,{onClose:()=>r(!1)}):null]})}function Kn(t,s){return t==="pending_approval"?s("workTaskStatusPendingApproval"):t==="approved"?s("workTaskStatusApproved"):t==="archived"?s("workTaskStatusArchived"):M(t,s)}function Ts(t,s){return t==="urgent"?s("workTaskPriorityUrgent"):t==="high"?s("workTaskPriorityHigh"):t==="medium"?s("workTaskPriorityMedium"):t==="low"?s("workTaskPriorityLow"):t}function Fn(t,s){const a=Ts(t,s);return s("workTaskPriorityLabelWithValue",{priorityLabel:a})}function Ls(t,s){switch(t){case"Blocked before runtime launch completed.":return s(p.workRunSummaryBlockedBeforeRuntimeLaunch);case"Blocked before scheduled runtime launch completed.":return s(p.workRunSummaryBlockedBeforeScheduledRuntimeLaunch);case"Launching scheduled mission through supervised runtime boundary.":return s(p.workRunSummaryLaunchingScheduledMission);case"Provider-agent runtime message completed.":return s(p.workRunSummaryProviderAgentRuntimeMessageCompleted);case"Queued supervised Work run.":return s(p.workRunSummaryQueuedSupervisedWorkRun);case"Started supervised Code task execution.":return s(p.workRunSummaryStartedSupervisedCodeTaskExecution)}const a=t.match(/^Relay fan-out dispatch for (.+)\.$/u);return a?s(p.workRunSummaryRelayFanOutDispatch,{agentLabel:a[1]}):t}function $n(){const t=ze(),s=t.data?.runs??[],{t:a}=N();return e.jsxs("div",{className:"runsList",children:[e.jsxs("header",{className:"channelTopBar runsListTopBar",children:[e.jsxs("div",{className:"channelTopBarStart runsListTopBar__start",children:[e.jsx("h1",{className:"channelTopBarTitle runsListTopBar__title",children:a("workRunsListTitle")}),e.jsx("span",{className:"runsListTopBar__count",children:s.length})]}),e.jsx("div",{className:"channelTopBarCenter runsListTopBar__center",children:e.jsx("p",{className:"runsListTopBar__lede",children:a("workRunsListLede")})}),e.jsx("div",{className:"channelTopBarEnd runsListTopBar__end"})]}),e.jsx("main",{className:"runsList__main",children:t.isPending?e.jsx("p",{className:"runsList__empty",children:a("workRunsListLoading")}):t.isError?e.jsx("p",{className:"runsList__empty",children:a("workRunsListLoadError",{errorMessage:String(t.error.message)})}):s.length===0?e.jsx("p",{className:"runsList__empty",children:a("workRunsListNoRunsIntro")}):e.jsx("ul",{className:"runsList__list",children:s.map(r=>{const n=r.taskId??"orphan";return e.jsx("li",{className:"runsList__row",children:e.jsxs(B,{to:ye(n,r.id),className:"runsList__rowLink","aria-label":a("workRunOpenAriaLabel",{runTitle:r.title}),children:[e.jsxs("div",{className:"runsList__rowMain",children:[e.jsx("span",{className:`runsList__dot runsList__dot--${r.status}`,"aria-hidden":"true"}),e.jsxs("div",{className:"runsList__rowText",children:[e.jsx("span",{className:"runsList__rowTitle",children:r.title}),r.summary?e.jsx("span",{className:"runsList__rowSummary",children:Ls(r.summary,a)}):null]})]}),e.jsxs("div",{className:"runsList__rowMeta",children:[r.taskTitle?e.jsx("span",{className:"runsList__chip runsList__chip--task",children:r.taskTitle}):null,r.parentRunId?e.jsx("span",{className:"runsList__chip runsList__chip--parentRun",children:a("workRunSubRunChip")}):null,e.jsx("span",{className:"runsList__metric runsList__metric--muted",children:W(r.updatedAt,a)}),e.jsx("span",{className:`runsList__statusPill runsList__statusPill--${r.status}`,children:M(r.status,a)})]})]})},r.id)})})})]})}function Un(t,s){const a=new Error(s);return a.statusCode=t,a}function Gn(){return{fallbackMessage:oe(p.workRunStopError),routeFallback:t=>oe(p.workRunStopRouteFailed,{statusCode:t})}}function Qn(){return{fallbackMessage:oe(p.workMissionCancelError),routeFallback:t=>oe(p.workMissionCancelRouteFailed,{statusCode:t})}}async function vs(t,s,a){const n=await fetch(t,{method:"POST",headers:void 0,body:void 0}),o=await n.text();let i=null;if(o)try{i=JSON.parse(o)}catch{}if(!n.ok){const l=(()=>{if(i&&typeof i=="object"&&!Array.isArray(i)){const c=i.error?.message;if(typeof c=="string"&&c.length>0)return c}return a.routeFallback(n.status)||a.fallbackMessage})();throw Un(n.status,l)}return i}async function Hn(t,s,a=Gn()){return vs(ca(t),s,a)}async function qn(t,s,a=Qn()){return vs(da(t),s,a)}const Tt=["missions"],Vn=t=>["missions","detail",t];async function Yn(t){const s=await fetch(ua,{headers:{accept:"application/json"}});if(!s.ok)throw me(s,t);return await s.json()}async function zn(t,s){const a=await fetch(ha(t),{headers:{accept:"application/json"}});if(a.status===404)return null;if(!a.ok)throw me(a,s);return await a.json()}function Lt(){const{t}=N();return te({queryKey:Tt,queryFn:()=>Yn(t)})}function Jn(t){const{t:s}=N();return te({queryKey:t?Vn(t):["missions","detail","__none__"],queryFn:()=>t?zn(t,s):Promise.resolve(null),enabled:!!t})}async function Xn(t,s,a){const r=new URLSearchParams;r.set("runId",t);const n=await fetch(`/api/core/traces?${r.toString()}`,{signal:a});return(await K(n,s)).traces}const Zn={approval:p.sharedOperatorTraceKindApproval,checkpoint:p.sharedOperatorTraceKindCheckpoint,dispatch:p.sharedOperatorTraceKindDispatch,error:p.sharedOperatorTraceKindError,outcome:p.sharedOperatorTraceKindOutcome,status:p.sharedOperatorTraceKindStatus,note:p.sharedOperatorTraceKindNote},eo={succeeded:p.sharedOperatorOutcomeStatusSucceeded,blocked:p.sharedOperatorOutcomeStatusBlocked,failed:p.sharedOperatorOutcomeStatusFailed,cancelled:p.sharedOperatorOutcomeStatusCancelled},to={draft:p.workRunArtifactStatusDraft,ready:p.workRunArtifactStatusReady,published:p.workRunArtifactStatusPublished,archived:p.workRunArtifactStatusArchived};function vt(t){return t.trim().replace(/[_-]+/gu," ").replace(/\s+/gu," ")}function so(t,s){const a=Zn[t];return a?s(a):s(p.workRunTraceKindUnknown,{kind:vt(t)})}function ao(t,s){const a=eo[t];return a?s(a):s(p.workObjectStatusUnknown,{status:vt(t)})}function ro(t,s){const a=to[t];return a?s(a):s(p.workObjectStatusUnknown,{status:vt(t)})}const no="Running run is not stoppable: no supervised runtime session is bridged.",oo="Runtime client is unavailable; cannot request runtime cancellation.",io="Run is not stoppable.",Qt="Runtime cancellation failed: ";function Ds(t,s){const a=t?.trim();if(!a||a===io)return s("workCancellationBlockerRunNotStoppable");if(a===no)return s("workCancellationBlockerNoRuntimeSession");if(a===oo)return s("workCancellationBlockerRuntimeClientUnavailable");if(a.startsWith(Qt)){const r=a.slice(Qt.length).trim();return r?s("workCancellationBlockerRuntimeCancellationFailed",{error:r}):s("workRunStopErrorFallback")}return a}function lo(t,s){return t.message?Ds(t.message,s):t.runtimeAbort.status==="failed"?t.runtimeAbort.error==="runtime_client_unavailable"?s("workCancellationBlockerRuntimeClientUnavailable"):t.runtimeAbort.error?s("workCancellationBlockerRuntimeCancellationFailed",{error:t.runtimeAbort.error}):s("workRunStopErrorFallback"):t.runtimeAbort.status==="not_applicable"?s("workCancellationBlockerNoRuntimeSession"):s("workCancellationBlockerRunNotStoppable")}function co(t,s){return t.map(a=>`${a.runId}: ${Ds(a.reason,s)}`).join("; ")}function uo(t,s){const a=co(t,s);return s("workMissionCancelBlocked",{detail:a||s("workMissionCancelBlockedNoDetails")})}const ho={status:"idle",traces:[],error:null};function mo(t,s){const a=new Map;for(const n of s){const o=n.parentRunId??"",i=a.get(o)??[];i.push(n),a.set(o,i)}function r(n,o){return(a.get(n)??[]).filter(l=>!o.has(l.id)).sort((l,c)=>(l.startedAt??l.updatedAt).localeCompare(c.startedAt??c.updatedAt)).map(l=>{const c=new Set(o);return c.add(l.id),{run:l,children:r(l.id,c)}})}return r(t,new Set([t]))}function po(t){return t==="completed"||t==="failed"||t==="cancelled"}function ko(t,s){if(!t)return null;const a=Date.parse(t);if(Number.isNaN(a))return null;const r=s?Date.parse(s):Date.now();if(Number.isNaN(r))return null;const n=Math.max(0,Math.round((r-a)/1e3));if(n<60)return`${n}s`;const o=Math.round(n/60);return o<60?`${o}m`:`${Math.round(o/60)}h`}function wo(){const{taskId:t,runId:s}=xe(),a=U(),{t:r}=N(),n=ze(),o=Se(),i=ke(r("workGraphLoadErrorFallback")).data??pe,[l,c]=m.useState(null),h=n.data?.runs??[],u=o.data?.tasks??[],d=s?h.find(b=>b.id===s):void 0,w=t?u.find(b=>b.id===t):void 0,y=$({mutationFn:async b=>Hn(b,void 0,{fallbackMessage:r("workRunStopError"),routeFallback:T=>r("workRunStopRouteFailed",{statusCode:T})}),onSuccess:async b=>{await Promise.all([a.invalidateQueries({queryKey:Ye}),a.invalidateQueries({queryKey:Tt}),a.invalidateQueries({queryKey:Y})]),b.status==="not_stoppable"?c(lo(b,r)):c(null)}}),j=()=>{d&&window.confirm(r("workRunStopConfirmation",{runTitle:d.title}))&&(c(null),y.mutate(d.id))},_=y.error,x=_?_ instanceof Error?_.message:r("workRunStopError"):null,L=m.useMemo(()=>s?mo(s,h):[],[s,h]),g=m.useMemo(()=>i.objects.filter(b=>b.kind==="activity"&&b.linkedRunId===s).sort((b,T)=>T.updatedAt.localeCompare(b.updatedAt)),[i.objects,s]),k=m.useMemo(()=>{const b=new Map;for(const T of i.objects)T.kind==="agent"&&b.set(T.id,T.title);return b},[i.objects]),R=m.useMemo(()=>i.objects.filter(b=>b.kind==="outcome"&&b.linkedRunId===s).sort((b,T)=>T.updatedAt.localeCompare(b.updatedAt)),[i.objects,s]),D=m.useMemo(()=>i.objects.filter(b=>b.kind==="artifact"&&b.linkedRunId===s).sort((b,T)=>T.updatedAt.localeCompare(b.updatedAt)),[i.objects,s]),[S,C]=m.useState(ho);if(m.useEffect(()=>{if(!s)return;const b=d?.status==="queued"||d?.status==="running",T=new AbortController;let v=!1;async function O(){try{const A=await Xn(s,r("workRunTraceLoadFallback"),T.signal);if(v)return;C({status:"ready",traces:A,error:null})}catch(A){if(v||T.signal.aborted)return;C(F=>({status:"error",traces:F.traces,error:A instanceof Error?A.message:String(A)}))}}if(C(A=>({status:A.traces.length===0?"loading":"ready",traces:A.traces,error:null})),O(),!b)return()=>{v=!0,T.abort()};const P=window.setInterval(()=>{a.invalidateQueries({queryKey:Y}),O()},3e3);return()=>{v=!0,T.abort(),window.clearInterval(P)}},[s,d?.status,a]),n.isPending)return e.jsx(jo,{});if(!d)return e.jsx(xo,{runId:s??null});const I=ko(d.startedAt??null,d.completedAt??null);return e.jsxs("div",{className:"runDetail",children:[e.jsxs("header",{className:"channelTopBar runDetailTopBar",children:[e.jsxs("div",{className:"channelTopBarStart runDetailTopBar__start",children:[e.jsxs(B,{to:Q,className:"runDetailTopBar__back","aria-label":r("workRunBackArrowLabel"),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M7.5 2L3.5 6l4 4"})}),e.jsx("span",{children:r("workRunBackLabel")})]}),w?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"runDetailTopBar__sep",children:"›"}),e.jsx(B,{to:Nt(w.id),className:"runDetailTopBar__crumb",children:w.title})]}):null,e.jsx("span",{className:"runDetailTopBar__sep",children:"›"}),e.jsx("h1",{className:"channelTopBarTitle runDetailTopBar__title",children:d.title})]}),e.jsx("div",{className:"channelTopBarCenter runDetailTopBar__center"}),e.jsxs("div",{className:"channelTopBarEnd runDetailTopBar__end",children:[po(d.status)?null:e.jsx("button",{type:"button",className:"runDetailTopBar__action runDetailTopBar__action--destructive",onClick:j,disabled:y.isPending,"aria-label":r("workRunStopLabel"),children:y.isPending?r("workRunStopLabelBusy"):r("workRunStopLabel")}),e.jsx("span",{className:`runDetail__statusPill runDetail__statusPill--${d.status}`,children:M(d.status,r)})]})]}),e.jsxs("main",{className:"runDetail__main",children:[x?e.jsx("p",{className:"runDetail__error",role:"alert",children:x}):null,l?e.jsx("p",{className:"runDetail__warning",role:"alert",children:l}):null,e.jsxs("section",{className:"runDetail__section",children:[e.jsx("h2",{className:"runDetail__sectionHeading",children:r("workRunSummaryTitle")}),e.jsxs("dl",{className:"runDetail__summary",children:[e.jsxs("div",{className:"runDetail__summaryRow",children:[e.jsx("dt",{children:r("workRunStatusLabel")}),e.jsx("dd",{children:M(d.status,r)})]}),e.jsxs("div",{className:"runDetail__summaryRow",children:[e.jsx("dt",{children:r("workRunUpdatedLabel")}),e.jsx("dd",{children:W(d.updatedAt,r)})]}),I?e.jsxs("div",{className:"runDetail__summaryRow",children:[e.jsx("dt",{children:r("workRunDurationLabel")}),e.jsx("dd",{children:I})]}):null,d.parentRunId?e.jsxs("div",{className:"runDetail__summaryRow",children:[e.jsx("dt",{children:r("workRunParentRunLabel")}),e.jsx("dd",{children:w?e.jsx(B,{to:ye(w.id,d.parentRunId),className:"runDetail__crumbLink",children:d.parentRunTitle??d.parentRunId}):e.jsx("span",{title:d.parentRunId,children:d.parentRunTitle??e.jsx("code",{children:d.parentRunId})})})]}):null,d.conversationId?e.jsxs("div",{className:"runDetail__summaryRow",children:[e.jsx("dt",{children:r("workRunConversationLabel")}),e.jsx("dd",{children:d.conversationTitle??e.jsx("code",{children:d.conversationId})})]}):null]}),d.summary?e.jsx("p",{className:"runDetail__summaryBody",children:Ls(d.summary,r)}):null]}),e.jsxs("section",{className:"runDetail__section",children:[e.jsx("h2",{className:"runDetail__sectionHeading",children:r("workRunSubRunsTitle",{count:`${Ss(L)}`})}),L.length===0?e.jsx("p",{className:"runDetail__empty",children:r("workRunNoSubRuns")}):e.jsx(Rs,{nodes:L,taskId:t??"orphan",depth:0,t:r})]}),e.jsxs("section",{className:"runDetail__section",children:[e.jsx("h2",{className:"runDetail__sectionHeading",children:r("workRunTraceTitle",{count:`${S.traces.length}`})}),S.status==="loading"?e.jsx("p",{className:"runDetail__empty",children:r("workRunTraceLoading")}):S.status==="error"?e.jsx("p",{className:"runDetail__error",children:r("workRunTraceLoadError",{errorMessage:S.error})}):S.traces.length===0?e.jsx("p",{className:"runDetail__empty",children:_o(d.status,r)}):e.jsx("ol",{className:"runDetail__trace",children:S.traces.slice().sort((b,T)=>b.createdAt.localeCompare(T.createdAt)).map(b=>{const T=b.actorId?k.get(b.actorId)??b.actorId:null;return e.jsxs("li",{className:`runDetail__traceRow runDetail__traceRow--${b.kind}`,children:[e.jsx("span",{className:"runDetail__traceKind",children:so(b.kind,r)}),e.jsx("span",{className:"runDetail__traceActor",title:b.actorId??r("workRunTraceNoActorRecorded"),children:T??"—"}),e.jsx("p",{className:"runDetail__traceMessage",children:b.message}),e.jsx("span",{className:"runDetail__traceTime",children:W(b.createdAt,r)})]},b.id)})})]}),g.length>0?e.jsxs("section",{className:"runDetail__section",children:[e.jsx("h2",{className:"runDetail__sectionHeading",children:r("workRunActivitiesTitle",{count:`${g.length}`})}),e.jsx("ul",{className:"runDetail__simpleList",children:g.map(b=>e.jsxs("li",{className:"runDetail__simpleRow",children:[e.jsx("span",{className:"runDetail__simpleTitle",children:b.title}),e.jsx("span",{className:"runDetail__simpleTime",children:W(b.updatedAt,r)})]},b.id))})]}):null,R.length>0?e.jsxs("section",{className:"runDetail__section",children:[e.jsx("h2",{className:"runDetail__sectionHeading",children:r("workRunOutcomesTitle",{count:`${R.length}`})}),e.jsx("ul",{className:"runDetail__simpleList",children:R.map(b=>e.jsxs("li",{className:"runDetail__simpleRow",children:[e.jsx("span",{className:"runDetail__simpleTitle",children:b.title}),e.jsx("span",{className:"runDetail__simpleStatus",children:ao(b.status,r)})]},b.id))})]}):null,D.length>0?e.jsxs("section",{className:"runDetail__section",children:[e.jsx("h2",{className:"runDetail__sectionHeading",children:r("workRunArtifactsTitle",{count:`${D.length}`})}),e.jsx("ul",{className:"runDetail__simpleList",children:D.map(b=>e.jsxs("li",{className:"runDetail__simpleRow",children:[e.jsx("span",{className:"runDetail__simpleTitle",children:b.title}),e.jsx("span",{className:"runDetail__simpleStatus",children:ro(b.status,r)})]},b.id))})]}):null]})]})}function Ss(t){let s=0;for(const a of t)s+=1+Ss(a.children);return s}function _o(t,s){switch(t){case"queued":return s("workRunTraceEmptyQueued");case"running":return s("workRunTraceEmptyRunning");case"blocked":return s("workRunTraceEmptyBlocked");case"completed":return s("workRunTraceEmptyCompleted");case"failed":return s("workRunTraceEmptyFailed");case"cancelled":return s("workRunTraceEmptyCancelled");default:return s("workRunTraceEmptyDefault")}}function Rs({nodes:t,taskId:s,depth:a,t:r}){return e.jsx("ul",{className:a===0?"runDetail__subTree":"runDetail__subTree runDetail__subTree--nested",children:t.map(({run:n,children:o})=>e.jsxs("li",{className:"runDetail__subTreeNode",children:[e.jsxs(B,{to:ye(s,n.id),className:"runDetail__subTreeLink","aria-label":r("workRunOpenSubRunAriaLabel",{runTitle:n.title}),children:[e.jsx("span",{className:`runDetail__subTreeDot runDetail__subTreeDot--${n.status}`,"aria-hidden":"true"}),e.jsx("span",{className:"runDetail__subTreeTitle",children:n.title}),e.jsx("span",{className:`runDetail__subTreeStatus runDetail__subTreeStatus--${n.status}`,children:M(n.status,r)}),e.jsx("span",{className:"runDetail__subTreeTime",children:W(n.updatedAt,r)})]}),o.length>0?e.jsx(Rs,{nodes:o,taskId:s,depth:a+1,t:r}):null]},n.id))})}function jo(){const{t}=N();return e.jsxs("div",{className:"runDetail",children:[e.jsx("header",{className:"channelTopBar runDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart runDetailTopBar__start",children:e.jsx(B,{to:Q,className:"runDetailTopBar__back",children:e.jsx("span",{children:t("workRunBackLabel")})})})}),e.jsx("main",{className:"runDetail__main",children:e.jsx("p",{className:"runDetail__empty",children:t("workRunLoadingLabel")})})]})}function xo({runId:t}){const{t:s}=N();return e.jsxs("div",{className:"runDetail",children:[e.jsx("header",{className:"channelTopBar runDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart runDetailTopBar__start",children:e.jsx(B,{to:Q,className:"runDetailTopBar__back",children:e.jsx("span",{children:s("workRunBackLabel")})})})}),e.jsx("main",{className:"runDetail__main",children:e.jsx("p",{className:"runDetail__empty",children:t?s("workRunNotFound",{runId:t}):s("workRunNoRunId")})})]})}function go(){const t=Lt(),s=t.data?.missions??[],{t:a}=N();return e.jsxs("div",{className:"missionsList",children:[e.jsxs("header",{className:"channelTopBar missionsListTopBar",children:[e.jsxs("div",{className:"channelTopBarStart missionsListTopBar__start",children:[e.jsx("h1",{className:"channelTopBarTitle missionsListTopBar__title",children:a("workMissionsListTitle")}),e.jsx("span",{className:"missionsListTopBar__count",children:s.length})]}),e.jsx("div",{className:"channelTopBarCenter missionsListTopBar__center",children:e.jsx("p",{className:"missionsListTopBar__lede",children:a("workMissionsListLede")})}),e.jsx("div",{className:"channelTopBarEnd missionsListTopBar__end"})]}),e.jsx("main",{className:"missionsList__main",children:t.isPending?e.jsx("p",{className:"missionsList__empty",children:a("workMissionsListLoading")}):t.isError?e.jsx("p",{className:"missionsList__empty",children:a("workMissionsListLoadError",{errorMessage:String(t.error.message)})}):s.length===0?e.jsx("p",{className:"missionsList__empty",children:a("workMissionsListEmpty")}):e.jsx("ul",{className:"missionsList__list",children:s.map(r=>e.jsx("li",{className:"missionsList__row",children:e.jsxs(B,{to:bs(r.id),className:"missionsList__rowLink","aria-label":a("workMissionsListOpenMissionAria",{title:r.title}),children:[e.jsxs("div",{className:"missionsList__rowMain",children:[e.jsx("span",{className:`missionsList__dot missionsList__dot--${r.status}`,"aria-hidden":"true"}),e.jsxs("div",{className:"missionsList__rowText",children:[e.jsx("span",{className:"missionsList__rowTitle",children:r.title}),r.summary?e.jsx("span",{className:"missionsList__rowSummary",children:r.summary}):null]})]}),e.jsxs("div",{className:"missionsList__rowMeta",children:[r.managedWorkTitle?e.jsx("span",{className:"missionsList__chip missionsList__chip--workItem",children:r.managedWorkTitle}):null,e.jsx("span",{className:"missionsList__metric missionsList__metric--muted",children:W(r.updatedAt,a)}),e.jsx("span",{className:`missionsList__statusPill missionsList__statusPill--${r.status}`,children:M(r.status,a)})]})]})},r.id))})})]})}function bo(){const{missionId:t}=xe(),s=U(),a=Lt(),r=Jn(t),n=Je(),o=Se(),i=ze(),{t:l}=N(),[c,h]=m.useState(null),u=t?a.data?.missions.find(D=>D.id===t)??r.data?.mission:void 0,d=$({mutationFn:async D=>qn(D,void 0,{fallbackMessage:l("workMissionCancelError"),routeFallback:S=>l("workMissionCancelRouteFailed",{statusCode:S})}),onSuccess:async D=>{await Promise.all([s.invalidateQueries({queryKey:Tt}),s.invalidateQueries({queryKey:Ye})]),D.status==="blocked"?h(uo(D.blockers,l)):h(null)}}),w=()=>{u&&window.confirm(l("workMissionCancelConfirmation",{missionTitle:u.title}))&&(h(null),d.mutate(u.id))},y=d.error,j=y?y instanceof Error?y.message:l("workMissionCancelError"):null,_=u?.managedWorkId?n.data?.workItems.find(D=>D.id===u.managedWorkId):void 0,x=m.useMemo(()=>_?(o.data?.tasks??[]).filter(S=>S.workItemId===_.id).sort((S,C)=>C.updatedAt.localeCompare(S.updatedAt)):[],[o.data,_]),L=m.useMemo(()=>{if(x.length===0)return[];const D=new Set(x.map(C=>C.id));return(i.data?.runs??[]).filter(C=>C.taskId!==null&&D.has(C.taskId)).sort((C,I)=>I.updatedAt.localeCompare(C.updatedAt))},[i.data,x]),g=m.useMemo(()=>{const D=r.data?.runs??[];if(D.length===0)return[];const S=i.data?.runs??[],C=new Map(S.map(I=>[I.id,I]));return D.map(I=>{const b=C.get(I.id);return b||{id:I.id,title:I.title,status:I.status,summary:null,taskId:I.taskId,taskTitle:null,conversationId:I.conversationId,conversationTitle:null,parentRunId:null,parentRunTitle:null,startedAt:I.startedAt,completedAt:I.completedAt,updatedAt:I.updatedAt}}).sort((I,b)=>b.updatedAt.localeCompare(I.updatedAt))},[r.data,i.data]),k=m.useMemo(()=>{const D=new Set,S=[];for(const C of[...g,...L])D.has(C.id)||(D.add(C.id),S.push(C));return S},[g,L]);if(a.isPending&&r.isPending)return e.jsx(yo,{});if(!u)return e.jsx(No,{missionId:t??null});const R=u.status==="completed"||u.status==="failed"||u.status==="cancelled";return e.jsxs("div",{className:"missionDetail",children:[e.jsxs("header",{className:"channelTopBar missionDetailTopBar",children:[e.jsxs("div",{className:"channelTopBarStart missionDetailTopBar__start",children:[e.jsxs(B,{to:ie,className:"missionDetailTopBar__back","aria-label":l("workMissionBackArrowLabel"),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M7.5 2L3.5 6l4 4"})}),e.jsx("span",{children:l("workMissionBackLabel")})]}),e.jsx("span",{className:"missionDetailTopBar__sep",children:"›"}),e.jsx("h1",{className:"channelTopBarTitle missionDetailTopBar__title",children:u.title})]}),e.jsx("div",{className:"channelTopBarCenter missionDetailTopBar__center"}),e.jsxs("div",{className:"channelTopBarEnd missionDetailTopBar__end",children:[R?null:e.jsx("button",{type:"button",className:"missionDetailTopBar__action missionDetailTopBar__action--destructive",onClick:w,disabled:d.isPending,"aria-label":l("workMissionCancelLabel"),children:d.isPending?l("workMissionCancelLabelBusy"):l("workMissionCancelLabel")}),e.jsx("span",{className:`missionDetail__statusPill missionDetail__statusPill--${u.status}`,children:M(u.status,l)})]})]}),e.jsxs("main",{className:"missionDetail__main",children:[j?e.jsx("p",{className:"missionDetail__error",role:"alert",children:j}):null,c?e.jsx("p",{className:"missionDetail__warning",role:"alert",children:c}):null,e.jsxs("section",{className:"missionDetail__section",children:[e.jsx("h2",{className:"missionDetail__sectionHeading",children:l("workMissionSummaryTitle")}),e.jsxs("dl",{className:"missionDetail__summary",children:[e.jsxs("div",{className:"missionDetail__summaryRow",children:[e.jsx("dt",{children:l("workMissionStatusLabel")}),e.jsx("dd",{children:M(u.status,l)})]}),u.assignedAgentName?e.jsxs("div",{className:"missionDetail__summaryRow",children:[e.jsx("dt",{children:l("workMissionAssignedAgentLabel")}),e.jsx("dd",{children:u.assignedAgentName})]}):null,e.jsxs("div",{className:"missionDetail__summaryRow",children:[e.jsx("dt",{children:l("workMissionUpdatedAtLabel")}),e.jsx("dd",{children:W(u.updatedAt,l)})]}),_?e.jsxs("div",{className:"missionDetail__summaryRow",children:[e.jsx("dt",{children:l("workMissionWorkItemLabel")}),e.jsx("dd",{children:e.jsx(B,{to:Ve(_.id),className:"missionDetail__crumbLink",children:_.title})})]}):null,u.conversationId?e.jsxs("div",{className:"missionDetail__summaryRow",children:[e.jsx("dt",{children:l("workMissionConversationLabel")}),e.jsx("dd",{children:u.conversationTitle??e.jsx("code",{className:"missionDetail__monoId",children:u.conversationId})})]}):null]}),u.summary?e.jsx("p",{className:"missionDetail__summaryBody",children:u.summary}):null]}),e.jsxs("section",{className:"missionDetail__section",children:[e.jsx("h2",{className:"missionDetail__sectionHeading",children:l("workMissionTasksHeading",{count:`${x.length}`})}),_?x.length===0?e.jsx("p",{className:"missionDetail__empty",children:l("workMissionNoTasks")}):e.jsx("ul",{className:"missionDetail__transitiveList",children:x.map(D=>e.jsx("li",{className:"missionDetail__transitiveRow",children:e.jsxs(B,{to:Nt(D.id),className:"missionDetail__transitiveLink",children:[e.jsx("span",{className:"missionDetail__transitiveTitle",children:D.title}),e.jsx("span",{className:`missionDetail__transitiveStatus missionDetail__transitiveStatus--${D.status}`,children:M(D.status,l)}),e.jsx("span",{className:"missionDetail__transitiveTime",children:W(D.updatedAt,l)})]})},D.id))}):e.jsx("p",{className:"missionDetail__empty",children:l("workMissionNoLinkedWorkItemForTasks")})]}),e.jsxs("section",{className:"missionDetail__section",children:[e.jsx("h2",{className:"missionDetail__sectionHeading",children:l("workMissionRunsHeading",{count:`${k.length}`})}),k.length===0?e.jsx("p",{className:"missionDetail__empty",children:l(_?"workMissionNoTransitiveRuns":"workMissionNoLinkedWorkItemForRuns")}):e.jsx("ul",{className:"missionDetail__transitiveList",children:k.map(D=>e.jsx("li",{className:"missionDetail__transitiveRow",children:e.jsxs(B,{to:ye(D.taskId??"orphan",D.id),className:"missionDetail__transitiveLink",children:[e.jsx("span",{className:"missionDetail__transitiveTitle",children:D.title}),D.taskTitle?e.jsxs("span",{className:"missionDetail__transitiveParent",children:["↳ ",D.taskTitle]}):null,e.jsx("span",{className:`missionDetail__transitiveStatus missionDetail__transitiveStatus--${D.status}`,children:M(D.status,l)}),e.jsx("span",{className:"missionDetail__transitiveTime",children:W(D.updatedAt,l)})]})},D.id))})]})]})]})}function yo(){const{t}=N();return e.jsxs("div",{className:"missionDetail",children:[e.jsx("header",{className:"channelTopBar missionDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart missionDetailTopBar__start",children:e.jsx(B,{to:ie,className:"missionDetailTopBar__back",children:e.jsx("span",{children:t("workMissionBackLabel")})})})}),e.jsx("main",{className:"missionDetail__main",children:e.jsx("p",{className:"missionDetail__empty",children:t("workMissionLoadingLabel")})})]})}function No({missionId:t}){const{t:s}=N();return e.jsxs("div",{className:"missionDetail",children:[e.jsx("header",{className:"channelTopBar missionDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart missionDetailTopBar__start",children:e.jsx(B,{to:ie,className:"missionDetailTopBar__back",children:e.jsx("span",{children:s("workMissionBackLabel")})})})}),e.jsx("main",{className:"missionDetail__main",children:e.jsx("p",{className:"missionDetail__empty",children:t?s("workMissionNotFound",{missionId:t}):s("workMissionNoMissionId")})})]})}async function fo(t,s=oe(p.workSchedulesListLoadErrorFallback)){const a=await fetch(pa,{signal:t});return K(a,s)}async function To(t,s,a=oe(p.workScheduleUpdateFailed)){const r=await fetch(kt(t),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(s)});return K(r,a)}async function Lo(t,s=oe(p.workScheduleTestFireFailed)){const a=await fetch(ma(t),{method:"POST"});return K(a,s)}async function vo(t,s=oe(p.workScheduleDeleteFailed)){const a=await fetch(kt(t),{method:"DELETE"});return K(a,s)}const it=["schedules"];function lt(t){return["schedules",t]}function Do(){const{t}=N();return te({queryKey:it,queryFn:({signal:s})=>fo(s,t(p.workSchedulesListLoadErrorFallback))})}function So(t){const{t:s}=N();return te({queryKey:t?lt(t):["schedules","_unknown"],enabled:typeof t=="string"&&t.length>0,queryFn:async({signal:a})=>{const r=await fetch(kt(t),{signal:a});return K(r,s(p.workScheduleLoadFailed))}})}const Is=pt("en");function Ps(t,s){const a=s??Is;return t.schedule.kind==="once"?a("workScheduleSummaryOnceAt",{dateTime:ve(t.schedule.fireAt,t.timezone,s)}):a("workScheduleSummaryDailyAt",{time:t.schedule.time,timezone:t.timezone})}function ve(t,s,a){const r=a??Is;if(!t)return r("workScheduleDateNone");const n=new Date(t);return Number.isNaN(n.getTime())?t:new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",timeZone:s?.trim()||void 0}).format(n)}const Ro={claimed:"workScheduleReceiptStatusClaimed",admitted:"workScheduleReceiptStatusAdmitted",duplicate:"workScheduleReceiptStatusDuplicate",skipped:"workScheduleReceiptStatusSkipped",failed:"workScheduleReceiptStatusFailed"},Io={due:"workScheduleTriggerReasonDue",manual_test:"workScheduleTriggerReasonManualTest",startup_misfire:"workScheduleTriggerReasonStartupMisfire",retry:"workScheduleTriggerReasonRetry"},Po={per_fire:"workScheduleMissionPolicyPerFire"},Co={skip:"workScheduleConcurrencyPolicySkip",queue:"workScheduleConcurrencyPolicyQueue",replace:"workScheduleConcurrencyPolicyReplace"},Bo={skip:"workScheduleMisfirePolicySkip",fire_once:"workScheduleMisfirePolicyFireOnce",fire_all:"workScheduleMisfirePolicyFireAll"},Eo={none:"workScheduleRetryBackoffNone",fixed:"workScheduleRetryBackoffFixed",exponential:"workScheduleRetryBackoffExponential"};function Cs(t,s){return s(Ro[t])}function Ao(t,s){return s(Io[t])}function Wo(t,s){return s(Po[t])}function Mo(t,s){return s(Co[t])}function Oo(t,s){return s(Bo[t])}function Ko(t,s){return s(Eo[t])}function Fo(t){return{exportedAt:t.exportedAt,rules:t.rules.map(s=>structuredClone(s)),triggerReceipts:t.triggerReceipts.map(s=>structuredClone(s))}}function $o(t){return`${JSON.stringify(t,null,2)}
1
+ import{r as m,j as e}from"./client-DREGSZqQ.js";import{r as Ms,N as Os,C as zt,w as Xe,a as Ks,A as Fs,c as $s,d as Us,e as Gs}from"./conversationSidebarRecentEntries-y_bEg3Cp.js";import{S as Jt,d as St,e as X,f as We,g as Te,h as Me,j as tt,k as Rt,t as Qs,l as Ce,o as Hs,q as qs,v as It,w as Ke,x as Pt,y as Vs,z as ht,A as U,C as Ys,D as zs,r as Xt,E as Js,F as Xs,u as N,G as Zs,H as ea,m as p,I as K,W as ta,J as Zt,K as mt,L as es,M as sa,O as ts,P as Fe,Q as aa,T as ra,U as na,V as pt,X as z,Y as oa,Z as ia,_ as B,$ as xe,a0 as la,a1 as ca,a2 as da,a3 as oe,a4 as ua,a5 as ha,a6 as kt,a7 as ma,a8 as pa,a9 as Ct,aa as wt,c as H,ab as ka,ac as wa,ad as _a,ae as ja,af as ss,ag as xa,ah as ga,n as ba,ai as ya,aj as Na}from"./app-DTDTNtih.js";import{A as fa}from"./ActiveSessionPermissionChip-BugyYoVY.js";import{N as Ta,W as La}from"./WorkspaceAppRoutes-B8U5FWao.js";var va=class extends Jt{constructor(t,s){super(),this.options=s,this.#s=t,this.#i=null,this.#o=St(),this.bindMethods(),this.setOptions(s)}#s;#e=void 0;#a=void 0;#t=void 0;#r;#n;#o;#i;#k;#h;#m;#c;#d;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Bt(this.#e,this.options)?this.#u():this.updateResult(),this.#x())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return st(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return st(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#g(),this.#b(),this.#e.removeObserver(this)}setOptions(t){const s=this.options,a=this.#e;if(this.options=this.#s.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof X(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#y(),this.#e.setOptions(this.options),s._defaulted&&!We(this.options,s)&&this.#s.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Et(this.#e,a,this.options,s)&&this.#u(),this.updateResult(),r&&(this.#e!==a||X(this.options.enabled,this.#e)!==X(s.enabled,this.#e)||Te(this.options.staleTime,this.#e)!==Te(s.staleTime,this.#e))&&this.#w();const n=this.#_();r&&(this.#e!==a||X(this.options.enabled,this.#e)!==X(s.enabled,this.#e)||n!==this.#l)&&this.#j(n)}getOptimisticResult(t){const s=this.#s.getQueryCache().build(this.#s,t),a=this.createResult(s,t);return Sa(this,a)&&(this.#t=a,this.#n=this.options,this.#r=this.#e.state),a}getCurrentResult(){return this.#t}trackResult(t,s){return new Proxy(t,{get:(a,r)=>(this.trackProp(r),s?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(a,r))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=this.#s.defaultQueryOptions(t),a=this.#s.getQueryCache().build(this.#s,s);return a.fetch().then(()=>this.createResult(a,s))}fetch(t){return this.#u({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#t))}#u(t){this.#y();let s=this.#e.fetch(this.options,t);return t?.throwOnError||(s=s.catch(Me)),s}#w(){this.#g();const t=Te(this.options.staleTime,this.#e);if(tt.isServer()||this.#t.isStale||!Rt(t))return;const a=Qs(this.#t.dataUpdatedAt,t)+1;this.#c=Ce.setTimeout(()=>{this.#t.isStale||this.updateResult()},a)}#_(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#j(t){this.#b(),this.#l=t,!(tt.isServer()||X(this.options.enabled,this.#e)===!1||!Rt(this.#l)||this.#l===0)&&(this.#d=Ce.setInterval(()=>{(this.options.refetchIntervalInBackground||Hs.isFocused())&&this.#u()},this.#l))}#x(){this.#w(),this.#j(this.#_())}#g(){this.#c!==void 0&&(Ce.clearTimeout(this.#c),this.#c=void 0)}#b(){this.#d!==void 0&&(Ce.clearInterval(this.#d),this.#d=void 0)}createResult(t,s){const a=this.#e,r=this.options,n=this.#t,o=this.#r,i=this.#n,c=t!==a?t.state:this.#a,{state:h}=t;let u={...h},d=!1,w;if(s._optimisticResults){const I=this.hasListeners(),b=!I&&Bt(t,s),T=I&&Et(t,a,s,r);(b||T)&&(u={...u,...qs(h.data,t.options)}),s._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:y,errorUpdatedAt:j,status:_}=u;w=u.data;let x=!1;if(s.placeholderData!==void 0&&w===void 0&&_==="pending"){let I;n?.isPlaceholderData&&s.placeholderData===i?.placeholderData?(I=n.data,x=!0):I=typeof s.placeholderData=="function"?s.placeholderData(this.#m?.state.data,this.#m):s.placeholderData,I!==void 0&&(_="success",w=It(n?.data,I,s),d=!0)}if(s.select&&w!==void 0&&!x)if(n&&w===o?.data&&s.select===this.#k)w=this.#h;else try{this.#k=s.select,w=s.select(w),w=It(n?.data,w,s),this.#h=w,this.#i=null}catch(I){this.#i=I}this.#i&&(y=this.#i,w=this.#h,j=Date.now(),_="error");const L=u.fetchStatus==="fetching",g=_==="pending",k=_==="error",R=g&&L,D=w!==void 0,C={status:_,fetchStatus:u.fetchStatus,isPending:g,isSuccess:_==="success",isError:k,isInitialLoading:R,isLoading:R,data:w,dataUpdatedAt:u.dataUpdatedAt,error:y,errorUpdatedAt:j,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:L,isRefetching:L&&!g,isLoadingError:k&&!D,isPaused:u.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:k&&D,isStale:_t(t,s),refetch:this.refetch,promise:this.#o,isEnabled:X(s.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const I=C.data!==void 0,b=C.status==="error"&&!I,T=P=>{b?P.reject(C.error):I&&P.resolve(C.data)},v=()=>{const P=this.#o=C.promise=St();T(P)},O=this.#o;switch(O.status){case"pending":t.queryHash===a.queryHash&&T(O);break;case"fulfilled":(b||C.data!==O.value)&&v();break;case"rejected":(!b||C.error!==O.reason)&&v();break}}return C}updateResult(){const t=this.#t,s=this.createResult(this.#e,this.options);if(this.#r=this.#e.state,this.#n=this.options,this.#r.data!==void 0&&(this.#m=this.#e),We(s,t))return;this.#t=s;const a=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,n=typeof r=="function"?r():r;if(n==="all"||!n&&!this.#p.size)return!0;const o=new Set(n??this.#p);return this.options.throwOnError&&o.add("error"),Object.keys(this.#t).some(i=>{const l=i;return this.#t[l]!==t[l]&&o.has(l)})};this.#N({listeners:a()})}#y(){const t=this.#s.getQueryCache().build(this.#s,this.options);if(t===this.#e)return;const s=this.#e;this.#e=t,this.#a=t.state,this.hasListeners()&&(s?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#x()}#N(t){Ke.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(this.#t)}),this.#s.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Da(t,s){return X(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&X(s.retryOnMount,t)===!1)}function Bt(t,s){return Da(t,s)||t.state.data!==void 0&&st(t,s,s.refetchOnMount)}function st(t,s,a){if(X(s.enabled,t)!==!1&&Te(s.staleTime,t)!=="static"){const r=typeof a=="function"?a(t):a;return r==="always"||r!==!1&&_t(t,s)}return!1}function Et(t,s,a,r){return(t!==s||X(r.enabled,t)===!1)&&(!a.suspense||t.state.status!=="error")&&_t(t,a)}function _t(t,s){return X(s.enabled,t)!==!1&&t.isStaleByTime(Te(s.staleTime,t))}function Sa(t,s){return!We(t.getCurrentResult(),s)}var Ra=class extends Jt{#s;#e=void 0;#a;#t;constructor(t,s){super(),this.#s=t,this.setOptions(s),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const s=this.options;this.options=this.#s.defaultMutationOptions(t),We(this.options,s)||this.#s.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#a,observer:this}),s?.mutationKey&&this.options.mutationKey&&Pt(s.mutationKey)!==Pt(this.options.mutationKey)?this.reset():this.#a?.state.status==="pending"&&this.#a.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#a?.removeObserver(this)}onMutationUpdate(t){this.#r(),this.#n(t)}getCurrentResult(){return this.#e}reset(){this.#a?.removeObserver(this),this.#a=void 0,this.#r(),this.#n()}mutate(t,s){return this.#t=s,this.#a?.removeObserver(this),this.#a=this.#s.getMutationCache().build(this.#s,this.options),this.#a.addObserver(this),this.#a.execute(t)}#r(){const t=this.#a?.state??Vs();this.#e={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#n(t){Ke.batch(()=>{if(this.#t&&this.hasListeners()){const s=this.#e.variables,a=this.#e.context,r={client:this.#s,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#t.onSuccess?.(t.data,s,a,r)}catch(n){Promise.reject(n)}try{this.#t.onSettled?.(t.data,null,s,a,r)}catch(n){Promise.reject(n)}}else if(t?.type==="error"){try{this.#t.onError?.(t.error,s,a,r)}catch(n){Promise.reject(n)}try{this.#t.onSettled?.(void 0,t.error,s,a,r)}catch(n){Promise.reject(n)}}}this.listeners.forEach(s=>{s(this.#e)})})}},as=m.createContext(!1),Ia=()=>m.useContext(as);as.Provider;function Pa(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Ca=m.createContext(Pa()),Ba=()=>m.useContext(Ca),Ea=(t,s,a)=>{const r=a?.state.error&&typeof t.throwOnError=="function"?ht(t.throwOnError,[a.state.error,a]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(s.isReset()||(t.retryOnMount=!1))},Aa=t=>{m.useEffect(()=>{t.clearReset()},[t])},Wa=({result:t,errorResetBoundary:s,throwOnError:a,query:r,suspense:n})=>t.isError&&!s.isReset()&&!t.isFetching&&r&&(n&&t.data===void 0||ht(a,[t.error,r])),Ma=t=>{if(t.suspense){const a=n=>n==="static"?n:Math.max(n??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...n)=>a(r(...n)):a(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Oa=(t,s)=>t.isLoading&&t.isFetching&&!s,Ka=(t,s)=>t?.suspense&&s.isPending,At=(t,s,a)=>s.fetchOptimistic(t).catch(()=>{a.clearReset()});function Fa(t,s,a){const r=Ia(),n=Ba(),o=U(),i=o.defaultQueryOptions(t);o.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const l=o.getQueryCache().get(i.queryHash);i._optimisticResults=r?"isRestoring":"optimistic",Ma(i),Ea(i,n,l),Aa(n);const c=!o.getQueryCache().get(i.queryHash),[h]=m.useState(()=>new s(o,i)),u=h.getOptimisticResult(i),d=!r&&t.subscribed!==!1;if(m.useSyncExternalStore(m.useCallback(w=>{const y=d?h.subscribe(Ke.batchCalls(w)):Me;return h.updateResult(),y},[h,d]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),m.useEffect(()=>{h.setOptions(i)},[i,h]),Ka(i,u))throw At(i,h,n);if(Wa({result:u,errorResetBoundary:n,throwOnError:i.throwOnError,query:l,suspense:i.suspense}))throw u.error;return o.getDefaultOptions().queries?._experimental_afterQuery?.(i,u),i.experimental_prefetchInRender&&!tt.isServer()&&Oa(u,r)&&(c?At(i,h,n):l?.promise)?.catch(Me).finally(()=>{h.updateResult()}),i.notifyOnChangeProps?u:h.trackResult(u)}function te(t,s){return Fa(t,va)}function $(t,s){const a=U(),[r]=m.useState(()=>new Ra(a,t));m.useEffect(()=>{r.setOptions(t)},[r,t]);const n=m.useSyncExternalStore(m.useCallback(i=>r.subscribe(Ke.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=m.useCallback((i,l)=>{r.mutate(i,l).catch(Me)},[r]);if(n.error&&ht(r.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:o,mutateAsync:n.mutate}}const $e=Xt("work");function $a(t){return zs($e,t)}function rs(t){return Xs($e,t)}function jt(t){return Js($e,t)}function Ua(t,s){return Ys($e,t,s,"work")}function ns(){const{t}=N();return Zs("Work",t)}const Ga=[{id:"work-start-project",labelKey:p.workNewChatDraftStartProjectChipLabel,promptKey:p.workNewChatDraftStartProjectPrompt},{id:"work-add-task",labelKey:p.workNewChatDraftAddTaskChipLabel,promptKey:p.workNewChatDraftAddTaskPrompt},{id:"work-plan-sprint",labelKey:p.workNewChatDraftPlanSprintChipLabel,promptKey:p.workNewChatDraftPlanSprintPrompt},{id:"work-schedule-review",labelKey:p.workNewChatDraftScheduleReviewChipLabel,promptKey:p.workNewChatDraftScheduleReviewPrompt},{id:"work-triage-backlog",labelKey:p.workNewChatDraftTriageBacklogChipLabel,promptKey:p.workNewChatDraftTriageBacklogPrompt}];function Qa(t,s){return Ga.map(a=>({id:a.id,label:s(a.labelKey),onClick:()=>t.onComposerChange(s(a.promptKey))}))}function os(t){return e.jsx(zt,{surface:t.draftSurface,onDismiss:t.draftSurface!=="work"?()=>t.onDraftSurfaceChange("work"):void 0})}function Ha(t){const{t:s}=N(),a=ea(t.payload.chat.advancedDraftControls,"work"),r=Ms({advancedDraftControlsEnabled:a,entryPreset:t.entryPreset??"default",showStructuredDraftControls:!0,hasVisibleParallelDraftTargets:(t.parallelTargets?.length??0)>1});return e.jsx(Os,{...t,draftChrome:{surfaceTag:os(t)},builderControls:r,starterChips:{leading:Qa(t,s)}})}function qa(t){const s=t.greeting??void 0;return e.jsx(Ta,{...t,greeting:s,surfaceTag:os(t)})}function Va(t){return t.draftDefaultRecipientCatId?e.jsx(qa,{...t}):e.jsx(Ha,{...t})}async function Ya(t,s,a){const r=await fetch(Zt,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function is(t,s,a){const r=await fetch(sa(t),{method:"DELETE",signal:a});return K(r,s)}async function za(t,s,a){const r=await fetch(es,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function Ja(t,s,a){const r=await fetch(aa(t),{method:"DELETE",signal:a});return K(r,s)}async function Xa(t,s,a){const r=await fetch(ts,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function ls(t,s,a){const r=await fetch(ts,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function Za(t,s,a){const r=await fetch(ta,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function er(t,s,a){const r=await fetch(mt,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function tr(t,s,a){const r=await fetch(Fe(t),{method:"DELETE",signal:a});return K(r,s)}async function sr(t,s,a,r){const n=await fetch("/api/core/approvals",{method:"POST",headers:{"content-type":"application/json",Accept:"application/json"},body:JSON.stringify({taskId:t,status:s.action==="approve"?"approved":"rejected",action:s.action,decidedByActorId:s.decidedByActorId??null,notes:s.notes??null,taskStatus:s.action==="approve"?"approved":"cancelled"}),signal:r});return K(n,a)}async function ar(t,s,a){const r=await fetch(`${Fe(t)}/supervised-run`,{method:"POST",headers:{Accept:"application/json"},signal:a});return K(r,s)}async function rr(t,s,a){const r=await fetch(`${Fe(t)}/golden-path/lifecycle/${s}`,{method:"POST",headers:{Accept:"application/json"},signal:a});return K(r,"The run lifecycle action failed.")}async function nr(t,s){const a=await fetch(`${Fe(t)}/golden-path/retry-delivery`,{method:"POST",headers:{Accept:"application/json"},signal:s});return K(a,"Retrying the transport delivery failed.")}async function or(t,s,a){const r=await fetch(t.path,{method:t.method,headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t.body),signal:a});return K(r,s)}const Wt="actor-cat-";function ir(t){if(!t||!t.startsWith(Wt))return null;const s=t.slice(Wt.length);return s.length>0?s:null}function cs(t){return t.flatMap(s=>{const a=ir(s.actorId);return a?[{...s,catId:a}]:[]})}async function lr(t,s){const a=await fetch(ra,{signal:s});return K(a,t)}const De=["workDashboard"];function cr(t){return te({queryKey:De,queryFn:({signal:s})=>lr(t,s)})}function me(t,s){const a=t.statusText.trim();return new Error(a?s(p.workQueryHttpErrorWithStatusText,{status:t.status,statusText:a}):s(p.workQueryHttpError,{status:t.status}))}const we=["tasks"];async function dr(t){const s=await fetch(mt,{headers:{accept:"application/json"}});if(!s.ok)throw me(s,t);return await s.json()}function Se(){const{t}=N();return te({queryKey:we,queryFn:()=>dr(t)})}const Y=["workGraph"],pe={objects:[],evidenceAttachments:[],gateDecorators:[],links:[],linksByEndpoint:{},diagnostics:[]};async function ur(t){const s=await fetch(na);return K(s,t)}function ke(t){return te({queryKey:Y,queryFn:()=>ur(t)})}function hr(t){switch(t){case"chat":return"Chat";case"code":return"Code";default:return"Work"}}const de=pt("en"),mr={acknowledge:p.workExecutionActionAcknowledge,approve:p.workExecutionActionApprove,approval_pending:p.workExecutionReasonApprovalPending,approved:p.workExecutionApprovalStatusApproved,artifact_only:p.workExecutionDeliveryModeArtifactOnly,child_tasks_in_progress:p.workExecutionReasonChildTasksInProgress,commit_only:p.workExecutionDeliveryModeCommitOnly,complete:p.workExecutionActionComplete,create_commit:p.workExecutionActionCreateCommit,deploy_preview:p.workExecutionDeliveryModeDeployPreview,dispatch:p.workExecutionActionDispatch,failed:p.workExecutionReplayStateFailed,in_progress:p.workExecutionReplayStateInProgress,max_dispatches:p.workExecutionReasonMaxDispatches,no_valid_targets:p.workExecutionReasonNoValidTargets,not_requested:p.workExecutionApprovalStatusNotRequested,open_pull_request:p.workExecutionActionOpenPullRequest,orchestrator_replay:p.workExecutionReplaySourceOrchestratorReplay,orchestrator_startup_recovery:p.workExecutionReplaySourceOrchestratorStartupRecovery,pdca:p.workExecutionStrategyPdca,pending:p.workExecutionReplayStatePending,plan_and_execute:p.workExecutionStrategyPlanAndExecute,pr_with_checks:p.workExecutionDeliveryModePrWithChecks,publish_preview:p.workExecutionActionPublishPreview,push_branch:p.workExecutionDeliveryModePushBranch,ready:p.workExecutionReplayStateReady,react:p.workExecutionStrategyReact,reflexion:p.workExecutionStrategyReflexion,reject:p.workExecutionActionReject,rejected:p.workExecutionApprovalStatusRejected,request_review:p.workExecutionActionRequestReview,retry:p.workExecutionActionRetry,retry_available:p.workExecutionReasonRetryAvailable,reroute:p.workExecutionActionReroute,run_blocked:p.workExecutionReasonRunBlocked,run_failed:p.workExecutionReasonRunFailed,user_cancelled:p.workExecutionReasonUserCancelled,wait:p.workExecutionActionWait,wait_for_checks:p.workExecutionActionWaitForChecks,workflow_continuation_replay:p.workExecutionReplaySourceWorkflowContinuationReplay,workflow_review_required:p.workExecutionReasonWorkflowReviewRequired};function ds(t){return t.trim().toLowerCase().replace(/-/gu,"_")}function Re(t,s,a){const r=t?.trim();if(!r)return s;const n=mr[ds(r)];return n?a(n):r.replace(/[_-]+/gu," ").replace(/\s+/gu," ").replace(/\b\w/gu,o=>o.toUpperCase())}function at(t,s=de,a){const r=typeof s=="function"?s:de,n=typeof s=="string"?s:a??r(p.workWarRoomMetaValueNone),o=(t??[]).map(i=>Re(i,"",r)).filter(i=>i.length>0);return o.length>0?o.join(", "):n}function se(t,s=de,a){return Re(t,a??s(p.workWarRoomMetaValueNotSpecified),s)}function pr(t,s=de){return ds(t??"")==="pending"?s(p.workExecutionApprovalStatusPending):se(t,s)}function us(t,s=de){return t?.trim()?t==="chat"||t==="work"||t==="code"?hr(t):Re(t,t,s):s(p.workWarRoomMetaValueUnassigned)}function hs(t,s=de){return Re(t,s(p.workWarRoomMetaValueNotSpecified),s)}function xt(t,s=de){return Re(t,s(p.workWarRoomMetaValueNotSpecified),s)}function Ue(t){return`${t.recordFamily}:${t.recordId}`}const kr={agent:"workObjectKindAgent",container:"workObjectKindContainer",conversation:"workObjectKindConversation",turn:"workObjectKindTurn",lane:"workObjectKindLane",project:"workObjectKindProject",work_item:"workObjectKindWorkItem",task:"workObjectKindTask",mission:"workObjectKindMission",run:"workObjectKindRun",artifact:"workObjectKindArtifact",activity:"workObjectKindActivity",outcome:"workObjectKindOutcome",approval_binding:"workObjectKindApprovalBinding"},wr={decision_needed:"workObjectAttentionDecisionNeeded",blocked:"workObjectAttentionBlocked",failed:"workObjectAttentionFailed",ready_to_review:"workObjectAttentionReadyToReview",recently_shipped:"workObjectAttentionRecentlyShipped"},_r={artifact:"workObjectKindArtifact",activity:"workObjectKindActivity",outcome:"workObjectKindOutcome"},jr={interaction:"workTopdownSystemMapLayerInteractionLabel",planning:"workTopdownSystemMapLayerPlanningLabel",execution:"workTopdownSystemMapLayerExecutionLabel"},xr={work:"platformProductWorkSettingsLabel",code:"platformProductCodeSettingsLabel",chat:"platformProductChatSettingsLabel",unbound:"workTopdownTaskProductBindingUnbound"},gr={error:"workTopdownBrokenLinksSeverityErrorLabel",warning:"workTopdownBrokenLinksSeverityWarningLabel",info:"workTopdownBrokenLinksSeverityInfoLabel"},br={broken_fk:"workTopdownDiagnosticKindBrokenFk",missing_project_anchor:"workTopdownDiagnosticKindMissingProjectAnchor",missing_planning_execution_bridge:"workTopdownDiagnosticKindMissingPlanningExecutionBridge",unanchored_run:"workTopdownDiagnosticKindUnanchoredRun",unanchored_evidence:"workTopdownDiagnosticKindUnanchoredEvidence",missing_gate_subject:"workTopdownDiagnosticKindMissingGateSubject",orphan_link:"workTopdownDiagnosticKindOrphanLink",link_cycle:"workTopdownDiagnosticKindLinkCycle"},yr={assistant:"workActorRoleAssistant",boss:"workActorRoleBoss",coder:"workActorRoleCoder",coordinator:"workActorRoleCoordinator",critic:"workActorRoleCritic",drafter:"workActorRoleDrafter",main_coder:"workActorRoleMainCoder",orchestrator:"workActorRoleOrchestrator",owner:"workActorRoleOwner",planner:"workActorRolePlanner",reviewer:"workActorRoleReviewer",summarizer:"workActorRoleSummarizer"},Nr={github:"GitHub",gitlab:"GitLab",gitea:"Gitea",redmine:"Redmine",bugzilla:"Bugzilla"};function ae(t,s){const a=kr[t];return a?s(a):s("workObjectKindUnknown",{kind:t.replace(/_/g," ")})}function re(t,s){const a=wr[t];return a?s(a):t==="none"?null:s("workObjectAttentionUnknown",{attention:t.replace(/_/g," ")})}function fr(t,s){return s(_r[t])}function rt(t,s){return s(jr[t])}function gt(t,s){return s(xr[t])}function Tr(t,s){return s(gr[t])}function ms(t,s){return s(br[t])}function ge(t,s){const a=t.trim().toLowerCase(),r=yr[a];return r?s(r):t}function ps(t,s){const a=String(t).replace(/_/g," ");return t==="not_requested"?s("workObjectGateStateNotRequested"):t==="pending"?s("workObjectGateStatePending"):t==="approved"?s("workObjectGateStateApproved"):t==="rejected"?s("workObjectGateStateRejected"):s("workObjectGateStateUnknown",{state:a})}function ee(t){const s=Nr[t.provider]??t.provider;return t.externalType==="issue"?`${s} #${t.externalId}`:`${s} ${t.externalType} ${t.externalId}`}function bt(t){if(!t)return!1;try{const s=new URL(t);return s.protocol==="http:"||s.protocol==="https:"}catch{return!1}}function be(t){const s=new Map,a=new Map;for(const o of t.objects)s.set(o.id,o),a.set(`${o.sourceRecordFamily}:${o.sourceRecordId}`,o);const r=new Map;for(const o of t.evidenceAttachments){const i=r.get(o.anchorObjectId)??[];i.push(o),r.set(o.anchorObjectId,i)}const n=new Map;for(const o of t.gateDecorators){const i=n.get(o.subjectObjectId)??[];i.push(o),n.set(o.subjectObjectId,i)}return{objectsById:s,objectsByCoreRef:a,evidenceByAnchor:r,gatesBySubject:n}}function Lr(t,s,a,r){if(r<=0)return[];const n=`${t.recordFamily}:${t.recordId}`,o=new Set([n]),i=[],l=[{key:n,depth:0}],c=new Map;for(const h of s){if(h.kind!=="blocks")continue;const u=`${h.targetRecordFamily}:${h.targetRecordId}`,d=c.get(u)??[];d.push(h),c.set(u,d)}for(;l.length>0;){const{key:h,depth:u}=l.shift();if(u>=r)continue;const d=c.get(h)??[];for(const w of d){const y=`${w.sourceRecordFamily}:${w.sourceRecordId}`;if(o.has(y))continue;o.add(y);const j=a.get(y);j&&(i.push(j),l.push({key:y,depth:u+1}))}}return i}function W(t,s){const a=Date.parse(t);if(Number.isNaN(a))return t;const r=Date.now()-a;if(r<0)return s("workTopdownRelativeJustNow");const n=Math.round(r/6e4);if(n<1)return s("workTopdownRelativeJustNow");if(n<60)return s("workTopdownRelativeMinutesAgo",{count:`${n}`});const o=Math.round(n/60);if(o<48)return s("workTopdownRelativeHoursAgo",{count:`${o}`});const i=Math.round(o/24);return s("workTopdownRelativeDaysAgo",{count:`${i}`})}function Ge({object:t,evidence:s,gates:a,selected:r,onSelect:n}){const{t:o}=N(),i=ae(t.kind,o),l=t.attention==="none"?null:re(t.attention,o),c=M(t.status,o),h=t.kind==="task"&&t.productBinding?gt(t.productBinding,o):null,u=t.kind==="run"?o("workTopdownParentTaskOwningLabel"):o("workTopdownParentTaskLabel"),d=t.kind==="work_item"&&t.linkedWorkItemTitle?o("workTopdownParentWorkItemLabel",{parentWorkItemTitle:t.linkedWorkItemTitle}):null,w=t.externalBindings??[];return e.jsxs("article",{className:`topDownCard topDownCard--${t.kind} topDownCard--attention-${t.attention}`+(r?" topDownCard--selected":""),role:"button",tabIndex:0,onClick:()=>n(t.id),onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),n(t.id))},children:[e.jsxs("header",{className:"topDownCard__head",children:[e.jsx("span",{className:"topDownCard__kind",children:i}),t.kind==="task"&&t.productBinding&&h?e.jsx("span",{className:`topDownCard__binding topDownCard__binding--${t.productBinding}`,title:o("workTopdownTaskProductBindingTitle",{productBinding:h}),children:h}):null,l?e.jsx("span",{className:`topDownCard__attention topDownCard__attention--${t.attention}`,children:l}):null,e.jsx("span",{className:"topDownCard__status",children:c})]}),e.jsx("h4",{className:"topDownCard__title",children:t.title}),t.summary?e.jsx("p",{className:"topDownCard__summary",children:t.summary}):null,t.nextAction?e.jsxs("p",{className:"topDownCard__next",children:["→ ",t.nextAction]}):null,s.total>0||a.length>0||w.length>0||t.ownerRole||(t.kind==="run"||t.kind==="task")&&t.linkedTaskTitle||t.kind==="work_item"&&t.linkedWorkItemTitle?e.jsxs("footer",{className:"topDownCard__foot",children:[t.ownerRole?e.jsx("span",{className:"topDownCard__role",children:ge(t.ownerRole,o)}):null,(t.kind==="run"||t.kind==="task")&&t.linkedTaskTitle?e.jsxs("span",{className:"topDownCard__chip topDownCard__chip--parentTask",title:o("workTopdownParentTaskTooltip",{linkedTaskTitle:t.linkedTaskTitle,linkType:t.kind==="run"?o("workTopdownParentTaskOwningLabel"):o("workTopdownParentTaskLabel")}),children:[u,": ",t.linkedTaskTitle]}):null,t.kind==="work_item"&&t.linkedWorkItemTitle?e.jsx("span",{className:"topDownCard__chip topDownCard__chip--parentTask",title:o("workTopdownParentWorkItemLabel",{parentWorkItemTitle:t.linkedWorkItemTitle}),children:d}):null,w.map(y=>e.jsx("span",{className:"topDownCard__chip topDownCard__chip--external",title:o("workTopdownExternalBindingTooltip",{externalBinding:ee(y)}),children:ee(y)},`${y.provider}:${y.externalType}:${y.externalId}`)),s.artifact>0?e.jsxs("span",{className:"topDownCard__chip topDownCard__chip--artifact",children:["📎 ",s.artifact]}):null,s.activity>0?e.jsxs("span",{className:"topDownCard__chip topDownCard__chip--activity",children:["📜 ",s.activity]}):null,s.outcome>0?e.jsxs("span",{className:"topDownCard__chip topDownCard__chip--outcome",children:["🎯 ",s.outcome]}):null,a.map(y=>e.jsxs("span",{className:`topDownCard__chip topDownCard__chip--gate-${y.state}`,children:["⊘ ",ps(y.state,o)]},y.gateObjectId))]}):null]})}function Qe(t,s){const a=t.evidenceByAnchor.get(s),r={artifact:0,activity:0,outcome:0,total:0};if(!a)return r;for(const n of a)r[n.relation]+=1,r.total+=1;return r}function M(t,s){return t==="draft"?s("workObjectStatusDraft"):t==="planned"?s("workObjectStatusPlanned"):t==="active"?s("workObjectStatusActive"):t==="paused"?s("workObjectStatusPaused"):t==="archived"?s("workObjectStatusArchived"):t==="ready"?s("workObjectStatusReady"):t==="in_progress"?s("workObjectStatusInProgress"):t==="blocked"?s("workObjectStatusBlocked"):t==="completed"?s("workObjectStatusCompleted"):t==="cancelled"?s("workObjectStatusCancelled"):t==="running"?s("workObjectStatusRunning"):t==="queued"?s("workObjectStatusQueued"):s("workObjectStatusUnknown",{status:t.replace(/_/g," ")})}const vr=pt("en"),Dr={"Approval requested":p.workTimelineTitleApprovalRequested,"Approval decided":p.workTimelineTitleApprovalDecided,"Operator action":p.workTimelineTitleOperatorAction,"Artifact recorded":p.workTimelineTitleArtifactRecorded,"Checkpoint recorded":p.workTimelineTitleCheckpointRecorded,"Work item updated":p.workTimelineTitleWorkItemUpdated,"Status changed":p.workTimelineTitleStatusChanged,Note:p.workTimelineTitleNote};function Sr(t,s){switch(t){case"approval":return s(p.sharedOperatorTraceKindApproval);case"checkpoint":return s(p.sharedOperatorTraceKindCheckpoint);case"dispatch":return s(p.sharedOperatorTraceKindDispatch);case"error":return s(p.sharedOperatorTraceKindError);case"outcome":return s(p.sharedOperatorTraceKindOutcome);case"status":return s(p.sharedOperatorTraceKindStatus);case"note":return s(p.sharedOperatorTraceKindNote);default:return t}}function Rr(t,s){switch(t){case"provider-agent run loop":return s(p.workTimelineEvidenceProviderAgentRunLoop);case"supervision evidence":return s(p.workTimelineEvidenceSupervision);default:return t}}function Ir(t,s=vr){const a=Dr[t];if(a)return s(a);const r=/^Approval binding \((.+)\)$/u.exec(t);if(r)return s(p.workTimelineTitleApprovalBinding,{kind:r[1]});const n=/^Trace \((.+)\)$/u.exec(t);if(n)return s(p.workTimelineTitleTrace,{kind:Sr(n[1]??"",s)});const o=/^Checkpoint: (.+)$/u.exec(t);if(o)return s(p.workTimelineTitleCheckpoint,{label:o[1]});const i=/^Provider-agent plan: (.+)$/u.exec(t);if(i)return s(p.workTimelineTitleProviderAgentPlan,{planId:i[1]});const l=/^Evidence: (.+)$/u.exec(t);return l?s(p.workTimelineTitleEvidence,{source:Rr(l[1]??"",s)}):t}function Pr(t,s){const a=t.trim();if(a.length===0)return null;switch(a){case"title is required.":return s("workCrudErrorTitleRequired");case"Invalid input":return s("workCrudErrorInvalidInput");case"Project id is required.":return s("workCrudErrorProjectIdRequired");case"Work item id is required.":return s("workCrudErrorWorkItemIdRequired");case"Task id is required.":return s("workCrudErrorTaskIdRequired");case"must be a string when provided.":return s("workCrudErrorMustBeStringWhenProvided");case"metadata must be an object when provided.":return s("workCrudErrorMetadataObjectRequired")}let r=/^No project with id (.+)\.$/u.exec(a);return r?s("workCrudErrorProjectNotFound",{id:r[1]??""}):(r=/^No work item with id (.+)\.$/u.exec(a),r?s("workCrudErrorWorkItemNotFound",{id:r[1]??""}):(r=/^No task with id (.+)\.$/u.exec(a),r?s("workCrudErrorTaskNotFound",{id:r[1]??""}):(r=/^(.+) must be a string or null\.$/u.exec(a),r?s("workCrudErrorFieldStringOrNull",{fieldName:r[1]??""}):(r=/^(.+) must be a string\[\]\.$/u.exec(a),r?s("workCrudErrorFieldStringArray",{fieldName:r[1]??""}):(r=/^must be one of: (.+)\.$/u.exec(a),r?s("workCrudErrorMustBeOneOf",{values:r[1]??""}):null)))))}function V(t,s,a){return t instanceof Error?Pr(t.message,a)??t.message:s}function He(t,s){if(!t)return s("workWarRoomNotRecorded");const a=new Date(t);return Number.isNaN(a.getTime())?t:a.toLocaleString()}function qe(t,s){return t.length>0?t.join(", "):s("workWarRoomNone")}function ks(t){switch(t){case"attention":return"operatorStatusBadge isAttention";case"error":return"operatorStatusBadge isError";case"progress":return"operatorStatusBadge isProgress";case"success":return"operatorStatusBadge isSuccess";default:return"operatorStatusBadge isMuted"}}function ws(t,s){return t==="attention"?s("workWarRoomAttentionAttention"):t==="error"?s("workWarRoomAttentionError"):t==="progress"?s("workWarRoomAttentionProgress"):t==="success"?s("workWarRoomAttentionSuccess"):t==="muted"?s("workWarRoomAttentionMuted"):s("workWarRoomAttentionFallback",{severity:t})}function Ie(t,s){if(!t)return s("workWarRoomNoStatus");const a=M(t,s);return a===t?s("workWarRoomStatusFallback",{status:t}):a}function Pe(t){switch(t){case"blocked":case"paused":case"cancelled":return"operatorStatusBadge isError";case"ready":case"pending_approval":case"planned":return"operatorStatusBadge isAttention";case"active":case"in_progress":return"operatorStatusBadge isProgress";case"completed":case"archived":return"operatorStatusBadge isSuccess";default:return"operatorStatusBadge isMuted"}}function Be({label:t,value:s,helper:a}){return e.jsxs("article",{className:"operatorCard workWarRoomSummaryCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:t}),e.jsx("span",{className:"operatorStatusBadge isMuted",children:s})]}),e.jsx("p",{children:a})]})}function ue({eyebrow:t,title:s,summary:a}){return e.jsxs("div",{className:"operatorPanelHeader",children:[e.jsxs("div",{children:[e.jsx("p",{className:"operatorEyebrow",children:t}),e.jsx("h2",{children:s})]}),e.jsx("span",{className:"operatorStatusBadge isMuted",children:a})]})}function Cr({taskId:t,t:s}){const a=z();return e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{a(`/work/tasks/${encodeURIComponent(t)}`)})},children:s("workWarRoomOpenTask")})}function yt({taskId:t,taskContext:s,nextActions:a=[],isTaskActionPending:r=!1,onTaskAction:n,t:o}){const i=z(),l=n,c=l?a.filter(Br):[];return e.jsxs("div",{className:"workWarRoomHeaderActions",children:[c.map(h=>e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>l?.(h.action),disabled:r,children:r?o("workWarRoomActionBusy"):se(h.kind,o)},`${t}:${h.kind}`)),e.jsx(Cr,{taskId:t,t:o}),s.projectId?e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{i(`/work/projects/${encodeURIComponent(s.projectId)}`)})},children:o("workWarRoomOpenProject")}):null,s.workItemId?e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{i(`/work/work-items/${encodeURIComponent(s.workItemId)}`)})},children:o("workWarRoomOpenWorkItem")}):null,s.conversationSourceChannelId?e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{i(jt(s.conversationSourceChannelId))})},children:o("workWarRoomOpenBriefingThread")}):null,cs(s.assignedActors).map(h=>e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{i(rs(h.catId))})},children:o("workWarRoomOpenActor",{actorName:h.displayName})},h.actorId))]})}function Br(t){return(t.kind==="approve"||t.kind==="reject")&&t.action!==null}function Er({items:t,totalAvailable:s,isTaskActionPending:a,onTaskAction:r,t:n}){return e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:n("workWarRoomOperateEyebrow"),title:n("workWarRoomOperatorInbox"),summary:n("workWarRoomCountSummary",{count:t.length,total:s})}),t.length===0?e.jsxs("article",{className:"operatorCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:n("workWarRoomOperatorInboxEmptyTitle")}),e.jsx("span",{className:"operatorStatusBadge isMuted",children:n("workWarRoomOperatorInboxEmptyBadge")})]}),e.jsx("p",{children:n("workWarRoomOperatorInboxEmptyBody")})]}):e.jsx("div",{className:"workWarRoomTaskGrid",children:t.map(o=>e.jsxs("article",{className:"operatorCard workWarRoomTaskCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:o.taskTitle}),e.jsxs("div",{className:"workWarRoomBadgeRow",children:[e.jsx("span",{className:ks(o.attention.severity),children:ws(o.attention.severity,n)}),e.jsx("span",{className:Pe(o.taskStatus),children:Ie(o.taskStatus,n)})]})]}),e.jsx("p",{children:o.summary??n("workWarRoomNoTaskSummary")}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelReasons"),":"," ",at(o.attention.reasons,n)]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelActions"),":"," ",at(o.nextActions.map(i=>i.kind),n)]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelProduct"),":"," ",us(o.planning.effectiveProduct,n)]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelStrategy"),":"," ",hs(o.runtimeBridge.request.requestedStrategy,n)]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelDelivery"),":"," ",xt(o.runtimeDeliveryIntent?.mode,n)]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelWorkflow"),":"," ",se(o.workflowContinuation?.blockedReason,n,n("workWarRoomMetaValueNoReplayBlock"))]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelLatest"),":"," ",o.latestTimelineItem?Ir(o.latestTimelineItem.title,n):n("workWarRoomMetaValueNoTimelineItem")]}),e.jsx("span",{children:He(o.latestTimelineItem?.timestamp,n)})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelProject"),": ",o.taskContext.projectTitle??n("workWarRoomNoLinkedProject")]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelWorkItem"),":"," ",o.taskContext.workItemTitle??n("workWarRoomNoLinkedWorkItem")]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelConversation"),":"," ",o.taskContext.conversationTitle??n("workWarRoomNoLinkedConversation")]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelActors"),":"," ",qe(o.taskContext.assignedActors.map(i=>i.displayName),n)]})]}),e.jsx(yt,{taskId:o.taskId,taskContext:o.taskContext,nextActions:o.nextActions,isTaskActionPending:a,onTaskAction:r,t:n})]},o.taskId))})]})}function Ar({items:t,totalAvailable:s,isTaskActionPending:a,onTaskAction:r,t:n}){return e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:n("workWarRoomGovernanceEyebrow"),title:n("workWarRoomControlPlane"),summary:n("workWarRoomCountSummary",{count:t.length,total:s})}),t.length===0?e.jsxs("article",{className:"operatorCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:n("workWarRoomControlPlaneEmptyTitle")}),e.jsx("span",{className:"operatorStatusBadge isMuted",children:n("workWarRoomControlPlaneEmptyBadge")})]}),e.jsx("p",{children:n("workWarRoomControlPlaneEmptyBody")})]}):e.jsx("div",{className:"workWarRoomTaskGrid",children:t.map(o=>e.jsxs("article",{className:"operatorCard workWarRoomTaskCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:o.taskId}),e.jsxs("div",{className:"workWarRoomBadgeRow",children:[e.jsx("span",{className:ks(o.attention.severity),children:ws(o.attention.severity,n)}),e.jsx("span",{className:Pe(o.taskStatus),children:Ie(o.taskStatus,n)})]})]}),e.jsx("p",{children:o.workflowContinuation?.targetNames.length?n("workWarRoomControlPlaneTargets",{targets:o.workflowContinuation.targetNames.join(", ")}):o.workflowContinuation?.blockedReason?n("workWarRoomControlPlaneBlockedBy",{reason:se(o.workflowContinuation.blockedReason,n)}):n("workWarRoomControlPlaneNoTargets")}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelProduct"),":"," ",us(o.planning.effectiveProduct,n)]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelStrategy"),":"," ",hs(o.planning.effectiveStrategy,n)]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelNext"),":"," ",at(o.nextActions.map(i=>i.kind),n)]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelDelivery"),":"," ",xt(o.runtimeDeliveryIntent?.mode,n)]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelReplay"),":"," ",se(o.workflowContinuation?.replayState,n,n("workWarRoomMetaValueNotRecorded"))]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelBlocked"),":"," ",se(o.workflowContinuation?.blockedReason,n,n("workWarRoomMetaValueNo"))]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelProject"),":"," ",o.taskContext.projectTitle??n("workWarRoomNoLinkedProject")]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelWorkItem"),":"," ",o.taskContext.workItemTitle??n("workWarRoomNoLinkedWorkItem")]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[n("workWarRoomMetaLabelConversation"),":"," ",o.taskContext.conversationTitle??n("workWarRoomNoLinkedConversation")]}),e.jsxs("span",{children:[n("workWarRoomMetaLabelActors"),":"," ",qe(o.taskContext.assignedActors.map(i=>i.displayName),n)]})]}),e.jsx(yt,{taskId:o.taskId,taskContext:o.taskContext,nextActions:o.nextActions,isTaskActionPending:a,onTaskAction:r,t:n})]},o.taskId))})]})}function Wr({items:t,totalAvailable:s,t:a}){const r=z();return e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:a("workWarRoomPortfolioEyebrow"),title:a("workWarRoomProjects"),summary:a("workWarRoomCountSummary",{count:t.length,total:s})}),t.length===0?e.jsxs("article",{className:"operatorCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:a("workWarRoomProjectsEmptyTitle")}),e.jsx("span",{className:"operatorStatusBadge isMuted",children:a("workWarRoomProjectsEmptyBadge")})]}),e.jsx("p",{children:a("workWarRoomProjectsEmptyBody")})]}):e.jsx("div",{className:"workWarRoomTaskGrid",children:t.map(n=>e.jsxs("article",{className:"operatorCard workWarRoomTaskCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:n.title}),e.jsx("span",{className:Pe(n.status),children:Ie(n.status,a)})]}),e.jsx("p",{children:n.summary??a("workWarRoomNoProjectSummary")}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelOwner"),": ",n.ownerName]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelRepo"),": ",n.repoPath??a("workWarRoomMetaValueNotBound")]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelWorkItems"),": ",n.linkedWorkItemCount]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelTasks"),": ",n.linkedTaskCount]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelConversation"),": ",n.primaryConversationTitle??a("workWarRoomNoPrimaryConversation")]}),e.jsx("span",{children:He(n.updatedAt,a)})]}),e.jsxs("div",{className:"workWarRoomHeaderActions",children:[e.jsx(Kr,{projectId:n.id,t:a}),n.primaryConversationSourceChannelId?e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{r(jt(n.primaryConversationSourceChannelId))})},children:a("workWarRoomOpenBriefingThread")}):null]})]},n.id))})]})}function Mr({items:t,totalAvailable:s,t:a}){const r=z();return e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:a("workWarRoomManagedWorkEyebrow"),title:a("workWarRoomWorkItems"),summary:a("workWarRoomCountSummary",{count:t.length,total:s})}),t.length===0?e.jsxs("article",{className:"operatorCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:a("workWarRoomWorkItemsEmptyTitle")}),e.jsx("span",{className:"operatorStatusBadge isMuted",children:a("workWarRoomWorkItemsEmptyBadge")})]}),e.jsx("p",{children:a("workWarRoomWorkItemsEmptyBody")})]}):e.jsx("div",{className:"workWarRoomTaskGrid",children:t.map(n=>e.jsxs("article",{className:"operatorCard workWarRoomTaskCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:n.title}),e.jsx("span",{className:Pe(n.status),children:Ie(n.status,a)})]}),e.jsx("p",{children:n.summary??a("workWarRoomNoWorkItemSummary")}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelProject"),":"," ",n.projectTitle??a("workWarRoomNoLinkedProject")]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelTask"),":"," ",n.taskTitle??a("workWarRoomNoLinkedTask")]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelOwner"),": ",n.ownerName]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelActors"),":"," ",qe(n.assignedActors.map(o=>o.displayName),a)]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelConversation"),": ",n.conversationTitle??a("workWarRoomNoLinkedConversation")]}),e.jsx("span",{children:He(n.updatedAt,a)})]}),e.jsxs("div",{className:"workWarRoomHeaderActions",children:[e.jsx(Fr,{workItemId:n.id,t:a}),n.conversationSourceChannelId?e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{r(jt(n.conversationSourceChannelId))})},children:a("workWarRoomOpenBriefingThread")}):null,cs(n.assignedActors).map(o=>e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{r(rs(o.catId))})},children:a("workWarRoomOpenActor",{actorName:o.displayName})},o.actorId))]})]},n.id))})]})}function Or({items:t,totalAvailable:s,t:a}){return e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:a("workWarRoomRecoveryEyebrow"),title:a("workWarRoomRecovery"),summary:a("workWarRoomCountSummary",{count:t.length,total:s})}),t.length===0?e.jsxs("article",{className:"operatorCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:a("workWarRoomRecoveryEmptyTitle")}),e.jsx("span",{className:"operatorStatusBadge isSuccess",children:a("workWarRoomRecoveryEmptyBadge")})]}),e.jsx("p",{children:a("workWarRoomRecoveryEmptyBody")})]}):e.jsx("div",{className:"workWarRoomTaskGrid",children:t.map(r=>e.jsxs("article",{className:"operatorCard workWarRoomTaskCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:r.taskId}),e.jsxs("div",{className:"workWarRoomBadgeRow",children:[e.jsx("span",{className:r.canRetry?"operatorStatusBadge isAttention":"operatorStatusBadge isMuted",children:r.canRetry?a("workWarRoomMetaLabelRetryAvailable"):a("workWarRoomMetaLabelWatch")}),e.jsx("span",{className:Pe(r.taskStatus),children:Ie(r.taskStatus,a)})]})]}),e.jsx("p",{children:r.latestActivity?.message??(r.workflowContinuationReplay?.blockedReason?se(r.workflowContinuationReplay.blockedReason,a):null)??r.dispatchReplay?.replayError??a("workWarRoomRecoveryNoRecoveryNote")}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelDelivery"),": ",xt(r.context?.deliveryMode,a)]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelApproval"),":"," ",pr(r.approval.status,a)]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelReplay"),":"," ",se(r.workflowContinuationReplay?.replayState??r.dispatchReplay?.replayState,a,a("workWarRoomMetaValueNone"))]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelBlocked"),":"," ",se(r.workflowContinuationReplay?.blockedReason,a,a("workWarRoomMetaValueNo"))]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelLatestSource"),":"," ",se(r.latestActivity?.source,a,a("workWarRoomMetaValueNotRecorded"))]}),e.jsx("span",{children:He(r.latestActivity?.createdAt,a)})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelProject"),": ",r.taskContext.projectTitle??a("workWarRoomNoLinkedProject")]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelWorkItem"),":"," ",r.taskContext.workItemTitle??a("workWarRoomNoLinkedWorkItem")]})]}),e.jsxs("div",{className:"operatorMetaRow",children:[e.jsxs("span",{children:[a("workWarRoomMetaLabelConversation"),":"," ",r.taskContext.conversationTitle??a("workWarRoomNoLinkedConversation")]}),e.jsxs("span",{children:[a("workWarRoomMetaLabelActors"),":"," ",qe(r.taskContext.assignedActors.map(n=>n.displayName),a)]})]}),e.jsx(yt,{taskId:r.taskId,taskContext:r.taskContext,t:a})]},r.taskId))})]})}function Kr({projectId:t,t:s}){const a=z();return e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{a(`/work/projects/${encodeURIComponent(t)}`)})},children:s("workWarRoomOpenProject")})}function Fr({workItemId:t,t:s}){const a=z();return e.jsx("button",{type:"button",className:"operatorActionButton",onClick:()=>{m.startTransition(()=>{a(`/work/work-items/${encodeURIComponent(t)}`)})},children:s("workWarRoomOpenWorkItem")})}function $r(){const{t}=N(),s=U(),a=cr(t("workWarRoomLoadError")),r=$({mutationFn:async l=>or(l,t("workWarRoomActionError")),onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:De}),s.invalidateQueries({queryKey:we}),s.invalidateQueries({queryKey:Y})])}}),n=a.data??null,o=a.error?a.error instanceof Error?a.error.message:t("workWarRoomLoadError"):"",i=r.error?V(r.error,t("workWarRoomActionError"),t):"";return e.jsxs("div",{className:"workWarRoomView",children:[e.jsx("div",{className:"codeBuilderHeader",children:e.jsxs("div",{children:[e.jsx("p",{className:"operatorEyebrow",children:t("workWarRoomPageEyebrow")}),e.jsx("h1",{className:"codeBuilderTitle",children:t("workWarRoomPageTitle")})]})}),o||i?e.jsx("div",{className:"codeBuilderFeedback",children:o||i}):null,a.isPending&&!n?e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:t("workWarRoomLoadingEyebrow"),title:t("workWarRoomPageTitle"),summary:t("workWarRoomLoadingSummary")}),e.jsxs("article",{className:"operatorCard",children:[e.jsxs("div",{className:"operatorCardHeader",children:[e.jsx("strong",{children:t("workWarRoomLoadingTitle")}),e.jsx("span",{className:"operatorStatusBadge isProgress",children:t("workWarRoomLoadingBadge")})]}),e.jsx("p",{children:t("workWarRoomLoadingBody")})]})]}):null,n?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"operatorPanel",children:[e.jsx(ue,{eyebrow:t("workWarRoomSnapshotEyebrow"),title:t("workWarRoomSnapshotTitle"),summary:t("workWarRoomSnapshotSummary",{ownerActorId:n.summary.ownerActorId})}),e.jsxs("div",{className:"workWarRoomSummaryGrid",children:[e.jsx(Be,{label:t("workWarRoomSummaryLabelProjects"),value:n.summary.projectCount,helper:t("workWarRoomSummaryInProgressBlocked",{inProgress:n.summary.inProgressCount,blocked:n.summary.blockedCount})}),e.jsx(Be,{label:t("workWarRoomSummaryLabelTasks"),value:n.summary.taskCount,helper:t("workWarRoomSummaryInProgressBlocked",{inProgress:n.summary.inProgressCount,blocked:n.summary.blockedCount})}),e.jsx(Be,{label:t("workWarRoomSummaryLabelAttention"),value:n.summary.operatorAttentionCount,helper:t("workWarRoomSummaryAttention",{count:n.sections.operatorInbox.summary.returned})}),e.jsx(Be,{label:t("workWarRoomSummaryLabelRecovery"),value:n.summary.recoveryCount,helper:t("workWarRoomSummaryRecovery",{count:n.sections.recovery.summary.returned})})]})]}),e.jsx(Wr,{items:n.sections.projects.items,totalAvailable:n.sections.projects.summary.totalAvailable,t}),e.jsx(Mr,{items:n.sections.workItems.items,totalAvailable:n.sections.workItems.summary.totalAvailable,t}),e.jsx(Er,{items:n.sections.operatorInbox.items,totalAvailable:n.sections.operatorInbox.summary.totalAvailable,isTaskActionPending:r.isPending,onTaskAction:l=>r.mutate(l),t}),e.jsx(Ar,{items:n.sections.controlPlane.items,totalAvailable:n.sections.controlPlane.summary.totalAvailable,isTaskActionPending:r.isPending,onTaskAction:l=>r.mutate(l),t}),e.jsx(Or,{items:n.sections.recovery.items,totalAvailable:n.sections.recovery.summary.totalAvailable,t})]}):null]})}const Z=Xt("work"),_s=`${Z}/war-room`,ne=`${Z}/projects`,Q=`${Z}/tasks`,he=`${Z}/work-items`,nt=`${Z}/runs`,ie=`${Z}/missions`,le=`${Z}/schedules`,js=`${Z}/system-map`,xs=`${Z}/cockpit`,gs=`${Z}/broken-links`;function Ur(t){const s=t?.trim();return s?`${ne}/${encodeURIComponent(s)}`:ne}function Nt(t){const s=t?.trim();return s?`${Q}/${encodeURIComponent(s)}`:Q}function Ve(t){const s=t?.trim();return s?`${he}/${encodeURIComponent(s)}`:he}function ye(t,s){const a=t.trim()||"orphan",r=s.trim();return`${Q}/${encodeURIComponent(a)}/runs/${encodeURIComponent(r)}`}function bs(t){const s=t?.trim();return s?`${ie}/${encodeURIComponent(s)}`:ie}function Gr(t){const s=t?.trim();return s?`${le}/${encodeURIComponent(s)}`:le}function Qr(t){return t.startsWith(_s)}function Hr(t){return t===Q||t.startsWith(`${Q}/`)}function qr(t){return t.startsWith(ne)}function Vr(t){return t.startsWith(he)}function Yr(t){return t.startsWith(js)}function zr(t){return t.startsWith(xs)}function Jr(t){return t.startsWith(gs)}function Mt(t){return t===nt||t.startsWith(`${nt}/`)?!0:t.startsWith(`${Q}/`)&&/\/runs\//.test(t)}function Xr(t){return t===ie||t.startsWith(`${ie}/`)}function Zr(t){return t===le||t.startsWith(`${le}/`)}async function en(t,s,a){const r=await fetch(ia,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),signal:a});return K(r,s)}async function tn(t,s,a){const r=await fetch(oa(t),{method:"DELETE",signal:a});return K(r,s)}const Ot=[{value:"blocks",label:"workTopdownLinkageViewKindBlocksLabel",help:"workTopdownLinkKindBlocksHelp"},{value:"blocked_by",label:"workTopdownLinkageViewKindBlockedByLabel",help:"workTopdownLinkKindBlockedByHelp"},{value:"related_to",label:"workTopdownLinkageViewKindRelatedToLabel",help:"workTopdownLinkKindRelatedToHelp"},{value:"duplicate_of",label:"workTopdownLinkageViewKindDuplicateOfLabel",help:"workTopdownLinkKindDuplicateOfHelp"},{value:"follows",label:"workTopdownLinkageViewKindFollowsLabel",help:"workTopdownLinkKindFollowsHelp"}],sn=new Set(["project","work_item","task"]),Ee=280;function Kt(t){return sn.has(t.kind)}function an({selfRef:t,graph:s,onClose:a,onCreated:r}){const n=m.useId(),o=m.useId(),i=m.useId(),l=m.useId(),c=m.useRef(null),h=U(),[u,d]=m.useState("blocks"),[w,y]=m.useState(""),[j,_]=m.useState(null),[x,L]=m.useState(""),[g,k]=m.useState(!1),[R,D]=m.useState(null),{t:S}=N();m.useEffect(()=>{c.current?.focus()},[]),m.useEffect(()=>{function P(A){A.key==="Escape"&&!g&&(A.stopPropagation(),a())}return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[a,g]);const C=m.useMemo(()=>{const P=Ue(t),A=w.trim().toLowerCase();return s.objects.filter(Kt).filter(F=>`${F.kind}:${F.sourceRecordId}`!==P).filter(F=>A.length===0?!0:F.title.toLowerCase().includes(A)||F.sourceRecordId.toLowerCase().includes(A)).slice(0,25)},[s.objects,t,w]),I=j?s.objects.find(P=>P.id===j)??null:null,b=Ot.find(P=>P.value===u);function T(P){P.target===P.currentTarget&&!g&&a()}async function v(P){if(P.preventDefault(),!I||g)return;if(!Kt(I)){D(S("workTopdownNewLinkErrorInvalidTarget"));return}const A=I.kind;if(A===t.recordFamily&&I.sourceRecordId===t.recordId){D(S("workTopdownNewLinkErrorSelfLink"));return}const F=x.trim();if(F.length>Ee){D(S("workTopdownNewLinkErrorNoteTooLong",{max:`${Ee}`}));return}k(!0),D(null);try{const f=await en({kind:u,source:t,target:{recordFamily:A,recordId:I.sourceRecordId},note:F.length===0?null:F},S("workTopdownNewLinkErrorFailed"));await h.invalidateQueries({queryKey:Y}),r?.(f.link.id),a()}catch(f){D(f instanceof Error?f.message:S("workTopdownNewLinkErrorFailed"))}finally{k(!1)}}const O=!I||g;return e.jsx("div",{className:"newLinkDialog__backdrop",role:"presentation",onClick:T,children:e.jsxs("div",{className:"newLinkDialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":n,children:[e.jsxs("header",{className:"newLinkDialog__header",children:[e.jsx("h2",{id:n,className:"newLinkDialog__heading",children:S("workTopdownNewLinkDialogTitle")}),e.jsx("button",{type:"button",className:"newLinkDialog__close","aria-label":S("workTopdownNewLinkClose"),onClick:a,disabled:g,children:"×"})]}),e.jsxs("form",{className:"newLinkDialog__form",onSubmit:v,children:[e.jsxs("p",{className:"newLinkDialog__sourceLine",children:[S("workTopdownNewLinkSourcePrefix")," ",e.jsx("strong",{children:ae(t.recordFamily,S)})," ",e.jsx("code",{children:t.recordId})]}),e.jsxs("label",{className:"newLinkDialog__field",htmlFor:o,children:[e.jsx("span",{className:"newLinkDialog__label",children:S("workTopdownNewLinkRelationLabel")}),e.jsx("select",{id:o,className:"newLinkDialog__select",value:u,onChange:P=>d(P.target.value),children:Ot.map(P=>e.jsx("option",{value:P.value,children:S(P.label)},P.value))}),e.jsx("span",{className:"newLinkDialog__hint",children:b?S(b.help):""})]}),e.jsxs("div",{className:"newLinkDialog__field",children:[e.jsx("label",{className:"newLinkDialog__label",htmlFor:i,children:S("workTopdownNewLinkTargetLabel")}),e.jsx("input",{ref:c,id:i,type:"text",className:"newLinkDialog__input",value:w,onChange:P=>{y(P.target.value),_(null)},placeholder:S("workTopdownNewLinkTargetSearchPlaceholder",{project:S("workTopdownAnchorProject"),workItem:S("workTopdownAnchorWorkItem"),task:S("workTopdownAnchorTask")}),autoComplete:"off"}),C.length===0?e.jsx("p",{className:"newLinkDialog__empty",children:S("workTopdownNewLinkNoMatches")}):e.jsx("ul",{className:"newLinkDialog__candidates",children:C.map(P=>{const A=j===P.id;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"newLinkDialog__candidate"+(A?" newLinkDialog__candidate--selected":""),onClick:()=>_(P.id),children:[e.jsx("span",{className:"newLinkDialog__candidateKind",children:ae(P.kind,S)}),e.jsx("span",{className:"newLinkDialog__candidateTitle",children:P.title})]})},P.id)})})]}),e.jsxs("label",{className:"newLinkDialog__field",htmlFor:l,children:[e.jsx("span",{className:"newLinkDialog__label",children:S("workTopdownNewLinkNoteLabel")}),e.jsx("textarea",{id:l,className:"newLinkDialog__textarea",value:x,onChange:P=>L(P.target.value),placeholder:S("workTopdownNewLinkNotePlaceholder"),rows:2,maxLength:Ee}),e.jsxs("span",{className:"newLinkDialog__charCount",children:[x.length,"/",Ee]})]}),R?e.jsx("p",{className:"newLinkDialog__error",role:"alert",children:R}):null,e.jsxs("footer",{className:"newLinkDialog__footer",children:[e.jsx("button",{type:"button",className:"newLinkDialog__cancelBtn",onClick:a,disabled:g,children:S("workTopdownNewLinkCancel")}),e.jsx("button",{type:"submit",className:"newLinkDialog__submitBtn",disabled:O,children:S(g?"workTopdownNewLinkSaving":"workTopdownLinkageAddAction")})]})]})]})})}const Ft={blocks:"workTopdownLinkageViewKindBlocksLabel",blocked_by:"workTopdownLinkageViewKindBlockedByLabel",related_to:"workTopdownLinkageViewKindRelatedToLabel",duplicate_of:"workTopdownLinkageViewKindDuplicateOfLabel",follows:"workTopdownLinkageViewKindFollowsLabel"},rn=["blocks","blocked_by","related_to","duplicate_of","follows"],nn={blocks:"workTopdownLinkageViewKindBlocksEmpty",blocked_by:"workTopdownLinkageViewKindBlockedByEmpty",related_to:"workTopdownLinkageViewKindRelatedToEmpty",duplicate_of:"workTopdownLinkageViewKindDuplicateOfEmpty",follows:"workTopdownLinkageViewKindFollowsEmpty"};function on(t){switch(t.recordFamily){case"project":return Ur(t.recordId);case"work_item":return Ve(t.recordId);case"task":return Nt(t.recordId)}}function ft({selfRef:t,graph:s,indexes:a}){const{t:r}=N(),[n,o]=m.useState(!1),i=Ue(t),l=s.linksByEndpoint[i]??[],c=new Map;for(const u of l){const d=c.get(u.kind)??[];d.push(u),c.set(u.kind,d)}const h=rn.filter(u=>c.has(u));return e.jsxs("section",{className:"linkageSection",children:[e.jsxs("header",{className:"linkageSection__header",children:[e.jsx("h2",{children:r("workTopdownLinkageTitle")}),e.jsx("span",{className:"linkageSection__count",children:l.length}),e.jsxs("button",{type:"button",className:"linkageSection__addBtn",onClick:()=>o(!0),children:["+ ",r("workTopdownLinkageAddAction")]})]}),l.length===0?e.jsxs("p",{className:"linkageSection__empty",children:[r("workTopdownLinkageNoLinksYetPrefix")," ",e.jsx("strong",{children:r("workTopdownLinkageAddAction")})," ",r("workTopdownLinkageNoLinksYetSuffix")]}):h.map(u=>e.jsx(ln,{views:c.get(u)??[],kind:u,indexes:a},u)),n?e.jsx(an,{selfRef:t,graph:s,onClose:()=>o(!1)}):null]})}function ln({views:t,kind:s,indexes:a}){const{t:r}=N();return t.length===0?e.jsxs("div",{className:`linkageSection__group linkageSection__group--${s}`,children:[e.jsx("h3",{className:"linkageSection__groupLabel",children:r(Ft[s])}),e.jsx("p",{className:"linkageSection__groupEmpty",children:r(nn[s])})]}):e.jsxs("div",{className:`linkageSection__group linkageSection__group--${s}`,children:[e.jsx("h3",{className:"linkageSection__groupLabel",children:r(Ft[s])}),e.jsx("ul",{className:"linkageSection__list",children:t.map(n=>{const o=Ue(n.otherEndpoint),i=a.objectsByCoreRef.get(o);return i?e.jsxs("li",{className:"linkageSection__row",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--small projectsList__dot--${i.status}`,"aria-hidden":"true"}),e.jsx(B,{className:"linkageSection__title",to:on(n.otherEndpoint),children:i.title}),e.jsx("span",{className:"linkageSection__kindBadge",children:ae(i.kind,r)}),n.note?e.jsx("span",{className:"linkageSection__note",children:n.note}):null]},n.linkId):null})})]})}const _e=["projects"];async function cn(t){const s=await fetch(Zt,{headers:{accept:"application/json"}});if(!s.ok)throw me(s,t);return await s.json()}function Ne(){const{t}=N();return te({queryKey:_e,queryFn:()=>cn(t)})}function ys(t,s){const a=mn(t);if(!a)return null;const r=a.hostname.toLowerCase(),n=a.pathname.split("/").filter(Boolean),o=dn(r);if(o==="github")return Le(n,"github",["issues"]);if(o==="gitlab")return $t(n);const i=hn(a);if(i)return{externalId:i,externalType:"ticket",provider:"bugzilla"};const l=o??s;return l==="redmine"?un(n):l==="gitea"?Le(n,"gitea",["issues"]):l==="gitlab"?$t(n):l==="github"?Le(n,"github",["issues"]):null}function dn(t){return t==="github.com"||t.endsWith(".github.com")?"github":t==="gitlab.com"||t.endsWith(".gitlab.com")?"gitlab":t.includes("bugzilla")?"bugzilla":t.includes("redmine")?"redmine":t.includes("gitea")?"gitea":null}function $t(t){const s=t.indexOf("-");if(s>=0&&t[s+1]==="issues"){const a=t[s+2];return a?{externalId:a,externalType:"issue",provider:"gitlab"}:null}return Le(t,"gitlab",["issues"])}function un(t){const s=Le(t,"redmine",["issues"]);if(s)return{...s,externalType:"ticket"};const a=t.indexOf("projects"),r=a>=0?t[a+1]:null;return r?{externalId:r,externalType:"project",provider:"redmine"}:null}function Le(t,s,a){const r=t.findIndex(o=>a.includes(o)),n=r>=0?t[r+1]:null;return n?{externalId:n,externalType:"issue",provider:s}:null}function hn(t){return!t.pathname.endsWith("/show_bug.cgi")&&t.pathname!=="/show_bug.cgi"?null:t.searchParams.get("id")?.trim()||null}function mn(t){try{const s=t.trim();if(!s)return null;const a=new URL(s);return(a.protocol==="http:"||a.protocol==="https:")&&a.username===""&&a.password===""?a:null}catch{return null}}function Ns({localKind:t,localId:s,defaultExternalType:a="issue",errorFallback:r,invalidateQueryKeys:n,onClose:o,title:i}){const{t:l}=N(),c=U(),h=m.useId(),u=m.useId(),d=m.useId(),w=m.useId(),y=m.useId(),j=m.useId(),_=m.useRef(null),[x,L]=m.useState("github"),[g,k]=m.useState(a),[R,D]=m.useState(""),[S,C]=m.useState(""),[I,b]=m.useState("pull"),T=$({mutationFn:()=>Xa({localKind:t,localId:s,provider:x,externalType:g,externalId:R.trim(),externalUrl:S.trim()||null,syncDirection:I},r),onSuccess:async()=>{await Promise.all(n.map(f=>c.invalidateQueries({queryKey:f}))),o()}}),v=T.isPending,O=T.error?V(T.error,r,l):null;m.useEffect(()=>{_.current?.focus()},[]),m.useEffect(()=>{function f(G){G.key==="Escape"&&(G.stopPropagation(),o())}return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[o]);function P(f){f.target===f.currentTarget&&o()}function A(f){C(f);const G=ys(f,x);G&&(G.provider&&L(G.provider),G.externalType&&k(G.externalType),G.externalId&&R.trim().length===0&&D(G.externalId))}function F(f){f.preventDefault(),!(!R.trim()||v)&&T.mutate()}return e.jsx("div",{className:"newProjectDialog__backdrop",role:"presentation",onClick:P,children:e.jsxs("div",{className:"newProjectDialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":`${h}-heading`,children:[e.jsxs("header",{className:"newProjectDialog__header",children:[e.jsx("h2",{id:`${h}-heading`,className:"newProjectDialog__heading",children:i}),e.jsx("button",{type:"button",className:"newProjectDialog__close","aria-label":l("workExternalLinkCloseLabel"),onClick:o,children:"×"})]}),e.jsxs("form",{className:"newProjectDialog__form",onSubmit:F,children:[e.jsxs("label",{className:"newProjectDialog__field",htmlFor:u,children:[e.jsx("span",{className:"newProjectDialog__label",children:l("workExternalProviderLabel")}),e.jsxs("select",{id:u,className:"newProjectDialog__select",value:x,onChange:f=>L(f.target.value),children:[e.jsx("option",{value:"github",children:l("workExternalProviderGithub")}),e.jsx("option",{value:"gitlab",children:l("workExternalProviderGitlab")}),e.jsx("option",{value:"gitea",children:l("workExternalProviderGitea")}),e.jsx("option",{value:"redmine",children:l("workExternalProviderRedmine")}),e.jsx("option",{value:"bugzilla",children:l("workExternalProviderBugzilla")})]})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:d,children:[e.jsx("span",{className:"newProjectDialog__label",children:l("workExternalTypeLabel")}),e.jsxs("select",{id:d,className:"newProjectDialog__select",value:g,onChange:f=>k(f.target.value),children:[e.jsx("option",{value:"issue",children:l("workExternalTypeIssue")}),e.jsx("option",{value:"ticket",children:l("workExternalTypeTicket")}),e.jsx("option",{value:"project",children:l("workExternalTypeProject")})]})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:w,children:[e.jsxs("span",{className:"newProjectDialog__label",children:[l("workExternalIdLabel"),e.jsx("span",{className:"newProjectDialog__required","aria-hidden":"true",children:"*"})]}),e.jsx("input",{ref:_,id:w,type:"text",className:"newProjectDialog__input",value:R,onChange:f=>D(f.target.value),placeholder:l("workExternalIdPlaceholder"),required:!0,maxLength:200})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:y,children:[e.jsx("span",{className:"newProjectDialog__label",children:l("workExternalUrlLabel")}),e.jsx("input",{id:y,type:"url",className:"newProjectDialog__input",value:S,onChange:f=>A(f.target.value),placeholder:l("workExternalUrlPlaceholder"),maxLength:1e3})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:j,children:[e.jsx("span",{className:"newProjectDialog__label",children:l("workExternalSyncDirectionLabel")}),e.jsxs("select",{id:j,className:"newProjectDialog__select",value:I,onChange:f=>b(f.target.value),children:[e.jsx("option",{value:"pull",children:l("workExternalSyncPull")}),e.jsx("option",{value:"push",children:l("workExternalSyncPush")}),e.jsx("option",{value:"bidirectional",children:l("workExternalSyncBidirectional")})]})]}),O?e.jsx("p",{className:"newProjectDialog__error",role:"alert",children:O}):null,e.jsxs("footer",{className:"newProjectDialog__footer",children:[e.jsx("button",{type:"button",className:"newProjectDialog__cancelBtn",onClick:o,disabled:v,children:l("workExternalCancelButton")}),e.jsx("button",{type:"submit",className:"newProjectDialog__submitBtn",disabled:R.trim().length===0||v,children:l(v?"workExternalSubmitBusyLabel":"workExternalSubmitLabel")})]})]})]})})}function pn({projectId:t,onClose:s}){const{t:a}=N();return e.jsx(Ns,{localKind:"project",localId:t,defaultExternalType:"project",errorFallback:a("workExternalLinkError"),invalidateQueryKeys:[_e,Y],onClose:s,title:a("workExternalLinkDialogTitle")})}function kn({addLabel:t,bindings:s,emptyLabel:a,onAddClick:r,onRemoveBinding:n,removeDisabled:o}){const{t:i}=N();return s.length===0&&!r?null:e.jsxs("section",{className:"projectDetail__section projectDetail__external",children:[e.jsxs("header",{className:"projectDetail__sectionHeader",children:[e.jsx("h2",{children:i("workTopdownExternalTitle")}),e.jsx("span",{className:"projectDetail__sectionCount",children:s.length}),r?e.jsx("button",{type:"button",className:"projectDetail__sectionAction",onClick:r,children:t??i("workExternalLinkTrackerAction")}):null]}),s.length===0?e.jsx("p",{className:"projectDetail__empty",children:a??i("workExternalEmpty")}):e.jsx("ul",{className:"projectDetail__externalRefs",children:s.map(l=>{const c=ee(l),h=bt(l.externalUrl)?l.externalUrl:null;return e.jsxs("li",{className:"projectDetail__externalRef",children:[e.jsx("span",{className:"projectDetail__externalProvider",children:l.provider}),e.jsxs("span",{className:"projectDetail__externalMain",children:[h?e.jsx("a",{className:"projectDetail__externalLink",href:h,target:"_blank",rel:"noreferrer",children:c}):e.jsx("span",{className:"projectDetail__externalLabel",children:c}),e.jsxs("span",{className:"projectDetail__externalMeta",children:[i("workTopdownExternalSyncLabel",{syncDirection:l.syncDirection}),l.externalUpdatedAt?` - ${i("workTopdownExternalUpdatedLabel",{updatedAt:W(l.externalUpdatedAt,i)})}`:""]}),n?e.jsx("button",{type:"button",className:"projectDetail__externalRemove",onClick:()=>n(l),disabled:o,"aria-label":i("workExternalUnlinkAriaLabel",{label:c}),children:i("workExternalUnlinkAction")}):null]})]},`${l.provider}:${l.externalType}:${l.externalId}`)})})]})}function wn(){const{t}=N(),{projectId:s}=xe(),a=z(),r=U(),[n,o]=m.useState(!1),i=ke(t("workGraphLoadErrorFallback")).data??pe,l=m.useMemo(()=>be(i),[i]),c=Ne(),h=s?c.data?.projects.find(k=>k.id===s):void 0,u=$({mutationFn:async k=>{await is(k,t("workProjectDeleteError"))},onSuccess:async()=>{await r.invalidateQueries({queryKey:_e}),a(ne)}}),d=$({mutationFn:async k=>{await ls({localKind:"project",localId:k.projectId,provider:k.binding.provider,externalType:k.binding.externalType,externalId:k.binding.externalId},t("workExternalUnlinkError"))},onSuccess:async()=>{await Promise.all([r.invalidateQueries({queryKey:_e}),r.invalidateQueries({queryKey:Y})])}}),w=()=>{h&&window.confirm(t("workProjectDeleteConfirmation",{projectTitle:h.title}))&&u.mutate(h.id)},y=k=>{if(!h)return;const R=ee(k);window.confirm(t("workExternalUnlinkConfirmation",{label:R}))&&d.mutate({binding:k,projectId:h.id})};if(c.isPending)return e.jsx(_n,{});if(!h)return e.jsx(jn,{projectId:s??null});const j=u.error?V(u.error,t("workProjectDeleteError"),t):null,_=d.error?V(d.error,t("workExternalUnlinkError"),t):null,x=i.objects.filter(k=>k.kind==="work_item"&&k.linkedProjectId===h.id),L=i.objects.filter(k=>k.kind==="task"&&k.linkedProjectId===h.id),g=i.objects.filter(k=>k.kind==="activity"&&k.linkedProjectId===h.id).sort((k,R)=>R.updatedAt.localeCompare(k.updatedAt));return e.jsxs("div",{className:"projectDetail",children:[e.jsxs("header",{className:"channelTopBar projectDetailTopBar",children:[e.jsx("div",{className:"channelTopBarStart projectDetailTopBar__start",children:e.jsxs(B,{to:"..",relative:"path",className:"projectDetailTopBar__back","aria-label":t("workProjectBackArrowLabel"),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M7.5 2L3.5 6l4 4"})}),e.jsx("span",{children:t("workProjectBackLabel")})]})}),e.jsxs("div",{className:"channelTopBarCenter projectDetailTopBar__center",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--${h.status}`,"aria-hidden":"true"}),e.jsx("h1",{className:"channelTopBarTitle projectDetailTopBar__title",children:h.title})]}),e.jsxs("div",{className:"channelTopBarEnd projectDetailTopBar__end",children:[re(h.attention,t)?e.jsx("span",{className:`projectDetail__attention projectDetail__attention--${h.attention}`,children:re(h.attention,t)}):null,e.jsx("span",{className:`projectsList__statusPill projectsList__statusPill--${h.status}`,children:M(h.status,t)}),e.jsx("span",{className:"projectDetailTopBar__updated",children:t("workProjectUpdatedAtPrefix",{updatedAt:W(h.updatedAt,t)})}),e.jsx("button",{type:"button",className:"projectDetailTopBar__action projectDetailTopBar__action--destructive",onClick:w,disabled:u.isPending,"aria-label":t("workProjectDeleteLabel"),children:u.isPending?t("workProjectDeleteLabelBusy"):t("workProjectDeleteLabel")})]})]}),e.jsxs("main",{className:"projectDetail__main",children:[j?e.jsx("p",{className:"projectDetail__error",role:"alert",children:j}):null,_?e.jsx("p",{className:"projectDetail__error",role:"alert",children:_}):null,e.jsxs("section",{className:"projectDetail__section projectDetail__overview",children:[e.jsx("header",{className:"projectDetail__sectionHeader",children:e.jsx("h2",{children:t("workProjectOverviewTitle")})}),e.jsxs("dl",{className:"projectDetail__overviewList",children:[h.summary?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:t("workProjectSummaryLabel")}),e.jsx("dd",{children:h.summary})]}):null,e.jsx("dt",{children:t("workProjectOwnerLabel")}),e.jsx("dd",{children:h.ownerName}),h.primaryConversationId?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:t("workProjectConversationLabel")}),e.jsx("dd",{children:e.jsx("span",{className:"projectDetail__convoTitle",children:h.primaryConversationTitle??h.primaryConversationId})})]}):null]})]}),e.jsx(kn,{bindings:h.externalBindings??[],onAddClick:()=>o(!0),onRemoveBinding:y,removeDisabled:d.isPending}),e.jsx(Ut,{title:t("workProjectWorkItemsTitle"),items:x,emptyLabel:t("workProjectNoWorkItems")}),e.jsx(Ut,{title:t("workProjectTasksTitle"),items:L,emptyLabel:t("workProjectNoTasks")}),e.jsx(ft,{selfRef:{recordFamily:"project",recordId:h.id},graph:i,indexes:l}),e.jsxs("section",{className:"projectDetail__section",children:[e.jsxs("header",{className:"projectDetail__sectionHeader",children:[e.jsx("h2",{children:t("workProjectActivityTitle")}),e.jsx("span",{className:"projectDetail__sectionCount",children:g.length})]}),g.length===0?e.jsx("p",{className:"projectDetail__empty",children:t("workProjectNoActivity")}):e.jsx("ul",{className:"projectDetail__activity",children:g.map(k=>e.jsxs("li",{className:"projectDetail__activityRow",children:[e.jsx("span",{className:"projectDetail__activityWhen",children:W(k.updatedAt,t)}),e.jsx("span",{className:"projectDetail__activityTitle",children:k.title}),k.summary?e.jsx("span",{className:"projectDetail__activitySummary",children:k.summary}):null]},k.id))})]})]}),n?e.jsx(pn,{projectId:h.id,onClose:()=>o(!1)}):null]})}function Ut({title:t,items:s,emptyLabel:a}){const{t:r}=N();return e.jsxs("section",{className:"projectDetail__section",children:[e.jsxs("header",{className:"projectDetail__sectionHeader",children:[e.jsx("h2",{children:t}),e.jsx("span",{className:"projectDetail__sectionCount",children:s.length})]}),s.length===0?e.jsx("p",{className:"projectDetail__empty",children:a}):e.jsx("ul",{className:"projectDetail__items",children:s.map(n=>e.jsxs("li",{className:"projectDetail__item",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--small projectsList__dot--${n.status}`,"aria-hidden":"true"}),e.jsx("span",{className:"projectDetail__itemKind",children:ae(n.kind,r)}),e.jsx("span",{className:"projectDetail__itemTitle",children:n.title}),re(n.attention,r)?e.jsx("span",{className:`projectDetail__itemAttention projectDetail__itemAttention--${n.attention}`,children:re(n.attention,r)}):null,e.jsx("span",{className:"projectDetail__itemStatus",children:M(n.status,r)}),n.ownerRole?e.jsx("span",{className:"projectDetail__itemOwner",children:ge(n.ownerRole,r)}):null]},n.id))})]})}function _n(){const{t}=N();return e.jsxs("div",{className:"projectDetail",children:[e.jsx("header",{className:"channelTopBar projectDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart projectDetailTopBar__start",children:e.jsx(B,{to:"..",relative:"path",className:"projectDetailTopBar__back",children:e.jsx("span",{children:t("workProjectBackArrowLabel")})})})}),e.jsx("main",{className:"projectDetail__main",children:e.jsx("p",{className:"projectDetail__empty",children:t("workProjectLoadingLabel")})})]})}function jn({projectId:t}){const{t:s}=N(),a=t??s("workProjectMissingIdLabel");return e.jsxs("div",{className:"projectDetail",children:[e.jsx("header",{className:"channelTopBar projectDetailTopBar",children:e.jsxs("div",{className:"channelTopBarStart projectDetailTopBar__start",children:[e.jsx(B,{to:"..",relative:"path",className:"projectDetailTopBar__back",children:e.jsx("span",{children:s("workProjectBackArrowLabel")})}),e.jsx("span",{className:"projectDetailTopBar__separator","aria-hidden":"true",children:"/"}),e.jsx("h1",{className:"channelTopBarTitle projectDetailTopBar__title",children:s("workProjectNotFoundTitle")})]})}),e.jsx("main",{className:"projectDetail__main",children:e.jsxs("p",{className:"projectDetail__empty",children:[s("workProjectNotFoundPrefix")," ",e.jsx("code",{children:a})," ",s("workProjectNotFoundSuffix")]})})]})}async function xn(t,s){return{id:(await Ya({title:t.title,summary:t.summary,status:t.status},s)).project.id}}const gn=["planned","active","paused","archived"];function bn({onClose:t}){const{t:s}=N(),a=z(),r=U(),n=m.useId(),o=m.useId(),i=m.useId(),l=m.useRef(null),[c,h]=m.useState(""),[u,d]=m.useState(""),[w,y]=m.useState("planned"),j=$({mutationFn:k=>xn(k,s("workNewProjectCreateError")),onSuccess:async k=>{await r.invalidateQueries({queryKey:_e}),t(),a(`${ne}/${k.id}`)}}),_=j.isPending,x=j.error?V(j.error,s("workNewProjectCreateError"),s):null;m.useEffect(()=>{l.current?.focus()},[]),m.useEffect(()=>{function k(R){R.key==="Escape"&&(R.stopPropagation(),t())}return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[t]);function L(k){k.target===k.currentTarget&&t()}function g(k){k.preventDefault();const R=c.trim();!R||_||j.mutate({title:R,summary:u.trim()||null,status:w})}return e.jsx("div",{className:"newProjectDialog__backdrop",role:"presentation",onClick:L,children:e.jsxs("div",{className:"newProjectDialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":`${n}-heading`,children:[e.jsxs("header",{className:"newProjectDialog__header",children:[e.jsx("h2",{id:`${n}-heading`,className:"newProjectDialog__heading",children:s("workNewProjectTitle")}),e.jsx("button",{type:"button",className:"newProjectDialog__close","aria-label":s("workNewProjectCloseLabel"),onClick:t,children:"×"})]}),e.jsxs("form",{className:"newProjectDialog__form",onSubmit:g,children:[e.jsxs("label",{className:"newProjectDialog__field",htmlFor:n,children:[e.jsxs("span",{className:"newProjectDialog__label",children:[s("workNewProjectTitleLabel"),e.jsx("span",{className:"newProjectDialog__required","aria-hidden":"true",children:"*"})]}),e.jsx("input",{ref:l,id:n,type:"text",className:"newProjectDialog__input",value:c,onChange:k=>h(k.target.value),placeholder:s("workNewProjectTitlePlaceholder"),required:!0,maxLength:120})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:o,children:[e.jsx("span",{className:"newProjectDialog__label",children:s("workNewProjectSummaryLabel")}),e.jsx("textarea",{id:o,className:"newProjectDialog__textarea",value:u,onChange:k=>d(k.target.value),placeholder:s("workNewProjectSummaryPlaceholder"),rows:3,maxLength:400})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:i,children:[e.jsx("span",{className:"newProjectDialog__label",children:s("workNewProjectStatusLabel")}),e.jsx("select",{id:i,className:"newProjectDialog__select",value:w,onChange:k=>y(k.target.value),children:gn.map(k=>e.jsx("option",{value:k,children:M(k,s)},k))})]}),x?e.jsx("p",{className:"newProjectDialog__error",role:"alert",children:x}):null,e.jsxs("footer",{className:"newProjectDialog__footer",children:[e.jsx("button",{type:"button",className:"newProjectDialog__cancelBtn",onClick:t,disabled:_,children:s("workNewProjectCancelButton")}),e.jsx("button",{type:"submit",className:"newProjectDialog__submitBtn",disabled:c.trim().length===0||_,children:s(_?"workNewProjectSubmitBusyLabel":"workNewProjectSubmitLabel")})]})]})]})})}function yn(){const{t}=N(),s=Ne(),a=s.data?.projects??[],[r,n]=m.useState(!1);return e.jsxs("div",{className:"projectsList",children:[e.jsxs("header",{className:"channelTopBar projectsListTopBar",children:[e.jsxs("div",{className:"channelTopBarStart projectsListTopBar__start",children:[e.jsx("h1",{className:"channelTopBarTitle projectsListTopBar__title",children:t("workProjectsListTitle")}),e.jsx("span",{className:"projectsListTopBar__count",children:a.length})]}),e.jsx("div",{className:"channelTopBarCenter projectsListTopBar__center"}),e.jsx("div",{className:"channelTopBarEnd projectsListTopBar__end",children:e.jsxs("button",{type:"button",className:"projectsListTopBar__addBtn",onClick:()=>n(!0),"aria-label":t("workProjectsCreateNewProjectAriaLabel"),children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M7 2v10"}),e.jsx("path",{d:"M2 7h10"})]}),e.jsx("span",{children:t("workProjectsNewAction")})]})})]}),e.jsx("main",{className:"projectsList__main",children:s.isPending?e.jsx("p",{className:"projectsList__empty",children:t("workProjectsListLoading")}):s.isError?e.jsx("p",{className:"projectsList__empty",children:t("workProjectsListLoadError",{errorMessage:String(s.error.message)})}):a.length===0?e.jsxs("p",{className:"projectsList__empty",children:[t("workProjectsListEmptyIntro")," ",e.jsx("strong",{children:t("workProjectsNewAction")})," ",t("workProjectsListEmptySuffix")]}):e.jsx("ul",{className:"projectsList__list",children:a.map(o=>e.jsx("li",{className:"projectsList__row",children:e.jsxs(B,{to:o.id,className:"projectsList__rowLink","aria-label":t("workProjectsOpenProjectAriaLabel",{projectTitle:o.title}),children:[e.jsxs("div",{className:"projectsList__rowMain",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--${o.status}`,"aria-hidden":"true"}),e.jsxs("div",{className:"projectsList__rowText",children:[e.jsx("span",{className:"projectsList__rowTitle",children:o.title}),o.summary?e.jsx("span",{className:"projectsList__rowSummary",children:o.summary}):null]})]}),e.jsxs("div",{className:"projectsList__rowMeta",children:[o.attentionDecisionCount>0?e.jsx("span",{className:"projectsList__pip projectsList__pip--decision",children:t("workProjectsDecisionPill",{count:o.attentionDecisionCount,pluralSuffix:o.attentionDecisionCount===1?"":"s"})}):null,o.attentionBlockedCount>0?e.jsx("span",{className:"projectsList__pip projectsList__pip--blocked",children:t("workProjectsBlockedPill",{count:o.attentionBlockedCount})}):null,(o.externalBindings??[]).slice(0,2).map(i=>e.jsx("span",{className:"projectsList__externalChip",title:t("workTopdownExternalBindingTooltip",{externalBinding:ee(i)}),children:ee(i)},`${i.provider}:${i.externalType}:${i.externalId}`)),(o.externalBindings?.length??0)>2?e.jsxs("span",{className:"projectsList__externalChip",children:["+",(o.externalBindings?.length??0)-2]}):null,e.jsxs("span",{className:"projectsList__metric",children:[e.jsx("strong",{children:o.linkedWorkItemCount})," ",t("workProjectsWorkItemsAbbrev")]}),e.jsxs("span",{className:"projectsList__metric",children:[e.jsx("strong",{children:o.linkedTaskCount})," ",t("workProjectsTasksLabel")]}),e.jsx("span",{className:"projectsList__metric projectsList__metric--muted",children:W(o.updatedAt,t)}),e.jsx("span",{className:`projectsList__statusPill projectsList__statusPill--${o.status}`,children:M(o.status,t)})]})]})},o.id))})}),r?e.jsx(bn,{onClose:()=>n(!1)}):null]})}const ot=["task-golden-path"];async function Nn(t,s){const a=await fetch(`${mt}/${encodeURIComponent(t)}`,{headers:{accept:"application/json"}});if(!a.ok)throw me(a,s);return(await a.json()).goldenPath}function fn(t){const{t:s}=N();return te({queryKey:[...ot,t],queryFn:()=>Nn(t,s),enabled:typeof t=="string"&&t.length>0})}const Tn={received:p.workTaskGoldenPathStageReceived,scope_proposed:p.workTaskGoldenPathStageScopeproposed,execution_authorized:p.workTaskGoldenPathStageExecutionauthorized,admitted:p.workTaskGoldenPathStageAdmitted,running:p.workTaskGoldenPathStageRunning,decision_needed:p.workTaskGoldenPathStageDecisionneeded,result_ready:p.workTaskGoldenPathStageResultready,publish_authorized:p.workTaskGoldenPathStagePublishauthorized,delivered:p.workTaskGoldenPathStageDelivered,failed:p.workTaskGoldenPathStageFailed,cancelled:p.workTaskGoldenPathStageCancelled};function J({label:t,children:s}){return e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function Ln({attempt:t}){const{t:s}=N();return e.jsxs("li",{className:"taskDetail__goldenPathAttempt",children:[e.jsx("span",{children:s("workTaskGoldenPathAttempt",{purpose:t.purpose,state:t.state,count:String(t.attemptCount)})}),t.lastErrorCode?e.jsx("span",{className:"taskDetail__goldenPathError",children:t.lastErrorCode}):null]})}function vn({taskId:t}){const{t:s}=N(),a=U(),r=fn(t),[n,o]=m.useState(!1),[i,l]=m.useState(null),c=r.data??null;if(c===null)return null;const h=c.recoveryActions.includes("retry_delivery"),u=c.recoveryActions.includes("retry_run"),d=c.recoveryActions.includes("resume_run");async function w(k){o(!0),l(null);try{const R=await rr(t,k);R.status!=="redrivable"&&l(s("workTaskGoldenPathLifecycleFailed",{reason:R.reason??R.status})),await a.invalidateQueries({queryKey:ot})}catch(R){l(R instanceof Error?R.message:String(R))}finally{o(!1)}}async function y(){o(!0),l(null);try{const k=await nr(t);k.status!=="delivered"&&l(s("workTaskGoldenPathRetryFailed",{reason:k.reason??k.status})),await a.invalidateQueries({queryKey:ot})}catch(k){l(k instanceof Error?k.message:String(k))}finally{o(!1)}}const{scope:j,source:_,authorization:x,evidence:L,delivery:g}=c;return e.jsxs("section",{className:"taskDetail__section taskDetail__goldenPath",children:[e.jsxs("header",{className:"taskDetail__sectionHeader",children:[e.jsx("h2",{children:s("workTaskGoldenPathTitle")}),e.jsx("span",{className:"taskDetail__sectionCount",children:s(Tn[c.stage])})]}),e.jsx("p",{className:"taskDetail__goldenPathRationale",children:c.stageRationale}),e.jsxs("dl",{className:"taskDetail__overviewList",children:[e.jsxs(J,{label:s("workTaskGoldenPathBinding"),children:[_.transport," · ",_.bindingId,_.present?null:e.jsxs("span",{className:"taskDetail__goldenPathError",children:[" ","(",s("workTaskGoldenPathBindingMissing"),")"]})]}),e.jsxs(J,{label:s("workTaskGoldenPathRevision"),children:[j.revision," · ",e.jsx("code",{children:j.digest.slice(0,12)})]}),e.jsx(J,{label:s("workTaskGoldenPathTarget"),children:j.targetLabel}),j.workspacePath?e.jsx(J,{label:s("workTaskGoldenPathWorkspace"),children:e.jsx("code",{children:j.workspacePath})}):null,e.jsx(J,{label:s("workTaskGoldenPathDoneWhen"),children:j.acceptanceCriteria.join("; ")}),e.jsx(J,{label:s("workTaskGoldenPathDelivery"),children:j.deliveryMode}),c.outstandingGates.length>0?e.jsx(J,{label:s("workTaskGoldenPathGates"),children:c.outstandingGates.join(", ")}):null,e.jsx(J,{label:s("workTaskGoldenPathAuthorizationTitle"),children:x.authorizedByActorId&&x.authorizedAt?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:s("workTaskGoldenPathAuthorizedBy",{actor:x.authorizedByActorId,at:x.authorizedAt})}),e.jsx("br",{}),e.jsx("span",{children:s("workTaskGoldenPathAuthorizedFrom",{binding:x.bindingId??_.bindingId,revision:String(x.proposalRevision??j.revision)})})]}):s("workTaskGoldenPathNotAuthorized")})]}),c.permissionDenial?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:s("workTaskGoldenPathPermissionDenial")}),e.jsx("p",{className:"taskDetail__goldenPathError",children:s("workTaskGoldenPathPermissionDenialDetail",{tool:c.permissionDenial.toolName,code:c.permissionDenial.code})})]}):null,c.blockers.length>0?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:s("workTaskGoldenPathBlockers")}),e.jsx("ul",{className:"taskDetail__goldenPathBlockers",children:c.blockers.map(k=>e.jsx("li",{children:k},k))})]}):null,e.jsx("h3",{children:s("workTaskGoldenPathEvidenceTitle")}),L.outcomeStatus===null&&L.artifacts.length===0?e.jsx("p",{className:"taskDetail__empty",children:s("workTaskGoldenPathNoEvidence")}):e.jsxs("dl",{className:"taskDetail__overviewList",children:[L.commitId?e.jsxs(J,{label:s("workTaskGoldenPathCommit"),children:[e.jsx("code",{children:L.commitId}),L.changeSummary?` — ${L.changeSummary}`:null]}):null,L.validation?e.jsxs(J,{label:s("workTaskGoldenPathValidation"),children:[L.validation.command," — ",L.validation.passed?s("workTaskGoldenPathValidationPassed"):s("workTaskGoldenPathValidationFailed")]}):null,L.artifacts.length>0?e.jsx(J,{label:s("workTaskGoldenPathArtifacts"),children:L.artifacts.map(k=>`${k.title} (${k.status})`).join(", ")}):null,L.unmetCriteria.length>0?e.jsx(J,{label:s("workTaskGoldenPathUnmet"),children:L.unmetCriteria.join("; ")}):null]}),e.jsx("h3",{children:s("workTaskGoldenPathDeliveryTitle")}),g.attempts.length===0?e.jsx("p",{className:"taskDetail__empty",children:s("workTaskGoldenPathNoAttempts")}):e.jsx("ul",{className:"taskDetail__goldenPathAttempts",children:g.attempts.map(k=>e.jsx(Ln,{attempt:k},k.idempotencyKey))}),g.receipt?.externalMessageRef&&g.receipt.sentAt?e.jsx("p",{className:"taskDetail__goldenPathReceipt",children:s("workTaskGoldenPathReceipt",{messageId:g.receipt.externalMessageRef,at:g.receipt.sentAt})}):null,e.jsxs("div",{className:"taskDetail__goldenPathActions",children:[h?e.jsx("button",{type:"button",className:"taskDetailTopBar__action",onClick:()=>{y()},disabled:n,children:s(n?"workTaskGoldenPathRetrying":"workTaskGoldenPathRetryDelivery")}):null,u?e.jsx("button",{type:"button",className:"taskDetailTopBar__action",onClick:()=>{w("retry")},disabled:n,children:s("workTaskGoldenPathRetryRun")}):null,d?e.jsx("button",{type:"button",className:"taskDetailTopBar__action",onClick:()=>{w("resume")},disabled:n,children:s("workTaskGoldenPathResumeRun")}):null]}),i?e.jsx("p",{className:"taskDetail__error",role:"alert",children:i}):null]})}const Ye=["runs"];async function Dn(t){const s=await fetch(la,{headers:{accept:"application/json"}});if(!s.ok)throw me(s,t);return await s.json()}function ze(){const{t}=N();return te({queryKey:Ye,queryFn:()=>Dn(t)})}const je=["workItems"];async function Sn(t){const s=await fetch(es,{headers:{accept:"application/json"}});if(!s.ok)throw me(s,t);return await s.json()}function Je(){const{t}=N();return te({queryKey:je,queryFn:()=>Sn(t)})}function Rn(){const{taskId:t}=xe(),s=z(),a=U(),{t:r}=N(),n=ke(r("workGraphLoadErrorFallback")).data??pe,o=m.useMemo(()=>be(n),[n]),i=Se(),l=Ne(),c=Je(),h=ze(),u=i.data?.tasks??[],d=t?u.find(f=>f.id===t):void 0,w=$({mutationFn:async f=>{await tr(f,r("workTaskDeleteError"))},onSuccess:async()=>{await a.invalidateQueries({queryKey:we}),s(Q)}}),y=$({mutationFn:async f=>{await sr(f.taskId,{action:f.action,decidedByActorId:f.decidedByActorId},r("workTaskApprovalDecisionError"))},onSuccess:async()=>{await Promise.all([a.invalidateQueries({queryKey:we}),a.invalidateQueries({queryKey:De}),a.invalidateQueries({queryKey:Y})])}}),j=$({mutationFn:async f=>ar(f,r("workTaskStartRunError")),onSuccess:async f=>{await Promise.all([a.invalidateQueries({queryKey:we}),a.invalidateQueries({queryKey:Ye}),a.invalidateQueries({queryKey:De}),a.invalidateQueries({queryKey:Y})]),s(ye(f.run.taskId??f.task.id,f.run.id))}}),_=()=>{d&&window.confirm(r("workTaskDeleteConfirmation",{taskTitle:d.title}))&&w.mutate(d.id)},x=f=>{d&&y.mutate({taskId:d.id,action:f,decidedByActorId:d.ownerActorId})},L=()=>{!d||d.status!=="approved"||j.mutate(d.id)};if(i.isPending)return e.jsx(Cn,{});if(!d)return e.jsx(Bn,{taskId:t??null});const g=w.error?V(w.error,r("workTaskDeleteError"),r):null,k=y.error?V(y.error,r("workTaskApprovalDecisionError"),r):null,R=j.error?V(j.error,r("workTaskStartRunError"),r):null,D=d.projectId?l.data?.projects.find(f=>f.id===d.projectId):void 0,S=d.workItemId?c.data?.workItems.find(f=>f.id===d.workItemId):void 0,C=d.parentTaskId?u.find(f=>f.id===d.parentTaskId):void 0,I=u.filter(f=>f.parentTaskId===d.id),b=(h.data?.runs??[]).filter(f=>f.taskId===d.id).sort((f,G)=>G.updatedAt.localeCompare(f.updatedAt)),T=d.productBinding?gt(d.productBinding,r):null,v=n.objects.filter(f=>f.kind==="activity"&&f.linkedTaskId===d.id).sort((f,G)=>G.updatedAt.localeCompare(f.updatedAt)),O=d.assignedActors.map(f=>f.displayName),P=d.status==="pending_approval",A=y.isPending,F=d.status==="approved"&&b.length===0;return e.jsxs("div",{className:"taskDetail",children:[e.jsxs("header",{className:"channelTopBar taskDetailTopBar",children:[e.jsx("div",{className:"channelTopBarStart taskDetailTopBar__start",children:e.jsxs(B,{to:"..",relative:"path",className:"taskDetailTopBar__back","aria-label":r("workTaskBackLabel"),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M7.5 2L3.5 6l4 4"})}),e.jsx("span",{children:r("workTaskBackArrowLabel")})]})}),e.jsxs("div",{className:"channelTopBarCenter taskDetailTopBar__center",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--${d.status}`,"aria-hidden":"true"}),e.jsx("h1",{className:"channelTopBarTitle taskDetailTopBar__title",children:d.title})]}),e.jsxs("div",{className:"channelTopBarEnd taskDetailTopBar__end",children:[d.attention!=="none"?e.jsx("span",{className:`taskDetail__attention taskDetail__attention--${d.attention}`,children:re(d.attention,r)}):null,d.priority?e.jsx("span",{className:`tasksList__priority tasksList__priority--${d.priority}`,title:r("workTaskPriorityTooltip",{priority:Gt(d.priority,r)}),children:Gt(d.priority,r)}):null,d.productBinding?e.jsx("span",{className:`tasksList__binding tasksList__binding--${d.productBinding}`,title:r("workTopdownTaskProductBindingTitle",{productBinding:T??""}),children:T}):null,e.jsx("span",{className:`tasksList__statusPill tasksList__statusPill--${d.status}`,children:fs(d.status,r)}),e.jsx("span",{className:"taskDetailTopBar__updated",children:r("workTaskUpdatedAtPrefix",{updatedAt:W(d.updatedAt,r)})}),P?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"taskDetailTopBar__action taskDetailTopBar__action--primary",onClick:()=>x("approve"),disabled:A,"aria-label":r("workTaskApproveLabel"),children:r(A?"workTaskApproveBusyLabel":"workTaskApproveLabel")}),e.jsx("button",{type:"button",className:"taskDetailTopBar__action",onClick:()=>x("reject"),disabled:A,"aria-label":r("workTaskRejectLabel"),children:r(A?"workTaskRejectBusyLabel":"workTaskRejectLabel")})]}):null,F?e.jsx("button",{type:"button",className:"taskDetailTopBar__action taskDetailTopBar__action--primary",onClick:L,disabled:j.isPending,"aria-label":r("workTaskNoRunsActionLabel"),children:j.isPending?r("workTaskStartRunBusyLabel"):r("workTaskNoRunsActionLabel")}):null,e.jsx("button",{type:"button",className:"taskDetailTopBar__action taskDetailTopBar__action--destructive",onClick:_,disabled:w.isPending||A||j.isPending,"aria-label":r("workTaskDeleteLabel"),children:w.isPending?r("workTaskDeleteLabelBusy"):r("workTaskDeleteLabel")})]})]}),e.jsxs("main",{className:"taskDetail__main",children:[g||k||R?e.jsx("p",{className:"taskDetail__error",role:"alert",children:g??k??R}):null,e.jsxs("section",{className:"taskDetail__section taskDetail__overview",children:[e.jsx("header",{className:"taskDetail__sectionHeader",children:e.jsx("h2",{children:r("workTaskOverviewTitle")})}),e.jsxs("dl",{className:"taskDetail__overviewList",children:[d.summary?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:r("workTaskSummaryLabel")}),e.jsx("dd",{children:d.summary})]}):null,e.jsx("dt",{children:r("workTaskProjectLabel")}),e.jsx("dd",{children:D?e.jsx(B,{className:"taskDetail__refLink",to:`${ne}/${D.id}`,children:D.title}):d.projectTitle?e.jsx("span",{children:d.projectTitle}):e.jsx("em",{children:r("workTaskOrphanProjectFallback")})}),e.jsx("dt",{children:r("workTaskWorkItemLabel")}),e.jsx("dd",{children:S?e.jsx(B,{className:"taskDetail__refLink",to:`${he}/${S.id}`,children:S.title}):d.workItemTitle?e.jsx("span",{children:d.workItemTitle}):e.jsx("em",{children:r("workTaskNoWorkItemFallback")})}),C?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:r("workTaskParentTaskLabel")}),e.jsx("dd",{children:e.jsx(B,{className:"taskDetail__refLink",to:`${Q}/${C.id}`,children:C.title})})]}):null,e.jsx("dt",{children:r("workTaskOwnerLabel")}),e.jsx("dd",{children:d.ownerName}),e.jsx("dt",{children:r("workTaskAssigneeLabel")}),e.jsx("dd",{children:d.assigneeName??e.jsx("em",{children:r("workTaskNoAssigneeFallback")})}),e.jsx("dt",{children:r("workTaskAssignedActorsLabel")}),e.jsx("dd",{children:O.length>0?O.join(", "):e.jsx("em",{children:r("workTaskNoActorsAssignedFallback")})}),d.acceptanceCriteria?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:r("workTaskAcceptanceCriteriaLabel")}),e.jsx("dd",{children:d.acceptanceCriteria})]}):null,d.conversationId?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:r("workTaskConversationLabel")}),e.jsx("dd",{children:e.jsx("span",{className:"taskDetail__convoTitle",children:d.conversationTitle??d.conversationId})})]}):null]})]}),e.jsx(In,{subTasks:I}),e.jsx(Pn,{taskId:d.id,runs:b,canStartRun:F,isStartingRun:j.isPending,onStartRun:L}),e.jsx(ft,{selfRef:{recordFamily:"task",recordId:d.id},graph:n,indexes:o}),e.jsx(vn,{taskId:d.id}),e.jsxs("section",{className:"taskDetail__section",children:[e.jsxs("header",{className:"taskDetail__sectionHeader",children:[e.jsx("h2",{children:r("workTaskActivityTitle")}),e.jsx("span",{className:"taskDetail__sectionCount",children:v.length})]}),v.length===0?e.jsx("p",{className:"taskDetail__empty",children:r("workTaskNoActivity")}):e.jsx("ul",{className:"taskDetail__activity",children:v.map(f=>e.jsxs("li",{className:"taskDetail__activityRow",children:[e.jsx("span",{className:"taskDetail__activityWhen",children:W(f.updatedAt,r)}),e.jsx("span",{className:"taskDetail__activityTitle",children:f.title}),f.summary?e.jsx("span",{className:"taskDetail__activitySummary",children:f.summary}):null]},f.id))})]})]})]})}function In({subTasks:t}){const{t:s}=N();return e.jsxs("section",{className:"taskDetail__section",children:[e.jsxs("header",{className:"taskDetail__sectionHeader",children:[e.jsx("h2",{children:s("workTaskSubTasksTitle")}),e.jsx("span",{className:"taskDetail__sectionCount",children:t.length})]}),t.length===0?e.jsx("p",{className:"taskDetail__empty",children:s("workTaskNoSubTasksLabel")}):e.jsx("ul",{className:"taskDetail__subTasks",children:t.map(a=>e.jsxs("li",{className:"taskDetail__subTaskRow",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--small projectsList__dot--${a.status}`,"aria-hidden":"true"}),e.jsx(B,{to:`${Q}/${a.id}`,className:"taskDetail__subTaskTitle",children:a.title}),e.jsx("span",{className:`tasksList__statusPill tasksList__statusPill--${a.status}`,children:fs(a.status,s)})]},a.id))})]})}function Pn({taskId:t,runs:s,canStartRun:a,isStartingRun:r,onStartRun:n}){const{t:o}=N();return e.jsxs("section",{className:"taskDetail__section",children:[e.jsxs("header",{className:"taskDetail__sectionHeader",children:[e.jsx("h2",{children:o("workTaskRunsTitle")}),e.jsx("span",{className:"taskDetail__sectionCount",children:s.length})]}),s.length===0?e.jsxs("div",{className:"taskDetail__emptyAction",children:[e.jsxs("p",{className:"taskDetail__empty",children:[o("workTaskNoRunsIntro")," ",e.jsx("strong",{children:o("workTaskNoRunsActionLabel")})," ",o("workTaskNoRunsSuffix")]}),e.jsx("button",{type:"button",className:"taskDetail__inlineAction",onClick:n,disabled:!a||r,children:o(r?"workTaskStartRunBusyLabel":"workTaskNoRunsActionLabel")})]}):e.jsx("ul",{className:"taskDetail__subTasks",children:s.map(i=>e.jsxs("li",{className:"taskDetail__subTaskRow",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--small projectsList__dot--${i.status}`,"aria-hidden":"true"}),e.jsx(B,{to:ye(t,i.id),className:"taskDetail__subTaskTitle",children:i.title}),e.jsx("span",{className:`tasksList__statusPill tasksList__statusPill--${i.status}`,children:En(i.status,o)}),e.jsx("span",{className:"taskDetail__activityWhen",children:W(i.updatedAt,o)})]},i.id))})]})}function Cn(){const{t}=N();return e.jsxs("div",{className:"taskDetail",children:[e.jsx("header",{className:"channelTopBar taskDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart taskDetailTopBar__start",children:e.jsx(B,{to:"..",relative:"path",className:"taskDetailTopBar__back",children:e.jsx("span",{children:t("workTaskBackArrowLabel")})})})}),e.jsx("main",{className:"taskDetail__main",children:e.jsx("p",{className:"taskDetail__empty",children:t("workTaskLoadingLabel")})})]})}function Bn({taskId:t}){const{t:s}=N();return e.jsxs("div",{className:"taskDetail",children:[e.jsx("header",{className:"channelTopBar taskDetailTopBar",children:e.jsxs("div",{className:"channelTopBarStart taskDetailTopBar__start",children:[e.jsx(B,{to:"..",relative:"path",className:"taskDetailTopBar__back",children:e.jsx("span",{children:s("workTaskBackArrowLabel")})}),e.jsx("span",{className:"taskDetailTopBar__separator","aria-hidden":"true",children:"/"}),e.jsx("h1",{className:"channelTopBarTitle taskDetailTopBar__title",children:s("workTaskNotFoundTitle")})]})}),e.jsx("main",{className:"taskDetail__main",children:e.jsx("p",{className:"taskDetail__empty",children:s("workTaskNotFoundText",{taskId:t??s("workTaskNotFoundCodeLabel")})})})]})}function fs(t,s){return t==="pending_approval"?s("workTaskStatusPendingApproval"):t==="approved"?s("workTaskStatusApproved"):t==="archived"?s("workTaskStatusArchived"):M(t,s)}function En(t,s){return t==="pending_approval"?s("workTaskStatusPendingApproval"):M(t,s)}function Gt(t,s){return t==="urgent"?s("workTaskPriorityUrgent"):t==="high"?s("workTaskPriorityHigh"):t==="medium"?s("workTaskPriorityMedium"):t==="low"?s("workTaskPriorityLow"):t}const An="workRenderer";async function Wn(t,s){const a={};t.priority&&(a.priority=t.priority),t.assigneeName&&(a.assigneeName=t.assigneeName),t.acceptanceCriteria&&(a.acceptanceCriteria=t.acceptanceCriteria);const r=Object.keys(a).length>0?{[An]:a}:void 0;return{id:(await er({title:t.title,summary:t.summary,status:t.status,parentTaskId:t.parentTaskId,metadata:r},s)).task.id}}function Mn({onClose:t,defaultParentTaskId:s}){const{t:a}=N(),r=z(),n=U(),o=m.useId(),i=m.useId(),l=m.useId(),c=m.useId(),h=m.useId(),u=m.useId(),d=m.useId(),w=m.useRef(null),y=Se(),[j,_]=m.useState(""),[x,L]=m.useState(""),[g,k]=m.useState(s??""),[R,D]=m.useState(""),[S,C]=m.useState("draft"),[I,b]=m.useState(""),[T,v]=m.useState(""),O=$({mutationFn:E=>Wn(E,a("workNewTaskCreateError")),onSuccess:async E=>{await n.invalidateQueries({queryKey:we}),t(),r(`${Q}/${E.id}`)}}),P=O.isPending,A=O.error?V(O.error,a("workNewTaskCreateError"),a):null;m.useEffect(()=>{w.current?.focus()},[]),m.useEffect(()=>{function E(fe){fe.key==="Escape"&&(fe.stopPropagation(),t())}return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[t]);function F(E){E.target===E.currentTarget&&t()}function f(E){E.preventDefault();const fe=j.trim();!fe||P||O.mutate({title:fe,summary:x.trim()||null,status:S,priority:I||null,assigneeName:R.trim()||null,acceptanceCriteria:T.trim()||null,parentTaskId:g||null})}const G=[{value:"draft",label:a("workNewTaskStatusDraft")},{value:"pending_approval",label:a("workNewTaskStatusPendingApproval")},{value:"approved",label:a("workNewTaskStatusApproved")},{value:"in_progress",label:a("workNewTaskStatusInProgress")},{value:"blocked",label:a("workNewTaskStatusBlocked")},{value:"completed",label:a("workNewTaskStatusCompleted")}],As=[{value:"",label:a("workNewTaskNoPriority")},{value:"urgent",label:a("workNewTaskPriorityUrgent")},{value:"high",label:a("workNewTaskPriorityHigh")},{value:"medium",label:a("workNewTaskPriorityMedium")},{value:"low",label:a("workNewTaskPriorityLow")}],Ws=y.data?.tasks??[];return e.jsx("div",{className:"newProjectDialog__backdrop",role:"presentation",onClick:F,children:e.jsxs("div",{className:"newProjectDialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":`${o}-heading`,children:[e.jsxs("header",{className:"newProjectDialog__header",children:[e.jsx("h2",{id:`${o}-heading`,className:"newProjectDialog__heading",children:a("workNewTaskTitle")}),e.jsx("button",{type:"button",className:"newProjectDialog__close","aria-label":a("workNewTaskCloseLabel"),onClick:t,children:"×"})]}),e.jsxs("form",{className:"newProjectDialog__form",onSubmit:f,children:[e.jsxs("label",{className:"newProjectDialog__field",htmlFor:o,children:[e.jsxs("span",{className:"newProjectDialog__label",children:[a("workNewTaskTitleLabel"),e.jsx("span",{className:"newProjectDialog__required","aria-hidden":"true",children:"*"})]}),e.jsx("input",{ref:w,id:o,type:"text",className:"newProjectDialog__input",value:j,onChange:E=>_(E.target.value),placeholder:a("workNewTaskTitlePlaceholder"),required:!0,maxLength:120})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:i,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workNewTaskSummaryLabel")}),e.jsx("textarea",{id:i,className:"newProjectDialog__textarea",value:x,onChange:E=>L(E.target.value),placeholder:a("workNewTaskSummaryPlaceholder"),rows:3,maxLength:400})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:l,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workNewTaskParentTaskLabel")}),e.jsxs("select",{id:l,className:"newProjectDialog__select",value:g,onChange:E=>k(E.target.value),children:[e.jsx("option",{value:"",children:a("workNewTaskNoParentTask")}),Ws.map(E=>e.jsx("option",{value:E.id,children:E.title},E.id))]})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:c,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workNewTaskAssigneeLabel")}),e.jsx("input",{id:c,type:"text",className:"newProjectDialog__input",value:R,onChange:E=>D(E.target.value),placeholder:a("workNewTaskAssigneePlaceholder"),maxLength:60})]}),e.jsxs("div",{className:"newProjectDialog__row",children:[e.jsxs("label",{className:"newProjectDialog__field",htmlFor:h,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workNewTaskStatusLabel")}),e.jsx("select",{id:h,className:"newProjectDialog__select",value:S,onChange:E=>C(E.target.value),children:G.map(E=>e.jsx("option",{value:E.value,children:E.label},E.value))})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:u,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workNewTaskPriorityLabel")}),e.jsx("select",{id:u,className:"newProjectDialog__select",value:I,onChange:E=>b(E.target.value),children:As.map(E=>e.jsx("option",{value:E.value,children:E.label},E.value))})]})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:d,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workNewTaskAcceptanceCriteriaLabel")}),e.jsx("textarea",{id:d,className:"newProjectDialog__textarea",value:T,onChange:E=>v(E.target.value),placeholder:a("workNewTaskAcceptanceCriteriaPlaceholder"),rows:2,maxLength:280})]}),A?e.jsx("p",{className:"newProjectDialog__error",role:"alert",children:A}):null,e.jsxs("footer",{className:"newProjectDialog__footer",children:[e.jsx("button",{type:"button",className:"newProjectDialog__cancelBtn",onClick:t,disabled:P,children:a("workNewTaskCancelButton")}),e.jsx("button",{type:"submit",className:"newProjectDialog__submitBtn",disabled:j.trim().length===0||P,children:a(P?"workNewTaskSubmittingLabel":"workNewTaskSubmitLabel")})]})]})]})})}function On(){const t=Se(),s=t.data?.tasks??[],[a,r]=m.useState(!1),{t:n}=N();return e.jsxs("div",{className:"tasksList",children:[e.jsxs("header",{className:"channelTopBar tasksListTopBar",children:[e.jsxs("div",{className:"channelTopBarStart tasksListTopBar__start",children:[e.jsx("h1",{className:"channelTopBarTitle tasksListTopBar__title",children:n("workTasksListTitle")}),e.jsx("span",{className:"tasksListTopBar__count",children:s.length})]}),e.jsx("div",{className:"channelTopBarCenter tasksListTopBar__center"}),e.jsx("div",{className:"channelTopBarEnd tasksListTopBar__end",children:e.jsxs("button",{type:"button",className:"tasksListTopBar__addBtn",onClick:()=>r(!0),"aria-label":n("workTasksListCreateNewTaskAriaLabel"),children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M7 2v10"}),e.jsx("path",{d:"M2 7h10"})]}),e.jsx("span",{children:n("workTasksListNewAction")})]})})]}),e.jsx("main",{className:"tasksList__main",children:t.isPending?e.jsx("p",{className:"tasksList__empty",children:n("workTasksListLoading")}):t.isError?e.jsx("p",{className:"tasksList__empty",children:n("workTasksListLoadError",{errorMessage:String(t.error.message)})}):s.length===0?e.jsxs("p",{className:"tasksList__empty",children:[n("workTasksListEmptyIntro")," ",e.jsx("strong",{children:n("workTasksListEmptyActionLabel")})," ",n("workTasksListEmptySuffix")]}):e.jsx("ul",{className:"tasksList__list",children:s.map(o=>{const i=o.productBinding?gt(o.productBinding,n):null;return e.jsx("li",{className:"tasksList__row",children:e.jsxs(B,{to:o.id,className:"tasksList__rowLink","aria-label":n("workTasksListOpenTaskAria",{title:o.title}),children:[e.jsxs("div",{className:"tasksList__rowMain",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--${o.status}`,"aria-hidden":"true"}),e.jsxs("div",{className:"tasksList__rowText",children:[e.jsx("span",{className:"tasksList__rowTitle",children:o.title}),o.summary?e.jsx("span",{className:"tasksList__rowSummary",children:o.summary}):null]})]}),e.jsxs("div",{className:"tasksList__rowMeta",children:[o.productBinding?e.jsx("span",{className:`tasksList__binding tasksList__binding--${o.productBinding}`,title:n("workTopdownTaskProductBindingTitle",{productBinding:i??""}),children:i}):null,o.projectTitle?e.jsx("span",{className:"tasksList__chip tasksList__chip--project",children:o.projectTitle}):null,o.workItemTitle?e.jsx("span",{className:"tasksList__chip tasksList__chip--workItem",children:o.workItemTitle}):null,o.priority?e.jsx("span",{className:`tasksList__priority tasksList__priority--${o.priority}`,title:Fn(o.priority,n),children:Ts(o.priority,n)}):null,o.attention==="decision_needed"?e.jsx("span",{className:"tasksList__pip tasksList__pip--decision",children:n("workObjectAttentionDecisionNeeded")}):null,o.attention==="blocked"||o.attention==="failed"?e.jsx("span",{className:"tasksList__pip tasksList__pip--blocked",children:re(o.attention,n)}):null,o.assigneeName?e.jsx("span",{className:"tasksList__assignee",children:o.assigneeName}):o.ownerRole?e.jsx("span",{className:"tasksList__assignee tasksList__assignee--role",children:ge(o.ownerRole,n)}):null,e.jsx("span",{className:"tasksList__metric tasksList__metric--muted",children:W(o.updatedAt,n)}),e.jsx("span",{className:`tasksList__statusPill tasksList__statusPill--${o.status}`,children:Kn(o.status,n)})]})]})},o.id)})})}),a?e.jsx(Mn,{onClose:()=>r(!1)}):null]})}function Kn(t,s){return t==="pending_approval"?s("workTaskStatusPendingApproval"):t==="approved"?s("workTaskStatusApproved"):t==="archived"?s("workTaskStatusArchived"):M(t,s)}function Ts(t,s){return t==="urgent"?s("workTaskPriorityUrgent"):t==="high"?s("workTaskPriorityHigh"):t==="medium"?s("workTaskPriorityMedium"):t==="low"?s("workTaskPriorityLow"):t}function Fn(t,s){const a=Ts(t,s);return s("workTaskPriorityLabelWithValue",{priorityLabel:a})}function Ls(t,s){switch(t){case"Blocked before runtime launch completed.":return s(p.workRunSummaryBlockedBeforeRuntimeLaunch);case"Blocked before scheduled runtime launch completed.":return s(p.workRunSummaryBlockedBeforeScheduledRuntimeLaunch);case"Launching scheduled mission through supervised runtime boundary.":return s(p.workRunSummaryLaunchingScheduledMission);case"Provider-agent runtime message completed.":return s(p.workRunSummaryProviderAgentRuntimeMessageCompleted);case"Queued supervised Work run.":return s(p.workRunSummaryQueuedSupervisedWorkRun);case"Started supervised Code task execution.":return s(p.workRunSummaryStartedSupervisedCodeTaskExecution)}const a=t.match(/^Relay fan-out dispatch for (.+)\.$/u);return a?s(p.workRunSummaryRelayFanOutDispatch,{agentLabel:a[1]}):t}function $n(){const t=ze(),s=t.data?.runs??[],{t:a}=N();return e.jsxs("div",{className:"runsList",children:[e.jsxs("header",{className:"channelTopBar runsListTopBar",children:[e.jsxs("div",{className:"channelTopBarStart runsListTopBar__start",children:[e.jsx("h1",{className:"channelTopBarTitle runsListTopBar__title",children:a("workRunsListTitle")}),e.jsx("span",{className:"runsListTopBar__count",children:s.length})]}),e.jsx("div",{className:"channelTopBarCenter runsListTopBar__center",children:e.jsx("p",{className:"runsListTopBar__lede",children:a("workRunsListLede")})}),e.jsx("div",{className:"channelTopBarEnd runsListTopBar__end"})]}),e.jsx("main",{className:"runsList__main",children:t.isPending?e.jsx("p",{className:"runsList__empty",children:a("workRunsListLoading")}):t.isError?e.jsx("p",{className:"runsList__empty",children:a("workRunsListLoadError",{errorMessage:String(t.error.message)})}):s.length===0?e.jsx("p",{className:"runsList__empty",children:a("workRunsListNoRunsIntro")}):e.jsx("ul",{className:"runsList__list",children:s.map(r=>{const n=r.taskId??"orphan";return e.jsx("li",{className:"runsList__row",children:e.jsxs(B,{to:ye(n,r.id),className:"runsList__rowLink","aria-label":a("workRunOpenAriaLabel",{runTitle:r.title}),children:[e.jsxs("div",{className:"runsList__rowMain",children:[e.jsx("span",{className:`runsList__dot runsList__dot--${r.status}`,"aria-hidden":"true"}),e.jsxs("div",{className:"runsList__rowText",children:[e.jsx("span",{className:"runsList__rowTitle",children:r.title}),r.summary?e.jsx("span",{className:"runsList__rowSummary",children:Ls(r.summary,a)}):null]})]}),e.jsxs("div",{className:"runsList__rowMeta",children:[r.taskTitle?e.jsx("span",{className:"runsList__chip runsList__chip--task",children:r.taskTitle}):null,r.parentRunId?e.jsx("span",{className:"runsList__chip runsList__chip--parentRun",children:a("workRunSubRunChip")}):null,e.jsx("span",{className:"runsList__metric runsList__metric--muted",children:W(r.updatedAt,a)}),e.jsx("span",{className:`runsList__statusPill runsList__statusPill--${r.status}`,children:M(r.status,a)})]})]})},r.id)})})})]})}function Un(t,s){const a=new Error(s);return a.statusCode=t,a}function Gn(){return{fallbackMessage:oe(p.workRunStopError),routeFallback:t=>oe(p.workRunStopRouteFailed,{statusCode:t})}}function Qn(){return{fallbackMessage:oe(p.workMissionCancelError),routeFallback:t=>oe(p.workMissionCancelRouteFailed,{statusCode:t})}}async function vs(t,s,a){const n=await fetch(t,{method:"POST",headers:void 0,body:void 0}),o=await n.text();let i=null;if(o)try{i=JSON.parse(o)}catch{}if(!n.ok){const l=(()=>{if(i&&typeof i=="object"&&!Array.isArray(i)){const c=i.error?.message;if(typeof c=="string"&&c.length>0)return c}return a.routeFallback(n.status)||a.fallbackMessage})();throw Un(n.status,l)}return i}async function Hn(t,s,a=Gn()){return vs(ca(t),s,a)}async function qn(t,s,a=Qn()){return vs(da(t),s,a)}const Tt=["missions"],Vn=t=>["missions","detail",t];async function Yn(t){const s=await fetch(ua,{headers:{accept:"application/json"}});if(!s.ok)throw me(s,t);return await s.json()}async function zn(t,s){const a=await fetch(ha(t),{headers:{accept:"application/json"}});if(a.status===404)return null;if(!a.ok)throw me(a,s);return await a.json()}function Lt(){const{t}=N();return te({queryKey:Tt,queryFn:()=>Yn(t)})}function Jn(t){const{t:s}=N();return te({queryKey:t?Vn(t):["missions","detail","__none__"],queryFn:()=>t?zn(t,s):Promise.resolve(null),enabled:!!t})}async function Xn(t,s,a){const r=new URLSearchParams;r.set("runId",t);const n=await fetch(`/api/core/traces?${r.toString()}`,{signal:a});return(await K(n,s)).traces}const Zn={approval:p.sharedOperatorTraceKindApproval,checkpoint:p.sharedOperatorTraceKindCheckpoint,dispatch:p.sharedOperatorTraceKindDispatch,error:p.sharedOperatorTraceKindError,outcome:p.sharedOperatorTraceKindOutcome,status:p.sharedOperatorTraceKindStatus,note:p.sharedOperatorTraceKindNote},eo={succeeded:p.sharedOperatorOutcomeStatusSucceeded,blocked:p.sharedOperatorOutcomeStatusBlocked,failed:p.sharedOperatorOutcomeStatusFailed,cancelled:p.sharedOperatorOutcomeStatusCancelled},to={draft:p.workRunArtifactStatusDraft,ready:p.workRunArtifactStatusReady,published:p.workRunArtifactStatusPublished,archived:p.workRunArtifactStatusArchived};function vt(t){return t.trim().replace(/[_-]+/gu," ").replace(/\s+/gu," ")}function so(t,s){const a=Zn[t];return a?s(a):s(p.workRunTraceKindUnknown,{kind:vt(t)})}function ao(t,s){const a=eo[t];return a?s(a):s(p.workObjectStatusUnknown,{status:vt(t)})}function ro(t,s){const a=to[t];return a?s(a):s(p.workObjectStatusUnknown,{status:vt(t)})}const no="Running run is not stoppable: no supervised runtime session is bridged.",oo="Runtime client is unavailable; cannot request runtime cancellation.",io="Run is not stoppable.",Qt="Runtime cancellation failed: ";function Ds(t,s){const a=t?.trim();if(!a||a===io)return s("workCancellationBlockerRunNotStoppable");if(a===no)return s("workCancellationBlockerNoRuntimeSession");if(a===oo)return s("workCancellationBlockerRuntimeClientUnavailable");if(a.startsWith(Qt)){const r=a.slice(Qt.length).trim();return r?s("workCancellationBlockerRuntimeCancellationFailed",{error:r}):s("workRunStopErrorFallback")}return a}function lo(t,s){return t.message?Ds(t.message,s):t.runtimeAbort.status==="failed"?t.runtimeAbort.error==="runtime_client_unavailable"?s("workCancellationBlockerRuntimeClientUnavailable"):t.runtimeAbort.error?s("workCancellationBlockerRuntimeCancellationFailed",{error:t.runtimeAbort.error}):s("workRunStopErrorFallback"):t.runtimeAbort.status==="not_applicable"?s("workCancellationBlockerNoRuntimeSession"):s("workCancellationBlockerRunNotStoppable")}function co(t,s){return t.map(a=>`${a.runId}: ${Ds(a.reason,s)}`).join("; ")}function uo(t,s){const a=co(t,s);return s("workMissionCancelBlocked",{detail:a||s("workMissionCancelBlockedNoDetails")})}const ho={status:"idle",traces:[],error:null};function mo(t,s){const a=new Map;for(const n of s){const o=n.parentRunId??"",i=a.get(o)??[];i.push(n),a.set(o,i)}function r(n,o){return(a.get(n)??[]).filter(l=>!o.has(l.id)).sort((l,c)=>(l.startedAt??l.updatedAt).localeCompare(c.startedAt??c.updatedAt)).map(l=>{const c=new Set(o);return c.add(l.id),{run:l,children:r(l.id,c)}})}return r(t,new Set([t]))}function po(t){return t==="completed"||t==="failed"||t==="cancelled"}function ko(t,s){if(!t)return null;const a=Date.parse(t);if(Number.isNaN(a))return null;const r=s?Date.parse(s):Date.now();if(Number.isNaN(r))return null;const n=Math.max(0,Math.round((r-a)/1e3));if(n<60)return`${n}s`;const o=Math.round(n/60);return o<60?`${o}m`:`${Math.round(o/60)}h`}function wo(){const{taskId:t,runId:s}=xe(),a=U(),{t:r}=N(),n=ze(),o=Se(),i=ke(r("workGraphLoadErrorFallback")).data??pe,[l,c]=m.useState(null),h=n.data?.runs??[],u=o.data?.tasks??[],d=s?h.find(b=>b.id===s):void 0,w=t?u.find(b=>b.id===t):void 0,y=$({mutationFn:async b=>Hn(b,void 0,{fallbackMessage:r("workRunStopError"),routeFallback:T=>r("workRunStopRouteFailed",{statusCode:T})}),onSuccess:async b=>{await Promise.all([a.invalidateQueries({queryKey:Ye}),a.invalidateQueries({queryKey:Tt}),a.invalidateQueries({queryKey:Y})]),b.status==="not_stoppable"?c(lo(b,r)):c(null)}}),j=()=>{d&&window.confirm(r("workRunStopConfirmation",{runTitle:d.title}))&&(c(null),y.mutate(d.id))},_=y.error,x=_?_ instanceof Error?_.message:r("workRunStopError"):null,L=m.useMemo(()=>s?mo(s,h):[],[s,h]),g=m.useMemo(()=>i.objects.filter(b=>b.kind==="activity"&&b.linkedRunId===s).sort((b,T)=>T.updatedAt.localeCompare(b.updatedAt)),[i.objects,s]),k=m.useMemo(()=>{const b=new Map;for(const T of i.objects)T.kind==="agent"&&b.set(T.id,T.title);return b},[i.objects]),R=m.useMemo(()=>i.objects.filter(b=>b.kind==="outcome"&&b.linkedRunId===s).sort((b,T)=>T.updatedAt.localeCompare(b.updatedAt)),[i.objects,s]),D=m.useMemo(()=>i.objects.filter(b=>b.kind==="artifact"&&b.linkedRunId===s).sort((b,T)=>T.updatedAt.localeCompare(b.updatedAt)),[i.objects,s]),[S,C]=m.useState(ho);if(m.useEffect(()=>{if(!s)return;const b=d?.status==="queued"||d?.status==="running",T=new AbortController;let v=!1;async function O(){try{const A=await Xn(s,r("workRunTraceLoadFallback"),T.signal);if(v)return;C({status:"ready",traces:A,error:null})}catch(A){if(v||T.signal.aborted)return;C(F=>({status:"error",traces:F.traces,error:A instanceof Error?A.message:String(A)}))}}if(C(A=>({status:A.traces.length===0?"loading":"ready",traces:A.traces,error:null})),O(),!b)return()=>{v=!0,T.abort()};const P=window.setInterval(()=>{a.invalidateQueries({queryKey:Y}),O()},3e3);return()=>{v=!0,T.abort(),window.clearInterval(P)}},[s,d?.status,a]),n.isPending)return e.jsx(jo,{});if(!d)return e.jsx(xo,{runId:s??null});const I=ko(d.startedAt??null,d.completedAt??null);return e.jsxs("div",{className:"runDetail",children:[e.jsxs("header",{className:"channelTopBar runDetailTopBar",children:[e.jsxs("div",{className:"channelTopBarStart runDetailTopBar__start",children:[e.jsxs(B,{to:Q,className:"runDetailTopBar__back","aria-label":r("workRunBackArrowLabel"),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M7.5 2L3.5 6l4 4"})}),e.jsx("span",{children:r("workRunBackLabel")})]}),w?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"runDetailTopBar__sep",children:"›"}),e.jsx(B,{to:Nt(w.id),className:"runDetailTopBar__crumb",children:w.title})]}):null,e.jsx("span",{className:"runDetailTopBar__sep",children:"›"}),e.jsx("h1",{className:"channelTopBarTitle runDetailTopBar__title",children:d.title})]}),e.jsx("div",{className:"channelTopBarCenter runDetailTopBar__center"}),e.jsxs("div",{className:"channelTopBarEnd runDetailTopBar__end",children:[po(d.status)?null:e.jsx("button",{type:"button",className:"runDetailTopBar__action runDetailTopBar__action--destructive",onClick:j,disabled:y.isPending,"aria-label":r("workRunStopLabel"),children:y.isPending?r("workRunStopLabelBusy"):r("workRunStopLabel")}),e.jsx("span",{className:`runDetail__statusPill runDetail__statusPill--${d.status}`,children:M(d.status,r)})]})]}),e.jsxs("main",{className:"runDetail__main",children:[x?e.jsx("p",{className:"runDetail__error",role:"alert",children:x}):null,l?e.jsx("p",{className:"runDetail__warning",role:"alert",children:l}):null,e.jsxs("section",{className:"runDetail__section",children:[e.jsx("h2",{className:"runDetail__sectionHeading",children:r("workRunSummaryTitle")}),e.jsxs("dl",{className:"runDetail__summary",children:[e.jsxs("div",{className:"runDetail__summaryRow",children:[e.jsx("dt",{children:r("workRunStatusLabel")}),e.jsx("dd",{children:M(d.status,r)})]}),e.jsxs("div",{className:"runDetail__summaryRow",children:[e.jsx("dt",{children:r("workRunUpdatedLabel")}),e.jsx("dd",{children:W(d.updatedAt,r)})]}),I?e.jsxs("div",{className:"runDetail__summaryRow",children:[e.jsx("dt",{children:r("workRunDurationLabel")}),e.jsx("dd",{children:I})]}):null,d.parentRunId?e.jsxs("div",{className:"runDetail__summaryRow",children:[e.jsx("dt",{children:r("workRunParentRunLabel")}),e.jsx("dd",{children:w?e.jsx(B,{to:ye(w.id,d.parentRunId),className:"runDetail__crumbLink",children:d.parentRunTitle??d.parentRunId}):e.jsx("span",{title:d.parentRunId,children:d.parentRunTitle??e.jsx("code",{children:d.parentRunId})})})]}):null,d.conversationId?e.jsxs("div",{className:"runDetail__summaryRow",children:[e.jsx("dt",{children:r("workRunConversationLabel")}),e.jsx("dd",{children:d.conversationTitle??e.jsx("code",{children:d.conversationId})})]}):null]}),d.summary?e.jsx("p",{className:"runDetail__summaryBody",children:Ls(d.summary,r)}):null]}),e.jsxs("section",{className:"runDetail__section",children:[e.jsx("h2",{className:"runDetail__sectionHeading",children:r("workRunSubRunsTitle",{count:`${Ss(L)}`})}),L.length===0?e.jsx("p",{className:"runDetail__empty",children:r("workRunNoSubRuns")}):e.jsx(Rs,{nodes:L,taskId:t??"orphan",depth:0,t:r})]}),e.jsxs("section",{className:"runDetail__section",children:[e.jsx("h2",{className:"runDetail__sectionHeading",children:r("workRunTraceTitle",{count:`${S.traces.length}`})}),S.status==="loading"?e.jsx("p",{className:"runDetail__empty",children:r("workRunTraceLoading")}):S.status==="error"?e.jsx("p",{className:"runDetail__error",children:r("workRunTraceLoadError",{errorMessage:S.error})}):S.traces.length===0?e.jsx("p",{className:"runDetail__empty",children:_o(d.status,r)}):e.jsx("ol",{className:"runDetail__trace",children:S.traces.slice().sort((b,T)=>b.createdAt.localeCompare(T.createdAt)).map(b=>{const T=b.actorId?k.get(b.actorId)??b.actorId:null;return e.jsxs("li",{className:`runDetail__traceRow runDetail__traceRow--${b.kind}`,children:[e.jsx("span",{className:"runDetail__traceKind",children:so(b.kind,r)}),e.jsx("span",{className:"runDetail__traceActor",title:b.actorId??r("workRunTraceNoActorRecorded"),children:T??"—"}),e.jsx("p",{className:"runDetail__traceMessage",children:b.message}),e.jsx("span",{className:"runDetail__traceTime",children:W(b.createdAt,r)})]},b.id)})})]}),g.length>0?e.jsxs("section",{className:"runDetail__section",children:[e.jsx("h2",{className:"runDetail__sectionHeading",children:r("workRunActivitiesTitle",{count:`${g.length}`})}),e.jsx("ul",{className:"runDetail__simpleList",children:g.map(b=>e.jsxs("li",{className:"runDetail__simpleRow",children:[e.jsx("span",{className:"runDetail__simpleTitle",children:b.title}),e.jsx("span",{className:"runDetail__simpleTime",children:W(b.updatedAt,r)})]},b.id))})]}):null,R.length>0?e.jsxs("section",{className:"runDetail__section",children:[e.jsx("h2",{className:"runDetail__sectionHeading",children:r("workRunOutcomesTitle",{count:`${R.length}`})}),e.jsx("ul",{className:"runDetail__simpleList",children:R.map(b=>e.jsxs("li",{className:"runDetail__simpleRow",children:[e.jsx("span",{className:"runDetail__simpleTitle",children:b.title}),e.jsx("span",{className:"runDetail__simpleStatus",children:ao(b.status,r)})]},b.id))})]}):null,D.length>0?e.jsxs("section",{className:"runDetail__section",children:[e.jsx("h2",{className:"runDetail__sectionHeading",children:r("workRunArtifactsTitle",{count:`${D.length}`})}),e.jsx("ul",{className:"runDetail__simpleList",children:D.map(b=>e.jsxs("li",{className:"runDetail__simpleRow",children:[e.jsx("span",{className:"runDetail__simpleTitle",children:b.title}),e.jsx("span",{className:"runDetail__simpleStatus",children:ro(b.status,r)})]},b.id))})]}):null]})]})}function Ss(t){let s=0;for(const a of t)s+=1+Ss(a.children);return s}function _o(t,s){switch(t){case"queued":return s("workRunTraceEmptyQueued");case"running":return s("workRunTraceEmptyRunning");case"blocked":return s("workRunTraceEmptyBlocked");case"completed":return s("workRunTraceEmptyCompleted");case"failed":return s("workRunTraceEmptyFailed");case"cancelled":return s("workRunTraceEmptyCancelled");default:return s("workRunTraceEmptyDefault")}}function Rs({nodes:t,taskId:s,depth:a,t:r}){return e.jsx("ul",{className:a===0?"runDetail__subTree":"runDetail__subTree runDetail__subTree--nested",children:t.map(({run:n,children:o})=>e.jsxs("li",{className:"runDetail__subTreeNode",children:[e.jsxs(B,{to:ye(s,n.id),className:"runDetail__subTreeLink","aria-label":r("workRunOpenSubRunAriaLabel",{runTitle:n.title}),children:[e.jsx("span",{className:`runDetail__subTreeDot runDetail__subTreeDot--${n.status}`,"aria-hidden":"true"}),e.jsx("span",{className:"runDetail__subTreeTitle",children:n.title}),e.jsx("span",{className:`runDetail__subTreeStatus runDetail__subTreeStatus--${n.status}`,children:M(n.status,r)}),e.jsx("span",{className:"runDetail__subTreeTime",children:W(n.updatedAt,r)})]}),o.length>0?e.jsx(Rs,{nodes:o,taskId:s,depth:a+1,t:r}):null]},n.id))})}function jo(){const{t}=N();return e.jsxs("div",{className:"runDetail",children:[e.jsx("header",{className:"channelTopBar runDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart runDetailTopBar__start",children:e.jsx(B,{to:Q,className:"runDetailTopBar__back",children:e.jsx("span",{children:t("workRunBackLabel")})})})}),e.jsx("main",{className:"runDetail__main",children:e.jsx("p",{className:"runDetail__empty",children:t("workRunLoadingLabel")})})]})}function xo({runId:t}){const{t:s}=N();return e.jsxs("div",{className:"runDetail",children:[e.jsx("header",{className:"channelTopBar runDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart runDetailTopBar__start",children:e.jsx(B,{to:Q,className:"runDetailTopBar__back",children:e.jsx("span",{children:s("workRunBackLabel")})})})}),e.jsx("main",{className:"runDetail__main",children:e.jsx("p",{className:"runDetail__empty",children:t?s("workRunNotFound",{runId:t}):s("workRunNoRunId")})})]})}function go(){const t=Lt(),s=t.data?.missions??[],{t:a}=N();return e.jsxs("div",{className:"missionsList",children:[e.jsxs("header",{className:"channelTopBar missionsListTopBar",children:[e.jsxs("div",{className:"channelTopBarStart missionsListTopBar__start",children:[e.jsx("h1",{className:"channelTopBarTitle missionsListTopBar__title",children:a("workMissionsListTitle")}),e.jsx("span",{className:"missionsListTopBar__count",children:s.length})]}),e.jsx("div",{className:"channelTopBarCenter missionsListTopBar__center",children:e.jsx("p",{className:"missionsListTopBar__lede",children:a("workMissionsListLede")})}),e.jsx("div",{className:"channelTopBarEnd missionsListTopBar__end"})]}),e.jsx("main",{className:"missionsList__main",children:t.isPending?e.jsx("p",{className:"missionsList__empty",children:a("workMissionsListLoading")}):t.isError?e.jsx("p",{className:"missionsList__empty",children:a("workMissionsListLoadError",{errorMessage:String(t.error.message)})}):s.length===0?e.jsx("p",{className:"missionsList__empty",children:a("workMissionsListEmpty")}):e.jsx("ul",{className:"missionsList__list",children:s.map(r=>e.jsx("li",{className:"missionsList__row",children:e.jsxs(B,{to:bs(r.id),className:"missionsList__rowLink","aria-label":a("workMissionsListOpenMissionAria",{title:r.title}),children:[e.jsxs("div",{className:"missionsList__rowMain",children:[e.jsx("span",{className:`missionsList__dot missionsList__dot--${r.status}`,"aria-hidden":"true"}),e.jsxs("div",{className:"missionsList__rowText",children:[e.jsx("span",{className:"missionsList__rowTitle",children:r.title}),r.summary?e.jsx("span",{className:"missionsList__rowSummary",children:r.summary}):null]})]}),e.jsxs("div",{className:"missionsList__rowMeta",children:[r.managedWorkTitle?e.jsx("span",{className:"missionsList__chip missionsList__chip--workItem",children:r.managedWorkTitle}):null,e.jsx("span",{className:"missionsList__metric missionsList__metric--muted",children:W(r.updatedAt,a)}),e.jsx("span",{className:`missionsList__statusPill missionsList__statusPill--${r.status}`,children:M(r.status,a)})]})]})},r.id))})})]})}function bo(){const{missionId:t}=xe(),s=U(),a=Lt(),r=Jn(t),n=Je(),o=Se(),i=ze(),{t:l}=N(),[c,h]=m.useState(null),u=t?a.data?.missions.find(D=>D.id===t)??r.data?.mission:void 0,d=$({mutationFn:async D=>qn(D,void 0,{fallbackMessage:l("workMissionCancelError"),routeFallback:S=>l("workMissionCancelRouteFailed",{statusCode:S})}),onSuccess:async D=>{await Promise.all([s.invalidateQueries({queryKey:Tt}),s.invalidateQueries({queryKey:Ye})]),D.status==="blocked"?h(uo(D.blockers,l)):h(null)}}),w=()=>{u&&window.confirm(l("workMissionCancelConfirmation",{missionTitle:u.title}))&&(h(null),d.mutate(u.id))},y=d.error,j=y?y instanceof Error?y.message:l("workMissionCancelError"):null,_=u?.managedWorkId?n.data?.workItems.find(D=>D.id===u.managedWorkId):void 0,x=m.useMemo(()=>_?(o.data?.tasks??[]).filter(S=>S.workItemId===_.id).sort((S,C)=>C.updatedAt.localeCompare(S.updatedAt)):[],[o.data,_]),L=m.useMemo(()=>{if(x.length===0)return[];const D=new Set(x.map(C=>C.id));return(i.data?.runs??[]).filter(C=>C.taskId!==null&&D.has(C.taskId)).sort((C,I)=>I.updatedAt.localeCompare(C.updatedAt))},[i.data,x]),g=m.useMemo(()=>{const D=r.data?.runs??[];if(D.length===0)return[];const S=i.data?.runs??[],C=new Map(S.map(I=>[I.id,I]));return D.map(I=>{const b=C.get(I.id);return b||{id:I.id,title:I.title,status:I.status,summary:null,taskId:I.taskId,taskTitle:null,conversationId:I.conversationId,conversationTitle:null,parentRunId:null,parentRunTitle:null,startedAt:I.startedAt,completedAt:I.completedAt,updatedAt:I.updatedAt}}).sort((I,b)=>b.updatedAt.localeCompare(I.updatedAt))},[r.data,i.data]),k=m.useMemo(()=>{const D=new Set,S=[];for(const C of[...g,...L])D.has(C.id)||(D.add(C.id),S.push(C));return S},[g,L]);if(a.isPending&&r.isPending)return e.jsx(yo,{});if(!u)return e.jsx(No,{missionId:t??null});const R=u.status==="completed"||u.status==="failed"||u.status==="cancelled";return e.jsxs("div",{className:"missionDetail",children:[e.jsxs("header",{className:"channelTopBar missionDetailTopBar",children:[e.jsxs("div",{className:"channelTopBarStart missionDetailTopBar__start",children:[e.jsxs(B,{to:ie,className:"missionDetailTopBar__back","aria-label":l("workMissionBackArrowLabel"),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M7.5 2L3.5 6l4 4"})}),e.jsx("span",{children:l("workMissionBackLabel")})]}),e.jsx("span",{className:"missionDetailTopBar__sep",children:"›"}),e.jsx("h1",{className:"channelTopBarTitle missionDetailTopBar__title",children:u.title})]}),e.jsx("div",{className:"channelTopBarCenter missionDetailTopBar__center"}),e.jsxs("div",{className:"channelTopBarEnd missionDetailTopBar__end",children:[R?null:e.jsx("button",{type:"button",className:"missionDetailTopBar__action missionDetailTopBar__action--destructive",onClick:w,disabled:d.isPending,"aria-label":l("workMissionCancelLabel"),children:d.isPending?l("workMissionCancelLabelBusy"):l("workMissionCancelLabel")}),e.jsx("span",{className:`missionDetail__statusPill missionDetail__statusPill--${u.status}`,children:M(u.status,l)})]})]}),e.jsxs("main",{className:"missionDetail__main",children:[j?e.jsx("p",{className:"missionDetail__error",role:"alert",children:j}):null,c?e.jsx("p",{className:"missionDetail__warning",role:"alert",children:c}):null,e.jsxs("section",{className:"missionDetail__section",children:[e.jsx("h2",{className:"missionDetail__sectionHeading",children:l("workMissionSummaryTitle")}),e.jsxs("dl",{className:"missionDetail__summary",children:[e.jsxs("div",{className:"missionDetail__summaryRow",children:[e.jsx("dt",{children:l("workMissionStatusLabel")}),e.jsx("dd",{children:M(u.status,l)})]}),u.assignedAgentName?e.jsxs("div",{className:"missionDetail__summaryRow",children:[e.jsx("dt",{children:l("workMissionAssignedAgentLabel")}),e.jsx("dd",{children:u.assignedAgentName})]}):null,e.jsxs("div",{className:"missionDetail__summaryRow",children:[e.jsx("dt",{children:l("workMissionUpdatedAtLabel")}),e.jsx("dd",{children:W(u.updatedAt,l)})]}),_?e.jsxs("div",{className:"missionDetail__summaryRow",children:[e.jsx("dt",{children:l("workMissionWorkItemLabel")}),e.jsx("dd",{children:e.jsx(B,{to:Ve(_.id),className:"missionDetail__crumbLink",children:_.title})})]}):null,u.conversationId?e.jsxs("div",{className:"missionDetail__summaryRow",children:[e.jsx("dt",{children:l("workMissionConversationLabel")}),e.jsx("dd",{children:u.conversationTitle??e.jsx("code",{className:"missionDetail__monoId",children:u.conversationId})})]}):null]}),u.summary?e.jsx("p",{className:"missionDetail__summaryBody",children:u.summary}):null]}),e.jsxs("section",{className:"missionDetail__section",children:[e.jsx("h2",{className:"missionDetail__sectionHeading",children:l("workMissionTasksHeading",{count:`${x.length}`})}),_?x.length===0?e.jsx("p",{className:"missionDetail__empty",children:l("workMissionNoTasks")}):e.jsx("ul",{className:"missionDetail__transitiveList",children:x.map(D=>e.jsx("li",{className:"missionDetail__transitiveRow",children:e.jsxs(B,{to:Nt(D.id),className:"missionDetail__transitiveLink",children:[e.jsx("span",{className:"missionDetail__transitiveTitle",children:D.title}),e.jsx("span",{className:`missionDetail__transitiveStatus missionDetail__transitiveStatus--${D.status}`,children:M(D.status,l)}),e.jsx("span",{className:"missionDetail__transitiveTime",children:W(D.updatedAt,l)})]})},D.id))}):e.jsx("p",{className:"missionDetail__empty",children:l("workMissionNoLinkedWorkItemForTasks")})]}),e.jsxs("section",{className:"missionDetail__section",children:[e.jsx("h2",{className:"missionDetail__sectionHeading",children:l("workMissionRunsHeading",{count:`${k.length}`})}),k.length===0?e.jsx("p",{className:"missionDetail__empty",children:l(_?"workMissionNoTransitiveRuns":"workMissionNoLinkedWorkItemForRuns")}):e.jsx("ul",{className:"missionDetail__transitiveList",children:k.map(D=>e.jsx("li",{className:"missionDetail__transitiveRow",children:e.jsxs(B,{to:ye(D.taskId??"orphan",D.id),className:"missionDetail__transitiveLink",children:[e.jsx("span",{className:"missionDetail__transitiveTitle",children:D.title}),D.taskTitle?e.jsxs("span",{className:"missionDetail__transitiveParent",children:["↳ ",D.taskTitle]}):null,e.jsx("span",{className:`missionDetail__transitiveStatus missionDetail__transitiveStatus--${D.status}`,children:M(D.status,l)}),e.jsx("span",{className:"missionDetail__transitiveTime",children:W(D.updatedAt,l)})]})},D.id))})]})]})]})}function yo(){const{t}=N();return e.jsxs("div",{className:"missionDetail",children:[e.jsx("header",{className:"channelTopBar missionDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart missionDetailTopBar__start",children:e.jsx(B,{to:ie,className:"missionDetailTopBar__back",children:e.jsx("span",{children:t("workMissionBackLabel")})})})}),e.jsx("main",{className:"missionDetail__main",children:e.jsx("p",{className:"missionDetail__empty",children:t("workMissionLoadingLabel")})})]})}function No({missionId:t}){const{t:s}=N();return e.jsxs("div",{className:"missionDetail",children:[e.jsx("header",{className:"channelTopBar missionDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart missionDetailTopBar__start",children:e.jsx(B,{to:ie,className:"missionDetailTopBar__back",children:e.jsx("span",{children:s("workMissionBackLabel")})})})}),e.jsx("main",{className:"missionDetail__main",children:e.jsx("p",{className:"missionDetail__empty",children:t?s("workMissionNotFound",{missionId:t}):s("workMissionNoMissionId")})})]})}async function fo(t,s=oe(p.workSchedulesListLoadErrorFallback)){const a=await fetch(pa,{signal:t});return K(a,s)}async function To(t,s,a=oe(p.workScheduleUpdateFailed)){const r=await fetch(kt(t),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(s)});return K(r,a)}async function Lo(t,s=oe(p.workScheduleTestFireFailed)){const a=await fetch(ma(t),{method:"POST"});return K(a,s)}async function vo(t,s=oe(p.workScheduleDeleteFailed)){const a=await fetch(kt(t),{method:"DELETE"});return K(a,s)}const it=["schedules"];function lt(t){return["schedules",t]}function Do(){const{t}=N();return te({queryKey:it,queryFn:({signal:s})=>fo(s,t(p.workSchedulesListLoadErrorFallback))})}function So(t){const{t:s}=N();return te({queryKey:t?lt(t):["schedules","_unknown"],enabled:typeof t=="string"&&t.length>0,queryFn:async({signal:a})=>{const r=await fetch(kt(t),{signal:a});return K(r,s(p.workScheduleLoadFailed))}})}const Is=pt("en");function Ps(t,s){const a=s??Is;return t.schedule.kind==="once"?a("workScheduleSummaryOnceAt",{dateTime:ve(t.schedule.fireAt,t.timezone,s)}):a("workScheduleSummaryDailyAt",{time:t.schedule.time,timezone:t.timezone})}function ve(t,s,a){const r=a??Is;if(!t)return r("workScheduleDateNone");const n=new Date(t);return Number.isNaN(n.getTime())?t:new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",timeZone:s?.trim()||void 0}).format(n)}const Ro={claimed:"workScheduleReceiptStatusClaimed",admitted:"workScheduleReceiptStatusAdmitted",duplicate:"workScheduleReceiptStatusDuplicate",skipped:"workScheduleReceiptStatusSkipped",failed:"workScheduleReceiptStatusFailed"},Io={due:"workScheduleTriggerReasonDue",manual_test:"workScheduleTriggerReasonManualTest",startup_misfire:"workScheduleTriggerReasonStartupMisfire",retry:"workScheduleTriggerReasonRetry"},Po={per_fire:"workScheduleMissionPolicyPerFire"},Co={skip:"workScheduleConcurrencyPolicySkip",queue:"workScheduleConcurrencyPolicyQueue",replace:"workScheduleConcurrencyPolicyReplace"},Bo={skip:"workScheduleMisfirePolicySkip",fire_once:"workScheduleMisfirePolicyFireOnce",fire_all:"workScheduleMisfirePolicyFireAll"},Eo={none:"workScheduleRetryBackoffNone",fixed:"workScheduleRetryBackoffFixed",exponential:"workScheduleRetryBackoffExponential"};function Cs(t,s){return s(Ro[t])}function Ao(t,s){return s(Io[t])}function Wo(t,s){return s(Po[t])}function Mo(t,s){return s(Co[t])}function Oo(t,s){return s(Bo[t])}function Ko(t,s){return s(Eo[t])}function Fo(t){return{exportedAt:t.exportedAt,rules:t.rules.map(s=>structuredClone(s)),triggerReceipts:t.triggerReceipts.map(s=>structuredClone(s))}}function $o(t){return`${JSON.stringify(t,null,2)}
2
2
  `}function Uo(){const{t}=N(),s=Do(),a=s.data?.rules??[],r=s.data?.triggerReceipts??[],n=m.useMemo(()=>{const c=new Map;for(const h of r){const u=c.get(h.ruleId);(!u||h.actualFireAt.localeCompare(u.actualFireAt)>0)&&c.set(h.ruleId,h)}return c},[r]),o=m.useCallback(()=>{const c=Fo({exportedAt:new Date().toISOString(),rules:a,triggerReceipts:r}),h=new Blob([$o(c)],{type:"application/json"}),u=URL.createObjectURL(h),d=document.createElement("a");d.href=u,d.download=`cats-work-schedules-audit-${c.exportedAt.slice(0,10)}.json`,d.click(),URL.revokeObjectURL(u)},[a,r]),i=m.useMemo(()=>a.slice().sort((c,h)=>h.updatedAt.localeCompare(c.updatedAt)),[a]),l=s.error?s.error instanceof Error?s.error.message:t("workSchedulesListLoadErrorFallback"):null;return e.jsxs("div",{className:"schedulesList",children:[e.jsxs("header",{className:"channelTopBar schedulesListTopBar",children:[e.jsxs("div",{className:"channelTopBarStart schedulesListTopBar__start",children:[e.jsx("h1",{className:"channelTopBarTitle schedulesListTopBar__title",children:t("workSchedulesListTitle")}),e.jsx("span",{className:"schedulesListTopBar__count",children:i.length})]}),e.jsx("div",{className:"channelTopBarCenter schedulesListTopBar__center",children:e.jsx("p",{className:"schedulesListTopBar__lede",children:t("workSchedulesListLede")})}),e.jsx("div",{className:"channelTopBarEnd schedulesListTopBar__end",children:e.jsx("button",{type:"button",className:"schedulesList__secondaryButton",onClick:o,disabled:a.length===0&&r.length===0,children:t("workSchedulesExportAction")})})]}),e.jsxs("main",{className:"schedulesList__main",children:[l?e.jsx("p",{className:"schedulesList__error",role:"alert",children:l}):null,s.isPending?e.jsx("p",{className:"schedulesList__empty",children:t("workSchedulesListLoading")}):i.length===0?e.jsx("p",{className:"schedulesList__empty",children:t("workSchedulesListEmpty")}):e.jsx("ul",{className:"schedulesList__list",children:i.map(c=>e.jsx(Go,{rule:c,latestReceipt:n.get(c.id)??null},c.id))})]})]})}function Go({rule:t,latestReceipt:s}){const{t:a}=N(),r=Ps(t,a),n=t.nextFireAt?a("workScheduleNextFireChip",{dateTime:ve(t.nextFireAt,t.timezone,a)}):null,o=s?a("workScheduleReceiptChip",{status:Cs(s.status,a),relativeTime:W(s.actualFireAt,a)}):null,i=t.enabled?"enabled":"disabled",l=t.enabled?a("workScheduleEnabledStatus"):a("workScheduleDisabledStatus");return e.jsx("li",{className:"schedulesList__row",children:e.jsxs(B,{to:Gr(t.id),className:"schedulesList__rowLink","aria-label":a("workScheduleOpenAriaLabel",{scheduleTitle:t.title}),children:[e.jsxs("div",{className:"schedulesList__rowMain",children:[e.jsx("span",{className:`schedulesList__dot schedulesList__dot--${i}`,"aria-hidden":"true"}),e.jsxs("div",{className:"schedulesList__rowText",children:[e.jsx("span",{className:"schedulesList__rowTitle",children:t.title}),e.jsx("span",{className:"schedulesList__rowSummary",children:r})]})]}),e.jsxs("div",{className:"schedulesList__rowMeta",children:[n?e.jsx("span",{className:"schedulesList__chip",children:n}):null,o?e.jsx("span",{className:`schedulesList__chip schedulesList__chip--${s.status}`,children:o}):null,e.jsx("span",{className:"schedulesList__metric--muted",children:W(t.updatedAt,a)}),e.jsx("span",{className:`schedulesList__statusPill schedulesList__statusPill--${i}`,children:l})]})]})})}function Qo(){const{t}=N(),{scheduleId:s}=xe(),a=z(),r=U(),n=So(s),o=n.data?.rule??null,i=n.data?.triggerReceipts??[],l=async()=>{s&&await Promise.all([r.invalidateQueries({queryKey:lt(s)}),r.invalidateQueries({queryKey:it})])},c=$({mutationFn:async x=>{if(!o)throw new Error(t("workScheduleRuleNotLoadedError"));await To(o.id,{enabled:x},t("workScheduleUpdateFailed"))},onSuccess:l}),h=$({mutationFn:async()=>{if(!o)throw new Error(t("workScheduleRuleNotLoadedError"));await Lo(o.id,t("workScheduleTestFireFailed"))},onSuccess:l}),u=$({mutationFn:async()=>{if(!o)throw new Error(t("workScheduleRuleNotLoadedError"));await vo(o.id,t("workScheduleDeleteFailed"))},onSuccess:async()=>{await r.invalidateQueries({queryKey:it}),s&&r.removeQueries({queryKey:lt(s)}),a(le)}}),d=()=>{o&&window.confirm(t("workScheduleDeleteConfirmation",{scheduleTitle:o.title}))&&u.mutate()},w=m.useMemo(()=>i.slice().sort((x,L)=>L.actualFireAt.localeCompare(x.actualFireAt)).slice(0,25),[i]),y=c.error??h.error??u.error,j=y?y instanceof Error?y.message:t("workScheduleActionFailed"):null;if(!s)return e.jsx(qt,{scheduleId:null});if(n.isPending)return e.jsxs("div",{className:"scheduleDetail",children:[e.jsx(Ht,{title:t("workScheduleLoadingTitle"),rule:null,togglePending:!1,testFirePending:!1,deletePending:!1,onToggle:()=>{},onTestFire:()=>{},onDelete:()=>{}}),e.jsx("main",{className:"scheduleDetail__main",children:e.jsx("p",{className:"scheduleDetail__empty",children:t("workScheduleLoadingLabel")})})]});if(n.isError||!o){const x=n.error?n.error instanceof Error?n.error.message:t("workScheduleLoadFailed"):null;return e.jsx(qt,{scheduleId:s,message:x})}const _=o.missionTemplate.target.kind==="cat"?t("workScheduleTargetKindCat"):t("workScheduleTargetKindAgent");return e.jsxs("div",{className:"scheduleDetail",children:[e.jsx(Ht,{title:o.title,rule:o,togglePending:c.isPending,testFirePending:h.isPending,deletePending:u.isPending,onToggle:()=>c.mutate(!o.enabled),onTestFire:()=>h.mutate(),onDelete:d}),e.jsxs("main",{className:"scheduleDetail__main",children:[j?e.jsx("p",{className:"scheduleDetail__error",role:"alert",children:j}):null,e.jsxs("section",{className:"scheduleDetail__section",children:[e.jsx("h2",{className:"scheduleDetail__sectionHeading",children:t("workScheduleOverviewTitle")}),e.jsxs("dl",{className:"scheduleDetail__summary",children:[e.jsx(q,{label:t("workScheduleScheduleLabel"),value:Ps(o,t)}),e.jsx(q,{label:t("workScheduleTimezoneLabel"),value:o.timezone}),e.jsx(q,{label:t("workScheduleRevisionLabel"),value:`r${o.revision}`,mono:!0}),e.jsx(q,{label:t("workScheduleTargetLabel"),value:`${_}:${o.missionTemplate.target.id}`,mono:!0}),e.jsx(q,{label:t("workScheduleOriginLabel"),value:t("workScheduleOriginSchedule")}),e.jsx(q,{label:t("workScheduleMissionPolicyLabel"),value:Wo(o.executionPolicy.missionPolicy,t)}),e.jsx(q,{label:t("workScheduleConcurrencyLabel"),value:Mo(o.executionPolicy.concurrencyPolicy,t)}),e.jsx(q,{label:t("workScheduleMisfireLabel"),value:Oo(o.executionPolicy.misfirePolicy,t)}),e.jsx(q,{label:t("workScheduleRetryLabel"),value:o.executionPolicy.retryPolicy.maxAttempts===0?t("workScheduleRetryNone"):t("workScheduleRetryPolicyValue",{maxAttempts:o.executionPolicy.retryPolicy.maxAttempts,backoff:Ko(o.executionPolicy.retryPolicy.backoff,t)})})]}),o.missionTemplate.intent?e.jsx("p",{className:"scheduleDetail__summaryBody",children:o.missionTemplate.intent}):null]}),e.jsxs("section",{className:"scheduleDetail__section",children:[e.jsx("h2",{className:"scheduleDetail__sectionHeading",children:t("workScheduleDiagnosticsTitle")}),e.jsxs("dl",{className:"scheduleDetail__summary",children:[e.jsx(q,{label:t("workScheduleNextFireLabel"),value:ve(o.nextFireAt,o.timezone,t)}),e.jsx(q,{label:t("workScheduleLastScheduledFireLabel"),value:ve(o.lastFireAt,o.timezone,t)}),e.jsx(q,{label:t("workScheduleLastRunLabel"),value:o.lastRunId??t("workScheduleDateNone"),mono:!!o.lastRunId}),e.jsx(q,{label:t("workScheduleConsecutiveFailuresLabel"),value:String(o.consecutiveFailures??0)})]}),e.jsxs("div",{className:"scheduleDetail__diagnostics",children:[o.enabled?null:e.jsx(Ze,{tone:o.pausedAt?"bad":"muted",text:o.pauseReason??t("workScheduleDisabledDiagnosticFallback")}),o.retryState?e.jsx(Ze,{tone:"warn",text:t("workScheduleRetryStatePill",{attempt:o.retryState.attempt,maxAttempts:o.retryState.maxAttempts,dateTime:ve(o.retryState.nextRetryAt,o.timezone,t)})}):null,o.lastFailure?e.jsx(Ze,{tone:"bad",text:t("workScheduleLastFailurePill",{failure:o.lastFailure})}):null]})]}),e.jsxs("section",{className:"scheduleDetail__section",children:[e.jsx("h2",{className:"scheduleDetail__sectionHeading",children:t("workScheduleRecentTriggersTitle",{count:w.length})}),w.length===0?e.jsx("p",{className:"scheduleDetail__empty",children:t("workScheduleNoTriggerReceipts")}):e.jsx("ol",{className:"scheduleDetail__triggerList",children:w.map(x=>e.jsxs("li",{className:"scheduleDetail__triggerRow",children:[e.jsx("span",{className:`scheduleDetail__triggerStatus scheduleDetail__triggerStatus--${x.status}`,children:Cs(x.status,t)}),e.jsxs("span",{className:"scheduleDetail__triggerReason",children:[Ao(x.reason,t),typeof x.metadata.retryAttempt=="number"?t("workScheduleRetryAttemptSuffix",{attempt:x.metadata.retryAttempt}):""]}),e.jsx("span",{className:"scheduleDetail__triggerWhen",children:W(x.actualFireAt,t)}),x.runId?e.jsx("code",{className:"scheduleDetail__triggerRun",children:x.runId}):null]},x.id))})]})]})]})}function Ht({title:t,rule:s,togglePending:a,testFirePending:r,deletePending:n,onToggle:o,onTestFire:i,onDelete:l}){const{t:c}=N(),h=a||r||n;return e.jsxs("header",{className:"channelTopBar scheduleDetailTopBar",children:[e.jsx("div",{className:"channelTopBarStart scheduleDetailTopBar__start",children:e.jsxs(B,{to:le,className:"scheduleDetailTopBar__back","aria-label":c("workScheduleBackArrowLabel"),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M7.5 2L3.5 6l4 4"})}),e.jsx("span",{children:c("workScheduleBackLabel")})]})}),e.jsxs("div",{className:"channelTopBarCenter scheduleDetailTopBar__center",children:[s?e.jsx("span",{className:"schedulesList__dot"+(s.enabled?" schedulesList__dot--enabled":" schedulesList__dot--disabled"),"aria-hidden":"true"}):null,e.jsx("h1",{className:"channelTopBarTitle scheduleDetailTopBar__title",children:t})]}),e.jsx("div",{className:"channelTopBarEnd scheduleDetailTopBar__end",children:s?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"schedulesList__secondaryButton",onClick:i,disabled:h,children:c(r?"workScheduleTestFireBusyLabel":"workScheduleTestFireLabel")}),e.jsx("button",{type:"button",className:"schedulesList__secondaryButton",onClick:o,disabled:h,children:a?c("workScheduleUpdatingLabel"):s.enabled?c("workScheduleDisableLabel"):c("workScheduleEnableLabel")}),e.jsx("button",{type:"button",className:"schedulesList__destructiveButton",onClick:l,disabled:h,"aria-label":c("workScheduleDeleteAriaLabel"),children:c(n?"workScheduleDeleteBusyLabel":"workScheduleDeleteLabel")}),e.jsx("span",{className:"schedulesList__statusPill"+(s.enabled?" schedulesList__statusPill--enabled":" schedulesList__statusPill--disabled"),children:s.enabled?c("workScheduleEnabledStatus"):c("workScheduleDisabledStatus")})]}):null})]})}function q({label:t,value:s,mono:a}){return e.jsxs("div",{className:"scheduleDetail__summaryRow",children:[e.jsx("dt",{children:t}),e.jsx("dd",{className:a?"scheduleDetail__monoValue":void 0,children:s})]})}function Ze({tone:t,text:s}){return e.jsx("span",{className:`schedulesList__diagnostic schedulesList__diagnostic--${t}`,children:s})}function qt({scheduleId:t,message:s}){const{t:a}=N(),r=t??a("workScheduleMissingIdLabel");return e.jsxs("div",{className:"scheduleDetail",children:[e.jsxs("header",{className:"channelTopBar scheduleDetailTopBar",children:[e.jsx("div",{className:"channelTopBarStart scheduleDetailTopBar__start",children:e.jsx(B,{to:le,className:"scheduleDetailTopBar__back",children:e.jsx("span",{children:a("workScheduleBackArrowLabel")})})}),e.jsx("div",{className:"channelTopBarCenter scheduleDetailTopBar__center",children:e.jsx("h1",{className:"channelTopBarTitle scheduleDetailTopBar__title",children:a("workScheduleNotFoundTitle")})})]}),e.jsx("main",{className:"scheduleDetail__main",children:e.jsx("p",{className:"scheduleDetail__empty",children:s??e.jsxs(e.Fragment,{children:[a("workScheduleNotFoundPrefix")," ",e.jsx("code",{children:r})," ",a("workScheduleNotFoundSuffix")]})})})]})}function Ho({workItemId:t,onClose:s}){const{t:a}=N();return e.jsx(Ns,{localKind:"work_item",localId:t,defaultExternalType:"issue",errorFallback:a("workExternalLinkError"),invalidateQueryKeys:[je,Y],onClose:s,title:a("workExternalLinkDialogTitle")})}function qo({addLabel:t,bindings:s,emptyLabel:a,onAddClick:r,onRemoveBinding:n,removeDisabled:o}){const{t:i}=N();return s.length===0&&!r?null:e.jsxs("section",{className:"workItemDetail__section workItemDetail__external",children:[e.jsxs("header",{className:"workItemDetail__sectionHeader",children:[e.jsx("h2",{children:i("workTopdownExternalTitle")}),e.jsx("span",{className:"workItemDetail__sectionCount",children:s.length}),r?e.jsx("button",{type:"button",className:"workItemDetail__sectionAction",onClick:r,children:t??i("workExternalLinkIssueAction")}):null]}),s.length===0?e.jsx("p",{className:"workItemDetail__empty",children:a??i("workExternalEmpty")}):e.jsx("ul",{className:"workItemDetail__externalRefs",children:s.map(l=>{const c=ee(l),h=bt(l.externalUrl)?l.externalUrl:null;return e.jsxs("li",{className:"workItemDetail__externalRef",children:[e.jsx("span",{className:"workItemDetail__externalProvider",children:l.provider}),e.jsxs("span",{className:"workItemDetail__externalMain",children:[h?e.jsx("a",{className:"workItemDetail__externalLink",href:h,target:"_blank",rel:"noreferrer",children:c}):e.jsx("span",{className:"workItemDetail__externalLabel",children:c}),e.jsxs("span",{className:"workItemDetail__externalMeta",children:[i("workTopdownExternalSyncLabel",{syncDirection:l.syncDirection}),l.externalUpdatedAt?` - ${i("workTopdownExternalUpdatedLabel",{updatedAt:W(l.externalUpdatedAt,i)})}`:""]}),n?e.jsx("button",{type:"button",className:"workItemDetail__externalRemove",onClick:()=>n(l),disabled:o,"aria-label":i("workExternalUnlinkAriaLabel",{label:c}),children:i("workExternalUnlinkAction")}):null]})]},`${l.provider}:${l.externalType}:${l.externalId}`)})})]})}function Vo(){const{workItemId:t}=xe(),s=z(),a=U(),[r,n]=m.useState(!1),o=Je(),i=Ne(),l=Lt(),{t:c}=N(),h=ke(c("workGraphLoadErrorFallback")).data??pe,u=m.useMemo(()=>be(h),[h]),d=o.data?.workItems??[],w=t?d.find(v=>v.id===t):void 0,y=$({mutationFn:async v=>{await Ja(v,c("workItemDeleteError"))},onSuccess:async()=>{await a.invalidateQueries({queryKey:je}),s(he)}}),j=$({mutationFn:async v=>{await ls({localKind:"work_item",localId:v.workItemId,provider:v.binding.provider,externalType:v.binding.externalType,externalId:v.binding.externalId},c("workExternalUnlinkError"))},onSuccess:async()=>{await Promise.all([a.invalidateQueries({queryKey:je}),a.invalidateQueries({queryKey:Y})])}}),_=()=>{w&&window.confirm(c("workItemDeleteConfirmation",{title:w.title}))&&y.mutate(w.id)},x=v=>{if(!w)return;const O=ee(v);window.confirm(c("workExternalUnlinkConfirmation",{label:O}))&&j.mutate({binding:v,workItemId:w.id})};if(o.isPending)return e.jsx(Xo,{});if(!w)return e.jsx(Zo,{workItemId:t??null});const L=y.error?V(y.error,c("workItemDeleteError"),c):null,g=j.error?V(j.error,c("workExternalUnlinkError"),c):null,k=w.projectId?i.data?.projects.find(v=>v.id===w.projectId):void 0,R=w.parentWorkItemId?d.find(v=>v.id===w.parentWorkItemId):void 0,D=d.filter(v=>v.parentWorkItemId===w.id),C=h.objects.find(v=>v.kind==="work_item"&&v.sourceRecordId===w.id)?.externalBindings??[],I=h.objects.filter(v=>v.kind==="task"&&v.linkedWorkItemId===w.id),b=h.objects.filter(v=>v.kind==="activity"&&v.linkedWorkItemId===w.id).sort((v,O)=>O.updatedAt.localeCompare(v.updatedAt)),T=(l.data?.missions??[]).filter(v=>v.managedWorkId===w.id);return e.jsxs("div",{className:"workItemDetail",children:[e.jsxs("header",{className:"channelTopBar workItemDetailTopBar",children:[e.jsx("div",{className:"channelTopBarStart workItemDetailTopBar__start",children:e.jsxs(B,{to:"..",relative:"path",className:"workItemDetailTopBar__back","aria-label":c("workItemBackLabel"),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M7.5 2L3.5 6l4 4"})}),e.jsx("span",{children:c("workItemBackArrowLabel")})]})}),e.jsxs("div",{className:"channelTopBarCenter workItemDetailTopBar__center",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--${w.status}`,"aria-hidden":"true"}),e.jsx("h1",{className:"channelTopBarTitle workItemDetailTopBar__title",children:w.title})]}),e.jsxs("div",{className:"channelTopBarEnd workItemDetailTopBar__end",children:[w.attention!=="none"?e.jsx("span",{className:`workItemDetail__attention workItemDetail__attention--${w.attention}`,children:re(w.attention,c)}):null,e.jsx("span",{className:`workItemsList__statusPill workItemsList__statusPill--${w.status}`,children:M(w.status,c)}),e.jsx("span",{className:"workItemDetailTopBar__updated",children:c("workItemUpdatedAtPrefix",{updatedAt:W(w.updatedAt,c)})}),e.jsx("button",{type:"button",className:"workItemDetailTopBar__action workItemDetailTopBar__action--destructive",onClick:_,disabled:y.isPending,"aria-label":c("workItemDeleteLabel"),children:y.isPending?c("workItemDeleteLabelBusy"):c("workItemDeleteLabel")})]})]}),e.jsxs("main",{className:"workItemDetail__main",children:[L?e.jsx("p",{className:"workItemDetail__error",role:"alert",children:L}):null,g?e.jsx("p",{className:"workItemDetail__error",role:"alert",children:g}):null,e.jsxs("section",{className:"workItemDetail__section workItemDetail__overview",children:[e.jsx("header",{className:"workItemDetail__sectionHeader",children:e.jsx("h2",{children:c("workItemOverviewTitle")})}),e.jsxs("dl",{className:"workItemDetail__overviewList",children:[w.summary?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:c("workItemSummaryLabel")}),e.jsx("dd",{children:w.summary})]}):null,e.jsx("dt",{children:c("workItemProjectLabel")}),e.jsx("dd",{children:k?e.jsx(B,{className:"workItemDetail__projectLink",to:`${ne}/${k.id}`,children:k.title}):e.jsx("em",{children:c("workItemOrphanSummaryFallback")})}),R?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:c("workItemParentLabel")}),e.jsx("dd",{children:e.jsx(B,{className:"workItemDetail__projectLink",to:Ve(R.id),children:R.title})})]}):null,e.jsx("dt",{children:c("workItemOwnerLabel")}),e.jsx("dd",{children:w.ownerName}),w.conversationId?e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:c("workItemConversationLabel")}),e.jsx("dd",{children:e.jsx("span",{className:"workItemDetail__convoTitle",children:w.conversationTitle??w.conversationId})})]}):null]})]}),e.jsx(zo,{items:D}),e.jsx(qo,{bindings:C,onAddClick:()=>n(!0),onRemoveBinding:x,removeDisabled:j.isPending}),e.jsx(Yo,{title:c("workItemTasksTitle"),items:I,emptyLabel:c("workItemNoTasksLabel")}),e.jsx(Jo,{missions:T}),e.jsx(ft,{selfRef:{recordFamily:"work_item",recordId:w.id},graph:h,indexes:u}),e.jsxs("section",{className:"workItemDetail__section",children:[e.jsxs("header",{className:"workItemDetail__sectionHeader",children:[e.jsx("h2",{children:c("workItemActivityTitle")}),e.jsx("span",{className:"workItemDetail__sectionCount",children:b.length})]}),b.length===0?e.jsx("p",{className:"workItemDetail__empty",children:c("workItemNoActivity")}):e.jsx("ul",{className:"workItemDetail__activity",children:b.map(v=>e.jsxs("li",{className:"workItemDetail__activityRow",children:[e.jsx("span",{className:"workItemDetail__activityWhen",children:W(v.updatedAt,c)}),e.jsx("span",{className:"workItemDetail__activityTitle",children:v.title}),v.summary?e.jsx("span",{className:"workItemDetail__activitySummary",children:v.summary}):null]},v.id))})]})]}),r?e.jsx(Ho,{workItemId:w.id,onClose:()=>n(!1)}):null]})}function Yo({title:t,items:s,emptyLabel:a}){const{t:r}=N();return e.jsxs("section",{className:"workItemDetail__section",children:[e.jsxs("header",{className:"workItemDetail__sectionHeader",children:[e.jsx("h2",{children:t}),e.jsx("span",{className:"workItemDetail__sectionCount",children:s.length})]}),s.length===0?e.jsx("p",{className:"workItemDetail__empty",children:a}):e.jsx("ul",{className:"workItemDetail__items",children:s.map(n=>e.jsxs("li",{className:"workItemDetail__item",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--small projectsList__dot--${n.status}`,"aria-hidden":"true"}),e.jsx("span",{className:"workItemDetail__itemKind",children:ae(n.kind,r)}),e.jsx("span",{className:"workItemDetail__itemTitle",children:n.title}),n.attention!=="none"?e.jsx("span",{className:`workItemDetail__itemAttention workItemDetail__itemAttention--${n.attention}`,children:re(n.attention,r)}):null,e.jsx("span",{className:"workItemDetail__itemStatus",children:M(n.status,r)}),n.ownerRole?e.jsx("span",{className:"workItemDetail__itemOwner",children:ge(n.ownerRole,r)}):null]},n.id))})]})}function zo({items:t}){const{t:s}=N();return e.jsxs("section",{className:"workItemDetail__section",children:[e.jsxs("header",{className:"workItemDetail__sectionHeader",children:[e.jsx("h2",{children:s("workItemSubWorkItemsTitle")}),e.jsx("span",{className:"workItemDetail__sectionCount",children:t.length})]}),t.length===0?e.jsx("p",{className:"workItemDetail__empty",children:s("workItemNoSubWorkItems")}):e.jsx("ul",{className:"workItemDetail__items",children:t.map(a=>e.jsxs("li",{className:"workItemDetail__item",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--small projectsList__dot--${a.status}`,"aria-hidden":"true"}),e.jsx(B,{to:Ve(a.id),className:"workItemDetail__itemTitle",children:a.title}),e.jsx("span",{className:"workItemDetail__itemStatus",children:M(a.status,s)}),e.jsx("span",{className:"workItemDetail__itemOwner",children:W(a.updatedAt,s)})]},a.id))})]})}function Jo({missions:t}){const{t:s}=N();return e.jsxs("section",{className:"workItemDetail__section",children:[e.jsxs("header",{className:"workItemDetail__sectionHeader",children:[e.jsx("h2",{children:s("workItemMissionsTitle")}),e.jsx("span",{className:"workItemDetail__sectionCount",children:t.length})]}),t.length===0?e.jsx("p",{className:"workItemDetail__empty",children:s("workItemNoMissions")}):e.jsx("ul",{className:"workItemDetail__items",children:t.map(a=>e.jsxs("li",{className:"workItemDetail__item",children:[e.jsx(B,{to:bs(a.id),className:"workItemDetail__itemTitle",children:a.title}),e.jsx("span",{className:"workItemDetail__itemStatus",children:M(a.status,s)}),e.jsx("span",{className:"workItemDetail__itemOwner",children:W(a.updatedAt,s)})]},a.id))})]})}function Xo(){const{t}=N();return e.jsxs("div",{className:"workItemDetail",children:[e.jsx("header",{className:"channelTopBar workItemDetailTopBar",children:e.jsx("div",{className:"channelTopBarStart workItemDetailTopBar__start",children:e.jsx(B,{to:"..",relative:"path",className:"workItemDetailTopBar__back",children:e.jsx("span",{children:t("workItemBackArrowLabel")})})})}),e.jsx("main",{className:"workItemDetail__main",children:e.jsx("p",{className:"workItemDetail__empty",children:t("workItemLoadingLabel")})})]})}function Zo({workItemId:t}){const{t:s}=N();return e.jsxs("div",{className:"workItemDetail",children:[e.jsx("header",{className:"channelTopBar workItemDetailTopBar",children:e.jsxs("div",{className:"channelTopBarStart workItemDetailTopBar__start",children:[e.jsx(B,{to:"..",relative:"path",className:"workItemDetailTopBar__back",children:e.jsx("span",{children:s("workItemBackArrowLabel")})}),e.jsx("span",{className:"workItemDetailTopBar__separator","aria-hidden":"true",children:"/"}),e.jsx("h1",{className:"channelTopBarTitle workItemDetailTopBar__title",children:s("workItemNotFoundTitle")})]})}),e.jsx("main",{className:"workItemDetail__main",children:e.jsx("p",{className:"workItemDetail__empty",children:s("workItemNotFoundText",{workItemId:t??s("workItemNotFoundCodeLabel")})})})]})}const ei=["github","redmine","bugzilla"];function ti(t){return t==="github"||t==="redmine"||t==="bugzilla"}function si(t){switch(t){case"github":return"GitHub";case"redmine":return"Redmine";case"bugzilla":return"Bugzilla"}}function ai({onClose:t}){const s=U(),{t:a}=N(),r=m.useId(),n=m.useId(),o=m.useId(),i=m.useRef(null),[l,c]=m.useState("github"),[h,u]=m.useState(""),d=$({mutationFn:g=>Za(g,a("workExternalImportError")),onSuccess:async()=>{await Promise.all([s.invalidateQueries({queryKey:je}),s.invalidateQueries({queryKey:Y}),s.invalidateQueries({queryKey:De})]),t()}}),w=d.isPending,y=h.trim(),j=d.error?V(d.error,a("workExternalImportError"),a):null;m.useEffect(()=>{i.current?.focus()},[]),m.useEffect(()=>{function g(k){k.key==="Escape"&&(k.stopPropagation(),t())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[t]);function _(g){g.target===g.currentTarget&&t()}function x(g){u(g);const k=ys(g,l);ti(k?.provider)&&c(k.provider)}function L(g){g.preventDefault(),!(!y||w)&&d.mutate({provider:l,externalUrl:y})}return e.jsx("div",{className:"newProjectDialog__backdrop",role:"presentation",onClick:_,children:e.jsxs("div",{className:"newProjectDialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":`${r}-heading`,children:[e.jsxs("header",{className:"newProjectDialog__header",children:[e.jsx("h2",{id:`${r}-heading`,className:"newProjectDialog__heading",children:a("workExternalImportDialogTitle")}),e.jsx("button",{type:"button",className:"newProjectDialog__close","aria-label":a("workExternalLinkCloseLabel"),onClick:t,children:"×"})]}),e.jsxs("form",{className:"newProjectDialog__form",onSubmit:L,children:[e.jsxs("label",{className:"newProjectDialog__field",htmlFor:n,children:[e.jsx("span",{className:"newProjectDialog__label",children:a("workExternalImportProviderLabel")}),e.jsx("select",{id:n,className:"newProjectDialog__select",value:l,onChange:g=>c(g.target.value),children:ei.map(g=>e.jsx("option",{value:g,children:si(g)},g))})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:o,children:[e.jsxs("span",{className:"newProjectDialog__label",children:[a("workExternalImportUrlLabel"),e.jsx("span",{className:"newProjectDialog__required","aria-hidden":"true",children:"*"})]}),e.jsx("input",{ref:i,id:o,type:"url",className:"newProjectDialog__input",value:h,onChange:g=>x(g.target.value),placeholder:a("workExternalImportUrlPlaceholder"),required:!0,maxLength:1e3})]}),j?e.jsx("p",{className:"newProjectDialog__error",role:"alert",children:j}):null,e.jsxs("footer",{className:"newProjectDialog__footer",children:[e.jsx("button",{type:"button",className:"newProjectDialog__cancelBtn",onClick:t,disabled:w,children:a("workExternalImportCancelButton")}),e.jsx("button",{type:"submit",className:"newProjectDialog__submitBtn",disabled:y.length===0||w,children:a(w?"workExternalImportSubmitBusyLabel":"workExternalImportSubmitLabel")})]})]})]})})}async function ri(t,s){return{id:(await za({title:t.title,summary:t.summary,status:t.status,projectId:t.projectId},s)).workItem.id}}function ni({onClose:t,defaultProjectId:s}){const a=z(),r=U(),{t:n}=N(),o=m.useId(),i=m.useId(),l=m.useId(),c=m.useId(),h=m.useRef(null),u=Ne(),[d,w]=m.useState(""),[y,j]=m.useState(""),[_,x]=m.useState(s??""),[L,g]=m.useState("draft"),k=$({mutationFn:T=>ri(T,n("workNewWorkItemCreateError")),onSuccess:async T=>{await r.invalidateQueries({queryKey:je}),t(),a(`${he}/${T.id}`)}}),R=k.isPending,D=k.error?V(k.error,n("workNewWorkItemCreateError"),n):null;m.useEffect(()=>{h.current?.focus()},[]),m.useEffect(()=>{function T(v){v.key==="Escape"&&(v.stopPropagation(),t())}return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t]);function S(T){T.target===T.currentTarget&&t()}function C(T){T.preventDefault();const v=d.trim();!v||R||k.mutate({title:v,summary:y.trim()||null,status:L,projectId:_||null})}const I=u.data?.projects??[],b=[{value:"draft",label:n("workNewWorkItemStatusDraft")},{value:"planned",label:n("workNewWorkItemStatusPlanned")},{value:"ready",label:n("workNewWorkItemStatusReady")},{value:"in_progress",label:n("workNewWorkItemStatusInProgress")},{value:"blocked",label:n("workNewWorkItemStatusBlocked")},{value:"completed",label:n("workNewWorkItemStatusCompleted")},{value:"cancelled",label:n("workNewWorkItemStatusCancelled")}];return e.jsx("div",{className:"newProjectDialog__backdrop",role:"presentation",onClick:S,children:e.jsxs("div",{className:"newProjectDialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":`${o}-heading`,children:[e.jsxs("header",{className:"newProjectDialog__header",children:[e.jsx("h2",{id:`${o}-heading`,className:"newProjectDialog__heading",children:n("workNewWorkItemTitle")}),e.jsx("button",{type:"button",className:"newProjectDialog__close","aria-label":n("workNewWorkItemCloseLabel"),onClick:t,children:"×"})]}),e.jsxs("form",{className:"newProjectDialog__form",onSubmit:C,children:[e.jsxs("label",{className:"newProjectDialog__field",htmlFor:o,children:[e.jsxs("span",{className:"newProjectDialog__label",children:[n("workNewWorkItemTitleLabel"),e.jsx("span",{className:"newProjectDialog__required","aria-hidden":"true",children:"*"})]}),e.jsx("input",{ref:h,id:o,type:"text",className:"newProjectDialog__input",value:d,onChange:T=>w(T.target.value),placeholder:n("workNewWorkItemTitlePlaceholder"),required:!0,maxLength:120})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:i,children:[e.jsx("span",{className:"newProjectDialog__label",children:n("workNewWorkItemSummaryLabel")}),e.jsx("textarea",{id:i,className:"newProjectDialog__textarea",value:y,onChange:T=>j(T.target.value),placeholder:n("workNewWorkItemSummaryPlaceholder"),rows:3,maxLength:400})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:l,children:[e.jsx("span",{className:"newProjectDialog__label",children:n("workNewWorkItemProjectLabel")}),e.jsxs("select",{id:l,className:"newProjectDialog__select",value:_,onChange:T=>x(T.target.value),children:[e.jsx("option",{value:"",children:n("workNewWorkItemProjectOrphan")}),I.map(T=>e.jsx("option",{value:T.id,children:T.title},T.id))]})]}),e.jsxs("label",{className:"newProjectDialog__field",htmlFor:c,children:[e.jsx("span",{className:"newProjectDialog__label",children:n("workNewWorkItemStatusLabel")}),e.jsx("select",{id:c,className:"newProjectDialog__select",value:L,onChange:T=>g(T.target.value),children:b.map(T=>e.jsx("option",{value:T.value,children:T.label},T.value))})]}),D?e.jsx("p",{className:"newProjectDialog__error",role:"alert",children:D}):null,e.jsxs("footer",{className:"newProjectDialog__footer",children:[e.jsx("button",{type:"button",className:"newProjectDialog__cancelBtn",onClick:t,disabled:R,children:n("workNewWorkItemCancelButton")}),e.jsx("button",{type:"submit",className:"newProjectDialog__submitBtn",disabled:d.trim().length===0||R,children:n(R?"workNewWorkItemSubmitBusyLabel":"workNewWorkItemSubmitLabel")})]})]})]})})}function oi(){const t=Je(),s=t.data?.workItems??[],[a,r]=m.useState(!1),[n,o]=m.useState(!1),{t:i}=N();return e.jsxs("div",{className:"workItemsList",children:[e.jsxs("header",{className:"channelTopBar workItemsListTopBar",children:[e.jsxs("div",{className:"channelTopBarStart workItemsListTopBar__start",children:[e.jsx("h1",{className:"channelTopBarTitle workItemsListTopBar__title",children:i("workItemsListTitle")}),e.jsx("span",{className:"workItemsListTopBar__count",children:s.length})]}),e.jsx("div",{className:"channelTopBarCenter workItemsListTopBar__center"}),e.jsxs("div",{className:"channelTopBarEnd workItemsListTopBar__end",children:[e.jsxs("button",{type:"button",className:"workItemsListTopBar__addBtn workItemsListTopBar__addBtn--secondary",onClick:()=>o(!0),"aria-label":i("workItemsListImportExternalIssueAriaLabel"),children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M3 3h8v8H3z"}),e.jsx("path",{d:"M5 5h4"}),e.jsx("path",{d:"M5 7h4"}),e.jsx("path",{d:"M5 9h2"})]}),e.jsx("span",{children:i("workItemsListImportExternalIssueAction")})]}),e.jsxs("button",{type:"button",className:"workItemsListTopBar__addBtn",onClick:()=>r(!0),"aria-label":i("workItemsListCreateNewWorkItemAriaLabel"),children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M7 2v10"}),e.jsx("path",{d:"M2 7h10"})]}),e.jsx("span",{children:i("workItemsListNewAction")})]})]})]}),e.jsx("main",{className:"workItemsList__main",children:t.isPending?e.jsx("p",{className:"workItemsList__empty",children:i("workItemsListLoading")}):t.isError?e.jsx("p",{className:"workItemsList__empty",children:i("workItemsListLoadError",{errorMessage:String(t.error.message)})}):s.length===0?e.jsxs("p",{className:"workItemsList__empty",children:[i("workItemsListEmptyIntro")," ",e.jsx("strong",{children:i("workItemsListEmptyActionLabel")})," ",i("workItemsListEmptySuffix")]}):e.jsx("ul",{className:"workItemsList__list",children:s.map(l=>e.jsx("li",{className:"workItemsList__row",children:e.jsxs(B,{to:l.id,className:"workItemsList__rowLink","aria-label":i("workItemsListOpenWorkItemAria",{title:l.title}),children:[e.jsxs("div",{className:"workItemsList__rowMain",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--${l.status}`,"aria-hidden":"true"}),e.jsxs("div",{className:"workItemsList__rowText",children:[e.jsx("span",{className:"workItemsList__rowTitle",children:l.title}),l.summary?e.jsx("span",{className:"workItemsList__rowSummary",children:l.summary}):null]})]}),e.jsxs("div",{className:"workItemsList__rowMeta",children:[l.projectTitle?e.jsx("span",{className:"workItemsList__projectChip",children:i("workItemsListProjectPrefix",{projectTitle:l.projectTitle})}):e.jsx("span",{className:"workItemsList__projectChip workItemsList__projectChip--orphan",children:i("workItemsListProjectOrphan")}),l.parentWorkItemTitle?e.jsxs("span",{className:"workItemsList__projectChip workItemsList__projectChip--parent",title:i("workItemsListParentWorkItemTooltip",{parentTitle:l.parentWorkItemTitle}),children:["↳ ",l.parentWorkItemTitle]}):null,(l.externalBindings??[]).slice(0,2).map(c=>e.jsx("span",{className:"workItemsList__projectChip workItemsList__projectChip--external",title:i("workTopdownExternalBindingTooltip",{externalBinding:ee(c)}),children:ee(c)},`${c.provider}:${c.externalType}:${c.externalId}`)),(l.externalBindings?.length??0)>2?e.jsxs("span",{className:"workItemsList__projectChip workItemsList__projectChip--external",children:["+",(l.externalBindings?.length??0)-2]}):null,l.attention==="decision_needed"?e.jsx("span",{className:"workItemsList__pip workItemsList__pip--decision",children:i("workItemsListDecisionPill")}):null,l.attention==="blocked"||l.attention==="failed"?e.jsx("span",{className:"workItemsList__pip workItemsList__pip--blocked",children:i("workItemsListBlockedPill")}):null,e.jsxs("span",{className:"workItemsList__metric",children:[e.jsx("strong",{children:l.linkedTaskCount})," ",i("workItemsListTasksLabel")]}),e.jsx("span",{className:"workItemsList__metric workItemsList__metric--muted",children:W(l.updatedAt,i)}),e.jsx("span",{className:`workItemsList__statusPill workItemsList__statusPill--${l.status}`,children:M(l.status,i)})]})]})},l.id))})}),a?e.jsx(ni,{onClose:()=>r(!1)}):null,n?e.jsx(ai,{onClose:()=>o(!1)}):null]})}function Dt({graph:t,indexes:s,selectedId:a,onClose:r,onSelect:n}){const{t:o}=N(),[i,l]=m.useState("identity");if(!a)return null;const c=s.objectsById.get(a);if(!c)return e.jsx(Ct,{title:o("workTopdownSelectionLost"),activeSection:"missing",onSectionToggle:()=>{},onClose:r,className:"chatPaneSidePanel chatPaneSidePanelBelowBar topDownDrawer",sections:[{id:"missing",title:o("workTopdownObjectNotInProjectionTitle"),children:e.jsx("p",{className:"topDownDrawer__missing",children:o("workTopdownObjectNotInProjectionMessage",{selectedId:a})})}]});const h=s.evidenceByAnchor.get(c.id)??[],u=s.gatesBySubject.get(c.id)??[],d=t.diagnostics.filter(j=>j.objectId===c.id),w=c.externalBindings??[],y=[{id:"identity",title:o("workTopdownIdentityTitle"),children:e.jsxs("dl",{className:"topDownDrawer__list",children:[e.jsx(ce,{label:o("workTopdownIdentityKind"),value:ae(c.kind,o)}),e.jsx(ce,{label:o("workTopdownIdentityStatus"),value:M(c.status,o)}),e.jsx(ce,{label:o("workTopdownIdentityLayer"),value:c.structuralLayer?rt(c.structuralLayer,o):o("workTopdownCrossCuttingLayer")}),c.ownerRole?e.jsx(ce,{label:o("workTopdownIdentityOwnerRole"),value:ge(c.ownerRole,o)}):null,c.nextAction?e.jsx(ce,{label:o("workTopdownIdentityNextAction"),value:c.nextAction}):null,e.jsx(ce,{label:o("workTopdownIdentityUpdated"),value:W(c.updatedAt,o)}),c.summary?e.jsx(ce,{label:o("workTopdownIdentitySummary"),value:c.summary}):null]})},{id:"anchors",title:o("workTopdownAnchorsTitle"),children:e.jsx(li,{object:c,indexes:s,onSelect:n})},...w.length>0?[{id:"external",title:o("workTopdownExternalTitle"),badge:w.length,children:e.jsx(ii,{bindings:w})}]:[],{id:"evidence",title:o("workTopdownEvidenceTitle"),badge:h.length||void 0,children:h.length===0?e.jsx("p",{className:"topDownDrawer__empty",children:o("workTopdownEvidenceEmpty")}):e.jsx("ul",{className:"topDownDrawer__refs",children:h.map(j=>{const _=s.objectsById.get(j.evidenceObjectId);return e.jsxs("li",{children:[e.jsx("span",{className:"topDownDrawer__refKind",children:fr(j.relation,o)}),_?e.jsx("button",{type:"button",className:"topDownDrawer__refLink",onClick:()=>n(_.id),children:_.title}):e.jsxs("span",{children:[j.evidenceObjectId," ",o("workTopdownMissingSuffix")]})]},j.evidenceObjectId)})})},{id:"gates",title:o("workTopdownGatesTitle"),badge:u.length||void 0,children:u.length===0?e.jsx("p",{className:"topDownDrawer__empty",children:o("workTopdownGatesEmpty")}):e.jsx("ul",{className:"topDownDrawer__refs",children:u.map(j=>{const _=s.objectsById.get(j.gateObjectId);return e.jsxs("li",{children:[e.jsx("span",{className:`topDownDrawer__gateState topDownDrawer__gateState--${j.state}`,children:ps(j.state,o)}),_?e.jsx("button",{type:"button",className:"topDownDrawer__refLink",onClick:()=>n(_.id),children:_.title}):e.jsxs("span",{children:[j.gateObjectId," ",o("workTopdownMissingSuffix")]})]},j.gateObjectId)})})}];return d.length>0&&y.push({id:"diagnostics",title:o("workTopdownDiagnosticsTitle"),badge:d.length,children:e.jsx("ul",{className:"topDownDrawer__diagnostics",children:d.map(j=>e.jsxs("li",{className:`topDownDrawer__diagnostic topDownDrawer__diagnostic--${j.severity}`,children:[e.jsx("span",{className:"topDownDrawer__diagnosticKind",children:ms(j.kind,o)}),e.jsx("p",{children:j.message})]},j.id))})}),e.jsx(Ct,{title:c.title,activeSection:i,onSectionToggle:j=>l(j),onClose:r,className:"chatPaneSidePanel chatPaneSidePanelBelowBar topDownDrawer",sections:y})}function ii({bindings:t}){const{t:s}=N();return e.jsx("ul",{className:"topDownDrawer__refs topDownDrawer__externalRefs",children:t.map(a=>{const r=ee(a),n=bt(a.externalUrl)?a.externalUrl:null;return e.jsxs("li",{children:[e.jsx("span",{className:"topDownDrawer__refKind",children:a.provider}),e.jsxs("span",{className:"topDownDrawer__externalValue",children:[n?e.jsx("a",{className:"topDownDrawer__externalLink",href:n,target:"_blank",rel:"noreferrer",children:r}):e.jsx("span",{children:r}),e.jsxs("span",{className:"topDownDrawer__externalMeta",children:[s("workTopdownExternalSyncLabel",{syncDirection:a.syncDirection}),a.externalUpdatedAt?` - ${s("workTopdownExternalUpdatedLabel",{updatedAt:W(a.externalUpdatedAt,s)})}`:""]})]})]},`${a.provider}:${a.externalType}:${a.externalId}`)})})}function ce({label:t,value:s}){return e.jsxs("div",{className:"topDownDrawer__field",children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function li({object:t,indexes:s,onSelect:a}){const{t:r}=N(),o=[{label:r("workTopdownAnchorProject"),id:t.linkedProjectId},{label:r("workTopdownAnchorWorkItem"),id:t.linkedWorkItemId},{label:r("workTopdownAnchorTask"),id:t.linkedTaskId},{label:r("workTopdownAnchorRun"),id:t.linkedRunId},{label:r("workTopdownAnchorConversation"),id:t.linkedConversationId}].filter(i=>i.id!==null);return o.length===0?e.jsx("p",{className:"topDownDrawer__empty",children:r("workTopdownAnchorsEmpty")}):e.jsx("ul",{className:"topDownDrawer__refs",children:o.map(i=>{const l=i.id?s.objectsById.get(i.id):void 0;return e.jsxs("li",{children:[e.jsx("span",{className:"topDownDrawer__refKind",children:i.label}),l?e.jsx("button",{type:"button",className:"topDownDrawer__refLink",onClick:()=>a(l.id),children:l.title}):e.jsxs("span",{className:"topDownDrawer__refBroken",children:[i.id," ",r("workTopdownMissingSuffix")]})]},i.label)})})}const Vt=["error","warning","info"];function ci(){const{t}=N(),[s,a]=wt(),r=s.get("severity")??"all",n=s.get("selectedId"),o=U(),i=ke(t("workGraphLoadErrorFallback")).data??pe,l=m.useMemo(()=>be(i),[i]),c=m.useMemo(()=>new Set(i.links.map(g=>g.id)),[i.links]),[h,u]=m.useState(null),[d,w]=m.useState(null),y=m.useCallback(async g=>{w(g),u(null);try{await tn(g,t("workTopdownBrokenLinksRemoveUnknownError")),await o.invalidateQueries({queryKey:Y})}catch(k){u(k instanceof Error?k.message:t("workTopdownBrokenLinksRemoveUnknownError"))}finally{w(null)}},[o,t]),j=m.useMemo(()=>{const g={error:0,warning:0,info:0};for(const k of i.diagnostics)g[k.severity]+=1;return g},[i]),_=m.useMemo(()=>i.diagnostics.filter(g=>r==="all"?!0:g.severity===r).sort((g,k)=>{const R=Vt.indexOf(g.severity)-Vt.indexOf(k.severity);return R!==0?R:g.kind.localeCompare(k.kind)}),[i,r]);function x(g){const k=new URLSearchParams(s);g==="all"?k.delete("severity"):k.set("severity",g),a(k,{replace:!0})}function L(g){const k=new URLSearchParams(s);g===null?k.delete("selectedId"):k.set("selectedId",g),a(k,{replace:!0})}return e.jsxs("div",{className:"topDownPage",children:[e.jsxs("header",{className:"channelTopBar topDownTopBar",children:[e.jsxs("div",{className:"channelTopBarStart topDownTopBar__start",children:[e.jsx("span",{className:"topDownTopBar__eyebrow",children:t("workTopdownBrokenLinksEyebrow")}),e.jsx("h1",{className:"channelTopBarTitle topDownTopBar__title",children:t("workTopdownBrokenLinksTitle")})]}),e.jsx("div",{className:"channelTopBarCenter topDownTopBar__center",children:e.jsx("p",{className:"topDownTopBar__lede",children:t("workTopdownBrokenLinksLede")})}),e.jsxs("div",{className:"channelTopBarEnd topDownTopBar__end",children:[e.jsxs("span",{className:"topDownTopBar__metric"+(j.error>0?" topDownTopBar__metric--bad":""),children:[e.jsx("strong",{children:j.error})," ",t("workTopdownBrokenLinksErrorMetricSuffix")]}),e.jsxs("span",{className:"topDownTopBar__metric"+(j.warning>0?" topDownTopBar__metric--warn":""),children:[e.jsx("strong",{children:j.warning})," ",t("workTopdownBrokenLinksWarningMetricSuffix")]}),e.jsxs("span",{className:"topDownTopBar__metric",children:[e.jsx("strong",{children:j.info})," ",t("workTopdownBrokenLinksInfoMetricSuffix")]})]})]}),e.jsxs("nav",{className:"brokenLinks__filters","aria-label":t("workTopdownBrokenLinksSeverityFiltersAriaLabel"),children:[e.jsx(Ae,{active:r==="all",label:t("workTopdownBrokenLinksSeverityAllLabel"),n:i.diagnostics.length,onClick:()=>x("all")}),e.jsx(Ae,{active:r==="error",label:t("workTopdownBrokenLinksSeverityErrorLabel"),n:j.error,tone:"error",onClick:()=>x("error")}),e.jsx(Ae,{active:r==="warning",label:t("workTopdownBrokenLinksSeverityWarningLabel"),n:j.warning,tone:"warning",onClick:()=>x("warning")}),e.jsx(Ae,{active:r==="info",label:t("workTopdownBrokenLinksSeverityInfoLabel"),n:j.info,tone:"info",onClick:()=>x("info")})]}),e.jsxs("div",{className:"brokenLinks__list",children:[h?e.jsx("p",{className:"brokenLinks__removeError",role:"alert",children:h}):null,_.length===0?e.jsx("p",{className:"brokenLinks__empty",children:t("workTopdownBrokenLinksNoDiagnostics")}):_.map(g=>e.jsx(di,{diagnostic:g,indexes:l,onOpenObject:L,fetchedLinkIds:c,onRemoveLink:y,removingId:d},g.id))]}),e.jsx(Dt,{graph:i,indexes:l,selectedId:n,onClose:()=>L(null),onSelect:g=>L(n===g?null:g)})]})}function di({diagnostic:t,indexes:s,onOpenObject:a,fetchedLinkIds:r,onRemoveLink:n,removingId:o}){const{t:i}=N();return e.jsxs("article",{className:`brokenLinks__row brokenLinks__row--${t.severity}`,children:[e.jsxs("header",{className:"brokenLinks__rowHead",children:[e.jsx("span",{className:`brokenLinks__sev brokenLinks__sev--${t.severity}`,children:Tr(t.severity,i)}),e.jsx("span",{className:"brokenLinks__kind",children:ms(t.kind,i)}),e.jsx(ui,{diagnostic:t,indexes:s})]}),e.jsx("p",{className:"brokenLinks__msg",children:t.message}),e.jsx(hi,{diagnostic:t,indexes:s,onOpenObject:a,fetchedLinkIds:r,onRemoveLink:n,removingId:o})]})}function ui({diagnostic:t,indexes:s}){const{t:a}=N();if(t.kind==="orphan_link"||t.kind==="link_cycle"||!t.objectId)return null;const r=s.objectsById.get(t.objectId);return r?e.jsxs("span",{className:"brokenLinks__rowSubject",children:[a("workTopdownBrokenLinksOn")," ",e.jsx("strong",{children:r.title})]}):null}function hi({diagnostic:t,indexes:s,onOpenObject:a,fetchedLinkIds:r,onRemoveLink:n,removingId:o}){switch(t.kind){case"orphan_link":return e.jsx(pi,{diagnostic:t,indexes:s,removable:r.has(t.linkId),onRemove:n,removing:o===t.linkId});case"link_cycle":return e.jsx(ki,{diagnostic:t,indexes:s,fetchedLinkIds:r,onRemove:n,removingId:o});default:return e.jsx(mi,{diagnostic:t,indexes:s,onOpenObject:a})}}function mi({diagnostic:t,indexes:s,onOpenObject:a}){const{t:r}=N(),n=t.objectId?s.objectsById.get(t.objectId):void 0;return e.jsx("footer",{className:"brokenLinks__rowFoot",children:t.objectId?n?e.jsxs("button",{type:"button",className:"brokenLinks__open",onClick:()=>a(t.objectId),children:[r("workTopdownBrokenLinksOpenInDrawer")," →"]}):e.jsx("span",{className:"brokenLinks__broken",children:r("workTopdownBrokenLinksObjectNotInProjection",{objectId:t.objectId})}):e.jsx("span",{className:"brokenLinks__system",children:r("workTopdownBrokenLinksNoSpecificObject")})})}function pi({diagnostic:t,indexes:s,removable:a,onRemove:r,removing:n}){const o=t.unresolvedSide==="source"||t.unresolvedSide==="both",i=t.unresolvedSide==="target"||t.unresolvedSide==="both",{t:l}=N();return e.jsxs("div",{className:"brokenLinks__linkBody",children:[e.jsxs("div",{className:"brokenLinks__endpoints",children:[e.jsx(ct,{endpoint:t.sourceEndpoint,indexes:s,unresolved:o}),e.jsx("span",{className:"brokenLinks__arrow","aria-hidden":"true",children:"→"}),e.jsx(ct,{endpoint:t.targetEndpoint,indexes:s,unresolved:i})]}),e.jsxs("footer",{className:"brokenLinks__rowFoot",children:[e.jsx("button",{type:"button",className:"brokenLinks__removeLink",disabled:!a||n,onClick:()=>{a&&!n&&r(t.linkId)},title:l(a?"workTopdownBrokenLinksRemoveTooltipRemovable":"workTopdownBrokenLinksRemoveTooltipDemoSeed"),children:l(n?"workTopdownBrokenLinksRemovingInProgress":"workTopdownBrokenLinksRemoveAction")}),a?null:e.jsx("span",{className:"brokenLinks__pendingNote",children:l("workTopdownBrokenLinksRemovableOnlyDemo")})]})]})}function ki({diagnostic:t,indexes:s,fetchedLinkIds:a,onRemove:r,removingId:n}){const{t:o}=N();return e.jsxs("div",{className:"brokenLinks__linkBody",children:[e.jsx("ol",{className:"brokenLinks__cycle",children:t.cycleEndpoints.map((i,l)=>e.jsxs("li",{className:"brokenLinks__cycleStep",children:[e.jsx(ct,{endpoint:i,indexes:s,unresolved:!1}),e.jsx("span",{className:"brokenLinks__arrow"+(l===t.cycleEndpoints.length-1?" brokenLinks__arrow--loop":""),"aria-hidden":"true",children:l===t.cycleEndpoints.length-1?"↺":"→"})]},`${i.recordFamily}:${i.recordId}:${l}`))}),e.jsxs("footer",{className:"brokenLinks__rowFoot brokenLinks__rowFoot--cycle",children:[e.jsx("span",{className:"brokenLinks__cycleActionsLabel",children:o("workTopdownBrokenLinksCycleRemovableRows",{count:`${t.cycleLinkIds.length}`})}),e.jsx("ul",{className:"brokenLinks__cycleActions",children:t.cycleLinkIds.map(i=>{const l=a.has(i),c=n===i;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"brokenLinks__removeLink",disabled:!l||c,onClick:()=>{l&&!c&&r(i)},title:o(l?"workTopdownBrokenLinksRemoveTooltipRemovable":"workTopdownBrokenLinksRemoveTooltipDemoSeed"),children:[o(c?"workTopdownBrokenLinksRemovingInProgress":"workTopdownBrokenLinksRemoveAction"),c?null:e.jsx("code",{children:i})]})},i)})})]})]})}function ct({endpoint:t,indexes:s,unresolved:a}){const r=s.objectsByCoreRef.get(Ue(t)),{t:n}=N(),o=ae(t.recordFamily,n);return e.jsxs("span",{className:"brokenLinks__endpointPill"+(a?" brokenLinks__endpointPill--unresolved":""),children:[e.jsx("span",{className:"brokenLinks__endpointFamily",children:o}),e.jsx("span",{className:"brokenLinks__endpointTitle",children:r?r.title:e.jsx("code",{children:t.recordId})}),a?e.jsx("span",{className:"brokenLinks__deletedMark",children:n("workTopdownBrokenLinksDeletedLabel")}):null]})}function Ae({active:t,label:s,n:a,tone:r,onClick:n}){return e.jsxs("button",{type:"button",className:"brokenLinks__chip"+(r?` brokenLinks__chip--${r}`:"")+(t?" brokenLinks__chip--active":""),onClick:n,"aria-pressed":t,children:[e.jsx("span",{className:"brokenLinks__chipLabel",children:s}),e.jsx("span",{className:"brokenLinks__chipCount",children:a})]})}const wi=new Set(["project","work_item","task"]);function _i({rows:t,links:s,indexes:a,selectedId:r,onSelect:n,maxDepth:o=3}){const{t:i}=N(),l=m.useMemo(()=>{const c=[];for(const h of t){if(!wi.has(h.kind))continue;const u=Lr({recordFamily:h.kind,recordId:h.sourceRecordId},s,a.objectsByCoreRef,o);u.length!==0&&c.push({row:h,chain:u})}return c},[t,s,a.objectsByCoreRef,o]);return e.jsxs("aside",{className:"blockersRail","aria-label":i("workTopdownUpstreamBlockersAriaLabel"),children:[e.jsxs("header",{className:"blockersRail__head",children:[e.jsx("h3",{children:i("workTopdownBlockersTitle")}),e.jsx("p",{children:i("workTopdownUpstreamBlocksLine",{maxDepth:`${o}`})})]}),l.length===0?e.jsx("p",{className:"blockersRail__empty",children:i("workTopdownNoUpstreamBlockers")}):e.jsx("ul",{className:"blockersRail__sections",children:l.map(({row:c,chain:h})=>e.jsxs("li",{className:"blockersRail__section",children:[e.jsxs("div",{className:"blockersRail__rowHead",children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--small projectsList__dot--${c.status}`,"aria-hidden":"true"}),e.jsx("span",{className:"blockersRail__rowTitle",children:c.title})]}),e.jsx("ul",{className:"blockersRail__chain",children:h.map(u=>e.jsx("li",{className:"blockersRail__chainItem",children:e.jsxs("button",{type:"button",className:"blockersRail__btn"+(r===u.id?" blockersRail__btn--selected":""),onClick:()=>n(r===u.id?null:u.id),children:[e.jsx("span",{className:`projectsList__dot projectsList__dot--small projectsList__dot--${u.status}`,"aria-hidden":"true"}),e.jsx("span",{className:"blockersRail__btnTitle",children:u.title}),e.jsx("span",{className:"blockersRail__btnTier",children:ae(u.kind,i)})]})},u.id))})]},c.id))})]})}const et=[{id:"command",labelKey:"workTopdownCockpitTabCommandLabel",subKey:"workTopdownCockpitTabCommandSub"},{id:"needs-decision",labelKey:"workTopdownCockpitTabNeedsDecisionLabel",subKey:"workTopdownCockpitTabNeedsDecisionSub"},{id:"active",labelKey:"workTopdownCockpitTabActiveLabel",subKey:"workTopdownCockpitTabActiveSub"},{id:"active-runs",labelKey:"workTopdownCockpitTabActiveRunsLabel",subKey:"workTopdownCockpitTabActiveRunsSub"},{id:"blocked",labelKey:"workTopdownCockpitTabBlockedLabel",subKey:"workTopdownCockpitTabBlockedSub"},{id:"shipped",labelKey:"workTopdownCockpitTabShippedLabel",subKey:"workTopdownCockpitTabShippedSub"},{id:"teams",labelKey:"workTopdownCockpitTabTeamsLabel",subKey:"workTopdownCockpitTabTeamsSub"}],ji=["needs-decision","blocked","active","active-runs","shipped"],Yt=["project","work_item","task","mission","run","conversation"],xi={decision_needed:"needs-decision",blocked:"blocked",failed:"blocked",recently_shipped:"shipped"};function gi(){const{t}=N(),[s,a]=wt(),r=s.get("tab")??"command",n=s.get("selectedId"),o=ke(t("workGraphLoadErrorFallback")).data??pe,i=m.useMemo(()=>be(o),[o]),l=m.useMemo(()=>{const _={"needs-decision":[],active:[],"active-runs":[],blocked:[],shipped:[]};for(const x of o.objects){if(!Yt.includes(x.kind))continue;if(x.kind==="run"&&x.status==="running"){_["active-runs"].push(x);continue}const L=xi[x.attention];L?_[L].push(x):x.attention==="none"&&["in_progress","active"].includes(x.status)&&_.active.push(x)}return _},[o]),c=m.useMemo(()=>{const _=new Map;for(const x of o.objects){if(!Yt.includes(x.kind)||!x.ownerRole)continue;const L=_.get(x.ownerRole)??[];L.push(x),_.set(x.ownerRole,L)}return Array.from(_.entries()).map(([x,L])=>({role:x,items:L})).sort((x,L)=>x.role.localeCompare(L.role))},[o]);function h(_){const x=new URLSearchParams(s);_==="command"?x.delete("tab"):x.set("tab",_),a(x,{replace:!0})}function u(_){const x=new URLSearchParams(s);_===null?x.delete("selectedId"):x.set("selectedId",_),a(x,{replace:!0})}const d={"needs-decision":l["needs-decision"].length,active:l.active.length,"active-runs":l["active-runs"].length,blocked:l.blocked.length,shipped:l.shipped.length,teams:c.length},w=et.find(_=>_.id===r),y=w?t(w.labelKey):"",j=w?t(w.subKey):"";return e.jsxs("div",{className:"topDownPage",children:[e.jsxs("header",{className:"channelTopBar topDownTopBar",children:[e.jsxs("div",{className:"channelTopBarStart topDownTopBar__start",children:[e.jsx("span",{className:"topDownTopBar__eyebrow",children:t("workTopdownCockpitEyebrow")}),e.jsx("h1",{className:"channelTopBarTitle topDownTopBar__title",children:t("workTopdownCockpitTitle")})]}),e.jsx("div",{className:"channelTopBarCenter topDownTopBar__center",children:e.jsx("p",{className:"topDownTopBar__lede",children:t("workTopdownCockpitLede")})}),e.jsxs("div",{className:"channelTopBarEnd topDownTopBar__end",children:[e.jsxs("span",{className:"topDownTopBar__metric"+(d["needs-decision"]>0?" topDownTopBar__metric--warn":""),children:[e.jsx("strong",{children:d["needs-decision"]})," ",t("workTopdownCockpitMetricDecisions")]}),e.jsxs("span",{className:"topDownTopBar__metric"+(d.blocked>0?" topDownTopBar__metric--bad":""),children:[e.jsx("strong",{children:d.blocked})," ",t("workTopdownCockpitMetricBlocked")]}),e.jsxs("span",{className:"topDownTopBar__metric",children:[e.jsx("strong",{children:d.shipped})," ",t("workTopdownCockpitMetricShipped")]})]})]}),e.jsx("nav",{className:"cockpit__tabs","aria-label":t("workTopdownCockpitTabsAriaLabel"),children:et.map(_=>{const x=t(_.labelKey),L=t(_.subKey);return e.jsxs("button",{type:"button",className:"cockpit__tab"+(r===_.id?" cockpit__tab--active":""),onClick:()=>h(_.id),"aria-pressed":r===_.id,children:[e.jsx("span",{className:"cockpit__tabLabel",children:x}),e.jsx("span",{className:"cockpit__tabSub",children:L}),_.id!=="command"&&_.id!=="teams"?e.jsx("span",{className:"cockpit__tabCount",children:d[_.id]}):null,_.id==="teams"?e.jsx("span",{className:"cockpit__tabCount",children:d.teams}):null]},_.id)})}),e.jsx("div",{className:"cockpit__main",children:r==="command"?e.jsx(bi,{graph:o,buckets:l,indexes:i,selectedId:n,onSelect:u,onJump:_=>h(_),tabs:et,t}):r==="teams"?e.jsx(Ni,{lanes:c,indexes:i,selectedId:n,onSelect:u,t}):e.jsx(yi,{label:y,sub:j,objects:l[r],graph:o,indexes:i,selectedId:n,onSelect:u,t})}),e.jsx(Dt,{graph:o,indexes:i,selectedId:n,onClose:()=>u(null),onSelect:_=>u(n===_?null:_)})]})}function bi({graph:t,buckets:s,indexes:a,selectedId:r,onSelect:n,onJump:o,tabs:i,t:l}){const c=t.objects.filter(u=>u.kind==="activity").sort((u,d)=>d.updatedAt.localeCompare(u.updatedAt)).slice(0,5);function h(u){const d=i.find(w=>w.id===u);return d?l(d.labelKey):""}return e.jsxs("div",{className:"commandCenter",children:[e.jsx("div",{className:"commandCenter__grid",children:ji.map(u=>e.jsxs("section",{className:"commandCenter__bucket","data-bucket":u,"aria-label":h(u),children:[e.jsxs("header",{className:"commandCenter__bucketHead",children:[e.jsx("h3",{children:h(u)}),e.jsx("span",{className:"commandCenter__bucketCount",children:s[u].length}),e.jsxs("button",{type:"button",className:"commandCenter__seeMore",onClick:()=>o(u),children:[l("workTopdownCockpitOpen")," →"]})]}),e.jsx("div",{className:"commandCenter__bucketBody",children:s[u].length===0?e.jsx("p",{className:"commandCenter__empty",children:l("workTopdownCockpitNoBucketItems")}):s[u].slice(0,3).map(d=>e.jsx(Ge,{object:d,evidence:Qe(a,d.id),gates:a.gatesBySubject.get(d.id)??[],selected:r===d.id,onSelect:w=>n(r===w?null:w)},d.id))})]},u))}),e.jsxs("aside",{className:"commandCenter__rail","aria-label":l("workTopdownCockpitRecentActivityAriaLabel"),children:[e.jsxs("header",{className:"commandCenter__railHead",children:[e.jsx("h3",{children:l("workTopdownCockpitRecentActivityTitle")}),e.jsx("p",{children:l("workTopdownCockpitRecentActivitySummary",{count:`${c.length}`})})]}),c.length===0?e.jsx("p",{className:"commandCenter__empty",children:l("workTopdownCockpitRecentActivityEmpty")}):e.jsx("ul",{className:"commandCenter__activityList",children:c.map(u=>e.jsx("li",{className:"commandCenter__activityItem"+(r===u.id?" commandCenter__activityItem--selected":""),children:e.jsxs("button",{type:"button",onClick:()=>n(r===u.id?null:u.id),children:[e.jsx("span",{className:"commandCenter__activityTitle",children:u.title}),e.jsx("span",{className:"commandCenter__activityWhen",children:W(u.updatedAt,l)})]})},u.id))})]})]})}function yi({label:t,sub:s,objects:a,graph:r,indexes:n,selectedId:o,onSelect:i,t:l}){return e.jsxs("section",{className:"bucketDetail",children:[e.jsxs("header",{className:"bucketDetail__head",children:[e.jsx("h2",{children:t}),e.jsx("p",{children:s})]}),a.length===0?e.jsx("p",{className:"bucketDetail__empty",children:l("workTopdownCockpitNoBucketItems")}):e.jsxs("div",{className:"bucketDetail__body",children:[e.jsx("div",{className:"bucketDetail__main",children:e.jsx("div",{className:"bucketDetail__list",children:a.map(c=>e.jsx(Ge,{object:c,evidence:Qe(n,c.id),gates:n.gatesBySubject.get(c.id)??[],selected:o===c.id,onSelect:h=>i(o===h?null:h)},c.id))})}),e.jsx(_i,{rows:a,links:r.links,indexes:n,selectedId:o,onSelect:i})]})]})}function Ni({lanes:t,indexes:s,selectedId:a,onSelect:r,t:n}){return t.length===0?e.jsx("p",{className:"bucketDetail__empty",children:n("workTopdownCockpitNoActorRoles")}):e.jsx("div",{className:"teamsLanes",children:t.map(o=>{const i=ge(o.role,n);return e.jsxs("section",{className:"teamsLanes__lane","aria-label":i,children:[e.jsxs("header",{className:"teamsLanes__head",children:[e.jsx("h3",{children:i}),e.jsx("span",{className:"teamsLanes__count",children:o.items.length})]}),e.jsx("div",{className:"teamsLanes__body",children:o.items.map(l=>e.jsx(Ge,{object:l,evidence:Qe(s,l.id),gates:s.gatesBySubject.get(l.id)??[],selected:a===l.id,onSelect:c=>r(a===c?null:c)},l.id))})]},o.role)})})}const fi=[{layer:"interaction"},{layer:"planning"},{layer:"execution"}];function Ti(){const{t}=N(),[s,a]=wt(),r=s.get("selectedId"),n=ke(t("workGraphLoadErrorFallback")).data??pe,o=m.useMemo(()=>be(n),[n]),i=m.useMemo(()=>{const h={interaction:[],planning:[],execution:[]};for(const u of n.objects)u.structuralLayer&&h[u.structuralLayer].push(u);return h},[n]),l={objects:n.objects.length,diagnostics:n.diagnostics.length,structural:i.interaction.length+i.planning.length+i.execution.length};function c(h){const u=new URLSearchParams(s);h===null?u.delete("selectedId"):u.set("selectedId",h),a(u,{replace:!0})}return e.jsxs("div",{className:"topDownPage",children:[e.jsxs("header",{className:"channelTopBar topDownTopBar",children:[e.jsxs("div",{className:"channelTopBarStart topDownTopBar__start",children:[e.jsx("span",{className:"topDownTopBar__eyebrow",children:t("workTopdownSystemMapEyebrow")}),e.jsx("h1",{className:"channelTopBarTitle topDownTopBar__title",children:t("workTopdownSystemMapTitle")})]}),e.jsx("div",{className:"channelTopBarCenter topDownTopBar__center",children:e.jsx("p",{className:"topDownTopBar__lede",children:t("workTopdownSystemMapLede")})}),e.jsxs("div",{className:"channelTopBarEnd topDownTopBar__end",children:[e.jsxs("span",{className:"topDownTopBar__metric",children:[e.jsx("strong",{children:l.structural})," ",t("workTopdownSystemMapStructuralLabel")]}),e.jsxs("span",{className:"topDownTopBar__metric",children:[e.jsx("strong",{children:l.objects})," ",t("workTopdownSystemMapTotalLabel")]}),e.jsxs("span",{className:"topDownTopBar__metric"+(l.diagnostics>0?" topDownTopBar__metric--warn":""),children:[e.jsx("strong",{children:l.diagnostics})," ",t("workTopdownSystemMapDiagnosticsLabel")]})]})]}),e.jsx("div",{className:"systemMap",children:fi.map(h=>{const u=i[h.layer];return e.jsxs("section",{className:"systemMap__pane","data-layer":h.layer,"aria-label":t("workTopdownSystemMapLayerAriaLabel",{layerLabel:rt(h.layer,t)}),children:[e.jsxs("header",{className:"systemMap__paneHead",children:[e.jsx("h2",{className:"systemMap__paneTitle",children:rt(h.layer,t)}),e.jsx("span",{className:"systemMap__paneCount",children:u.length}),e.jsx("p",{className:"systemMap__paneDescription",children:Li(h.layer,t)})]}),e.jsx("div",{className:"systemMap__paneBody",children:u.length===0?e.jsx("p",{className:"systemMap__paneEmpty",children:t("workTopdownSystemMapLayerEmpty")}):u.map(d=>e.jsx(Ge,{object:d,evidence:Qe(o,d.id),gates:o.gatesBySubject.get(d.id)??[],selected:r===d.id,onSelect:w=>c(r===w?null:w)},d.id))})]},h.layer)})}),e.jsx(Dt,{graph:n,indexes:o,selectedId:r,onClose:()=>c(null),onSelect:h=>c(r===h?null:h)})]})}function Li(t,s){return s(t==="interaction"?"workTopdownSystemMapLayerInteractionDescription":t==="planning"?"workTopdownSystemMapLayerPlanningDescription":"workTopdownSystemMapLayerExecutionDescription")}function vi({payload:t,selectedChannel:s,directLaneChannel:a,showDirectLaneBoot:r,feedback:n,busy:o,chatSurfaceProps:i,draftSurfaceProps:l,addCatOpen:c,onToggleAddCat:h,addCatPanelProps:u,folderBrowserProps:d,onOpenDraftAddCat:w,onChangeDraftDefaultRecipient:y}){const j=d;return La({payload:t,selectedChannel:s,directLaneChannel:a,showDirectLaneBoot:r,feedback:n,busy:o,addCatOpen:c,entryPath:$a(t.setupCompleteAt),chatsPath:Ua(t.chat.channels,t.chat.selectedChannelId),extraRoutes:[e.jsx(H,{path:"war-room",element:e.jsx($r,{})},"war-room"),e.jsx(H,{path:"projects",element:e.jsx(yn,{})},"project-list"),Xe({key:"project-detail",path:"projects/:projectId",surfaceKind:"work_project",surfaceIdParam:"projectId",element:e.jsx(wn,{})}),e.jsx(H,{path:"tasks",element:e.jsx(On,{})},"task-list"),Xe({key:"task-detail",path:"tasks/:taskId",surfaceKind:"work_task",surfaceIdParam:"taskId",element:e.jsx(Rn,{})}),e.jsx(H,{path:"tasks/:taskId/runs/:runId",element:e.jsx(wo,{})},"run-detail"),e.jsx(H,{path:"runs",element:e.jsx($n,{})},"run-list"),e.jsx(H,{path:"missions",element:e.jsx(go,{})},"mission-list"),e.jsx(H,{path:"missions/:missionId",element:e.jsx(bo,{})},"mission-detail"),e.jsx(H,{path:"schedules",element:e.jsx(Uo,{})},"schedule-list"),e.jsx(H,{path:"schedules/:scheduleId",element:e.jsx(Qo,{})},"schedule-detail"),e.jsx(H,{path:"work-items",element:e.jsx(oi,{})},"work-item-list"),Xe({key:"work-item-detail",path:"work-items/:workItemId",surfaceKind:"work_item",surfaceIdParam:"workItemId",element:e.jsx(Vo,{})}),e.jsx(H,{path:"system-map",element:e.jsx(Ti,{})},"system-map"),e.jsx(H,{path:"cockpit",element:e.jsx(gi,{})},"cockpit"),e.jsx(H,{path:"broken-links",element:e.jsx(ci,{})},"broken-links")],renderBootShell:()=>e.jsx(ns,{}),renderChatView:(_,x)=>e.jsx(Ks,{...i,payload:t,selectedChannel:_,behaviorSurface:"work",onOpenAddCat:x.onOpenAddCat,showAddCatButton:x.showAddCatButton,renderComposerHeaderAccessory:L=>e.jsx(fa,{channel:L.selectedChannel}),renderComposerSurfaceTag:()=>e.jsx(zt,{surface:"work"})}),renderNewChatDraft:_=>e.jsx(Va,{...l,payload:t,onOpenAddCat:_.onOpenAddCat,onDraftDefaultRecipientChange:_.onDraftDefaultRecipientChange,allowAddCat:_.allowAddCat,folderBrowsePath:j.folderBrowsePath,folderBrowseCurrentPath:j.folderBrowseCurrentPath,folderBrowseParentPath:j.folderBrowseParentPath,folderBrowseEntries:j.folderBrowseEntries,folderBrowseLoading:j.folderBrowseLoading,folderBrowseError:j.folderBrowseError,onFolderBrowsePathChange:j.onPathChange,onFolderBrowse:j.onBrowse,onFolderBrowseSelect:j.onSelect}),renderAddCatPanel:_=>e.jsx(Fs,{...u,busy:_.busy,feedback:_.feedback}),onToggleAddCat:h,onOpenDraftAddCat:w,onChangeDraftDefaultRecipient:y})}const Bs="cats-work:unpinned-projects",Oe=new Set(Di()),dt=new Set;let ut=Es();function Di(){try{const t=globalThis.localStorage?.getItem(Bs);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s:[]}catch{return[]}}function Si(){try{globalThis.localStorage?.setItem(Bs,JSON.stringify([...Oe]))}catch{}}function Es(){return new Set(Oe)}function Ri(){ut=Es();for(const t of dt)t()}function Ii(t){Oe.has(t)||(Oe.add(t),Si(),Ri())}function Pi(){return m.useSyncExternalStore(t=>(dt.add(t),()=>{dt.delete(t)}),()=>ut,()=>ut)}function Ci(t,s){const a=[{key:"new-work",label:s("workSidebarNewWorkLabel"),onClick:t.onStartNewChat,icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M8 3v10"}),e.jsx("path",{d:"M3 8h10"})]})}];return t.onStartNewGroupChat&&a.push({key:"new-team-work",label:s("workSidebarTeamWorkLabel"),onClick:t.onStartNewGroupChat,icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"5",cy:"6",r:"2.25"}),e.jsx("circle",{cx:"11",cy:"6",r:"2.25"}),e.jsx("path",{d:"M2.75 12c.35-1.85 1.6-2.85 3.75-2.85S9.9 10.15 10.25 12"}),e.jsx("path",{d:"M8.6 12c.28-1.48 1.26-2.28 2.9-2.28 1.56 0 2.46.7 2.75 2.28"})]})}),t.onStartNewParallelChat&&a.push({key:"new-parallel-work",label:s("workSidebarParallelWorkLabel"),onClick:t.onStartNewParallelChat,icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 13V3h12v10H2z"}),e.jsx("path",{d:"M7 3v10"}),e.jsx("path",{d:"M11 3v10"})]})}),a}function Bi(t,s,a){const r=globalThis.location?.pathname??Z,n=[];if(t.onOpenProjects&&n.push({key:"projects",ariaLabel:a("workSidebarPortfolioLabel"),items:[{key:"projects",label:a("workSidebarProjectsLabel"),onClick:t.onOpenProjects,active:qr(r),icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2.5",y:"3",width:"11",height:"10",rx:"1.5"}),e.jsx("path",{d:"M5 3v-1"}),e.jsx("path",{d:"M11 3v-1"}),e.jsx("path",{d:"M4.5 7h7"})]})}],pinnedItems:Ei(t,r,s,a)}),t.onOpenWorkItems&&n.push({key:"work-items",ariaLabel:a("workSidebarManagedWorkLabel"),items:[{key:"work-items",label:a("workSidebarWorkItemsLabel"),onClick:t.onOpenWorkItems,active:Vr(r),icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2.5",y:"2.5",width:"11",height:"11",rx:"2"}),e.jsx("path",{d:"M5 6h6"}),e.jsx("path",{d:"M5 8.5h6"}),e.jsx("path",{d:"M5 11h3.5"})]})}]}),t.onOpenTasks||t.onOpenRuns||t.onOpenMissions||t.onOpenSchedules){const i=[];t.onOpenTasks&&i.push({key:"tasks",label:a("workSidebarTasksLabel"),onClick:t.onOpenTasks,active:Hr(r)&&!Mt(r),icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2.5",y:"2.5",width:"11",height:"11",rx:"2"}),e.jsx("path",{d:"M5 5.5h6"}),e.jsx("path",{d:"M5 8h6"}),e.jsx("path",{d:"M5 10.5h4"})]})}),t.onOpenRuns&&i.push({key:"runs",label:a("workSidebarRunsLabel"),onClick:t.onOpenRuns,active:Mt(r),icon:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polygon",{points:"5,3 12.5,8 5,13"})})}),t.onOpenMissions&&i.push({key:"missions",label:a("workSidebarMissionsLabel"),onClick:t.onOpenMissions,active:Xr(r),icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"5"}),e.jsx("circle",{cx:"8",cy:"8",r:"2"}),e.jsx("path",{d:"M8 1.5v2"}),e.jsx("path",{d:"M8 12.5v2"}),e.jsx("path",{d:"M1.5 8h2"}),e.jsx("path",{d:"M12.5 8h2"})]})}),t.onOpenSchedules&&i.push({key:"schedules",label:a("workSidebarSchedulesLabel"),onClick:t.onOpenSchedules,active:Zr(r),icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"5.5"}),e.jsx("path",{d:"M8 4.5V8l2.5 1.5"}),e.jsx("path",{d:"M4 2.5l-1 1"}),e.jsx("path",{d:"M12 2.5l1 1"})]})}),n.push({key:"execution",ariaLabel:a("workSidebarExecutionLabel"),items:i})}const o=[];return t.onOpenSystemMap&&o.push({key:"system-map",label:a("workSidebarSystemMapLabel"),onClick:t.onOpenSystemMap,active:Yr(r),icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"2",width:"4",height:"4",rx:"1"}),e.jsx("rect",{x:"6.5",y:"6.5",width:"4",height:"4",rx:"1"}),e.jsx("rect",{x:"11",y:"11",width:"3",height:"3",rx:"0.75"}),e.jsx("path",{d:"M6 4h2"}),e.jsx("path",{d:"M9 8h1.5"})]})}),t.onOpenCockpit&&o.push({key:"cockpit",label:a("workSidebarCockpitLabel"),onClick:t.onOpenCockpit,active:zr(r),icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 12.5a6 6 0 0 1 12 0"}),e.jsx("path",{d:"M8 12.5V8"}),e.jsx("path",{d:"M8 8l3-2.5"}),e.jsx("circle",{cx:"8",cy:"12.5",r:"0.6",fill:"currentColor",stroke:"none"})]})}),t.onOpenBrokenLinks&&o.push({key:"broken-links",label:a("workSidebarBrokenLinksLabel"),onClick:t.onOpenBrokenLinks,active:Jr(r),icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 6.5L4 8.5a2.12 2.12 0 0 0 3 3l1-1"}),e.jsx("path",{d:"M10 9.5l2-2a2.12 2.12 0 0 0-3-3l-1 1"}),e.jsx("path",{d:"M5.5 10.5l5-5",strokeDasharray:"1.5 1.5"})]})}),t.onOpenWarRoom&&o.push({key:"war-room",label:a("workSidebarWarRoomLabel"),onClick:t.onOpenWarRoom,active:Qr(r),icon:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2.5",y:"2.5",width:"11",height:"11",rx:"2"}),e.jsx("path",{d:"M4 5h8"}),e.jsx("path",{d:"M4 8h8"}),e.jsx("path",{d:"M6 11h4"})]})}),o.length>0&&n.push({key:"top-down",ariaLabel:a("workSidebarWorkTopDownSurfacesLabel"),items:o}),n}function Ei(t,s,a,r){return t.onOpenProject?a.map(n=>({id:n.id,label:n.title,isActive:s===`${Z}/projects/${n.id}`,onClick:()=>t.onOpenProject?.(n.id),statusDot:{className:`projectsList__dot projectsList__dot--small projectsList__dot--${n.status}`,title:M(n.status,r)},overflowActions:[{key:"unpin",label:r("workSidebarUnpinProjectLabel"),onClick:()=>{t.onOverflowMenuToggle(null),Ii(n.id)}},{key:"delete",label:r("workSidebarDeleteProjectLabel"),destructive:!0,onClick:()=>{t.onOverflowMenuToggle(null),is(n.id,r("workProjectDeleteError")).then(()=>Na.invalidateQueries({queryKey:_e}))}}]})):[]}function Ai(t){return Us({channels:t.payload.chat.channels,parallelChatGroups:t.payload.chat.parallelChatGroups,activeSurface:t.shellSurface??"work",routeChannelId:t.routeChannelId,isDirectLaneSummary:ss,onSelect:t.onSelect,onRenameParallelGroup:t.onRenameParallelChatGroup,onUngroupParallelGroup:t.onUngroupParallelChatGroup,onDeleteParallelGroup:t.onDeleteParallelChatGroup,onCloseOverflowMenu:()=>t.onOverflowMenuToggle(null)})}function Wi(t,s={},a){const r=s.pinnedProjects??[];return{payload:t.payload,sidebarOpen:t.sidebarOpen,accountMenuOpen:t.accountMenuOpen,overflowMenuOpenId:t.overflowMenuOpenId,busy:t.busy,surface:t.surface,shellSurface:t.shellSurface,routeChannelId:t.routeChannelId,accountMenuRef:t.accountMenuRef,primaryActions:Ci(t,a),extraActionGroups:Bi(t,r,a),recentEntries:Ai(t),recentEmptyStateLabel:a("workSidebarNoWorkYetLabel"),helpers:{catInitials:ba,presentChannelTitle:n=>ya(n,a),isVisibleCat:ga,sortCatsForDisplay:xa,isDirectLaneSummary:ss,findDirectLaneForCat:ja,resolveMyCatStatusDot:_a,statusDotClassName:wa,statusDotLabel:ka},onToggleSidebar:t.onToggleSidebar,onCollapsedSidebarClick:t.onCollapsedSidebarClick,onOpenChatsOverview:t.onOpenChatsOverview,onSelect:t.onSelect,onDeleteChannel:t.onDeleteChannel,onRenameChannel:t.onRenameChannel,onArchiveCat:t.onArchiveCat,onAccountMenuToggle:t.onAccountMenuToggle,onOverflowMenuToggle:t.onOverflowMenuToggle,onNavigateSettings:t.onNavigateSettings,onNavigateRuntime:t.onNavigateRuntime,onSwitchProduct:t.onSwitchProduct,activeMyCatId:t.activeMyCatId,onDirectChatCat:t.onDirectChatCat}}function Mi(t){const{t:s}=N(),a=Ne(),r=Pi(),n=(a.data?.projects??[]).filter(o=>!r.has(o.id));return e.jsx($s,{...Wi(t,{pinnedProjects:n},s)})}const Gi=Gs({productName:"Work",shellSurface:"work",supportsStructuredDraftModes:!0,BootShell:ns,AppRoutesComponent:vi,renderSidebar:t=>e.jsx(Mi,{...t,onStartNewGroupChat:t.onStartNewGroupChat,onStartNewParallelChat:t.onStartNewParallelChat,onOpenWarRoom:()=>t.navigate(_s),onOpenProjects:()=>t.navigate(ne),onOpenProject:s=>t.navigate(`${ne}/${s}`),onOpenTasks:()=>t.navigate(Q),onOpenRuns:()=>t.navigate(nt),onOpenMissions:()=>t.navigate(ie),onOpenSchedules:()=>t.navigate(le),onOpenWorkItems:()=>t.navigate(he),onOpenSystemMap:()=>t.navigate(js),onOpenCockpit:()=>t.navigate(xs),onOpenBrokenLinks:()=>t.navigate(gs)})});export{Gi as default};