plaincrew 0.2.1 → 0.2.2
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/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 → dLfuxcueP2VUobb7KqDeT}/_buildManifest.js +0 -0
- /package/app-build/static/{HAjlyCK72AXHP41NT95Jp → dLfuxcueP2VUobb7KqDeT}/_clientMiddlewareManifest.js +0 -0
- /package/app-build/static/{HAjlyCK72AXHP41NT95Jp → dLfuxcueP2VUobb7KqDeT}/_ssgManifest.js +0 -0
|
@@ -2,6 +2,6 @@ module.exports=[47349,(a,b,c)=>{"use strict";var d=a.r(72131);d.useState,d.useEf
|
|
|
2
2
|
M${B.x},${B.y}h${B.width}v${B.height}h${-B.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}hD.displayName="MiniMap",(0,s.memo)(hD);let hE={[p.Line]:"right",[p.Handle]:"bottom-right"};(0,s.memo)(function({nodeId:a,position:b,variant:c=p.Handle,className:d,style:e,children:f,color:g,minWidth:h=10,minHeight:i=10,maxWidth:j=Number.MAX_VALUE,maxHeight:k=Number.MAX_VALUE,keepAspectRatio:l=!1,resizeDirection:m,autoScale:n=!0,shouldResize:o,onResizeStart:q,onResize:t,onResizeEnd:u}){let v,w=f9(),x="string"==typeof a?a:w,y=fg(),z=(0,s.useRef)(null),A=c===p.Handle,B=ff((0,s.useCallback)((v=A&&n,a=>v?`${Math.max(1/a.transform[2],1)}`:void 0),[A,n]),fa),C=(0,s.useRef)(null),D=b??hE[c];(0,s.useEffect)(()=>{if(z.current&&x)return C.current||(C.current=function({domNode:a,nodeId:b,getStoreItems:c,onChange:d,onEnd:e}){let f=bk(a),g={controlDirection:eZ("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};return{update:function({controlPosition:a,boundaries:h,keepAspectRatio:i,resizeDirection:j,onResizeStart:k,onResize:l,onResizeEnd:m,shouldResize:n}){let o,p,q,r,s={...e1},t={...e2};g={boundaries:h,resizeDirection:j,keepAspectRatio:i,controlDirection:eZ(a)};let u=null,v=[],w=bA().on("start",a=>{let{nodeLookup:d,transform:e,snapGrid:f,snapToGrid:g,nodeOrigin:h,paneDomNode:i}=c();if(!(o=d.get(b)))return;u=i?.getBoundingClientRect()??null;let{xSnapped:j,ySnapped:l}=ed(a.sourceEvent,{transform:e,snapGrid:f,snapToGrid:g,containerBounds:u});for(let[a,c]of(t={...s={width:o.measured.width??0,height:o.measured.height??0,x:o.position.x??0,y:o.position.y??0},pointerX:j,pointerY:l,aspectRatio:s.width/s.height},p=void 0,q=d7(o.extent)?o.extent:void 0,o.parentId&&("parent"===o.extent||o.expandParent)&&(p=d.get(o.parentId)),p&&"parent"===o.extent&&(q=[[0,0],[p.measured.width,p.measured.height]]),v=[],r=void 0,d))if(c.parentId===b&&(v.push({id:a,position:{...c.position},extent:c.extent}),"parent"===c.extent||c.expandParent)){let a=function(a,b,c){let d=b.position.x+a.position.x,e=b.position.y+a.position.y,f=a.measured.width??0,g=a.measured.height??0,h=c[0]*f,i=c[1]*g;return[[d-h,e-i],[d+f-h,e+g-i]]}(c,o,c.origin??h);r=r?[[Math.min(a[0][0],r[0][0]),Math.min(a[0][1],r[0][1])],[Math.max(a[1][0],r[1][0]),Math.max(a[1][1],r[1][1])]]:a}k?.(a,{...s})}).on("drag",a=>{let{transform:b,snapGrid:e,snapToGrid:f,nodeOrigin:h}=c(),i=ed(a.sourceEvent,{transform:b,snapGrid:e,snapToGrid:f,containerBounds:u}),j=[];if(!o)return;let{x:k,y:m,width:w,height:x}=s,y={},z=o.origin??h,{width:A,height:B,x:C,y:D}=function(a,b,c,d,e,f,g,h){var i,j,k,l;let{affectsX:m,affectsY:n}=b,{isHorizontal:o,isVertical:p}=b,q=o&&p,{xSnapped:r,ySnapped:s}=c,{minWidth:t,maxWidth:u,minHeight:v,maxHeight:w}=d,{x:x,y:y,width:z,height:A,aspectRatio:B}=a,C=Math.floor(o?r-a.pointerX:0),D=Math.floor(p?s-a.pointerY:0),E=z+(m?-C:C),F=A+(n?-D:D),G=-f[0]*z,H=-f[1]*A,I=e0(E,t,u),J=e0(F,v,w);if(g){let a=0,b=0;m&&C<0?a=e$(x+C+G,g[0][0]):!m&&C>0&&(a=e_(x+E+G,g[1][0])),n&&D<0?b=e$(y+D+H,g[0][1]):!n&&D>0&&(b=e_(y+F+H,g[1][1])),I=Math.max(I,a),J=Math.max(J,b)}if(h){let a=0,b=0;m&&C>0?a=e_(x+C,h[0][0]):!m&&C<0&&(a=e$(x+E,h[1][0])),n&&D>0?b=e_(y+D,h[0][1]):!n&&D<0&&(b=e$(y+F,h[1][1])),I=Math.max(I,a),J=Math.max(J,b)}if(e){if(o){(I=Math.max(I,e0(E/B,v,w)*B),g)&&(I=Math.max(I,(m||n)&&(!m||n||!q)?e$(y+H+(m?C:-C)/B,g[0][1])*B:e_(y+H+E/B,g[1][1])*B));h&&(I=Math.max(I,(m||n)&&(!m||n||!q)?e_(y+(m?C:-C)/B,h[0][1])*B:e$(y+E/B,h[1][1])*B))}if(p){(J=Math.max(J,e0(F*B,t,u)/B),g)&&(J=Math.max(J,(m||n)&&(!n||m||!q)?e$(x+(n?D:-D)*B+G,g[0][0])/B:e_(x+F*B+G,g[1][0])/B));h&&(J=Math.max(J,(m||n)&&(!n||m||!q)?e_(x+(n?D:-D)*B,h[0][0])/B:e$(x+F*B,h[1][0])/B))}}D+=D<0?J:-J,C+=C<0?I:-I,e&&(q?E>F*B?D=((i=m,j=n,i?!j:j)?-C:C)/B:C=((k=m,l=n,k?!l:l)?-D:D)*B:o?(D=C/B,n=m):(C=D*B,m=n));let K=m?x+C:x,L=n?y+D:y;return{width:z+(m?-C:C),height:A+(n?-D:D),x:f[0]*C*(m?-1:1)+K,y:f[1]*D*(n?-1:1)+L}}(t,g.controlDirection,i,g.boundaries,g.keepAspectRatio,z,q,r),E=A!==w,F=B!==x,G=C!==k&&E,H=D!==m&&F;if(!G&&!H&&!E&&!F)return;let I={prevValues:{...s},startX:t.x,startY:t.y,childNodes:v.map(a=>({...a,position:{...a.position}}))};if((G||H||1===z[0]||1===z[1])&&(y.x=G?C:s.x,y.y=H?D:s.y,s.x=y.x,s.y=y.y,v.length>0)){let a=C-k,b=D-m;for(let c of v)c.position={x:c.position.x-a+z[0]*(A-w),y:c.position.y-b+z[1]*(B-x)},j.push(c)}if((E||F)&&(y.width=E&&(!g.resizeDirection||"horizontal"===g.resizeDirection)?A:s.width,y.height=F&&(!g.resizeDirection||"vertical"===g.resizeDirection)?B:s.height,s.width=y.width,s.height=y.height),p&&o.expandParent){let a=z[0]*(y.width??0);y.x&&y.x<a&&(s.x=a,t.x=t.x-(y.x-a));let b=z[1]*(y.height??0);y.y&&y.y<b&&(s.y=b,t.y=t.y-(y.y-b))}let J=function({width:a,prevWidth:b,height:c,prevHeight:d,affectsX:e,affectsY:f}){let g=a-b,h=c-d,i=[g>0?1:g<0?-1:0,h>0?1:h<0?-1:0];return g&&e&&(i[0]=-1*i[0]),h&&f&&(i[1]=-1*i[1]),i}({width:s.width,prevWidth:w,height:s.height,prevHeight:x,affectsX:g.controlDirection.affectsX,affectsY:g.controlDirection.affectsY}),K={...s,direction:J};if(!1===n?.(a,K)){s=I.prevValues,t.x=I.startX,t.y=I.startY,v.forEach((a,b)=>{a.position=I.childNodes[b].position});return}l?.(a,K),d(y,j)}).on("end",a=>{m?.(a,{...s}),e?.({...s})});f.call(w)},destroy:function(){f.on(".drag",null)}}}({domNode:z.current,nodeId:x,getStoreItems:()=>{let{nodeLookup:a,transform:b,snapGrid:c,snapToGrid:d,nodeOrigin:e,domNode:f}=y.getState();return{nodeLookup:a,transform:b,snapGrid:c,snapToGrid:d,nodeOrigin:e,paneDomNode:f}},onChange:(a,b)=>{let{triggerNodeChanges:c,nodeLookup:d,parentLookup:e,nodeOrigin:f}=y.getState(),g=[],h={x:a.x,y:a.y},i=d.get(x);if(i&&i.expandParent&&i.parentId){let b=i.origin??f,c=a.width??i.measured.width??0,j=a.height??i.measured.height??0,k=eH([{id:i.id,parentId:i.parentId,rect:{width:c,height:j,...ea({x:a.x??i.position.x,y:a.y??i.position.y},{width:c,height:j},i.parentId,d,b)}}],d,e,f);g.push(...k),h.x=a.x?Math.max(b[0]*c,a.x):void 0,h.y=a.y?Math.max(b[1]*j,a.y):void 0}if(void 0!==h.x&&void 0!==h.y){let a={id:x,type:"position",position:{...h}};g.push(a)}if(void 0!==a.width&&void 0!==a.height){let b={id:x,type:"dimensions",resizing:!0,setAttributes:!m||("horizontal"===m?"width":"height"),dimensions:{width:a.width,height:a.height}};g.push(b)}for(let a of b){let b={...a,type:"position"};g.push(b)}c(g)},onEnd:({width:a,height:b})=>{y.getState().triggerNodeChanges([{id:x,type:"dimensions",resizing:!1,dimensions:{width:a,height:b}}])}})),C.current.update({controlPosition:D,boundaries:{minWidth:h,minHeight:i,maxWidth:j,maxHeight:k},keepAspectRatio:l,resizeDirection:m,onResizeStart:q,onResize:t,onResizeEnd:u,shouldResize:o}),()=>{C.current?.destroy()}},[D,h,i,j,k,l,q,t,u,o]);let E=D.split("-");return(0,r.jsx)("div",{className:aC(["react-flow__resize-control","nodrag",...E,c,d]),ref:z,style:{...e,scale:B,...g&&{[A?"backgroundColor":"borderColor"]:g}},children:f})});var hF=a.i(80614);let hG={display:"block",width:"100%",marginTop:4,padding:"6px 8px",background:A.f.bg,color:"inherit",border:`1px solid ${A.f.border}`,borderRadius:6,boxSizing:"border-box"};function hH({block:a,onChange:b,canDisable:c=!0,runOnScreen:d=!1}){let e="string"==typeof a.config.model?a.config.model:"";function f(c,d){let{[c]:e,...f}=a.config;b({...a,config:""===d?f:{...f,[c]:d}})}let g="string"==typeof a.config.ai?a.config.ai:"",h=(0,s.useContext)(D.c),i=b=>"string"==typeof a.config[b]?a.config[b]:"";return(0,r.jsxs)("div",{style:{display:"grid",gap:10},children:[(0,r.jsxs)("label",{children:[t.B.editing.name,(0,r.jsx)("input",{style:hG,value:a.label,onChange:c=>b({...a,label:c.target.value})})]}),"tests"===a.kind?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("label",{children:[t.B.editing.testCommand,(0,r.jsx)("input",{style:{...hG,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12.5},value:i("testCommand"),placeholder:t.B.editing.testCommandPlaceholder,spellCheck:!1,onChange:a=>f("testCommand",a.target.value)})]}),(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:A.f.skipped},children:t.B.editing.testCommandHint})]}):(0,r.jsxs)(r.Fragment,{children:[ah.o.has(a.kind)&&(0,r.jsxs)("div",{children:[t.B.editing.ai,(0,r.jsx)(hF.G,{testId:"block-ai",ai:h(a.config.ai,a.kind)??(0,ah.j)(g),value:g,taskAi:h(void 0,a.kind)??void 0,label:t.B.editing.chooseAi(a.label),model:e,onChange:(c,d)=>b({...a,config:(0,ah.c)(a.config,c,d)}),markSize:18,style:{...hG,display:"flex",padding:"8px 10px",fontSize:14,textAlign:"left",cursor:"pointer"}})]}),(0,r.jsxs)("label",{children:[t.B.editing.model,(0,r.jsx)("input",{style:hG,value:e,placeholder:t.B.editing.modelPlaceholder,onChange:a=>f("model",a.target.value)})]})]}),"review"===a.kind&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("label",{children:[t.B.editing.lookFor,(0,r.jsx)("textarea",{style:{...hG,minHeight:190,resize:"vertical",lineHeight:1.45},value:i("lookFor"),placeholder:t.B.editing.lookForPlaceholder,maxLength:600,onChange:a=>f("lookFor",a.target.value)})]}),(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:A.f.skipped},children:t.B.editing.lookForHint})]}),"build"===a.kind&&!(0,ah.q)(g)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("label",{children:[t.B.editing.modelFrontend,(0,r.jsx)("input",{style:hG,value:i("modelFrontend"),placeholder:t.B.editing.sameAsModel,onChange:a=>f("modelFrontend",a.target.value)})]}),(0,r.jsxs)("label",{children:[t.B.editing.modelBackend,(0,r.jsx)("input",{style:hG,value:i("modelBackend"),placeholder:t.B.editing.sameAsModel,onChange:a=>f("modelBackend",a.target.value)})]}),(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:A.f.skipped},children:t.B.editing.areaHint})]}),d&&(0,r.jsx)("p",{style:{margin:0,fontSize:12,color:A.f.skipped},children:t.B.editing.appliesNextRun}),(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,r.jsx)("input",{type:"checkbox",checked:a.enabled,disabled:!c,"aria-describedby":c?void 0:"cannot-disable",onChange:c=>b({...a,enabled:c.target.checked})}),t.B.editing.enabled]}),!c&&(0,r.jsx)("p",{id:"cannot-disable",style:{margin:0,color:A.f.skipped},children:t.B.editing.cannotDisable})]})}function hI(a){return aw.filter(b=>!ax.includes(b)||!a.blocks.some(a=>a.kind===b))}function hJ(a,b,c){return{blocks:a.blocks.map(a=>a.id===b?{...a,position:c}:a)}}function hK(a,b){return ay.includes(b.kind)&&!a.blocks.some(a=>a.kind===b.kind&&a.id!==b.id&&a.enabled)}function hL(a,b){return{blocks:a.blocks.filter(a=>a.id!==b)}}function hM(a,b){let c=a.blocks.find(a=>a.id===b);if(!c)return[];let d=aw.indexOf(c.kind);return[...aw.slice(0,d).flatMap(b=>{let c=a.blocks.filter(a=>a.kind===b&&a.enabled).map(a=>a.label);return c.length>0?[c.join(" / ")]:[]}),c.label]}function hN({floorRef:a}){return(0,r.jsxs)("div",{"aria-hidden":"true","data-testid":"depth",style:{position:"absolute",inset:0,overflow:"hidden",pointerEvents:"none",zIndex:0},children:[(0,r.jsx)("div",{"data-testid":"depth-ambient",style:{position:"absolute",inset:0,background:A.f.ambient,pointerEvents:"none"}}),(0,r.jsx)("div",{style:{position:"absolute",inset:0,perspective:700,perspectiveOrigin:"50% 0%",pointerEvents:"none"},children:(0,r.jsx)("div",{ref:a,"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(${A.f.floorLine} 1px, transparent 1px), linear-gradient(90deg, ${A.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 hO="factory.panel.closed",hP=new Set,hQ=new Map;function hR(a){return hP.add(a),window.addEventListener("storage",a),()=>{hP.delete(a),window.removeEventListener("storage",a)}}function hS(a,b){return[(0,s.useSyncExternalStore)(hR,()=>(function(a,b){try{let c=window.localStorage.getItem(a);return null===c?b:"1"===c}catch{return hQ.get(a)??b}})(a,b),()=>b),(0,s.useCallback)(b=>{hQ.set(a,b);try{window.localStorage.setItem(a,b?"1":"0")}catch{}hP.forEach(a=>a())},[a])]}var hT=a.i(32332);let hU=t.B.steps,hV=["failed","blocked","waiting_approval","running","queued","cancelled","skipped","passed"],hW=["failed","blocked","waiting_approval","running"],hX=a=>"passed"===a?z.f.green:null===a||"queued"===a||"skipped"===a||"cancelled"===a?z.f.faint:A.f[(0,D.Y)(a)];function hY({state:a,size:b=22,id:c="step"}){if("running"===a)return(0,r.jsx)(D.m,{blockId:`step-${c}`,size:b});let d=hX(a),e="passed"===a;return(0,r.jsx)("span",{"aria-hidden":"true",style:{width:b,height:b,flex:"none",borderRadius:"50%",display:"grid",placeItems:"center",background:e?d:"transparent",border:`1.5px solid ${d}`,color:e?z.f.onGreen:d,fontSize:.55*b,fontWeight:900,lineHeight:1},children:e?"✓":"failed"===a?"!":"waiting_approval"===a?"•":""})}let hZ={width:28,height:28,display:"grid",placeItems:"center",borderRadius:7,border:"1px solid transparent",background:"none",color:z.f.quiet,cursor:"pointer"};function h$({blocks:a,stateOf:b,hasRun:c,pickedId:d,onPick:e,workOf:f,title:g,detail:h,blank:i=!1,loading:j=!1,side:k,onSettings:l}){let m=aw.map(b=>a.filter(a=>a.kind===b)).filter(a=>a.length>0).map(a=>({id:a[0].id,label:a.length>1&&"tests"===a[0].kind?hU.checks:a[0].label,blocks:a})),n=a=>{let c=a.blocks.filter(a=>a.enabled).map(a=>b(a.id));return hV.find(a=>c.includes(a))??null},o=void 0!==k,[p]=hS(hO,!1),q=p?56:497,u=o?{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 ${q+36}px 56px 36px`,display:"grid",gap:28,alignContent:"start"},v=(0,r.jsxs)("div",{"data-testid":"steps-view","data-column":o?"true":void 0,style:{...u,backgroundColor:z.f.bg,backgroundImage:"radial-gradient(circle, #2b2b2b 1px, transparent 1.5px)",backgroundSize:"24px 24px",backgroundAttachment:"local",color:z.f.text,fontFamily:z.f.sans,scrollbarWidth:"thin",scrollbarColor:`${z.f.line} transparent`,opacity:j?.4:1},children:[g&&(0,r.jsx)("div",{style:{position:"relative",height:44,margin:"-18px 0 14px -24px"},children:g}),!i&&(0,r.jsx)("ol",{"data-testid":"steps-row","aria-label":hU.rowLabel,style:{listStyle:"none",margin:0,padding:0,display:"flex",...o?{flexDirection:"column",alignItems:"stretch"}:{flexWrap:"wrap",rowGap:12,alignItems:"flex-start"}},children:m.map((a,g)=>{let h=n(a),i=a.blocks.every(a=>!a.enabled),j=a.blocks.some(a=>a.id===d),k=a.blocks.length>1,p=g>0?n(m[g-1]):null,q=i?null:"running"===h?"59, 130, 246":"waiting_approval"===h?"245, 158, 11":null,u=i?void 0:a.blocks.find(a=>a.enabled&&hW.includes(b(a.id)??"")),v=u?f?.(u.id)??null:null,w=v&&"running"===h?v.steps[v.steps.length-1]:void 0;return(0,r.jsxs)(s.Fragment,{children:[g>0&&(0,r.jsx)("li",{"aria-hidden":"true",className:"running"===h?"factory-step-flow":void 0,style:{...o?{flex:"none",width:2,height:16,marginLeft:30}:{flex:"0 1 22px",minWidth:8,height:2,marginTop:34},..."running"===h?{"--pulse":q}:{background:"passed"===p?z.f.green:z.f.line,opacity:"passed"===p?.55:1}}}),(0,r.jsx)("li",{style:{...o?{flex:"none"}:{flex:v?"2 1 230px":"1 1 104px",maxWidth:v?320:170,minWidth:104},display:"grid",opacity:i?.5:1},children:(0,r.jsxs)("div",{"data-live":q?"true":void 0,className:q?"factory-step-live":void 0,style:{position:"relative",display:"grid",gap:12,alignContent:"start",padding:14,borderRadius:14,border:`1px solid ${q?`rgb(${q})`:j?z.f.green:z.f.line}`,background:j?"#1c1f1c":z.f.card,...q?{"--pulse":q}:{boxShadow:j?"0 0 0 3px rgba(121, 220, 139, 0.12)":"none"}},children:[(0,r.jsxs)("button",{type:"button","data-testid":`step-${a.id}`,"aria-current":j?"step":void 0,onClick:()=>e(a.blocks[0].id),style:{display:"grid",gap:14,padding:0,background:"none",border:"none",color:"inherit",font:"inherit",textAlign:"left",cursor:"pointer"},children:[(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)(hT.f,{kind:a.blocks[0].kind,colour:z.f.text,size:34}),(0,r.jsx)(hY,{state:h,id:a.id})]}),(0,r.jsxs)("span",{style:{display:"grid",gap:4},children:[(0,r.jsx)("strong",{style:{fontSize:16,letterSpacing:"-0.01em",overflowWrap:"anywhere"},children:a.label}),(0,r.jsx)("span",{style:{minHeight:13,fontFamily:z.f.mono,fontSize:10.5,letterSpacing:"0.14em",textTransform:"uppercase",color:hX(h)},children:"waiting_approval"===h&&a.blocks.some(a=>f?.(a.id)?.turn)?t.B.direct.yourTurn:i?hU.off:h?t.B.canvas.stateLabel[h]:c?hU.notInTask:""})]})]}),l&&!k&&(0,r.jsxs)("span",{style:{position:"absolute",top:17,left:58,display:"flex",gap:4},children:[(0,r.jsx)("button",{type:"button",className:"factory-step-tool","data-testid":`step-settings-${a.id}`,"aria-label":hU.settings(a.label),title:hU.settings(a.label),onClick:()=>l(a.blocks[0].id),style:hZ,children:(0,r.jsx)(L,{size:15})}),null!==h&&(0,r.jsx)("button",{type:"button",className:"factory-step-tool","data-testid":`step-see-${a.id}`,"aria-label":hU.see(a.label),title:hU.see(a.label),onClick:()=>e(a.blocks[0].id),style:hZ,children:(0,r.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,r.jsx)("path",{d:"M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7z"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})})]}),v&&(v.summary||w)&&(0,r.jsxs)("div",{"data-testid":`step-work-${a.id}`,style:{display:"grid",gap:6,paddingTop:10,borderTop:`1px solid ${z.f.line}`,fontSize:13,lineHeight:1.45},children:[v.summary&&(0,r.jsx)("span",{style:{color:z.f.text,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden",overflowWrap:"anywhere"},children:v.summary}),w&&w!==v.summary&&(0,r.jsxs)("span",{style:{display:"flex",gap:7,color:z.f.quiet,fontFamily:z.f.mono,fontSize:11.5},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{color:hX(h)},children:"›"}),(0,r.jsx)("span",{style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",overflowWrap:"anywhere"},children:w})]})]}),k&&(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:"10px 0 0",display:"grid",gap:4,borderTop:`1px solid ${z.f.line}`},children:a.blocks.map(a=>(0,r.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:2},children:[(0,r.jsxs)("button",{type:"button","data-testid":`check-${a.id}`,"aria-current":d===a.id?"step":void 0,onClick:()=>e(a.id),style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"4px 6px",borderRadius:7,background:d===a.id?"#262a26":"none",border:"none",color:a.enabled?z.f.quiet:z.f.faint,font:"inherit",fontSize:13.5,textAlign:"left",cursor:"pointer"},children:[(0,r.jsx)(hY,{state:a.enabled?b(a.id):null,size:15,id:`check-${a.id}`}),a.label,c&&a.enabled&&!b(a.id)&&(0,r.jsx)("span",{"data-testid":`check-later-${a.id}`,style:{marginLeft:"auto",color:z.f.faint,fontSize:11.5},children:hU.fromNextTask})]}),l&&(0,r.jsx)("button",{type:"button",className:"factory-step-tool","data-testid":`step-settings-${a.id}`,"aria-label":hU.settings(a.label),title:hU.settings(a.label),onClick:()=>l(a.id),style:{...hZ,width:24,height:24,flex:"none"},children:(0,r.jsx)(L,{size:13})})]},a.id))})]})})]},a.id)})}),!i&&!o&&(h??(0,r.jsx)("p",{style:{margin:0,maxWidth:"60ch",fontSize:14.5,lineHeight:1.55,color:z.f.quiet},children:c?hU.notInTaskHint:hU.beforeRun}))]});return o?(0,r.jsxs)("div",{"data-testid":"direct-edit",style:{position:"absolute",inset:0,display:"flex",paddingRight:q,transition:"padding-right 200ms ease-out",background:z.f.bg},children:[v,(0,r.jsx)("div",{style:{flex:1,minWidth:0},children:k})]}):v}function h_({edge:a,path:b,active:c}){return c?(0,r.jsx)("g",{"data-testid":`particles-${a.from}->${a.to}`,"aria-hidden":"true",style:{pointerEvents:"none"},children:Array.from({length:3},(a,c)=>(0,r.jsx)("circle",{r:3.5,fill:A.f.running,style:{filter:`drop-shadow(0 0 4px ${A.f.running})`},children:(0,r.jsx)("animateMotion",{dur:"2.4s",begin:`${2.4*c/3}s`,repeatCount:"indefinite",path:b})},c))}):null}function h0({cable:a}){let b=hg(a.edge.from),c=hg(a.edge.to),d=a.from.x+(b?.measured.width??D.X),e=a.from.y+(b?.measured.height??120)/2,f=a.to.y+(c?.measured.height??120)/2,[g]=en({sourceX:d,sourceY:e,sourcePosition:o.Right,targetX:a.to.x,targetY:f,targetPosition:o.Left});return(0,r.jsx)(h_,{edge:a.edge,path:g,active:!0})}function h1({cables:a}){return(0,r.jsx)("svg",{"aria-hidden":"true","data-testid":"particle-layer",width:1,height:1,style:{position:"absolute",overflow:"visible",pointerEvents:"none"},children:a.map(a=>(0,r.jsx)(h0,{cable:a},`${a.edge.from}->${a.edge.to}`))})}function h2(a){return aw.map(b=>a.filter(a=>a.kind===b)).filter(a=>a.length>0)}let h3=["running","waiting_approval","blocked","failed"],h4={run:(0,r.jsx)("path",{d:"M5 3.5v9l7-4.5z"}),add:(0,r.jsx)("path",{d:"M8 3v10M3 8h10"}),settings:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("path",{d:"M3 4.5h10M3 11.5h10"}),(0,r.jsx)("circle",{cx:"6",cy:"4.5",r:"1.6"}),(0,r.jsx)("circle",{cx:"10.5",cy:"11.5",r:"1.6"})]}),log:(0,r.jsx)("path",{d:"M3 4h10M3 8h10M3 12h7"}),collapse:(0,r.jsx)("path",{d:"M10 3.5L5.5 8l4.5 4.5"}),expand:(0,r.jsx)("path",{d:"M6 3.5L10.5 8 6 12.5"})};function h5({name:a,size:b=16}){return(0,r.jsx)("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",width:b,height:b,fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block",flex:"0 0 auto"},children:h4[a]})}function h6({width:a="100%",height:b=12,radius:c=6,style:d}){return(0,r.jsx)("div",{"aria-hidden":"true",className:"factory-skeleton",style:{width:a,height:b,borderRadius:c,...d}})}function h7({count:a}){let b=Math.min(2,a);return(0,r.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:a},(c,d)=>{let e=d>=a-b;return(0,r.jsxs)("div",{style:{width:e?230:46,height:180,borderRadius:12,border:`1px solid ${A.f.border}`,background:A.f.card,padding:e?14:8,display:"grid",alignContent:"start",gap:10},children:[(0,r.jsx)(h6,{width:e?"55%":"100%",height:e?16:22}),e&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h6,{width:"35%",height:9}),(0,r.jsx)(h6,{height:11}),(0,r.jsx)(h6,{width:"80%",height:11}),(0,r.jsx)(h6,{height:48,radius:8})]})]},d)})})}function h8(){return(0,r.jsxs)("div",{"data-testid":"card-skeleton","aria-busy":"true",style:{display:"grid",gap:12},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[(0,r.jsx)(h6,{width:30,height:30,radius:8}),(0,r.jsxs)("div",{style:{flex:1,display:"grid",gap:6},children:[(0,r.jsx)(h6,{width:"40%",height:14}),(0,r.jsx)(h6,{width:"75%",height:10})]})]}),(0,r.jsx)(h6,{height:10}),(0,r.jsx)(h6,{width:"85%",height:10}),(0,r.jsx)(h6,{height:96,radius:10}),(0,r.jsx)(h6,{height:38,radius:8})]})}let h9="return-out",ia="return-in",ib={top:48,bottom:48,left:40,right:537},ic={maxZoom:1,padding:{top:`${ib.top}px`,bottom:`${ib.bottom}px`,left:`${ib.left}px`,right:`${ib.right}px`}},id={block:function({data:a}){let b=B(),[c,d]=(0,s.useState)(!1);return(0,r.jsxs)("div",{onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),"data-testid":`node-${a.block.id}`,"data-state":a.view?a.view.state:"not_in_run","data-highlighted":a.highlighted?"true":"false",style:{borderRadius:10,outline:a.highlighted?`3px solid ${A.f.pointer}`:"none",outlineOffset:3,boxShadow:A.f.elevation(2*!!(c&&!b)),transition:b?"none":"box-shadow 120ms ease-out"},children:[(0,r.jsx)(ge,{type:"target",position:o.Left,isConnectable:!1}),(0,r.jsx)("div",{style:void 0===a.cardWidth||b?void 0:{width:(a.collapsed?D.K:a.cardWidth)+28,padding:14,margin:-14,overflow:"hidden",transition:"width 320ms cubic-bezier(0.2, 0.7, 0.2, 1)"},children:(0,r.jsx)("div",{className:void 0===a.cardWidth||b?void 0:"factory-fade-in",children:a.collapsed?(0,r.jsx)(D.u,{block:a.block,view:a.view,selected:a.selected}):a.view?(0,r.jsx)(D.l,{block:a.block,view:a.view,expanded:a.expanded,selected:a.selected,issues:a.issues,breadcrumb:a.breadcrumb,onCollapse:a.onCollapse,collapseLabel:a.collapseLabel,onRemove:a.onRemove,width:a.cardWidth,failedActions:a.failedActions,onDetails:a.onDetails}):(0,r.jsx)(D.e,{block:a.block,selected:a.selected,issues:a.issues,onRemove:a.onRemove})},a.collapsed?"spine":"card")}),(0,r.jsx)(ge,{type:"source",position:o.Right,isConnectable:!1}),(0,r.jsx)(ge,{id:h9,type:"source",position:o.Top,isConnectable:!1}),(0,r.jsx)(ge,{id:ia,type:"target",position:o.Top,isConnectable:!1})]})}},ie="factory.sidebar.open",ig="sidebar-palette",ih="sidebar-block-settings",ii="factory:step-settings",ij="sidebar-log",ik="run-request";function il({icon:a,label:b,onClick:c}){return(0,r.jsx)("button",{type:"button","aria-label":b,title:b,onClick:c,style:{width:36,height:36,display:"grid",placeItems:"center",background:"transparent",color:A.f.dim,border:"1px solid transparent",borderRadius:8,cursor:"pointer"},onMouseEnter:a=>{a.currentTarget.style.background=A.f.card,a.currentTarget.style.borderColor=A.f.border},onMouseLeave:a=>{a.currentTarget.style.background="transparent",a.currentTarget.style.borderColor="transparent"},children:(0,r.jsx)(h5,{name:a})})}let im={padding:"6px 10px",background:A.f.card,color:"inherit",border:`1px solid ${A.f.border}`,borderRadius:6,cursor:"pointer",textAlign:"left"};function io(a){return{blockId:a.id,state:"queued",summary:al({kind:a.kind,state:"queued"}),summaryIsClaim:!1,steps:[]}}function ip({graph:a,nodeRuns:b=[],save:c,expandedId:d=null,runBlocks:e,highlightedId:f=null,flushRef:g,sidebarTop:h,sidebarLog:i,loading:j=!1,blank:k=!1,taskId:l=null,overlay:m,onFailedClick:o,onDetails:p,canRetry:q=!1,layout:u="canvas",stepDetails:v,site:w}){var x;let y,C,E,F,G,[H,I]=(0,s.useState)(a),[J,K]=(0,s.useState)(d),[L,M]=(0,s.useState)(d),[N,O]=(0,s.useState)([]),[P,Q]=(0,s.useState)(null),[R,S]=(0,s.useState)(l);R!==l&&(S(l),Q(null),K(null));let[T,U]=(0,s.useState)(f);f!==T&&(U(f),f&&Q(f));let[V,W]=(0,s.useState)(!1),X=(0,s.useRef)(a),Y=(0,s.useRef)(!1),Z=(0,s.useRef)(null),$=(0,s.useRef)(0),_=(0,s.useRef)(!1),aa=(0,s.useRef)(c);(0,s.useEffect)(()=>{aa.current=c});let ab=(0,s.useRef)(Promise.resolve()),ac=(0,s.useCallback)(()=>{Z.current&&clearTimeout(Z.current),Z.current=null;let a=aa.current;if(!Y.current||!a)return ab.current;Y.current=!1;let b=++$.current;return ab.current=a(X.current).then(a=>{_.current&&b===$.current&&(O(a),W(!1))},()=>{Y.current=!0,_.current&&b===$.current&&W(!0)}),ab.current},[]),ad=(0,s.useCallback)(()=>void ac(),[ac]);(0,s.useEffect)(()=>{if(g)return g.current=async()=>(await ac(),!Y.current),()=>{g.current=null}},[g,ac]),(0,s.useEffect)(()=>(_.current=!0,window.addEventListener("pagehide",ad),()=>{window.removeEventListener("pagehide",ad),ad(),_.current=!1}),[ad]);let ae=(0,s.useCallback)((a,b=!0)=>{X.current=a(X.current),I(X.current),b&&(Y.current=!0,Z.current&&clearTimeout(Z.current),Z.current=setTimeout(ad,500))},[ad]),af=new Map(b.map(a=>[a.blockId,a])),ag=a=>N.filter(b=>b.blockId===a).map(a=>a.message),ah=N.filter(a=>null===a.blockId||!H.blocks.some(b=>b.id===a.blockId)),ai=hI(H),aj=(0,s.useRef)(null),[ak,al]=(0,s.useState)({}),am=B(),[an,ao]=hS(ie,!0),[ap,aq]=(0,s.useState)(!1),ar=(0,s.useCallback)(a=>{aq(!0),ao(a)},[ao]),as=(0,s.useRef)(null),at=(0,s.useRef)(null),au=(0,s.useCallback)(a=>{let b=aj.current,c=as.current;if(!b)return;let d=at.current;d&&c?b.setViewport(function(a,b,c,d=0){let e=[...a.values()].map(a=>({x:a.x,y:a.y,w:a.collapsed?D.K:D.X,h:D.G}));if(0===e.length)return{x:0,y:0,zoom:1};let f=Math.min(...e.map(a=>a.x)),g=Math.max(...e.map(a=>a.x+a.w)),h=Math.min(...e.map(a=>a.y)),i=Math.max(...e.map(a=>a.y+a.h)),j=Math.max(1,b.width-c.left-c.right),k=Math.max(1,b.height-c.top-c.bottom),l=Math.max(d,Math.min(1,j/(g-f),k/(i-h)));return{x:c.left+Math.max(0,j-(g-f)*l)/2-f*l,y:c.top+Math.max(0,k-(i-h)*l)/2-h*l,zoom:l}}(d.lane,{width:c.clientWidth,height:c.clientHeight},ib,d.minZoom),{duration:a}):b.fitView({...ic,duration:a})},[]);(0,s.useEffect)(()=>{let a=()=>au(0);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[au]),(0,s.useEffect)(()=>{let a=0,b=requestAnimationFrame(()=>{a=requestAnimationFrame(()=>au(300*!am))});return()=>{cancelAnimationFrame(b),cancelAnimationFrame(a)}},[an,am,au]);let av=(a,b)=>{ar(!0),requestAnimationFrame(()=>{document.getElementById(a)?.scrollIntoView?.({block:"start",behavior:am?"auto":"smooth"}),b&&document.getElementById(b)?.focus()})},ax=(0,s.useRef)(()=>void 0),[ay,az]=(0,s.useState)(0);(0,s.useEffect)(()=>{ax.current=a=>{K(a),az(a=>a+1),av(ih)}}),(0,s.useEffect)(()=>{let a=a=>{let b=a.detail;"string"==typeof b&&ax.current(b)};return window.addEventListener(ii,a),()=>window.removeEventListener(ii,a)},[]);let aA=(0,s.useRef)(null),aB=(0,s.useCallback)(a=>{aA.current&&(aA.current.style.translate=`${.3*a.x}px ${.3*a.y}px`)},[]);(0,s.useEffect)(()=>{f&&aj.current?.fitView({...ic,nodes:[{id:f}],duration:300})},[f]);let aC=void 0!==e||b.length>0,aD=e?.map(a=>a.id)??[],aE=a=>e?e.some(b=>b.id===a.id&&b.kind===a.kind):af.has(a.id),aF=a=>e?.find(b=>b.id===a.id&&b.kind===a.kind),aG=new Set(H.blocks.map(a=>a.id)),aH=(e??[]).filter(a=>!aG.has(a.id)),aI={blocks:[...H.blocks.map(a=>{var b;return{...a,...(b=aF(a))?{label:b.label,enabled:b.enabled,config:b.config}:{}}}),...aH]},aJ=aw.flatMap(a=>aI.blocks.filter(b=>b.kind===a)),aK=aC?P??function(a){for(let b of h3){let c=a.find(a=>a.state===b);if(c)return c.id}let b=[...a].reverse().find(a=>null!==a.state&&"queued"!==a.state);return b?.id??a[0]?.id??null}(aJ.map(a=>({id:a.id,state:af.get(a.id)?.state??null}))):null,aL=new Set(aJ.filter(a=>{var b;let c;return ag(a.id).length>0||aC&&(aG.has(a.id)&&!aE(a)||(b=a.id,"running"===(c=af.get(b)?.state)||"waiting_approval"===c))}).map(a=>a.id)),aM=aC?function(a,b,c=new Set,d={}){let e=h2(a),f=e.findIndex(a=>a.some(a=>a.id===b)),g=-1===f?0:f,h=a=>1>=Math.abs(a-g)||e[a].some(a=>c.has(a.id)),i=new Map,j=0;return e.forEach((a,b)=>{let c=!h(b),f=0;for(let b of a)i.set(b.id,{x:j,y:f,collapsed:c}),f+=Math.max(D.G,d[b.id]?.height??0)+40;if(b===e.length-1)return;let g=h(b),k=h(b+1);j+=(c?D.K:D.X)+(g&&k?64:g||k?44:18)}),i}(aJ,aK,aL,ak):null,aN=aC?null:function(a,b={}){let c=new Map;for(let d of h2(a)){let a=-1/0,e=null;for(let f of[...d].sort((a,b)=>a.position.y-b.position.y)){let d=null!==e&&Math.abs(f.position.x-e)<D.X?Math.max(f.position.y,a):f.position.y;c.set(f.id,{x:f.position.x,y:d,collapsed:!1}),a=d+Math.max(D.G,b[f.id]?.height??0)+40,e=f.position.x}}return c}(H.blocks,ak),aO=(0,s.useRef)(aN);(0,s.useEffect)(()=>{at.current=aM?{lane:aM,minZoom:0}:aN?{lane:aN,minZoom:.5}:null,aO.current=aN});let aP=(0,s.useRef)(L);(0,s.useEffect)(()=>{if(aC||aP.current===L)return;aP.current=L;let a=300*!am;L?aj.current?.fitView({...ic,nodes:[{id:L}],duration:a}):au(a)},[L,aC,am,au]),(0,s.useEffect)(()=>{aC||au(0)},[aC,au]);let aQ=aC?aK:null;(0,s.useEffect)(()=>{null!==aQ&&au(300*!am)},[aQ,am,au]);let aR=a=>aM?.get(a.id),aS="steps"===u,aT=a=>{let b=aI.blocks.find(b=>b.id===a);return aC&&b&&(aE(b)||!aG.has(a))?af.get(a)?.state??"queued":null},aU=(aC?P:null)??J,aV=aS?aU&&aI.blocks.some(a=>a.id===aU)?aU:(x=aI.blocks,y=aw.flatMap(a=>x.filter(b=>b.kind===a&&b.enabled)),(y.find(a=>hW.includes(aT(a.id)??""))??y[y.length-1])?.id??null):null,aW=H.blocks.find(a=>a.id===(aS?aV:J))??null,aX=aS?{bg:z.f.bg,line:z.f.line,panel:z.f.card,head:"#1e1e1e"}:{bg:A.f.bg,line:A.f.border,panel:"#0f141c",head:"#131a24"},aY=()=>{K(null),M(null),Q(null)};(0,s.useEffect)(()=>{let a=a=>{if("Escape"!==a.key)return;let b=a.target;b&&("INPUT"===b.tagName||"TEXTAREA"===b.tagName||"SELECT"===b.tagName||b.isContentEditable)||(K(null),M(null),Q(null))};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[]);let aZ=aC&&o?{onSee:()=>o("see"),onAgain:q?()=>o("again"):void 0}:void 0,a$=[...H.blocks.map(a=>{let b=aC?aE(a)?af.get(a.id)??io(a):null:io(a),c=aR(a);return{id:a.id,type:"block",position:c?{x:c.x,y:c.y}:{x:a.position.x,y:aN?.get(a.id)?.y??a.position.y},data:{block:b?aF(a)??a:a,view:b,highlighted:f===a.id,expanded:aC?a.id===aK:L===a.id,selected:J===a.id,issues:ag(a.id),breadcrumb:aC?[]:hM(H,a.id),collapsed:c?.collapsed??!1,cardWidth:aC?D.X:void 0,collapseLabel:t.B.canvas.close,onCollapse:aC?void 0:aY,onRemove:hK(H,a)||aC&&b?void 0:()=>{var b;return b=a.id,void(ae(a=>hL(a,b)),K(null),M(null),Q(a=>a===b?null:a))},failedActions:aZ,onDetails:aC&&p&&aE(a)?()=>p(a.id):void 0}}}),...aH.map(a=>({id:a.id,type:"block",position:aR(a)??{x:a.position.x,y:a.position.y},draggable:!1,data:{block:a,view:af.get(a.id)??io(a),highlighted:f===a.id,expanded:aC?a.id===aK:L===a.id,selected:!1,issues:[],breadcrumb:aC?[]:hM({blocks:[...e??[]]},a.id),collapsed:aR(a)?.collapsed??!1,cardWidth:aC?D.X:void 0,collapseLabel:t.B.canvas.close,onCollapse:aC?void 0:aY}}))].map(a=>ak[a.id]?{...a,measured:ak[a.id]}:a),a_=new Set(a$.map(a=>a.id)),a0=new Set(a$.filter(a=>null===a.data.view).map(a=>a.id)),a1=(a,b)=>{let c=X.current.blocks.find(b=>b.id===a);if(!c)return b;let d=aO.current?.get(a)?.y,e=void 0!==d&&d!==c.position.y&&b.y===d?c.position.y:b.y;return{x:b.x,y:e}},a2=(C=aw.map(a=>aI.blocks.filter(b=>b.kind===a&&b.enabled)).filter(a=>a.length>0),E=[],C.forEach((a,b)=>{let c=C[b+1];if(c)for(let b of a)for(let a of c)E.push({from:b.id,to:a.id,kind:"normal"})}),F=aI.blocks.find(a=>"approve"===a.kind&&a.enabled),G=aI.blocks.find(a=>"build"===a.kind&&a.enabled),F&&G&&E.push({from:F.id,to:G.id,kind:"return"}),E),a3=a2.filter(a=>a_.has(a.from)&&a_.has(a.to)).map(a=>"return"===a.kind?{id:`${a.from}->${a.to}:return`,source:a.from,target:a.to,sourceHandle:h9,targetHandle:ia,type:"smoothstep",label:t.B.canvas.returnEdge,style:{stroke:A.f.failed,strokeWidth:2,strokeDasharray:"6 4"},labelStyle:{fill:A.f.failed},markerEnd:{type:n.ArrowClosed,color:A.f.failed}}:{id:`${a.from}->${a.to}`,source:a.from,target:a.to,style:{stroke:A.f.border,strokeWidth:2,strokeDasharray:a0.has(a.from)||a0.has(a.to)?"4 4":void 0},markerEnd:{type:n.ArrowClosed,color:A.f.border}}),a4=am?[]:a2.filter(a=>"normal"===a.kind&&a_.has(a.from)&&a_.has(a.to)).filter(a=>a$.find(b=>b.id===a.to)?.data.view?.state==="running").map(a=>({edge:a,from:a$.find(b=>b.id===a.from).position,to:a$.find(b=>b.id===a.to).position}));return(0,r.jsxs)("div",{"data-testid":"canvas","data-edges":a3.map(a=>a.id).join(","),style:{display:"flex",width:"100%",height:"100%",background:aX.bg,color:"inherit"},children:[(0,r.jsxs)("div",{"data-testid":"sidebar-column",style:{flexShrink:0,display:"flex",overflow:"hidden",width:an?300:56,transition:am?void 0:"width 220ms cubic-bezier(0.22, 1, 0.36, 1)"},children:[!an&&(0,r.jsxs)("nav",{"data-testid":"sidebar-rail",className:ap?"factory-fade-in":void 0,"aria-label":t.B.sidebar.label,style:{width:56,flexShrink:0,padding:"10px 0",display:"flex",flexDirection:"column",alignItems:"center",gap:6,borderRight:`1px solid ${aX.line}`},children:[(0,r.jsx)(il,{icon:"expand",label:t.B.sidebar.open,onClick:()=>ar(!0)}),(0,r.jsx)("span",{"aria-hidden":"true",style:{width:24,height:1,background:A.f.border,margin:"4px 0"}}),(0,r.jsx)(il,{icon:"run",label:t.B.sidebar.run,onClick:()=>document.getElementById(ik)?.focus()}),(0,r.jsx)(il,{icon:"add",label:t.B.editing.paletteTitle,onClick:()=>av(ig)}),(0,r.jsx)(il,{icon:"settings",label:t.B.editing.inspectorTitle,onClick:()=>av(ih)}),i&&(0,r.jsx)(il,{icon:"log",label:t.B.events.barTitle,onClick:()=>av(ij)})]}),(0,r.jsxs)("aside",{"data-testid":"sidebar",className:ap&&an?"factory-fade-in":void 0,"aria-label":t.B.sidebar.label,hidden:!an,style:{width:300,flexShrink:0,padding:12,display:an?"flex":"none",flexDirection:"column",gap:20,borderRight:`1px solid ${aX.line}`,overflowY:"auto",scrollbarWidth:"thin",scrollbarColor:`${A.f.floorLine} transparent`},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,r.jsx)("span",{style:{display:"flex",alignItems:"center",gap:8,fontSize:11,fontWeight:800,letterSpacing:"0.13em",textTransform:"uppercase",color:A.f.dim},children:t.B.sidebar.label}),(0,r.jsx)(il,{icon:"collapse",label:t.B.sidebar.close,onClick:()=>ar(!1)})]}),h&&(0,r.jsx)("section",{id:"sidebar-run",style:{display:"grid",gap:10,paddingBottom:20,borderBottom:`1px solid ${aX.line}`},children:h}),(0,r.jsxs)("section",{id:ig,"data-testid":"palette",style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:6},children:[(0,r.jsx)("h2",{style:{margin:0,fontSize:14,gridColumn:"1 / -1"},children:t.B.editing.paletteTitle}),0===ai.length&&(0,r.jsx)("p",{style:{margin:0,gridColumn:"1 / -1",color:A.f.skipped},children:t.B.editing.paletteEmpty}),ai.map(a=>(0,r.jsxs)("button",{type:"button",className:"factory-add-block",style:{...im,display:"flex",alignItems:"center",justifyContent:"center",gap:7,background:"transparent",border:`1px dashed ${z.f.green}`,color:z.f.green,fontWeight:700,whiteSpace:"nowrap",padding:"8px 6px",fontSize:13},onClick:()=>{let b=new Set(X.current.blocks.map(a=>a.id));ae(b=>(function(a,b,c=[]){if(!hI(a).includes(b))return a;let d=a.blocks.filter(a=>a.kind===b).length,e={id:function(a,b,c=[]){let d=new Set([...a.blocks.map(a=>a.id),...c]);if(!d.has(b))return b;let e=1;for(;d.has(`${b}-${e}`);)e++;return`${b}-${e}`}(a,b,c),kind:b,label:t.B.blocks[b],enabled:!0,config:{},position:{x:420*aw.indexOf(b),y:160*d}};return{blocks:[...a.blocks,e]}})(b,a,aD));let c=X.current.blocks.find(a=>!b.has(a.id));c&&(K(c.id),aC?Q(c.id):M(c.id))},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{fontSize:18,lineHeight:1,flex:"none"},children:"+"}),t.B.editing.addKind(t.B.blocks[a])]},a))]}),(0,r.jsxs)("section",{id:ih,"data-testid":"block-settings",style:{position:"relative",flexShrink:0,background:aX.panel,border:`1px solid ${aX.line}`,borderRadius:10,overflow:"hidden"},children:[ay>0&&(0,r.jsx)("span",{"aria-hidden":"true","data-testid":"settings-flash",className:"factory-flash",style:{position:"absolute",inset:0,borderRadius:10,pointerEvents:"none"}},ay),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 10px",background:aX.head,borderBottom:`1px solid ${aX.line}`},children:[(0,r.jsx)("h2",{style:{margin:0,fontSize:11,fontWeight:800,letterSpacing:"0.12em",textTransform:"uppercase",color:aW?A.f.ink:A.f.dim},children:t.B.editing.inspectorTitle}),aW&&!aS&&(0,r.jsx)("button",{type:"button","aria-label":t.B.editing.closeSettings,title:t.B.editing.closeSettings,onClick:aY,style:{background:"none",border:"none",color:A.f.skipped,cursor:"pointer",fontSize:16,lineHeight:1,padding:2},children:"✕"})]}),(0,r.jsx)("div",{style:{display:"grid",gap:10,padding:10},children:aW?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(hH,{block:aW,canDisable:!(aW.enabled&&hK(H,aW)),runOnScreen:aC,onChange:a=>ae(b=>({blocks:b.blocks.map(b=>b.id===a.id?a:b)}))}),!hK(H,aW)&&(0,r.jsx)("button",{type:"button",style:{...im,color:A.f.failed},onClick:()=>{ae(a=>hL(a,aW.id)),K(null),M(null)},children:t.B.editing.remove})]}):(0,r.jsx)("p",{style:{margin:0,color:A.f.skipped},children:t.B.editing.inspectorEmpty})})]}),ah.length>0&&(0,r.jsxs)("section",{style:{display:"grid",gap:6,color:A.f.failed},children:[(0,r.jsx)("h2",{style:{margin:0,fontSize:14},children:t.B.editing.unattributedIssues}),ah.map(a=>(0,r.jsx)("p",{style:{margin:0},children:a.message},a.message))]}),V&&(0,r.jsx)("p",{role:"alert",style:{margin:0,color:A.f.failed},children:t.B.editing.saveFailed}),i&&(0,r.jsxs)("section",{id:ij,"data-testid":"sidebar-log",style:{marginTop:aS?0:"auto",flexShrink:0,background:aX.panel,border:`1px solid ${aX.line}`,borderRadius:10,overflow:"hidden"},children:[(0,r.jsx)("h2",{style:{margin:0,padding:"8px 10px",fontSize:11,fontWeight:800,letterSpacing:"0.12em",textTransform:"uppercase",color:A.f.dim,background:aX.head,borderBottom:`1px solid ${aX.line}`},children:t.B.events.barTitle}),(0,r.jsx)("div",{style:{maxHeight:aS?"max(380px, calc(100vh - 560px))":380,overflowY:"auto",padding:6,scrollbarWidth:"thin",scrollbarColor:`${A.f.floorLine} transparent`},children:i})]})]})]}),(0,r.jsxs)("div",{ref:as,style:{flex:1,minWidth:0,position:"relative"},children:[aS&&(0,r.jsx)(h$,{blocks:aI.blocks,stateOf:aT,workOf:a=>af.get(a)??null,hasRun:aC,pickedId:aV,onPick:a=>{K(a),aC&&Q(a),void 0!==w&&null!==aT(a)&&p?.(a)},side:w,onSettings:a=>ax.current(a),title:m,detail:aV&&null!==aT(aV)?v?.(aV):void 0,blank:k,loading:j}),!aS&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(hN,{floorRef:aA}),m,j&&(0,r.jsx)(h7,{count:e?.length??H.blocks.length}),(0,r.jsx)(hd,{nodes:a$,edges:a3,nodeTypes:id,className:am?void 0:aC?"factory-glide":"factory-glide-edit",style:{background:"transparent",zIndex:1,opacity:j||k?0:1,pointerEvents:k?"none":void 0,transition:am?"none":"opacity 220ms ease-out"},onMove:(a,b)=>aB(b),onPaneClick:aY,onInit:a=>{aj.current=a,au(0),aB(a.getViewport())},onNodeClick:(a,b)=>{K(b.id),aC?Q(b.id):M(b.id)},onNodesChange:a=>{for(let b of a){if("dimensions"===b.type&&b.dimensions){let{width:a,height:c}=b.dimensions;al(d=>d[b.id]?.width===a&&d[b.id]?.height===c?d:{...d,[b.id]:{width:a,height:c}})}if("position"===b.type&&b.position){let a=a1(b.id,b.position);ae(c=>hJ(c,b.id,a),!1)}}},onNodeDragStop:(a,b)=>{let c=a1(b.id,b.position);ae(a=>hJ(a,b.id,c))},nodesDraggable:!aC,nodesConnectable:!1,deleteKeyCode:null,colorMode:"dark",proOptions:{hideAttribution:!0},children:(0,r.jsx)(hf,{children:(0,r.jsx)(h1,{cables:a4})})})]})]})]})}let iq=new Set(["request","followUp","replan","changes","approvedNote","rejectedNote","answer"]);function ir(a,b,c,d,e){let f=[];a=[...a].sort((a,b)=>aw.indexOf(a.kind)-aw.indexOf(b.kind));let g={};for(let b of a)b.enabled&&("input"===b.kind||"plan"===b.kind||"build"===b.kind||"review"===b.kind||"human"===b.kind)&&!g[b.kind]&&(g[b.kind]=b.id);for(let h of a){if(!h.enabled)continue;c.forEach((a,b)=>{iq.has(a.kind)&&g[(0,J.B)(a)]===h.id&&f.push({who:"you",key:`${d}you-${b}`,kind:a.kind,text:a.text,earlier:!0===a.earlier})});let a=b[h.id];a&&"queued"!==a.state&&"input"!==h.kind&&f.push({who:"app",key:`${d}app-${h.id}`,blockId:h.id,label:h.label,view:a,block:h,...e?{past:!0}:null})}return f}function is({by:a,children:b}){let c={width:34,height:34,flex:"none",borderRadius:"50%",display:"grid",placeItems:"center"};return(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"34px minmax(0, 1fr) 34px",columnGap:12,alignItems:"start"},children:["app"===a?(0,r.jsx)("span",{"data-testid":"face-app","aria-label":t.B.app.name,role:"img",style:{...c,background:A.f.card,border:`1px solid ${A.f.border}`},children:(0,r.jsx)(aA.f,{size:18})}):(0,r.jsx)("span",{}),(0,r.jsx)("div",{style:{minWidth:0,display:"grid"},children:b}),"you"===a&&(0,r.jsx)("span",{"data-testid":"face-you","aria-label":t.B.conversation.you,role:"img",style:{...c,background:z.f.green,color:z.f.onGreen},children:(0,r.jsx)(az.f,{name:"person",size:19})})]})}let it=new Set(["running","waiting_approval","failed"]),iu={running:A.f.running,passed:A.f.passed,failed:A.f.failed,waiting:A.f.waiting,skipped:A.f.skipped};function iv({turn:a,last:b,onDetails:c}){let{view:d}=a,e=(0,s.useContext)(D.c)(a.block.config.ai,a.block.kind),f=(0,D.Y)(d.state),g="waiting_approval"===d.state&&!a.past,h="running"===d.state&&!a.past,i="skipped"===d.state||"cancelled"===d.state,j=h||g||"failed"===d.state&&!a.past,k=h?d.steps[d.steps.length-1]:void 0,l=d.asking?d.planMeasure?.question:void 0;return(0,r.jsxs)("div",{"data-testid":a.past?`turn-past-${a.blockId}`:`turn-${a.blockId}`,style:{display:"grid",gridTemplateColumns:"22px minmax(0, 1fr)",columnGap:12},children:[(0,r.jsxs)("div",{"aria-hidden":"true",style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,r.jsx)("span",{style:{width:22,height:22,flex:"none",display:"grid",placeItems:"center",borderRadius:"50%",background:A.f.tint(f,.16),marginTop:12*!!j},children:h?(0,r.jsx)(D.m,{blockId:`turn-${a.blockId}`,size:14}):(0,r.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:iu[f]}})}),!b&&(0,r.jsx)("span",{style:{flex:1,width:2,marginTop:4,background:A.f.border}})]}),(0,r.jsxs)("div",{style:{display:"grid",gap:6,marginBottom:18,opacity:i?.6:1,...j?{padding:"12px 14px",borderRadius:12,background:A.f.card,border:`1px solid ${A.f.tint(f,.55)}`}:null},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",flexWrap:"wrap",gap:8},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:700,color:A.f.ink},children:a.label}),e&&(0,r.jsx)(D.J,{ai:e,testId:a.past?void 0:`turn-ai-${a.blockId}`}),(0,r.jsx)("span",{style:{fontSize:12.5,fontWeight:600,color:iu[f]},children:a.past&&"waiting_approval"===d.state?t.B.conversation.askedChanges:d.asking?t.B.conversation.question:t.B.canvas.stateLabel[d.state]}),c&&!a.past&&(0,r.jsx)("button",{type:"button",onClick:()=>c(a.blockId),style:{marginLeft:"auto",padding:0,background:"none",border:"none",color:"#93c5fd",fontSize:12.5,fontWeight:600,cursor:"pointer"},children:t.B.conversation.details})]}),l?(0,r.jsx)("div",{style:{fontSize:16,lineHeight:1.5,color:A.f.ink,overflowWrap:"anywhere"},children:l}):d.summary&&(0,r.jsx)("div",{style:{fontSize:14.5,lineHeight:1.55,color:"#c9d1dd",overflowWrap:"anywhere"},children:d.summary}),k&&(0,r.jsx)("div",{style:{fontSize:12.5,color:A.f.dim,overflowWrap:"anywhere"},children:k}),d.risk&&d.risk.reasons.length>0&&(0,r.jsx)("ul",{style:{margin:0,paddingLeft:18,display:"grid",gap:2,fontSize:13,lineHeight:1.45,color:A.f.dim},children:d.risk.reasons.map(a=>(0,r.jsx)("li",{children:a},a))}),g&&(0,r.jsxs)("div",{style:{fontSize:13,fontWeight:600,color:A.f.waiting},children:[d.asking?t.B.conversation.answerRight:t.B.conversation.decideRight," →"]})]})]})}function iw({chat:a,onChange:b}){let[c]=hS(hO,!1);return(0,r.jsxs)("button",{type:"button","data-testid":"view-switch",className:"factory-switch",title:a?void 0:t.B.conversation.hint,onClick:()=>b(!a),style:{position:"absolute",top:16,right:(c?56:497)+16,zIndex:4,display:"inline-flex",alignItems:"center",gap:8,padding:"8px 16px",borderRadius:999,border:`1px solid ${A.f.passed}`,background:A.f.tint("passed",.14),color:A.f.passed,fontFamily:"inherit",fontSize:13.5,fontWeight:700,cursor:"pointer",boxShadow:"0 6px 18px rgba(0,0,0,.35)"},children:[(0,r.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:a?(0,r.jsx)("path",{d:"M19 12H5M11 6l-6 6 6 6"}):(0,r.jsx)("path",{d:"M21 12a8 8 0 0 1-11.8 7L4 20l1.1-4.6A8 8 0 1 1 21 12z"})}),a?t.B.conversation.back:t.B.conversation.tab]})}function ix({runId:a,blocks:b,views:c,rounds:d,prompts:e,onDetails:f}){let[g]=hS(ie,!0),[h]=hS(hO,!1),i=function(a,b,c,d){let e=c.flatMap((a,b)=>"changes"!==a.kind||a.earlier?[]:[b]);if(d&&d.earlier.length>0&&d.earlier.length===e.length){let f=[],g=0;d.earlier.forEach((b,d)=>{let h=e[d];f.push(...ir(a,b.views,c.slice(g,h),`r${d}-`,!0)),b.change&&f.push({who:"looked",key:`r${d}-looked`,change:b.change});let i=c[h];f.push({who:"you",key:`r${d}-asked`,kind:i.kind,text:i.text,earlier:!1}),g=h+1});let h=d.earlier[d.earlier.length-1].views;return[...f,...ir(a,Object.fromEntries(Object.entries(b).filter(([a])=>d.reopened.includes(a)||!h[a]||"queued"===h[a].state)),c.slice(g),"now-",!1)]}return ir(a,b,c,"",!1)}(b,c,e,d),j=[];for(let a of i)if("you"===a.who)j.push({you:a});else if("looked"===a.who)j.push({looked:a});else if(it.has(a.view.state)&&!a.past)j.push({loud:a});else{let b=j[j.length-1];b&&"done"in b?b.done.push(a):j.push({done:[a]})}let k=b.map(a=>c[a.id]).find(a=>a?.results),l=(0,s.useRef)(null),m=i.map(a=>"app"===a.who?`${a.key}:${a.view.state}:${a.view.steps.length}`:a.key).join("|");return(0,s.useEffect)(()=>{l.current?.scrollIntoView?.({block:"end"})},[m]),(0,r.jsx)("section",{"data-testid":"conversation","aria-label":t.B.conversation.tab,style:{position:"absolute",top:0,left:g?300:56,bottom:0,right:h?56:497,zIndex:3,overflowY:"auto",background:A.f.bg},children:(0,r.jsx)("div",{children:(0,r.jsxs)("div",{style:{maxWidth:880,margin:"0 auto",padding:"84px 24px 24px",display:"grid"},children:[0===i.length&&(0,r.jsx)("p",{style:{margin:"0 0 16px",fontSize:14.5,color:A.f.dim},children:t.B.conversation.empty}),j.map((b,c)=>"you"in b?(0,r.jsx)(is,{by:"you",children:(0,r.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:A.f.tint("running",b.you.earlier?.08:.18),border:`1px solid ${A.f.tint("running",.35)}`},children:[(0,r.jsxs)("span",{style:{fontSize:11.5,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"#93c5fd"},children:[t.B.prompts.kind[b.you.kind],b.you.earlier?` \xb7 ${t.B.prompts.earlier}`:""]}),(0,r.jsx)("span",{style:{fontSize:15,lineHeight:1.55,color:A.f.ink,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:b.you.text})]})},b.you.key):"looked"in b?a&&(0,r.jsx)(is,{by:"app",children:(0,r.jsxs)("div",{"data-testid":"turn-looked",style:{display:"grid",gap:10,marginBottom:18,padding:"14px 16px",borderRadius:16,borderTopLeftRadius:4,background:A.f.card,border:`1px solid ${A.f.border}`},children:[(0,r.jsx)("span",{style:{fontSize:15.5,fontWeight:700,color:A.f.ink},children:t.B.conversation.howItLooked}),(0,r.jsx)(aB.v,{runId:a,change:b.looked.change,canTake:!1})]})},b.looked.key):"loud"in b?(0,r.jsx)(is,{by:"app",children:(0,r.jsx)(iv,{turn:b.loud,last:!0,onDetails:f})},b.loud.key):(0,r.jsx)(is,{by:"app",children:(0,r.jsxs)("details",{"data-testid":"done-steps",className:"factory-done-steps",style:{marginBottom:18},children:[(0,r.jsxs)("summary",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",borderRadius:10,border:`1px solid ${A.f.border}`,background:A.f.card,fontSize:14,fontWeight:600,color:A.f.ink,cursor:"pointer",listStyle:"none"},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{width:20,height:20,flex:"none",display:"grid",placeItems:"center",borderRadius:"50%",background:A.f.tint("passed",.18),color:A.f.passed,fontSize:12,fontWeight:900},children:"✓"}),t.B.conversation.doneSteps(b.done.length),(0,r.jsx)("span",{style:{fontSize:12.5,fontWeight:400,color:A.f.dim,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.done.map(a=>a.label).join(" · ")}),(0,r.jsxs)("span",{style:{marginLeft:"auto",flex:"none",fontSize:12.5,color:"#93c5fd"},children:[t.B.conversation.seeSteps," ▸"]})]}),(0,r.jsx)("div",{style:{paddingTop:16},children:b.done.map((a,c)=>(0,r.jsx)(iv,{turn:a,last:c===b.done.length-1,onDetails:f},a.key))})]})},`done-${c}`)),k?.results&&(0,r.jsx)(is,{by:"app",children:(0,r.jsxs)("div",{"data-testid":"turn-result",style:{display:"grid",gap:10,padding:"14px 16px",borderRadius:16,borderTopLeftRadius:4,background:A.f.card,border:`1px solid ${A.f.border}`},children:[(0,r.jsx)("span",{style:{fontSize:15.5,fontWeight:700,color:A.f.ink},children:"passed"===k.state&&k.summary?k.summary:t.B.conversation.howItLooks}),(0,r.jsx)(aB.v,{runId:k.results})]})}),(0,r.jsx)("div",{ref:l})]})})})}let iy=t.B.failure,iz="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace";function iA({runId:a,note:b,imageIds:c,imagesBusy:d,composer:e,onFollowUp:f,actionsRef:g,onCanContinue:h}){let[i,j]=(0,s.useState)(null),[k,l]=(0,s.useState)(!1),[m,n]=(0,s.useState)(!1),[o,p]=(0,s.useState)(null),[q,u]=(0,s.useState)(null),[v,w]=(0,s.useState)(void 0);async function x(b,d){p(d),u(null);try{let e=await fetch(`/api/runs/${a}/follow-up`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({note:b,attachments:"send"===d?c:[]})}),g=await e.json().catch(()=>null);if(!e.ok||!g?.runId)return u(g?.error??t.B.run.startFailed);f(g.runId)}catch{u(t.B.run.startFailed)}finally{p(null)}}if((0,s.useEffect)(()=>{let b=!0;return fetch(`/api/runs/${a}/failure`).then(a=>a.ok?a.json():null).then(a=>{b&&a&&(j(a),h?.(a.canContinue))}).catch(()=>void 0).finally(()=>b&&l(!0)),()=>{b=!1}},[a]),(0,s.useEffect)(()=>{if(!m||void 0!==v)return;let b=!0;return fetch(`/api/runs/${a}/failure/explain`,{method:"POST"}).then(a=>a.ok?a.json():null).then(a=>b&&w(a?.explanation??null)).catch(()=>b&&w(null)),()=>{b=!1}},[m,a]),(0,s.useEffect)(()=>{if(g)return g.current={see:()=>n(!0),again:()=>void x(iy.againText,"again")},()=>{g.current=null}}),!k)return(0,r.jsx)(h8,{});let y=i?.failed[0],z=i?.canContinue===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{flex:"none",width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:A.f.tint("failed",.18),color:A.f.failed},children:(0,r.jsxs)("svg",{viewBox:"0 0 24 24",width:17,height:17,fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M12 7.5v5.5M12 16.4v.1"})]})}),(0,r.jsx)("div",{className:"factory-display",style:{fontSize:17},children:iy.cardTitle})]}),(0,r.jsx)("div",{"data-testid":"failure-summary",style:{fontSize:13.5,color:"#d6dce6",lineHeight:1.45},children:y?iy.cardText(y.label):iy.cardTextUnknown}),"again"===o||"fix"===o?(0,r.jsxs)("div",{role:"status",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"#cfe0ff"},children:[(0,r.jsx)(D.m,{blockId:"again",size:15})," ","fix"===o?iy.fixing:iy.retrying]}):(0,r.jsx)("div",{style:{fontSize:12.5,color:A.f.dim,lineHeight:1.45},children:iy.cardHint}),z?(0,r.jsx)("div",{style:{display:"grid",gap:6,gridTemplateColumns:"minmax(0, 1fr)",paddingTop:10,borderTop:`1px solid ${A.f.lineSoft}`},children:e({label:iy.send,onSend:()=>void x(b,"send"),enabled:null===o&&!d&&""!==b.trim(),busy:"send"===o})}):(0,r.jsx)("div",{style:{fontSize:12.5,color:A.f.waiting,lineHeight:1.45},children:iy.cannotContinue}),q&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12.5,color:A.f.failed,lineHeight:1.4},children:q}),m&&(0,r.jsx)(iF,{failure:i,canContinue:z,explanation:v??null,explaining:void 0===v,onClose:()=>n(!1),onFix:()=>{let a,b;return n(!1),void x((a=iy.fixText(y?.label??"",y?.command??null),(b=function(a,b=25,c=1500){return a?a.trim().split("\n").slice(-b).join("\n").slice(-c):""}(y?.output??null))?`${a}
|
|
3
3
|
|
|
4
4
|
${iy.errorIntro}
|
|
5
|
-
${b}`:a),"fix")},onAgain:()=>(n(!1),void x(iy.againText,"again")),onOwn:()=>{n(!1),requestAnimationFrame(()=>document.querySelector('[data-testid="command-card"] textarea')?.focus())}})]})}function iB(){return(0,r.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,r.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 iC(){return(0,r.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,r.jsx)("path",{d:"M4 20h4L19 9l-4-4L4 16v4z"}),(0,r.jsx)("path",{d:"M13.5 6.5l4 4"})]})}function iD(){return(0,r.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,r.jsx)("path",{d:"M20 11a8 8 0 1 0-2.3 5.7"}),(0,r.jsx)("path",{d:"M20 4v7h-7"})]})}function iE({icon:a,label:b,help:c,badge:d,primary:e,onClick:f}){return(0,r.jsxs)("button",{type:"button","aria-label":b,onClick:f,style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",columnGap:12,rowGap:3,alignItems:"center",padding:e?"16px 18px":"13px 18px",borderRadius:10,border:`1px solid ${e?A.f.running:A.f.border}`,background:e?A.f.running:"#0f141c",color:e?"#fff":"#e6e9ef",cursor:"pointer",textAlign:"left"},children:[(0,r.jsx)("span",{style:{gridRow:"1 / span 2",display:"grid",placeItems:"center"},children:a}),(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:8,fontSize:e?17.5:15.5,fontWeight:700},children:[b,d&&(0,r.jsx)("span",{style:{padding:"1px 8px",borderRadius:999,background:"rgba(255,255,255,0.22)",fontSize:11.5,fontWeight:700},children:d})]}),(0,r.jsx)("span",{style:{fontSize:14,lineHeight:1.4,color:e?"rgba(255,255,255,0.88)":A.f.dim},children:c})]})}function iF({failure:a,canContinue:b,explanation:c,explaining:d,onClose:e,onFix:f,onAgain:g,onOwn:h}){(0,s.useEffect)(()=>{let a=a=>{"Escape"===a.key&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);let i=a?.failed[0],j=a?.failed.filter(a=>a.command||a.message)??[];return(0,r.jsx)("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:60,display:"grid",gridTemplateRows:"minmax(0, 1fr)",placeItems:"center",background:"rgba(5, 7, 11, 0.65)"},children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":iy.title,"data-testid":"failure-dialog",onClick:a=>a.stopPropagation(),style:{width:`min(${j.length>0?1240:720}px, calc(100% - 32px))`,maxHeight:"calc(100% - 48px)",display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",background:A.f.card,border:`1px solid ${A.f.tint("failed",.5)}`,borderRadius:14,boxShadow:"0 24px 60px rgba(0,0,0,0.6)",fontSize:14},children:[(0,r.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"18px 26px",borderBottom:`1px solid ${A.f.border}`},children:[(0,r.jsx)("h2",{className:"factory-display",style:{margin:0,fontSize:25},children:iy.title}),(0,r.jsx)("button",{type:"button","aria-label":iy.close,onClick:e,style:{background:"none",border:"none",color:A.f.skipped,cursor:"pointer",fontSize:18},children:"✕"})]}),(0,r.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:`${A.f.skipped} transparent`},children:a?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"grid",gap:22,minWidth:0},children:[(0,r.jsxs)("section",{style:{display:"grid",gap:10},children:[(0,r.jsx)("strong",{style:{fontSize:17},children:iy.happened}),(0,r.jsx)("p",{"data-testid":"failure-plain",style:{margin:0,fontSize:16.5,lineHeight:1.55,color:"#e6e9ef"},children:c??(i?iy.plain(i.label):iy.plainUnknown)}),d&&(0,r.jsxs)("div",{role:"status",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:A.f.dim},children:[(0,r.jsx)(D.m,{blockId:"explain",size:14})," ",iy.explaining]}),(0,r.jsx)("p",{style:{margin:0,fontSize:14.5,lineHeight:1.5,color:A.f.passed},children:iy.safe})]}),(0,r.jsxs)("section",{style:{display:"grid",gap:10},children:[(0,r.jsx)("strong",{style:{fontSize:17},children:iy.whatNow}),b?(0,r.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,r.jsx)(iE,{primary:!0,icon:(0,r.jsx)(iB,{}),label:iy.actions.fix.label,help:iy.actions.fix.help,badge:iy.actions.fix.badge,onClick:f}),(0,r.jsx)(iE,{icon:(0,r.jsx)(iD,{}),label:iy.actions.again.label,help:iy.actions.again.help,onClick:g}),(0,r.jsx)(iE,{icon:(0,r.jsx)(iC,{}),label:iy.actions.own.label,help:iy.actions.own.help,onClick:h})]}):(0,r.jsx)("span",{style:{fontSize:13.5,color:A.f.waiting,lineHeight:1.5},children:iy.cannotContinue})]})]}),j.length>0&&(0,r.jsxs)("section",{style:{display:"grid",gap:12,minWidth:0},children:[(0,r.jsx)("strong",{style:{fontSize:17},children:iy.details}),j.map(a=>(0,r.jsxs)("div",{"data-testid":"failed-block",style:{display:"grid",gap:8},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap",fontSize:13},children:[(0,r.jsx)("strong",{style:{color:A.f.failed},children:a.label}),a.message&&(0,r.jsx)("span",{style:{color:A.f.dim},children:a.message})]}),a.command&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap",fontSize:13,color:A.f.dim},children:[iy.command,(0,r.jsx)("code",{style:{padding:"3px 8px",borderRadius:6,background:"#0b0e14",border:`1px solid ${A.f.border}`,fontFamily:iz,fontSize:12.5,color:"#d6dce6"},children:a.command}),(0,r.jsx)("span",{style:{color:A.f.failed},children:iy.ended(a.exitCode,a.signal)})]}),(0,r.jsx)("span",{style:{fontSize:13,color:A.f.dim},children:iy.output}),(0,r.jsx)("pre",{"data-testid":"failure-output",style:{margin:0,maxHeight:"min(50vh, 460px)",overflow:"auto",padding:12,borderRadius:8,background:"#0b0e14",border:`1px solid ${A.f.border}`,fontFamily:iz,fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",scrollbarWidth:"thin",scrollbarColor:`${A.f.skipped} transparent`},children:a.output??iy.noOutput})]})]},a.blockId))]})]}):(0,r.jsx)("div",{style:{color:A.f.dim},children:iy.unreadable})})]})})}let iG=(0,s.createContext)(!1);function iH(a){return a.filter(a=>"ready"===a.status&&a.id).map(a=>a.id)}function iI(a){return a.some(a=>"uploading"===a.status)}function iJ({inputId:a,label:b,placeholder:c,text:d,onText:e,images:f,onImages:g,onSubmit:h,send:i,minHeight:j=170,disabled:k=!1}){let[l,m]=(0,s.useState)(!1),[n,o]=(0,s.useState)(null),p=(0,s.useRef)(null),q=(0,s.useRef)(null);(0,s.useLayoutEffect)(()=>{let a=q.current;a&&(a.style.height="auto",a.style.height=`${Math.min(Math.max(a.scrollHeight,j),380)}px`)},[d,j]);let u=(0,s.useRef)(()=>void 0);function v(a){o(null);let b=a.filter(a=>a.type.startsWith("image/"));b.length<a.length&&o(t.B.attachments.notImage);let c=6-f.length;for(let a of(b.length>c&&o(t.B.attachments.tooMany(6)),b.slice(0,Math.max(0,c)))){let b=`${Date.now()}-${Math.random().toString(36).slice(2)}`;g(c=>[...c,{key:b,name:a.name||"image",previewUrl:URL.createObjectURL(a),status:"uploading"}]);let c=new FormData;c.append("file",a),fetch("/api/attachments",{method:"POST",body:c}).then(async a=>{let c=await a.json().catch(()=>null);g(d=>d.map(d=>d.key!==b?d:a.ok&&c?.id?{...d,status:"ready",id:c.id}:{...d,status:"failed",error:c?.error??t.B.attachments.failed}))}).catch(()=>g(a=>a.map(a=>a.key===b?{...a,status:"failed",error:t.B.attachments.failed}:a)))}}return(0,s.useEffect)(()=>{if(k)return;let a=a=>{var b;let c,d=a.target;if(d&&d!==q.current&&("INPUT"===d.tagName||"TEXTAREA"===d.tagName||d.isContentEditable)||!a.clipboardData)return;let e=(c=[...(b=a.clipboardData).files].filter(a=>a.type.startsWith("image/"))).length>0?c:[...b.items].filter(a=>"file"===a.kind&&a.type.startsWith("image/")).map(a=>a.getAsFile()).filter(a=>null!==a);0!==e.length&&(a.preventDefault(),u.current(e),d!==q.current&&q.current?.focus({preventScroll:!0}))},b=a=>a.dataTransfer?.types.includes("Files")===!0,c=a=>{b(a)&&(a.preventDefault(),m(!0))},d=a=>{null===a.relatedTarget&&m(!1)},e=a=>{b(a)&&(a.preventDefault(),m(!1),u.current([...a.dataTransfer?.files??[]]),q.current?.focus({preventScroll:!0}))};return window.addEventListener("paste",a),window.addEventListener("dragover",c),window.addEventListener("dragleave",d),window.addEventListener("drop",e),()=>{window.removeEventListener("paste",a),window.removeEventListener("dragover",c),window.removeEventListener("dragleave",d),window.removeEventListener("drop",e)}},[k]),(0,s.useEffect)(()=>{u.current=v}),(0,r.jsxs)("div",{"data-testid":"composer",style:{display:"grid",gap:6},children:[(0,r.jsx)("label",{htmlFor:a,style:{fontSize:12.5,fontWeight:600,color:A.f.dim},children:b}),(0,r.jsxs)("div",{style:{position:"relative",background:z.f.card,border:`1px ${l?"dashed":"solid"} ${l?A.f.running:z.f.line}`,borderRadius:10,padding:8,display:"grid",gap:8},children:[f.length>0&&(0,r.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:f.map(a=>(0,r.jsxs)("div",{"data-testid":"composer-thumb","data-status":a.status,title:a.error??a.name,style:{position:"relative",width:56,height:56,borderRadius:8,overflow:"hidden",border:`1px solid ${"failed"===a.status?A.f.failed:z.f.line}`,background:z.f.bg},children:[(0,r.jsx)("img",{src:a.previewUrl,alt:a.name,style:{width:"100%",height:"100%",objectFit:"cover",opacity:"ready"===a.status?1:.45}}),"uploading"===a.status&&(0,r.jsx)("span",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center"},children:(0,r.jsx)(D.m,{blockId:`thumb-${a.key}`,size:18})}),"failed"===a.status&&(0,r.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",color:A.f.failed,fontWeight:900},children:"!"}),(0,r.jsx)("button",{type:"button","aria-label":t.B.attachments.remove(a.name),onClick:()=>{var b;return b=a.key,void g(a=>{let c=a.find(a=>a.key===b);return c&&URL.revokeObjectURL(c.previewUrl),a.filter(a=>a.key!==b)})},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:"✕"})]},a.key))}),(0,r.jsx)("textarea",{ref:q,id:a,"aria-label":b,placeholder:l?t.B.attachments.dropHere:c,value:d,disabled:k,rows:8,onChange:a=>e(a.target.value),onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.altKey||a.nativeEvent.isComposing||(i?.enabled?(a.preventDefault(),i.onSend()):h?(a.preventDefault(),h()):i&&""===d.trim()&&a.preventDefault())},style:{width:"100%",boxSizing:"border-box",resize:"vertical",minHeight:j,maxHeight:380,padding:4,background:"transparent",color:"inherit",border:"none",outline:"none",font:"inherit",fontSize:14,lineHeight:1.45,scrollbarWidth:"thin",scrollbarColor:`${A.f.floorLine} transparent`}}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,borderTop:`1px solid ${A.f.lineSoft}`,paddingTop:8},children:[(0,r.jsxs)("button",{type:"button",disabled:k||f.length>=6,onClick:()=>p.current?.click(),title:t.B.attachments.add,"aria-label":t.B.attachments.add,style:{display:"inline-flex",alignItems:"center",gap:6,background:"none",border:`1px solid ${z.f.line}`,borderRadius:6,color:"#d6dce6",cursor:"pointer",padding:"4px 10px",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsx)(iL,{})," ",t.B.attachments.browse]}),(0,r.jsx)("span",{style:{flex:1,fontSize:11.5,color:A.f.dim},children:iI(f)?t.B.attachments.uploading:t.B.attachments.pasteHint}),i&&(0,r.jsx)("button",{type:"button","aria-label":i.label,title:i.label,disabled:!i.enabled,onClick:i.onSend,style:{flex:"none",width:32,height:32,borderRadius:"50%",display:"grid",placeItems:"center",padding:0,border:"none",background:i.enabled?A.f.passed:z.f.line,color:i.enabled?"#07110a":A.f.skipped,cursor:i.enabled?"pointer":"not-allowed"},children:i.busy?(0,r.jsx)(D.m,{blockId:"composer-send",size:14}):(0,r.jsx)(iK,{})})]}),(0,r.jsx)("input",{ref:p,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,onChange:a=>{v([...a.target.files??[]]),a.target.value=""}})]}),n&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12,color:A.f.waiting},children:n})]})}function iK(){return(0,r.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,r.jsx)("path",{d:"M14.5 1.5 7 9M14.5 1.5 10 14.5 7 9 1.5 6l13-4.5Z"})})}function iL(){return(0,r.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,r.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 iM=a.i(9298);function iN({runId:a}){let[b,c]=(0,s.useState)(null),[d,e]=(0,s.useState)(null),[f,g]=(0,s.useState)(!1),h=b?.status==="installing"||b?.status==="starting";async function i(b){e(null);try{let d=await fetch(`/api/runs/${a}/preview`,{method:b}),f=await d.json().catch(()=>null);if(!d.ok||!f)return e(f?.error??t.B.preview.failed);c(f)}catch{e(t.B.preview.failed)}}(0,s.useEffect)(()=>{let b=!0,d=()=>fetch(`/api/runs/${a}/preview`).then(a=>a.json()).then(a=>b&&c(a)).catch(()=>void 0);if(d(),!h)return()=>void(b=!1);let e=setInterval(d,1e3);return()=>{b=!1,clearInterval(e)}},[a,h]);let j=b?.status??"stopped",k="installing"===j?t.B.preview.installing:"starting"===j?t.B.preview.starting:"ready"===j?t.B.preview.ready:null;return(0,r.jsxs)("div",{"data-testid":"preview","data-status":j,style:{display:"grid",gap:6},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:["ready"===j&&b?.url?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("a",{href:b.url,target:"_blank",rel:"noreferrer",style:{padding:"7px 14px",borderRadius:8,background:A.f.running,color:"#fff",fontWeight:700,textDecoration:"none",fontSize:13},children:["↗ ",t.B.preview.open]}),(0,r.jsx)("button",{type:"button",onClick:()=>void i("DELETE"),style:{background:"none",border:"none",color:A.f.dim,cursor:"pointer",fontSize:12.5},children:t.B.preview.stop})]}):(0,r.jsxs)("button",{type:"button",disabled:h,onClick:()=>void i("POST"),style:{padding:"7px 14px",borderRadius:8,border:`1px solid ${A.f.running}`,background:A.f.tint("running",.12),color:"#cfe0ff",fontWeight:700,fontSize:13,cursor:h?"wait":"pointer"},children:["▶ ",t.B.preview.start]}),k&&(0,r.jsx)("span",{style:{fontSize:12,color:"ready"===j?A.f.dim:"#cfe0ff"},children:k})]}),("failed"===j||d)&&(0,r.jsxs)("div",{role:"alert",style:{fontSize:12.5,color:A.f.failed},children:[d??b?.message??t.B.preview.failed," ",b?.log&&(0,r.jsx)("button",{type:"button",onClick:()=>g(a=>!a),style:{background:"none",border:"none",color:A.f.running,cursor:"pointer",padding:0,fontSize:12.5},children:t.B.preview.showLog})]}),f&&b?.log&&(0,r.jsx)("pre",{style:{margin:0,maxHeight:180,overflow:"auto",background:"#0b0e14",border:`1px solid ${A.f.border}`,borderRadius:8,padding:10,fontSize:11.5,color:"#9aa5b6",whiteSpace:"pre-wrap"},children:b.log})]})}let iO=["needs_you","in_progress","fixed","set_aside"],iP={needs_you:A.f.waiting,in_progress:A.f.running,fixed:A.f.passed,set_aside:A.f.skipped};function iQ(a){return iO.flatMap(b=>a.filter(a=>a.ending===b))}let iR={checked:{colour:A.f.passed,icon:(0,r.jsx)("path",{d:"M3 8.5 6.5 12 13 4.5"})},ai:{colour:A.f.waiting,icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("path",{d:"M2.5 3.5h11v7h-6l-3 2.5v-2.5h-2z"}),(0,r.jsx)("path",{d:"M5.5 7h.01M8 7h.01M10.5 7h.01"})]})},not_checked:{colour:A.f.dim,icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",strokeDasharray:"2.4 2.2"}),(0,r.jsx)("path",{d:"M5.5 8h5"})]})}};function iS({how:a,inLegend:b=!1}){let c=iR[a];return(0,r.jsxs)("span",{"data-testid":b?"how-key":"how-mark","data-state":a,title:t.B.findings.howMeans[a],style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:999,border:`1px ${"not_checked"===a?"dashed":"solid"} ${c.colour}`,color:c.colour,fontSize:11.5,fontWeight:700,whiteSpace:"nowrap"},children:[(0,r.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:c.icon}),t.B.findings.how[a]]})}function iT({f:a,n:b,touched:c}){let[d,e]=(0,s.useState)(!1),f=(0,s.useId)(),g=a.detail,h=(a,b,c=!1)=>""===b?null:(0,r.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:A.f.dim},children:a}),(0,r.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",fontFamily:c?"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace":void 0,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:b})]});return(0,r.jsxs)("li",{"data-testid":"finding",style:{display:"grid",gap:6,padding:"10px 12px",borderRadius:10,border:`1px solid ${A.f.border}`,borderLeft:`3px solid ${iP[a.ending]}`,background:"#0d1118"},children:[(0,r.jsx)("span",{"data-testid":"finding-number",style:{fontSize:11.5,fontWeight:700,color:A.f.dim},children:t.B.findings.number(b)}),(0,r.jsx)("span",{style:{fontSize:13.5,fontWeight:600,color:A.f.ink,lineHeight:1.4,overflowWrap:"anywhere"},children:a.title}),(0,r.jsx)("span",{style:{fontSize:12.5,color:A.f.dim,lineHeight:1.45,overflowWrap:"anywhere"},children:(0,iM.f)(a.outcome,c)}),(0,r.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,r.jsx)(iS,{how:a.how}),(0,r.jsx)("button",{type:"button",className:"factory-action","aria-expanded":d,"aria-controls":f,onClick:()=>e(a=>!a),style:{background:"none",border:"none",padding:"6px 0 6px 8px",minHeight:32,color:A.f.running,cursor:"pointer",fontSize:12.5},children:t.B.question.seeDetails})]}),d&&(0,r.jsxs)("div",{id:f,style:{display:"grid",gap:8,paddingTop:8,borderTop:`1px solid ${A.f.lineSoft}`},children:[h(t.B.findings.detail.where,g.where,!0),""!==g.problem&&(0,r.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:A.f.waiting},children:t.B.findings.detail.aiSaid}),(0,r.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:(0,iM.f)(g.problem,c)})]}),h(t.B.findings.detail.command,g.command,!0),h(t.B.findings.detail.output,g.outputTail,!0),h(t.B.findings.detail.why,(0,iM.f)(g.reason,c)),""===g.where&&""===g.problem&&""===g.command&&""===g.outputTail&&""===g.reason&&(0,r.jsx)("span",{style:{fontSize:12.5,color:A.f.dim},children:t.B.findings.detail.none})]})]})}function iU({findings:a,touched:b=[]}){let c=new Map(iQ(a).map((a,b)=>[a.id,b+1]));return(0,r.jsxs)("section",{"data-testid":"findings-list","aria-label":t.B.findings.heading,style:{display:"grid",gap:10},children:[(0,r.jsx)("h3",{className:"factory-display",style:{margin:0,fontSize:15},children:t.B.findings.heading}),0===a.length&&(0,r.jsx)("p",{style:{margin:0,fontSize:13,color:A.f.dim},children:t.B.findings.none}),a.length>0&&(0,r.jsx)("dl",{"data-testid":"legend","aria-label":t.B.findings.legendTitle,style:{margin:0,display:"grid",gap:6},children:["checked","ai","not_checked"].filter(b=>a.some(a=>a.how===b)).map(a=>(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 8px"},children:[(0,r.jsx)("dt",{style:{margin:0},children:(0,r.jsx)(iS,{how:a,inLegend:!0})}),(0,r.jsx)("dd",{style:{margin:0,fontSize:12,color:A.f.dim,lineHeight:1.4,flex:"1 1 180px"},children:t.B.findings.howMeans[a]})]},a))}),iO.map(d=>{let e=a.filter(a=>a.ending===d);return 0===e.length?null:(0,r.jsxs)("div",{style:{display:"grid",gap:6},children:[(0,r.jsxs)("h4",{style:{margin:0,display:"flex",alignItems:"center",gap:8,fontSize:12,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:iP[d]},children:[t.B.findings.group[d],(0,r.jsx)("span",{style:{fontSize:11,padding:"0 7px",borderRadius:999,border:`1px solid ${iP[d]}`},children:e.length})]}),(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:6},children:e.map(a=>(0,r.jsx)(iT,{f:a,n:c.get(a.id)??0,touched:b},a.id))})]},d)})]})}let iV="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace";function iW({findings:a,touched:b=[],away:c=null,runId:d,risk:e,note:f,imageIds:g,imagesBusy:h,composer:i,onSent:j,onSeeChanges:k}){let[l,m]=(0,s.useState)(null),[n,o]=(0,s.useState)(!1),[p,q]=(0,s.useState)(!1),[u,v]=(0,s.useState)(null),[w,x]=(0,s.useState)(0);async function y(a){if(l){q(!0),v(null);try{let b=await fetch(`/api/runs/${d}/decision`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({decision:a,reason:f.trim()||null,diffHash:l.hash,..."changes"===a?{attachments:g}:{}})}),e=await b.json().catch(()=>null);if(!b.ok){v({text:e?.error??t.B.gate.notDelivered,ok:!1}),409===b.status&&x(a=>a+1);return}v({text:c?t.B.machine.sentElsewhere(c.machine):"approved"===a?t.B.gate.approved:"rejected"===a?t.B.gate.rejected:t.B.gate.changesSent,ok:!0}),j()}catch{v({text:t.B.gate.notDelivered,ok:!1})}finally{q(!1)}}}(0,s.useEffect)(()=>{let a=!0;return fetch(`/api/runs/${d}/review`).then(a=>a.ok?a.json():Promise.reject(Error(String(a.status)))).then(b=>a&&(m(b),o(!1))).catch(()=>a&&o(!0)),()=>{a=!1}},[d,w]);let z=u?.ok===!0,[B,C]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!z)return;let a=setTimeout(()=>C(!0),2e4);return()=>clearTimeout(a)},[z]);let E=!z&&(""!==f.trim()||g.length>0),F=a=>({flex:1,padding:"9px 12px",borderRadius:8,border:`1px solid ${E?"#2a3140":A.f[a]}`,...E?{background:"#2a3140",color:"#8b95a7"}:{background:"passed"===a?A.f.passed:"transparent",color:"passed"===a?"#07090d":A.f.failed},fontWeight:700,cursor:p||!l||z||E?"not-allowed":"pointer",opacity:p||!l||z?.6:1});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:A.f.waiting,color:"#1a1206",fontWeight:900,fontSize:17},children:"!"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:t.B.gate.title}),(0,r.jsx)("div",{style:{fontSize:12.5,color:"#d9c9a3"},children:t.B.gate.waiting})]})]}),e&&!k&&(0,r.jsxs)("div",{style:{fontSize:12.5,color:"low"===e.level?A.f.passed:A.f.waiting,lineHeight:1.4},children:[(0,r.jsxs)("strong",{children:[t.B.risk.label[e.level],":"]}),(0,r.jsx)(iX,{reasons:e.reasons,touched:b}),"low"===e.level&&e.stopForMe&&(0,r.jsx)("div",{"data-testid":"stop-for-me-why",style:{color:A.f.waiting},children:t.B.gate.stopForMe})]}),n&&(0,r.jsx)("div",{style:{fontSize:12.5,color:A.f.failed},children:t.B.gate.loadFailed}),!l&&!n&&(0,r.jsxs)("div",{"aria-busy":"true","aria-label":t.B.gate.loading,style:{display:"grid",gap:8,padding:10,borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0d1118"},children:[(0,r.jsx)(h6,{width:"35%",height:10}),(0,r.jsx)(h6,{height:12}),(0,r.jsx)(h6,{width:"80%",height:12})]}),l&&!k&&(0,r.jsx)(iZ,{review:l}),l&&k&&(0,r.jsxs)("button",{type:"button","data-testid":"see-changes",onClick:k,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,padding:"10px 12px",borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0d1118",color:"#e6e9ef",fontSize:13.5,fontWeight:700,cursor:"pointer",textAlign:"left"},children:[(0,r.jsxs)("span",{style:{display:"grid",gap:2},children:[t.B.gate.seeChanges,(0,r.jsx)("span",{style:{fontSize:12,fontWeight:400,color:A.f.dim},children:0===l.files.length?t.B.gate.noFiles:t.B.gate.filesChanged(l.files.length)})]}),(0,r.jsx)("span",{"aria-hidden":"true",style:{flex:"none",display:"grid",placeItems:"center",width:28,height:28,borderRadius:8,background:A.f.tint("running",.16),color:A.f.running},children:(0,r.jsx)("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M6 3.5 10.5 8 6 12.5"})})})]}),a&&(0,r.jsx)(iU,{findings:a,touched:b}),l&&l.files.length>0&&!z&&(k?(0,r.jsx)(aB.$,{runId:d,autoStart:!c}):(0,r.jsx)(aB.v,{runId:d,autoStart:!c,canTake:!c})),l&&l.files.length>0&&!z&&!c&&!k&&(0,r.jsx)(iN,{runId:d}),c&&!z&&(0,r.jsx)("div",{style:{fontSize:12,color:A.f.dim,lineHeight:1.4},children:t.B.machine.elsewhere(c.machine)}),!z&&i({label:t.B.gate.askChanges,onSend:()=>void y("changes"),enabled:!p&&null!==l&&!h&&""!==f.trim()}),!z&&(0,r.jsxs)("div",{style:{display:"flex",gap:8,paddingTop:10,borderTop:`1px solid ${A.f.lineSoft}`},children:[(0,r.jsx)("button",{type:"button",disabled:p||!l||h||E,onClick:()=>void y("approved"),style:F("passed"),children:p?t.B.gate.deciding:`✓ ${t.B.gate.approve}`}),(0,r.jsxs)("button",{type:"button",disabled:p||!l||h||E,onClick:()=>void y("rejected"),style:F("failed"),children:["✕ ",t.B.gate.reject]})]}),E&&(0,r.jsx)("span",{role:"note","data-testid":"gate-unsent",style:{fontSize:12.5,color:"#f3d9a4",textAlign:"center",lineHeight:1.45},children:t.B.gate.unsent}),u&&(0,r.jsxs)("div",{role:u.ok?"status":"alert",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:u.ok?A.f.passed:A.f.failed},children:[u.ok&&!B&&(0,r.jsx)(D.m,{blockId:"gate",size:16}),u.text]}),z&&B&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12.5,color:A.f.waiting,lineHeight:1.4},children:t.B.gate.notPickedUp})]})}function iX({reasons:a,touched:b=[]}){return(0,r.jsx)("ul",{style:{margin:"2px 0 0",padding:0,listStyle:"none",display:"grid",gap:2},children:a.map((a,c)=>(0,r.jsx)("li",{"data-testid":"risk-reason",style:{overflowWrap:"anywhere"},children:(0,iM.f)((0,t.g)(a),b)},c))})}function iY({diff:a,truncated:b}){return(0,r.jsxs)(r.Fragment,{children:[a.split("\n").map((a,b)=>(0,r.jsx)("div",{style:{color:a.startsWith("+")?"#86efac":a.startsWith("-")?"#fca5a5":a.startsWith("@@")?"#93c5fd":"#9aa5b6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",paddingLeft:"1.2em",textIndent:"-1.2em"},children:a||" "},b)),b&&(0,r.jsx)("div",{style:{color:A.f.waiting},children:t.B.gate.truncated})]})}function iZ({review:a,roomy:b=!1}){let[c,d]=(0,s.useState)(!1),[e,f]=(0,s.useState)(!1),g=b||c;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{"data-testid":"gate-changes",style:{display:"grid",gap:6,maxHeight:b?"min(56vh, 600px)":g?260:180,overflowY:"auto",padding:10,borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0d1118",scrollbarWidth:"thin",scrollbarColor:`${A.f.floorLine} transparent`},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,r.jsx)("div",{style:{fontSize:12.5,color:A.f.dim},children:0===a.files.length?t.B.gate.noFiles:t.B.gate.filesChanged(a.files.length)}),a.diff&&!b&&(0,r.jsx)("button",{type:"button","aria-label":t.B.gate.expandChanges,title:t.B.gate.expandChanges,onClick:()=>f(!0),style:{display:"grid",placeItems:"center",width:26,height:26,padding:0,borderRadius:6,border:`1px solid ${A.f.border}`,background:A.f.card,color:"#d6dce6",cursor:"pointer"},children:(0,r.jsx)(i0,{})})]}),a.files.slice(0,8).map(a=>(0,r.jsxs)("div",{style:{display:"flex",gap:8,fontFamily:iV,fontSize:12,color:"#d6dce6"},children:[(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:a.path,children:a.path}),(0,r.jsxs)("span",{style:{color:A.f.passed},children:["+",a.added]}),(0,r.jsxs)("span",{style:{color:A.f.failed},children:["−",a.removed]})]},a.path)),a.files.length>8&&(0,r.jsx)("div",{style:{fontSize:12,color:A.f.dim},children:t.B.canvas.andMore(a.files.length-8)}),a.diff&&!b&&(0,r.jsx)("button",{type:"button",onClick:()=>d(a=>!a),style:{justifySelf:"start",background:"none",border:"none",color:A.f.running,cursor:"pointer",padding:0,fontSize:12.5},children:g?t.B.gate.hideChanges:t.B.gate.showChanges}),g&&(0,r.jsx)("pre",{"data-testid":"gate-diff",style:{margin:0,background:"#0b0e14",border:`1px solid ${A.f.border}`,borderRadius:8,padding:10,fontSize:12,lineHeight:1.5},children:(0,r.jsx)(iY,{diff:a.diff,truncated:a.truncated})})]}),e&&a&&(0,r.jsx)(i_,{files:a.files,diff:a.diff,truncated:a.truncated,onClose:()=>f(!1)})]})}function i$({runId:a,risk:b,away:c=null,decided:d=!1}){let[e,f]=(0,s.useState)(null),[g,h]=(0,s.useState)(!1);return((0,s.useEffect)(()=>{let b=!0;return fetch(`/api/runs/${a}/review`).then(a=>a.ok?a.json():Promise.reject(Error(String(a.status)))).then(a=>b&&f(a)).catch(()=>b&&h(!0)),()=>{b=!1}},[a]),g)?(0,r.jsx)("div",{style:{fontSize:13,color:A.f.failed},children:t.B.gate.loadFailed}):e?(0,r.jsxs)("div",{"data-testid":"change-under-check",style:{display:"grid",gap:12},children:[b&&(0,r.jsxs)("div",{style:{fontSize:13.5,color:"low"===b.level?A.f.passed:A.f.waiting,lineHeight:1.5},children:[(0,r.jsxs)("strong",{children:[t.B.risk.label[b.level],":"]}),(0,r.jsx)(iX,{reasons:b.reasons}),"low"===b.level&&b.stopForMe&&(0,r.jsx)("div",{"data-testid":"stop-for-me-why",style:{color:A.f.waiting},children:t.B.gate.stopForMe})]}),(0,r.jsx)(iZ,{review:e,roomy:!0}),e.files.length>0&&!c&&!d&&(0,r.jsx)(iN,{runId:a}),c&&(0,r.jsx)("div",{style:{fontSize:12.5,color:A.f.dim},children:t.B.machine.elsewhere(c.machine)})]}):(0,r.jsx)(h6,{height:60,radius:10})}function i_({files:a,diff:b,truncated:c,onClose:d}){let e=(0,s.useRef)(null);return(0,s.useEffect)(()=>{e.current?.focus();let a=a=>{"Escape"===a.key&&d()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[d]),(0,fb.createPortal)((0,r.jsx)("div",{"data-testid":"changes-modal",onClick:d,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,r.jsxs)("div",{ref:e,role:"dialog","aria-modal":"true","aria-label":t.B.gate.changesTitle,tabIndex:-1,onClick:a=>a.stopPropagation(),style:{width:"min(1100px, 100%)",height:"min(86vh, calc(100vh - 48px))",minHeight:0,display:"flex",flexDirection:"column",background:A.f.bg,border:`1px solid ${A.f.border}`,borderRadius:14,boxShadow:"0 30px 80px rgba(0,0,0,0.6)",outline:"none",color:"#e6e9ef"},children:[(0,r.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"12px 16px",borderBottom:`1px solid ${A.f.border}`},children:[(0,r.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,r.jsx)("div",{className:"factory-display",style:{fontSize:19},children:t.B.gate.changesTitle}),(0,r.jsx)("div",{style:{fontSize:12,color:A.f.dim,fontFamily:iV},children:a.map(a=>`${a.path} +${a.added} −${a.removed}`).join(" · ")})]}),(0,r.jsx)("button",{type:"button","aria-label":t.B.gate.closeChanges,onClick:d,style:{background:"none",border:"none",color:A.f.skipped,cursor:"pointer",fontSize:18,lineHeight:1,padding:6},children:"✕"})]}),(0,r.jsx)("pre",{style:{flex:1,minHeight:0,margin:0,overflow:"auto",padding:16,fontFamily:iV,fontSize:13,lineHeight:1.55,background:"#0b0e14",borderRadius:"0 0 14px 14px",scrollbarWidth:"thin",scrollbarColor:`${A.f.floorLine} transparent`},children:(0,r.jsx)(iY,{diff:b,truncated:c})})]})}),document.body)}function i0(){return(0,r.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,r.jsx)("path",{d:"M9.5 2.5h4v4M13.5 2.5 9 7M6.5 13.5h-4v-4M2.5 13.5 7 9"})})}let i1="other",i2="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",i3=a=>a.length>400?`${a.slice(0,399)}…`:a;function i4({question:a,onAnswer:b,position:c,touched:d=[],finding:e}){let[f,g]=(0,s.useState)(null),[h,i]=(0,s.useState)(""),[j,k]=(0,s.useState)(!1),[l,m]=(0,s.useState)(!1),[n,o]=(0,s.useState)(null),[p,q]=(0,s.useState)(!1),u=(0,s.useRef)(!1),v=(0,s.useId)(),w=(0,s.useId)(),x=f??(""!==h.trim()?i1:null),y=null!==x,z=j||l;async function B(){if(y&&!u.current&&!l){u.current=!0,k(!0),o(null);try{await b(x,""!==h.trim()?h.trim():void 0),m(!0)}catch(a){o(a instanceof Error&&a.message?a.message:t.B.question.failed)}finally{u.current=!1,k(!1)}}}let C=d.filter(b=>a.touches.includes(b.number)),D=e?.problem.trim()?e.problem.trim():null,E=D?[e.where.trim()?{label:t.B.findings.detail.where,text:e.where.trim(),mono:!1}:null,e.command.trim()?{label:t.B.findings.detail.command,text:e.command.trim(),mono:!0}:null,e.outputTail.trim()?{label:t.B.findings.detail.output,text:e.outputTail.trim(),mono:!0}:null].filter(a=>null!==a):[],F=a.detail&&(!D||"fix_held"===a.kind)?a.detail:null,G=E.length>0||null!==F;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{flex:"none",width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:A.f.waiting,color:"#1a1206",fontWeight:900,fontSize:17},children:"?"}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:t.B.question.title}),(0,r.jsx)("div",{style:{fontSize:12.5,color:"#d9c9a3"},children:t.B.question.waiting})]})]}),c&&c.of>1&&(0,r.jsx)("div",{style:{fontSize:11.5,fontWeight:700,letterSpacing:"0.04em",color:A.f.dim},children:t.B.question.position(c.n,c.of)}),(0,r.jsx)("p",{style:{margin:0,fontSize:15,lineHeight:1.45,color:A.f.ink,fontWeight:600,overflowWrap:"anywhere"},children:(0,iM.f)(a.text,d)}),a.why&&(0,r.jsx)("p",{style:{margin:0,fontSize:13,lineHeight:1.5,color:A.f.dim,overflowWrap:"anywhere"},children:(0,iM.f)(a.why,d)}),C.length>0&&(0,r.jsxs)("div",{style:{display:"grid",gap:4,fontSize:12.5,color:A.f.dim},children:[(0,r.jsx)("span",{style:{fontWeight:700},children:t.B.question.touchesTitle}),(0,r.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:C.map(a=>(0,r.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"baseline",padding:"6px 8px",borderRadius:8,border:`1px solid ${A.f.border}`,background:"#0d1118",color:"#d6dce6",overflowWrap:"anywhere"},children:[(0,r.jsx)("span",{style:{flex:"none",fontFamily:i2,fontSize:11.5,color:A.f.waiting},children:a.label}),(0,r.jsx)("span",{children:a.text})]},a.number))})]}),D&&(0,r.jsxs)("div",{style:{display:"grid",gap:4,padding:10,borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0d1118",minWidth:0},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:A.f.waiting},children:t.B.question.aiSaid}),(0,r.jsx)("span",{style:{fontSize:13,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:(0,iM.f)(i3(D),d)})]}),G&&(0,r.jsxs)("div",{style:{display:"grid",gap:6},children:[(0,r.jsx)("button",{type:"button",className:"factory-action","aria-expanded":p,"aria-controls":w,onClick:()=>q(a=>!a),style:{justifySelf:"start",background:"none",border:"none",padding:"6px 8px 6px 0",minHeight:32,color:A.f.running,cursor:"pointer",fontSize:12.5},children:t.B.question.seeDetails}),p&&(0,r.jsxs)("div",{id:w,style:{display:"grid",gap:8,padding:10,borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0d1118",minWidth:0},children:[E.map(a=>(0,r.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:A.f.dim},children:a.label}),(0,r.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",...a.mono?{fontFamily:i2,fontSize:12}:{}},children:a.text})]},a.label)),F&&(0,r.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:A.f.waiting},children:D?t.B.question.moreAbout:t.B.question.aiSaid}),(0,r.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:(0,iM.f)(F,d)})]})]})]}),(0,r.jsxs)("fieldset",{disabled:z,style:{margin:0,padding:0,border:"none",minWidth:0,display:"grid",gap:8},children:[(0,r.jsx)("legend",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:t.B.question.choicesLabel}),a.options.map(b=>{let c=f===b.id;return(0,r.jsxs)("label",{className:"factory-choice",style:{display:"flex",gap:10,alignItems:"flex-start",padding:"10px 12px",borderRadius:10,border:`1px solid ${c?A.f.waiting:A.f.border}`,background:c?A.f.tint("waiting",.1):"#0d1118",cursor:z?"not-allowed":"pointer"},children:[(0,r.jsx)("input",{type:"radio",name:v,value:b.id,checked:c,onChange:()=>g(b.id),style:{flex:"none",width:18,height:18,margin:"1px 0 0",accentColor:A.f.waiting,cursor:"inherit"}}),(0,r.jsxs)("span",{style:{display:"grid",gap:3,minWidth:0},children:[(0,r.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center",fontSize:14,fontWeight:700,color:A.f.ink},children:[b.label,a.recommended===b.id&&(0,r.jsx)("span",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:"#1a1206",background:A.f.waiting,borderRadius:999,padding:"2px 7px"},children:t.B.question.recommended})]}),(0,r.jsx)("span",{style:{fontSize:12.5,lineHeight:1.45,color:A.f.dim,overflowWrap:"anywhere"},children:b.means})]})]},b.id)}),(0,r.jsxs)("label",{style:{display:"grid",gap:4,fontSize:12.5,fontWeight:600,color:A.f.dim},children:[null===f?t.B.question.ownWordsLabel:t.B.question.noteLabel,(0,r.jsx)("textarea",{value:h,rows:3,placeholder:null===f?t.B.question.ownWordsPlaceholder:t.B.question.notePlaceholder,onChange:a=>i(a.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 ${A.f.border}`,borderRadius:8}})]})]}),(0,r.jsx)("button",{type:"button",className:"factory-action",disabled:!y||z,onClick:()=>void B(),style:{padding:"10px 12px",borderRadius:8,border:`1px solid ${A.f.waiting}`,background:y&&!z?A.f.waiting:"transparent",color:y&&!z?"#1a1206":A.f.skipped,fontWeight:700,fontSize:14,cursor:y&&!z?"pointer":"not-allowed"},children:j?t.B.question.sending:t.B.question.confirm}),n&&(0,r.jsx)("div",{role:"alert",style:{fontSize:13,fontWeight:600,color:A.f.failed,lineHeight:1.4},children:n}),l&&(0,r.jsx)("div",{role:"status",style:{fontSize:13,fontWeight:600,color:A.f.passed},children:t.B.question.sent})]})}function i5({runId:a,record:b,failed:c=!1,mark:d=0,readMark:e=0,askedId:f=null,onChanged:g}){let h=e<d,i=b?.question&&!(h&&null!==f&&b.question.id!==f)?b.question:null,[j,k]=(0,s.useState)(null),[l,m]=(0,s.useState)(null);i&&j?.id!==i.id&&(k(i),m(null));let n=(0,r.jsxs)("div",{role:"alert",style:{display:"grid",gap:8,fontSize:13,color:A.f.failed,lineHeight:1.4},children:[t.B.question.loadFailed,(0,r.jsx)("button",{type:"button",className:"factory-action",onClick:g,style:{justifySelf:"start",minHeight:32,padding:"6px 12px",borderRadius:8,border:`1px solid ${A.f.border}`,background:"#0f141c",color:"#e6e9ef",fontWeight:700,cursor:"pointer"},children:t.B.question.tryAgain})]});if(!i)return!b||h||c?c?n:(0,r.jsxs)("div",{"aria-busy":"true","aria-label":t.B.question.title,style:{display:"grid",gap:8},children:[(0,r.jsx)(h6,{height:20,width:"60%"}),(0,r.jsx)(h6,{height:70,radius:10})]}):(0,r.jsx)("div",{role:"status",style:{fontSize:13.5,fontWeight:600,color:A.f.dim,lineHeight:1.45},children:l??t.B.question.closed});async function o(b,c,d){let e;try{e=await fetch(`/api/runs/${encodeURIComponent(a)}/questions/${encodeURIComponent(i.id)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({option:b,...void 0!==c?{text:c}:{},...d&&d.length>0?{attachments:d}:{}})})}catch{throw Error(t.B.question.failed)}if(!e.ok){let a=await e.json().catch(()=>null),b=a?.error??t.B.question.failed;throw m(b),g(),Error(b)}g()}if("direct"===i.kind)return(0,r.jsxs)(r.Fragment,{children:[c&&n,(0,r.jsx)(i7,{question:i,onAnswer:o},i.id)]});let p=iQ(b.findings),q=p.findIndex(a=>a.id===i.findingId);return(0,r.jsxs)(r.Fragment,{children:[c&&n,(0,r.jsx)(i4,{question:i,touched:b.touched,onAnswer:o,position:q>=0?{n:q+1,of:p.length}:void 0,...q>=0?{finding:p[q].detail}:{}},i.id)]})}let i6=t.B.direct;function i7({question:a,onAnswer:b}){let[c,d]=(0,s.useState)(""),[e,f]=(0,s.useState)([]),[g,h]=(0,s.useState)(null),[i,j]=(0,s.useState)(null),k=(0,s.useRef)(!1),l=(0,s.useId)(),m=Number(/^direct-(\d+)/.exec(a.findingId??"")?.[1]??1),n=a.text===i6.lastText,o=a.options.some(a=>"undo"===a.id),p=!n&&(""!==c.trim()||e.length>0);async function q(a){if(!(k.current||"next"===a&&(""===c.trim()||iI(e)))&&("done"!==a||!p)){k.current=!0,h(a),j(null);try{await ("done"===a?b("leave"):"undo"===a?b("undo"):b(i1,c.trim(),iH(e)))}catch(a){j(a instanceof Error&&a.message?a.message:t.B.question.failed),k.current=!1,h(null)}}}let u=null!==g;return(0,r.jsxs)("div",{"data-testid":"direct-pause",style:{display:"grid",gap:12},children:[(0,r.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,r.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:i6.pauseTitle}),(0,r.jsxs)("div",{style:{fontSize:13,color:A.f.dim,lineHeight:1.45},children:[i6.look," ",i6.pauseWhy]})]}),a.detail&&(0,r.jsxs)("div",{style:{display:"grid",gap:4,padding:"10px 12px",borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0f141c"},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.1em",textTransform:"uppercase",color:A.f.dim},children:i6.lastBuilt}),(0,r.jsx)("span",{style:{fontSize:13.5,lineHeight:1.45,overflowWrap:"anywhere"},children:i3(a.detail)})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,fontSize:12,color:A.f.dim},children:[(0,r.jsx)("span",{children:i6.count(m)}),o&&(0,r.jsxs)("button",{type:"button",className:"factory-action","data-testid":"direct-undo",disabled:u,title:i6.undoMeans,onClick:()=>void q("undo"),style:{background:"none",border:"none",padding:0,color:"#cfe0ff",font:"inherit",fontWeight:700,cursor:u?"default":"pointer"},children:["↩ ","undo"===g?i6.sending:i6.undo]})]}),(m>=5||n)&&(0,r.jsx)("div",{role:"note","data-testid":"direct-many",style:{padding:"9px 12px",borderRadius:10,border:`1px solid ${A.f.waiting}`,color:"#f3d9a4",fontSize:13,lineHeight:1.45},children:n?i6.lastText:i6.many}),!n&&(0,r.jsx)(iJ,{inputId:l,label:i6.nextLabel,placeholder:i6.nextPlaceholder,text:c,onText:d,images:e,onImages:f,minHeight:96,disabled:u,onSubmit:()=>void q("next"),send:{label:i6.send,onSend:()=>void q("next"),enabled:!u&&""!==c.trim()&&!iI(e),busy:"next"===g}}),(0,r.jsxs)("div",{style:{display:"grid",gap:5,paddingTop:12,borderTop:`1px solid ${A.f.border}`},children:[(0,r.jsx)("button",{type:"button",className:"factory-action","data-testid":"direct-done",disabled:u||p,onClick:()=>void q("done"),style:{minHeight:40,padding:"9px 16px",borderRadius:9,border:"none",background:p?"#2a3140":A.f.passed,color:p?"#8b95a7":"#0d1f12",fontWeight:800,fontSize:14.5,cursor:p?"not-allowed":u?"default":"pointer"},children:"done"===g?i6.sending:i6.done}),p?(0,r.jsx)("span",{role:"note","data-testid":"direct-unsent",style:{fontSize:12.5,color:"#f3d9a4",textAlign:"center",lineHeight:1.45},children:i6.unsent}):(0,r.jsx)("span",{style:{fontSize:12,color:A.f.dim,textAlign:"center"},children:i6.doneHint})]}),i&&(0,r.jsx)("div",{role:"alert",style:{fontSize:13,color:A.f.failed},children:i})]})}function i8({runId:a,note:b,composer:c,onSent:d,measure:e}){let f=(0,s.useRef)(null),[g,h]=(0,s.useState)(new Set),[i,j]=(0,s.useState)(null),[k,l]=(0,s.useState)(null),[m,n]=(0,s.useState)(null),[o,p]=(0,s.useState)(!1),[q,u]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let b=!0;return fetch(`/api/runs/${a}/plan`).then(a=>a.ok?a.json():null).then(a=>b&&j((a?.plan?.jobs??[]).map((a,b)=>({key:`j${b}-${Date.now()}`,title:a.title,done:a.done.join("\n"),...a.paths?{paths:a.paths}:{}})))).catch(()=>b&&j([])),()=>{b=!1}},[a]);let v=m?.ok===!0;async function w(b,c){l(c),n(null);try{let e=await fetch(`/api/runs/${a}/plan`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b)}),f=await e.json().catch(()=>null);if(!e.ok)return n({ok:!1,text:f?.error??t.B.run.startFailed});if(f&&!1===f.delivered&&"machine"in f)return n({ok:!0,text:t.B.machine.sentElsewhere(f.machine??null)});n({ok:!0,text:"build"===c?t.B.plan.building_sent:t.B.plan.replanned}),"replan"===c&&d()}catch{n({ok:!1,text:t.B.run.startFailed})}finally{l(null)}}(0,s.useEffect)(()=>{if(!v)return;let a=setTimeout(()=>p(!0),2e4);return()=>clearTimeout(a)},[v]);let x=(a,b)=>j(c=>(c??[]).map(c=>c.key===a?{...c,...b}:c)),y=i?i.map(a=>({title:a.title.trim(),done:a.done.split("\n").map(a=>a.trim()).filter(Boolean),...a.paths?{paths:a.paths}:{}})).filter(a=>""!==a.title):[],z=null!==k||v,B={width:"100%",boxSizing:"border-box",background:"#0b0e14",color:"#d6dce6",border:`1px solid ${A.f.border}`,borderRadius:6,font:"inherit"};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:A.f.waiting,color:"#1a1206"},children:(0,r.jsx)(i9,{})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:t.B.plan.title}),(0,r.jsx)("div",{style:{fontSize:12.5,color:"#d9c9a3"},children:t.B.plan.waiting})]})]}),e&&e.reasons.length>0&&(0,r.jsxs)("div",{"data-testid":"plan-why",style:{display:"grid",gap:6,fontSize:13,lineHeight:1.45,color:"#d9c9a3",overflowWrap:"anywhere"},children:[q?(0,r.jsx)("ul",{style:{margin:0,paddingLeft:18,display:"grid",gap:4},children:e.reasons.map((a,b)=>(0,r.jsx)("li",{children:a},b))}):(0,r.jsx)("span",{children:e.reasons[0]}),e.question&&(0,r.jsx)("span",{"data-testid":"plan-question",style:{color:"#f1e6c8",fontWeight:600},children:e.question}),e.reasons.length>1&&(0,r.jsx)("button",{type:"button","aria-expanded":q,onClick:()=>u(a=>!a),style:{justifySelf:"start",padding:0,background:"none",border:"none",color:"#9cc2ff",fontSize:12.5,cursor:"pointer",textDecoration:"underline"},children:t.B.plan.whyStopped})]}),null===i?(0,r.jsxs)("div",{"aria-busy":"true",style:{display:"grid",gap:8},children:[(0,r.jsx)(h6,{height:70,radius:10}),(0,r.jsx)(h6,{height:70,radius:10})]}):(0,r.jsx)("ol",{ref:f,"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:`${A.f.skipped} transparent`},children:i.map((a,b)=>(0,r.jsxs)("li",{className:"factory-job-in",style:{display:"grid",gap:6,padding:10,borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0d1118",animationDelay:`${300+260*Math.min(b,6)}ms`},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{fontSize:11,color:A.f.dim,paddingLeft:28},children:t.B.plan.jobWhat}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:-3},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{flex:"none",width:20,height:20,borderRadius:"50%",display:"grid",placeItems:"center",fontSize:11,fontWeight:800,background:A.f.tint("waiting",.2),color:A.f.waiting},children:b+1}),(0,r.jsx)("input",{"aria-label":t.B.plan.jobLabel(b+1),value:a.title,placeholder:t.B.plan.jobPlaceholder,disabled:z,onChange:b=>x(a.key,{title:b.target.value}),style:{...B,flex:1,minWidth:0,padding:"6px 8px",fontSize:13,fontWeight:600}}),(0,r.jsx)("button",{type:"button","aria-label":t.B.plan.removeJob(b+1),title:t.B.plan.removeJob(b+1),disabled:z,onClick:()=>j(b=>(b??[]).filter(b=>b.key!==a.key)),style:{flex:"none",width:26,height:26,display:"grid",placeItems:"center",padding:0,background:"none",border:"none",color:A.f.skipped,cursor:"pointer"},children:(0,r.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,r.jsx)("path",{d:"M2.5 4h11M6.5 4V2.5h3V4M4 4l.7 9.5h6.6L12 4"})})})]}),""!==a.done.trim()||g.has(a.key)?(0,r.jsxs)("label",{style:{display:"grid",gap:3,fontSize:11,color:A.f.dim,paddingLeft:28},children:[t.B.plan.doneLabel,(0,r.jsx)("textarea",{value:a.done,rows:Math.max(1,a.done.split("\n").length),placeholder:t.B.plan.donePlaceholder,disabled:z,onFocus:()=>h(b=>b.has(a.key)?b:new Set(b).add(a.key)),onChange:b=>x(a.key,{done:b.target.value}),style:{...B,padding:"5px 8px",fontSize:12,lineHeight:1.45,resize:"vertical"}})]}):!z&&(0,r.jsxs)("button",{type:"button",onClick:()=>h(b=>new Set(b).add(a.key)),style:{justifySelf:"start",marginLeft:28,padding:0,background:"none",border:"none",color:A.f.dim,fontSize:11.5,cursor:"pointer",textDecoration:"underline"},children:["+ ",t.B.plan.addChecks]})]},a.key))}),null!==i&&!z&&(0,r.jsxs)("button",{type:"button",onClick:()=>{j(a=>[...a??[],{key:`new-${Date.now()}`,title:"",done:""}]),requestAnimationFrame(()=>{let a=f.current?.lastElementChild;a?.scrollIntoView?.({block:"nearest",behavior:"smooth"}),a?.querySelector("input")?.focus({preventScroll:!0})})},style:{justifySelf:"start",display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:6,border:`1px dashed ${A.f.border}`,background:"transparent",color:"#d6dce6",fontSize:12.5,fontWeight:600,cursor:"pointer"},children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"+"})," ",t.B.plan.addJob]}),!v&&(0,r.jsxs)("button",{type:"button",disabled:z||0===y.length,onClick:()=>void w({action:"build",jobs:y},"build"),className:"factory-call",style:{padding:"9px 12px",borderRadius:8,border:`1px solid ${A.f.passed}`,background:y.length>0?A.f.passed:"transparent",color:y.length>0?"#07110a":A.f.skipped,fontWeight:700,cursor:z?"wait":0===y.length?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:["build"===k?(0,r.jsx)(D.m,{blockId:"plan-build",size:16}):(0,r.jsx)("span",{"aria-hidden":"true",children:"▶"})," ","build"===k?t.B.plan.building:t.B.plan.build]}),!v&&(0,r.jsx)("div",{style:{paddingTop:10,borderTop:`1px solid ${A.f.lineSoft}`,display:"grid"},children:c({label:t.B.plan.replan,onSend:()=>void w({action:"replan",note:b},"replan"),enabled:!z&&""!==b.trim()})}),m&&(0,r.jsxs)("div",{role:m.ok?"status":"alert",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:m.ok?A.f.passed:A.f.failed},children:[m.ok&&!o&&(0,r.jsx)(D.m,{blockId:"plan-sent",size:16}),m.text]}),v&&o&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12.5,color:A.f.waiting,lineHeight:1.4},children:t.B.plan.notPickedUp})]})}function i9(){return(0,r.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,r.jsx)("path",{d:"M6 4h7.5M6 8h7.5M6 12h7.5M2.5 4h.01M2.5 8h.01M2.5 12h.01"})})}let ja=t.B.delivery;function jb({runId:a,button:b}){let[c,d]=(0,s.useState)("idle"),[e,f]=(0,s.useState)(null),[g,h]=(0,s.useState)(null),i=(0,s.useRef)(null),j=(0,s.useRef)(!1);async function k(){i.current=window.open("","_blank"),j.current=!1,h(null),d("starting");let b=await fetch(`/api/runs/${a}/preview`,{method:"POST"}).catch(()=>null);if(j.current=!0,!b?.ok){let a=await b?.json().catch(()=>null);i.current?.close(),i.current=null,h(a?.error??null),d("failed")}}return((0,s.useEffect)(()=>{if("starting"!==c&&"open"!==c)return;let b=!0,e=async()=>{let e=await fetch(`/api/runs/${a}/preview`).catch(()=>null),g=e?.ok?await e.json().catch(()=>null):null;b&&g&&j.current&&("ready"===g.status&&g.url?(f(g.url),"starting"===c&&(i.current&&!i.current.closed?i.current.location.href=g.url:window.open(g.url,"_blank","noopener"),i.current=null,d("open"))):"open"===c&&"installing"!==g.status&&"starting"!==g.status?(f(null),d("idle")):("failed"===g.status||"stopped"===g.status)&&(i.current?.close(),i.current=null,h(g.message),d("failed")))},g=setInterval(()=>void e(),2e3);return e(),()=>{b=!1,clearInterval(g)}},[c,a]),"starting"===c)?(0,r.jsxs)("div",{"data-testid":"open-site",role:"status",style:{display:"grid",gap:4},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"#d6dce6"},children:[(0,r.jsx)(D.m,{blockId:"open-site",size:16})," ",ja.openingSite]}),(0,r.jsx)("div",{style:{fontSize:11.5,color:A.f.dim,lineHeight:1.4},children:ja.openingSiteHint})]}):"open"===c&&e?(0,r.jsxs)("div",{"data-testid":"open-site",style:{display:"grid",gap:6},children:[(0,r.jsxs)("div",{style:{fontSize:12.5,color:A.f.passed,lineHeight:1.4},children:["✓ ",ja.siteOpen]}),(0,r.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",style:{...b(!1),textDecoration:"none"},children:["↗ ",ja.openSiteAgain]})]}):(0,r.jsxs)("div",{"data-testid":"open-site",style:{display:"grid",gap:4},children:["failed"===c&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12.5,color:A.f.failed,lineHeight:1.4},children:g??ja.siteFailed}),(0,r.jsxs)("button",{type:"button",onClick:()=>void k(),style:b(!1),children:["↗ ","failed"===c?ja.siteTryAgain:ja.openSite]}),"idle"===c&&(0,r.jsx)("div",{style:{fontSize:11.5,color:A.f.dim,lineHeight:1.4},children:ja.openSiteWhat})]})}let jc={pending:{glyph:"…",colour:A.f.waiting},passed:{glyph:"✓",colour:A.f.passed},failed:{glyph:"✕",colour:A.f.failed},neutral:{glyph:"·",colour:A.f.skipped}};function jd({checks:a}){return(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:3,fontSize:12},children:a.map((a,b)=>(0,r.jsxs)("li",{style:{display:"flex",gap:6,alignItems:"baseline"},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{color:jc[a.state].colour,fontWeight:800,width:12},children:jc[a.state].glyph}),a.url?(0,r.jsx)("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",style:{color:z.f.green},children:a.name}):(0,r.jsx)("span",{children:a.name}),(0,r.jsx)("span",{style:{color:A.f.dim},children:t.B.ship.checkState[a.state]})]},`${a.name}-${b}`))})}function je({runId:a,button:b,onState:c,canOpen:d=!0,onRecorded:e}){let[f,g]=(0,s.useState)(null),h=(0,s.useCallback)(a=>{g({...a,readAt:Date.now()}),c?.(a)},[c]),[i,j]=(0,s.useState)(null),[k,l]=(0,s.useState)(!1),[m,n]=(0,s.useState)(null),o=(0,s.useCallback)(()=>{fetch(`/api/runs/${a}/ship`).then(a=>a.ok?a.json():null).then(a=>a&&h(a)).catch(()=>void 0)},[a,h]);(0,s.useEffect)(o,[o]);let p=f?.pr?.state==="open",q=f?.pr?.state==="merged",u=q&&!0===f.deployPending,w=f?.conflictFix?.status==="working"||f?.conflictFix?.status==="done"&&f.pr?.conflicts===!0,x=p&&!f.checksDone||u||w;async function y(b){j(b),n(null);try{let c=await fetch(`/api/runs/${a}/ship`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:b})}),d=await c.json().catch(()=>null);if(!c.ok||!d)return n(d?.error??t.B.run.startFailed);h(d),l(!1),"fix-conflict"===b&&window.dispatchEvent(new Event(E)),e?.()}catch{n(t.B.run.startFailed)}finally{j(null)}}if((0,s.useEffect)(()=>{if(!x)return;let a=setInterval(o,8e3);return()=>clearInterval(a)},[x,o]),null===f)return(0,r.jsxs)("div",{"data-testid":"ship-skeleton","aria-busy":"true",style:{display:"grid",gap:6},children:[(0,r.jsx)(h6,{height:38,radius:8}),(0,r.jsx)(h6,{width:"70%",height:10})]});let B={fontSize:11.5,color:A.f.dim,lineHeight:1.4};return(0,r.jsxs)("div",{"data-testid":"ship-section",style:{display:"grid",gap:6},children:[!f.pr&&d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button",disabled:null!==i,onClick:()=>void y("open"),style:b(i),children:["open"===i?(0,r.jsx)(D.m,{blockId:"ship-open",size:16}):(0,r.jsx)(jf,{})," ","open"===i?t.B.ship.opening:t.B.ship.shipIt]}),(0,r.jsx)("div",{style:{...B,marginTop:-2},children:t.B.ship.shipWhat})]}),f.pr&&(0,r.jsxs)("div",{style:{display:"grid",gap:6,fontSize:12.5,lineHeight:1.4},children:[(0,r.jsxs)("a",{href:f.pr.url,target:"_blank",rel:"noopener noreferrer",style:{color:z.f.green,fontWeight:600,fontSize:12},children:[t.B.ship.pr(f.pr.number)," ↗"]}),"closed"===f.pr.state&&(0,r.jsx)("span",{style:{color:A.f.failed},children:t.B.ship.closed}),p&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.1em",textTransform:"uppercase",color:A.f.dim},children:t.B.ship.checksTitle}),!f.checksDone&&(0,r.jsxs)("div",{role:"status","data-testid":"ship-checking",style:{display:"flex",gap:10,alignItems:"center",padding:"10px 12px",borderRadius:8,border:`1px solid ${A.f.tint("running",.5)}`,background:A.f.tint("running",.1),color:"#cfe0ff",fontSize:13,fontWeight:600,lineHeight:1.4},children:[(0,r.jsx)(D.m,{blockId:"ship-checks",size:18}),0===f.checks.length?t.B.ship.looking:t.B.ship.waiting]}),f.checks.length>0&&(0,r.jsx)(jd,{checks:f.checks}),f.checksDone&&0===f.checks.length&&(0,r.jsx)("span",{style:B,children:t.B.ship.noChecks}),f.checksDone&&f.checks.length>0&&!f.checksFailed&&(0,r.jsxs)("span",{style:{color:A.f.passed},children:["✓ ",t.B.ship.allPassed]}),f.checksFailed&&(0,r.jsx)("span",{style:{color:A.f.failed},children:t.B.ship.someFailed}),f.pr.conflicts&&f.conflictFix?.status!=="working"&&f.conflictFix?.status!=="done"&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{style:{color:A.f.failed},children:t.B.ship.conflicts}),f.conflictFix?.status==="failed"&&(0,r.jsx)("span",{role:"alert","data-testid":"conflict-failed",style:{color:A.f.failed},children:f.conflictFix.message}),f.conflictFix?.status==="failed"&&(0,r.jsxs)("a",{"data-testid":"conflict-on-github",href:`${f.pr.url.replace(/\/+$/,"")}/conflicts`,target:"_blank",rel:"noopener noreferrer",style:{color:z.f.green,fontWeight:600},children:[t.B.conflict.onGitHub," ↗"]}),d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button","data-testid":"fix-conflict",disabled:null!==i,onClick:()=>void y("fix-conflict"),style:b(i),children:["fix-conflict"===i&&(0,r.jsx)(D.m,{blockId:"fix-conflict",size:16})," ",t.B.conflict.fix]}),(0,r.jsx)("span",{style:B,children:t.B.conflict.what})]})]}),(f.conflictFix?.status==="working"||f.conflictFix?.status==="done"&&f.pr.conflicts)&&(0,r.jsxs)("div",{role:"status","data-testid":"conflict-working",style:{display:"flex",gap:10,alignItems:"center",padding:"10px 12px",borderRadius:8,border:`1px solid ${A.f.tint("running",.5)}`,background:A.f.tint("running",.08),lineHeight:1.4},children:[(0,r.jsx)(D.m,{blockId:"conflict-fix",size:18}),(0,r.jsx)("span",{children:"working"===f.conflictFix.status?f.conflictFix.message:t.B.conflict.seen})]}),f.conflictFix?.status==="done"&&!f.pr.conflicts&&(0,r.jsxs)("span",{"data-testid":"conflict-done",style:{color:A.f.passed},children:["✓ ",f.conflictFix.message]}),f.onHold&&(0,r.jsxs)("div",{"data-testid":"on-hold",style:{display:"flex",gap:8,alignItems:"flex-start",padding:8,borderRadius:8,border:`1px solid ${A.f.tint("waiting",.5)}`,background:A.f.tint("waiting",.08),color:A.f.waiting},children:[(0,r.jsx)("span",{style:{marginTop:2},children:(0,r.jsx)(v.h,{size:12})}),(0,r.jsx)("span",{style:{lineHeight:1.4},children:t.B.ship.onHold})]}),f.checksDone&&!f.checksFailed&&!f.pr.conflicts&&!k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{style:{display:"flex",gap:6},children:[(0,r.jsx)("button",{type:"button",disabled:null!==i,onClick:()=>l(!0),style:{...b(i),flex:1},children:t.B.ship.merge}),(0,r.jsxs)("button",{type:"button",disabled:null!==i,onClick:()=>void y(f.onHold?"unhold":"hold"),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6,padding:"6px 10px",borderRadius:8,border:`1px solid ${A.f.tint("waiting",.6)}`,background:"transparent",color:A.f.waiting,fontWeight:700,cursor:i?"wait":"pointer"},children:["hold"===i||"unhold"===i?(0,r.jsx)(D.m,{blockId:"ship-hold",size:13}):(0,r.jsx)(v.h,{size:11}),"hold"===i?t.B.ship.holding:f.onHold?t.B.ship.unhold:t.B.ship.hold]})]}),(0,r.jsx)("div",{style:{...B,marginTop:-2},children:t.B.ship.mergeWhat}),!f.onHold&&(0,r.jsx)("div",{style:B,children:t.B.ship.holdWhat})]}),k&&(0,r.jsxs)("div",{role:"group","aria-label":t.B.ship.confirm,className:"factory-ask-in",style:{display:"grid",gap:6,padding:8,border:`1px solid ${A.f.tint("waiting",.5)}`,borderRadius:8,background:A.f.tint("waiting",.08)},children:[t.B.ship.confirm,(0,r.jsxs)("span",{style:{display:"flex",gap:6},children:[(0,r.jsxs)("button",{type:"button",disabled:null!==i,onClick:()=>void y("merge"),style:{...b(i),flex:1},children:["merge"===i?(0,r.jsx)(D.m,{blockId:"ship-merge",size:14}):null," ","merge"===i?t.B.ship.merging:t.B.ship.yes]}),(0,r.jsx)("button",{type:"button",disabled:null!==i,onClick:()=>l(!1),style:{flex:1,padding:"6px 10px",borderRadius:8,border:`1px solid ${A.f.dim}`,background:z.f.card,color:A.f.ink,fontWeight:600,cursor:"pointer"},children:t.B.ship.no})]})]})]}),q&&(0,r.jsxs)(r.Fragment,{children:[u?(0,r.jsxs)("div",{role:"status","data-testid":"ship-publishing",style:{display:"flex",gap:10,alignItems:"center",padding:"10px 12px",borderRadius:8,border:`1px solid ${A.f.tint("running",.5)}`,background:A.f.tint("running",.1),color:"#cfe0ff",fontSize:13,fontWeight:600,lineHeight:1.4},children:[(0,r.jsx)(D.m,{blockId:"ship-deploy",size:18}),t.B.ship.deployWaiting]}):(0,r.jsxs)("span",{style:{color:A.f.passed,fontWeight:700},children:["✓ ",t.B.ship.merged]}),void 0!==f.folder&&(0,r.jsx)("span",{"data-testid":"ship-folder",style:B,children:f.folder?t.B.ship.folderUpdated:t.B.ship.folderNot}),f.deploy.length>0&&(0,r.jsx)(jd,{checks:f.deploy}),!u&&0===f.deploy.length&&(0,r.jsx)("span",{style:B,children:t.B.ship.noDeploy}),!u&&f.deploy.length>0&&!f.deploy.some(a=>"failed"===a.state)&&(0,r.jsxs)("span",{style:{color:A.f.passed},children:["✓ ",t.B.ship.live]}),f.deploy.some(a=>"failed"===a.state)&&(0,r.jsx)("span",{style:{color:A.f.failed},children:t.B.ship.deployFailed})]})]}),m&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12.5,color:A.f.failed,lineHeight:1.4},children:m})]})}function jf(){return(0,r.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,r.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 jg=a.i(89956);let jh=t.B.delivery.throwAway;function ji({runId:a,prOpen:b,onThrown:c}){let[d,e]=(0,s.useState)(!1),[f,g]=(0,s.useState)(!1),[h,i]=(0,s.useState)(null);async function j(){g(!0),i(null);try{let b=await fetch(`/api/runs/${a}/throw-away`,{method:"POST"}),d=await b.json().catch(()=>null);if(!b.ok||!d)return i(d?.error??t.B.run.startFailed);e(!1),c(d)}catch{i(t.B.run.startFailed)}finally{g(!1)}}let k=()=>{f||e(!1)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button","data-testid":"throw-away",onClick:()=>{i(null),e(!0)},style:{width:"100%",padding:"10px 14px",borderRadius:8,border:`1px solid ${A.f.failed}`,background:A.f.tint("failed",.12),color:"#fecaca",font:"inherit",fontSize:13.5,fontWeight:600,cursor:"pointer"},children:jh.link}),d&&(0,r.jsxs)(jg.f,{title:jh.title,testid:"throw-away-dialog",onClose:k,children:[(0,r.jsxs)("p",{style:{margin:0,color:z.f.quiet,fontSize:15,lineHeight:1.5},children:[jh.text,b?` ${jh.prToo}`:""]}),h&&(0,r.jsx)("p",{role:"alert",style:{margin:0,color:A.f.failed,fontSize:13.5,lineHeight:1.45},children:h}),(0,r.jsxs)("div",{style:{display:"flex",gap:10,justifyContent:"flex-end",flexWrap:"wrap"},children:[(0,r.jsx)("button",{type:"button",disabled:f,onClick:k,style:{padding:"10px 16px",borderRadius:8,border:`1px solid ${z.f.line}`,background:"transparent",color:z.f.text,font:"inherit",fontSize:14,cursor:"pointer"},children:jh.no}),(0,r.jsxs)("button",{type:"button","data-testid":"throw-away-yes",disabled:f,onClick:()=>void j(),style:{display:"inline-flex",alignItems:"center",gap:8,padding:"10px 16px",borderRadius:8,border:`1px solid ${A.f.failed}`,background:A.f.tint("failed",.16),color:"#fecaca",font:"inherit",fontSize:14,fontWeight:700,cursor:f?"wait":"pointer"},children:[f&&(0,r.jsx)(D.m,{blockId:"throw-away",size:14}),f?jh.busy:jh.yes]})]})]})]})}function jj({runId:a,note:b,imageIds:c,imagesBusy:d,composer:e,onFollowUp:f,onShipState:g,away:h=null,onRecorded:i,onNewTask:j}){let k=(0,s.useContext)(iG),[l,m]=(0,s.useState)(null),[n,o]=(0,s.useState)(null),p=(0,s.useCallback)(a=>{m(a);let b=a.autoShip?.state==="started"?a.autoShip.at??"started":null;null!==b&&o(a=>a?.key===b?a:{key:b,at:Date.now()})},[]),[q,u]=(0,s.useState)(!1),[v,w]=(0,s.useState)(!1),x=v||""!==b.trim(),[B,C]=(0,s.useState)(null),[E,F]=(0,s.useState)(!1),[G,H]=(0,s.useState)(""),[I,J]=(0,s.useState)(!1),[K,L]=(0,s.useState)(null),[M,N]=(0,s.useState)(null),O=M?.pr!=null,P=M?.pr?.state==="merged",Q=M?.pr?.state==="open"&&!M.checksDone,R=P&&M?.deployPending===!0,S=P&&void 0!==j&&!x,T=Q||R,U=(0,s.useCallback)(a=>{N(a),g?.(a)},[g]),[V,W]=(0,s.useState)(null);async function X(b){W((b??"").replace(/^https:\/\/github\.com\/|^git@github\.com:/,"").replace(/\.git$/,"")),m(a=>a&&{...a,hasRemote:!0});let c=await fetch(`/api/runs/${a}/delivery`).catch(()=>null);c?.ok&&p(await c.json())}let[Y,Z]=(0,s.useState)(null),[$,aa]=(0,s.useState)(!1),[ab,ac]=(0,s.useState)(null);async function ad(){aa(!0),ac(null);try{let b=await fetch(`/api/runs/${a}/connect-github`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skip:!0})}),c=await b.json().catch(()=>null);if(!b.ok)return ac(c?.error??t.B.run.startFailed);Z(!0)}catch{ac(t.B.run.startFailed)}finally{aa(!1)}}(0,s.useEffect)(()=>{let b=!0;return fetch(`/api/runs/${a}/delivery`).then(a=>a.ok?a.json():null).then(a=>b&&a&&p(a)).catch(()=>void 0).finally(()=>b&&u(!0)),()=>{b=!1}},[a,p]);let[ae,af]=(0,s.useState)(()=>Date.now()),ag=l?.autoShip?.state==="started"?l.autoShip.at??"started":null,ah=null!==ag,ai=ah&&n?.key===ag&&ae-n.at>18e4,aj=ah&&!ai;(0,s.useEffect)(()=>{if(!ah)return;let b=setInterval(()=>{af(Date.now()),fetch(`/api/runs/${a}/delivery`).then(a=>a.ok?a.json():null).then(a=>a&&p(a)).catch(()=>void 0)},3e3);return()=>clearInterval(b)},[ah,a,p]);let[ak,al]=(0,s.useState)(!1),am=l?.eligible===!0&&!l.kept;async function an(){J(!0);try{let b=await fetch(`/api/runs/${a}/branch-name`),c=await b.json().catch(()=>null);b.ok&&c?.name&&H(c.name)}catch{}finally{J(!1)}}async function ao(b){C(b),L(null);try{let c=await fetch(`/api/runs/${a}/delivery`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify("branch"===b||"apply"===b?{mode:b,name:G.trim()}:{mode:b})}),d=await c.json().catch(()=>null);if(!c.ok||!d)return L(d?.error??t.B.run.startFailed);p(d),i?.()}catch{L(t.B.run.startFailed)}finally{C(null)}}async function ap(){C("follow"),L(null);try{let d=await fetch(`/api/runs/${a}/follow-up`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({note:b,attachments:c})}),e=await d.json().catch(()=>null);if(!d.ok||!e?.runId)return L(e?.error??t.B.run.startFailed);f(e.runId)}catch{L(t.B.run.startFailed)}finally{C(null)}}if((0,s.useEffect)(()=>{am&&an()},[am,a]),!q)return(0,r.jsx)(h8,{});if(!l?.eligible)return(0,r.jsx)(r.Fragment,{children:e()});if(l.thrownAway)return(0,r.jsx)("div",{"data-testid":"thrown-away",style:{fontSize:13.5,color:A.f.dim,lineHeight:1.5},children:t.B.delivery.throwAway.done});let aq=l.kept&&null!==l.branch,ar=y(M),as=aq&&!O&&!h&&!1===l.hasRemote,at=as&&(Y??!0===l.githubSkipped),au=P&&!R?4:P||ar?3:aq?2:1,av=t.B.delivery,aw=l.autoShip,ax=aw?.reason==="no_connection"&&aw.message===av.noRemote,ay=aw?.state==="stopped"&&(at&&"no_connection"===aw.reason||"keep"===aw.step&&aq||"send"===aw.step&&(O||l.pushed||ax&&(!0===l.hasRemote||null!==V))||"open"===aw.step&&O),az=aw?.state==="opened"?M?.pr?.state!=="open"||M.checksFailed||M.pr.conflicts?null:`${"app"===l.passedBy?av.auto.openedByApp:av.auto.openedAfterYes}${ar?` ${av.auto.publishWhenReady}`:""}`:aw?.state!=="stopped"||ay?ai?av.auto.seemsStopped:aw||"app"!==l.passedBy||aq||l.delivered?null:av.auto.passedReady:"open"===aw.step?av.auto.stopped.open:"keep"===aw.step?av.auto.stopped.keep:"no_connection"===aw.reason?av.auto.stopped.noConnection:av.auto.stopped.send,aA=aj?av.auto.working:R?av.nowPublishing:P?av.finished:ar?M.onHold?av.nowOnHold:av.nowPublish:M?.pr?.state==="closed"?av.nowClosed:O?M.checksFailed||M.pr.conflicts?av.nowProblem:av.nowChecking:aq?as?av.nowSaved:av.nowSend:av.nowSave,aB=aq&&l.current===l.branch,aC=!h&&!O&&!l.delivered&&!aB,aD=!h&&aq&&!O&&!l.pushed&&!as;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(jk,{current:au,passedByApp:"app"===l.passedBy,docked:k}),(0,r.jsxs)("div",{style:k?{display:"grid",gap:12,gridTemplateColumns:"minmax(0, 1fr)",padding:18,borderRadius:14,border:`1px solid ${z.f.line}`,background:z.f.card}:{display:"contents"},children:[(0,r.jsxs)("div",{"data-testid":"next-step",role:aj?"status":void 0,style:{display:"flex",alignItems:"center",gap:8,fontSize:k?16:13.5,fontWeight:k?700:void 0,color:k?z.f.text:"#d6dce6",lineHeight:1.45,overflowWrap:"anywhere"},children:[aj&&(0,r.jsx)(D.m,{blockId:"auto-ship",size:16}),(0,r.jsx)("span",{style:{minWidth:0},children:aA})]}),P&&j&&(0,r.jsxs)("div",{"data-testid":"next-change",style:{display:"grid",gap:10,fontSize:13.5,lineHeight:1.5,color:"#c9d0db"},children:[(0,r.jsx)("span",{children:av.nextChange}),[{key:"new",when:av.newTaskWhen,points:av.newTaskPoints},{key:"keep",when:av.keepHereWhen,points:av.keepHerePoints}].map(a=>(0,r.jsxs)("div",{"data-testid":`way-${a.key}`,style:{display:"grid",gap:8,padding:"12px 14px",borderRadius:11,border:`1px solid ${z.f.line}`,background:"#141414"},children:[(0,r.jsx)("strong",{style:{fontSize:13.5,color:"#e6e9ef"},children:a.when}),(0,r.jsx)("ul",{style:{margin:0,paddingLeft:18,display:"grid",gap:3,fontSize:12.5,color:"#c9d0db"},children:a.points.map(a=>(0,r.jsx)("li",{children:a},a))}),"new"===a.key?(0,r.jsxs)("button",{type:"button",className:"factory-action",onClick:j,style:{marginTop:2,padding:"9px 14px",borderRadius:9,border:`1px solid ${A.f.passed}`,background:A.f.passed,color:"#0d1f12",fontWeight:800,fontSize:14,cursor:"pointer"},children:["+ ",av.newTask]}):(0,r.jsx)("button",{type:"button",className:"factory-action","data-testid":"keep-here","aria-pressed":x,onClick:()=>w(!0),style:{marginTop:2,padding:"9px 14px",borderRadius:9,border:`1.5px solid ${A.f.passed}`,background:A.f.tint("passed",x?.28:.12),color:A.f.passed,fontWeight:800,fontSize:14,cursor:"pointer"},children:x?`${av.keepHere} ↓`:av.keepHere})]},a.key))]}),az&&(0,r.jsxs)("div",{"data-testid":"auto-line",style:{display:"grid",gap:6,fontSize:12.5,lineHeight:1.45,color:aw?.state==="stopped"?A.f.waiting:"#b9dcc5",overflowWrap:"anywhere"},children:[(0,r.jsx)("span",{children:az}),aw?.state==="stopped"&&!ay&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{style:{color:A.f.dim},children:av.auto.tryAgain}),aw.message&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button","aria-expanded":ak,onClick:()=>al(a=>!a),style:{justifySelf:"start",padding:0,background:"none",border:"none",color:z.f.green,fontSize:12.5,cursor:"pointer",textDecoration:"underline"},children:av.auto.whatHappened}),ak&&(0,r.jsx)("span",{"data-testid":"auto-message",style:{color:A.f.dim},children:aw.message})]})]})]}),(0,r.jsxs)("div",{style:{display:"grid",gap:8,gridTemplateColumns:"minmax(0, 1fr)"},children:[h&&!P&&(0,r.jsx)("div",{"data-testid":"away",style:{fontSize:12.5,color:A.f.waiting,lineHeight:1.45},children:t.B.machine.elsewhere(h.machine)}),!aq&&!h&&!aj&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"grid",gap:4,fontSize:12,color:A.f.dim},children:[(0,r.jsx)("label",{htmlFor:`branch-name-${a}`,children:av.branchName}),(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("input",{id:`branch-name-${a}`,value:G,placeholder:av.branchPlaceholder,disabled:null!==B||I,spellCheck:!1,onChange:a=>H(a.target.value),style:{flex:1,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,padding:"7px 8px",background:z.f.bg,color:"#d6dce6",border:`1px solid ${z.f.line}`,borderRadius:6,minWidth:0}}),(0,r.jsxs)("button",{type:"button",disabled:null!==B||I,onClick:()=>void an(),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",borderRadius:6,border:`1px solid ${z.f.line}`,background:z.f.card,color:"#d6dce6",fontSize:12,fontWeight:600,cursor:I?"wait":"pointer",whiteSpace:"nowrap"},children:[I?(0,r.jsx)(D.m,{blockId:"suggest",size:12}):(0,r.jsx)(jp,{})," ",I?av.suggesting:av.suggestName]})]}),(0,r.jsx)("span",{style:{fontSize:11,lineHeight:1.4},children:av.branchNameHint})]}),(0,r.jsxs)("button",{type:"button",disabled:null!==B,onClick:()=>void ao("branch"),style:jn(B),children:["branch"===B?(0,r.jsx)(D.m,{blockId:"keep",size:16}):(0,r.jsx)(jl,{})," ",av.keepButton]})]}),aq&&!aj&&(0,r.jsxs)("div",{"data-testid":"kept",style:{display:"grid",gap:8,gridTemplateColumns:"minmax(0, 1fr)"},children:[as&&!at?(0,r.jsxs)("div",{"data-testid":"not-connected",style:{display:"grid",gap:10,padding:14,borderRadius:10,border:`1px solid ${z.f.line}`,background:"#141414",fontSize:13,lineHeight:1.45},children:[(0,r.jsx)("span",{style:{color:"#c9d0db"},children:av.notConnected.offer}),(0,r.jsx)(_,{endpoint:`/api/runs/${a}/connect-github`,onConnected:X}),(0,r.jsx)("button",{type:"button","data-testid":"skip-github",disabled:$,onClick:()=>void ad(),style:{...jo(null),cursor:$?"wait":"pointer"},children:$?av.notConnected.skipping:av.notConnected.skip}),ab&&(0,r.jsx)("span",{role:"alert",style:{color:A.f.failed},children:ab})]}):at?(0,r.jsx)("div",{"data-testid":"github-skipped",style:{fontSize:12.5,color:A.f.dim,lineHeight:1.45},children:av.notConnected.skipped}):(0,r.jsxs)(r.Fragment,{children:[null!==V&&!O&&(0,r.jsxs)("div",{role:"status","data-testid":"connected",style:{display:"flex",alignItems:"center",gap:8,padding:"9px 11px",borderRadius:8,border:`1px solid ${A.f.tint("passed",.5)}`,background:A.f.tint("passed",.1),fontSize:13,color:"#d7f5e0",lineHeight:1.4},children:[(0,r.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:A.f.passed,strokeWidth:"2.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:(0,r.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})}),av.connect.done(V)]}),(0,r.jsx)(je,{runId:a,button:jn,onState:U,canOpen:!h,onRecorded:i})]}),!P&&!h&&(0,r.jsx)(jb,{runId:a,button:jo})]}),l.delivered&&(0,r.jsx)("div",{style:{fontSize:12.5,color:"#b9dcc5",lineHeight:1.4},children:av.done(l.files.length)})]})]}),(aq||aC)&&!T&&!aj&&(0,r.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,r.jsxs)("button",{type:"button","aria-expanded":E,onClick:()=>F(a=>!a),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderRadius:8,border:`1px solid ${z.f.line}`,background:z.f.card,color:"#d6dce6",fontSize:12.5,fontWeight:600,cursor:"pointer"},children:[av.moreOptions,(0,r.jsx)("span",{"aria-hidden":"true",style:{display:"inline-block",transform:E?"rotate(180deg)":"none",transition:"transform 150ms ease-out"},children:"▾"})]}),E&&(0,r.jsxs)("div",{"data-testid":"more-options",style:{display:"grid",gap:8},children:[aq&&(0,r.jsxs)("dl",{"data-testid":"kept-facts",style:{...jm,margin:0,gridTemplateColumns:"auto minmax(0, 1fr)",columnGap:12,rowGap:6,fontSize:12},children:[(0,r.jsx)("dt",{style:{color:A.f.dim},children:av.branchLabel}),(0,r.jsx)("dd",{style:{margin:0,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",color:"#d6dce6",overflowWrap:"anywhere"},children:l.branch}),(0,r.jsx)("dt",{style:{color:A.f.dim},children:av.commitLabel}),(0,r.jsx)("dd",{style:{margin:0,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",color:"#d6dce6"},children:(l.commit??"").slice(0,7)})]}),aq&&!h&&(aB||!P)&&(0,r.jsx)("div",{style:jm,children:aB?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{"data-testid":"on-branch",style:{fontSize:12,color:A.f.passed,lineHeight:1.4,overflowWrap:"anywhere"},children:["✓ ",av.onBranch(l.branch)]}),l.returnTo&&(0,r.jsxs)("button",{type:"button",disabled:null!==B,onClick:()=>void ao("back"),style:jo(B),children:["back"===B?(0,r.jsx)(D.m,{blockId:"back",size:16}):"←"," ",av.backButton(l.returnTo)]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button",disabled:null!==B,onClick:()=>void ao("switch"),style:jo(B),children:["switch"===B?(0,r.jsx)(D.m,{blockId:"switch",size:16}):(0,r.jsx)("span",{"aria-hidden":"true",children:"⇄"})," ",av.switchButton]}),(0,r.jsx)("div",{style:{fontSize:11.5,color:A.f.dim,lineHeight:1.4},children:av.switchWhat})]})}),aD&&(0,r.jsxs)("div",{style:jm,children:[(0,r.jsxs)("button",{type:"button",disabled:null!==B,onClick:()=>void ao("push"),style:jo(B),children:["push"===B?(0,r.jsx)(D.m,{blockId:"push",size:16}):"↑"," ",av.pushOnly]}),(0,r.jsx)("div",{style:{fontSize:11.5,color:A.f.dim,lineHeight:1.4},children:av.pushOnlyWhat})]}),aC&&(0,r.jsxs)("div",{style:jm,children:[(0,r.jsxs)("button",{type:"button",disabled:null!==B,onClick:()=>void ao("apply"),style:jo(B),children:["apply"===B?(0,r.jsx)(D.m,{blockId:"apply",size:16}):"⤵"," ",av.applyButton]}),(0,r.jsx)("div",{style:{fontSize:11.5,color:A.f.dim,lineHeight:1.4},children:av.applyWhat})]})]})]}),!P&&!R&&!h&&!aj&&(0,r.jsx)(ji,{runId:a,prOpen:M?.pr?.state==="open",onThrown:a=>{p(a),i?.()}}),(0,r.jsxs)("div",{"data-testid":"follow-up-box",style:{display:T||S?"none":"grid",gap:6,gridTemplateColumns:"minmax(0, 1fr)",paddingTop:10,borderTop:`1px solid ${A.f.lineSoft}`,...k?{marginTop:"auto",marginInline:-20,padding:"20px 20px 0",gap:10,borderTop:`1px solid ${z.f.line}`}:null},children:[(0,r.jsx)("div",{style:{fontSize:12,color:A.f.dim},children:P?t.B.followUp.hintPublished:t.B.followUp.hint}),e({label:t.B.followUp.start,name:P?t.B.followUp.titleContinue:t.B.followUp.titleAdjust,onSend:()=>void ap(),enabled:null===B&&!d&&""!==b.trim(),busy:"follow"===B})]}),K&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12.5,color:A.f.failed,lineHeight:1.4},children:K})]})}function jk({current:a,passedByApp:b,docked:c=!1}){let d=b?[t.B.delivery.passedStep,...t.B.delivery.steps.slice(1)]:t.B.delivery.steps,e=c?26:18;return(0,r.jsx)("ol",{"data-testid":"steps","aria-label":t.B.delivery.stepsLabel,style:{listStyle:"none",margin:0,padding:0,display:"flex",alignItems:c?"flex-start":"center",gap:4*!c},children:d.map((b,f)=>{let g=f<a||4===a,h=f===a&&4!==a,i=g?A.f.passed:h?"#d6dce6":A.f.skipped,j=(0,r.jsx)("span",{"aria-hidden":"true",style:{position:"relative",width:e,height:e,flex:"none",borderRadius:"50%",display:"grid",placeItems:"center",fontSize:c?13:10,fontWeight:900,background:g?A.f.passed:z.f.bg,color:g?"#07110a":i,border:`1.5px solid ${g?A.f.passed:i}`},children:g?"✓":f+1}),k=g&&f+1<=a?A.f.tint("passed",.6):z.f.line;return c?(0,r.jsxs)("li",{"aria-current":h?"step":void 0,style:{position:"relative",flex:"1 1 0",minWidth:0,display:"grid",justifyItems:"center",gap:8},children:[f<d.length-1&&(0,r.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",top:e/2-1,left:"50%",width:"100%",height:1.5,background:k}}),j,(0,r.jsx)("span",{style:{fontSize:12.5,fontWeight:h?800:500,color:g?z.f.quiet:i,textAlign:"center",lineHeight:1.3,textWrap:"balance"},children:b})]},b):(0,r.jsxs)("li",{"aria-current":h?"step":void 0,style:{display:"flex",alignItems:"center",gap:4,flex:f<d.length-1?"1 1 auto":"none",minWidth:0},children:[j,(0,r.jsx)("span",{style:{fontSize:11.5,fontWeight:h?800:600,color:i,whiteSpace:"nowrap"},children:b}),f<d.length-1&&(0,r.jsx)("span",{"aria-hidden":"true",style:{flex:1,height:1.5,minWidth:8,background:k}})]},b)})})}function jl(){return(0,r.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,r.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 jm={display:"grid",gap:6,padding:10,borderRadius:8,border:`1px solid ${z.f.line}`,background:"#141414"};function jn(a){return{padding:"9px 12px",borderRadius:8,border:`1px solid ${A.f.passed}`,background:A.f.passed,color:"#07110a",fontWeight:700,cursor:a?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8}}function jo(a){return{padding:"8px 12px",borderRadius:8,border:`1px solid ${A.f.tint("passed",.6)}`,background:"transparent",color:"#b9dcc5",fontWeight:700,cursor:a?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8}}function jp(){return(0,r.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,r.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 jq={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}},jr=(0,s.forwardRef)(function({docked:a=!1,direct:b=!1,planMeasure:c,stopForMe:d=!1,onStopForMe:e,onSeeChanges:f,record:g=null,recordFailed:h=!1,recordMark:i=0,recordReadMark:j=0,askedId:k=null,onRecordChanged:l,showFindings:m=!1,notice:n,mode:o,runId:p,risk:q,text:u,onText:v,images:w,onImages:x,onRun:y,canRun:B,onFollowUp:C,onNewTask:E,onSent:F,startOptions:G=[],startFrom:H,onStartFrom:I,onShipState:J,loading:K=!1,taskName:L,onTaskName:M,away:N=null,onRecorded:O,failureActions:P,onCanContinue:Q},R){let S=jq[o],[T,U]=hS(hO,!1),V=a&&T,[W,X]=(0,s.useState)(!1),Y=a=>{X(!0),U(a)},Z="plan"===o?t.B.plan.replanLabel:"waiting"===o?t.B.gate.reasonLabel:"done"===o?t.B.followUp.title:"failed"===o?t.B.failure.label:t.B.run.requestLabel,$="plan"===o?t.B.plan.replanPlaceholder:"waiting"===o?t.B.gate.reasonPlaceholder:"done"===o?t.B.followUp.placeholder:"failed"===o?t.B.failure.placeholder:t.B.run.requestPlaceholder,_=a=>(0,r.jsx)(iJ,{send:a,minHeight:"waiting"===o||"done"===o||"plan"===o||"failed"===o?96:void 0,inputId:ik,label:a?.name??Z,placeholder:$,text:u,onText:v,images:w,onImages:x,onSubmit:"idle"===o&&B?y:void 0});return(0,r.jsxs)(r.Fragment,{children:[V&&(0,r.jsx)(ju,{mode:K?"idle":o,glide:W,onOpen:()=>Y(!1)}),(0,r.jsx)("section",{ref:R,className:W&&!V?"factory-from-right":void 0,tabIndex:-1,"data-testid":"command-card","data-mode":o,"aria-label":"plan"===o?t.B.plan.title:"question"===o?t.B.question.title:"waiting"===o?t.B.gate.title:"done"===o?t.B.delivery.title:t.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, ${S.from} 0%, ${S.to} 100%)`,border:`1px solid ${A.f.tint(S.tone,S.strength)}`,borderRadius:14,boxShadow:`0 0 0 1px ${A.f.tint(S.tone,.15)}, 0 0 30px ${A.f.tint(S.tone,"idle"===o?.06:.16)}, 0 18px 40px rgba(0,0,0,0.55)`,padding:16,display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:12,outline:"none",...a?{top:0,right:0,bottom:0,maxWidth:"100%",maxHeight:"none",padding:"20px 20px 24px",display:"flex",flexDirection:"column",gap:16,zoom:1.08,background:z.f.bg,border:"none",borderLeft:`1px solid ${z.f.line}`,borderRadius:0,boxShadow:"none"}:null,...V?{display:"none"}:null},children:(0,r.jsxs)(iG.Provider,{value:a,children:[a&&(0,r.jsx)("button",{type:"button","data-testid":"panel-fold","aria-label":t.B.panel.fold,title:t.B.panel.fold,onClick:()=>Y(!0),style:{...js,alignSelf:"flex-start",margin:"-10px 0 -10px -10px"},children:(0,r.jsx)(h5,{name:"expand"})}),K&&(0,r.jsx)(h8,{}),!K&&"idle"===o&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:t.B.sidebar.runTitle}),b&&(0,r.jsx)("div",{"data-testid":"direct-start-hint",role:"note",style:{padding:"9px 12px",borderRadius:10,border:`1px solid ${A.f.tint("passed",.5)}`,color:A.f.passed,fontSize:13,lineHeight:1.45},children:t.B.direct.startHint}),1===G.length&&(0,r.jsx)("div",{"data-testid":"starts-from",style:{fontSize:12,color:A.f.dim,marginTop:-6,overflowWrap:"anywhere"},children:t.B.delivery.startsFrom(G[0])}),G.length>1&&(0,r.jsxs)("label",{"data-testid":"starts-from",style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:A.f.dim,marginTop:-6},children:[t.B.delivery.startFromLabel,(0,r.jsx)("select",{value:H??G[0],onChange:a=>I?.(a.target.value),style:{flex:1,minWidth:0,padding:"4px 6px",background:A.f.bg,color:"inherit",border:`1px solid ${A.f.border}`,borderRadius:6,fontSize:12},children:G.map((a,b)=>(0,r.jsx)("option",{value:a,children:0===b?t.B.delivery.mainOption(a):t.B.delivery.currentOption(a)},a))})]}),M&&(0,r.jsxs)("label",{style:{display:"grid",gap:4,fontSize:12.5,fontWeight:600,color:A.f.dim},children:[(0,r.jsxs)("span",{children:[t.B.title.label," ",(0,r.jsx)("span",{style:{fontWeight:400},children:t.B.title.optional})]}),(0,r.jsx)("input",{value:L??"",maxLength:60,placeholder:t.B.title.placeholder,onChange:a=>M(a.target.value),style:{font:"inherit",fontSize:13.5,fontWeight:400,padding:"7px 10px",background:A.f.card,color:"#e6e9ef",border:`1px solid ${A.f.border}`,borderRadius:8}})]}),e&&(0,r.jsx)(jv,{checked:d,onChange:e}),_({label:t.B.run.send,onSend:y,enabled:B})]}),!K&&"working"===o&&(0,r.jsxs)("div",{role:"status",style:{display:"flex",alignItems:"center",gap:10,fontSize:14,fontWeight:600,color:"#cfe0ff"},children:[(0,r.jsx)(D.m,{blockId:"card",size:20}),t.B.card.working]}),!K&&"working"===o&&n&&(0,r.jsx)(jw,{notice:n}),!K&&"plan"===o&&p&&(0,r.jsx)(i8,{measure:c,away:N,runId:p,note:u,composer:_,onSent:F}),!K&&"question"===o&&p&&(0,r.jsx)(i5,{runId:p,record:g,failed:h,mark:i,readMark:j,askedId:k,onChanged:()=>l?.()}),!K&&"waiting"===o&&p&&(0,r.jsx)(iW,{findings:m?g?.findings:void 0,touched:g?.touched,away:N,runId:p,risk:q,note:u,imageIds:iH(w),imagesBusy:iI(w),composer:_,onSent:F,onSeeChanges:f}),!K&&"done"===o&&p&&(0,r.jsx)(jj,{away:N,onRecorded:O,onNewTask:E,onShipState:J,runId:p,note:u,imageIds:iH(w),imagesBusy:iI(w),composer:_,onFollowUp:a=>{F(),C(a)}}),!K&&"failed"===o&&p&&(0,r.jsx)(iA,{runId:p,note:u,imageIds:iH(w),imagesBusy:iI(w),composer:_,onText:v,actionsRef:P,onCanContinue:Q,onFollowUp:a=>{F(),C(a)}})]})})]})}),js={width:36,height:36,display:"grid",placeItems:"center",background:"transparent",color:A.f.dim,border:"1px solid transparent",borderRadius:8,cursor:"pointer"},jt={idle:z.f.quiet,working:A.f.passed,plan:A.f.waiting,question:A.f.waiting,waiting:A.f.waiting,done:A.f.passed,failed:A.f.failed};function ju({mode:a,glide:b,onOpen:c}){let d=jt[a],e="plan"===a||"question"===a||"waiting"===a,f="working"===a?(0,r.jsx)(D.m,{blockId:"panel-rail",size:20}):(0,r.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"===a&&(0,r.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"}),"failed"===a&&(0,r.jsx)("path",{d:"M6 6l12 12M18 6L6 18"}),e&&(0,r.jsx)("path",{d:"M12 5v9M12 18.5v.5"}),"idle"===a&&(0,r.jsx)("path",{d:"M4 20h4L19 9l-4-4L4 16v4zM13.5 6.5l4 4"})]});return(0,r.jsxs)("button",{type:"button","data-testid":"panel-rail",className:b?"factory-from-right":void 0,"data-mode":a,"aria-label":`${t.B.panel.open}. ${t.B.panel.state[a]}`,title:`${t.B.panel.state[a]} \xb7 ${t.B.panel.open}`,onClick:c,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 ${z.f.line}`,background:z.f.bg,color:z.f.quiet,cursor:"pointer"},children:[(0,r.jsx)("span",{style:js,children:(0,r.jsx)(h5,{name:"collapse"})}),(0,r.jsx)("span",{role:"working"===a?"status":void 0,style:{width:36,height:36,borderRadius:10,display:"grid",placeItems:"center",color:d,background:A.f.tint("working"===a?"passed":e?"waiting":"done"===a?"passed":"failed"===a?"failed":"skipped",.16),border:`1px solid ${e?A.f.waiting:z.f.line}`},children:f}),(0,r.jsx)("span",{style:{writingMode:"vertical-rl",fontSize:12,letterSpacing:.3,color:e?A.f.waiting:z.f.quiet,fontWeight:e?700:500},children:t.B.panel.state[a]})]})}function jv({checked:a,onChange:b}){let[c,d]=(0,s.useState)(!1),e="stop-for-me-why";return(0,r.jsxs)("div",{"data-testid":"stop-for-me",style:{display:"grid",gap:4,minWidth:0},children:[(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 12px"},children:[(0,r.jsxs)("label",{style:{display:"inline-flex",alignItems:"center",gap:8,fontSize:13,color:"#d6dce6",cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:a,onChange:a=>b(a.target.checked)}),t.B.composer.stopForMe]}),(0,r.jsx)("button",{type:"button","aria-expanded":c,"aria-controls":e,onClick:()=>d(a=>!a),style:{padding:0,background:"none",border:"none",color:"#9cc2ff",fontSize:12.5,cursor:"pointer",textDecoration:"underline"},children:t.B.composer.stopForMeWhat})]}),c&&(0,r.jsx)("span",{id:e,style:{fontSize:12.5,lineHeight:1.45,color:A.f.dim,overflowWrap:"anywhere"},children:t.B.composer.stopForMeWhy})]})}function jw({notice:a}){let[b,c]=(0,s.useState)(!1),d={fontSize:12,lineHeight:1.4,color:A.f.dim,margin:0};return"ask"===a.offer?(0,r.jsx)("button",{type:"button",onClick:()=>{c(!0),a.onAllow()},style:{justifySelf:"start",textAlign:"left",padding:"5px 10px",borderRadius:8,border:`1px solid ${A.f.border}`,background:"transparent",color:"inherit",fontSize:12.5,cursor:"pointer"},children:t.B.tell.offer}):b&&"on"===a.offer?(0,r.jsx)("p",{style:d,children:t.B.tell.on}):b&&"blocked"===a.offer?(0,r.jsx)("p",{style:d,children:t.B.tell.blocked}):null}let jx=new Set(["node.question_asked","node.question_answered","node.findings_checked","node.finding_resolved"]);function jy(a){for(let b=a.length-1;b>=0;b--){let c=a[b];if("node.question_answered"===c.type)break;if("node.question_asked"===c.type){let a=c.payload?.questionId;return"string"==typeof a?a:null}}return null}let jz=t.B.details,jA="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",jB={scrollbarWidth:"thin",scrollbarColor:`${A.f.skipped} transparent`},jC=["input","plan","build","tests","review","approve","human","ship"],jD="min(48vh, 440px)";function jE(a){if(a<1e3)return jz.underASecond;let b=Math.round(a/1e3);if(b<60)return`${b}s`;let c=Math.floor(b/60);return c<60?`${c}m ${b%60}s`:`${Math.floor(c/60)}h ${c%60}m`}function jF(a){if(!a)return jz.none;let b=new Date(a);return Number.isNaN(b.getTime())?jz.none:b.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function jG({text:a}){return(0,r.jsx)(r.Fragment,{children:a.replace(/\*\*/g,"").split(/\n{2,}/).map((a,b)=>(0,r.jsx)("p",{style:{margin:0},children:a.split("`").map((a,b)=>b%2==1?(0,r.jsx)("code",{style:{padding:"1px 6px",borderRadius:5,background:z.f.bg,border:`1px solid ${z.f.line}`,fontFamily:jA,fontSize:"0.86em",color:z.f.text},children:a},b):a)},b))})}function jH({path:a,size:b=16}){return(0,r.jsx)("svg",{viewBox:"0 0 24 24",width:b,height:b,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:a})}let jI={clock:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M12 7v5l3 2"})]}),play:(0,r.jsx)("path",{d:"M8 5.5v13l10-6.5z"}),flag:(0,r.jsx)("path",{d:"M6 21V4h11l-2 4 2 4H6"}),spark:(0,r.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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("rect",{x:"7",y:"7",width:"10",height:"10",rx:"2"}),(0,r.jsx)("path",{d:"M10 3v4M14 3v4M10 17v4M14 17v4M3 10h4M3 14h4M17 10h4M17 14h4"})]}),repeat:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("path",{d:"M20 11a8 8 0 1 0-2.3 5.7"}),(0,r.jsx)("path",{d:"M20 4v7h-7"})]}),check:(0,r.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"}),cross:(0,r.jsx)("path",{d:"M6 6l12 12M18 6L6 18"}),chevron:(0,r.jsx)("path",{d:"M9 6l6 6-6 6"}),enlarge:(0,r.jsx)("path",{d:"M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5"})};function jJ({icon:a,label:b,value:c,help:d}){return(0,r.jsxs)("div",{style:{display:"grid",gap:5,padding:"13px 15px",borderRadius:12,background:"#141414",border:`1px solid ${z.f.line}`,minWidth:0},children:[(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:7,fontSize:12.5,color:z.f.quiet},children:[(0,r.jsx)(jH,{path:a,size:14})," ",b]}),(0,r.jsx)("span",{style:{fontSize:19,fontWeight:700,color:z.f.text,overflowWrap:"anywhere"},children:c}),d&&(0,r.jsx)("span",{style:{fontSize:11.5,color:A.f.skipped},children:d})]})}function jK({title:a,help:b,children:c}){return(0,r.jsxs)("section",{style:{display:"grid",gap:10},children:[(0,r.jsxs)("div",{style:{display:"grid",gap:3},children:[(0,r.jsx)("strong",{className:"factory-display",style:{fontSize:17},children:a}),b&&(0,r.jsx)("span",{style:{fontSize:13,color:z.f.quiet},children:b})]}),c]})}function jL({measure:a,startedOnItsOwn:b}){return(0,r.jsxs)(r.Fragment,{children:[a.reasons.length>0&&(0,r.jsx)(jK,{title:b?t.B.plan.whyStarted:t.B.plan.whyStopped,children:(0,r.jsx)("ul",{style:{margin:0,paddingLeft:20,display:"grid",gap:6,fontSize:14.5,lineHeight:1.5,color:"#d6dce6",overflowWrap:"anywhere"},children:a.reasons.map((a,b)=>(0,r.jsx)("li",{children:a},b))})}),(0,r.jsx)(jK,{title:t.B.plan.expects,children:a.entries.length>0?(0,r.jsx)("ul",{style:{margin:0,paddingLeft:20,display:"grid",gap:4,fontFamily:jA,fontSize:13,color:"#d6dce6",overflowWrap:"anywhere"},children:a.entries.map((a,b)=>(0,r.jsx)("li",{children:a},b))}):(0,r.jsx)("span",{style:{color:z.f.quiet},children:t.B.plan.noneExpected})})]})}function jM({c:a}){let[b,c]=(0,s.useState)(!1),d=0===a.exitCode;return(0,r.jsxs)("div",{style:{display:"grid",gap:8,padding:"11px 13px",borderRadius:10,background:"#141414",border:`1px solid ${d?z.f.line:A.f.tint("failed",.5)}`},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"3px 10px",borderRadius:999,background:A.f.tint(d?"passed":"failed",.16),color:d?A.f.passed:A.f.failed,fontSize:12.5,fontWeight:700},children:[(0,r.jsx)(jH,{path:d?jI.check:jI.cross,size:13})," ",d?jz.commandPassed:jz.commandFailed]}),(0,r.jsx)("code",{style:{fontFamily:jA,fontSize:13,color:"#e6e9ef"},children:a.command}),null!==a.durationMs&&(0,r.jsx)("span",{style:{marginLeft:"auto",fontSize:13,color:z.f.quiet},children:jE(a.durationMs)})]}),!d&&(0,r.jsx)("span",{style:{fontSize:13,color:A.f.failed},children:t.B.failure.ended(a.exitCode,a.signal)}),a.output&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button","aria-expanded":b,onClick:()=>c(a=>!a),style:{justifySelf:"start",display:"inline-flex",alignItems:"center",gap:5,padding:0,background:"none",border:"none",color:z.f.green,fontSize:13,cursor:"pointer"},children:[(0,r.jsx)("span",{style:{display:"inline-flex",transform:b?"rotate(90deg)":"none"},children:(0,r.jsx)(jH,{path:jI.chevron,size:13})}),b?jz.hideOutput:jz.showOutput]}),b&&(0,r.jsx)("pre",{style:{margin:0,maxHeight:280,overflow:"auto",padding:12,borderRadius:8,background:z.f.bg,border:`1px solid ${z.f.line}`,fontFamily:jA,fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",...jB},children:a.output})]})]})}function jN({runId:a}){let{state:b}=(0,aB.C)(a,!1);return b&&"unneeded"!==b.status?(0,r.jsx)(jK,{title:jz.pictures,help:jz.picturesHelp,children:(0,r.jsx)(jY,{runId:a,state:b})}):null}function jO({runId:a,name:b,done:c}){let{state:d,take:e,error:f}=(0,aB.C)(a,c),[g,h]=(0,s.useState)(!1),[i,j]=(0,s.useState)(!1);if(!d)return(0,r.jsx)(h6,{width:300,height:96,radius:8});if(!c&&"ready"!==d.status&&"working"!==d.status)return(0,r.jsx)("span",{style:{fontSize:13,color:A.f.skipped},children:jz.historyWhenDone});if("unneeded"===d.status)return(0,r.jsx)("span",{style:{fontSize:13,color:A.f.skipped},children:jz.historyNothingToSee});if("working"===d.status||i&&"none"===d.status&&!f)return(0,r.jsxs)("span",{role:"status",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:z.f.quiet},children:[(0,r.jsx)(D.m,{blockId:`pictures-${a}`,size:14})," ",d.message??jz.historyTaking]});if("ready"!==d.status||0===d.shots.length)return(0,r.jsxs)("span",{style:{display:"grid",gap:6,justifyItems:"start"},children:[(0,r.jsx)("button",{type:"button",onClick:()=>{j(!0),e()},style:{padding:"6px 12px",borderRadius:8,border:`1px solid ${z.f.line}`,background:z.f.bg,color:z.f.text,fontSize:13,fontWeight:600,cursor:"pointer"},children:jz.historyTake}),(f??("failed"===d.status?d.message:null))&&(0,r.jsx)("span",{style:{fontSize:12.5,color:A.f.failed},children:f??d.message})]});let k=["before","after"].filter(a=>d.shots.includes(`${a}-desktop`));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button","data-testid":"history-thumbs","aria-label":jz.historyPicturesOf(b),onClick:()=>h(!0),style:{display:"flex",gap:10,padding:0,border:"none",background:"none",cursor:"zoom-in",justifySelf:"start"},children:k.map(b=>(0,r.jsxs)("span",{style:{display:"grid",gap:4,justifyItems:"start"},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:"before"===b?z.f.quiet:A.f.passed},children:t.B.snapshots[b]}),(0,r.jsx)("img",{src:(0,aB.h)(a,`${b}-desktop`,d),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 ${z.f.line}`}})]},b))}),g&&(0,fb.createPortal)((0,r.jsx)("div",{onClick:()=>h(!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,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":jz.historyPicturesOf(b),onClick:a=>a.stopPropagation(),style:{width:"min(1100px, calc(100% - 32px))",maxHeight:"calc(100% - 64px)",overflowY:"auto",display:"grid",gap:14,padding:22,background:z.f.card,border:`1px solid ${z.f.line}`,borderRadius:14,...jB},children:[(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:12},children:[(0,r.jsx)("strong",{className:"factory-display",style:{fontSize:18},children:jz.historyPicturesOf(b)}),(0,r.jsx)("button",{type:"button","aria-label":jz.close,onClick:()=>h(!1),style:{background:"none",border:"none",color:A.f.skipped,cursor:"pointer",fontSize:18},children:"✕"})]}),(0,r.jsx)(jY,{runId:a,state:d})]})}),document.body)]})}let jP={position:"relative",display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:14,paddingBottom:16},jQ={position:"absolute",left:12,top:26,bottom:0,width:2,background:z.f.line},jR={display:"grid",gap:10,minWidth:0,padding:"12px 14px",borderRadius:12,border:`1px solid ${z.f.line}`,background:"#141414"},jS={fontSize:11,fontWeight:800,letterSpacing:"0.1em",textTransform:"uppercase",color:z.f.quiet},jT=a=>new Date(a).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),jU=({colour:a})=>(0,r.jsx)("span",{className:"factory-history-dot",style:{width:26,height:26,borderRadius:999,display:"grid",placeItems:"center",background:"#141414",border:`2px solid ${a}`,color:a,fontSize:12.5,fontWeight:800,zIndex:1}});function jV({files:a}){return 0===a.length?null:(0,r.jsxs)("div",{style:{display:"grid",gap:4,fontSize:12.5,paddingTop:8,borderTop:`1px solid ${z.f.line}`},children:[(0,r.jsx)("span",{style:{color:z.f.quiet,fontWeight:700},children:jz.historyFiles(a.length)}),(0,r.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[a.slice(0,6).map(a=>(0,r.jsx)("code",{style:{padding:"2px 7px",borderRadius:6,background:z.f.bg,border:`1px solid ${z.f.line}`,color:"#c9d0db",fontSize:12},children:a},a)),a.length>6&&(0,r.jsx)("span",{style:{color:A.f.skipped,alignSelf:"center"},children:jz.historyMoreFiles(a.length-6)})]})]})}function jW({t:a,more:b}){let{state:c,versions:d}=(0,aB.w)(a.runId),e={margin:0,fontSize:14.5,lineHeight:1.5,color:"#e6e9ef",overflowWrap:"anywhere"},f=(0,r.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px",marginLeft:"auto"},children:[a.here&&(0,r.jsx)("span",{style:{padding:"2px 9px",borderRadius:999,background:A.f.tint("passed",.18),color:A.f.passed,fontSize:11.5,fontWeight:800},children:jz.historyHere}),(0,r.jsx)("span",{style:{fontSize:12.5,color:A.f.skipped},children:jT(a.at)})]});if(c&&d.length>0)return(0,r.jsx)(r.Fragment,{children:d.map((g,h)=>(0,r.jsxs)("li",{"data-testid":"history-step",style:jP,children:[(b||h<d.length-1)&&(0,r.jsx)("span",{"aria-hidden":"true",style:jQ}),(0,r.jsx)(jU,{colour:A.f.passed}),(0,r.jsxs)("div",{style:jR,children:[(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px"},children:[(0,r.jsx)("span",{style:jS,children:0===h?jz.historyAsked:jz.historyAskedChange}),0===h&&f]}),(0,r.jsx)("p",{style:e,children:g.asked}),(0,r.jsx)(aB.R,{runId:a.runId,state:c,versions:d,index:h}),h===d.length-1&&(0,r.jsx)(jV,{files:a.files})]})]},`${a.runId}-${g.change}`))});let g=a.request.replace(/\s+/g," ").trim().startsWith(a.name)?null:a.name;return(0,r.jsxs)("li",{"data-testid":"history-step",style:jP,children:[b&&(0,r.jsx)("span",{"aria-hidden":"true",style:jQ}),(0,r.jsx)(jU,{colour:A.f.passed}),(0,r.jsxs)("div",{style:jR,children:[(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px"},children:[(0,r.jsx)("span",{style:jS,children:jz.historyAsked}),f]}),g&&(0,r.jsx)("strong",{style:{fontSize:15,color:"#e6e9ef",overflowWrap:"anywhere"},children:g}),(0,r.jsx)("p",{style:{...e,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},title:a.request,children:a.request}),a.asks&&a.asks.length>0&&(0,r.jsxs)("div",{"data-testid":"history-asks",style:{display:"grid",gap:4,fontSize:13.5,color:"#c9d0db"},children:[(0,r.jsx)("span",{style:jS,children:jz.historyAsks}),(0,r.jsx)("ol",{start:2,style:{margin:0,paddingLeft:20,display:"grid",gap:3,lineHeight:1.5},children:a.asks.map((a,b)=>(0,r.jsx)("li",{style:{overflowWrap:"anywhere"},children:a},b))})]}),a.look?(0,r.jsx)(jO,{runId:a.runId,name:a.name,done:a.done}):(0,r.jsx)("span",{style:{fontSize:13,color:A.f.skipped},children:jz.historyNothingToSee}),(0,r.jsx)(jV,{files:a.files})]})]})}function jX({tasks:a,github:b}){return(0,r.jsx)(jK,{title:jz.history,help:jz.historyHelp,children:(0,r.jsxs)("ol",{"data-testid":"details-history",className:"factory-history",style:{listStyle:"none",margin:0,padding:0},children:[a.map((c,d)=>(0,r.jsx)(jW,{t:c,more:d<a.length-1||!!b},c.runId)),b&&(0,r.jsxs)("li",{"data-testid":"history-github",style:{...jP,paddingBottom:0},children:[(0,r.jsx)(jU,{colour:b.published?A.f.passed:A.f.waiting}),(0,r.jsxs)("div",{style:{...jR,gap:6},children:[(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px",minHeight:26},children:[(0,r.jsx)("strong",{style:{fontSize:15,color:"#e6e9ef"},children:jz.historyGithub}),(0,r.jsx)("span",{style:{padding:"2px 9px",borderRadius:999,background:A.f.tint(b.published?"passed":"waiting",.18),color:b.published?A.f.passed:A.f.waiting,fontSize:11.5,fontWeight:800},children:b.published?jz.historyPublished:jz.historyWaiting}),(0,r.jsx)("span",{style:{fontSize:12.5,color:A.f.skipped},children:jT(b.at)})]}),(0,r.jsxs)("span",{style:{fontSize:13,color:z.f.quiet,overflowWrap:"anywhere"},children:[jz.historyBranch," ",(0,r.jsx)("code",{style:{color:"#c9d0db"},children:b.branch})]}),b.pr&&(0,r.jsxs)("a",{href:b.pr.url,target:"_blank",rel:"noreferrer",style:{justifySelf:"start",color:z.f.green,fontSize:13.5},children:[jz.historyPr(b.pr.number)," ↗"]})]})]})]})})}function jY({runId:a,state:b}){let[c,d]=(0,s.useState)("desktop"),[e,f]=(0,s.useState)(null);if("working"===b.status)return(0,r.jsxs)("span",{role:"status",style:{display:"flex",alignItems:"center",gap:8,color:z.f.quiet},children:[(0,r.jsx)(D.m,{blockId:"pictures",size:15})," ",jz.picturesWorking]});if("ready"!==b.status||0===b.shots.length)return(0,r.jsx)("span",{style:{color:z.f.quiet},children:jz.noPictures});let g=c=>(0,aB.h)(a,c,b);return(0,r.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,r.jsxs)("div",{role:"tablist",style:{display:"flex",gap:8},children:[["desktop","mobile"].map(a=>(0,r.jsx)("button",{type:"button",role:"tab","aria-selected":c===a,onClick:()=>d(a),style:{padding:"7px 16px",borderRadius:999,border:`1px solid ${c===a?A.f.running:z.f.line}`,background:c===a?A.f.tint("running",.18):"transparent",color:c===a?z.f.text:z.f.quiet,fontSize:13.5,fontWeight:700,cursor:"pointer"},children:t.B.snapshots[a]},a)),b.route&&(0,r.jsx)("span",{"data-testid":"pictures-page",style:{alignSelf:"center",marginLeft:"auto",fontSize:13,color:z.f.quiet},children:t.B.snapshots.page(b.route,b.opened)})]}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:14,alignItems:"start"},children:["before","after"].map(a=>{let d=`${a}-${c}`,e=`${t.B.snapshots[a]} \xb7 ${t.B.snapshots[c]}`;return(0,r.jsxs)("figure",{style:{margin:0,display:"grid",gap:6},children:[(0,r.jsx)("figcaption",{style:{justifySelf:"start",fontSize:13,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:"before"===a?z.f.quiet:A.f.passed},children:t.B.snapshots[a]}),b.shots.includes(d)?(0,r.jsxs)("button",{type:"button","aria-label":jz.enlarge(e),title:jz.enlargeHint,onClick:()=>f(d),style:{position:"relative",height:jD,boxSizing:"border-box",display:"flex",justifyContent:"center",alignItems:"flex-start",overflow:"hidden",borderRadius:8,background:z.f.bg,border:`1px solid ${z.f.line}`,padding:8,cursor:"zoom-in"},children:[(0,r.jsx)("img",{src:g(d),alt:e,style:{display:"block",maxWidth:"100%",maxHeight:"100%",borderRadius:6,border:`1px solid ${"before"===a?z.f.line:A.f.tint("passed",.5)}`}}),(0,r.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 ${z.f.line}`,color:"#e6e9ef",fontSize:12.5,fontWeight:700},children:[(0,r.jsx)(jH,{path:jI.enlarge,size:14})," ",jz.enlargeHint]})]}):(0,r.jsx)("div",{style:{height:jD,display:"grid",placeItems:"center",padding:16,textAlign:"center",borderRadius:8,border:`1px dashed ${z.f.line}`,color:z.f.quiet,fontSize:13.5,lineHeight:1.45},children:"before"===a?jz.noBefore:jz.noAfter})]},a)})}),e&&(0,r.jsx)(jZ,{src:g(e),label:`${t.B.snapshots[e.startsWith("before")?"before":"after"]} \xb7 ${t.B.snapshots[e.endsWith("mobile")?"mobile":"desktop"]}`,phone:e.endsWith("mobile"),onClose:()=>f(null)})]})}function jZ({src:a,label:b,phone:c,onClose:d}){return(0,s.useEffect)(()=>{let a=a=>{"Escape"===a.key&&(a.stopImmediatePropagation(),d())};return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[d]),(0,fb.createPortal)((0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":b,"data-testid":"large-picture",onClick:a=>{a.stopPropagation(),d()},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,r.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",color:"#e6e9ef"},children:[(0,r.jsx)("strong",{className:"factory-display",style:{fontSize:17},children:b}),(0,r.jsxs)("button",{type:"button",onClick:d,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"7px 14px",borderRadius:8,border:`1px solid ${z.f.line}`,background:"#141414",color:"#e6e9ef",fontSize:13.5,fontWeight:700,cursor:"pointer"},children:[(0,r.jsx)(jH,{path:jI.cross,size:14})," ",jz.close]})]}),(0,r.jsx)("div",{style:{overflow:"auto",display:"grid",justifyItems:"center",alignItems:"start",padding:"0 20px 24px",...jB},children:(0,r.jsx)("img",{src:a,alt:b,onClick:a=>a.stopPropagation(),style:{display:"block",width:c?"min(100%, 420px)":void 0,maxWidth:"100%",borderRadius:8,border:`1px solid ${z.f.line}`,cursor:"default"}})})]}),document.body)}function j$({runId:a,blockId:b,label:c,view:d,pr:e,away:f=null,onClose:g,onSeeShip:h,onSettings:i,inline:j=!1}){let[k,l]=(0,s.useState)(void 0),[m,n]=(0,s.useState)(!1),o=d?.state==="running";(0,s.useEffect)(()=>{let c=!0,d=d=>fetch(`/api/runs/${a}/blocks/${encodeURIComponent(b)}`).then(a=>a.ok?a.json():null).then(a=>c&&(a||d)&&l(a)).catch(()=>c&&d&&l(null));d(!0);let e=o?setInterval(()=>void d(!1),4e3):null;return()=>{c=!1,e&&clearInterval(e)}},[a,b,o]),(0,s.useEffect)(()=>{if(j)return;let a=a=>{"Escape"===a.key&&g()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[g,j]);let p=d?.state??k?.state??"queued",q=A.f[(0,D.Y)(p)],u=k?.kind,v=(d?.summary||k?.summary)??null,w=k?.steps??[],x=m?w:w.slice(-8),y="ship"===u||"human"===u,B="human"===u&&"waiting_approval"!==p&&void 0!==h;return(0,r.jsx)("div",{onClick:j?void 0:g,style:j?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,r.jsxs)("div",{role:j?"region":"dialog","aria-modal":j?void 0:"true","aria-label":jz.title(c),"data-testid":"block-details",onClick:a=>a.stopPropagation(),style:{width:j?"100%":"min(920px, calc(100% - 32px))",height:j?void 0:"min(780px, calc(100% - 96px))",boxSizing:"border-box",display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",background:z.f.card,border:`1px solid ${z.f.line}`,borderTop:j?`1px solid ${z.f.line}`:`3px solid ${q}`,borderRadius:16,boxShadow:j?"none":"0 24px 60px rgba(0,0,0,0.6)",fontSize:j?15:14.5,...j?{"--thumb-w":"380px","--thumb-h":"236px"}:null},children:[(0,r.jsxs)("header",{style:{display:"flex",alignItems:"center",gap:14,padding:j?"26px 28px 0":"18px 26px",borderBottom:j?"none":`1px solid ${z.f.line}`},children:[u&&jC.includes(u)&&(0,r.jsx)(hT.f,{kind:u,colour:q,size:40}),(0,r.jsxs)("div",{style:{display:"grid",gap:4,flex:1,minWidth:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[(0,r.jsx)("h2",{className:"factory-display",style:{margin:0,fontSize:26},children:c}),k&&(0,r.jsx)("span",{style:{padding:"3px 11px",borderRadius:999,background:`${q}26`,color:q,fontSize:12.5,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase"},children:d?.turn?t.B.direct.yourTurn:t.B.canvas.stateLabel[p]})]}),u&&jz.purpose[u]&&(0,r.jsx)("span",{style:{fontSize:14,color:z.f.quiet},children:jz.purpose[u]})]}),i&&(0,r.jsxs)("button",{type:"button","data-testid":"details-settings",onClick:i,title:jz.settingsHelp,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"7px 12px",borderRadius:8,border:`1px solid ${z.f.line}`,background:"#141414",color:"#c9d0db",cursor:"pointer",font:"inherit",fontSize:13.5,whiteSpace:"nowrap"},children:[(0,r.jsx)(L,{size:14}),jz.settings]}),!j&&(0,r.jsx)("button",{type:"button","aria-label":jz.close,onClick:g,style:{background:"none",border:"none",color:A.f.skipped,cursor:"pointer",fontSize:18},children:"✕"})]}),(0,r.jsxs)("div",{style:{overflowY:"auto",padding:"22px 26px 28px",display:"grid",gap:26,alignContent:"start",...jB},children:[void 0===k&&(0,r.jsxs)("div",{role:"status","aria-label":jz.loading,"data-testid":"details-loading",style:{display:"grid",gap:26},children:[(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:10},children:[(0,r.jsx)(h6,{height:78,radius:12}),(0,r.jsx)(h6,{height:78,radius:12}),(0,r.jsx)(h6,{height:78,radius:12})]}),(0,r.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,r.jsx)(h6,{width:170,height:18}),(0,r.jsx)(h6,{height:58,radius:12})]}),(0,r.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,r.jsx)(h6,{width:210,height:18}),(0,r.jsx)(h6,{width:"72%",height:13}),(0,r.jsx)(h6,{width:"58%",height:13}),(0,r.jsx)(h6,{width:"64%",height:13})]}),(0,r.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,r.jsx)(h6,{width:150,height:18}),(0,r.jsx)(h6,{height:110,radius:10}),(0,r.jsx)(h6,{height:110,radius:10})]})]}),null===k&&(0,r.jsx)("div",{style:{color:z.f.quiet},children:jz.unreadable}),k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(170px, 1fr))",gap:10},children:[k.startedAt&&(0,r.jsx)(jJ,{icon:jI.clock,label:jz.took,value:null!==k.durationMs?jE(k.durationMs):jz.stillWorking}),k.startedAt&&(0,r.jsx)(jJ,{icon:jI.play,label:jz.started,value:jF(k.startedAt)}),k.startedAt&&k.finishedAt&&(0,r.jsx)(jJ,{icon:jI.flag,label:jz.finished,value:jF(k.finishedAt)}),null!==k.tokens&&(0,r.jsx)(jJ,{icon:jI.spark,label:jz.tokens,value:k.tokens.toLocaleString("en-US"),help:jz.tokensHelp}),k.model&&(0,r.jsx)(jJ,{icon:jI.chip,label:jz.model,value:k.model}),k.attempt>1&&(0,r.jsx)(jJ,{icon:jI.repeat,label:jz.attempts,value:k.attempt})]}),(0,r.jsxs)(jK,{title:jz.said,help:d?.summaryIsClaim?jz.saidByAi:void 0,children:[(0,r.jsx)("div",{"data-testid":"details-summary",style:{display:"grid",gap:10,padding:"14px 16px",borderRadius:12,background:"#141414",borderLeft:`3px solid ${q}`,fontSize:15.5,lineHeight:1.6,color:"#e6e9ef",overflowWrap:"anywhere"},children:v?(0,r.jsx)(jG,{text:v}):(0,r.jsx)("span",{style:{color:z.f.quiet},children:jz.nothingSaid})}),e&&"ship"===u&&(0,r.jsxs)("a",{href:e.url,target:"_blank",rel:"noreferrer",style:{justifySelf:"start",color:z.f.green,fontSize:14},children:[jz.seeOnGithub(e.number)," ↗"]})]}),k.asked&&k.asked.length>0&&(0,r.jsx)(jK,{title:jz.asked,help:k.asked.length>1?jz.askedHelp:void 0,children:(0,r.jsx)("ol",{"data-testid":"details-asked",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:k.asked.map((a,b)=>(0,r.jsxs)("li",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:12,padding:"12px 14px",borderRadius:10,background:"#141414",border:`1px solid ${z.f.line}`,fontSize:14.5,lineHeight:1.55,color:"#e6e9ef"},children:[(0,r.jsx)("span",{style:{color:A.f.passed,fontWeight:800},children:b+1}),(0,r.jsx)("span",{style:{overflowWrap:"anywhere",whiteSpace:"pre-wrap"},children:a})]},b))})}),B&&(0,r.jsx)(jK,{title:t.B.gate.changesTitle,children:(0,r.jsx)(i$,{runId:a,away:f,decided:!0})}),B&&(0,r.jsx)(jK,{title:jz.history,children:(0,r.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,r.jsx)("span",{children:jz.historyOnShip}),(0,r.jsxs)("button",{type:"button",onClick:h,style:{padding:"7px 14px",borderRadius:8,border:`1px solid ${z.f.line}`,background:"#141414",color:z.f.green,fontWeight:700,cursor:"pointer",font:"inherit"},children:[jz.historySeeOnShip," →"]})]})}),y&&!B&&((k.history?.length??0)>0?(0,r.jsx)(jX,{tasks:k.history,github:k.github}):(0,r.jsx)(jN,{runId:a})),"human"===u&&"waiting_approval"===p&&(0,r.jsx)(jK,{title:t.B.gate.changesTitle,children:(0,r.jsx)(i$,{runId:a,risk:d?.risk,away:f})}),(d?.planMeasure??k.planMeasure)&&(0,r.jsx)(jL,{measure:d?.planMeasure??k.planMeasure,startedOnItsOwn:d?.autoStarted===!0}),k.jobs.length>0&&(0,r.jsx)(jK,{title:jz.jobs(k.jobs.length),children:(0,r.jsx)("div",{style:{display:"grid",gap:10},children:k.jobs.map((a,b)=>(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:12,padding:"12px 14px",borderRadius:10,background:"#141414",border:`1px solid ${z.f.line}`},children:[(0,r.jsx)("span",{style:{width:26,height:26,borderRadius:999,display:"grid",placeItems:"center",background:A.f.tint("waiting",.18),color:A.f.waiting,fontSize:13,fontWeight:800},children:b+1}),(0,r.jsxs)("div",{style:{display:"grid",gap:6},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:600,color:"#e6e9ef",lineHeight:1.45},children:a.title}),a.done.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{style:{fontSize:12,letterSpacing:"0.06em",textTransform:"uppercase",color:A.f.skipped},children:jz.doneWhen}),a.done.map((a,b)=>(0,r.jsxs)("span",{style:{display:"flex",gap:8,fontSize:13.5,lineHeight:1.45,color:"#c9d0db"},children:[(0,r.jsx)("span",{style:{color:A.f.passed,marginTop:2},children:(0,r.jsx)(jH,{path:jI.check,size:13})}),a]},b))]})]})]},b))})}),k.commands.length>0&&(0,r.jsx)(jK,{title:jz.commands,children:(0,r.jsx)("div",{style:{display:"grid",gap:8},children:k.commands.map((a,b)=>(0,r.jsx)(jM,{c:a},b))})}),w.length>0&&(0,r.jsxs)(jK,{title:jz.steps(w.length),help:jz.stepsHelp,children:[(0,r.jsx)("ol",{"data-testid":"details-steps",style:{margin:0,padding:0,listStyle:"none",display:"grid"},children:x.map((a,b)=>{let c=/^Running:?\s/.test(a.text),d=b===x.length-1;return(0,r.jsxs)("li",{style:{display:"grid",gridTemplateColumns:"54px 18px minmax(0, 1fr)",columnGap:10,alignItems:"start"},children:[(0,r.jsx)("span",{style:{paddingTop:2,fontFamily:jA,fontSize:12,color:A.f.skipped,textAlign:"right"},children:function(a,b){let c=a?Date.parse(b)-Date.parse(a):0/0;if(!Number.isFinite(c))return"";let d=Math.max(0,Math.round(c/1e3));return`+${Math.floor(d/60)}:${String(d%60).padStart(2,"0")}`}(k.startedAt,a.at)}),(0,r.jsxs)("span",{"aria-hidden":"true",style:{display:"grid",justifyItems:"center",alignSelf:"stretch",gridTemplateRows:"auto 1fr"},children:[(0,r.jsx)("span",{style:{width:9,height:9,marginTop:6,borderRadius:999,background:d?q:A.f.skipped}}),!d&&(0,r.jsx)("span",{style:{width:2,minHeight:14,background:z.f.line}})]}),(0,r.jsx)("span",{style:{paddingBottom:12,fontSize:14,lineHeight:1.5,color:"#d6dce6",overflowWrap:"anywhere",...c?{fontFamily:jA,fontSize:12.5}:{}},children:a.text})]},b)})}),w.length>8&&(0,r.jsx)("button",{type:"button",onClick:()=>n(a=>!a),style:{justifySelf:"start",padding:"6px 12px",borderRadius:8,border:`1px solid ${z.f.line}`,background:"#141414",color:"#e6e9ef",fontSize:13,fontWeight:600,cursor:"pointer"},children:m?jz.showFewer:jz.showAll(w.length)})]})]})]})]})})}let j_={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:[]},j0=[1e3,2e3,5e3],j1={"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"},j2={nodes:{},lastSequence:0},j3=a=>"string"==typeof a&&""!==a.trim()?a:void 0,j4=a=>"number"==typeof a&&Number.isInteger(a)&&a>=0?a:null,j5=new Set(["input","plan","build","tests","review","approve","human","ship"]);function j6(a){return{...a.round?{round:a.round}:{},...a.asking?{asking:!0}:{},...a.planMeasure?{planMeasure:a.planMeasure}:{},...a.autoStarted?{autoStarted:!0}:{},...a.evidence?{evidence:a.evidence}:{},...a.risk?{risk:a.risk}:{},...void 0!==a.tokens?{usage:{tokens:a.tokens,costCents:null}}:{}}}let j7=new Set([t.B.run.notYet.plan,t.B.run.notYet.review]),j8=a=>"skipped"===a.state&&void 0!==a.skippedReason&&j7.has(a.skippedReason);function j9(a,b=[],c,d){let e={};for(let[c,d]of Object.entries(a)){let a=b.find(a=>a.id===c)?.kind;if(void 0===a||!j5.has(a)){e[c]={blockId:c,state:d.state,summary:t.B.summary.generic[d.state],summaryIsClaim:!1,steps:d.steps,...j6(d)};continue}let f="failed"===d.state,g={kind:a,state:d.state,claim:f?d.failureMessage:d.reportedSummary,claimSource:f?d.failureSource:d.claimSource,cause:f?d.failureCause:void 0,skippedReason:d.skippedReason,counts:d.evidence?.counts??void 0};e[c]={blockId:c,state:d.state,summary:al(g),summaryIsClaim:am(g),steps:d.steps,...j6(d),...j8(d)?{notBuilt:!0}:{}}}if(c)for(let a of b.filter(a=>"ship"===a.kind))e[a.id]=c.merged?{blockId:a.id,state:"passed",summary:t.B.summary.mergedVia(c.pr??null),summaryIsClaim:!1,steps:[]}:void 0!==c.pr?{blockId:a.id,state:"waiting_approval",summary:t.B.summary.prOpen(c.pr),summaryIsClaim:!1,steps:[]}:{blockId:a.id,state:"passed",summary:t.B.summary.shippedTo(c.branch),summaryIsClaim:!1,steps:[]};if(!c)for(let a of b.filter(a=>"ship"===a.kind)){let b=e[a.id];b?.state==="skipped"&&(e[a.id]=d?{...b,state:"cancelled",summary:t.B.summary.thrownAway}:{...b,waitingForYou:!0})}return e}let ka={"run.created":"queued","run.started":"running","run.waiting_approval":"waiting_approval","run.completed":"completed","run.failed":"failed","run.cancelled":"cancelled"},kb=new Set(["completed","failed","cancelled"]),kc={events:[],runStatus:null},kd=a=>({runId:a,stream:j2,log:kc});function ke(a,b){var c,d,e;let f;if("reset"===b.type)return kd(b.runId);let g=a.runId===b.runId?a:kd(b.runId);return{runId:b.runId,stream:function(a,b){var c;if(b.sequence<=a.lastSequence)return a;let d={...a,lastSequence:b.sequence},e=b.payload??{};if("run.snapshots"===b.type){let a=j3(e.change);return void 0!==a&&Array.isArray(e.shots)&&e.shots.length>0?{...d,pictured:a}:d}if("run.pushed"===b.type){let b=j3(e.branch);return void 0===b?d:{...d,shipped:{...a.shipped,branch:b}}}if("run.pr_opened"===b.type&&"number"==typeof e.number)return{...d,shipped:{branch:a.shipped?.branch??"",...a.shipped,pr:e.number}};if("run.merged"===b.type)return{...d,shipped:{branch:a.shipped?.branch??"",...a.shipped,merged:!0}};if("run.thrown_away"===b.type)return{...d,thrownAway:!0};let f=j3(e.blockId);if(void 0===f)return d;let g=a.nodes[f];if("node.plan_decided"===b.type)return{...d,planBlocks:[...new Set([...a.planBlocks??[],f])]};if("node.step"===b.type){let c=j3(e.text);return g&&void 0!==c?{...a,nodes:{...a.nodes,[f]:{...g,steps:[...g.steps,c]}},lastSequence:b.sequence}:d}if("node.evidence"===b.type){let c=function(a){let b=j4(a.durationMs);if(null===b)return;let c="number"==typeof a.exitCode&&Number.isInteger(a.exitCode)?a.exitCode:null,d=a.counts,e=j4(d?.passed),f=j4(d?.failed),g=j4(d?.total),h="string"==typeof a.signal?a.signal:null,i=Array.isArray(a.changedTestFiles)?a.changedTestFiles.filter(a=>"string"==typeof a):null,j=null===i?null:Math.max(j4(a.changedTestFilesCount)??0,i.length);return{counts:null!==e&&null!==f&&null!==g&&e+f<=g?{passed:e,failed:f,total:g}:null,exitCode:c,signal:h,durationMs:b,changedTestFiles:i,changedTestFilesCount:j}}(e);return g&&c?{...a,nodes:{...a.nodes,[f]:{...g,evidence:c}},lastSequence:b.sequence}:d}if("node.reopened"===b.type){if(!g)return d;let c="number"==typeof e.asked?e.asked:"fixes"===e.by?g.round:e.round,h=`${String(e.by)}-${String(e.round)}`,i="fixes"!==e.by&&"reviewer"!==e.by&&void 0!==j3(e.note)&&!a.planBlocks?.includes(f)&&!a.kept?.includes(h);return{...a,nodes:{...a.nodes,[f]:{state:"queued",steps:[],round:"number"==typeof c&&c>1?c:void 0}},lastSequence:b.sequence,...i?{earlier:[...a.earlier??[],{nodes:a.nodes,change:a.pictured}],pictured:void 0,kept:[...a.kept??[],h],reopened:[f]}:{reopened:[...new Set([...a.reopened??[],f])]}}}if("node.assessed"===b.type){let c="low"===e.level||"high"===e.level?e.level:void 0,h=Array.isArray(e.reasons)?e.reasons.filter(a=>"string"==typeof a):[];return g&&c?{...a,nodes:{...a.nodes,[f]:{...g,risk:{level:c,reasons:h,...!0===e.stopForMe?{stopForMe:!0}:{}}}},lastSequence:b.sequence}:d}if("node.plan_measured"===b.type){if(!g)return d;let c=a=>Array.isArray(a)?a.filter(a=>"string"==typeof a):[],h=e.question?.text,i="string"==typeof h&&""!==h.trim()?h:void 0;return{...a,nodes:{...a.nodes,[f]:{...g,planMeasure:{simple:!0===e.simple,reasons:c(e.reasons),entries:c(e.entries),...i?{question:i}:{}}}},lastSequence:b.sequence}}let h=j1[b.type];if(void 0===h||g&&g.state!==h&&(c=g.state,!j_[c].includes(h)))return d;let i={...g,state:h,steps:g?.steps??[]};return"node.question_asked"===b.type?i.asking=!0:delete i.asking,delete i.autoStarted,"node.completed"===b.type&&!0===e.autoStarted&&(i.autoStarted=!0),"node.waiting_approval"===b.type&&"string"==typeof e.summary&&(i.reportedSummary=j3(e.summary),i.claimSource="string"==typeof e.summarySource?e.summarySource:void 0),"queued"===h&&(i.reportedSummary=void 0),"node.completed"===b.type&&(i.reportedSummary=j3(e.summary),i.claimSource="string"==typeof e.summarySource?e.summarySource:void 0,"tokens"in e&&(i.tokens="number"==typeof e.tokens?e.tokens:null)),"node.failed"===b.type&&(i.failureCause=j3(e.cause),i.failureMessage=j3(e.message),i.failureSource="string"==typeof e.messageSource?e.messageSource:void 0),"node.skipped"===b.type&&(i.skippedReason=j3(e.reason)),{...a,nodes:{...a.nodes,[f]:i},lastSequence:b.sequence}}(g.stream,b.event),log:(c=g.log,d=b.event,c.events.length>0&&d.sequence<=c.events[c.events.length-1].sequence?c:{events:[...c.events,d].slice(-300),runStatus:(e=c.runStatus,void 0===(f=ka[d.type])||null!==e&&kb.has(e)?e:f)})}}let kf=()=>()=>void 0,kg=new Set(["queued","running","waiting_approval"]),kh={padding:"6px 14px",background:A.f.card,color:"inherit",border:`1px solid ${A.f.border}`,borderRadius:6,cursor:"pointer"};async function ki(a,b){let c=await a.json().catch(()=>null);return"string"==typeof c?.error?c.error:b}let kj=ah.R.filter(a=>a.ready).map(a=>({id:a.id,name:a.name}));a.s(["CanvasScreen",0,function({workflowId:a,graph:b,run:c=null,settings:d=null,draftUpdatedAt:e,localData:f=!1,noTasksYet:g=!1,account:h,ais:i=kj,ai:j=ah.b,installedAis:k}){var l;let[m,n]=(0,s.useState)(c),[o,p]=(0,s.useState)(d),[q,z]=(0,s.useState)(null),B=q??(d?.repoPath?j:ai.C),E=m?.providerId??B,F=(0,s.useMemo)(()=>k?new Set(k):null,[k]),G=(0,s.useCallback)((a,b,c)=>(0,ah.p)((0,ah.t)(E,c,b),a,b),[E]),M=(0,s.useCallback)((a,b)=>(0,ah.y)(E)&&ah.o.has(b)?(0,ah.j)((0,ah.t)(E,a,b))??null:null,[E]),N=B!==ai.C&&!o?.repoPath,[O,P]=(0,s.useState)(null),Q=(0,s.useSyncExternalStore)(kf,()=>{try{return window.sessionStorage.getItem((0,K.V)(a))}catch{return null}},()=>null),R=O??Q??"",S=b=>{try{window.sessionStorage.removeItem((0,K.V)(a))}catch{}P(b)},[W,X]=(0,s.useState)([]),[Y,Z]=(0,s.useState)(!1),[$,_]=(0,s.useState)(""),aa=()=>{S(""),X(a=>{for(let b of a)URL.revokeObjectURL(b.previewUrl);return[]})},[ab,ac]=(0,s.useState)(!1),[ad,ae]=(0,s.useState)(null),[af,aj]=(0,s.useState)(null),ak=(0,s.useRef)(null),al=(0,s.useRef)(null);async function am(a){let b=await fetch(`/api/runs/${a}`);if(!b.ok)return ae(await ki(b,t.B.run.startFailed));aj(null),n(await b.json())}let an=`factory.direct.${a}`,ao=(0,s.useSyncExternalStore)(kf,()=>{try{return"1"===window.localStorage.getItem(an)}catch{return!1}},()=>!1),[ap,aq]=(0,s.useState)(null),ar=a=>{aq(a);try{window.localStorage.setItem(an,a?"1":"0")}catch{}},[as,at]=(0,s.useState)(null),{views:au,rounds:aw,events:ax,runStatus:ay,connected:az,loaded:aB,reopen:aC}=function(a,b){let[c,d]=(0,s.useReducer)(ke,null,()=>kd(a)),{stream:e,log:f}=c.runId===a?c:kd(a),[g,h]=(0,s.useReducer)((a,b)=>b,!1),i=(0,s.useRef)(0),j=(0,s.useRef)(null),k=(0,s.useCallback)(()=>j.current?.(),[]),[l,m]=(0,s.useReducer)((a,b)=>b,null);return(0,s.useEffect)(()=>{let b,c;if(i.current=0,d({type:"reset",runId:a}),null===a)return void h(!1);let e=0,f=!1,g=!1,k=()=>{let j=new EventSource(`/api/runs/${encodeURIComponent(a)}/events?after=${i.current}`);b=j,"function"==typeof j.addEventListener?(j.addEventListener("caughtup",()=>m(a)),j.addEventListener("end",()=>{g=!0,j.close()})):m(a),j.onopen=()=>{e=0,h(!0)},j.onmessage=b=>{let c;try{c=JSON.parse(b.data)}catch{return}"number"!=typeof c.sequence||c.sequence<=i.current||(i.current=c.sequence,d({type:"event",runId:a,event:c}))},j.onerror=()=>{if(j.close(),h(!1),f||g||l())return;let a=j0[Math.min(e,j0.length-1)];e++,c=setTimeout(k,a)}},l=()=>"u">typeof document&&"hidden"===document.visibilityState,n=()=>{l()?(clearTimeout(c),b?.close(),h(!1)):f||g||(b?.close(),k())};"u">typeof document&&document.addEventListener("visibilitychange",n),j.current=()=>{!f&&g&&(g=!1,k())},k();let o=setTimeout(()=>m(a),2500);return()=>{f=!0,"u">typeof document&&document.removeEventListener("visibilitychange",n),clearTimeout(o),clearTimeout(c),b?.close()}},[a]),{views:(0,s.useMemo)(()=>j9(e.nodes,b,e.shipped,e.thrownAway),[e.nodes,b,e.shipped,e.thrownAway]),rounds:(0,s.useMemo)(()=>({earlier:(e.earlier??[]).map(a=>({views:j9(a.nodes,b),change:a.change})),reopened:e.reopened??[]}),[e.earlier,e.reopened,b]),lastSequence:e.lastSequence,connected:g,events:f.events,runStatus:f.runStatus,loaded:null!==a&&l===a,reopen:k}}(m?.runId??null,m?.blocks),aD=!!m&&ax.some(a=>"run.created"===a.type&&a.payload?.direct===!0),aE=(ap??ao)||aD&&as!==m?.runId,aF=(0,s.useRef)(e),aG=(0,s.useRef)(Promise.resolve()),aH=(0,s.useRef)(!1),[aI,aJ]=(0,s.useState)(null),aK=[...new Set([o?.defaultBranch,o?.currentBranch].filter(a=>!!a))],aL=null!==aI&&aK.includes(aI)?aI:aK[0]??null,[aM,aN]=(0,s.useState)(!1),[aO,aP]=hS("factory.view.conversation",!1),[aQ,aR]=(0,s.useState)(null),aS=m?.runId??null,aT=(0,s.useCallback)(a=>aS&&aR({runId:aS,state:a}),[aS]),aU=m?.blocks.find(a=>"ship"===a.kind),[aV,aW]=(0,s.useState)(null),aX=ax.some(a=>"run.pr_opened"===a.type),aY=aQ?.runId===aS;(0,s.useEffect)(()=>{if(!aB||!aS||!aX||aY)return;let a=!0;return fetch(`/api/runs/${aS}/ship`).then(a=>a.ok?a.json():null).then(b=>a&&b&&aR({runId:aS,state:b})).catch(()=>void 0),()=>{a=!1}},[aB,aS,aX,aY]);let aZ=aB&&(!aX||aY);(0,s.useEffect)(()=>{if(!aB||!aS)return;let a=setTimeout(()=>aW(aS),aZ?250:4e3);return()=>clearTimeout(a)},[aB,aZ,aS]);let a$=!!m&&aV!==m.runId,a_=(0,J.O)(aS,`${ax.filter(a=>"node.reopened"===a.type||"node.plan_decided"===a.type||"node.question_answered"===a.type).length}-${ay??""}`),a0=function(a){for(let b=a.length-1;b>=0;b--)if(jx.has(a[b].type))return a[b].sequence;return 0}(ax),{record:a1,readMark:a2,failed:a3,reload:a4}=function(a,b){let[c,d]=(0,s.useState)(null),[e,f]=(0,s.useState)(null),[g,h]=(0,s.useState)(0);(0,s.useEffect)(()=>{if(!a)return;let c=!0;return fetch(`/api/runs/${encodeURIComponent(a)}/findings`).then(a=>a.ok?a.json():Promise.reject(Error(String(a.status)))).then(e=>{c&&(d({runId:a,record:e,mark:b}),f(null))}).catch(()=>c&&f(a)),()=>{c=!1}},[a,b,g]);let i=(0,s.useCallback)(()=>h(a=>a+1),[]);return{record:c&&c.runId===a?c.record:null,readMark:c&&c.runId===a?c.mark:-1,failed:e===a,reload:i}}(aS,a0),a5=a=>{if(!m||!aD)return a;let b={...a};for(let a of m.blocks){let c=b[a.id];"build"===a.kind&&c?.state==="waiting_approval"&&(b[a.id]={...c,turn:!0,summary:t.B.direct.turnSummary})}return b},a6=a=>{if(!m||0===a_.length)return a;let b={...a};for(let a of["input","plan","build","review","human"]){let c=m.blocks.find(b=>b.kind===a&&b.enabled),d=a_.filter(b=>(0,J.B)(b)===a||"input"===a&&"changes"===b.kind);c&&b[c.id]&&d.length>0&&(b[c.id]={...b[c.id],asked:d})}return b},a7=aQ&&aQ.runId===aS&&aU?function(a,b){if(!b.pr)return null;let c=t.B.ship,d=[c.stepPushed,c.stepPr(b.pr.number),...b.checks.map(a=>`${a.name}: ${c.checkState[a.state]}`)],e={blockId:a,summaryIsClaim:!1,steps:d};if("closed"===b.pr.state)return{...e,state:"cancelled",summary:c.closed};if("open"===b.pr.state){if(b.pr.conflicts)return{...e,state:"failed",summary:c.conflicts};if(b.checksFailed)return{...e,state:"failed",summary:c.someFailed};if(!b.checksDone){let a=b.checks.filter(a=>"pending"!==a.state).length;return{...e,state:"running",summary:0===b.checks.length?c.cardLooking:c.cardChecking(a,b.checks.length)}}return{...e,state:"waiting_approval",summary:b.onHold?c.cardOnHold:c.cardReady}}let f=[...d,b.deployPending?c.stepMerged:c.merged,...b.deploy.map(a=>`${a.name}: ${c.checkState[a.state]}`)];return b.deploy.some(a=>"failed"===a.state)?{...e,steps:f,state:"failed",summary:c.deployFailed}:b.deployPending||b.deploy.some(a=>"pending"===a.state)?{...e,steps:f,state:"running",summary:c.cardDeploying}:{...e,steps:f,state:"passed",summary:b.deploy.length>0?c.cardLive:c.merged}}(aU.id,aQ.state):null,a8=a7&&aU?{...au,[aU.id]:a7}:au,a9=Object.values(au).some(a=>a.risk)&&aS&&aU&&a8[aU.id]?{...a8,[aU.id]:{...a8[aU.id],results:aS}}:a8,ba=(0,s.useCallback)(()=>aN(!1),[]);async function bb(){ac(!0),ae(null);try{if(ak.current&&!await ak.current())return ae(t.B.run.saveFirst);let b=await fetch(`/api/workflows/${a}/publish`,{method:"POST"});if(!b.ok)return ae(400===b.status?t.B.run.fixFirst:await ki(b,t.B.run.startFailed));let c=await fetch(`/api/workflows/${a}/runs`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({request:R,provider:B,attachments:iH(W),...Y?{stopForMe:!0}:{},...aE&&B!==ai.C?{direct:!0}:{},...$.trim()?{title:$.trim()}:{},...B!==ai.C&&aL?{startFrom:aL}:{}})});if(!c.ok)return ae(await ki(c,t.B.run.startFailed));let{runId:d}=await c.json(),e=await fetch(`/api/runs/${d}`);if(!e.ok)return ae(await ki(e,t.B.run.startFailed));aj(null),n(await e.json()),aa(),Z(!1),_("")}catch{ae(t.B.run.startFailed)}finally{ac(!1)}}let[bc,bd]=(0,s.useState)("none"),[be,bf]=(0,s.useState)(g?0:null),[bg,bh]=(0,s.useState)(0),bi=null===m&&0!==be&&"new"!==bc,bj=o?.projectId,bk=(0,s.useCallback)(()=>{bj&&fetch(`/api/projects/${bj}`).then(a=>a.ok?a.json():null).then(a=>a&&p(a)).catch(()=>void 0)},[bj]),bl=o?.suggestedTestCommand??null,bm=(0,s.useSyncExternalStore)(kf,()=>{try{return bj?localStorage.getItem(`factory.testSuggestion.${bj}`):null}catch{return null}},()=>null),[bn,bo]=(0,s.useState)(null),[bp,bq]=(0,s.useState)(!1),[br,bs]=(0,s.useState)(!1);async function bt(){if(bl&&bj){bq(!0),bs(!1);try{let a=await fetch(`/api/projects/${bj}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({testCommand:bl})}),b=await a.json().catch(()=>null);if(!a.ok||!b)return bs(!0);p(b)}catch{bs(!0)}finally{bq(!1)}}}function bu(a="new"){aE&&ar(!0),bd(a),n(null),aJ(null),aj(null),ae(null),aa(),bk(),"new"===a&&requestAnimationFrame(()=>document.getElementById(ik)?.focus())}async function bv(){if(m){ae(null);try{let a=await fetch(`/api/runs/${m.runId}/cancel`,{method:"POST"});a.ok||ae(await ki(a,t.B.run.cancelFailed))}catch{ae(t.B.run.cancelFailed)}}}let bw=null!==ay&&kg.has(ay),bx="completed"===ay||"failed"===ay||"cancelled"===ay,by=!!m&&m.blocks.some(a=>au[a.id]?.asking===!0&&au[a.id]?.state==="waiting_approval"),bz=null===m?null:null!==ay?bx?t.B.run.lastRun(t.B.run.status[ay]):"waiting_approval"===ay&&by?t.B.question.stateLabel:t.B.run.status[ay]:az?null:t.B.run.connecting,bA=!ab&&!bw&&""!==R.trim()&&!N&&!iI(W),[bB,bC]=(0,s.useState)(!1),bD=(0,s.useRef)(null),[bE,bF]=(0,s.useState)(null),[bG,bH]=(0,s.useState)(null),bI=m?.blocks.find(a=>"human"===a.kind),bJ=aU?a9[aU.id]?.state:void 0,bK=aU&&bJ&&"queued"!==bJ&&"skipped"!==bJ?aU.id:null,bL=m?.blocks.find(a=>"plan"===a.kind),bM=!!m&&m.blocks.some(a=>"plan"===a.kind&&au[a.id]?.state==="waiting_approval"&&au[a.id]?.asking!==!0),bN=!!m&&m.providerId!==ai.C&&m.blocks.some(a=>"review"===a.kind&&a.enabled&&au[a.id]?.state==="passed"),bO=m&&"waiting_approval"===ay&&by?"question":m&&"waiting_approval"===ay&&bM?"plan":m&&"waiting_approval"===ay?"waiting":m&&("running"===ay||"queued"===ay)?"working":m&&"completed"===ay&&m.providerId!==ai.C?"done":m&&"failed"===ay&&m.providerId!==ai.C?"failed":"idle",bP=aQ&&aQ.runId===aS?aQ.state:null,bQ=y(bP)&&!bP?.onHold,bR=function(a,b){let c=(0,s.useRef)(null),[d,e]=(0,s.useState)(null),f=b?.pr?.state==="merged"&&!0!==b.deployPending,g=null!==b;return(0,s.useEffect)(()=>{if(!a||!g)return;let b=c.current;if(c.current={runId:a,published:f},b?.runId!==a||b.published||!f)return;let d=setTimeout(()=>e(a),0),h=setTimeout(()=>e(null),3200);return()=>{clearTimeout(d),clearTimeout(h)}},[a,g,f]),null!==d&&d===a}(aS,bP),bS="plan"===bO||"question"===bO||"waiting"===bO?"answer":"done"===bO&&bQ?"publish":null,{offer:bT,allow:bU}=function({attention:a,waitingCount:b,taskTitle:c,askKey:d=null}){var e;let f="granted"===(e=(0,s.useSyncExternalStore)(w,x,()=>null))?"on":"denied"===e?"blocked":"default"===e?"ask":"none",[,g]=(0,s.useState)(0);(0,s.useEffect)(()=>{if("u">typeof document){var c;let d;document.title=(c="publish"===a,d=b>0?t.B.tell.waitingTitle(b):c?t.B.tell.readyTitle:null,t.B.tell.tabTitle(d))}},[b,a]),(0,s.useEffect)(()=>()=>{"u">typeof document&&(document.title=t.B.app.name)},[]);let h=(0,s.useRef)(new Set);return(0,s.useEffect)(()=>{if(!a)return;let b=`${a}|${d??""}`;if(!h.current.has(b)){h.current.add(b);try{if("u"<typeof document||!document.hidden||"granted"!==x())return;new Notification("answer"===a?t.B.tell.needsAnswer:t.B.tell.readyToPublish,{body:c??""})}catch{}}},[a,d]),{offer:f,allow:(0,s.useCallback)(()=>{try{if(null===x())return;Promise.resolve(Notification.requestPermission()).then(()=>g(a=>a+1)).catch(()=>void 0)}catch{}},[])}}({attention:bS,waitingCount:Math.max(bg,+("answer"===bS)),taskTitle:m?.title??null,askKey:m?`${m.runId}:${bO}:${jy(ax)??""}`:null}),bV=(0,r.jsxs)("button",{type:"button","aria-expanded":aM,onClick:()=>aN(a=>!a),style:{...kh,marginLeft:o?.repoPath?0:"auto",fontWeight:600,display:"inline-flex",alignItems:"center",gap:8},children:[(0,r.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,r.jsx)("path",{d:"M5 7h14M5 12h14M5 17h14"})}),t.B.history.open,(be??0)>0&&(0,r.jsx)("span",{style:{padding:"1px 8px",borderRadius:999,background:A.f.border,fontSize:12},children:be})]}),bW=aO&&!aE&&null!==m&&!a$,bX=(0,r.jsx)(jr,{docked:!0,direct:aE&&B!==ai.C,ref:al,mode:bO,runId:m?.runId??null,risk:Object.values(au).find(a=>"waiting_approval"===a.state)?.risk,planMeasure:bL?au[bL.id]?.planMeasure:void 0,stopForMe:Y,onStopForMe:Z,text:R,onText:S,images:W,onImages:X,onRun:()=>void bb(),canRun:bA,onFollowUp:a=>void am(a),onNewTask:()=>bu("new"),onShipState:aT,onSent:aa,startOptions:B!==ai.C?aK:[],startFrom:aI,onStartFrom:aJ,onRecorded:()=>{aC(),bk()},away:m&&!1===m.here?{machine:m.machine??null}:null,taskName:$,onTaskName:_,loading:a$,failureActions:bD,onCanContinue:a=>bF(a&&m?m.runId:null),onSeeChanges:bI?()=>bH(bI.id):void 0,record:a1,recordFailed:a3,recordMark:a0,recordReadMark:a2,askedId:jy(ax),onRecordChanged:a4,showFindings:bN,notice:{offer:bT,onAllow:bU}},`${m?.runId??"none"}-${a$?"loading":bO}`);return(0,r.jsxs)("div",{style:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,r.jsxs)("header",{style:{display:"flex",alignItems:"center",gap:12,padding:"8px 12px",minHeight:36,borderBottom:`1px solid ${A.f.border}`,background:A.f.bg},children:[(0,r.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:A.f.dim,whiteSpace:"nowrap"},children:[(0,r.jsx)("span",{style:{color:"#e8eaf0",display:"flex"},children:(0,r.jsx)(aA.f,{size:22})}),t.B.app.name]}),h&&(0,r.jsx)(V.f,{account:h,style:kh}),(0,r.jsx)(T,{workflowId:a,style:kh,onOpenSettings:o?()=>bC(!0):void 0}),f&&(0,r.jsxs)("span",{"data-testid":"local-data",title:t.B.localData.hint,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:999,border:`1px solid ${A.f.waiting}`,color:A.f.waiting,fontSize:12,fontWeight:700,whiteSpace:"nowrap",cursor:"help"},children:[(0,r.jsx)("span",{"aria-hidden":!0,style:{width:7,height:7,borderRadius:"50%",background:A.f.waiting}}),t.B.localData.label]}),o&&(0,r.jsx)("button",{type:"button","aria-label":t.B.projectSettings.open,title:t.B.projectSettings.open,onClick:()=>bC(!0),style:{...kh,padding:"6px 9px",display:"grid",placeItems:"center"},children:(0,r.jsx)(L,{size:17})}),bB&&o&&(0,r.jsx)(ag,{settings:o,onClose:()=>bC(!1),onSaved:p}),o&&(0,r.jsx)(hF.g.Provider,{value:F,children:(0,r.jsx)(hF.T,{value:B,ais:i,disabled:bw,style:{...kh,padding:"6px 10px"},onChange:a=>{z(a),a!==ai.C&&fetch("/api/account/ai",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({ai:a})}).catch(()=>void 0)}})}),!aE&&(0,r.jsx)("button",{type:"button",disabled:!bA,title:N?t.B.settings.needsRepo:""===R.trim()?t.B.run.writeFirst:void 0,onClick:bb,style:{...kh,fontWeight:600,background:bA?A.f.running:A.f.card,borderColor:bA?A.f.running:A.f.border,color:bA?"#fff":A.f.skipped,cursor:bA?"pointer":"not-allowed"},children:ab?t.B.run.starting:t.B.run.run}),N&&(0,r.jsx)("button",{type:"button",onClick:()=>bC(!0),style:{background:"none",border:"none",padding:0,fontSize:12.5,color:A.f.waiting,cursor:"pointer",textDecoration:"underline"},children:t.B.settings.needsRepo}),(!aE||bw)&&(0,r.jsx)("button",{type:"button",style:kh,disabled:!bw,onClick:bv,children:t.B.run.cancel}),m&&!bw&&(0,r.jsxs)("button",{type:"button",style:{...kh,fontWeight:700,background:A.f.passed,borderColor:A.f.passed,color:"#0d1f12"},onClick:()=>bu("new"),children:["+ ",t.B.delivery.newTask]}),(0,r.jsx)("span",{"aria-hidden":"true",style:{flex:1}}),m?.providerId===ai.C&&(0,r.jsx)("span",{title:t.B.run.demoTitle,style:{padding:"2px 8px",border:`1px solid ${A.f.waiting}`,color:A.f.waiting,borderRadius:999,fontSize:12,fontWeight:600},children:t.B.run.demoBadge}),bz&&"waiting_approval"===ay?(0,r.jsxs)("button",{type:"button","data-testid":"run-status",title:t.B.gate.goToGate,onClick:()=>{let a=m?.blocks.find(a=>au[a.id]?.state==="waiting_approval");a&&aj(a.id),al.current?.focus(),al.current?.scrollIntoView?.({block:"nearest"})},style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",background:A.f.tint("waiting",.12),color:A.f.waiting,border:`1px solid ${A.f.tint("waiting",.5)}`,borderRadius:999,fontSize:13,fontWeight:600,cursor:"pointer"},children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠"}),bz]}):bz&&"completed"===ay&&m&&m.providerId!==ai.C?(0,r.jsxs)("button",{type:"button","data-testid":"run-status",title:t.B.delivery.title,onClick:()=>{al.current?.focus(),al.current?.scrollIntoView?.({block:"nearest"})},style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",background:A.f.tint("passed",.12),color:A.f.passed,border:`1px solid ${A.f.tint("passed",.5)}`,borderRadius:999,fontSize:13,fontWeight:600,cursor:"pointer"},children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✓"}),bz]}):bz&&(0,r.jsxs)("span",{"data-testid":"run-status",role:"status",style:{display:"flex",alignItems:"center",gap:7,color:ay?A.f["running"===(l=ay)?"running":"completed"===l?"passed":"failed"===l?"failed":"waiting_approval"===l?"waiting":"skipped"]:A.f.skipped,fontSize:13},children:["running"===ay&&(0,r.jsx)(D.m,{blockId:"run",size:14}),bz]}),o?.repoPath&&(0,r.jsxs)("button",{type:"button","data-testid":"direct-edit-toggle","aria-pressed":aE,title:t.B.direct.hint,onClick:()=>{ar(!aE),at(aE?m?.runId??null:null)},style:{...kh,marginLeft:"auto",fontWeight:600,display:"inline-flex",alignItems:"center",gap:8,...aE?{border:`1px solid ${A.f.passed}`,color:A.f.passed}:{}},children:[(0,r.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,r.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),(0,r.jsx)("path",{d:"M10 4v16"})]}),aE?t.B.direct.off:t.B.direct.on]}),bV,h&&(0,r.jsx)(U.P,{person:h.person})]}),bl&&(bn??bm)!==bl&&(0,r.jsxs)("div",{"data-testid":"test-suggestion",role:"status",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,padding:"8px 14px",borderBottom:`1px solid ${A.f.border}`,background:"rgba(121, 220, 139, 0.07)",fontSize:13},children:[(0,r.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:A.f.passed,strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})}),(0,r.jsx)("span",{children:br?t.B.testSuggestion.failed:t.B.testSuggestion.text(bl)}),(0,r.jsx)("button",{type:"button",disabled:bp,onClick:()=>void bt(),style:{padding:"5px 12px",borderRadius:6,border:`1px solid ${A.f.passed}`,background:A.f.passed,color:"#07110a",fontWeight:700,cursor:bp?"wait":"pointer"},children:t.B.testSuggestion.accept}),(0,r.jsx)("button",{type:"button",disabled:bp,onClick:function(){if(bl&&bj){bo(bl);try{localStorage.setItem(`factory.testSuggestion.${bj}`,bl)}catch{}}},style:{...kh,padding:"5px 12px"},children:t.B.testSuggestion.dismiss})]}),(0,r.jsxs)("div",{style:{flex:1,minHeight:0,position:"relative",overflow:"clip"},children:[null===m&&!(aE&&(be??0)>0&&"new"===bc)&&(0,r.jsx)("div",{"data-testid":"no-task",role:"region","aria-label":0===be?t.B.history.firstTaskTitle:t.B.history.noTaskTitle,style:{position:"absolute",top:bi?"50%":64,left:"50%",transform:bi?"translate(-50%, -60%)":"translateX(-50%)",zIndex:4,width:bi?"min(520px, calc(100% - 32px))":"min(440px, calc(100% - 32px))",display:"grid",gap:bi?12:8,padding:bi?"28px 28px 26px":"16px 18px",background:A.f.card,border:`1px solid ${A.f.border}`,borderRadius:12,boxShadow:"0 12px 30px rgba(0,0,0,0.4)",textAlign:"center"},children:0===be?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{className:"factory-display",style:{fontSize:19},children:t.B.history.firstTaskTitle}),(0,r.jsx)("span",{style:{fontSize:13,color:A.f.dim,lineHeight:1.5},children:t.B.history.firstTaskText}),(0,r.jsxs)("button",{type:"button",onClick:()=>{let a=document.querySelector('[data-testid="command-card"]');a?.querySelector("textarea")?.focus(),a?.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:A.f.running,color:"#fff",fontWeight:700,cursor:"pointer"},children:[(0,r.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,r.jsx)("path",{d:"M12 5v14M5 12h14"})}),t.B.history.firstTaskAction]})]}):"new"===bc?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{style:{fontSize:15},children:t.B.history.newTaskTitle}),(0,r.jsx)("span",{style:{fontSize:12.5,color:A.f.dim,lineHeight:1.45},children:t.B.history.newTaskText})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{className:"factory-display",style:{fontSize:24},children:t.B.history.noTaskTitle}),(0,r.jsx)("span",{style:{fontSize:14.5,color:A.f.dim,lineHeight:1.5},children:t.B.history.noTaskText}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"center",gap:10,flexWrap:"wrap",marginTop:6},children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{bd("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:A.f.running,color:"#fff",fontSize:14.5,fontWeight:700,cursor:"pointer"},children:[(0,r.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,r.jsx)("path",{d:"M12 5v14M5 12h14"})}),t.B.history.createOne]}),(0,r.jsxs)("button",{type:"button",onClick:()=>aN(!0),style:{display:"inline-flex",alignItems:"center",gap:8,padding:"10px 20px",borderRadius:8,border:`1px solid ${A.f.border}`,background:"#0f141c",color:"#e6e9ef",fontSize:14.5,fontWeight:700,cursor:"pointer"},children:[(0,r.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,r.jsx)("path",{d:"M5 7h14M5 12h14M5 17h14"})}),t.B.history.openPast]})]})]})}),(0,r.jsx)(C,{open:aM,onClose:ba,count:be,children:(0,r.jsx)(v.R,{workflowId:a,currentRunId:m?.runId??null,publishing:aQ?.runId===m?.runId&&aQ?.state.pr?.state==="merged"&&!0===aQ.state.deployPending,refreshKey:`${m?.runId??""}-${ay??""}-${aM}`,onOpen:a=>{aN(!1),am(a)},onCount:bf,onWaiting:bh,onDeleted:a=>{a===m?.runId&&(bu("none"),aN(!1))}})}),bX,(0,r.jsx)(hF.g.Provider,{value:F,children:(0,r.jsxs)(D.c.Provider,{value:M,children:[(0,r.jsx)(D.v.Provider,{value:G,children:(0,r.jsx)(ip,{layout:aE?"steps":"canvas",site:aE?(0,r.jsx)(H,{runId:m&&!1!==m.here&&B!==ai.C?m.runId:null,projectId:m?null:o?.projectId??null}):void 0,stepDetails:a=>m?(0,r.jsx)(j$,{inline:!0,runId:m.runId,blockId:a,label:m.blocks.find(b=>b.id===a)?.label??a,view:a6(a5(a9))[a],pr:aQ?.runId===m.runId?aQ.state.pr??null:null,away:!1===m.here?{machine:m.machine??null}:null,onClose:()=>void 0},`inline-${m.runId}-${a}`):null,graph:b,save:function(b){let c=aG.current.catch(()=>void 0).then(async()=>{if(aH.current)throw Error("stale draft");let c=await fetch(`/api/workflows/${a}/draft`,{method:"PUT",headers:{"content-type":"application/json",...aF.current?{"x-draft-base":aF.current}:{}},body:JSON.stringify(b),keepalive:!0});if(409===c.status)throw aH.current=!0,ae(t.B.editing.staleDraft),Error("stale draft");if(!c.ok)throw Error(`Saving the draft failed (${c.status})`);let d=await c.json();return d.updatedAt&&(aF.current=d.updatedAt),d.issues});return aG.current=c,c},nodeRuns:Object.values(a6(a5(a9))),runBlocks:m?.blocks,highlightedId:af,onFailedClick:"failed"===bO?a=>"see"===a?bD.current?.see():bD.current?.again():void 0,canRetry:"failed"===bO&&bE===m?.runId,onDetails:m?bH:void 0,blank:bi,taskId:m?.runId??null,flushRef:ak,loading:a$,overlay:m&&!a$?(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(I,{roomy:aE,runId:m.runId,initial:m.title??"",onRenamed:a=>n(b=>b&&b.runId===m.runId?{...b,title:a}:b)},m.runId)}):void 0,sidebarLog:m?(0,r.jsx)(av,{events:ax,blocks:m.blocks,onPoint:aj}):void 0})}),bW&&m&&(0,r.jsx)(ix,{runId:m.runId,blocks:m.blocks,views:a6(a5(a9)),rounds:aw,prompts:a_,onDetails:bH}),!aE&&null!==m&&!a$&&(0,r.jsx)(iw,{chat:aO,onChange:aP}),bR&&(0,r.jsx)(u,{})]})}),m&&bG&&(0,r.jsx)(j$,{runId:m.runId,blockId:bG,label:m.blocks.find(a=>a.id===bG)?.label??bG,view:a5(a9)[bG],pr:aQ?.runId===m.runId?aQ.state.pr??null:null,away:!1===m.here?{machine:m.machine??null}:null,onClose:()=>bH(null),onSeeShip:bK?()=>bH(bK):void 0,onSettings:()=>{bH(null),window.dispatchEvent(new CustomEvent(ii,{detail:bG}))}},`details-${m.runId}-${bG}`)]})]})}],1603)}];
|
|
5
|
+
${b}`:a),"fix")},onAgain:()=>(n(!1),void x(iy.againText,"again")),onOwn:()=>{n(!1),requestAnimationFrame(()=>document.querySelector('[data-testid="command-card"] textarea')?.focus())}})]})}function iB(){return(0,r.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,r.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 iC(){return(0,r.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,r.jsx)("path",{d:"M4 20h4L19 9l-4-4L4 16v4z"}),(0,r.jsx)("path",{d:"M13.5 6.5l4 4"})]})}function iD(){return(0,r.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,r.jsx)("path",{d:"M20 11a8 8 0 1 0-2.3 5.7"}),(0,r.jsx)("path",{d:"M20 4v7h-7"})]})}function iE({icon:a,label:b,help:c,badge:d,primary:e,onClick:f}){return(0,r.jsxs)("button",{type:"button","aria-label":b,onClick:f,style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",columnGap:12,rowGap:3,alignItems:"center",padding:e?"16px 18px":"13px 18px",borderRadius:10,border:`1px solid ${e?A.f.running:A.f.border}`,background:e?A.f.running:"#0f141c",color:e?"#fff":"#e6e9ef",cursor:"pointer",textAlign:"left"},children:[(0,r.jsx)("span",{style:{gridRow:"1 / span 2",display:"grid",placeItems:"center"},children:a}),(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:8,fontSize:e?17.5:15.5,fontWeight:700},children:[b,d&&(0,r.jsx)("span",{style:{padding:"1px 8px",borderRadius:999,background:"rgba(255,255,255,0.22)",fontSize:11.5,fontWeight:700},children:d})]}),(0,r.jsx)("span",{style:{fontSize:14,lineHeight:1.4,color:e?"rgba(255,255,255,0.88)":A.f.dim},children:c})]})}function iF({failure:a,canContinue:b,explanation:c,explaining:d,onClose:e,onFix:f,onAgain:g,onOwn:h}){(0,s.useEffect)(()=>{let a=a=>{"Escape"===a.key&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);let i=a?.failed[0],j=a?.failed.filter(a=>a.command||a.message)??[];return(0,r.jsx)("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:60,display:"grid",gridTemplateRows:"minmax(0, 1fr)",placeItems:"center",background:"rgba(5, 7, 11, 0.65)"},children:(0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":iy.title,"data-testid":"failure-dialog",onClick:a=>a.stopPropagation(),style:{width:`min(${j.length>0?1240:720}px, calc(100% - 32px))`,maxHeight:"calc(100% - 48px)",display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",background:A.f.card,border:`1px solid ${A.f.tint("failed",.5)}`,borderRadius:14,boxShadow:"0 24px 60px rgba(0,0,0,0.6)",fontSize:14},children:[(0,r.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"18px 26px",borderBottom:`1px solid ${A.f.border}`},children:[(0,r.jsx)("h2",{className:"factory-display",style:{margin:0,fontSize:25},children:iy.title}),(0,r.jsx)("button",{type:"button","aria-label":iy.close,onClick:e,style:{background:"none",border:"none",color:A.f.skipped,cursor:"pointer",fontSize:18},children:"✕"})]}),(0,r.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:`${A.f.skipped} transparent`},children:a?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"grid",gap:22,minWidth:0},children:[(0,r.jsxs)("section",{style:{display:"grid",gap:10},children:[(0,r.jsx)("strong",{style:{fontSize:17},children:iy.happened}),(0,r.jsx)("p",{"data-testid":"failure-plain",style:{margin:0,fontSize:16.5,lineHeight:1.55,color:"#e6e9ef"},children:c??(i?iy.plain(i.label):iy.plainUnknown)}),d&&(0,r.jsxs)("div",{role:"status",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:A.f.dim},children:[(0,r.jsx)(D.m,{blockId:"explain",size:14})," ",iy.explaining]}),(0,r.jsx)("p",{style:{margin:0,fontSize:14.5,lineHeight:1.5,color:A.f.passed},children:iy.safe})]}),(0,r.jsxs)("section",{style:{display:"grid",gap:10},children:[(0,r.jsx)("strong",{style:{fontSize:17},children:iy.whatNow}),b?(0,r.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,r.jsx)(iE,{primary:!0,icon:(0,r.jsx)(iB,{}),label:iy.actions.fix.label,help:iy.actions.fix.help,badge:iy.actions.fix.badge,onClick:f}),(0,r.jsx)(iE,{icon:(0,r.jsx)(iD,{}),label:iy.actions.again.label,help:iy.actions.again.help,onClick:g}),(0,r.jsx)(iE,{icon:(0,r.jsx)(iC,{}),label:iy.actions.own.label,help:iy.actions.own.help,onClick:h})]}):(0,r.jsx)("span",{style:{fontSize:13.5,color:A.f.waiting,lineHeight:1.5},children:iy.cannotContinue})]})]}),j.length>0&&(0,r.jsxs)("section",{style:{display:"grid",gap:12,minWidth:0},children:[(0,r.jsx)("strong",{style:{fontSize:17},children:iy.details}),j.map(a=>(0,r.jsxs)("div",{"data-testid":"failed-block",style:{display:"grid",gap:8},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:10,flexWrap:"wrap",fontSize:13},children:[(0,r.jsx)("strong",{style:{color:A.f.failed},children:a.label}),a.message&&(0,r.jsx)("span",{style:{color:A.f.dim},children:a.message})]}),a.command&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap",fontSize:13,color:A.f.dim},children:[iy.command,(0,r.jsx)("code",{style:{padding:"3px 8px",borderRadius:6,background:"#0b0e14",border:`1px solid ${A.f.border}`,fontFamily:iz,fontSize:12.5,color:"#d6dce6"},children:a.command}),(0,r.jsx)("span",{style:{color:A.f.failed},children:iy.ended(a.exitCode,a.signal)})]}),(0,r.jsx)("span",{style:{fontSize:13,color:A.f.dim},children:iy.output}),(0,r.jsx)("pre",{"data-testid":"failure-output",style:{margin:0,maxHeight:"min(50vh, 460px)",overflow:"auto",padding:12,borderRadius:8,background:"#0b0e14",border:`1px solid ${A.f.border}`,fontFamily:iz,fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",scrollbarWidth:"thin",scrollbarColor:`${A.f.skipped} transparent`},children:a.output??iy.noOutput})]})]},a.blockId))]})]}):(0,r.jsx)("div",{style:{color:A.f.dim},children:iy.unreadable})})]})})}let iG=(0,s.createContext)(!1);function iH(a){return a.filter(a=>"ready"===a.status&&a.id).map(a=>a.id)}function iI(a){return a.some(a=>"uploading"===a.status)}function iJ({inputId:a,label:b,placeholder:c,text:d,onText:e,images:f,onImages:g,onSubmit:h,send:i,minHeight:j=170,disabled:k=!1}){let[l,m]=(0,s.useState)(!1),[n,o]=(0,s.useState)(null),p=(0,s.useRef)(null),q=(0,s.useRef)(null);(0,s.useLayoutEffect)(()=>{let a=q.current;a&&(a.style.height="auto",a.style.height=`${Math.min(Math.max(a.scrollHeight,j),380)}px`)},[d,j]);let u=(0,s.useRef)(()=>void 0);function v(a){o(null);let b=a.filter(a=>a.type.startsWith("image/"));b.length<a.length&&o(t.B.attachments.notImage);let c=6-f.length;for(let a of(b.length>c&&o(t.B.attachments.tooMany(6)),b.slice(0,Math.max(0,c)))){let b=`${Date.now()}-${Math.random().toString(36).slice(2)}`;g(c=>[...c,{key:b,name:a.name||"image",previewUrl:URL.createObjectURL(a),status:"uploading"}]);let c=new FormData;c.append("file",a),fetch("/api/attachments",{method:"POST",body:c}).then(async a=>{let c=await a.json().catch(()=>null);g(d=>d.map(d=>d.key!==b?d:a.ok&&c?.id?{...d,status:"ready",id:c.id}:{...d,status:"failed",error:c?.error??t.B.attachments.failed}))}).catch(()=>g(a=>a.map(a=>a.key===b?{...a,status:"failed",error:t.B.attachments.failed}:a)))}}return(0,s.useEffect)(()=>{if(k)return;let a=a=>{var b;let c,d=a.target;if(d&&d!==q.current&&("INPUT"===d.tagName||"TEXTAREA"===d.tagName||d.isContentEditable)||!a.clipboardData)return;let e=(c=[...(b=a.clipboardData).files].filter(a=>a.type.startsWith("image/"))).length>0?c:[...b.items].filter(a=>"file"===a.kind&&a.type.startsWith("image/")).map(a=>a.getAsFile()).filter(a=>null!==a);0!==e.length&&(a.preventDefault(),u.current(e),d!==q.current&&q.current?.focus({preventScroll:!0}))},b=a=>a.dataTransfer?.types.includes("Files")===!0,c=a=>{b(a)&&(a.preventDefault(),m(!0))},d=a=>{null===a.relatedTarget&&m(!1)},e=a=>{b(a)&&(a.preventDefault(),m(!1),u.current([...a.dataTransfer?.files??[]]),q.current?.focus({preventScroll:!0}))};return window.addEventListener("paste",a),window.addEventListener("dragover",c),window.addEventListener("dragleave",d),window.addEventListener("drop",e),()=>{window.removeEventListener("paste",a),window.removeEventListener("dragover",c),window.removeEventListener("dragleave",d),window.removeEventListener("drop",e)}},[k]),(0,s.useEffect)(()=>{u.current=v}),(0,r.jsxs)("div",{"data-testid":"composer",style:{display:"grid",gap:6},children:[(0,r.jsx)("label",{htmlFor:a,style:{fontSize:12.5,fontWeight:600,color:A.f.dim},children:b}),(0,r.jsxs)("div",{style:{position:"relative",background:z.f.card,border:`1px ${l?"dashed":"solid"} ${l?A.f.running:z.f.line}`,borderRadius:10,padding:8,display:"grid",gap:8},children:[f.length>0&&(0,r.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:f.map(a=>(0,r.jsxs)("div",{"data-testid":"composer-thumb","data-status":a.status,title:a.error??a.name,style:{position:"relative",width:56,height:56,borderRadius:8,overflow:"hidden",border:`1px solid ${"failed"===a.status?A.f.failed:z.f.line}`,background:z.f.bg},children:[(0,r.jsx)("img",{src:a.previewUrl,alt:a.name,style:{width:"100%",height:"100%",objectFit:"cover",opacity:"ready"===a.status?1:.45}}),"uploading"===a.status&&(0,r.jsx)("span",{style:{position:"absolute",inset:0,display:"grid",placeItems:"center"},children:(0,r.jsx)(D.m,{blockId:`thumb-${a.key}`,size:18})}),"failed"===a.status&&(0,r.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",inset:0,display:"grid",placeItems:"center",color:A.f.failed,fontWeight:900},children:"!"}),(0,r.jsx)("button",{type:"button","aria-label":t.B.attachments.remove(a.name),onClick:()=>{var b;return b=a.key,void g(a=>{let c=a.find(a=>a.key===b);return c&&URL.revokeObjectURL(c.previewUrl),a.filter(a=>a.key!==b)})},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:"✕"})]},a.key))}),(0,r.jsx)("textarea",{ref:q,id:a,"aria-label":b,placeholder:l?t.B.attachments.dropHere:c,value:d,disabled:k,rows:8,onChange:a=>e(a.target.value),onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.altKey||a.nativeEvent.isComposing||(i?.enabled?(a.preventDefault(),i.onSend()):h?(a.preventDefault(),h()):i&&""===d.trim()&&a.preventDefault())},style:{width:"100%",boxSizing:"border-box",resize:"vertical",minHeight:j,maxHeight:380,padding:4,background:"transparent",color:"inherit",border:"none",outline:"none",font:"inherit",fontSize:14,lineHeight:1.45,scrollbarWidth:"thin",scrollbarColor:`${A.f.floorLine} transparent`}}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,borderTop:`1px solid ${A.f.lineSoft}`,paddingTop:8},children:[(0,r.jsxs)("button",{type:"button",disabled:k||f.length>=6,onClick:()=>p.current?.click(),title:t.B.attachments.add,"aria-label":t.B.attachments.add,style:{display:"inline-flex",alignItems:"center",gap:6,background:"none",border:`1px solid ${z.f.line}`,borderRadius:6,color:"#d6dce6",cursor:"pointer",padding:"4px 10px",fontSize:12,fontWeight:600,whiteSpace:"nowrap"},children:[(0,r.jsx)(iL,{})," ",t.B.attachments.browse]}),(0,r.jsx)("span",{style:{flex:1,fontSize:11.5,color:A.f.dim},children:iI(f)?t.B.attachments.uploading:t.B.attachments.pasteHint}),i&&(0,r.jsx)("button",{type:"button","aria-label":i.label,title:i.label,disabled:!i.enabled,onClick:i.onSend,style:{flex:"none",width:32,height:32,borderRadius:"50%",display:"grid",placeItems:"center",padding:0,border:"none",background:i.enabled?A.f.passed:z.f.line,color:i.enabled?"#07110a":A.f.skipped,cursor:i.enabled?"pointer":"not-allowed"},children:i.busy?(0,r.jsx)(D.m,{blockId:"composer-send",size:14}):(0,r.jsx)(iK,{})})]}),(0,r.jsx)("input",{ref:p,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,onChange:a=>{v([...a.target.files??[]]),a.target.value=""}})]}),n&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12,color:A.f.waiting},children:n})]})}function iK(){return(0,r.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,r.jsx)("path",{d:"M14.5 1.5 7 9M14.5 1.5 10 14.5 7 9 1.5 6l13-4.5Z"})})}function iL(){return(0,r.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,r.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 iM=a.i(9298);function iN({runId:a}){let[b,c]=(0,s.useState)(null),[d,e]=(0,s.useState)(null),[f,g]=(0,s.useState)(!1),h=b?.status==="installing"||b?.status==="starting";async function i(b){e(null);try{let d=await fetch(`/api/runs/${a}/preview`,{method:b}),f=await d.json().catch(()=>null);if(!d.ok||!f)return e(f?.error??t.B.preview.failed);c(f)}catch{e(t.B.preview.failed)}}(0,s.useEffect)(()=>{let b=!0,d=()=>fetch(`/api/runs/${a}/preview`).then(a=>a.json()).then(a=>b&&c(a)).catch(()=>void 0);if(d(),!h)return()=>void(b=!1);let e=setInterval(d,1e3);return()=>{b=!1,clearInterval(e)}},[a,h]);let j=b?.status??"stopped",k="installing"===j?t.B.preview.installing:"starting"===j?t.B.preview.starting:"ready"===j?t.B.preview.ready:null;return(0,r.jsxs)("div",{"data-testid":"preview","data-status":j,style:{display:"grid",gap:6},children:[(0,r.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:["ready"===j&&b?.url?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("a",{href:b.url,target:"_blank",rel:"noreferrer",style:{padding:"7px 14px",borderRadius:8,background:A.f.running,color:"#fff",fontWeight:700,textDecoration:"none",fontSize:13},children:["↗ ",t.B.preview.open]}),(0,r.jsx)("button",{type:"button",onClick:()=>void i("DELETE"),style:{background:"none",border:"none",color:A.f.dim,cursor:"pointer",fontSize:12.5},children:t.B.preview.stop})]}):(0,r.jsxs)("button",{type:"button",disabled:h,onClick:()=>void i("POST"),style:{padding:"7px 14px",borderRadius:8,border:`1px solid ${A.f.running}`,background:A.f.tint("running",.12),color:"#cfe0ff",fontWeight:700,fontSize:13,cursor:h?"wait":"pointer"},children:["▶ ",t.B.preview.start]}),k&&(0,r.jsx)("span",{style:{fontSize:12,color:"ready"===j?A.f.dim:"#cfe0ff"},children:k})]}),("failed"===j||d)&&(0,r.jsxs)("div",{role:"alert",style:{fontSize:12.5,color:A.f.failed},children:[d??b?.message??t.B.preview.failed," ",b?.log&&(0,r.jsx)("button",{type:"button",onClick:()=>g(a=>!a),style:{background:"none",border:"none",color:A.f.running,cursor:"pointer",padding:0,fontSize:12.5},children:t.B.preview.showLog})]}),f&&b?.log&&(0,r.jsx)("pre",{style:{margin:0,maxHeight:180,overflow:"auto",background:"#0b0e14",border:`1px solid ${A.f.border}`,borderRadius:8,padding:10,fontSize:11.5,color:"#9aa5b6",whiteSpace:"pre-wrap"},children:b.log})]})}let iO=["needs_you","in_progress","fixed","set_aside"],iP={needs_you:A.f.waiting,in_progress:A.f.running,fixed:A.f.passed,set_aside:A.f.skipped};function iQ(a){return iO.flatMap(b=>a.filter(a=>a.ending===b))}let iR={checked:{colour:A.f.passed,icon:(0,r.jsx)("path",{d:"M3 8.5 6.5 12 13 4.5"})},ai:{colour:A.f.waiting,icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("path",{d:"M2.5 3.5h11v7h-6l-3 2.5v-2.5h-2z"}),(0,r.jsx)("path",{d:"M5.5 7h.01M8 7h.01M10.5 7h.01"})]})},not_checked:{colour:A.f.dim,icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"5.5",strokeDasharray:"2.4 2.2"}),(0,r.jsx)("path",{d:"M5.5 8h5"})]})}};function iS({how:a,inLegend:b=!1}){let c=iR[a];return(0,r.jsxs)("span",{"data-testid":b?"how-key":"how-mark","data-state":a,title:t.B.findings.howMeans[a],style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:999,border:`1px ${"not_checked"===a?"dashed":"solid"} ${c.colour}`,color:c.colour,fontSize:11.5,fontWeight:700,whiteSpace:"nowrap"},children:[(0,r.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:c.icon}),t.B.findings.how[a]]})}function iT({f:a,n:b,touched:c}){let[d,e]=(0,s.useState)(!1),f=(0,s.useId)(),g=a.detail,h=(a,b,c=!1)=>""===b?null:(0,r.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:A.f.dim},children:a}),(0,r.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",fontFamily:c?"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace":void 0,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:b})]});return(0,r.jsxs)("li",{"data-testid":"finding",style:{display:"grid",gap:6,padding:"10px 12px",borderRadius:10,border:`1px solid ${A.f.border}`,borderLeft:`3px solid ${iP[a.ending]}`,background:"#0d1118"},children:[(0,r.jsx)("span",{"data-testid":"finding-number",style:{fontSize:11.5,fontWeight:700,color:A.f.dim},children:t.B.findings.number(b)}),(0,r.jsx)("span",{style:{fontSize:13.5,fontWeight:600,color:A.f.ink,lineHeight:1.4,overflowWrap:"anywhere"},children:a.title}),(0,r.jsx)("span",{style:{fontSize:12.5,color:A.f.dim,lineHeight:1.45,overflowWrap:"anywhere"},children:(0,iM.f)(a.outcome,c)}),(0,r.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,r.jsx)(iS,{how:a.how}),(0,r.jsx)("button",{type:"button",className:"factory-action","aria-expanded":d,"aria-controls":f,onClick:()=>e(a=>!a),style:{background:"none",border:"none",padding:"6px 0 6px 8px",minHeight:32,color:A.f.running,cursor:"pointer",fontSize:12.5},children:t.B.question.seeDetails})]}),d&&(0,r.jsxs)("div",{id:f,style:{display:"grid",gap:8,paddingTop:8,borderTop:`1px solid ${A.f.lineSoft}`},children:[h(t.B.findings.detail.where,g.where,!0),""!==g.problem&&(0,r.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:A.f.waiting},children:t.B.findings.detail.aiSaid}),(0,r.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:(0,iM.f)(g.problem,c)})]}),h(t.B.findings.detail.command,g.command,!0),h(t.B.findings.detail.output,g.outputTail,!0),h(t.B.findings.detail.why,(0,iM.f)(g.reason,c)),""===g.where&&""===g.problem&&""===g.command&&""===g.outputTail&&""===g.reason&&(0,r.jsx)("span",{style:{fontSize:12.5,color:A.f.dim},children:t.B.findings.detail.none})]})]})}function iU({findings:a,touched:b=[]}){let c=new Map(iQ(a).map((a,b)=>[a.id,b+1]));return(0,r.jsxs)("section",{"data-testid":"findings-list","aria-label":t.B.findings.heading,style:{display:"grid",gap:10},children:[(0,r.jsx)("h3",{className:"factory-display",style:{margin:0,fontSize:15},children:t.B.findings.heading}),0===a.length&&(0,r.jsx)("p",{style:{margin:0,fontSize:13,color:A.f.dim},children:t.B.findings.none}),a.length>0&&(0,r.jsx)("dl",{"data-testid":"legend","aria-label":t.B.findings.legendTitle,style:{margin:0,display:"grid",gap:6},children:["checked","ai","not_checked"].filter(b=>a.some(a=>a.how===b)).map(a=>(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 8px"},children:[(0,r.jsx)("dt",{style:{margin:0},children:(0,r.jsx)(iS,{how:a,inLegend:!0})}),(0,r.jsx)("dd",{style:{margin:0,fontSize:12,color:A.f.dim,lineHeight:1.4,flex:"1 1 180px"},children:t.B.findings.howMeans[a]})]},a))}),iO.map(d=>{let e=a.filter(a=>a.ending===d);return 0===e.length?null:(0,r.jsxs)("div",{style:{display:"grid",gap:6},children:[(0,r.jsxs)("h4",{style:{margin:0,display:"flex",alignItems:"center",gap:8,fontSize:12,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:iP[d]},children:[t.B.findings.group[d],(0,r.jsx)("span",{style:{fontSize:11,padding:"0 7px",borderRadius:999,border:`1px solid ${iP[d]}`},children:e.length})]}),(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:6},children:e.map(a=>(0,r.jsx)(iT,{f:a,n:c.get(a.id)??0,touched:b},a.id))})]},d)})]})}let iV="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace";function iW({findings:a,touched:b=[],away:c=null,runId:d,risk:e,note:f,imageIds:g,imagesBusy:h,composer:i,onSent:j,onSeeChanges:k}){let[l,m]=(0,s.useState)(null),[n,o]=(0,s.useState)(!1),[p,q]=(0,s.useState)(!1),[u,v]=(0,s.useState)(null),[w,x]=(0,s.useState)(0);async function y(a){if(l){q(!0),v(null);try{let b=await fetch(`/api/runs/${d}/decision`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({decision:a,reason:f.trim()||null,diffHash:l.hash,..."changes"===a?{attachments:g}:{}})}),e=await b.json().catch(()=>null);if(!b.ok){v({text:e?.error??t.B.gate.notDelivered,ok:!1}),409===b.status&&x(a=>a+1);return}v({text:c?t.B.machine.sentElsewhere(c.machine):"approved"===a?t.B.gate.approved:"rejected"===a?t.B.gate.rejected:t.B.gate.changesSent,ok:!0}),j()}catch{v({text:t.B.gate.notDelivered,ok:!1})}finally{q(!1)}}}(0,s.useEffect)(()=>{let a=!0;return fetch(`/api/runs/${d}/review`).then(a=>a.ok?a.json():Promise.reject(Error(String(a.status)))).then(b=>a&&(m(b),o(!1))).catch(()=>a&&o(!0)),()=>{a=!1}},[d,w]);let z=u?.ok===!0,[B,C]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!z)return;let a=setTimeout(()=>C(!0),2e4);return()=>clearTimeout(a)},[z]);let E=!z&&(""!==f.trim()||g.length>0),F=a=>({flex:1,padding:"9px 12px",borderRadius:8,border:`1px solid ${E?"#2a3140":A.f[a]}`,...E?{background:"#2a3140",color:"#8b95a7"}:{background:"passed"===a?A.f.passed:"transparent",color:"passed"===a?"#07090d":A.f.failed},fontWeight:700,cursor:p||!l||z||E?"not-allowed":"pointer",opacity:p||!l||z?.6:1});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:A.f.waiting,color:"#1a1206",fontWeight:900,fontSize:17},children:"!"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:t.B.gate.title}),(0,r.jsx)("div",{style:{fontSize:12.5,color:"#d9c9a3"},children:t.B.gate.waiting})]})]}),e&&!k&&(0,r.jsxs)("div",{style:{fontSize:12.5,color:"low"===e.level?A.f.passed:A.f.waiting,lineHeight:1.4},children:[(0,r.jsxs)("strong",{children:[t.B.risk.label[e.level],":"]}),(0,r.jsx)(iX,{reasons:e.reasons,touched:b}),"low"===e.level&&e.stopForMe&&(0,r.jsx)("div",{"data-testid":"stop-for-me-why",style:{color:A.f.waiting},children:t.B.gate.stopForMe})]}),n&&(0,r.jsx)("div",{style:{fontSize:12.5,color:A.f.failed},children:t.B.gate.loadFailed}),!l&&!n&&(0,r.jsxs)("div",{"aria-busy":"true","aria-label":t.B.gate.loading,style:{display:"grid",gap:8,padding:10,borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0d1118"},children:[(0,r.jsx)(h6,{width:"35%",height:10}),(0,r.jsx)(h6,{height:12}),(0,r.jsx)(h6,{width:"80%",height:12})]}),l&&!k&&(0,r.jsx)(iZ,{review:l}),l&&k&&(0,r.jsxs)("button",{type:"button","data-testid":"see-changes",onClick:k,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,padding:"10px 12px",borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0d1118",color:"#e6e9ef",fontSize:13.5,fontWeight:700,cursor:"pointer",textAlign:"left"},children:[(0,r.jsxs)("span",{style:{display:"grid",gap:2},children:[t.B.gate.seeChanges,(0,r.jsx)("span",{style:{fontSize:12,fontWeight:400,color:A.f.dim},children:0===l.files.length?t.B.gate.noFiles:t.B.gate.filesChanged(l.files.length)})]}),(0,r.jsx)("span",{"aria-hidden":"true",style:{flex:"none",display:"grid",placeItems:"center",width:28,height:28,borderRadius:8,background:A.f.tint("running",.16),color:A.f.running},children:(0,r.jsx)("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M6 3.5 10.5 8 6 12.5"})})})]}),a&&(0,r.jsx)(iU,{findings:a,touched:b}),l&&l.files.length>0&&!z&&(k?(0,r.jsx)(aB.$,{runId:d,autoStart:!c}):(0,r.jsx)(aB.v,{runId:d,autoStart:!c,canTake:!c})),l&&l.files.length>0&&!z&&!c&&!k&&(0,r.jsx)(iN,{runId:d}),c&&!z&&(0,r.jsx)("div",{style:{fontSize:12,color:A.f.dim,lineHeight:1.4},children:t.B.machine.elsewhere(c.machine)}),!z&&i({label:t.B.gate.askChanges,onSend:()=>void y("changes"),enabled:!p&&null!==l&&!h&&""!==f.trim()}),!z&&(0,r.jsxs)("div",{style:{display:"flex",gap:8,paddingTop:10,borderTop:`1px solid ${A.f.lineSoft}`},children:[(0,r.jsx)("button",{type:"button",disabled:p||!l||h||E,onClick:()=>void y("approved"),style:F("passed"),children:p?t.B.gate.deciding:`✓ ${t.B.gate.approve}`}),(0,r.jsxs)("button",{type:"button",disabled:p||!l||h||E,onClick:()=>void y("rejected"),style:F("failed"),children:["✕ ",t.B.gate.reject]})]}),E&&(0,r.jsx)("span",{role:"note","data-testid":"gate-unsent",style:{fontSize:12.5,color:"#f3d9a4",textAlign:"center",lineHeight:1.45},children:t.B.gate.unsent}),u&&(0,r.jsxs)("div",{role:u.ok?"status":"alert",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:u.ok?A.f.passed:A.f.failed},children:[u.ok&&!B&&(0,r.jsx)(D.m,{blockId:"gate",size:16}),u.text]}),z&&B&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12.5,color:A.f.waiting,lineHeight:1.4},children:t.B.gate.notPickedUp})]})}function iX({reasons:a,touched:b=[]}){return(0,r.jsx)("ul",{style:{margin:"2px 0 0",padding:0,listStyle:"none",display:"grid",gap:2},children:a.map((a,c)=>(0,r.jsx)("li",{"data-testid":"risk-reason",style:{overflowWrap:"anywhere"},children:(0,iM.f)((0,t.g)(a),b)},c))})}function iY({diff:a,truncated:b}){return(0,r.jsxs)(r.Fragment,{children:[a.split("\n").map((a,b)=>(0,r.jsx)("div",{style:{color:a.startsWith("+")?"#86efac":a.startsWith("-")?"#fca5a5":a.startsWith("@@")?"#93c5fd":"#9aa5b6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",paddingLeft:"1.2em",textIndent:"-1.2em"},children:a||" "},b)),b&&(0,r.jsx)("div",{style:{color:A.f.waiting},children:t.B.gate.truncated})]})}function iZ({review:a,roomy:b=!1}){let[c,d]=(0,s.useState)(!1),[e,f]=(0,s.useState)(!1),g=b||c;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{"data-testid":"gate-changes",style:{display:"grid",gap:6,maxHeight:b?"min(56vh, 600px)":g?260:180,overflowY:"auto",padding:10,borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0d1118",scrollbarWidth:"thin",scrollbarColor:`${A.f.floorLine} transparent`},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,r.jsx)("div",{style:{fontSize:12.5,color:A.f.dim},children:0===a.files.length?t.B.gate.noFiles:t.B.gate.filesChanged(a.files.length)}),a.diff&&!b&&(0,r.jsx)("button",{type:"button","aria-label":t.B.gate.expandChanges,title:t.B.gate.expandChanges,onClick:()=>f(!0),style:{display:"grid",placeItems:"center",width:26,height:26,padding:0,borderRadius:6,border:`1px solid ${A.f.border}`,background:A.f.card,color:"#d6dce6",cursor:"pointer"},children:(0,r.jsx)(i0,{})})]}),a.files.slice(0,8).map(a=>(0,r.jsxs)("div",{style:{display:"flex",gap:8,fontFamily:iV,fontSize:12,color:"#d6dce6"},children:[(0,r.jsx)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:a.path,children:a.path}),(0,r.jsxs)("span",{style:{color:A.f.passed},children:["+",a.added]}),(0,r.jsxs)("span",{style:{color:A.f.failed},children:["−",a.removed]})]},a.path)),a.files.length>8&&(0,r.jsx)("div",{style:{fontSize:12,color:A.f.dim},children:t.B.canvas.andMore(a.files.length-8)}),a.diff&&!b&&(0,r.jsx)("button",{type:"button",onClick:()=>d(a=>!a),style:{justifySelf:"start",background:"none",border:"none",color:A.f.running,cursor:"pointer",padding:0,fontSize:12.5},children:g?t.B.gate.hideChanges:t.B.gate.showChanges}),g&&(0,r.jsx)("pre",{"data-testid":"gate-diff",style:{margin:0,background:"#0b0e14",border:`1px solid ${A.f.border}`,borderRadius:8,padding:10,fontSize:12,lineHeight:1.5},children:(0,r.jsx)(iY,{diff:a.diff,truncated:a.truncated})})]}),e&&a&&(0,r.jsx)(i_,{files:a.files,diff:a.diff,truncated:a.truncated,onClose:()=>f(!1)})]})}function i$({runId:a,risk:b,away:c=null,decided:d=!1}){let[e,f]=(0,s.useState)(null),[g,h]=(0,s.useState)(!1);return((0,s.useEffect)(()=>{let b=!0;return fetch(`/api/runs/${a}/review`).then(a=>a.ok?a.json():Promise.reject(Error(String(a.status)))).then(a=>b&&f(a)).catch(()=>b&&h(!0)),()=>{b=!1}},[a]),g)?(0,r.jsx)("div",{style:{fontSize:13,color:A.f.failed},children:t.B.gate.loadFailed}):e?(0,r.jsxs)("div",{"data-testid":"change-under-check",style:{display:"grid",gap:12},children:[b&&(0,r.jsxs)("div",{style:{fontSize:13.5,color:"low"===b.level?A.f.passed:A.f.waiting,lineHeight:1.5},children:[(0,r.jsxs)("strong",{children:[t.B.risk.label[b.level],":"]}),(0,r.jsx)(iX,{reasons:b.reasons}),"low"===b.level&&b.stopForMe&&(0,r.jsx)("div",{"data-testid":"stop-for-me-why",style:{color:A.f.waiting},children:t.B.gate.stopForMe})]}),(0,r.jsx)(iZ,{review:e,roomy:!0}),e.files.length>0&&!c&&!d&&(0,r.jsx)(iN,{runId:a}),c&&(0,r.jsx)("div",{style:{fontSize:12.5,color:A.f.dim},children:t.B.machine.elsewhere(c.machine)})]}):(0,r.jsx)(h6,{height:60,radius:10})}function i_({files:a,diff:b,truncated:c,onClose:d}){let e=(0,s.useRef)(null);return(0,s.useEffect)(()=>{e.current?.focus();let a=a=>{"Escape"===a.key&&d()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[d]),(0,fb.createPortal)((0,r.jsx)("div",{"data-testid":"changes-modal",onClick:d,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,r.jsxs)("div",{ref:e,role:"dialog","aria-modal":"true","aria-label":t.B.gate.changesTitle,tabIndex:-1,onClick:a=>a.stopPropagation(),style:{width:"min(1100px, 100%)",height:"min(86vh, calc(100vh - 48px))",minHeight:0,display:"flex",flexDirection:"column",background:A.f.bg,border:`1px solid ${A.f.border}`,borderRadius:14,boxShadow:"0 30px 80px rgba(0,0,0,0.6)",outline:"none",color:"#e6e9ef"},children:[(0,r.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"12px 16px",borderBottom:`1px solid ${A.f.border}`},children:[(0,r.jsxs)("div",{style:{display:"grid",gap:2},children:[(0,r.jsx)("div",{className:"factory-display",style:{fontSize:19},children:t.B.gate.changesTitle}),(0,r.jsx)("div",{style:{fontSize:12,color:A.f.dim,fontFamily:iV},children:a.map(a=>`${a.path} +${a.added} −${a.removed}`).join(" · ")})]}),(0,r.jsx)("button",{type:"button","aria-label":t.B.gate.closeChanges,onClick:d,style:{background:"none",border:"none",color:A.f.skipped,cursor:"pointer",fontSize:18,lineHeight:1,padding:6},children:"✕"})]}),(0,r.jsx)("pre",{style:{flex:1,minHeight:0,margin:0,overflow:"auto",padding:16,fontFamily:iV,fontSize:13,lineHeight:1.55,background:"#0b0e14",borderRadius:"0 0 14px 14px",scrollbarWidth:"thin",scrollbarColor:`${A.f.floorLine} transparent`},children:(0,r.jsx)(iY,{diff:b,truncated:c})})]})}),document.body)}function i0(){return(0,r.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,r.jsx)("path",{d:"M9.5 2.5h4v4M13.5 2.5 9 7M6.5 13.5h-4v-4M2.5 13.5 7 9"})})}let i1="other",i2="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",i3=a=>a.length>400?`${a.slice(0,399)}…`:a;function i4({question:a,onAnswer:b,position:c,touched:d=[],finding:e}){let[f,g]=(0,s.useState)(null),[h,i]=(0,s.useState)(""),[j,k]=(0,s.useState)(!1),[l,m]=(0,s.useState)(!1),[n,o]=(0,s.useState)(null),[p,q]=(0,s.useState)(!1),u=(0,s.useRef)(!1),v=(0,s.useId)(),w=(0,s.useId)(),x=f??(""!==h.trim()?i1:null),y=null!==x,z=j||l;async function B(){if(y&&!u.current&&!l){u.current=!0,k(!0),o(null);try{await b(x,""!==h.trim()?h.trim():void 0),m(!0)}catch(a){o(a instanceof Error&&a.message?a.message:t.B.question.failed)}finally{u.current=!1,k(!1)}}}let C=d.filter(b=>a.touches.includes(b.number)),D=e?.problem.trim()?e.problem.trim():null,E=D?[e.where.trim()?{label:t.B.findings.detail.where,text:e.where.trim(),mono:!1}:null,e.command.trim()?{label:t.B.findings.detail.command,text:e.command.trim(),mono:!0}:null,e.outputTail.trim()?{label:t.B.findings.detail.output,text:e.outputTail.trim(),mono:!0}:null].filter(a=>null!==a):[],F=a.detail&&(!D||"fix_held"===a.kind)?a.detail:null,G=E.length>0||null!==F;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{flex:"none",width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:A.f.waiting,color:"#1a1206",fontWeight:900,fontSize:17},children:"?"}),(0,r.jsxs)("div",{style:{minWidth:0},children:[(0,r.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:t.B.question.title}),(0,r.jsx)("div",{style:{fontSize:12.5,color:"#d9c9a3"},children:t.B.question.waiting})]})]}),c&&c.of>1&&(0,r.jsx)("div",{style:{fontSize:11.5,fontWeight:700,letterSpacing:"0.04em",color:A.f.dim},children:t.B.question.position(c.n,c.of)}),(0,r.jsx)("p",{style:{margin:0,fontSize:15,lineHeight:1.45,color:A.f.ink,fontWeight:600,overflowWrap:"anywhere"},children:(0,iM.f)(a.text,d)}),a.why&&(0,r.jsx)("p",{style:{margin:0,fontSize:13,lineHeight:1.5,color:A.f.dim,overflowWrap:"anywhere"},children:(0,iM.f)(a.why,d)}),C.length>0&&(0,r.jsxs)("div",{style:{display:"grid",gap:4,fontSize:12.5,color:A.f.dim},children:[(0,r.jsx)("span",{style:{fontWeight:700},children:t.B.question.touchesTitle}),(0,r.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:C.map(a=>(0,r.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"baseline",padding:"6px 8px",borderRadius:8,border:`1px solid ${A.f.border}`,background:"#0d1118",color:"#d6dce6",overflowWrap:"anywhere"},children:[(0,r.jsx)("span",{style:{flex:"none",fontFamily:i2,fontSize:11.5,color:A.f.waiting},children:a.label}),(0,r.jsx)("span",{children:a.text})]},a.number))})]}),D&&(0,r.jsxs)("div",{style:{display:"grid",gap:4,padding:10,borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0d1118",minWidth:0},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:A.f.waiting},children:t.B.question.aiSaid}),(0,r.jsx)("span",{style:{fontSize:13,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:(0,iM.f)(i3(D),d)})]}),G&&(0,r.jsxs)("div",{style:{display:"grid",gap:6},children:[(0,r.jsx)("button",{type:"button",className:"factory-action","aria-expanded":p,"aria-controls":w,onClick:()=>q(a=>!a),style:{justifySelf:"start",background:"none",border:"none",padding:"6px 8px 6px 0",minHeight:32,color:A.f.running,cursor:"pointer",fontSize:12.5},children:t.B.question.seeDetails}),p&&(0,r.jsxs)("div",{id:w,style:{display:"grid",gap:8,padding:10,borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0d1118",minWidth:0},children:[E.map(a=>(0,r.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:A.f.dim},children:a.label}),(0,r.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",...a.mono?{fontFamily:i2,fontSize:12}:{}},children:a.text})]},a.label)),F&&(0,r.jsxs)("div",{style:{display:"grid",gap:2,minWidth:0},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:A.f.waiting},children:D?t.B.question.moreAbout:t.B.question.aiSaid}),(0,r.jsx)("span",{style:{fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:(0,iM.f)(F,d)})]})]})]}),(0,r.jsxs)("fieldset",{disabled:z,style:{margin:0,padding:0,border:"none",minWidth:0,display:"grid",gap:8},children:[(0,r.jsx)("legend",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:t.B.question.choicesLabel}),a.options.map(b=>{let c=f===b.id;return(0,r.jsxs)("label",{className:"factory-choice",style:{display:"flex",gap:10,alignItems:"flex-start",padding:"10px 12px",borderRadius:10,border:`1px solid ${c?A.f.waiting:A.f.border}`,background:c?A.f.tint("waiting",.1):"#0d1118",cursor:z?"not-allowed":"pointer"},children:[(0,r.jsx)("input",{type:"radio",name:v,value:b.id,checked:c,onChange:()=>g(b.id),style:{flex:"none",width:18,height:18,margin:"1px 0 0",accentColor:A.f.waiting,cursor:"inherit"}}),(0,r.jsxs)("span",{style:{display:"grid",gap:3,minWidth:0},children:[(0,r.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center",fontSize:14,fontWeight:700,color:A.f.ink},children:[b.label,a.recommended===b.id&&(0,r.jsx)("span",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:"#1a1206",background:A.f.waiting,borderRadius:999,padding:"2px 7px"},children:t.B.question.recommended})]}),(0,r.jsx)("span",{style:{fontSize:12.5,lineHeight:1.45,color:A.f.dim,overflowWrap:"anywhere"},children:b.means})]})]},b.id)}),(0,r.jsxs)("label",{style:{display:"grid",gap:4,fontSize:12.5,fontWeight:600,color:A.f.dim},children:[null===f?t.B.question.ownWordsLabel:t.B.question.noteLabel,(0,r.jsx)("textarea",{value:h,rows:3,placeholder:null===f?t.B.question.ownWordsPlaceholder:t.B.question.notePlaceholder,onChange:a=>i(a.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 ${A.f.border}`,borderRadius:8}})]})]}),(0,r.jsx)("button",{type:"button",className:"factory-action",disabled:!y||z,onClick:()=>void B(),style:{padding:"10px 12px",borderRadius:8,border:`1px solid ${A.f.waiting}`,background:y&&!z?A.f.waiting:"transparent",color:y&&!z?"#1a1206":A.f.skipped,fontWeight:700,fontSize:14,cursor:y&&!z?"pointer":"not-allowed"},children:j?t.B.question.sending:t.B.question.confirm}),n&&(0,r.jsx)("div",{role:"alert",style:{fontSize:13,fontWeight:600,color:A.f.failed,lineHeight:1.4},children:n}),l&&(0,r.jsx)("div",{role:"status",style:{fontSize:13,fontWeight:600,color:A.f.passed},children:t.B.question.sent})]})}function i5({runId:a,record:b,failed:c=!1,mark:d=0,readMark:e=0,askedId:f=null,onChanged:g}){let h=e<d,i=b?.question&&!(h&&null!==f&&b.question.id!==f)?b.question:null,[j,k]=(0,s.useState)(null),[l,m]=(0,s.useState)(null);i&&j?.id!==i.id&&(k(i),m(null));let n=(0,r.jsxs)("div",{role:"alert",style:{display:"grid",gap:8,fontSize:13,color:A.f.failed,lineHeight:1.4},children:[t.B.question.loadFailed,(0,r.jsx)("button",{type:"button",className:"factory-action",onClick:g,style:{justifySelf:"start",minHeight:32,padding:"6px 12px",borderRadius:8,border:`1px solid ${A.f.border}`,background:"#0f141c",color:"#e6e9ef",fontWeight:700,cursor:"pointer"},children:t.B.question.tryAgain})]});if(!i)return!b||h||c?c?n:(0,r.jsxs)("div",{"aria-busy":"true","aria-label":t.B.question.title,style:{display:"grid",gap:8},children:[(0,r.jsx)(h6,{height:20,width:"60%"}),(0,r.jsx)(h6,{height:70,radius:10})]}):(0,r.jsx)("div",{role:"status",style:{fontSize:13.5,fontWeight:600,color:A.f.dim,lineHeight:1.45},children:l??t.B.question.closed});async function o(b,c,d){let e;try{e=await fetch(`/api/runs/${encodeURIComponent(a)}/questions/${encodeURIComponent(i.id)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({option:b,...void 0!==c?{text:c}:{},...d&&d.length>0?{attachments:d}:{}})})}catch{throw Error(t.B.question.failed)}if(!e.ok){let a=await e.json().catch(()=>null),b=a?.error??t.B.question.failed;throw m(b),g(),Error(b)}g()}if("direct"===i.kind)return(0,r.jsxs)(r.Fragment,{children:[c&&n,(0,r.jsx)(i7,{question:i,onAnswer:o},i.id)]});let p=iQ(b.findings),q=p.findIndex(a=>a.id===i.findingId);return(0,r.jsxs)(r.Fragment,{children:[c&&n,(0,r.jsx)(i4,{question:i,touched:b.touched,onAnswer:o,position:q>=0?{n:q+1,of:p.length}:void 0,...q>=0?{finding:p[q].detail}:{}},i.id)]})}let i6=t.B.direct;function i7({question:a,onAnswer:b}){let[c,d]=(0,s.useState)(""),[e,f]=(0,s.useState)([]),[g,h]=(0,s.useState)(null),[i,j]=(0,s.useState)(null),k=(0,s.useRef)(!1),l=(0,s.useId)(),m=Number(/^direct-(\d+)/.exec(a.findingId??"")?.[1]??1),n=a.text===i6.lastText,o=a.options.some(a=>"undo"===a.id),p=!n&&(""!==c.trim()||e.length>0);async function q(a){if(!(k.current||"next"===a&&(""===c.trim()||iI(e)))&&("done"!==a||!p)){k.current=!0,h(a),j(null);try{await ("done"===a?b("leave"):"undo"===a?b("undo"):b(i1,c.trim(),iH(e)))}catch(a){j(a instanceof Error&&a.message?a.message:t.B.question.failed),k.current=!1,h(null)}}}let u=null!==g;return(0,r.jsxs)("div",{"data-testid":"direct-pause",style:{display:"grid",gap:12},children:[(0,r.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,r.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:i6.pauseTitle}),(0,r.jsxs)("div",{style:{fontSize:13,color:A.f.dim,lineHeight:1.45},children:[i6.look," ",i6.pauseWhy]})]}),a.detail&&(0,r.jsxs)("div",{style:{display:"grid",gap:4,padding:"10px 12px",borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0f141c"},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.1em",textTransform:"uppercase",color:A.f.dim},children:i6.lastBuilt}),(0,r.jsx)("span",{style:{fontSize:13.5,lineHeight:1.45,overflowWrap:"anywhere"},children:i3(a.detail)})]}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,fontSize:12,color:A.f.dim},children:[(0,r.jsx)("span",{children:i6.count(m)}),o&&(0,r.jsxs)("button",{type:"button",className:"factory-action","data-testid":"direct-undo",disabled:u,title:i6.undoMeans,onClick:()=>void q("undo"),style:{background:"none",border:"none",padding:0,color:"#cfe0ff",font:"inherit",fontWeight:700,cursor:u?"default":"pointer"},children:["↩ ","undo"===g?i6.sending:i6.undo]})]}),(m>=5||n)&&(0,r.jsx)("div",{role:"note","data-testid":"direct-many",style:{padding:"9px 12px",borderRadius:10,border:`1px solid ${A.f.waiting}`,color:"#f3d9a4",fontSize:13,lineHeight:1.45},children:n?i6.lastText:i6.many}),!n&&(0,r.jsx)(iJ,{inputId:l,label:i6.nextLabel,placeholder:i6.nextPlaceholder,text:c,onText:d,images:e,onImages:f,minHeight:96,disabled:u,onSubmit:()=>void q("next"),send:{label:i6.send,onSend:()=>void q("next"),enabled:!u&&""!==c.trim()&&!iI(e),busy:"next"===g}}),(0,r.jsxs)("div",{style:{display:"grid",gap:5,paddingTop:12,borderTop:`1px solid ${A.f.border}`},children:[(0,r.jsx)("button",{type:"button",className:"factory-action","data-testid":"direct-done",disabled:u||p,onClick:()=>void q("done"),style:{minHeight:40,padding:"9px 16px",borderRadius:9,border:"none",background:p?"#2a3140":A.f.passed,color:p?"#8b95a7":"#0d1f12",fontWeight:800,fontSize:14.5,cursor:p?"not-allowed":u?"default":"pointer"},children:"done"===g?i6.sending:i6.done}),p?(0,r.jsx)("span",{role:"note","data-testid":"direct-unsent",style:{fontSize:12.5,color:"#f3d9a4",textAlign:"center",lineHeight:1.45},children:i6.unsent}):(0,r.jsx)("span",{style:{fontSize:12,color:A.f.dim,textAlign:"center"},children:i6.doneHint})]}),i&&(0,r.jsx)("div",{role:"alert",style:{fontSize:13,color:A.f.failed},children:i})]})}function i8({runId:a,note:b,composer:c,onSent:d,measure:e}){let f=(0,s.useRef)(null),[g,h]=(0,s.useState)(new Set),[i,j]=(0,s.useState)(null),[k,l]=(0,s.useState)(null),[m,n]=(0,s.useState)(null),[o,p]=(0,s.useState)(!1),[q,u]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let b=!0;return fetch(`/api/runs/${a}/plan`).then(a=>a.ok?a.json():null).then(a=>b&&j((a?.plan?.jobs??[]).map((a,b)=>({key:`j${b}-${Date.now()}`,title:a.title,done:a.done.join("\n"),...a.paths?{paths:a.paths}:{}})))).catch(()=>b&&j([])),()=>{b=!1}},[a]);let v=m?.ok===!0;async function w(b,c){l(c),n(null);try{let e=await fetch(`/api/runs/${a}/plan`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b)}),f=await e.json().catch(()=>null);if(!e.ok)return n({ok:!1,text:f?.error??t.B.run.startFailed});if(f&&!1===f.delivered&&"machine"in f)return n({ok:!0,text:t.B.machine.sentElsewhere(f.machine??null)});n({ok:!0,text:"build"===c?t.B.plan.building_sent:t.B.plan.replanned}),"replan"===c&&d()}catch{n({ok:!1,text:t.B.run.startFailed})}finally{l(null)}}(0,s.useEffect)(()=>{if(!v)return;let a=setTimeout(()=>p(!0),2e4);return()=>clearTimeout(a)},[v]);let x=(a,b)=>j(c=>(c??[]).map(c=>c.key===a?{...c,...b}:c)),y=i?i.map(a=>({title:a.title.trim(),done:a.done.split("\n").map(a=>a.trim()).filter(Boolean),...a.paths?{paths:a.paths}:{}})).filter(a=>""!==a.title):[],z=null!==k||v,B={width:"100%",boxSizing:"border-box",background:"#0b0e14",color:"#d6dce6",border:`1px solid ${A.f.border}`,borderRadius:6,font:"inherit"};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,display:"grid",placeItems:"center",background:A.f.waiting,color:"#1a1206"},children:(0,r.jsx)(i9,{})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:t.B.plan.title}),(0,r.jsx)("div",{style:{fontSize:12.5,color:"#d9c9a3"},children:t.B.plan.waiting})]})]}),e&&e.reasons.length>0&&(0,r.jsxs)("div",{"data-testid":"plan-why",style:{display:"grid",gap:6,fontSize:13,lineHeight:1.45,color:"#d9c9a3",overflowWrap:"anywhere"},children:[q?(0,r.jsx)("ul",{style:{margin:0,paddingLeft:18,display:"grid",gap:4},children:e.reasons.map((a,b)=>(0,r.jsx)("li",{children:a},b))}):(0,r.jsx)("span",{children:e.reasons[0]}),e.question&&(0,r.jsx)("span",{"data-testid":"plan-question",style:{color:"#f1e6c8",fontWeight:600},children:e.question}),e.reasons.length>1&&(0,r.jsx)("button",{type:"button","aria-expanded":q,onClick:()=>u(a=>!a),style:{justifySelf:"start",padding:0,background:"none",border:"none",color:"#9cc2ff",fontSize:12.5,cursor:"pointer",textDecoration:"underline"},children:t.B.plan.whyStopped})]}),null===i?(0,r.jsxs)("div",{"aria-busy":"true",style:{display:"grid",gap:8},children:[(0,r.jsx)(h6,{height:70,radius:10}),(0,r.jsx)(h6,{height:70,radius:10})]}):(0,r.jsx)("ol",{ref:f,"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:`${A.f.skipped} transparent`},children:i.map((a,b)=>(0,r.jsxs)("li",{className:"factory-job-in",style:{display:"grid",gap:6,padding:10,borderRadius:10,border:`1px solid ${A.f.border}`,background:"#0d1118",animationDelay:`${300+260*Math.min(b,6)}ms`},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{fontSize:11,color:A.f.dim,paddingLeft:28},children:t.B.plan.jobWhat}),(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:-3},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{flex:"none",width:20,height:20,borderRadius:"50%",display:"grid",placeItems:"center",fontSize:11,fontWeight:800,background:A.f.tint("waiting",.2),color:A.f.waiting},children:b+1}),(0,r.jsx)("input",{"aria-label":t.B.plan.jobLabel(b+1),value:a.title,placeholder:t.B.plan.jobPlaceholder,disabled:z,onChange:b=>x(a.key,{title:b.target.value}),style:{...B,flex:1,minWidth:0,padding:"6px 8px",fontSize:13,fontWeight:600}}),(0,r.jsx)("button",{type:"button","aria-label":t.B.plan.removeJob(b+1),title:t.B.plan.removeJob(b+1),disabled:z,onClick:()=>j(b=>(b??[]).filter(b=>b.key!==a.key)),style:{flex:"none",width:26,height:26,display:"grid",placeItems:"center",padding:0,background:"none",border:"none",color:A.f.skipped,cursor:"pointer"},children:(0,r.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,r.jsx)("path",{d:"M2.5 4h11M6.5 4V2.5h3V4M4 4l.7 9.5h6.6L12 4"})})})]}),""!==a.done.trim()||g.has(a.key)?(0,r.jsxs)("label",{style:{display:"grid",gap:3,fontSize:11,color:A.f.dim,paddingLeft:28},children:[t.B.plan.doneLabel,(0,r.jsx)("textarea",{value:a.done,rows:Math.max(1,a.done.split("\n").length),placeholder:t.B.plan.donePlaceholder,disabled:z,onFocus:()=>h(b=>b.has(a.key)?b:new Set(b).add(a.key)),onChange:b=>x(a.key,{done:b.target.value}),style:{...B,padding:"5px 8px",fontSize:12,lineHeight:1.45,resize:"vertical"}})]}):!z&&(0,r.jsxs)("button",{type:"button",onClick:()=>h(b=>new Set(b).add(a.key)),style:{justifySelf:"start",marginLeft:28,padding:0,background:"none",border:"none",color:A.f.dim,fontSize:11.5,cursor:"pointer",textDecoration:"underline"},children:["+ ",t.B.plan.addChecks]})]},a.key))}),null!==i&&!z&&(0,r.jsxs)("button",{type:"button",onClick:()=>{j(a=>[...a??[],{key:`new-${Date.now()}`,title:"",done:""}]),requestAnimationFrame(()=>{let a=f.current?.lastElementChild;a?.scrollIntoView?.({block:"nearest",behavior:"smooth"}),a?.querySelector("input")?.focus({preventScroll:!0})})},style:{justifySelf:"start",display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:6,border:`1px dashed ${A.f.border}`,background:"transparent",color:"#d6dce6",fontSize:12.5,fontWeight:600,cursor:"pointer"},children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"+"})," ",t.B.plan.addJob]}),!v&&(0,r.jsxs)("button",{type:"button",disabled:z||0===y.length,onClick:()=>void w({action:"build",jobs:y},"build"),className:"factory-call",style:{padding:"9px 12px",borderRadius:8,border:`1px solid ${A.f.passed}`,background:y.length>0?A.f.passed:"transparent",color:y.length>0?"#07110a":A.f.skipped,fontWeight:700,cursor:z?"wait":0===y.length?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:["build"===k?(0,r.jsx)(D.m,{blockId:"plan-build",size:16}):(0,r.jsx)("span",{"aria-hidden":"true",children:"▶"})," ","build"===k?t.B.plan.building:t.B.plan.build]}),!v&&(0,r.jsx)("div",{style:{paddingTop:10,borderTop:`1px solid ${A.f.lineSoft}`,display:"grid"},children:c({label:t.B.plan.replan,onSend:()=>void w({action:"replan",note:b},"replan"),enabled:!z&&""!==b.trim()})}),m&&(0,r.jsxs)("div",{role:m.ok?"status":"alert",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:m.ok?A.f.passed:A.f.failed},children:[m.ok&&!o&&(0,r.jsx)(D.m,{blockId:"plan-sent",size:16}),m.text]}),v&&o&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12.5,color:A.f.waiting,lineHeight:1.4},children:t.B.plan.notPickedUp})]})}function i9(){return(0,r.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,r.jsx)("path",{d:"M6 4h7.5M6 8h7.5M6 12h7.5M2.5 4h.01M2.5 8h.01M2.5 12h.01"})})}let ja=t.B.delivery;function jb({runId:a,button:b}){let[c,d]=(0,s.useState)("idle"),[e,f]=(0,s.useState)(null),[g,h]=(0,s.useState)(null),i=(0,s.useRef)(null),j=(0,s.useRef)(!1);async function k(){i.current=window.open("","_blank"),j.current=!1,h(null),d("starting");let b=await fetch(`/api/runs/${a}/preview`,{method:"POST"}).catch(()=>null);if(j.current=!0,!b?.ok){let a=await b?.json().catch(()=>null);i.current?.close(),i.current=null,h(a?.error??null),d("failed")}}return((0,s.useEffect)(()=>{if("starting"!==c&&"open"!==c)return;let b=!0,e=async()=>{let e=await fetch(`/api/runs/${a}/preview`).catch(()=>null),g=e?.ok?await e.json().catch(()=>null):null;b&&g&&j.current&&("ready"===g.status&&g.url?(f(g.url),"starting"===c&&(i.current&&!i.current.closed?i.current.location.href=g.url:window.open(g.url,"_blank","noopener"),i.current=null,d("open"))):"open"===c&&"installing"!==g.status&&"starting"!==g.status?(f(null),d("idle")):("failed"===g.status||"stopped"===g.status)&&(i.current?.close(),i.current=null,h(g.message),d("failed")))},g=setInterval(()=>void e(),2e3);return e(),()=>{b=!1,clearInterval(g)}},[c,a]),"starting"===c)?(0,r.jsxs)("div",{"data-testid":"open-site",role:"status",style:{display:"grid",gap:4},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"#d6dce6"},children:[(0,r.jsx)(D.m,{blockId:"open-site",size:16})," ",ja.openingSite]}),(0,r.jsx)("div",{style:{fontSize:11.5,color:A.f.dim,lineHeight:1.4},children:ja.openingSiteHint})]}):"open"===c&&e?(0,r.jsxs)("div",{"data-testid":"open-site",style:{display:"grid",gap:6},children:[(0,r.jsxs)("div",{style:{fontSize:12.5,color:A.f.passed,lineHeight:1.4},children:["✓ ",ja.siteOpen]}),(0,r.jsxs)("a",{href:e,target:"_blank",rel:"noopener noreferrer",style:{...b(!1),textDecoration:"none"},children:["↗ ",ja.openSiteAgain]})]}):(0,r.jsxs)("div",{"data-testid":"open-site",style:{display:"grid",gap:4},children:["failed"===c&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12.5,color:A.f.failed,lineHeight:1.4},children:g??ja.siteFailed}),(0,r.jsxs)("button",{type:"button",onClick:()=>void k(),style:b(!1),children:["↗ ","failed"===c?ja.siteTryAgain:ja.openSite]}),"idle"===c&&(0,r.jsx)("div",{style:{fontSize:11.5,color:A.f.dim,lineHeight:1.4},children:ja.openSiteWhat})]})}let jc={pending:{glyph:"…",colour:A.f.waiting},passed:{glyph:"✓",colour:A.f.passed},failed:{glyph:"✕",colour:A.f.failed},neutral:{glyph:"·",colour:A.f.skipped}};function jd({checks:a}){return(0,r.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:3,fontSize:12},children:a.map((a,b)=>(0,r.jsxs)("li",{style:{display:"flex",gap:6,alignItems:"baseline"},children:[(0,r.jsx)("span",{"aria-hidden":"true",style:{color:jc[a.state].colour,fontWeight:800,width:12},children:jc[a.state].glyph}),a.url?(0,r.jsx)("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",style:{color:z.f.green},children:a.name}):(0,r.jsx)("span",{children:a.name}),(0,r.jsx)("span",{style:{color:A.f.dim},children:t.B.ship.checkState[a.state]})]},`${a.name}-${b}`))})}function je({runId:a,button:b,onState:c,canOpen:d=!0,onRecorded:e}){let[f,g]=(0,s.useState)(null),h=(0,s.useCallback)(a=>{g({...a,readAt:Date.now()}),c?.(a)},[c]),[i,j]=(0,s.useState)(null),[k,l]=(0,s.useState)(!1),[m,n]=(0,s.useState)(null),o=(0,s.useCallback)(()=>{fetch(`/api/runs/${a}/ship`).then(a=>a.ok?a.json():null).then(a=>a&&h(a)).catch(()=>void 0)},[a,h]);(0,s.useEffect)(o,[o]);let p=f?.pr?.state==="open",q=f?.pr?.state==="merged",u=q&&!0===f.deployPending,w=f?.conflictFix?.status==="working"||f?.conflictFix?.status==="done"&&f.pr?.conflicts===!0,x=p&&!f.checksDone||u||w;async function y(b){j(b),n(null);try{let c=await fetch(`/api/runs/${a}/ship`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:b})}),d=await c.json().catch(()=>null);if(!c.ok||!d)return n(d?.error??t.B.run.startFailed);h(d),l(!1),"fix-conflict"===b&&window.dispatchEvent(new Event(E)),e?.()}catch{n(t.B.run.startFailed)}finally{j(null)}}if((0,s.useEffect)(()=>{if(!x)return;let a=setInterval(o,8e3);return()=>clearInterval(a)},[x,o]),null===f)return(0,r.jsxs)("div",{"data-testid":"ship-skeleton","aria-busy":"true",style:{display:"grid",gap:6},children:[(0,r.jsx)(h6,{height:38,radius:8}),(0,r.jsx)(h6,{width:"70%",height:10})]});let B={fontSize:11.5,color:A.f.dim,lineHeight:1.4};return(0,r.jsxs)("div",{"data-testid":"ship-section",style:{display:"grid",gap:6},children:[!f.pr&&d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button",disabled:null!==i,onClick:()=>void y("open"),style:b(i),children:["open"===i?(0,r.jsx)(D.m,{blockId:"ship-open",size:16}):(0,r.jsx)(jf,{})," ","open"===i?t.B.ship.opening:t.B.ship.shipIt]}),(0,r.jsx)("div",{style:{...B,marginTop:-2},children:t.B.ship.shipWhat})]}),f.pr&&(0,r.jsxs)("div",{style:{display:"grid",gap:6,fontSize:12.5,lineHeight:1.4},children:[(0,r.jsxs)("a",{href:f.pr.url,target:"_blank",rel:"noopener noreferrer",style:{color:z.f.green,fontWeight:600,fontSize:12},children:[t.B.ship.pr(f.pr.number)," ↗"]}),"closed"===f.pr.state&&(0,r.jsx)("span",{style:{color:A.f.failed},children:t.B.ship.closed}),p&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.1em",textTransform:"uppercase",color:A.f.dim},children:t.B.ship.checksTitle}),!f.checksDone&&(0,r.jsxs)("div",{role:"status","data-testid":"ship-checking",style:{display:"flex",gap:10,alignItems:"center",padding:"10px 12px",borderRadius:8,border:`1px solid ${A.f.tint("running",.5)}`,background:A.f.tint("running",.1),color:"#cfe0ff",fontSize:13,fontWeight:600,lineHeight:1.4},children:[(0,r.jsx)(D.m,{blockId:"ship-checks",size:18}),0===f.checks.length?t.B.ship.looking:t.B.ship.waiting]}),f.checks.length>0&&(0,r.jsx)(jd,{checks:f.checks}),f.checksDone&&0===f.checks.length&&(0,r.jsx)("span",{style:B,children:t.B.ship.noChecks}),f.checksDone&&f.checks.length>0&&!f.checksFailed&&(0,r.jsxs)("span",{style:{color:A.f.passed},children:["✓ ",t.B.ship.allPassed]}),f.checksFailed&&(0,r.jsx)("span",{style:{color:A.f.failed},children:t.B.ship.someFailed}),f.pr.conflicts&&f.conflictFix?.status!=="working"&&f.conflictFix?.status!=="done"&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{style:{color:A.f.failed},children:t.B.ship.conflicts}),f.conflictFix?.status==="failed"&&(0,r.jsx)("span",{role:"alert","data-testid":"conflict-failed",style:{color:A.f.failed},children:f.conflictFix.message}),f.conflictFix?.status==="failed"&&(0,r.jsxs)("a",{"data-testid":"conflict-on-github",href:`${f.pr.url.replace(/\/+$/,"")}/conflicts`,target:"_blank",rel:"noopener noreferrer",style:{color:z.f.green,fontWeight:600},children:[t.B.conflict.onGitHub," ↗"]}),d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button","data-testid":"fix-conflict",disabled:null!==i,onClick:()=>void y("fix-conflict"),style:b(i),children:["fix-conflict"===i&&(0,r.jsx)(D.m,{blockId:"fix-conflict",size:16})," ",t.B.conflict.fix]}),(0,r.jsx)("span",{style:B,children:t.B.conflict.what})]})]}),(f.conflictFix?.status==="working"||f.conflictFix?.status==="done"&&f.pr.conflicts)&&(0,r.jsxs)("div",{role:"status","data-testid":"conflict-working",style:{display:"flex",gap:10,alignItems:"center",padding:"10px 12px",borderRadius:8,border:`1px solid ${A.f.tint("running",.5)}`,background:A.f.tint("running",.08),lineHeight:1.4},children:[(0,r.jsx)(D.m,{blockId:"conflict-fix",size:18}),(0,r.jsx)("span",{children:"working"===f.conflictFix.status?f.conflictFix.message:t.B.conflict.seen})]}),f.conflictFix?.status==="done"&&!f.pr.conflicts&&(0,r.jsxs)("span",{"data-testid":"conflict-done",style:{color:A.f.passed},children:["✓ ",f.conflictFix.message]}),f.onHold&&(0,r.jsxs)("div",{"data-testid":"on-hold",style:{display:"flex",gap:8,alignItems:"flex-start",padding:8,borderRadius:8,border:`1px solid ${A.f.tint("waiting",.5)}`,background:A.f.tint("waiting",.08),color:A.f.waiting},children:[(0,r.jsx)("span",{style:{marginTop:2},children:(0,r.jsx)(v.h,{size:12})}),(0,r.jsx)("span",{style:{lineHeight:1.4},children:t.B.ship.onHold})]}),f.checksDone&&!f.checksFailed&&!f.pr.conflicts&&!k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{style:{display:"flex",gap:6},children:[(0,r.jsx)("button",{type:"button",disabled:null!==i,onClick:()=>l(!0),style:{...b(i),flex:1},children:t.B.ship.merge}),(0,r.jsxs)("button",{type:"button",disabled:null!==i,onClick:()=>void y(f.onHold?"unhold":"hold"),style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:6,padding:"6px 10px",borderRadius:8,border:`1px solid ${A.f.tint("waiting",.6)}`,background:"transparent",color:A.f.waiting,fontWeight:700,cursor:i?"wait":"pointer"},children:["hold"===i||"unhold"===i?(0,r.jsx)(D.m,{blockId:"ship-hold",size:13}):(0,r.jsx)(v.h,{size:11}),"hold"===i?t.B.ship.holding:f.onHold?t.B.ship.unhold:t.B.ship.hold]})]}),(0,r.jsx)("div",{style:{...B,marginTop:-2},children:t.B.ship.mergeWhat}),!f.onHold&&(0,r.jsx)("div",{style:B,children:t.B.ship.holdWhat})]}),k&&(0,r.jsxs)("div",{role:"group","aria-label":t.B.ship.confirm,className:"factory-ask-in",style:{display:"grid",gap:6,padding:8,border:`1px solid ${A.f.tint("waiting",.5)}`,borderRadius:8,background:A.f.tint("waiting",.08)},children:[t.B.ship.confirm,(0,r.jsxs)("span",{style:{display:"flex",gap:6},children:[(0,r.jsxs)("button",{type:"button",disabled:null!==i,onClick:()=>void y("merge"),style:{...b(i),flex:1},children:["merge"===i?(0,r.jsx)(D.m,{blockId:"ship-merge",size:14}):null," ","merge"===i?t.B.ship.merging:t.B.ship.yes]}),(0,r.jsx)("button",{type:"button",disabled:null!==i,onClick:()=>l(!1),style:{flex:1,padding:"6px 10px",borderRadius:8,border:`1px solid ${A.f.dim}`,background:z.f.card,color:A.f.ink,fontWeight:600,cursor:"pointer"},children:t.B.ship.no})]})]})]}),q&&(0,r.jsxs)(r.Fragment,{children:[u?(0,r.jsxs)("div",{role:"status","data-testid":"ship-publishing",style:{display:"flex",gap:10,alignItems:"center",padding:"10px 12px",borderRadius:8,border:`1px solid ${A.f.tint("running",.5)}`,background:A.f.tint("running",.1),color:"#cfe0ff",fontSize:13,fontWeight:600,lineHeight:1.4},children:[(0,r.jsx)(D.m,{blockId:"ship-deploy",size:18}),t.B.ship.deployWaiting]}):(0,r.jsxs)("span",{style:{color:A.f.passed,fontWeight:700},children:["✓ ",t.B.ship.merged]}),void 0!==f.folder&&(0,r.jsx)("span",{"data-testid":"ship-folder",style:B,children:f.folder?t.B.ship.folderUpdated:t.B.ship.folderNot}),f.deploy.length>0&&(0,r.jsx)(jd,{checks:f.deploy}),!u&&0===f.deploy.length&&(0,r.jsx)("span",{style:B,children:t.B.ship.noDeploy}),!u&&f.deploy.length>0&&!f.deploy.some(a=>"failed"===a.state)&&(0,r.jsxs)("span",{style:{color:A.f.passed},children:["✓ ",t.B.ship.live]}),f.deploy.some(a=>"failed"===a.state)&&(0,r.jsx)("span",{style:{color:A.f.failed},children:t.B.ship.deployFailed})]})]}),m&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12.5,color:A.f.failed,lineHeight:1.4},children:m})]})}function jf(){return(0,r.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,r.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 jg=a.i(89956);let jh=t.B.delivery.throwAway,ji={padding:"10px 16px",borderRadius:8,border:`1px solid ${z.f.line}`,background:"transparent",color:z.f.text,font:"inherit",fontSize:14,cursor:"pointer"};function jj({runId:a,prOpen:b,onGone:c}){let[d,e]=(0,s.useState)(!1),[f,g]=(0,s.useState)(!1),[h,i]=(0,s.useState)(null);async function j(){g(!0),i(null);try{let b=await fetch(`/api/runs/${a}/throw-away`,{method:"POST"}),d=await b.json().catch(()=>null);if(!b.ok||!d?.deleted)return i(d?.error??t.B.run.startFailed);e(!1),c()}catch{i(t.B.run.startFailed)}finally{g(!1)}}let k=()=>{f||e(!1)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button","data-testid":"throw-away",onClick:()=>{i(null),e(!0)},style:{width:"100%",padding:"10px 14px",borderRadius:8,border:`1px solid ${A.f.failed}`,background:A.f.tint("failed",.12),color:"#fecaca",font:"inherit",fontSize:13.5,fontWeight:600,cursor:"pointer"},children:jh.link}),d&&(0,r.jsxs)(jg.f,{title:jh.title,testid:"throw-away-dialog",onClose:k,children:[(0,r.jsxs)("p",{style:{margin:0,color:z.f.quiet,fontSize:15,lineHeight:1.5},children:[jh.text,b?` ${jh.prToo}`:""]}),h&&(0,r.jsx)("p",{role:"alert",style:{margin:0,color:A.f.failed,fontSize:13.5,lineHeight:1.45},children:h}),(0,r.jsxs)("div",{style:{display:"flex",gap:10,justifyContent:"flex-end",flexWrap:"wrap"},children:[(0,r.jsx)("button",{type:"button",disabled:f,onClick:k,style:ji,children:jh.no}),(0,r.jsxs)("button",{type:"button","data-testid":"throw-away-yes",disabled:f,onClick:()=>void j(),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:8,padding:"10px 16px",borderRadius:8,border:`1px solid ${A.f.failed}`,background:A.f.tint("failed",.16),color:"#fecaca",font:"inherit",fontSize:14,fontWeight:700,cursor:f?"wait":"pointer"},children:[f&&(0,r.jsx)(D.m,{blockId:"throw-away",size:14}),f?jh.busy:jh.yes]})]})]})]})}function jk({runId:a,note:b,imageIds:c,imagesBusy:d,composer:e,onFollowUp:f,onShipState:g,away:h=null,onRecorded:i,onNewTask:j,onDeleted:k}){let l=(0,s.useContext)(iG),[m,n]=(0,s.useState)(null),[o,p]=(0,s.useState)(null),q=(0,s.useCallback)(a=>{n(a);let b=a.autoShip?.state==="started"?a.autoShip.at??"started":null;null!==b&&p(a=>a?.key===b?a:{key:b,at:Date.now()})},[]),[u,v]=(0,s.useState)(!1),[w,x]=(0,s.useState)(!1),B=w||""!==b.trim(),[C,E]=(0,s.useState)(null),[F,G]=(0,s.useState)(!1),[H,I]=(0,s.useState)(""),[J,K]=(0,s.useState)(!1),[L,M]=(0,s.useState)(null),[N,O]=(0,s.useState)(null),P=N?.pr!=null,Q=N?.pr?.state==="merged",R=N?.pr?.state==="open"&&!N.checksDone,S=Q&&N?.deployPending===!0,T=Q&&void 0!==j&&!B,U=R||S,V=(0,s.useCallback)(a=>{O(a),g?.(a)},[g]),[W,X]=(0,s.useState)(null);async function Y(b){X((b??"").replace(/^https:\/\/github\.com\/|^git@github\.com:/,"").replace(/\.git$/,"")),n(a=>a&&{...a,hasRemote:!0});let c=await fetch(`/api/runs/${a}/delivery`).catch(()=>null);c?.ok&&q(await c.json())}let[Z,$]=(0,s.useState)(null),[aa,ab]=(0,s.useState)(!1),[ac,ad]=(0,s.useState)(null);async function ae(){ab(!0),ad(null);try{let b=await fetch(`/api/runs/${a}/connect-github`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skip:!0})}),c=await b.json().catch(()=>null);if(!b.ok)return ad(c?.error??t.B.run.startFailed);$(!0)}catch{ad(t.B.run.startFailed)}finally{ab(!1)}}(0,s.useEffect)(()=>{let b=!0;return fetch(`/api/runs/${a}/delivery`).then(a=>a.ok?a.json():null).then(a=>b&&a&&q(a)).catch(()=>void 0).finally(()=>b&&v(!0)),()=>{b=!1}},[a,q]);let[af,ag]=(0,s.useState)(()=>Date.now()),ah=m?.autoShip?.state==="started"?m.autoShip.at??"started":null,ai=null!==ah,aj=ai&&o?.key===ah&&af-o.at>18e4,ak=ai&&!aj;(0,s.useEffect)(()=>{if(!ai)return;let b=setInterval(()=>{ag(Date.now()),fetch(`/api/runs/${a}/delivery`).then(a=>a.ok?a.json():null).then(a=>a&&q(a)).catch(()=>void 0)},3e3);return()=>clearInterval(b)},[ai,a,q]);let[al,am]=(0,s.useState)(!1),an=m?.eligible===!0&&!m.kept;async function ao(){K(!0);try{let b=await fetch(`/api/runs/${a}/branch-name`),c=await b.json().catch(()=>null);b.ok&&c?.name&&I(c.name)}catch{}finally{K(!1)}}async function ap(b){E(b),M(null);try{let c=await fetch(`/api/runs/${a}/delivery`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify("branch"===b||"apply"===b?{mode:b,name:H.trim()}:{mode:b})}),d=await c.json().catch(()=>null);if(!c.ok||!d)return M(d?.error??t.B.run.startFailed);q(d),i?.()}catch{M(t.B.run.startFailed)}finally{E(null)}}async function aq(){E("follow"),M(null);try{let d=await fetch(`/api/runs/${a}/follow-up`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({note:b,attachments:c})}),e=await d.json().catch(()=>null);if(!d.ok||!e?.runId)return M(e?.error??t.B.run.startFailed);f(e.runId)}catch{M(t.B.run.startFailed)}finally{E(null)}}if((0,s.useEffect)(()=>{an&&ao()},[an,a]),!u)return(0,r.jsx)(h8,{});if(!m?.eligible)return(0,r.jsx)(r.Fragment,{children:e()});let ar=m.kept&&null!==m.branch,as=y(N),at=ar&&!P&&!h&&!1===m.hasRemote,au=at&&(Z??!0===m.githubSkipped),av=Q&&!S?4:Q||as?3:ar?2:1,aw=t.B.delivery,ax=m.autoShip,ay=ax?.reason==="no_connection"&&ax.message===aw.noRemote,az=ax?.state==="stopped"&&(au&&"no_connection"===ax.reason||"keep"===ax.step&&ar||"send"===ax.step&&(P||m.pushed||ay&&(!0===m.hasRemote||null!==W))||"open"===ax.step&&P),aA=ax?.state==="opened"?N?.pr?.state!=="open"||N.checksFailed||N.pr.conflicts?null:`${"app"===m.passedBy?aw.auto.openedByApp:aw.auto.openedAfterYes}${as?` ${aw.auto.publishWhenReady}`:""}`:ax?.state!=="stopped"||az?aj?aw.auto.seemsStopped:ax||"app"!==m.passedBy||ar||m.delivered?null:aw.auto.passedReady:"open"===ax.step?aw.auto.stopped.open:"keep"===ax.step?aw.auto.stopped.keep:"no_connection"===ax.reason?aw.auto.stopped.noConnection:aw.auto.stopped.send,aB=ak?aw.auto.working:S?aw.nowPublishing:Q?aw.finished:as?N.onHold?aw.nowOnHold:aw.nowPublish:N?.pr?.state==="closed"?aw.nowClosed:P?N.checksFailed||N.pr.conflicts?aw.nowProblem:aw.nowChecking:ar?at?aw.nowSaved:aw.nowSend:aw.nowSave,aC=ar&&m.current===m.branch,aD=!h&&!P&&!m.delivered&&!aC,aE=!h&&ar&&!P&&!m.pushed&&!at;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(jl,{current:av,passedByApp:"app"===m.passedBy,docked:l}),(0,r.jsxs)("div",{style:l?{display:"grid",gap:12,gridTemplateColumns:"minmax(0, 1fr)",padding:18,borderRadius:14,border:`1px solid ${z.f.line}`,background:z.f.card}:{display:"contents"},children:[(0,r.jsxs)("div",{"data-testid":"next-step",role:ak?"status":void 0,style:{display:"flex",alignItems:"center",gap:8,fontSize:l?16:13.5,fontWeight:l?700:void 0,color:l?z.f.text:"#d6dce6",lineHeight:1.45,overflowWrap:"anywhere"},children:[ak&&(0,r.jsx)(D.m,{blockId:"auto-ship",size:16}),(0,r.jsx)("span",{style:{minWidth:0},children:aB})]}),Q&&j&&(0,r.jsxs)("div",{"data-testid":"next-change",style:{display:"grid",gap:10,fontSize:13.5,lineHeight:1.5,color:"#c9d0db"},children:[(0,r.jsx)("span",{children:aw.nextChange}),[{key:"new",when:aw.newTaskWhen,points:aw.newTaskPoints},{key:"keep",when:aw.keepHereWhen,points:aw.keepHerePoints}].map(a=>(0,r.jsxs)("div",{"data-testid":`way-${a.key}`,style:{display:"grid",gap:8,padding:"12px 14px",borderRadius:11,border:`1px solid ${z.f.line}`,background:"#141414"},children:[(0,r.jsx)("strong",{style:{fontSize:13.5,color:"#e6e9ef"},children:a.when}),(0,r.jsx)("ul",{style:{margin:0,paddingLeft:18,display:"grid",gap:3,fontSize:12.5,color:"#c9d0db"},children:a.points.map(a=>(0,r.jsx)("li",{children:a},a))}),"new"===a.key?(0,r.jsxs)("button",{type:"button",className:"factory-action",onClick:j,style:{marginTop:2,padding:"9px 14px",borderRadius:9,border:`1px solid ${A.f.passed}`,background:A.f.passed,color:"#0d1f12",fontWeight:800,fontSize:14,cursor:"pointer"},children:["+ ",aw.newTask]}):(0,r.jsx)("button",{type:"button",className:"factory-action","data-testid":"keep-here","aria-pressed":B,onClick:()=>x(!0),style:{marginTop:2,padding:"9px 14px",borderRadius:9,border:`1.5px solid ${A.f.passed}`,background:A.f.tint("passed",B?.28:.12),color:A.f.passed,fontWeight:800,fontSize:14,cursor:"pointer"},children:B?`${aw.keepHere} ↓`:aw.keepHere})]},a.key))]}),aA&&(0,r.jsxs)("div",{"data-testid":"auto-line",style:{display:"grid",gap:6,fontSize:12.5,lineHeight:1.45,color:ax?.state==="stopped"?A.f.waiting:"#b9dcc5",overflowWrap:"anywhere"},children:[(0,r.jsx)("span",{children:aA}),ax?.state==="stopped"&&!az&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{style:{color:A.f.dim},children:aw.auto.tryAgain}),ax.message&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button","aria-expanded":al,onClick:()=>am(a=>!a),style:{justifySelf:"start",padding:0,background:"none",border:"none",color:z.f.green,fontSize:12.5,cursor:"pointer",textDecoration:"underline"},children:aw.auto.whatHappened}),al&&(0,r.jsx)("span",{"data-testid":"auto-message",style:{color:A.f.dim},children:ax.message})]})]})]}),(0,r.jsxs)("div",{style:{display:"grid",gap:8,gridTemplateColumns:"minmax(0, 1fr)"},children:[h&&!Q&&(0,r.jsx)("div",{"data-testid":"away",style:{fontSize:12.5,color:A.f.waiting,lineHeight:1.45},children:t.B.machine.elsewhere(h.machine)}),!ar&&!h&&!ak&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"grid",gap:4,fontSize:12,color:A.f.dim},children:[(0,r.jsx)("label",{htmlFor:`branch-name-${a}`,children:aw.branchName}),(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("input",{id:`branch-name-${a}`,value:H,placeholder:aw.branchPlaceholder,disabled:null!==C||J,spellCheck:!1,onChange:a=>I(a.target.value),style:{flex:1,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,padding:"7px 8px",background:z.f.bg,color:"#d6dce6",border:`1px solid ${z.f.line}`,borderRadius:6,minWidth:0}}),(0,r.jsxs)("button",{type:"button",disabled:null!==C||J,onClick:()=>void ao(),style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",borderRadius:6,border:`1px solid ${z.f.line}`,background:z.f.card,color:"#d6dce6",fontSize:12,fontWeight:600,cursor:J?"wait":"pointer",whiteSpace:"nowrap"},children:[J?(0,r.jsx)(D.m,{blockId:"suggest",size:12}):(0,r.jsx)(jq,{})," ",J?aw.suggesting:aw.suggestName]})]}),(0,r.jsx)("span",{style:{fontSize:11,lineHeight:1.4},children:aw.branchNameHint})]}),(0,r.jsxs)("button",{type:"button",disabled:null!==C,onClick:()=>void ap("branch"),style:jo(C),children:["branch"===C?(0,r.jsx)(D.m,{blockId:"keep",size:16}):(0,r.jsx)(jm,{})," ",aw.keepButton]})]}),ar&&!ak&&(0,r.jsxs)("div",{"data-testid":"kept",style:{display:"grid",gap:8,gridTemplateColumns:"minmax(0, 1fr)"},children:[at&&!au?(0,r.jsxs)("div",{"data-testid":"not-connected",style:{display:"grid",gap:10,padding:14,borderRadius:10,border:`1px solid ${z.f.line}`,background:"#141414",fontSize:13,lineHeight:1.45},children:[(0,r.jsx)("span",{style:{color:"#c9d0db"},children:aw.notConnected.offer}),(0,r.jsx)(_,{endpoint:`/api/runs/${a}/connect-github`,onConnected:Y}),(0,r.jsx)("button",{type:"button","data-testid":"skip-github",disabled:aa,onClick:()=>void ae(),style:{...jp(null),cursor:aa?"wait":"pointer"},children:aa?aw.notConnected.skipping:aw.notConnected.skip}),ac&&(0,r.jsx)("span",{role:"alert",style:{color:A.f.failed},children:ac})]}):au?(0,r.jsx)("div",{"data-testid":"github-skipped",style:{fontSize:12.5,color:A.f.dim,lineHeight:1.45},children:aw.notConnected.skipped}):(0,r.jsxs)(r.Fragment,{children:[null!==W&&!P&&(0,r.jsxs)("div",{role:"status","data-testid":"connected",style:{display:"flex",alignItems:"center",gap:8,padding:"9px 11px",borderRadius:8,border:`1px solid ${A.f.tint("passed",.5)}`,background:A.f.tint("passed",.1),fontSize:13,color:"#d7f5e0",lineHeight:1.4},children:[(0,r.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:A.f.passed,strokeWidth:"2.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:(0,r.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})}),aw.connect.done(W)]}),(0,r.jsx)(je,{runId:a,button:jo,onState:V,canOpen:!h,onRecorded:i})]}),!Q&&!h&&(0,r.jsx)(jb,{runId:a,button:jp})]}),m.delivered&&(0,r.jsx)("div",{style:{fontSize:12.5,color:"#b9dcc5",lineHeight:1.4},children:aw.done(m.files.length)})]})]}),(ar||aD)&&!U&&!ak&&(0,r.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,r.jsxs)("button",{type:"button","aria-expanded":F,onClick:()=>G(a=>!a),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderRadius:8,border:`1px solid ${z.f.line}`,background:z.f.card,color:"#d6dce6",fontSize:12.5,fontWeight:600,cursor:"pointer"},children:[aw.moreOptions,(0,r.jsx)("span",{"aria-hidden":"true",style:{display:"inline-block",transform:F?"rotate(180deg)":"none",transition:"transform 150ms ease-out"},children:"▾"})]}),F&&(0,r.jsxs)("div",{"data-testid":"more-options",style:{display:"grid",gap:8},children:[ar&&(0,r.jsxs)("dl",{"data-testid":"kept-facts",style:{...jn,margin:0,gridTemplateColumns:"auto minmax(0, 1fr)",columnGap:12,rowGap:6,fontSize:12},children:[(0,r.jsx)("dt",{style:{color:A.f.dim},children:aw.branchLabel}),(0,r.jsx)("dd",{style:{margin:0,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",color:"#d6dce6",overflowWrap:"anywhere"},children:m.branch}),(0,r.jsx)("dt",{style:{color:A.f.dim},children:aw.commitLabel}),(0,r.jsx)("dd",{style:{margin:0,fontFamily:"var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",color:"#d6dce6"},children:(m.commit??"").slice(0,7)})]}),ar&&!h&&(aC||!Q)&&(0,r.jsx)("div",{style:jn,children:aC?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{"data-testid":"on-branch",style:{fontSize:12,color:A.f.passed,lineHeight:1.4,overflowWrap:"anywhere"},children:["✓ ",aw.onBranch(m.branch)]}),m.returnTo&&(0,r.jsxs)("button",{type:"button",disabled:null!==C,onClick:()=>void ap("back"),style:jp(C),children:["back"===C?(0,r.jsx)(D.m,{blockId:"back",size:16}):"←"," ",aw.backButton(m.returnTo)]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button",disabled:null!==C,onClick:()=>void ap("switch"),style:jp(C),children:["switch"===C?(0,r.jsx)(D.m,{blockId:"switch",size:16}):(0,r.jsx)("span",{"aria-hidden":"true",children:"⇄"})," ",aw.switchButton]}),(0,r.jsx)("div",{style:{fontSize:11.5,color:A.f.dim,lineHeight:1.4},children:aw.switchWhat})]})}),aE&&(0,r.jsxs)("div",{style:jn,children:[(0,r.jsxs)("button",{type:"button",disabled:null!==C,onClick:()=>void ap("push"),style:jp(C),children:["push"===C?(0,r.jsx)(D.m,{blockId:"push",size:16}):"↑"," ",aw.pushOnly]}),(0,r.jsx)("div",{style:{fontSize:11.5,color:A.f.dim,lineHeight:1.4},children:aw.pushOnlyWhat})]}),aD&&(0,r.jsxs)("div",{style:jn,children:[(0,r.jsxs)("button",{type:"button",disabled:null!==C,onClick:()=>void ap("apply"),style:jp(C),children:["apply"===C?(0,r.jsx)(D.m,{blockId:"apply",size:16}):"⤵"," ",aw.applyButton]}),(0,r.jsx)("div",{style:{fontSize:11.5,color:A.f.dim,lineHeight:1.4},children:aw.applyWhat})]})]})]}),!Q&&!S&&!h&&!ak&&(0,r.jsx)(jj,{runId:a,prOpen:N?.pr?.state==="open",onGone:()=>{i?.(),k?.()}}),(0,r.jsxs)("div",{"data-testid":"follow-up-box",style:{display:U||T?"none":"grid",gap:6,gridTemplateColumns:"minmax(0, 1fr)",paddingTop:10,borderTop:`1px solid ${A.f.lineSoft}`,...l?{marginTop:"auto",marginInline:-20,padding:"20px 20px 0",gap:10,borderTop:`1px solid ${z.f.line}`}:null},children:[(0,r.jsx)("div",{style:{fontSize:12,color:A.f.dim},children:Q?t.B.followUp.hintPublished:t.B.followUp.hint}),e({label:t.B.followUp.start,name:Q?t.B.followUp.titleContinue:t.B.followUp.titleAdjust,onSend:()=>void aq(),enabled:null===C&&!d&&""!==b.trim(),busy:"follow"===C})]}),L&&(0,r.jsx)("div",{role:"alert",style:{fontSize:12.5,color:A.f.failed,lineHeight:1.4},children:L})]})}function jl({current:a,passedByApp:b,docked:c=!1}){let d=b?[t.B.delivery.passedStep,...t.B.delivery.steps.slice(1)]:t.B.delivery.steps,e=c?26:18;return(0,r.jsx)("ol",{"data-testid":"steps","aria-label":t.B.delivery.stepsLabel,style:{listStyle:"none",margin:0,padding:0,display:"flex",alignItems:c?"flex-start":"center",gap:4*!c},children:d.map((b,f)=>{let g=f<a||4===a,h=f===a&&4!==a,i=g?A.f.passed:h?"#d6dce6":A.f.skipped,j=(0,r.jsx)("span",{"aria-hidden":"true",style:{position:"relative",width:e,height:e,flex:"none",borderRadius:"50%",display:"grid",placeItems:"center",fontSize:c?13:10,fontWeight:900,background:g?A.f.passed:z.f.bg,color:g?"#07110a":i,border:`1.5px solid ${g?A.f.passed:i}`},children:g?"✓":f+1}),k=g&&f+1<=a?A.f.tint("passed",.6):z.f.line;return c?(0,r.jsxs)("li",{"aria-current":h?"step":void 0,style:{position:"relative",flex:"1 1 0",minWidth:0,display:"grid",justifyItems:"center",gap:8},children:[f<d.length-1&&(0,r.jsx)("span",{"aria-hidden":"true",style:{position:"absolute",top:e/2-1,left:"50%",width:"100%",height:1.5,background:k}}),j,(0,r.jsx)("span",{style:{fontSize:12.5,fontWeight:h?800:500,color:g?z.f.quiet:i,textAlign:"center",lineHeight:1.3,textWrap:"balance"},children:b})]},b):(0,r.jsxs)("li",{"aria-current":h?"step":void 0,style:{display:"flex",alignItems:"center",gap:4,flex:f<d.length-1?"1 1 auto":"none",minWidth:0},children:[j,(0,r.jsx)("span",{style:{fontSize:11.5,fontWeight:h?800:600,color:i,whiteSpace:"nowrap"},children:b}),f<d.length-1&&(0,r.jsx)("span",{"aria-hidden":"true",style:{flex:1,height:1.5,minWidth:8,background:k}})]},b)})})}function jm(){return(0,r.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,r.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 jn={display:"grid",gap:6,padding:10,borderRadius:8,border:`1px solid ${z.f.line}`,background:"#141414"};function jo(a){return{padding:"9px 12px",borderRadius:8,border:`1px solid ${A.f.passed}`,background:A.f.passed,color:"#07110a",fontWeight:700,cursor:a?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8}}function jp(a){return{padding:"8px 12px",borderRadius:8,border:`1px solid ${A.f.tint("passed",.6)}`,background:"transparent",color:"#b9dcc5",fontWeight:700,cursor:a?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8}}function jq(){return(0,r.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,r.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 jr={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}},js=(0,s.forwardRef)(function({docked:a=!1,direct:b=!1,planMeasure:c,stopForMe:d=!1,onStopForMe:e,onSeeChanges:f,record:g=null,recordFailed:h=!1,recordMark:i=0,recordReadMark:j=0,askedId:k=null,onRecordChanged:l,showFindings:m=!1,notice:n,mode:o,runId:p,risk:q,text:u,onText:v,images:w,onImages:x,onRun:y,canRun:B,onFollowUp:C,onNewTask:E,onTaskDeleted:F,onSent:G,startOptions:H=[],startFrom:I,onStartFrom:J,onShipState:K,loading:L=!1,taskName:M,onTaskName:N,away:O=null,onRecorded:P,failureActions:Q,onCanContinue:R},S){let T=jr[o],[U,V]=hS(hO,!1),W=a&&U,[X,Y]=(0,s.useState)(!1),Z=a=>{Y(!0),V(a)},$="plan"===o?t.B.plan.replanLabel:"waiting"===o?t.B.gate.reasonLabel:"done"===o?t.B.followUp.title:"failed"===o?t.B.failure.label:t.B.run.requestLabel,_="plan"===o?t.B.plan.replanPlaceholder:"waiting"===o?t.B.gate.reasonPlaceholder:"done"===o?t.B.followUp.placeholder:"failed"===o?t.B.failure.placeholder:t.B.run.requestPlaceholder,aa=a=>(0,r.jsx)(iJ,{send:a,minHeight:"waiting"===o||"done"===o||"plan"===o||"failed"===o?96:void 0,inputId:ik,label:a?.name??$,placeholder:_,text:u,onText:v,images:w,onImages:x,onSubmit:"idle"===o&&B?y:void 0});return(0,r.jsxs)(r.Fragment,{children:[W&&(0,r.jsx)(jv,{mode:L?"idle":o,glide:X,onOpen:()=>Z(!1)}),(0,r.jsx)("section",{ref:S,className:X&&!W?"factory-from-right":void 0,tabIndex:-1,"data-testid":"command-card","data-mode":o,"aria-label":"plan"===o?t.B.plan.title:"question"===o?t.B.question.title:"waiting"===o?t.B.gate.title:"done"===o?t.B.delivery.title:t.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, ${T.from} 0%, ${T.to} 100%)`,border:`1px solid ${A.f.tint(T.tone,T.strength)}`,borderRadius:14,boxShadow:`0 0 0 1px ${A.f.tint(T.tone,.15)}, 0 0 30px ${A.f.tint(T.tone,"idle"===o?.06:.16)}, 0 18px 40px rgba(0,0,0,0.55)`,padding:16,display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:12,outline:"none",...a?{top:0,right:0,bottom:0,maxWidth:"100%",maxHeight:"none",padding:"20px 20px 24px",display:"flex",flexDirection:"column",gap:16,zoom:1.08,background:z.f.bg,border:"none",borderLeft:`1px solid ${z.f.line}`,borderRadius:0,boxShadow:"none"}:null,...W?{display:"none"}:null},children:(0,r.jsxs)(iG.Provider,{value:a,children:[a&&(0,r.jsx)("button",{type:"button","data-testid":"panel-fold","aria-label":t.B.panel.fold,title:t.B.panel.fold,onClick:()=>Z(!0),style:{...jt,alignSelf:"flex-start",margin:"-10px 0 -10px -10px"},children:(0,r.jsx)(h5,{name:"expand"})}),L&&(0,r.jsx)(h8,{}),!L&&"idle"===o&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"factory-display",style:{fontSize:17,fontWeight:700},children:t.B.sidebar.runTitle}),b&&(0,r.jsx)("div",{"data-testid":"direct-start-hint",role:"note",style:{padding:"9px 12px",borderRadius:10,border:`1px solid ${A.f.tint("passed",.5)}`,color:A.f.passed,fontSize:13,lineHeight:1.45},children:t.B.direct.startHint}),1===H.length&&(0,r.jsx)("div",{"data-testid":"starts-from",style:{fontSize:12,color:A.f.dim,marginTop:-6,overflowWrap:"anywhere"},children:t.B.delivery.startsFrom(H[0])}),H.length>1&&(0,r.jsxs)("label",{"data-testid":"starts-from",style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:A.f.dim,marginTop:-6},children:[t.B.delivery.startFromLabel,(0,r.jsx)("select",{value:I??H[0],onChange:a=>J?.(a.target.value),style:{flex:1,minWidth:0,padding:"4px 6px",background:A.f.bg,color:"inherit",border:`1px solid ${A.f.border}`,borderRadius:6,fontSize:12},children:H.map((a,b)=>(0,r.jsx)("option",{value:a,children:0===b?t.B.delivery.mainOption(a):t.B.delivery.currentOption(a)},a))})]}),N&&(0,r.jsxs)("label",{style:{display:"grid",gap:4,fontSize:12.5,fontWeight:600,color:A.f.dim},children:[(0,r.jsxs)("span",{children:[t.B.title.label," ",(0,r.jsx)("span",{style:{fontWeight:400},children:t.B.title.optional})]}),(0,r.jsx)("input",{value:M??"",maxLength:60,placeholder:t.B.title.placeholder,onChange:a=>N(a.target.value),style:{font:"inherit",fontSize:13.5,fontWeight:400,padding:"7px 10px",background:A.f.card,color:"#e6e9ef",border:`1px solid ${A.f.border}`,borderRadius:8}})]}),e&&(0,r.jsx)(jw,{checked:d,onChange:e}),aa({label:t.B.run.send,onSend:y,enabled:B})]}),!L&&"working"===o&&(0,r.jsxs)("div",{role:"status",style:{display:"flex",alignItems:"center",gap:10,fontSize:14,fontWeight:600,color:"#cfe0ff"},children:[(0,r.jsx)(D.m,{blockId:"card",size:20}),t.B.card.working]}),!L&&"working"===o&&n&&(0,r.jsx)(jx,{notice:n}),!L&&"plan"===o&&p&&(0,r.jsx)(i8,{measure:c,away:O,runId:p,note:u,composer:aa,onSent:G}),!L&&"question"===o&&p&&(0,r.jsx)(i5,{runId:p,record:g,failed:h,mark:i,readMark:j,askedId:k,onChanged:()=>l?.()}),!L&&"waiting"===o&&p&&(0,r.jsx)(iW,{findings:m?g?.findings:void 0,touched:g?.touched,away:O,runId:p,risk:q,note:u,imageIds:iH(w),imagesBusy:iI(w),composer:aa,onSent:G,onSeeChanges:f}),!L&&"done"===o&&p&&(0,r.jsx)(jk,{away:O,onRecorded:P,onNewTask:E,onDeleted:F,onShipState:K,runId:p,note:u,imageIds:iH(w),imagesBusy:iI(w),composer:aa,onFollowUp:a=>{G(),C(a)}}),!L&&"failed"===o&&p&&(0,r.jsx)(iA,{runId:p,note:u,imageIds:iH(w),imagesBusy:iI(w),composer:aa,onText:v,actionsRef:Q,onCanContinue:R,onFollowUp:a=>{G(),C(a)}})]})})]})}),jt={width:36,height:36,display:"grid",placeItems:"center",background:"transparent",color:A.f.dim,border:"1px solid transparent",borderRadius:8,cursor:"pointer"},ju={idle:z.f.quiet,working:A.f.passed,plan:A.f.waiting,question:A.f.waiting,waiting:A.f.waiting,done:A.f.passed,failed:A.f.failed};function jv({mode:a,glide:b,onOpen:c}){let d=ju[a],e="plan"===a||"question"===a||"waiting"===a,f="working"===a?(0,r.jsx)(D.m,{blockId:"panel-rail",size:20}):(0,r.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"===a&&(0,r.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"}),"failed"===a&&(0,r.jsx)("path",{d:"M6 6l12 12M18 6L6 18"}),e&&(0,r.jsx)("path",{d:"M12 5v9M12 18.5v.5"}),"idle"===a&&(0,r.jsx)("path",{d:"M4 20h4L19 9l-4-4L4 16v4zM13.5 6.5l4 4"})]});return(0,r.jsxs)("button",{type:"button","data-testid":"panel-rail",className:b?"factory-from-right":void 0,"data-mode":a,"aria-label":`${t.B.panel.open}. ${t.B.panel.state[a]}`,title:`${t.B.panel.state[a]} \xb7 ${t.B.panel.open}`,onClick:c,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 ${z.f.line}`,background:z.f.bg,color:z.f.quiet,cursor:"pointer"},children:[(0,r.jsx)("span",{style:jt,children:(0,r.jsx)(h5,{name:"collapse"})}),(0,r.jsx)("span",{role:"working"===a?"status":void 0,style:{width:36,height:36,borderRadius:10,display:"grid",placeItems:"center",color:d,background:A.f.tint("working"===a?"passed":e?"waiting":"done"===a?"passed":"failed"===a?"failed":"skipped",.16),border:`1px solid ${e?A.f.waiting:z.f.line}`},children:f}),(0,r.jsx)("span",{style:{writingMode:"vertical-rl",fontSize:12,letterSpacing:.3,color:e?A.f.waiting:z.f.quiet,fontWeight:e?700:500},children:t.B.panel.state[a]})]})}function jw({checked:a,onChange:b}){let[c,d]=(0,s.useState)(!1),e="stop-for-me-why";return(0,r.jsxs)("div",{"data-testid":"stop-for-me",style:{display:"grid",gap:4,minWidth:0},children:[(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 12px"},children:[(0,r.jsxs)("label",{style:{display:"inline-flex",alignItems:"center",gap:8,fontSize:13,color:"#d6dce6",cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:a,onChange:a=>b(a.target.checked)}),t.B.composer.stopForMe]}),(0,r.jsx)("button",{type:"button","aria-expanded":c,"aria-controls":e,onClick:()=>d(a=>!a),style:{padding:0,background:"none",border:"none",color:"#9cc2ff",fontSize:12.5,cursor:"pointer",textDecoration:"underline"},children:t.B.composer.stopForMeWhat})]}),c&&(0,r.jsx)("span",{id:e,style:{fontSize:12.5,lineHeight:1.45,color:A.f.dim,overflowWrap:"anywhere"},children:t.B.composer.stopForMeWhy})]})}function jx({notice:a}){let[b,c]=(0,s.useState)(!1),d={fontSize:12,lineHeight:1.4,color:A.f.dim,margin:0};return"ask"===a.offer?(0,r.jsx)("button",{type:"button",onClick:()=>{c(!0),a.onAllow()},style:{justifySelf:"start",textAlign:"left",padding:"5px 10px",borderRadius:8,border:`1px solid ${A.f.border}`,background:"transparent",color:"inherit",fontSize:12.5,cursor:"pointer"},children:t.B.tell.offer}):b&&"on"===a.offer?(0,r.jsx)("p",{style:d,children:t.B.tell.on}):b&&"blocked"===a.offer?(0,r.jsx)("p",{style:d,children:t.B.tell.blocked}):null}let jy=new Set(["node.question_asked","node.question_answered","node.findings_checked","node.finding_resolved"]);function jz(a){for(let b=a.length-1;b>=0;b--){let c=a[b];if("node.question_answered"===c.type)break;if("node.question_asked"===c.type){let a=c.payload?.questionId;return"string"==typeof a?a:null}}return null}let jA=t.B.details,jB="var(--font-mono), ui-monospace, SFMono-Regular, Menlo, monospace",jC={scrollbarWidth:"thin",scrollbarColor:`${A.f.skipped} transparent`},jD=["input","plan","build","tests","review","approve","human","ship"],jE="min(48vh, 440px)";function jF(a){if(a<1e3)return jA.underASecond;let b=Math.round(a/1e3);if(b<60)return`${b}s`;let c=Math.floor(b/60);return c<60?`${c}m ${b%60}s`:`${Math.floor(c/60)}h ${c%60}m`}function jG(a){if(!a)return jA.none;let b=new Date(a);return Number.isNaN(b.getTime())?jA.none:b.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function jH({text:a}){return(0,r.jsx)(r.Fragment,{children:a.replace(/\*\*/g,"").split(/\n{2,}/).map((a,b)=>(0,r.jsx)("p",{style:{margin:0},children:a.split("`").map((a,b)=>b%2==1?(0,r.jsx)("code",{style:{padding:"1px 6px",borderRadius:5,background:z.f.bg,border:`1px solid ${z.f.line}`,fontFamily:jB,fontSize:"0.86em",color:z.f.text},children:a},b):a)},b))})}function jI({path:a,size:b=16}){return(0,r.jsx)("svg",{viewBox:"0 0 24 24",width:b,height:b,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:a})}let jJ={clock:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,r.jsx)("path",{d:"M12 7v5l3 2"})]}),play:(0,r.jsx)("path",{d:"M8 5.5v13l10-6.5z"}),flag:(0,r.jsx)("path",{d:"M6 21V4h11l-2 4 2 4H6"}),spark:(0,r.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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("rect",{x:"7",y:"7",width:"10",height:"10",rx:"2"}),(0,r.jsx)("path",{d:"M10 3v4M14 3v4M10 17v4M14 17v4M3 10h4M3 14h4M17 10h4M17 14h4"})]}),repeat:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("path",{d:"M20 11a8 8 0 1 0-2.3 5.7"}),(0,r.jsx)("path",{d:"M20 4v7h-7"})]}),check:(0,r.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"}),cross:(0,r.jsx)("path",{d:"M6 6l12 12M18 6L6 18"}),chevron:(0,r.jsx)("path",{d:"M9 6l6 6-6 6"}),enlarge:(0,r.jsx)("path",{d:"M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5"})};function jK({icon:a,label:b,value:c,help:d}){return(0,r.jsxs)("div",{style:{display:"grid",gap:5,padding:"13px 15px",borderRadius:12,background:"#141414",border:`1px solid ${z.f.line}`,minWidth:0},children:[(0,r.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:7,fontSize:12.5,color:z.f.quiet},children:[(0,r.jsx)(jI,{path:a,size:14})," ",b]}),(0,r.jsx)("span",{style:{fontSize:19,fontWeight:700,color:z.f.text,overflowWrap:"anywhere"},children:c}),d&&(0,r.jsx)("span",{style:{fontSize:11.5,color:A.f.skipped},children:d})]})}function jL({title:a,help:b,children:c}){return(0,r.jsxs)("section",{style:{display:"grid",gap:10},children:[(0,r.jsxs)("div",{style:{display:"grid",gap:3},children:[(0,r.jsx)("strong",{className:"factory-display",style:{fontSize:17},children:a}),b&&(0,r.jsx)("span",{style:{fontSize:13,color:z.f.quiet},children:b})]}),c]})}function jM({measure:a,startedOnItsOwn:b}){return(0,r.jsxs)(r.Fragment,{children:[a.reasons.length>0&&(0,r.jsx)(jL,{title:b?t.B.plan.whyStarted:t.B.plan.whyStopped,children:(0,r.jsx)("ul",{style:{margin:0,paddingLeft:20,display:"grid",gap:6,fontSize:14.5,lineHeight:1.5,color:"#d6dce6",overflowWrap:"anywhere"},children:a.reasons.map((a,b)=>(0,r.jsx)("li",{children:a},b))})}),(0,r.jsx)(jL,{title:t.B.plan.expects,children:a.entries.length>0?(0,r.jsx)("ul",{style:{margin:0,paddingLeft:20,display:"grid",gap:4,fontFamily:jB,fontSize:13,color:"#d6dce6",overflowWrap:"anywhere"},children:a.entries.map((a,b)=>(0,r.jsx)("li",{children:a},b))}):(0,r.jsx)("span",{style:{color:z.f.quiet},children:t.B.plan.noneExpected})})]})}function jN({c:a}){let[b,c]=(0,s.useState)(!1),d=0===a.exitCode;return(0,r.jsxs)("div",{style:{display:"grid",gap:8,padding:"11px 13px",borderRadius:10,background:"#141414",border:`1px solid ${d?z.f.line:A.f.tint("failed",.5)}`},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,r.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"3px 10px",borderRadius:999,background:A.f.tint(d?"passed":"failed",.16),color:d?A.f.passed:A.f.failed,fontSize:12.5,fontWeight:700},children:[(0,r.jsx)(jI,{path:d?jJ.check:jJ.cross,size:13})," ",d?jA.commandPassed:jA.commandFailed]}),(0,r.jsx)("code",{style:{fontFamily:jB,fontSize:13,color:"#e6e9ef"},children:a.command}),null!==a.durationMs&&(0,r.jsx)("span",{style:{marginLeft:"auto",fontSize:13,color:z.f.quiet},children:jF(a.durationMs)})]}),!d&&(0,r.jsx)("span",{style:{fontSize:13,color:A.f.failed},children:t.B.failure.ended(a.exitCode,a.signal)}),a.output&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{type:"button","aria-expanded":b,onClick:()=>c(a=>!a),style:{justifySelf:"start",display:"inline-flex",alignItems:"center",gap:5,padding:0,background:"none",border:"none",color:z.f.green,fontSize:13,cursor:"pointer"},children:[(0,r.jsx)("span",{style:{display:"inline-flex",transform:b?"rotate(90deg)":"none"},children:(0,r.jsx)(jI,{path:jJ.chevron,size:13})}),b?jA.hideOutput:jA.showOutput]}),b&&(0,r.jsx)("pre",{style:{margin:0,maxHeight:280,overflow:"auto",padding:12,borderRadius:8,background:z.f.bg,border:`1px solid ${z.f.line}`,fontFamily:jB,fontSize:12.5,lineHeight:1.5,color:"#d6dce6",whiteSpace:"pre-wrap",overflowWrap:"anywhere",...jC},children:a.output})]})]})}function jO({runId:a}){let{state:b}=(0,aB.C)(a,!1);return b&&"unneeded"!==b.status?(0,r.jsx)(jL,{title:jA.pictures,help:jA.picturesHelp,children:(0,r.jsx)(jZ,{runId:a,state:b})}):null}function jP({runId:a,name:b,done:c}){let{state:d,take:e,error:f}=(0,aB.C)(a,c),[g,h]=(0,s.useState)(!1),[i,j]=(0,s.useState)(!1);if(!d)return(0,r.jsx)(h6,{width:300,height:96,radius:8});if(!c&&"ready"!==d.status&&"working"!==d.status)return(0,r.jsx)("span",{style:{fontSize:13,color:A.f.skipped},children:jA.historyWhenDone});if("unneeded"===d.status)return(0,r.jsx)("span",{style:{fontSize:13,color:A.f.skipped},children:jA.historyNothingToSee});if("working"===d.status||i&&"none"===d.status&&!f)return(0,r.jsxs)("span",{role:"status",style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:z.f.quiet},children:[(0,r.jsx)(D.m,{blockId:`pictures-${a}`,size:14})," ",d.message??jA.historyTaking]});if("ready"!==d.status||0===d.shots.length)return(0,r.jsxs)("span",{style:{display:"grid",gap:6,justifyItems:"start"},children:[(0,r.jsx)("button",{type:"button",onClick:()=>{j(!0),e()},style:{padding:"6px 12px",borderRadius:8,border:`1px solid ${z.f.line}`,background:z.f.bg,color:z.f.text,fontSize:13,fontWeight:600,cursor:"pointer"},children:jA.historyTake}),(f??("failed"===d.status?d.message:null))&&(0,r.jsx)("span",{style:{fontSize:12.5,color:A.f.failed},children:f??d.message})]});let k=["before","after"].filter(a=>d.shots.includes(`${a}-desktop`));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button","data-testid":"history-thumbs","aria-label":jA.historyPicturesOf(b),onClick:()=>h(!0),style:{display:"flex",gap:10,padding:0,border:"none",background:"none",cursor:"zoom-in",justifySelf:"start"},children:k.map(b=>(0,r.jsxs)("span",{style:{display:"grid",gap:4,justifyItems:"start"},children:[(0,r.jsx)("span",{style:{fontSize:11,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:"before"===b?z.f.quiet:A.f.passed},children:t.B.snapshots[b]}),(0,r.jsx)("img",{src:(0,aB.h)(a,`${b}-desktop`,d),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 ${z.f.line}`}})]},b))}),g&&(0,fb.createPortal)((0,r.jsx)("div",{onClick:()=>h(!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,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":jA.historyPicturesOf(b),onClick:a=>a.stopPropagation(),style:{width:"min(1100px, calc(100% - 32px))",maxHeight:"calc(100% - 64px)",overflowY:"auto",display:"grid",gap:14,padding:22,background:z.f.card,border:`1px solid ${z.f.line}`,borderRadius:14,...jC},children:[(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:12},children:[(0,r.jsx)("strong",{className:"factory-display",style:{fontSize:18},children:jA.historyPicturesOf(b)}),(0,r.jsx)("button",{type:"button","aria-label":jA.close,onClick:()=>h(!1),style:{background:"none",border:"none",color:A.f.skipped,cursor:"pointer",fontSize:18},children:"✕"})]}),(0,r.jsx)(jZ,{runId:a,state:d})]})}),document.body)]})}let jQ={position:"relative",display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:14,paddingBottom:16},jR={position:"absolute",left:12,top:26,bottom:0,width:2,background:z.f.line},jS={display:"grid",gap:10,minWidth:0,padding:"12px 14px",borderRadius:12,border:`1px solid ${z.f.line}`,background:"#141414"},jT={fontSize:11,fontWeight:800,letterSpacing:"0.1em",textTransform:"uppercase",color:z.f.quiet},jU=a=>new Date(a).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),jV=({colour:a})=>(0,r.jsx)("span",{className:"factory-history-dot",style:{width:26,height:26,borderRadius:999,display:"grid",placeItems:"center",background:"#141414",border:`2px solid ${a}`,color:a,fontSize:12.5,fontWeight:800,zIndex:1}});function jW({files:a}){return 0===a.length?null:(0,r.jsxs)("div",{style:{display:"grid",gap:4,fontSize:12.5,paddingTop:8,borderTop:`1px solid ${z.f.line}`},children:[(0,r.jsx)("span",{style:{color:z.f.quiet,fontWeight:700},children:jA.historyFiles(a.length)}),(0,r.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[a.slice(0,6).map(a=>(0,r.jsx)("code",{style:{padding:"2px 7px",borderRadius:6,background:z.f.bg,border:`1px solid ${z.f.line}`,color:"#c9d0db",fontSize:12},children:a},a)),a.length>6&&(0,r.jsx)("span",{style:{color:A.f.skipped,alignSelf:"center"},children:jA.historyMoreFiles(a.length-6)})]})]})}function jX({t:a,more:b}){let{state:c,versions:d}=(0,aB.w)(a.runId),e={margin:0,fontSize:14.5,lineHeight:1.5,color:"#e6e9ef",overflowWrap:"anywhere"},f=(0,r.jsxs)("span",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px",marginLeft:"auto"},children:[a.here&&(0,r.jsx)("span",{style:{padding:"2px 9px",borderRadius:999,background:A.f.tint("passed",.18),color:A.f.passed,fontSize:11.5,fontWeight:800},children:jA.historyHere}),(0,r.jsx)("span",{style:{fontSize:12.5,color:A.f.skipped},children:jU(a.at)})]});if(c&&d.length>0)return(0,r.jsx)(r.Fragment,{children:d.map((g,h)=>(0,r.jsxs)("li",{"data-testid":"history-step",style:jQ,children:[(b||h<d.length-1)&&(0,r.jsx)("span",{"aria-hidden":"true",style:jR}),(0,r.jsx)(jV,{colour:A.f.passed}),(0,r.jsxs)("div",{style:jS,children:[(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px"},children:[(0,r.jsx)("span",{style:jT,children:0===h?jA.historyAsked:jA.historyAskedChange}),0===h&&f]}),(0,r.jsx)("p",{style:e,children:g.asked}),(0,r.jsx)(aB.R,{runId:a.runId,state:c,versions:d,index:h}),h===d.length-1&&(0,r.jsx)(jW,{files:a.files})]})]},`${a.runId}-${g.change}`))});let g=a.request.replace(/\s+/g," ").trim().startsWith(a.name)?null:a.name;return(0,r.jsxs)("li",{"data-testid":"history-step",style:jQ,children:[b&&(0,r.jsx)("span",{"aria-hidden":"true",style:jR}),(0,r.jsx)(jV,{colour:A.f.passed}),(0,r.jsxs)("div",{style:jS,children:[(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px"},children:[(0,r.jsx)("span",{style:jT,children:jA.historyAsked}),f]}),g&&(0,r.jsx)("strong",{style:{fontSize:15,color:"#e6e9ef",overflowWrap:"anywhere"},children:g}),(0,r.jsx)("p",{style:{...e,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},title:a.request,children:a.request}),a.asks&&a.asks.length>0&&(0,r.jsxs)("div",{"data-testid":"history-asks",style:{display:"grid",gap:4,fontSize:13.5,color:"#c9d0db"},children:[(0,r.jsx)("span",{style:jT,children:jA.historyAsks}),(0,r.jsx)("ol",{start:2,style:{margin:0,paddingLeft:20,display:"grid",gap:3,lineHeight:1.5},children:a.asks.map((a,b)=>(0,r.jsx)("li",{style:{overflowWrap:"anywhere"},children:a},b))})]}),a.look?(0,r.jsx)(jP,{runId:a.runId,name:a.name,done:a.done}):(0,r.jsx)("span",{style:{fontSize:13,color:A.f.skipped},children:jA.historyNothingToSee}),(0,r.jsx)(jW,{files:a.files})]})]})}function jY({tasks:a,github:b}){return(0,r.jsx)(jL,{title:jA.history,help:jA.historyHelp,children:(0,r.jsxs)("ol",{"data-testid":"details-history",className:"factory-history",style:{listStyle:"none",margin:0,padding:0},children:[a.map((c,d)=>(0,r.jsx)(jX,{t:c,more:d<a.length-1||!!b},c.runId)),b&&(0,r.jsxs)("li",{"data-testid":"history-github",style:{...jQ,paddingBottom:0},children:[(0,r.jsx)(jV,{colour:b.published?A.f.passed:A.f.waiting}),(0,r.jsxs)("div",{style:{...jS,gap:6},children:[(0,r.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 10px",minHeight:26},children:[(0,r.jsx)("strong",{style:{fontSize:15,color:"#e6e9ef"},children:jA.historyGithub}),(0,r.jsx)("span",{style:{padding:"2px 9px",borderRadius:999,background:A.f.tint(b.published?"passed":"waiting",.18),color:b.published?A.f.passed:A.f.waiting,fontSize:11.5,fontWeight:800},children:b.published?jA.historyPublished:jA.historyWaiting}),(0,r.jsx)("span",{style:{fontSize:12.5,color:A.f.skipped},children:jU(b.at)})]}),(0,r.jsxs)("span",{style:{fontSize:13,color:z.f.quiet,overflowWrap:"anywhere"},children:[jA.historyBranch," ",(0,r.jsx)("code",{style:{color:"#c9d0db"},children:b.branch})]}),b.pr&&(0,r.jsxs)("a",{href:b.pr.url,target:"_blank",rel:"noreferrer",style:{justifySelf:"start",color:z.f.green,fontSize:13.5},children:[jA.historyPr(b.pr.number)," ↗"]})]})]})]})})}function jZ({runId:a,state:b}){let[c,d]=(0,s.useState)("desktop"),[e,f]=(0,s.useState)(null);if("working"===b.status)return(0,r.jsxs)("span",{role:"status",style:{display:"flex",alignItems:"center",gap:8,color:z.f.quiet},children:[(0,r.jsx)(D.m,{blockId:"pictures",size:15})," ",jA.picturesWorking]});if("ready"!==b.status||0===b.shots.length)return(0,r.jsx)("span",{style:{color:z.f.quiet},children:jA.noPictures});let g=c=>(0,aB.h)(a,c,b);return(0,r.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,r.jsxs)("div",{role:"tablist",style:{display:"flex",gap:8},children:[["desktop","mobile"].map(a=>(0,r.jsx)("button",{type:"button",role:"tab","aria-selected":c===a,onClick:()=>d(a),style:{padding:"7px 16px",borderRadius:999,border:`1px solid ${c===a?A.f.running:z.f.line}`,background:c===a?A.f.tint("running",.18):"transparent",color:c===a?z.f.text:z.f.quiet,fontSize:13.5,fontWeight:700,cursor:"pointer"},children:t.B.snapshots[a]},a)),b.route&&(0,r.jsx)("span",{"data-testid":"pictures-page",style:{alignSelf:"center",marginLeft:"auto",fontSize:13,color:z.f.quiet},children:t.B.snapshots.page(b.route,b.opened)})]}),(0,r.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:14,alignItems:"start"},children:["before","after"].map(a=>{let d=`${a}-${c}`,e=`${t.B.snapshots[a]} \xb7 ${t.B.snapshots[c]}`;return(0,r.jsxs)("figure",{style:{margin:0,display:"grid",gap:6},children:[(0,r.jsx)("figcaption",{style:{justifySelf:"start",fontSize:13,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase",color:"before"===a?z.f.quiet:A.f.passed},children:t.B.snapshots[a]}),b.shots.includes(d)?(0,r.jsxs)("button",{type:"button","aria-label":jA.enlarge(e),title:jA.enlargeHint,onClick:()=>f(d),style:{position:"relative",height:jE,boxSizing:"border-box",display:"flex",justifyContent:"center",alignItems:"flex-start",overflow:"hidden",borderRadius:8,background:z.f.bg,border:`1px solid ${z.f.line}`,padding:8,cursor:"zoom-in"},children:[(0,r.jsx)("img",{src:g(d),alt:e,style:{display:"block",maxWidth:"100%",maxHeight:"100%",borderRadius:6,border:`1px solid ${"before"===a?z.f.line:A.f.tint("passed",.5)}`}}),(0,r.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 ${z.f.line}`,color:"#e6e9ef",fontSize:12.5,fontWeight:700},children:[(0,r.jsx)(jI,{path:jJ.enlarge,size:14})," ",jA.enlargeHint]})]}):(0,r.jsx)("div",{style:{height:jE,display:"grid",placeItems:"center",padding:16,textAlign:"center",borderRadius:8,border:`1px dashed ${z.f.line}`,color:z.f.quiet,fontSize:13.5,lineHeight:1.45},children:"before"===a?jA.noBefore:jA.noAfter})]},a)})}),e&&(0,r.jsx)(j$,{src:g(e),label:`${t.B.snapshots[e.startsWith("before")?"before":"after"]} \xb7 ${t.B.snapshots[e.endsWith("mobile")?"mobile":"desktop"]}`,phone:e.endsWith("mobile"),onClose:()=>f(null)})]})}function j$({src:a,label:b,phone:c,onClose:d}){return(0,s.useEffect)(()=>{let a=a=>{"Escape"===a.key&&(a.stopImmediatePropagation(),d())};return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[d]),(0,fb.createPortal)((0,r.jsxs)("div",{role:"dialog","aria-modal":"true","aria-label":b,"data-testid":"large-picture",onClick:a=>{a.stopPropagation(),d()},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,r.jsxs)("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",color:"#e6e9ef"},children:[(0,r.jsx)("strong",{className:"factory-display",style:{fontSize:17},children:b}),(0,r.jsxs)("button",{type:"button",onClick:d,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"7px 14px",borderRadius:8,border:`1px solid ${z.f.line}`,background:"#141414",color:"#e6e9ef",fontSize:13.5,fontWeight:700,cursor:"pointer"},children:[(0,r.jsx)(jI,{path:jJ.cross,size:14})," ",jA.close]})]}),(0,r.jsx)("div",{style:{overflow:"auto",display:"grid",justifyItems:"center",alignItems:"start",padding:"0 20px 24px",...jC},children:(0,r.jsx)("img",{src:a,alt:b,onClick:a=>a.stopPropagation(),style:{display:"block",width:c?"min(100%, 420px)":void 0,maxWidth:"100%",borderRadius:8,border:`1px solid ${z.f.line}`,cursor:"default"}})})]}),document.body)}function j_({runId:a,blockId:b,label:c,view:d,pr:e,away:f=null,onClose:g,onSeeShip:h,onSettings:i,inline:j=!1}){let[k,l]=(0,s.useState)(void 0),[m,n]=(0,s.useState)(!1),o=d?.state==="running";(0,s.useEffect)(()=>{let c=!0,d=d=>fetch(`/api/runs/${a}/blocks/${encodeURIComponent(b)}`).then(a=>a.ok?a.json():null).then(a=>c&&(a||d)&&l(a)).catch(()=>c&&d&&l(null));d(!0);let e=o?setInterval(()=>void d(!1),4e3):null;return()=>{c=!1,e&&clearInterval(e)}},[a,b,o]),(0,s.useEffect)(()=>{if(j)return;let a=a=>{"Escape"===a.key&&g()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[g,j]);let p=d?.state??k?.state??"queued",q=A.f[(0,D.Y)(p)],u=k?.kind,v=(d?.summary||k?.summary)??null,w=k?.steps??[],x=m?w:w.slice(-8),y="ship"===u||"human"===u,B="human"===u&&"waiting_approval"!==p&&void 0!==h;return(0,r.jsx)("div",{onClick:j?void 0:g,style:j?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,r.jsxs)("div",{role:j?"region":"dialog","aria-modal":j?void 0:"true","aria-label":jA.title(c),"data-testid":"block-details",onClick:a=>a.stopPropagation(),style:{width:j?"100%":"min(920px, calc(100% - 32px))",height:j?void 0:"min(780px, calc(100% - 96px))",boxSizing:"border-box",display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",background:z.f.card,border:`1px solid ${z.f.line}`,borderTop:j?`1px solid ${z.f.line}`:`3px solid ${q}`,borderRadius:16,boxShadow:j?"none":"0 24px 60px rgba(0,0,0,0.6)",fontSize:j?15:14.5,...j?{"--thumb-w":"380px","--thumb-h":"236px"}:null},children:[(0,r.jsxs)("header",{style:{display:"flex",alignItems:"center",gap:14,padding:j?"26px 28px 0":"18px 26px",borderBottom:j?"none":`1px solid ${z.f.line}`},children:[u&&jD.includes(u)&&(0,r.jsx)(hT.f,{kind:u,colour:q,size:40}),(0,r.jsxs)("div",{style:{display:"grid",gap:4,flex:1,minWidth:0},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[(0,r.jsx)("h2",{className:"factory-display",style:{margin:0,fontSize:26},children:c}),k&&(0,r.jsx)("span",{style:{padding:"3px 11px",borderRadius:999,background:`${q}26`,color:q,fontSize:12.5,fontWeight:800,letterSpacing:"0.08em",textTransform:"uppercase"},children:d?.turn?t.B.direct.yourTurn:t.B.canvas.stateLabel[p]})]}),u&&jA.purpose[u]&&(0,r.jsx)("span",{style:{fontSize:14,color:z.f.quiet},children:jA.purpose[u]})]}),i&&(0,r.jsxs)("button",{type:"button","data-testid":"details-settings",onClick:i,title:jA.settingsHelp,style:{display:"inline-flex",alignItems:"center",gap:7,padding:"7px 12px",borderRadius:8,border:`1px solid ${z.f.line}`,background:"#141414",color:"#c9d0db",cursor:"pointer",font:"inherit",fontSize:13.5,whiteSpace:"nowrap"},children:[(0,r.jsx)(L,{size:14}),jA.settings]}),!j&&(0,r.jsx)("button",{type:"button","aria-label":jA.close,onClick:g,style:{background:"none",border:"none",color:A.f.skipped,cursor:"pointer",fontSize:18},children:"✕"})]}),(0,r.jsxs)("div",{style:{overflowY:"auto",padding:"22px 26px 28px",display:"grid",gap:26,alignContent:"start",...jC},children:[void 0===k&&(0,r.jsxs)("div",{role:"status","aria-label":jA.loading,"data-testid":"details-loading",style:{display:"grid",gap:26},children:[(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:10},children:[(0,r.jsx)(h6,{height:78,radius:12}),(0,r.jsx)(h6,{height:78,radius:12}),(0,r.jsx)(h6,{height:78,radius:12})]}),(0,r.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,r.jsx)(h6,{width:170,height:18}),(0,r.jsx)(h6,{height:58,radius:12})]}),(0,r.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,r.jsx)(h6,{width:210,height:18}),(0,r.jsx)(h6,{width:"72%",height:13}),(0,r.jsx)(h6,{width:"58%",height:13}),(0,r.jsx)(h6,{width:"64%",height:13})]}),(0,r.jsxs)("div",{style:{display:"grid",gap:12},children:[(0,r.jsx)(h6,{width:150,height:18}),(0,r.jsx)(h6,{height:110,radius:10}),(0,r.jsx)(h6,{height:110,radius:10})]})]}),null===k&&(0,r.jsx)("div",{style:{color:z.f.quiet},children:jA.unreadable}),k&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(170px, 1fr))",gap:10},children:[k.startedAt&&(0,r.jsx)(jK,{icon:jJ.clock,label:jA.took,value:null!==k.durationMs?jF(k.durationMs):jA.stillWorking}),k.startedAt&&(0,r.jsx)(jK,{icon:jJ.play,label:jA.started,value:jG(k.startedAt)}),k.startedAt&&k.finishedAt&&(0,r.jsx)(jK,{icon:jJ.flag,label:jA.finished,value:jG(k.finishedAt)}),null!==k.tokens&&(0,r.jsx)(jK,{icon:jJ.spark,label:jA.tokens,value:k.tokens.toLocaleString("en-US"),help:jA.tokensHelp}),k.model&&(0,r.jsx)(jK,{icon:jJ.chip,label:jA.model,value:k.model}),k.attempt>1&&(0,r.jsx)(jK,{icon:jJ.repeat,label:jA.attempts,value:k.attempt})]}),(0,r.jsxs)(jL,{title:jA.said,help:d?.summaryIsClaim?jA.saidByAi:void 0,children:[(0,r.jsx)("div",{"data-testid":"details-summary",style:{display:"grid",gap:10,padding:"14px 16px",borderRadius:12,background:"#141414",borderLeft:`3px solid ${q}`,fontSize:15.5,lineHeight:1.6,color:"#e6e9ef",overflowWrap:"anywhere"},children:v?(0,r.jsx)(jH,{text:v}):(0,r.jsx)("span",{style:{color:z.f.quiet},children:jA.nothingSaid})}),e&&"ship"===u&&(0,r.jsxs)("a",{href:e.url,target:"_blank",rel:"noreferrer",style:{justifySelf:"start",color:z.f.green,fontSize:14},children:[jA.seeOnGithub(e.number)," ↗"]})]}),k.asked&&k.asked.length>0&&(0,r.jsx)(jL,{title:jA.asked,help:k.asked.length>1?jA.askedHelp:void 0,children:(0,r.jsx)("ol",{"data-testid":"details-asked",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:8},children:k.asked.map((a,b)=>(0,r.jsxs)("li",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:12,padding:"12px 14px",borderRadius:10,background:"#141414",border:`1px solid ${z.f.line}`,fontSize:14.5,lineHeight:1.55,color:"#e6e9ef"},children:[(0,r.jsx)("span",{style:{color:A.f.passed,fontWeight:800},children:b+1}),(0,r.jsx)("span",{style:{overflowWrap:"anywhere",whiteSpace:"pre-wrap"},children:a})]},b))})}),B&&(0,r.jsx)(jL,{title:t.B.gate.changesTitle,children:(0,r.jsx)(i$,{runId:a,away:f,decided:!0})}),B&&(0,r.jsx)(jL,{title:jA.history,children:(0,r.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,r.jsx)("span",{children:jA.historyOnShip}),(0,r.jsxs)("button",{type:"button",onClick:h,style:{padding:"7px 14px",borderRadius:8,border:`1px solid ${z.f.line}`,background:"#141414",color:z.f.green,fontWeight:700,cursor:"pointer",font:"inherit"},children:[jA.historySeeOnShip," →"]})]})}),y&&!B&&((k.history?.length??0)>0?(0,r.jsx)(jY,{tasks:k.history,github:k.github}):(0,r.jsx)(jO,{runId:a})),"human"===u&&"waiting_approval"===p&&(0,r.jsx)(jL,{title:t.B.gate.changesTitle,children:(0,r.jsx)(i$,{runId:a,risk:d?.risk,away:f})}),(d?.planMeasure??k.planMeasure)&&(0,r.jsx)(jM,{measure:d?.planMeasure??k.planMeasure,startedOnItsOwn:d?.autoStarted===!0}),k.jobs.length>0&&(0,r.jsx)(jL,{title:jA.jobs(k.jobs.length),children:(0,r.jsx)("div",{style:{display:"grid",gap:10},children:k.jobs.map((a,b)=>(0,r.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:12,padding:"12px 14px",borderRadius:10,background:"#141414",border:`1px solid ${z.f.line}`},children:[(0,r.jsx)("span",{style:{width:26,height:26,borderRadius:999,display:"grid",placeItems:"center",background:A.f.tint("waiting",.18),color:A.f.waiting,fontSize:13,fontWeight:800},children:b+1}),(0,r.jsxs)("div",{style:{display:"grid",gap:6},children:[(0,r.jsx)("span",{style:{fontSize:15,fontWeight:600,color:"#e6e9ef",lineHeight:1.45},children:a.title}),a.done.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{style:{fontSize:12,letterSpacing:"0.06em",textTransform:"uppercase",color:A.f.skipped},children:jA.doneWhen}),a.done.map((a,b)=>(0,r.jsxs)("span",{style:{display:"flex",gap:8,fontSize:13.5,lineHeight:1.45,color:"#c9d0db"},children:[(0,r.jsx)("span",{style:{color:A.f.passed,marginTop:2},children:(0,r.jsx)(jI,{path:jJ.check,size:13})}),a]},b))]})]})]},b))})}),k.commands.length>0&&(0,r.jsx)(jL,{title:jA.commands,children:(0,r.jsx)("div",{style:{display:"grid",gap:8},children:k.commands.map((a,b)=>(0,r.jsx)(jN,{c:a},b))})}),w.length>0&&(0,r.jsxs)(jL,{title:jA.steps(w.length),help:jA.stepsHelp,children:[(0,r.jsx)("ol",{"data-testid":"details-steps",style:{margin:0,padding:0,listStyle:"none",display:"grid"},children:x.map((a,b)=>{let c=/^Running:?\s/.test(a.text),d=b===x.length-1;return(0,r.jsxs)("li",{style:{display:"grid",gridTemplateColumns:"54px 18px minmax(0, 1fr)",columnGap:10,alignItems:"start"},children:[(0,r.jsx)("span",{style:{paddingTop:2,fontFamily:jB,fontSize:12,color:A.f.skipped,textAlign:"right"},children:function(a,b){let c=a?Date.parse(b)-Date.parse(a):0/0;if(!Number.isFinite(c))return"";let d=Math.max(0,Math.round(c/1e3));return`+${Math.floor(d/60)}:${String(d%60).padStart(2,"0")}`}(k.startedAt,a.at)}),(0,r.jsxs)("span",{"aria-hidden":"true",style:{display:"grid",justifyItems:"center",alignSelf:"stretch",gridTemplateRows:"auto 1fr"},children:[(0,r.jsx)("span",{style:{width:9,height:9,marginTop:6,borderRadius:999,background:d?q:A.f.skipped}}),!d&&(0,r.jsx)("span",{style:{width:2,minHeight:14,background:z.f.line}})]}),(0,r.jsx)("span",{style:{paddingBottom:12,fontSize:14,lineHeight:1.5,color:"#d6dce6",overflowWrap:"anywhere",...c?{fontFamily:jB,fontSize:12.5}:{}},children:a.text})]},b)})}),w.length>8&&(0,r.jsx)("button",{type:"button",onClick:()=>n(a=>!a),style:{justifySelf:"start",padding:"6px 12px",borderRadius:8,border:`1px solid ${z.f.line}`,background:"#141414",color:"#e6e9ef",fontSize:13,fontWeight:600,cursor:"pointer"},children:m?jA.showFewer:jA.showAll(w.length)})]})]})]})]})})}let j0={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:[]},j1=[1e3,2e3,5e3],j2={"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"},j3={nodes:{},lastSequence:0},j4=a=>"string"==typeof a&&""!==a.trim()?a:void 0,j5=a=>"number"==typeof a&&Number.isInteger(a)&&a>=0?a:null,j6=new Set(["input","plan","build","tests","review","approve","human","ship"]);function j7(a){return{...a.round?{round:a.round}:{},...a.asking?{asking:!0}:{},...a.planMeasure?{planMeasure:a.planMeasure}:{},...a.autoStarted?{autoStarted:!0}:{},...a.evidence?{evidence:a.evidence}:{},...a.risk?{risk:a.risk}:{},...void 0!==a.tokens?{usage:{tokens:a.tokens,costCents:null}}:{}}}let j8=new Set([t.B.run.notYet.plan,t.B.run.notYet.review]),j9=a=>"skipped"===a.state&&void 0!==a.skippedReason&&j8.has(a.skippedReason);function ka(a,b=[],c){let d={};for(let[c,e]of Object.entries(a)){let a=b.find(a=>a.id===c)?.kind;if(void 0===a||!j6.has(a)){d[c]={blockId:c,state:e.state,summary:t.B.summary.generic[e.state],summaryIsClaim:!1,steps:e.steps,...j7(e)};continue}let f="failed"===e.state,g={kind:a,state:e.state,claim:f?e.failureMessage:e.reportedSummary,claimSource:f?e.failureSource:e.claimSource,cause:f?e.failureCause:void 0,skippedReason:e.skippedReason,counts:e.evidence?.counts??void 0};d[c]={blockId:c,state:e.state,summary:al(g),summaryIsClaim:am(g),steps:e.steps,...j7(e),...j9(e)?{notBuilt:!0}:{}}}if(c)for(let a of b.filter(a=>"ship"===a.kind))d[a.id]=c.merged?{blockId:a.id,state:"passed",summary:t.B.summary.mergedVia(c.pr??null),summaryIsClaim:!1,steps:[]}:void 0!==c.pr?{blockId:a.id,state:"waiting_approval",summary:t.B.summary.prOpen(c.pr),summaryIsClaim:!1,steps:[]}:{blockId:a.id,state:"passed",summary:t.B.summary.shippedTo(c.branch),summaryIsClaim:!1,steps:[]};if(!c)for(let a of b.filter(a=>"ship"===a.kind)){let b=d[a.id];b?.state==="skipped"&&(d[a.id]={...b,stateWord:t.B.canvas.waitingForYou})}return d}let kb={"run.created":"queued","run.started":"running","run.waiting_approval":"waiting_approval","run.completed":"completed","run.failed":"failed","run.cancelled":"cancelled"},kc=new Set(["completed","failed","cancelled"]),kd={events:[],runStatus:null},ke=a=>({runId:a,stream:j3,log:kd});function kf(a,b){var c,d,e;let f;if("reset"===b.type)return ke(b.runId);let g=a.runId===b.runId?a:ke(b.runId);return{runId:b.runId,stream:function(a,b){var c;if(b.sequence<=a.lastSequence)return a;let d={...a,lastSequence:b.sequence},e=b.payload??{};if("run.snapshots"===b.type){let a=j4(e.change);return void 0!==a&&Array.isArray(e.shots)&&e.shots.length>0?{...d,pictured:a}:d}if("run.pushed"===b.type){let b=j4(e.branch);return void 0===b?d:{...d,shipped:{...a.shipped,branch:b}}}if("run.pr_opened"===b.type&&"number"==typeof e.number)return{...d,shipped:{branch:a.shipped?.branch??"",...a.shipped,pr:e.number}};if("run.merged"===b.type)return{...d,shipped:{branch:a.shipped?.branch??"",...a.shipped,merged:!0}};let f=j4(e.blockId);if(void 0===f)return d;let g=a.nodes[f];if("node.plan_decided"===b.type)return{...d,planBlocks:[...new Set([...a.planBlocks??[],f])]};if("node.step"===b.type){let c=j4(e.text);return g&&void 0!==c?{...a,nodes:{...a.nodes,[f]:{...g,steps:[...g.steps,c]}},lastSequence:b.sequence}:d}if("node.evidence"===b.type){let c=function(a){let b=j5(a.durationMs);if(null===b)return;let c="number"==typeof a.exitCode&&Number.isInteger(a.exitCode)?a.exitCode:null,d=a.counts,e=j5(d?.passed),f=j5(d?.failed),g=j5(d?.total),h="string"==typeof a.signal?a.signal:null,i=Array.isArray(a.changedTestFiles)?a.changedTestFiles.filter(a=>"string"==typeof a):null,j=null===i?null:Math.max(j5(a.changedTestFilesCount)??0,i.length);return{counts:null!==e&&null!==f&&null!==g&&e+f<=g?{passed:e,failed:f,total:g}:null,exitCode:c,signal:h,durationMs:b,changedTestFiles:i,changedTestFilesCount:j}}(e);return g&&c?{...a,nodes:{...a.nodes,[f]:{...g,evidence:c}},lastSequence:b.sequence}:d}if("node.reopened"===b.type){if(!g)return d;let c="number"==typeof e.asked?e.asked:"fixes"===e.by?g.round:e.round,h=`${String(e.by)}-${String(e.round)}`,i="fixes"!==e.by&&"reviewer"!==e.by&&void 0!==j4(e.note)&&!a.planBlocks?.includes(f)&&!a.kept?.includes(h);return{...a,nodes:{...a.nodes,[f]:{state:"queued",steps:[],round:"number"==typeof c&&c>1?c:void 0}},lastSequence:b.sequence,...i?{earlier:[...a.earlier??[],{nodes:a.nodes,change:a.pictured}],pictured:void 0,kept:[...a.kept??[],h],reopened:[f]}:{reopened:[...new Set([...a.reopened??[],f])]}}}if("node.assessed"===b.type){let c="low"===e.level||"high"===e.level?e.level:void 0,h=Array.isArray(e.reasons)?e.reasons.filter(a=>"string"==typeof a):[];return g&&c?{...a,nodes:{...a.nodes,[f]:{...g,risk:{level:c,reasons:h,...!0===e.stopForMe?{stopForMe:!0}:{}}}},lastSequence:b.sequence}:d}if("node.plan_measured"===b.type){if(!g)return d;let c=a=>Array.isArray(a)?a.filter(a=>"string"==typeof a):[],h=e.question?.text,i="string"==typeof h&&""!==h.trim()?h:void 0;return{...a,nodes:{...a.nodes,[f]:{...g,planMeasure:{simple:!0===e.simple,reasons:c(e.reasons),entries:c(e.entries),...i?{question:i}:{}}}},lastSequence:b.sequence}}let h=j2[b.type];if(void 0===h||g&&g.state!==h&&(c=g.state,!j0[c].includes(h)))return d;let i={...g,state:h,steps:g?.steps??[]};return"node.question_asked"===b.type?i.asking=!0:delete i.asking,delete i.autoStarted,"node.completed"===b.type&&!0===e.autoStarted&&(i.autoStarted=!0),"node.waiting_approval"===b.type&&"string"==typeof e.summary&&(i.reportedSummary=j4(e.summary),i.claimSource="string"==typeof e.summarySource?e.summarySource:void 0),"queued"===h&&(i.reportedSummary=void 0),"node.completed"===b.type&&(i.reportedSummary=j4(e.summary),i.claimSource="string"==typeof e.summarySource?e.summarySource:void 0,"tokens"in e&&(i.tokens="number"==typeof e.tokens?e.tokens:null)),"node.failed"===b.type&&(i.failureCause=j4(e.cause),i.failureMessage=j4(e.message),i.failureSource="string"==typeof e.messageSource?e.messageSource:void 0),"node.skipped"===b.type&&(i.skippedReason=j4(e.reason)),{...a,nodes:{...a.nodes,[f]:i},lastSequence:b.sequence}}(g.stream,b.event),log:(c=g.log,d=b.event,c.events.length>0&&d.sequence<=c.events[c.events.length-1].sequence?c:{events:[...c.events,d].slice(-300),runStatus:(e=c.runStatus,void 0===(f=kb[d.type])||null!==e&&kc.has(e)?e:f)})}}let kg=()=>()=>void 0,kh=new Set(["queued","running","waiting_approval"]),ki={padding:"6px 14px",background:A.f.card,color:"inherit",border:`1px solid ${A.f.border}`,borderRadius:6,cursor:"pointer"};async function kj(a,b){let c=await a.json().catch(()=>null);return"string"==typeof c?.error?c.error:b}let kk=ah.R.filter(a=>a.ready).map(a=>({id:a.id,name:a.name}));a.s(["CanvasScreen",0,function({workflowId:a,graph:b,run:c=null,settings:d=null,draftUpdatedAt:e,localData:f=!1,noTasksYet:g=!1,account:h,ais:i=kk,ai:j=ah.b,installedAis:k}){var l;let[m,n]=(0,s.useState)(c),[o,p]=(0,s.useState)(d),[q,z]=(0,s.useState)(null),B=q??(d?.repoPath?j:ai.C),E=m?.providerId??B,F=(0,s.useMemo)(()=>k?new Set(k):null,[k]),G=(0,s.useCallback)((a,b,c)=>(0,ah.p)((0,ah.t)(E,c,b),a,b),[E]),M=(0,s.useCallback)((a,b)=>(0,ah.y)(E)&&ah.o.has(b)?(0,ah.j)((0,ah.t)(E,a,b))??null:null,[E]),N=B!==ai.C&&!o?.repoPath,[O,P]=(0,s.useState)(null),Q=(0,s.useSyncExternalStore)(kg,()=>{try{return window.sessionStorage.getItem((0,K.V)(a))}catch{return null}},()=>null),R=O??Q??"",S=b=>{try{window.sessionStorage.removeItem((0,K.V)(a))}catch{}P(b)},[W,X]=(0,s.useState)([]),[Y,Z]=(0,s.useState)(!1),[$,_]=(0,s.useState)(""),aa=()=>{S(""),X(a=>{for(let b of a)URL.revokeObjectURL(b.previewUrl);return[]})},[ab,ac]=(0,s.useState)(!1),[ad,ae]=(0,s.useState)(null),[af,aj]=(0,s.useState)(null),ak=(0,s.useRef)(null),al=(0,s.useRef)(null);async function am(a){let b=await fetch(`/api/runs/${a}`);if(!b.ok)return ae(await kj(b,t.B.run.startFailed));aj(null),n(await b.json())}let an=`factory.direct.${a}`,ao=(0,s.useSyncExternalStore)(kg,()=>{try{return"1"===window.localStorage.getItem(an)}catch{return!1}},()=>!1),[ap,aq]=(0,s.useState)(null),ar=a=>{aq(a);try{window.localStorage.setItem(an,a?"1":"0")}catch{}},[as,at]=(0,s.useState)(null),{views:au,rounds:aw,events:ax,runStatus:ay,connected:az,loaded:aB,reopen:aC}=function(a,b){let[c,d]=(0,s.useReducer)(kf,null,()=>ke(a)),{stream:e,log:f}=c.runId===a?c:ke(a),[g,h]=(0,s.useReducer)((a,b)=>b,!1),i=(0,s.useRef)(0),j=(0,s.useRef)(null),k=(0,s.useCallback)(()=>j.current?.(),[]),[l,m]=(0,s.useReducer)((a,b)=>b,null);return(0,s.useEffect)(()=>{let b,c;if(i.current=0,d({type:"reset",runId:a}),null===a)return void h(!1);let e=0,f=!1,g=!1,k=()=>{let j=new EventSource(`/api/runs/${encodeURIComponent(a)}/events?after=${i.current}`);b=j,"function"==typeof j.addEventListener?(j.addEventListener("caughtup",()=>m(a)),j.addEventListener("end",()=>{g=!0,j.close()})):m(a),j.onopen=()=>{e=0,h(!0)},j.onmessage=b=>{let c;try{c=JSON.parse(b.data)}catch{return}"number"!=typeof c.sequence||c.sequence<=i.current||(i.current=c.sequence,d({type:"event",runId:a,event:c}))},j.onerror=()=>{if(j.close(),h(!1),f||g||l())return;let a=j1[Math.min(e,j1.length-1)];e++,c=setTimeout(k,a)}},l=()=>"u">typeof document&&"hidden"===document.visibilityState,n=()=>{l()?(clearTimeout(c),b?.close(),h(!1)):f||g||(b?.close(),k())};"u">typeof document&&document.addEventListener("visibilitychange",n),j.current=()=>{!f&&g&&(g=!1,k())},k();let o=setTimeout(()=>m(a),2500);return()=>{f=!0,"u">typeof document&&document.removeEventListener("visibilitychange",n),clearTimeout(o),clearTimeout(c),b?.close()}},[a]),{views:(0,s.useMemo)(()=>ka(e.nodes,b,e.shipped),[e.nodes,b,e.shipped]),rounds:(0,s.useMemo)(()=>({earlier:(e.earlier??[]).map(a=>({views:ka(a.nodes,b),change:a.change})),reopened:e.reopened??[]}),[e.earlier,e.reopened,b]),lastSequence:e.lastSequence,connected:g,events:f.events,runStatus:f.runStatus,loaded:null!==a&&l===a,reopen:k}}(m?.runId??null,m?.blocks),aD=!!m&&ax.some(a=>"run.created"===a.type&&a.payload?.direct===!0),aE=(ap??ao)||aD&&as!==m?.runId,aF=(0,s.useRef)(e),aG=(0,s.useRef)(Promise.resolve()),aH=(0,s.useRef)(!1),[aI,aJ]=(0,s.useState)(null),aK=[...new Set([o?.defaultBranch,o?.currentBranch].filter(a=>!!a))],aL=null!==aI&&aK.includes(aI)?aI:aK[0]??null,[aM,aN]=(0,s.useState)(!1),[aO,aP]=hS("factory.view.conversation",!1),[aQ,aR]=(0,s.useState)(null),aS=m?.runId??null,aT=(0,s.useCallback)(a=>aS&&aR({runId:aS,state:a}),[aS]),aU=m?.blocks.find(a=>"ship"===a.kind),[aV,aW]=(0,s.useState)(null),aX=ax.some(a=>"run.pr_opened"===a.type),aY=aQ?.runId===aS;(0,s.useEffect)(()=>{if(!aB||!aS||!aX||aY)return;let a=!0;return fetch(`/api/runs/${aS}/ship`).then(a=>a.ok?a.json():null).then(b=>a&&b&&aR({runId:aS,state:b})).catch(()=>void 0),()=>{a=!1}},[aB,aS,aX,aY]);let aZ=aB&&(!aX||aY);(0,s.useEffect)(()=>{if(!aB||!aS)return;let a=setTimeout(()=>aW(aS),aZ?250:4e3);return()=>clearTimeout(a)},[aB,aZ,aS]);let a$=!!m&&aV!==m.runId,a_=(0,J.O)(aS,`${ax.filter(a=>"node.reopened"===a.type||"node.plan_decided"===a.type||"node.question_answered"===a.type).length}-${ay??""}`),a0=function(a){for(let b=a.length-1;b>=0;b--)if(jy.has(a[b].type))return a[b].sequence;return 0}(ax),{record:a1,readMark:a2,failed:a3,reload:a4}=function(a,b){let[c,d]=(0,s.useState)(null),[e,f]=(0,s.useState)(null),[g,h]=(0,s.useState)(0);(0,s.useEffect)(()=>{if(!a)return;let c=!0;return fetch(`/api/runs/${encodeURIComponent(a)}/findings`).then(a=>a.ok?a.json():Promise.reject(Error(String(a.status)))).then(e=>{c&&(d({runId:a,record:e,mark:b}),f(null))}).catch(()=>c&&f(a)),()=>{c=!1}},[a,b,g]);let i=(0,s.useCallback)(()=>h(a=>a+1),[]);return{record:c&&c.runId===a?c.record:null,readMark:c&&c.runId===a?c.mark:-1,failed:e===a,reload:i}}(aS,a0),a5=a=>{if(!m||!aD)return a;let b={...a};for(let a of m.blocks){let c=b[a.id];"build"===a.kind&&c?.state==="waiting_approval"&&(b[a.id]={...c,turn:!0,summary:t.B.direct.turnSummary})}return b},a6=a=>{if(!m||0===a_.length)return a;let b={...a};for(let a of["input","plan","build","review","human"]){let c=m.blocks.find(b=>b.kind===a&&b.enabled),d=a_.filter(b=>(0,J.B)(b)===a||"input"===a&&"changes"===b.kind);c&&b[c.id]&&d.length>0&&(b[c.id]={...b[c.id],asked:d})}return b},a7=aQ&&aQ.runId===aS&&aU?function(a,b){if(!b.pr)return null;let c=t.B.ship,d=[c.stepPushed,c.stepPr(b.pr.number),...b.checks.map(a=>`${a.name}: ${c.checkState[a.state]}`)],e={blockId:a,summaryIsClaim:!1,steps:d};if("closed"===b.pr.state)return{...e,state:"cancelled",summary:c.closed};if("open"===b.pr.state){if(b.pr.conflicts)return{...e,state:"failed",summary:c.conflicts};if(b.checksFailed)return{...e,state:"failed",summary:c.someFailed};if(!b.checksDone){let a=b.checks.filter(a=>"pending"!==a.state).length;return{...e,state:"running",summary:0===b.checks.length?c.cardLooking:c.cardChecking(a,b.checks.length)}}return{...e,state:"waiting_approval",summary:b.onHold?c.cardOnHold:c.cardReady}}let f=[...d,b.deployPending?c.stepMerged:c.merged,...b.deploy.map(a=>`${a.name}: ${c.checkState[a.state]}`)];return b.deploy.some(a=>"failed"===a.state)?{...e,steps:f,state:"failed",summary:c.deployFailed}:b.deployPending||b.deploy.some(a=>"pending"===a.state)?{...e,steps:f,state:"running",summary:c.cardDeploying}:{...e,steps:f,state:"passed",summary:b.deploy.length>0?c.cardLive:c.merged}}(aU.id,aQ.state):null,a8=a7&&aU?{...au,[aU.id]:a7}:au,a9=Object.values(au).some(a=>a.risk)&&aS&&aU&&a8[aU.id]?{...a8,[aU.id]:{...a8[aU.id],results:aS}}:a8,ba=(0,s.useCallback)(()=>aN(!1),[]);async function bb(){ac(!0),ae(null);try{if(ak.current&&!await ak.current())return ae(t.B.run.saveFirst);let b=await fetch(`/api/workflows/${a}/publish`,{method:"POST"});if(!b.ok)return ae(400===b.status?t.B.run.fixFirst:await kj(b,t.B.run.startFailed));let c=await fetch(`/api/workflows/${a}/runs`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({request:R,provider:B,attachments:iH(W),...Y?{stopForMe:!0}:{},...aE&&B!==ai.C?{direct:!0}:{},...$.trim()?{title:$.trim()}:{},...B!==ai.C&&aL?{startFrom:aL}:{}})});if(!c.ok)return ae(await kj(c,t.B.run.startFailed));let{runId:d}=await c.json(),e=await fetch(`/api/runs/${d}`);if(!e.ok)return ae(await kj(e,t.B.run.startFailed));aj(null),n(await e.json()),aa(),Z(!1),_("")}catch{ae(t.B.run.startFailed)}finally{ac(!1)}}let[bc,bd]=(0,s.useState)("none"),[be,bf]=(0,s.useState)(g?0:null),[bg,bh]=(0,s.useState)(0),bi=null===m&&0!==be&&"new"!==bc,bj=o?.projectId,bk=(0,s.useCallback)(()=>{bj&&fetch(`/api/projects/${bj}`).then(a=>a.ok?a.json():null).then(a=>a&&p(a)).catch(()=>void 0)},[bj]),bl=o?.suggestedTestCommand??null,bm=(0,s.useSyncExternalStore)(kg,()=>{try{return bj?localStorage.getItem(`factory.testSuggestion.${bj}`):null}catch{return null}},()=>null),[bn,bo]=(0,s.useState)(null),[bp,bq]=(0,s.useState)(!1),[br,bs]=(0,s.useState)(!1);async function bt(){if(bl&&bj){bq(!0),bs(!1);try{let a=await fetch(`/api/projects/${bj}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({testCommand:bl})}),b=await a.json().catch(()=>null);if(!a.ok||!b)return bs(!0);p(b)}catch{bs(!0)}finally{bq(!1)}}}function bu(a="new"){aE&&ar(!0),bd(a),n(null),aJ(null),aj(null),ae(null),aa(),bk(),"new"===a&&requestAnimationFrame(()=>document.getElementById(ik)?.focus())}async function bv(){if(m){ae(null);try{let a=await fetch(`/api/runs/${m.runId}/cancel`,{method:"POST"});a.ok||ae(await kj(a,t.B.run.cancelFailed))}catch{ae(t.B.run.cancelFailed)}}}let bw=null!==ay&&kh.has(ay),bx="completed"===ay||"failed"===ay||"cancelled"===ay,by=!!m&&m.blocks.some(a=>au[a.id]?.asking===!0&&au[a.id]?.state==="waiting_approval"),bz=null===m?null:null!==ay?bx?t.B.run.lastRun(t.B.run.status[ay]):"waiting_approval"===ay&&by?t.B.question.stateLabel:t.B.run.status[ay]:az?null:t.B.run.connecting,bA=!ab&&!bw&&""!==R.trim()&&!N&&!iI(W),[bB,bC]=(0,s.useState)(!1),bD=(0,s.useRef)(null),[bE,bF]=(0,s.useState)(null),[bG,bH]=(0,s.useState)(null),bI=m?.blocks.find(a=>"human"===a.kind),bJ=aU?a9[aU.id]?.state:void 0,bK=aU&&bJ&&"queued"!==bJ&&"skipped"!==bJ?aU.id:null,bL=m?.blocks.find(a=>"plan"===a.kind),bM=!!m&&m.blocks.some(a=>"plan"===a.kind&&au[a.id]?.state==="waiting_approval"&&au[a.id]?.asking!==!0),bN=!!m&&m.providerId!==ai.C&&m.blocks.some(a=>"review"===a.kind&&a.enabled&&au[a.id]?.state==="passed"),bO=m&&"waiting_approval"===ay&&by?"question":m&&"waiting_approval"===ay&&bM?"plan":m&&"waiting_approval"===ay?"waiting":m&&("running"===ay||"queued"===ay)?"working":m&&"completed"===ay&&m.providerId!==ai.C?"done":m&&"failed"===ay&&m.providerId!==ai.C?"failed":"idle",bP=aQ&&aQ.runId===aS?aQ.state:null,bQ=y(bP)&&!bP?.onHold,bR=function(a,b){let c=(0,s.useRef)(null),[d,e]=(0,s.useState)(null),f=b?.pr?.state==="merged"&&!0!==b.deployPending,g=null!==b;return(0,s.useEffect)(()=>{if(!a||!g)return;let b=c.current;if(c.current={runId:a,published:f},b?.runId!==a||b.published||!f)return;let d=setTimeout(()=>e(a),0),h=setTimeout(()=>e(null),3200);return()=>{clearTimeout(d),clearTimeout(h)}},[a,g,f]),null!==d&&d===a}(aS,bP),bS="plan"===bO||"question"===bO||"waiting"===bO?"answer":"done"===bO&&bQ?"publish":null,{offer:bT,allow:bU}=function({attention:a,waitingCount:b,taskTitle:c,askKey:d=null}){var e;let f="granted"===(e=(0,s.useSyncExternalStore)(w,x,()=>null))?"on":"denied"===e?"blocked":"default"===e?"ask":"none",[,g]=(0,s.useState)(0);(0,s.useEffect)(()=>{if("u">typeof document){var c;let d;document.title=(c="publish"===a,d=b>0?t.B.tell.waitingTitle(b):c?t.B.tell.readyTitle:null,t.B.tell.tabTitle(d))}},[b,a]),(0,s.useEffect)(()=>()=>{"u">typeof document&&(document.title=t.B.app.name)},[]);let h=(0,s.useRef)(new Set);return(0,s.useEffect)(()=>{if(!a)return;let b=`${a}|${d??""}`;if(!h.current.has(b)){h.current.add(b);try{if("u"<typeof document||!document.hidden||"granted"!==x())return;new Notification("answer"===a?t.B.tell.needsAnswer:t.B.tell.readyToPublish,{body:c??""})}catch{}}},[a,d]),{offer:f,allow:(0,s.useCallback)(()=>{try{if(null===x())return;Promise.resolve(Notification.requestPermission()).then(()=>g(a=>a+1)).catch(()=>void 0)}catch{}},[])}}({attention:bS,waitingCount:Math.max(bg,+("answer"===bS)),taskTitle:m?.title??null,askKey:m?`${m.runId}:${bO}:${jz(ax)??""}`:null}),bV=(0,r.jsxs)("button",{type:"button","aria-expanded":aM,onClick:()=>aN(a=>!a),style:{...ki,marginLeft:o?.repoPath?0:"auto",fontWeight:600,display:"inline-flex",alignItems:"center",gap:8},children:[(0,r.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,r.jsx)("path",{d:"M5 7h14M5 12h14M5 17h14"})}),t.B.history.open,(be??0)>0&&(0,r.jsx)("span",{style:{padding:"1px 8px",borderRadius:999,background:A.f.border,fontSize:12},children:be})]}),bW=aO&&!aE&&null!==m&&!a$,bX=(0,r.jsx)(js,{docked:!0,direct:aE&&B!==ai.C,ref:al,mode:bO,runId:m?.runId??null,risk:Object.values(au).find(a=>"waiting_approval"===a.state)?.risk,planMeasure:bL?au[bL.id]?.planMeasure:void 0,stopForMe:Y,onStopForMe:Z,text:R,onText:S,images:W,onImages:X,onRun:()=>void bb(),canRun:bA,onFollowUp:a=>void am(a),onNewTask:()=>bu("new"),onTaskDeleted:()=>bu("none"),onShipState:aT,onSent:aa,startOptions:B!==ai.C?aK:[],startFrom:aI,onStartFrom:aJ,onRecorded:()=>{aC(),bk()},away:m&&!1===m.here?{machine:m.machine??null}:null,taskName:$,onTaskName:_,loading:a$,failureActions:bD,onCanContinue:a=>bF(a&&m?m.runId:null),onSeeChanges:bI?()=>bH(bI.id):void 0,record:a1,recordFailed:a3,recordMark:a0,recordReadMark:a2,askedId:jz(ax),onRecordChanged:a4,showFindings:bN,notice:{offer:bT,onAllow:bU}},`${m?.runId??"none"}-${a$?"loading":bO}`);return(0,r.jsxs)("div",{style:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[(0,r.jsxs)("header",{style:{display:"flex",alignItems:"center",gap:12,padding:"8px 12px",minHeight:36,borderBottom:`1px solid ${A.f.border}`,background:A.f.bg},children:[(0,r.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:A.f.dim,whiteSpace:"nowrap"},children:[(0,r.jsx)("span",{style:{color:"#e8eaf0",display:"flex"},children:(0,r.jsx)(aA.f,{size:22})}),t.B.app.name]}),h&&(0,r.jsx)(V.f,{account:h,style:ki}),(0,r.jsx)(T,{workflowId:a,style:ki,onOpenSettings:o?()=>bC(!0):void 0}),f&&(0,r.jsxs)("span",{"data-testid":"local-data",title:t.B.localData.hint,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:999,border:`1px solid ${A.f.waiting}`,color:A.f.waiting,fontSize:12,fontWeight:700,whiteSpace:"nowrap",cursor:"help"},children:[(0,r.jsx)("span",{"aria-hidden":!0,style:{width:7,height:7,borderRadius:"50%",background:A.f.waiting}}),t.B.localData.label]}),o&&(0,r.jsx)("button",{type:"button","aria-label":t.B.projectSettings.open,title:t.B.projectSettings.open,onClick:()=>bC(!0),style:{...ki,padding:"6px 9px",display:"grid",placeItems:"center"},children:(0,r.jsx)(L,{size:17})}),bB&&o&&(0,r.jsx)(ag,{settings:o,onClose:()=>bC(!1),onSaved:p}),o&&(0,r.jsx)(hF.g.Provider,{value:F,children:(0,r.jsx)(hF.T,{value:B,ais:i,disabled:bw,style:{...ki,padding:"6px 10px"},onChange:a=>{z(a),a!==ai.C&&fetch("/api/account/ai",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({ai:a})}).catch(()=>void 0)}})}),!aE&&(0,r.jsx)("button",{type:"button",disabled:!bA,title:N?t.B.settings.needsRepo:""===R.trim()?t.B.run.writeFirst:void 0,onClick:bb,style:{...ki,fontWeight:600,background:bA?A.f.running:A.f.card,borderColor:bA?A.f.running:A.f.border,color:bA?"#fff":A.f.skipped,cursor:bA?"pointer":"not-allowed"},children:ab?t.B.run.starting:t.B.run.run}),N&&(0,r.jsx)("button",{type:"button",onClick:()=>bC(!0),style:{background:"none",border:"none",padding:0,fontSize:12.5,color:A.f.waiting,cursor:"pointer",textDecoration:"underline"},children:t.B.settings.needsRepo}),(!aE||bw)&&(0,r.jsx)("button",{type:"button",style:ki,disabled:!bw,onClick:bv,children:t.B.run.cancel}),m&&!bw&&(0,r.jsxs)("button",{type:"button",style:{...ki,fontWeight:700,background:A.f.passed,borderColor:A.f.passed,color:"#0d1f12"},onClick:()=>bu("new"),children:["+ ",t.B.delivery.newTask]}),(0,r.jsx)("span",{"aria-hidden":"true",style:{flex:1}}),m?.providerId===ai.C&&(0,r.jsx)("span",{title:t.B.run.demoTitle,style:{padding:"2px 8px",border:`1px solid ${A.f.waiting}`,color:A.f.waiting,borderRadius:999,fontSize:12,fontWeight:600},children:t.B.run.demoBadge}),bz&&"waiting_approval"===ay?(0,r.jsxs)("button",{type:"button","data-testid":"run-status",title:t.B.gate.goToGate,onClick:()=>{let a=m?.blocks.find(a=>au[a.id]?.state==="waiting_approval");a&&aj(a.id),al.current?.focus(),al.current?.scrollIntoView?.({block:"nearest"})},style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",background:A.f.tint("waiting",.12),color:A.f.waiting,border:`1px solid ${A.f.tint("waiting",.5)}`,borderRadius:999,fontSize:13,fontWeight:600,cursor:"pointer"},children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"⚠"}),bz]}):bz&&"completed"===ay&&m&&m.providerId!==ai.C?(0,r.jsxs)("button",{type:"button","data-testid":"run-status",title:t.B.delivery.title,onClick:()=>{al.current?.focus(),al.current?.scrollIntoView?.({block:"nearest"})},style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",background:A.f.tint("passed",.12),color:A.f.passed,border:`1px solid ${A.f.tint("passed",.5)}`,borderRadius:999,fontSize:13,fontWeight:600,cursor:"pointer"},children:[(0,r.jsx)("span",{"aria-hidden":"true",children:"✓"}),bz]}):bz&&(0,r.jsxs)("span",{"data-testid":"run-status",role:"status",style:{display:"flex",alignItems:"center",gap:7,color:ay?A.f["running"===(l=ay)?"running":"completed"===l?"passed":"failed"===l?"failed":"waiting_approval"===l?"waiting":"skipped"]:A.f.skipped,fontSize:13},children:["running"===ay&&(0,r.jsx)(D.m,{blockId:"run",size:14}),bz]}),o?.repoPath&&(0,r.jsxs)("button",{type:"button","data-testid":"direct-edit-toggle","aria-pressed":aE,title:t.B.direct.hint,onClick:()=>{ar(!aE),at(aE?m?.runId??null:null)},style:{...ki,marginLeft:"auto",fontWeight:600,display:"inline-flex",alignItems:"center",gap:8,...aE?{border:`1px solid ${A.f.passed}`,color:A.f.passed}:{}},children:[(0,r.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,r.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),(0,r.jsx)("path",{d:"M10 4v16"})]}),aE?t.B.direct.off:t.B.direct.on]}),bV,h&&(0,r.jsx)(U.P,{person:h.person})]}),bl&&(bn??bm)!==bl&&(0,r.jsxs)("div",{"data-testid":"test-suggestion",role:"status",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,padding:"8px 14px",borderBottom:`1px solid ${A.f.border}`,background:"rgba(121, 220, 139, 0.07)",fontSize:13},children:[(0,r.jsx)("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:"none",stroke:A.f.passed,strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,r.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})}),(0,r.jsx)("span",{children:br?t.B.testSuggestion.failed:t.B.testSuggestion.text(bl)}),(0,r.jsx)("button",{type:"button",disabled:bp,onClick:()=>void bt(),style:{padding:"5px 12px",borderRadius:6,border:`1px solid ${A.f.passed}`,background:A.f.passed,color:"#07110a",fontWeight:700,cursor:bp?"wait":"pointer"},children:t.B.testSuggestion.accept}),(0,r.jsx)("button",{type:"button",disabled:bp,onClick:function(){if(bl&&bj){bo(bl);try{localStorage.setItem(`factory.testSuggestion.${bj}`,bl)}catch{}}},style:{...ki,padding:"5px 12px"},children:t.B.testSuggestion.dismiss})]}),(0,r.jsxs)("div",{style:{flex:1,minHeight:0,position:"relative",overflow:"clip"},children:[null===m&&!(aE&&(be??0)>0&&"new"===bc)&&(0,r.jsx)("div",{"data-testid":"no-task",role:"region","aria-label":0===be?t.B.history.firstTaskTitle:t.B.history.noTaskTitle,style:{position:"absolute",top:bi?"50%":64,left:"50%",transform:bi?"translate(-50%, -60%)":"translateX(-50%)",zIndex:4,width:bi?"min(520px, calc(100% - 32px))":"min(440px, calc(100% - 32px))",display:"grid",gap:bi?12:8,padding:bi?"28px 28px 26px":"16px 18px",background:A.f.card,border:`1px solid ${A.f.border}`,borderRadius:12,boxShadow:"0 12px 30px rgba(0,0,0,0.4)",textAlign:"center"},children:0===be?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{className:"factory-display",style:{fontSize:19},children:t.B.history.firstTaskTitle}),(0,r.jsx)("span",{style:{fontSize:13,color:A.f.dim,lineHeight:1.5},children:t.B.history.firstTaskText}),(0,r.jsxs)("button",{type:"button",onClick:()=>{let a=document.querySelector('[data-testid="command-card"]');a?.querySelector("textarea")?.focus(),a?.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:A.f.running,color:"#fff",fontWeight:700,cursor:"pointer"},children:[(0,r.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,r.jsx)("path",{d:"M12 5v14M5 12h14"})}),t.B.history.firstTaskAction]})]}):"new"===bc?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{style:{fontSize:15},children:t.B.history.newTaskTitle}),(0,r.jsx)("span",{style:{fontSize:12.5,color:A.f.dim,lineHeight:1.45},children:t.B.history.newTaskText})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{className:"factory-display",style:{fontSize:24},children:t.B.history.noTaskTitle}),(0,r.jsx)("span",{style:{fontSize:14.5,color:A.f.dim,lineHeight:1.5},children:t.B.history.noTaskText}),(0,r.jsxs)("div",{style:{display:"flex",justifyContent:"center",gap:10,flexWrap:"wrap",marginTop:6},children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{bd("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:A.f.running,color:"#fff",fontSize:14.5,fontWeight:700,cursor:"pointer"},children:[(0,r.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,r.jsx)("path",{d:"M12 5v14M5 12h14"})}),t.B.history.createOne]}),(0,r.jsxs)("button",{type:"button",onClick:()=>aN(!0),style:{display:"inline-flex",alignItems:"center",gap:8,padding:"10px 20px",borderRadius:8,border:`1px solid ${A.f.border}`,background:"#0f141c",color:"#e6e9ef",fontSize:14.5,fontWeight:700,cursor:"pointer"},children:[(0,r.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,r.jsx)("path",{d:"M5 7h14M5 12h14M5 17h14"})}),t.B.history.openPast]})]})]})}),(0,r.jsx)(C,{open:aM,onClose:ba,count:be,children:(0,r.jsx)(v.R,{workflowId:a,currentRunId:m?.runId??null,publishing:aQ?.runId===m?.runId&&aQ?.state.pr?.state==="merged"&&!0===aQ.state.deployPending,refreshKey:`${m?.runId??""}-${ay??""}-${aM}`,onOpen:a=>{aN(!1),am(a)},onCount:bf,onWaiting:bh,onDeleted:a=>{a===m?.runId&&(bu("none"),aN(!1))}})}),bX,(0,r.jsx)(hF.g.Provider,{value:F,children:(0,r.jsxs)(D.c.Provider,{value:M,children:[(0,r.jsx)(D.v.Provider,{value:G,children:(0,r.jsx)(ip,{layout:aE?"steps":"canvas",site:aE?(0,r.jsx)(H,{runId:m&&!1!==m.here&&B!==ai.C?m.runId:null,projectId:m?null:o?.projectId??null}):void 0,stepDetails:a=>m?(0,r.jsx)(j_,{inline:!0,runId:m.runId,blockId:a,label:m.blocks.find(b=>b.id===a)?.label??a,view:a6(a5(a9))[a],pr:aQ?.runId===m.runId?aQ.state.pr??null:null,away:!1===m.here?{machine:m.machine??null}:null,onClose:()=>void 0},`inline-${m.runId}-${a}`):null,graph:b,save:function(b){let c=aG.current.catch(()=>void 0).then(async()=>{if(aH.current)throw Error("stale draft");let c=await fetch(`/api/workflows/${a}/draft`,{method:"PUT",headers:{"content-type":"application/json",...aF.current?{"x-draft-base":aF.current}:{}},body:JSON.stringify(b),keepalive:!0});if(409===c.status)throw aH.current=!0,ae(t.B.editing.staleDraft),Error("stale draft");if(!c.ok)throw Error(`Saving the draft failed (${c.status})`);let d=await c.json();return d.updatedAt&&(aF.current=d.updatedAt),d.issues});return aG.current=c,c},nodeRuns:Object.values(a6(a5(a9))),runBlocks:m?.blocks,highlightedId:af,onFailedClick:"failed"===bO?a=>"see"===a?bD.current?.see():bD.current?.again():void 0,canRetry:"failed"===bO&&bE===m?.runId,onDetails:m?bH:void 0,blank:bi,taskId:m?.runId??null,flushRef:ak,loading:a$,overlay:m&&!a$?(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(I,{roomy:aE,runId:m.runId,initial:m.title??"",onRenamed:a=>n(b=>b&&b.runId===m.runId?{...b,title:a}:b)},m.runId)}):void 0,sidebarLog:m?(0,r.jsx)(av,{events:ax,blocks:m.blocks,onPoint:aj}):void 0})}),bW&&m&&(0,r.jsx)(ix,{runId:m.runId,blocks:m.blocks,views:a6(a5(a9)),rounds:aw,prompts:a_,onDetails:bH}),!aE&&null!==m&&!a$&&(0,r.jsx)(iw,{chat:aO,onChange:aP}),bR&&(0,r.jsx)(u,{})]})}),m&&bG&&(0,r.jsx)(j_,{runId:m.runId,blockId:bG,label:m.blocks.find(a=>a.id===bG)?.label??bG,view:a5(a9)[bG],pr:aQ?.runId===m.runId?aQ.state.pr??null:null,away:!1===m.here?{machine:m.machine??null}:null,onClose:()=>bH(null),onSeeShip:bK?()=>bH(bK):void 0,onSettings:()=>{bH(null),window.dispatchEvent(new CustomEvent(ii,{detail:bG}))}},`details-${m.runId}-${bG}`)]})]})}],1603)}];
|
|
6
6
|
|
|
7
7
|
//# sourceMappingURL=_14z-y2hqpv20w._.js.map
|