plaincrew 0.2.1 → 0.2.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/app-build/BUILD_ID +1 -1
- package/app-build/build-manifest.json +3 -3
- package/app-build/diagnostics/route-bundle-stats.json +20 -20
- package/app-build/fallback-build-manifest.json +3 -3
- package/app-build/server/app/_global-error.html +1 -1
- package/app-build/server/app/_global-error.rsc +1 -1
- package/app-build/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/app-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app-build/server/app/_not-found.html +1 -1
- package/app-build/server/app/_not-found.rsc +1 -1
- package/app-build/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/app-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/app-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/app-build/server/app/api/projects/[id]/route.js +13 -12
- package/app-build/server/app/api/projects/[id]/site/route.js +10 -9
- package/app-build/server/app/canvas/[workflowId]/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/connect/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/invite/[id]/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/organization/new/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/sign-in/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/sign-up/page_client-reference-manifest.js +1 -1
- package/app-build/server/chunks/[root-of-the-server]__0_use5ykfraw7._.js +10 -10
- package/app-build/server/chunks/{[root-of-the-server]__10o1v6vzm-1vx._.js → [root-of-the-server]__0a-kovunokq7y._.js} +1 -1
- package/app-build/server/chunks/_0-spos-0d2krg._.js +4 -4
- package/app-build/server/chunks/_00_jnbz1zvwgx._.js +4 -4
- package/app-build/server/chunks/_00nvlapuy-n5u._.js +4 -4
- package/app-build/server/chunks/_02ydx-6i02-15._.js +4 -4
- package/app-build/server/chunks/_09ejh1dyvkto7._.js +1 -1
- package/app-build/server/chunks/_0acmw0tv499h0._.js +4 -4
- package/app-build/server/chunks/_0aw98t7vmjb88._.js +4 -4
- package/app-build/server/chunks/_0b2ridyy82jxe._.js +1 -1
- package/app-build/server/chunks/_0bhd3724mk5_8._.js +4 -4
- package/app-build/server/chunks/_0bhh96fypchdz._.js +3 -0
- package/app-build/server/chunks/_0bsptjrzcu8a7._.js +4 -4
- package/app-build/server/chunks/_0d-t3ot63p6q4._.js +4 -4
- package/app-build/server/chunks/_0e2pq-eirvzjq._.js +1 -1
- package/app-build/server/chunks/_0et5mjk8ma941._.js +1 -1
- package/app-build/server/chunks/_0ety_xj8s9se5._.js +4 -4
- package/app-build/server/chunks/_0fbwelpje0vpp._.js +4 -4
- package/app-build/server/chunks/_0ipkjlo50tvzh._.js +4 -4
- package/app-build/server/chunks/_0j8and6kle-vr._.js +4 -4
- package/app-build/server/chunks/_0l56fyw-2mdap._.js +4 -4
- package/app-build/server/chunks/_0o-zfrg3y0fq7._.js +4 -4
- package/app-build/server/chunks/_0oh4tv1yn6ko-._.js +4 -4
- package/app-build/server/chunks/_0omlu-feiobkm._.js +19 -0
- package/app-build/server/chunks/_0prtq3d1e3y27._.js +1 -1
- package/app-build/server/chunks/_0qgouuuv9x557._.js +4 -4
- package/app-build/server/chunks/_0r2znajb4c33_._.js +4 -4
- package/app-build/server/chunks/_0r7go8jj5dc5t._.js +2 -2
- package/app-build/server/chunks/_0w3v4t4p9vsb-._.js +11 -11
- package/app-build/server/chunks/_0wi30r5c4hlyh._.js +4 -4
- package/app-build/server/chunks/_0yxx6fkquhd5h._.js +4 -4
- package/app-build/server/chunks/_1-l-baxl7r6o-._.js +4 -4
- package/app-build/server/chunks/_12v43tznpol4u._.js +1 -1
- package/app-build/server/chunks/_153o0hrf0g3mk._.js +4 -4
- package/app-build/server/chunks/_155fw3g6f3-4h._.js +4 -4
- package/app-build/server/chunks/_19_0wmfnwvz9o._.js +1 -1
- package/app-build/server/chunks/_19q1zxel7pllh._.js +1 -1
- package/app-build/server/chunks/_1_mlvky6w1ov8._.js +4 -4
- package/app-build/server/chunks/_1bf1pcq2wtg91._.js +1 -1
- package/app-build/server/chunks/_1cq7469bqdm3u._.js +1 -1
- package/app-build/server/chunks/_1f610h-qim306._.js +4 -4
- package/app-build/server/chunks/_1h24vpftu-w_x._.js +4 -4
- package/app-build/server/chunks/_1hhnlf5x-a4y4._.js +4 -4
- package/app-build/server/chunks/_1l2bdu1tjz32v._.js +3 -0
- package/app-build/server/chunks/_1nx8fwgx5ca29._.js +4 -4
- package/app-build/server/chunks/_1ob-6ym8mt48u._.js +1 -1
- package/app-build/server/chunks/_1uwtj6yrwszfe._.js +1 -1
- package/app-build/server/chunks/_1vb0vvvhh6nh7._.js +1 -1
- package/app-build/server/chunks/_1w-v2i1f-t_3x._.js +4 -4
- package/app-build/server/chunks/_1wau1ee-6k-7o._.js +11 -11
- package/app-build/server/chunks/_1yho6hc7s0457._.js +11 -11
- package/app-build/server/chunks/_1zn_x1pv0cr9q._.js +4 -4
- package/app-build/server/chunks/src_1mb1qcardcu_6._.js +1 -1
- package/app-build/server/chunks/src_engine_site-preview_ts_0-dbxa3-3tr7l._.js +3 -0
- package/app-build/server/chunks/ssr/_14z-y2hqpv20w._.js +1 -1
- package/app-build/server/chunks/ssr/src_ui_0a7papum2y8_i._.js +1 -1
- package/app-build/server/chunks/ssr/src_ui_0dybjq718frlj._.js +1 -1
- package/app-build/server/chunks/ssr/src_ui_1lk_5nzn_qoqs._.js +1 -1
- package/app-build/server/chunks/ssr/src_ui_1pd2_lbqeputa._.js +1 -1
- package/app-build/server/chunks/ssr/src_ui_canvas_AddProjectDialog_tsx_10a7chj-0e01u._.js +1 -1
- package/app-build/server/chunks/ssr/src_ui_strings_ts_1es3352ykktl1._.js +1 -1
- package/app-build/server/middleware-build-manifest.js +3 -3
- package/app-build/server/pages/404.html +1 -1
- package/app-build/server/pages/500.html +1 -1
- package/app-build/static/chunks/0ii9_22v9su8d.js +1 -0
- package/app-build/static/chunks/{0u800lsoqi8_z.js → 1itn52l0g-rzl.js} +8 -8
- package/app-build/static/chunks/2-i8llxdbif11.js +1 -0
- package/app-build/static/chunks/{13qqhom208k1g.js → 2ld15xpoa2y6e.js} +1 -1
- package/app-build/trace-build +1 -1
- package/bin/plaincrew.mjs +49 -13
- package/package.json +1 -1
- package/app-build/server/chunks/_01f7ho67e16bo._.js +0 -3
- package/app-build/server/chunks/_0zm1mzakhcn80._.js +0 -3
- package/app-build/static/chunks/2z0spwjyeqvjq.js +0 -1
- package/app-build/static/chunks/3sj18n0bki38_.js +0 -1
- /package/app-build/static/{HAjlyCK72AXHP41NT95Jp → iyQHfRfrgCgNDJ3ln9VSf}/_buildManifest.js +0 -0
- /package/app-build/static/{HAjlyCK72AXHP41NT95Jp → iyQHfRfrgCgNDJ3ln9VSf}/_clientMiddlewareManifest.js +0 -0
- /package/app-build/static/{HAjlyCK72AXHP41NT95Jp → iyQHfRfrgCgNDJ3ln9VSf}/_ssgManifest.js +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
M${z.x},${z.y}h${z.width}v${z.height}h${-z.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}l_.displayName="MiniMap",(0,m.memo)(l_);let lR={[g.Line]:"right",[g.Handle]:"bottom-right"};(0,m.memo)(function({nodeId:e,position:t,variant:n=g.Handle,className:i,style:r,children:o,color:a,minWidth:l=10,minHeight:s=10,maxWidth:d=Number.MAX_VALUE,maxHeight:c=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:p,autoScale:f=!0,shouldResize:h,onResizeStart:x,onResize:b,onResizeEnd:v}){let w,j=an(),k="string"==typeof e?e:j,S=os(),C=(0,m.useRef)(null),B=n===g.Handle,z=ol((0,m.useCallback)((w=B&&f,e=>w?`${Math.max(1/e.transform[2],1)}`:void 0),[B,f]),on),I=(0,m.useRef)(null),M=t??lR[n];(0,m.useEffect)(()=>{if(C.current&&k)return I.current||(I.current=function({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:r}){let o=tu(e),a={controlDirection:rQ("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};return{update:function({controlPosition:e,boundaries:l,keepAspectRatio:s,resizeDirection:d,onResizeStart:c,onResize:u,onResizeEnd:p,shouldResize:f}){let h,g,x,y,m={...r5},b={...r4};a={boundaries:l,resizeDirection:d,keepAspectRatio:s,controlDirection:rQ(e)};let v=null,w=[],j=tz().on("start",e=>{let{nodeLookup:i,transform:r,snapGrid:o,snapToGrid:a,nodeOrigin:l,paneDomNode:s}=n();if(!(h=i.get(t)))return;v=s?.getBoundingClientRect()??null;let{xSnapped:d,ySnapped:u}=ro(e.sourceEvent,{transform:r,snapGrid:o,snapToGrid:a,containerBounds:v});for(let[e,n]of(b={...m={width:h.measured.width??0,height:h.measured.height??0,x:h.position.x??0,y:h.position.y??0},pointerX:d,pointerY:u,aspectRatio:m.width/m.height},g=void 0,x=i7(h.extent)?h.extent:void 0,h.parentId&&("parent"===h.extent||h.expandParent)&&(g=i.get(h.parentId)),g&&"parent"===h.extent&&(x=[[0,0],[g.measured.width,g.measured.height]]),w=[],y=void 0,i))if(n.parentId===t&&(w.push({id:e,position:{...n.position},extent:n.extent}),"parent"===n.extent||n.expandParent)){let e=function(e,t,n){let i=t.position.x+e.position.x,r=t.position.y+e.position.y,o=e.measured.width??0,a=e.measured.height??0,l=n[0]*o,s=n[1]*a;return[[i-l,r-s],[i+o-l,r+a-s]]}(n,h,n.origin??l);y=y?[[Math.min(e[0][0],y[0][0]),Math.min(e[0][1],y[0][1])],[Math.max(e[1][0],y[1][0]),Math.max(e[1][1],y[1][1])]]:e}c?.(e,{...m})}).on("drag",e=>{let{transform:t,snapGrid:r,snapToGrid:o,nodeOrigin:l}=n(),s=ro(e.sourceEvent,{transform:t,snapGrid:r,snapToGrid:o,containerBounds:v}),d=[];if(!h)return;let{x:c,y:p,width:j,height:k}=m,S={},C=h.origin??l,{width:B,height:z,x:I,y:M}=function(e,t,n,i,r,o,a,l){var s,d,c,u;let{affectsX:p,affectsY:f}=t,{isHorizontal:h,isVertical:g}=t,x=h&&g,{xSnapped:y,ySnapped:m}=n,{minWidth:b,maxWidth:v,minHeight:w,maxHeight:j}=i,{x:k,y:S,width:C,height:B,aspectRatio:z}=e,I=Math.floor(h?y-e.pointerX:0),M=Math.floor(g?m-e.pointerY:0),$=C+(p?-I:I),E=B+(f?-M:M),_=-o[0]*C,R=-o[1]*B,N=r2($,b,v),T=r2(E,w,j);if(a){let e=0,t=0;p&&I<0?e=r0(k+I+_,a[0][0]):!p&&I>0&&(e=r1(k+$+_,a[1][0])),f&&M<0?t=r0(S+M+R,a[0][1]):!f&&M>0&&(t=r1(S+E+R,a[1][1])),N=Math.max(N,e),T=Math.max(T,t)}if(l){let e=0,t=0;p&&I>0?e=r1(k+I,l[0][0]):!p&&I<0&&(e=r0(k+$,l[1][0])),f&&M>0?t=r1(S+M,l[0][1]):!f&&M<0&&(t=r0(S+E,l[1][1])),N=Math.max(N,e),T=Math.max(T,t)}if(r){if(h){(N=Math.max(N,r2($/z,w,j)*z),a)&&(N=Math.max(N,(p||f)&&(!p||f||!x)?r0(S+R+(p?I:-I)/z,a[0][1])*z:r1(S+R+$/z,a[1][1])*z));l&&(N=Math.max(N,(p||f)&&(!p||f||!x)?r1(S+(p?I:-I)/z,l[0][1])*z:r0(S+$/z,l[1][1])*z))}if(g){(T=Math.max(T,r2(E*z,b,v)/z),a)&&(T=Math.max(T,(p||f)&&(!f||p||!x)?r0(k+(f?M:-M)*z+_,a[0][0])/z:r1(k+E*z+_,a[1][0])/z));l&&(T=Math.max(T,(p||f)&&(!f||p||!x)?r1(k+(f?M:-M)*z,l[0][0])/z:r0(k+E*z,l[1][0])/z))}}M+=M<0?T:-T,I+=I<0?N:-N,r&&(x?$>E*z?M=((s=p,d=f,s?!d:d)?-I:I)/z:I=((c=p,u=f,c?!u:u)?-M:M)*z:h?(M=I/z,f=p):(I=M*z,p=f));let W=p?k+I:k,L=f?S+M:S;return{width:C+(p?-I:I),height:B+(f?-M:M),x:o[0]*I*(p?-1:1)+W,y:o[1]*M*(f?-1:1)+L}}(b,a.controlDirection,s,a.boundaries,a.keepAspectRatio,C,x,y),$=B!==j,E=z!==k,_=I!==c&&$,R=M!==p&&E;if(!_&&!R&&!$&&!E)return;let N={prevValues:{...m},startX:b.x,startY:b.y,childNodes:w.map(e=>({...e,position:{...e.position}}))};if((_||R||1===C[0]||1===C[1])&&(S.x=_?I:m.x,S.y=R?M:m.y,m.x=S.x,m.y=S.y,w.length>0)){let e=I-c,t=M-p;for(let n of w)n.position={x:n.position.x-e+C[0]*(B-j),y:n.position.y-t+C[1]*(z-k)},d.push(n)}if(($||E)&&(S.width=$&&(!a.resizeDirection||"horizontal"===a.resizeDirection)?B:m.width,S.height=E&&(!a.resizeDirection||"vertical"===a.resizeDirection)?z:m.height,m.width=S.width,m.height=S.height),g&&h.expandParent){let e=C[0]*(S.width??0);S.x&&S.x<e&&(m.x=e,b.x=b.x-(S.x-e));let t=C[1]*(S.height??0);S.y&&S.y<t&&(m.y=t,b.y=b.y-(S.y-t))}let T=function({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:r,affectsY:o}){let a=e-t,l=n-i,s=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&r&&(s[0]=-1*s[0]),l&&o&&(s[1]=-1*s[1]),s}({width:m.width,prevWidth:j,height:m.height,prevHeight:k,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),W={...m,direction:T};if(!1===f?.(e,W)){m=N.prevValues,b.x=N.startX,b.y=N.startY,w.forEach((e,t)=>{e.position=N.childNodes[t].position});return}u?.(e,W),i(S,d)}).on("end",e=>{p?.(e,{...m}),r?.({...m})});o.call(j)},destroy:function(){o.on(".drag",null)}}}({domNode:C.current,nodeId:k,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:i,nodeOrigin:r,domNode:o}=S.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:i,nodeOrigin:r,paneDomNode:o}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:i,parentLookup:r,nodeOrigin:o}=S.getState(),a=[],l={x:e.x,y:e.y},s=i.get(k);if(s&&s.expandParent&&s.parentId){let t=s.origin??o,n=e.width??s.measured.width??0,d=e.height??s.measured.height??0,c=rT([{id:s.id,parentId:s.parentId,rect:{width:n,height:d,...rn({x:e.x??s.position.x,y:e.y??s.position.y},{width:n,height:d},s.parentId,i,t)}}],i,r,o);a.push(...c),l.x=e.x?Math.max(t[0]*n,e.x):void 0,l.y=e.y?Math.max(t[1]*d,e.y):void 0}if(void 0!==l.x&&void 0!==l.y){let e={id:k,type:"position",position:{...l}};a.push(e)}if(void 0!==e.width&&void 0!==e.height){let t={id:k,type:"dimensions",resizing:!0,setAttributes:!p||("horizontal"===p?"width":"height"),dimensions:{width:e.width,height:e.height}};a.push(t)}for(let e of t){let t={...e,type:"position"};a.push(t)}n(a)},onEnd:({width:e,height:t})=>{S.getState().triggerNodeChanges([{id:k,type:"dimensions",resizing:!1,dimensions:{width:e,height:t}}])}})),I.current.update({controlPosition:M,boundaries:{minWidth:l,minHeight:s,maxWidth:d,maxHeight:c},keepAspectRatio:u,resizeDirection:p,onResizeStart:x,onResize:b,onResizeEnd:v,shouldResize:h}),()=>{I.current?.destroy()}},[M,l,s,d,c,u,x,b,v,h]);let $=M.split("-");return(0,y.jsx)("div",{className:eM(["react-flow__resize-control","nodrag",...$,n,i]),ref:C,style:{...r,scale:z,...a&&{[B?"backgroundColor":"borderColor"]:a}},children:o})});var lN=e.i(62570);let lT={display:"block",width:"100%",marginTop:4,padding:"6px 8px",background:B.f.bg,color:"inherit",border:`1px solid ${B.f.border}`,borderRadius:6,boxSizing:"border-box"};function lW({block:e,onChange:t,canDisable:n=!0,runOnScreen:i=!1}){let r="string"==typeof e.config.model?e.config.model:"";function o(n,i){let{[n]:r,...o}=e.config;t({...e,config:""===i?o:{...o,[n]:i}})}let a="string"==typeof e.config.ai?e.config.ai:"",l=(0,m.useContext)($.c),s=t=>"string"==typeof e.config[t]?e.config[t]:"";return(0,y.jsxs)("div",{style:{display:"grid",gap:10},children:[(0,y.jsxs)("label",{children:[b.B.editing.name,(0,y.jsx)("input",{style:lT,value:e.label,onChange:n=>t({...e,label:n.target.value})})]}),"tests"===e.kind?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("label",{children:[b.B.editing.testCommand,(0,y.jsx)("input",{style:{...lT,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12.5},value:s("testCommand"),placeholder:b.B.editing.testCommandPlaceholder,spellCheck:!1,onChange:e=>o("testCommand",e.target.value)})]}),(0,y.jsx)("p",{style:{margin:0,fontSize:12,color:B.f.skipped},children:b.B.editing.testCommandHint})]}):(0,y.jsxs)(y.Fragment,{children:[es.o.has(e.kind)&&(0,y.jsxs)("div",{children:[b.B.editing.ai,(0,y.jsx)(lN.G,{testId:"block-ai",ai:l(e.config.ai,e.kind)??(0,es.j)(a),value:a,taskAi:l(void 0,e.kind)??void 0,label:b.B.editing.chooseAi(e.label),model:r,onChange:(n,i)=>t({...e,config:(0,es.c)(e.config,n,i)}),markSize:18,style:{...lT,display:"flex",padding:"8px 10px",fontSize:14,textAlign:"left",cursor:"pointer"}})]}),(0,y.jsxs)("label",{children:[b.B.editing.model,(0,y.jsx)("input",{style:lT,value:r,placeholder:b.B.editing.modelPlaceholder,onChange:e=>o("model",e.target.value)})]})]}),"review"===e.kind&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("label",{children:[b.B.editing.lookFor,(0,y.jsx)("textarea",{style:{...lT,minHeight:190,resize:"vertical",lineHeight:1.45},value:s("lookFor"),placeholder:b.B.editing.lookForPlaceholder,maxLength:600,onChange:e=>o("lookFor",e.target.value)})]}),(0,y.jsx)("p",{style:{margin:0,fontSize:12,color:B.f.skipped},children:b.B.editing.lookForHint})]}),"build"===e.kind&&!(0,es.q)(a)&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("label",{children:[b.B.editing.modelFrontend,(0,y.jsx)("input",{style:lT,value:s("modelFrontend"),placeholder:b.B.editing.sameAsModel,onChange:e=>o("modelFrontend",e.target.value)})]}),(0,y.jsxs)("label",{children:[b.B.editing.modelBackend,(0,y.jsx)("input",{style:lT,value:s("modelBackend"),placeholder:b.B.editing.sameAsModel,onChange:e=>o("modelBackend",e.target.value)})]}),(0,y.jsx)("p",{style:{margin:0,fontSize:12,color:B.f.skipped},children:b.B.editing.areaHint})]}),i&&(0,y.jsx)("p",{style:{margin:0,fontSize:12,color:B.f.skipped},children:b.B.editing.appliesNextRun}),(0,y.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,y.jsx)("input",{type:"checkbox",checked:e.enabled,disabled:!n,"aria-describedby":n?void 0:"cannot-disable",onChange:n=>t({...e,enabled:n.target.checked})}),b.B.editing.enabled]}),!n&&(0,y.jsx)("p",{id:"cannot-disable",style:{margin:0,color:B.f.skipped},children:b.B.editing.cannotDisable})]})}function lL(e){return ek.filter(t=>!eS.includes(t)||!e.blocks.some(e=>e.kind===t))}function lP(e,t,n){return{blocks:e.blocks.map(e=>e.id===t?{...e,position:n}:e)}}function lA(e,t){return eC.includes(t.kind)&&!e.blocks.some(e=>e.kind===t.kind&&e.id!==t.id&&e.enabled)}function lH(e,t){return{blocks:e.blocks.filter(e=>e.id!==t)}}function lF(e,t){let n=e.blocks.find(e=>e.id===t);if(!n)return[];let i=ek.indexOf(n.kind);return[...ek.slice(0,i).flatMap(t=>{let n=e.blocks.filter(e=>e.kind===t&&e.enabled).map(e=>e.label);return n.length>0?[n.join(" / ")]:[]}),n.label]}function lO({floorRef:e}){return(0,y.jsxs)("div",{"aria-hidden":"true","data-testid":"depth",style:{position:"absolute",inset:0,overflow:"hidden",pointerEvents:"none",zIndex:0},children:[(0,y.jsx)("div",{"data-testid":"depth-ambient",style:{position:"absolute",inset:0,background:B.f.ambient,pointerEvents:"none"}}),(0,y.jsx)("div",{style:{position:"absolute",inset:0,perspective:700,perspectiveOrigin:"50% 0%",pointerEvents:"none"},children:(0,y.jsx)("div",{ref:e,"aria-hidden":"true","data-testid":"depth-floor",style:{position:"absolute",left:"-100%",width:"300%",top:"15%",height:"300%",transformOrigin:"50% 0%",transform:"rotateX(62deg)",backgroundImage:`linear-gradient(${B.f.floorLine} 1px, transparent 1px), linear-gradient(90deg, ${B.f.floorLine} 1px, transparent 1px)`,backgroundSize:"64px 64px",maskImage:"linear-gradient(to bottom, transparent 0%, black 35%)",WebkitMaskImage:"linear-gradient(to bottom, transparent 0%, black 35%)",pointerEvents:"none"}})})]})}let lD="factory.panel.closed",lq=new Set,lV=new Map;function lY(e){return lq.add(e),window.addEventListener("storage",e),()=>{lq.delete(e),window.removeEventListener("storage",e)}}function lX(e,t){return[(0,m.useSyncExternalStore)(lY,()=>(function(e,t){try{let n=window.localStorage.getItem(e);return null===n?t:"1"===n}catch{return lV.get(e)??t}})(e,t),()=>t),(0,m.useCallback)(t=>{lV.set(e,t);try{window.localStorage.setItem(e,t?"1":"0")}catch{}lq.forEach(e=>e())},[e])]}var lU=e.i(34910);let lZ=b.B.steps,lK=["failed","blocked","waiting_approval","running","queued","cancelled","skipped","passed"],lG=["failed","blocked","waiting_approval","running"],lJ=e=>"passed"===e?C.f.green:null===e||"queued"===e||"skipped"===e||"cancelled"===e?C.f.faint:B.f[(0,$.Y)(e)];function lQ({state:e,size:t=22,id:n="step"}){if("running"===e)return(0,y.jsx)($.m,{blockId:`step-${n}`,size:t});let i=lJ(e),r="passed"===e;return(0,y.jsx)("span",{"aria-hidden":"true",style:{width:t,height:t,flex:"none",borderRadius:"50%",display:"grid",placeItems:"center",background:r?i:"transparent",border:`1.5px solid ${i}`,color:r?C.f.onGreen:i,fontSize:.55*t,fontWeight:900,lineHeight:1},children:r?"✓":"failed"===e?"!":"waiting_approval"===e?"•":""})}let l0={width:28,height:28,display:"grid",placeItems:"center",borderRadius:7,border:"1px solid transparent",background:"none",color:C.f.quiet,cursor:"pointer"};function l1({blocks:e,stateOf:t,hasRun:n,pickedId:i,onPick:r,workOf:o,title:a,detail:l,blank:s=!1,loading:d=!1,side:c,onSettings:u}){let p=ek.map(t=>e.filter(e=>e.kind===t)).filter(e=>e.length>0).map(e=>({id:e[0].id,label:e.length>1&&"tests"===e[0].kind?lZ.checks:e[0].label,blocks:e})),f=e=>{let n=e.blocks.filter(e=>e.enabled).map(e=>t(e.id));return lK.find(e=>n.includes(e))??null},h=void 0!==c,[g]=lX(lD,!1),x=g?56:497,v=h?{flex:"none",width:300,overflowY:"auto",padding:"28px 20px 40px 24px",display:"grid",gap:22,alignContent:"start"}:{position:"absolute",inset:0,overflowY:"auto",padding:`28px ${x+36}px 56px 36px`,display:"grid",gap:28,alignContent:"start"},w=(0,y.jsxs)("div",{"data-testid":"steps-view","data-column":h?"true":void 0,style:{...v,backgroundColor:C.f.bg,backgroundImage:"radial-gradient(circle, #2b2b2b 1px, transparent 1.5px)",backgroundSize:"24px 24px",backgroundAttachment:"local",color:C.f.text,fontFamily:C.f.sans,scrollbarWidth:"thin",scrollbarColor:`${C.f.line} transparent`,opacity:d?.4:1},children:[a&&(0,y.jsx)("div",{style:{position:"relative",height:44,margin:"-18px 0 14px -24px"},children:a}),!s&&(0,y.jsx)("ol",{"data-testid":"steps-row","aria-label":lZ.rowLabel,style:{listStyle:"none",margin:0,padding:0,display:"flex",...h?{flexDirection:"column",alignItems:"stretch"}:{flexWrap:"wrap",rowGap:12,alignItems:"flex-start"}},children:p.map((e,a)=>{let l=f(e),s=e.blocks.every(e=>!e.enabled),d=e.blocks.some(e=>e.id===i),c=e.blocks.length>1,g=a>0?f(p[a-1]):null,x=s?null:"running"===l?"59, 130, 246":"waiting_approval"===l?"245, 158, 11":null,v=s?void 0:e.blocks.find(e=>e.enabled&&lG.includes(t(e.id)??"")),w=v?o?.(v.id)??null:null,j=w&&"running"===l?w.steps[w.steps.length-1]:void 0;return(0,y.jsxs)(m.Fragment,{children:[a>0&&(0,y.jsx)("li",{"aria-hidden":"true",className:"running"===l?"factory-step-flow":void 0,style:{...h?{flex:"none",width:2,height:16,marginLeft:30}:{flex:"0 1 22px",minWidth:8,height:2,marginTop:34},..."running"===l?{"--pulse":x}:{background:"passed"===g?C.f.green:C.f.line,opacity:"passed"===g?.55:1}}}),(0,y.jsx)("li",{style:{...h?{flex:"none"}:{flex:w?"2 1 230px":"1 1 104px",maxWidth:w?320:170,minWidth:104},display:"grid",opacity:s?.5:1},children:(0,y.jsxs)("div",{"data-live":x?"true":void 0,className:x?"factory-step-live":void 0,style:{position:"relative",display:"grid",gap:12,alignContent:"start",padding:14,borderRadius:14,border:`1px solid ${x?`rgb(${x})`:d?C.f.green:C.f.line}`,background:d?"#1c1f1c":C.f.card,...x?{"--pulse":x}:{boxShadow:d?"0 0 0 3px rgba(121, 220, 139, 0.12)":"none"}},children:[(0,y.jsxs)("button",{type:"button","data-testid":`step-${e.id}`,"aria-current":d?"step":void 0,onClick:()=>r(e.blocks[0].id),style:{display:"grid",gap:14,padding:0,background:"none",border:"none",color:"inherit",font:"inherit",textAlign:"left",cursor:"pointer"},children:[(0,y.jsxs)("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,y.jsx)(lU.f,{kind:e.blocks[0].kind,colour:C.f.text,size:34}),(0,y.jsx)(lQ,{state:l,id:e.id})]}),(0,y.jsxs)("span",{style:{display:"grid",gap:4},children:[(0,y.jsx)("strong",{style:{fontSize:16,letterSpacing:"-0.01em",overflowWrap:"anywhere"},children:e.label}),(0,y.jsx)("span",{style:{minHeight:13,fontFamily:C.f.mono,fontSize:10.5,letterSpacing:"0.14em",textTransform:"uppercase",color:lJ(l)},children:"waiting_approval"===l&&e.blocks.some(e=>o?.(e.id)?.turn)?b.B.direct.yourTurn:s?lZ.off:l?b.B.canvas.stateLabel[l]:n?lZ.notInTask:""})]})]}),u&&!c&&(0,y.jsxs)("span",{style:{position:"absolute",top:17,left:58,display:"flex",gap:4},children:[(0,y.jsx)("button",{type:"button",className:"factory-step-tool","data-testid":`step-settings-${e.id}`,"aria-label":lZ.settings(e.label),title:lZ.settings(e.label),onClick:()=>u(e.blocks[0].id),style:l0,children:(0,y.jsx)(P,{size:15})}),null!==l&&(0,y.jsx)("button",{type:"button",className:"factory-step-tool","data-testid":`step-see-${e.id}`,"aria-label":lZ.see(e.label),title:lZ.see(e.label),onClick:()=>r(e.blocks[0].id),style:l0,children:(0,y.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,y.jsx)("path",{d:"M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7z"}),(0,y.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})})]}),w&&(w.summary||j)&&(0,y.jsxs)("div",{"data-testid":`step-work-${e.id}`,style:{display:"grid",gap:6,paddingTop:10,borderTop:`1px solid ${C.f.line}`,fontSize:13,lineHeight:1.45},children:[w.summary&&(0,y.jsx)("span",{style:{color:C.f.text,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden",overflowWrap:"anywhere"},children:w.summary}),j&&j!==w.summary&&(0,y.jsxs)("span",{style:{display:"flex",gap:7,color:C.f.quiet,fontFamily:C.f.mono,fontSize:11.5},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{color:lJ(l)},children:"›"}),(0,y.jsx)("span",{style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",overflowWrap:"anywhere"},children:j})]})]}),c&&(0,y.jsx)("ul",{style:{listStyle:"none",margin:0,padding:"10px 0 0",display:"grid",gap:4,borderTop:`1px solid ${C.f.line}`},children:e.blocks.map(e=>(0,y.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:2},children:[(0,y.jsxs)("button",{type:"button","data-testid":`check-${e.id}`,"aria-current":i===e.id?"step":void 0,onClick:()=>r(e.id),style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"4px 6px",borderRadius:7,background:i===e.id?"#262a26":"none",border:"none",color:e.enabled?C.f.quiet:C.f.faint,font:"inherit",fontSize:13.5,textAlign:"left",cursor:"pointer"},children:[(0,y.jsx)(lQ,{state:e.enabled?t(e.id):null,size:15,id:`check-${e.id}`}),e.label,n&&e.enabled&&!t(e.id)&&(0,y.jsx)("span",{"data-testid":`check-later-${e.id}`,style:{marginLeft:"auto",color:C.f.faint,fontSize:11.5},children:lZ.fromNextTask})]}),u&&(0,y.jsx)("button",{type:"button",className:"factory-step-tool","data-testid":`step-settings-${e.id}`,"aria-label":lZ.settings(e.label),title:lZ.settings(e.label),onClick:()=>u(e.id),style:{...l0,width:24,height:24,flex:"none"},children:(0,y.jsx)(P,{size:13})})]},e.id))})]})})]},e.id)})}),!s&&!h&&(l??(0,y.jsx)("p",{style:{margin:0,maxWidth:"60ch",fontSize:14.5,lineHeight:1.55,color:C.f.quiet},children:n?lZ.notInTaskHint:lZ.beforeRun}))]});return h?(0,y.jsxs)("div",{"data-testid":"direct-edit",style:{position:"absolute",inset:0,display:"flex",paddingRight:x,transition:"padding-right 200ms ease-out",background:C.f.bg},children:[w,(0,y.jsx)("div",{style:{flex:1,minWidth:0},children:c})]}):w}function l2({edge:e,path:t,active:n}){return n?(0,y.jsx)("g",{"data-testid":`particles-${e.from}->${e.to}`,"aria-hidden":"true",style:{pointerEvents:"none"},children:Array.from({length:3},(e,n)=>(0,y.jsx)("circle",{r:3.5,fill:B.f.running,style:{filter:`drop-shadow(0 0 4px ${B.f.running})`},children:(0,y.jsx)("animateMotion",{dur:"2.4s",begin:`${2.4*n/3}s`,repeatCount:"indefinite",path:t})},n))}):null}function l5({cable:e}){let t=ld(e.edge.from),n=ld(e.edge.to),i=e.from.x+(t?.measured.width??$.X),r=e.from.y+(t?.measured.height??120)/2,o=e.to.y+(n?.measured.height??120)/2,[a]=rg({sourceX:i,sourceY:r,sourcePosition:h.Right,targetX:e.to.x,targetY:o,targetPosition:h.Left});return(0,y.jsx)(l2,{edge:e.edge,path:a,active:!0})}function l4({cables:e}){return(0,y.jsx)("svg",{"aria-hidden":"true","data-testid":"particle-layer",width:1,height:1,style:{position:"absolute",overflow:"visible",pointerEvents:"none"},children:e.map(e=>(0,y.jsx)(l5,{cable:e},`${e.edge.from}->${e.edge.to}`))})}function l6(e){return ek.map(t=>e.filter(e=>e.kind===t)).filter(e=>e.length>0)}let l3=["running","waiting_approval","blocked","failed"],l8={run:(0,y.jsx)("path",{d:"M5 3.5v9l7-4.5z"}),add:(0,y.jsx)("path",{d:"M8 3v10M3 8h10"}),settings:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("path",{d:"M3 4.5h10M3 11.5h10"}),(0,y.jsx)("circle",{cx:"6",cy:"4.5",r:"1.6"}),(0,y.jsx)("circle",{cx:"10.5",cy:"11.5",r:"1.6"})]}),log:(0,y.jsx)("path",{d:"M3 4h10M3 8h10M3 12h7"}),collapse:(0,y.jsx)("path",{d:"M10 3.5L5.5 8l4.5 4.5"}),expand:(0,y.jsx)("path",{d:"M6 3.5L10.5 8 6 12.5"})};function l9({name:e,size:t=16}){return(0,y.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block",flex:"0 0 auto"},children:l8[e]})}function l7({width:e="100%",height:t=12,radius:n=6,style:i}){return(0,y.jsx)("div",{"aria-hidden":"true",className:"factory-skeleton",style:{width:e,height:t,borderRadius:n,...i}})}function se({count:e}){let t=Math.min(2,e);return(0,y.jsx)("div",{"data-testid":"lane-skeleton","aria-busy":"true",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",gap:12,pointerEvents:"none",paddingRight:360},children:Array.from({length:e},(n,i)=>{let r=i>=e-t;return(0,y.jsxs)("div",{style:{width:r?230:46,height:180,borderRadius:12,border:`1px solid ${B.f.border}`,background:B.f.card,padding:r?14:8,display:"grid",alignContent:"start",gap:10},children:[(0,y.jsx)(l7,{width:r?"55%":"100%",height:r?16:22}),r&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(l7,{width:"35%",height:9}),(0,y.jsx)(l7,{height:11}),(0,y.jsx)(l7,{width:"80%",height:11}),(0,y.jsx)(l7,{height:48,radius:8})]})]},i)})})}function st(){return(0,y.jsxs)("div",{"data-testid":"card-skeleton","aria-busy":"true",style:{display:"grid",gap:12},children:[(0,y.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[(0,y.jsx)(l7,{width:30,height:30,radius:8}),(0,y.jsxs)("div",{style:{flex:1,display:"grid",gap:6},children:[(0,y.jsx)(l7,{width:"40%",height:14}),(0,y.jsx)(l7,{width:"75%",height:10})]})]}),(0,y.jsx)(l7,{height:10}),(0,y.jsx)(l7,{width:"85%",height:10}),(0,y.jsx)(l7,{height:96,radius:10}),(0,y.jsx)(l7,{height:38,radius:8})]})}let sn="return-out",si="return-in",sr={top:48,bottom:48,left:40,right:537},so={maxZoom:1,padding:{top:`${sr.top}px`,bottom:`${sr.bottom}px`,left:`${sr.left}px`,right:`${sr.right}px`}},sa={block:function({data:e}){let t=I(),[n,i]=(0,m.useState)(!1);return(0,y.jsxs)("div",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),"data-testid":`node-${e.block.id}`,"data-state":e.view?e.view.state:"not_in_run","data-highlighted":e.highlighted?"true":"false",style:{borderRadius:10,outline:e.highlighted?`3px solid ${B.f.pointer}`:"none",outlineOffset:3,boxShadow:B.f.elevation(2*!!(n&&!t)),transition:t?"none":"box-shadow 120ms ease-out"},children:[(0,y.jsx)(al,{type:"target",position:h.Left,isConnectable:!1}),(0,y.jsx)("div",{style:void 0===e.cardWidth||t?void 0:{width:(e.collapsed?$.K:e.cardWidth)+28,padding:14,margin:-14,overflow:"hidden",transition:"width 320ms cubic-bezier(0.2, 0.7, 0.2, 1)"},children:(0,y.jsx)("div",{className:void 0===e.cardWidth||t?void 0:"factory-fade-in",children:e.collapsed?(0,y.jsx)($.u,{block:e.block,view:e.view,selected:e.selected}):e.view?(0,y.jsx)($.l,{block:e.block,view:e.view,expanded:e.expanded,selected:e.selected,issues:e.issues,breadcrumb:e.breadcrumb,onCollapse:e.onCollapse,collapseLabel:e.collapseLabel,onRemove:e.onRemove,width:e.cardWidth,failedActions:e.failedActions,onDetails:e.onDetails}):(0,y.jsx)($.e,{block:e.block,selected:e.selected,issues:e.issues,onRemove:e.onRemove})},e.collapsed?"spine":"card")}),(0,y.jsx)(al,{type:"source",position:h.Right,isConnectable:!1}),(0,y.jsx)(al,{id:sn,type:"source",position:h.Top,isConnectable:!1}),(0,y.jsx)(al,{id:si,type:"target",position:h.Top,isConnectable:!1})]})}},sl="factory.sidebar.open",ss="sidebar-palette",sd="sidebar-block-settings",sc="factory:step-settings",su="sidebar-log",sp="run-request";function sf({icon:e,label:t,onClick:n}){return(0,y.jsx)("button",{type:"button","aria-label":t,title:t,onClick:n,style:{width:36,height:36,display:"grid",placeItems:"center",background:"transparent",color:B.f.dim,border:"1px solid transparent",borderRadius:8,cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.background=B.f.card,e.currentTarget.style.borderColor=B.f.border},onMouseLeave:e=>{e.currentTarget.style.background="transparent",e.currentTarget.style.borderColor="transparent"},children:(0,y.jsx)(l9,{name:e})})}let sh={padding:"6px 10px",background:B.f.card,color:"inherit",border:`1px solid ${B.f.border}`,borderRadius:6,cursor:"pointer",textAlign:"left"};function sg(e){return{blockId:e.id,state:"queued",summary:ep({kind:e.kind,state:"queued"}),summaryIsClaim:!1,steps:[]}}function sx({graph:e,nodeRuns:t=[],save:n,expandedId:i=null,runBlocks:r,highlightedId:o=null,flushRef:a,sidebarTop:l,sidebarLog:s,loading:d=!1,blank:c=!1,taskId:u=null,overlay:p,onFailedClick:h,onDetails:g,canRetry:x=!1,layout:v="canvas",stepDetails:w,site:j}){var k;let S,z,M,E,_,[R,N]=(0,m.useState)(e),[T,W]=(0,m.useState)(i),[L,P]=(0,m.useState)(i),[A,H]=(0,m.useState)([]),[F,O]=(0,m.useState)(null),[D,q]=(0,m.useState)(u);D!==u&&(q(u),O(null),W(null));let[V,Y]=(0,m.useState)(o);o!==V&&(Y(o),o&&O(o));let[X,U]=(0,m.useState)(!1),Z=(0,m.useRef)(e),K=(0,m.useRef)(!1),G=(0,m.useRef)(null),J=(0,m.useRef)(0),Q=(0,m.useRef)(!1),ee=(0,m.useRef)(n);(0,m.useEffect)(()=>{ee.current=n});let et=(0,m.useRef)(Promise.resolve()),en=(0,m.useCallback)(()=>{G.current&&clearTimeout(G.current),G.current=null;let e=ee.current;if(!K.current||!e)return et.current;K.current=!1;let t=++J.current;return et.current=e(Z.current).then(e=>{Q.current&&t===J.current&&(H(e),U(!1))},()=>{K.current=!0,Q.current&&t===J.current&&U(!0)}),et.current},[]),ei=(0,m.useCallback)(()=>void en(),[en]);(0,m.useEffect)(()=>{if(a)return a.current=async()=>(await en(),!K.current),()=>{a.current=null}},[a,en]),(0,m.useEffect)(()=>(Q.current=!0,window.addEventListener("pagehide",ei),()=>{window.removeEventListener("pagehide",ei),ei(),Q.current=!1}),[ei]);let er=(0,m.useCallback)((e,t=!0)=>{Z.current=e(Z.current),N(Z.current),t&&(K.current=!0,G.current&&clearTimeout(G.current),G.current=setTimeout(ei,500))},[ei]),eo=new Map(t.map(e=>[e.blockId,e])),ea=e=>A.filter(t=>t.blockId===e).map(e=>e.message),el=A.filter(e=>null===e.blockId||!R.blocks.some(t=>t.id===e.blockId)),es=lL(R),ed=(0,m.useRef)(null),[ec,eu]=(0,m.useState)({}),ep=I(),[ef,eh]=lX(sl,!0),[eg,ex]=(0,m.useState)(!1),ey=(0,m.useCallback)(e=>{ex(!0),eh(e)},[eh]),em=(0,m.useRef)(null),eb=(0,m.useRef)(null),ev=(0,m.useCallback)(e=>{let t=ed.current,n=em.current;if(!t)return;let i=eb.current;i&&n?t.setViewport(function(e,t,n,i=0){let r=[...e.values()].map(e=>({x:e.x,y:e.y,w:e.collapsed?$.K:$.X,h:$.G}));if(0===r.length)return{x:0,y:0,zoom:1};let o=Math.min(...r.map(e=>e.x)),a=Math.max(...r.map(e=>e.x+e.w)),l=Math.min(...r.map(e=>e.y)),s=Math.max(...r.map(e=>e.y+e.h)),d=Math.max(1,t.width-n.left-n.right),c=Math.max(1,t.height-n.top-n.bottom),u=Math.max(i,Math.min(1,d/(a-o),c/(s-l)));return{x:n.left+Math.max(0,d-(a-o)*u)/2-o*u,y:n.top+Math.max(0,c-(s-l)*u)/2-l*u,zoom:u}}(i.lane,{width:n.clientWidth,height:n.clientHeight},sr,i.minZoom),{duration:e}):t.fitView({...so,duration:e})},[]);(0,m.useEffect)(()=>{let e=()=>ev(0);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[ev]),(0,m.useEffect)(()=>{let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>ev(300*!ep))});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}},[ef,ep,ev]);let ew=(e,t)=>{ey(!0),requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView?.({block:"start",behavior:ep?"auto":"smooth"}),t&&document.getElementById(t)?.focus()})},ej=(0,m.useRef)(()=>void 0),[eS,eC]=(0,m.useState)(0);(0,m.useEffect)(()=>{ej.current=e=>{W(e),eC(e=>e+1),ew(sd)}}),(0,m.useEffect)(()=>{let e=e=>{let t=e.detail;"string"==typeof t&&ej.current(t)};return window.addEventListener(sc,e),()=>window.removeEventListener(sc,e)},[]);let eB=(0,m.useRef)(null),ez=(0,m.useCallback)(e=>{eB.current&&(eB.current.style.translate=`${.3*e.x}px ${.3*e.y}px`)},[]);(0,m.useEffect)(()=>{o&&ed.current?.fitView({...so,nodes:[{id:o}],duration:300})},[o]);let eI=void 0!==r||t.length>0,eM=r?.map(e=>e.id)??[],e$=e=>r?r.some(t=>t.id===e.id&&t.kind===e.kind):eo.has(e.id),eE=e=>r?.find(t=>t.id===e.id&&t.kind===e.kind),e_=new Set(R.blocks.map(e=>e.id)),eR=(r??[]).filter(e=>!e_.has(e.id)),eN={blocks:[...R.blocks.map(e=>{var t;return{...e,...(t=eE(e))?{label:t.label,enabled:t.enabled,config:t.config}:{}}}),...eR]},eT=ek.flatMap(e=>eN.blocks.filter(t=>t.kind===e)),eW=eI?F??function(e){for(let t of l3){let n=e.find(e=>e.state===t);if(n)return n.id}let t=[...e].reverse().find(e=>null!==e.state&&"queued"!==e.state);return t?.id??e[0]?.id??null}(eT.map(e=>({id:e.id,state:eo.get(e.id)?.state??null}))):null,eL=new Set(eT.filter(e=>{var t;let n;return ea(e.id).length>0||eI&&(e_.has(e.id)&&!e$(e)||(t=e.id,"running"===(n=eo.get(t)?.state)||"waiting_approval"===n))}).map(e=>e.id)),eP=eI?function(e,t,n=new Set,i={}){let r=l6(e),o=r.findIndex(e=>e.some(e=>e.id===t)),a=-1===o?0:o,l=e=>1>=Math.abs(e-a)||r[e].some(e=>n.has(e.id)),s=new Map,d=0;return r.forEach((e,t)=>{let n=!l(t),o=0;for(let t of e)s.set(t.id,{x:d,y:o,collapsed:n}),o+=Math.max($.G,i[t.id]?.height??0)+40;if(t===r.length-1)return;let a=l(t),c=l(t+1);d+=(n?$.K:$.X)+(a&&c?64:a||c?44:18)}),s}(eT,eW,eL,ec):null,eA=eI?null:function(e,t={}){let n=new Map;for(let i of l6(e)){let e=-1/0,r=null;for(let o of[...i].sort((e,t)=>e.position.y-t.position.y)){let i=null!==r&&Math.abs(o.position.x-r)<$.X?Math.max(o.position.y,e):o.position.y;n.set(o.id,{x:o.position.x,y:i,collapsed:!1}),e=i+Math.max($.G,t[o.id]?.height??0)+40,r=o.position.x}}return n}(R.blocks,ec),eH=(0,m.useRef)(eA);(0,m.useEffect)(()=>{eb.current=eP?{lane:eP,minZoom:0}:eA?{lane:eA,minZoom:.5}:null,eH.current=eA});let eF=(0,m.useRef)(L);(0,m.useEffect)(()=>{if(eI||eF.current===L)return;eF.current=L;let e=300*!ep;L?ed.current?.fitView({...so,nodes:[{id:L}],duration:e}):ev(e)},[L,eI,ep,ev]),(0,m.useEffect)(()=>{eI||ev(0)},[eI,ev]);let eO=eI?eW:null;(0,m.useEffect)(()=>{null!==eO&&ev(300*!ep)},[eO,ep,ev]);let eD=e=>eP?.get(e.id),eq="steps"===v,eV=e=>{let t=eN.blocks.find(t=>t.id===e);return eI&&t&&(e$(t)||!e_.has(e))?eo.get(e)?.state??"queued":null},eY=(eI?F:null)??T,eX=eq?eY&&eN.blocks.some(e=>e.id===eY)?eY:(k=eN.blocks,S=ek.flatMap(e=>k.filter(t=>t.kind===e&&t.enabled)),(S.find(e=>lG.includes(eV(e.id)??""))??S[S.length-1])?.id??null):null,eU=R.blocks.find(e=>e.id===(eq?eX:T))??null,eZ=eq?{bg:C.f.bg,line:C.f.line,panel:C.f.card,head:"#1e1e1e"}:{bg:B.f.bg,line:B.f.border,panel:"#0f141c",head:"#131a24"},eK=()=>{W(null),P(null),O(null)};(0,m.useEffect)(()=>{let e=e=>{if("Escape"!==e.key)return;let t=e.target;t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName||t.isContentEditable)||(W(null),P(null),O(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let eG=eI&&h?{onSee:()=>h("see"),onAgain:x?()=>h("again"):void 0}:void 0,eJ=[...R.blocks.map(e=>{let t=eI?e$(e)?eo.get(e.id)??sg(e):null:sg(e),n=eD(e);return{id:e.id,type:"block",position:n?{x:n.x,y:n.y}:{x:e.position.x,y:eA?.get(e.id)?.y??e.position.y},data:{block:t?eE(e)??e:e,view:t,highlighted:o===e.id,expanded:eI?e.id===eW:L===e.id,selected:T===e.id,issues:ea(e.id),breadcrumb:eI?[]:lF(R,e.id),collapsed:n?.collapsed??!1,cardWidth:eI?$.X:void 0,collapseLabel:b.B.canvas.close,onCollapse:eI?void 0:eK,onRemove:lA(R,e)||eI&&t?void 0:()=>{var t;return t=e.id,void(er(e=>lH(e,t)),W(null),P(null),O(e=>e===t?null:e))},failedActions:eG,onDetails:eI&&g&&e$(e)?()=>g(e.id):void 0}}}),...eR.map(e=>({id:e.id,type:"block",position:eD(e)??{x:e.position.x,y:e.position.y},draggable:!1,data:{block:e,view:eo.get(e.id)??sg(e),highlighted:o===e.id,expanded:eI?e.id===eW:L===e.id,selected:!1,issues:[],breadcrumb:eI?[]:lF({blocks:[...r??[]]},e.id),collapsed:eD(e)?.collapsed??!1,cardWidth:eI?$.X:void 0,collapseLabel:b.B.canvas.close,onCollapse:eI?void 0:eK}}))].map(e=>ec[e.id]?{...e,measured:ec[e.id]}:e),eQ=new Set(eJ.map(e=>e.id)),e0=new Set(eJ.filter(e=>null===e.data.view).map(e=>e.id)),e1=(e,t)=>{let n=Z.current.blocks.find(t=>t.id===e);if(!n)return t;let i=eH.current?.get(e)?.y,r=void 0!==i&&i!==n.position.y&&t.y===i?n.position.y:t.y;return{x:t.x,y:r}},e2=(z=ek.map(e=>eN.blocks.filter(t=>t.kind===e&&t.enabled)).filter(e=>e.length>0),M=[],z.forEach((e,t)=>{let n=z[t+1];if(n)for(let t of e)for(let e of n)M.push({from:t.id,to:e.id,kind:"normal"})}),E=eN.blocks.find(e=>"approve"===e.kind&&e.enabled),_=eN.blocks.find(e=>"build"===e.kind&&e.enabled),E&&_&&M.push({from:E.id,to:_.id,kind:"return"}),M),e5=e2.filter(e=>eQ.has(e.from)&&eQ.has(e.to)).map(e=>"return"===e.kind?{id:`${e.from}->${e.to}:return`,source:e.from,target:e.to,sourceHandle:sn,targetHandle:si,type:"smoothstep",label:b.B.canvas.returnEdge,style:{stroke:B.f.failed,strokeWidth:2,strokeDasharray:"6 4"},labelStyle:{fill:B.f.failed},markerEnd:{type:f.ArrowClosed,color:B.f.failed}}:{id:`${e.from}->${e.to}`,source:e.from,target:e.to,style:{stroke:B.f.border,strokeWidth:2,strokeDasharray:e0.has(e.from)||e0.has(e.to)?"4 4":void 0},markerEnd:{type:f.ArrowClosed,color:B.f.border}}),e4=ep?[]:e2.filter(e=>"normal"===e.kind&&eQ.has(e.from)&&eQ.has(e.to)).filter(e=>eJ.find(t=>t.id===e.to)?.data.view?.state==="running").map(e=>({edge:e,from:eJ.find(t=>t.id===e.from).position,to:eJ.find(t=>t.id===e.to).position}));return(0,y.jsxs)("div",{"data-testid":"canvas","data-edges":e5.map(e=>e.id).join(","),style:{display:"flex",width:"100%",height:"100%",background:eZ.bg,color:"inherit"},children:[(0,y.jsxs)("div",{"data-testid":"sidebar-column",style:{flexShrink:0,display:"flex",overflow:"hidden",width:ef?300:56,transition:ep?void 0:"width 220ms cubic-bezier(0.22, 1, 0.36, 1)"},children:[!ef&&(0,y.jsxs)("nav",{"data-testid":"sidebar-rail",className:eg?"factory-fade-in":void 0,"aria-label":b.B.sidebar.label,style:{width:56,flexShrink:0,padding:"10px 0",display:"flex",flexDirection:"column",alignItems:"center",gap:6,borderRight:`1px solid ${eZ.line}`},children:[(0,y.jsx)(sf,{icon:"expand",label:b.B.sidebar.open,onClick:()=>ey(!0)}),(0,y.jsx)("span",{"aria-hidden":"true",style:{width:24,height:1,background:B.f.border,margin:"4px 0"}}),(0,y.jsx)(sf,{icon:"run",label:b.B.sidebar.run,onClick:()=>document.getElementById(sp)?.focus()}),(0,y.jsx)(sf,{icon:"add",label:b.B.editing.paletteTitle,onClick:()=>ew(ss)}),(0,y.jsx)(sf,{icon:"settings",label:b.B.editing.inspectorTitle,onClick:()=>ew(sd)}),s&&(0,y.jsx)(sf,{icon:"log",label:b.B.events.barTitle,onClick:()=>ew(su)})]}),(0,y.jsxs)("aside",{"data-testid":"sidebar",className:eg&&ef?"factory-fade-in":void 0,"aria-label":b.B.sidebar.label,hidden:!ef,style:{width:300,flexShrink:0,padding:12,display:ef?"flex":"none",flexDirection:"column",gap:20,borderRight:`1px solid ${eZ.line}`,overflowY:"auto",scrollbarWidth:"thin",scrollbarColor:`${B.f.floorLine} transparent`},children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,y.jsx)("span",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,fontWeight:800,letterSpacing:"0.13em",textTransform:"uppercase",color:B.f.dim},children:b.B.sidebar.label}),(0,y.jsx)(sf,{icon:"collapse",label:b.B.sidebar.close,onClick:()=>ey(!1)})]}),l&&(0,y.jsx)("section",{id:"sidebar-run",style:{display:"grid",gap:10,paddingBottom:20,borderBottom:`1px solid ${eZ.line}`},children:l}),(0,y.jsxs)("section",{id:ss,"data-testid":"palette",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:6},children:[(0,y.jsx)("h2",{style:{margin:0,fontSize:14,gridColumn:"1 / -1"},children:b.B.editing.paletteTitle}),0===es.length&&(0,y.jsx)("p",{style:{margin:0,gridColumn:"1 / -1",color:B.f.skipped},children:b.B.editing.paletteEmpty}),es.map(e=>(0,y.jsxs)("button",{type:"button",className:"factory-add-block",style:{...sh,display:"flex",alignItems:"center",justifyContent:"center",gap:7,background:"transparent",border:`1px dashed ${C.f.green}`,color:C.f.green,fontWeight:700,whiteSpace:"nowrap",padding:"8px 6px",fontSize:13},onClick:()=>{let t=new Set(Z.current.blocks.map(e=>e.id));er(t=>(function(e,t,n=[]){if(!lL(e).includes(t))return e;let i=e.blocks.filter(e=>e.kind===t).length,r={id:function(e,t,n=[]){let i=new Set([...e.blocks.map(e=>e.id),...n]);if(!i.has(t))return t;let r=1;for(;i.has(`${t}-${r}`);)r++;return`${t}-${r}`}(e,t,n),kind:t,label:b.B.blocks[t],enabled:!0,config:{},position:{x:420*ek.indexOf(t),y:160*i}};return{blocks:[...e.blocks,r]}})(t,e,eM));let n=Z.current.blocks.find(e=>!t.has(e.id));n&&(W(n.id),eI?O(n.id):P(n.id))},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{fontSize:18,lineHeight:1,flex:"none"},children:"+"}),b.B.editing.addKind(b.B.blocks[e])]},e))]}),(0,y.jsxs)("section",{id:sd,"data-testid":"block-settings",style:{position:"relative",flexShrink:0,background:eZ.panel,border:`1px solid ${eZ.line}`,borderRadius:10,overflow:"hidden"},children:[eS>0&&(0,y.jsx)("span",{"aria-hidden":"true","data-testid":"settings-flash",className:"factory-flash",style:{position:"absolute",inset:0,borderRadius:10,pointerEvents:"none"}},eS),(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 10px",background:eZ.head,borderBottom:`1px solid ${eZ.line}`},children:[(0,y.jsx)("h2",{style:{margin:0,fontSize:11,fontWeight:800,letterSpacing:"0.12em",textTransform:"uppercase",color:eU?B.f.ink:B.f.dim},children:b.B.editing.inspectorTitle}),eU&&!eq&&(0,y.jsx)("button",{type:"button","aria-label":b.B.editing.closeSettings,title:b.B.editing.closeSettings,onClick:eK,style:{background:"none",border:"none",color:B.f.skipped,cursor:"pointer",fontSize:16,lineHeight:1,padding:2},children:"✕"})]}),(0,y.jsx)("div",{style:{display:"grid",gap:10,padding:10},children:eU?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(lW,{block:eU,canDisable:!(eU.enabled&&lA(R,eU)),runOnScreen:eI,onChange:e=>er(t=>({blocks:t.blocks.map(t=>t.id===e.id?e:t)}))}),!lA(R,eU)&&(0,y.jsx)("button",{type:"button",style:{...sh,color:B.f.failed},onClick:()=>{er(e=>lH(e,eU.id)),W(null),P(null)},children:b.B.editing.remove})]}):(0,y.jsx)("p",{style:{margin:0,color:B.f.skipped},children:b.B.editing.inspectorEmpty})})]}),el.length>0&&(0,y.jsxs)("section",{style:{display:"grid",gap:6,color:B.f.failed},children:[(0,y.jsx)("h2",{style:{margin:0,fontSize:14},children:b.B.editing.unattributedIssues}),el.map(e=>(0,y.jsx)("p",{style:{margin:0},children:e.message},e.message))]}),X&&(0,y.jsx)("p",{role:"alert",style:{margin:0,color:B.f.failed},children:b.B.editing.saveFailed}),s&&(0,y.jsxs)("section",{id:su,"data-testid":"sidebar-log",style:{marginTop:eq?0:"auto",flexShrink:0,background:eZ.panel,border:`1px solid ${eZ.line}`,borderRadius:10,overflow:"hidden"},children:[(0,y.jsx)("h2",{style:{margin:0,padding:"8px 10px",fontSize:11,fontWeight:800,letterSpacing:"0.12em",textTransform:"uppercase",color:B.f.dim,background:eZ.head,borderBottom:`1px solid ${eZ.line}`},children:b.B.events.barTitle}),(0,y.jsx)("div",{style:{maxHeight:eq?"max(380px, calc(100vh - 560px))":380,overflowY:"auto",padding:6,scrollbarWidth:"thin",scrollbarColor:`${B.f.floorLine} transparent`},children:s})]})]})]}),(0,y.jsxs)("div",{ref:em,style:{flex:1,minWidth:0,position:"relative"},children:[eq&&(0,y.jsx)(l1,{blocks:eN.blocks,stateOf:eV,workOf:e=>eo.get(e)??null,hasRun:eI,pickedId:eX,onPick:e=>{W(e),eI&&O(e),void 0!==j&&null!==eV(e)&&g?.(e)},side:j,onSettings:e=>ej.current(e),title:p,detail:eX&&null!==eV(eX)?w?.(eX):void 0,blank:c,loading:d}),!eq&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(lO,{floorRef:eB}),p,d&&(0,y.jsx)(se,{count:r?.length??R.blocks.length}),(0,y.jsx)(la,{nodes:eJ,edges:e5,nodeTypes:sa,className:ep?void 0:eI?"factory-glide":"factory-glide-edit",style:{background:"transparent",zIndex:1,opacity:d||c?0:1,pointerEvents:c?"none":void 0,transition:ep?"none":"opacity 220ms ease-out"},onMove:(e,t)=>ez(t),onPaneClick:eK,onInit:e=>{ed.current=e,ev(0),ez(e.getViewport())},onNodeClick:(e,t)=>{W(t.id),eI?O(t.id):P(t.id)},onNodesChange:e=>{for(let t of e){if("dimensions"===t.type&&t.dimensions){let{width:e,height:n}=t.dimensions;eu(i=>i[t.id]?.width===e&&i[t.id]?.height===n?i:{...i,[t.id]:{width:e,height:n}})}if("position"===t.type&&t.position){let e=e1(t.id,t.position);er(n=>lP(n,t.id,e),!1)}}},onNodeDragStop:(e,t)=>{let n=e1(t.id,t.position);er(e=>lP(e,t.id,n))},nodesDraggable:!eI,nodesConnectable:!1,deleteKeyCode:null,colorMode:"dark",proOptions:{hideAttribution:!0},children:(0,y.jsx)(ls,{children:(0,y.jsx)(l4,{cables:e4})})})]})]})]})}let sy=new Set(["request","followUp","replan","changes","approvedNote","rejectedNote","answer"]);function sm(e,t,n,i,r){let o=[];e=[...e].sort((e,t)=>ek.indexOf(e.kind)-ek.indexOf(t.kind));let a={};for(let t of e)t.enabled&&("input"===t.kind||"plan"===t.kind||"build"===t.kind||"review"===t.kind||"human"===t.kind)&&!a[t.kind]&&(a[t.kind]=t.id);for(let l of e){if(!l.enabled)continue;n.forEach((e,t)=>{sy.has(e.kind)&&a[(0,W.B)(e)]===l.id&&o.push({who:"you",key:`${i}you-${t}`,kind:e.kind,text:e.text,earlier:!0===e.earlier})});let e=t[l.id];e&&"queued"!==e.state&&"input"!==l.kind&&o.push({who:"app",key:`${i}app-${l.id}`,blockId:l.id,label:l.label,view:e,block:l,...r?{past:!0}:null})}return o}function sb({by:e,children:t}){let n={width:34,height:34,flex:"none",borderRadius:"50%",display:"grid",placeItems:"center"};return(0,y.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"34px minmax(0, 1fr) 34px",columnGap:12,alignItems:"start"},children:["app"===e?(0,y.jsx)("span",{"data-testid":"face-app","aria-label":b.B.app.name,role:"img",style:{...n,background:B.f.card,border:`1px solid ${B.f.border}`},children:(0,y.jsx)(ez.f,{size:18})}):(0,y.jsx)("span",{}),(0,y.jsx)("div",{style:{minWidth:0,display:"grid"},children:t}),"you"===e&&(0,y.jsx)("span",{"data-testid":"face-you","aria-label":b.B.conversation.you,role:"img",style:{...n,background:C.f.green,color:C.f.onGreen},children:(0,y.jsx)(eB.f,{name:"person",size:19})})]})}let sv=new Set(["running","waiting_approval","failed"]),sw={running:B.f.running,passed:B.f.passed,failed:B.f.failed,waiting:B.f.waiting,skipped:B.f.skipped};function sj({turn:e,last:t,onDetails:n}){let{view:i}=e,r=(0,m.useContext)($.c)(e.block.config.ai,e.block.kind),o=(0,$.Y)(i.state),a="waiting_approval"===i.state&&!e.past,l="running"===i.state&&!e.past,s="skipped"===i.state||"cancelled"===i.state,d=l||a||"failed"===i.state&&!e.past,c=l?i.steps[i.steps.length-1]:void 0,u=i.asking?i.planMeasure?.question:void 0;return(0,y.jsxs)("div",{"data-testid":e.past?`turn-past-${e.blockId}`:`turn-${e.blockId}`,style:{display:"grid",gridTemplateColumns:"22px minmax(0, 1fr)",columnGap:12},children:[(0,y.jsxs)("div",{"aria-hidden":"true",style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,y.jsx)("span",{style:{width:22,height:22,flex:"none",display:"grid",placeItems:"center",borderRadius:"50%",background:B.f.tint(o,.16),marginTop:12*!!d},children:l?(0,y.jsx)($.m,{blockId:`turn-${e.blockId}`,size:14}):(0,y.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:sw[o]}})}),!t&&(0,y.jsx)("span",{style:{flex:1,width:2,marginTop:4,background:B.f.border}})]}),(0,y.jsxs)("div",{style:{display:"grid",gap:6,marginBottom:18,opacity:s?.6:1,...d?{padding:"12px 14px",borderRadius:12,background:B.f.card,border:`1px solid ${B.f.tint(o,.55)}`}:null},children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"baseline",flexWrap:"wrap",gap:8},children:[(0,y.jsx)("span",{style:{fontSize:15,fontWeight:700,color:B.f.ink},children:e.label}),r&&(0,y.jsx)($.J,{ai:r,testId:e.past?void 0:`turn-ai-${e.blockId}`}),(0,y.jsx)("span",{style:{fontSize:12.5,fontWeight:600,color:sw[o]},children:e.past&&"waiting_approval"===i.state?b.B.conversation.askedChanges:i.asking?b.B.conversation.question:b.B.canvas.stateLabel[i.state]}),n&&!e.past&&(0,y.jsx)("button",{type:"button",onClick:()=>n(e.blockId),style:{marginLeft:"auto",padding:0,background:"none",border:"none",color:"#93c5fd",fontSize:12.5,fontWeight:600,cursor:"pointer"},children:b.B.conversation.details})]}),u?(0,y.jsx)("div",{style:{fontSize:16,lineHeight:1.5,color:B.f.ink,overflowWrap:"anywhere"},children:u}):i.summary&&(0,y.jsx)("div",{style:{fontSize:14.5,lineHeight:1.55,color:"#c9d1dd",overflowWrap:"anywhere"},children:i.summary}),c&&(0,y.jsx)("div",{style:{fontSize:12.5,color:B.f.dim,overflowWrap:"anywhere"},children:c}),i.risk&&i.risk.reasons.length>0&&(0,y.jsx)("ul",{style:{margin:0,paddingLeft:18,display:"grid",gap:2,fontSize:13,lineHeight:1.45,color:B.f.dim},children:i.risk.reasons.map(e=>(0,y.jsx)("li",{children:e},e))}),a&&(0,y.jsxs)("div",{style:{fontSize:13,fontWeight:600,color:B.f.waiting},children:[i.asking?b.B.conversation.answerRight:b.B.conversation.decideRight," →"]})]})]})}function sk({chat:e,onChange:t}){let[n]=lX(lD,!1);return(0,y.jsxs)("button",{type:"button","data-testid":"view-switch",className:"factory-switch",title:e?void 0:b.B.conversation.hint,onClick:()=>t(!e),style:{position:"absolute",top:16,right:(n?56:497)+16,zIndex:4,display:"inline-flex",alignItems:"center",gap:8,padding:"8px 16px",borderRadius:999,border:`1px solid ${B.f.passed}`,background:B.f.tint("passed",.14),color:B.f.passed,fontFamily:"inherit",fontSize:13.5,fontWeight:700,cursor:"pointer",boxShadow:"0 6px 18px rgba(0,0,0,.35)"},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e?(0,y.jsx)("path",{d:"M19 12H5M11 6l-6 6 6 6"}):(0,y.jsx)("path",{d:"M21 12a8 8 0 0 1-11.8 7L4 20l1.1-4.6A8 8 0 1 1 21 12z"})}),e?b.B.conversation.back:b.B.conversation.tab]})}function sS({runId:e,blocks:t,views:n,rounds:i,prompts:r,onDetails:o}){let[a]=lX(sl,!0),[l]=lX(lD,!1),s=function(e,t,n,i){let r=n.flatMap((e,t)=>"changes"!==e.kind||e.earlier?[]:[t]);if(i&&i.earlier.length>0&&i.earlier.length===r.length){let o=[],a=0;i.earlier.forEach((t,i)=>{let l=r[i];o.push(...sm(e,t.views,n.slice(a,l),`r${i}-`,!0)),t.change&&o.push({who:"looked",key:`r${i}-looked`,change:t.change});let s=n[l];o.push({who:"you",key:`r${i}-asked`,kind:s.kind,text:s.text,earlier:!1}),a=l+1});let l=i.earlier[i.earlier.length-1].views;return[...o,...sm(e,Object.fromEntries(Object.entries(t).filter(([e])=>i.reopened.includes(e)||!l[e]||"queued"===l[e].state)),n.slice(a),"now-",!1)]}return sm(e,t,n,"",!1)}(t,n,r,i),d=[];for(let e of s)if("you"===e.who)d.push({you:e});else if("looked"===e.who)d.push({looked:e});else if(sv.has(e.view.state)&&!e.past)d.push({loud:e});else{let t=d[d.length-1];t&&"done"in t?t.done.push(e):d.push({done:[e]})}let c=t.map(e=>n[e.id]).find(e=>e?.results),u=(0,m.useRef)(null),p=s.map(e=>"app"===e.who?`${e.key}:${e.view.state}:${e.view.steps.length}`:e.key).join("|");return(0,m.useEffect)(()=>{u.current?.scrollIntoView?.({block:"end"})},[p]),(0,y.jsx)("section",{"data-testid":"conversation","aria-label":b.B.conversation.tab,style:{position:"absolute",top:0,left:a?300:56,bottom:0,right:l?56:497,zIndex:3,overflowY:"auto",background:B.f.bg},children:(0,y.jsx)("div",{children:(0,y.jsxs)("div",{style:{maxWidth:880,margin:"0 auto",padding:"84px 24px 24px",display:"grid"},children:[0===s.length&&(0,y.jsx)("p",{style:{margin:"0 0 16px",fontSize:14.5,color:B.f.dim},children:b.B.conversation.empty}),d.map((t,n)=>"you"in t?(0,y.jsx)(sb,{by:"you",children:(0,y.jsxs)("div",{"data-testid":"turn-you",style:{justifySelf:"end",maxWidth:"86%",display:"grid",gap:4,margin:"2px 0 20px",padding:"12px 16px",borderRadius:16,borderTopRightRadius:4,background:B.f.tint("running",t.you.earlier?.08:.18),border:`1px solid ${B.f.tint("running",.35)}`},children:[(0,y.jsxs)("span",{style:{fontSize:11.5,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"#93c5fd"},children:[b.B.prompts.kind[t.you.kind],t.you.earlier?` \xb7 ${b.B.prompts.earlier}`:""]}),(0,y.jsx)("span",{style:{fontSize:15,lineHeight:1.55,color:B.f.ink,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:t.you.text})]})},t.you.key):"looked"in t?e&&(0,y.jsx)(sb,{by:"app",children:(0,y.jsxs)("div",{"data-testid":"turn-looked",style:{display:"grid",gap:10,marginBottom:18,padding:"14px 16px",borderRadius:16,borderTopLeftRadius:4,background:B.f.card,border:`1px solid ${B.f.border}`},children:[(0,y.jsx)("span",{style:{fontSize:15.5,fontWeight:700,color:B.f.ink},children:b.B.conversation.howItLooked}),(0,y.jsx)(eI.v,{runId:e,change:t.looked.change,canTake:!1})]})},t.looked.key):"loud"in t?(0,y.jsx)(sb,{by:"app",children:(0,y.jsx)(sj,{turn:t.loud,last:!0,onDetails:o})},t.loud.key):(0,y.jsx)(sb,{by:"app",children:(0,y.jsxs)("details",{"data-testid":"done-steps",className:"factory-done-steps",style:{marginBottom:18},children:[(0,y.jsxs)("summary",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",borderRadius:10,border:`1px solid ${B.f.border}`,background:B.f.card,fontSize:14,fontWeight:600,color:B.f.ink,cursor:"pointer",listStyle:"none"},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{width:20,height:20,flex:"none",display:"grid",placeItems:"center",borderRadius:"50%",background:B.f.tint("passed",.18),color:B.f.passed,fontSize:12,fontWeight:900},children:"✓"}),b.B.conversation.doneSteps(t.done.length),(0,y.jsx)("span",{style:{fontSize:12.5,fontWeight:400,color:B.f.dim,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.done.map(e=>e.label).join(" · ")}),(0,y.jsxs)("span",{style:{marginLeft:"auto",flex:"none",fontSize:12.5,color:"#93c5fd"},children:[b.B.conversation.seeSteps," ▸"]})]}),(0,y.jsx)("div",{style:{paddingTop:16},children:t.done.map((e,n)=>(0,y.jsx)(sj,{turn:e,last:n===t.done.length-1,onDetails:o},e.key))})]})},`done-${n}`)),c?.results&&(0,y.jsx)(sb,{by:"app",children:(0,y.jsxs)("div",{"data-testid":"turn-result",style:{display:"grid",gap:10,padding:"14px 16px",borderRadius:16,borderTopLeftRadius:4,background:B.f.card,border:`1px solid ${B.f.border}`},children:[(0,y.jsx)("span",{style:{fontSize:15.5,fontWeight:700,color:B.f.ink},children:"passed"===c.state&&c.summary?c.summary:b.B.conversation.howItLooks}),(0,y.jsx)(eI.v,{runId:c.results})]})}),(0,y.jsx)("div",{ref:u})]})})})}let sC=b.B.failure,sB="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace";function sz({runId:e,note:t,imageIds:n,imagesBusy:i,composer:r,onFollowUp:o,actionsRef:a,onCanContinue:l}){let[s,d]=(0,m.useState)(null),[c,u]=(0,m.useState)(!1),[p,f]=(0,m.useState)(!1),[h,g]=(0,m.useState)(null),[x,v]=(0,m.useState)(null),[w,j]=(0,m.useState)(void 0);async function k(t,i){g(i),v(null);try{let r=await fetch(`/api/runs/${e}/follow-up`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({note:t,attachments:"send"===i?n:[]})}),a=await r.json().catch(()=>null);if(!r.ok||!a?.runId)return v(a?.error??b.B.run.startFailed);o(a.runId)}catch{v(b.B.run.startFailed)}finally{g(null)}}if((0,m.useEffect)(()=>{let t=!0;return fetch(`/api/runs/${e}/failure`).then(e=>e.ok?e.json():null).then(e=>{t&&e&&(d(e),l?.(e.canContinue))}).catch(()=>void 0).finally(()=>t&&u(!0)),()=>{t=!1}},[e]),(0,m.useEffect)(()=>{if(!p||void 0!==w)return;let t=!0;return fetch(`/api/runs/${e}/failure/explain`,{method:"POST"}).then(e=>e.ok?e.json():null).then(e=>t&&j(e?.explanation??null)).catch(()=>t&&j(null)),()=>{t=!1}},[p,e]),(0,m.useEffect)(()=>{if(a)return a.current={see:()=>f(!0),again:()=>void k(sC.againText,"again")},()=>{a.current=null}}),!c)return(0,y.jsx)(st,{});let S=s?.failed[0],C=s?.canContinue===!0;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{flex:"none",width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:B.f.tint("failed",.18),color:B.f.failed},children:(0,y.jsxs)("svg",{viewBox:"0 0 24 24",width:17,height:17,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,y.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,y.jsx)("path",{d:"M12 7.5v5.5M12 16.4v.1"})]})}),(0,y.jsx)("div",{className:"factory-display",style:{fontSize:17},children:sC.cardTitle})]}),(0,y.jsx)("div",{"data-testid":"failure-summary",style:{fontSize:13.5,color:"#d6dce6",lineHeight:1.45},children:S?sC.cardText(S.label):sC.cardTextUnknown}),"again"===h||"fix"===h?(0,y.jsxs)("div",{role:"status",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"#cfe0ff"},children:[(0,y.jsx)($.m,{blockId:"again",size:15})," ","fix"===h?sC.fixing:sC.retrying]}):(0,y.jsx)("div",{style:{fontSize:12.5,color:B.f.dim,lineHeight:1.45},children:sC.cardHint}),C?(0,y.jsx)("div",{style:{display:"grid",gap:6,gridTemplateColumns:"minmax(0, 1fr)",paddingTop:10,borderTop:`1px solid ${B.f.lineSoft}`},children:r({label:sC.send,onSend:()=>void k(t,"send"),enabled:null===h&&!i&&""!==t.trim(),busy:"send"===h})}):(0,y.jsx)("div",{style:{fontSize:12.5,color:B.f.waiting,lineHeight:1.45},children:sC.cannotContinue}),x&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12.5,color:B.f.failed,lineHeight:1.4},children:x}),p&&(0,y.jsx)(s_,{failure:s,canContinue:C,explanation:w??null,explaining:void 0===w,onClose:()=>f(!1),onFix:()=>{let e,t;return f(!1),void k((e=sC.fixText(S?.label??"",S?.command??null),(t=function(e,t=25,n=1500){return e?e.trim().split("\n").slice(-t).join("\n").slice(-n):""}(S?.output??null))?`${e}
|
|
3
3
|
|
|
4
4
|
${sC.errorIntro}
|
|
5
|
-
${t}`:e),"fix")},onAgain:()=>(f(!1),void k(sC.againText,"again")),onOwn:()=>{f(!1),requestAnimationFrame(()=>document.querySelector('[data-testid="command-card"] textarea')?.focus())}})]})}function sI(){return(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:17,height:17,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M14.7 6.3a4 4 0 0 0-5.2 5.2L3.6 17.4a1.5 1.5 0 0 0 0 2.1l.9.9a1.5 1.5 0 0 0 2.1 0l5.9-5.9a4 4 0 0 0 5.2-5.2l-2.6 2.6-2.4-.6-.6-2.4z"})})}function sM(){return(0,y.jsxs)("svg",{viewBox:"0 0 24 24",width:15,height:15,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,y.jsx)("path",{d:"M4 20h4L19 9l-4-4L4 16v4z"}),(0,y.jsx)("path",{d:"M13.5 6.5l4 4"})]})}function s$(){return(0,y.jsxs)("svg",{viewBox:"0 0 24 24",width:15,height:15,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,y.jsx)("path",{d:"M20 11a8 8 0 1 0-2.3 5.7"}),(0,y.jsx)("path",{d:"M20 4v7h-7"})]})}function sE({icon:e,label:t,help:n,badge:i,primary:r,onClick:o}){return(0,y.jsxs)("button",{type:"button","aria-label":t,onClick:o,style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",columnGap:12,rowGap:3,alignItems:"center",padding:r?"16px 18px":"13px 18px",borderRadius:10,border:`1px solid ${r?B.f.running:B.f.border}`,background:r?B.f.running:"#0f141c",color:r?"#fff":"#e6e9ef",cursor:"pointer",textAlign:"left"},children:[(0,y.jsx)("span",{style:{gridRow:"1 / span 2",display:"grid",placeItems:"center"},children:e}),(0,y.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:8,fontSize:r?17.5:15.5,fontWeight:700},children:[t,i&&(0,y.jsx)("span",{style:{padding:"1px 8px",borderRadius:999,background:"rgba(255,255,255,0.22)",fontSize:11.5,fontWeight:700},children:i})]}),(0,y.jsx)("span",{style:{fontSize:14,lineHeight:1.4,color:r?"rgba(255,255,255,0.88)":B.f.dim},children:n})]})}function s_({failure:e,canContinue:t,explanation:n,explaining:i,onClose:r,onFix:o,onAgain:a,onOwn:l}){(0,m.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r]);let s=e?.failed[0],d=e?.failed.filter(e=>e.command||e.message)??[];return(0,y.jsx)("div",{onClick:r,style:{position:"fixed",inset:0,zIndex:60,display:"grid",gridTemplateRows:"minmax(0, 1fr)",placeItems:"center",background:"rgba(5, 7, 11, 0.65)"},children:(0,y.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":sC.title,"data-testid":"failure-dialog",onClick:e=>e.stopPropagation(),style:{width:`min(${d.length>0?1240:720}px, calc(100% - 32px))`,maxHeight:"calc(100% - 48px)",display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",background:B.f.card,border:`1px solid ${B.f.tint("failed",.5)}`,borderRadius:14,boxShadow:"0 24px 60px rgba(0,0,0,0.6)",fontSize:14},children:[(0,y.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"18px 26px",borderBottom:`1px solid ${B.f.border}`},children:[(0,y.jsx)("h2",{className:"factory-display",style:{margin:0,fontSize:25},children:sC.title}),(0,y.jsx)("button",{type:"button","aria-label":sC.close,onClick:r,style:{background:"none",border:"none",color:B.f.skipped,cursor:"pointer",fontSize:18},children:"✕"})]}),(0,y.jsx)("div",{style:{overflowY:"auto",padding:"22px 26px 26px",display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 420px), 1fr))",alignItems:"start",gap:28,scrollbarWidth:"thin",scrollbarColor:`${B.f.skipped} transparent`},children:e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"grid",gap:22,minWidth:0},children:[(0,y.jsxs)("section",{style:{display:"grid",gap:10},children:[(0,y.jsx)("strong",{style:{fontSize:17},children:sC.happened}),(0,y.jsx)("p",{"data-testid":"failure-plain",style:{margin:0,fontSize:16.5,lineHeight:1.55,color:"#e6e9ef"},children:n??(s?sC.plain(s.label):sC.plainUnknown)}),i&&(0,y.jsxs)("div",{role:"status",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:B.f.dim},children:[(0,y.jsx)($.m,{blockId:"explain",size:14})," ",sC.explaining]}),(0,y.jsx)("p",{style:{margin:0,fontSize:14.5,lineHeight:1.5,color:B.f.passed},children:sC.safe})]}),(0,y.jsxs)("section",{style:{display:"grid",gap:10},children:[(0,y.jsx)("strong",{style:{fontSize:17},children:sC.whatNow}),t?(0,y.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,y.jsx)(sE,{primary:!0,icon:(0,y.jsx)(sI,{}),label:sC.actions.fix.label,help:sC.actions.fix.help,badge:sC.actions.fix.badge,onClick:o}),(0,y.jsx)(sE,{icon:(0,y.jsx)(s$,{}),label:sC.actions.again.label,help:sC.actions.again.help,onClick:a}),(0,y.jsx)(sE,{icon:(0,y.jsx)(sM,{}),label:sC.actions.own.label,help:sC.actions.own.help,onClick:l})]}):(0,y.jsx)("span",{style:{fontSize:13.5,color:B.f.waiting,lineHeight:1.5},children:sC.cannotContinue})]})]}),d.length>0&&(0,y.jsxs)("section",{style:{display:"grid",gap:12,minWidth:0},children:[(0,y.jsx)("strong",{style:{fontSize:17},children:sC.details}),d.map(e=>(0,y.jsxs)("div",{"data-testid":"failed-block",style:{display:"grid",gap:8},children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap",fontSize:13},children:[(0,y.jsx)("strong",{style:{color:B.f.failed},children:e.label}),e.message&&(0,y.jsx)("span",{style:{color:B.f.dim},children:e.message})]}),e.command&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap",fontSize:13,color:B.f.dim},children:[sC.command,(0,y.jsx)("code",{style:{padding:"3px 8px",borderRadius:6,background:"#0b0e14",border:`1px solid ${B.f.border}`,fontFamily:sB,fontSize:12.5,color:"#d6dce6"},children:e.command}),(0,y.jsx)("span",{style:{color:B.f.failed},children:sC.ended(e.exitCode,e.signal)})]}),(0,y.jsx)("span",{style:{fontSize:13,color:B.f.dim},children:sC.output}),(0,y.jsx)("pre",{"data-testid":"failure-output",style:{margin:0,maxHeight:"min(50vh, 460px)",overflow:"auto",padding:12,borderRadius:8,background:"#0b0e14",border:`1px solid ${B.f.border}`,fontFamily:sB,fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",scrollbarWidth:"thin",scrollbarColor:`${B.f.skipped} transparent`},children:e.output??sC.noOutput})]})]},e.blockId))]})]}):(0,y.jsx)("div",{style:{color:B.f.dim},children:sC.unreadable})})]})})}let sR=(0,m.createContext)(!1);function sN(e){return e.filter(e=>"ready"===e.status&&e.id).map(e=>e.id)}function sT(e){return e.some(e=>"uploading"===e.status)}function sW({inputId:e,label:t,placeholder:n,text:i,onText:r,images:o,onImages:a,onSubmit:l,send:s,minHeight:d=170,disabled:c=!1}){let[u,p]=(0,m.useState)(!1),[f,h]=(0,m.useState)(null),g=(0,m.useRef)(null),x=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{let e=x.current;e&&(e.style.height="auto",e.style.height=`${Math.min(Math.max(e.scrollHeight,d),380)}px`)},[i,d]);let v=(0,m.useRef)(()=>void 0);function w(e){h(null);let t=e.filter(e=>e.type.startsWith("image/"));t.length<e.length&&h(b.B.attachments.notImage);let n=6-o.length;for(let e of(t.length>n&&h(b.B.attachments.tooMany(6)),t.slice(0,Math.max(0,n)))){let t=`${Date.now()}-${Math.random().toString(36).slice(2)}`;a(n=>[...n,{key:t,name:e.name||"image",previewUrl:URL.createObjectURL(e),status:"uploading"}]);let n=new FormData;n.append("file",e),fetch("/api/attachments",{method:"POST",body:n}).then(async e=>{let n=await e.json().catch(()=>null);a(i=>i.map(i=>i.key!==t?i:e.ok&&n?.id?{...i,status:"ready",id:n.id}:{...i,status:"failed",error:n?.error??b.B.attachments.failed}))}).catch(()=>a(e=>e.map(e=>e.key===t?{...e,status:"failed",error:b.B.attachments.failed}:e)))}}return(0,m.useEffect)(()=>{if(c)return;let e=e=>{var t;let n,i=e.target;if(i&&i!==x.current&&("INPUT"===i.tagName||"TEXTAREA"===i.tagName||i.isContentEditable)||!e.clipboardData)return;let r=(n=[...(t=e.clipboardData).files].filter(e=>e.type.startsWith("image/"))).length>0?n:[...t.items].filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>null!==e);0!==r.length&&(e.preventDefault(),v.current(r),i!==x.current&&x.current?.focus({preventScroll:!0}))},t=e=>e.dataTransfer?.types.includes("Files")===!0,n=e=>{t(e)&&(e.preventDefault(),p(!0))},i=e=>{null===e.relatedTarget&&p(!1)},r=e=>{t(e)&&(e.preventDefault(),p(!1),v.current([...e.dataTransfer?.files??[]]),x.current?.focus({preventScroll:!0}))};return window.addEventListener("paste",e),window.addEventListener("dragover",n),window.addEventListener("dragleave",i),window.addEventListener("drop",r),()=>{window.removeEventListener("paste",e),window.removeEventListener("dragover",n),window.removeEventListener("dragleave",i),window.removeEventListener("drop",r)}},[c]),(0,m.useEffect)(()=>{v.current=w}),(0,y.jsxs)("div",{"data-testid":"composer",style:{display:"grid",gap:6},children:[(0,y.jsx)("label",{htmlFor:e,style:{fontSize:12.5,fontWeight:600,color:B.f.dim},children:t}),(0,y.jsxs)("div",{style:{position:"relative",background:C.f.card,border:`1px ${u?"dashed":"solid"} ${u?B.f.running:C.f.line}`,borderRadius:10,padding:8,display:"grid",gap:8},children:[o.length>0&&(0,y.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:o.map(e=>(0,y.jsxs)("div",{"data-testid":"composer-thumb","data-status":e.status,title:e.error??e.name,style:{position:"relative",width:56,height:56,borderRadius:8,overflow:"hidden",border:`1px solid ${"failed"===e.status?B.f.failed:C.f.line}`,background:C.f.bg},children:[(0,y.jsx)("img",{src:e.previewUrl,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",opacity:"ready"===e.status?1:.45}}),"uploading"===e.status&&(0,y.jsx)("span",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center"},children:(0,y.jsx)($.m,{blockId:`thumb-${e.key}`,size:18})}),"failed"===e.status&&(0,y.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",color:B.f.failed,fontWeight:900},children:"!"}),(0,y.jsx)("button",{type:"button","aria-label":b.B.attachments.remove(e.name),onClick:()=>{var t;return t=e.key,void a(e=>{let n=e.find(e=>e.key===t);return n&&URL.revokeObjectURL(n.previewUrl),e.filter(e=>e.key!==t)})},style:{position:"absolute",top:2,right:2,width:18,height:18,borderRadius:"50%",border:"none",background:"rgba(0,0,0,0.7)",color:"#fff",fontSize:11,lineHeight:1,cursor:"pointer",display:"grid",placeItems:"center"},children:"✕"})]},e.key))}),(0,y.jsx)("textarea",{ref:x,id:e,"aria-label":t,placeholder:u?b.B.attachments.dropHere:n,value:i,disabled:c,rows:8,onChange:e=>r(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.altKey||e.nativeEvent.isComposing||(s?.enabled?(e.preventDefault(),s.onSend()):l?(e.preventDefault(),l()):s&&""===i.trim()&&e.preventDefault())},style:{width:"100%",boxSizing:"border-box",resize:"vertical",minHeight:d,maxHeight:380,padding:4,background:"transparent",color:"inherit",border:"none",outline:"none",font:"inherit",fontSize:14,lineHeight:1.45,scrollbarWidth:"thin",scrollbarColor:`${B.f.floorLine} transparent`}}),(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,borderTop:`1px solid ${B.f.lineSoft}`,paddingTop:8},children:[(0,y.jsxs)("button",{type:"button",disabled:c||o.length>=6,onClick:()=>g.current?.click(),title:b.B.attachments.add,"aria-label":b.B.attachments.add,style:{display:"inline-flex",alignItems:"center",gap:6,background:"none",border:`1px solid ${C.f.line}`,borderRadius:6,color:"#d6dce6",cursor:"pointer",padding:"4px 10px",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,y.jsx)(sP,{})," ",b.B.attachments.browse]}),(0,y.jsx)("span",{style:{flex:1,fontSize:11.5,color:B.f.dim},children:sT(o)?b.B.attachments.uploading:b.B.attachments.pasteHint}),s&&(0,y.jsx)("button",{type:"button","aria-label":s.label,title:s.label,disabled:!s.enabled,onClick:s.onSend,style:{flex:"none",width:32,height:32,borderRadius:"50%",display:"grid",placeItems:"center",padding:0,border:"none",background:s.enabled?B.f.passed:C.f.line,color:s.enabled?"#07110a":B.f.skipped,cursor:s.enabled?"pointer":"not-allowed"},children:s.busy?(0,y.jsx)($.m,{blockId:"composer-send",size:14}):(0,y.jsx)(sL,{})})]}),(0,y.jsx)("input",{ref:g,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,onChange:e=>{w([...e.target.files??[]]),e.target.value=""}})]}),f&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12,color:B.f.waiting},children:f})]})}function sL(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M14.5 1.5 7 9M14.5 1.5 10 14.5 7 9 1.5 6l13-4.5Z"})})}function sP(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M13 7.5 8 12.5a3.2 3.2 0 0 1-4.5-4.5l5.3-5.3a2.1 2.1 0 0 1 3 3L6.5 11a1.1 1.1 0 0 1-1.5-1.5L10 4.5"})})}var sA=e.i(44094);function sH({runId:e}){let[t,n]=(0,m.useState)(null),[i,r]=(0,m.useState)(null),[o,a]=(0,m.useState)(!1),l=t?.status==="installing"||t?.status==="starting";async function s(t){r(null);try{let i=await fetch(`/api/runs/${e}/preview`,{method:t}),o=await i.json().catch(()=>null);if(!i.ok||!o)return r(o?.error??b.B.preview.failed);n(o)}catch{r(b.B.preview.failed)}}(0,m.useEffect)(()=>{let t=!0,i=()=>fetch(`/api/runs/${e}/preview`).then(e=>e.json()).then(e=>t&&n(e)).catch(()=>void 0);if(i(),!l)return()=>void(t=!1);let r=setInterval(i,1e3);return()=>{t=!1,clearInterval(r)}},[e,l]);let d=t?.status??"stopped",c="installing"===d?b.B.preview.installing:"starting"===d?b.B.preview.starting:"ready"===d?b.B.preview.ready:null;return(0,y.jsxs)("div",{"data-testid":"preview","data-status":d,style:{display:"grid",gap:6},children:[(0,y.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:["ready"===d&&t?.url?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("a",{href:t.url,target:"_blank",rel:"noreferrer",style:{padding:"7px 14px",borderRadius:8,background:B.f.running,color:"#fff",fontWeight:700,textDecoration:"none",fontSize:13},children:["↗ ",b.B.preview.open]}),(0,y.jsx)("button",{type:"button",onClick:()=>void s("DELETE"),style:{background:"none",border:"none",color:B.f.dim,cursor:"pointer",fontSize:12.5},children:b.B.preview.stop})]}):(0,y.jsxs)("button",{type:"button",disabled:l,onClick:()=>void s("POST"),style:{padding:"7px 14px",borderRadius:8,border:`1px solid ${B.f.running}`,background:B.f.tint("running",.12),color:"#cfe0ff",fontWeight:700,fontSize:13,cursor:l?"wait":"pointer"},children:["▶ ",b.B.preview.start]}),c&&(0,y.jsx)("span",{style:{fontSize:12,color:"ready"===d?B.f.dim:"#cfe0ff"},children:c})]}),("failed"===d||i)&&(0,y.jsxs)("div",{role:"alert",style:{fontSize:12.5,color:B.f.failed},children:[i??t?.message??b.B.preview.failed," ",t?.log&&(0,y.jsx)("button",{type:"button",onClick:()=>a(e=>!e),style:{background:"none",border:"none",color:B.f.running,cursor:"pointer",padding:0,fontSize:12.5},children:b.B.preview.showLog})]}),o&&t?.log&&(0,y.jsx)("pre",{style:{margin:0,maxHeight:180,overflow:"auto",background:"#0b0e14",border:`1px solid ${B.f.border}`,borderRadius:8,padding:10,fontSize:11.5,color:"#9aa5b6",whiteSpace:"pre-wrap"},children:t.log})]})}let sF=["needs_you","in_progress","fixed","set_aside"],sO={needs_you:B.f.waiting,in_progress:B.f.running,fixed:B.f.passed,set_aside:B.f.skipped};function sD(e){return sF.flatMap(t=>e.filter(e=>e.ending===t))}let sq={checked:{colour:B.f.passed,icon:(0,y.jsx)("path",{d:"M3 8.5 6.5 12 13 4.5"})},ai:{colour:B.f.waiting,icon:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("path",{d:"M2.5 3.5h11v7h-6l-3 2.5v-2.5h-2z"}),(0,y.jsx)("path",{d:"M5.5 7h.01M8 7h.01M10.5 7h.01"})]})},not_checked:{colour:B.f.dim,icon:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("circle",{cx:"8",cy:"8",r:"5.5",strokeDasharray:"2.4 2.2"}),(0,y.jsx)("path",{d:"M5.5 8h5"})]})}};function sV({how:e,inLegend:t=!1}){let n=sq[e];return(0,y.jsxs)("span",{"data-testid":t?"how-key":"how-mark","data-state":e,title:b.B.findings.howMeans[e],style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:999,border:`1px ${"not_checked"===e?"dashed":"solid"} ${n.colour}`,color:n.colour,fontSize:11.5,fontWeight:700,whiteSpace:"nowrap"},children:[(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:n.icon}),b.B.findings.how[e]]})}function sY({f:e,n:t,touched:n}){let[i,r]=(0,m.useState)(!1),o=(0,m.useId)(),a=e.detail,l=(e,t,n=!1)=>""===t?null:(0,y.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:B.f.dim},children:e}),(0,y.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",fontFamily:n?"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace":void 0,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:t})]});return(0,y.jsxs)("li",{"data-testid":"finding",style:{display:"grid",gap:6,padding:"10px 12px",borderRadius:10,border:`1px solid ${B.f.border}`,borderLeft:`3px solid ${sO[e.ending]}`,background:"#0d1118"},children:[(0,y.jsx)("span",{"data-testid":"finding-number",style:{fontSize:11.5,fontWeight:700,color:B.f.dim},children:b.B.findings.number(t)}),(0,y.jsx)("span",{style:{fontSize:13.5,fontWeight:600,color:B.f.ink,lineHeight:1.4,overflowWrap:"anywhere"},children:e.title}),(0,y.jsx)("span",{style:{fontSize:12.5,color:B.f.dim,lineHeight:1.45,overflowWrap:"anywhere"},children:(0,sA.f)(e.outcome,n)}),(0,y.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,y.jsx)(sV,{how:e.how}),(0,y.jsx)("button",{type:"button",className:"factory-action","aria-expanded":i,"aria-controls":o,onClick:()=>r(e=>!e),style:{background:"none",border:"none",padding:"6px 0 6px 8px",minHeight:32,color:B.f.running,cursor:"pointer",fontSize:12.5},children:b.B.question.seeDetails})]}),i&&(0,y.jsxs)("div",{id:o,style:{display:"grid",gap:8,paddingTop:8,borderTop:`1px solid ${B.f.lineSoft}`},children:[l(b.B.findings.detail.where,a.where,!0),""!==a.problem&&(0,y.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:B.f.waiting},children:b.B.findings.detail.aiSaid}),(0,y.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:(0,sA.f)(a.problem,n)})]}),l(b.B.findings.detail.command,a.command,!0),l(b.B.findings.detail.output,a.outputTail,!0),l(b.B.findings.detail.why,(0,sA.f)(a.reason,n)),""===a.where&&""===a.problem&&""===a.command&&""===a.outputTail&&""===a.reason&&(0,y.jsx)("span",{style:{fontSize:12.5,color:B.f.dim},children:b.B.findings.detail.none})]})]})}function sX({findings:e,touched:t=[]}){let n=new Map(sD(e).map((e,t)=>[e.id,t+1]));return(0,y.jsxs)("section",{"data-testid":"findings-list","aria-label":b.B.findings.heading,style:{display:"grid",gap:10},children:[(0,y.jsx)("h3",{className:"factory-display",style:{margin:0,fontSize:15},children:b.B.findings.heading}),0===e.length&&(0,y.jsx)("p",{style:{margin:0,fontSize:13,color:B.f.dim},children:b.B.findings.none}),e.length>0&&(0,y.jsx)("dl",{"data-testid":"legend","aria-label":b.B.findings.legendTitle,style:{margin:0,display:"grid",gap:6},children:["checked","ai","not_checked"].filter(t=>e.some(e=>e.how===t)).map(e=>(0,y.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 8px"},children:[(0,y.jsx)("dt",{style:{margin:0},children:(0,y.jsx)(sV,{how:e,inLegend:!0})}),(0,y.jsx)("dd",{style:{margin:0,fontSize:12,color:B.f.dim,lineHeight:1.4,flex:"1 1 180px"},children:b.B.findings.howMeans[e]})]},e))}),sF.map(i=>{let r=e.filter(e=>e.ending===i);return 0===r.length?null:(0,y.jsxs)("div",{style:{display:"grid",gap:6},children:[(0,y.jsxs)("h4",{style:{margin:0,display:"flex",alignItems:"center",gap:8,fontSize:12,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:sO[i]},children:[b.B.findings.group[i],(0,y.jsx)("span",{style:{fontSize:11,padding:"0 7px",borderRadius:999,border:`1px solid ${sO[i]}`},children:r.length})]}),(0,y.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:6},children:r.map(e=>(0,y.jsx)(sY,{f:e,n:n.get(e.id)??0,touched:t},e.id))})]},i)})]})}let sU="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace";function sZ({findings:e,touched:t=[],away:n=null,runId:i,risk:r,note:o,imageIds:a,imagesBusy:l,composer:s,onSent:d,onSeeChanges:c}){let[u,p]=(0,m.useState)(null),[f,h]=(0,m.useState)(!1),[g,x]=(0,m.useState)(!1),[v,w]=(0,m.useState)(null),[j,k]=(0,m.useState)(0);async function S(e){if(u){x(!0),w(null);try{let t=await fetch(`/api/runs/${i}/decision`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({decision:e,reason:o.trim()||null,diffHash:u.hash,..."changes"===e?{attachments:a}:{}})}),r=await t.json().catch(()=>null);if(!t.ok){w({text:r?.error??b.B.gate.notDelivered,ok:!1}),409===t.status&&k(e=>e+1);return}w({text:n?b.B.machine.sentElsewhere(n.machine):"approved"===e?b.B.gate.approved:"rejected"===e?b.B.gate.rejected:b.B.gate.changesSent,ok:!0}),d()}catch{w({text:b.B.gate.notDelivered,ok:!1})}finally{x(!1)}}}(0,m.useEffect)(()=>{let e=!0;return fetch(`/api/runs/${i}/review`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(t=>e&&(p(t),h(!1))).catch(()=>e&&h(!0)),()=>{e=!1}},[i,j]);let C=v?.ok===!0,[z,I]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(!C)return;let e=setTimeout(()=>I(!0),2e4);return()=>clearTimeout(e)},[C]);let M=!C&&(""!==o.trim()||a.length>0),E=e=>({flex:1,padding:"9px 12px",borderRadius:8,border:`1px solid ${M?"#2a3140":B.f[e]}`,...M?{background:"#2a3140",color:"#8b95a7"}:{background:"passed"===e?B.f.passed:"transparent",color:"passed"===e?"#07090d":B.f.failed},fontWeight:700,cursor:g||!u||C||M?"not-allowed":"pointer",opacity:g||!u||C?.6:1});return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:B.f.waiting,color:"#1a1206",fontWeight:900,fontSize:17},children:"!"}),(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:b.B.gate.title}),(0,y.jsx)("div",{style:{fontSize:12.5,color:"#d9c9a3"},children:b.B.gate.waiting})]})]}),r&&!c&&(0,y.jsxs)("div",{style:{fontSize:12.5,color:"low"===r.level?B.f.passed:B.f.waiting,lineHeight:1.4},children:[(0,y.jsxs)("strong",{children:[b.B.risk.label[r.level],":"]}),(0,y.jsx)(sK,{reasons:r.reasons,touched:t}),"low"===r.level&&r.stopForMe&&(0,y.jsx)("div",{"data-testid":"stop-for-me-why",style:{color:B.f.waiting},children:b.B.gate.stopForMe})]}),f&&(0,y.jsx)("div",{style:{fontSize:12.5,color:B.f.failed},children:b.B.gate.loadFailed}),!u&&!f&&(0,y.jsxs)("div",{"aria-busy":"true","aria-label":b.B.gate.loading,style:{display:"grid",gap:8,padding:10,borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0d1118"},children:[(0,y.jsx)(l7,{width:"35%",height:10}),(0,y.jsx)(l7,{height:12}),(0,y.jsx)(l7,{width:"80%",height:12})]}),u&&!c&&(0,y.jsx)(sJ,{review:u}),u&&c&&(0,y.jsxs)("button",{type:"button","data-testid":"see-changes",onClick:c,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,padding:"10px 12px",borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0d1118",color:"#e6e9ef",fontSize:13.5,fontWeight:700,cursor:"pointer",textAlign:"left"},children:[(0,y.jsxs)("span",{style:{display:"grid",gap:2},children:[b.B.gate.seeChanges,(0,y.jsx)("span",{style:{fontSize:12,fontWeight:400,color:B.f.dim},children:0===u.files.length?b.B.gate.noFiles:b.B.gate.filesChanged(u.files.length)})]}),(0,y.jsx)("span",{"aria-hidden":"true",style:{flex:"none",display:"grid",placeItems:"center",width:28,height:28,borderRadius:8,background:B.f.tint("running",.16),color:B.f.running},children:(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,y.jsx)("path",{d:"M6 3.5 10.5 8 6 12.5"})})})]}),e&&(0,y.jsx)(sX,{findings:e,touched:t}),u&&u.files.length>0&&!C&&(c?(0,y.jsx)(eI.$,{runId:i,autoStart:!n}):(0,y.jsx)(eI.v,{runId:i,autoStart:!n,canTake:!n})),u&&u.files.length>0&&!C&&!n&&!c&&(0,y.jsx)(sH,{runId:i}),n&&!C&&(0,y.jsx)("div",{style:{fontSize:12,color:B.f.dim,lineHeight:1.4},children:b.B.machine.elsewhere(n.machine)}),!C&&s({label:b.B.gate.askChanges,onSend:()=>void S("changes"),enabled:!g&&null!==u&&!l&&""!==o.trim()}),!C&&(0,y.jsxs)("div",{style:{display:"flex",gap:8,paddingTop:10,borderTop:`1px solid ${B.f.lineSoft}`},children:[(0,y.jsx)("button",{type:"button",disabled:g||!u||l||M,onClick:()=>void S("approved"),style:E("passed"),children:g?b.B.gate.deciding:`✓ ${b.B.gate.approve}`}),(0,y.jsxs)("button",{type:"button",disabled:g||!u||l||M,onClick:()=>void S("rejected"),style:E("failed"),children:["✕ ",b.B.gate.reject]})]}),M&&(0,y.jsx)("span",{role:"note","data-testid":"gate-unsent",style:{fontSize:12.5,color:"#f3d9a4",textAlign:"center",lineHeight:1.45},children:b.B.gate.unsent}),v&&(0,y.jsxs)("div",{role:v.ok?"status":"alert",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:v.ok?B.f.passed:B.f.failed},children:[v.ok&&!z&&(0,y.jsx)($.m,{blockId:"gate",size:16}),v.text]}),C&&z&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12.5,color:B.f.waiting,lineHeight:1.4},children:b.B.gate.notPickedUp})]})}function sK({reasons:e,touched:t=[]}){return(0,y.jsx)("ul",{style:{margin:"2px 0 0",padding:0,listStyle:"none",display:"grid",gap:2},children:e.map((e,n)=>(0,y.jsx)("li",{"data-testid":"risk-reason",style:{overflowWrap:"anywhere"},children:(0,sA.f)((0,b.g)(e),t)},n))})}function sG({diff:e,truncated:t}){return(0,y.jsxs)(y.Fragment,{children:[e.split("\n").map((e,t)=>(0,y.jsx)("div",{style:{color:e.startsWith("+")?"#86efac":e.startsWith("-")?"#fca5a5":e.startsWith("@@")?"#93c5fd":"#9aa5b6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",paddingLeft:"1.2em",textIndent:"-1.2em"},children:e||" "},t)),t&&(0,y.jsx)("div",{style:{color:B.f.waiting},children:b.B.gate.truncated})]})}function sJ({review:e,roomy:t=!1}){let[n,i]=(0,m.useState)(!1),[r,o]=(0,m.useState)(!1),a=t||n;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{"data-testid":"gate-changes",style:{display:"grid",gap:6,maxHeight:t?"min(56vh, 600px)":a?260:180,overflowY:"auto",padding:10,borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0d1118",scrollbarWidth:"thin",scrollbarColor:`${B.f.floorLine} transparent`},children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,y.jsx)("div",{style:{fontSize:12.5,color:B.f.dim},children:0===e.files.length?b.B.gate.noFiles:b.B.gate.filesChanged(e.files.length)}),e.diff&&!t&&(0,y.jsx)("button",{type:"button","aria-label":b.B.gate.expandChanges,title:b.B.gate.expandChanges,onClick:()=>o(!0),style:{display:"grid",placeItems:"center",width:26,height:26,padding:0,borderRadius:6,border:`1px solid ${B.f.border}`,background:B.f.card,color:"#d6dce6",cursor:"pointer"},children:(0,y.jsx)(s1,{})})]}),e.files.slice(0,8).map(e=>(0,y.jsxs)("div",{style:{display:"flex",gap:8,fontFamily:sU,fontSize:12,color:"#d6dce6"},children:[(0,y.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.path,children:e.path}),(0,y.jsxs)("span",{style:{color:B.f.passed},children:["+",e.added]}),(0,y.jsxs)("span",{style:{color:B.f.failed},children:["−",e.removed]})]},e.path)),e.files.length>8&&(0,y.jsx)("div",{style:{fontSize:12,color:B.f.dim},children:b.B.canvas.andMore(e.files.length-8)}),e.diff&&!t&&(0,y.jsx)("button",{type:"button",onClick:()=>i(e=>!e),style:{justifySelf:"start",background:"none",border:"none",color:B.f.running,cursor:"pointer",padding:0,fontSize:12.5},children:a?b.B.gate.hideChanges:b.B.gate.showChanges}),a&&(0,y.jsx)("pre",{"data-testid":"gate-diff",style:{margin:0,background:"#0b0e14",border:`1px solid ${B.f.border}`,borderRadius:8,padding:10,fontSize:12,lineHeight:1.5},children:(0,y.jsx)(sG,{diff:e.diff,truncated:e.truncated})})]}),r&&e&&(0,y.jsx)(s0,{files:e.files,diff:e.diff,truncated:e.truncated,onClose:()=>o(!1)})]})}function sQ({runId:e,risk:t,away:n=null,decided:i=!1}){let[r,o]=(0,m.useState)(null),[a,l]=(0,m.useState)(!1);return((0,m.useEffect)(()=>{let t=!0;return fetch(`/api/runs/${e}/review`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(e=>t&&o(e)).catch(()=>t&&l(!0)),()=>{t=!1}},[e]),a)?(0,y.jsx)("div",{style:{fontSize:13,color:B.f.failed},children:b.B.gate.loadFailed}):r?(0,y.jsxs)("div",{"data-testid":"change-under-check",style:{display:"grid",gap:12},children:[t&&(0,y.jsxs)("div",{style:{fontSize:13.5,color:"low"===t.level?B.f.passed:B.f.waiting,lineHeight:1.5},children:[(0,y.jsxs)("strong",{children:[b.B.risk.label[t.level],":"]}),(0,y.jsx)(sK,{reasons:t.reasons}),"low"===t.level&&t.stopForMe&&(0,y.jsx)("div",{"data-testid":"stop-for-me-why",style:{color:B.f.waiting},children:b.B.gate.stopForMe})]}),(0,y.jsx)(sJ,{review:r,roomy:!0}),r.files.length>0&&!n&&!i&&(0,y.jsx)(sH,{runId:e}),n&&(0,y.jsx)("div",{style:{fontSize:12.5,color:B.f.dim},children:b.B.machine.elsewhere(n.machine)})]}):(0,y.jsx)(l7,{height:60,radius:10})}function s0({files:e,diff:t,truncated:n,onClose:i}){let r=(0,m.useRef)(null);return(0,m.useEffect)(()=>{r.current?.focus();let e=e=>{"Escape"===e.key&&i()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i]),(0,oi.createPortal)((0,y.jsx)("div",{"data-testid":"changes-modal",onClick:i,style:{position:"fixed",inset:0,zIndex:100,background:"rgba(5, 7, 11, 0.7)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",gridTemplateColumns:"minmax(0, 1fr)",placeItems:"center",padding:24},children:(0,y.jsxs)("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":b.B.gate.changesTitle,tabIndex:-1,onClick:e=>e.stopPropagation(),style:{width:"min(1100px, 100%)",height:"min(86vh, calc(100vh - 48px))",minHeight:0,display:"flex",flexDirection:"column",background:B.f.bg,border:`1px solid ${B.f.border}`,borderRadius:14,boxShadow:"0 30px 80px rgba(0,0,0,0.6)",outline:"none",color:"#e6e9ef"},children:[(0,y.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"12px 16px",borderBottom:`1px solid ${B.f.border}`},children:[(0,y.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,y.jsx)("div",{className:"factory-display",style:{fontSize:19},children:b.B.gate.changesTitle}),(0,y.jsx)("div",{style:{fontSize:12,color:B.f.dim,fontFamily:sU},children:e.map(e=>`${e.path} +${e.added} −${e.removed}`).join(" · ")})]}),(0,y.jsx)("button",{type:"button","aria-label":b.B.gate.closeChanges,onClick:i,style:{background:"none",border:"none",color:B.f.skipped,cursor:"pointer",fontSize:18,lineHeight:1,padding:6},children:"✕"})]}),(0,y.jsx)("pre",{style:{flex:1,minHeight:0,margin:0,overflow:"auto",padding:16,fontFamily:sU,fontSize:13,lineHeight:1.55,background:"#0b0e14",borderRadius:"0 0 14px 14px",scrollbarWidth:"thin",scrollbarColor:`${B.f.floorLine} transparent`},children:(0,y.jsx)(sG,{diff:t,truncated:n})})]})}),document.body)}function s1(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M9.5 2.5h4v4M13.5 2.5 9 7M6.5 13.5h-4v-4M2.5 13.5 7 9"})})}let s2="other",s5="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",s4=e=>e.length>400?`${e.slice(0,399)}…`:e;function s6({question:e,onAnswer:t,position:n,touched:i=[],finding:r}){let[o,a]=(0,m.useState)(null),[l,s]=(0,m.useState)(""),[d,c]=(0,m.useState)(!1),[u,p]=(0,m.useState)(!1),[f,h]=(0,m.useState)(null),[g,x]=(0,m.useState)(!1),v=(0,m.useRef)(!1),w=(0,m.useId)(),j=(0,m.useId)(),k=o??(""!==l.trim()?s2:null),S=null!==k,C=d||u;async function z(){if(S&&!v.current&&!u){v.current=!0,c(!0),h(null);try{await t(k,""!==l.trim()?l.trim():void 0),p(!0)}catch(e){h(e instanceof Error&&e.message?e.message:b.B.question.failed)}finally{v.current=!1,c(!1)}}}let I=i.filter(t=>e.touches.includes(t.number)),M=r?.problem.trim()?r.problem.trim():null,$=M?[r.where.trim()?{label:b.B.findings.detail.where,text:r.where.trim(),mono:!1}:null,r.command.trim()?{label:b.B.findings.detail.command,text:r.command.trim(),mono:!0}:null,r.outputTail.trim()?{label:b.B.findings.detail.output,text:r.outputTail.trim(),mono:!0}:null].filter(e=>null!==e):[],E=e.detail&&(!M||"fix_held"===e.kind)?e.detail:null,_=$.length>0||null!==E;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{flex:"none",width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:B.f.waiting,color:"#1a1206",fontWeight:900,fontSize:17},children:"?"}),(0,y.jsxs)("div",{style:{minWidth:0},children:[(0,y.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:b.B.question.title}),(0,y.jsx)("div",{style:{fontSize:12.5,color:"#d9c9a3"},children:b.B.question.waiting})]})]}),n&&n.of>1&&(0,y.jsx)("div",{style:{fontSize:11.5,fontWeight:700,letterSpacing:"0.04em",color:B.f.dim},children:b.B.question.position(n.n,n.of)}),(0,y.jsx)("p",{style:{margin:0,fontSize:15,lineHeight:1.45,color:B.f.ink,fontWeight:600,overflowWrap:"anywhere"},children:(0,sA.f)(e.text,i)}),e.why&&(0,y.jsx)("p",{style:{margin:0,fontSize:13,lineHeight:1.5,color:B.f.dim,overflowWrap:"anywhere"},children:(0,sA.f)(e.why,i)}),I.length>0&&(0,y.jsxs)("div",{style:{display:"grid",gap:4,fontSize:12.5,color:B.f.dim},children:[(0,y.jsx)("span",{style:{fontWeight:700},children:b.B.question.touchesTitle}),(0,y.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:I.map(e=>(0,y.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"baseline",padding:"6px 8px",borderRadius:8,border:`1px solid ${B.f.border}`,background:"#0d1118",color:"#d6dce6",overflowWrap:"anywhere"},children:[(0,y.jsx)("span",{style:{flex:"none",fontFamily:s5,fontSize:11.5,color:B.f.waiting},children:e.label}),(0,y.jsx)("span",{children:e.text})]},e.number))})]}),M&&(0,y.jsxs)("div",{style:{display:"grid",gap:4,padding:10,borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0d1118",minWidth:0},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:B.f.waiting},children:b.B.question.aiSaid}),(0,y.jsx)("span",{style:{fontSize:13,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:(0,sA.f)(s4(M),i)})]}),_&&(0,y.jsxs)("div",{style:{display:"grid",gap:6},children:[(0,y.jsx)("button",{type:"button",className:"factory-action","aria-expanded":g,"aria-controls":j,onClick:()=>x(e=>!e),style:{justifySelf:"start",background:"none",border:"none",padding:"6px 8px 6px 0",minHeight:32,color:B.f.running,cursor:"pointer",fontSize:12.5},children:b.B.question.seeDetails}),g&&(0,y.jsxs)("div",{id:j,style:{display:"grid",gap:8,padding:10,borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0d1118",minWidth:0},children:[$.map(e=>(0,y.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:B.f.dim},children:e.label}),(0,y.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",...e.mono?{fontFamily:s5,fontSize:12}:{}},children:e.text})]},e.label)),E&&(0,y.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:B.f.waiting},children:M?b.B.question.moreAbout:b.B.question.aiSaid}),(0,y.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:(0,sA.f)(E,i)})]})]})]}),(0,y.jsxs)("fieldset",{disabled:C,style:{margin:0,padding:0,border:"none",minWidth:0,display:"grid",gap:8},children:[(0,y.jsx)("legend",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:b.B.question.choicesLabel}),e.options.map(t=>{let n=o===t.id;return(0,y.jsxs)("label",{className:"factory-choice",style:{display:"flex",gap:10,alignItems:"flex-start",padding:"10px 12px",borderRadius:10,border:`1px solid ${n?B.f.waiting:B.f.border}`,background:n?B.f.tint("waiting",.1):"#0d1118",cursor:C?"not-allowed":"pointer"},children:[(0,y.jsx)("input",{type:"radio",name:w,value:t.id,checked:n,onChange:()=>a(t.id),style:{flex:"none",width:18,height:18,margin:"1px 0 0",accentColor:B.f.waiting,cursor:"inherit"}}),(0,y.jsxs)("span",{style:{display:"grid",gap:3,minWidth:0},children:[(0,y.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center",fontSize:14,fontWeight:700,color:B.f.ink},children:[t.label,e.recommended===t.id&&(0,y.jsx)("span",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:"#1a1206",background:B.f.waiting,borderRadius:999,padding:"2px 7px"},children:b.B.question.recommended})]}),(0,y.jsx)("span",{style:{fontSize:12.5,lineHeight:1.45,color:B.f.dim,overflowWrap:"anywhere"},children:t.means})]})]},t.id)}),(0,y.jsxs)("label",{style:{display:"grid",gap:4,fontSize:12.5,fontWeight:600,color:B.f.dim},children:[null===o?b.B.question.ownWordsLabel:b.B.question.noteLabel,(0,y.jsx)("textarea",{value:l,rows:3,placeholder:null===o?b.B.question.ownWordsPlaceholder:b.B.question.notePlaceholder,onChange:e=>s(e.target.value),style:{font:"inherit",fontSize:13,fontWeight:400,padding:"8px 10px",boxSizing:"border-box",width:"100%",resize:"vertical",background:"#0b0e14",color:"#e6e9ef",border:`1px solid ${B.f.border}`,borderRadius:8}})]})]}),(0,y.jsx)("button",{type:"button",className:"factory-action",disabled:!S||C,onClick:()=>void z(),style:{padding:"10px 12px",borderRadius:8,border:`1px solid ${B.f.waiting}`,background:S&&!C?B.f.waiting:"transparent",color:S&&!C?"#1a1206":B.f.skipped,fontWeight:700,fontSize:14,cursor:S&&!C?"pointer":"not-allowed"},children:d?b.B.question.sending:b.B.question.confirm}),f&&(0,y.jsx)("div",{role:"alert",style:{fontSize:13,fontWeight:600,color:B.f.failed,lineHeight:1.4},children:f}),u&&(0,y.jsx)("div",{role:"status",style:{fontSize:13,fontWeight:600,color:B.f.passed},children:b.B.question.sent})]})}function s3({runId:e,record:t,failed:n=!1,mark:i=0,readMark:r=0,askedId:o=null,onChanged:a}){let l=r<i,s=t?.question&&!(l&&null!==o&&t.question.id!==o)?t.question:null,[d,c]=(0,m.useState)(null),[u,p]=(0,m.useState)(null);s&&d?.id!==s.id&&(c(s),p(null));let f=(0,y.jsxs)("div",{role:"alert",style:{display:"grid",gap:8,fontSize:13,color:B.f.failed,lineHeight:1.4},children:[b.B.question.loadFailed,(0,y.jsx)("button",{type:"button",className:"factory-action",onClick:a,style:{justifySelf:"start",minHeight:32,padding:"6px 12px",borderRadius:8,border:`1px solid ${B.f.border}`,background:"#0f141c",color:"#e6e9ef",fontWeight:700,cursor:"pointer"},children:b.B.question.tryAgain})]});if(!s)return!t||l||n?n?f:(0,y.jsxs)("div",{"aria-busy":"true","aria-label":b.B.question.title,style:{display:"grid",gap:8},children:[(0,y.jsx)(l7,{height:20,width:"60%"}),(0,y.jsx)(l7,{height:70,radius:10})]}):(0,y.jsx)("div",{role:"status",style:{fontSize:13.5,fontWeight:600,color:B.f.dim,lineHeight:1.45},children:u??b.B.question.closed});async function h(t,n,i){let r;try{r=await fetch(`/api/runs/${encodeURIComponent(e)}/questions/${encodeURIComponent(s.id)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({option:t,...void 0!==n?{text:n}:{},...i&&i.length>0?{attachments:i}:{}})})}catch{throw Error(b.B.question.failed)}if(!r.ok){let e=await r.json().catch(()=>null),t=e?.error??b.B.question.failed;throw p(t),a(),Error(t)}a()}if("direct"===s.kind)return(0,y.jsxs)(y.Fragment,{children:[n&&f,(0,y.jsx)(s9,{question:s,onAnswer:h},s.id)]});let g=sD(t.findings),x=g.findIndex(e=>e.id===s.findingId);return(0,y.jsxs)(y.Fragment,{children:[n&&f,(0,y.jsx)(s6,{question:s,touched:t.touched,onAnswer:h,position:x>=0?{n:x+1,of:g.length}:void 0,...x>=0?{finding:g[x].detail}:{}},s.id)]})}let s8=b.B.direct;function s9({question:e,onAnswer:t}){let[n,i]=(0,m.useState)(""),[r,o]=(0,m.useState)([]),[a,l]=(0,m.useState)(null),[s,d]=(0,m.useState)(null),c=(0,m.useRef)(!1),u=(0,m.useId)(),p=Number(/^direct-(\d+)/.exec(e.findingId??"")?.[1]??1),f=e.text===s8.lastText,h=e.options.some(e=>"undo"===e.id),g=!f&&(""!==n.trim()||r.length>0);async function x(e){if(!(c.current||"next"===e&&(""===n.trim()||sT(r)))&&("done"!==e||!g)){c.current=!0,l(e),d(null);try{await ("done"===e?t("leave"):"undo"===e?t("undo"):t(s2,n.trim(),sN(r)))}catch(e){d(e instanceof Error&&e.message?e.message:b.B.question.failed),c.current=!1,l(null)}}}let v=null!==a;return(0,y.jsxs)("div",{"data-testid":"direct-pause",style:{display:"grid",gap:12},children:[(0,y.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,y.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:s8.pauseTitle}),(0,y.jsxs)("div",{style:{fontSize:13,color:B.f.dim,lineHeight:1.45},children:[s8.look," ",s8.pauseWhy]})]}),e.detail&&(0,y.jsxs)("div",{style:{display:"grid",gap:4,padding:"10px 12px",borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0f141c"},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.1em",textTransform:"uppercase",color:B.f.dim},children:s8.lastBuilt}),(0,y.jsx)("span",{style:{fontSize:13.5,lineHeight:1.45,overflowWrap:"anywhere"},children:s4(e.detail)})]}),(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,fontSize:12,color:B.f.dim},children:[(0,y.jsx)("span",{children:s8.count(p)}),h&&(0,y.jsxs)("button",{type:"button",className:"factory-action","data-testid":"direct-undo",disabled:v,title:s8.undoMeans,onClick:()=>void x("undo"),style:{background:"none",border:"none",padding:0,color:"#cfe0ff",font:"inherit",fontWeight:700,cursor:v?"default":"pointer"},children:["↩ ","undo"===a?s8.sending:s8.undo]})]}),(p>=5||f)&&(0,y.jsx)("div",{role:"note","data-testid":"direct-many",style:{padding:"9px 12px",borderRadius:10,border:`1px solid ${B.f.waiting}`,color:"#f3d9a4",fontSize:13,lineHeight:1.45},children:f?s8.lastText:s8.many}),!f&&(0,y.jsx)(sW,{inputId:u,label:s8.nextLabel,placeholder:s8.nextPlaceholder,text:n,onText:i,images:r,onImages:o,minHeight:96,disabled:v,onSubmit:()=>void x("next"),send:{label:s8.send,onSend:()=>void x("next"),enabled:!v&&""!==n.trim()&&!sT(r),busy:"next"===a}}),(0,y.jsxs)("div",{style:{display:"grid",gap:5,paddingTop:12,borderTop:`1px solid ${B.f.border}`},children:[(0,y.jsx)("button",{type:"button",className:"factory-action","data-testid":"direct-done",disabled:v||g,onClick:()=>void x("done"),style:{minHeight:40,padding:"9px 16px",borderRadius:9,border:"none",background:g?"#2a3140":B.f.passed,color:g?"#8b95a7":"#0d1f12",fontWeight:800,fontSize:14.5,cursor:g?"not-allowed":v?"default":"pointer"},children:"done"===a?s8.sending:s8.done}),g?(0,y.jsx)("span",{role:"note","data-testid":"direct-unsent",style:{fontSize:12.5,color:"#f3d9a4",textAlign:"center",lineHeight:1.45},children:s8.unsent}):(0,y.jsx)("span",{style:{fontSize:12,color:B.f.dim,textAlign:"center"},children:s8.doneHint})]}),s&&(0,y.jsx)("div",{role:"alert",style:{fontSize:13,color:B.f.failed},children:s})]})}function s7({runId:e,note:t,composer:n,onSent:i,measure:r}){let o=(0,m.useRef)(null),[a,l]=(0,m.useState)(new Set),[s,d]=(0,m.useState)(null),[c,u]=(0,m.useState)(null),[p,f]=(0,m.useState)(null),[h,g]=(0,m.useState)(!1),[x,v]=(0,m.useState)(!1);(0,m.useEffect)(()=>{let t=!0;return fetch(`/api/runs/${e}/plan`).then(e=>e.ok?e.json():null).then(e=>t&&d((e?.plan?.jobs??[]).map((e,t)=>({key:`j${t}-${Date.now()}`,title:e.title,done:e.done.join("\n"),...e.paths?{paths:e.paths}:{}})))).catch(()=>t&&d([])),()=>{t=!1}},[e]);let w=p?.ok===!0;async function j(t,n){u(n),f(null);try{let r=await fetch(`/api/runs/${e}/plan`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}),o=await r.json().catch(()=>null);if(!r.ok)return f({ok:!1,text:o?.error??b.B.run.startFailed});if(o&&!1===o.delivered&&"machine"in o)return f({ok:!0,text:b.B.machine.sentElsewhere(o.machine??null)});f({ok:!0,text:"build"===n?b.B.plan.building_sent:b.B.plan.replanned}),"replan"===n&&i()}catch{f({ok:!1,text:b.B.run.startFailed})}finally{u(null)}}(0,m.useEffect)(()=>{if(!w)return;let e=setTimeout(()=>g(!0),2e4);return()=>clearTimeout(e)},[w]);let k=(e,t)=>d(n=>(n??[]).map(n=>n.key===e?{...n,...t}:n)),S=s?s.map(e=>({title:e.title.trim(),done:e.done.split("\n").map(e=>e.trim()).filter(Boolean),...e.paths?{paths:e.paths}:{}})).filter(e=>""!==e.title):[],C=null!==c||w,z={width:"100%",boxSizing:"border-box",background:"#0b0e14",color:"#d6dce6",border:`1px solid ${B.f.border}`,borderRadius:6,font:"inherit"};return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:B.f.waiting,color:"#1a1206"},children:(0,y.jsx)(de,{})}),(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:b.B.plan.title}),(0,y.jsx)("div",{style:{fontSize:12.5,color:"#d9c9a3"},children:b.B.plan.waiting})]})]}),r&&r.reasons.length>0&&(0,y.jsxs)("div",{"data-testid":"plan-why",style:{display:"grid",gap:6,fontSize:13,lineHeight:1.45,color:"#d9c9a3",overflowWrap:"anywhere"},children:[x?(0,y.jsx)("ul",{style:{margin:0,paddingLeft:18,display:"grid",gap:4},children:r.reasons.map((e,t)=>(0,y.jsx)("li",{children:e},t))}):(0,y.jsx)("span",{children:r.reasons[0]}),r.question&&(0,y.jsx)("span",{"data-testid":"plan-question",style:{color:"#f1e6c8",fontWeight:600},children:r.question}),r.reasons.length>1&&(0,y.jsx)("button",{type:"button","aria-expanded":x,onClick:()=>v(e=>!e),style:{justifySelf:"start",padding:0,background:"none",border:"none",color:"#9cc2ff",fontSize:12.5,cursor:"pointer",textDecoration:"underline"},children:b.B.plan.whyStopped})]}),null===s?(0,y.jsxs)("div",{"aria-busy":"true",style:{display:"grid",gap:8},children:[(0,y.jsx)(l7,{height:70,radius:10}),(0,y.jsx)(l7,{height:70,radius:10})]}):(0,y.jsx)("ol",{ref:o,"data-testid":"plan-jobs",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:8,maxHeight:"min(52vh, 560px)",overflowY:"auto",paddingRight:4,scrollbarWidth:"thin",scrollbarColor:`${B.f.skipped} transparent`},children:s.map((e,t)=>(0,y.jsxs)("li",{className:"factory-job-in",style:{display:"grid",gap:6,padding:10,borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0d1118",animationDelay:`${300+260*Math.min(t,6)}ms`},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{fontSize:11,color:B.f.dim,paddingLeft:28},children:b.B.plan.jobWhat}),(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:-3},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{flex:"none",width:20,height:20,borderRadius:"50%",display:"grid",placeItems:"center",fontSize:11,fontWeight:800,background:B.f.tint("waiting",.2),color:B.f.waiting},children:t+1}),(0,y.jsx)("input",{"aria-label":b.B.plan.jobLabel(t+1),value:e.title,placeholder:b.B.plan.jobPlaceholder,disabled:C,onChange:t=>k(e.key,{title:t.target.value}),style:{...z,flex:1,minWidth:0,padding:"6px 8px",fontSize:13,fontWeight:600}}),(0,y.jsx)("button",{type:"button","aria-label":b.B.plan.removeJob(t+1),title:b.B.plan.removeJob(t+1),disabled:C,onClick:()=>d(t=>(t??[]).filter(t=>t.key!==e.key)),style:{flex:"none",width:26,height:26,display:"grid",placeItems:"center",padding:0,background:"none",border:"none",color:B.f.skipped,cursor:"pointer"},children:(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M2.5 4h11M6.5 4V2.5h3V4M4 4l.7 9.5h6.6L12 4"})})})]}),""!==e.done.trim()||a.has(e.key)?(0,y.jsxs)("label",{style:{display:"grid",gap:3,fontSize:11,color:B.f.dim,paddingLeft:28},children:[b.B.plan.doneLabel,(0,y.jsx)("textarea",{value:e.done,rows:Math.max(1,e.done.split("\n").length),placeholder:b.B.plan.donePlaceholder,disabled:C,onFocus:()=>l(t=>t.has(e.key)?t:new Set(t).add(e.key)),onChange:t=>k(e.key,{done:t.target.value}),style:{...z,padding:"5px 8px",fontSize:12,lineHeight:1.45,resize:"vertical"}})]}):!C&&(0,y.jsxs)("button",{type:"button",onClick:()=>l(t=>new Set(t).add(e.key)),style:{justifySelf:"start",marginLeft:28,padding:0,background:"none",border:"none",color:B.f.dim,fontSize:11.5,cursor:"pointer",textDecoration:"underline"},children:["+ ",b.B.plan.addChecks]})]},e.key))}),null!==s&&!C&&(0,y.jsxs)("button",{type:"button",onClick:()=>{d(e=>[...e??[],{key:`new-${Date.now()}`,title:"",done:""}]),requestAnimationFrame(()=>{let e=o.current?.lastElementChild;e?.scrollIntoView?.({block:"nearest",behavior:"smooth"}),e?.querySelector("input")?.focus({preventScroll:!0})})},style:{justifySelf:"start",display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:6,border:`1px dashed ${B.f.border}`,background:"transparent",color:"#d6dce6",fontSize:12.5,fontWeight:600,cursor:"pointer"},children:[(0,y.jsx)("span",{"aria-hidden":"true",children:"+"})," ",b.B.plan.addJob]}),!w&&(0,y.jsxs)("button",{type:"button",disabled:C||0===S.length,onClick:()=>void j({action:"build",jobs:S},"build"),className:"factory-call",style:{padding:"9px 12px",borderRadius:8,border:`1px solid ${B.f.passed}`,background:S.length>0?B.f.passed:"transparent",color:S.length>0?"#07110a":B.f.skipped,fontWeight:700,cursor:C?"wait":0===S.length?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:["build"===c?(0,y.jsx)($.m,{blockId:"plan-build",size:16}):(0,y.jsx)("span",{"aria-hidden":"true",children:"▶"})," ","build"===c?b.B.plan.building:b.B.plan.build]}),!w&&(0,y.jsx)("div",{style:{paddingTop:10,borderTop:`1px solid ${B.f.lineSoft}`,display:"grid"},children:n({label:b.B.plan.replan,onSend:()=>void j({action:"replan",note:t},"replan"),enabled:!C&&""!==t.trim()})}),p&&(0,y.jsxs)("div",{role:p.ok?"status":"alert",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:p.ok?B.f.passed:B.f.failed},children:[p.ok&&!h&&(0,y.jsx)($.m,{blockId:"plan-sent",size:16}),p.text]}),w&&h&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12.5,color:B.f.waiting,lineHeight:1.4},children:b.B.plan.notPickedUp})]})}function de(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M6 4h7.5M6 8h7.5M6 12h7.5M2.5 4h.01M2.5 8h.01M2.5 12h.01"})})}let dt=b.B.delivery;function dn({runId:e,button:t}){let[n,i]=(0,m.useState)("idle"),[r,o]=(0,m.useState)(null),[a,l]=(0,m.useState)(null),s=(0,m.useRef)(null),d=(0,m.useRef)(!1);async function c(){s.current=window.open("","_blank"),d.current=!1,l(null),i("starting");let t=await fetch(`/api/runs/${e}/preview`,{method:"POST"}).catch(()=>null);if(d.current=!0,!t?.ok){let e=await t?.json().catch(()=>null);s.current?.close(),s.current=null,l(e?.error??null),i("failed")}}return((0,m.useEffect)(()=>{if("starting"!==n&&"open"!==n)return;let t=!0,r=async()=>{let r=await fetch(`/api/runs/${e}/preview`).catch(()=>null),a=r?.ok?await r.json().catch(()=>null):null;t&&a&&d.current&&("ready"===a.status&&a.url?(o(a.url),"starting"===n&&(s.current&&!s.current.closed?s.current.location.href=a.url:window.open(a.url,"_blank","noopener"),s.current=null,i("open"))):"open"===n&&"installing"!==a.status&&"starting"!==a.status?(o(null),i("idle")):("failed"===a.status||"stopped"===a.status)&&(s.current?.close(),s.current=null,l(a.message),i("failed")))},a=setInterval(()=>void r(),2e3);return r(),()=>{t=!1,clearInterval(a)}},[n,e]),"starting"===n)?(0,y.jsxs)("div",{"data-testid":"open-site",role:"status",style:{display:"grid",gap:4},children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"#d6dce6"},children:[(0,y.jsx)($.m,{blockId:"open-site",size:16})," ",dt.openingSite]}),(0,y.jsx)("div",{style:{fontSize:11.5,color:B.f.dim,lineHeight:1.4},children:dt.openingSiteHint})]}):"open"===n&&r?(0,y.jsxs)("div",{"data-testid":"open-site",style:{display:"grid",gap:6},children:[(0,y.jsxs)("div",{style:{fontSize:12.5,color:B.f.passed,lineHeight:1.4},children:["✓ ",dt.siteOpen]}),(0,y.jsxs)("a",{href:r,target:"_blank",rel:"noopener noreferrer",style:{...t(!1),textDecoration:"none"},children:["↗ ",dt.openSiteAgain]})]}):(0,y.jsxs)("div",{"data-testid":"open-site",style:{display:"grid",gap:4},children:["failed"===n&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12.5,color:B.f.failed,lineHeight:1.4},children:a??dt.siteFailed}),(0,y.jsxs)("button",{type:"button",onClick:()=>void c(),style:t(!1),children:["↗ ","failed"===n?dt.siteTryAgain:dt.openSite]}),"idle"===n&&(0,y.jsx)("div",{style:{fontSize:11.5,color:B.f.dim,lineHeight:1.4},children:dt.openSiteWhat})]})}let di={pending:{glyph:"…",colour:B.f.waiting},passed:{glyph:"✓",colour:B.f.passed},failed:{glyph:"✕",colour:B.f.failed},neutral:{glyph:"·",colour:B.f.skipped}};function dr({checks:e}){return(0,y.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:3,fontSize:12},children:e.map((e,t)=>(0,y.jsxs)("li",{style:{display:"flex",gap:6,alignItems:"baseline"},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{color:di[e.state].colour,fontWeight:800,width:12},children:di[e.state].glyph}),e.url?(0,y.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:C.f.green},children:e.name}):(0,y.jsx)("span",{children:e.name}),(0,y.jsx)("span",{style:{color:B.f.dim},children:b.B.ship.checkState[e.state]})]},`${e.name}-${t}`))})}function da({runId:e,button:t,onState:n,canOpen:i=!0,onRecorded:r}){let[o,a]=(0,m.useState)(null),l=(0,m.useCallback)(e=>{a({...e,readAt:Date.now()}),n?.(e)},[n]),[s,d]=(0,m.useState)(null),[c,u]=(0,m.useState)(!1),[p,f]=(0,m.useState)(null),h=(0,m.useCallback)(()=>{fetch(`/api/runs/${e}/ship`).then(e=>e.ok?e.json():null).then(e=>e&&l(e)).catch(()=>void 0)},[e,l]);(0,m.useEffect)(h,[h]);let g=o?.pr?.state==="open",x=o?.pr?.state==="merged",v=x&&!0===o.deployPending,j=o?.conflictFix?.status==="working"||o?.conflictFix?.status==="done"&&o.pr?.conflicts===!0,k=g&&!o.checksDone||v||j;async function S(t){d(t),f(null);try{let n=await fetch(`/api/runs/${e}/ship`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:t})}),i=await n.json().catch(()=>null);if(!n.ok||!i)return f(i?.error??b.B.run.startFailed);l(i),u(!1),"fix-conflict"===t&&window.dispatchEvent(new Event(E)),r?.()}catch{f(b.B.run.startFailed)}finally{d(null)}}if((0,m.useEffect)(()=>{if(!k)return;let e=setInterval(h,8e3);return()=>clearInterval(e)},[k,h]),null===o)return(0,y.jsxs)("div",{"data-testid":"ship-skeleton","aria-busy":"true",style:{display:"grid",gap:6},children:[(0,y.jsx)(l7,{height:38,radius:8}),(0,y.jsx)(l7,{width:"70%",height:10})]});let z={fontSize:11.5,color:B.f.dim,lineHeight:1.4};return(0,y.jsxs)("div",{"data-testid":"ship-section",style:{display:"grid",gap:6},children:[!o.pr&&i&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("button",{type:"button",disabled:null!==s,onClick:()=>void S("open"),style:t(s),children:["open"===s?(0,y.jsx)($.m,{blockId:"ship-open",size:16}):(0,y.jsx)(dl,{})," ","open"===s?b.B.ship.opening:b.B.ship.shipIt]}),(0,y.jsx)("div",{style:{...z,marginTop:-2},children:b.B.ship.shipWhat})]}),o.pr&&(0,y.jsxs)("div",{style:{display:"grid",gap:6,fontSize:12.5,lineHeight:1.4},children:[(0,y.jsxs)("a",{href:o.pr.url,target:"_blank",rel:"noopener noreferrer",style:{color:C.f.green,fontWeight:600,fontSize:12},children:[b.B.ship.pr(o.pr.number)," ↗"]}),"closed"===o.pr.state&&(0,y.jsx)("span",{style:{color:B.f.failed},children:b.B.ship.closed}),g&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.1em",textTransform:"uppercase",color:B.f.dim},children:b.B.ship.checksTitle}),!o.checksDone&&(0,y.jsxs)("div",{role:"status","data-testid":"ship-checking",style:{display:"flex",gap:10,alignItems:"center",padding:"10px 12px",borderRadius:8,border:`1px solid ${B.f.tint("running",.5)}`,background:B.f.tint("running",.1),color:"#cfe0ff",fontSize:13,fontWeight:600,lineHeight:1.4},children:[(0,y.jsx)($.m,{blockId:"ship-checks",size:18}),0===o.checks.length?b.B.ship.looking:b.B.ship.waiting]}),o.checks.length>0&&(0,y.jsx)(dr,{checks:o.checks}),o.checksDone&&0===o.checks.length&&(0,y.jsx)("span",{style:z,children:b.B.ship.noChecks}),o.checksDone&&o.checks.length>0&&!o.checksFailed&&(0,y.jsxs)("span",{style:{color:B.f.passed},children:["✓ ",b.B.ship.allPassed]}),o.checksFailed&&(0,y.jsx)("span",{style:{color:B.f.failed},children:b.B.ship.someFailed}),o.pr.conflicts&&o.conflictFix?.status!=="working"&&o.conflictFix?.status!=="done"&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("span",{style:{color:B.f.failed},children:b.B.ship.conflicts}),o.conflictFix?.status==="failed"&&(0,y.jsx)("span",{role:"alert","data-testid":"conflict-failed",style:{color:B.f.failed},children:o.conflictFix.message}),o.conflictFix?.status==="failed"&&(0,y.jsxs)("a",{"data-testid":"conflict-on-github",href:`${o.pr.url.replace(/\/+$/,"")}/conflicts`,target:"_blank",rel:"noopener noreferrer",style:{color:C.f.green,fontWeight:600},children:[b.B.conflict.onGitHub," ↗"]}),i&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("button",{type:"button","data-testid":"fix-conflict",disabled:null!==s,onClick:()=>void S("fix-conflict"),style:t(s),children:["fix-conflict"===s&&(0,y.jsx)($.m,{blockId:"fix-conflict",size:16})," ",b.B.conflict.fix]}),(0,y.jsx)("span",{style:z,children:b.B.conflict.what})]})]}),(o.conflictFix?.status==="working"||o.conflictFix?.status==="done"&&o.pr.conflicts)&&(0,y.jsxs)("div",{role:"status","data-testid":"conflict-working",style:{display:"flex",gap:10,alignItems:"center",padding:"10px 12px",borderRadius:8,border:`1px solid ${B.f.tint("running",.5)}`,background:B.f.tint("running",.08),lineHeight:1.4},children:[(0,y.jsx)($.m,{blockId:"conflict-fix",size:18}),(0,y.jsx)("span",{children:"working"===o.conflictFix.status?o.conflictFix.message:b.B.conflict.seen})]}),o.conflictFix?.status==="done"&&!o.pr.conflicts&&(0,y.jsxs)("span",{"data-testid":"conflict-done",style:{color:B.f.passed},children:["✓ ",o.conflictFix.message]}),o.onHold&&(0,y.jsxs)("div",{"data-testid":"on-hold",style:{display:"flex",gap:8,alignItems:"flex-start",padding:8,borderRadius:8,border:`1px solid ${B.f.tint("waiting",.5)}`,background:B.f.tint("waiting",.08),color:B.f.waiting},children:[(0,y.jsx)("span",{style:{marginTop:2},children:(0,y.jsx)(w.h,{size:12})}),(0,y.jsx)("span",{style:{lineHeight:1.4},children:b.B.ship.onHold})]}),o.checksDone&&!o.checksFailed&&!o.pr.conflicts&&!c&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("span",{style:{display:"flex",gap:6},children:[(0,y.jsx)("button",{type:"button",disabled:null!==s,onClick:()=>u(!0),style:{...t(s),flex:1},children:b.B.ship.merge}),(0,y.jsxs)("button",{type:"button",disabled:null!==s,onClick:()=>void S(o.onHold?"unhold":"hold"),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6,padding:"6px 10px",borderRadius:8,border:`1px solid ${B.f.tint("waiting",.6)}`,background:"transparent",color:B.f.waiting,fontWeight:700,cursor:s?"wait":"pointer"},children:["hold"===s||"unhold"===s?(0,y.jsx)($.m,{blockId:"ship-hold",size:13}):(0,y.jsx)(w.h,{size:11}),"hold"===s?b.B.ship.holding:o.onHold?b.B.ship.unhold:b.B.ship.hold]})]}),(0,y.jsx)("div",{style:{...z,marginTop:-2},children:b.B.ship.mergeWhat}),!o.onHold&&(0,y.jsx)("div",{style:z,children:b.B.ship.holdWhat})]}),c&&(0,y.jsxs)("div",{role:"group","aria-label":b.B.ship.confirm,className:"factory-ask-in",style:{display:"grid",gap:6,padding:8,border:`1px solid ${B.f.tint("waiting",.5)}`,borderRadius:8,background:B.f.tint("waiting",.08)},children:[b.B.ship.confirm,(0,y.jsxs)("span",{style:{display:"flex",gap:6},children:[(0,y.jsxs)("button",{type:"button",disabled:null!==s,onClick:()=>void S("merge"),style:{...t(s),flex:1},children:["merge"===s?(0,y.jsx)($.m,{blockId:"ship-merge",size:14}):null," ","merge"===s?b.B.ship.merging:b.B.ship.yes]}),(0,y.jsx)("button",{type:"button",disabled:null!==s,onClick:()=>u(!1),style:{flex:1,padding:"6px 10px",borderRadius:8,border:`1px solid ${B.f.dim}`,background:C.f.card,color:B.f.ink,fontWeight:600,cursor:"pointer"},children:b.B.ship.no})]})]})]}),x&&(0,y.jsxs)(y.Fragment,{children:[v?(0,y.jsxs)("div",{role:"status","data-testid":"ship-publishing",style:{display:"flex",gap:10,alignItems:"center",padding:"10px 12px",borderRadius:8,border:`1px solid ${B.f.tint("running",.5)}`,background:B.f.tint("running",.1),color:"#cfe0ff",fontSize:13,fontWeight:600,lineHeight:1.4},children:[(0,y.jsx)($.m,{blockId:"ship-deploy",size:18}),b.B.ship.deployWaiting]}):(0,y.jsxs)("span",{style:{color:B.f.passed,fontWeight:700},children:["✓ ",b.B.ship.merged]}),void 0!==o.folder&&(0,y.jsx)("span",{"data-testid":"ship-folder",style:z,children:o.folder?b.B.ship.folderUpdated:b.B.ship.folderNot}),o.deploy.length>0&&(0,y.jsx)(dr,{checks:o.deploy}),!v&&0===o.deploy.length&&(0,y.jsx)("span",{style:z,children:b.B.ship.noDeploy}),!v&&o.deploy.length>0&&!o.deploy.some(e=>"failed"===e.state)&&(0,y.jsxs)("span",{style:{color:B.f.passed},children:["✓ ",b.B.ship.live]}),o.deploy.some(e=>"failed"===e.state)&&(0,y.jsx)("span",{style:{color:B.f.failed},children:b.B.ship.deployFailed})]})]}),p&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12.5,color:B.f.failed,lineHeight:1.4},children:p})]})}function dl(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M8 10.5V2.5M4.5 6 8 2.5 11.5 6M2.5 10v2.5a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1V10"})})}var ds=e.i(29978);let dd=b.B.delivery.throwAway;function dc({runId:e,prOpen:t,onThrown:n}){let[i,r]=(0,m.useState)(!1),[o,a]=(0,m.useState)(!1),[l,s]=(0,m.useState)(null);async function d(){a(!0),s(null);try{let t=await fetch(`/api/runs/${e}/throw-away`,{method:"POST"}),i=await t.json().catch(()=>null);if(!t.ok||!i)return s(i?.error??b.B.run.startFailed);r(!1),n(i)}catch{s(b.B.run.startFailed)}finally{a(!1)}}let c=()=>{o||r(!1)};return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("button",{type:"button","data-testid":"throw-away",onClick:()=>{s(null),r(!0)},style:{width:"100%",padding:"10px 14px",borderRadius:8,border:`1px solid ${B.f.failed}`,background:B.f.tint("failed",.12),color:"#fecaca",font:"inherit",fontSize:13.5,fontWeight:600,cursor:"pointer"},children:dd.link}),i&&(0,y.jsxs)(ds.f,{title:dd.title,testid:"throw-away-dialog",onClose:c,children:[(0,y.jsxs)("p",{style:{margin:0,color:C.f.quiet,fontSize:15,lineHeight:1.5},children:[dd.text,t?` ${dd.prToo}`:""]}),l&&(0,y.jsx)("p",{role:"alert",style:{margin:0,color:B.f.failed,fontSize:13.5,lineHeight:1.45},children:l}),(0,y.jsxs)("div",{style:{display:"flex",gap:10,justifyContent:"flex-end",flexWrap:"wrap"},children:[(0,y.jsx)("button",{type:"button",disabled:o,onClick:c,style:{padding:"10px 16px",borderRadius:8,border:`1px solid ${C.f.line}`,background:"transparent",color:C.f.text,font:"inherit",fontSize:14,cursor:"pointer"},children:dd.no}),(0,y.jsxs)("button",{type:"button","data-testid":"throw-away-yes",disabled:o,onClick:()=>void d(),style:{display:"inline-flex",alignItems:"center",gap:8,padding:"10px 16px",borderRadius:8,border:`1px solid ${B.f.failed}`,background:B.f.tint("failed",.16),color:"#fecaca",font:"inherit",fontSize:14,fontWeight:700,cursor:o?"wait":"pointer"},children:[o&&(0,y.jsx)($.m,{blockId:"throw-away",size:14}),o?dd.busy:dd.yes]})]})]})]})}function du({runId:e,note:t,imageIds:n,imagesBusy:i,composer:r,onFollowUp:o,onShipState:a,away:l=null,onRecorded:s,onNewTask:d}){let c=(0,m.useContext)(sR),[u,p]=(0,m.useState)(null),[f,h]=(0,m.useState)(null),g=(0,m.useCallback)(e=>{p(e);let t=e.autoShip?.state==="started"?e.autoShip.at??"started":null;null!==t&&h(e=>e?.key===t?e:{key:t,at:Date.now()})},[]),[x,v]=(0,m.useState)(!1),[w,j]=(0,m.useState)(!1),k=w||""!==t.trim(),[z,I]=(0,m.useState)(null),[M,E]=(0,m.useState)(!1),[_,R]=(0,m.useState)(""),[N,T]=(0,m.useState)(!1),[W,L]=(0,m.useState)(null),[P,A]=(0,m.useState)(null),H=P?.pr!=null,F=P?.pr?.state==="merged",O=P?.pr?.state==="open"&&!P.checksDone,D=F&&P?.deployPending===!0,q=F&&void 0!==d&&!k,V=O||D,Y=(0,m.useCallback)(e=>{A(e),a?.(e)},[a]),[X,U]=(0,m.useState)(null);async function Z(t){U((t??"").replace(/^https:\/\/github\.com\/|^git@github\.com:/,"").replace(/\.git$/,"")),p(e=>e&&{...e,hasRemote:!0});let n=await fetch(`/api/runs/${e}/delivery`).catch(()=>null);n?.ok&&g(await n.json())}let[K,G]=(0,m.useState)(null),[J,Q]=(0,m.useState)(!1),[et,en]=(0,m.useState)(null);async function ei(){Q(!0),en(null);try{let t=await fetch(`/api/runs/${e}/connect-github`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skip:!0})}),n=await t.json().catch(()=>null);if(!t.ok)return en(n?.error??b.B.run.startFailed);G(!0)}catch{en(b.B.run.startFailed)}finally{Q(!1)}}(0,m.useEffect)(()=>{let t=!0;return fetch(`/api/runs/${e}/delivery`).then(e=>e.ok?e.json():null).then(e=>t&&e&&g(e)).catch(()=>void 0).finally(()=>t&&v(!0)),()=>{t=!1}},[e,g]);let[er,eo]=(0,m.useState)(()=>Date.now()),ea=u?.autoShip?.state==="started"?u.autoShip.at??"started":null,el=null!==ea,es=el&&f?.key===ea&&er-f.at>18e4,ed=el&&!es;(0,m.useEffect)(()=>{if(!el)return;let t=setInterval(()=>{eo(Date.now()),fetch(`/api/runs/${e}/delivery`).then(e=>e.ok?e.json():null).then(e=>e&&g(e)).catch(()=>void 0)},3e3);return()=>clearInterval(t)},[el,e,g]);let[ec,eu]=(0,m.useState)(!1),ep=u?.eligible===!0&&!u.kept;async function ef(){T(!0);try{let t=await fetch(`/api/runs/${e}/branch-name`),n=await t.json().catch(()=>null);t.ok&&n?.name&&R(n.name)}catch{}finally{T(!1)}}async function eh(t){I(t),L(null);try{let n=await fetch(`/api/runs/${e}/delivery`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify("branch"===t||"apply"===t?{mode:t,name:_.trim()}:{mode:t})}),i=await n.json().catch(()=>null);if(!n.ok||!i)return L(i?.error??b.B.run.startFailed);g(i),s?.()}catch{L(b.B.run.startFailed)}finally{I(null)}}async function eg(){I("follow"),L(null);try{let i=await fetch(`/api/runs/${e}/follow-up`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({note:t,attachments:n})}),r=await i.json().catch(()=>null);if(!i.ok||!r?.runId)return L(r?.error??b.B.run.startFailed);o(r.runId)}catch{L(b.B.run.startFailed)}finally{I(null)}}if((0,m.useEffect)(()=>{ep&&ef()},[ep,e]),!x)return(0,y.jsx)(st,{});if(!u?.eligible)return(0,y.jsx)(y.Fragment,{children:r()});if(u.thrownAway)return(0,y.jsx)("div",{"data-testid":"thrown-away",style:{fontSize:13.5,color:B.f.dim,lineHeight:1.5},children:b.B.delivery.throwAway.done});let ex=u.kept&&null!==u.branch,ey=S(P),em=ex&&!H&&!l&&!1===u.hasRemote,eb=em&&(K??!0===u.githubSkipped),ev=F&&!D?4:F||ey?3:ex?2:1,ew=b.B.delivery,ej=u.autoShip,ek=ej?.reason==="no_connection"&&ej.message===ew.noRemote,eS=ej?.state==="stopped"&&(eb&&"no_connection"===ej.reason||"keep"===ej.step&&ex||"send"===ej.step&&(H||u.pushed||ek&&(!0===u.hasRemote||null!==X))||"open"===ej.step&&H),eC=ej?.state==="opened"?P?.pr?.state!=="open"||P.checksFailed||P.pr.conflicts?null:`${"app"===u.passedBy?ew.auto.openedByApp:ew.auto.openedAfterYes}${ey?` ${ew.auto.publishWhenReady}`:""}`:ej?.state!=="stopped"||eS?es?ew.auto.seemsStopped:ej||"app"!==u.passedBy||ex||u.delivered?null:ew.auto.passedReady:"open"===ej.step?ew.auto.stopped.open:"keep"===ej.step?ew.auto.stopped.keep:"no_connection"===ej.reason?ew.auto.stopped.noConnection:ew.auto.stopped.send,eB=ed?ew.auto.working:D?ew.nowPublishing:F?ew.finished:ey?P.onHold?ew.nowOnHold:ew.nowPublish:P?.pr?.state==="closed"?ew.nowClosed:H?P.checksFailed||P.pr.conflicts?ew.nowProblem:ew.nowChecking:ex?em?ew.nowSaved:ew.nowSend:ew.nowSave,ez=ex&&u.current===u.branch,eI=!l&&!H&&!u.delivered&&!ez,eM=!l&&ex&&!H&&!u.pushed&&!em;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(dp,{current:ev,passedByApp:"app"===u.passedBy,docked:c}),(0,y.jsxs)("div",{style:c?{display:"grid",gap:12,gridTemplateColumns:"minmax(0, 1fr)",padding:18,borderRadius:14,border:`1px solid ${C.f.line}`,background:C.f.card}:{display:"contents"},children:[(0,y.jsxs)("div",{"data-testid":"next-step",role:ed?"status":void 0,style:{display:"flex",alignItems:"center",gap:8,fontSize:c?16:13.5,fontWeight:c?700:void 0,color:c?C.f.text:"#d6dce6",lineHeight:1.45,overflowWrap:"anywhere"},children:[ed&&(0,y.jsx)($.m,{blockId:"auto-ship",size:16}),(0,y.jsx)("span",{style:{minWidth:0},children:eB})]}),F&&d&&(0,y.jsxs)("div",{"data-testid":"next-change",style:{display:"grid",gap:10,fontSize:13.5,lineHeight:1.5,color:"#c9d0db"},children:[(0,y.jsx)("span",{children:ew.nextChange}),[{key:"new",when:ew.newTaskWhen,points:ew.newTaskPoints},{key:"keep",when:ew.keepHereWhen,points:ew.keepHerePoints}].map(e=>(0,y.jsxs)("div",{"data-testid":`way-${e.key}`,style:{display:"grid",gap:8,padding:"12px 14px",borderRadius:11,border:`1px solid ${C.f.line}`,background:"#141414"},children:[(0,y.jsx)("strong",{style:{fontSize:13.5,color:"#e6e9ef"},children:e.when}),(0,y.jsx)("ul",{style:{margin:0,paddingLeft:18,display:"grid",gap:3,fontSize:12.5,color:"#c9d0db"},children:e.points.map(e=>(0,y.jsx)("li",{children:e},e))}),"new"===e.key?(0,y.jsxs)("button",{type:"button",className:"factory-action",onClick:d,style:{marginTop:2,padding:"9px 14px",borderRadius:9,border:`1px solid ${B.f.passed}`,background:B.f.passed,color:"#0d1f12",fontWeight:800,fontSize:14,cursor:"pointer"},children:["+ ",ew.newTask]}):(0,y.jsx)("button",{type:"button",className:"factory-action","data-testid":"keep-here","aria-pressed":k,onClick:()=>j(!0),style:{marginTop:2,padding:"9px 14px",borderRadius:9,border:`1.5px solid ${B.f.passed}`,background:B.f.tint("passed",k?.28:.12),color:B.f.passed,fontWeight:800,fontSize:14,cursor:"pointer"},children:k?`${ew.keepHere} ↓`:ew.keepHere})]},e.key))]}),eC&&(0,y.jsxs)("div",{"data-testid":"auto-line",style:{display:"grid",gap:6,fontSize:12.5,lineHeight:1.45,color:ej?.state==="stopped"?B.f.waiting:"#b9dcc5",overflowWrap:"anywhere"},children:[(0,y.jsx)("span",{children:eC}),ej?.state==="stopped"&&!eS&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("span",{style:{color:B.f.dim},children:ew.auto.tryAgain}),ej.message&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("button",{type:"button","aria-expanded":ec,onClick:()=>eu(e=>!e),style:{justifySelf:"start",padding:0,background:"none",border:"none",color:C.f.green,fontSize:12.5,cursor:"pointer",textDecoration:"underline"},children:ew.auto.whatHappened}),ec&&(0,y.jsx)("span",{"data-testid":"auto-message",style:{color:B.f.dim},children:ej.message})]})]})]}),(0,y.jsxs)("div",{style:{display:"grid",gap:8,gridTemplateColumns:"minmax(0, 1fr)"},children:[l&&!F&&(0,y.jsx)("div",{"data-testid":"away",style:{fontSize:12.5,color:B.f.waiting,lineHeight:1.45},children:b.B.machine.elsewhere(l.machine)}),!ex&&!l&&!ed&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"grid",gap:4,fontSize:12,color:B.f.dim},children:[(0,y.jsx)("label",{htmlFor:`branch-name-${e}`,children:ew.branchName}),(0,y.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,y.jsx)("input",{id:`branch-name-${e}`,value:_,placeholder:ew.branchPlaceholder,disabled:null!==z||N,spellCheck:!1,onChange:e=>R(e.target.value),style:{flex:1,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,padding:"7px 8px",background:C.f.bg,color:"#d6dce6",border:`1px solid ${C.f.line}`,borderRadius:6,minWidth:0}}),(0,y.jsxs)("button",{type:"button",disabled:null!==z||N,onClick:()=>void ef(),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",borderRadius:6,border:`1px solid ${C.f.line}`,background:C.f.card,color:"#d6dce6",fontSize:12,fontWeight:600,cursor:N?"wait":"pointer",whiteSpace:"nowrap"},children:[N?(0,y.jsx)($.m,{blockId:"suggest",size:12}):(0,y.jsx)(dy,{})," ",N?ew.suggesting:ew.suggestName]})]}),(0,y.jsx)("span",{style:{fontSize:11,lineHeight:1.4},children:ew.branchNameHint})]}),(0,y.jsxs)("button",{type:"button",disabled:null!==z,onClick:()=>void eh("branch"),style:dg(z),children:["branch"===z?(0,y.jsx)($.m,{blockId:"keep",size:16}):(0,y.jsx)(df,{})," ",ew.keepButton]})]}),ex&&!ed&&(0,y.jsxs)("div",{"data-testid":"kept",style:{display:"grid",gap:8,gridTemplateColumns:"minmax(0, 1fr)"},children:[em&&!eb?(0,y.jsxs)("div",{"data-testid":"not-connected",style:{display:"grid",gap:10,padding:14,borderRadius:10,border:`1px solid ${C.f.line}`,background:"#141414",fontSize:13,lineHeight:1.45},children:[(0,y.jsx)("span",{style:{color:"#c9d0db"},children:ew.notConnected.offer}),(0,y.jsx)(ee,{endpoint:`/api/runs/${e}/connect-github`,onConnected:Z}),(0,y.jsx)("button",{type:"button","data-testid":"skip-github",disabled:J,onClick:()=>void ei(),style:{...dx(null),cursor:J?"wait":"pointer"},children:J?ew.notConnected.skipping:ew.notConnected.skip}),et&&(0,y.jsx)("span",{role:"alert",style:{color:B.f.failed},children:et})]}):eb?(0,y.jsx)("div",{"data-testid":"github-skipped",style:{fontSize:12.5,color:B.f.dim,lineHeight:1.45},children:ew.notConnected.skipped}):(0,y.jsxs)(y.Fragment,{children:[null!==X&&!H&&(0,y.jsxs)("div",{role:"status","data-testid":"connected",style:{display:"flex",alignItems:"center",gap:8,padding:"9px 11px",borderRadius:8,border:`1px solid ${B.f.tint("passed",.5)}`,background:B.f.tint("passed",.1),fontSize:13,color:"#d7f5e0",lineHeight:1.4},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:B.f.passed,strokeWidth:"2.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:(0,y.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})}),ew.connect.done(X)]}),(0,y.jsx)(da,{runId:e,button:dg,onState:Y,canOpen:!l,onRecorded:s})]}),!F&&!l&&(0,y.jsx)(dn,{runId:e,button:dx})]}),u.delivered&&(0,y.jsx)("div",{style:{fontSize:12.5,color:"#b9dcc5",lineHeight:1.4},children:ew.done(u.files.length)})]})]}),(ex||eI)&&!V&&!ed&&(0,y.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,y.jsxs)("button",{type:"button","aria-expanded":M,onClick:()=>E(e=>!e),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderRadius:8,border:`1px solid ${C.f.line}`,background:C.f.card,color:"#d6dce6",fontSize:12.5,fontWeight:600,cursor:"pointer"},children:[ew.moreOptions,(0,y.jsx)("span",{"aria-hidden":"true",style:{display:"inline-block",transform:M?"rotate(180deg)":"none",transition:"transform 150ms ease-out"},children:"▾"})]}),M&&(0,y.jsxs)("div",{"data-testid":"more-options",style:{display:"grid",gap:8},children:[ex&&(0,y.jsxs)("dl",{"data-testid":"kept-facts",style:{...dh,margin:0,gridTemplateColumns:"auto minmax(0, 1fr)",columnGap:12,rowGap:6,fontSize:12},children:[(0,y.jsx)("dt",{style:{color:B.f.dim},children:ew.branchLabel}),(0,y.jsx)("dd",{style:{margin:0,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",color:"#d6dce6",overflowWrap:"anywhere"},children:u.branch}),(0,y.jsx)("dt",{style:{color:B.f.dim},children:ew.commitLabel}),(0,y.jsx)("dd",{style:{margin:0,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",color:"#d6dce6"},children:(u.commit??"").slice(0,7)})]}),ex&&!l&&(ez||!F)&&(0,y.jsx)("div",{style:dh,children:ez?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{"data-testid":"on-branch",style:{fontSize:12,color:B.f.passed,lineHeight:1.4,overflowWrap:"anywhere"},children:["✓ ",ew.onBranch(u.branch)]}),u.returnTo&&(0,y.jsxs)("button",{type:"button",disabled:null!==z,onClick:()=>void eh("back"),style:dx(z),children:["back"===z?(0,y.jsx)($.m,{blockId:"back",size:16}):"←"," ",ew.backButton(u.returnTo)]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("button",{type:"button",disabled:null!==z,onClick:()=>void eh("switch"),style:dx(z),children:["switch"===z?(0,y.jsx)($.m,{blockId:"switch",size:16}):(0,y.jsx)("span",{"aria-hidden":"true",children:"⇄"})," ",ew.switchButton]}),(0,y.jsx)("div",{style:{fontSize:11.5,color:B.f.dim,lineHeight:1.4},children:ew.switchWhat})]})}),eM&&(0,y.jsxs)("div",{style:dh,children:[(0,y.jsxs)("button",{type:"button",disabled:null!==z,onClick:()=>void eh("push"),style:dx(z),children:["push"===z?(0,y.jsx)($.m,{blockId:"push",size:16}):"↑"," ",ew.pushOnly]}),(0,y.jsx)("div",{style:{fontSize:11.5,color:B.f.dim,lineHeight:1.4},children:ew.pushOnlyWhat})]}),eI&&(0,y.jsxs)("div",{style:dh,children:[(0,y.jsxs)("button",{type:"button",disabled:null!==z,onClick:()=>void eh("apply"),style:dx(z),children:["apply"===z?(0,y.jsx)($.m,{blockId:"apply",size:16}):"⤵"," ",ew.applyButton]}),(0,y.jsx)("div",{style:{fontSize:11.5,color:B.f.dim,lineHeight:1.4},children:ew.applyWhat})]})]})]}),!F&&!D&&!l&&!ed&&(0,y.jsx)(dc,{runId:e,prOpen:P?.pr?.state==="open",onThrown:e=>{g(e),s?.()}}),(0,y.jsxs)("div",{"data-testid":"follow-up-box",style:{display:V||q?"none":"grid",gap:6,gridTemplateColumns:"minmax(0, 1fr)",paddingTop:10,borderTop:`1px solid ${B.f.lineSoft}`,...c?{marginTop:"auto",marginInline:-20,padding:"20px 20px 0",gap:10,borderTop:`1px solid ${C.f.line}`}:null},children:[(0,y.jsx)("div",{style:{fontSize:12,color:B.f.dim},children:F?b.B.followUp.hintPublished:b.B.followUp.hint}),r({label:b.B.followUp.start,name:F?b.B.followUp.titleContinue:b.B.followUp.titleAdjust,onSend:()=>void eg(),enabled:null===z&&!i&&""!==t.trim(),busy:"follow"===z})]}),W&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12.5,color:B.f.failed,lineHeight:1.4},children:W})]})}function dp({current:e,passedByApp:t,docked:n=!1}){let i=t?[b.B.delivery.passedStep,...b.B.delivery.steps.slice(1)]:b.B.delivery.steps,r=n?26:18;return(0,y.jsx)("ol",{"data-testid":"steps","aria-label":b.B.delivery.stepsLabel,style:{listStyle:"none",margin:0,padding:0,display:"flex",alignItems:n?"flex-start":"center",gap:4*!n},children:i.map((t,o)=>{let a=o<e||4===e,l=o===e&&4!==e,s=a?B.f.passed:l?"#d6dce6":B.f.skipped,d=(0,y.jsx)("span",{"aria-hidden":"true",style:{position:"relative",width:r,height:r,flex:"none",borderRadius:"50%",display:"grid",placeItems:"center",fontSize:n?13:10,fontWeight:900,background:a?B.f.passed:C.f.bg,color:a?"#07110a":s,border:`1.5px solid ${a?B.f.passed:s}`},children:a?"✓":o+1}),c=a&&o+1<=e?B.f.tint("passed",.6):C.f.line;return n?(0,y.jsxs)("li",{"aria-current":l?"step":void 0,style:{position:"relative",flex:"1 1 0",minWidth:0,display:"grid",justifyItems:"center",gap:8},children:[o<i.length-1&&(0,y.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",top:r/2-1,left:"50%",width:"100%",height:1.5,background:c}}),d,(0,y.jsx)("span",{style:{fontSize:12.5,fontWeight:l?800:500,color:a?C.f.quiet:s,textAlign:"center",lineHeight:1.3,textWrap:"balance"},children:t})]},t):(0,y.jsxs)("li",{"aria-current":l?"step":void 0,style:{display:"flex",alignItems:"center",gap:4,flex:o<i.length-1?"1 1 auto":"none",minWidth:0},children:[d,(0,y.jsx)("span",{style:{fontSize:11.5,fontWeight:l?800:600,color:s,whiteSpace:"nowrap"},children:t}),o<i.length-1&&(0,y.jsx)("span",{"aria-hidden":"true",style:{flex:1,height:1.5,minWidth:8,background:c}})]},t)})})}function df(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M8 2.5v8M4.5 7 8 10.5 11.5 7M2.5 10v2.5a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1V10"})})}let dh={display:"grid",gap:6,padding:10,borderRadius:8,border:`1px solid ${C.f.line}`,background:"#141414"};function dg(e){return{padding:"9px 12px",borderRadius:8,border:`1px solid ${B.f.passed}`,background:B.f.passed,color:"#07110a",fontWeight:700,cursor:e?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8}}function dx(e){return{padding:"8px 12px",borderRadius:8,border:`1px solid ${B.f.tint("passed",.6)}`,background:"transparent",color:"#b9dcc5",fontWeight:700,cursor:e?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8}}function dy(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M8 1.5 9.4 6.6 14.5 8 9.4 9.4 8 14.5 6.6 9.4 1.5 8 6.6 6.6 8 1.5Z"})})}let dm={idle:{tone:"running",from:"#141b27",to:"#10151e",strength:.35},working:{tone:"running",from:"#121a29",to:"#0f1520",strength:.5},plan:{tone:"waiting",from:"#1f1a10",to:"#16130d",strength:.55},question:{tone:"waiting",from:"#1f1a10",to:"#16130d",strength:.55},waiting:{tone:"waiting",from:"#1f1a10",to:"#16130d",strength:.55},done:{tone:"passed",from:"#0f1f16",to:"#0c1711",strength:.5},failed:{tone:"failed",from:"#211214",to:"#170e10",strength:.5}},db=(0,m.forwardRef)(function({docked:e=!1,direct:t=!1,planMeasure:n,stopForMe:i=!1,onStopForMe:r,onSeeChanges:o,record:a=null,recordFailed:l=!1,recordMark:s=0,recordReadMark:d=0,askedId:c=null,onRecordChanged:u,showFindings:p=!1,notice:f,mode:h,runId:g,risk:x,text:v,onText:w,images:j,onImages:k,onRun:S,canRun:z,onFollowUp:I,onNewTask:M,onSent:E,startOptions:_=[],startFrom:R,onStartFrom:N,onShipState:T,loading:W=!1,taskName:L,onTaskName:P,away:A=null,onRecorded:H,failureActions:F,onCanContinue:O},D){let q=dm[h],[V,Y]=lX(lD,!1),X=e&&V,[U,Z]=(0,m.useState)(!1),K=e=>{Z(!0),Y(e)},G="plan"===h?b.B.plan.replanLabel:"waiting"===h?b.B.gate.reasonLabel:"done"===h?b.B.followUp.title:"failed"===h?b.B.failure.label:b.B.run.requestLabel,J="plan"===h?b.B.plan.replanPlaceholder:"waiting"===h?b.B.gate.reasonPlaceholder:"done"===h?b.B.followUp.placeholder:"failed"===h?b.B.failure.placeholder:b.B.run.requestPlaceholder,Q=e=>(0,y.jsx)(sW,{send:e,minHeight:"waiting"===h||"done"===h||"plan"===h||"failed"===h?96:void 0,inputId:sp,label:e?.name??G,placeholder:J,text:v,onText:w,images:j,onImages:k,onSubmit:"idle"===h&&z?S:void 0});return(0,y.jsxs)(y.Fragment,{children:[X&&(0,y.jsx)(dj,{mode:W?"idle":h,glide:U,onOpen:()=>K(!1)}),(0,y.jsx)("section",{ref:D,className:U&&!X?"factory-from-right":void 0,tabIndex:-1,"data-testid":"command-card","data-mode":h,"aria-label":"plan"===h?b.B.plan.title:"question"===h?b.B.question.title:"waiting"===h?b.B.gate.title:"done"===h?b.B.delivery.title:b.B.sidebar.runTitle,style:{position:"absolute",right:16,bottom:16,zIndex:5,width:460,maxWidth:"calc(100% - 32px)",maxHeight:"calc(100% - 72px)",overflowY:"auto",overflowX:"hidden",background:`linear-gradient(180deg, ${q.from} 0%, ${q.to} 100%)`,border:`1px solid ${B.f.tint(q.tone,q.strength)}`,borderRadius:14,boxShadow:`0 0 0 1px ${B.f.tint(q.tone,.15)}, 0 0 30px ${B.f.tint(q.tone,"idle"===h?.06:.16)}, 0 18px 40px rgba(0,0,0,0.55)`,padding:16,display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:12,outline:"none",...e?{top:0,right:0,bottom:0,maxWidth:"100%",maxHeight:"none",padding:"20px 20px 24px",display:"flex",flexDirection:"column",gap:16,zoom:1.08,background:C.f.bg,border:"none",borderLeft:`1px solid ${C.f.line}`,borderRadius:0,boxShadow:"none"}:null,...X?{display:"none"}:null},children:(0,y.jsxs)(sR.Provider,{value:e,children:[e&&(0,y.jsx)("button",{type:"button","data-testid":"panel-fold","aria-label":b.B.panel.fold,title:b.B.panel.fold,onClick:()=>K(!0),style:{...dv,alignSelf:"flex-start",margin:"-10px 0 -10px -10px"},children:(0,y.jsx)(l9,{name:"expand"})}),W&&(0,y.jsx)(st,{}),!W&&"idle"===h&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:b.B.sidebar.runTitle}),t&&(0,y.jsx)("div",{"data-testid":"direct-start-hint",role:"note",style:{padding:"9px 12px",borderRadius:10,border:`1px solid ${B.f.tint("passed",.5)}`,color:B.f.passed,fontSize:13,lineHeight:1.45},children:b.B.direct.startHint}),1===_.length&&(0,y.jsx)("div",{"data-testid":"starts-from",style:{fontSize:12,color:B.f.dim,marginTop:-6,overflowWrap:"anywhere"},children:b.B.delivery.startsFrom(_[0])}),_.length>1&&(0,y.jsxs)("label",{"data-testid":"starts-from",style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:B.f.dim,marginTop:-6},children:[b.B.delivery.startFromLabel,(0,y.jsx)("select",{value:R??_[0],onChange:e=>N?.(e.target.value),style:{flex:1,minWidth:0,padding:"4px 6px",background:B.f.bg,color:"inherit",border:`1px solid ${B.f.border}`,borderRadius:6,fontSize:12},children:_.map((e,t)=>(0,y.jsx)("option",{value:e,children:0===t?b.B.delivery.mainOption(e):b.B.delivery.currentOption(e)},e))})]}),P&&(0,y.jsxs)("label",{style:{display:"grid",gap:4,fontSize:12.5,fontWeight:600,color:B.f.dim},children:[(0,y.jsxs)("span",{children:[b.B.title.label," ",(0,y.jsx)("span",{style:{fontWeight:400},children:b.B.title.optional})]}),(0,y.jsx)("input",{value:L??"",maxLength:60,placeholder:b.B.title.placeholder,onChange:e=>P(e.target.value),style:{font:"inherit",fontSize:13.5,fontWeight:400,padding:"7px 10px",background:B.f.card,color:"#e6e9ef",border:`1px solid ${B.f.border}`,borderRadius:8}})]}),r&&(0,y.jsx)(dk,{checked:i,onChange:r}),Q({label:b.B.run.send,onSend:S,enabled:z})]}),!W&&"working"===h&&(0,y.jsxs)("div",{role:"status",style:{display:"flex",alignItems:"center",gap:10,fontSize:14,fontWeight:600,color:"#cfe0ff"},children:[(0,y.jsx)($.m,{blockId:"card",size:20}),b.B.card.working]}),!W&&"working"===h&&f&&(0,y.jsx)(dS,{notice:f}),!W&&"plan"===h&&g&&(0,y.jsx)(s7,{measure:n,away:A,runId:g,note:v,composer:Q,onSent:E}),!W&&"question"===h&&g&&(0,y.jsx)(s3,{runId:g,record:a,failed:l,mark:s,readMark:d,askedId:c,onChanged:()=>u?.()}),!W&&"waiting"===h&&g&&(0,y.jsx)(sZ,{findings:p?a?.findings:void 0,touched:a?.touched,away:A,runId:g,risk:x,note:v,imageIds:sN(j),imagesBusy:sT(j),composer:Q,onSent:E,onSeeChanges:o}),!W&&"done"===h&&g&&(0,y.jsx)(du,{away:A,onRecorded:H,onNewTask:M,onShipState:T,runId:g,note:v,imageIds:sN(j),imagesBusy:sT(j),composer:Q,onFollowUp:e=>{E(),I(e)}}),!W&&"failed"===h&&g&&(0,y.jsx)(sz,{runId:g,note:v,imageIds:sN(j),imagesBusy:sT(j),composer:Q,onText:w,actionsRef:F,onCanContinue:O,onFollowUp:e=>{E(),I(e)}})]})})]})}),dv={width:36,height:36,display:"grid",placeItems:"center",background:"transparent",color:B.f.dim,border:"1px solid transparent",borderRadius:8,cursor:"pointer"},dw={idle:C.f.quiet,working:B.f.passed,plan:B.f.waiting,question:B.f.waiting,waiting:B.f.waiting,done:B.f.passed,failed:B.f.failed};function dj({mode:e,glide:t,onOpen:n}){let i=dw[e],r="plan"===e||"question"===e||"waiting"===e,o="working"===e?(0,y.jsx)($.m,{blockId:"panel-rail",size:20}):(0,y.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",...{fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round"},children:["done"===e&&(0,y.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"}),"failed"===e&&(0,y.jsx)("path",{d:"M6 6l12 12M18 6L6 18"}),r&&(0,y.jsx)("path",{d:"M12 5v9M12 18.5v.5"}),"idle"===e&&(0,y.jsx)("path",{d:"M4 20h4L19 9l-4-4L4 16v4zM13.5 6.5l4 4"})]});return(0,y.jsxs)("button",{type:"button","data-testid":"panel-rail",className:t?"factory-from-right":void 0,"data-mode":e,"aria-label":`${b.B.panel.open}. ${b.B.panel.state[e]}`,title:`${b.B.panel.state[e]} \xb7 ${b.B.panel.open}`,onClick:n,style:{position:"absolute",top:0,right:0,bottom:0,zIndex:5,width:56,display:"flex",flexDirection:"column",alignItems:"center",gap:10,padding:"10px 0",border:"none",borderLeft:`1px solid ${C.f.line}`,background:C.f.bg,color:C.f.quiet,cursor:"pointer"},children:[(0,y.jsx)("span",{style:dv,children:(0,y.jsx)(l9,{name:"collapse"})}),(0,y.jsx)("span",{role:"working"===e?"status":void 0,style:{width:36,height:36,borderRadius:10,display:"grid",placeItems:"center",color:i,background:B.f.tint("working"===e?"passed":r?"waiting":"done"===e?"passed":"failed"===e?"failed":"skipped",.16),border:`1px solid ${r?B.f.waiting:C.f.line}`},children:o}),(0,y.jsx)("span",{style:{writingMode:"vertical-rl",fontSize:12,letterSpacing:.3,color:r?B.f.waiting:C.f.quiet,fontWeight:r?700:500},children:b.B.panel.state[e]})]})}function dk({checked:e,onChange:t}){let[n,i]=(0,m.useState)(!1),r="stop-for-me-why";return(0,y.jsxs)("div",{"data-testid":"stop-for-me",style:{display:"grid",gap:4,minWidth:0},children:[(0,y.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 12px"},children:[(0,y.jsxs)("label",{style:{display:"inline-flex",alignItems:"center",gap:8,fontSize:13,color:"#d6dce6",cursor:"pointer"},children:[(0,y.jsx)("input",{type:"checkbox",checked:e,onChange:e=>t(e.target.checked)}),b.B.composer.stopForMe]}),(0,y.jsx)("button",{type:"button","aria-expanded":n,"aria-controls":r,onClick:()=>i(e=>!e),style:{padding:0,background:"none",border:"none",color:"#9cc2ff",fontSize:12.5,cursor:"pointer",textDecoration:"underline"},children:b.B.composer.stopForMeWhat})]}),n&&(0,y.jsx)("span",{id:r,style:{fontSize:12.5,lineHeight:1.45,color:B.f.dim,overflowWrap:"anywhere"},children:b.B.composer.stopForMeWhy})]})}function dS({notice:e}){let[t,n]=(0,m.useState)(!1),i={fontSize:12,lineHeight:1.4,color:B.f.dim,margin:0};return"ask"===e.offer?(0,y.jsx)("button",{type:"button",onClick:()=>{n(!0),e.onAllow()},style:{justifySelf:"start",textAlign:"left",padding:"5px 10px",borderRadius:8,border:`1px solid ${B.f.border}`,background:"transparent",color:"inherit",fontSize:12.5,cursor:"pointer"},children:b.B.tell.offer}):t&&"on"===e.offer?(0,y.jsx)("p",{style:i,children:b.B.tell.on}):t&&"blocked"===e.offer?(0,y.jsx)("p",{style:i,children:b.B.tell.blocked}):null}let dC=new Set(["node.question_asked","node.question_answered","node.findings_checked","node.finding_resolved"]);function dB(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if("node.question_answered"===n.type)break;if("node.question_asked"===n.type){let e=n.payload?.questionId;return"string"==typeof e?e:null}}return null}let dz=b.B.details,dI="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",dM={scrollbarWidth:"thin",scrollbarColor:`${B.f.skipped} transparent`},d$=["input","plan","build","tests","review","approve","human","ship"],dE="min(48vh, 440px)";function d_(e){if(e<1e3)return dz.underASecond;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function dR(e){if(!e)return dz.none;let t=new Date(e);return Number.isNaN(t.getTime())?dz.none:t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function dN({text:e}){return(0,y.jsx)(y.Fragment,{children:e.replace(/\*\*/g,"").split(/\n{2,}/).map((e,t)=>(0,y.jsx)("p",{style:{margin:0},children:e.split("`").map((e,t)=>t%2==1?(0,y.jsx)("code",{style:{padding:"1px 6px",borderRadius:5,background:C.f.bg,border:`1px solid ${C.f.line}`,fontFamily:dI,fontSize:"0.86em",color:C.f.text},children:e},t):e)},t))})}function dT({path:e,size:t=16}){return(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:e})}let dW={clock:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,y.jsx)("path",{d:"M12 7v5l3 2"})]}),play:(0,y.jsx)("path",{d:"M8 5.5v13l10-6.5z"}),flag:(0,y.jsx)("path",{d:"M6 21V4h11l-2 4 2 4H6"}),spark:(0,y.jsx)("path",{d:"M12 3l1.9 5.6L19.5 10l-5.6 1.4L12 17l-1.9-5.6L4.5 10l5.6-1.4z"}),chip:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("rect",{x:"7",y:"7",width:"10",height:"10",rx:"2"}),(0,y.jsx)("path",{d:"M10 3v4M14 3v4M10 17v4M14 17v4M3 10h4M3 14h4M17 10h4M17 14h4"})]}),repeat:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("path",{d:"M20 11a8 8 0 1 0-2.3 5.7"}),(0,y.jsx)("path",{d:"M20 4v7h-7"})]}),check:(0,y.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"}),cross:(0,y.jsx)("path",{d:"M6 6l12 12M18 6L6 18"}),chevron:(0,y.jsx)("path",{d:"M9 6l6 6-6 6"}),enlarge:(0,y.jsx)("path",{d:"M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5"})};function dL({icon:e,label:t,value:n,help:i}){return(0,y.jsxs)("div",{style:{display:"grid",gap:5,padding:"13px 15px",borderRadius:12,background:"#141414",border:`1px solid ${C.f.line}`,minWidth:0},children:[(0,y.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:7,fontSize:12.5,color:C.f.quiet},children:[(0,y.jsx)(dT,{path:e,size:14})," ",t]}),(0,y.jsx)("span",{style:{fontSize:19,fontWeight:700,color:C.f.text,overflowWrap:"anywhere"},children:n}),i&&(0,y.jsx)("span",{style:{fontSize:11.5,color:B.f.skipped},children:i})]})}function dP({title:e,help:t,children:n}){return(0,y.jsxs)("section",{style:{display:"grid",gap:10},children:[(0,y.jsxs)("div",{style:{display:"grid",gap:3},children:[(0,y.jsx)("strong",{className:"factory-display",style:{fontSize:17},children:e}),t&&(0,y.jsx)("span",{style:{fontSize:13,color:C.f.quiet},children:t})]}),n]})}function dA({measure:e,startedOnItsOwn:t}){return(0,y.jsxs)(y.Fragment,{children:[e.reasons.length>0&&(0,y.jsx)(dP,{title:t?b.B.plan.whyStarted:b.B.plan.whyStopped,children:(0,y.jsx)("ul",{style:{margin:0,paddingLeft:20,display:"grid",gap:6,fontSize:14.5,lineHeight:1.5,color:"#d6dce6",overflowWrap:"anywhere"},children:e.reasons.map((e,t)=>(0,y.jsx)("li",{children:e},t))})}),(0,y.jsx)(dP,{title:b.B.plan.expects,children:e.entries.length>0?(0,y.jsx)("ul",{style:{margin:0,paddingLeft:20,display:"grid",gap:4,fontFamily:dI,fontSize:13,color:"#d6dce6",overflowWrap:"anywhere"},children:e.entries.map((e,t)=>(0,y.jsx)("li",{children:e},t))}):(0,y.jsx)("span",{style:{color:C.f.quiet},children:b.B.plan.noneExpected})})]})}function dH({c:e}){let[t,n]=(0,m.useState)(!1),i=0===e.exitCode;return(0,y.jsxs)("div",{style:{display:"grid",gap:8,padding:"11px 13px",borderRadius:10,background:"#141414",border:`1px solid ${i?C.f.line:B.f.tint("failed",.5)}`},children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,y.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"3px 10px",borderRadius:999,background:B.f.tint(i?"passed":"failed",.16),color:i?B.f.passed:B.f.failed,fontSize:12.5,fontWeight:700},children:[(0,y.jsx)(dT,{path:i?dW.check:dW.cross,size:13})," ",i?dz.commandPassed:dz.commandFailed]}),(0,y.jsx)("code",{style:{fontFamily:dI,fontSize:13,color:"#e6e9ef"},children:e.command}),null!==e.durationMs&&(0,y.jsx)("span",{style:{marginLeft:"auto",fontSize:13,color:C.f.quiet},children:d_(e.durationMs)})]}),!i&&(0,y.jsx)("span",{style:{fontSize:13,color:B.f.failed},children:b.B.failure.ended(e.exitCode,e.signal)}),e.output&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("button",{type:"button","aria-expanded":t,onClick:()=>n(e=>!e),style:{justifySelf:"start",display:"inline-flex",alignItems:"center",gap:5,padding:0,background:"none",border:"none",color:C.f.green,fontSize:13,cursor:"pointer"},children:[(0,y.jsx)("span",{style:{display:"inline-flex",transform:t?"rotate(90deg)":"none"},children:(0,y.jsx)(dT,{path:dW.chevron,size:13})}),t?dz.hideOutput:dz.showOutput]}),t&&(0,y.jsx)("pre",{style:{margin:0,maxHeight:280,overflow:"auto",padding:12,borderRadius:8,background:C.f.bg,border:`1px solid ${C.f.line}`,fontFamily:dI,fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",...dM},children:e.output})]})]})}function dF({runId:e}){let{state:t}=(0,eI.C)(e,!1);return t&&"unneeded"!==t.status?(0,y.jsx)(dP,{title:dz.pictures,help:dz.picturesHelp,children:(0,y.jsx)(dJ,{runId:e,state:t})}):null}function dO({runId:e,name:t,done:n}){let{state:i,take:r,error:o}=(0,eI.C)(e,n),[a,l]=(0,m.useState)(!1),[s,d]=(0,m.useState)(!1);if(!i)return(0,y.jsx)(l7,{width:300,height:96,radius:8});if(!n&&"ready"!==i.status&&"working"!==i.status)return(0,y.jsx)("span",{style:{fontSize:13,color:B.f.skipped},children:dz.historyWhenDone});if("unneeded"===i.status)return(0,y.jsx)("span",{style:{fontSize:13,color:B.f.skipped},children:dz.historyNothingToSee});if("working"===i.status||s&&"none"===i.status&&!o)return(0,y.jsxs)("span",{role:"status",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:C.f.quiet},children:[(0,y.jsx)($.m,{blockId:`pictures-${e}`,size:14})," ",i.message??dz.historyTaking]});if("ready"!==i.status||0===i.shots.length)return(0,y.jsxs)("span",{style:{display:"grid",gap:6,justifyItems:"start"},children:[(0,y.jsx)("button",{type:"button",onClick:()=>{d(!0),r()},style:{padding:"6px 12px",borderRadius:8,border:`1px solid ${C.f.line}`,background:C.f.bg,color:C.f.text,fontSize:13,fontWeight:600,cursor:"pointer"},children:dz.historyTake}),(o??("failed"===i.status?i.message:null))&&(0,y.jsx)("span",{style:{fontSize:12.5,color:B.f.failed},children:o??i.message})]});let c=["before","after"].filter(e=>i.shots.includes(`${e}-desktop`));return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("button",{type:"button","data-testid":"history-thumbs","aria-label":dz.historyPicturesOf(t),onClick:()=>l(!0),style:{display:"flex",gap:10,padding:0,border:"none",background:"none",cursor:"zoom-in",justifySelf:"start"},children:c.map(t=>(0,y.jsxs)("span",{style:{display:"grid",gap:4,justifyItems:"start"},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:"before"===t?C.f.quiet:B.f.passed},children:b.B.snapshots[t]}),(0,y.jsx)("img",{src:(0,eI.h)(e,`${t}-desktop`,i),alt:"",style:{display:"block",width:"min(var(--thumb-w, 150px), 34vw)",height:"auto",aspectRatio:"25 / 16",objectFit:"cover",objectPosition:"top",borderRadius:8,border:`1px solid ${C.f.line}`}})]},t))}),a&&(0,oi.createPortal)((0,y.jsx)("div",{onClick:()=>l(!1),style:{position:"fixed",inset:0,zIndex:110,display:"grid",gridTemplateRows:"minmax(0, 1fr)",placeItems:"center",background:"rgba(5, 7, 11, 0.8)"},children:(0,y.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":dz.historyPicturesOf(t),onClick:e=>e.stopPropagation(),style:{width:"min(1100px, calc(100% - 32px))",maxHeight:"calc(100% - 64px)",overflowY:"auto",display:"grid",gap:14,padding:22,background:C.f.card,border:`1px solid ${C.f.line}`,borderRadius:14,...dM},children:[(0,y.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:12},children:[(0,y.jsx)("strong",{className:"factory-display",style:{fontSize:18},children:dz.historyPicturesOf(t)}),(0,y.jsx)("button",{type:"button","aria-label":dz.close,onClick:()=>l(!1),style:{background:"none",border:"none",color:B.f.skipped,cursor:"pointer",fontSize:18},children:"✕"})]}),(0,y.jsx)(dJ,{runId:e,state:i})]})}),document.body)]})}let dD={position:"relative",display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:14,paddingBottom:16},dq={position:"absolute",left:12,top:26,bottom:0,width:2,background:C.f.line},dV={display:"grid",gap:10,minWidth:0,padding:"12px 14px",borderRadius:12,border:`1px solid ${C.f.line}`,background:"#141414"},dY={fontSize:11,fontWeight:800,letterSpacing:"0.1em",textTransform:"uppercase",color:C.f.quiet},dX=e=>new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),dU=({colour:e})=>(0,y.jsx)("span",{className:"factory-history-dot",style:{width:26,height:26,borderRadius:999,display:"grid",placeItems:"center",background:"#141414",border:`2px solid ${e}`,color:e,fontSize:12.5,fontWeight:800,zIndex:1}});function dZ({files:e}){return 0===e.length?null:(0,y.jsxs)("div",{style:{display:"grid",gap:4,fontSize:12.5,paddingTop:8,borderTop:`1px solid ${C.f.line}`},children:[(0,y.jsx)("span",{style:{color:C.f.quiet,fontWeight:700},children:dz.historyFiles(e.length)}),(0,y.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[e.slice(0,6).map(e=>(0,y.jsx)("code",{style:{padding:"2px 7px",borderRadius:6,background:C.f.bg,border:`1px solid ${C.f.line}`,color:"#c9d0db",fontSize:12},children:e},e)),e.length>6&&(0,y.jsx)("span",{style:{color:B.f.skipped,alignSelf:"center"},children:dz.historyMoreFiles(e.length-6)})]})]})}function dK({t:e,more:t}){let{state:n,versions:i}=(0,eI.w)(e.runId),r={margin:0,fontSize:14.5,lineHeight:1.5,color:"#e6e9ef",overflowWrap:"anywhere"},o=(0,y.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px",marginLeft:"auto"},children:[e.here&&(0,y.jsx)("span",{style:{padding:"2px 9px",borderRadius:999,background:B.f.tint("passed",.18),color:B.f.passed,fontSize:11.5,fontWeight:800},children:dz.historyHere}),(0,y.jsx)("span",{style:{fontSize:12.5,color:B.f.skipped},children:dX(e.at)})]});if(n&&i.length>0)return(0,y.jsx)(y.Fragment,{children:i.map((a,l)=>(0,y.jsxs)("li",{"data-testid":"history-step",style:dD,children:[(t||l<i.length-1)&&(0,y.jsx)("span",{"aria-hidden":"true",style:dq}),(0,y.jsx)(dU,{colour:B.f.passed}),(0,y.jsxs)("div",{style:dV,children:[(0,y.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px"},children:[(0,y.jsx)("span",{style:dY,children:0===l?dz.historyAsked:dz.historyAskedChange}),0===l&&o]}),(0,y.jsx)("p",{style:r,children:a.asked}),(0,y.jsx)(eI.R,{runId:e.runId,state:n,versions:i,index:l}),l===i.length-1&&(0,y.jsx)(dZ,{files:e.files})]})]},`${e.runId}-${a.change}`))});let a=e.request.replace(/\s+/g," ").trim().startsWith(e.name)?null:e.name;return(0,y.jsxs)("li",{"data-testid":"history-step",style:dD,children:[t&&(0,y.jsx)("span",{"aria-hidden":"true",style:dq}),(0,y.jsx)(dU,{colour:B.f.passed}),(0,y.jsxs)("div",{style:dV,children:[(0,y.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px"},children:[(0,y.jsx)("span",{style:dY,children:dz.historyAsked}),o]}),a&&(0,y.jsx)("strong",{style:{fontSize:15,color:"#e6e9ef",overflowWrap:"anywhere"},children:a}),(0,y.jsx)("p",{style:{...r,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},title:e.request,children:e.request}),e.asks&&e.asks.length>0&&(0,y.jsxs)("div",{"data-testid":"history-asks",style:{display:"grid",gap:4,fontSize:13.5,color:"#c9d0db"},children:[(0,y.jsx)("span",{style:dY,children:dz.historyAsks}),(0,y.jsx)("ol",{start:2,style:{margin:0,paddingLeft:20,display:"grid",gap:3,lineHeight:1.5},children:e.asks.map((e,t)=>(0,y.jsx)("li",{style:{overflowWrap:"anywhere"},children:e},t))})]}),e.look?(0,y.jsx)(dO,{runId:e.runId,name:e.name,done:e.done}):(0,y.jsx)("span",{style:{fontSize:13,color:B.f.skipped},children:dz.historyNothingToSee}),(0,y.jsx)(dZ,{files:e.files})]})]})}function dG({tasks:e,github:t}){return(0,y.jsx)(dP,{title:dz.history,help:dz.historyHelp,children:(0,y.jsxs)("ol",{"data-testid":"details-history",className:"factory-history",style:{listStyle:"none",margin:0,padding:0},children:[e.map((n,i)=>(0,y.jsx)(dK,{t:n,more:i<e.length-1||!!t},n.runId)),t&&(0,y.jsxs)("li",{"data-testid":"history-github",style:{...dD,paddingBottom:0},children:[(0,y.jsx)(dU,{colour:t.published?B.f.passed:B.f.waiting}),(0,y.jsxs)("div",{style:{...dV,gap:6},children:[(0,y.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px",minHeight:26},children:[(0,y.jsx)("strong",{style:{fontSize:15,color:"#e6e9ef"},children:dz.historyGithub}),(0,y.jsx)("span",{style:{padding:"2px 9px",borderRadius:999,background:B.f.tint(t.published?"passed":"waiting",.18),color:t.published?B.f.passed:B.f.waiting,fontSize:11.5,fontWeight:800},children:t.published?dz.historyPublished:dz.historyWaiting}),(0,y.jsx)("span",{style:{fontSize:12.5,color:B.f.skipped},children:dX(t.at)})]}),(0,y.jsxs)("span",{style:{fontSize:13,color:C.f.quiet,overflowWrap:"anywhere"},children:[dz.historyBranch," ",(0,y.jsx)("code",{style:{color:"#c9d0db"},children:t.branch})]}),t.pr&&(0,y.jsxs)("a",{href:t.pr.url,target:"_blank",rel:"noreferrer",style:{justifySelf:"start",color:C.f.green,fontSize:13.5},children:[dz.historyPr(t.pr.number)," ↗"]})]})]})]})})}function dJ({runId:e,state:t}){let[n,i]=(0,m.useState)("desktop"),[r,o]=(0,m.useState)(null);if("working"===t.status)return(0,y.jsxs)("span",{role:"status",style:{display:"flex",alignItems:"center",gap:8,color:C.f.quiet},children:[(0,y.jsx)($.m,{blockId:"pictures",size:15})," ",dz.picturesWorking]});if("ready"!==t.status||0===t.shots.length)return(0,y.jsx)("span",{style:{color:C.f.quiet},children:dz.noPictures});let a=n=>(0,eI.h)(e,n,t);return(0,y.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,y.jsxs)("div",{role:"tablist",style:{display:"flex",gap:8},children:[["desktop","mobile"].map(e=>(0,y.jsx)("button",{type:"button",role:"tab","aria-selected":n===e,onClick:()=>i(e),style:{padding:"7px 16px",borderRadius:999,border:`1px solid ${n===e?B.f.running:C.f.line}`,background:n===e?B.f.tint("running",.18):"transparent",color:n===e?C.f.text:C.f.quiet,fontSize:13.5,fontWeight:700,cursor:"pointer"},children:b.B.snapshots[e]},e)),t.route&&(0,y.jsx)("span",{"data-testid":"pictures-page",style:{alignSelf:"center",marginLeft:"auto",fontSize:13,color:C.f.quiet},children:b.B.snapshots.page(t.route,t.opened)})]}),(0,y.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:14,alignItems:"start"},children:["before","after"].map(e=>{let i=`${e}-${n}`,r=`${b.B.snapshots[e]} \xb7 ${b.B.snapshots[n]}`;return(0,y.jsxs)("figure",{style:{margin:0,display:"grid",gap:6},children:[(0,y.jsx)("figcaption",{style:{justifySelf:"start",fontSize:13,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:"before"===e?C.f.quiet:B.f.passed},children:b.B.snapshots[e]}),t.shots.includes(i)?(0,y.jsxs)("button",{type:"button","aria-label":dz.enlarge(r),title:dz.enlargeHint,onClick:()=>o(i),style:{position:"relative",height:dE,boxSizing:"border-box",display:"flex",justifyContent:"center",alignItems:"flex-start",overflow:"hidden",borderRadius:8,background:C.f.bg,border:`1px solid ${C.f.line}`,padding:8,cursor:"zoom-in"},children:[(0,y.jsx)("img",{src:a(i),alt:r,style:{display:"block",maxWidth:"100%",maxHeight:"100%",borderRadius:6,border:`1px solid ${"before"===e?C.f.line:B.f.tint("passed",.5)}`}}),(0,y.jsxs)("span",{style:{position:"absolute",right:10,bottom:10,display:"inline-flex",alignItems:"center",gap:6,padding:"6px 11px",borderRadius:999,background:"rgba(11, 14, 20, 0.88)",border:`1px solid ${C.f.line}`,color:"#e6e9ef",fontSize:12.5,fontWeight:700},children:[(0,y.jsx)(dT,{path:dW.enlarge,size:14})," ",dz.enlargeHint]})]}):(0,y.jsx)("div",{style:{height:dE,display:"grid",placeItems:"center",padding:16,textAlign:"center",borderRadius:8,border:`1px dashed ${C.f.line}`,color:C.f.quiet,fontSize:13.5,lineHeight:1.45},children:"before"===e?dz.noBefore:dz.noAfter})]},e)})}),r&&(0,y.jsx)(dQ,{src:a(r),label:`${b.B.snapshots[r.startsWith("before")?"before":"after"]} \xb7 ${b.B.snapshots[r.endsWith("mobile")?"mobile":"desktop"]}`,phone:r.endsWith("mobile"),onClose:()=>o(null)})]})}function dQ({src:e,label:t,phone:n,onClose:i}){return(0,m.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(e.stopImmediatePropagation(),i())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[i]),(0,oi.createPortal)((0,y.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":t,"data-testid":"large-picture",onClick:e=>{e.stopPropagation(),i()},style:{position:"fixed",inset:0,zIndex:120,display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",background:"rgba(5, 7, 11, 0.94)",cursor:"zoom-out"},children:[(0,y.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",color:"#e6e9ef"},children:[(0,y.jsx)("strong",{className:"factory-display",style:{fontSize:17},children:t}),(0,y.jsxs)("button",{type:"button",onClick:i,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"7px 14px",borderRadius:8,border:`1px solid ${C.f.line}`,background:"#141414",color:"#e6e9ef",fontSize:13.5,fontWeight:700,cursor:"pointer"},children:[(0,y.jsx)(dT,{path:dW.cross,size:14})," ",dz.close]})]}),(0,y.jsx)("div",{style:{overflow:"auto",display:"grid",justifyItems:"center",alignItems:"start",padding:"0 20px 24px",...dM},children:(0,y.jsx)("img",{src:e,alt:t,onClick:e=>e.stopPropagation(),style:{display:"block",width:n?"min(100%, 420px)":void 0,maxWidth:"100%",borderRadius:8,border:`1px solid ${C.f.line}`,cursor:"default"}})})]}),document.body)}function d0({runId:e,blockId:t,label:n,view:i,pr:r,away:o=null,onClose:a,onSeeShip:l,onSettings:s,inline:d=!1}){let[c,u]=(0,m.useState)(void 0),[p,f]=(0,m.useState)(!1),h=i?.state==="running";(0,m.useEffect)(()=>{let n=!0,i=i=>fetch(`/api/runs/${e}/blocks/${encodeURIComponent(t)}`).then(e=>e.ok?e.json():null).then(e=>n&&(e||i)&&u(e)).catch(()=>n&&i&&u(null));i(!0);let r=h?setInterval(()=>void i(!1),4e3):null;return()=>{n=!1,r&&clearInterval(r)}},[e,t,h]),(0,m.useEffect)(()=>{if(d)return;let e=e=>{"Escape"===e.key&&a()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,d]);let g=i?.state??c?.state??"queued",x=B.f[(0,$.Y)(g)],v=c?.kind,w=(i?.summary||c?.summary)??null,j=c?.steps??[],k=p?j:j.slice(-8),S="ship"===v||"human"===v,z="human"===v&&"waiting_approval"!==g&&void 0!==l;return(0,y.jsx)("div",{onClick:d?void 0:a,style:d?void 0:{position:"fixed",inset:0,zIndex:60,display:"grid",gridTemplateRows:"minmax(0, 1fr)",placeItems:"center",background:"rgba(5, 7, 11, 0.7)"},children:(0,y.jsxs)("div",{role:d?"region":"dialog","aria-modal":d?void 0:"true","aria-label":dz.title(n),"data-testid":"block-details",onClick:e=>e.stopPropagation(),style:{width:d?"100%":"min(920px, calc(100% - 32px))",height:d?void 0:"min(780px, calc(100% - 96px))",boxSizing:"border-box",display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",background:C.f.card,border:`1px solid ${C.f.line}`,borderTop:d?`1px solid ${C.f.line}`:`3px solid ${x}`,borderRadius:16,boxShadow:d?"none":"0 24px 60px rgba(0,0,0,0.6)",fontSize:d?15:14.5,...d?{"--thumb-w":"380px","--thumb-h":"236px"}:null},children:[(0,y.jsxs)("header",{style:{display:"flex",alignItems:"center",gap:14,padding:d?"26px 28px 0":"18px 26px",borderBottom:d?"none":`1px solid ${C.f.line}`},children:[v&&d$.includes(v)&&(0,y.jsx)(lU.f,{kind:v,colour:x,size:40}),(0,y.jsxs)("div",{style:{display:"grid",gap:4,flex:1,minWidth:0},children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[(0,y.jsx)("h2",{className:"factory-display",style:{margin:0,fontSize:26},children:n}),c&&(0,y.jsx)("span",{style:{padding:"3px 11px",borderRadius:999,background:`${x}26`,color:x,fontSize:12.5,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase"},children:i?.turn?b.B.direct.yourTurn:b.B.canvas.stateLabel[g]})]}),v&&dz.purpose[v]&&(0,y.jsx)("span",{style:{fontSize:14,color:C.f.quiet},children:dz.purpose[v]})]}),s&&(0,y.jsxs)("button",{type:"button","data-testid":"details-settings",onClick:s,title:dz.settingsHelp,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"7px 12px",borderRadius:8,border:`1px solid ${C.f.line}`,background:"#141414",color:"#c9d0db",cursor:"pointer",font:"inherit",fontSize:13.5,whiteSpace:"nowrap"},children:[(0,y.jsx)(P,{size:14}),dz.settings]}),!d&&(0,y.jsx)("button",{type:"button","aria-label":dz.close,onClick:a,style:{background:"none",border:"none",color:B.f.skipped,cursor:"pointer",fontSize:18},children:"✕"})]}),(0,y.jsxs)("div",{style:{overflowY:"auto",padding:"22px 26px 28px",display:"grid",gap:26,alignContent:"start",...dM},children:[void 0===c&&(0,y.jsxs)("div",{role:"status","aria-label":dz.loading,"data-testid":"details-loading",style:{display:"grid",gap:26},children:[(0,y.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:10},children:[(0,y.jsx)(l7,{height:78,radius:12}),(0,y.jsx)(l7,{height:78,radius:12}),(0,y.jsx)(l7,{height:78,radius:12})]}),(0,y.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,y.jsx)(l7,{width:170,height:18}),(0,y.jsx)(l7,{height:58,radius:12})]}),(0,y.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,y.jsx)(l7,{width:210,height:18}),(0,y.jsx)(l7,{width:"72%",height:13}),(0,y.jsx)(l7,{width:"58%",height:13}),(0,y.jsx)(l7,{width:"64%",height:13})]}),(0,y.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,y.jsx)(l7,{width:150,height:18}),(0,y.jsx)(l7,{height:110,radius:10}),(0,y.jsx)(l7,{height:110,radius:10})]})]}),null===c&&(0,y.jsx)("div",{style:{color:C.f.quiet},children:dz.unreadable}),c&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(170px, 1fr))",gap:10},children:[c.startedAt&&(0,y.jsx)(dL,{icon:dW.clock,label:dz.took,value:null!==c.durationMs?d_(c.durationMs):dz.stillWorking}),c.startedAt&&(0,y.jsx)(dL,{icon:dW.play,label:dz.started,value:dR(c.startedAt)}),c.startedAt&&c.finishedAt&&(0,y.jsx)(dL,{icon:dW.flag,label:dz.finished,value:dR(c.finishedAt)}),null!==c.tokens&&(0,y.jsx)(dL,{icon:dW.spark,label:dz.tokens,value:c.tokens.toLocaleString("en-US"),help:dz.tokensHelp}),c.model&&(0,y.jsx)(dL,{icon:dW.chip,label:dz.model,value:c.model}),c.attempt>1&&(0,y.jsx)(dL,{icon:dW.repeat,label:dz.attempts,value:c.attempt})]}),(0,y.jsxs)(dP,{title:dz.said,help:i?.summaryIsClaim?dz.saidByAi:void 0,children:[(0,y.jsx)("div",{"data-testid":"details-summary",style:{display:"grid",gap:10,padding:"14px 16px",borderRadius:12,background:"#141414",borderLeft:`3px solid ${x}`,fontSize:15.5,lineHeight:1.6,color:"#e6e9ef",overflowWrap:"anywhere"},children:w?(0,y.jsx)(dN,{text:w}):(0,y.jsx)("span",{style:{color:C.f.quiet},children:dz.nothingSaid})}),r&&"ship"===v&&(0,y.jsxs)("a",{href:r.url,target:"_blank",rel:"noreferrer",style:{justifySelf:"start",color:C.f.green,fontSize:14},children:[dz.seeOnGithub(r.number)," ↗"]})]}),c.asked&&c.asked.length>0&&(0,y.jsx)(dP,{title:dz.asked,help:c.asked.length>1?dz.askedHelp:void 0,children:(0,y.jsx)("ol",{"data-testid":"details-asked",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:c.asked.map((e,t)=>(0,y.jsxs)("li",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:12,padding:"12px 14px",borderRadius:10,background:"#141414",border:`1px solid ${C.f.line}`,fontSize:14.5,lineHeight:1.55,color:"#e6e9ef"},children:[(0,y.jsx)("span",{style:{color:B.f.passed,fontWeight:800},children:t+1}),(0,y.jsx)("span",{style:{overflowWrap:"anywhere",whiteSpace:"pre-wrap"},children:e})]},t))})}),z&&(0,y.jsx)(dP,{title:b.B.gate.changesTitle,children:(0,y.jsx)(sQ,{runId:e,away:o,decided:!0})}),z&&(0,y.jsx)(dP,{title:dz.history,children:(0,y.jsxs)("div",{"data-testid":"details-history-on-ship",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"8px 14px",fontSize:14.5,color:"#c9d0db",lineHeight:1.55},children:[(0,y.jsx)("span",{children:dz.historyOnShip}),(0,y.jsxs)("button",{type:"button",onClick:l,style:{padding:"7px 14px",borderRadius:8,border:`1px solid ${C.f.line}`,background:"#141414",color:C.f.green,fontWeight:700,cursor:"pointer",font:"inherit"},children:[dz.historySeeOnShip," →"]})]})}),S&&!z&&((c.history?.length??0)>0?(0,y.jsx)(dG,{tasks:c.history,github:c.github}):(0,y.jsx)(dF,{runId:e})),"human"===v&&"waiting_approval"===g&&(0,y.jsx)(dP,{title:b.B.gate.changesTitle,children:(0,y.jsx)(sQ,{runId:e,risk:i?.risk,away:o})}),(i?.planMeasure??c.planMeasure)&&(0,y.jsx)(dA,{measure:i?.planMeasure??c.planMeasure,startedOnItsOwn:i?.autoStarted===!0}),c.jobs.length>0&&(0,y.jsx)(dP,{title:dz.jobs(c.jobs.length),children:(0,y.jsx)("div",{style:{display:"grid",gap:10},children:c.jobs.map((e,t)=>(0,y.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:12,padding:"12px 14px",borderRadius:10,background:"#141414",border:`1px solid ${C.f.line}`},children:[(0,y.jsx)("span",{style:{width:26,height:26,borderRadius:999,display:"grid",placeItems:"center",background:B.f.tint("waiting",.18),color:B.f.waiting,fontSize:13,fontWeight:800},children:t+1}),(0,y.jsxs)("div",{style:{display:"grid",gap:6},children:[(0,y.jsx)("span",{style:{fontSize:15,fontWeight:600,color:"#e6e9ef",lineHeight:1.45},children:e.title}),e.done.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("span",{style:{fontSize:12,letterSpacing:"0.06em",textTransform:"uppercase",color:B.f.skipped},children:dz.doneWhen}),e.done.map((e,t)=>(0,y.jsxs)("span",{style:{display:"flex",gap:8,fontSize:13.5,lineHeight:1.45,color:"#c9d0db"},children:[(0,y.jsx)("span",{style:{color:B.f.passed,marginTop:2},children:(0,y.jsx)(dT,{path:dW.check,size:13})}),e]},t))]})]})]},t))})}),c.commands.length>0&&(0,y.jsx)(dP,{title:dz.commands,children:(0,y.jsx)("div",{style:{display:"grid",gap:8},children:c.commands.map((e,t)=>(0,y.jsx)(dH,{c:e},t))})}),j.length>0&&(0,y.jsxs)(dP,{title:dz.steps(j.length),help:dz.stepsHelp,children:[(0,y.jsx)("ol",{"data-testid":"details-steps",style:{margin:0,padding:0,listStyle:"none",display:"grid"},children:k.map((e,t)=>{let n=/^Running:?\s/.test(e.text),i=t===k.length-1;return(0,y.jsxs)("li",{style:{display:"grid",gridTemplateColumns:"54px 18px minmax(0, 1fr)",columnGap:10,alignItems:"start"},children:[(0,y.jsx)("span",{style:{paddingTop:2,fontFamily:dI,fontSize:12,color:B.f.skipped,textAlign:"right"},children:function(e,t){let n=e?Date.parse(t)-Date.parse(e):0/0;if(!Number.isFinite(n))return"";let i=Math.max(0,Math.round(n/1e3));return`+${Math.floor(i/60)}:${String(i%60).padStart(2,"0")}`}(c.startedAt,e.at)}),(0,y.jsxs)("span",{"aria-hidden":"true",style:{display:"grid",justifyItems:"center",alignSelf:"stretch",gridTemplateRows:"auto 1fr"},children:[(0,y.jsx)("span",{style:{width:9,height:9,marginTop:6,borderRadius:999,background:i?x:B.f.skipped}}),!i&&(0,y.jsx)("span",{style:{width:2,minHeight:14,background:C.f.line}})]}),(0,y.jsx)("span",{style:{paddingBottom:12,fontSize:14,lineHeight:1.5,color:"#d6dce6",overflowWrap:"anywhere",...n?{fontFamily:dI,fontSize:12.5}:{}},children:e.text})]},t)})}),j.length>8&&(0,y.jsx)("button",{type:"button",onClick:()=>f(e=>!e),style:{justifySelf:"start",padding:"6px 12px",borderRadius:8,border:`1px solid ${C.f.line}`,background:"#141414",color:"#e6e9ef",fontSize:13,fontWeight:600,cursor:"pointer"},children:p?dz.showFewer:dz.showAll(j.length)})]})]})]})]})})}let d1={queued:["running","skipped","blocked","cancelled"],running:["waiting_approval","passed","failed","cancelled"],waiting_approval:["running","passed","failed","cancelled"],blocked:["queued","skipped","cancelled"],passed:[],failed:[],cancelled:[],skipped:[]},d2=[1e3,2e3,5e3],d5={"node.queued":"queued","node.started":"running","node.waiting_approval":"waiting_approval","node.question_asked":"waiting_approval","node.question_answered":"running","node.completed":"passed","node.failed":"failed","node.skipped":"skipped","node.cancelled":"cancelled"},d4={nodes:{},lastSequence:0},d6=e=>"string"==typeof e&&""!==e.trim()?e:void 0,d3=e=>"number"==typeof e&&Number.isInteger(e)&&e>=0?e:null,d8=new Set(["input","plan","build","tests","review","approve","human","ship"]);function d9(e){return{...e.round?{round:e.round}:{},...e.asking?{asking:!0}:{},...e.planMeasure?{planMeasure:e.planMeasure}:{},...e.autoStarted?{autoStarted:!0}:{},...e.evidence?{evidence:e.evidence}:{},...e.risk?{risk:e.risk}:{},...void 0!==e.tokens?{usage:{tokens:e.tokens,costCents:null}}:{}}}let d7=new Set([b.B.run.notYet.plan,b.B.run.notYet.review]),ce=e=>"skipped"===e.state&&void 0!==e.skippedReason&&d7.has(e.skippedReason);function ct(e,t=[],n,i){let r={};for(let[n,i]of Object.entries(e)){let e=t.find(e=>e.id===n)?.kind;if(void 0===e||!d8.has(e)){r[n]={blockId:n,state:i.state,summary:b.B.summary.generic[i.state],summaryIsClaim:!1,steps:i.steps,...d9(i)};continue}let o="failed"===i.state,a={kind:e,state:i.state,claim:o?i.failureMessage:i.reportedSummary,claimSource:o?i.failureSource:i.claimSource,cause:o?i.failureCause:void 0,skippedReason:i.skippedReason,counts:i.evidence?.counts??void 0};r[n]={blockId:n,state:i.state,summary:ep(a),summaryIsClaim:ef(a),steps:i.steps,...d9(i),...ce(i)?{notBuilt:!0}:{}}}if(n)for(let e of t.filter(e=>"ship"===e.kind))r[e.id]=n.merged?{blockId:e.id,state:"passed",summary:b.B.summary.mergedVia(n.pr??null),summaryIsClaim:!1,steps:[]}:void 0!==n.pr?{blockId:e.id,state:"waiting_approval",summary:b.B.summary.prOpen(n.pr),summaryIsClaim:!1,steps:[]}:{blockId:e.id,state:"passed",summary:b.B.summary.shippedTo(n.branch),summaryIsClaim:!1,steps:[]};if(!n)for(let e of t.filter(e=>"ship"===e.kind)){let t=r[e.id];t?.state==="skipped"&&(r[e.id]=i?{...t,state:"cancelled",summary:b.B.summary.thrownAway}:{...t,waitingForYou:!0})}return r}let cn={"run.created":"queued","run.started":"running","run.waiting_approval":"waiting_approval","run.completed":"completed","run.failed":"failed","run.cancelled":"cancelled"},ci=new Set(["completed","failed","cancelled"]),cr={events:[],runStatus:null},co=e=>({runId:e,stream:d4,log:cr});function ca(e,t){var n,i,r;let o;if("reset"===t.type)return co(t.runId);let a=e.runId===t.runId?e:co(t.runId);return{runId:t.runId,stream:function(e,t){var n;if(t.sequence<=e.lastSequence)return e;let i={...e,lastSequence:t.sequence},r=t.payload??{};if("run.snapshots"===t.type){let e=d6(r.change);return void 0!==e&&Array.isArray(r.shots)&&r.shots.length>0?{...i,pictured:e}:i}if("run.pushed"===t.type){let t=d6(r.branch);return void 0===t?i:{...i,shipped:{...e.shipped,branch:t}}}if("run.pr_opened"===t.type&&"number"==typeof r.number)return{...i,shipped:{branch:e.shipped?.branch??"",...e.shipped,pr:r.number}};if("run.merged"===t.type)return{...i,shipped:{branch:e.shipped?.branch??"",...e.shipped,merged:!0}};if("run.thrown_away"===t.type)return{...i,thrownAway:!0};let o=d6(r.blockId);if(void 0===o)return i;let a=e.nodes[o];if("node.plan_decided"===t.type)return{...i,planBlocks:[...new Set([...e.planBlocks??[],o])]};if("node.step"===t.type){let n=d6(r.text);return a&&void 0!==n?{...e,nodes:{...e.nodes,[o]:{...a,steps:[...a.steps,n]}},lastSequence:t.sequence}:i}if("node.evidence"===t.type){let n=function(e){let t=d3(e.durationMs);if(null===t)return;let n="number"==typeof e.exitCode&&Number.isInteger(e.exitCode)?e.exitCode:null,i=e.counts,r=d3(i?.passed),o=d3(i?.failed),a=d3(i?.total),l="string"==typeof e.signal?e.signal:null,s=Array.isArray(e.changedTestFiles)?e.changedTestFiles.filter(e=>"string"==typeof e):null,d=null===s?null:Math.max(d3(e.changedTestFilesCount)??0,s.length);return{counts:null!==r&&null!==o&&null!==a&&r+o<=a?{passed:r,failed:o,total:a}:null,exitCode:n,signal:l,durationMs:t,changedTestFiles:s,changedTestFilesCount:d}}(r);return a&&n?{...e,nodes:{...e.nodes,[o]:{...a,evidence:n}},lastSequence:t.sequence}:i}if("node.reopened"===t.type){if(!a)return i;let n="number"==typeof r.asked?r.asked:"fixes"===r.by?a.round:r.round,l=`${String(r.by)}-${String(r.round)}`,s="fixes"!==r.by&&"reviewer"!==r.by&&void 0!==d6(r.note)&&!e.planBlocks?.includes(o)&&!e.kept?.includes(l);return{...e,nodes:{...e.nodes,[o]:{state:"queued",steps:[],round:"number"==typeof n&&n>1?n:void 0}},lastSequence:t.sequence,...s?{earlier:[...e.earlier??[],{nodes:e.nodes,change:e.pictured}],pictured:void 0,kept:[...e.kept??[],l],reopened:[o]}:{reopened:[...new Set([...e.reopened??[],o])]}}}if("node.assessed"===t.type){let n="low"===r.level||"high"===r.level?r.level:void 0,l=Array.isArray(r.reasons)?r.reasons.filter(e=>"string"==typeof e):[];return a&&n?{...e,nodes:{...e.nodes,[o]:{...a,risk:{level:n,reasons:l,...!0===r.stopForMe?{stopForMe:!0}:{}}}},lastSequence:t.sequence}:i}if("node.plan_measured"===t.type){if(!a)return i;let n=e=>Array.isArray(e)?e.filter(e=>"string"==typeof e):[],l=r.question?.text,s="string"==typeof l&&""!==l.trim()?l:void 0;return{...e,nodes:{...e.nodes,[o]:{...a,planMeasure:{simple:!0===r.simple,reasons:n(r.reasons),entries:n(r.entries),...s?{question:s}:{}}}},lastSequence:t.sequence}}let l=d5[t.type];if(void 0===l||a&&a.state!==l&&(n=a.state,!d1[n].includes(l)))return i;let s={...a,state:l,steps:a?.steps??[]};return"node.question_asked"===t.type?s.asking=!0:delete s.asking,delete s.autoStarted,"node.completed"===t.type&&!0===r.autoStarted&&(s.autoStarted=!0),"node.waiting_approval"===t.type&&"string"==typeof r.summary&&(s.reportedSummary=d6(r.summary),s.claimSource="string"==typeof r.summarySource?r.summarySource:void 0),"queued"===l&&(s.reportedSummary=void 0),"node.completed"===t.type&&(s.reportedSummary=d6(r.summary),s.claimSource="string"==typeof r.summarySource?r.summarySource:void 0,"tokens"in r&&(s.tokens="number"==typeof r.tokens?r.tokens:null)),"node.failed"===t.type&&(s.failureCause=d6(r.cause),s.failureMessage=d6(r.message),s.failureSource="string"==typeof r.messageSource?r.messageSource:void 0),"node.skipped"===t.type&&(s.skippedReason=d6(r.reason)),{...e,nodes:{...e.nodes,[o]:s},lastSequence:t.sequence}}(a.stream,t.event),log:(n=a.log,i=t.event,n.events.length>0&&i.sequence<=n.events[n.events.length-1].sequence?n:{events:[...n.events,i].slice(-300),runStatus:(r=n.runStatus,void 0===(o=cn[i.type])||null!==r&&ci.has(r)?r:o)})}}let cl=()=>()=>void 0,cs=new Set(["queued","running","waiting_approval"]),cd={padding:"6px 14px",background:B.f.card,color:"inherit",border:`1px solid ${B.f.border}`,borderRadius:6,cursor:"pointer"};async function cc(e,t){let n=await e.json().catch(()=>null);return"string"==typeof n?.error?n.error:t}let cu=es.R.filter(e=>e.ready).map(e=>({id:e.id,name:e.name}));e.s(["CanvasScreen",0,function({workflowId:e,graph:t,run:n=null,settings:i=null,draftUpdatedAt:r,localData:o=!1,noTasksYet:a=!1,account:l,ais:s=cu,ai:d=es.b,installedAis:c}){var u;let[p,f]=(0,m.useState)(n),[h,g]=(0,m.useState)(i),[x,C]=(0,m.useState)(null),z=x??(i?.repoPath?d:ed.C),I=p?.providerId??z,E=(0,m.useMemo)(()=>c?new Set(c):null,[c]),_=(0,m.useCallback)((e,t,n)=>(0,es.p)((0,es.t)(I,n,t),e,t),[I]),R=(0,m.useCallback)((e,t)=>(0,es.y)(I)&&es.o.has(t)?(0,es.j)((0,es.t)(I,e,t))??null:null,[I]),A=z!==ed.C&&!h?.repoPath,[H,F]=(0,m.useState)(null),O=(0,m.useSyncExternalStore)(cl,()=>{try{return window.sessionStorage.getItem((0,L.V)(e))}catch{return null}},()=>null),D=H??O??"",q=t=>{try{window.sessionStorage.removeItem((0,L.V)(e))}catch{}F(t)},[V,Z]=(0,m.useState)([]),[K,G]=(0,m.useState)(!1),[J,Q]=(0,m.useState)(""),ee=()=>{q(""),Z(e=>{for(let t of e)URL.revokeObjectURL(t.previewUrl);return[]})},[et,en]=(0,m.useState)(!1),[ei,er]=(0,m.useState)(null),[eo,ea]=(0,m.useState)(null),ec=(0,m.useRef)(null),eu=(0,m.useRef)(null);async function ep(e){let t=await fetch(`/api/runs/${e}`);if(!t.ok)return er(await cc(t,b.B.run.startFailed));ea(null),f(await t.json())}let ef=`factory.direct.${e}`,eh=(0,m.useSyncExternalStore)(cl,()=>{try{return"1"===window.localStorage.getItem(ef)}catch{return!1}},()=>!1),[eg,ex]=(0,m.useState)(null),ey=e=>{ex(e);try{window.localStorage.setItem(ef,e?"1":"0")}catch{}},[em,eb]=(0,m.useState)(null),{views:ev,rounds:ew,events:ek,runStatus:eS,connected:eC,loaded:eB,reopen:eI}=function(e,t){let[n,i]=(0,m.useReducer)(ca,null,()=>co(e)),{stream:r,log:o}=n.runId===e?n:co(e),[a,l]=(0,m.useReducer)((e,t)=>t,!1),s=(0,m.useRef)(0),d=(0,m.useRef)(null),c=(0,m.useCallback)(()=>d.current?.(),[]),[u,p]=(0,m.useReducer)((e,t)=>t,null);return(0,m.useEffect)(()=>{let t,n;if(s.current=0,i({type:"reset",runId:e}),null===e)return void l(!1);let r=0,o=!1,a=!1,c=()=>{let d=new EventSource(`/api/runs/${encodeURIComponent(e)}/events?after=${s.current}`);t=d,"function"==typeof d.addEventListener?(d.addEventListener("caughtup",()=>p(e)),d.addEventListener("end",()=>{a=!0,d.close()})):p(e),d.onopen=()=>{r=0,l(!0)},d.onmessage=t=>{let n;try{n=JSON.parse(t.data)}catch{return}"number"!=typeof n.sequence||n.sequence<=s.current||(s.current=n.sequence,i({type:"event",runId:e,event:n}))},d.onerror=()=>{if(d.close(),l(!1),o||a||u())return;let e=d2[Math.min(r,d2.length-1)];r++,n=setTimeout(c,e)}},u=()=>"u">typeof document&&"hidden"===document.visibilityState,f=()=>{u()?(clearTimeout(n),t?.close(),l(!1)):o||a||(t?.close(),c())};"u">typeof document&&document.addEventListener("visibilitychange",f),d.current=()=>{!o&&a&&(a=!1,c())},c();let h=setTimeout(()=>p(e),2500);return()=>{o=!0,"u">typeof document&&document.removeEventListener("visibilitychange",f),clearTimeout(h),clearTimeout(n),t?.close()}},[e]),{views:(0,m.useMemo)(()=>ct(r.nodes,t,r.shipped,r.thrownAway),[r.nodes,t,r.shipped,r.thrownAway]),rounds:(0,m.useMemo)(()=>({earlier:(r.earlier??[]).map(e=>({views:ct(e.nodes,t),change:e.change})),reopened:r.reopened??[]}),[r.earlier,r.reopened,t]),lastSequence:r.lastSequence,connected:a,events:o.events,runStatus:o.runStatus,loaded:null!==e&&u===e,reopen:c}}(p?.runId??null,p?.blocks),eM=!!p&&ek.some(e=>"run.created"===e.type&&e.payload?.direct===!0),e$=(eg??eh)||eM&&em!==p?.runId,eE=(0,m.useRef)(r),e_=(0,m.useRef)(Promise.resolve()),eR=(0,m.useRef)(!1),[eN,eT]=(0,m.useState)(null),eW=[...new Set([h?.defaultBranch,h?.currentBranch].filter(e=>!!e))],eL=null!==eN&&eW.includes(eN)?eN:eW[0]??null,[eP,eA]=(0,m.useState)(!1),[eH,eF]=lX("factory.view.conversation",!1),[eO,eD]=(0,m.useState)(null),eq=p?.runId??null,eV=(0,m.useCallback)(e=>eq&&eD({runId:eq,state:e}),[eq]),eY=p?.blocks.find(e=>"ship"===e.kind),[eX,eU]=(0,m.useState)(null),eZ=ek.some(e=>"run.pr_opened"===e.type),eK=eO?.runId===eq;(0,m.useEffect)(()=>{if(!eB||!eq||!eZ||eK)return;let e=!0;return fetch(`/api/runs/${eq}/ship`).then(e=>e.ok?e.json():null).then(t=>e&&t&&eD({runId:eq,state:t})).catch(()=>void 0),()=>{e=!1}},[eB,eq,eZ,eK]);let eG=eB&&(!eZ||eK);(0,m.useEffect)(()=>{if(!eB||!eq)return;let e=setTimeout(()=>eU(eq),eG?250:4e3);return()=>clearTimeout(e)},[eB,eG,eq]);let eJ=!!p&&eX!==p.runId,eQ=(0,W.O)(eq,`${ek.filter(e=>"node.reopened"===e.type||"node.plan_decided"===e.type||"node.question_answered"===e.type).length}-${eS??""}`),e0=function(e){for(let t=e.length-1;t>=0;t--)if(dC.has(e[t].type))return e[t].sequence;return 0}(ek),{record:e1,readMark:e2,failed:e5,reload:e4}=function(e,t){let[n,i]=(0,m.useState)(null),[r,o]=(0,m.useState)(null),[a,l]=(0,m.useState)(0);(0,m.useEffect)(()=>{if(!e)return;let n=!0;return fetch(`/api/runs/${encodeURIComponent(e)}/findings`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(r=>{n&&(i({runId:e,record:r,mark:t}),o(null))}).catch(()=>n&&o(e)),()=>{n=!1}},[e,t,a]);let s=(0,m.useCallback)(()=>l(e=>e+1),[]);return{record:n&&n.runId===e?n.record:null,readMark:n&&n.runId===e?n.mark:-1,failed:r===e,reload:s}}(eq,e0),e6=e=>{if(!p||!eM)return e;let t={...e};for(let e of p.blocks){let n=t[e.id];"build"===e.kind&&n?.state==="waiting_approval"&&(t[e.id]={...n,turn:!0,summary:b.B.direct.turnSummary})}return t},e3=e=>{if(!p||0===eQ.length)return e;let t={...e};for(let e of["input","plan","build","review","human"]){let n=p.blocks.find(t=>t.kind===e&&t.enabled),i=eQ.filter(t=>(0,W.B)(t)===e||"input"===e&&"changes"===t.kind);n&&t[n.id]&&i.length>0&&(t[n.id]={...t[n.id],asked:i})}return t},e8=eO&&eO.runId===eq&&eY?function(e,t){if(!t.pr)return null;let n=b.B.ship,i=[n.stepPushed,n.stepPr(t.pr.number),...t.checks.map(e=>`${e.name}: ${n.checkState[e.state]}`)],r={blockId:e,summaryIsClaim:!1,steps:i};if("closed"===t.pr.state)return{...r,state:"cancelled",summary:n.closed};if("open"===t.pr.state){if(t.pr.conflicts)return{...r,state:"failed",summary:n.conflicts};if(t.checksFailed)return{...r,state:"failed",summary:n.someFailed};if(!t.checksDone){let e=t.checks.filter(e=>"pending"!==e.state).length;return{...r,state:"running",summary:0===t.checks.length?n.cardLooking:n.cardChecking(e,t.checks.length)}}return{...r,state:"waiting_approval",summary:t.onHold?n.cardOnHold:n.cardReady}}let o=[...i,t.deployPending?n.stepMerged:n.merged,...t.deploy.map(e=>`${e.name}: ${n.checkState[e.state]}`)];return t.deploy.some(e=>"failed"===e.state)?{...r,steps:o,state:"failed",summary:n.deployFailed}:t.deployPending||t.deploy.some(e=>"pending"===e.state)?{...r,steps:o,state:"running",summary:n.cardDeploying}:{...r,steps:o,state:"passed",summary:t.deploy.length>0?n.cardLive:n.merged}}(eY.id,eO.state):null,e9=e8&&eY?{...ev,[eY.id]:e8}:ev,e7=Object.values(ev).some(e=>e.risk)&&eq&&eY&&e9[eY.id]?{...e9,[eY.id]:{...e9[eY.id],results:eq}}:e9,te=(0,m.useCallback)(()=>eA(!1),[]);async function tt(){en(!0),er(null);try{if(ec.current&&!await ec.current())return er(b.B.run.saveFirst);let t=await fetch(`/api/workflows/${e}/publish`,{method:"POST"});if(!t.ok)return er(400===t.status?b.B.run.fixFirst:await cc(t,b.B.run.startFailed));let n=await fetch(`/api/workflows/${e}/runs`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({request:D,provider:z,attachments:sN(V),...K?{stopForMe:!0}:{},...e$&&z!==ed.C?{direct:!0}:{},...J.trim()?{title:J.trim()}:{},...z!==ed.C&&eL?{startFrom:eL}:{}})});if(!n.ok)return er(await cc(n,b.B.run.startFailed));let{runId:i}=await n.json(),r=await fetch(`/api/runs/${i}`);if(!r.ok)return er(await cc(r,b.B.run.startFailed));ea(null),f(await r.json()),ee(),G(!1),Q("")}catch{er(b.B.run.startFailed)}finally{en(!1)}}let[tn,ti]=(0,m.useState)("none"),[tr,to]=(0,m.useState)(a?0:null),[ta,tl]=(0,m.useState)(0),ts=null===p&&0!==tr&&"new"!==tn,td=h?.projectId,tc=(0,m.useCallback)(()=>{td&&fetch(`/api/projects/${td}`).then(e=>e.ok?e.json():null).then(e=>e&&g(e)).catch(()=>void 0)},[td]),tu=h?.suggestedTestCommand??null,tp=(0,m.useSyncExternalStore)(cl,()=>{try{return td?localStorage.getItem(`factory.testSuggestion.${td}`):null}catch{return null}},()=>null),[tf,th]=(0,m.useState)(null),[tg,tx]=(0,m.useState)(!1),[ty,tm]=(0,m.useState)(!1);async function tb(){if(tu&&td){tx(!0),tm(!1);try{let e=await fetch(`/api/projects/${td}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({testCommand:tu})}),t=await e.json().catch(()=>null);if(!e.ok||!t)return tm(!0);g(t)}catch{tm(!0)}finally{tx(!1)}}}function tv(e="new"){e$&&ey(!0),ti(e),f(null),eT(null),ea(null),er(null),ee(),tc(),"new"===e&&requestAnimationFrame(()=>document.getElementById(sp)?.focus())}async function tw(){if(p){er(null);try{let e=await fetch(`/api/runs/${p.runId}/cancel`,{method:"POST"});e.ok||er(await cc(e,b.B.run.cancelFailed))}catch{er(b.B.run.cancelFailed)}}}let tj=null!==eS&&cs.has(eS),tk="completed"===eS||"failed"===eS||"cancelled"===eS,tS=!!p&&p.blocks.some(e=>ev[e.id]?.asking===!0&&ev[e.id]?.state==="waiting_approval"),tC=null===p?null:null!==eS?tk?b.B.run.lastRun(b.B.run.status[eS]):"waiting_approval"===eS&&tS?b.B.question.stateLabel:b.B.run.status[eS]:eC?null:b.B.run.connecting,tB=!et&&!tj&&""!==D.trim()&&!A&&!sT(V),[tz,tI]=(0,m.useState)(!1),tM=(0,m.useRef)(null),[t$,tE]=(0,m.useState)(null),[t_,tR]=(0,m.useState)(null),tN=p?.blocks.find(e=>"human"===e.kind),tT=eY?e7[eY.id]?.state:void 0,tW=eY&&tT&&"queued"!==tT&&"skipped"!==tT?eY.id:null,tL=p?.blocks.find(e=>"plan"===e.kind),tP=!!p&&p.blocks.some(e=>"plan"===e.kind&&ev[e.id]?.state==="waiting_approval"&&ev[e.id]?.asking!==!0),tA=!!p&&p.providerId!==ed.C&&p.blocks.some(e=>"review"===e.kind&&e.enabled&&ev[e.id]?.state==="passed"),tH=p&&"waiting_approval"===eS&&tS?"question":p&&"waiting_approval"===eS&&tP?"plan":p&&"waiting_approval"===eS?"waiting":p&&("running"===eS||"queued"===eS)?"working":p&&"completed"===eS&&p.providerId!==ed.C?"done":p&&"failed"===eS&&p.providerId!==ed.C?"failed":"idle",tF=eO&&eO.runId===eq?eO.state:null,tO=S(tF)&&!tF?.onHold,tD=function(e,t){let n=(0,m.useRef)(null),[i,r]=(0,m.useState)(null),o=t?.pr?.state==="merged"&&!0!==t.deployPending,a=null!==t;return(0,m.useEffect)(()=>{if(!e||!a)return;let t=n.current;if(n.current={runId:e,published:o},t?.runId!==e||t.published||!o)return;let i=setTimeout(()=>r(e),0),l=setTimeout(()=>r(null),3200);return()=>{clearTimeout(i),clearTimeout(l)}},[e,a,o]),null!==i&&i===e}(eq,tF),tq="plan"===tH||"question"===tH||"waiting"===tH?"answer":"done"===tH&&tO?"publish":null,{offer:tV,allow:tY}=function({attention:e,waitingCount:t,taskTitle:n,askKey:i=null}){var r;let o="granted"===(r=(0,m.useSyncExternalStore)(j,k,()=>null))?"on":"denied"===r?"blocked":"default"===r?"ask":"none",[,a]=(0,m.useState)(0);(0,m.useEffect)(()=>{if("u">typeof document){var n;let i;document.title=(n="publish"===e,i=t>0?b.B.tell.waitingTitle(t):n?b.B.tell.readyTitle:null,b.B.tell.tabTitle(i))}},[t,e]),(0,m.useEffect)(()=>()=>{"u">typeof document&&(document.title=b.B.app.name)},[]);let l=(0,m.useRef)(new Set);return(0,m.useEffect)(()=>{if(!e)return;let t=`${e}|${i??""}`;if(!l.current.has(t)){l.current.add(t);try{if("u"<typeof document||!document.hidden||"granted"!==k())return;new Notification("answer"===e?b.B.tell.needsAnswer:b.B.tell.readyToPublish,{body:n??""})}catch{}}},[e,i]),{offer:o,allow:(0,m.useCallback)(()=>{try{if(null===k())return;Promise.resolve(Notification.requestPermission()).then(()=>a(e=>e+1)).catch(()=>void 0)}catch{}},[])}}({attention:tq,waitingCount:Math.max(ta,+("answer"===tq)),taskTitle:p?.title??null,askKey:p?`${p.runId}:${tH}:${dB(ek)??""}`:null}),tX=(0,y.jsxs)("button",{type:"button","aria-expanded":eP,onClick:()=>eA(e=>!e),style:{...cd,marginLeft:h?.repoPath?0:"auto",fontWeight:600,display:"inline-flex",alignItems:"center",gap:8},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M5 7h14M5 12h14M5 17h14"})}),b.B.history.open,(tr??0)>0&&(0,y.jsx)("span",{style:{padding:"1px 8px",borderRadius:999,background:B.f.border,fontSize:12},children:tr})]}),tU=eH&&!e$&&null!==p&&!eJ,tZ=(0,y.jsx)(db,{docked:!0,direct:e$&&z!==ed.C,ref:eu,mode:tH,runId:p?.runId??null,risk:Object.values(ev).find(e=>"waiting_approval"===e.state)?.risk,planMeasure:tL?ev[tL.id]?.planMeasure:void 0,stopForMe:K,onStopForMe:G,text:D,onText:q,images:V,onImages:Z,onRun:()=>void tt(),canRun:tB,onFollowUp:e=>void ep(e),onNewTask:()=>tv("new"),onShipState:eV,onSent:ee,startOptions:z!==ed.C?eW:[],startFrom:eN,onStartFrom:eT,onRecorded:()=>{eI(),tc()},away:p&&!1===p.here?{machine:p.machine??null}:null,taskName:J,onTaskName:Q,loading:eJ,failureActions:tM,onCanContinue:e=>tE(e&&p?p.runId:null),onSeeChanges:tN?()=>tR(tN.id):void 0,record:e1,recordFailed:e5,recordMark:e0,recordReadMark:e2,askedId:dB(ek),onRecordChanged:e4,showFindings:tA,notice:{offer:tV,onAllow:tY}},`${p?.runId??"none"}-${eJ?"loading":tH}`);return(0,y.jsxs)("div",{style:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,y.jsxs)("header",{style:{display:"flex",alignItems:"center",gap:12,padding:"8px 12px",minHeight:36,borderBottom:`1px solid ${B.f.border}`,background:B.f.bg},children:[(0,y.jsxs)("span",{"data-testid":"app-mark",style:{display:"flex",alignItems:"center",gap:8,marginRight:4,fontSize:11,fontWeight:800,letterSpacing:"0.13em",textTransform:"uppercase",color:B.f.dim,whiteSpace:"nowrap"},children:[(0,y.jsx)("span",{style:{color:"#e8eaf0",display:"flex"},children:(0,y.jsx)(ez.f,{size:22})}),b.B.app.name]}),l&&(0,y.jsx)(U.f,{account:l,style:cd}),(0,y.jsx)(Y,{workflowId:e,style:cd,onOpenSettings:h?()=>tI(!0):void 0}),o&&(0,y.jsxs)("span",{"data-testid":"local-data",title:b.B.localData.hint,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:999,border:`1px solid ${B.f.waiting}`,color:B.f.waiting,fontSize:12,fontWeight:700,whiteSpace:"nowrap",cursor:"help"},children:[(0,y.jsx)("span",{"aria-hidden":!0,style:{width:7,height:7,borderRadius:"50%",background:B.f.waiting}}),b.B.localData.label]}),h&&(0,y.jsx)("button",{type:"button","aria-label":b.B.projectSettings.open,title:b.B.projectSettings.open,onClick:()=>tI(!0),style:{...cd,padding:"6px 9px",display:"grid",placeItems:"center"},children:(0,y.jsx)(P,{size:17})}),tz&&h&&(0,y.jsx)(el,{settings:h,onClose:()=>tI(!1),onSaved:g}),h&&(0,y.jsx)(lN.g.Provider,{value:E,children:(0,y.jsx)(lN.T,{value:z,ais:s,disabled:tj,style:{...cd,padding:"6px 10px"},onChange:e=>{C(e),e!==ed.C&&fetch("/api/account/ai",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({ai:e})}).catch(()=>void 0)}})}),!e$&&(0,y.jsx)("button",{type:"button",disabled:!tB,title:A?b.B.settings.needsRepo:""===D.trim()?b.B.run.writeFirst:void 0,onClick:tt,style:{...cd,fontWeight:600,background:tB?B.f.running:B.f.card,borderColor:tB?B.f.running:B.f.border,color:tB?"#fff":B.f.skipped,cursor:tB?"pointer":"not-allowed"},children:et?b.B.run.starting:b.B.run.run}),A&&(0,y.jsx)("button",{type:"button",onClick:()=>tI(!0),style:{background:"none",border:"none",padding:0,fontSize:12.5,color:B.f.waiting,cursor:"pointer",textDecoration:"underline"},children:b.B.settings.needsRepo}),(!e$||tj)&&(0,y.jsx)("button",{type:"button",style:cd,disabled:!tj,onClick:tw,children:b.B.run.cancel}),p&&!tj&&(0,y.jsxs)("button",{type:"button",style:{...cd,fontWeight:700,background:B.f.passed,borderColor:B.f.passed,color:"#0d1f12"},onClick:()=>tv("new"),children:["+ ",b.B.delivery.newTask]}),(0,y.jsx)("span",{"aria-hidden":"true",style:{flex:1}}),p?.providerId===ed.C&&(0,y.jsx)("span",{title:b.B.run.demoTitle,style:{padding:"2px 8px",border:`1px solid ${B.f.waiting}`,color:B.f.waiting,borderRadius:999,fontSize:12,fontWeight:600},children:b.B.run.demoBadge}),tC&&"waiting_approval"===eS?(0,y.jsxs)("button",{type:"button","data-testid":"run-status",title:b.B.gate.goToGate,onClick:()=>{let e=p?.blocks.find(e=>ev[e.id]?.state==="waiting_approval");e&&ea(e.id),eu.current?.focus(),eu.current?.scrollIntoView?.({block:"nearest"})},style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",background:B.f.tint("waiting",.12),color:B.f.waiting,border:`1px solid ${B.f.tint("waiting",.5)}`,borderRadius:999,fontSize:13,fontWeight:600,cursor:"pointer"},children:[(0,y.jsx)("span",{"aria-hidden":"true",children:"⚠"}),tC]}):tC&&"completed"===eS&&p&&p.providerId!==ed.C?(0,y.jsxs)("button",{type:"button","data-testid":"run-status",title:b.B.delivery.title,onClick:()=>{eu.current?.focus(),eu.current?.scrollIntoView?.({block:"nearest"})},style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",background:B.f.tint("passed",.12),color:B.f.passed,border:`1px solid ${B.f.tint("passed",.5)}`,borderRadius:999,fontSize:13,fontWeight:600,cursor:"pointer"},children:[(0,y.jsx)("span",{"aria-hidden":"true",children:"✓"}),tC]}):tC&&(0,y.jsxs)("span",{"data-testid":"run-status",role:"status",style:{display:"flex",alignItems:"center",gap:7,color:eS?B.f["running"===(u=eS)?"running":"completed"===u?"passed":"failed"===u?"failed":"waiting_approval"===u?"waiting":"skipped"]:B.f.skipped,fontSize:13},children:["running"===eS&&(0,y.jsx)($.m,{blockId:"run",size:14}),tC]}),h?.repoPath&&(0,y.jsxs)("button",{type:"button","data-testid":"direct-edit-toggle","aria-pressed":e$,title:b.B.direct.hint,onClick:()=>{ey(!e$),eb(e$?p?.runId??null:null)},style:{...cd,marginLeft:"auto",fontWeight:600,display:"inline-flex",alignItems:"center",gap:8,...e$?{border:`1px solid ${B.f.passed}`,color:B.f.passed}:{}},children:[(0,y.jsxs)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,y.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),(0,y.jsx)("path",{d:"M10 4v16"})]}),e$?b.B.direct.off:b.B.direct.on]}),tX,l&&(0,y.jsx)(X.P,{person:l.person})]}),tu&&(tf??tp)!==tu&&(0,y.jsxs)("div",{"data-testid":"test-suggestion",role:"status",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,padding:"8px 14px",borderBottom:`1px solid ${B.f.border}`,background:"rgba(121, 220, 139, 0.07)",fontSize:13},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:B.f.passed,strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})}),(0,y.jsx)("span",{children:ty?b.B.testSuggestion.failed:b.B.testSuggestion.text(tu)}),(0,y.jsx)("button",{type:"button",disabled:tg,onClick:()=>void tb(),style:{padding:"5px 12px",borderRadius:6,border:`1px solid ${B.f.passed}`,background:B.f.passed,color:"#07110a",fontWeight:700,cursor:tg?"wait":"pointer"},children:b.B.testSuggestion.accept}),(0,y.jsx)("button",{type:"button",disabled:tg,onClick:function(){if(tu&&td){th(tu);try{localStorage.setItem(`factory.testSuggestion.${td}`,tu)}catch{}}},style:{...cd,padding:"5px 12px"},children:b.B.testSuggestion.dismiss})]}),(0,y.jsxs)("div",{style:{flex:1,minHeight:0,position:"relative",overflow:"clip"},children:[null===p&&!(e$&&(tr??0)>0&&"new"===tn)&&(0,y.jsx)("div",{"data-testid":"no-task",role:"region","aria-label":0===tr?b.B.history.firstTaskTitle:b.B.history.noTaskTitle,style:{position:"absolute",top:ts?"50%":64,left:"50%",transform:ts?"translate(-50%, -60%)":"translateX(-50%)",zIndex:4,width:ts?"min(520px, calc(100% - 32px))":"min(440px, calc(100% - 32px))",display:"grid",gap:ts?12:8,padding:ts?"28px 28px 26px":"16px 18px",background:B.f.card,border:`1px solid ${B.f.border}`,borderRadius:12,boxShadow:"0 12px 30px rgba(0,0,0,0.4)",textAlign:"center"},children:0===tr?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("strong",{className:"factory-display",style:{fontSize:19},children:b.B.history.firstTaskTitle}),(0,y.jsx)("span",{style:{fontSize:13,color:B.f.dim,lineHeight:1.5},children:b.B.history.firstTaskText}),(0,y.jsxs)("button",{type:"button",onClick:()=>{let e=document.querySelector('[data-testid="command-card"]');e?.querySelector("textarea")?.focus(),e?.animate?.([{boxShadow:"0 0 0 0 rgba(59, 130, 246, 0.95)",transform:"scale(1)"},{boxShadow:"0 0 0 10px rgba(59, 130, 246, 0.35)",transform:"scale(1.015)"},{boxShadow:"0 0 0 22px rgba(59, 130, 246, 0)",transform:"scale(1)"}],{duration:650,iterations:2,easing:"ease-out"})},style:{justifySelf:"center",marginTop:4,display:"inline-flex",alignItems:"center",gap:8,padding:"8px 18px",borderRadius:8,border:"none",background:B.f.running,color:"#fff",fontWeight:700,cursor:"pointer"},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M12 5v14M5 12h14"})}),b.B.history.firstTaskAction]})]}):"new"===tn?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("strong",{style:{fontSize:15},children:b.B.history.newTaskTitle}),(0,y.jsx)("span",{style:{fontSize:12.5,color:B.f.dim,lineHeight:1.45},children:b.B.history.newTaskText})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("strong",{className:"factory-display",style:{fontSize:24},children:b.B.history.noTaskTitle}),(0,y.jsx)("span",{style:{fontSize:14.5,color:B.f.dim,lineHeight:1.5},children:b.B.history.noTaskText}),(0,y.jsxs)("div",{style:{display:"flex",justifyContent:"center",gap:10,flexWrap:"wrap",marginTop:6},children:[(0,y.jsxs)("button",{type:"button",onClick:()=>{ti("new"),requestAnimationFrame(()=>document.querySelector('[data-testid="command-card"] textarea')?.focus())},style:{display:"inline-flex",alignItems:"center",gap:8,padding:"10px 20px",borderRadius:8,border:"none",background:B.f.running,color:"#fff",fontSize:14.5,fontWeight:700,cursor:"pointer"},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M12 5v14M5 12h14"})}),b.B.history.createOne]}),(0,y.jsxs)("button",{type:"button",onClick:()=>eA(!0),style:{display:"inline-flex",alignItems:"center",gap:8,padding:"10px 20px",borderRadius:8,border:`1px solid ${B.f.border}`,background:"#0f141c",color:"#e6e9ef",fontSize:14.5,fontWeight:700,cursor:"pointer"},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M5 7h14M5 12h14M5 17h14"})}),b.B.history.openPast]})]})]})}),(0,y.jsx)(M,{open:eP,onClose:te,count:tr,children:(0,y.jsx)(w.R,{workflowId:e,currentRunId:p?.runId??null,publishing:eO?.runId===p?.runId&&eO?.state.pr?.state==="merged"&&!0===eO.state.deployPending,refreshKey:`${p?.runId??""}-${eS??""}-${eP}`,onOpen:e=>{eA(!1),ep(e)},onCount:to,onWaiting:tl,onDeleted:e=>{e===p?.runId&&(tv("none"),eA(!1))}})}),tZ,(0,y.jsx)(lN.g.Provider,{value:E,children:(0,y.jsxs)($.c.Provider,{value:R,children:[(0,y.jsx)($.v.Provider,{value:_,children:(0,y.jsx)(sx,{layout:e$?"steps":"canvas",site:e$?(0,y.jsx)(N,{runId:p&&!1!==p.here&&z!==ed.C?p.runId:null,projectId:p?null:h?.projectId??null}):void 0,stepDetails:e=>p?(0,y.jsx)(d0,{inline:!0,runId:p.runId,blockId:e,label:p.blocks.find(t=>t.id===e)?.label??e,view:e3(e6(e7))[e],pr:eO?.runId===p.runId?eO.state.pr??null:null,away:!1===p.here?{machine:p.machine??null}:null,onClose:()=>void 0},`inline-${p.runId}-${e}`):null,graph:t,save:function(t){let n=e_.current.catch(()=>void 0).then(async()=>{if(eR.current)throw Error("stale draft");let n=await fetch(`/api/workflows/${e}/draft`,{method:"PUT",headers:{"content-type":"application/json",...eE.current?{"x-draft-base":eE.current}:{}},body:JSON.stringify(t),keepalive:!0});if(409===n.status)throw eR.current=!0,er(b.B.editing.staleDraft),Error("stale draft");if(!n.ok)throw Error(`Saving the draft failed (${n.status})`);let i=await n.json();return i.updatedAt&&(eE.current=i.updatedAt),i.issues});return e_.current=n,n},nodeRuns:Object.values(e3(e6(e7))),runBlocks:p?.blocks,highlightedId:eo,onFailedClick:"failed"===tH?e=>"see"===e?tM.current?.see():tM.current?.again():void 0,canRetry:"failed"===tH&&t$===p?.runId,onDetails:p?tR:void 0,blank:ts,taskId:p?.runId??null,flushRef:ec,loading:eJ,overlay:p&&!eJ?(0,y.jsx)(y.Fragment,{children:(0,y.jsx)(T,{roomy:e$,runId:p.runId,initial:p.title??"",onRenamed:e=>f(t=>t&&t.runId===p.runId?{...t,title:e}:t)},p.runId)}):void 0,sidebarLog:p?(0,y.jsx)(ej,{events:ek,blocks:p.blocks,onPoint:ea}):void 0})}),tU&&p&&(0,y.jsx)(sS,{runId:p.runId,blocks:p.blocks,views:e3(e6(e7)),rounds:ew,prompts:eQ,onDetails:tR}),!e$&&null!==p&&!eJ&&(0,y.jsx)(sk,{chat:eH,onChange:eF}),tD&&(0,y.jsx)(v,{})]})}),p&&t_&&(0,y.jsx)(d0,{runId:p.runId,blockId:t_,label:p.blocks.find(e=>e.id===t_)?.label??t_,view:e6(e7)[t_],pr:eO?.runId===p.runId?eO.state.pr??null:null,away:!1===p.here?{machine:p.machine??null}:null,onClose:()=>tR(null),onSeeShip:tW?()=>tR(tW):void 0,onSettings:()=>{tR(null),window.dispatchEvent(new CustomEvent(sc,{detail:t_}))}},`details-${p.runId}-${t_}`)]})]})}],92432)}]);
|
|
5
|
+
${t}`:e),"fix")},onAgain:()=>(f(!1),void k(sC.againText,"again")),onOwn:()=>{f(!1),requestAnimationFrame(()=>document.querySelector('[data-testid="command-card"] textarea')?.focus())}})]})}function sI(){return(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:17,height:17,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M14.7 6.3a4 4 0 0 0-5.2 5.2L3.6 17.4a1.5 1.5 0 0 0 0 2.1l.9.9a1.5 1.5 0 0 0 2.1 0l5.9-5.9a4 4 0 0 0 5.2-5.2l-2.6 2.6-2.4-.6-.6-2.4z"})})}function sM(){return(0,y.jsxs)("svg",{viewBox:"0 0 24 24",width:15,height:15,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,y.jsx)("path",{d:"M4 20h4L19 9l-4-4L4 16v4z"}),(0,y.jsx)("path",{d:"M13.5 6.5l4 4"})]})}function s$(){return(0,y.jsxs)("svg",{viewBox:"0 0 24 24",width:15,height:15,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,y.jsx)("path",{d:"M20 11a8 8 0 1 0-2.3 5.7"}),(0,y.jsx)("path",{d:"M20 4v7h-7"})]})}function sE({icon:e,label:t,help:n,badge:i,primary:r,onClick:o}){return(0,y.jsxs)("button",{type:"button","aria-label":t,onClick:o,style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",columnGap:12,rowGap:3,alignItems:"center",padding:r?"16px 18px":"13px 18px",borderRadius:10,border:`1px solid ${r?B.f.running:B.f.border}`,background:r?B.f.running:"#0f141c",color:r?"#fff":"#e6e9ef",cursor:"pointer",textAlign:"left"},children:[(0,y.jsx)("span",{style:{gridRow:"1 / span 2",display:"grid",placeItems:"center"},children:e}),(0,y.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:8,fontSize:r?17.5:15.5,fontWeight:700},children:[t,i&&(0,y.jsx)("span",{style:{padding:"1px 8px",borderRadius:999,background:"rgba(255,255,255,0.22)",fontSize:11.5,fontWeight:700},children:i})]}),(0,y.jsx)("span",{style:{fontSize:14,lineHeight:1.4,color:r?"rgba(255,255,255,0.88)":B.f.dim},children:n})]})}function s_({failure:e,canContinue:t,explanation:n,explaining:i,onClose:r,onFix:o,onAgain:a,onOwn:l}){(0,m.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r]);let s=e?.failed[0],d=e?.failed.filter(e=>e.command||e.message)??[];return(0,y.jsx)("div",{onClick:r,style:{position:"fixed",inset:0,zIndex:60,display:"grid",gridTemplateRows:"minmax(0, 1fr)",placeItems:"center",background:"rgba(5, 7, 11, 0.65)"},children:(0,y.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":sC.title,"data-testid":"failure-dialog",onClick:e=>e.stopPropagation(),style:{width:`min(${d.length>0?1240:720}px, calc(100% - 32px))`,maxHeight:"calc(100% - 48px)",display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",background:B.f.card,border:`1px solid ${B.f.tint("failed",.5)}`,borderRadius:14,boxShadow:"0 24px 60px rgba(0,0,0,0.6)",fontSize:14},children:[(0,y.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"18px 26px",borderBottom:`1px solid ${B.f.border}`},children:[(0,y.jsx)("h2",{className:"factory-display",style:{margin:0,fontSize:25},children:sC.title}),(0,y.jsx)("button",{type:"button","aria-label":sC.close,onClick:r,style:{background:"none",border:"none",color:B.f.skipped,cursor:"pointer",fontSize:18},children:"✕"})]}),(0,y.jsx)("div",{style:{overflowY:"auto",padding:"22px 26px 26px",display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 420px), 1fr))",alignItems:"start",gap:28,scrollbarWidth:"thin",scrollbarColor:`${B.f.skipped} transparent`},children:e?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"grid",gap:22,minWidth:0},children:[(0,y.jsxs)("section",{style:{display:"grid",gap:10},children:[(0,y.jsx)("strong",{style:{fontSize:17},children:sC.happened}),(0,y.jsx)("p",{"data-testid":"failure-plain",style:{margin:0,fontSize:16.5,lineHeight:1.55,color:"#e6e9ef"},children:n??(s?sC.plain(s.label):sC.plainUnknown)}),i&&(0,y.jsxs)("div",{role:"status",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:B.f.dim},children:[(0,y.jsx)($.m,{blockId:"explain",size:14})," ",sC.explaining]}),(0,y.jsx)("p",{style:{margin:0,fontSize:14.5,lineHeight:1.5,color:B.f.passed},children:sC.safe})]}),(0,y.jsxs)("section",{style:{display:"grid",gap:10},children:[(0,y.jsx)("strong",{style:{fontSize:17},children:sC.whatNow}),t?(0,y.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,y.jsx)(sE,{primary:!0,icon:(0,y.jsx)(sI,{}),label:sC.actions.fix.label,help:sC.actions.fix.help,badge:sC.actions.fix.badge,onClick:o}),(0,y.jsx)(sE,{icon:(0,y.jsx)(s$,{}),label:sC.actions.again.label,help:sC.actions.again.help,onClick:a}),(0,y.jsx)(sE,{icon:(0,y.jsx)(sM,{}),label:sC.actions.own.label,help:sC.actions.own.help,onClick:l})]}):(0,y.jsx)("span",{style:{fontSize:13.5,color:B.f.waiting,lineHeight:1.5},children:sC.cannotContinue})]})]}),d.length>0&&(0,y.jsxs)("section",{style:{display:"grid",gap:12,minWidth:0},children:[(0,y.jsx)("strong",{style:{fontSize:17},children:sC.details}),d.map(e=>(0,y.jsxs)("div",{"data-testid":"failed-block",style:{display:"grid",gap:8},children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap",fontSize:13},children:[(0,y.jsx)("strong",{style:{color:B.f.failed},children:e.label}),e.message&&(0,y.jsx)("span",{style:{color:B.f.dim},children:e.message})]}),e.command&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap",fontSize:13,color:B.f.dim},children:[sC.command,(0,y.jsx)("code",{style:{padding:"3px 8px",borderRadius:6,background:"#0b0e14",border:`1px solid ${B.f.border}`,fontFamily:sB,fontSize:12.5,color:"#d6dce6"},children:e.command}),(0,y.jsx)("span",{style:{color:B.f.failed},children:sC.ended(e.exitCode,e.signal)})]}),(0,y.jsx)("span",{style:{fontSize:13,color:B.f.dim},children:sC.output}),(0,y.jsx)("pre",{"data-testid":"failure-output",style:{margin:0,maxHeight:"min(50vh, 460px)",overflow:"auto",padding:12,borderRadius:8,background:"#0b0e14",border:`1px solid ${B.f.border}`,fontFamily:sB,fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",scrollbarWidth:"thin",scrollbarColor:`${B.f.skipped} transparent`},children:e.output??sC.noOutput})]})]},e.blockId))]})]}):(0,y.jsx)("div",{style:{color:B.f.dim},children:sC.unreadable})})]})})}let sR=(0,m.createContext)(!1);function sN(e){return e.filter(e=>"ready"===e.status&&e.id).map(e=>e.id)}function sT(e){return e.some(e=>"uploading"===e.status)}function sW({inputId:e,label:t,placeholder:n,text:i,onText:r,images:o,onImages:a,onSubmit:l,send:s,minHeight:d=170,disabled:c=!1}){let[u,p]=(0,m.useState)(!1),[f,h]=(0,m.useState)(null),g=(0,m.useRef)(null),x=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{let e=x.current;e&&(e.style.height="auto",e.style.height=`${Math.min(Math.max(e.scrollHeight,d),380)}px`)},[i,d]);let v=(0,m.useRef)(()=>void 0);function w(e){h(null);let t=e.filter(e=>e.type.startsWith("image/"));t.length<e.length&&h(b.B.attachments.notImage);let n=6-o.length;for(let e of(t.length>n&&h(b.B.attachments.tooMany(6)),t.slice(0,Math.max(0,n)))){let t=`${Date.now()}-${Math.random().toString(36).slice(2)}`;a(n=>[...n,{key:t,name:e.name||"image",previewUrl:URL.createObjectURL(e),status:"uploading"}]);let n=new FormData;n.append("file",e),fetch("/api/attachments",{method:"POST",body:n}).then(async e=>{let n=await e.json().catch(()=>null);a(i=>i.map(i=>i.key!==t?i:e.ok&&n?.id?{...i,status:"ready",id:n.id}:{...i,status:"failed",error:n?.error??b.B.attachments.failed}))}).catch(()=>a(e=>e.map(e=>e.key===t?{...e,status:"failed",error:b.B.attachments.failed}:e)))}}return(0,m.useEffect)(()=>{if(c)return;let e=e=>{var t;let n,i=e.target;if(i&&i!==x.current&&("INPUT"===i.tagName||"TEXTAREA"===i.tagName||i.isContentEditable)||!e.clipboardData)return;let r=(n=[...(t=e.clipboardData).files].filter(e=>e.type.startsWith("image/"))).length>0?n:[...t.items].filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>null!==e);0!==r.length&&(e.preventDefault(),v.current(r),i!==x.current&&x.current?.focus({preventScroll:!0}))},t=e=>e.dataTransfer?.types.includes("Files")===!0,n=e=>{t(e)&&(e.preventDefault(),p(!0))},i=e=>{null===e.relatedTarget&&p(!1)},r=e=>{t(e)&&(e.preventDefault(),p(!1),v.current([...e.dataTransfer?.files??[]]),x.current?.focus({preventScroll:!0}))};return window.addEventListener("paste",e),window.addEventListener("dragover",n),window.addEventListener("dragleave",i),window.addEventListener("drop",r),()=>{window.removeEventListener("paste",e),window.removeEventListener("dragover",n),window.removeEventListener("dragleave",i),window.removeEventListener("drop",r)}},[c]),(0,m.useEffect)(()=>{v.current=w}),(0,y.jsxs)("div",{"data-testid":"composer",style:{display:"grid",gap:6},children:[(0,y.jsx)("label",{htmlFor:e,style:{fontSize:12.5,fontWeight:600,color:B.f.dim},children:t}),(0,y.jsxs)("div",{style:{position:"relative",background:C.f.card,border:`1px ${u?"dashed":"solid"} ${u?B.f.running:C.f.line}`,borderRadius:10,padding:8,display:"grid",gap:8},children:[o.length>0&&(0,y.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:o.map(e=>(0,y.jsxs)("div",{"data-testid":"composer-thumb","data-status":e.status,title:e.error??e.name,style:{position:"relative",width:56,height:56,borderRadius:8,overflow:"hidden",border:`1px solid ${"failed"===e.status?B.f.failed:C.f.line}`,background:C.f.bg},children:[(0,y.jsx)("img",{src:e.previewUrl,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",opacity:"ready"===e.status?1:.45}}),"uploading"===e.status&&(0,y.jsx)("span",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center"},children:(0,y.jsx)($.m,{blockId:`thumb-${e.key}`,size:18})}),"failed"===e.status&&(0,y.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",color:B.f.failed,fontWeight:900},children:"!"}),(0,y.jsx)("button",{type:"button","aria-label":b.B.attachments.remove(e.name),onClick:()=>{var t;return t=e.key,void a(e=>{let n=e.find(e=>e.key===t);return n&&URL.revokeObjectURL(n.previewUrl),e.filter(e=>e.key!==t)})},style:{position:"absolute",top:2,right:2,width:18,height:18,borderRadius:"50%",border:"none",background:"rgba(0,0,0,0.7)",color:"#fff",fontSize:11,lineHeight:1,cursor:"pointer",display:"grid",placeItems:"center"},children:"✕"})]},e.key))}),(0,y.jsx)("textarea",{ref:x,id:e,"aria-label":t,placeholder:u?b.B.attachments.dropHere:n,value:i,disabled:c,rows:8,onChange:e=>r(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.altKey||e.nativeEvent.isComposing||(s?.enabled?(e.preventDefault(),s.onSend()):l?(e.preventDefault(),l()):s&&""===i.trim()&&e.preventDefault())},style:{width:"100%",boxSizing:"border-box",resize:"vertical",minHeight:d,maxHeight:380,padding:4,background:"transparent",color:"inherit",border:"none",outline:"none",font:"inherit",fontSize:14,lineHeight:1.45,scrollbarWidth:"thin",scrollbarColor:`${B.f.floorLine} transparent`}}),(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,borderTop:`1px solid ${B.f.lineSoft}`,paddingTop:8},children:[(0,y.jsxs)("button",{type:"button",disabled:c||o.length>=6,onClick:()=>g.current?.click(),title:b.B.attachments.add,"aria-label":b.B.attachments.add,style:{display:"inline-flex",alignItems:"center",gap:6,background:"none",border:`1px solid ${C.f.line}`,borderRadius:6,color:"#d6dce6",cursor:"pointer",padding:"4px 10px",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,y.jsx)(sP,{})," ",b.B.attachments.browse]}),(0,y.jsx)("span",{style:{flex:1,fontSize:11.5,color:B.f.dim},children:sT(o)?b.B.attachments.uploading:b.B.attachments.pasteHint}),s&&(0,y.jsx)("button",{type:"button","aria-label":s.label,title:s.label,disabled:!s.enabled,onClick:s.onSend,style:{flex:"none",width:32,height:32,borderRadius:"50%",display:"grid",placeItems:"center",padding:0,border:"none",background:s.enabled?B.f.passed:C.f.line,color:s.enabled?"#07110a":B.f.skipped,cursor:s.enabled?"pointer":"not-allowed"},children:s.busy?(0,y.jsx)($.m,{blockId:"composer-send",size:14}):(0,y.jsx)(sL,{})})]}),(0,y.jsx)("input",{ref:g,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,onChange:e=>{w([...e.target.files??[]]),e.target.value=""}})]}),f&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12,color:B.f.waiting},children:f})]})}function sL(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M14.5 1.5 7 9M14.5 1.5 10 14.5 7 9 1.5 6l13-4.5Z"})})}function sP(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M13 7.5 8 12.5a3.2 3.2 0 0 1-4.5-4.5l5.3-5.3a2.1 2.1 0 0 1 3 3L6.5 11a1.1 1.1 0 0 1-1.5-1.5L10 4.5"})})}var sA=e.i(44094);function sH({runId:e}){let[t,n]=(0,m.useState)(null),[i,r]=(0,m.useState)(null),[o,a]=(0,m.useState)(!1),l=t?.status==="installing"||t?.status==="starting";async function s(t){r(null);try{let i=await fetch(`/api/runs/${e}/preview`,{method:t}),o=await i.json().catch(()=>null);if(!i.ok||!o)return r(o?.error??b.B.preview.failed);n(o)}catch{r(b.B.preview.failed)}}(0,m.useEffect)(()=>{let t=!0,i=()=>fetch(`/api/runs/${e}/preview`).then(e=>e.json()).then(e=>t&&n(e)).catch(()=>void 0);if(i(),!l)return()=>void(t=!1);let r=setInterval(i,1e3);return()=>{t=!1,clearInterval(r)}},[e,l]);let d=t?.status??"stopped",c="installing"===d?b.B.preview.installing:"starting"===d?b.B.preview.starting:"ready"===d?b.B.preview.ready:null;return(0,y.jsxs)("div",{"data-testid":"preview","data-status":d,style:{display:"grid",gap:6},children:[(0,y.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:["ready"===d&&t?.url?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("a",{href:t.url,target:"_blank",rel:"noreferrer",style:{padding:"7px 14px",borderRadius:8,background:B.f.running,color:"#fff",fontWeight:700,textDecoration:"none",fontSize:13},children:["↗ ",b.B.preview.open]}),(0,y.jsx)("button",{type:"button",onClick:()=>void s("DELETE"),style:{background:"none",border:"none",color:B.f.dim,cursor:"pointer",fontSize:12.5},children:b.B.preview.stop})]}):(0,y.jsxs)("button",{type:"button",disabled:l,onClick:()=>void s("POST"),style:{padding:"7px 14px",borderRadius:8,border:`1px solid ${B.f.running}`,background:B.f.tint("running",.12),color:"#cfe0ff",fontWeight:700,fontSize:13,cursor:l?"wait":"pointer"},children:["▶ ",b.B.preview.start]}),c&&(0,y.jsx)("span",{style:{fontSize:12,color:"ready"===d?B.f.dim:"#cfe0ff"},children:c})]}),("failed"===d||i)&&(0,y.jsxs)("div",{role:"alert",style:{fontSize:12.5,color:B.f.failed},children:[i??t?.message??b.B.preview.failed," ",t?.log&&(0,y.jsx)("button",{type:"button",onClick:()=>a(e=>!e),style:{background:"none",border:"none",color:B.f.running,cursor:"pointer",padding:0,fontSize:12.5},children:b.B.preview.showLog})]}),o&&t?.log&&(0,y.jsx)("pre",{style:{margin:0,maxHeight:180,overflow:"auto",background:"#0b0e14",border:`1px solid ${B.f.border}`,borderRadius:8,padding:10,fontSize:11.5,color:"#9aa5b6",whiteSpace:"pre-wrap"},children:t.log})]})}let sF=["needs_you","in_progress","fixed","set_aside"],sO={needs_you:B.f.waiting,in_progress:B.f.running,fixed:B.f.passed,set_aside:B.f.skipped};function sD(e){return sF.flatMap(t=>e.filter(e=>e.ending===t))}let sq={checked:{colour:B.f.passed,icon:(0,y.jsx)("path",{d:"M3 8.5 6.5 12 13 4.5"})},ai:{colour:B.f.waiting,icon:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("path",{d:"M2.5 3.5h11v7h-6l-3 2.5v-2.5h-2z"}),(0,y.jsx)("path",{d:"M5.5 7h.01M8 7h.01M10.5 7h.01"})]})},not_checked:{colour:B.f.dim,icon:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("circle",{cx:"8",cy:"8",r:"5.5",strokeDasharray:"2.4 2.2"}),(0,y.jsx)("path",{d:"M5.5 8h5"})]})}};function sV({how:e,inLegend:t=!1}){let n=sq[e];return(0,y.jsxs)("span",{"data-testid":t?"how-key":"how-mark","data-state":e,title:b.B.findings.howMeans[e],style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:999,border:`1px ${"not_checked"===e?"dashed":"solid"} ${n.colour}`,color:n.colour,fontSize:11.5,fontWeight:700,whiteSpace:"nowrap"},children:[(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:n.icon}),b.B.findings.how[e]]})}function sY({f:e,n:t,touched:n}){let[i,r]=(0,m.useState)(!1),o=(0,m.useId)(),a=e.detail,l=(e,t,n=!1)=>""===t?null:(0,y.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:B.f.dim},children:e}),(0,y.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",fontFamily:n?"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace":void 0,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:t})]});return(0,y.jsxs)("li",{"data-testid":"finding",style:{display:"grid",gap:6,padding:"10px 12px",borderRadius:10,border:`1px solid ${B.f.border}`,borderLeft:`3px solid ${sO[e.ending]}`,background:"#0d1118"},children:[(0,y.jsx)("span",{"data-testid":"finding-number",style:{fontSize:11.5,fontWeight:700,color:B.f.dim},children:b.B.findings.number(t)}),(0,y.jsx)("span",{style:{fontSize:13.5,fontWeight:600,color:B.f.ink,lineHeight:1.4,overflowWrap:"anywhere"},children:e.title}),(0,y.jsx)("span",{style:{fontSize:12.5,color:B.f.dim,lineHeight:1.45,overflowWrap:"anywhere"},children:(0,sA.f)(e.outcome,n)}),(0,y.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,y.jsx)(sV,{how:e.how}),(0,y.jsx)("button",{type:"button",className:"factory-action","aria-expanded":i,"aria-controls":o,onClick:()=>r(e=>!e),style:{background:"none",border:"none",padding:"6px 0 6px 8px",minHeight:32,color:B.f.running,cursor:"pointer",fontSize:12.5},children:b.B.question.seeDetails})]}),i&&(0,y.jsxs)("div",{id:o,style:{display:"grid",gap:8,paddingTop:8,borderTop:`1px solid ${B.f.lineSoft}`},children:[l(b.B.findings.detail.where,a.where,!0),""!==a.problem&&(0,y.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:B.f.waiting},children:b.B.findings.detail.aiSaid}),(0,y.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:(0,sA.f)(a.problem,n)})]}),l(b.B.findings.detail.command,a.command,!0),l(b.B.findings.detail.output,a.outputTail,!0),l(b.B.findings.detail.why,(0,sA.f)(a.reason,n)),""===a.where&&""===a.problem&&""===a.command&&""===a.outputTail&&""===a.reason&&(0,y.jsx)("span",{style:{fontSize:12.5,color:B.f.dim},children:b.B.findings.detail.none})]})]})}function sX({findings:e,touched:t=[]}){let n=new Map(sD(e).map((e,t)=>[e.id,t+1]));return(0,y.jsxs)("section",{"data-testid":"findings-list","aria-label":b.B.findings.heading,style:{display:"grid",gap:10},children:[(0,y.jsx)("h3",{className:"factory-display",style:{margin:0,fontSize:15},children:b.B.findings.heading}),0===e.length&&(0,y.jsx)("p",{style:{margin:0,fontSize:13,color:B.f.dim},children:b.B.findings.none}),e.length>0&&(0,y.jsx)("dl",{"data-testid":"legend","aria-label":b.B.findings.legendTitle,style:{margin:0,display:"grid",gap:6},children:["checked","ai","not_checked"].filter(t=>e.some(e=>e.how===t)).map(e=>(0,y.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 8px"},children:[(0,y.jsx)("dt",{style:{margin:0},children:(0,y.jsx)(sV,{how:e,inLegend:!0})}),(0,y.jsx)("dd",{style:{margin:0,fontSize:12,color:B.f.dim,lineHeight:1.4,flex:"1 1 180px"},children:b.B.findings.howMeans[e]})]},e))}),sF.map(i=>{let r=e.filter(e=>e.ending===i);return 0===r.length?null:(0,y.jsxs)("div",{style:{display:"grid",gap:6},children:[(0,y.jsxs)("h4",{style:{margin:0,display:"flex",alignItems:"center",gap:8,fontSize:12,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:sO[i]},children:[b.B.findings.group[i],(0,y.jsx)("span",{style:{fontSize:11,padding:"0 7px",borderRadius:999,border:`1px solid ${sO[i]}`},children:r.length})]}),(0,y.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:6},children:r.map(e=>(0,y.jsx)(sY,{f:e,n:n.get(e.id)??0,touched:t},e.id))})]},i)})]})}let sU="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace";function sZ({findings:e,touched:t=[],away:n=null,runId:i,risk:r,note:o,imageIds:a,imagesBusy:l,composer:s,onSent:d,onSeeChanges:c}){let[u,p]=(0,m.useState)(null),[f,h]=(0,m.useState)(!1),[g,x]=(0,m.useState)(!1),[v,w]=(0,m.useState)(null),[j,k]=(0,m.useState)(0);async function S(e){if(u){x(!0),w(null);try{let t=await fetch(`/api/runs/${i}/decision`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({decision:e,reason:o.trim()||null,diffHash:u.hash,..."changes"===e?{attachments:a}:{}})}),r=await t.json().catch(()=>null);if(!t.ok){w({text:r?.error??b.B.gate.notDelivered,ok:!1}),409===t.status&&k(e=>e+1);return}w({text:n?b.B.machine.sentElsewhere(n.machine):"approved"===e?b.B.gate.approved:"rejected"===e?b.B.gate.rejected:b.B.gate.changesSent,ok:!0}),d()}catch{w({text:b.B.gate.notDelivered,ok:!1})}finally{x(!1)}}}(0,m.useEffect)(()=>{let e=!0;return fetch(`/api/runs/${i}/review`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(t=>e&&(p(t),h(!1))).catch(()=>e&&h(!0)),()=>{e=!1}},[i,j]);let C=v?.ok===!0,[z,I]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(!C)return;let e=setTimeout(()=>I(!0),2e4);return()=>clearTimeout(e)},[C]);let M=!C&&(""!==o.trim()||a.length>0),E=e=>({flex:1,padding:"9px 12px",borderRadius:8,border:`1px solid ${M?"#2a3140":B.f[e]}`,...M?{background:"#2a3140",color:"#8b95a7"}:{background:"passed"===e?B.f.passed:"transparent",color:"passed"===e?"#07090d":B.f.failed},fontWeight:700,cursor:g||!u||C||M?"not-allowed":"pointer",opacity:g||!u||C?.6:1});return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:B.f.waiting,color:"#1a1206",fontWeight:900,fontSize:17},children:"!"}),(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:b.B.gate.title}),(0,y.jsx)("div",{style:{fontSize:12.5,color:"#d9c9a3"},children:b.B.gate.waiting})]})]}),r&&!c&&(0,y.jsxs)("div",{style:{fontSize:12.5,color:"low"===r.level?B.f.passed:B.f.waiting,lineHeight:1.4},children:[(0,y.jsxs)("strong",{children:[b.B.risk.label[r.level],":"]}),(0,y.jsx)(sK,{reasons:r.reasons,touched:t}),"low"===r.level&&r.stopForMe&&(0,y.jsx)("div",{"data-testid":"stop-for-me-why",style:{color:B.f.waiting},children:b.B.gate.stopForMe})]}),f&&(0,y.jsx)("div",{style:{fontSize:12.5,color:B.f.failed},children:b.B.gate.loadFailed}),!u&&!f&&(0,y.jsxs)("div",{"aria-busy":"true","aria-label":b.B.gate.loading,style:{display:"grid",gap:8,padding:10,borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0d1118"},children:[(0,y.jsx)(l7,{width:"35%",height:10}),(0,y.jsx)(l7,{height:12}),(0,y.jsx)(l7,{width:"80%",height:12})]}),u&&!c&&(0,y.jsx)(sJ,{review:u}),u&&c&&(0,y.jsxs)("button",{type:"button","data-testid":"see-changes",onClick:c,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,padding:"10px 12px",borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0d1118",color:"#e6e9ef",fontSize:13.5,fontWeight:700,cursor:"pointer",textAlign:"left"},children:[(0,y.jsxs)("span",{style:{display:"grid",gap:2},children:[b.B.gate.seeChanges,(0,y.jsx)("span",{style:{fontSize:12,fontWeight:400,color:B.f.dim},children:0===u.files.length?b.B.gate.noFiles:b.B.gate.filesChanged(u.files.length)})]}),(0,y.jsx)("span",{"aria-hidden":"true",style:{flex:"none",display:"grid",placeItems:"center",width:28,height:28,borderRadius:8,background:B.f.tint("running",.16),color:B.f.running},children:(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,y.jsx)("path",{d:"M6 3.5 10.5 8 6 12.5"})})})]}),e&&(0,y.jsx)(sX,{findings:e,touched:t}),u&&u.files.length>0&&!C&&(c?(0,y.jsx)(eI.$,{runId:i,autoStart:!n}):(0,y.jsx)(eI.v,{runId:i,autoStart:!n,canTake:!n})),u&&u.files.length>0&&!C&&!n&&!c&&(0,y.jsx)(sH,{runId:i}),n&&!C&&(0,y.jsx)("div",{style:{fontSize:12,color:B.f.dim,lineHeight:1.4},children:b.B.machine.elsewhere(n.machine)}),!C&&s({label:b.B.gate.askChanges,onSend:()=>void S("changes"),enabled:!g&&null!==u&&!l&&""!==o.trim()}),!C&&(0,y.jsxs)("div",{style:{display:"flex",gap:8,paddingTop:10,borderTop:`1px solid ${B.f.lineSoft}`},children:[(0,y.jsx)("button",{type:"button",disabled:g||!u||l||M,onClick:()=>void S("approved"),style:E("passed"),children:g?b.B.gate.deciding:`✓ ${b.B.gate.approve}`}),(0,y.jsxs)("button",{type:"button",disabled:g||!u||l||M,onClick:()=>void S("rejected"),style:E("failed"),children:["✕ ",b.B.gate.reject]})]}),M&&(0,y.jsx)("span",{role:"note","data-testid":"gate-unsent",style:{fontSize:12.5,color:"#f3d9a4",textAlign:"center",lineHeight:1.45},children:b.B.gate.unsent}),v&&(0,y.jsxs)("div",{role:v.ok?"status":"alert",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:v.ok?B.f.passed:B.f.failed},children:[v.ok&&!z&&(0,y.jsx)($.m,{blockId:"gate",size:16}),v.text]}),C&&z&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12.5,color:B.f.waiting,lineHeight:1.4},children:b.B.gate.notPickedUp})]})}function sK({reasons:e,touched:t=[]}){return(0,y.jsx)("ul",{style:{margin:"2px 0 0",padding:0,listStyle:"none",display:"grid",gap:2},children:e.map((e,n)=>(0,y.jsx)("li",{"data-testid":"risk-reason",style:{overflowWrap:"anywhere"},children:(0,sA.f)((0,b.g)(e),t)},n))})}function sG({diff:e,truncated:t}){return(0,y.jsxs)(y.Fragment,{children:[e.split("\n").map((e,t)=>(0,y.jsx)("div",{style:{color:e.startsWith("+")?"#86efac":e.startsWith("-")?"#fca5a5":e.startsWith("@@")?"#93c5fd":"#9aa5b6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",paddingLeft:"1.2em",textIndent:"-1.2em"},children:e||" "},t)),t&&(0,y.jsx)("div",{style:{color:B.f.waiting},children:b.B.gate.truncated})]})}function sJ({review:e,roomy:t=!1}){let[n,i]=(0,m.useState)(!1),[r,o]=(0,m.useState)(!1),a=t||n;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{"data-testid":"gate-changes",style:{display:"grid",gap:6,maxHeight:t?"min(56vh, 600px)":a?260:180,overflowY:"auto",padding:10,borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0d1118",scrollbarWidth:"thin",scrollbarColor:`${B.f.floorLine} transparent`},children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,y.jsx)("div",{style:{fontSize:12.5,color:B.f.dim},children:0===e.files.length?b.B.gate.noFiles:b.B.gate.filesChanged(e.files.length)}),e.diff&&!t&&(0,y.jsx)("button",{type:"button","aria-label":b.B.gate.expandChanges,title:b.B.gate.expandChanges,onClick:()=>o(!0),style:{display:"grid",placeItems:"center",width:26,height:26,padding:0,borderRadius:6,border:`1px solid ${B.f.border}`,background:B.f.card,color:"#d6dce6",cursor:"pointer"},children:(0,y.jsx)(s1,{})})]}),e.files.slice(0,8).map(e=>(0,y.jsxs)("div",{style:{display:"flex",gap:8,fontFamily:sU,fontSize:12,color:"#d6dce6"},children:[(0,y.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.path,children:e.path}),(0,y.jsxs)("span",{style:{color:B.f.passed},children:["+",e.added]}),(0,y.jsxs)("span",{style:{color:B.f.failed},children:["−",e.removed]})]},e.path)),e.files.length>8&&(0,y.jsx)("div",{style:{fontSize:12,color:B.f.dim},children:b.B.canvas.andMore(e.files.length-8)}),e.diff&&!t&&(0,y.jsx)("button",{type:"button",onClick:()=>i(e=>!e),style:{justifySelf:"start",background:"none",border:"none",color:B.f.running,cursor:"pointer",padding:0,fontSize:12.5},children:a?b.B.gate.hideChanges:b.B.gate.showChanges}),a&&(0,y.jsx)("pre",{"data-testid":"gate-diff",style:{margin:0,background:"#0b0e14",border:`1px solid ${B.f.border}`,borderRadius:8,padding:10,fontSize:12,lineHeight:1.5},children:(0,y.jsx)(sG,{diff:e.diff,truncated:e.truncated})})]}),r&&e&&(0,y.jsx)(s0,{files:e.files,diff:e.diff,truncated:e.truncated,onClose:()=>o(!1)})]})}function sQ({runId:e,risk:t,away:n=null,decided:i=!1}){let[r,o]=(0,m.useState)(null),[a,l]=(0,m.useState)(!1);return((0,m.useEffect)(()=>{let t=!0;return fetch(`/api/runs/${e}/review`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(e=>t&&o(e)).catch(()=>t&&l(!0)),()=>{t=!1}},[e]),a)?(0,y.jsx)("div",{style:{fontSize:13,color:B.f.failed},children:b.B.gate.loadFailed}):r?(0,y.jsxs)("div",{"data-testid":"change-under-check",style:{display:"grid",gap:12},children:[t&&(0,y.jsxs)("div",{style:{fontSize:13.5,color:"low"===t.level?B.f.passed:B.f.waiting,lineHeight:1.5},children:[(0,y.jsxs)("strong",{children:[b.B.risk.label[t.level],":"]}),(0,y.jsx)(sK,{reasons:t.reasons}),"low"===t.level&&t.stopForMe&&(0,y.jsx)("div",{"data-testid":"stop-for-me-why",style:{color:B.f.waiting},children:b.B.gate.stopForMe})]}),(0,y.jsx)(sJ,{review:r,roomy:!0}),r.files.length>0&&!n&&!i&&(0,y.jsx)(sH,{runId:e}),n&&(0,y.jsx)("div",{style:{fontSize:12.5,color:B.f.dim},children:b.B.machine.elsewhere(n.machine)})]}):(0,y.jsx)(l7,{height:60,radius:10})}function s0({files:e,diff:t,truncated:n,onClose:i}){let r=(0,m.useRef)(null);return(0,m.useEffect)(()=>{r.current?.focus();let e=e=>{"Escape"===e.key&&i()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i]),(0,oi.createPortal)((0,y.jsx)("div",{"data-testid":"changes-modal",onClick:i,style:{position:"fixed",inset:0,zIndex:100,background:"rgba(5, 7, 11, 0.7)",display:"grid",gridTemplateRows:"minmax(0, 1fr)",gridTemplateColumns:"minmax(0, 1fr)",placeItems:"center",padding:24},children:(0,y.jsxs)("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":b.B.gate.changesTitle,tabIndex:-1,onClick:e=>e.stopPropagation(),style:{width:"min(1100px, 100%)",height:"min(86vh, calc(100vh - 48px))",minHeight:0,display:"flex",flexDirection:"column",background:B.f.bg,border:`1px solid ${B.f.border}`,borderRadius:14,boxShadow:"0 30px 80px rgba(0,0,0,0.6)",outline:"none",color:"#e6e9ef"},children:[(0,y.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"12px 16px",borderBottom:`1px solid ${B.f.border}`},children:[(0,y.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,y.jsx)("div",{className:"factory-display",style:{fontSize:19},children:b.B.gate.changesTitle}),(0,y.jsx)("div",{style:{fontSize:12,color:B.f.dim,fontFamily:sU},children:e.map(e=>`${e.path} +${e.added} −${e.removed}`).join(" · ")})]}),(0,y.jsx)("button",{type:"button","aria-label":b.B.gate.closeChanges,onClick:i,style:{background:"none",border:"none",color:B.f.skipped,cursor:"pointer",fontSize:18,lineHeight:1,padding:6},children:"✕"})]}),(0,y.jsx)("pre",{style:{flex:1,minHeight:0,margin:0,overflow:"auto",padding:16,fontFamily:sU,fontSize:13,lineHeight:1.55,background:"#0b0e14",borderRadius:"0 0 14px 14px",scrollbarWidth:"thin",scrollbarColor:`${B.f.floorLine} transparent`},children:(0,y.jsx)(sG,{diff:t,truncated:n})})]})}),document.body)}function s1(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M9.5 2.5h4v4M13.5 2.5 9 7M6.5 13.5h-4v-4M2.5 13.5 7 9"})})}let s2="other",s5="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",s4=e=>e.length>400?`${e.slice(0,399)}…`:e;function s6({question:e,onAnswer:t,position:n,touched:i=[],finding:r}){let[o,a]=(0,m.useState)(null),[l,s]=(0,m.useState)(""),[d,c]=(0,m.useState)(!1),[u,p]=(0,m.useState)(!1),[f,h]=(0,m.useState)(null),[g,x]=(0,m.useState)(!1),v=(0,m.useRef)(!1),w=(0,m.useId)(),j=(0,m.useId)(),k=o??(""!==l.trim()?s2:null),S=null!==k,C=d||u;async function z(){if(S&&!v.current&&!u){v.current=!0,c(!0),h(null);try{await t(k,""!==l.trim()?l.trim():void 0),p(!0)}catch(e){h(e instanceof Error&&e.message?e.message:b.B.question.failed)}finally{v.current=!1,c(!1)}}}let I=i.filter(t=>e.touches.includes(t.number)),M=r?.problem.trim()?r.problem.trim():null,$=M?[r.where.trim()?{label:b.B.findings.detail.where,text:r.where.trim(),mono:!1}:null,r.command.trim()?{label:b.B.findings.detail.command,text:r.command.trim(),mono:!0}:null,r.outputTail.trim()?{label:b.B.findings.detail.output,text:r.outputTail.trim(),mono:!0}:null].filter(e=>null!==e):[],E=e.detail&&(!M||"fix_held"===e.kind)?e.detail:null,_=$.length>0||null!==E;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{flex:"none",width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:B.f.waiting,color:"#1a1206",fontWeight:900,fontSize:17},children:"?"}),(0,y.jsxs)("div",{style:{minWidth:0},children:[(0,y.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:b.B.question.title}),(0,y.jsx)("div",{style:{fontSize:12.5,color:"#d9c9a3"},children:b.B.question.waiting})]})]}),n&&n.of>1&&(0,y.jsx)("div",{style:{fontSize:11.5,fontWeight:700,letterSpacing:"0.04em",color:B.f.dim},children:b.B.question.position(n.n,n.of)}),(0,y.jsx)("p",{style:{margin:0,fontSize:15,lineHeight:1.45,color:B.f.ink,fontWeight:600,overflowWrap:"anywhere"},children:(0,sA.f)(e.text,i)}),e.why&&(0,y.jsx)("p",{style:{margin:0,fontSize:13,lineHeight:1.5,color:B.f.dim,overflowWrap:"anywhere"},children:(0,sA.f)(e.why,i)}),I.length>0&&(0,y.jsxs)("div",{style:{display:"grid",gap:4,fontSize:12.5,color:B.f.dim},children:[(0,y.jsx)("span",{style:{fontWeight:700},children:b.B.question.touchesTitle}),(0,y.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:I.map(e=>(0,y.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"baseline",padding:"6px 8px",borderRadius:8,border:`1px solid ${B.f.border}`,background:"#0d1118",color:"#d6dce6",overflowWrap:"anywhere"},children:[(0,y.jsx)("span",{style:{flex:"none",fontFamily:s5,fontSize:11.5,color:B.f.waiting},children:e.label}),(0,y.jsx)("span",{children:e.text})]},e.number))})]}),M&&(0,y.jsxs)("div",{style:{display:"grid",gap:4,padding:10,borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0d1118",minWidth:0},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:B.f.waiting},children:b.B.question.aiSaid}),(0,y.jsx)("span",{style:{fontSize:13,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:(0,sA.f)(s4(M),i)})]}),_&&(0,y.jsxs)("div",{style:{display:"grid",gap:6},children:[(0,y.jsx)("button",{type:"button",className:"factory-action","aria-expanded":g,"aria-controls":j,onClick:()=>x(e=>!e),style:{justifySelf:"start",background:"none",border:"none",padding:"6px 8px 6px 0",minHeight:32,color:B.f.running,cursor:"pointer",fontSize:12.5},children:b.B.question.seeDetails}),g&&(0,y.jsxs)("div",{id:j,style:{display:"grid",gap:8,padding:10,borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0d1118",minWidth:0},children:[$.map(e=>(0,y.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:B.f.dim},children:e.label}),(0,y.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",...e.mono?{fontFamily:s5,fontSize:12}:{}},children:e.text})]},e.label)),E&&(0,y.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:B.f.waiting},children:M?b.B.question.moreAbout:b.B.question.aiSaid}),(0,y.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:(0,sA.f)(E,i)})]})]})]}),(0,y.jsxs)("fieldset",{disabled:C,style:{margin:0,padding:0,border:"none",minWidth:0,display:"grid",gap:8},children:[(0,y.jsx)("legend",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:b.B.question.choicesLabel}),e.options.map(t=>{let n=o===t.id;return(0,y.jsxs)("label",{className:"factory-choice",style:{display:"flex",gap:10,alignItems:"flex-start",padding:"10px 12px",borderRadius:10,border:`1px solid ${n?B.f.waiting:B.f.border}`,background:n?B.f.tint("waiting",.1):"#0d1118",cursor:C?"not-allowed":"pointer"},children:[(0,y.jsx)("input",{type:"radio",name:w,value:t.id,checked:n,onChange:()=>a(t.id),style:{flex:"none",width:18,height:18,margin:"1px 0 0",accentColor:B.f.waiting,cursor:"inherit"}}),(0,y.jsxs)("span",{style:{display:"grid",gap:3,minWidth:0},children:[(0,y.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center",fontSize:14,fontWeight:700,color:B.f.ink},children:[t.label,e.recommended===t.id&&(0,y.jsx)("span",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:"#1a1206",background:B.f.waiting,borderRadius:999,padding:"2px 7px"},children:b.B.question.recommended})]}),(0,y.jsx)("span",{style:{fontSize:12.5,lineHeight:1.45,color:B.f.dim,overflowWrap:"anywhere"},children:t.means})]})]},t.id)}),(0,y.jsxs)("label",{style:{display:"grid",gap:4,fontSize:12.5,fontWeight:600,color:B.f.dim},children:[null===o?b.B.question.ownWordsLabel:b.B.question.noteLabel,(0,y.jsx)("textarea",{value:l,rows:3,placeholder:null===o?b.B.question.ownWordsPlaceholder:b.B.question.notePlaceholder,onChange:e=>s(e.target.value),style:{font:"inherit",fontSize:13,fontWeight:400,padding:"8px 10px",boxSizing:"border-box",width:"100%",resize:"vertical",background:"#0b0e14",color:"#e6e9ef",border:`1px solid ${B.f.border}`,borderRadius:8}})]})]}),(0,y.jsx)("button",{type:"button",className:"factory-action",disabled:!S||C,onClick:()=>void z(),style:{padding:"10px 12px",borderRadius:8,border:`1px solid ${B.f.waiting}`,background:S&&!C?B.f.waiting:"transparent",color:S&&!C?"#1a1206":B.f.skipped,fontWeight:700,fontSize:14,cursor:S&&!C?"pointer":"not-allowed"},children:d?b.B.question.sending:b.B.question.confirm}),f&&(0,y.jsx)("div",{role:"alert",style:{fontSize:13,fontWeight:600,color:B.f.failed,lineHeight:1.4},children:f}),u&&(0,y.jsx)("div",{role:"status",style:{fontSize:13,fontWeight:600,color:B.f.passed},children:b.B.question.sent})]})}function s3({runId:e,record:t,failed:n=!1,mark:i=0,readMark:r=0,askedId:o=null,onChanged:a}){let l=r<i,s=t?.question&&!(l&&null!==o&&t.question.id!==o)?t.question:null,[d,c]=(0,m.useState)(null),[u,p]=(0,m.useState)(null);s&&d?.id!==s.id&&(c(s),p(null));let f=(0,y.jsxs)("div",{role:"alert",style:{display:"grid",gap:8,fontSize:13,color:B.f.failed,lineHeight:1.4},children:[b.B.question.loadFailed,(0,y.jsx)("button",{type:"button",className:"factory-action",onClick:a,style:{justifySelf:"start",minHeight:32,padding:"6px 12px",borderRadius:8,border:`1px solid ${B.f.border}`,background:"#0f141c",color:"#e6e9ef",fontWeight:700,cursor:"pointer"},children:b.B.question.tryAgain})]});if(!s)return!t||l||n?n?f:(0,y.jsxs)("div",{"aria-busy":"true","aria-label":b.B.question.title,style:{display:"grid",gap:8},children:[(0,y.jsx)(l7,{height:20,width:"60%"}),(0,y.jsx)(l7,{height:70,radius:10})]}):(0,y.jsx)("div",{role:"status",style:{fontSize:13.5,fontWeight:600,color:B.f.dim,lineHeight:1.45},children:u??b.B.question.closed});async function h(t,n,i){let r;try{r=await fetch(`/api/runs/${encodeURIComponent(e)}/questions/${encodeURIComponent(s.id)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({option:t,...void 0!==n?{text:n}:{},...i&&i.length>0?{attachments:i}:{}})})}catch{throw Error(b.B.question.failed)}if(!r.ok){let e=await r.json().catch(()=>null),t=e?.error??b.B.question.failed;throw p(t),a(),Error(t)}a()}if("direct"===s.kind)return(0,y.jsxs)(y.Fragment,{children:[n&&f,(0,y.jsx)(s9,{question:s,onAnswer:h},s.id)]});let g=sD(t.findings),x=g.findIndex(e=>e.id===s.findingId);return(0,y.jsxs)(y.Fragment,{children:[n&&f,(0,y.jsx)(s6,{question:s,touched:t.touched,onAnswer:h,position:x>=0?{n:x+1,of:g.length}:void 0,...x>=0?{finding:g[x].detail}:{}},s.id)]})}let s8=b.B.direct;function s9({question:e,onAnswer:t}){let[n,i]=(0,m.useState)(""),[r,o]=(0,m.useState)([]),[a,l]=(0,m.useState)(null),[s,d]=(0,m.useState)(null),c=(0,m.useRef)(!1),u=(0,m.useId)(),p=Number(/^direct-(\d+)/.exec(e.findingId??"")?.[1]??1),f=e.text===s8.lastText,h=e.options.some(e=>"undo"===e.id),g=!f&&(""!==n.trim()||r.length>0);async function x(e){if(!(c.current||"next"===e&&(""===n.trim()||sT(r)))&&("done"!==e||!g)){c.current=!0,l(e),d(null);try{await ("done"===e?t("leave"):"undo"===e?t("undo"):t(s2,n.trim(),sN(r)))}catch(e){d(e instanceof Error&&e.message?e.message:b.B.question.failed),c.current=!1,l(null)}}}let v=null!==a;return(0,y.jsxs)("div",{"data-testid":"direct-pause",style:{display:"grid",gap:12},children:[(0,y.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,y.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:s8.pauseTitle}),(0,y.jsxs)("div",{style:{fontSize:13,color:B.f.dim,lineHeight:1.45},children:[s8.look," ",s8.pauseWhy]})]}),e.detail&&(0,y.jsxs)("div",{style:{display:"grid",gap:4,padding:"10px 12px",borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0f141c"},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.1em",textTransform:"uppercase",color:B.f.dim},children:s8.lastBuilt}),(0,y.jsx)("span",{style:{fontSize:13.5,lineHeight:1.45,overflowWrap:"anywhere"},children:s4(e.detail)})]}),(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,fontSize:12,color:B.f.dim},children:[(0,y.jsx)("span",{children:s8.count(p)}),h&&(0,y.jsxs)("button",{type:"button",className:"factory-action","data-testid":"direct-undo",disabled:v,title:s8.undoMeans,onClick:()=>void x("undo"),style:{background:"none",border:"none",padding:0,color:"#cfe0ff",font:"inherit",fontWeight:700,cursor:v?"default":"pointer"},children:["↩ ","undo"===a?s8.sending:s8.undo]})]}),(p>=5||f)&&(0,y.jsx)("div",{role:"note","data-testid":"direct-many",style:{padding:"9px 12px",borderRadius:10,border:`1px solid ${B.f.waiting}`,color:"#f3d9a4",fontSize:13,lineHeight:1.45},children:f?s8.lastText:s8.many}),!f&&(0,y.jsx)(sW,{inputId:u,label:s8.nextLabel,placeholder:s8.nextPlaceholder,text:n,onText:i,images:r,onImages:o,minHeight:96,disabled:v,onSubmit:()=>void x("next"),send:{label:s8.send,onSend:()=>void x("next"),enabled:!v&&""!==n.trim()&&!sT(r),busy:"next"===a}}),(0,y.jsxs)("div",{style:{display:"grid",gap:5,paddingTop:12,borderTop:`1px solid ${B.f.border}`},children:[(0,y.jsx)("button",{type:"button",className:"factory-action","data-testid":"direct-done",disabled:v||g,onClick:()=>void x("done"),style:{minHeight:40,padding:"9px 16px",borderRadius:9,border:"none",background:g?"#2a3140":B.f.passed,color:g?"#8b95a7":"#0d1f12",fontWeight:800,fontSize:14.5,cursor:g?"not-allowed":v?"default":"pointer"},children:"done"===a?s8.sending:s8.done}),g?(0,y.jsx)("span",{role:"note","data-testid":"direct-unsent",style:{fontSize:12.5,color:"#f3d9a4",textAlign:"center",lineHeight:1.45},children:s8.unsent}):(0,y.jsx)("span",{style:{fontSize:12,color:B.f.dim,textAlign:"center"},children:s8.doneHint})]}),s&&(0,y.jsx)("div",{role:"alert",style:{fontSize:13,color:B.f.failed},children:s})]})}function s7({runId:e,note:t,composer:n,onSent:i,measure:r}){let o=(0,m.useRef)(null),[a,l]=(0,m.useState)(new Set),[s,d]=(0,m.useState)(null),[c,u]=(0,m.useState)(null),[p,f]=(0,m.useState)(null),[h,g]=(0,m.useState)(!1),[x,v]=(0,m.useState)(!1);(0,m.useEffect)(()=>{let t=!0;return fetch(`/api/runs/${e}/plan`).then(e=>e.ok?e.json():null).then(e=>t&&d((e?.plan?.jobs??[]).map((e,t)=>({key:`j${t}-${Date.now()}`,title:e.title,done:e.done.join("\n"),...e.paths?{paths:e.paths}:{}})))).catch(()=>t&&d([])),()=>{t=!1}},[e]);let w=p?.ok===!0;async function j(t,n){u(n),f(null);try{let r=await fetch(`/api/runs/${e}/plan`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}),o=await r.json().catch(()=>null);if(!r.ok)return f({ok:!1,text:o?.error??b.B.run.startFailed});if(o&&!1===o.delivered&&"machine"in o)return f({ok:!0,text:b.B.machine.sentElsewhere(o.machine??null)});f({ok:!0,text:"build"===n?b.B.plan.building_sent:b.B.plan.replanned}),"replan"===n&&i()}catch{f({ok:!1,text:b.B.run.startFailed})}finally{u(null)}}(0,m.useEffect)(()=>{if(!w)return;let e=setTimeout(()=>g(!0),2e4);return()=>clearTimeout(e)},[w]);let k=(e,t)=>d(n=>(n??[]).map(n=>n.key===e?{...n,...t}:n)),S=s?s.map(e=>({title:e.title.trim(),done:e.done.split("\n").map(e=>e.trim()).filter(Boolean),...e.paths?{paths:e.paths}:{}})).filter(e=>""!==e.title):[],C=null!==c||w,z={width:"100%",boxSizing:"border-box",background:"#0b0e14",color:"#d6dce6",border:`1px solid ${B.f.border}`,borderRadius:6,font:"inherit"};return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:B.f.waiting,color:"#1a1206"},children:(0,y.jsx)(de,{})}),(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:b.B.plan.title}),(0,y.jsx)("div",{style:{fontSize:12.5,color:"#d9c9a3"},children:b.B.plan.waiting})]})]}),r&&r.reasons.length>0&&(0,y.jsxs)("div",{"data-testid":"plan-why",style:{display:"grid",gap:6,fontSize:13,lineHeight:1.45,color:"#d9c9a3",overflowWrap:"anywhere"},children:[x?(0,y.jsx)("ul",{style:{margin:0,paddingLeft:18,display:"grid",gap:4},children:r.reasons.map((e,t)=>(0,y.jsx)("li",{children:e},t))}):(0,y.jsx)("span",{children:r.reasons[0]}),r.question&&(0,y.jsx)("span",{"data-testid":"plan-question",style:{color:"#f1e6c8",fontWeight:600},children:r.question}),r.reasons.length>1&&(0,y.jsx)("button",{type:"button","aria-expanded":x,onClick:()=>v(e=>!e),style:{justifySelf:"start",padding:0,background:"none",border:"none",color:"#9cc2ff",fontSize:12.5,cursor:"pointer",textDecoration:"underline"},children:b.B.plan.whyStopped})]}),null===s?(0,y.jsxs)("div",{"aria-busy":"true",style:{display:"grid",gap:8},children:[(0,y.jsx)(l7,{height:70,radius:10}),(0,y.jsx)(l7,{height:70,radius:10})]}):(0,y.jsx)("ol",{ref:o,"data-testid":"plan-jobs",style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:8,maxHeight:"min(52vh, 560px)",overflowY:"auto",paddingRight:4,scrollbarWidth:"thin",scrollbarColor:`${B.f.skipped} transparent`},children:s.map((e,t)=>(0,y.jsxs)("li",{className:"factory-job-in",style:{display:"grid",gap:6,padding:10,borderRadius:10,border:`1px solid ${B.f.border}`,background:"#0d1118",animationDelay:`${300+260*Math.min(t,6)}ms`},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{fontSize:11,color:B.f.dim,paddingLeft:28},children:b.B.plan.jobWhat}),(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:-3},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{flex:"none",width:20,height:20,borderRadius:"50%",display:"grid",placeItems:"center",fontSize:11,fontWeight:800,background:B.f.tint("waiting",.2),color:B.f.waiting},children:t+1}),(0,y.jsx)("input",{"aria-label":b.B.plan.jobLabel(t+1),value:e.title,placeholder:b.B.plan.jobPlaceholder,disabled:C,onChange:t=>k(e.key,{title:t.target.value}),style:{...z,flex:1,minWidth:0,padding:"6px 8px",fontSize:13,fontWeight:600}}),(0,y.jsx)("button",{type:"button","aria-label":b.B.plan.removeJob(t+1),title:b.B.plan.removeJob(t+1),disabled:C,onClick:()=>d(t=>(t??[]).filter(t=>t.key!==e.key)),style:{flex:"none",width:26,height:26,display:"grid",placeItems:"center",padding:0,background:"none",border:"none",color:B.f.skipped,cursor:"pointer"},children:(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M2.5 4h11M6.5 4V2.5h3V4M4 4l.7 9.5h6.6L12 4"})})})]}),""!==e.done.trim()||a.has(e.key)?(0,y.jsxs)("label",{style:{display:"grid",gap:3,fontSize:11,color:B.f.dim,paddingLeft:28},children:[b.B.plan.doneLabel,(0,y.jsx)("textarea",{value:e.done,rows:Math.max(1,e.done.split("\n").length),placeholder:b.B.plan.donePlaceholder,disabled:C,onFocus:()=>l(t=>t.has(e.key)?t:new Set(t).add(e.key)),onChange:t=>k(e.key,{done:t.target.value}),style:{...z,padding:"5px 8px",fontSize:12,lineHeight:1.45,resize:"vertical"}})]}):!C&&(0,y.jsxs)("button",{type:"button",onClick:()=>l(t=>new Set(t).add(e.key)),style:{justifySelf:"start",marginLeft:28,padding:0,background:"none",border:"none",color:B.f.dim,fontSize:11.5,cursor:"pointer",textDecoration:"underline"},children:["+ ",b.B.plan.addChecks]})]},e.key))}),null!==s&&!C&&(0,y.jsxs)("button",{type:"button",onClick:()=>{d(e=>[...e??[],{key:`new-${Date.now()}`,title:"",done:""}]),requestAnimationFrame(()=>{let e=o.current?.lastElementChild;e?.scrollIntoView?.({block:"nearest",behavior:"smooth"}),e?.querySelector("input")?.focus({preventScroll:!0})})},style:{justifySelf:"start",display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:6,border:`1px dashed ${B.f.border}`,background:"transparent",color:"#d6dce6",fontSize:12.5,fontWeight:600,cursor:"pointer"},children:[(0,y.jsx)("span",{"aria-hidden":"true",children:"+"})," ",b.B.plan.addJob]}),!w&&(0,y.jsxs)("button",{type:"button",disabled:C||0===S.length,onClick:()=>void j({action:"build",jobs:S},"build"),className:"factory-call",style:{padding:"9px 12px",borderRadius:8,border:`1px solid ${B.f.passed}`,background:S.length>0?B.f.passed:"transparent",color:S.length>0?"#07110a":B.f.skipped,fontWeight:700,cursor:C?"wait":0===S.length?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:["build"===c?(0,y.jsx)($.m,{blockId:"plan-build",size:16}):(0,y.jsx)("span",{"aria-hidden":"true",children:"▶"})," ","build"===c?b.B.plan.building:b.B.plan.build]}),!w&&(0,y.jsx)("div",{style:{paddingTop:10,borderTop:`1px solid ${B.f.lineSoft}`,display:"grid"},children:n({label:b.B.plan.replan,onSend:()=>void j({action:"replan",note:t},"replan"),enabled:!C&&""!==t.trim()})}),p&&(0,y.jsxs)("div",{role:p.ok?"status":"alert",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:p.ok?B.f.passed:B.f.failed},children:[p.ok&&!h&&(0,y.jsx)($.m,{blockId:"plan-sent",size:16}),p.text]}),w&&h&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12.5,color:B.f.waiting,lineHeight:1.4},children:b.B.plan.notPickedUp})]})}function de(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M6 4h7.5M6 8h7.5M6 12h7.5M2.5 4h.01M2.5 8h.01M2.5 12h.01"})})}let dt=b.B.delivery;function dn({runId:e,button:t}){let[n,i]=(0,m.useState)("idle"),[r,o]=(0,m.useState)(null),[a,l]=(0,m.useState)(null),s=(0,m.useRef)(null),d=(0,m.useRef)(!1);async function c(){s.current=window.open("","_blank"),d.current=!1,l(null),i("starting");let t=await fetch(`/api/runs/${e}/preview`,{method:"POST"}).catch(()=>null);if(d.current=!0,!t?.ok){let e=await t?.json().catch(()=>null);s.current?.close(),s.current=null,l(e?.error??null),i("failed")}}return((0,m.useEffect)(()=>{if("starting"!==n&&"open"!==n)return;let t=!0,r=async()=>{let r=await fetch(`/api/runs/${e}/preview`).catch(()=>null),a=r?.ok?await r.json().catch(()=>null):null;t&&a&&d.current&&("ready"===a.status&&a.url?(o(a.url),"starting"===n&&(s.current&&!s.current.closed?s.current.location.href=a.url:window.open(a.url,"_blank","noopener"),s.current=null,i("open"))):"open"===n&&"installing"!==a.status&&"starting"!==a.status?(o(null),i("idle")):("failed"===a.status||"stopped"===a.status)&&(s.current?.close(),s.current=null,l(a.message),i("failed")))},a=setInterval(()=>void r(),2e3);return r(),()=>{t=!1,clearInterval(a)}},[n,e]),"starting"===n)?(0,y.jsxs)("div",{"data-testid":"open-site",role:"status",style:{display:"grid",gap:4},children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"#d6dce6"},children:[(0,y.jsx)($.m,{blockId:"open-site",size:16})," ",dt.openingSite]}),(0,y.jsx)("div",{style:{fontSize:11.5,color:B.f.dim,lineHeight:1.4},children:dt.openingSiteHint})]}):"open"===n&&r?(0,y.jsxs)("div",{"data-testid":"open-site",style:{display:"grid",gap:6},children:[(0,y.jsxs)("div",{style:{fontSize:12.5,color:B.f.passed,lineHeight:1.4},children:["✓ ",dt.siteOpen]}),(0,y.jsxs)("a",{href:r,target:"_blank",rel:"noopener noreferrer",style:{...t(!1),textDecoration:"none"},children:["↗ ",dt.openSiteAgain]})]}):(0,y.jsxs)("div",{"data-testid":"open-site",style:{display:"grid",gap:4},children:["failed"===n&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12.5,color:B.f.failed,lineHeight:1.4},children:a??dt.siteFailed}),(0,y.jsxs)("button",{type:"button",onClick:()=>void c(),style:t(!1),children:["↗ ","failed"===n?dt.siteTryAgain:dt.openSite]}),"idle"===n&&(0,y.jsx)("div",{style:{fontSize:11.5,color:B.f.dim,lineHeight:1.4},children:dt.openSiteWhat})]})}let di={pending:{glyph:"…",colour:B.f.waiting},passed:{glyph:"✓",colour:B.f.passed},failed:{glyph:"✕",colour:B.f.failed},neutral:{glyph:"·",colour:B.f.skipped}};function dr({checks:e}){return(0,y.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:3,fontSize:12},children:e.map((e,t)=>(0,y.jsxs)("li",{style:{display:"flex",gap:6,alignItems:"baseline"},children:[(0,y.jsx)("span",{"aria-hidden":"true",style:{color:di[e.state].colour,fontWeight:800,width:12},children:di[e.state].glyph}),e.url?(0,y.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:C.f.green},children:e.name}):(0,y.jsx)("span",{children:e.name}),(0,y.jsx)("span",{style:{color:B.f.dim},children:b.B.ship.checkState[e.state]})]},`${e.name}-${t}`))})}function da({runId:e,button:t,onState:n,canOpen:i=!0,onRecorded:r}){let[o,a]=(0,m.useState)(null),l=(0,m.useCallback)(e=>{a({...e,readAt:Date.now()}),n?.(e)},[n]),[s,d]=(0,m.useState)(null),[c,u]=(0,m.useState)(!1),[p,f]=(0,m.useState)(null),h=(0,m.useCallback)(()=>{fetch(`/api/runs/${e}/ship`).then(e=>e.ok?e.json():null).then(e=>e&&l(e)).catch(()=>void 0)},[e,l]);(0,m.useEffect)(h,[h]);let g=o?.pr?.state==="open",x=o?.pr?.state==="merged",v=x&&!0===o.deployPending,j=o?.conflictFix?.status==="working"||o?.conflictFix?.status==="done"&&o.pr?.conflicts===!0,k=g&&!o.checksDone||v||j;async function S(t){d(t),f(null);try{let n=await fetch(`/api/runs/${e}/ship`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:t})}),i=await n.json().catch(()=>null);if(!n.ok||!i)return f(i?.error??b.B.run.startFailed);l(i),u(!1),"fix-conflict"===t&&window.dispatchEvent(new Event(E)),r?.()}catch{f(b.B.run.startFailed)}finally{d(null)}}if((0,m.useEffect)(()=>{if(!k)return;let e=setInterval(h,8e3);return()=>clearInterval(e)},[k,h]),null===o)return(0,y.jsxs)("div",{"data-testid":"ship-skeleton","aria-busy":"true",style:{display:"grid",gap:6},children:[(0,y.jsx)(l7,{height:38,radius:8}),(0,y.jsx)(l7,{width:"70%",height:10})]});let z={fontSize:11.5,color:B.f.dim,lineHeight:1.4};return(0,y.jsxs)("div",{"data-testid":"ship-section",style:{display:"grid",gap:6},children:[!o.pr&&i&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("button",{type:"button",disabled:null!==s,onClick:()=>void S("open"),style:t(s),children:["open"===s?(0,y.jsx)($.m,{blockId:"ship-open",size:16}):(0,y.jsx)(dl,{})," ","open"===s?b.B.ship.opening:b.B.ship.shipIt]}),(0,y.jsx)("div",{style:{...z,marginTop:-2},children:b.B.ship.shipWhat})]}),o.pr&&(0,y.jsxs)("div",{style:{display:"grid",gap:6,fontSize:12.5,lineHeight:1.4},children:[(0,y.jsxs)("a",{href:o.pr.url,target:"_blank",rel:"noopener noreferrer",style:{color:C.f.green,fontWeight:600,fontSize:12},children:[b.B.ship.pr(o.pr.number)," ↗"]}),"closed"===o.pr.state&&(0,y.jsx)("span",{style:{color:B.f.failed},children:b.B.ship.closed}),g&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.1em",textTransform:"uppercase",color:B.f.dim},children:b.B.ship.checksTitle}),!o.checksDone&&(0,y.jsxs)("div",{role:"status","data-testid":"ship-checking",style:{display:"flex",gap:10,alignItems:"center",padding:"10px 12px",borderRadius:8,border:`1px solid ${B.f.tint("running",.5)}`,background:B.f.tint("running",.1),color:"#cfe0ff",fontSize:13,fontWeight:600,lineHeight:1.4},children:[(0,y.jsx)($.m,{blockId:"ship-checks",size:18}),0===o.checks.length?b.B.ship.looking:b.B.ship.waiting]}),o.checks.length>0&&(0,y.jsx)(dr,{checks:o.checks}),o.checksDone&&0===o.checks.length&&(0,y.jsx)("span",{style:z,children:b.B.ship.noChecks}),o.checksDone&&o.checks.length>0&&!o.checksFailed&&(0,y.jsxs)("span",{style:{color:B.f.passed},children:["✓ ",b.B.ship.allPassed]}),o.checksFailed&&(0,y.jsx)("span",{style:{color:B.f.failed},children:b.B.ship.someFailed}),o.pr.conflicts&&o.conflictFix?.status!=="working"&&o.conflictFix?.status!=="done"&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("span",{style:{color:B.f.failed},children:b.B.ship.conflicts}),o.conflictFix?.status==="failed"&&(0,y.jsx)("span",{role:"alert","data-testid":"conflict-failed",style:{color:B.f.failed},children:o.conflictFix.message}),o.conflictFix?.status==="failed"&&(0,y.jsxs)("a",{"data-testid":"conflict-on-github",href:`${o.pr.url.replace(/\/+$/,"")}/conflicts`,target:"_blank",rel:"noopener noreferrer",style:{color:C.f.green,fontWeight:600},children:[b.B.conflict.onGitHub," ↗"]}),i&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("button",{type:"button","data-testid":"fix-conflict",disabled:null!==s,onClick:()=>void S("fix-conflict"),style:t(s),children:["fix-conflict"===s&&(0,y.jsx)($.m,{blockId:"fix-conflict",size:16})," ",b.B.conflict.fix]}),(0,y.jsx)("span",{style:z,children:b.B.conflict.what})]})]}),(o.conflictFix?.status==="working"||o.conflictFix?.status==="done"&&o.pr.conflicts)&&(0,y.jsxs)("div",{role:"status","data-testid":"conflict-working",style:{display:"flex",gap:10,alignItems:"center",padding:"10px 12px",borderRadius:8,border:`1px solid ${B.f.tint("running",.5)}`,background:B.f.tint("running",.08),lineHeight:1.4},children:[(0,y.jsx)($.m,{blockId:"conflict-fix",size:18}),(0,y.jsx)("span",{children:"working"===o.conflictFix.status?o.conflictFix.message:b.B.conflict.seen})]}),o.conflictFix?.status==="done"&&!o.pr.conflicts&&(0,y.jsxs)("span",{"data-testid":"conflict-done",style:{color:B.f.passed},children:["✓ ",o.conflictFix.message]}),o.onHold&&(0,y.jsxs)("div",{"data-testid":"on-hold",style:{display:"flex",gap:8,alignItems:"flex-start",padding:8,borderRadius:8,border:`1px solid ${B.f.tint("waiting",.5)}`,background:B.f.tint("waiting",.08),color:B.f.waiting},children:[(0,y.jsx)("span",{style:{marginTop:2},children:(0,y.jsx)(w.h,{size:12})}),(0,y.jsx)("span",{style:{lineHeight:1.4},children:b.B.ship.onHold})]}),o.checksDone&&!o.checksFailed&&!o.pr.conflicts&&!c&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("span",{style:{display:"flex",gap:6},children:[(0,y.jsx)("button",{type:"button",disabled:null!==s,onClick:()=>u(!0),style:{...t(s),flex:1},children:b.B.ship.merge}),(0,y.jsxs)("button",{type:"button",disabled:null!==s,onClick:()=>void S(o.onHold?"unhold":"hold"),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6,padding:"6px 10px",borderRadius:8,border:`1px solid ${B.f.tint("waiting",.6)}`,background:"transparent",color:B.f.waiting,fontWeight:700,cursor:s?"wait":"pointer"},children:["hold"===s||"unhold"===s?(0,y.jsx)($.m,{blockId:"ship-hold",size:13}):(0,y.jsx)(w.h,{size:11}),"hold"===s?b.B.ship.holding:o.onHold?b.B.ship.unhold:b.B.ship.hold]})]}),(0,y.jsx)("div",{style:{...z,marginTop:-2},children:b.B.ship.mergeWhat}),!o.onHold&&(0,y.jsx)("div",{style:z,children:b.B.ship.holdWhat})]}),c&&(0,y.jsxs)("div",{role:"group","aria-label":b.B.ship.confirm,className:"factory-ask-in",style:{display:"grid",gap:6,padding:8,border:`1px solid ${B.f.tint("waiting",.5)}`,borderRadius:8,background:B.f.tint("waiting",.08)},children:[b.B.ship.confirm,(0,y.jsxs)("span",{style:{display:"flex",gap:6},children:[(0,y.jsxs)("button",{type:"button",disabled:null!==s,onClick:()=>void S("merge"),style:{...t(s),flex:1},children:["merge"===s?(0,y.jsx)($.m,{blockId:"ship-merge",size:14}):null," ","merge"===s?b.B.ship.merging:b.B.ship.yes]}),(0,y.jsx)("button",{type:"button",disabled:null!==s,onClick:()=>u(!1),style:{flex:1,padding:"6px 10px",borderRadius:8,border:`1px solid ${B.f.dim}`,background:C.f.card,color:B.f.ink,fontWeight:600,cursor:"pointer"},children:b.B.ship.no})]})]})]}),x&&(0,y.jsxs)(y.Fragment,{children:[v?(0,y.jsxs)("div",{role:"status","data-testid":"ship-publishing",style:{display:"flex",gap:10,alignItems:"center",padding:"10px 12px",borderRadius:8,border:`1px solid ${B.f.tint("running",.5)}`,background:B.f.tint("running",.1),color:"#cfe0ff",fontSize:13,fontWeight:600,lineHeight:1.4},children:[(0,y.jsx)($.m,{blockId:"ship-deploy",size:18}),b.B.ship.deployWaiting]}):(0,y.jsxs)("span",{style:{color:B.f.passed,fontWeight:700},children:["✓ ",b.B.ship.merged]}),void 0!==o.folder&&(0,y.jsx)("span",{"data-testid":"ship-folder",style:z,children:o.folder?b.B.ship.folderUpdated:b.B.ship.folderNot}),o.deploy.length>0&&(0,y.jsx)(dr,{checks:o.deploy}),!v&&0===o.deploy.length&&(0,y.jsx)("span",{style:z,children:b.B.ship.noDeploy}),!v&&o.deploy.length>0&&!o.deploy.some(e=>"failed"===e.state)&&(0,y.jsxs)("span",{style:{color:B.f.passed},children:["✓ ",b.B.ship.live]}),o.deploy.some(e=>"failed"===e.state)&&(0,y.jsx)("span",{style:{color:B.f.failed},children:b.B.ship.deployFailed})]})]}),p&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12.5,color:B.f.failed,lineHeight:1.4},children:p})]})}function dl(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M8 10.5V2.5M4.5 6 8 2.5 11.5 6M2.5 10v2.5a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1V10"})})}var ds=e.i(29978);let dd=b.B.delivery.throwAway,dc={padding:"10px 16px",borderRadius:8,border:`1px solid ${C.f.line}`,background:"transparent",color:C.f.text,font:"inherit",fontSize:14,cursor:"pointer"};function du({runId:e,prOpen:t,onGone:n}){let[i,r]=(0,m.useState)(!1),[o,a]=(0,m.useState)(!1),[l,s]=(0,m.useState)(null);async function d(){a(!0),s(null);try{let t=await fetch(`/api/runs/${e}/throw-away`,{method:"POST"}),i=await t.json().catch(()=>null);if(!t.ok||!i?.deleted)return s(i?.error??b.B.run.startFailed);r(!1),n()}catch{s(b.B.run.startFailed)}finally{a(!1)}}let c=()=>{o||r(!1)};return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("button",{type:"button","data-testid":"throw-away",onClick:()=>{s(null),r(!0)},style:{width:"100%",padding:"10px 14px",borderRadius:8,border:`1px solid ${B.f.failed}`,background:B.f.tint("failed",.12),color:"#fecaca",font:"inherit",fontSize:13.5,fontWeight:600,cursor:"pointer"},children:dd.link}),i&&(0,y.jsxs)(ds.f,{title:dd.title,testid:"throw-away-dialog",onClose:c,children:[(0,y.jsxs)("p",{style:{margin:0,color:C.f.quiet,fontSize:15,lineHeight:1.5},children:[dd.text,t?` ${dd.prToo}`:""]}),l&&(0,y.jsx)("p",{role:"alert",style:{margin:0,color:B.f.failed,fontSize:13.5,lineHeight:1.45},children:l}),(0,y.jsxs)("div",{style:{display:"flex",gap:10,justifyContent:"flex-end",flexWrap:"wrap"},children:[(0,y.jsx)("button",{type:"button",disabled:o,onClick:c,style:dc,children:dd.no}),(0,y.jsxs)("button",{type:"button","data-testid":"throw-away-yes",disabled:o,onClick:()=>void d(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:8,padding:"10px 16px",borderRadius:8,border:`1px solid ${B.f.failed}`,background:B.f.tint("failed",.16),color:"#fecaca",font:"inherit",fontSize:14,fontWeight:700,cursor:o?"wait":"pointer"},children:[o&&(0,y.jsx)($.m,{blockId:"throw-away",size:14}),o?dd.busy:dd.yes]})]})]})]})}function dp({runId:e,note:t,imageIds:n,imagesBusy:i,composer:r,onFollowUp:o,onShipState:a,away:l=null,onRecorded:s,onNewTask:d,onDeleted:c}){let u=(0,m.useContext)(sR),[p,f]=(0,m.useState)(null),[h,g]=(0,m.useState)(null),x=(0,m.useCallback)(e=>{f(e);let t=e.autoShip?.state==="started"?e.autoShip.at??"started":null;null!==t&&g(e=>e?.key===t?e:{key:t,at:Date.now()})},[]),[v,w]=(0,m.useState)(!1),[j,k]=(0,m.useState)(!1),z=j||""!==t.trim(),[I,M]=(0,m.useState)(null),[E,_]=(0,m.useState)(!1),[R,N]=(0,m.useState)(""),[T,W]=(0,m.useState)(!1),[L,P]=(0,m.useState)(null),[A,H]=(0,m.useState)(null),F=A?.pr!=null,O=A?.pr?.state==="merged",D=A?.pr?.state==="open"&&!A.checksDone,q=O&&A?.deployPending===!0,V=O&&void 0!==d&&!z,Y=D||q,X=(0,m.useCallback)(e=>{H(e),a?.(e)},[a]),[U,Z]=(0,m.useState)(null);async function K(t){Z((t??"").replace(/^https:\/\/github\.com\/|^git@github\.com:/,"").replace(/\.git$/,"")),f(e=>e&&{...e,hasRemote:!0});let n=await fetch(`/api/runs/${e}/delivery`).catch(()=>null);n?.ok&&x(await n.json())}let[G,J]=(0,m.useState)(null),[Q,et]=(0,m.useState)(!1),[en,ei]=(0,m.useState)(null);async function er(){et(!0),ei(null);try{let t=await fetch(`/api/runs/${e}/connect-github`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skip:!0})}),n=await t.json().catch(()=>null);if(!t.ok)return ei(n?.error??b.B.run.startFailed);J(!0)}catch{ei(b.B.run.startFailed)}finally{et(!1)}}(0,m.useEffect)(()=>{let t=!0;return fetch(`/api/runs/${e}/delivery`).then(e=>e.ok?e.json():null).then(e=>t&&e&&x(e)).catch(()=>void 0).finally(()=>t&&w(!0)),()=>{t=!1}},[e,x]);let[eo,ea]=(0,m.useState)(()=>Date.now()),el=p?.autoShip?.state==="started"?p.autoShip.at??"started":null,es=null!==el,ed=es&&h?.key===el&&eo-h.at>18e4,ec=es&&!ed;(0,m.useEffect)(()=>{if(!es)return;let t=setInterval(()=>{ea(Date.now()),fetch(`/api/runs/${e}/delivery`).then(e=>e.ok?e.json():null).then(e=>e&&x(e)).catch(()=>void 0)},3e3);return()=>clearInterval(t)},[es,e,x]);let[eu,ep]=(0,m.useState)(!1),ef=p?.eligible===!0&&!p.kept;async function eh(){W(!0);try{let t=await fetch(`/api/runs/${e}/branch-name`),n=await t.json().catch(()=>null);t.ok&&n?.name&&N(n.name)}catch{}finally{W(!1)}}async function eg(t){M(t),P(null);try{let n=await fetch(`/api/runs/${e}/delivery`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify("branch"===t||"apply"===t?{mode:t,name:R.trim()}:{mode:t})}),i=await n.json().catch(()=>null);if(!n.ok||!i)return P(i?.error??b.B.run.startFailed);x(i),s?.()}catch{P(b.B.run.startFailed)}finally{M(null)}}async function ex(){M("follow"),P(null);try{let i=await fetch(`/api/runs/${e}/follow-up`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({note:t,attachments:n})}),r=await i.json().catch(()=>null);if(!i.ok||!r?.runId)return P(r?.error??b.B.run.startFailed);o(r.runId)}catch{P(b.B.run.startFailed)}finally{M(null)}}if((0,m.useEffect)(()=>{ef&&eh()},[ef,e]),!v)return(0,y.jsx)(st,{});if(!p?.eligible)return(0,y.jsx)(y.Fragment,{children:r()});let ey=p.kept&&null!==p.branch,em=S(A),eb=ey&&!F&&!l&&!1===p.hasRemote,ev=eb&&(G??!0===p.githubSkipped),ew=O&&!q?4:O||em?3:ey?2:1,ej=b.B.delivery,ek=p.autoShip,eS=ek?.reason==="no_connection"&&ek.message===ej.noRemote,eC=ek?.state==="stopped"&&(ev&&"no_connection"===ek.reason||"keep"===ek.step&&ey||"send"===ek.step&&(F||p.pushed||eS&&(!0===p.hasRemote||null!==U))||"open"===ek.step&&F),eB=ek?.state==="opened"?A?.pr?.state!=="open"||A.checksFailed||A.pr.conflicts?null:`${"app"===p.passedBy?ej.auto.openedByApp:ej.auto.openedAfterYes}${em?` ${ej.auto.publishWhenReady}`:""}`:ek?.state!=="stopped"||eC?ed?ej.auto.seemsStopped:ek||"app"!==p.passedBy||ey||p.delivered?null:ej.auto.passedReady:"open"===ek.step?ej.auto.stopped.open:"keep"===ek.step?ej.auto.stopped.keep:"no_connection"===ek.reason?ej.auto.stopped.noConnection:ej.auto.stopped.send,ez=ec?ej.auto.working:q?ej.nowPublishing:O?ej.finished:em?A.onHold?ej.nowOnHold:ej.nowPublish:A?.pr?.state==="closed"?ej.nowClosed:F?A.checksFailed||A.pr.conflicts?ej.nowProblem:ej.nowChecking:ey?eb?ej.nowSaved:ej.nowSend:ej.nowSave,eI=ey&&p.current===p.branch,eM=!l&&!F&&!p.delivered&&!eI,e$=!l&&ey&&!F&&!p.pushed&&!eb;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(df,{current:ew,passedByApp:"app"===p.passedBy,docked:u}),(0,y.jsxs)("div",{style:u?{display:"grid",gap:12,gridTemplateColumns:"minmax(0, 1fr)",padding:18,borderRadius:14,border:`1px solid ${C.f.line}`,background:C.f.card}:{display:"contents"},children:[(0,y.jsxs)("div",{"data-testid":"next-step",role:ec?"status":void 0,style:{display:"flex",alignItems:"center",gap:8,fontSize:u?16:13.5,fontWeight:u?700:void 0,color:u?C.f.text:"#d6dce6",lineHeight:1.45,overflowWrap:"anywhere"},children:[ec&&(0,y.jsx)($.m,{blockId:"auto-ship",size:16}),(0,y.jsx)("span",{style:{minWidth:0},children:ez})]}),O&&d&&(0,y.jsxs)("div",{"data-testid":"next-change",style:{display:"grid",gap:10,fontSize:13.5,lineHeight:1.5,color:"#c9d0db"},children:[(0,y.jsx)("span",{children:ej.nextChange}),[{key:"new",when:ej.newTaskWhen,points:ej.newTaskPoints},{key:"keep",when:ej.keepHereWhen,points:ej.keepHerePoints}].map(e=>(0,y.jsxs)("div",{"data-testid":`way-${e.key}`,style:{display:"grid",gap:8,padding:"12px 14px",borderRadius:11,border:`1px solid ${C.f.line}`,background:"#141414"},children:[(0,y.jsx)("strong",{style:{fontSize:13.5,color:"#e6e9ef"},children:e.when}),(0,y.jsx)("ul",{style:{margin:0,paddingLeft:18,display:"grid",gap:3,fontSize:12.5,color:"#c9d0db"},children:e.points.map(e=>(0,y.jsx)("li",{children:e},e))}),"new"===e.key?(0,y.jsxs)("button",{type:"button",className:"factory-action",onClick:d,style:{marginTop:2,padding:"9px 14px",borderRadius:9,border:`1px solid ${B.f.passed}`,background:B.f.passed,color:"#0d1f12",fontWeight:800,fontSize:14,cursor:"pointer"},children:["+ ",ej.newTask]}):(0,y.jsx)("button",{type:"button",className:"factory-action","data-testid":"keep-here","aria-pressed":z,onClick:()=>k(!0),style:{marginTop:2,padding:"9px 14px",borderRadius:9,border:`1.5px solid ${B.f.passed}`,background:B.f.tint("passed",z?.28:.12),color:B.f.passed,fontWeight:800,fontSize:14,cursor:"pointer"},children:z?`${ej.keepHere} ↓`:ej.keepHere})]},e.key))]}),eB&&(0,y.jsxs)("div",{"data-testid":"auto-line",style:{display:"grid",gap:6,fontSize:12.5,lineHeight:1.45,color:ek?.state==="stopped"?B.f.waiting:"#b9dcc5",overflowWrap:"anywhere"},children:[(0,y.jsx)("span",{children:eB}),ek?.state==="stopped"&&!eC&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("span",{style:{color:B.f.dim},children:ej.auto.tryAgain}),ek.message&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("button",{type:"button","aria-expanded":eu,onClick:()=>ep(e=>!e),style:{justifySelf:"start",padding:0,background:"none",border:"none",color:C.f.green,fontSize:12.5,cursor:"pointer",textDecoration:"underline"},children:ej.auto.whatHappened}),eu&&(0,y.jsx)("span",{"data-testid":"auto-message",style:{color:B.f.dim},children:ek.message})]})]})]}),(0,y.jsxs)("div",{style:{display:"grid",gap:8,gridTemplateColumns:"minmax(0, 1fr)"},children:[l&&!O&&(0,y.jsx)("div",{"data-testid":"away",style:{fontSize:12.5,color:B.f.waiting,lineHeight:1.45},children:b.B.machine.elsewhere(l.machine)}),!ey&&!l&&!ec&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"grid",gap:4,fontSize:12,color:B.f.dim},children:[(0,y.jsx)("label",{htmlFor:`branch-name-${e}`,children:ej.branchName}),(0,y.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,y.jsx)("input",{id:`branch-name-${e}`,value:R,placeholder:ej.branchPlaceholder,disabled:null!==I||T,spellCheck:!1,onChange:e=>N(e.target.value),style:{flex:1,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,padding:"7px 8px",background:C.f.bg,color:"#d6dce6",border:`1px solid ${C.f.line}`,borderRadius:6,minWidth:0}}),(0,y.jsxs)("button",{type:"button",disabled:null!==I||T,onClick:()=>void eh(),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",borderRadius:6,border:`1px solid ${C.f.line}`,background:C.f.card,color:"#d6dce6",fontSize:12,fontWeight:600,cursor:T?"wait":"pointer",whiteSpace:"nowrap"},children:[T?(0,y.jsx)($.m,{blockId:"suggest",size:12}):(0,y.jsx)(dm,{})," ",T?ej.suggesting:ej.suggestName]})]}),(0,y.jsx)("span",{style:{fontSize:11,lineHeight:1.4},children:ej.branchNameHint})]}),(0,y.jsxs)("button",{type:"button",disabled:null!==I,onClick:()=>void eg("branch"),style:dx(I),children:["branch"===I?(0,y.jsx)($.m,{blockId:"keep",size:16}):(0,y.jsx)(dh,{})," ",ej.keepButton]})]}),ey&&!ec&&(0,y.jsxs)("div",{"data-testid":"kept",style:{display:"grid",gap:8,gridTemplateColumns:"minmax(0, 1fr)"},children:[eb&&!ev?(0,y.jsxs)("div",{"data-testid":"not-connected",style:{display:"grid",gap:10,padding:14,borderRadius:10,border:`1px solid ${C.f.line}`,background:"#141414",fontSize:13,lineHeight:1.45},children:[(0,y.jsx)("span",{style:{color:"#c9d0db"},children:ej.notConnected.offer}),(0,y.jsx)(ee,{endpoint:`/api/runs/${e}/connect-github`,onConnected:K}),(0,y.jsx)("button",{type:"button","data-testid":"skip-github",disabled:Q,onClick:()=>void er(),style:{...dy(null),cursor:Q?"wait":"pointer"},children:Q?ej.notConnected.skipping:ej.notConnected.skip}),en&&(0,y.jsx)("span",{role:"alert",style:{color:B.f.failed},children:en})]}):ev?(0,y.jsx)("div",{"data-testid":"github-skipped",style:{fontSize:12.5,color:B.f.dim,lineHeight:1.45},children:ej.notConnected.skipped}):(0,y.jsxs)(y.Fragment,{children:[null!==U&&!F&&(0,y.jsxs)("div",{role:"status","data-testid":"connected",style:{display:"flex",alignItems:"center",gap:8,padding:"9px 11px",borderRadius:8,border:`1px solid ${B.f.tint("passed",.5)}`,background:B.f.tint("passed",.1),fontSize:13,color:"#d7f5e0",lineHeight:1.4},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:B.f.passed,strokeWidth:"2.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:(0,y.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})}),ej.connect.done(U)]}),(0,y.jsx)(da,{runId:e,button:dx,onState:X,canOpen:!l,onRecorded:s})]}),!O&&!l&&(0,y.jsx)(dn,{runId:e,button:dy})]}),p.delivered&&(0,y.jsx)("div",{style:{fontSize:12.5,color:"#b9dcc5",lineHeight:1.4},children:ej.done(p.files.length)})]})]}),(ey||eM)&&!Y&&!ec&&(0,y.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,y.jsxs)("button",{type:"button","aria-expanded":E,onClick:()=>_(e=>!e),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderRadius:8,border:`1px solid ${C.f.line}`,background:C.f.card,color:"#d6dce6",fontSize:12.5,fontWeight:600,cursor:"pointer"},children:[ej.moreOptions,(0,y.jsx)("span",{"aria-hidden":"true",style:{display:"inline-block",transform:E?"rotate(180deg)":"none",transition:"transform 150ms ease-out"},children:"▾"})]}),E&&(0,y.jsxs)("div",{"data-testid":"more-options",style:{display:"grid",gap:8},children:[ey&&(0,y.jsxs)("dl",{"data-testid":"kept-facts",style:{...dg,margin:0,gridTemplateColumns:"auto minmax(0, 1fr)",columnGap:12,rowGap:6,fontSize:12},children:[(0,y.jsx)("dt",{style:{color:B.f.dim},children:ej.branchLabel}),(0,y.jsx)("dd",{style:{margin:0,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",color:"#d6dce6",overflowWrap:"anywhere"},children:p.branch}),(0,y.jsx)("dt",{style:{color:B.f.dim},children:ej.commitLabel}),(0,y.jsx)("dd",{style:{margin:0,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",color:"#d6dce6"},children:(p.commit??"").slice(0,7)})]}),ey&&!l&&(eI||!O)&&(0,y.jsx)("div",{style:dg,children:eI?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{"data-testid":"on-branch",style:{fontSize:12,color:B.f.passed,lineHeight:1.4,overflowWrap:"anywhere"},children:["✓ ",ej.onBranch(p.branch)]}),p.returnTo&&(0,y.jsxs)("button",{type:"button",disabled:null!==I,onClick:()=>void eg("back"),style:dy(I),children:["back"===I?(0,y.jsx)($.m,{blockId:"back",size:16}):"←"," ",ej.backButton(p.returnTo)]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("button",{type:"button",disabled:null!==I,onClick:()=>void eg("switch"),style:dy(I),children:["switch"===I?(0,y.jsx)($.m,{blockId:"switch",size:16}):(0,y.jsx)("span",{"aria-hidden":"true",children:"⇄"})," ",ej.switchButton]}),(0,y.jsx)("div",{style:{fontSize:11.5,color:B.f.dim,lineHeight:1.4},children:ej.switchWhat})]})}),e$&&(0,y.jsxs)("div",{style:dg,children:[(0,y.jsxs)("button",{type:"button",disabled:null!==I,onClick:()=>void eg("push"),style:dy(I),children:["push"===I?(0,y.jsx)($.m,{blockId:"push",size:16}):"↑"," ",ej.pushOnly]}),(0,y.jsx)("div",{style:{fontSize:11.5,color:B.f.dim,lineHeight:1.4},children:ej.pushOnlyWhat})]}),eM&&(0,y.jsxs)("div",{style:dg,children:[(0,y.jsxs)("button",{type:"button",disabled:null!==I,onClick:()=>void eg("apply"),style:dy(I),children:["apply"===I?(0,y.jsx)($.m,{blockId:"apply",size:16}):"⤵"," ",ej.applyButton]}),(0,y.jsx)("div",{style:{fontSize:11.5,color:B.f.dim,lineHeight:1.4},children:ej.applyWhat})]})]})]}),!O&&!q&&!l&&!ec&&(0,y.jsx)(du,{runId:e,prOpen:A?.pr?.state==="open",onGone:()=>{s?.(),c?.()}}),(0,y.jsxs)("div",{"data-testid":"follow-up-box",style:{display:Y||V?"none":"grid",gap:6,gridTemplateColumns:"minmax(0, 1fr)",paddingTop:10,borderTop:`1px solid ${B.f.lineSoft}`,...u?{marginTop:"auto",marginInline:-20,padding:"20px 20px 0",gap:10,borderTop:`1px solid ${C.f.line}`}:null},children:[(0,y.jsx)("div",{style:{fontSize:12,color:B.f.dim},children:O?b.B.followUp.hintPublished:b.B.followUp.hint}),r({label:b.B.followUp.start,name:O?b.B.followUp.titleContinue:b.B.followUp.titleAdjust,onSend:()=>void ex(),enabled:null===I&&!i&&""!==t.trim(),busy:"follow"===I})]}),L&&(0,y.jsx)("div",{role:"alert",style:{fontSize:12.5,color:B.f.failed,lineHeight:1.4},children:L})]})}function df({current:e,passedByApp:t,docked:n=!1}){let i=t?[b.B.delivery.passedStep,...b.B.delivery.steps.slice(1)]:b.B.delivery.steps,r=n?26:18;return(0,y.jsx)("ol",{"data-testid":"steps","aria-label":b.B.delivery.stepsLabel,style:{listStyle:"none",margin:0,padding:0,display:"flex",alignItems:n?"flex-start":"center",gap:4*!n},children:i.map((t,o)=>{let a=o<e||4===e,l=o===e&&4!==e,s=a?B.f.passed:l?"#d6dce6":B.f.skipped,d=(0,y.jsx)("span",{"aria-hidden":"true",style:{position:"relative",width:r,height:r,flex:"none",borderRadius:"50%",display:"grid",placeItems:"center",fontSize:n?13:10,fontWeight:900,background:a?B.f.passed:C.f.bg,color:a?"#07110a":s,border:`1.5px solid ${a?B.f.passed:s}`},children:a?"✓":o+1}),c=a&&o+1<=e?B.f.tint("passed",.6):C.f.line;return n?(0,y.jsxs)("li",{"aria-current":l?"step":void 0,style:{position:"relative",flex:"1 1 0",minWidth:0,display:"grid",justifyItems:"center",gap:8},children:[o<i.length-1&&(0,y.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",top:r/2-1,left:"50%",width:"100%",height:1.5,background:c}}),d,(0,y.jsx)("span",{style:{fontSize:12.5,fontWeight:l?800:500,color:a?C.f.quiet:s,textAlign:"center",lineHeight:1.3,textWrap:"balance"},children:t})]},t):(0,y.jsxs)("li",{"aria-current":l?"step":void 0,style:{display:"flex",alignItems:"center",gap:4,flex:o<i.length-1?"1 1 auto":"none",minWidth:0},children:[d,(0,y.jsx)("span",{style:{fontSize:11.5,fontWeight:l?800:600,color:s,whiteSpace:"nowrap"},children:t}),o<i.length-1&&(0,y.jsx)("span",{"aria-hidden":"true",style:{flex:1,height:1.5,minWidth:8,background:c}})]},t)})})}function dh(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M8 2.5v8M4.5 7 8 10.5 11.5 7M2.5 10v2.5a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1V10"})})}let dg={display:"grid",gap:6,padding:10,borderRadius:8,border:`1px solid ${C.f.line}`,background:"#141414"};function dx(e){return{padding:"9px 12px",borderRadius:8,border:`1px solid ${B.f.passed}`,background:B.f.passed,color:"#07110a",fontWeight:700,cursor:e?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8}}function dy(e){return{padding:"8px 12px",borderRadius:8,border:`1px solid ${B.f.tint("passed",.6)}`,background:"transparent",color:"#b9dcc5",fontWeight:700,cursor:e?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8}}function dm(){return(0,y.jsx)("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M8 1.5 9.4 6.6 14.5 8 9.4 9.4 8 14.5 6.6 9.4 1.5 8 6.6 6.6 8 1.5Z"})})}let db={idle:{tone:"running",from:"#141b27",to:"#10151e",strength:.35},working:{tone:"running",from:"#121a29",to:"#0f1520",strength:.5},plan:{tone:"waiting",from:"#1f1a10",to:"#16130d",strength:.55},question:{tone:"waiting",from:"#1f1a10",to:"#16130d",strength:.55},waiting:{tone:"waiting",from:"#1f1a10",to:"#16130d",strength:.55},done:{tone:"passed",from:"#0f1f16",to:"#0c1711",strength:.5},failed:{tone:"failed",from:"#211214",to:"#170e10",strength:.5}},dv=(0,m.forwardRef)(function({docked:e=!1,direct:t=!1,planMeasure:n,stopForMe:i=!1,onStopForMe:r,onSeeChanges:o,record:a=null,recordFailed:l=!1,recordMark:s=0,recordReadMark:d=0,askedId:c=null,onRecordChanged:u,showFindings:p=!1,notice:f,mode:h,runId:g,risk:x,text:v,onText:w,images:j,onImages:k,onRun:S,canRun:z,onFollowUp:I,onNewTask:M,onTaskDeleted:E,onSent:_,startOptions:R=[],startFrom:N,onStartFrom:T,onShipState:W,loading:L=!1,taskName:P,onTaskName:A,away:H=null,onRecorded:F,failureActions:O,onCanContinue:D},q){let V=db[h],[Y,X]=lX(lD,!1),U=e&&Y,[Z,K]=(0,m.useState)(!1),G=e=>{K(!0),X(e)},J="plan"===h?b.B.plan.replanLabel:"waiting"===h?b.B.gate.reasonLabel:"done"===h?b.B.followUp.title:"failed"===h?b.B.failure.label:b.B.run.requestLabel,Q="plan"===h?b.B.plan.replanPlaceholder:"waiting"===h?b.B.gate.reasonPlaceholder:"done"===h?b.B.followUp.placeholder:"failed"===h?b.B.failure.placeholder:b.B.run.requestPlaceholder,ee=e=>(0,y.jsx)(sW,{send:e,minHeight:"waiting"===h||"done"===h||"plan"===h||"failed"===h?96:void 0,inputId:sp,label:e?.name??J,placeholder:Q,text:v,onText:w,images:j,onImages:k,onSubmit:"idle"===h&&z?S:void 0});return(0,y.jsxs)(y.Fragment,{children:[U&&(0,y.jsx)(dk,{mode:L?"idle":h,glide:Z,onOpen:()=>G(!1)}),(0,y.jsx)("section",{ref:q,className:Z&&!U?"factory-from-right":void 0,tabIndex:-1,"data-testid":"command-card","data-mode":h,"aria-label":"plan"===h?b.B.plan.title:"question"===h?b.B.question.title:"waiting"===h?b.B.gate.title:"done"===h?b.B.delivery.title:b.B.sidebar.runTitle,style:{position:"absolute",right:16,bottom:16,zIndex:5,width:460,maxWidth:"calc(100% - 32px)",maxHeight:"calc(100% - 72px)",overflowY:"auto",overflowX:"hidden",background:`linear-gradient(180deg, ${V.from} 0%, ${V.to} 100%)`,border:`1px solid ${B.f.tint(V.tone,V.strength)}`,borderRadius:14,boxShadow:`0 0 0 1px ${B.f.tint(V.tone,.15)}, 0 0 30px ${B.f.tint(V.tone,"idle"===h?.06:.16)}, 0 18px 40px rgba(0,0,0,0.55)`,padding:16,display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:12,outline:"none",...e?{top:0,right:0,bottom:0,maxWidth:"100%",maxHeight:"none",padding:"20px 20px 24px",display:"flex",flexDirection:"column",gap:16,zoom:1.08,background:C.f.bg,border:"none",borderLeft:`1px solid ${C.f.line}`,borderRadius:0,boxShadow:"none"}:null,...U?{display:"none"}:null},children:(0,y.jsxs)(sR.Provider,{value:e,children:[e&&(0,y.jsx)("button",{type:"button","data-testid":"panel-fold","aria-label":b.B.panel.fold,title:b.B.panel.fold,onClick:()=>G(!0),style:{...dw,alignSelf:"flex-start",margin:"-10px 0 -10px -10px"},children:(0,y.jsx)(l9,{name:"expand"})}),L&&(0,y.jsx)(st,{}),!L&&"idle"===h&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:b.B.sidebar.runTitle}),t&&(0,y.jsx)("div",{"data-testid":"direct-start-hint",role:"note",style:{padding:"9px 12px",borderRadius:10,border:`1px solid ${B.f.tint("passed",.5)}`,color:B.f.passed,fontSize:13,lineHeight:1.45},children:b.B.direct.startHint}),1===R.length&&(0,y.jsx)("div",{"data-testid":"starts-from",style:{fontSize:12,color:B.f.dim,marginTop:-6,overflowWrap:"anywhere"},children:b.B.delivery.startsFrom(R[0])}),R.length>1&&(0,y.jsxs)("label",{"data-testid":"starts-from",style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:B.f.dim,marginTop:-6},children:[b.B.delivery.startFromLabel,(0,y.jsx)("select",{value:N??R[0],onChange:e=>T?.(e.target.value),style:{flex:1,minWidth:0,padding:"4px 6px",background:B.f.bg,color:"inherit",border:`1px solid ${B.f.border}`,borderRadius:6,fontSize:12},children:R.map((e,t)=>(0,y.jsx)("option",{value:e,children:0===t?b.B.delivery.mainOption(e):b.B.delivery.currentOption(e)},e))})]}),A&&(0,y.jsxs)("label",{style:{display:"grid",gap:4,fontSize:12.5,fontWeight:600,color:B.f.dim},children:[(0,y.jsxs)("span",{children:[b.B.title.label," ",(0,y.jsx)("span",{style:{fontWeight:400},children:b.B.title.optional})]}),(0,y.jsx)("input",{value:P??"",maxLength:60,placeholder:b.B.title.placeholder,onChange:e=>A(e.target.value),style:{font:"inherit",fontSize:13.5,fontWeight:400,padding:"7px 10px",background:B.f.card,color:"#e6e9ef",border:`1px solid ${B.f.border}`,borderRadius:8}})]}),r&&(0,y.jsx)(dS,{checked:i,onChange:r}),ee({label:b.B.run.send,onSend:S,enabled:z})]}),!L&&"working"===h&&(0,y.jsxs)("div",{role:"status",style:{display:"flex",alignItems:"center",gap:10,fontSize:14,fontWeight:600,color:"#cfe0ff"},children:[(0,y.jsx)($.m,{blockId:"card",size:20}),b.B.card.working]}),!L&&"working"===h&&f&&(0,y.jsx)(dC,{notice:f}),!L&&"plan"===h&&g&&(0,y.jsx)(s7,{measure:n,away:H,runId:g,note:v,composer:ee,onSent:_}),!L&&"question"===h&&g&&(0,y.jsx)(s3,{runId:g,record:a,failed:l,mark:s,readMark:d,askedId:c,onChanged:()=>u?.()}),!L&&"waiting"===h&&g&&(0,y.jsx)(sZ,{findings:p?a?.findings:void 0,touched:a?.touched,away:H,runId:g,risk:x,note:v,imageIds:sN(j),imagesBusy:sT(j),composer:ee,onSent:_,onSeeChanges:o}),!L&&"done"===h&&g&&(0,y.jsx)(dp,{away:H,onRecorded:F,onNewTask:M,onDeleted:E,onShipState:W,runId:g,note:v,imageIds:sN(j),imagesBusy:sT(j),composer:ee,onFollowUp:e=>{_(),I(e)}}),!L&&"failed"===h&&g&&(0,y.jsx)(sz,{runId:g,note:v,imageIds:sN(j),imagesBusy:sT(j),composer:ee,onText:w,actionsRef:O,onCanContinue:D,onFollowUp:e=>{_(),I(e)}})]})})]})}),dw={width:36,height:36,display:"grid",placeItems:"center",background:"transparent",color:B.f.dim,border:"1px solid transparent",borderRadius:8,cursor:"pointer"},dj={idle:C.f.quiet,working:B.f.passed,plan:B.f.waiting,question:B.f.waiting,waiting:B.f.waiting,done:B.f.passed,failed:B.f.failed};function dk({mode:e,glide:t,onOpen:n}){let i=dj[e],r="plan"===e||"question"===e||"waiting"===e,o="working"===e?(0,y.jsx)($.m,{blockId:"panel-rail",size:20}):(0,y.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",...{fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round"},children:["done"===e&&(0,y.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"}),"failed"===e&&(0,y.jsx)("path",{d:"M6 6l12 12M18 6L6 18"}),r&&(0,y.jsx)("path",{d:"M12 5v9M12 18.5v.5"}),"idle"===e&&(0,y.jsx)("path",{d:"M4 20h4L19 9l-4-4L4 16v4zM13.5 6.5l4 4"})]});return(0,y.jsxs)("button",{type:"button","data-testid":"panel-rail",className:t?"factory-from-right":void 0,"data-mode":e,"aria-label":`${b.B.panel.open}. ${b.B.panel.state[e]}`,title:`${b.B.panel.state[e]} \xb7 ${b.B.panel.open}`,onClick:n,style:{position:"absolute",top:0,right:0,bottom:0,zIndex:5,width:56,display:"flex",flexDirection:"column",alignItems:"center",gap:10,padding:"10px 0",border:"none",borderLeft:`1px solid ${C.f.line}`,background:C.f.bg,color:C.f.quiet,cursor:"pointer"},children:[(0,y.jsx)("span",{style:dw,children:(0,y.jsx)(l9,{name:"collapse"})}),(0,y.jsx)("span",{role:"working"===e?"status":void 0,style:{width:36,height:36,borderRadius:10,display:"grid",placeItems:"center",color:i,background:B.f.tint("working"===e?"passed":r?"waiting":"done"===e?"passed":"failed"===e?"failed":"skipped",.16),border:`1px solid ${r?B.f.waiting:C.f.line}`},children:o}),(0,y.jsx)("span",{style:{writingMode:"vertical-rl",fontSize:12,letterSpacing:.3,color:r?B.f.waiting:C.f.quiet,fontWeight:r?700:500},children:b.B.panel.state[e]})]})}function dS({checked:e,onChange:t}){let[n,i]=(0,m.useState)(!1),r="stop-for-me-why";return(0,y.jsxs)("div",{"data-testid":"stop-for-me",style:{display:"grid",gap:4,minWidth:0},children:[(0,y.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 12px"},children:[(0,y.jsxs)("label",{style:{display:"inline-flex",alignItems:"center",gap:8,fontSize:13,color:"#d6dce6",cursor:"pointer"},children:[(0,y.jsx)("input",{type:"checkbox",checked:e,onChange:e=>t(e.target.checked)}),b.B.composer.stopForMe]}),(0,y.jsx)("button",{type:"button","aria-expanded":n,"aria-controls":r,onClick:()=>i(e=>!e),style:{padding:0,background:"none",border:"none",color:"#9cc2ff",fontSize:12.5,cursor:"pointer",textDecoration:"underline"},children:b.B.composer.stopForMeWhat})]}),n&&(0,y.jsx)("span",{id:r,style:{fontSize:12.5,lineHeight:1.45,color:B.f.dim,overflowWrap:"anywhere"},children:b.B.composer.stopForMeWhy})]})}function dC({notice:e}){let[t,n]=(0,m.useState)(!1),i={fontSize:12,lineHeight:1.4,color:B.f.dim,margin:0};return"ask"===e.offer?(0,y.jsx)("button",{type:"button",onClick:()=>{n(!0),e.onAllow()},style:{justifySelf:"start",textAlign:"left",padding:"5px 10px",borderRadius:8,border:`1px solid ${B.f.border}`,background:"transparent",color:"inherit",fontSize:12.5,cursor:"pointer"},children:b.B.tell.offer}):t&&"on"===e.offer?(0,y.jsx)("p",{style:i,children:b.B.tell.on}):t&&"blocked"===e.offer?(0,y.jsx)("p",{style:i,children:b.B.tell.blocked}):null}let dB=new Set(["node.question_asked","node.question_answered","node.findings_checked","node.finding_resolved"]);function dz(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if("node.question_answered"===n.type)break;if("node.question_asked"===n.type){let e=n.payload?.questionId;return"string"==typeof e?e:null}}return null}let dI=b.B.details,dM="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",d$={scrollbarWidth:"thin",scrollbarColor:`${B.f.skipped} transparent`},dE=["input","plan","build","tests","review","approve","human","ship"],d_="min(48vh, 440px)";function dR(e){if(e<1e3)return dI.underASecond;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function dN(e){if(!e)return dI.none;let t=new Date(e);return Number.isNaN(t.getTime())?dI.none:t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function dT({text:e}){return(0,y.jsx)(y.Fragment,{children:e.replace(/\*\*/g,"").split(/\n{2,}/).map((e,t)=>(0,y.jsx)("p",{style:{margin:0},children:e.split("`").map((e,t)=>t%2==1?(0,y.jsx)("code",{style:{padding:"1px 6px",borderRadius:5,background:C.f.bg,border:`1px solid ${C.f.line}`,fontFamily:dM,fontSize:"0.86em",color:C.f.text},children:e},t):e)},t))})}function dW({path:e,size:t=16}){return(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:e})}let dL={clock:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,y.jsx)("path",{d:"M12 7v5l3 2"})]}),play:(0,y.jsx)("path",{d:"M8 5.5v13l10-6.5z"}),flag:(0,y.jsx)("path",{d:"M6 21V4h11l-2 4 2 4H6"}),spark:(0,y.jsx)("path",{d:"M12 3l1.9 5.6L19.5 10l-5.6 1.4L12 17l-1.9-5.6L4.5 10l5.6-1.4z"}),chip:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("rect",{x:"7",y:"7",width:"10",height:"10",rx:"2"}),(0,y.jsx)("path",{d:"M10 3v4M14 3v4M10 17v4M14 17v4M3 10h4M3 14h4M17 10h4M17 14h4"})]}),repeat:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("path",{d:"M20 11a8 8 0 1 0-2.3 5.7"}),(0,y.jsx)("path",{d:"M20 4v7h-7"})]}),check:(0,y.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"}),cross:(0,y.jsx)("path",{d:"M6 6l12 12M18 6L6 18"}),chevron:(0,y.jsx)("path",{d:"M9 6l6 6-6 6"}),enlarge:(0,y.jsx)("path",{d:"M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5"})};function dP({icon:e,label:t,value:n,help:i}){return(0,y.jsxs)("div",{style:{display:"grid",gap:5,padding:"13px 15px",borderRadius:12,background:"#141414",border:`1px solid ${C.f.line}`,minWidth:0},children:[(0,y.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:7,fontSize:12.5,color:C.f.quiet},children:[(0,y.jsx)(dW,{path:e,size:14})," ",t]}),(0,y.jsx)("span",{style:{fontSize:19,fontWeight:700,color:C.f.text,overflowWrap:"anywhere"},children:n}),i&&(0,y.jsx)("span",{style:{fontSize:11.5,color:B.f.skipped},children:i})]})}function dA({title:e,help:t,children:n}){return(0,y.jsxs)("section",{style:{display:"grid",gap:10},children:[(0,y.jsxs)("div",{style:{display:"grid",gap:3},children:[(0,y.jsx)("strong",{className:"factory-display",style:{fontSize:17},children:e}),t&&(0,y.jsx)("span",{style:{fontSize:13,color:C.f.quiet},children:t})]}),n]})}function dH({measure:e,startedOnItsOwn:t}){return(0,y.jsxs)(y.Fragment,{children:[e.reasons.length>0&&(0,y.jsx)(dA,{title:t?b.B.plan.whyStarted:b.B.plan.whyStopped,children:(0,y.jsx)("ul",{style:{margin:0,paddingLeft:20,display:"grid",gap:6,fontSize:14.5,lineHeight:1.5,color:"#d6dce6",overflowWrap:"anywhere"},children:e.reasons.map((e,t)=>(0,y.jsx)("li",{children:e},t))})}),(0,y.jsx)(dA,{title:b.B.plan.expects,children:e.entries.length>0?(0,y.jsx)("ul",{style:{margin:0,paddingLeft:20,display:"grid",gap:4,fontFamily:dM,fontSize:13,color:"#d6dce6",overflowWrap:"anywhere"},children:e.entries.map((e,t)=>(0,y.jsx)("li",{children:e},t))}):(0,y.jsx)("span",{style:{color:C.f.quiet},children:b.B.plan.noneExpected})})]})}function dF({c:e}){let[t,n]=(0,m.useState)(!1),i=0===e.exitCode;return(0,y.jsxs)("div",{style:{display:"grid",gap:8,padding:"11px 13px",borderRadius:10,background:"#141414",border:`1px solid ${i?C.f.line:B.f.tint("failed",.5)}`},children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,y.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"3px 10px",borderRadius:999,background:B.f.tint(i?"passed":"failed",.16),color:i?B.f.passed:B.f.failed,fontSize:12.5,fontWeight:700},children:[(0,y.jsx)(dW,{path:i?dL.check:dL.cross,size:13})," ",i?dI.commandPassed:dI.commandFailed]}),(0,y.jsx)("code",{style:{fontFamily:dM,fontSize:13,color:"#e6e9ef"},children:e.command}),null!==e.durationMs&&(0,y.jsx)("span",{style:{marginLeft:"auto",fontSize:13,color:C.f.quiet},children:dR(e.durationMs)})]}),!i&&(0,y.jsx)("span",{style:{fontSize:13,color:B.f.failed},children:b.B.failure.ended(e.exitCode,e.signal)}),e.output&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("button",{type:"button","aria-expanded":t,onClick:()=>n(e=>!e),style:{justifySelf:"start",display:"inline-flex",alignItems:"center",gap:5,padding:0,background:"none",border:"none",color:C.f.green,fontSize:13,cursor:"pointer"},children:[(0,y.jsx)("span",{style:{display:"inline-flex",transform:t?"rotate(90deg)":"none"},children:(0,y.jsx)(dW,{path:dL.chevron,size:13})}),t?dI.hideOutput:dI.showOutput]}),t&&(0,y.jsx)("pre",{style:{margin:0,maxHeight:280,overflow:"auto",padding:12,borderRadius:8,background:C.f.bg,border:`1px solid ${C.f.line}`,fontFamily:dM,fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",...d$},children:e.output})]})]})}function dO({runId:e}){let{state:t}=(0,eI.C)(e,!1);return t&&"unneeded"!==t.status?(0,y.jsx)(dA,{title:dI.pictures,help:dI.picturesHelp,children:(0,y.jsx)(dQ,{runId:e,state:t})}):null}function dD({runId:e,name:t,done:n}){let{state:i,take:r,error:o}=(0,eI.C)(e,n),[a,l]=(0,m.useState)(!1),[s,d]=(0,m.useState)(!1);if(!i)return(0,y.jsx)(l7,{width:300,height:96,radius:8});if(!n&&"ready"!==i.status&&"working"!==i.status)return(0,y.jsx)("span",{style:{fontSize:13,color:B.f.skipped},children:dI.historyWhenDone});if("unneeded"===i.status)return(0,y.jsx)("span",{style:{fontSize:13,color:B.f.skipped},children:dI.historyNothingToSee});if("working"===i.status||s&&"none"===i.status&&!o)return(0,y.jsxs)("span",{role:"status",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:C.f.quiet},children:[(0,y.jsx)($.m,{blockId:`pictures-${e}`,size:14})," ",i.message??dI.historyTaking]});if("ready"!==i.status||0===i.shots.length)return(0,y.jsxs)("span",{style:{display:"grid",gap:6,justifyItems:"start"},children:[(0,y.jsx)("button",{type:"button",onClick:()=>{d(!0),r()},style:{padding:"6px 12px",borderRadius:8,border:`1px solid ${C.f.line}`,background:C.f.bg,color:C.f.text,fontSize:13,fontWeight:600,cursor:"pointer"},children:dI.historyTake}),(o??("failed"===i.status?i.message:null))&&(0,y.jsx)("span",{style:{fontSize:12.5,color:B.f.failed},children:o??i.message})]});let c=["before","after"].filter(e=>i.shots.includes(`${e}-desktop`));return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("button",{type:"button","data-testid":"history-thumbs","aria-label":dI.historyPicturesOf(t),onClick:()=>l(!0),style:{display:"flex",gap:10,padding:0,border:"none",background:"none",cursor:"zoom-in",justifySelf:"start"},children:c.map(t=>(0,y.jsxs)("span",{style:{display:"grid",gap:4,justifyItems:"start"},children:[(0,y.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:"before"===t?C.f.quiet:B.f.passed},children:b.B.snapshots[t]}),(0,y.jsx)("img",{src:(0,eI.h)(e,`${t}-desktop`,i),alt:"",style:{display:"block",width:"min(var(--thumb-w, 150px), 34vw)",height:"auto",aspectRatio:"25 / 16",objectFit:"cover",objectPosition:"top",borderRadius:8,border:`1px solid ${C.f.line}`}})]},t))}),a&&(0,oi.createPortal)((0,y.jsx)("div",{onClick:()=>l(!1),style:{position:"fixed",inset:0,zIndex:110,display:"grid",gridTemplateRows:"minmax(0, 1fr)",placeItems:"center",background:"rgba(5, 7, 11, 0.8)"},children:(0,y.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":dI.historyPicturesOf(t),onClick:e=>e.stopPropagation(),style:{width:"min(1100px, calc(100% - 32px))",maxHeight:"calc(100% - 64px)",overflowY:"auto",display:"grid",gap:14,padding:22,background:C.f.card,border:`1px solid ${C.f.line}`,borderRadius:14,...d$},children:[(0,y.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:12},children:[(0,y.jsx)("strong",{className:"factory-display",style:{fontSize:18},children:dI.historyPicturesOf(t)}),(0,y.jsx)("button",{type:"button","aria-label":dI.close,onClick:()=>l(!1),style:{background:"none",border:"none",color:B.f.skipped,cursor:"pointer",fontSize:18},children:"✕"})]}),(0,y.jsx)(dQ,{runId:e,state:i})]})}),document.body)]})}let dq={position:"relative",display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:14,paddingBottom:16},dV={position:"absolute",left:12,top:26,bottom:0,width:2,background:C.f.line},dY={display:"grid",gap:10,minWidth:0,padding:"12px 14px",borderRadius:12,border:`1px solid ${C.f.line}`,background:"#141414"},dX={fontSize:11,fontWeight:800,letterSpacing:"0.1em",textTransform:"uppercase",color:C.f.quiet},dU=e=>new Date(e).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),dZ=({colour:e})=>(0,y.jsx)("span",{className:"factory-history-dot",style:{width:26,height:26,borderRadius:999,display:"grid",placeItems:"center",background:"#141414",border:`2px solid ${e}`,color:e,fontSize:12.5,fontWeight:800,zIndex:1}});function dK({files:e}){return 0===e.length?null:(0,y.jsxs)("div",{style:{display:"grid",gap:4,fontSize:12.5,paddingTop:8,borderTop:`1px solid ${C.f.line}`},children:[(0,y.jsx)("span",{style:{color:C.f.quiet,fontWeight:700},children:dI.historyFiles(e.length)}),(0,y.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[e.slice(0,6).map(e=>(0,y.jsx)("code",{style:{padding:"2px 7px",borderRadius:6,background:C.f.bg,border:`1px solid ${C.f.line}`,color:"#c9d0db",fontSize:12},children:e},e)),e.length>6&&(0,y.jsx)("span",{style:{color:B.f.skipped,alignSelf:"center"},children:dI.historyMoreFiles(e.length-6)})]})]})}function dG({t:e,more:t}){let{state:n,versions:i}=(0,eI.w)(e.runId),r={margin:0,fontSize:14.5,lineHeight:1.5,color:"#e6e9ef",overflowWrap:"anywhere"},o=(0,y.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px",marginLeft:"auto"},children:[e.here&&(0,y.jsx)("span",{style:{padding:"2px 9px",borderRadius:999,background:B.f.tint("passed",.18),color:B.f.passed,fontSize:11.5,fontWeight:800},children:dI.historyHere}),(0,y.jsx)("span",{style:{fontSize:12.5,color:B.f.skipped},children:dU(e.at)})]});if(n&&i.length>0)return(0,y.jsx)(y.Fragment,{children:i.map((a,l)=>(0,y.jsxs)("li",{"data-testid":"history-step",style:dq,children:[(t||l<i.length-1)&&(0,y.jsx)("span",{"aria-hidden":"true",style:dV}),(0,y.jsx)(dZ,{colour:B.f.passed}),(0,y.jsxs)("div",{style:dY,children:[(0,y.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px"},children:[(0,y.jsx)("span",{style:dX,children:0===l?dI.historyAsked:dI.historyAskedChange}),0===l&&o]}),(0,y.jsx)("p",{style:r,children:a.asked}),(0,y.jsx)(eI.R,{runId:e.runId,state:n,versions:i,index:l}),l===i.length-1&&(0,y.jsx)(dK,{files:e.files})]})]},`${e.runId}-${a.change}`))});let a=e.request.replace(/\s+/g," ").trim().startsWith(e.name)?null:e.name;return(0,y.jsxs)("li",{"data-testid":"history-step",style:dq,children:[t&&(0,y.jsx)("span",{"aria-hidden":"true",style:dV}),(0,y.jsx)(dZ,{colour:B.f.passed}),(0,y.jsxs)("div",{style:dY,children:[(0,y.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px"},children:[(0,y.jsx)("span",{style:dX,children:dI.historyAsked}),o]}),a&&(0,y.jsx)("strong",{style:{fontSize:15,color:"#e6e9ef",overflowWrap:"anywhere"},children:a}),(0,y.jsx)("p",{style:{...r,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},title:e.request,children:e.request}),e.asks&&e.asks.length>0&&(0,y.jsxs)("div",{"data-testid":"history-asks",style:{display:"grid",gap:4,fontSize:13.5,color:"#c9d0db"},children:[(0,y.jsx)("span",{style:dX,children:dI.historyAsks}),(0,y.jsx)("ol",{start:2,style:{margin:0,paddingLeft:20,display:"grid",gap:3,lineHeight:1.5},children:e.asks.map((e,t)=>(0,y.jsx)("li",{style:{overflowWrap:"anywhere"},children:e},t))})]}),e.look?(0,y.jsx)(dD,{runId:e.runId,name:e.name,done:e.done}):(0,y.jsx)("span",{style:{fontSize:13,color:B.f.skipped},children:dI.historyNothingToSee}),(0,y.jsx)(dK,{files:e.files})]})]})}function dJ({tasks:e,github:t}){return(0,y.jsx)(dA,{title:dI.history,help:dI.historyHelp,children:(0,y.jsxs)("ol",{"data-testid":"details-history",className:"factory-history",style:{listStyle:"none",margin:0,padding:0},children:[e.map((n,i)=>(0,y.jsx)(dG,{t:n,more:i<e.length-1||!!t},n.runId)),t&&(0,y.jsxs)("li",{"data-testid":"history-github",style:{...dq,paddingBottom:0},children:[(0,y.jsx)(dZ,{colour:t.published?B.f.passed:B.f.waiting}),(0,y.jsxs)("div",{style:{...dY,gap:6},children:[(0,y.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px",minHeight:26},children:[(0,y.jsx)("strong",{style:{fontSize:15,color:"#e6e9ef"},children:dI.historyGithub}),(0,y.jsx)("span",{style:{padding:"2px 9px",borderRadius:999,background:B.f.tint(t.published?"passed":"waiting",.18),color:t.published?B.f.passed:B.f.waiting,fontSize:11.5,fontWeight:800},children:t.published?dI.historyPublished:dI.historyWaiting}),(0,y.jsx)("span",{style:{fontSize:12.5,color:B.f.skipped},children:dU(t.at)})]}),(0,y.jsxs)("span",{style:{fontSize:13,color:C.f.quiet,overflowWrap:"anywhere"},children:[dI.historyBranch," ",(0,y.jsx)("code",{style:{color:"#c9d0db"},children:t.branch})]}),t.pr&&(0,y.jsxs)("a",{href:t.pr.url,target:"_blank",rel:"noreferrer",style:{justifySelf:"start",color:C.f.green,fontSize:13.5},children:[dI.historyPr(t.pr.number)," ↗"]})]})]})]})})}function dQ({runId:e,state:t}){let[n,i]=(0,m.useState)("desktop"),[r,o]=(0,m.useState)(null);if("working"===t.status)return(0,y.jsxs)("span",{role:"status",style:{display:"flex",alignItems:"center",gap:8,color:C.f.quiet},children:[(0,y.jsx)($.m,{blockId:"pictures",size:15})," ",dI.picturesWorking]});if("ready"!==t.status||0===t.shots.length)return(0,y.jsx)("span",{style:{color:C.f.quiet},children:dI.noPictures});let a=n=>(0,eI.h)(e,n,t);return(0,y.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,y.jsxs)("div",{role:"tablist",style:{display:"flex",gap:8},children:[["desktop","mobile"].map(e=>(0,y.jsx)("button",{type:"button",role:"tab","aria-selected":n===e,onClick:()=>i(e),style:{padding:"7px 16px",borderRadius:999,border:`1px solid ${n===e?B.f.running:C.f.line}`,background:n===e?B.f.tint("running",.18):"transparent",color:n===e?C.f.text:C.f.quiet,fontSize:13.5,fontWeight:700,cursor:"pointer"},children:b.B.snapshots[e]},e)),t.route&&(0,y.jsx)("span",{"data-testid":"pictures-page",style:{alignSelf:"center",marginLeft:"auto",fontSize:13,color:C.f.quiet},children:b.B.snapshots.page(t.route,t.opened)})]}),(0,y.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:14,alignItems:"start"},children:["before","after"].map(e=>{let i=`${e}-${n}`,r=`${b.B.snapshots[e]} \xb7 ${b.B.snapshots[n]}`;return(0,y.jsxs)("figure",{style:{margin:0,display:"grid",gap:6},children:[(0,y.jsx)("figcaption",{style:{justifySelf:"start",fontSize:13,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:"before"===e?C.f.quiet:B.f.passed},children:b.B.snapshots[e]}),t.shots.includes(i)?(0,y.jsxs)("button",{type:"button","aria-label":dI.enlarge(r),title:dI.enlargeHint,onClick:()=>o(i),style:{position:"relative",height:d_,boxSizing:"border-box",display:"flex",justifyContent:"center",alignItems:"flex-start",overflow:"hidden",borderRadius:8,background:C.f.bg,border:`1px solid ${C.f.line}`,padding:8,cursor:"zoom-in"},children:[(0,y.jsx)("img",{src:a(i),alt:r,style:{display:"block",maxWidth:"100%",maxHeight:"100%",borderRadius:6,border:`1px solid ${"before"===e?C.f.line:B.f.tint("passed",.5)}`}}),(0,y.jsxs)("span",{style:{position:"absolute",right:10,bottom:10,display:"inline-flex",alignItems:"center",gap:6,padding:"6px 11px",borderRadius:999,background:"rgba(11, 14, 20, 0.88)",border:`1px solid ${C.f.line}`,color:"#e6e9ef",fontSize:12.5,fontWeight:700},children:[(0,y.jsx)(dW,{path:dL.enlarge,size:14})," ",dI.enlargeHint]})]}):(0,y.jsx)("div",{style:{height:d_,display:"grid",placeItems:"center",padding:16,textAlign:"center",borderRadius:8,border:`1px dashed ${C.f.line}`,color:C.f.quiet,fontSize:13.5,lineHeight:1.45},children:"before"===e?dI.noBefore:dI.noAfter})]},e)})}),r&&(0,y.jsx)(d0,{src:a(r),label:`${b.B.snapshots[r.startsWith("before")?"before":"after"]} \xb7 ${b.B.snapshots[r.endsWith("mobile")?"mobile":"desktop"]}`,phone:r.endsWith("mobile"),onClose:()=>o(null)})]})}function d0({src:e,label:t,phone:n,onClose:i}){return(0,m.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(e.stopImmediatePropagation(),i())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[i]),(0,oi.createPortal)((0,y.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":t,"data-testid":"large-picture",onClick:e=>{e.stopPropagation(),i()},style:{position:"fixed",inset:0,zIndex:120,display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",background:"rgba(5, 7, 11, 0.94)",cursor:"zoom-out"},children:[(0,y.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",color:"#e6e9ef"},children:[(0,y.jsx)("strong",{className:"factory-display",style:{fontSize:17},children:t}),(0,y.jsxs)("button",{type:"button",onClick:i,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"7px 14px",borderRadius:8,border:`1px solid ${C.f.line}`,background:"#141414",color:"#e6e9ef",fontSize:13.5,fontWeight:700,cursor:"pointer"},children:[(0,y.jsx)(dW,{path:dL.cross,size:14})," ",dI.close]})]}),(0,y.jsx)("div",{style:{overflow:"auto",display:"grid",justifyItems:"center",alignItems:"start",padding:"0 20px 24px",...d$},children:(0,y.jsx)("img",{src:e,alt:t,onClick:e=>e.stopPropagation(),style:{display:"block",width:n?"min(100%, 420px)":void 0,maxWidth:"100%",borderRadius:8,border:`1px solid ${C.f.line}`,cursor:"default"}})})]}),document.body)}function d1({runId:e,blockId:t,label:n,view:i,pr:r,away:o=null,onClose:a,onSeeShip:l,onSettings:s,inline:d=!1}){let[c,u]=(0,m.useState)(void 0),[p,f]=(0,m.useState)(!1),h=i?.state==="running";(0,m.useEffect)(()=>{let n=!0,i=i=>fetch(`/api/runs/${e}/blocks/${encodeURIComponent(t)}`).then(e=>e.ok?e.json():null).then(e=>n&&(e||i)&&u(e)).catch(()=>n&&i&&u(null));i(!0);let r=h?setInterval(()=>void i(!1),4e3):null;return()=>{n=!1,r&&clearInterval(r)}},[e,t,h]),(0,m.useEffect)(()=>{if(d)return;let e=e=>{"Escape"===e.key&&a()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,d]);let g=i?.state??c?.state??"queued",x=B.f[(0,$.Y)(g)],v=c?.kind,w=(i?.summary||c?.summary)??null,j=c?.steps??[],k=p?j:j.slice(-8),S="ship"===v||"human"===v,z="human"===v&&"waiting_approval"!==g&&void 0!==l;return(0,y.jsx)("div",{onClick:d?void 0:a,style:d?void 0:{position:"fixed",inset:0,zIndex:60,display:"grid",gridTemplateRows:"minmax(0, 1fr)",placeItems:"center",background:"rgba(5, 7, 11, 0.7)"},children:(0,y.jsxs)("div",{role:d?"region":"dialog","aria-modal":d?void 0:"true","aria-label":dI.title(n),"data-testid":"block-details",onClick:e=>e.stopPropagation(),style:{width:d?"100%":"min(920px, calc(100% - 32px))",height:d?void 0:"min(780px, calc(100% - 96px))",boxSizing:"border-box",display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",background:C.f.card,border:`1px solid ${C.f.line}`,borderTop:d?`1px solid ${C.f.line}`:`3px solid ${x}`,borderRadius:16,boxShadow:d?"none":"0 24px 60px rgba(0,0,0,0.6)",fontSize:d?15:14.5,...d?{"--thumb-w":"380px","--thumb-h":"236px"}:null},children:[(0,y.jsxs)("header",{style:{display:"flex",alignItems:"center",gap:14,padding:d?"26px 28px 0":"18px 26px",borderBottom:d?"none":`1px solid ${C.f.line}`},children:[v&&dE.includes(v)&&(0,y.jsx)(lU.f,{kind:v,colour:x,size:40}),(0,y.jsxs)("div",{style:{display:"grid",gap:4,flex:1,minWidth:0},children:[(0,y.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[(0,y.jsx)("h2",{className:"factory-display",style:{margin:0,fontSize:26},children:n}),c&&(0,y.jsx)("span",{style:{padding:"3px 11px",borderRadius:999,background:`${x}26`,color:x,fontSize:12.5,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase"},children:i?.turn?b.B.direct.yourTurn:b.B.canvas.stateLabel[g]})]}),v&&dI.purpose[v]&&(0,y.jsx)("span",{style:{fontSize:14,color:C.f.quiet},children:dI.purpose[v]})]}),s&&(0,y.jsxs)("button",{type:"button","data-testid":"details-settings",onClick:s,title:dI.settingsHelp,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"7px 12px",borderRadius:8,border:`1px solid ${C.f.line}`,background:"#141414",color:"#c9d0db",cursor:"pointer",font:"inherit",fontSize:13.5,whiteSpace:"nowrap"},children:[(0,y.jsx)(P,{size:14}),dI.settings]}),!d&&(0,y.jsx)("button",{type:"button","aria-label":dI.close,onClick:a,style:{background:"none",border:"none",color:B.f.skipped,cursor:"pointer",fontSize:18},children:"✕"})]}),(0,y.jsxs)("div",{style:{overflowY:"auto",padding:"22px 26px 28px",display:"grid",gap:26,alignContent:"start",...d$},children:[void 0===c&&(0,y.jsxs)("div",{role:"status","aria-label":dI.loading,"data-testid":"details-loading",style:{display:"grid",gap:26},children:[(0,y.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:10},children:[(0,y.jsx)(l7,{height:78,radius:12}),(0,y.jsx)(l7,{height:78,radius:12}),(0,y.jsx)(l7,{height:78,radius:12})]}),(0,y.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,y.jsx)(l7,{width:170,height:18}),(0,y.jsx)(l7,{height:58,radius:12})]}),(0,y.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,y.jsx)(l7,{width:210,height:18}),(0,y.jsx)(l7,{width:"72%",height:13}),(0,y.jsx)(l7,{width:"58%",height:13}),(0,y.jsx)(l7,{width:"64%",height:13})]}),(0,y.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,y.jsx)(l7,{width:150,height:18}),(0,y.jsx)(l7,{height:110,radius:10}),(0,y.jsx)(l7,{height:110,radius:10})]})]}),null===c&&(0,y.jsx)("div",{style:{color:C.f.quiet},children:dI.unreadable}),c&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(170px, 1fr))",gap:10},children:[c.startedAt&&(0,y.jsx)(dP,{icon:dL.clock,label:dI.took,value:null!==c.durationMs?dR(c.durationMs):dI.stillWorking}),c.startedAt&&(0,y.jsx)(dP,{icon:dL.play,label:dI.started,value:dN(c.startedAt)}),c.startedAt&&c.finishedAt&&(0,y.jsx)(dP,{icon:dL.flag,label:dI.finished,value:dN(c.finishedAt)}),null!==c.tokens&&(0,y.jsx)(dP,{icon:dL.spark,label:dI.tokens,value:c.tokens.toLocaleString("en-US"),help:dI.tokensHelp}),c.model&&(0,y.jsx)(dP,{icon:dL.chip,label:dI.model,value:c.model}),c.attempt>1&&(0,y.jsx)(dP,{icon:dL.repeat,label:dI.attempts,value:c.attempt})]}),(0,y.jsxs)(dA,{title:dI.said,help:i?.summaryIsClaim?dI.saidByAi:void 0,children:[(0,y.jsx)("div",{"data-testid":"details-summary",style:{display:"grid",gap:10,padding:"14px 16px",borderRadius:12,background:"#141414",borderLeft:`3px solid ${x}`,fontSize:15.5,lineHeight:1.6,color:"#e6e9ef",overflowWrap:"anywhere"},children:w?(0,y.jsx)(dT,{text:w}):(0,y.jsx)("span",{style:{color:C.f.quiet},children:dI.nothingSaid})}),r&&"ship"===v&&(0,y.jsxs)("a",{href:r.url,target:"_blank",rel:"noreferrer",style:{justifySelf:"start",color:C.f.green,fontSize:14},children:[dI.seeOnGithub(r.number)," ↗"]})]}),c.asked&&c.asked.length>0&&(0,y.jsx)(dA,{title:dI.asked,help:c.asked.length>1?dI.askedHelp:void 0,children:(0,y.jsx)("ol",{"data-testid":"details-asked",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:c.asked.map((e,t)=>(0,y.jsxs)("li",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:12,padding:"12px 14px",borderRadius:10,background:"#141414",border:`1px solid ${C.f.line}`,fontSize:14.5,lineHeight:1.55,color:"#e6e9ef"},children:[(0,y.jsx)("span",{style:{color:B.f.passed,fontWeight:800},children:t+1}),(0,y.jsx)("span",{style:{overflowWrap:"anywhere",whiteSpace:"pre-wrap"},children:e})]},t))})}),z&&(0,y.jsx)(dA,{title:b.B.gate.changesTitle,children:(0,y.jsx)(sQ,{runId:e,away:o,decided:!0})}),z&&(0,y.jsx)(dA,{title:dI.history,children:(0,y.jsxs)("div",{"data-testid":"details-history-on-ship",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"8px 14px",fontSize:14.5,color:"#c9d0db",lineHeight:1.55},children:[(0,y.jsx)("span",{children:dI.historyOnShip}),(0,y.jsxs)("button",{type:"button",onClick:l,style:{padding:"7px 14px",borderRadius:8,border:`1px solid ${C.f.line}`,background:"#141414",color:C.f.green,fontWeight:700,cursor:"pointer",font:"inherit"},children:[dI.historySeeOnShip," →"]})]})}),S&&!z&&((c.history?.length??0)>0?(0,y.jsx)(dJ,{tasks:c.history,github:c.github}):(0,y.jsx)(dO,{runId:e})),"human"===v&&"waiting_approval"===g&&(0,y.jsx)(dA,{title:b.B.gate.changesTitle,children:(0,y.jsx)(sQ,{runId:e,risk:i?.risk,away:o})}),(i?.planMeasure??c.planMeasure)&&(0,y.jsx)(dH,{measure:i?.planMeasure??c.planMeasure,startedOnItsOwn:i?.autoStarted===!0}),c.jobs.length>0&&(0,y.jsx)(dA,{title:dI.jobs(c.jobs.length),children:(0,y.jsx)("div",{style:{display:"grid",gap:10},children:c.jobs.map((e,t)=>(0,y.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:12,padding:"12px 14px",borderRadius:10,background:"#141414",border:`1px solid ${C.f.line}`},children:[(0,y.jsx)("span",{style:{width:26,height:26,borderRadius:999,display:"grid",placeItems:"center",background:B.f.tint("waiting",.18),color:B.f.waiting,fontSize:13,fontWeight:800},children:t+1}),(0,y.jsxs)("div",{style:{display:"grid",gap:6},children:[(0,y.jsx)("span",{style:{fontSize:15,fontWeight:600,color:"#e6e9ef",lineHeight:1.45},children:e.title}),e.done.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("span",{style:{fontSize:12,letterSpacing:"0.06em",textTransform:"uppercase",color:B.f.skipped},children:dI.doneWhen}),e.done.map((e,t)=>(0,y.jsxs)("span",{style:{display:"flex",gap:8,fontSize:13.5,lineHeight:1.45,color:"#c9d0db"},children:[(0,y.jsx)("span",{style:{color:B.f.passed,marginTop:2},children:(0,y.jsx)(dW,{path:dL.check,size:13})}),e]},t))]})]})]},t))})}),c.commands.length>0&&(0,y.jsx)(dA,{title:dI.commands,children:(0,y.jsx)("div",{style:{display:"grid",gap:8},children:c.commands.map((e,t)=>(0,y.jsx)(dF,{c:e},t))})}),j.length>0&&(0,y.jsxs)(dA,{title:dI.steps(j.length),help:dI.stepsHelp,children:[(0,y.jsx)("ol",{"data-testid":"details-steps",style:{margin:0,padding:0,listStyle:"none",display:"grid"},children:k.map((e,t)=>{let n=/^Running:?\s/.test(e.text),i=t===k.length-1;return(0,y.jsxs)("li",{style:{display:"grid",gridTemplateColumns:"54px 18px minmax(0, 1fr)",columnGap:10,alignItems:"start"},children:[(0,y.jsx)("span",{style:{paddingTop:2,fontFamily:dM,fontSize:12,color:B.f.skipped,textAlign:"right"},children:function(e,t){let n=e?Date.parse(t)-Date.parse(e):0/0;if(!Number.isFinite(n))return"";let i=Math.max(0,Math.round(n/1e3));return`+${Math.floor(i/60)}:${String(i%60).padStart(2,"0")}`}(c.startedAt,e.at)}),(0,y.jsxs)("span",{"aria-hidden":"true",style:{display:"grid",justifyItems:"center",alignSelf:"stretch",gridTemplateRows:"auto 1fr"},children:[(0,y.jsx)("span",{style:{width:9,height:9,marginTop:6,borderRadius:999,background:i?x:B.f.skipped}}),!i&&(0,y.jsx)("span",{style:{width:2,minHeight:14,background:C.f.line}})]}),(0,y.jsx)("span",{style:{paddingBottom:12,fontSize:14,lineHeight:1.5,color:"#d6dce6",overflowWrap:"anywhere",...n?{fontFamily:dM,fontSize:12.5}:{}},children:e.text})]},t)})}),j.length>8&&(0,y.jsx)("button",{type:"button",onClick:()=>f(e=>!e),style:{justifySelf:"start",padding:"6px 12px",borderRadius:8,border:`1px solid ${C.f.line}`,background:"#141414",color:"#e6e9ef",fontSize:13,fontWeight:600,cursor:"pointer"},children:p?dI.showFewer:dI.showAll(j.length)})]})]})]})]})})}let d2={queued:["running","skipped","blocked","cancelled"],running:["waiting_approval","passed","failed","cancelled"],waiting_approval:["running","passed","failed","cancelled"],blocked:["queued","skipped","cancelled"],passed:[],failed:[],cancelled:[],skipped:[]},d5=[1e3,2e3,5e3],d4={"node.queued":"queued","node.started":"running","node.waiting_approval":"waiting_approval","node.question_asked":"waiting_approval","node.question_answered":"running","node.completed":"passed","node.failed":"failed","node.skipped":"skipped","node.cancelled":"cancelled"},d6={nodes:{},lastSequence:0},d3=e=>"string"==typeof e&&""!==e.trim()?e:void 0,d8=e=>"number"==typeof e&&Number.isInteger(e)&&e>=0?e:null,d9=new Set(["input","plan","build","tests","review","approve","human","ship"]);function d7(e){return{...e.round?{round:e.round}:{},...e.asking?{asking:!0}:{},...e.planMeasure?{planMeasure:e.planMeasure}:{},...e.autoStarted?{autoStarted:!0}:{},...e.evidence?{evidence:e.evidence}:{},...e.risk?{risk:e.risk}:{},...void 0!==e.tokens?{usage:{tokens:e.tokens,costCents:null}}:{}}}let ce=new Set([b.B.run.notYet.plan,b.B.run.notYet.review]),ct=e=>"skipped"===e.state&&void 0!==e.skippedReason&&ce.has(e.skippedReason);function cn(e,t=[],n){let i={};for(let[n,r]of Object.entries(e)){let e=t.find(e=>e.id===n)?.kind;if(void 0===e||!d9.has(e)){i[n]={blockId:n,state:r.state,summary:b.B.summary.generic[r.state],summaryIsClaim:!1,steps:r.steps,...d7(r)};continue}let o="failed"===r.state,a={kind:e,state:r.state,claim:o?r.failureMessage:r.reportedSummary,claimSource:o?r.failureSource:r.claimSource,cause:o?r.failureCause:void 0,skippedReason:r.skippedReason,counts:r.evidence?.counts??void 0};i[n]={blockId:n,state:r.state,summary:ep(a),summaryIsClaim:ef(a),steps:r.steps,...d7(r),...ct(r)?{notBuilt:!0}:{}}}if(n)for(let e of t.filter(e=>"ship"===e.kind))i[e.id]=n.merged?{blockId:e.id,state:"passed",summary:b.B.summary.mergedVia(n.pr??null),summaryIsClaim:!1,steps:[]}:void 0!==n.pr?{blockId:e.id,state:"waiting_approval",summary:b.B.summary.prOpen(n.pr),summaryIsClaim:!1,steps:[]}:{blockId:e.id,state:"passed",summary:b.B.summary.shippedTo(n.branch),summaryIsClaim:!1,steps:[]};if(!n)for(let e of t.filter(e=>"ship"===e.kind)){let t=i[e.id];t?.state==="skipped"&&(i[e.id]={...t,stateWord:b.B.canvas.waitingForYou})}return i}let ci={"run.created":"queued","run.started":"running","run.waiting_approval":"waiting_approval","run.completed":"completed","run.failed":"failed","run.cancelled":"cancelled"},cr=new Set(["completed","failed","cancelled"]),co={events:[],runStatus:null},ca=e=>({runId:e,stream:d6,log:co});function cl(e,t){var n,i,r;let o;if("reset"===t.type)return ca(t.runId);let a=e.runId===t.runId?e:ca(t.runId);return{runId:t.runId,stream:function(e,t){var n;if(t.sequence<=e.lastSequence)return e;let i={...e,lastSequence:t.sequence},r=t.payload??{};if("run.snapshots"===t.type){let e=d3(r.change);return void 0!==e&&Array.isArray(r.shots)&&r.shots.length>0?{...i,pictured:e}:i}if("run.pushed"===t.type){let t=d3(r.branch);return void 0===t?i:{...i,shipped:{...e.shipped,branch:t}}}if("run.pr_opened"===t.type&&"number"==typeof r.number)return{...i,shipped:{branch:e.shipped?.branch??"",...e.shipped,pr:r.number}};if("run.merged"===t.type)return{...i,shipped:{branch:e.shipped?.branch??"",...e.shipped,merged:!0}};let o=d3(r.blockId);if(void 0===o)return i;let a=e.nodes[o];if("node.plan_decided"===t.type)return{...i,planBlocks:[...new Set([...e.planBlocks??[],o])]};if("node.step"===t.type){let n=d3(r.text);return a&&void 0!==n?{...e,nodes:{...e.nodes,[o]:{...a,steps:[...a.steps,n]}},lastSequence:t.sequence}:i}if("node.evidence"===t.type){let n=function(e){let t=d8(e.durationMs);if(null===t)return;let n="number"==typeof e.exitCode&&Number.isInteger(e.exitCode)?e.exitCode:null,i=e.counts,r=d8(i?.passed),o=d8(i?.failed),a=d8(i?.total),l="string"==typeof e.signal?e.signal:null,s=Array.isArray(e.changedTestFiles)?e.changedTestFiles.filter(e=>"string"==typeof e):null,d=null===s?null:Math.max(d8(e.changedTestFilesCount)??0,s.length);return{counts:null!==r&&null!==o&&null!==a&&r+o<=a?{passed:r,failed:o,total:a}:null,exitCode:n,signal:l,durationMs:t,changedTestFiles:s,changedTestFilesCount:d}}(r);return a&&n?{...e,nodes:{...e.nodes,[o]:{...a,evidence:n}},lastSequence:t.sequence}:i}if("node.reopened"===t.type){if(!a)return i;let n="number"==typeof r.asked?r.asked:"fixes"===r.by?a.round:r.round,l=`${String(r.by)}-${String(r.round)}`,s="fixes"!==r.by&&"reviewer"!==r.by&&void 0!==d3(r.note)&&!e.planBlocks?.includes(o)&&!e.kept?.includes(l);return{...e,nodes:{...e.nodes,[o]:{state:"queued",steps:[],round:"number"==typeof n&&n>1?n:void 0}},lastSequence:t.sequence,...s?{earlier:[...e.earlier??[],{nodes:e.nodes,change:e.pictured}],pictured:void 0,kept:[...e.kept??[],l],reopened:[o]}:{reopened:[...new Set([...e.reopened??[],o])]}}}if("node.assessed"===t.type){let n="low"===r.level||"high"===r.level?r.level:void 0,l=Array.isArray(r.reasons)?r.reasons.filter(e=>"string"==typeof e):[];return a&&n?{...e,nodes:{...e.nodes,[o]:{...a,risk:{level:n,reasons:l,...!0===r.stopForMe?{stopForMe:!0}:{}}}},lastSequence:t.sequence}:i}if("node.plan_measured"===t.type){if(!a)return i;let n=e=>Array.isArray(e)?e.filter(e=>"string"==typeof e):[],l=r.question?.text,s="string"==typeof l&&""!==l.trim()?l:void 0;return{...e,nodes:{...e.nodes,[o]:{...a,planMeasure:{simple:!0===r.simple,reasons:n(r.reasons),entries:n(r.entries),...s?{question:s}:{}}}},lastSequence:t.sequence}}let l=d4[t.type];if(void 0===l||a&&a.state!==l&&(n=a.state,!d2[n].includes(l)))return i;let s={...a,state:l,steps:a?.steps??[]};return"node.question_asked"===t.type?s.asking=!0:delete s.asking,delete s.autoStarted,"node.completed"===t.type&&!0===r.autoStarted&&(s.autoStarted=!0),"node.waiting_approval"===t.type&&"string"==typeof r.summary&&(s.reportedSummary=d3(r.summary),s.claimSource="string"==typeof r.summarySource?r.summarySource:void 0),"queued"===l&&(s.reportedSummary=void 0),"node.completed"===t.type&&(s.reportedSummary=d3(r.summary),s.claimSource="string"==typeof r.summarySource?r.summarySource:void 0,"tokens"in r&&(s.tokens="number"==typeof r.tokens?r.tokens:null)),"node.failed"===t.type&&(s.failureCause=d3(r.cause),s.failureMessage=d3(r.message),s.failureSource="string"==typeof r.messageSource?r.messageSource:void 0),"node.skipped"===t.type&&(s.skippedReason=d3(r.reason)),{...e,nodes:{...e.nodes,[o]:s},lastSequence:t.sequence}}(a.stream,t.event),log:(n=a.log,i=t.event,n.events.length>0&&i.sequence<=n.events[n.events.length-1].sequence?n:{events:[...n.events,i].slice(-300),runStatus:(r=n.runStatus,void 0===(o=ci[i.type])||null!==r&&cr.has(r)?r:o)})}}let cs=()=>()=>void 0,cd=new Set(["queued","running","waiting_approval"]),cc={padding:"6px 14px",background:B.f.card,color:"inherit",border:`1px solid ${B.f.border}`,borderRadius:6,cursor:"pointer"};async function cu(e,t){let n=await e.json().catch(()=>null);return"string"==typeof n?.error?n.error:t}let cp=es.R.filter(e=>e.ready).map(e=>({id:e.id,name:e.name}));e.s(["CanvasScreen",0,function({workflowId:e,graph:t,run:n=null,settings:i=null,draftUpdatedAt:r,localData:o=!1,noTasksYet:a=!1,account:l,ais:s=cp,ai:d=es.b,installedAis:c}){var u;let[p,f]=(0,m.useState)(n),[h,g]=(0,m.useState)(i),[x,C]=(0,m.useState)(null),z=x??(i?.repoPath?d:ed.C),I=p?.providerId??z,E=(0,m.useMemo)(()=>c?new Set(c):null,[c]),_=(0,m.useCallback)((e,t,n)=>(0,es.p)((0,es.t)(I,n,t),e,t),[I]),R=(0,m.useCallback)((e,t)=>(0,es.y)(I)&&es.o.has(t)?(0,es.j)((0,es.t)(I,e,t))??null:null,[I]),A=z!==ed.C&&!h?.repoPath,[H,F]=(0,m.useState)(null),O=(0,m.useSyncExternalStore)(cs,()=>{try{return window.sessionStorage.getItem((0,L.V)(e))}catch{return null}},()=>null),D=H??O??"",q=t=>{try{window.sessionStorage.removeItem((0,L.V)(e))}catch{}F(t)},[V,Z]=(0,m.useState)([]),[K,G]=(0,m.useState)(!1),[J,Q]=(0,m.useState)(""),ee=()=>{q(""),Z(e=>{for(let t of e)URL.revokeObjectURL(t.previewUrl);return[]})},[et,en]=(0,m.useState)(!1),[ei,er]=(0,m.useState)(null),[eo,ea]=(0,m.useState)(null),ec=(0,m.useRef)(null),eu=(0,m.useRef)(null);async function ep(e){let t=await fetch(`/api/runs/${e}`);if(!t.ok)return er(await cu(t,b.B.run.startFailed));ea(null),f(await t.json())}let ef=`factory.direct.${e}`,eh=(0,m.useSyncExternalStore)(cs,()=>{try{return"1"===window.localStorage.getItem(ef)}catch{return!1}},()=>!1),[eg,ex]=(0,m.useState)(null),ey=e=>{ex(e);try{window.localStorage.setItem(ef,e?"1":"0")}catch{}},[em,eb]=(0,m.useState)(null),{views:ev,rounds:ew,events:ek,runStatus:eS,connected:eC,loaded:eB,reopen:eI}=function(e,t){let[n,i]=(0,m.useReducer)(cl,null,()=>ca(e)),{stream:r,log:o}=n.runId===e?n:ca(e),[a,l]=(0,m.useReducer)((e,t)=>t,!1),s=(0,m.useRef)(0),d=(0,m.useRef)(null),c=(0,m.useCallback)(()=>d.current?.(),[]),[u,p]=(0,m.useReducer)((e,t)=>t,null);return(0,m.useEffect)(()=>{let t,n;if(s.current=0,i({type:"reset",runId:e}),null===e)return void l(!1);let r=0,o=!1,a=!1,c=()=>{let d=new EventSource(`/api/runs/${encodeURIComponent(e)}/events?after=${s.current}`);t=d,"function"==typeof d.addEventListener?(d.addEventListener("caughtup",()=>p(e)),d.addEventListener("end",()=>{a=!0,d.close()})):p(e),d.onopen=()=>{r=0,l(!0)},d.onmessage=t=>{let n;try{n=JSON.parse(t.data)}catch{return}"number"!=typeof n.sequence||n.sequence<=s.current||(s.current=n.sequence,i({type:"event",runId:e,event:n}))},d.onerror=()=>{if(d.close(),l(!1),o||a||u())return;let e=d5[Math.min(r,d5.length-1)];r++,n=setTimeout(c,e)}},u=()=>"u">typeof document&&"hidden"===document.visibilityState,f=()=>{u()?(clearTimeout(n),t?.close(),l(!1)):o||a||(t?.close(),c())};"u">typeof document&&document.addEventListener("visibilitychange",f),d.current=()=>{!o&&a&&(a=!1,c())},c();let h=setTimeout(()=>p(e),2500);return()=>{o=!0,"u">typeof document&&document.removeEventListener("visibilitychange",f),clearTimeout(h),clearTimeout(n),t?.close()}},[e]),{views:(0,m.useMemo)(()=>cn(r.nodes,t,r.shipped),[r.nodes,t,r.shipped]),rounds:(0,m.useMemo)(()=>({earlier:(r.earlier??[]).map(e=>({views:cn(e.nodes,t),change:e.change})),reopened:r.reopened??[]}),[r.earlier,r.reopened,t]),lastSequence:r.lastSequence,connected:a,events:o.events,runStatus:o.runStatus,loaded:null!==e&&u===e,reopen:c}}(p?.runId??null,p?.blocks),eM=!!p&&ek.some(e=>"run.created"===e.type&&e.payload?.direct===!0),e$=(eg??eh)||eM&&em!==p?.runId,eE=(0,m.useRef)(r),e_=(0,m.useRef)(Promise.resolve()),eR=(0,m.useRef)(!1),[eN,eT]=(0,m.useState)(null),eW=[...new Set([h?.defaultBranch,h?.currentBranch].filter(e=>!!e))],eL=null!==eN&&eW.includes(eN)?eN:eW[0]??null,[eP,eA]=(0,m.useState)(!1),[eH,eF]=lX("factory.view.conversation",!1),[eO,eD]=(0,m.useState)(null),eq=p?.runId??null,eV=(0,m.useCallback)(e=>eq&&eD({runId:eq,state:e}),[eq]),eY=p?.blocks.find(e=>"ship"===e.kind),[eX,eU]=(0,m.useState)(null),eZ=ek.some(e=>"run.pr_opened"===e.type),eK=eO?.runId===eq;(0,m.useEffect)(()=>{if(!eB||!eq||!eZ||eK)return;let e=!0;return fetch(`/api/runs/${eq}/ship`).then(e=>e.ok?e.json():null).then(t=>e&&t&&eD({runId:eq,state:t})).catch(()=>void 0),()=>{e=!1}},[eB,eq,eZ,eK]);let eG=eB&&(!eZ||eK);(0,m.useEffect)(()=>{if(!eB||!eq)return;let e=setTimeout(()=>eU(eq),eG?250:4e3);return()=>clearTimeout(e)},[eB,eG,eq]);let eJ=!!p&&eX!==p.runId,eQ=(0,W.O)(eq,`${ek.filter(e=>"node.reopened"===e.type||"node.plan_decided"===e.type||"node.question_answered"===e.type).length}-${eS??""}`),e0=function(e){for(let t=e.length-1;t>=0;t--)if(dB.has(e[t].type))return e[t].sequence;return 0}(ek),{record:e1,readMark:e2,failed:e5,reload:e4}=function(e,t){let[n,i]=(0,m.useState)(null),[r,o]=(0,m.useState)(null),[a,l]=(0,m.useState)(0);(0,m.useEffect)(()=>{if(!e)return;let n=!0;return fetch(`/api/runs/${encodeURIComponent(e)}/findings`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(r=>{n&&(i({runId:e,record:r,mark:t}),o(null))}).catch(()=>n&&o(e)),()=>{n=!1}},[e,t,a]);let s=(0,m.useCallback)(()=>l(e=>e+1),[]);return{record:n&&n.runId===e?n.record:null,readMark:n&&n.runId===e?n.mark:-1,failed:r===e,reload:s}}(eq,e0),e6=e=>{if(!p||!eM)return e;let t={...e};for(let e of p.blocks){let n=t[e.id];"build"===e.kind&&n?.state==="waiting_approval"&&(t[e.id]={...n,turn:!0,summary:b.B.direct.turnSummary})}return t},e3=e=>{if(!p||0===eQ.length)return e;let t={...e};for(let e of["input","plan","build","review","human"]){let n=p.blocks.find(t=>t.kind===e&&t.enabled),i=eQ.filter(t=>(0,W.B)(t)===e||"input"===e&&"changes"===t.kind);n&&t[n.id]&&i.length>0&&(t[n.id]={...t[n.id],asked:i})}return t},e8=eO&&eO.runId===eq&&eY?function(e,t){if(!t.pr)return null;let n=b.B.ship,i=[n.stepPushed,n.stepPr(t.pr.number),...t.checks.map(e=>`${e.name}: ${n.checkState[e.state]}`)],r={blockId:e,summaryIsClaim:!1,steps:i};if("closed"===t.pr.state)return{...r,state:"cancelled",summary:n.closed};if("open"===t.pr.state){if(t.pr.conflicts)return{...r,state:"failed",summary:n.conflicts};if(t.checksFailed)return{...r,state:"failed",summary:n.someFailed};if(!t.checksDone){let e=t.checks.filter(e=>"pending"!==e.state).length;return{...r,state:"running",summary:0===t.checks.length?n.cardLooking:n.cardChecking(e,t.checks.length)}}return{...r,state:"waiting_approval",summary:t.onHold?n.cardOnHold:n.cardReady}}let o=[...i,t.deployPending?n.stepMerged:n.merged,...t.deploy.map(e=>`${e.name}: ${n.checkState[e.state]}`)];return t.deploy.some(e=>"failed"===e.state)?{...r,steps:o,state:"failed",summary:n.deployFailed}:t.deployPending||t.deploy.some(e=>"pending"===e.state)?{...r,steps:o,state:"running",summary:n.cardDeploying}:{...r,steps:o,state:"passed",summary:t.deploy.length>0?n.cardLive:n.merged}}(eY.id,eO.state):null,e9=e8&&eY?{...ev,[eY.id]:e8}:ev,e7=Object.values(ev).some(e=>e.risk)&&eq&&eY&&e9[eY.id]?{...e9,[eY.id]:{...e9[eY.id],results:eq}}:e9,te=(0,m.useCallback)(()=>eA(!1),[]);async function tt(){en(!0),er(null);try{if(ec.current&&!await ec.current())return er(b.B.run.saveFirst);let t=await fetch(`/api/workflows/${e}/publish`,{method:"POST"});if(!t.ok)return er(400===t.status?b.B.run.fixFirst:await cu(t,b.B.run.startFailed));let n=await fetch(`/api/workflows/${e}/runs`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({request:D,provider:z,attachments:sN(V),...K?{stopForMe:!0}:{},...e$&&z!==ed.C?{direct:!0}:{},...J.trim()?{title:J.trim()}:{},...z!==ed.C&&eL?{startFrom:eL}:{}})});if(!n.ok)return er(await cu(n,b.B.run.startFailed));let{runId:i}=await n.json(),r=await fetch(`/api/runs/${i}`);if(!r.ok)return er(await cu(r,b.B.run.startFailed));ea(null),f(await r.json()),ee(),G(!1),Q("")}catch{er(b.B.run.startFailed)}finally{en(!1)}}let[tn,ti]=(0,m.useState)("none"),[tr,to]=(0,m.useState)(a?0:null),[ta,tl]=(0,m.useState)(0),ts=null===p&&0!==tr&&"new"!==tn,td=h?.projectId,tc=(0,m.useCallback)(()=>{td&&fetch(`/api/projects/${td}`).then(e=>e.ok?e.json():null).then(e=>e&&g(e)).catch(()=>void 0)},[td]),tu=h?.suggestedTestCommand??null,tp=(0,m.useSyncExternalStore)(cs,()=>{try{return td?localStorage.getItem(`factory.testSuggestion.${td}`):null}catch{return null}},()=>null),[tf,th]=(0,m.useState)(null),[tg,tx]=(0,m.useState)(!1),[ty,tm]=(0,m.useState)(!1);async function tb(){if(tu&&td){tx(!0),tm(!1);try{let e=await fetch(`/api/projects/${td}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({testCommand:tu})}),t=await e.json().catch(()=>null);if(!e.ok||!t)return tm(!0);g(t)}catch{tm(!0)}finally{tx(!1)}}}function tv(e="new"){e$&&ey(!0),ti(e),f(null),eT(null),ea(null),er(null),ee(),tc(),"new"===e&&requestAnimationFrame(()=>document.getElementById(sp)?.focus())}async function tw(){if(p){er(null);try{let e=await fetch(`/api/runs/${p.runId}/cancel`,{method:"POST"});e.ok||er(await cu(e,b.B.run.cancelFailed))}catch{er(b.B.run.cancelFailed)}}}let tj=null!==eS&&cd.has(eS),tk="completed"===eS||"failed"===eS||"cancelled"===eS,tS=!!p&&p.blocks.some(e=>ev[e.id]?.asking===!0&&ev[e.id]?.state==="waiting_approval"),tC=null===p?null:null!==eS?tk?b.B.run.lastRun(b.B.run.status[eS]):"waiting_approval"===eS&&tS?b.B.question.stateLabel:b.B.run.status[eS]:eC?null:b.B.run.connecting,tB=!et&&!tj&&""!==D.trim()&&!A&&!sT(V),[tz,tI]=(0,m.useState)(!1),tM=(0,m.useRef)(null),[t$,tE]=(0,m.useState)(null),[t_,tR]=(0,m.useState)(null),tN=p?.blocks.find(e=>"human"===e.kind),tT=eY?e7[eY.id]?.state:void 0,tW=eY&&tT&&"queued"!==tT&&"skipped"!==tT?eY.id:null,tL=p?.blocks.find(e=>"plan"===e.kind),tP=!!p&&p.blocks.some(e=>"plan"===e.kind&&ev[e.id]?.state==="waiting_approval"&&ev[e.id]?.asking!==!0),tA=!!p&&p.providerId!==ed.C&&p.blocks.some(e=>"review"===e.kind&&e.enabled&&ev[e.id]?.state==="passed"),tH=p&&"waiting_approval"===eS&&tS?"question":p&&"waiting_approval"===eS&&tP?"plan":p&&"waiting_approval"===eS?"waiting":p&&("running"===eS||"queued"===eS)?"working":p&&"completed"===eS&&p.providerId!==ed.C?"done":p&&"failed"===eS&&p.providerId!==ed.C?"failed":"idle",tF=eO&&eO.runId===eq?eO.state:null,tO=S(tF)&&!tF?.onHold,tD=function(e,t){let n=(0,m.useRef)(null),[i,r]=(0,m.useState)(null),o=t?.pr?.state==="merged"&&!0!==t.deployPending,a=null!==t;return(0,m.useEffect)(()=>{if(!e||!a)return;let t=n.current;if(n.current={runId:e,published:o},t?.runId!==e||t.published||!o)return;let i=setTimeout(()=>r(e),0),l=setTimeout(()=>r(null),3200);return()=>{clearTimeout(i),clearTimeout(l)}},[e,a,o]),null!==i&&i===e}(eq,tF),tq="plan"===tH||"question"===tH||"waiting"===tH?"answer":"done"===tH&&tO?"publish":null,{offer:tV,allow:tY}=function({attention:e,waitingCount:t,taskTitle:n,askKey:i=null}){var r;let o="granted"===(r=(0,m.useSyncExternalStore)(j,k,()=>null))?"on":"denied"===r?"blocked":"default"===r?"ask":"none",[,a]=(0,m.useState)(0);(0,m.useEffect)(()=>{if("u">typeof document){var n;let i;document.title=(n="publish"===e,i=t>0?b.B.tell.waitingTitle(t):n?b.B.tell.readyTitle:null,b.B.tell.tabTitle(i))}},[t,e]),(0,m.useEffect)(()=>()=>{"u">typeof document&&(document.title=b.B.app.name)},[]);let l=(0,m.useRef)(new Set);return(0,m.useEffect)(()=>{if(!e)return;let t=`${e}|${i??""}`;if(!l.current.has(t)){l.current.add(t);try{if("u"<typeof document||!document.hidden||"granted"!==k())return;new Notification("answer"===e?b.B.tell.needsAnswer:b.B.tell.readyToPublish,{body:n??""})}catch{}}},[e,i]),{offer:o,allow:(0,m.useCallback)(()=>{try{if(null===k())return;Promise.resolve(Notification.requestPermission()).then(()=>a(e=>e+1)).catch(()=>void 0)}catch{}},[])}}({attention:tq,waitingCount:Math.max(ta,+("answer"===tq)),taskTitle:p?.title??null,askKey:p?`${p.runId}:${tH}:${dz(ek)??""}`:null}),tX=(0,y.jsxs)("button",{type:"button","aria-expanded":eP,onClick:()=>eA(e=>!e),style:{...cc,marginLeft:h?.repoPath?0:"auto",fontWeight:600,display:"inline-flex",alignItems:"center",gap:8},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M5 7h14M5 12h14M5 17h14"})}),b.B.history.open,(tr??0)>0&&(0,y.jsx)("span",{style:{padding:"1px 8px",borderRadius:999,background:B.f.border,fontSize:12},children:tr})]}),tU=eH&&!e$&&null!==p&&!eJ,tZ=(0,y.jsx)(dv,{docked:!0,direct:e$&&z!==ed.C,ref:eu,mode:tH,runId:p?.runId??null,risk:Object.values(ev).find(e=>"waiting_approval"===e.state)?.risk,planMeasure:tL?ev[tL.id]?.planMeasure:void 0,stopForMe:K,onStopForMe:G,text:D,onText:q,images:V,onImages:Z,onRun:()=>void tt(),canRun:tB,onFollowUp:e=>void ep(e),onNewTask:()=>tv("new"),onTaskDeleted:()=>tv("none"),onShipState:eV,onSent:ee,startOptions:z!==ed.C?eW:[],startFrom:eN,onStartFrom:eT,onRecorded:()=>{eI(),tc()},away:p&&!1===p.here?{machine:p.machine??null}:null,taskName:J,onTaskName:Q,loading:eJ,failureActions:tM,onCanContinue:e=>tE(e&&p?p.runId:null),onSeeChanges:tN?()=>tR(tN.id):void 0,record:e1,recordFailed:e5,recordMark:e0,recordReadMark:e2,askedId:dz(ek),onRecordChanged:e4,showFindings:tA,notice:{offer:tV,onAllow:tY}},`${p?.runId??"none"}-${eJ?"loading":tH}`);return(0,y.jsxs)("div",{style:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,y.jsxs)("header",{style:{display:"flex",alignItems:"center",gap:12,padding:"8px 12px",minHeight:36,borderBottom:`1px solid ${B.f.border}`,background:B.f.bg},children:[(0,y.jsxs)("span",{"data-testid":"app-mark",style:{display:"flex",alignItems:"center",gap:8,marginRight:4,fontSize:11,fontWeight:800,letterSpacing:"0.13em",textTransform:"uppercase",color:B.f.dim,whiteSpace:"nowrap"},children:[(0,y.jsx)("span",{style:{color:"#e8eaf0",display:"flex"},children:(0,y.jsx)(ez.f,{size:22})}),b.B.app.name]}),l&&(0,y.jsx)(U.f,{account:l,style:cc}),(0,y.jsx)(Y,{workflowId:e,style:cc,onOpenSettings:h?()=>tI(!0):void 0}),o&&(0,y.jsxs)("span",{"data-testid":"local-data",title:b.B.localData.hint,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:999,border:`1px solid ${B.f.waiting}`,color:B.f.waiting,fontSize:12,fontWeight:700,whiteSpace:"nowrap",cursor:"help"},children:[(0,y.jsx)("span",{"aria-hidden":!0,style:{width:7,height:7,borderRadius:"50%",background:B.f.waiting}}),b.B.localData.label]}),h&&(0,y.jsx)("button",{type:"button","aria-label":b.B.projectSettings.open,title:b.B.projectSettings.open,onClick:()=>tI(!0),style:{...cc,padding:"6px 9px",display:"grid",placeItems:"center"},children:(0,y.jsx)(P,{size:17})}),tz&&h&&(0,y.jsx)(el,{settings:h,onClose:()=>tI(!1),onSaved:g}),h&&(0,y.jsx)(lN.g.Provider,{value:E,children:(0,y.jsx)(lN.T,{value:z,ais:s,disabled:tj,style:{...cc,padding:"6px 10px"},onChange:e=>{C(e),e!==ed.C&&fetch("/api/account/ai",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({ai:e})}).catch(()=>void 0)}})}),!e$&&(0,y.jsx)("button",{type:"button",disabled:!tB,title:A?b.B.settings.needsRepo:""===D.trim()?b.B.run.writeFirst:void 0,onClick:tt,style:{...cc,fontWeight:600,background:tB?B.f.running:B.f.card,borderColor:tB?B.f.running:B.f.border,color:tB?"#fff":B.f.skipped,cursor:tB?"pointer":"not-allowed"},children:et?b.B.run.starting:b.B.run.run}),A&&(0,y.jsx)("button",{type:"button",onClick:()=>tI(!0),style:{background:"none",border:"none",padding:0,fontSize:12.5,color:B.f.waiting,cursor:"pointer",textDecoration:"underline"},children:b.B.settings.needsRepo}),(!e$||tj)&&(0,y.jsx)("button",{type:"button",style:cc,disabled:!tj,onClick:tw,children:b.B.run.cancel}),p&&!tj&&(0,y.jsxs)("button",{type:"button",style:{...cc,fontWeight:700,background:B.f.passed,borderColor:B.f.passed,color:"#0d1f12"},onClick:()=>tv("new"),children:["+ ",b.B.delivery.newTask]}),(0,y.jsx)("span",{"aria-hidden":"true",style:{flex:1}}),p?.providerId===ed.C&&(0,y.jsx)("span",{title:b.B.run.demoTitle,style:{padding:"2px 8px",border:`1px solid ${B.f.waiting}`,color:B.f.waiting,borderRadius:999,fontSize:12,fontWeight:600},children:b.B.run.demoBadge}),tC&&"waiting_approval"===eS?(0,y.jsxs)("button",{type:"button","data-testid":"run-status",title:b.B.gate.goToGate,onClick:()=>{let e=p?.blocks.find(e=>ev[e.id]?.state==="waiting_approval");e&&ea(e.id),eu.current?.focus(),eu.current?.scrollIntoView?.({block:"nearest"})},style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",background:B.f.tint("waiting",.12),color:B.f.waiting,border:`1px solid ${B.f.tint("waiting",.5)}`,borderRadius:999,fontSize:13,fontWeight:600,cursor:"pointer"},children:[(0,y.jsx)("span",{"aria-hidden":"true",children:"⚠"}),tC]}):tC&&"completed"===eS&&p&&p.providerId!==ed.C?(0,y.jsxs)("button",{type:"button","data-testid":"run-status",title:b.B.delivery.title,onClick:()=>{eu.current?.focus(),eu.current?.scrollIntoView?.({block:"nearest"})},style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",background:B.f.tint("passed",.12),color:B.f.passed,border:`1px solid ${B.f.tint("passed",.5)}`,borderRadius:999,fontSize:13,fontWeight:600,cursor:"pointer"},children:[(0,y.jsx)("span",{"aria-hidden":"true",children:"✓"}),tC]}):tC&&(0,y.jsxs)("span",{"data-testid":"run-status",role:"status",style:{display:"flex",alignItems:"center",gap:7,color:eS?B.f["running"===(u=eS)?"running":"completed"===u?"passed":"failed"===u?"failed":"waiting_approval"===u?"waiting":"skipped"]:B.f.skipped,fontSize:13},children:["running"===eS&&(0,y.jsx)($.m,{blockId:"run",size:14}),tC]}),h?.repoPath&&(0,y.jsxs)("button",{type:"button","data-testid":"direct-edit-toggle","aria-pressed":e$,title:b.B.direct.hint,onClick:()=>{ey(!e$),eb(e$?p?.runId??null:null)},style:{...cc,marginLeft:"auto",fontWeight:600,display:"inline-flex",alignItems:"center",gap:8,...e$?{border:`1px solid ${B.f.passed}`,color:B.f.passed}:{}},children:[(0,y.jsxs)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,y.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),(0,y.jsx)("path",{d:"M10 4v16"})]}),e$?b.B.direct.off:b.B.direct.on]}),tX,l&&(0,y.jsx)(X.P,{person:l.person})]}),tu&&(tf??tp)!==tu&&(0,y.jsxs)("div",{"data-testid":"test-suggestion",role:"status",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,padding:"8px 14px",borderBottom:`1px solid ${B.f.border}`,background:"rgba(121, 220, 139, 0.07)",fontSize:13},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:B.f.passed,strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})}),(0,y.jsx)("span",{children:ty?b.B.testSuggestion.failed:b.B.testSuggestion.text(tu)}),(0,y.jsx)("button",{type:"button",disabled:tg,onClick:()=>void tb(),style:{padding:"5px 12px",borderRadius:6,border:`1px solid ${B.f.passed}`,background:B.f.passed,color:"#07110a",fontWeight:700,cursor:tg?"wait":"pointer"},children:b.B.testSuggestion.accept}),(0,y.jsx)("button",{type:"button",disabled:tg,onClick:function(){if(tu&&td){th(tu);try{localStorage.setItem(`factory.testSuggestion.${td}`,tu)}catch{}}},style:{...cc,padding:"5px 12px"},children:b.B.testSuggestion.dismiss})]}),(0,y.jsxs)("div",{style:{flex:1,minHeight:0,position:"relative",overflow:"clip"},children:[null===p&&!(e$&&(tr??0)>0&&"new"===tn)&&(0,y.jsx)("div",{"data-testid":"no-task",role:"region","aria-label":0===tr?b.B.history.firstTaskTitle:b.B.history.noTaskTitle,style:{position:"absolute",top:ts?"50%":64,left:"50%",transform:ts?"translate(-50%, -60%)":"translateX(-50%)",zIndex:4,width:ts?"min(520px, calc(100% - 32px))":"min(440px, calc(100% - 32px))",display:"grid",gap:ts?12:8,padding:ts?"28px 28px 26px":"16px 18px",background:B.f.card,border:`1px solid ${B.f.border}`,borderRadius:12,boxShadow:"0 12px 30px rgba(0,0,0,0.4)",textAlign:"center"},children:0===tr?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("strong",{className:"factory-display",style:{fontSize:19},children:b.B.history.firstTaskTitle}),(0,y.jsx)("span",{style:{fontSize:13,color:B.f.dim,lineHeight:1.5},children:b.B.history.firstTaskText}),(0,y.jsxs)("button",{type:"button",onClick:()=>{let e=document.querySelector('[data-testid="command-card"]');e?.querySelector("textarea")?.focus(),e?.animate?.([{boxShadow:"0 0 0 0 rgba(59, 130, 246, 0.95)",transform:"scale(1)"},{boxShadow:"0 0 0 10px rgba(59, 130, 246, 0.35)",transform:"scale(1.015)"},{boxShadow:"0 0 0 22px rgba(59, 130, 246, 0)",transform:"scale(1)"}],{duration:650,iterations:2,easing:"ease-out"})},style:{justifySelf:"center",marginTop:4,display:"inline-flex",alignItems:"center",gap:8,padding:"8px 18px",borderRadius:8,border:"none",background:B.f.running,color:"#fff",fontWeight:700,cursor:"pointer"},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M12 5v14M5 12h14"})}),b.B.history.firstTaskAction]})]}):"new"===tn?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("strong",{style:{fontSize:15},children:b.B.history.newTaskTitle}),(0,y.jsx)("span",{style:{fontSize:12.5,color:B.f.dim,lineHeight:1.45},children:b.B.history.newTaskText})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("strong",{className:"factory-display",style:{fontSize:24},children:b.B.history.noTaskTitle}),(0,y.jsx)("span",{style:{fontSize:14.5,color:B.f.dim,lineHeight:1.5},children:b.B.history.noTaskText}),(0,y.jsxs)("div",{style:{display:"flex",justifyContent:"center",gap:10,flexWrap:"wrap",marginTop:6},children:[(0,y.jsxs)("button",{type:"button",onClick:()=>{ti("new"),requestAnimationFrame(()=>document.querySelector('[data-testid="command-card"] textarea')?.focus())},style:{display:"inline-flex",alignItems:"center",gap:8,padding:"10px 20px",borderRadius:8,border:"none",background:B.f.running,color:"#fff",fontSize:14.5,fontWeight:700,cursor:"pointer"},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M12 5v14M5 12h14"})}),b.B.history.createOne]}),(0,y.jsxs)("button",{type:"button",onClick:()=>eA(!0),style:{display:"inline-flex",alignItems:"center",gap:8,padding:"10px 20px",borderRadius:8,border:`1px solid ${B.f.border}`,background:"#0f141c",color:"#e6e9ef",fontSize:14.5,fontWeight:700,cursor:"pointer"},children:[(0,y.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round","aria-hidden":"true",children:(0,y.jsx)("path",{d:"M5 7h14M5 12h14M5 17h14"})}),b.B.history.openPast]})]})]})}),(0,y.jsx)(M,{open:eP,onClose:te,count:tr,children:(0,y.jsx)(w.R,{workflowId:e,currentRunId:p?.runId??null,publishing:eO?.runId===p?.runId&&eO?.state.pr?.state==="merged"&&!0===eO.state.deployPending,refreshKey:`${p?.runId??""}-${eS??""}-${eP}`,onOpen:e=>{eA(!1),ep(e)},onCount:to,onWaiting:tl,onDeleted:e=>{e===p?.runId&&(tv("none"),eA(!1))}})}),tZ,(0,y.jsx)(lN.g.Provider,{value:E,children:(0,y.jsxs)($.c.Provider,{value:R,children:[(0,y.jsx)($.v.Provider,{value:_,children:(0,y.jsx)(sx,{layout:e$?"steps":"canvas",site:e$?(0,y.jsx)(N,{runId:p&&!1!==p.here&&z!==ed.C?p.runId:null,projectId:p?null:h?.projectId??null}):void 0,stepDetails:e=>p?(0,y.jsx)(d1,{inline:!0,runId:p.runId,blockId:e,label:p.blocks.find(t=>t.id===e)?.label??e,view:e3(e6(e7))[e],pr:eO?.runId===p.runId?eO.state.pr??null:null,away:!1===p.here?{machine:p.machine??null}:null,onClose:()=>void 0},`inline-${p.runId}-${e}`):null,graph:t,save:function(t){let n=e_.current.catch(()=>void 0).then(async()=>{if(eR.current)throw Error("stale draft");let n=await fetch(`/api/workflows/${e}/draft`,{method:"PUT",headers:{"content-type":"application/json",...eE.current?{"x-draft-base":eE.current}:{}},body:JSON.stringify(t),keepalive:!0});if(409===n.status)throw eR.current=!0,er(b.B.editing.staleDraft),Error("stale draft");if(!n.ok)throw Error(`Saving the draft failed (${n.status})`);let i=await n.json();return i.updatedAt&&(eE.current=i.updatedAt),i.issues});return e_.current=n,n},nodeRuns:Object.values(e3(e6(e7))),runBlocks:p?.blocks,highlightedId:eo,onFailedClick:"failed"===tH?e=>"see"===e?tM.current?.see():tM.current?.again():void 0,canRetry:"failed"===tH&&t$===p?.runId,onDetails:p?tR:void 0,blank:ts,taskId:p?.runId??null,flushRef:ec,loading:eJ,overlay:p&&!eJ?(0,y.jsx)(y.Fragment,{children:(0,y.jsx)(T,{roomy:e$,runId:p.runId,initial:p.title??"",onRenamed:e=>f(t=>t&&t.runId===p.runId?{...t,title:e}:t)},p.runId)}):void 0,sidebarLog:p?(0,y.jsx)(ej,{events:ek,blocks:p.blocks,onPoint:ea}):void 0})}),tU&&p&&(0,y.jsx)(sS,{runId:p.runId,blocks:p.blocks,views:e3(e6(e7)),rounds:ew,prompts:eQ,onDetails:tR}),!e$&&null!==p&&!eJ&&(0,y.jsx)(sk,{chat:eH,onChange:eF}),tD&&(0,y.jsx)(v,{})]})}),p&&t_&&(0,y.jsx)(d1,{runId:p.runId,blockId:t_,label:p.blocks.find(e=>e.id===t_)?.label??t_,view:e6(e7)[t_],pr:eO?.runId===p.runId?eO.state.pr??null:null,away:!1===p.here?{machine:p.machine??null}:null,onClose:()=>tR(null),onSeeShip:tW?()=>tR(tW):void 0,onSettings:()=>{tR(null),window.dispatchEvent(new CustomEvent(sc,{detail:t_}))}},`details-${p.runId}-${t_}`)]})]})}],92432)}]);
|