@bigduu/lotus-next 2026.11.2 → 2026.11.3
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.
- package/dist/asset-manifest.json +229 -202
- package/dist/assets/{AgentService-BcSV4V6G.js → AgentService-T_rVeCqc.js} +1 -1
- package/dist/assets/{BrowserPane-Qpdtlb6C.js → BrowserPane-BCZscRcO.js} +1 -1
- package/dist/assets/{CommandPalette-FYYof7PJ.js → CommandPalette-CgiVqLDj.js} +1 -1
- package/dist/assets/ComposerEditor-VqGIrsdq.js +102 -0
- package/dist/assets/{ConversationClearDialogContent-DapZ3K4B.js → ConversationClearDialogContent-Dhq7t2MJ.js} +1 -1
- package/dist/assets/{ErrorBoundary-Cd8Mqhm-.js → ErrorBoundary-Dvuhdy_Q.js} +1 -1
- package/dist/assets/ErrorBoundary-kV_VJwPy.js +1 -0
- package/dist/assets/{ExternalLinkDialog-DxecTv9b.js → ExternalLinkDialog--gaLElt0.js} +1 -1
- package/dist/assets/{JianduProjectMemories-BSU_YgtD.js → JianduProjectMemories-DGz_FvO5.js} +1 -1
- package/dist/assets/Markdown-D90UutFO.js +2 -0
- package/dist/assets/MermaidChart-D1bUSRYY.js +1 -0
- package/dist/assets/{NewChatWorktreeControl-BVvX1tE3.js → NewChatWorktreeControl-BokjqEn9.js} +1 -1
- package/dist/assets/{ProjectWorkBoard-BDerd2KC.js → ProjectWorkBoard-_Gx9gO7O.js} +1 -1
- package/dist/assets/{RightWorkbench-ClTIc5yT.js → RightWorkbench-Bx2XueC9.js} +1 -1
- package/dist/assets/{RightWorkbenchSurface-5chVm3Q5.js → RightWorkbenchSurface-C6yJ1qQs.js} +1 -1
- package/dist/assets/Root-BVX9BeqN.js +11 -0
- package/dist/assets/{RunDiagnosticsDialogContent-C83miiCb.js → RunDiagnosticsDialogContent-fFSfsQk9.js} +1 -1
- package/dist/assets/Settings-BP9B8xH8.js +9 -0
- package/dist/assets/{SidebarProjectDrag-B8jeZZwD.js → SidebarProjectDrag-Tr-RiAfv.js} +1 -1
- package/dist/assets/{StreamdownMarkdown-BYrL8Htd.js → StreamdownMarkdown-B9_N1kbO.js} +2 -2
- package/dist/assets/StreamdownMermaid-D1bUSRYY.js +1 -0
- package/dist/assets/{StreamdownMermaid-BqMCspWP.js → StreamdownMermaid-DihA1DWx.js} +1 -1
- package/dist/assets/{SupervisorManagedSessions-DDL1goCC.js → SupervisorManagedSessions-CDSclXHy.js} +1 -1
- package/dist/assets/{SupervisorProjectScopeDialog-BRpx_B7f.js → SupervisorProjectScopeDialog-CqLk6xn2.js} +1 -1
- package/dist/assets/{TicketWorkPanel-CoPV3q8A.js → TicketWorkPanel-_eNUp0U9.js} +1 -1
- package/dist/assets/{WorkflowRunsContent-lUfm3WNf.js → WorkflowRunsContent-BW5KNi4_.js} +1 -1
- package/dist/assets/api-CPcpMjoM.js +1 -0
- package/dist/assets/appStore-DivM-eKj.js +14 -0
- package/dist/assets/{client-IKYlOoXY.js → client-Cxjm7aQO.js} +1 -1
- package/dist/assets/{command-CKwm5a6S.js → command-Cxbz9MXP.js} +3 -3
- package/dist/assets/{composerStyles-t36ulToF.js → composerStyles-BGNR54wZ.js} +1 -1
- package/dist/assets/dist-DRdYZy9Q.js +1 -0
- package/dist/assets/{dropdown-menu-CL18d3V3.js → dropdown-menu-L3Js6izm.js} +1 -1
- package/dist/assets/{en-US-CsZdRXMR.js → en-US-D9PrFi7z.js} +1 -1
- package/dist/assets/floating-ui.dom-BRnbq1vk.js +1 -0
- package/dist/assets/{index-BziNk-bd.js → index-CHQa-Zcr.js} +3 -3
- package/dist/assets/{jianduMemoryApi-o1cxvito.js → jianduMemoryApi-Bg3hZQEs.js} +1 -1
- package/dist/assets/{managedSessions-Df_XdXaQ.js → managedSessions-CyG8WTnE.js} +2 -2
- package/dist/assets/{managedSessions-CNlNA0Gf.js → managedSessions-DoDwGW7n.js} +1 -1
- package/dist/assets/{popover-NRuw3aPJ.js → popover-Cu0Q3dYz.js} +1 -1
- package/dist/assets/{project-EohCp9v3.js → project-Bes6r3Er.js} +1 -1
- package/dist/assets/{renderPdf-Cug6wuGM.js → renderPdf-md4Uxowu.js} +1 -1
- package/dist/assets/{responsive-dialog-ChvCU7Pw.js → responsive-dialog-5w1qV2Jr.js} +1 -1
- package/dist/assets/{select-D2Yn2_yL.js → select-CBtmzEvB.js} +1 -1
- package/dist/assets/{sessionLabels-CKjmBG2k.js → sessionLabels-CEwTJAqp.js} +1 -1
- package/dist/assets/shim-B7rqb4U2.js +1 -0
- package/dist/assets/{state-BgzWNmJm.js → state-BjHHK7Ni.js} +1 -1
- package/dist/assets/{ticketWorkLabels-tosshWRq.js → ticketWorkLabels-BNVpjOJX.js} +1 -1
- package/dist/assets/{ui-DQy0lUHc.js → ui-OvgR8HKW.js} +3 -3
- package/dist/assets/{useBrowserSession-DTq2injR.js → useBrowserSession-CA0yWm0c.js} +1 -1
- package/dist/assets/{useWorkflowCatalog-B3e4h1Zh.js → useWorkflowCatalog-BlIMJrl3.js} +1 -1
- package/dist/assets/{zh-CN-M8nOhM1r.js → zh-CN-CGY2FZ8_.js} +1 -1
- package/dist/bundle-ownership.json +114 -95
- package/dist/index.html +1 -1
- package/dist/lotus-next-manifest.json +144 -129
- package/package.json +1 -1
- package/dist/assets/ErrorBoundary-DrkdmL6R.js +0 -1
- package/dist/assets/Markdown-sn8uDNJU.js +0 -2
- package/dist/assets/MermaidChart-CK128dqg.js +0 -1
- package/dist/assets/Root-Cbi1Q37c.js +0 -112
- package/dist/assets/Settings-6l99-5Ca.js +0 -9
- package/dist/assets/StreamdownMermaid-CK128dqg.js +0 -1
- package/dist/assets/api-dae15_RX.js +0 -1
- package/dist/assets/appStore-DJRgb7nl.js +0 -14
- package/dist/assets/dist-gWmr0ziz.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{a as r}from"./ui-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{a as r}from"./ui-OvgR8HKW.js";import{i}from"./appStore-DivM-eKj.js";import{t as a}from"./button-Cfb4l-V4.js";import{i as o,n as s,r as c,t as l}from"./responsive-dialog-5w1qV2Jr.js";var u=e(t(),1),d=n(),f={active_run:`conversation_clear_active_run`,pending_approval:`conversation_clear_pending_approval`,state_unavailable:`conversation_clear_state_unavailable`,authority_conflict:`conversation_clear_authority_conflict`,incompatible:`conversation_clear_incompatible`,unsupported:`conversation_clear_unsupported`,unknown:`conversation_clear_unknown`,readback_failed:`conversation_clear_readback_failed`};function p({sessionId:e,title:t,onClose:n}){let p=r(),m=i(t=>t.conversationClears[e]),h=(0,u.useRef)(!1),g=m?.error===`unknown`||m?.error===`readback_failed`,_=()=>{i.getState().conversationClears[e]?.busy||(i.getState().dismissConversationClear(e),n())},v=async t=>{if(!h.current){h.current=!0;try{let n=i.getState();await(t?g?n.verifyConversationClear(e):n.refreshConversationClear(e):n.clearConversation(e))}catch{}finally{h.current=!1}}};return(0,d.jsx)(l,{open:!0,onOpenChange:e=>{e||_()},children:(0,d.jsxs)(s,{showCloseButton:!m?.busy,dismissable:!m?.busy,className:`gap-3 overflow-y-auto p-4 sm:pb-4 sm:max-w-lg`,children:[(0,d.jsx)(o,{children:p(`conversation_clear_title`)}),(0,d.jsx)(c,{asChild:!0,children:(0,d.jsxs)(`div`,{className:`space-y-2 text-sm text-muted-foreground`,children:[(0,d.jsxs)(`p`,{className:`break-all font-medium text-foreground`,children:[t,` · `,e]}),(0,d.jsx)(`p`,{children:p(`conversation_clear_impact`)}),(0,d.jsx)(`p`,{children:p(`conversation_clear_limits`)})]})}),m?.confirmed?(0,d.jsx)(`p`,{role:`status`,className:`text-sm`,children:p(`conversation_clear_confirmed`)}):null,m?.error?(0,d.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:p(f[m.error])}):null,m?.readbackConfirmed?(0,d.jsx)(`p`,{role:`status`,className:`text-sm`,children:p(`conversation_clear_readback_only`)}):null,m?.refreshFailed?(0,d.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:p(`conversation_clear_refresh_failed`)}):null,(0,d.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,d.jsx)(a,{variant:`secondary`,size:`sm`,disabled:m?.busy,onClick:_,children:m?.confirmed||g?p(`close_3fd47edc`):p(`cancel_2cd0f3be`)}),m?.error?(0,d.jsx)(a,{variant:`outline`,size:`sm`,disabled:m?.busy,onClick:()=>void v(!0),children:m?.busy?p(`processing_d3d21191`):p(`conversation_clear_refresh`)}):null,!g&&!m?.confirmed?(0,d.jsx)(a,{variant:`destructive`,size:`sm`,disabled:m?.busy,onClick:()=>void v(!1),children:m?.busy?p(`processing_d3d21191`):p(`conversation_clear_action`)}):null]})]})})}export{p as ConversationClearDialogContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r,r as i}from"./ui-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r,r as i}from"./ui-OvgR8HKW.js";import{t as a}from"./createLucideIcon-5m7IB1Aa.js";import{t as o}from"./button-Cfb4l-V4.js";var s=a(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),c=a(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),l=e(t(),1),u=n(),d=class extends l.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){let n=this.props.name??`ErrorBoundary`;console.error(`[${n}] Uncaught error:`,e,t),this.props.onError?.(e,t)}handleReset=()=>{this.setState({hasError:!1,error:null})};render(){if(!this.state.hasError)return this.props.children;let{fallback:e}=this.props,t=this.state.error;return typeof e==`function`?e(t,this.handleReset):e===void 0?(0,u.jsx)(f,{error:t,onReset:this.handleReset}):e}};function f({error:e,onReset:t}){r();let[n,a]=(0,l.useState)(!1);return(0,u.jsxs)(`div`,{role:`alert`,className:`flex min-h-[200px] flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,u.jsx)(s,{className:`size-9 text-amber-500`}),(0,u.jsx)(`div`,{className:`text-base font-semibold`,children:i(`something_went_wrong_04c5b397`)}),(0,u.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:i(`this_section_could_not_render_try_again_or_reload_the_p_e644d5da`)}),(0,u.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,u.jsxs)(o,{size:`sm`,onClick:t,children:[(0,u.jsx)(c,{className:`size-4`}),i(`retry_b8784c8d`)]}),(0,u.jsx)(o,{size:`sm`,variant:`ghost`,onClick:()=>a(e=>!e),"aria-expanded":n,children:i(n?`hide_details_2e1b7da4`:`show_details_448d5d38`)})]}),n&&(0,u.jsxs)(`pre`,{className:`mt-2 max-h-[200px] w-full max-w-xl overflow-auto rounded-md bg-muted p-3 text-left text-xs`,children:[e.message,e.stack?`\n\n${e.stack}`:``]})]})}export{c as n,s as r,d as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./ErrorBoundary-Dvuhdy_Q.js";export{e as ErrorBoundary,e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r,r as i}from"./ui-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r,r as i}from"./ui-OvgR8HKW.js";import{t as a}from"./earth-CjVWVKTC.js";import{s as o}from"./dist-DRdYZy9Q.js";import{n as s,r as c,t as l,u}from"./dropdown-menu-L3Js6izm.js";import{t as d}from"./copy-DmHig_f7.js";import{t as f}from"./external-link-zzXjsZJY.js";import{t as p}from"./clipboard-CyQ_pZV9.js";import{t as m}from"./button-Cfb4l-V4.js";import{a as h,n as g,o as _,r as v,t as y}from"./dialog-CfOua_Le.js";import{r as b}from"./FileOperationsService-XcscMou0.js";var x=e(t(),1),S=()=>window.__TAURI_INTERNALS__?.invoke,C=e=>{if(typeof window>`u`)return;let t=window.open(e,`_blank`,`noopener,noreferrer`);if(t){t.opener=null;return}window.location.assign(e)},w=async e=>{let t=e.trim();if(t){if(b()){let e=S();if(typeof e!=`function`)throw Error(`Desktop shell is unavailable`);await e(`plugin:shell|open`,{path:t});return}C(t)}},T=async e=>{let t=e.trim();if(!t)throw Error(i(`this_project_has_no_primary_directory_configured_1b81c32a`));if(!b())throw Error(i(`open_the_local_directory_in_the_bodhi_desktop_app_74255b08`));let n=S();if(typeof n!=`function`)throw Error(i(`desktop_file_manager_is_temporarily_unavailable_331d04fe`));await n(`plugin:shell|open`,{path:t})},E=n(),D=(0,x.createContext)(null),O=e=>{try{let t=new URL(e);return(t.protocol===`http:`||t.protocol===`https:`)&&!!t.hostname}catch{return!1}};function k({children:e,onOpenInApp:t}){return r(),(0,E.jsx)(D.Provider,{value:t??null,children:e})}function A({url:e,isOpen:t,onClose:n}){r();let b=(0,x.useContext)(D),[S,C]=(0,x.useState)(!1),[T,k]=(0,x.useState)(null),A=async(e,t)=>{if(!S){C(!0),k(null);try{await e(),n()}catch{k(t)}finally{C(!1)}}};return(0,E.jsx)(y,{open:t,onOpenChange:e=>{!e&&!S&&n()},children:(0,E.jsxs)(g,{className:`max-w-md`,"data-streamdown":`link-safety-modal`,children:[(0,E.jsxs)(h,{children:[(0,E.jsxs)(_,{className:`flex items-center gap-2`,children:[(0,E.jsx)(f,{className:`size-5`}),i(`open_external_link_fd407c70`)]}),(0,E.jsx)(v,{children:i(`you_are_about_to_visit_an_external_website_d5fdb530`)})]}),(0,E.jsx)(`div`,{className:`max-h-32 overflow-y-auto break-all rounded-md bg-muted p-3 font-mono text-sm`,children:e}),T?(0,E.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:T}):null,(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsxs)(m,{className:`min-w-0 flex-1`,disabled:S,variant:`outline`,onClick:()=>void A(()=>p(e),i(`could_not_copy_link_please_try_again_c54af852`)),children:[(0,E.jsx)(d,{}),i(`copy_link_8e86f9b1`)]}),(0,E.jsxs)(l,{modal:!1,children:[(0,E.jsx)(u,{asChild:!0,children:(0,E.jsxs)(m,{className:`min-w-0 flex-1`,disabled:S,children:[i(`open_link_a2639495`),` `,(0,E.jsx)(o,{})]})}),(0,E.jsxs)(s,{align:`end`,className:`min-w-48`,style:{zIndex:60},children:[b&&O(e)?(0,E.jsxs)(c,{onSelect:()=>void A(()=>b(e),i(`could_not_open_the_link_in_the_app_please_try_again_769b498f`)),children:[(0,E.jsx)(a,{}),i(`open_in_app_af4b79db`)]}):null,(0,E.jsxs)(c,{onSelect:()=>void A(()=>w(e),i(`could_not_open_the_link_in_your_default_browser_please__14278433`)),children:[(0,E.jsx)(f,{}),i(`open_in_default_browser_a489338a`)]})]})]})]})]})})}export{k as n,T as r,A as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{u as r}from"./ui-DQy0lUHc.js";import{t as i}from"./input-DWysC80E.js";import{a,i as o,n as s,r as c,s as l,t as ee}from"./select-D2Yn2_yL.js";import{i as te}from"./appStore-DJRgb7nl.js";import{t as u}from"./button-Cfb4l-V4.js";import{i as ne,n as re,r as ie,t as ae}from"./responsive-dialog-ChvCU7Pw.js";import{t as oe}from"./textarea-BKzYyWL5.js";import{a as d,c as se,i as ce,l as le,n as ue,o as de,s as fe,t as pe,u as f}from"./jianduMemoryApi-o1cxvito.js";var p=e(t(),1),m=n(),h={title:``,type:`project`,content:``,tags:``,keywords:``,entities:``,granularity:``},g=e=>{if(!(e instanceof d))return`unavailable`;switch(e.code){case`invalid_input`:return`invalid`;case`context_unavailable`:return`context`;case`access_denied`:return`denied`;case`action_rejected`:return`rejected`;case`malformed_response`:return`malformed`;case`request_failed`:return`unavailable`}},_=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),me=e=>({title:e.title,type:e.type,content:e.content,tags:_(e.tags),keywords:_(e.keywords),entities:_(e.entities),...e.granularity?{granularity:e.granularity}:{}}),he=(e,t)=>{let n=new Map(e.map(e=>[e.id,e]));return t.forEach(e=>n.set(e.id,e)),[...n.values()]};function v({api:e=fe}){let{t}=r(),n=te(e=>e.currentSessionId),d=(0,p.useRef)(n);d.current=n;let _=(0,p.useRef)(0),v=(0,p.useRef)(0),y=(0,p.useRef)(0),b=(0,p.useRef)(0),x=(0,p.useRef)(0),[ge,_e]=(0,p.useState)(0),[S,ve]=(0,p.useState)(null),[ye,C]=(0,p.useState)(!1),[be,w]=(0,p.useState)(null),[xe,T]=(0,p.useState)(``),[E,Se]=(0,p.useState)(``),[Ce,we]=(0,p.useState)(`active`),[D,Te]=(0,p.useState)(`active`),[Ee,O]=(0,p.useState)([]),[k,A]=(0,p.useState)(null),[j,M]=(0,p.useState)(!1),[De,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(null),[Oe,I]=(0,p.useState)(null),[ke,L]=(0,p.useState)(null),[Ae,R]=(0,p.useState)(!1),[z,B]=(0,p.useState)(h),[V,H]=(0,p.useState)(null),[je,U]=(0,p.useState)(!1),[Me,W]=(0,p.useState)(null),[G,K]=(0,p.useState)(null),[Ne,q]=(0,p.useState)(null),[Pe,J]=(0,p.useState)(null),[Fe,Y]=(0,p.useState)(null),X=(0,p.useCallback)(async(t,n,r,i,a,o)=>{let s=++v.current;M(!0),N(null);try{let c=await e.queryProjectMemories(t,{query:n,filters:{status:[r]},...i?{cursor:i}:{}});return _.current!==o||v.current!==s?`stale`:(O(e=>a?he(e,c.items):c.items),A(c),`ok`)}catch(e){return _.current!==o||v.current!==s?`stale`:(N(g(e)),a||(O([]),A(null)),`failed`)}finally{_.current===o&&v.current===s&&M(!1)}},[e]),Ie=(0,p.useCallback)(e=>{let t=_.current;t===e&&(_.current=t+1)},[]);(0,p.useEffect)(()=>{let t=++_.current;if(++v.current,++y.current,++b.current,++x.current,ve(null),w(null),C(!!n),T(``),Se(``),we(`active`),Te(`active`),O([]),A(null),N(null),M(!1),F(null),I(null),L(null),R(!1),B(h),H(null),U(!1),W(null),K(null),q(null),J(null),Y(null),!n){w(`context`);return}return e.resolveProjectContext(n).then(e=>{_.current!==t||d.current!==n||(ve(e),C(!1),X(e,``,`active`,void 0,!1,t))}).catch(e=>{_.current!==t||d.current!==n||(C(!1),w(g(e)))}),()=>Ie(t)},[e,n,Ie,X,ge]);let Le=(0,p.useCallback)(e=>{++_.current,++v.current,++y.current,++b.current,++x.current,ve(null),T(``),Se(``),we(`active`),Te(`active`),O([]),A(null),M(!1),N(null),F(null),I(null),L(null),R(!1),B(h),H(null),U(!1),W(null),K(null),q(null),J(null),Y(null),w(e),C(!1)},[]),Re=(0,p.useCallback)(async(t,n)=>{let r=d.current;if(!r||_.current!==n)return null;try{let i=await e.resolveProjectContext(r);return _.current!==n||d.current!==r?null:le(t,i)?i:(Le(`context`),null)}catch(e){return _.current===n&&Le(g(e)),null}},[e,Le]),ze=()=>{if(!S)return;let e=xe.trim(),t=Ce;Se(e),Te(t),Y(null),X(S,e,t,void 0,!1,_.current)},Be=async t=>{if(!S)return;let n=++y.current,r=_.current;F(null),L(null),I(t.id);try{let i=await e.getProjectMemory(S,t.id);if(_.current!==r||y.current!==n)return;F(i)}catch(e){_.current===r&&y.current===n&&L(g(e))}finally{_.current===r&&y.current===n&&I(null)}},Ve=()=>{++y.current,F(null),L(null),I(null),q(null),J(null)},He=(0,p.useMemo)(()=>JSON.stringify(z),[z]),Z=(e,t)=>{++b.current,B(n=>({...n,[e]:t})),H(null),U(!1),W(null)},Ue=()=>{B(h),H(null),W(null),R(!0)},We=()=>{G!==`create`&&(++b.current,R(!1),B(h),H(null),W(null))},Ge=async()=>{if(!S||je||G)return;let t=me(z);try{se(t)}catch(e){W(g(e));return}let n=He,r=++b.current,i=_.current;U(!0),H(null),W(null);try{let a=await e.queryProjectMemories(S,{query:``,limit:1});if(_.current!==i||b.current!==r)return;let o=a.matchedCount===0?a:await e.queryProjectMemories(S,{query:de(t),limit:5});if(_.current!==i||b.current!==r)return;H({fingerprint:n,items:o.items,truncated:o.truncated})}catch(e){_.current===i&&b.current===r&&W(g(e))}finally{_.current===i&&b.current===r&&U(!1)}},Ke=async()=>{if(!S||G||!V||V.fingerprint!==He)return;let t=me(z);try{se(t)}catch(e){W(g(e));return}let n=_.current,r=++x.current;K(`create`),W(null);let i=await Re(S,n);if(!i||_.current!==n||x.current!==r){x.current===r&&K(null);return}try{let a=await e.createProjectMemory(i,t);if(_.current!==n||x.current!==r)return;R(!1),H(null),Y({kind:`created`,title:a.title}),await X(i,E,D,void 0,!1,n)===`failed`&&x.current===r&&Y({kind:`createdRefreshFailed`,title:a.title})}catch(e){_.current===n&&x.current===r&&W(g(e))}finally{_.current===n&&x.current===r&&K(null)}},qe=async()=>{let t=Ne;if(!S||!t||G)return;let n=_.current,r=++x.current;K(`archive`),J(null);let i=await Re(S,n);if(!i||_.current!==n||x.current!==r){x.current===r&&K(null);return}try{if(await e.archiveProjectMemory(i,t.id),_.current!==n||x.current!==r)return;q(null),Ve(),Y({kind:`archived`,title:t.title}),await X(i,E,D,void 0,!1,n)===`failed`&&x.current===r&&Y({kind:`archivedRefreshFailed`,title:t.title})}catch(e){_.current===n&&x.current===r&&J(g(e))}finally{_.current===n&&x.current===r&&K(null)}},Q=e=>t(`settings.jiandu.errors.${e}`),Je=e=>t(`settings.jiandu.types.${e}`),$=e=>t(`settings.jiandu.statuses.${e}`);return(0,m.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4`,children:[(0,m.jsx)(`header`,{className:`space-y-1`,children:(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h2`,{className:`text-lg font-semibold`,children:t(`settings.jiandu.title`)}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings.jiandu.description`)})]}),(0,m.jsx)(u,{onClick:Ue,disabled:!S||ye,children:t(`settings.jiandu.create.open`)})]})}),(0,m.jsxs)(`section`,{className:`rounded-lg border p-3`,"aria-label":t(`settings.jiandu.context.label`),children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:t(`settings.jiandu.context.label`)}),ye?(0,m.jsx)(`p`,{className:`mt-1 text-sm`,children:t(`settings.jiandu.context.loading`)}):S?(0,m.jsxs)(`dl`,{className:`mt-2 grid gap-2 text-sm sm:grid-cols-2`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.context.session`)}),(0,m.jsx)(`dd`,{className:`break-words font-medium`,children:S.activeSessionTitle})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.context.project`)}),(0,m.jsx)(`dd`,{className:`break-all font-mono text-xs`,children:S.projectId})]}),S.activeSessionId===S.authoritySessionId?null:(0,m.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,m.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.context.rootSession`)}),(0,m.jsx)(`dd`,{children:S.authoritySessionTitle})]})]}):(0,m.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(be??`context`)}),n?(0,m.jsx)(u,{variant:`outline`,size:`sm`,onClick:()=>_e(e=>e+1),children:t(`settings.jiandu.context.retry`)}):null]})]}),Fe?(0,m.jsx)(`p`,{role:`status`,className:`rounded-lg border border-primary/30 bg-primary/5 p-3 text-sm`,children:t(`settings.jiandu.notices.${Fe.kind}`,{title:Fe.title})}):null,S?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:e=>{e.preventDefault(),ze()},children:[(0,m.jsx)(i,{"aria-label":t(`settings.jiandu.search.label`),value:xe,maxLength:ue.queryChars,onChange:e=>T(e.target.value),placeholder:t(`settings.jiandu.search.placeholder`)}),(0,m.jsxs)(ee,{value:Ce,disabled:j,onValueChange:e=>we(e),children:[(0,m.jsx)(o,{className:`w-full sm:w-36`,"aria-label":t(`settings.jiandu.search.statusLabel`),children:(0,m.jsx)(a,{})}),(0,m.jsxs)(s,{className:`z-[150]`,children:[(0,m.jsx)(c,{value:`active`,children:$(`active`)}),(0,m.jsx)(c,{value:`archived`,children:$(`archived`)})]})]}),(0,m.jsx)(u,{type:`submit`,disabled:j,children:t(`settings.jiandu.search.action`)}),(0,m.jsx)(u,{type:`button`,variant:`outline`,disabled:j,onClick:()=>void X(S,E,D,void 0,!1,_.current),children:t(`settings.jiandu.search.refresh`)})]}),De?(0,m.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-destructive/40 p-3 text-sm text-destructive`,children:Q(De)}):null,k?(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,m.jsx)(`span`,{children:t(`settings.jiandu.list.count`,{visible:Ee.length,matched:k.matchedCount})}),k.truncated?(0,m.jsx)(`span`,{children:t(`settings.jiandu.list.truncated`)}):null,k.remainingCount>0?(0,m.jsx)(`span`,{children:t(`settings.jiandu.list.remaining`,{count:k.remainingCount})}):null]}):null,Ee.length>0?(0,m.jsx)(`ul`,{className:`space-y-2`,"aria-label":t(`settings.jiandu.list.label`),children:Ee.map(e=>(0,m.jsxs)(`li`,{className:`rounded-lg border p-3`,children:[(0,m.jsx)(`button`,{type:`button`,className:`max-w-full break-words text-left text-sm font-semibold hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,disabled:Oe===e.id,onClick:()=>void Be(e),children:e.title}),(0,m.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,m.jsx)(l,{variant:`outline`,children:Je(e.type)}),(0,m.jsx)(l,{variant:e.status===`archived`?`secondary`:`outline`,children:$(e.status)}),e.granularity?(0,m.jsx)(l,{variant:`outline`,children:e.granularity}):null]}),(0,m.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-muted-foreground`,children:e.summary})]},e.id))}):k&&!j?(0,m.jsx)(`p`,{className:`rounded-lg border p-4 text-sm text-muted-foreground`,children:t(`settings.jiandu.list.empty`)}):null,j?(0,m.jsx)(`p`,{role:`status`,children:t(`settings.jiandu.list.loading`)}):null,k?.nextCursor?(0,m.jsx)(u,{variant:`outline`,className:`w-full`,disabled:j,onClick:()=>void X(S,E,D,k.nextCursor,!0,_.current),children:t(`settings.jiandu.list.more`)}):null]}):null,(0,m.jsx)(ae,{open:!!(P||Oe||ke),onOpenChange:e=>e?null:Ve(),children:(0,m.jsxs)(re,{showCloseButton:!1,className:`gap-4 p-5 sm:max-w-2xl`,children:[(0,m.jsx)(ne,{children:P?.title??t(`settings.jiandu.detail.title`)}),Oe?(0,m.jsx)(`p`,{role:`status`,children:t(`settings.jiandu.detail.loading`)}):null,ke?(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(ke)}):null,P?(0,m.jsxs)(`div`,{className:`min-h-0 space-y-3 overflow-y-auto`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,m.jsx)(l,{variant:`outline`,children:Je(P.type)}),(0,m.jsx)(l,{variant:P.status===`archived`?`secondary`:`outline`,children:$(P.status)})]}),P.bodyTruncated||P.retrievalMetadataTruncated?(0,m.jsx)(`p`,{role:`status`,className:`text-xs text-amber-600 dark:text-amber-400`,children:P.bodyTruncated?t(`settings.jiandu.detail.bodyTruncated`):t(`settings.jiandu.detail.metadataTruncated`)}):null,(0,m.jsx)(`pre`,{className:`max-h-[50dvh] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 font-sans text-sm`,children:P.body})]}):null,(0,m.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[P&&P.status!==`archived`?(0,m.jsx)(u,{variant:`destructive`,onClick:()=>{J(null),q(P)},children:t(`settings.jiandu.archive.open`)}):null,(0,m.jsx)(u,{variant:`outline`,onClick:Ve,children:t(`settings.jiandu.detail.close`)})]})]})}),(0,m.jsx)(ae,{open:Ae,onOpenChange:e=>e?null:We(),children:(0,m.jsxs)(re,{showCloseButton:!1,dismissable:G!==`create`,className:`gap-4 p-5 sm:max-w-2xl`,children:[(0,m.jsx)(ne,{children:t(`settings.jiandu.create.title`)}),(0,m.jsx)(ie,{children:t(`settings.jiandu.create.description`)}),(0,m.jsxs)(`div`,{className:`min-h-0 space-y-3 overflow-y-auto pr-1`,children:[(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{htmlFor:`jiandu-title`,children:t(`settings.jiandu.create.titleLabel`)}),(0,m.jsx)(i,{id:`jiandu-title`,value:z.title,maxLength:ue.titleChars,disabled:!!G,onChange:e=>Z(`title`,e.target.value)})]}),(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{children:t(`settings.jiandu.create.typeLabel`)}),(0,m.jsxs)(ee,{value:z.type,disabled:!!G,onValueChange:e=>Z(`type`,e),children:[(0,m.jsx)(o,{className:`w-full`,"aria-label":t(`settings.jiandu.create.typeLabel`),children:(0,m.jsx)(a,{})}),(0,m.jsx)(s,{className:`z-[150]`,children:ce.map(e=>(0,m.jsx)(c,{value:e,children:Je(e)},e))})]})]}),(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{htmlFor:`jiandu-body`,children:t(`settings.jiandu.create.bodyLabel`)}),(0,m.jsx)(oe,{id:`jiandu-body`,rows:7,value:z.content,maxLength:ue.bodyChars,disabled:!!G,onChange:e=>Z(`content`,e.target.value)})]}),(0,m.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`tags`,`keywords`,`entities`].map(e=>(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{htmlFor:`jiandu-${e}`,children:t(`settings.jiandu.create.${e}Label`)}),(0,m.jsx)(i,{id:`jiandu-${e}`,value:z[e],disabled:!!G,onChange:t=>Z(e,t.target.value),placeholder:t(`settings.jiandu.create.csvHint`)})]},e)),(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{children:t(`settings.jiandu.create.granularityLabel`)}),(0,m.jsxs)(ee,{value:z.granularity||`none`,disabled:!!G,onValueChange:e=>Z(`granularity`,e===`none`?``:e),children:[(0,m.jsx)(o,{className:`w-full`,"aria-label":t(`settings.jiandu.create.granularityLabel`),children:(0,m.jsx)(a,{})}),(0,m.jsxs)(s,{className:`z-[150]`,children:[(0,m.jsx)(c,{value:`none`,children:t(`settings.jiandu.create.noGranularity`)}),pe.map(e=>(0,m.jsx)(c,{value:e,children:e},e))]})]})]})]}),Me?(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(Me)}):null,V?(0,m.jsxs)(`section`,{className:`rounded-lg border p-3`,"aria-label":t(`settings.jiandu.create.matchesLabel`),children:[(0,m.jsx)(`h3`,{className:`text-sm font-medium`,children:V.items.length>0?t(`settings.jiandu.create.matches`):t(`settings.jiandu.create.noMatches`)}),V.items.length>0?(0,m.jsx)(`ul`,{className:`mt-2 space-y-1 text-sm`,children:V.items.map(e=>(0,m.jsxs)(`li`,{children:[e.title,` · `,$(e.status)]},e.id))}):null,V.truncated?(0,m.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:t(`settings.jiandu.create.matchesTruncated`)}):null]}):null]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,m.jsx)(u,{variant:`outline`,disabled:G===`create`,onClick:We,children:t(`settings.jiandu.create.close`)}),(0,m.jsx)(u,{variant:`secondary`,disabled:je||!!G,onClick:()=>void Ge(),children:t(je?`settings.jiandu.create.lookingUp`:`settings.jiandu.create.lookup`)}),(0,m.jsx)(u,{disabled:G===`create`||!V||V.fingerprint!==He,onClick:()=>void Ke(),children:t(G===`create`?`settings.jiandu.create.creating`:`settings.jiandu.create.confirm`)})]})]})}),(0,m.jsx)(ae,{open:!!Ne,onOpenChange:e=>{!e&&G!==`archive`&&(q(null),J(null))},children:(0,m.jsxs)(re,{showCloseButton:!1,dismissable:G!==`archive`,className:`gap-4 p-5`,children:[(0,m.jsx)(ne,{children:t(`settings.jiandu.archive.title`,{title:Ne?.title??``})}),(0,m.jsx)(ie,{children:t(`settings.jiandu.archive.description`)}),Pe?(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(Pe)}):null,(0,m.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,m.jsx)(u,{variant:`outline`,disabled:G===`archive`,onClick:()=>{q(null),J(null)},children:t(`settings.jiandu.archive.cancel`)}),(0,m.jsx)(u,{variant:`destructive`,disabled:G===`archive`,onClick:()=>void qe(),children:t(G===`archive`?`settings.jiandu.archive.archiving`:`settings.jiandu.archive.confirm`)})]})]})})]})}export{v as JianduProjectMemories};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{u as r}from"./ui-OvgR8HKW.js";import{t as i}from"./input-DWysC80E.js";import{a,i as o,n as s,r as c,s as l,t as ee}from"./select-CBtmzEvB.js";import{i as te}from"./appStore-DivM-eKj.js";import{t as u}from"./button-Cfb4l-V4.js";import{i as ne,n as re,r as ie,t as ae}from"./responsive-dialog-5w1qV2Jr.js";import{t as oe}from"./textarea-BKzYyWL5.js";import{a as d,c as se,i as ce,l as le,n as ue,o as de,s as fe,t as pe,u as f}from"./jianduMemoryApi-Bg3hZQEs.js";var p=e(t(),1),m=n(),h={title:``,type:`project`,content:``,tags:``,keywords:``,entities:``,granularity:``},g=e=>{if(!(e instanceof d))return`unavailable`;switch(e.code){case`invalid_input`:return`invalid`;case`context_unavailable`:return`context`;case`access_denied`:return`denied`;case`action_rejected`:return`rejected`;case`malformed_response`:return`malformed`;case`request_failed`:return`unavailable`}},_=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),me=e=>({title:e.title,type:e.type,content:e.content,tags:_(e.tags),keywords:_(e.keywords),entities:_(e.entities),...e.granularity?{granularity:e.granularity}:{}}),he=(e,t)=>{let n=new Map(e.map(e=>[e.id,e]));return t.forEach(e=>n.set(e.id,e)),[...n.values()]};function v({api:e=fe}){let{t}=r(),n=te(e=>e.currentSessionId),d=(0,p.useRef)(n);d.current=n;let _=(0,p.useRef)(0),v=(0,p.useRef)(0),y=(0,p.useRef)(0),b=(0,p.useRef)(0),x=(0,p.useRef)(0),[ge,_e]=(0,p.useState)(0),[S,ve]=(0,p.useState)(null),[ye,C]=(0,p.useState)(!1),[be,w]=(0,p.useState)(null),[xe,T]=(0,p.useState)(``),[E,Se]=(0,p.useState)(``),[Ce,we]=(0,p.useState)(`active`),[D,Te]=(0,p.useState)(`active`),[Ee,O]=(0,p.useState)([]),[k,A]=(0,p.useState)(null),[j,M]=(0,p.useState)(!1),[De,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(null),[Oe,I]=(0,p.useState)(null),[ke,L]=(0,p.useState)(null),[Ae,R]=(0,p.useState)(!1),[z,B]=(0,p.useState)(h),[V,H]=(0,p.useState)(null),[je,U]=(0,p.useState)(!1),[Me,W]=(0,p.useState)(null),[G,K]=(0,p.useState)(null),[Ne,q]=(0,p.useState)(null),[Pe,J]=(0,p.useState)(null),[Fe,Y]=(0,p.useState)(null),X=(0,p.useCallback)(async(t,n,r,i,a,o)=>{let s=++v.current;M(!0),N(null);try{let c=await e.queryProjectMemories(t,{query:n,filters:{status:[r]},...i?{cursor:i}:{}});return _.current!==o||v.current!==s?`stale`:(O(e=>a?he(e,c.items):c.items),A(c),`ok`)}catch(e){return _.current!==o||v.current!==s?`stale`:(N(g(e)),a||(O([]),A(null)),`failed`)}finally{_.current===o&&v.current===s&&M(!1)}},[e]),Ie=(0,p.useCallback)(e=>{let t=_.current;t===e&&(_.current=t+1)},[]);(0,p.useEffect)(()=>{let t=++_.current;if(++v.current,++y.current,++b.current,++x.current,ve(null),w(null),C(!!n),T(``),Se(``),we(`active`),Te(`active`),O([]),A(null),N(null),M(!1),F(null),I(null),L(null),R(!1),B(h),H(null),U(!1),W(null),K(null),q(null),J(null),Y(null),!n){w(`context`);return}return e.resolveProjectContext(n).then(e=>{_.current!==t||d.current!==n||(ve(e),C(!1),X(e,``,`active`,void 0,!1,t))}).catch(e=>{_.current!==t||d.current!==n||(C(!1),w(g(e)))}),()=>Ie(t)},[e,n,Ie,X,ge]);let Le=(0,p.useCallback)(e=>{++_.current,++v.current,++y.current,++b.current,++x.current,ve(null),T(``),Se(``),we(`active`),Te(`active`),O([]),A(null),M(!1),N(null),F(null),I(null),L(null),R(!1),B(h),H(null),U(!1),W(null),K(null),q(null),J(null),Y(null),w(e),C(!1)},[]),Re=(0,p.useCallback)(async(t,n)=>{let r=d.current;if(!r||_.current!==n)return null;try{let i=await e.resolveProjectContext(r);return _.current!==n||d.current!==r?null:le(t,i)?i:(Le(`context`),null)}catch(e){return _.current===n&&Le(g(e)),null}},[e,Le]),ze=()=>{if(!S)return;let e=xe.trim(),t=Ce;Se(e),Te(t),Y(null),X(S,e,t,void 0,!1,_.current)},Be=async t=>{if(!S)return;let n=++y.current,r=_.current;F(null),L(null),I(t.id);try{let i=await e.getProjectMemory(S,t.id);if(_.current!==r||y.current!==n)return;F(i)}catch(e){_.current===r&&y.current===n&&L(g(e))}finally{_.current===r&&y.current===n&&I(null)}},Ve=()=>{++y.current,F(null),L(null),I(null),q(null),J(null)},He=(0,p.useMemo)(()=>JSON.stringify(z),[z]),Z=(e,t)=>{++b.current,B(n=>({...n,[e]:t})),H(null),U(!1),W(null)},Ue=()=>{B(h),H(null),W(null),R(!0)},We=()=>{G!==`create`&&(++b.current,R(!1),B(h),H(null),W(null))},Ge=async()=>{if(!S||je||G)return;let t=me(z);try{se(t)}catch(e){W(g(e));return}let n=He,r=++b.current,i=_.current;U(!0),H(null),W(null);try{let a=await e.queryProjectMemories(S,{query:``,limit:1});if(_.current!==i||b.current!==r)return;let o=a.matchedCount===0?a:await e.queryProjectMemories(S,{query:de(t),limit:5});if(_.current!==i||b.current!==r)return;H({fingerprint:n,items:o.items,truncated:o.truncated})}catch(e){_.current===i&&b.current===r&&W(g(e))}finally{_.current===i&&b.current===r&&U(!1)}},Ke=async()=>{if(!S||G||!V||V.fingerprint!==He)return;let t=me(z);try{se(t)}catch(e){W(g(e));return}let n=_.current,r=++x.current;K(`create`),W(null);let i=await Re(S,n);if(!i||_.current!==n||x.current!==r){x.current===r&&K(null);return}try{let a=await e.createProjectMemory(i,t);if(_.current!==n||x.current!==r)return;R(!1),H(null),Y({kind:`created`,title:a.title}),await X(i,E,D,void 0,!1,n)===`failed`&&x.current===r&&Y({kind:`createdRefreshFailed`,title:a.title})}catch(e){_.current===n&&x.current===r&&W(g(e))}finally{_.current===n&&x.current===r&&K(null)}},qe=async()=>{let t=Ne;if(!S||!t||G)return;let n=_.current,r=++x.current;K(`archive`),J(null);let i=await Re(S,n);if(!i||_.current!==n||x.current!==r){x.current===r&&K(null);return}try{if(await e.archiveProjectMemory(i,t.id),_.current!==n||x.current!==r)return;q(null),Ve(),Y({kind:`archived`,title:t.title}),await X(i,E,D,void 0,!1,n)===`failed`&&x.current===r&&Y({kind:`archivedRefreshFailed`,title:t.title})}catch(e){_.current===n&&x.current===r&&J(g(e))}finally{_.current===n&&x.current===r&&K(null)}},Q=e=>t(`settings.jiandu.errors.${e}`),Je=e=>t(`settings.jiandu.types.${e}`),$=e=>t(`settings.jiandu.statuses.${e}`);return(0,m.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4`,children:[(0,m.jsx)(`header`,{className:`space-y-1`,children:(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h2`,{className:`text-lg font-semibold`,children:t(`settings.jiandu.title`)}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`settings.jiandu.description`)})]}),(0,m.jsx)(u,{onClick:Ue,disabled:!S||ye,children:t(`settings.jiandu.create.open`)})]})}),(0,m.jsxs)(`section`,{className:`rounded-lg border p-3`,"aria-label":t(`settings.jiandu.context.label`),children:[(0,m.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:t(`settings.jiandu.context.label`)}),ye?(0,m.jsx)(`p`,{className:`mt-1 text-sm`,children:t(`settings.jiandu.context.loading`)}):S?(0,m.jsxs)(`dl`,{className:`mt-2 grid gap-2 text-sm sm:grid-cols-2`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.context.session`)}),(0,m.jsx)(`dd`,{className:`break-words font-medium`,children:S.activeSessionTitle})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.context.project`)}),(0,m.jsx)(`dd`,{className:`break-all font-mono text-xs`,children:S.projectId})]}),S.activeSessionId===S.authoritySessionId?null:(0,m.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,m.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:t(`settings.jiandu.context.rootSession`)}),(0,m.jsx)(`dd`,{children:S.authoritySessionTitle})]})]}):(0,m.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(be??`context`)}),n?(0,m.jsx)(u,{variant:`outline`,size:`sm`,onClick:()=>_e(e=>e+1),children:t(`settings.jiandu.context.retry`)}):null]})]}),Fe?(0,m.jsx)(`p`,{role:`status`,className:`rounded-lg border border-primary/30 bg-primary/5 p-3 text-sm`,children:t(`settings.jiandu.notices.${Fe.kind}`,{title:Fe.title})}):null,S?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:e=>{e.preventDefault(),ze()},children:[(0,m.jsx)(i,{"aria-label":t(`settings.jiandu.search.label`),value:xe,maxLength:ue.queryChars,onChange:e=>T(e.target.value),placeholder:t(`settings.jiandu.search.placeholder`)}),(0,m.jsxs)(ee,{value:Ce,disabled:j,onValueChange:e=>we(e),children:[(0,m.jsx)(o,{className:`w-full sm:w-36`,"aria-label":t(`settings.jiandu.search.statusLabel`),children:(0,m.jsx)(a,{})}),(0,m.jsxs)(s,{className:`z-[150]`,children:[(0,m.jsx)(c,{value:`active`,children:$(`active`)}),(0,m.jsx)(c,{value:`archived`,children:$(`archived`)})]})]}),(0,m.jsx)(u,{type:`submit`,disabled:j,children:t(`settings.jiandu.search.action`)}),(0,m.jsx)(u,{type:`button`,variant:`outline`,disabled:j,onClick:()=>void X(S,E,D,void 0,!1,_.current),children:t(`settings.jiandu.search.refresh`)})]}),De?(0,m.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-destructive/40 p-3 text-sm text-destructive`,children:Q(De)}):null,k?(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,m.jsx)(`span`,{children:t(`settings.jiandu.list.count`,{visible:Ee.length,matched:k.matchedCount})}),k.truncated?(0,m.jsx)(`span`,{children:t(`settings.jiandu.list.truncated`)}):null,k.remainingCount>0?(0,m.jsx)(`span`,{children:t(`settings.jiandu.list.remaining`,{count:k.remainingCount})}):null]}):null,Ee.length>0?(0,m.jsx)(`ul`,{className:`space-y-2`,"aria-label":t(`settings.jiandu.list.label`),children:Ee.map(e=>(0,m.jsxs)(`li`,{className:`rounded-lg border p-3`,children:[(0,m.jsx)(`button`,{type:`button`,className:`max-w-full break-words text-left text-sm font-semibold hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,disabled:Oe===e.id,onClick:()=>void Be(e),children:e.title}),(0,m.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,m.jsx)(l,{variant:`outline`,children:Je(e.type)}),(0,m.jsx)(l,{variant:e.status===`archived`?`secondary`:`outline`,children:$(e.status)}),e.granularity?(0,m.jsx)(l,{variant:`outline`,children:e.granularity}):null]}),(0,m.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-muted-foreground`,children:e.summary})]},e.id))}):k&&!j?(0,m.jsx)(`p`,{className:`rounded-lg border p-4 text-sm text-muted-foreground`,children:t(`settings.jiandu.list.empty`)}):null,j?(0,m.jsx)(`p`,{role:`status`,children:t(`settings.jiandu.list.loading`)}):null,k?.nextCursor?(0,m.jsx)(u,{variant:`outline`,className:`w-full`,disabled:j,onClick:()=>void X(S,E,D,k.nextCursor,!0,_.current),children:t(`settings.jiandu.list.more`)}):null]}):null,(0,m.jsx)(ae,{open:!!(P||Oe||ke),onOpenChange:e=>e?null:Ve(),children:(0,m.jsxs)(re,{showCloseButton:!1,className:`gap-4 p-5 sm:max-w-2xl`,children:[(0,m.jsx)(ne,{children:P?.title??t(`settings.jiandu.detail.title`)}),Oe?(0,m.jsx)(`p`,{role:`status`,children:t(`settings.jiandu.detail.loading`)}):null,ke?(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(ke)}):null,P?(0,m.jsxs)(`div`,{className:`min-h-0 space-y-3 overflow-y-auto`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,m.jsx)(l,{variant:`outline`,children:Je(P.type)}),(0,m.jsx)(l,{variant:P.status===`archived`?`secondary`:`outline`,children:$(P.status)})]}),P.bodyTruncated||P.retrievalMetadataTruncated?(0,m.jsx)(`p`,{role:`status`,className:`text-xs text-amber-600 dark:text-amber-400`,children:P.bodyTruncated?t(`settings.jiandu.detail.bodyTruncated`):t(`settings.jiandu.detail.metadataTruncated`)}):null,(0,m.jsx)(`pre`,{className:`max-h-[50dvh] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 font-sans text-sm`,children:P.body})]}):null,(0,m.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[P&&P.status!==`archived`?(0,m.jsx)(u,{variant:`destructive`,onClick:()=>{J(null),q(P)},children:t(`settings.jiandu.archive.open`)}):null,(0,m.jsx)(u,{variant:`outline`,onClick:Ve,children:t(`settings.jiandu.detail.close`)})]})]})}),(0,m.jsx)(ae,{open:Ae,onOpenChange:e=>e?null:We(),children:(0,m.jsxs)(re,{showCloseButton:!1,dismissable:G!==`create`,className:`gap-4 p-5 sm:max-w-2xl`,children:[(0,m.jsx)(ne,{children:t(`settings.jiandu.create.title`)}),(0,m.jsx)(ie,{children:t(`settings.jiandu.create.description`)}),(0,m.jsxs)(`div`,{className:`min-h-0 space-y-3 overflow-y-auto pr-1`,children:[(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{htmlFor:`jiandu-title`,children:t(`settings.jiandu.create.titleLabel`)}),(0,m.jsx)(i,{id:`jiandu-title`,value:z.title,maxLength:ue.titleChars,disabled:!!G,onChange:e=>Z(`title`,e.target.value)})]}),(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{children:t(`settings.jiandu.create.typeLabel`)}),(0,m.jsxs)(ee,{value:z.type,disabled:!!G,onValueChange:e=>Z(`type`,e),children:[(0,m.jsx)(o,{className:`w-full`,"aria-label":t(`settings.jiandu.create.typeLabel`),children:(0,m.jsx)(a,{})}),(0,m.jsx)(s,{className:`z-[150]`,children:ce.map(e=>(0,m.jsx)(c,{value:e,children:Je(e)},e))})]})]}),(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{htmlFor:`jiandu-body`,children:t(`settings.jiandu.create.bodyLabel`)}),(0,m.jsx)(oe,{id:`jiandu-body`,rows:7,value:z.content,maxLength:ue.bodyChars,disabled:!!G,onChange:e=>Z(`content`,e.target.value)})]}),(0,m.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`tags`,`keywords`,`entities`].map(e=>(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{htmlFor:`jiandu-${e}`,children:t(`settings.jiandu.create.${e}Label`)}),(0,m.jsx)(i,{id:`jiandu-${e}`,value:z[e],disabled:!!G,onChange:t=>Z(e,t.target.value),placeholder:t(`settings.jiandu.create.csvHint`)})]},e)),(0,m.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,m.jsx)(f,{children:t(`settings.jiandu.create.granularityLabel`)}),(0,m.jsxs)(ee,{value:z.granularity||`none`,disabled:!!G,onValueChange:e=>Z(`granularity`,e===`none`?``:e),children:[(0,m.jsx)(o,{className:`w-full`,"aria-label":t(`settings.jiandu.create.granularityLabel`),children:(0,m.jsx)(a,{})}),(0,m.jsxs)(s,{className:`z-[150]`,children:[(0,m.jsx)(c,{value:`none`,children:t(`settings.jiandu.create.noGranularity`)}),pe.map(e=>(0,m.jsx)(c,{value:e,children:e},e))]})]})]})]}),Me?(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(Me)}):null,V?(0,m.jsxs)(`section`,{className:`rounded-lg border p-3`,"aria-label":t(`settings.jiandu.create.matchesLabel`),children:[(0,m.jsx)(`h3`,{className:`text-sm font-medium`,children:V.items.length>0?t(`settings.jiandu.create.matches`):t(`settings.jiandu.create.noMatches`)}),V.items.length>0?(0,m.jsx)(`ul`,{className:`mt-2 space-y-1 text-sm`,children:V.items.map(e=>(0,m.jsxs)(`li`,{children:[e.title,` · `,$(e.status)]},e.id))}):null,V.truncated?(0,m.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:t(`settings.jiandu.create.matchesTruncated`)}):null]}):null]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,m.jsx)(u,{variant:`outline`,disabled:G===`create`,onClick:We,children:t(`settings.jiandu.create.close`)}),(0,m.jsx)(u,{variant:`secondary`,disabled:je||!!G,onClick:()=>void Ge(),children:t(je?`settings.jiandu.create.lookingUp`:`settings.jiandu.create.lookup`)}),(0,m.jsx)(u,{disabled:G===`create`||!V||V.fingerprint!==He,onClick:()=>void Ke(),children:t(G===`create`?`settings.jiandu.create.creating`:`settings.jiandu.create.confirm`)})]})]})}),(0,m.jsx)(ae,{open:!!Ne,onOpenChange:e=>{!e&&G!==`archive`&&(q(null),J(null))},children:(0,m.jsxs)(re,{showCloseButton:!1,dismissable:G!==`archive`,className:`gap-4 p-5`,children:[(0,m.jsx)(ne,{children:t(`settings.jiandu.archive.title`,{title:Ne?.title??``})}),(0,m.jsx)(ie,{children:t(`settings.jiandu.archive.description`)}),Pe?(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Q(Pe)}):null,(0,m.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,m.jsx)(u,{variant:`outline`,disabled:G===`archive`,onClick:()=>{q(null),J(null)},children:t(`settings.jiandu.archive.cancel`)}),(0,m.jsx)(u,{variant:`destructive`,disabled:G===`archive`,onClick:()=>void qe(),children:t(G===`archive`?`settings.jiandu.archive.archiving`:`settings.jiandu.archive.confirm`)})]})]})})]})}export{v as JianduProjectMemories};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CodeBlock-2pYVlrI7.js","./rolldown-runtime-QTnfLwEv.js","./vendor-react-CCIEwYL0.js","./defineProperty-8d_fL0DV.js","./typeof-B5XbjTb1.js","./vendor-highlighter-BO3UKWFM.js","./preload-helper-DYl5dUZ5.js","./vendor-markdown-CfSBref-.js","./lib-CFLxRXs3.js","./themeStore-iULXkh0N.js","./react-BqtYw2Yd.js","./unsupportedIterableToArray-7m2_meZB.js","./MermaidChart-D1bUSRYY.js","./StreamdownMermaid-DihA1DWx.js","./vendor-mermaid-D-p0xABq.js","./ui-OvgR8HKW.js","./shim-B7rqb4U2.js","./button-Cfb4l-V4.js","./bundle-mjs-B_AA55HL.js","./dist-F2p7j0vG.js","./utils-DqNhCx4L.js","./textarea-BKzYyWL5.js","./strictConfig-C66PYHjm.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{t as r}from"./preload-helper-DYl5dUZ5.js";import{a as i,d as a,u as o}from"./vendor-markdown-CfSBref-.js";import{t as s}from"./utils-DqNhCx4L.js";import{t as c}from"./markdownTheme-DZ_SWMdl.js";var l=e(t(),1),u=n(),d=(0,l.lazy)(()=>r(()=>import(`./CodeBlock-2pYVlrI7.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url)),f=(0,l.lazy)(()=>r(()=>import(`./MermaidChart-D1bUSRYY.js`),__vite__mapDeps([12,13,1,2,14,6,15,16,17,18,19,20,9,10,21,22]),import.meta.url)),p={pre:({children:e})=>(0,u.jsx)(`div`,{className:`my-2 overflow-hidden rounded-lg border text-xs [&>code]:block [&>code]:whitespace-pre-wrap [&>code]:break-words [&>code]:rounded-none [&>code]:bg-transparent [&>code]:p-3 [&>code]:[overflow-wrap:anywhere]`,children:e}),code(e){let{children:t,className:n}=e,r=/language-(\w+)/.exec(n||``),i=String(t).replace(/\n$/,``);return r?r[1]===`mermaid`?(0,u.jsx)(l.Suspense,{fallback:(0,u.jsx)(`pre`,{className:`overflow-x-auto p-3 font-mono text-xs`,children:i}),children:(0,u.jsx)(f,{code:i})}):(0,u.jsx)(l.Suspense,{fallback:(0,u.jsx)(`pre`,{className:`overflow-x-auto p-3 font-mono text-xs`,children:i}),children:(0,u.jsx)(d,{language:r[1],value:i})}):(0,u.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[0.85em] [overflow-wrap:anywhere]`,children:t})},table:({children:e})=>(0,u.jsx)(`div`,{className:`my-2 w-full overflow-x-auto rounded-lg border`,children:(0,u.jsx)(`table`,{className:`w-full border-collapse text-xs`,children:e})}),thead:({children:e})=>(0,u.jsx)(`thead`,{className:`bg-muted/50`,children:e}),th:({children:e})=>(0,u.jsx)(`th`,{className:`border-b px-3 py-2 text-left align-top font-medium [overflow-wrap:break-word]`,children:e}),td:({children:e})=>(0,u.jsx)(`td`,{className:`border-b border-border/40 px-3 py-2 align-top [overflow-wrap:break-word]`,children:e})};function m({children:e,className:t}){return(0,u.jsx)(`div`,{style:c,className:s(`prose prose-sm max-w-none [overflow-wrap:anywhere]`,`prose-p:my-2 prose-headings:mt-4 prose-headings:mb-2`,`prose-pre:my-0 prose-pre:bg-transparent prose-pre:p-0`,`prose-a:text-primary prose-li:my-0.5`,t),children:(0,u.jsx)(i,{remarkPlugins:[o],rehypePlugins:[a],components:p,children:e})})}var h=(0,l.memo)(m);export{h as Markdown};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./StreamdownMermaid-DihA1DWx.js";export{e as default};
|
package/dist/assets/{NewChatWorktreeControl-BVvX1tE3.js → NewChatWorktreeControl-BokjqEn9.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r,r as i}from"./ui-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r,r as i}from"./ui-OvgR8HKW.js";import{a,i as o,r as s,t as c}from"./popover-Cu0Q3dYz.js";import{t as l}from"./loader-circle-B9fKDSy8.js";import{n as u,t as d}from"./input-DWysC80E.js";import{s as f}from"./dist-DRdYZy9Q.js";import{a as p,i as m,r as h,t as g}from"./composerStyles-BGNR54wZ.js";import{t as _}from"./refresh-cw-DHR8UyeF.js";import{s as v}from"./api-CPcpMjoM.js";import{t as y}from"./button-Cfb4l-V4.js";import{t as b}from"./utils-DqNhCx4L.js";var x=e(t(),1),S=n(),C=e=>e?.replace(/\/+$/,``)||`/`,w=e=>e.split(`/`).filter(Boolean).at(-1)||e,T=()=>`chat-${new Date().toISOString().slice(0,10).replaceAll(`-`,``)}-${crypto.randomUUID().slice(0,6)}`;function E({projectId:e,workspacePath:t,value:n,onChange:E,disabled:D=!1,preparedPath:O,error:k}){r();let A=(0,x.useId)(),[j,M]=(0,x.useState)(!1),[N,P]=(0,x.useState)(0),[F,I]=(0,x.useState)(null),L=JSON.stringify([e,t??null]),R=F?.context===L?F:null,z=!!e&&(!R||R.loading),B=R?.data?.repositories.filter(e=>!e.error)??[],V=B.find(e=>e.path===n?.repository),H=B.find(e=>C(e.path)===C(t))??B[0],U=n?V:H,W=!!t&&!!U&&C(U.path)!==C(t),G=D||!!O,K=!n||/^[A-Za-z0-9_-]{1,80}$/.test(n.name),q=n?.root&&n.name?`${n.root.replace(/\/+$/,``)}/${n.name}`:null;return(0,x.useEffect)(()=>{if(!j||!e)return;let t=!1;return I({context:L,loading:!0}),h.list(e).then(e=>{t||I({context:L,loading:!1,data:e})}).catch(e=>{t||I({context:L,loading:!1,error:v(e)})}),()=>{t=!0}},[j,e,L,N]),(0,S.jsxs)(`div`,{className:`min-w-0 max-w-full space-y-1`,"data-new-chat-worktree-control":!0,children:[(0,S.jsxs)(c,{open:j,onOpenChange:M,children:[(0,S.jsx)(o,{asChild:!0,children:(0,S.jsxs)(`button`,{type:`button`,"aria-label":i(`chat_worktree_control`),title:O||n?.repository||t||i(`chat_worktree_current`),className:b(g,n&&`bg-primary/10 text-primary`),children:[k?(0,S.jsx)(a,{className:`size-4 shrink-0`}):O?(0,S.jsx)(u,{className:`size-4 shrink-0`}):n?(0,S.jsx)(m,{className:`size-4 shrink-0`}):(0,S.jsx)(p,{className:`size-4 shrink-0`}),(0,S.jsx)(`span`,{className:`truncate`,children:i(O?`chat_worktree_ready`:n?`chat_worktree_new`:`chat_worktree_current`)}),(0,S.jsx)(f,{className:`size-3 shrink-0 opacity-60`})]})}),(0,S.jsxs)(s,{side:`top`,align:`start`,className:`space-y-4 rounded-xl p-4`,"aria-label":i(`chat_worktree_control`),style:{width:`25rem`,maxWidth:`calc(100vw - 24px)`,maxHeight:`min(38rem, 75dvh)`,overflowY:`auto`},children:[(0,S.jsxs)(`div`,{className:`space-y-1`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:i(`chat_worktree_control`)}),(0,S.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:i(`chat_worktree_draft_hint`)})]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,role:`group`,"aria-label":i(`chat_worktree_mode`),children:[(0,S.jsxs)(`button`,{type:`button`,"aria-pressed":!n,disabled:G,onClick:()=>{!G&&n&&E(null)},className:`flex items-center justify-center gap-1.5 rounded-lg border p-2 text-xs disabled:opacity-50 ${n?`text-muted-foreground hover:bg-muted`:`border-primary/40 bg-primary/10 text-primary`}`,children:[(0,S.jsx)(p,{className:`size-3.5`}),i(`chat_worktree_current`)]}),(0,S.jsxs)(`button`,{type:`button`,"aria-pressed":!!n,disabled:G||z||!e||!H,onClick:()=>{if(G||z||!e||!H||n)return;let t=T();E({repository:H.path,root:R?.data?.default_root??``,name:t,branch:`chat/${t}`})},className:`flex items-center justify-center gap-1.5 rounded-lg border p-2 text-xs disabled:opacity-50 ${n?`border-primary/40 bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted`}`,children:[(0,S.jsx)(m,{className:`size-3.5`}),i(`chat_worktree_new`)]})]}),!n&&(0,S.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,S.jsx)(`p`,{className:`font-medium`,children:i(`chat_worktree_selected_workspace`)}),(0,S.jsx)(`p`,{className:`break-all text-muted-foreground`,children:t||i(`chat_worktree_default_workspace`)})]}),e?(0,S.jsxs)(S.Fragment,{children:[z&&(0,S.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,S.jsx)(l,{className:`size-3.5 animate-spin`}),i(`chat_worktree_loading`)]}),R?.error&&(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:i(`chat_worktree_inventory_failed`,{error:R.error})}),(0,S.jsxs)(y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>P(e=>e+1),children:[(0,S.jsx)(_,{className:`size-3.5`}),i(`chat_worktree_reload`)]})]}),!z&&R?.data&&!B.length&&(0,S.jsxs)(`div`,{className:`space-y-1 text-xs text-muted-foreground`,children:[(0,S.jsx)(`p`,{role:`status`,children:i(`chat_worktree_no_git`)}),R.data.repositories.filter(e=>e.error).map(e=>(0,S.jsxs)(`p`,{className:`break-all`,children:[e.path,`: `,e.error]},e.path))]}),n&&(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(`label`,{htmlFor:`${A}-source`,className:`text-xs font-medium`,children:i(`chat_worktree_source`)}),(0,S.jsxs)(`select`,{id:`${A}-source`,value:n.repository,disabled:G||z||!B.length,className:`h-9 w-full min-w-0 rounded-md border bg-background px-2 text-xs disabled:opacity-50`,onChange:e=>{!G&&B.some(t=>t.path===e.target.value)&&E({...n,repository:e.target.value})},children:[!V&&(0,S.jsx)(`option`,{value:n.repository,children:n.repository}),B.map(e=>(0,S.jsx)(`option`,{value:e.path,children:e.path},e.path))]}),(0,S.jsx)(`p`,{className:`break-all text-xs text-muted-foreground`,children:i(`chat_worktree_source_head`,{path:n.repository})}),W&&(0,S.jsx)(`p`,{role:`note`,className:`text-xs text-amber-600 dark:text-amber-400`,children:i(`chat_worktree_source_differs`,{workspace:t})}),!z&&R?.data&&!V&&(0,S.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:i(`chat_worktree_source_unavailable`)})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(`label`,{htmlFor:`${A}-root`,className:`text-xs font-medium`,children:i(`chat_worktree_root`)}),(0,S.jsx)(d,{id:`${A}-root`,value:n.root,disabled:G,placeholder:`/Volumes/External/worktrees`,autoComplete:`off`,onChange:e=>{G||E({...n,root:e.target.value})}}),(0,S.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:i(`chat_worktree_root_hint`)})]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(`label`,{htmlFor:`${A}-name`,className:`text-xs font-medium`,children:i(`chat_worktree_name`)}),(0,S.jsx)(d,{id:`${A}-name`,value:n.name,disabled:G,maxLength:80,"aria-invalid":!K,"aria-describedby":`${A}-name-hint`,autoComplete:`off`,onChange:e=>{G||E({...n,name:e.target.value})}})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(`label`,{htmlFor:`${A}-branch`,className:`text-xs font-medium`,children:i(`chat_worktree_branch`)}),(0,S.jsx)(d,{id:`${A}-branch`,value:n.branch,disabled:G,autoComplete:`off`,onChange:e=>{G||E({...n,branch:e.target.value})}})]})]}),(0,S.jsx)(`p`,{id:`${A}-name-hint`,className:`text-xs ${K?`text-muted-foreground`:`text-destructive`}`,children:i(`chat_worktree_name_hint`)}),(0,S.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-muted/60 p-2.5 text-xs`,children:[(0,S.jsx)(`p`,{className:`font-medium`,children:i(`chat_worktree_target`)}),(0,S.jsx)(`p`,{className:`break-all font-mono`,"data-worktree-target":!0,children:q||i(`chat_worktree_target_empty`)})]}),(0,S.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:i(`chat_worktree_clean_hint`)})]})]}):(0,S.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:i(`chat_worktree_no_project`)}),k&&(0,S.jsx)(`p`,{className:`break-words text-xs text-destructive`,children:k}),O&&(0,S.jsx)(`p`,{role:`status`,className:`break-all rounded-lg bg-primary/10 p-2.5 text-xs`,children:i(`chat_worktree_created`,{path:O})}),G&&(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`chat_worktree_locked`)})]})]}),O&&(0,S.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,style:{maxWidth:`16rem`},title:O,children:[w(O),` · `,O]}),k&&(0,S.jsx)(`p`,{role:`alert`,className:`max-w-sm break-words text-xs text-destructive`,children:k})]})}export{E as NewChatWorktreeControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r,r as i}from"./ui-DQy0lUHc.js";import{c as a,s as o,t as s}from"./api-dae15_RX.js";import{t as c}from"./button-Cfb4l-V4.js";import{t as l}from"./ownerAccessContext-DnfKhLRV.js";import{t as u}from"./ticketWorkLabels-tosshWRq.js";var d=e(t(),1),f=n();function p({status:e,submitting:t,uncertain:n,copy:r,onReload:i,onReconcile:a}){let o=e.phase===`idle`?null:{requested:r.requestSent,awaiting_ack:r.awaitingAck,acknowledged:r.acknowledged,conflict:r.conflict,denied:r.denied,outcome_unknown:r.outcomeUnknown,failed:r.failed}[e.phase],s=n||[`conflict`,`denied`,`outcome_unknown`,`failed`].includes(e.phase);return(0,f.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[t?(0,f.jsx)(`p`,{role:`status`,children:r.submitting}):null,n?(0,f.jsx)(`p`,{role:`alert`,className:`break-words text-destructive`,children:r.outcomeUnknown}):null,o?(0,f.jsxs)(`div`,{role:s?`alert`:`status`,className:`break-words`,children:[(0,f.jsx)(`p`,{children:o}),e.phase===`idle`?null:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.operation,`: `,(0,f.jsx)(`span`,{className:`break-all`,children:e.operationId})]}),e.detail?(0,f.jsx)(`p`,{children:e.detail}):null]})]}):null,s?(0,f.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,f.jsx)(`button`,{type:`button`,className:`rounded-md border px-3 py-2 outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:i,children:r.reload}),e.phase!==`idle`&&a?(0,f.jsx)(`button`,{type:`button`,className:`rounded-md border px-3 py-2 outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>a(e.operationId),children:r.reconcile}):null]}):null]})}function m(e){let t=(0,d.useRef)(new Set),n=(0,d.useRef)(null),[r,i]=(0,d.useState)(null),a=async(r,a)=>{if(!(e.some(e=>t.current.has(e))||n.current!==null&&e.includes(n.current))){t.current.add(r),n.current=r,i({operationId:r,phase:`submitting`});try{if((await a()).operationId!==r)throw Error(`Mismatched operation receipt`);i(e=>e?.operationId===r?null:e)}catch{i(e=>e?.operationId===r?{operationId:r,phase:`uncertain`}:e)}finally{n.current===r&&(n.current=null)}}},o=!!r&&e.includes(r.operationId);return{send:a,sent:e=>!!e&&t.current.has(e),operationId:o?r.operationId:null,submitting:o&&r.phase===`submitting`,uncertain:o&&r.phase===`uncertain`}}var h=[`low`,`medium`,`high`,`critical`];function g(e){if(typeof e!=`string`)return null;let t=/^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?([Zz]|[+-]\d{2}:\d{2})$/.exec(e);if(!t||t[8]===`-00:00`)return null;let[,n,r,i,a,o,s,,c]=t,[l,u,d,f,p,m]=[n,r,i,a,o,s].map(Number),h=[31,l%4==0&&(l%100!=0||l%400==0)?29:28,31,30,31,30,31,31,30,31,30,31];if(u<1||u>12||d<1||d>h[u-1]||f>23||p>59||m>59||c.toUpperCase()!==`Z`&&(Number(c.slice(1,3))>23||Number(c.slice(4,6))>59))return null;let g=Date.parse(e);if(!Number.isFinite(g))return null;let _=(t[7]??``).padEnd(9,`0`);return BigInt(g)*1000000n+BigInt(_.slice(3))}function _(e,t,n){if(e===void 0)return`unknown`;if(e===null)return`unset`;let r=g(e);if(r===null)return`invalid`;if(n===`accepted`||n===`cancelled`)return`terminal`;let i=g(t);return i===null?`as_of_unknown`:r<i?`overdue`:`within_deadline`}function v(e){if(!h.includes(e.priority))return null;let t=e.expectedCompletionAt.trim();return t&&g(t)===null?null:{priority:e.priority,expectedCompletionAt:t||null}}function y(e,t){return!!e?.operationId&&e.workId===t.id&&e.generation===t.generation&&e.recordRevision===t.recordRevision&&!!e.binding?.scope_id&&Number.isSafeInteger(e.generation)&&e.generation>=1&&Number.isSafeInteger(e.recordRevision)&&e.recordRevision>=1&&!!e.binding.supervisor_session_id&&Number.isSafeInteger(e.binding.binding_revision)&&e.binding.binding_revision>=1&&Number.isSafeInteger(e.expectedSeq)&&e.expectedSeq>=0&&Number.isSafeInteger(e.expectedEpoch)&&e.expectedEpoch>=1}var b=`min-w-0 w-full rounded-md border bg-background px-3 py-2 text-sm disabled:opacity-50 outline-none focus-visible:ring-2 focus-visible:ring-ring`;function x(e){let{work:t,current:n,draft:r,query:i,owner:a,editCapability:o,queryCapability:s,command:l,request:u,copy:x,onDraftChange:S,onQueryChange:C,onSavePlanning:w,onReload:T,onReconcile:E}=e,D=(0,d.useId)(),O=m(l?[l.operationId]:[]),k=v(r),A=u.phase!==`idle`||O.submitting||O.uncertain||O.sent(l?.operationId),j=a&&o.available&&n!==null&&y(l,t)&&!A,M=!!k&&!!n&&k.priority===n.priority&&k.expectedCompletionAt===n.expectedCompletionAt,N=_(n?.expectedCompletionAt,i.asOf,t.state),P={unknown:x.deadlineUnknown,unset:x.deadlineUnset,invalid:x.deadlineInvalid,as_of_unknown:x.asOfUnknown,overdue:x.overdue,within_deadline:x.withinDeadline,terminal:x.terminalDeadline}[N],F=a?o.available?n===null?x.unsupported:y(l,t)?null:x.unavailableContext:o.reason||x.unsupported:x.ownerRequired;return(0,f.jsxs)(`section`,{"aria-labelledby":`${D}-title`,className:`min-w-0 space-y-4 rounded-xl border bg-background p-4 text-sm`,"data-testid":`project-work-planning-controls`,children:[(0,f.jsx)(`h3`,{id:`${D}-title`,className:`font-semibold`,children:x.planning}),(0,f.jsxs)(`div`,{className:`space-y-1 break-words`,"aria-label":x.currentPlanning,children:[(0,f.jsxs)(`p`,{children:[x.priority,`: `,n?x.priorities[n.priority]:x.unsupported]}),(0,f.jsxs)(`p`,{children:[x.desiredDeadline,`: `,n?n.expectedCompletionAt===null?x.deadlineUnset:(0,f.jsx)(`time`,{className:`break-all`,dateTime:g(n.expectedCompletionAt)===null?void 0:n.expectedCompletionAt,children:n.expectedCompletionAt||x.deadlineInvalid}):x.deadlineUnknown]}),(0,f.jsx)(`p`,{className:N===`overdue`?`font-medium text-destructive`:`text-muted-foreground`,"data-deadline-status":N,children:P})]}),(0,f.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),j&&k&&!M&&l&&O.send(l.operationId,()=>w(k,l))},children:[(0,f.jsxs)(`fieldset`,{disabled:!j,className:`grid min-w-0 gap-3 sm:grid-cols-2`,children:[(0,f.jsxs)(`label`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:x.priority}),(0,f.jsx)(`select`,{className:b,value:r.priority,onChange:e=>S({...r,priority:e.target.value}),children:h.map(e=>(0,f.jsx)(`option`,{value:e,children:x.priorities[e]},e))})]}),(0,f.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`label`,{htmlFor:`${D}-deadline`,children:x.desiredDeadline}),(0,f.jsx)(`input`,{id:`${D}-deadline`,className:b,type:`text`,value:r.expectedCompletionAt,placeholder:`2026-10-18T18:00:00+08:00`,"aria-describedby":`${D}-deadline-help${k?``:` ${D}-deadline-error`}`,"aria-invalid":!k,onChange:e=>S({...r,expectedCompletionAt:e.target.value})}),(0,f.jsx)(`button`,{type:`button`,className:`rounded px-1 py-1 text-xs underline disabled:opacity-50 outline-none focus-visible:ring-2 focus-visible:ring-ring`,disabled:!r.expectedCompletionAt,onClick:()=>S({...r,expectedCompletionAt:``}),children:x.clearDeadline})]})]}),(0,f.jsx)(`p`,{id:`${D}-deadline-help`,className:`text-xs text-muted-foreground`,children:x.deadlineHelp}),k?null:(0,f.jsx)(`p`,{id:`${D}-deadline-error`,role:`alert`,className:`text-destructive`,children:x.invalidDeadline}),F?(0,f.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:F}):null,(0,f.jsx)(c,{type:`submit`,size:`sm`,disabled:!j||!k||M,children:x.savePlanning})]}),(0,f.jsx)(p,{status:O.uncertain&&(u.phase===`idle`||u.phase===`requested`||u.phase===`awaiting_ack`)?{phase:`outcome_unknown`,operationId:O.operationId}:u,submitting:O.submitting,uncertain:!1,copy:x,onReload:T,onReconcile:E}),(0,f.jsxs)(`fieldset`,{disabled:!s.available,"aria-labelledby":`${D}-query`,className:`grid min-w-0 gap-3 border-t pt-3 sm:grid-cols-2`,children:[(0,f.jsx)(`legend`,{id:`${D}-query`,className:`px-1 font-medium`,children:x.query}),(0,f.jsxs)(`label`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:x.order}),(0,f.jsxs)(`select`,{className:b,value:i.order,onChange:e=>C({...i,order:e.target.value}),children:[(0,f.jsx)(`option`,{value:`updated`,children:x.orderUpdated}),(0,f.jsx)(`option`,{value:`priority`,children:x.orderPriority}),(0,f.jsx)(`option`,{value:`expected_completion`,children:x.orderDeadline})]})]}),(0,f.jsxs)(`label`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:x.filterPriority}),(0,f.jsxs)(`select`,{className:b,value:i.priority??`all`,onChange:e=>C({...i,priority:e.target.value===`all`?null:e.target.value}),children:[(0,f.jsx)(`option`,{value:`all`,children:x.allPriorities}),h.map(e=>(0,f.jsx)(`option`,{value:e,children:x.priorities[e]},e))]})]}),(0,f.jsxs)(`label`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:x.filterDeadline}),(0,f.jsxs)(`select`,{className:b,value:i.deadline,onChange:e=>C({...i,deadline:e.target.value}),children:[(0,f.jsx)(`option`,{value:`any`,children:x.anyDeadline}),(0,f.jsx)(`option`,{value:`overdue`,disabled:g(i.asOf)===null,children:x.overdueOnly}),(0,f.jsx)(`option`,{value:`unset`,children:x.unsetOnly})]})]})]}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:x.serverQueryHelp}),s.available?null:(0,f.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:s.reason||x.unsupported}),(0,f.jsxs)(`p`,{className:`break-all text-xs text-muted-foreground`,children:[x.asOf,`: `,g(i.asOf)===null?x.asOfUnknown:(0,f.jsx)(`time`,{dateTime:i.asOf,children:i.asOf})]})]})}function S(e){let{work:t,owner:n,capabilities:r,commands:i,request:a,acceptance:o,acceptanceConfirmation:s,acceptedByUser:l,copy:u,onAcceptanceConfirmationChange:h,onRequestAction:g,onReload:_,onReconcile:v}=e,b=(0,d.useId)(),x=m(Object.values(i).map(e=>e.operationId)),S=a.phase!==`idle`||x.submitting||x.uncertain||Object.values(i).some(e=>x.sent(e.operationId)),C=!!o&&o.stopGuardEnforced===!0&&o.processStopped===!0&&!o.stale&&o.generation===t.generation&&!!o.submissionId&&o.submissionId===t.currentSubmissionId&&o.contractRevision===t.contractRevision&&Number.isSafeInteger(o.contractRevision)&&o.contractRevision>=1,w=!!o&&s?.submissionId===o.submissionId&&s.generation===o.generation&&s.contractRevision===o.contractRevision,T=e=>n&&r[e].available&&y(i[e],t)&&!S&&(e!==`accept`||C&&w),E=e=>{let t=i[e];if(!T(e)||!t)return;let n=e===`accept`&&o?{kind:`accept`,source:`user`,submissionId:o.submissionId,generation:o.generation,contractRevision:o.contractRevision,unverifiedItems:[...o.unverifiedItems]}:{kind:e};x.send(t.operationId,()=>g(n,t))};return(0,f.jsxs)(`section`,{"aria-labelledby":`${b}-title`,className:`min-w-0 space-y-3 rounded-xl border bg-background p-4 text-sm`,"data-testid":`project-work-owner-controls`,children:[(0,f.jsx)(`h3`,{id:`${b}-title`,className:`font-semibold`,children:u.ownerControls}),(0,f.jsxs)(`p`,{children:[u.actualState,`: `,(0,f.jsx)(`strong`,{"data-testid":`work-authoritative-state`,children:u.states[t.state]}),t.paused===!0?` · ${u.paused}`:t.paused===null?` · ${u.pauseUnknown}`:``]}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u.actualStateHelp}),n?null:(0,f.jsx)(`p`,{role:`status`,children:u.ownerRequired}),(0,f.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`pause`,`resume`,`cancel`].map(e=>(0,f.jsxs)(`div`,{className:`min-w-0 max-w-full space-y-1`,children:[(0,f.jsx)(c,{type:`button`,size:`sm`,variant:e===`cancel`?`destructive`:`outline`,disabled:!T(e),onClick:()=>E(e),children:u[e]}),r[e].available?y(i[e],t)?null:(0,f.jsx)(`p`,{className:`max-w-xs text-xs text-muted-foreground`,children:u.unavailableContext}):(0,f.jsx)(`p`,{className:`max-w-xs break-words text-xs text-muted-foreground`,children:r[e].reason||u.unsupported})]},e))}),(0,f.jsxs)(`div`,{className:`min-w-0 space-y-2 border-t pt-3`,children:[o?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`p`,{className:`break-all`,children:[u.submission,`: `,o.submissionId]}),(0,f.jsx)(`p`,{className:`font-medium`,children:u.evidence}),o.evidence.length?(0,f.jsx)(`ul`,{className:`list-inside list-disc break-words`,children:o.evidence.map((e,t)=>(0,f.jsx)(`li`,{children:e},t))}):(0,f.jsx)(`p`,{children:u.evidenceNotRecorded}),(0,f.jsx)(`p`,{className:`font-medium`,children:u.unverified}),o.unverifiedItems.length?(0,f.jsx)(`ul`,{className:`list-inside list-disc break-words`,children:o.unverifiedItems.map((e,t)=>(0,f.jsx)(`li`,{children:e},t))}):(0,f.jsx)(`p`,{className:`text-muted-foreground`,children:u.noUnverifiedRecorded})]}):null,(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u.userAcceptance}),C?null:(0,f.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:u.completionGuard}),r.accept.available?null:(0,f.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:r.accept.reason||u.unsupported}),(0,f.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,f.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:w,disabled:!n||!r.accept.available||!C||S,onChange:e=>h(e.target.checked&&o?{submissionId:o.submissionId,generation:o.generation,contractRevision:o.contractRevision}:null)}),(0,f.jsx)(`span`,{children:u.acceptanceConfirmation})]}),(0,f.jsx)(c,{type:`button`,size:`sm`,disabled:!T(`accept`),onClick:()=>E(`accept`),children:u.accept}),t.state===`accepted`&&l?(0,f.jsx)(`p`,{className:`font-medium`,children:u.acceptedByUser}):null]}),(0,f.jsx)(p,{status:x.uncertain&&(a.phase===`idle`||a.phase===`requested`||a.phase===`awaiting_ack`)?{phase:`outcome_unknown`,operationId:x.operationId}:a,submitting:x.submitting,uncertain:!1,copy:u,onReload:_,onReconcile:v})]})}function C(){return{planning:i(`project_work_controls_planning`),priority:i(`project_work_controls_priority`),desiredDeadline:i(`project_work_controls_desired_deadline`),deadlineHelp:i(`project_work_controls_deadline_help`),clearDeadline:i(`project_work_controls_clear_deadline`),currentPlanning:i(`project_work_controls_current_planning`),savePlanning:i(`project_work_controls_save_planning`),unsupported:i(`project_work_controls_unsupported`),ownerRequired:i(`project_work_controls_owner_required`),unavailableContext:i(`project_work_controls_unavailable_context`),invalidDeadline:i(`project_work_controls_invalid_deadline`),deadlineUnknown:i(`project_work_controls_deadline_unknown`),deadlineUnset:i(`project_work_controls_deadline_unset`),deadlineInvalid:i(`project_work_controls_deadline_invalid`),overdue:i(`project_work_controls_overdue`),withinDeadline:i(`project_work_controls_within_deadline`),terminalDeadline:i(`project_work_controls_terminal_deadline`),asOfUnknown:i(`project_work_controls_as_of_unknown`),asOf:i(`project_work_controls_as_of`),query:i(`project_work_controls_query`),order:i(`project_work_controls_order`),orderUpdated:i(`project_work_controls_order_updated`),orderPriority:i(`project_work_controls_order_priority`),orderDeadline:i(`project_work_controls_order_deadline`),filterPriority:i(`project_work_controls_filter_priority`),allPriorities:i(`project_work_controls_all_priorities`),filterDeadline:i(`project_work_controls_filter_deadline`),anyDeadline:i(`project_work_controls_any_deadline`),overdueOnly:i(`project_work_controls_overdue_only`),unsetOnly:i(`project_work_controls_unset_only`),serverQueryHelp:i(`project_work_controls_server_query_help`),ownerControls:i(`project_work_controls_owner_controls`),actualState:i(`project_work_controls_actual_state`),paused:i(`project_work_controls_paused`),pauseUnknown:i(`project_work_controls_pause_unknown`),pause:i(`project_work_controls_pause`),resume:i(`project_work_controls_resume`),cancel:i(`project_work_controls_cancel`),accept:i(`project_work_controls_accept`),submitting:i(`project_work_controls_submitting`),requestSent:i(`project_work_controls_request_sent`),awaitingAck:i(`project_work_controls_awaiting_ack`),acknowledged:i(`project_work_controls_acknowledged`),conflict:i(`project_work_controls_conflict`),denied:i(`project_work_controls_denied`),outcomeUnknown:i(`project_work_controls_outcome_unknown`),failed:i(`project_work_controls_failed`),reload:i(`project_work_controls_reload`),reconcile:i(`project_work_controls_reconcile`),operation:i(`project_work_controls_operation`),actualStateHelp:i(`project_work_controls_actual_state_help`),completionGuard:i(`project_work_controls_completion_guard`),submission:i(`project_work_controls_submission`),evidence:i(`project_work_controls_evidence`),unverified:i(`project_work_controls_unverified`),evidenceNotRecorded:i(`project_work_controls_evidence_not_recorded`),noUnverifiedRecorded:i(`project_work_controls_no_unverified_recorded`),userAcceptance:i(`project_work_controls_user_acceptance`),acceptanceConfirmation:i(`project_work_controls_acceptance_confirmation`),acceptedByUser:i(`project_work_controls_accepted_by_user`),priorities:{low:i(`project_work_controls_priorities_low`),medium:i(`project_work_controls_priorities_medium`),high:i(`project_work_controls_priorities_high`),critical:i(`project_work_controls_priorities_critical`)},states:{draft:i(`project_work_controls_states_draft`),ready:i(`project_work_controls_states_ready`),active:i(`project_work_controls_states_active`),submitted:i(`project_work_controls_states_submitted`),accepted:i(`project_work_controls_states_accepted`),blocked:i(`project_work_controls_states_blocked`),cancelled:i(`project_work_controls_states_cancelled`)}}}function w(e,t){if(e.commit!==t.commit||e.seq!==t.seq||e.authority_epoch!==t.authority_epoch||!e.commit||!Number.isSafeInteger(e.seq)||e.seq<0||!Number.isSafeInteger(e.authority_epoch)||e.authority_epoch<1)throw Error(i(`ticket_the_ticket_snapshot_is_inconsistent_refresh_a_4e2cb547`))}function T(e){let t=e.next_cursor!==null;return[`complete`,`authoritative_scope`].includes(e.coverage)&&(t||!e.truncated&&e.omitted_count===0)&&e.index_seq>=e.snapshot.seq}var E={async page(e,t,n,r,a){let o=await s.post(`tickets/project-board`,{project_id:e,include_cancelled:t,include_archived:!1,limit:100,cursor:n?.next_cursor??null,fixed_commit:n?.snapshot.commit??null,...a?{sprint_filter:a}:{}},{signal:r});if(w(o.snapshot,n?.snapshot??o.snapshot),[`todo`,`doing`,`testing`,`done`,`blocked`,`cancelled`,`total`].some(e=>{let t=o.data.counts[e];return!Number.isSafeInteger(t)||t<0})||o.data.project_id!==e||o.data.rows.some(e=>!e.ticket.id)||new Set(o.data.rows.map(e=>e.ticket.id)).size!==o.data.rows.length)throw Error(i(`project_work_inconsistent`));let c=o.next_cursor;if(c&&(c.commit!==o.snapshot.commit||!Number.isSafeInteger(c.offset)||c.offset<=(n?.next_cursor?.offset??0)||n?.next_cursor&&c.query_hash!==n.next_cursor.query_hash))throw Error(i(`project_work_inconsistent`));if(!n)return o;if(Object.keys(n.data.counts).some(e=>o.data.counts[e]!==n.data.counts[e])||o.data.rows.some(e=>n.data.rows.some(t=>t.ticket.id===e.ticket.id)))throw Error(i(`project_work_inconsistent`));return{...o,data:{...o.data,rows:[...n.data.rows,...o.data.rows]}}},async inspect(e,t,n){let r=await s.post(`tickets/inspect`,{ids:[e],sections:[`assignments`,`requests`,`submissions`],depth:0,budget_bytes:65536,fixed_commit:t.commit},{signal:n});if(w(r.snapshot,t),![`complete`,`authoritative_scope`].includes(r.coverage)||r.index_seq<t.seq||r.truncated||r.omitted_count||r.data.length!==1||r.data[0].ticket.id!==e)throw Error(i(`project_work_inconsistent`));return r.data[0]}},D=()=>Error(i(`project_work_inconsistent`)),O=(e,t=0)=>Number.isSafeInteger(e)&&e>=t,k=e=>e?.kind===`sprint`?JSON.stringify([`sprint`,e.sprint_id]):e?.kind??`all`;function A(e,t){if(!e||!e.commit||!O(e.seq)||!O(e.authority_epoch,1)||t&&(e.commit!==t.commit||e.seq!==t.seq||e.authority_epoch!==t.authority_epoch))throw D()}function j(e,t){if(A(e.snapshot,t),![`complete`,`authoritative_scope`].includes(e.coverage)||!O(e.index_seq)||e.index_seq<e.snapshot.seq||!O(e.omitted_count))throw D()}function M(e){if(!e||[`total`,`accepted`,`pending_acceptance`,`blocked`,`cancelled`,`unfinished`].some(t=>!O(e[t]))||e.total!==e.accepted+e.cancelled+e.unfinished||e.pending_acceptance>e.unfinished||e.blocked>e.unfinished)throw D()}function N(e){if(!e||typeof e.name!=`string`||!e.name.trim()||typeof e.goal!=`string`||!e.goal.trim()||[e.starts_at,e.ends_at].some(e=>e!==null&&!Number.isSafeInteger(e))||e.starts_at!==null&&e.ends_at!==null&&e.ends_at<e.starts_at)throw D()}function P(e){if(!e||!O(e.record_revision,1)||!O(e.contract_revision,1)||!O(e.generation)||![`draft`,`ready`,`active`,`submitted`,`accepted`,`blocked`,`cancelled`].includes(e.state)||typeof e.accepted!=`boolean`||typeof e.paused!=`boolean`||typeof e.archived!=`boolean`)throw D()}function F(e){if(!e?.source_commit||!O(e.source_seq)||!O(e.closed_seq)||e.closed_seq<=e.source_seq||!e.members||(M(e.counts),Object.keys(e.members).length!==e.counts.total))throw D();for(let t of Object.values(e.members))if(P(t.version),![`accepted`,`cancelled`,`backlog`,`sprint`].includes(t.disposition?.disposition)||t.disposition.disposition===`sprint`&&!t.disposition.sprint_id)throw D()}function I(e,t){if(!e?.id||e.project_id!==t||![`planned`,`active`,`closed`].includes(e.status)||!O(e.revision,1)||!O(e.created_seq)||!O(e.updated_seq)||e.updated_seq<e.created_seq)throw D();N(e.definition)}var L=e=>JSON.stringify(e&&typeof e==`object`?Array.isArray(e)?e.map(e=>JSON.parse(L(e))):Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,JSON.parse(L(t))])):e),R={async list(e,t,n,r){let i=t?.snapshot??n,a=await s.post(`tickets/sprints/list`,{project_id:e,status:null,limit:100,cursor:t?.next_cursor??null,fixed_commit:i?.commit??null},{signal:r});if(j(a,i),!Array.isArray(a.data)||new Set(a.data.map(e=>e.id)).size!==a.data.length)throw D();for(let t of a.data)if(I(t,e),!O(t.member_count)||(t.closure_counts&&M(t.closure_counts),t.status===`closed`!=(t.closure_counts!==null)))throw D();let o=a.next_cursor;if(o&&(o.commit!==a.snapshot.commit||!o.query_hash||!O(o.offset,1)||o.offset<=(t?.next_cursor?.offset??0)||t?.next_cursor&&o.query_hash!==t.next_cursor.query_hash)||!o&&(a.truncated||a.omitted_count!==0))throw D();if(!t)return a;if(a.data.some(e=>t.data.some(t=>t.id===e.id)))throw D();return{...a,data:[...t.data,...a.data]}},async inspect(e,t,n,r){let i=await s.post(`tickets/sprints/inspect`,{project_id:e,sprint_id:t,fixed_commit:n.commit},{signal:r});if(j(i,n),i.next_cursor||i.truncated||i.omitted_count!==0||i.data.sprint.id!==t)throw D();let{sprint:a,current_members:o,current_counts:c}=i.data;if(I(a,e),M(c),!Array.isArray(a.members)||new Set(a.members).size!==a.members.length||!Array.isArray(a.history)||!o||Object.keys(o).length!==a.members.length||c.total!==a.members.length||a.members.some(e=>!Object.hasOwn(o,e)))throw D();for(let e of Object.values(o))P(e);if(a.status===`closed`!=(a.closure!==null)||a.closure&&(F(a.closure),a.closure.closed_seq>n.seq||a.members.some(e=>!Object.hasOwn(a.closure.members,e))))throw D();return i},async scope(e){let t=await s.get(`tickets/scope`,{signal:e});if(t.available&&t.binding&&(!t.binding.scope_id||!t.binding.supervisor_session_id||!O(t.binding.binding_revision,1)))throw D();return t},async command(e){let t=await s.postOnce(`tickets/sprints/command`,e),n=t.operation;if(!n||n.operation_id!==e.operation_id||n.ids?.sprint!==e.sprint_id||!O(n.committed_seq)||n.committed_seq<=e.expected_seq||!n.request_hash||!n.principal)throw D();let r;try{r=JSON.parse(n.canonical_request)}catch{throw D()}if(!Array.isArray(r)||r[0]!==`sprint`||L(r[1])!==L(e)||e.action.op===`close`!=(t.closure!==null))throw D();return t.closure&&F(t.closure),t}};function ee(e,t,n){r();let s=(0,d.useContext)(l),[c,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(0),v=(0,d.useRef)(!1),y=(0,d.useRef)(null),b=n?.kind,x=n?.kind===`sprint`?n.sprint_id:null,S=(0,d.useMemo)(()=>b===`backlog`?{kind:`backlog`}:b===`sprint`&&x?{kind:`sprint`,sprint_id:x}:null,[b,x]),C=JSON.stringify([e,t,k(S)]),w=(0,d.useRef)(C),T=(0,d.useCallback)(()=>{y.current?.abort(),u(null),_(e=>e+1)},[]);return(0,d.useEffect)(()=>{let n=new AbortController;return y.current=n,w.current=C,v.current=!1,u(null),p(null),h(s),s&&E.page(e,t,void 0,n.signal,S).then(e=>{n.signal.aborted||u(e)}).catch(e=>{n.signal.aborted||p(a(e)&&e.status===404?i(`project_work_unsupported`):o(e))}).finally(()=>{n.signal.aborted||h(!1)}),window.addEventListener(`online`,T),()=>{n.abort(),window.removeEventListener(`online`,T)}},[e,t,s,g,T,C,S]),{page:s&&w.current===C?c:null,error:f,busy:m,refresh:T,loadMore:async()=>{if(!c?.next_cursor||m||v.current||!s||y.current?.signal.aborted)return;let n=y.current;v.current=!0,h(!0);try{let r=await E.page(e,t,c,n.signal,S);n.signal.aborted||(u(r),p(null))}catch(e){if(n.signal.aborted)return;a(e)&&[409,410].includes(e.status)?T():p(o(e))}finally{n.signal.aborted||(v.current=!1,h(!1))}},owner:s}}var z=e=>JSON.stringify([e.assignment_id,e.session_id,e.run_id]);async function B(e,t,n){let r=`unknown`;try{let{session:i}=await s.get(`sessions/${encodeURIComponent(e.session_id)}`,{signal:n});i?.id===e.session_id&&[`root`,`child`].includes(i.kind)&&(i.project_id==null||i.project_id===t)&&(r=`accessible`)}catch(e){if(n.aborted)throw e;a(e)&&(r=e.status===403?`denied`:e.status===404?`missing`:`unknown`)}return{...e,access:r}}function V(e,t,n,r){let[i,a]=(0,d.useState)(()=>navigator.onLine),[o,s]=(0,d.useState)({status:`unknown`}),c=(0,d.useRef)(0),l=(0,d.useRef)(null),u=(0,d.useRef)(new Map),f=(0,d.useMemo)(()=>{let n=new Map;for(let t of e??[])n.set(t.id,(n.get(t.id)??0)+1);return(e??[]).filter(e=>n.get(e.id)===1&&e.work_id===t&&Number.isSafeInteger(e.generation)&&e.generation>=1&&Number.isSafeInteger(e.authority_epoch)&&e.authority_epoch>=1&&e.runtime?.session_id&&e.runtime.run_id).map(e=>({assignment_id:e.id,session_id:e.runtime.session_id,run_id:e.runtime.run_id}))},[e,t]);(0,d.useEffect)(()=>{let e=()=>{navigator.onLine||l.current?.abort(),a(navigator.onLine)};return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[]);let p=(0,d.useCallback)(async(e,t,r)=>{let i=z(e),a=(u.current.get(i)??0)+1;u.current.set(i,a);try{let o=await B(e,n,t.signal);return t.signal.aborted||c.current!==r||u.current.get(i)!==a?void 0:(s(e=>({status:`available`,updatedAt:null,value:[...e.status===`available`?e.value.filter(e=>z(e)!==i):[],o]})),o)}catch{}},[n]);return(0,d.useEffect)(()=>{let t=new AbortController,n=++c.current;if(l.current=t,u.current.clear(),s({status:`unknown`}),r&&i&&e){let e=0;f.length||s({status:`available`,value:[],updatedAt:null});for(let r=0;r<Math.min(4,f.length);r++)(async()=>{for(;!t.signal.aborted&&e<f.length;)await p(f[e++],t,n)})()}return()=>{t.abort(),c.current+=1}},[e,f,r,i,p]),{online:i,sessions:r&&i?o:{status:`unknown`},recheck:async e=>{let t=l.current,n=f.find(t=>t.session_id===e);return!r||!i||!n||!t||t.signal.aborted?!1:(await p(n,t,c.current))?.access===`accessible`}}}function H(e){if(!e||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(e))return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function U(e,t,n=!1){if(!e)return`unsupported`;if(e.status!==`available`)return e.status;if(!Number.isFinite(t))return`unknown`;let r=H(e.updatedAt),i=H(e.validUntil);return e.updatedAt!=null&&(r===null||r>t)||e.validUntil!=null&&(i===null||i<=t||r!==null&&i<=r)||n&&(r===null||i===null)?`unknown`:`available`}function W(e,t){return e.work_id===t.work_id&&e.assignment_id===t.assignment_id&&e.generation===t.generation&&e.authority_epoch===t.authority_epoch}function G(e){let t=U(e.attempts,e.nowMs);if(t!==`available`)return{status:t};if(e.currentAssignmentId===null)return{status:`none`};let n=e.attempts.status===`available`?e.attempts.value.filter(t=>t.id===e.currentAssignmentId):[];if(n.length!==1)return{status:`unknown`};let r=n[0],i=[`admitted`,`running`,`blocked`,`cancelling`,`outcome_unknown`].includes(r.state);return r.work_id!==e.workId||r.generation!==e.generation||r.authority_epoch!==e.authorityEpoch||!Number.isSafeInteger(e.generation)||e.generation<1||!Number.isSafeInteger(e.authorityEpoch)||e.authorityEpoch<1||r.role!==void 0&&r.role!==`executor`||r.process_stopped||!i||!r.runtime?.session_id||!r.runtime.run_id?{status:`unknown`}:{status:`confirmed`,attempt:r}}function K(e,t,n){if(U(t,n,!0)!==`available`||t?.status!==`available`||!e.runtime||e.work_id===void 0||e.generation===void 0||e.authority_epoch===void 0)return;let{work_id:r,generation:i,authority_epoch:a,runtime:o}=e,s=t.value.filter(t=>W(t,{work_id:r,assignment_id:e.id,generation:i,authority_epoch:a})&&t.session_id===o.session_id&&t.run_id===o.run_id);if(s.length!==1)return;let c=s[0],l=H(t.updatedAt);if(![c.heartbeat_at,c.progress?.at,c.terminal?.at].filter(e=>e!=null).some(e=>{let t=H(e);return t===null||t>l})&&!(c.progress&&(!Number.isSafeInteger(c.progress.sequence)||c.progress.sequence<0||!c.progress.evidence_ref.trim()))&&!(c.terminal&&!c.terminal.evidence_ref.trim()))return c}function q(e,t,n){if(!e.runtime||U(t,n)!==`available`||t?.status!==`available`)return`unknown`;let r=t.value.filter(t=>t.assignment_id===e.id&&t.session_id===e.runtime.session_id&&t.run_id===e.runtime.run_id);return r.length===1?r[0].access:`unknown`}function J(e,t,n){let r=H(e.opened_at),i=H(e.recovery?.requested_at),a=H(e.recovery?.acknowledged_at);if(r===null||r>n||e.recovery?.requested_at!=null&&(i===null||i<r||i>n)||e.recovery?.acknowledged_at!=null&&(a===null||i===null||a<i||a>n))return`unconfirmed`;let o=i??r;if(t&&W(e,t)){let i=H(t.terminal?.at);if(i!==null&&i>=o&&i<=n&&t.terminal?.evidence_ref.trim())return`terminal_observed`;let a=H(t.progress?.at);if(e.progress_sequence!==null&&Number.isSafeInteger(e.progress_sequence)&&e.progress_sequence>=0&&t.progress&&Number.isSafeInteger(t.progress.sequence)&&t.progress.sequence>e.progress_sequence&&a!==null&&a>r&&a>=o&&a<=n&&t.progress.evidence_ref.trim())return`progress_observed`}return e.phase===`resolved`?`unconfirmed`:a===null?i===null?`not_recorded`:`requested`:`acknowledged`}function Y({label:e,children:t}){return(0,f.jsxs)(`div`,{className:`min-w-0`,children:[(0,f.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,f.jsx)(`dd`,{className:`mt-0.5 min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t})]})}function te(e){let{copy:t,nowMs:n,locale:r,workId:i}=e,a=(0,d.useId)(),o=e.attempts.status===`available`&&e.attempts.value.some(e=>e.work_id!==void 0&&e.work_id!==i)?{status:`unknown`,updatedAt:e.attempts.updatedAt}:e.attempts,s=G({...e,attempts:o}),l=U(o,n),u=e.attempts.status===`available`?e.attempts.value.filter(e=>e.work_id===void 0||e.work_id===i):[],p=s.attempt?K(s.attempt,e.observations,n):void 0,m=u.filter(e=>e!==s.attempt),h=e.incidents?.status===`available`&&e.incidents.value.some(e=>e.work_id!==i)?`unknown`:U(e.incidents,n,!0),g=e.incidents?.status===`available`?e.incidents.value.filter(e=>e.work_id===i):[],_=new Map;for(let e of g)_.set(e.id,(_.get(e.id)??0)+1);let v=e=>{let n=H(e);return n===null?(0,f.jsx)(`span`,{className:`text-muted-foreground`,children:t.notRecorded}):(0,f.jsx)(`time`,{dateTime:e,children:new Intl.DateTimeFormat(r,{dateStyle:`medium`,timeStyle:`long`}).format(n)})},y=e=>e?(0,f.jsx)(`code`,{className:`break-all text-xs`,children:e}):(0,f.jsx)(`span`,{className:`text-muted-foreground`,children:t.notRecorded}),b=r=>{let i=q(r,e.sessions,n),a=i===`accessible`&&e.onOpenSession&&r.runtime?.session_id,o=i===`denied`?t.sessionDenied:i===`missing`?t.sessionMissing:i===`accessible`?t.navigationUnavailable:t.sessionUnknown;return(0,f.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[y(r.runtime?.session_id),a?(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,className:`ml-2 h-auto max-w-full whitespace-normal text-left`,onClick:()=>e.onOpenSession(r.runtime.session_id),children:t.openSession}):(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o})]})},x=e=>(0,f.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,f.jsx)(Y,{label:t.assignment,children:y(e.id)}),(0,f.jsx)(Y,{label:t.role,children:t[e.role??`executor`]}),(0,f.jsx)(Y,{label:t.generation,children:Number.isSafeInteger(e.generation)?e.generation:t.notRecorded}),(0,f.jsx)(Y,{label:t.authorityEpoch,children:Number.isSafeInteger(e.authority_epoch)?e.authority_epoch:t.notRecorded}),e.step_id?(0,f.jsx)(Y,{label:t.step,children:y(e.step_id)}):null,(0,f.jsx)(Y,{label:t.attempt,children:y(e.attempt_id)}),(0,f.jsx)(Y,{label:t.session,children:b(e)}),(0,f.jsx)(Y,{label:t.run,children:y(e.runtime?.run_id)}),(0,f.jsx)(Y,{label:t.claimedAt,children:v(e.claimed_at)}),(0,f.jsx)(Y,{label:t.processStopped,children:e.process_stopped===!0?t.stoppedConfirmed:t.stopUnconfirmed}),(0,f.jsx)(Y,{label:t.endReason,children:e.end_reason||t.notRecorded}),e.awaiting_request?(0,f.jsx)(Y,{label:t.awaitingRequest,children:y(e.awaiting_request)}):null]}),S=`unknown`;return p&&s.attempt&&![`cancelling`,`outcome_unknown`].includes(s.attempt.state)&&(S=p.terminal?`terminal_observed`:p.execution===`running`&&s.attempt.state!==`running`?`unknown`:p.execution),(0,f.jsxs)(`section`,{"aria-labelledby":a,className:`min-w-0 rounded-xl border bg-background p-4 text-sm`,"data-testid":`assignment-health-panel`,children:[(0,f.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,f.jsx)(`h4`,{id:a,className:`font-semibold`,children:t.title}),(0,f.jsx)(`span`,{className:`rounded-md border px-2 py-0.5 text-xs`,"data-testid":`assignment-source-status`,children:t[l]})]}),(0,f.jsxs)(`p`,{className:`mt-1 break-words text-xs text-muted-foreground`,children:[t.updatedAt,`: `,v(e.attempts.updatedAt)]}),l===`available`?null:(0,f.jsx)(`p`,{role:`status`,className:`mt-2 break-words`,children:e.attempts.status!==`available`&&e.attempts.reason?e.attempts.reason:t.staleHint}),(0,f.jsxs)(`div`,{className:`mt-4 min-w-0`,"data-testid":`assignment-current`,children:[(0,f.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(`h5`,{className:`font-medium`,children:t.currentExecutor}),(0,f.jsx)(`span`,{className:`rounded-md bg-muted px-2 py-0.5 text-xs`,"data-testid":`assignment-owner-status`,children:s.status===`confirmed`?t.confirmed:s.status===`none`?t.noCurrentExecutor:t.ownerUnknown})]}),s.status===`none`?(0,f.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:t.noCurrentHint}):null,s.attempt?x(s.attempt):e.currentAssignmentId?(0,f.jsx)(`dl`,{children:(0,f.jsx)(Y,{label:t.assignment,children:y(e.currentAssignmentId)})}):null,(0,f.jsxs)(`div`,{className:`mt-3 rounded-lg bg-muted/40 p-3`,"data-testid":`assignment-observation`,children:[(0,f.jsx)(`p`,{className:`mb-2 font-medium`,"data-testid":`assignment-execution-status`,children:t[S]}),(0,f.jsxs)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:[t.updatedAt,`: `,v(p?e.observations?.updatedAt:null)]}),(0,f.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,f.jsx)(Y,{label:t.heartbeat,children:v(p?.heartbeat_at)}),(0,f.jsx)(Y,{label:t.progress,children:v(p?.progress?.at)}),(0,f.jsx)(Y,{label:t.waitReason,children:p?.wait_reason||t.notRecorded}),(0,f.jsx)(Y,{label:t.blockReason,children:e.blockReason||p?.block_reason||t.notRecorded}),(0,f.jsx)(Y,{label:t.nextCheck,children:v(p?.next_check_at)}),p?.progress?(0,f.jsx)(Y,{label:t.evidence,children:y(p.progress.evidence_ref)}):null,p?.terminal?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(Y,{label:t.terminal_observed,children:p.terminal.state}),(0,f.jsx)(Y,{label:t.evidence,children:y(p.terminal.evidence_ref)})]}):null]}),(0,f.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:t.heartbeatHint}),U(e.observations,n,!0)===`available`?null:(0,f.jsx)(`p`,{className:`mt-1 text-xs`,"data-testid":`assignment-observation-status`,children:t[U(e.observations,n,!0)]})]})]}),(0,f.jsxs)(`details`,{className:`mt-4 min-w-0 rounded-lg border p-3`,"data-testid":`assignment-history`,children:[(0,f.jsxs)(`summary`,{className:`cursor-pointer font-medium`,children:[t.history,` (`,m.length,`)`]}),m.length?(0,f.jsx)(`ul`,{className:`mt-3 grid min-w-0 gap-3`,children:m.map((e,t)=>(0,f.jsx)(`li`,{className:`min-w-0 rounded-lg bg-muted/30 p-3`,children:x(e)},`${e.id}:${t}`))}):(0,f.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:l===`available`?t.emptyHistory:t[l]})]}),(0,f.jsxs)(`div`,{className:`mt-4 min-w-0 border-t pt-3`,"data-testid":`assignment-patrol`,children:[(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(`h5`,{className:`font-medium`,children:t.patrol}),(0,f.jsx)(`span`,{className:`rounded-md border px-2 py-0.5 text-xs`,children:t[h]})]}),(0,f.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[t.updatedAt,`: `,v(e.incidents?.updatedAt)]}),h===`unsupported`?(0,f.jsx)(`p`,{className:`mt-2`,children:t.patrolUnsupported}):h===`unknown`?(0,f.jsx)(`p`,{className:`mt-2`,children:t.staleHint}):g.length?null:(0,f.jsx)(`p`,{className:`mt-2`,children:t.noIncidents}),e.incidents?.status!==`available`&&e.incidents?.reason?(0,f.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.incidents.reason}):null,(0,f.jsx)(`ul`,{className:`mt-3 grid min-w-0 gap-3`,children:g.map((r,a)=>{let o=s.attempt&&W(r,{work_id:i,assignment_id:s.attempt.id,generation:e.generation,authority_epoch:e.authorityEpoch}),c=o&&h===`available`&&_.get(r.id)===1,l=c?J(r,p,n):`unconfirmed`,u=l===`progress_observed`||l===`terminal_observed`,d=!c||r.phase===`resolved`&&!u?`unconfirmed`:r.phase;return(0,f.jsxs)(`li`,{className:`min-w-0 rounded-lg border p-3`,"data-testid":`assignment-incident`,children:[(0,f.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,f.jsx)(`h6`,{className:`font-medium`,children:o?t.incident:t.historicalIncident}),(0,f.jsx)(`span`,{className:`rounded-md bg-muted px-2 py-0.5 text-xs`,"data-testid":`assignment-incident-phase`,children:t[d]})]}),(0,f.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,f.jsx)(Y,{label:t.incident,children:y(r.id)}),(0,f.jsx)(Y,{label:t.work,children:y(r.work_id)}),(0,f.jsx)(Y,{label:t.assignment,children:y(r.assignment_id)}),(0,f.jsx)(Y,{label:t.generation,children:r.generation}),(0,f.jsx)(Y,{label:t.authorityEpoch,children:r.authority_epoch}),(0,f.jsx)(Y,{label:t.fingerprint,children:y(r.fingerprint)}),(0,f.jsx)(Y,{label:t.sourceRevision,children:y(r.source_revision)}),(0,f.jsx)(Y,{label:t.evidence,children:y(r.evidence_ref)}),(0,f.jsx)(Y,{label:t.blockReason,children:r.reason}),(0,f.jsx)(Y,{label:t.diagnosisAttempts,children:Number.isSafeInteger(r.attempts)&&r.attempts>=0?r.attempts:t.notRecorded}),(0,f.jsx)(Y,{label:t.findings,children:r.findings||t.notRecorded}),(0,f.jsx)(Y,{label:t.uncertainty,children:r.uncertainty||t.notRecorded}),(0,f.jsx)(Y,{label:t.escalation,children:r.escalation||t.notRecorded}),(0,f.jsx)(Y,{label:t.nextCheck,children:v(r.next_check_at)}),(0,f.jsx)(Y,{label:t.recovery,children:(0,f.jsx)(`span`,{"data-testid":`assignment-recovery-status`,children:t[l]})}),(0,f.jsx)(Y,{label:t.requestedAt,children:v(r.recovery?.requested_at)}),(0,f.jsx)(Y,{label:t.acknowledgedAt,children:v(r.recovery?.acknowledged_at)})]}),(0,f.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:t.recoveryHint})]},`${r.id}:${a}`)})})]})]})}var ne=()=>({title:i(`assignment_health_title`),updatedAt:i(`assignment_health_updated_at`),available:i(`assignment_health_available`),unsupported:i(`assignment_health_unsupported`),unknown:i(`assignment_health_unknown`),notRecorded:i(`assignment_health_not_recorded`),staleHint:i(`assignment_health_stale_hint`),currentExecutor:i(`assignment_health_current_executor`),confirmed:i(`assignment_health_confirmed`),noCurrentExecutor:i(`assignment_health_no_current_executor`),ownerUnknown:i(`assignment_health_owner_unknown`),assignment:i(`assignment_health_assignment`),step:i(`assignment_health_step`),attempt:i(`assignment_health_attempt`),session:i(`assignment_health_session`),run:i(`assignment_health_run`),role:i(`assignment_health_role`),executor:i(`assignment_health_executor`),collaborator:i(`assignment_health_collaborator`),reviewer:i(`assignment_health_reviewer`),claimedAt:i(`assignment_health_claimed_at`),heartbeat:i(`assignment_health_heartbeat`),progress:i(`assignment_health_progress`),heartbeatHint:i(`assignment_health_heartbeat_hint`),waitReason:i(`assignment_health_wait_reason`),blockReason:i(`assignment_health_block_reason`),awaitingRequest:i(`assignment_health_awaiting_request`),nextCheck:i(`assignment_health_next_check`),endReason:i(`assignment_health_end_reason`),history:i(`assignment_health_history`),emptyHistory:i(`assignment_health_empty_history`),openSession:i(`assignment_health_open_session`),sessionDenied:i(`assignment_health_session_denied`),sessionMissing:i(`assignment_health_session_missing`),sessionUnknown:i(`assignment_health_session_unknown`),navigationUnavailable:i(`assignment_health_navigation_unavailable`),patrol:i(`assignment_health_patrol`),patrolUnsupported:i(`assignment_health_patrol_unsupported`),noIncidents:i(`assignment_health_no_incidents`),incident:i(`assignment_health_incident`),historicalIncident:i(`assignment_health_historical_incident`),sourceRevision:i(`assignment_health_source_revision`),evidence:i(`assignment_health_evidence`),fingerprint:i(`assignment_health_fingerprint`),diagnosisAttempts:i(`assignment_health_diagnosis_attempts`),findings:i(`assignment_health_findings`),uncertainty:i(`assignment_health_uncertainty`),escalation:i(`assignment_health_escalation`),recovery:i(`assignment_health_recovery`),requestedAt:i(`assignment_health_requested_at`),acknowledgedAt:i(`assignment_health_acknowledged_at`),recoveryHint:i(`assignment_health_recovery_hint`),running:i(`assignment_health_running`),waiting:i(`assignment_health_waiting`),blocked:i(`assignment_health_blocked`),open:i(`assignment_health_open`),diagnosing:i(`assignment_health_diagnosing`),cooldown:i(`assignment_health_cooldown`),resolved:i(`assignment_health_resolved`),requested:i(`assignment_health_requested`),acknowledged:i(`assignment_health_acknowledged`),progress_observed:i(`assignment_health_progress_observed`),terminal_observed:i(`assignment_health_terminal_observed`),unconfirmed:i(`assignment_health_unconfirmed`),not_recorded:i(`assignment_health_recovery_not_recorded`),work:i(`assignment_health_work`),generation:i(`assignment_health_generation`),authorityEpoch:i(`assignment_health_authority_epoch`),noCurrentHint:i(`assignment_health_no_current_hint`),processStopped:i(`assignment_health_process_stopped`),stoppedConfirmed:i(`assignment_health_stopped_confirmed`),stopUnconfirmed:i(`assignment_health_stop_unconfirmed`)}),re=new Map,X=`lotus-sprint-command-changed`;function ie(e,t,n,r,i,s=re){let[c,l]=(0,d.useState)(null),[,u]=(0,d.useState)(0),[f,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(0),v=(0,d.useRef)(null),y=(0,d.useRef)(s),b=(0,d.useRef)(!1),x=(0,d.useRef)(!1),S=(0,d.useRef)(!0),C=(0,d.useRef)(e),[w,T]=(0,d.useState)(()=>navigator.onLine);C.current=e;let E=t?.commit,D=t?.seq,O=t?.authority_epoch,k=(0,d.useMemo)(()=>E!==void 0&&D!==void 0&&O!==void 0?{commit:E,seq:D,authority_epoch:O}:null,[E,D,O]);(0,d.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]),(0,d.useEffect)(()=>{let e=()=>u(e=>e+1);return window.addEventListener(X,e),()=>window.removeEventListener(X,e)},[]),(0,d.useEffect)(()=>{let e=()=>T(navigator.onLine);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[]);let A=(0,d.useCallback)(()=>{v.current?.abort(),_(e=>e+1)},[]);(0,d.useEffect)(()=>{let t=new AbortController;if(v.current=t,x.current=!1,h(!1),!r||!k)return()=>t.abort();let i={projectId:e,selectedId:n,commit:k.commit,list:null,inspection:null,scope:null,status:`loading`,error:null};return l(i),Promise.all([R.list(e,void 0,k,t.signal),R.scope(t.signal),n?R.inspect(e,n,k,t.signal):Promise.resolve(null)]).then(([e,n,r])=>{t.signal.aborted||l({...i,list:e,scope:n,inspection:r,status:`available`})}).catch(e=>{t.signal.aborted||l({...i,status:a(e)&&[404,405,501].includes(e.status)?`unsupported`:`error`,error:o(e)})}),()=>t.abort()},[e,k,n,r,g]);let j=r&&t&&c?.projectId===e&&c.selectedId===n&&c.commit===t.commit?c:null,M=y.current.get(e),N=M?.result??null,P=j?.scope?.overview?.snapshot,F=!!(j?.status===`available`&&j.scope?.available&&j.scope.health===`writable`&&j.scope.capabilities?.ticket_scope_v1&&j.scope.mutation_enabled&&j.scope.binding&&j.scope.overview&&[`complete`,`authoritative_scope`].includes(j.scope.overview.coverage)&&!j.scope.overview.truncated&&j.scope.overview.omitted_count===0&&j.scope.overview.index_seq>=j.scope.overview.snapshot.seq&&P&&P.commit===t?.commit&&P.seq===t.seq&&P.authority_epoch===t.authority_epoch&&w&&!f&&(!M||N?.status===`committed`&&t.seq>=N.committedSeq)),I=async()=>{let n=v.current;if(!(!j?.list?.next_cursor||!n||n.signal.aborted||x.current)){x.current=!0,h(!0);try{let r=await R.list(e,j.list,t,n.signal);n.signal.aborted||l(e=>e&&{...e,list:r})}catch(e){n.signal.aborted||l(t=>t&&{...t,error:o(e),status:`error`})}finally{n.signal.aborted||(x.current=!1,h(!1))}}},L=async(e,t=!1)=>{if(!b.current){b.current=!0,p(!0);try{let t=await R.command(e);y.current.set(e.project_id,{command:e,result:{status:`committed`,operationId:t.operation.operation_id,committedSeq:t.operation.committed_seq}}),window.dispatchEvent(new Event(X)),S.current&&C.current===e.project_id&&(i(),A())}catch(n){let r=!t&&a(n)&&n.status<500?n.status===409?`conflict`:`rejected`:`unknown`;y.current.set(e.project_id,{command:e,result:{status:r,message:o(n)}}),window.dispatchEvent(new Event(X))}finally{b.current=!1,S.current&&p(!1)}}};return{list:j?.list??null,inspection:j?.inspection??null,status:j?.status??(r?`loading`:`unsupported`),error:j?.error??null,request:N,sending:f,canWrite:F,moreBusy:m,loadMore:I,command:async(n,r)=>{let i=y.current.get(e);if(!F||!navigator.onLine||b.current||i&&(i.result?.status!==`committed`||t.seq<i.result.committedSeq)||!j?.scope?.binding||!t)return;let a={operation_id:crypto.randomUUID(),binding:{...j.scope.binding},expected_seq:t.seq,expected_epoch:t.authority_epoch,project_id:e,sprint_id:n,source:`Explicit owner Sprint planning`,action:r},o=structuredClone(a);y.current.set(e,{command:o,result:null}),u(e=>e+1),await L(o)},reconcile:async()=>{let t=y.current.get(e),n=t?.command;!r||!navigator.onLine||!j?.scope?.available||!j.scope.mutation_enabled||!n||n.project_id!==e||j.scope.binding?.scope_id!==n.binding.scope_id||t?.result?.status!==`unknown`||b.current||await L(n,!0)},reviewLatest:()=>{let t=y.current.get(e);b.current||t?.result?.status===`unknown`||t&&!t.result||(y.current.delete(e),u(e=>e+1),i(),A())},refresh:A}}function ae(e){let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.0{1,3})?)?$/.exec(e);if(!t)return;let[n,r,i,a,o,s]=[Number(t[1]),Number(t[2]),Number(t[3]),Number(t[4]),Number(t[5]),Number(t[6]??0)];if(n<1)return;let c=new Date(0);if(c.setUTCFullYear(n,r-1,i),c.setUTCHours(a,o,s,0),c.getUTCFullYear()!==n||c.getUTCMonth()!==r-1||c.getUTCDate()!==i||c.getUTCHours()!==a||c.getUTCMinutes()!==o||c.getUTCSeconds()!==s)return;let l=c.getTime()/1e3;return Number.isSafeInteger(l)?l:void 0}function oe(e){if(e===null)return``;if(!Number.isSafeInteger(e))return;let t=new Date(e*1e3),n=t.getUTCFullYear();if(n<1||n>9999||t.getTime()/1e3!==e)return;let r=e=>e.toString().padStart(2,`0`),i=`${n.toString().padStart(4,`0`)}-${r(t.getUTCMonth()+1)}-${r(t.getUTCDate())}T${r(t.getUTCHours())}:${r(t.getUTCMinutes())}:${r(t.getUTCSeconds())}`;return ae(i)===e?i:void 0}var Z=`w-full min-w-0 rounded-md border bg-background px-3 py-2 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,se=e=>({value:oe(e)??``,original:e,edited:!1,cleared:!1,invalid:!1}),ce=e=>({name:e?.sprint.definition.name??``,goal:e?.sprint.definition.goal??``,startsAt:se(e?.sprint.definition.starts_at??null),endsAt:se(e?.sprint.definition.ends_at??null)});function Q(e){return e.edited?e.cleared?null:e.invalid?void 0:ae(e.value):e.original}function le(e){let t=Q(e.startsAt),n=Q(e.endsAt),r=new TextEncoder;return!e.name.trim()||r.encode(e.name).length>256||!e.goal.trim()||r.encode(e.goal).length>4096||t===void 0||n===void 0||t!==null&&n!==null&&n<t?null:{name:e.name,goal:e.goal,starts_at:t,ends_at:n}}function ue(e){return(0,f.jsx)(de,{...e},`${e.projectId}:${e.view?.sprint.id??`create`}`)}function de({projectId:e,view:t,sprints:n,canWrite:r,busy:i,request:a,copy:o,onCommand:s,onReconcile:l,onReviewLatest:u}){let p=(0,d.useId)(),[m,h]=(0,d.useState)(()=>ce(t)),[g,_]=(0,d.useState)(t?.sprint.revision??null),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)({}),[S,C]=(0,d.useState)(!1),[w,T]=(0,d.useState)(!1),[E,D]=(0,d.useState)(!1),[O,k]=(0,d.useState)(!1),A=(0,d.useRef)(null),j=(0,d.useRef)(!1),M=(0,d.useRef)(!1),N=t?.sprint,P=!!e&&(!N||N.project_id===e&&Number.isSafeInteger(N.revision)&&N.revision>0),F=n.filter(t=>t.project_id===e&&t.id!==N?.id&&(t.status===`planned`||t.status===`active`)&&Number.isSafeInteger(t.revision)&&t.revision>0),I=Object.values(b).some(e=>e.destination===`sprint`&&!F.some(t=>t.id===e.sprint_id&&t.revision===e.revision)),L=g!==(N?.revision??null)||I,R=a?.status===`unknown`||!a&&(E||w&&!S),ee=!!a&&a.status!==`committed`,z=a&&`message`in a?a.message:``,B=!r||!P||i||S||w||ee||R||L||N?.status===`closed`,V=le(m),H=!!N&&!!V&&Object.entries(V).every(([e,t])=>N.definition[e]===t),U=!!v.trim()&&v===v.trim(),W=N?.members??[],G=!!t&&P&&new Set(W).size===W.length&&Object.keys(t.current_members).length===W.length&&W.every(e=>!!t.current_members[e]&&typeof t.current_members[e].accepted==`boolean`&&typeof t.current_members[e].archived==`boolean`),K=G?W.filter(e=>!t.current_members[e].accepted&&t.current_members[e].state!==`cancelled`):[],q=G&&K.every(e=>{let n=b[e];return n?.destination===`backlog`||n?.destination===`sprint`&&!t.current_members[e].archived&&F.some(e=>e.id===n.sprint_id&&e.revision===n.revision)}),J=n.some(t=>t.project_id===e&&t.id!==N?.id&&t.status===`active`),Y=async(e,t)=>{if(!(B||j.current||M.current)){j.current=!0,M.current=!0,C(!0),T(!0),D(!1);try{await s(e,t)}catch{D(!0)}finally{j.current=!1,C(!1)}}},te=()=>{if(!(B||!V||H)){if(N){Y(N.id,{op:`edit`,expected_revision:g,definition:V});return}if(!A.current)try{A.current=globalThis.crypto.randomUUID()}catch{k(!0);return}Y(A.current,{op:`create`,definition:V})}},ne=()=>{if(!N||N.status!==`active`||B||!q)return;let e=[],t=new Map;for(let n of K){let r=b[n];r.destination===`backlog`?e.push([n,{destination:`backlog`}]):(e.push([n,{destination:`sprint`,sprint_id:r.sprint_id}]),t.set(r.sprint_id,r.revision))}Y(N.id,{op:`close`,expected_revision:g,dispositions:Object.fromEntries(e),target_revisions:Object.fromEntries(t)})},re=async()=>{if(!(i||j.current||!R)){j.current=!0,C(!0);try{await l()}catch{D(!0)}finally{j.current=!1,C(!1)}}};return(0,f.jsxs)(`section`,{"aria-labelledby":`${p}-title`,className:`min-w-0 space-y-3 rounded-xl border bg-background p-4 text-sm`,"data-testid":`sprint-owner-controls`,children:[(0,f.jsx)(`h3`,{id:`${p}-title`,className:`font-semibold`,children:o.title}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o.planningHelp}),!r||!P?(0,f.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:o.ownerRequired}):null,N?(0,f.jsxs)(`p`,{className:`break-all text-xs text-muted-foreground`,children:[o.revision,`: `,N.revision]}):null,N?.status===`closed`?(0,f.jsx)(`p`,{role:`status`,children:o.closedReadOnly}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),te()},children:[(0,f.jsxs)(`fieldset`,{disabled:B,className:`grid min-w-0 gap-3 sm:grid-cols-2`,children:[(0,f.jsxs)(`label`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:o.name}),(0,f.jsx)(`input`,{className:Z,value:m.name,onChange:e=>h({...m,name:e.target.value})})]}),(0,f.jsxs)(`label`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:o.goal}),(0,f.jsx)(`textarea`,{className:Z,value:m.goal,onChange:e=>h({...m,goal:e.target.value})})]}),[`startsAt`,`endsAt`].map(e=>(0,f.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,f.jsxs)(`label`,{children:[(0,f.jsx)(`span`,{children:o[e]}),(0,f.jsx)(`input`,{className:Z,style:{colorScheme:`var(--native-scheme)`},type:`datetime-local`,step:`1`,min:`0001-01-01T00:00:00`,max:`9999-12-31T23:59:59`,value:m[e].value,"aria-invalid":Q(m[e])===void 0,"aria-describedby":`${p}-dates-help`,onChange:t=>{let{value:n,validity:r}=t.currentTarget;h({...m,[e]:{...m[e],value:n,edited:!0,cleared:!1,invalid:!r.valid}})}})]}),(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,disabled:m[e].original===null&&!m[e].value&&!m[e].edited,onClick:()=>h({...m,[e]:{...m[e],value:``,edited:!0,cleared:!0,invalid:!1}}),children:o[e===`startsAt`?`clearStart`:`clearEnd`]})]},e))]}),(0,f.jsx)(`p`,{id:`${p}-dates-help`,className:`text-xs text-muted-foreground`,children:o.datesHelp}),!V&&(m.name||m.goal||m.startsAt.edited||m.endsAt.edited)?(0,f.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:o.invalidDefinition}):null,O?(0,f.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:o.createIdUnavailable}):null,(0,f.jsx)(c,{type:`submit`,size:`sm`,disabled:B||!V||H,children:N?o.save:o.create})]}),N?.status===`planned`?(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,disabled:B||J,onClick:()=>void Y(N.id,{op:`start`,expected_revision:g}),children:o.start}),J?(0,f.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:o.activeExists}):null]}):null,N?(0,f.jsxs)(`div`,{className:`min-w-0 space-y-2 border-t pt-3`,children:[(0,f.jsxs)(`label`,{className:`block min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:o.workId}),(0,f.jsx)(`input`,{className:Z,disabled:B,value:v,"aria-describedby":`${p}-work-help`,onChange:e=>y(e.target.value)})]}),(0,f.jsx)(`p`,{id:`${p}-work-help`,className:`text-xs text-muted-foreground`,children:o.workIdHelp}),v&&!U?(0,f.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:o.invalidWorkId}):null,(0,f.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,disabled:B||!U||W.includes(v),onClick:()=>{U&&!W.includes(v)&&Y(N.id,{op:`add`,expected_revision:g,work_id:v})},children:o.add}),(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,disabled:B||!U||!W.includes(v),onClick:()=>{U&&W.includes(v)&&Y(N.id,{op:`remove`,expected_revision:g,work_id:v})},children:o.remove})]})]}):null,N?.status===`active`?(0,f.jsxs)(`div`,{className:`min-w-0 space-y-3 border-t pt-3`,children:[(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o.closeHelp}),G?K.map(e=>{let n=b[e];return(0,f.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,f.jsxs)(`label`,{className:`block min-w-0 space-y-1`,children:[(0,f.jsxs)(`span`,{className:`block break-all`,children:[o.destination,`: `,e]}),(0,f.jsxs)(`select`,{className:Z,disabled:B,value:n?.destination===`backlog`?`backlog`:n?.destination===`sprint`?`sprint:${n.sprint_id}`:``,onChange:t=>{let n=F.find(e=>`sprint:${e.id}`===t.target.value),r=t.target.value===`backlog`?{destination:`backlog`}:n?{destination:`sprint`,sprint_id:n.id,revision:n.revision}:null;x(t=>Object.fromEntries([...Object.entries(t).filter(([t])=>t!==e),...r?[[e,r]]:[]]))},children:[(0,f.jsx)(`option`,{value:``,children:o.chooseDestination}),(0,f.jsx)(`option`,{value:`backlog`,children:o.backlog}),F.map(n=>(0,f.jsxs)(`option`,{value:`sprint:${n.id}`,disabled:t.current_members[e].archived,children:[n.definition.name,` · `,n.id,` · `,o.targetRevision,` `,n.revision]},n.id))]})]}),n?.destination===`sprint`?(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[o.targetRevision,`: `,n.revision]}):null]},e)}):(0,f.jsx)(`p`,{role:`status`,children:o.incompleteInspect}),q?null:(0,f.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:o.incompleteDispositions}),(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`destructive`,disabled:B||!q,onClick:ne,children:o.close})]}):null]}),L?(0,f.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:o.draftStale}):null,S?(0,f.jsx)(`p`,{role:`status`,children:o.submitting}):w&&!a&&!E&&!R?(0,f.jsx)(`p`,{role:`status`,children:o.awaitingReceipt}):null,a?.status===`committed`?(0,f.jsxs)(`p`,{role:`status`,className:`break-all`,children:[o.committed,`: `,a.operationId,` · `,a.committedSeq]}):null,R||a&&a.status!==`committed`?(0,f.jsxs)(`p`,{role:`alert`,className:`break-words text-destructive`,children:[R?o.unknown:a?.status===`conflict`?o.conflict:o.rejected,z?` ${z}`:``]}):null,R?(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,disabled:i||S,onClick:()=>void re(),children:o.reconcile}):null,!R&&(L||a?.status===`conflict`||a?.status===`rejected`||w||a?.status===`committed`)&&N?.status!==`closed`?(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,disabled:i||S,onClick:()=>{i||j.current||R||(!N&&a?.status===`committed`&&(A.current=null),_(N?.revision??null),x(e=>Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{if(t.destination===`backlog`)return[[e,t]];let n=F.find(e=>e.id===t.sprint_id);return n?[[e,{...t,revision:n.revision}]]:[]}))),M.current=!1,T(!1),D(!1),u())},children:o.reviewLatest}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o.reviewHelp})]}):null,(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o.receiptHelp})]})}var fe=()=>({title:i(`project_sprint_owner_title`),planningHelp:i(`project_sprint_owner_planning_help`),ownerRequired:i(`project_sprint_owner_owner_required`),closedReadOnly:i(`project_sprint_owner_closed_read_only`),name:i(`project_sprint_owner_name`),goal:i(`project_sprint_owner_goal`),startsAt:i(`project_sprint_owner_starts_at`),endsAt:i(`project_sprint_owner_ends_at`),datesHelp:i(`project_sprint_owner_dates_help`),clearStart:i(`project_sprint_owner_clear_start`),clearEnd:i(`project_sprint_owner_clear_end`),create:i(`project_sprint_owner_create`),save:i(`project_sprint_owner_save`),start:i(`project_sprint_owner_start`),activeExists:i(`project_sprint_owner_active_exists`),workId:i(`project_sprint_owner_work_id`),workIdHelp:i(`project_sprint_owner_work_id_help`),add:i(`project_sprint_owner_add`),remove:i(`project_sprint_owner_remove`),close:i(`project_sprint_owner_close`),closeHelp:i(`project_sprint_owner_close_help`),destination:i(`project_sprint_owner_destination`),chooseDestination:i(`project_sprint_owner_choose_destination`),backlog:i(`project_sprint_owner_backlog`),targetRevision:i(`project_sprint_owner_target_revision`),revision:i(`project_sprint_owner_revision`),invalidDefinition:i(`project_sprint_owner_invalid_definition`),invalidWorkId:i(`project_sprint_owner_invalid_work_id`),incompleteInspect:i(`project_sprint_owner_incomplete_inspect`),incompleteDispositions:i(`project_sprint_owner_incomplete_dispositions`),draftStale:i(`project_sprint_owner_draft_stale`),reviewLatest:i(`project_sprint_owner_review_latest`),reviewHelp:i(`project_sprint_owner_review_help`),submitting:i(`project_sprint_owner_submitting`),awaitingReceipt:i(`project_sprint_owner_awaiting_receipt`),committed:i(`project_sprint_owner_committed`),conflict:i(`project_sprint_owner_conflict`),unknown:i(`project_sprint_owner_unknown`),rejected:i(`project_sprint_owner_rejected`),reconcile:i(`project_sprint_owner_reconcile`),receiptHelp:i(`project_sprint_owner_receipt_help`),createIdUnavailable:i(`project_sprint_owner_create_id_unavailable`)}),pe=e=>i({planned:`project_sprint_planned`,active:`project_sprint_active`,closed:`project_sprint_closed`}[e]),me=e=>i(`project_sprint_counts`,{...e});function he({projectId:e,projectActive:t,snapshot:n,owner:a,filter:o,onFilterChange:s,onRefresh:l}){r();let u=o?.kind===`sprint`?o.sprint_id:null,p=ie(e,n,u,a,l),m=p.inspection?.data,h=(0,d.useRef)(null);p.status===`available`&&(h.current={projectId:e,selectedId:u,view:m,list:p.list?.data??[]});let g=h.current?.projectId===e&&h.current.selectedId===u?h.current:null,_=u?`sprint:${u}`:o?.kind??`all`,v=e=>s(e===`all`?null:e===`backlog`?{kind:`backlog`}:{kind:`sprint`,sprint_id:e.slice(7)});return(0,f.jsxs)(`section`,{className:`mb-3 min-w-0 rounded-lg border p-3 text-sm`,"aria-label":i(`project_sprint_title`),"data-testid":`project-sprint-panel`,children:[(0,f.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(`span`,{className:`font-medium`,children:i(`project_sprint_filter`)}),(0,f.jsxs)(`select`,{"aria-label":i(`project_sprint_filter`),value:_,disabled:!a,onChange:e=>v(e.target.value),className:`min-w-0 max-w-xs rounded-md border bg-background p-2 text-sm focus-visible:ring-2 focus-visible:ring-ring`,"data-testid":`project-sprint-filter`,children:[(0,f.jsx)(`option`,{value:`all`,children:i(`project_sprint_all`)}),(0,f.jsx)(`option`,{value:`backlog`,disabled:p.status!==`available`,children:i(`project_sprint_backlog`)}),u&&!p.list?.data.some(e=>e.id===u)?(0,f.jsx)(`option`,{value:_,children:u}):null,p.list?.data.map(e=>(0,f.jsxs)(`option`,{value:`sprint:${e.id}`,children:[e.definition.name,` · `,pe(e.status)]},e.id))]}),p.list?.next_cursor?(0,f.jsx)(c,{size:`sm`,variant:`outline`,disabled:p.moreBusy,onClick:()=>void p.loadMore(),children:i(`project_sprint_more`)}):null]}),p.status===`unsupported`&&a?(0,f.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-muted-foreground`,children:i(`project_sprint_unsupported`)}):null,p.error?(0,f.jsxs)(`p`,{role:`status`,className:`mt-2 break-words text-xs text-destructive`,children:[i(`project_sprint_error`),` `,p.error]}):null,p.status===`loading`&&a?(0,f.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-muted-foreground`,children:i(`project_work_loading`)}):null,p.list&&!p.list.data.length?(0,f.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:i(`project_sprint_no_sprints`)}):null,o?.kind===`backlog`?(0,f.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:i(`project_sprint_backlog_hint`)}):null,m?(0,f.jsxs)(`div`,{className:`mt-3 min-w-0 space-y-2`,"data-testid":`project-sprint-summary`,children:[(0,f.jsxs)(`h3`,{className:`break-words font-semibold`,children:[m.sprint.definition.name,` · `,pe(m.sprint.status)]}),(0,f.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:m.sprint.definition.goal}),m.sprint.status===`closed`?(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`project_sprint_closed_hint`)}):null,(0,f.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-words text-xs`,children:[(0,f.jsx)(`dt`,{className:`font-medium`,children:i(`project_sprint_current`)}),(0,f.jsx)(`dd`,{"data-testid":`project-sprint-current-counts`,children:me(m.current_counts)}),(0,f.jsx)(`dd`,{className:`break-all text-muted-foreground`,children:i(`project_sprint_snapshot`,{seq:p.inspection.snapshot.seq,commit:p.inspection.snapshot.commit})}),m.sprint.closure?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`dt`,{className:`mt-2 font-medium`,children:i(`project_sprint_closure`)}),(0,f.jsx)(`dd`,{"data-testid":`project-sprint-closure-counts`,children:me(m.sprint.closure.counts)}),(0,f.jsx)(`dd`,{className:`break-all text-muted-foreground`,children:i(`project_sprint_closing_snapshot`,{closed:m.sprint.closure.closed_seq,source:m.sprint.closure.source_seq,commit:m.sprint.closure.source_commit})})]}):null]}),(0,f.jsxs)(`details`,{children:[(0,f.jsxs)(`summary`,{className:`cursor-pointer text-xs`,children:[i(`project_sprint_history`),` · `,i(`project_sprint_members`,{count:m.sprint.members.length})]}),(0,f.jsx)(`ul`,{className:`mt-2 space-y-2 text-xs`,children:m.sprint.history.map((e,t)=>(0,f.jsxs)(`li`,{className:`break-all`,children:[i({added:`project_sprint_history_added`,removed:`project_sprint_history_removed`,carried_in:`project_sprint_history_carried_in`,carried_out:`project_sprint_history_carried_out`}[e.change.kind]),` · `,e.work_id,e.change.kind===`carried_in`?` ← ${e.change.from}`:e.change.kind===`carried_out`?` → ${e.change.to??i(`project_sprint_backlog`)}`:``,(0,f.jsxs)(`span`,{className:`block text-muted-foreground`,children:[e.principal,` · `,e.source]})]},`${e.operation_id}:${e.work_id}:${t}`))})]})]}):null,g&&a?(0,f.jsxs)(`div`,{className:`mt-3`,children:[(0,f.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:i(`project_sprint_scope_hint`)}),!p.canWrite&&!p.sending&&!p.request?(0,f.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-muted-foreground`,children:i(`project_sprint_scope_stale`)}):null,(0,f.jsx)(ue,{projectId:e,view:g.view??null,sprints:g.list,canWrite:p.canWrite&&t,busy:p.sending,request:p.request,onCommand:async(e,n)=>{t&&await p.command(e,n)},onReconcile:p.reconcile,onReviewLatest:p.reviewLatest,copy:fe()})]}):null]})}var ge=[`todo`,`doing`,`testing`,`done`],$=e=>i({todo:`project_work_todo`,doing:`project_work_doing`,testing:`project_work_testing`,done:`project_work_done`}[e]);function _e({context:e}){return(0,f.jsx)(`span`,{children:e?i(`project_work_revision`,{project:e.project_revision,resources:e.resource_revision}):i(`project_work_unknown`)})}function ve({context:e,label:t,name:n}){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`dt`,{className:`font-medium`,children:t}),(0,f.jsxs)(`dd`,{"data-testid":`project-work-context-${n}`,children:[(0,f.jsx)(_e,{context:e}),e?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`span`,{className:`block`,children:i(`project_work_contract_revision`,{revision:e.contract_revision})}),(0,f.jsx)(`span`,{className:`block break-all`,children:e.workspace_binding.path})]}):null]})]})}function ye({row:e,snapshot:t,projectId:n,onClose:a,onOpenSession:s}){let l=r(),[u,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(!1),b=(0,d.useRef)(!1),x=(0,d.useRef)(!0),S=V(u?.assignments,e.ticket.id,n,!!s);(0,d.useEffect)(()=>(x.current=!0,()=>{x.current=!1}),[]);let C=async e=>{if(!(!s||b.current)){b.current=!0,y(!0),_(null);try{await s(e,()=>S.recheck(e))}catch(e){x.current&&_(o(e))}finally{b.current=!1,x.current&&y(!1)}}};(0,d.useEffect)(()=>{let n=new AbortController;return E.inspect(e.ticket.id,t,n.signal).then(e=>{n.signal.aborted||p(e)}).catch(e=>{n.signal.aborted||h(o(e))}),()=>n.abort()},[e.ticket.id,t]);let w=u?.assignments.find(t=>t.id===e.ticket.active_assignment);return(0,f.jsxs)(`section`,{"aria-label":e.ticket.contract.title,className:`min-w-0 rounded-xl border bg-background p-4 text-sm`,"data-testid":`project-work-details`,children:[(0,f.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,f.jsx)(`h3`,{className:`min-w-0 break-words font-semibold`,children:e.ticket.contract.title}),(0,f.jsx)(c,{size:`sm`,variant:`ghost`,onClick:a,children:i(`project_work_close_details`)})]}),(0,f.jsx)(`h4`,{className:`mt-3 font-medium`,children:i(`project_work_contract`)}),(0,f.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:e.ticket.contract.objective}),(0,f.jsx)(`ul`,{className:`list-inside list-disc break-words`,children:[...e.ticket.contract.constraints,...e.ticket.contract.acceptance].map((e,t)=>(0,f.jsx)(`li`,{children:e},t))}),(0,f.jsxs)(`dl`,{className:`mt-3 grid gap-1 break-words`,children:[(0,f.jsx)(`dt`,{className:`font-medium`,children:i(`project_work_dependencies`)}),(0,f.jsx)(`dd`,{children:e.ticket.depends_on.join(`, `)||`—`}),(0,f.jsx)(ve,{context:e.context,label:i(`project_work_candidate`),name:`candidate`}),e.pending_context?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(ve,{context:e.pending_context,label:i(`project_work_pending`),name:`pending`}),(0,f.jsx)(`dd`,{className:`text-xs text-muted-foreground`,children:i(`project_work_pending_hint`)})]}):null,(0,f.jsx)(ve,{context:e.adopted_context,label:i(`project_work_adopted`),name:`adopted`}),w?.workspace?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`dt`,{children:i(`project_work_repos`)}),(0,f.jsxs)(`dd`,{className:`break-all`,children:[w.workspace.repo,(0,f.jsx)(`br`,{}),w.workspace.branch,(0,f.jsx)(`br`,{}),w.workspace.worktree]})]}):null]}),(0,f.jsx)(`div`,{className:`mt-4`,children:(0,f.jsx)(te,{workId:e.ticket.id,generation:e.ticket.generation,authorityEpoch:t.authority_epoch,currentAssignmentId:e.ticket.active_assignment,attempts:u&&S.online?{status:`available`,value:u.assignments,updatedAt:null}:{status:`unknown`,reason:m??(S.online?i(`project_work_loading`):i(`assignment_health_stale_hint`))},observations:{status:`unsupported`},incidents:{status:`unsupported`},sessions:S.sessions,blockReason:e.ticket.blocked?.reason,nowMs:Date.now(),locale:l,copy:ne(),onOpenSession:s&&S.online?e=>void C(e):void 0})}),v?(0,f.jsx)(`p`,{role:`status`,className:`mt-2 text-xs`,children:i(`assignment_health_opening_session`)}):null,g?(0,f.jsx)(`p`,{role:`alert`,className:`mt-2 text-destructive`,children:g}):null,m?(0,f.jsx)(`p`,{role:`alert`,className:`mt-2 text-destructive`,children:m}):u?(0,f.jsxs)(f.Fragment,{children:[u.requests.some(e=>e.status===`open`)?(0,f.jsx)(`p`,{className:`mt-2`,children:i(`project_work_waiting`)}):null,(0,f.jsx)(`h4`,{className:`mt-3 font-medium`,children:i(`project_work_evidence`)}),u.submissions.filter(t=>[e.ticket.current_submission,e.ticket.accepted_submission].includes(t.id)).map(t=>(0,f.jsxs)(`div`,{className:`mt-2 break-words`,children:[(0,f.jsx)(`p`,{children:t.stale?i(`ticket_previous_submission_for_reference_only_8540a39f`):t.id===e.ticket.accepted_submission?i(`ticket_accepted_submission_a269d4af`):i(`ticket_submitted_awaiting_acceptance_14447588`)}),(0,f.jsx)(`ul`,{className:`list-inside list-disc`,children:t.evidence.map((e,t)=>(0,f.jsx)(`li`,{children:e},t))}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`supervisor_work_result_count`,{count:t.artifacts.length})})]},t.id)),!e.ticket.current_submission&&!e.ticket.accepted_submission?(0,f.jsx)(`p`,{children:i(`project_work_evidence_none`)}):null]}):(0,f.jsx)(`p`,{role:`status`,children:i(`project_work_loading`)})]})}function be(e,t){return e.id===t.ticket.id&&e.generation===t.ticket.generation&&e.recordRevision===t.ticket.record_revision&&e.state===t.ticket.state}function xe(e,t,n){return e?.binding?.scope_id===t.ticket.scope_id&&e.expectedSeq===n.seq&&e.expectedEpoch===n.authority_epoch?e:null}function Se({project:e,controls:t,onOpenSession:n}){r();let[a,o]=(0,d.useState)(`list`),[s,l]=(0,d.useState)(!1),[p,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(null),{page:_,error:v,busy:y,owner:b,refresh:w,loadMore:E}=ee(e.id,s,h),D=_?.data.rows??[],O=D.find(e=>e.ticket.id===p),k=O&&t?.planning&&be(t.planning.work,O)?t.planning:null,A=O&&t?.owner&&be(t.owner.work,O)&&t.owner.work.contractRevision===O.ticket.contract_revision&&t.owner.work.currentSubmissionId===O.ticket.current_submission?t.owner:null,j=O&&(t?.planning?.work.id===O.ticket.id&&!k||t?.owner?.work.id===O.ticket.id&&!A),M=A&&O&&_?Object.fromEntries(Object.entries(A.commands).filter(([,e])=>xe(e,O,_.snapshot))):{},N=_&&T(_),P=e=>(0,f.jsxs)(`button`,{type:`button`,"aria-pressed":p===e.ticket.id,onClick:()=>m(e.ticket.id),className:`min-w-0 w-full rounded-lg border bg-background p-3 text-left text-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring`,"data-testid":`project-work-${e.ticket.id}`,children:[(0,f.jsx)(`span`,{className:`block break-words font-medium`,children:e.ticket.contract.title}),(0,f.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:u[e.ticket.state]}),e.ticket.blocked?(0,f.jsxs)(`span`,{className:`mt-1 block break-words`,children:[i(`ticket_blocked_9059acb4`),`: `,e.ticket.blocked.reason]}):null,e.ticket.paused?(0,f.jsx)(`span`,{className:`block`,children:i(`project_work_paused`)}):null,(0,f.jsx)(`span`,{className:`mt-2 block text-xs text-muted-foreground`,children:e.ticket.current_submission||e.ticket.accepted_submission?i(`project_work_evidence_pending`):i(`project_work_evidence_none`)}),e.pending_context?(0,f.jsx)(`span`,{className:`block text-xs`,children:i(`project_work_pending`)}):null]},e.ticket.id);return(0,f.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,"data-testid":`project-work-board`,children:[(0,f.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:i(`project_work_readonly`)}),(0,f.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(c,{size:`sm`,variant:a===`list`?`default`:`outline`,"aria-pressed":a===`list`,onClick:()=>o(`list`),children:i(`project_work_list`)}),(0,f.jsx)(c,{size:`sm`,variant:a===`board`?`default`:`outline`,"aria-pressed":a===`board`,onClick:()=>o(`board`),children:i(`project_work_board`)}),(0,f.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>{m(null),l(e.target.checked)}}),i(`project_work_cancelled`)]}),(0,f.jsx)(c,{size:`sm`,variant:`ghost`,disabled:y||!b,onClick:w,children:i(`refresh_aee88743`)})]}),(0,f.jsx)(he,{projectId:e.id,projectActive:e.status===`active`,snapshot:_?.snapshot??null,owner:b,filter:h,onRefresh:w,onFilterChange:e=>{m(null),g(e)}}),(0,f.jsxs)(`details`,{className:`mb-3 rounded-lg border p-3 text-xs`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer`,children:i(`project_work_context`)}),(0,f.jsx)(`p`,{className:`mt-2`,children:(0,f.jsx)(_e,{context:{project_id:e.id,project_revision:e.revision,resource_revision:e.resource_revision}})}),(0,f.jsx)(`p`,{className:`mt-2 font-medium`,children:i(`project_work_repos`)}),(0,f.jsxs)(`ul`,{children:[e.project_path&&!e.workspace_bindings.some(t=>t.path===e.project_path)?(0,f.jsx)(`li`,{className:`break-all`,children:e.project_path}):null,e.workspace_bindings.map(e=>(0,f.jsxs)(`li`,{className:`break-all`,children:[e.label?`${e.label}: `:``,e.path]},e.path))]})]}),b?null:(0,f.jsx)(`p`,{role:`status`,children:i(`project_work_access`)}),v?(0,f.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-destructive`,children:v}):null,_&&!N?(0,f.jsx)(`p`,{role:`status`,className:`mb-3 text-sm`,children:i(`project_work_partial`)}):null,_?(0,f.jsxs)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:[ge.map(e=>`${$(e)}: ${N?_.data.counts[e]:`?`}`).join(` · `),` · `,i(`ticket_blocked_9059acb4`),`: `,N?_.data.counts.blocked:`?`,` · `,i(`cancelled_a37778f1`),`: `,N?_.data.counts.cancelled:`?`]}):null,a===`list`?(0,f.jsx)(`div`,{className:`grid gap-2`,children:D.map(P)}):(0,f.jsx)(`div`,{className:`project-work-stages grid grid-cols-1 gap-3`,children:ge.map(e=>(0,f.jsxs)(`section`,{"aria-label":$(e),className:`min-w-0 rounded-xl bg-muted/40 p-2`,children:[(0,f.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:$(e)}),(0,f.jsx)(`div`,{className:`grid gap-2`,children:D.filter(t=>t.stage===e).map(P)})]},e))}),a===`board`&&D.some(e=>e.stage===null)?(0,f.jsxs)(`section`,{className:`mt-3`,children:[(0,f.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:i(`project_work_other`)}),(0,f.jsx)(`div`,{className:`grid gap-2`,children:D.filter(e=>e.stage===null).map(P)})]}):null,_&&!D.length?(0,f.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:i(`project_work_empty`)}):null,y?(0,f.jsx)(`p`,{role:`status`,className:`mt-3 text-sm`,children:i(`project_work_loading`)}):null,_?.next_cursor?(0,f.jsx)(c,{className:`mt-3`,variant:`outline`,disabled:y,onClick:()=>void E(),children:i(`project_work_more`)}):null,O&&_?(0,f.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,f.jsx)(ye,{row:O,snapshot:_.snapshot,projectId:e.id,onOpenSession:n,onClose:()=>m(null)},`${_.snapshot.commit}:${O.ticket.id}`),j?(0,f.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:i(`project_work_controls_unavailable_context`)}):null,k?(0,f.jsx)(x,{...k,owner:b&&k.owner,command:xe(k.command,O,_.snapshot),copy:C()},`planning:${O.ticket.id}:${O.ticket.generation}`):null,A?(0,f.jsx)(S,{...A,owner:b&&A.owner,commands:M,copy:C()},`owner:${O.ticket.id}:${O.ticket.generation}`):null]}):null]})}export{Se as ProjectWorkBoard};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./vendor-react-CCIEwYL0.js";import{i as r,r as i}from"./ui-OvgR8HKW.js";import{c as a,s as o,t as s}from"./api-CPcpMjoM.js";import{t as c}from"./button-Cfb4l-V4.js";import{t as l}from"./ownerAccessContext-DnfKhLRV.js";import{t as u}from"./ticketWorkLabels-BNVpjOJX.js";var d=e(t(),1),f=n();function p({status:e,submitting:t,uncertain:n,copy:r,onReload:i,onReconcile:a}){let o=e.phase===`idle`?null:{requested:r.requestSent,awaiting_ack:r.awaitingAck,acknowledged:r.acknowledged,conflict:r.conflict,denied:r.denied,outcome_unknown:r.outcomeUnknown,failed:r.failed}[e.phase],s=n||[`conflict`,`denied`,`outcome_unknown`,`failed`].includes(e.phase);return(0,f.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[t?(0,f.jsx)(`p`,{role:`status`,children:r.submitting}):null,n?(0,f.jsx)(`p`,{role:`alert`,className:`break-words text-destructive`,children:r.outcomeUnknown}):null,o?(0,f.jsxs)(`div`,{role:s?`alert`:`status`,className:`break-words`,children:[(0,f.jsx)(`p`,{children:o}),e.phase===`idle`?null:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.operation,`: `,(0,f.jsx)(`span`,{className:`break-all`,children:e.operationId})]}),e.detail?(0,f.jsx)(`p`,{children:e.detail}):null]})]}):null,s?(0,f.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,f.jsx)(`button`,{type:`button`,className:`rounded-md border px-3 py-2 outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:i,children:r.reload}),e.phase!==`idle`&&a?(0,f.jsx)(`button`,{type:`button`,className:`rounded-md border px-3 py-2 outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>a(e.operationId),children:r.reconcile}):null]}):null]})}function m(e){let t=(0,d.useRef)(new Set),n=(0,d.useRef)(null),[r,i]=(0,d.useState)(null),a=async(r,a)=>{if(!(e.some(e=>t.current.has(e))||n.current!==null&&e.includes(n.current))){t.current.add(r),n.current=r,i({operationId:r,phase:`submitting`});try{if((await a()).operationId!==r)throw Error(`Mismatched operation receipt`);i(e=>e?.operationId===r?null:e)}catch{i(e=>e?.operationId===r?{operationId:r,phase:`uncertain`}:e)}finally{n.current===r&&(n.current=null)}}},o=!!r&&e.includes(r.operationId);return{send:a,sent:e=>!!e&&t.current.has(e),operationId:o?r.operationId:null,submitting:o&&r.phase===`submitting`,uncertain:o&&r.phase===`uncertain`}}var h=[`low`,`medium`,`high`,`critical`];function g(e){if(typeof e!=`string`)return null;let t=/^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?([Zz]|[+-]\d{2}:\d{2})$/.exec(e);if(!t||t[8]===`-00:00`)return null;let[,n,r,i,a,o,s,,c]=t,[l,u,d,f,p,m]=[n,r,i,a,o,s].map(Number),h=[31,l%4==0&&(l%100!=0||l%400==0)?29:28,31,30,31,30,31,31,30,31,30,31];if(u<1||u>12||d<1||d>h[u-1]||f>23||p>59||m>59||c.toUpperCase()!==`Z`&&(Number(c.slice(1,3))>23||Number(c.slice(4,6))>59))return null;let g=Date.parse(e);if(!Number.isFinite(g))return null;let _=(t[7]??``).padEnd(9,`0`);return BigInt(g)*1000000n+BigInt(_.slice(3))}function _(e,t,n){if(e===void 0)return`unknown`;if(e===null)return`unset`;let r=g(e);if(r===null)return`invalid`;if(n===`accepted`||n===`cancelled`)return`terminal`;let i=g(t);return i===null?`as_of_unknown`:r<i?`overdue`:`within_deadline`}function v(e){if(!h.includes(e.priority))return null;let t=e.expectedCompletionAt.trim();return t&&g(t)===null?null:{priority:e.priority,expectedCompletionAt:t||null}}function y(e,t){return!!e?.operationId&&e.workId===t.id&&e.generation===t.generation&&e.recordRevision===t.recordRevision&&!!e.binding?.scope_id&&Number.isSafeInteger(e.generation)&&e.generation>=1&&Number.isSafeInteger(e.recordRevision)&&e.recordRevision>=1&&!!e.binding.supervisor_session_id&&Number.isSafeInteger(e.binding.binding_revision)&&e.binding.binding_revision>=1&&Number.isSafeInteger(e.expectedSeq)&&e.expectedSeq>=0&&Number.isSafeInteger(e.expectedEpoch)&&e.expectedEpoch>=1}var b=`min-w-0 w-full rounded-md border bg-background px-3 py-2 text-sm disabled:opacity-50 outline-none focus-visible:ring-2 focus-visible:ring-ring`;function x(e){let{work:t,current:n,draft:r,query:i,owner:a,editCapability:o,queryCapability:s,command:l,request:u,copy:x,onDraftChange:S,onQueryChange:C,onSavePlanning:w,onReload:T,onReconcile:E}=e,D=(0,d.useId)(),O=m(l?[l.operationId]:[]),k=v(r),A=u.phase!==`idle`||O.submitting||O.uncertain||O.sent(l?.operationId),j=a&&o.available&&n!==null&&y(l,t)&&!A,M=!!k&&!!n&&k.priority===n.priority&&k.expectedCompletionAt===n.expectedCompletionAt,N=_(n?.expectedCompletionAt,i.asOf,t.state),P={unknown:x.deadlineUnknown,unset:x.deadlineUnset,invalid:x.deadlineInvalid,as_of_unknown:x.asOfUnknown,overdue:x.overdue,within_deadline:x.withinDeadline,terminal:x.terminalDeadline}[N],F=a?o.available?n===null?x.unsupported:y(l,t)?null:x.unavailableContext:o.reason||x.unsupported:x.ownerRequired;return(0,f.jsxs)(`section`,{"aria-labelledby":`${D}-title`,className:`min-w-0 space-y-4 rounded-xl border bg-background p-4 text-sm`,"data-testid":`project-work-planning-controls`,children:[(0,f.jsx)(`h3`,{id:`${D}-title`,className:`font-semibold`,children:x.planning}),(0,f.jsxs)(`div`,{className:`space-y-1 break-words`,"aria-label":x.currentPlanning,children:[(0,f.jsxs)(`p`,{children:[x.priority,`: `,n?x.priorities[n.priority]:x.unsupported]}),(0,f.jsxs)(`p`,{children:[x.desiredDeadline,`: `,n?n.expectedCompletionAt===null?x.deadlineUnset:(0,f.jsx)(`time`,{className:`break-all`,dateTime:g(n.expectedCompletionAt)===null?void 0:n.expectedCompletionAt,children:n.expectedCompletionAt||x.deadlineInvalid}):x.deadlineUnknown]}),(0,f.jsx)(`p`,{className:N===`overdue`?`font-medium text-destructive`:`text-muted-foreground`,"data-deadline-status":N,children:P})]}),(0,f.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),j&&k&&!M&&l&&O.send(l.operationId,()=>w(k,l))},children:[(0,f.jsxs)(`fieldset`,{disabled:!j,className:`grid min-w-0 gap-3 sm:grid-cols-2`,children:[(0,f.jsxs)(`label`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:x.priority}),(0,f.jsx)(`select`,{className:b,value:r.priority,onChange:e=>S({...r,priority:e.target.value}),children:h.map(e=>(0,f.jsx)(`option`,{value:e,children:x.priorities[e]},e))})]}),(0,f.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`label`,{htmlFor:`${D}-deadline`,children:x.desiredDeadline}),(0,f.jsx)(`input`,{id:`${D}-deadline`,className:b,type:`text`,value:r.expectedCompletionAt,placeholder:`2026-10-18T18:00:00+08:00`,"aria-describedby":`${D}-deadline-help${k?``:` ${D}-deadline-error`}`,"aria-invalid":!k,onChange:e=>S({...r,expectedCompletionAt:e.target.value})}),(0,f.jsx)(`button`,{type:`button`,className:`rounded px-1 py-1 text-xs underline disabled:opacity-50 outline-none focus-visible:ring-2 focus-visible:ring-ring`,disabled:!r.expectedCompletionAt,onClick:()=>S({...r,expectedCompletionAt:``}),children:x.clearDeadline})]})]}),(0,f.jsx)(`p`,{id:`${D}-deadline-help`,className:`text-xs text-muted-foreground`,children:x.deadlineHelp}),k?null:(0,f.jsx)(`p`,{id:`${D}-deadline-error`,role:`alert`,className:`text-destructive`,children:x.invalidDeadline}),F?(0,f.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:F}):null,(0,f.jsx)(c,{type:`submit`,size:`sm`,disabled:!j||!k||M,children:x.savePlanning})]}),(0,f.jsx)(p,{status:O.uncertain&&(u.phase===`idle`||u.phase===`requested`||u.phase===`awaiting_ack`)?{phase:`outcome_unknown`,operationId:O.operationId}:u,submitting:O.submitting,uncertain:!1,copy:x,onReload:T,onReconcile:E}),(0,f.jsxs)(`fieldset`,{disabled:!s.available,"aria-labelledby":`${D}-query`,className:`grid min-w-0 gap-3 border-t pt-3 sm:grid-cols-2`,children:[(0,f.jsx)(`legend`,{id:`${D}-query`,className:`px-1 font-medium`,children:x.query}),(0,f.jsxs)(`label`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:x.order}),(0,f.jsxs)(`select`,{className:b,value:i.order,onChange:e=>C({...i,order:e.target.value}),children:[(0,f.jsx)(`option`,{value:`updated`,children:x.orderUpdated}),(0,f.jsx)(`option`,{value:`priority`,children:x.orderPriority}),(0,f.jsx)(`option`,{value:`expected_completion`,children:x.orderDeadline})]})]}),(0,f.jsxs)(`label`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:x.filterPriority}),(0,f.jsxs)(`select`,{className:b,value:i.priority??`all`,onChange:e=>C({...i,priority:e.target.value===`all`?null:e.target.value}),children:[(0,f.jsx)(`option`,{value:`all`,children:x.allPriorities}),h.map(e=>(0,f.jsx)(`option`,{value:e,children:x.priorities[e]},e))]})]}),(0,f.jsxs)(`label`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:x.filterDeadline}),(0,f.jsxs)(`select`,{className:b,value:i.deadline,onChange:e=>C({...i,deadline:e.target.value}),children:[(0,f.jsx)(`option`,{value:`any`,children:x.anyDeadline}),(0,f.jsx)(`option`,{value:`overdue`,disabled:g(i.asOf)===null,children:x.overdueOnly}),(0,f.jsx)(`option`,{value:`unset`,children:x.unsetOnly})]})]})]}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:x.serverQueryHelp}),s.available?null:(0,f.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:s.reason||x.unsupported}),(0,f.jsxs)(`p`,{className:`break-all text-xs text-muted-foreground`,children:[x.asOf,`: `,g(i.asOf)===null?x.asOfUnknown:(0,f.jsx)(`time`,{dateTime:i.asOf,children:i.asOf})]})]})}function S(e){let{work:t,owner:n,capabilities:r,commands:i,request:a,acceptance:o,acceptanceConfirmation:s,acceptedByUser:l,copy:u,onAcceptanceConfirmationChange:h,onRequestAction:g,onReload:_,onReconcile:v}=e,b=(0,d.useId)(),x=m(Object.values(i).map(e=>e.operationId)),S=a.phase!==`idle`||x.submitting||x.uncertain||Object.values(i).some(e=>x.sent(e.operationId)),C=!!o&&o.stopGuardEnforced===!0&&o.processStopped===!0&&!o.stale&&o.generation===t.generation&&!!o.submissionId&&o.submissionId===t.currentSubmissionId&&o.contractRevision===t.contractRevision&&Number.isSafeInteger(o.contractRevision)&&o.contractRevision>=1,w=!!o&&s?.submissionId===o.submissionId&&s.generation===o.generation&&s.contractRevision===o.contractRevision,T=e=>n&&r[e].available&&y(i[e],t)&&!S&&(e!==`accept`||C&&w),E=e=>{let t=i[e];if(!T(e)||!t)return;let n=e===`accept`&&o?{kind:`accept`,source:`user`,submissionId:o.submissionId,generation:o.generation,contractRevision:o.contractRevision,unverifiedItems:[...o.unverifiedItems]}:{kind:e};x.send(t.operationId,()=>g(n,t))};return(0,f.jsxs)(`section`,{"aria-labelledby":`${b}-title`,className:`min-w-0 space-y-3 rounded-xl border bg-background p-4 text-sm`,"data-testid":`project-work-owner-controls`,children:[(0,f.jsx)(`h3`,{id:`${b}-title`,className:`font-semibold`,children:u.ownerControls}),(0,f.jsxs)(`p`,{children:[u.actualState,`: `,(0,f.jsx)(`strong`,{"data-testid":`work-authoritative-state`,children:u.states[t.state]}),t.paused===!0?` · ${u.paused}`:t.paused===null?` · ${u.pauseUnknown}`:``]}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u.actualStateHelp}),n?null:(0,f.jsx)(`p`,{role:`status`,children:u.ownerRequired}),(0,f.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`pause`,`resume`,`cancel`].map(e=>(0,f.jsxs)(`div`,{className:`min-w-0 max-w-full space-y-1`,children:[(0,f.jsx)(c,{type:`button`,size:`sm`,variant:e===`cancel`?`destructive`:`outline`,disabled:!T(e),onClick:()=>E(e),children:u[e]}),r[e].available?y(i[e],t)?null:(0,f.jsx)(`p`,{className:`max-w-xs text-xs text-muted-foreground`,children:u.unavailableContext}):(0,f.jsx)(`p`,{className:`max-w-xs break-words text-xs text-muted-foreground`,children:r[e].reason||u.unsupported})]},e))}),(0,f.jsxs)(`div`,{className:`min-w-0 space-y-2 border-t pt-3`,children:[o?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`p`,{className:`break-all`,children:[u.submission,`: `,o.submissionId]}),(0,f.jsx)(`p`,{className:`font-medium`,children:u.evidence}),o.evidence.length?(0,f.jsx)(`ul`,{className:`list-inside list-disc break-words`,children:o.evidence.map((e,t)=>(0,f.jsx)(`li`,{children:e},t))}):(0,f.jsx)(`p`,{children:u.evidenceNotRecorded}),(0,f.jsx)(`p`,{className:`font-medium`,children:u.unverified}),o.unverifiedItems.length?(0,f.jsx)(`ul`,{className:`list-inside list-disc break-words`,children:o.unverifiedItems.map((e,t)=>(0,f.jsx)(`li`,{children:e},t))}):(0,f.jsx)(`p`,{className:`text-muted-foreground`,children:u.noUnverifiedRecorded})]}):null,(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u.userAcceptance}),C?null:(0,f.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:u.completionGuard}),r.accept.available?null:(0,f.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:r.accept.reason||u.unsupported}),(0,f.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,f.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:w,disabled:!n||!r.accept.available||!C||S,onChange:e=>h(e.target.checked&&o?{submissionId:o.submissionId,generation:o.generation,contractRevision:o.contractRevision}:null)}),(0,f.jsx)(`span`,{children:u.acceptanceConfirmation})]}),(0,f.jsx)(c,{type:`button`,size:`sm`,disabled:!T(`accept`),onClick:()=>E(`accept`),children:u.accept}),t.state===`accepted`&&l?(0,f.jsx)(`p`,{className:`font-medium`,children:u.acceptedByUser}):null]}),(0,f.jsx)(p,{status:x.uncertain&&(a.phase===`idle`||a.phase===`requested`||a.phase===`awaiting_ack`)?{phase:`outcome_unknown`,operationId:x.operationId}:a,submitting:x.submitting,uncertain:!1,copy:u,onReload:_,onReconcile:v})]})}function C(){return{planning:i(`project_work_controls_planning`),priority:i(`project_work_controls_priority`),desiredDeadline:i(`project_work_controls_desired_deadline`),deadlineHelp:i(`project_work_controls_deadline_help`),clearDeadline:i(`project_work_controls_clear_deadline`),currentPlanning:i(`project_work_controls_current_planning`),savePlanning:i(`project_work_controls_save_planning`),unsupported:i(`project_work_controls_unsupported`),ownerRequired:i(`project_work_controls_owner_required`),unavailableContext:i(`project_work_controls_unavailable_context`),invalidDeadline:i(`project_work_controls_invalid_deadline`),deadlineUnknown:i(`project_work_controls_deadline_unknown`),deadlineUnset:i(`project_work_controls_deadline_unset`),deadlineInvalid:i(`project_work_controls_deadline_invalid`),overdue:i(`project_work_controls_overdue`),withinDeadline:i(`project_work_controls_within_deadline`),terminalDeadline:i(`project_work_controls_terminal_deadline`),asOfUnknown:i(`project_work_controls_as_of_unknown`),asOf:i(`project_work_controls_as_of`),query:i(`project_work_controls_query`),order:i(`project_work_controls_order`),orderUpdated:i(`project_work_controls_order_updated`),orderPriority:i(`project_work_controls_order_priority`),orderDeadline:i(`project_work_controls_order_deadline`),filterPriority:i(`project_work_controls_filter_priority`),allPriorities:i(`project_work_controls_all_priorities`),filterDeadline:i(`project_work_controls_filter_deadline`),anyDeadline:i(`project_work_controls_any_deadline`),overdueOnly:i(`project_work_controls_overdue_only`),unsetOnly:i(`project_work_controls_unset_only`),serverQueryHelp:i(`project_work_controls_server_query_help`),ownerControls:i(`project_work_controls_owner_controls`),actualState:i(`project_work_controls_actual_state`),paused:i(`project_work_controls_paused`),pauseUnknown:i(`project_work_controls_pause_unknown`),pause:i(`project_work_controls_pause`),resume:i(`project_work_controls_resume`),cancel:i(`project_work_controls_cancel`),accept:i(`project_work_controls_accept`),submitting:i(`project_work_controls_submitting`),requestSent:i(`project_work_controls_request_sent`),awaitingAck:i(`project_work_controls_awaiting_ack`),acknowledged:i(`project_work_controls_acknowledged`),conflict:i(`project_work_controls_conflict`),denied:i(`project_work_controls_denied`),outcomeUnknown:i(`project_work_controls_outcome_unknown`),failed:i(`project_work_controls_failed`),reload:i(`project_work_controls_reload`),reconcile:i(`project_work_controls_reconcile`),operation:i(`project_work_controls_operation`),actualStateHelp:i(`project_work_controls_actual_state_help`),completionGuard:i(`project_work_controls_completion_guard`),submission:i(`project_work_controls_submission`),evidence:i(`project_work_controls_evidence`),unverified:i(`project_work_controls_unverified`),evidenceNotRecorded:i(`project_work_controls_evidence_not_recorded`),noUnverifiedRecorded:i(`project_work_controls_no_unverified_recorded`),userAcceptance:i(`project_work_controls_user_acceptance`),acceptanceConfirmation:i(`project_work_controls_acceptance_confirmation`),acceptedByUser:i(`project_work_controls_accepted_by_user`),priorities:{low:i(`project_work_controls_priorities_low`),medium:i(`project_work_controls_priorities_medium`),high:i(`project_work_controls_priorities_high`),critical:i(`project_work_controls_priorities_critical`)},states:{draft:i(`project_work_controls_states_draft`),ready:i(`project_work_controls_states_ready`),active:i(`project_work_controls_states_active`),submitted:i(`project_work_controls_states_submitted`),accepted:i(`project_work_controls_states_accepted`),blocked:i(`project_work_controls_states_blocked`),cancelled:i(`project_work_controls_states_cancelled`)}}}function w(e,t){if(e.commit!==t.commit||e.seq!==t.seq||e.authority_epoch!==t.authority_epoch||!e.commit||!Number.isSafeInteger(e.seq)||e.seq<0||!Number.isSafeInteger(e.authority_epoch)||e.authority_epoch<1)throw Error(i(`ticket_the_ticket_snapshot_is_inconsistent_refresh_a_4e2cb547`))}function T(e){let t=e.next_cursor!==null;return[`complete`,`authoritative_scope`].includes(e.coverage)&&(t||!e.truncated&&e.omitted_count===0)&&e.index_seq>=e.snapshot.seq}var E={async page(e,t,n,r,a){let o=await s.post(`tickets/project-board`,{project_id:e,include_cancelled:t,include_archived:!1,limit:100,cursor:n?.next_cursor??null,fixed_commit:n?.snapshot.commit??null,...a?{sprint_filter:a}:{}},{signal:r});if(w(o.snapshot,n?.snapshot??o.snapshot),[`todo`,`doing`,`testing`,`done`,`blocked`,`cancelled`,`total`].some(e=>{let t=o.data.counts[e];return!Number.isSafeInteger(t)||t<0})||o.data.project_id!==e||o.data.rows.some(e=>!e.ticket.id)||new Set(o.data.rows.map(e=>e.ticket.id)).size!==o.data.rows.length)throw Error(i(`project_work_inconsistent`));let c=o.next_cursor;if(c&&(c.commit!==o.snapshot.commit||!Number.isSafeInteger(c.offset)||c.offset<=(n?.next_cursor?.offset??0)||n?.next_cursor&&c.query_hash!==n.next_cursor.query_hash))throw Error(i(`project_work_inconsistent`));if(!n)return o;if(Object.keys(n.data.counts).some(e=>o.data.counts[e]!==n.data.counts[e])||o.data.rows.some(e=>n.data.rows.some(t=>t.ticket.id===e.ticket.id)))throw Error(i(`project_work_inconsistent`));return{...o,data:{...o.data,rows:[...n.data.rows,...o.data.rows]}}},async inspect(e,t,n){let r=await s.post(`tickets/inspect`,{ids:[e],sections:[`assignments`,`requests`,`submissions`],depth:0,budget_bytes:65536,fixed_commit:t.commit},{signal:n});if(w(r.snapshot,t),![`complete`,`authoritative_scope`].includes(r.coverage)||r.index_seq<t.seq||r.truncated||r.omitted_count||r.data.length!==1||r.data[0].ticket.id!==e)throw Error(i(`project_work_inconsistent`));return r.data[0]}},D=()=>Error(i(`project_work_inconsistent`)),O=(e,t=0)=>Number.isSafeInteger(e)&&e>=t,k=e=>e?.kind===`sprint`?JSON.stringify([`sprint`,e.sprint_id]):e?.kind??`all`;function A(e,t){if(!e||!e.commit||!O(e.seq)||!O(e.authority_epoch,1)||t&&(e.commit!==t.commit||e.seq!==t.seq||e.authority_epoch!==t.authority_epoch))throw D()}function j(e,t){if(A(e.snapshot,t),![`complete`,`authoritative_scope`].includes(e.coverage)||!O(e.index_seq)||e.index_seq<e.snapshot.seq||!O(e.omitted_count))throw D()}function M(e){if(!e||[`total`,`accepted`,`pending_acceptance`,`blocked`,`cancelled`,`unfinished`].some(t=>!O(e[t]))||e.total!==e.accepted+e.cancelled+e.unfinished||e.pending_acceptance>e.unfinished||e.blocked>e.unfinished)throw D()}function N(e){if(!e||typeof e.name!=`string`||!e.name.trim()||typeof e.goal!=`string`||!e.goal.trim()||[e.starts_at,e.ends_at].some(e=>e!==null&&!Number.isSafeInteger(e))||e.starts_at!==null&&e.ends_at!==null&&e.ends_at<e.starts_at)throw D()}function P(e){if(!e||!O(e.record_revision,1)||!O(e.contract_revision,1)||!O(e.generation)||![`draft`,`ready`,`active`,`submitted`,`accepted`,`blocked`,`cancelled`].includes(e.state)||typeof e.accepted!=`boolean`||typeof e.paused!=`boolean`||typeof e.archived!=`boolean`)throw D()}function F(e){if(!e?.source_commit||!O(e.source_seq)||!O(e.closed_seq)||e.closed_seq<=e.source_seq||!e.members||(M(e.counts),Object.keys(e.members).length!==e.counts.total))throw D();for(let t of Object.values(e.members))if(P(t.version),![`accepted`,`cancelled`,`backlog`,`sprint`].includes(t.disposition?.disposition)||t.disposition.disposition===`sprint`&&!t.disposition.sprint_id)throw D()}function I(e,t){if(!e?.id||e.project_id!==t||![`planned`,`active`,`closed`].includes(e.status)||!O(e.revision,1)||!O(e.created_seq)||!O(e.updated_seq)||e.updated_seq<e.created_seq)throw D();N(e.definition)}var L=e=>JSON.stringify(e&&typeof e==`object`?Array.isArray(e)?e.map(e=>JSON.parse(L(e))):Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,JSON.parse(L(t))])):e),R={async list(e,t,n,r){let i=t?.snapshot??n,a=await s.post(`tickets/sprints/list`,{project_id:e,status:null,limit:100,cursor:t?.next_cursor??null,fixed_commit:i?.commit??null},{signal:r});if(j(a,i),!Array.isArray(a.data)||new Set(a.data.map(e=>e.id)).size!==a.data.length)throw D();for(let t of a.data)if(I(t,e),!O(t.member_count)||(t.closure_counts&&M(t.closure_counts),t.status===`closed`!=(t.closure_counts!==null)))throw D();let o=a.next_cursor;if(o&&(o.commit!==a.snapshot.commit||!o.query_hash||!O(o.offset,1)||o.offset<=(t?.next_cursor?.offset??0)||t?.next_cursor&&o.query_hash!==t.next_cursor.query_hash)||!o&&(a.truncated||a.omitted_count!==0))throw D();if(!t)return a;if(a.data.some(e=>t.data.some(t=>t.id===e.id)))throw D();return{...a,data:[...t.data,...a.data]}},async inspect(e,t,n,r){let i=await s.post(`tickets/sprints/inspect`,{project_id:e,sprint_id:t,fixed_commit:n.commit},{signal:r});if(j(i,n),i.next_cursor||i.truncated||i.omitted_count!==0||i.data.sprint.id!==t)throw D();let{sprint:a,current_members:o,current_counts:c}=i.data;if(I(a,e),M(c),!Array.isArray(a.members)||new Set(a.members).size!==a.members.length||!Array.isArray(a.history)||!o||Object.keys(o).length!==a.members.length||c.total!==a.members.length||a.members.some(e=>!Object.hasOwn(o,e)))throw D();for(let e of Object.values(o))P(e);if(a.status===`closed`!=(a.closure!==null)||a.closure&&(F(a.closure),a.closure.closed_seq>n.seq||a.members.some(e=>!Object.hasOwn(a.closure.members,e))))throw D();return i},async scope(e){let t=await s.get(`tickets/scope`,{signal:e});if(t.available&&t.binding&&(!t.binding.scope_id||!t.binding.supervisor_session_id||!O(t.binding.binding_revision,1)))throw D();return t},async command(e){let t=await s.postOnce(`tickets/sprints/command`,e),n=t.operation;if(!n||n.operation_id!==e.operation_id||n.ids?.sprint!==e.sprint_id||!O(n.committed_seq)||n.committed_seq<=e.expected_seq||!n.request_hash||!n.principal)throw D();let r;try{r=JSON.parse(n.canonical_request)}catch{throw D()}if(!Array.isArray(r)||r[0]!==`sprint`||L(r[1])!==L(e)||e.action.op===`close`!=(t.closure!==null))throw D();return t.closure&&F(t.closure),t}};function ee(e,t,n){r();let s=(0,d.useContext)(l),[c,u]=(0,d.useState)(null),[f,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(0),v=(0,d.useRef)(!1),y=(0,d.useRef)(null),b=n?.kind,x=n?.kind===`sprint`?n.sprint_id:null,S=(0,d.useMemo)(()=>b===`backlog`?{kind:`backlog`}:b===`sprint`&&x?{kind:`sprint`,sprint_id:x}:null,[b,x]),C=JSON.stringify([e,t,k(S)]),w=(0,d.useRef)(C),T=(0,d.useCallback)(()=>{y.current?.abort(),u(null),_(e=>e+1)},[]);return(0,d.useEffect)(()=>{let n=new AbortController;return y.current=n,w.current=C,v.current=!1,u(null),p(null),h(s),s&&E.page(e,t,void 0,n.signal,S).then(e=>{n.signal.aborted||u(e)}).catch(e=>{n.signal.aborted||p(a(e)&&e.status===404?i(`project_work_unsupported`):o(e))}).finally(()=>{n.signal.aborted||h(!1)}),window.addEventListener(`online`,T),()=>{n.abort(),window.removeEventListener(`online`,T)}},[e,t,s,g,T,C,S]),{page:s&&w.current===C?c:null,error:f,busy:m,refresh:T,loadMore:async()=>{if(!c?.next_cursor||m||v.current||!s||y.current?.signal.aborted)return;let n=y.current;v.current=!0,h(!0);try{let r=await E.page(e,t,c,n.signal,S);n.signal.aborted||(u(r),p(null))}catch(e){if(n.signal.aborted)return;a(e)&&[409,410].includes(e.status)?T():p(o(e))}finally{n.signal.aborted||(v.current=!1,h(!1))}},owner:s}}var z=e=>JSON.stringify([e.assignment_id,e.session_id,e.run_id]);async function B(e,t,n){let r=`unknown`;try{let{session:i}=await s.get(`sessions/${encodeURIComponent(e.session_id)}`,{signal:n});i?.id===e.session_id&&[`root`,`child`].includes(i.kind)&&(i.project_id==null||i.project_id===t)&&(r=`accessible`)}catch(e){if(n.aborted)throw e;a(e)&&(r=e.status===403?`denied`:e.status===404?`missing`:`unknown`)}return{...e,access:r}}function V(e,t,n,r){let[i,a]=(0,d.useState)(()=>navigator.onLine),[o,s]=(0,d.useState)({status:`unknown`}),c=(0,d.useRef)(0),l=(0,d.useRef)(null),u=(0,d.useRef)(new Map),f=(0,d.useMemo)(()=>{let n=new Map;for(let t of e??[])n.set(t.id,(n.get(t.id)??0)+1);return(e??[]).filter(e=>n.get(e.id)===1&&e.work_id===t&&Number.isSafeInteger(e.generation)&&e.generation>=1&&Number.isSafeInteger(e.authority_epoch)&&e.authority_epoch>=1&&e.runtime?.session_id&&e.runtime.run_id).map(e=>({assignment_id:e.id,session_id:e.runtime.session_id,run_id:e.runtime.run_id}))},[e,t]);(0,d.useEffect)(()=>{let e=()=>{navigator.onLine||l.current?.abort(),a(navigator.onLine)};return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[]);let p=(0,d.useCallback)(async(e,t,r)=>{let i=z(e),a=(u.current.get(i)??0)+1;u.current.set(i,a);try{let o=await B(e,n,t.signal);return t.signal.aborted||c.current!==r||u.current.get(i)!==a?void 0:(s(e=>({status:`available`,updatedAt:null,value:[...e.status===`available`?e.value.filter(e=>z(e)!==i):[],o]})),o)}catch{}},[n]);return(0,d.useEffect)(()=>{let t=new AbortController,n=++c.current;if(l.current=t,u.current.clear(),s({status:`unknown`}),r&&i&&e){let e=0;f.length||s({status:`available`,value:[],updatedAt:null});for(let r=0;r<Math.min(4,f.length);r++)(async()=>{for(;!t.signal.aborted&&e<f.length;)await p(f[e++],t,n)})()}return()=>{t.abort(),c.current+=1}},[e,f,r,i,p]),{online:i,sessions:r&&i?o:{status:`unknown`},recheck:async e=>{let t=l.current,n=f.find(t=>t.session_id===e);return!r||!i||!n||!t||t.signal.aborted?!1:(await p(n,t,c.current))?.access===`accessible`}}}function H(e){if(!e||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(e))return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function U(e,t,n=!1){if(!e)return`unsupported`;if(e.status!==`available`)return e.status;if(!Number.isFinite(t))return`unknown`;let r=H(e.updatedAt),i=H(e.validUntil);return e.updatedAt!=null&&(r===null||r>t)||e.validUntil!=null&&(i===null||i<=t||r!==null&&i<=r)||n&&(r===null||i===null)?`unknown`:`available`}function W(e,t){return e.work_id===t.work_id&&e.assignment_id===t.assignment_id&&e.generation===t.generation&&e.authority_epoch===t.authority_epoch}function G(e){let t=U(e.attempts,e.nowMs);if(t!==`available`)return{status:t};if(e.currentAssignmentId===null)return{status:`none`};let n=e.attempts.status===`available`?e.attempts.value.filter(t=>t.id===e.currentAssignmentId):[];if(n.length!==1)return{status:`unknown`};let r=n[0],i=[`admitted`,`running`,`blocked`,`cancelling`,`outcome_unknown`].includes(r.state);return r.work_id!==e.workId||r.generation!==e.generation||r.authority_epoch!==e.authorityEpoch||!Number.isSafeInteger(e.generation)||e.generation<1||!Number.isSafeInteger(e.authorityEpoch)||e.authorityEpoch<1||r.role!==void 0&&r.role!==`executor`||r.process_stopped||!i||!r.runtime?.session_id||!r.runtime.run_id?{status:`unknown`}:{status:`confirmed`,attempt:r}}function K(e,t,n){if(U(t,n,!0)!==`available`||t?.status!==`available`||!e.runtime||e.work_id===void 0||e.generation===void 0||e.authority_epoch===void 0)return;let{work_id:r,generation:i,authority_epoch:a,runtime:o}=e,s=t.value.filter(t=>W(t,{work_id:r,assignment_id:e.id,generation:i,authority_epoch:a})&&t.session_id===o.session_id&&t.run_id===o.run_id);if(s.length!==1)return;let c=s[0],l=H(t.updatedAt);if(![c.heartbeat_at,c.progress?.at,c.terminal?.at].filter(e=>e!=null).some(e=>{let t=H(e);return t===null||t>l})&&!(c.progress&&(!Number.isSafeInteger(c.progress.sequence)||c.progress.sequence<0||!c.progress.evidence_ref.trim()))&&!(c.terminal&&!c.terminal.evidence_ref.trim()))return c}function q(e,t,n){if(!e.runtime||U(t,n)!==`available`||t?.status!==`available`)return`unknown`;let r=t.value.filter(t=>t.assignment_id===e.id&&t.session_id===e.runtime.session_id&&t.run_id===e.runtime.run_id);return r.length===1?r[0].access:`unknown`}function J(e,t,n){let r=H(e.opened_at),i=H(e.recovery?.requested_at),a=H(e.recovery?.acknowledged_at);if(r===null||r>n||e.recovery?.requested_at!=null&&(i===null||i<r||i>n)||e.recovery?.acknowledged_at!=null&&(a===null||i===null||a<i||a>n))return`unconfirmed`;let o=i??r;if(t&&W(e,t)){let i=H(t.terminal?.at);if(i!==null&&i>=o&&i<=n&&t.terminal?.evidence_ref.trim())return`terminal_observed`;let a=H(t.progress?.at);if(e.progress_sequence!==null&&Number.isSafeInteger(e.progress_sequence)&&e.progress_sequence>=0&&t.progress&&Number.isSafeInteger(t.progress.sequence)&&t.progress.sequence>e.progress_sequence&&a!==null&&a>r&&a>=o&&a<=n&&t.progress.evidence_ref.trim())return`progress_observed`}return e.phase===`resolved`?`unconfirmed`:a===null?i===null?`not_recorded`:`requested`:`acknowledged`}function Y({label:e,children:t}){return(0,f.jsxs)(`div`,{className:`min-w-0`,children:[(0,f.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,f.jsx)(`dd`,{className:`mt-0.5 min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t})]})}function te(e){let{copy:t,nowMs:n,locale:r,workId:i}=e,a=(0,d.useId)(),o=e.attempts.status===`available`&&e.attempts.value.some(e=>e.work_id!==void 0&&e.work_id!==i)?{status:`unknown`,updatedAt:e.attempts.updatedAt}:e.attempts,s=G({...e,attempts:o}),l=U(o,n),u=e.attempts.status===`available`?e.attempts.value.filter(e=>e.work_id===void 0||e.work_id===i):[],p=s.attempt?K(s.attempt,e.observations,n):void 0,m=u.filter(e=>e!==s.attempt),h=e.incidents?.status===`available`&&e.incidents.value.some(e=>e.work_id!==i)?`unknown`:U(e.incidents,n,!0),g=e.incidents?.status===`available`?e.incidents.value.filter(e=>e.work_id===i):[],_=new Map;for(let e of g)_.set(e.id,(_.get(e.id)??0)+1);let v=e=>{let n=H(e);return n===null?(0,f.jsx)(`span`,{className:`text-muted-foreground`,children:t.notRecorded}):(0,f.jsx)(`time`,{dateTime:e,children:new Intl.DateTimeFormat(r,{dateStyle:`medium`,timeStyle:`long`}).format(n)})},y=e=>e?(0,f.jsx)(`code`,{className:`break-all text-xs`,children:e}):(0,f.jsx)(`span`,{className:`text-muted-foreground`,children:t.notRecorded}),b=r=>{let i=q(r,e.sessions,n),a=i===`accessible`&&e.onOpenSession&&r.runtime?.session_id,o=i===`denied`?t.sessionDenied:i===`missing`?t.sessionMissing:i===`accessible`?t.navigationUnavailable:t.sessionUnknown;return(0,f.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[y(r.runtime?.session_id),a?(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,className:`ml-2 h-auto max-w-full whitespace-normal text-left`,onClick:()=>e.onOpenSession(r.runtime.session_id),children:t.openSession}):(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o})]})},x=e=>(0,f.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,f.jsx)(Y,{label:t.assignment,children:y(e.id)}),(0,f.jsx)(Y,{label:t.role,children:t[e.role??`executor`]}),(0,f.jsx)(Y,{label:t.generation,children:Number.isSafeInteger(e.generation)?e.generation:t.notRecorded}),(0,f.jsx)(Y,{label:t.authorityEpoch,children:Number.isSafeInteger(e.authority_epoch)?e.authority_epoch:t.notRecorded}),e.step_id?(0,f.jsx)(Y,{label:t.step,children:y(e.step_id)}):null,(0,f.jsx)(Y,{label:t.attempt,children:y(e.attempt_id)}),(0,f.jsx)(Y,{label:t.session,children:b(e)}),(0,f.jsx)(Y,{label:t.run,children:y(e.runtime?.run_id)}),(0,f.jsx)(Y,{label:t.claimedAt,children:v(e.claimed_at)}),(0,f.jsx)(Y,{label:t.processStopped,children:e.process_stopped===!0?t.stoppedConfirmed:t.stopUnconfirmed}),(0,f.jsx)(Y,{label:t.endReason,children:e.end_reason||t.notRecorded}),e.awaiting_request?(0,f.jsx)(Y,{label:t.awaitingRequest,children:y(e.awaiting_request)}):null]}),S=`unknown`;return p&&s.attempt&&![`cancelling`,`outcome_unknown`].includes(s.attempt.state)&&(S=p.terminal?`terminal_observed`:p.execution===`running`&&s.attempt.state!==`running`?`unknown`:p.execution),(0,f.jsxs)(`section`,{"aria-labelledby":a,className:`min-w-0 rounded-xl border bg-background p-4 text-sm`,"data-testid":`assignment-health-panel`,children:[(0,f.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,f.jsx)(`h4`,{id:a,className:`font-semibold`,children:t.title}),(0,f.jsx)(`span`,{className:`rounded-md border px-2 py-0.5 text-xs`,"data-testid":`assignment-source-status`,children:t[l]})]}),(0,f.jsxs)(`p`,{className:`mt-1 break-words text-xs text-muted-foreground`,children:[t.updatedAt,`: `,v(e.attempts.updatedAt)]}),l===`available`?null:(0,f.jsx)(`p`,{role:`status`,className:`mt-2 break-words`,children:e.attempts.status!==`available`&&e.attempts.reason?e.attempts.reason:t.staleHint}),(0,f.jsxs)(`div`,{className:`mt-4 min-w-0`,"data-testid":`assignment-current`,children:[(0,f.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(`h5`,{className:`font-medium`,children:t.currentExecutor}),(0,f.jsx)(`span`,{className:`rounded-md bg-muted px-2 py-0.5 text-xs`,"data-testid":`assignment-owner-status`,children:s.status===`confirmed`?t.confirmed:s.status===`none`?t.noCurrentExecutor:t.ownerUnknown})]}),s.status===`none`?(0,f.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:t.noCurrentHint}):null,s.attempt?x(s.attempt):e.currentAssignmentId?(0,f.jsx)(`dl`,{children:(0,f.jsx)(Y,{label:t.assignment,children:y(e.currentAssignmentId)})}):null,(0,f.jsxs)(`div`,{className:`mt-3 rounded-lg bg-muted/40 p-3`,"data-testid":`assignment-observation`,children:[(0,f.jsx)(`p`,{className:`mb-2 font-medium`,"data-testid":`assignment-execution-status`,children:t[S]}),(0,f.jsxs)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:[t.updatedAt,`: `,v(p?e.observations?.updatedAt:null)]}),(0,f.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,f.jsx)(Y,{label:t.heartbeat,children:v(p?.heartbeat_at)}),(0,f.jsx)(Y,{label:t.progress,children:v(p?.progress?.at)}),(0,f.jsx)(Y,{label:t.waitReason,children:p?.wait_reason||t.notRecorded}),(0,f.jsx)(Y,{label:t.blockReason,children:e.blockReason||p?.block_reason||t.notRecorded}),(0,f.jsx)(Y,{label:t.nextCheck,children:v(p?.next_check_at)}),p?.progress?(0,f.jsx)(Y,{label:t.evidence,children:y(p.progress.evidence_ref)}):null,p?.terminal?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(Y,{label:t.terminal_observed,children:p.terminal.state}),(0,f.jsx)(Y,{label:t.evidence,children:y(p.terminal.evidence_ref)})]}):null]}),(0,f.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:t.heartbeatHint}),U(e.observations,n,!0)===`available`?null:(0,f.jsx)(`p`,{className:`mt-1 text-xs`,"data-testid":`assignment-observation-status`,children:t[U(e.observations,n,!0)]})]})]}),(0,f.jsxs)(`details`,{className:`mt-4 min-w-0 rounded-lg border p-3`,"data-testid":`assignment-history`,children:[(0,f.jsxs)(`summary`,{className:`cursor-pointer font-medium`,children:[t.history,` (`,m.length,`)`]}),m.length?(0,f.jsx)(`ul`,{className:`mt-3 grid min-w-0 gap-3`,children:m.map((e,t)=>(0,f.jsx)(`li`,{className:`min-w-0 rounded-lg bg-muted/30 p-3`,children:x(e)},`${e.id}:${t}`))}):(0,f.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:l===`available`?t.emptyHistory:t[l]})]}),(0,f.jsxs)(`div`,{className:`mt-4 min-w-0 border-t pt-3`,"data-testid":`assignment-patrol`,children:[(0,f.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(`h5`,{className:`font-medium`,children:t.patrol}),(0,f.jsx)(`span`,{className:`rounded-md border px-2 py-0.5 text-xs`,children:t[h]})]}),(0,f.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[t.updatedAt,`: `,v(e.incidents?.updatedAt)]}),h===`unsupported`?(0,f.jsx)(`p`,{className:`mt-2`,children:t.patrolUnsupported}):h===`unknown`?(0,f.jsx)(`p`,{className:`mt-2`,children:t.staleHint}):g.length?null:(0,f.jsx)(`p`,{className:`mt-2`,children:t.noIncidents}),e.incidents?.status!==`available`&&e.incidents?.reason?(0,f.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.incidents.reason}):null,(0,f.jsx)(`ul`,{className:`mt-3 grid min-w-0 gap-3`,children:g.map((r,a)=>{let o=s.attempt&&W(r,{work_id:i,assignment_id:s.attempt.id,generation:e.generation,authority_epoch:e.authorityEpoch}),c=o&&h===`available`&&_.get(r.id)===1,l=c?J(r,p,n):`unconfirmed`,u=l===`progress_observed`||l===`terminal_observed`,d=!c||r.phase===`resolved`&&!u?`unconfirmed`:r.phase;return(0,f.jsxs)(`li`,{className:`min-w-0 rounded-lg border p-3`,"data-testid":`assignment-incident`,children:[(0,f.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,f.jsx)(`h6`,{className:`font-medium`,children:o?t.incident:t.historicalIncident}),(0,f.jsx)(`span`,{className:`rounded-md bg-muted px-2 py-0.5 text-xs`,"data-testid":`assignment-incident-phase`,children:t[d]})]}),(0,f.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,f.jsx)(Y,{label:t.incident,children:y(r.id)}),(0,f.jsx)(Y,{label:t.work,children:y(r.work_id)}),(0,f.jsx)(Y,{label:t.assignment,children:y(r.assignment_id)}),(0,f.jsx)(Y,{label:t.generation,children:r.generation}),(0,f.jsx)(Y,{label:t.authorityEpoch,children:r.authority_epoch}),(0,f.jsx)(Y,{label:t.fingerprint,children:y(r.fingerprint)}),(0,f.jsx)(Y,{label:t.sourceRevision,children:y(r.source_revision)}),(0,f.jsx)(Y,{label:t.evidence,children:y(r.evidence_ref)}),(0,f.jsx)(Y,{label:t.blockReason,children:r.reason}),(0,f.jsx)(Y,{label:t.diagnosisAttempts,children:Number.isSafeInteger(r.attempts)&&r.attempts>=0?r.attempts:t.notRecorded}),(0,f.jsx)(Y,{label:t.findings,children:r.findings||t.notRecorded}),(0,f.jsx)(Y,{label:t.uncertainty,children:r.uncertainty||t.notRecorded}),(0,f.jsx)(Y,{label:t.escalation,children:r.escalation||t.notRecorded}),(0,f.jsx)(Y,{label:t.nextCheck,children:v(r.next_check_at)}),(0,f.jsx)(Y,{label:t.recovery,children:(0,f.jsx)(`span`,{"data-testid":`assignment-recovery-status`,children:t[l]})}),(0,f.jsx)(Y,{label:t.requestedAt,children:v(r.recovery?.requested_at)}),(0,f.jsx)(Y,{label:t.acknowledgedAt,children:v(r.recovery?.acknowledged_at)})]}),(0,f.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:t.recoveryHint})]},`${r.id}:${a}`)})})]})]})}var ne=()=>({title:i(`assignment_health_title`),updatedAt:i(`assignment_health_updated_at`),available:i(`assignment_health_available`),unsupported:i(`assignment_health_unsupported`),unknown:i(`assignment_health_unknown`),notRecorded:i(`assignment_health_not_recorded`),staleHint:i(`assignment_health_stale_hint`),currentExecutor:i(`assignment_health_current_executor`),confirmed:i(`assignment_health_confirmed`),noCurrentExecutor:i(`assignment_health_no_current_executor`),ownerUnknown:i(`assignment_health_owner_unknown`),assignment:i(`assignment_health_assignment`),step:i(`assignment_health_step`),attempt:i(`assignment_health_attempt`),session:i(`assignment_health_session`),run:i(`assignment_health_run`),role:i(`assignment_health_role`),executor:i(`assignment_health_executor`),collaborator:i(`assignment_health_collaborator`),reviewer:i(`assignment_health_reviewer`),claimedAt:i(`assignment_health_claimed_at`),heartbeat:i(`assignment_health_heartbeat`),progress:i(`assignment_health_progress`),heartbeatHint:i(`assignment_health_heartbeat_hint`),waitReason:i(`assignment_health_wait_reason`),blockReason:i(`assignment_health_block_reason`),awaitingRequest:i(`assignment_health_awaiting_request`),nextCheck:i(`assignment_health_next_check`),endReason:i(`assignment_health_end_reason`),history:i(`assignment_health_history`),emptyHistory:i(`assignment_health_empty_history`),openSession:i(`assignment_health_open_session`),sessionDenied:i(`assignment_health_session_denied`),sessionMissing:i(`assignment_health_session_missing`),sessionUnknown:i(`assignment_health_session_unknown`),navigationUnavailable:i(`assignment_health_navigation_unavailable`),patrol:i(`assignment_health_patrol`),patrolUnsupported:i(`assignment_health_patrol_unsupported`),noIncidents:i(`assignment_health_no_incidents`),incident:i(`assignment_health_incident`),historicalIncident:i(`assignment_health_historical_incident`),sourceRevision:i(`assignment_health_source_revision`),evidence:i(`assignment_health_evidence`),fingerprint:i(`assignment_health_fingerprint`),diagnosisAttempts:i(`assignment_health_diagnosis_attempts`),findings:i(`assignment_health_findings`),uncertainty:i(`assignment_health_uncertainty`),escalation:i(`assignment_health_escalation`),recovery:i(`assignment_health_recovery`),requestedAt:i(`assignment_health_requested_at`),acknowledgedAt:i(`assignment_health_acknowledged_at`),recoveryHint:i(`assignment_health_recovery_hint`),running:i(`assignment_health_running`),waiting:i(`assignment_health_waiting`),blocked:i(`assignment_health_blocked`),open:i(`assignment_health_open`),diagnosing:i(`assignment_health_diagnosing`),cooldown:i(`assignment_health_cooldown`),resolved:i(`assignment_health_resolved`),requested:i(`assignment_health_requested`),acknowledged:i(`assignment_health_acknowledged`),progress_observed:i(`assignment_health_progress_observed`),terminal_observed:i(`assignment_health_terminal_observed`),unconfirmed:i(`assignment_health_unconfirmed`),not_recorded:i(`assignment_health_recovery_not_recorded`),work:i(`assignment_health_work`),generation:i(`assignment_health_generation`),authorityEpoch:i(`assignment_health_authority_epoch`),noCurrentHint:i(`assignment_health_no_current_hint`),processStopped:i(`assignment_health_process_stopped`),stoppedConfirmed:i(`assignment_health_stopped_confirmed`),stopUnconfirmed:i(`assignment_health_stop_unconfirmed`)}),re=new Map,X=`lotus-sprint-command-changed`;function ie(e,t,n,r,i,s=re){let[c,l]=(0,d.useState)(null),[,u]=(0,d.useState)(0),[f,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(0),v=(0,d.useRef)(null),y=(0,d.useRef)(s),b=(0,d.useRef)(!1),x=(0,d.useRef)(!1),S=(0,d.useRef)(!0),C=(0,d.useRef)(e),[w,T]=(0,d.useState)(()=>navigator.onLine);C.current=e;let E=t?.commit,D=t?.seq,O=t?.authority_epoch,k=(0,d.useMemo)(()=>E!==void 0&&D!==void 0&&O!==void 0?{commit:E,seq:D,authority_epoch:O}:null,[E,D,O]);(0,d.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]),(0,d.useEffect)(()=>{let e=()=>u(e=>e+1);return window.addEventListener(X,e),()=>window.removeEventListener(X,e)},[]),(0,d.useEffect)(()=>{let e=()=>T(navigator.onLine);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[]);let A=(0,d.useCallback)(()=>{v.current?.abort(),_(e=>e+1)},[]);(0,d.useEffect)(()=>{let t=new AbortController;if(v.current=t,x.current=!1,h(!1),!r||!k)return()=>t.abort();let i={projectId:e,selectedId:n,commit:k.commit,list:null,inspection:null,scope:null,status:`loading`,error:null};return l(i),Promise.all([R.list(e,void 0,k,t.signal),R.scope(t.signal),n?R.inspect(e,n,k,t.signal):Promise.resolve(null)]).then(([e,n,r])=>{t.signal.aborted||l({...i,list:e,scope:n,inspection:r,status:`available`})}).catch(e=>{t.signal.aborted||l({...i,status:a(e)&&[404,405,501].includes(e.status)?`unsupported`:`error`,error:o(e)})}),()=>t.abort()},[e,k,n,r,g]);let j=r&&t&&c?.projectId===e&&c.selectedId===n&&c.commit===t.commit?c:null,M=y.current.get(e),N=M?.result??null,P=j?.scope?.overview?.snapshot,F=!!(j?.status===`available`&&j.scope?.available&&j.scope.health===`writable`&&j.scope.capabilities?.ticket_scope_v1&&j.scope.mutation_enabled&&j.scope.binding&&j.scope.overview&&[`complete`,`authoritative_scope`].includes(j.scope.overview.coverage)&&!j.scope.overview.truncated&&j.scope.overview.omitted_count===0&&j.scope.overview.index_seq>=j.scope.overview.snapshot.seq&&P&&P.commit===t?.commit&&P.seq===t.seq&&P.authority_epoch===t.authority_epoch&&w&&!f&&(!M||N?.status===`committed`&&t.seq>=N.committedSeq)),I=async()=>{let n=v.current;if(!(!j?.list?.next_cursor||!n||n.signal.aborted||x.current)){x.current=!0,h(!0);try{let r=await R.list(e,j.list,t,n.signal);n.signal.aborted||l(e=>e&&{...e,list:r})}catch(e){n.signal.aborted||l(t=>t&&{...t,error:o(e),status:`error`})}finally{n.signal.aborted||(x.current=!1,h(!1))}}},L=async(e,t=!1)=>{if(!b.current){b.current=!0,p(!0);try{let t=await R.command(e);y.current.set(e.project_id,{command:e,result:{status:`committed`,operationId:t.operation.operation_id,committedSeq:t.operation.committed_seq}}),window.dispatchEvent(new Event(X)),S.current&&C.current===e.project_id&&(i(),A())}catch(n){let r=!t&&a(n)&&n.status<500?n.status===409?`conflict`:`rejected`:`unknown`;y.current.set(e.project_id,{command:e,result:{status:r,message:o(n)}}),window.dispatchEvent(new Event(X))}finally{b.current=!1,S.current&&p(!1)}}};return{list:j?.list??null,inspection:j?.inspection??null,status:j?.status??(r?`loading`:`unsupported`),error:j?.error??null,request:N,sending:f,canWrite:F,moreBusy:m,loadMore:I,command:async(n,r)=>{let i=y.current.get(e);if(!F||!navigator.onLine||b.current||i&&(i.result?.status!==`committed`||t.seq<i.result.committedSeq)||!j?.scope?.binding||!t)return;let a={operation_id:crypto.randomUUID(),binding:{...j.scope.binding},expected_seq:t.seq,expected_epoch:t.authority_epoch,project_id:e,sprint_id:n,source:`Explicit owner Sprint planning`,action:r},o=structuredClone(a);y.current.set(e,{command:o,result:null}),u(e=>e+1),await L(o)},reconcile:async()=>{let t=y.current.get(e),n=t?.command;!r||!navigator.onLine||!j?.scope?.available||!j.scope.mutation_enabled||!n||n.project_id!==e||j.scope.binding?.scope_id!==n.binding.scope_id||t?.result?.status!==`unknown`||b.current||await L(n,!0)},reviewLatest:()=>{let t=y.current.get(e);b.current||t?.result?.status===`unknown`||t&&!t.result||(y.current.delete(e),u(e=>e+1),i(),A())},refresh:A}}function ae(e){let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.0{1,3})?)?$/.exec(e);if(!t)return;let[n,r,i,a,o,s]=[Number(t[1]),Number(t[2]),Number(t[3]),Number(t[4]),Number(t[5]),Number(t[6]??0)];if(n<1)return;let c=new Date(0);if(c.setUTCFullYear(n,r-1,i),c.setUTCHours(a,o,s,0),c.getUTCFullYear()!==n||c.getUTCMonth()!==r-1||c.getUTCDate()!==i||c.getUTCHours()!==a||c.getUTCMinutes()!==o||c.getUTCSeconds()!==s)return;let l=c.getTime()/1e3;return Number.isSafeInteger(l)?l:void 0}function oe(e){if(e===null)return``;if(!Number.isSafeInteger(e))return;let t=new Date(e*1e3),n=t.getUTCFullYear();if(n<1||n>9999||t.getTime()/1e3!==e)return;let r=e=>e.toString().padStart(2,`0`),i=`${n.toString().padStart(4,`0`)}-${r(t.getUTCMonth()+1)}-${r(t.getUTCDate())}T${r(t.getUTCHours())}:${r(t.getUTCMinutes())}:${r(t.getUTCSeconds())}`;return ae(i)===e?i:void 0}var Z=`w-full min-w-0 rounded-md border bg-background px-3 py-2 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,se=e=>({value:oe(e)??``,original:e,edited:!1,cleared:!1,invalid:!1}),ce=e=>({name:e?.sprint.definition.name??``,goal:e?.sprint.definition.goal??``,startsAt:se(e?.sprint.definition.starts_at??null),endsAt:se(e?.sprint.definition.ends_at??null)});function Q(e){return e.edited?e.cleared?null:e.invalid?void 0:ae(e.value):e.original}function le(e){let t=Q(e.startsAt),n=Q(e.endsAt),r=new TextEncoder;return!e.name.trim()||r.encode(e.name).length>256||!e.goal.trim()||r.encode(e.goal).length>4096||t===void 0||n===void 0||t!==null&&n!==null&&n<t?null:{name:e.name,goal:e.goal,starts_at:t,ends_at:n}}function ue(e){return(0,f.jsx)(de,{...e},`${e.projectId}:${e.view?.sprint.id??`create`}`)}function de({projectId:e,view:t,sprints:n,canWrite:r,busy:i,request:a,copy:o,onCommand:s,onReconcile:l,onReviewLatest:u}){let p=(0,d.useId)(),[m,h]=(0,d.useState)(()=>ce(t)),[g,_]=(0,d.useState)(t?.sprint.revision??null),[v,y]=(0,d.useState)(``),[b,x]=(0,d.useState)({}),[S,C]=(0,d.useState)(!1),[w,T]=(0,d.useState)(!1),[E,D]=(0,d.useState)(!1),[O,k]=(0,d.useState)(!1),A=(0,d.useRef)(null),j=(0,d.useRef)(!1),M=(0,d.useRef)(!1),N=t?.sprint,P=!!e&&(!N||N.project_id===e&&Number.isSafeInteger(N.revision)&&N.revision>0),F=n.filter(t=>t.project_id===e&&t.id!==N?.id&&(t.status===`planned`||t.status===`active`)&&Number.isSafeInteger(t.revision)&&t.revision>0),I=Object.values(b).some(e=>e.destination===`sprint`&&!F.some(t=>t.id===e.sprint_id&&t.revision===e.revision)),L=g!==(N?.revision??null)||I,R=a?.status===`unknown`||!a&&(E||w&&!S),ee=!!a&&a.status!==`committed`,z=a&&`message`in a?a.message:``,B=!r||!P||i||S||w||ee||R||L||N?.status===`closed`,V=le(m),H=!!N&&!!V&&Object.entries(V).every(([e,t])=>N.definition[e]===t),U=!!v.trim()&&v===v.trim(),W=N?.members??[],G=!!t&&P&&new Set(W).size===W.length&&Object.keys(t.current_members).length===W.length&&W.every(e=>!!t.current_members[e]&&typeof t.current_members[e].accepted==`boolean`&&typeof t.current_members[e].archived==`boolean`),K=G?W.filter(e=>!t.current_members[e].accepted&&t.current_members[e].state!==`cancelled`):[],q=G&&K.every(e=>{let n=b[e];return n?.destination===`backlog`||n?.destination===`sprint`&&!t.current_members[e].archived&&F.some(e=>e.id===n.sprint_id&&e.revision===n.revision)}),J=n.some(t=>t.project_id===e&&t.id!==N?.id&&t.status===`active`),Y=async(e,t)=>{if(!(B||j.current||M.current)){j.current=!0,M.current=!0,C(!0),T(!0),D(!1);try{await s(e,t)}catch{D(!0)}finally{j.current=!1,C(!1)}}},te=()=>{if(!(B||!V||H)){if(N){Y(N.id,{op:`edit`,expected_revision:g,definition:V});return}if(!A.current)try{A.current=globalThis.crypto.randomUUID()}catch{k(!0);return}Y(A.current,{op:`create`,definition:V})}},ne=()=>{if(!N||N.status!==`active`||B||!q)return;let e=[],t=new Map;for(let n of K){let r=b[n];r.destination===`backlog`?e.push([n,{destination:`backlog`}]):(e.push([n,{destination:`sprint`,sprint_id:r.sprint_id}]),t.set(r.sprint_id,r.revision))}Y(N.id,{op:`close`,expected_revision:g,dispositions:Object.fromEntries(e),target_revisions:Object.fromEntries(t)})},re=async()=>{if(!(i||j.current||!R)){j.current=!0,C(!0);try{await l()}catch{D(!0)}finally{j.current=!1,C(!1)}}};return(0,f.jsxs)(`section`,{"aria-labelledby":`${p}-title`,className:`min-w-0 space-y-3 rounded-xl border bg-background p-4 text-sm`,"data-testid":`sprint-owner-controls`,children:[(0,f.jsx)(`h3`,{id:`${p}-title`,className:`font-semibold`,children:o.title}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o.planningHelp}),!r||!P?(0,f.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:o.ownerRequired}):null,N?(0,f.jsxs)(`p`,{className:`break-all text-xs text-muted-foreground`,children:[o.revision,`: `,N.revision]}):null,N?.status===`closed`?(0,f.jsx)(`p`,{role:`status`,children:o.closedReadOnly}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),te()},children:[(0,f.jsxs)(`fieldset`,{disabled:B,className:`grid min-w-0 gap-3 sm:grid-cols-2`,children:[(0,f.jsxs)(`label`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:o.name}),(0,f.jsx)(`input`,{className:Z,value:m.name,onChange:e=>h({...m,name:e.target.value})})]}),(0,f.jsxs)(`label`,{className:`min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:o.goal}),(0,f.jsx)(`textarea`,{className:Z,value:m.goal,onChange:e=>h({...m,goal:e.target.value})})]}),[`startsAt`,`endsAt`].map(e=>(0,f.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,f.jsxs)(`label`,{children:[(0,f.jsx)(`span`,{children:o[e]}),(0,f.jsx)(`input`,{className:Z,style:{colorScheme:`var(--native-scheme)`},type:`datetime-local`,step:`1`,min:`0001-01-01T00:00:00`,max:`9999-12-31T23:59:59`,value:m[e].value,"aria-invalid":Q(m[e])===void 0,"aria-describedby":`${p}-dates-help`,onChange:t=>{let{value:n,validity:r}=t.currentTarget;h({...m,[e]:{...m[e],value:n,edited:!0,cleared:!1,invalid:!r.valid}})}})]}),(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,disabled:m[e].original===null&&!m[e].value&&!m[e].edited,onClick:()=>h({...m,[e]:{...m[e],value:``,edited:!0,cleared:!0,invalid:!1}}),children:o[e===`startsAt`?`clearStart`:`clearEnd`]})]},e))]}),(0,f.jsx)(`p`,{id:`${p}-dates-help`,className:`text-xs text-muted-foreground`,children:o.datesHelp}),!V&&(m.name||m.goal||m.startsAt.edited||m.endsAt.edited)?(0,f.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:o.invalidDefinition}):null,O?(0,f.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:o.createIdUnavailable}):null,(0,f.jsx)(c,{type:`submit`,size:`sm`,disabled:B||!V||H,children:N?o.save:o.create})]}),N?.status===`planned`?(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,disabled:B||J,onClick:()=>void Y(N.id,{op:`start`,expected_revision:g}),children:o.start}),J?(0,f.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:o.activeExists}):null]}):null,N?(0,f.jsxs)(`div`,{className:`min-w-0 space-y-2 border-t pt-3`,children:[(0,f.jsxs)(`label`,{className:`block min-w-0 space-y-1`,children:[(0,f.jsx)(`span`,{children:o.workId}),(0,f.jsx)(`input`,{className:Z,disabled:B,value:v,"aria-describedby":`${p}-work-help`,onChange:e=>y(e.target.value)})]}),(0,f.jsx)(`p`,{id:`${p}-work-help`,className:`text-xs text-muted-foreground`,children:o.workIdHelp}),v&&!U?(0,f.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:o.invalidWorkId}):null,(0,f.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,disabled:B||!U||W.includes(v),onClick:()=>{U&&!W.includes(v)&&Y(N.id,{op:`add`,expected_revision:g,work_id:v})},children:o.add}),(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,disabled:B||!U||!W.includes(v),onClick:()=>{U&&W.includes(v)&&Y(N.id,{op:`remove`,expected_revision:g,work_id:v})},children:o.remove})]})]}):null,N?.status===`active`?(0,f.jsxs)(`div`,{className:`min-w-0 space-y-3 border-t pt-3`,children:[(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o.closeHelp}),G?K.map(e=>{let n=b[e];return(0,f.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,f.jsxs)(`label`,{className:`block min-w-0 space-y-1`,children:[(0,f.jsxs)(`span`,{className:`block break-all`,children:[o.destination,`: `,e]}),(0,f.jsxs)(`select`,{className:Z,disabled:B,value:n?.destination===`backlog`?`backlog`:n?.destination===`sprint`?`sprint:${n.sprint_id}`:``,onChange:t=>{let n=F.find(e=>`sprint:${e.id}`===t.target.value),r=t.target.value===`backlog`?{destination:`backlog`}:n?{destination:`sprint`,sprint_id:n.id,revision:n.revision}:null;x(t=>Object.fromEntries([...Object.entries(t).filter(([t])=>t!==e),...r?[[e,r]]:[]]))},children:[(0,f.jsx)(`option`,{value:``,children:o.chooseDestination}),(0,f.jsx)(`option`,{value:`backlog`,children:o.backlog}),F.map(n=>(0,f.jsxs)(`option`,{value:`sprint:${n.id}`,disabled:t.current_members[e].archived,children:[n.definition.name,` · `,n.id,` · `,o.targetRevision,` `,n.revision]},n.id))]})]}),n?.destination===`sprint`?(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[o.targetRevision,`: `,n.revision]}):null]},e)}):(0,f.jsx)(`p`,{role:`status`,children:o.incompleteInspect}),q?null:(0,f.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:o.incompleteDispositions}),(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`destructive`,disabled:B||!q,onClick:ne,children:o.close})]}):null]}),L?(0,f.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:o.draftStale}):null,S?(0,f.jsx)(`p`,{role:`status`,children:o.submitting}):w&&!a&&!E&&!R?(0,f.jsx)(`p`,{role:`status`,children:o.awaitingReceipt}):null,a?.status===`committed`?(0,f.jsxs)(`p`,{role:`status`,className:`break-all`,children:[o.committed,`: `,a.operationId,` · `,a.committedSeq]}):null,R||a&&a.status!==`committed`?(0,f.jsxs)(`p`,{role:`alert`,className:`break-words text-destructive`,children:[R?o.unknown:a?.status===`conflict`?o.conflict:o.rejected,z?` ${z}`:``]}):null,R?(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,disabled:i||S,onClick:()=>void re(),children:o.reconcile}):null,!R&&(L||a?.status===`conflict`||a?.status===`rejected`||w||a?.status===`committed`)&&N?.status!==`closed`?(0,f.jsxs)(`div`,{className:`space-y-1`,children:[(0,f.jsx)(c,{type:`button`,size:`sm`,variant:`outline`,disabled:i||S,onClick:()=>{i||j.current||R||(!N&&a?.status===`committed`&&(A.current=null),_(N?.revision??null),x(e=>Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{if(t.destination===`backlog`)return[[e,t]];let n=F.find(e=>e.id===t.sprint_id);return n?[[e,{...t,revision:n.revision}]]:[]}))),M.current=!1,T(!1),D(!1),u())},children:o.reviewLatest}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o.reviewHelp})]}):null,(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o.receiptHelp})]})}var fe=()=>({title:i(`project_sprint_owner_title`),planningHelp:i(`project_sprint_owner_planning_help`),ownerRequired:i(`project_sprint_owner_owner_required`),closedReadOnly:i(`project_sprint_owner_closed_read_only`),name:i(`project_sprint_owner_name`),goal:i(`project_sprint_owner_goal`),startsAt:i(`project_sprint_owner_starts_at`),endsAt:i(`project_sprint_owner_ends_at`),datesHelp:i(`project_sprint_owner_dates_help`),clearStart:i(`project_sprint_owner_clear_start`),clearEnd:i(`project_sprint_owner_clear_end`),create:i(`project_sprint_owner_create`),save:i(`project_sprint_owner_save`),start:i(`project_sprint_owner_start`),activeExists:i(`project_sprint_owner_active_exists`),workId:i(`project_sprint_owner_work_id`),workIdHelp:i(`project_sprint_owner_work_id_help`),add:i(`project_sprint_owner_add`),remove:i(`project_sprint_owner_remove`),close:i(`project_sprint_owner_close`),closeHelp:i(`project_sprint_owner_close_help`),destination:i(`project_sprint_owner_destination`),chooseDestination:i(`project_sprint_owner_choose_destination`),backlog:i(`project_sprint_owner_backlog`),targetRevision:i(`project_sprint_owner_target_revision`),revision:i(`project_sprint_owner_revision`),invalidDefinition:i(`project_sprint_owner_invalid_definition`),invalidWorkId:i(`project_sprint_owner_invalid_work_id`),incompleteInspect:i(`project_sprint_owner_incomplete_inspect`),incompleteDispositions:i(`project_sprint_owner_incomplete_dispositions`),draftStale:i(`project_sprint_owner_draft_stale`),reviewLatest:i(`project_sprint_owner_review_latest`),reviewHelp:i(`project_sprint_owner_review_help`),submitting:i(`project_sprint_owner_submitting`),awaitingReceipt:i(`project_sprint_owner_awaiting_receipt`),committed:i(`project_sprint_owner_committed`),conflict:i(`project_sprint_owner_conflict`),unknown:i(`project_sprint_owner_unknown`),rejected:i(`project_sprint_owner_rejected`),reconcile:i(`project_sprint_owner_reconcile`),receiptHelp:i(`project_sprint_owner_receipt_help`),createIdUnavailable:i(`project_sprint_owner_create_id_unavailable`)}),pe=e=>i({planned:`project_sprint_planned`,active:`project_sprint_active`,closed:`project_sprint_closed`}[e]),me=e=>i(`project_sprint_counts`,{...e});function he({projectId:e,projectActive:t,snapshot:n,owner:a,filter:o,onFilterChange:s,onRefresh:l}){r();let u=o?.kind===`sprint`?o.sprint_id:null,p=ie(e,n,u,a,l),m=p.inspection?.data,h=(0,d.useRef)(null);p.status===`available`&&(h.current={projectId:e,selectedId:u,view:m,list:p.list?.data??[]});let g=h.current?.projectId===e&&h.current.selectedId===u?h.current:null,_=u?`sprint:${u}`:o?.kind??`all`,v=e=>s(e===`all`?null:e===`backlog`?{kind:`backlog`}:{kind:`sprint`,sprint_id:e.slice(7)});return(0,f.jsxs)(`section`,{className:`mb-3 min-w-0 rounded-lg border p-3 text-sm`,"aria-label":i(`project_sprint_title`),"data-testid":`project-sprint-panel`,children:[(0,f.jsxs)(`label`,{className:`flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(`span`,{className:`font-medium`,children:i(`project_sprint_filter`)}),(0,f.jsxs)(`select`,{"aria-label":i(`project_sprint_filter`),value:_,disabled:!a,onChange:e=>v(e.target.value),className:`min-w-0 max-w-xs rounded-md border bg-background p-2 text-sm focus-visible:ring-2 focus-visible:ring-ring`,"data-testid":`project-sprint-filter`,children:[(0,f.jsx)(`option`,{value:`all`,children:i(`project_sprint_all`)}),(0,f.jsx)(`option`,{value:`backlog`,disabled:p.status!==`available`,children:i(`project_sprint_backlog`)}),u&&!p.list?.data.some(e=>e.id===u)?(0,f.jsx)(`option`,{value:_,children:u}):null,p.list?.data.map(e=>(0,f.jsxs)(`option`,{value:`sprint:${e.id}`,children:[e.definition.name,` · `,pe(e.status)]},e.id))]}),p.list?.next_cursor?(0,f.jsx)(c,{size:`sm`,variant:`outline`,disabled:p.moreBusy,onClick:()=>void p.loadMore(),children:i(`project_sprint_more`)}):null]}),p.status===`unsupported`&&a?(0,f.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-muted-foreground`,children:i(`project_sprint_unsupported`)}):null,p.error?(0,f.jsxs)(`p`,{role:`status`,className:`mt-2 break-words text-xs text-destructive`,children:[i(`project_sprint_error`),` `,p.error]}):null,p.status===`loading`&&a?(0,f.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-muted-foreground`,children:i(`project_work_loading`)}):null,p.list&&!p.list.data.length?(0,f.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:i(`project_sprint_no_sprints`)}):null,o?.kind===`backlog`?(0,f.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:i(`project_sprint_backlog_hint`)}):null,m?(0,f.jsxs)(`div`,{className:`mt-3 min-w-0 space-y-2`,"data-testid":`project-sprint-summary`,children:[(0,f.jsxs)(`h3`,{className:`break-words font-semibold`,children:[m.sprint.definition.name,` · `,pe(m.sprint.status)]}),(0,f.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:m.sprint.definition.goal}),m.sprint.status===`closed`?(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`project_sprint_closed_hint`)}):null,(0,f.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-words text-xs`,children:[(0,f.jsx)(`dt`,{className:`font-medium`,children:i(`project_sprint_current`)}),(0,f.jsx)(`dd`,{"data-testid":`project-sprint-current-counts`,children:me(m.current_counts)}),(0,f.jsx)(`dd`,{className:`break-all text-muted-foreground`,children:i(`project_sprint_snapshot`,{seq:p.inspection.snapshot.seq,commit:p.inspection.snapshot.commit})}),m.sprint.closure?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`dt`,{className:`mt-2 font-medium`,children:i(`project_sprint_closure`)}),(0,f.jsx)(`dd`,{"data-testid":`project-sprint-closure-counts`,children:me(m.sprint.closure.counts)}),(0,f.jsx)(`dd`,{className:`break-all text-muted-foreground`,children:i(`project_sprint_closing_snapshot`,{closed:m.sprint.closure.closed_seq,source:m.sprint.closure.source_seq,commit:m.sprint.closure.source_commit})})]}):null]}),(0,f.jsxs)(`details`,{children:[(0,f.jsxs)(`summary`,{className:`cursor-pointer text-xs`,children:[i(`project_sprint_history`),` · `,i(`project_sprint_members`,{count:m.sprint.members.length})]}),(0,f.jsx)(`ul`,{className:`mt-2 space-y-2 text-xs`,children:m.sprint.history.map((e,t)=>(0,f.jsxs)(`li`,{className:`break-all`,children:[i({added:`project_sprint_history_added`,removed:`project_sprint_history_removed`,carried_in:`project_sprint_history_carried_in`,carried_out:`project_sprint_history_carried_out`}[e.change.kind]),` · `,e.work_id,e.change.kind===`carried_in`?` ← ${e.change.from}`:e.change.kind===`carried_out`?` → ${e.change.to??i(`project_sprint_backlog`)}`:``,(0,f.jsxs)(`span`,{className:`block text-muted-foreground`,children:[e.principal,` · `,e.source]})]},`${e.operation_id}:${e.work_id}:${t}`))})]})]}):null,g&&a?(0,f.jsxs)(`div`,{className:`mt-3`,children:[(0,f.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:i(`project_sprint_scope_hint`)}),!p.canWrite&&!p.sending&&!p.request?(0,f.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-muted-foreground`,children:i(`project_sprint_scope_stale`)}):null,(0,f.jsx)(ue,{projectId:e,view:g.view??null,sprints:g.list,canWrite:p.canWrite&&t,busy:p.sending,request:p.request,onCommand:async(e,n)=>{t&&await p.command(e,n)},onReconcile:p.reconcile,onReviewLatest:p.reviewLatest,copy:fe()})]}):null]})}var ge=[`todo`,`doing`,`testing`,`done`],$=e=>i({todo:`project_work_todo`,doing:`project_work_doing`,testing:`project_work_testing`,done:`project_work_done`}[e]);function _e({context:e}){return(0,f.jsx)(`span`,{children:e?i(`project_work_revision`,{project:e.project_revision,resources:e.resource_revision}):i(`project_work_unknown`)})}function ve({context:e,label:t,name:n}){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`dt`,{className:`font-medium`,children:t}),(0,f.jsxs)(`dd`,{"data-testid":`project-work-context-${n}`,children:[(0,f.jsx)(_e,{context:e}),e?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`span`,{className:`block`,children:i(`project_work_contract_revision`,{revision:e.contract_revision})}),(0,f.jsx)(`span`,{className:`block break-all`,children:e.workspace_binding.path})]}):null]})]})}function ye({row:e,snapshot:t,projectId:n,onClose:a,onOpenSession:s}){let l=r(),[u,p]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(!1),b=(0,d.useRef)(!1),x=(0,d.useRef)(!0),S=V(u?.assignments,e.ticket.id,n,!!s);(0,d.useEffect)(()=>(x.current=!0,()=>{x.current=!1}),[]);let C=async e=>{if(!(!s||b.current)){b.current=!0,y(!0),_(null);try{await s(e,()=>S.recheck(e))}catch(e){x.current&&_(o(e))}finally{b.current=!1,x.current&&y(!1)}}};(0,d.useEffect)(()=>{let n=new AbortController;return E.inspect(e.ticket.id,t,n.signal).then(e=>{n.signal.aborted||p(e)}).catch(e=>{n.signal.aborted||h(o(e))}),()=>n.abort()},[e.ticket.id,t]);let w=u?.assignments.find(t=>t.id===e.ticket.active_assignment);return(0,f.jsxs)(`section`,{"aria-label":e.ticket.contract.title,className:`min-w-0 rounded-xl border bg-background p-4 text-sm`,"data-testid":`project-work-details`,children:[(0,f.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,f.jsx)(`h3`,{className:`min-w-0 break-words font-semibold`,children:e.ticket.contract.title}),(0,f.jsx)(c,{size:`sm`,variant:`ghost`,onClick:a,children:i(`project_work_close_details`)})]}),(0,f.jsx)(`h4`,{className:`mt-3 font-medium`,children:i(`project_work_contract`)}),(0,f.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:e.ticket.contract.objective}),(0,f.jsx)(`ul`,{className:`list-inside list-disc break-words`,children:[...e.ticket.contract.constraints,...e.ticket.contract.acceptance].map((e,t)=>(0,f.jsx)(`li`,{children:e},t))}),(0,f.jsxs)(`dl`,{className:`mt-3 grid gap-1 break-words`,children:[(0,f.jsx)(`dt`,{className:`font-medium`,children:i(`project_work_dependencies`)}),(0,f.jsx)(`dd`,{children:e.ticket.depends_on.join(`, `)||`—`}),(0,f.jsx)(ve,{context:e.context,label:i(`project_work_candidate`),name:`candidate`}),e.pending_context?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(ve,{context:e.pending_context,label:i(`project_work_pending`),name:`pending`}),(0,f.jsx)(`dd`,{className:`text-xs text-muted-foreground`,children:i(`project_work_pending_hint`)})]}):null,(0,f.jsx)(ve,{context:e.adopted_context,label:i(`project_work_adopted`),name:`adopted`}),w?.workspace?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`dt`,{children:i(`project_work_repos`)}),(0,f.jsxs)(`dd`,{className:`break-all`,children:[w.workspace.repo,(0,f.jsx)(`br`,{}),w.workspace.branch,(0,f.jsx)(`br`,{}),w.workspace.worktree]})]}):null]}),(0,f.jsx)(`div`,{className:`mt-4`,children:(0,f.jsx)(te,{workId:e.ticket.id,generation:e.ticket.generation,authorityEpoch:t.authority_epoch,currentAssignmentId:e.ticket.active_assignment,attempts:u&&S.online?{status:`available`,value:u.assignments,updatedAt:null}:{status:`unknown`,reason:m??(S.online?i(`project_work_loading`):i(`assignment_health_stale_hint`))},observations:{status:`unsupported`},incidents:{status:`unsupported`},sessions:S.sessions,blockReason:e.ticket.blocked?.reason,nowMs:Date.now(),locale:l,copy:ne(),onOpenSession:s&&S.online?e=>void C(e):void 0})}),v?(0,f.jsx)(`p`,{role:`status`,className:`mt-2 text-xs`,children:i(`assignment_health_opening_session`)}):null,g?(0,f.jsx)(`p`,{role:`alert`,className:`mt-2 text-destructive`,children:g}):null,m?(0,f.jsx)(`p`,{role:`alert`,className:`mt-2 text-destructive`,children:m}):u?(0,f.jsxs)(f.Fragment,{children:[u.requests.some(e=>e.status===`open`)?(0,f.jsx)(`p`,{className:`mt-2`,children:i(`project_work_waiting`)}):null,(0,f.jsx)(`h4`,{className:`mt-3 font-medium`,children:i(`project_work_evidence`)}),u.submissions.filter(t=>[e.ticket.current_submission,e.ticket.accepted_submission].includes(t.id)).map(t=>(0,f.jsxs)(`div`,{className:`mt-2 break-words`,children:[(0,f.jsx)(`p`,{children:t.stale?i(`ticket_previous_submission_for_reference_only_8540a39f`):t.id===e.ticket.accepted_submission?i(`ticket_accepted_submission_a269d4af`):i(`ticket_submitted_awaiting_acceptance_14447588`)}),(0,f.jsx)(`ul`,{className:`list-inside list-disc`,children:t.evidence.map((e,t)=>(0,f.jsx)(`li`,{children:e},t))}),(0,f.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`supervisor_work_result_count`,{count:t.artifacts.length})})]},t.id)),!e.ticket.current_submission&&!e.ticket.accepted_submission?(0,f.jsx)(`p`,{children:i(`project_work_evidence_none`)}):null]}):(0,f.jsx)(`p`,{role:`status`,children:i(`project_work_loading`)})]})}function be(e,t){return e.id===t.ticket.id&&e.generation===t.ticket.generation&&e.recordRevision===t.ticket.record_revision&&e.state===t.ticket.state}function xe(e,t,n){return e?.binding?.scope_id===t.ticket.scope_id&&e.expectedSeq===n.seq&&e.expectedEpoch===n.authority_epoch?e:null}function Se({project:e,controls:t,onOpenSession:n}){r();let[a,o]=(0,d.useState)(`list`),[s,l]=(0,d.useState)(!1),[p,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(null),{page:_,error:v,busy:y,owner:b,refresh:w,loadMore:E}=ee(e.id,s,h),D=_?.data.rows??[],O=D.find(e=>e.ticket.id===p),k=O&&t?.planning&&be(t.planning.work,O)?t.planning:null,A=O&&t?.owner&&be(t.owner.work,O)&&t.owner.work.contractRevision===O.ticket.contract_revision&&t.owner.work.currentSubmissionId===O.ticket.current_submission?t.owner:null,j=O&&(t?.planning?.work.id===O.ticket.id&&!k||t?.owner?.work.id===O.ticket.id&&!A),M=A&&O&&_?Object.fromEntries(Object.entries(A.commands).filter(([,e])=>xe(e,O,_.snapshot))):{},N=_&&T(_),P=e=>(0,f.jsxs)(`button`,{type:`button`,"aria-pressed":p===e.ticket.id,onClick:()=>m(e.ticket.id),className:`min-w-0 w-full rounded-lg border bg-background p-3 text-left text-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring`,"data-testid":`project-work-${e.ticket.id}`,children:[(0,f.jsx)(`span`,{className:`block break-words font-medium`,children:e.ticket.contract.title}),(0,f.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:u[e.ticket.state]}),e.ticket.blocked?(0,f.jsxs)(`span`,{className:`mt-1 block break-words`,children:[i(`ticket_blocked_9059acb4`),`: `,e.ticket.blocked.reason]}):null,e.ticket.paused?(0,f.jsx)(`span`,{className:`block`,children:i(`project_work_paused`)}):null,(0,f.jsx)(`span`,{className:`mt-2 block text-xs text-muted-foreground`,children:e.ticket.current_submission||e.ticket.accepted_submission?i(`project_work_evidence_pending`):i(`project_work_evidence_none`)}),e.pending_context?(0,f.jsx)(`span`,{className:`block text-xs`,children:i(`project_work_pending`)}):null]},e.ticket.id);return(0,f.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,"data-testid":`project-work-board`,children:[(0,f.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:i(`project_work_readonly`)}),(0,f.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,f.jsx)(c,{size:`sm`,variant:a===`list`?`default`:`outline`,"aria-pressed":a===`list`,onClick:()=>o(`list`),children:i(`project_work_list`)}),(0,f.jsx)(c,{size:`sm`,variant:a===`board`?`default`:`outline`,"aria-pressed":a===`board`,onClick:()=>o(`board`),children:i(`project_work_board`)}),(0,f.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>{m(null),l(e.target.checked)}}),i(`project_work_cancelled`)]}),(0,f.jsx)(c,{size:`sm`,variant:`ghost`,disabled:y||!b,onClick:w,children:i(`refresh_aee88743`)})]}),(0,f.jsx)(he,{projectId:e.id,projectActive:e.status===`active`,snapshot:_?.snapshot??null,owner:b,filter:h,onRefresh:w,onFilterChange:e=>{m(null),g(e)}}),(0,f.jsxs)(`details`,{className:`mb-3 rounded-lg border p-3 text-xs`,children:[(0,f.jsx)(`summary`,{className:`cursor-pointer`,children:i(`project_work_context`)}),(0,f.jsx)(`p`,{className:`mt-2`,children:(0,f.jsx)(_e,{context:{project_id:e.id,project_revision:e.revision,resource_revision:e.resource_revision}})}),(0,f.jsx)(`p`,{className:`mt-2 font-medium`,children:i(`project_work_repos`)}),(0,f.jsxs)(`ul`,{children:[e.project_path&&!e.workspace_bindings.some(t=>t.path===e.project_path)?(0,f.jsx)(`li`,{className:`break-all`,children:e.project_path}):null,e.workspace_bindings.map(e=>(0,f.jsxs)(`li`,{className:`break-all`,children:[e.label?`${e.label}: `:``,e.path]},e.path))]})]}),b?null:(0,f.jsx)(`p`,{role:`status`,children:i(`project_work_access`)}),v?(0,f.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-destructive`,children:v}):null,_&&!N?(0,f.jsx)(`p`,{role:`status`,className:`mb-3 text-sm`,children:i(`project_work_partial`)}):null,_?(0,f.jsxs)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:[ge.map(e=>`${$(e)}: ${N?_.data.counts[e]:`?`}`).join(` · `),` · `,i(`ticket_blocked_9059acb4`),`: `,N?_.data.counts.blocked:`?`,` · `,i(`cancelled_a37778f1`),`: `,N?_.data.counts.cancelled:`?`]}):null,a===`list`?(0,f.jsx)(`div`,{className:`grid gap-2`,children:D.map(P)}):(0,f.jsx)(`div`,{className:`project-work-stages grid grid-cols-1 gap-3`,children:ge.map(e=>(0,f.jsxs)(`section`,{"aria-label":$(e),className:`min-w-0 rounded-xl bg-muted/40 p-2`,children:[(0,f.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:$(e)}),(0,f.jsx)(`div`,{className:`grid gap-2`,children:D.filter(t=>t.stage===e).map(P)})]},e))}),a===`board`&&D.some(e=>e.stage===null)?(0,f.jsxs)(`section`,{className:`mt-3`,children:[(0,f.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:i(`project_work_other`)}),(0,f.jsx)(`div`,{className:`grid gap-2`,children:D.filter(e=>e.stage===null).map(P)})]}):null,_&&!D.length?(0,f.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:i(`project_work_empty`)}):null,y?(0,f.jsx)(`p`,{role:`status`,className:`mt-3 text-sm`,children:i(`project_work_loading`)}):null,_?.next_cursor?(0,f.jsx)(c,{className:`mt-3`,variant:`outline`,disabled:y,onClick:()=>void E(),children:i(`project_work_more`)}):null,O&&_?(0,f.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,f.jsx)(ye,{row:O,snapshot:_.snapshot,projectId:e.id,onOpenSession:n,onClose:()=>m(null)},`${_.snapshot.commit}:${O.ticket.id}`),j?(0,f.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:i(`project_work_controls_unavailable_context`)}):null,k?(0,f.jsx)(x,{...k,owner:b&&k.owner,command:xe(k.command,O,_.snapshot),copy:C()},`planning:${O.ticket.id}:${O.ticket.generation}`):null,A?(0,f.jsx)(S,{...A,owner:b&&A.owner,commands:M,copy:C()},`owner:${O.ticket.id}:${O.ticket.generation}`):null]}):null]})}export{Se as ProjectWorkBoard};
|