gcf-board 0.18.7 → 0.19.1

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.
@@ -16,14 +16,14 @@ Error generating stack: `+e.message+`
16
16
  Press space again to drop the item in its new position, or press escape to cancel.
17
17
  `},Be={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function Ve(e){let{announcements:t=Be,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=ze}=e,{announce:a,announcement:o}=Fe(),s=xe(`DndLiveRegion`),[c,l]=(0,v.useState)(!1);if((0,v.useEffect)(()=>{l(!0)},[]),Le((0,v.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=v.createElement(v.Fragment,null,v.createElement(Ne,{id:r,value:i.draggable}),v.createElement(Pe,{id:s,announcement:o}));return n?(0,ce.createPortal)(u,n):u}var He;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(He||={});function Ue(){}function We(e,t){return(0,v.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Ge(){var e=[...arguments];return(0,v.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Ke=Object.freeze({x:0,y:0});function qe(e,t){let n=Oe(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function Je(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Ye(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Xe(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var Ze=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=Xe(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Je)};function Qe(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function $e(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ke}function et(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var tt=et(1);function nt(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function rt(e,t,n){let r=nt(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var it={ignoreTransform:!1};function at(e,t){t===void 0&&(t=it);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=le(e).getComputedStyle(e);t&&(n=rt(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function ot(e){return at(e,{ignoreTransform:!0})}function st(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function ct(e,t){return t===void 0&&(t=le(e).getComputedStyle(e)),t.position===`fixed`}function lt(e,t){t===void 0&&(t=le(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`&&n.test(r)})}function ut(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(ue(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!de(i)||fe(i)||n.includes(i))return n;let a=le(e).getComputedStyle(i);return i!==e&&lt(i,a)&&n.push(i),ct(i,a)?n:r(i.parentNode)}return e?r(e):n}function dt(e){let[t]=ut(e,1);return t??null}function ft(e){return!V||!e?null:H(e)?e:U(e)?ue(e)||e===pe(e).scrollingElement?window:de(e)?e:null:null}function pt(e){return H(e)?e.scrollX:e.scrollLeft}function mt(e){return H(e)?e.scrollY:e.scrollTop}function ht(e){return{x:pt(e),y:mt(e)}}var gt;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(gt||={});function _t(e){return!V||!e?!1:e===document.scrollingElement}function vt(e){let t={x:0,y:0},n=_t(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var yt={x:.2,y:.2};function bt(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=yt);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=vt(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=gt.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=gt.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=gt.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=gt.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function xt(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function St(e){return e.reduce((e,t)=>Ce(e,ht(t)),Ke)}function Ct(e){return e.reduce((e,t)=>e+pt(t),0)}function wt(e){return e.reduce((e,t)=>e+mt(t),0)}function Tt(e,t){if(t===void 0&&(t=at),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);dt(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Et=[[`x`,[`left`,`right`],Ct],[`y`,[`top`,`bottom`],wt]],Dt=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=ut(t),r=St(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Et)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},Ot=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function kt(e){let{EventTarget:t}=le(e);return e instanceof t?e:pe(e)}function At(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t&&r>t.y}var jt;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(jt||={});function Mt(e){e.preventDefault()}function Nt(e){e.stopPropagation()}var Pt;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(Pt||={});var Ft={start:[Pt.Space,Pt.Enter],cancel:[Pt.Esc],end:[Pt.Space,Pt.Enter,Pt.Tab]},It=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Pt.Right:return{...n,x:n.x+25};case Pt.Left:return{...n,x:n.x-25};case Pt.Down:return{...n,y:n.y+25};case Pt.Up:return{...n,y:n.y-25}}},Lt=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Ot(pe(t)),this.windowListeners=new Ot(le(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(jt.Resize,this.handleCancel),this.windowListeners.add(jt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(jt.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Tt(n),t(Ke)}handleKeyDown(e){if(Ee(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Ft,coordinateGetter:a=It,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:Ke;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=we(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=vt(n),p=xt(n),m={x:Math.min(i===Pt.Right?p.right-p.width/2:p.right,Math.max(i===Pt.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===Pt.Down?p.bottom-p.height/2:p.bottom,Math.max(i===Pt.Down?p.top:p.top+p.height/2,u.y))},h=i===Pt.Right&&!s||i===Pt.Left&&!c,g=i===Pt.Down&&!l||i===Pt.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===Pt.Right&&e<=d.x||i===Pt.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}r.x=a?n.scrollLeft-e:i===Pt.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===Pt.Down&&e<=d.y||i===Pt.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}r.y=a?n.scrollTop-e:i===Pt.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Ce(we(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Lt.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Ft,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Rt(e){return!!(e&&`distance`in e)}function zt(e){return!!(e&&`delay`in e)}var Bt=class{constructor(e,t,n){n===void 0&&(n=kt(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=pe(i),this.documentListeners=new Ot(this.document),this.listeners=new Ot(n),this.windowListeners=new Ot(le(i)),this.initialCoordinates=Oe(r)??Ke,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(jt.Resize,this.handleCancel),this.windowListeners.add(jt.DragStart,Mt),this.windowListeners.add(jt.VisibilityChange,this.handleCancel),this.windowListeners.add(jt.ContextMenu,Mt),this.documentListeners.add(jt.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(zt(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Rt(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(jt.Click,Nt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(jt.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=Oe(e)??Ke,s=we(n,o);if(!t&&a){if(Rt(a)){if(a.tolerance!=null&&At(s,a.tolerance))return this.handleCancel();if(At(s,a.distance))return this.handleStart()}if(zt(a)&&At(s,a.tolerance))return this.handleCancel();this.handlePending(a,s)}else e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===Pt.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},Vt={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Ht=class extends Bt{constructor(e){let{event:t}=e,n=pe(t.target);super(e,Vt,n)}};Ht.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var Ut={move:{name:`mousemove`},end:{name:`mouseup`}},Wt;(function(e){e[e.RightClick=2]=`RightClick`})(Wt||={});var Gt=class extends Bt{constructor(e){super(e,Ut,pe(e.event.target))}};Gt.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==Wt.RightClick&&(r?.({event:n}),!0)}}];var Kt={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},qt=class extends Bt{constructor(e){super(e,Kt)}static setup(){return window.addEventListener(Kt.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Kt.move.name,e)};function e(){}}};qt.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Jt;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Jt||={});var Yt;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Yt||={});function Xt(e){let{acceleration:t,activator:n=Jt.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Yt.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Qt({delta:d,disabled:!a}),[m,h]=he(),g=(0,v.useRef)({x:0,y:0}),_=(0,v.useRef)({x:0,y:0}),y=(0,v.useMemo)(()=>{switch(n){case Jt.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Jt.DraggableRect:return i}},[n,i,c]),b=(0,v.useRef)(null),x=(0,v.useCallback)(()=>{let e=b.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),S=(0,v.useMemo)(()=>s===Yt.TreeOrder?[...l].reverse():l,[s,l]);(0,v.useEffect)(()=>{if(!a||!l.length||!y)h();else{for(let e of S){if(r?.(e)===!1)continue;let n=l.indexOf(e),i=u[n];if(!i)continue;let{direction:a,speed:s}=bt(e,i,y,t,f);for(let e of[`x`,`y`])p[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){h(),b.current=e,m(x,o),g.current=s,_.current=a;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()}},[t,x,r,h,a,o,JSON.stringify(y),JSON.stringify(p),m,l,S,u,JSON.stringify(f)])}var Zt={x:{[gt.Backward]:!1,[gt.Forward]:!1},y:{[gt.Backward]:!1,[gt.Forward]:!1}};function Qt(e){let{delta:t,disabled:n}=e,r=ye(t);return _e(e=>{if(n||!r||!e)return Zt;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[gt.Backward]:e.x[gt.Backward]||i.x===-1,[gt.Forward]:e.x[gt.Forward]||i.x===1},y:{[gt.Backward]:e.y[gt.Backward]||i.y===-1,[gt.Forward]:e.y[gt.Forward]||i.y===1}}},[n,t,r])}function $t(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return _e(e=>t==null?null:r??e??null,[r,t])}function en(e,t){return(0,v.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var tn;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(tn||={});var nn;(function(e){e.Optimized=`optimized`})(nn||={});var rn=new Map;function an(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,v.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,v.useRef)(e),d=g(),f=ge(d),p=(0,v.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,v.useRef)(null),h=_e(t=>{if(d&&!n)return rn;if(!t||t===rn||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Dt(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,v.useEffect)(()=>{u.current=e},[e]),(0,v.useEffect)(()=>{d||p()},[n,d]),(0,v.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,v.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case tn.Always:return!1;case tn.BeforeDragging:return n;default:return!n}}}function on(e,t){return _e(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function sn(e,t){return on(e,t)}function cn(e){let{callback:t,disabled:n}=e,r=me(t),i=(0,v.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,v.useEffect)(()=>()=>i?.disconnect(),[i]),i}function ln(e){let{callback:t,disabled:n}=e,r=me(t),i=(0,v.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,v.useEffect)(()=>()=>i?.disconnect(),[i]),i}function un(e){return new Dt(at(e),e)}function dn(e,t,n){t===void 0&&(t=un);let[r,i]=(0,v.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=cn({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=ln({callback:a});return W(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function fn(e){return $e(e,on(e))}var pn=[];function mn(e){let t=(0,v.useRef)(e),n=_e(n=>e?n&&n!==pn&&e&&t.current&&e.parentNode===t.current.parentNode?n:ut(e):pn,[e]);return(0,v.useEffect)(()=>{t.current=e},[e]),n}function hn(e){let[t,n]=(0,v.useState)(null),r=(0,v.useRef)(e),i=(0,v.useCallback)(e=>{let t=ft(e.target);t&&n(e=>e?(e.set(t,ht(t)),new Map(e)):null)},[]);return(0,v.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=ft(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,ht(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{ft(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,v.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Ce(e,t),Ke):St(e):Ke,[e,t])}function gn(e,t){t===void 0&&(t=[]);let n=(0,v.useRef)(null);return(0,v.useEffect)(()=>{n.current=null},t),(0,v.useEffect)(()=>{let t=e!==Ke;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?we(e,n.current):Ke}function _n(e){(0,v.useEffect)(()=>{if(!V)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function vn(e,t){return(0,v.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function yn(e){return(0,v.useMemo)(()=>e?st(e):null,[e])}var bn=[];function xn(e,t){t===void 0&&(t=at);let[n]=e,r=yn(n?le(n):null),[i,a]=(0,v.useState)(bn);function o(){a(()=>e.length?e.map(e=>_t(e)?r:new Dt(t(e),e)):bn)}let s=ln({callback:o});return W(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Sn(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return de(t)?t:e}function Cn(e){let{measure:t}=e,[n,r]=(0,v.useState)(null),i=ln({callback:(0,v.useCallback)(e=>{for(let{target:n}of e)if(de(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=ve((0,v.useCallback)(e=>{let n=Sn(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,v.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var wn=[{sensor:Ht,options:{}},{sensor:Lt,options:{}}],Tn={current:{}},En={draggable:{measure:ot},droppable:{measure:ot,strategy:tn.WhileDragging,frequency:nn.Optimized},dragOverlay:{measure:at}},Dn=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},On={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Dn,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ue},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:En,measureDroppableContainers:Ue,windowRect:null,measuringScheduled:!1},kn={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Ue,draggableNodes:new Map,over:null,measureDroppableContainers:Ue},An=(0,v.createContext)(kn),jn=(0,v.createContext)(On);function Mn(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Dn}}}function Nn(e,t){switch(t.type){case He.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case He.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case He.DragEnd:case He.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case He.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Dn(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case He.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new Dn(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case He.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Dn(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Pn(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,v.useContext)(An),a=ye(r),o=ye(n?.id);return(0,v.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Ee(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=je(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Fn(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function In(e){return(0,v.useMemo)(()=>({draggable:{...En.draggable,...e?.draggable},droppable:{...En.droppable,...e?.droppable},dragOverlay:{...En.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Ln(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,v.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;W(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=$e(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=dt(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Rn=(0,v.createContext)({...Ke,scaleX:1,scaleY:1}),zn;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(zn||={});var Bn=(0,v.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=wn,collisionDetection:o=Ze,measuring:s,modifiers:c,...l}=e,[u,d]=(0,v.useReducer)(Nn,void 0,Mn),[f,p]=Re(),[m,h]=(0,v.useState)(zn.Uninitialized),g=m===zn.Initialized,{draggable:{active:_,nodes:y,translate:b},droppable:{containers:x}}=u,S=_==null?null:y.get(_),C=(0,v.useRef)({initial:null,translated:null}),w=(0,v.useMemo)(()=>_==null?null:{id:_,data:S?.data??Tn,rect:C},[_,S]),T=(0,v.useRef)(null),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(null),A=ge(l,Object.values(l)),ee=xe(`DndDescribedBy`,t),j=(0,v.useMemo)(()=>x.getEnabled(),[x]),M=In(s),{droppableRects:te,measureDroppableContainers:N,measuringScheduled:ne}=an(j,{dragging:g,dependencies:[b.x,b.y],config:M.droppable}),P=$t(y,_),F=(0,v.useMemo)(()=>O?Oe(O):null,[O]),re=Me(),I=sn(P,M.draggable.measure);Ln({activeNode:_==null?null:y.get(_),config:re.layoutShiftCompensation,initialRect:I,measure:M.draggable.measure});let L=dn(P,M.draggable.measure,I),R=dn(P?P.parentElement:null),z=(0,v.useRef)({activatorEvent:null,active:null,activeNode:P,collisionRect:null,collisions:null,droppableRects:te,draggableNodes:y,draggingNode:null,draggingNodeRect:null,droppableContainers:x,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ie=x.getNodeFor(z.current.over?.id),B=Cn({measure:M.dragOverlay.measure}),ae=B.nodeRef.current??P,oe=g?B.rect??L:null,se=!!(B.nodeRef.current&&B.rect),V=fn(se?null:L),H=yn(ae?le(ae):null),U=mn(g?ie??P:null),ue=xn(U),de=Fn(c,{transform:{x:b.x-V.x,y:b.y-V.y,scaleX:1,scaleY:1},activatorEvent:O,active:w,activeNodeRect:L,containerNodeRect:R,draggingNodeRect:oe,over:z.current.over,overlayNodeRect:B.rect,scrollableAncestors:U,scrollableAncestorRects:ue,windowRect:H}),fe=F?Ce(F,b):null,pe=hn(U),me=gn(pe),he=gn(pe,[L]),_e=Ce(de,me),ve=oe?tt(oe,de):null,ye=w&&ve?o({active:w,collisionRect:ve,droppableRects:te,droppableContainers:j,pointerCoordinates:fe}):null,be=Ye(ye,`id`),[Se,we]=(0,v.useState)(null),Te=Qe(se?de:Ce(de,he),Se?.rect??null,L),Ee=(0,v.useRef)(null),De=(0,v.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(T.current==null)return;let i=y.get(T.current);if(!i)return;let a=e.nativeEvent,o=new n({active:T.current,activeNode:i,event:a,options:r,context:z,onAbort(e){if(!y.get(e))return;let{onDragAbort:t}=A.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!y.get(e))return;let{onDragPending:i}=A.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=T.current;if(t==null)return;let n=y.get(t);if(!n)return;let{onDragStart:r}=A.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:C}};(0,ce.unstable_batchedUpdates)(()=>{r?.(i),h(zn.Initializing),d({type:He.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),D(Ee.current),k(a)})},onMove(e){d({type:He.DragMove,coordinates:e})},onEnd:s(He.DragEnd),onCancel:s(He.DragCancel)});Ee.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=z.current,o=null;if(t&&i){let{cancelDrop:s}=A.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===He.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=He.DragCancel)}T.current=null,(0,ce.unstable_batchedUpdates)(()=>{d({type:e}),h(zn.Uninitialized),we(null),D(null),k(null),Ee.current=null;let t=e===He.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=A.current[t];e?.(o),f({type:t,event:o})}})}}},[y]),ke=en(a,(0,v.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=y.get(r);if(T.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},T.current=r,De(n,t))},[y,De]));_n(a),W(()=>{L&&m===zn.Initializing&&h(zn.Initialized)},[L,m]),(0,v.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:i}=z.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:_e.x,y:_e.y},over:i};(0,ce.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[_e.x,_e.y]),(0,v.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=z.current;if(!e||T.current==null||!t||!i)return;let{onDragOver:a}=A.current,o=r.get(be),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,ce.unstable_batchedUpdates)(()=>{we(s),a?.(c),f({type:`onDragOver`,event:c})})},[be]),W(()=>{z.current={activatorEvent:O,active:w,activeNode:P,collisionRect:ve,collisions:ye,droppableRects:te,draggableNodes:y,draggingNode:ae,draggingNodeRect:oe,droppableContainers:x,over:Se,scrollableAncestors:U,scrollAdjustedTranslate:_e},C.current={initial:oe,translated:ve}},[w,P,ye,ve,y,ae,oe,te,x,Se,U,_e]),Xt({...re,delta:b,draggingRect:ve,pointerCoordinates:fe,scrollableAncestors:U,scrollableAncestorRects:ue});let Ae=(0,v.useMemo)(()=>({active:w,activeNode:P,activeNodeRect:L,activatorEvent:O,collisions:ye,containerNodeRect:R,dragOverlay:B,draggableNodes:y,droppableContainers:x,droppableRects:te,over:Se,measureDroppableContainers:N,scrollableAncestors:U,scrollableAncestorRects:ue,measuringConfiguration:M,measuringScheduled:ne,windowRect:H}),[w,P,L,O,ye,R,B,y,x,te,Se,N,U,ue,M,ne,H]),je=(0,v.useMemo)(()=>({activatorEvent:O,activators:ke,active:w,activeNodeRect:L,ariaDescribedById:{draggable:ee},dispatch:d,draggableNodes:y,over:Se,measureDroppableContainers:N}),[O,ke,w,L,d,ee,y,Se,N]);return v.createElement(Ie.Provider,{value:p},v.createElement(An.Provider,{value:je},v.createElement(jn.Provider,{value:Ae},v.createElement(Rn.Provider,{value:Te},i)),v.createElement(Pn,{disabled:n?.restoreFocus===!1})),v.createElement(Ve,{...n,hiddenTextDescribedById:ee}));function Me(){let e=E?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Vn=(0,v.createContext)(null),Hn=`button`,Un=`Draggable`;function Wn(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=xe(Un),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,v.useContext)(An),{role:p=Hn,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,v.useContext)(g?Rn:Vn),[y,b]=ve(),[x,S]=ve(),C=vn(o,t),w=ge(n);return W(()=>(d.set(t,{id:t,key:a,node:y,activatorNode:x,data:w}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,v.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Hn?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:C,node:y,over:f,setNodeRef:b,setActivatorNodeRef:S,transform:_}}function Gn(){return(0,v.useContext)(jn)}var Kn=`Droppable`,qn={timeout:25};function Jn(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=xe(Kn),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,v.useContext)(An),u=(0,v.useRef)({disabled:n}),d=(0,v.useRef)(!1),f=(0,v.useRef)(null),p=(0,v.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...qn,...i},_=ge(h??r),y=ln({callback:(0,v.useCallback)(()=>{d.current?(p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)):d.current=!0},[g]),disabled:m||!o}),[b,x]=ve((0,v.useCallback)((e,t)=>{y&&(t&&(y.unobserve(t),d.current=!1),e&&y.observe(e))},[y])),S=ge(t);return(0,v.useEffect)(()=>{y&&b.current&&(y.disconnect(),d.current=!1,y.observe(b.current))},[b,y]),(0,v.useEffect)(()=>(s({type:He.RegisterDroppable,element:{id:r,key:a,disabled:n,node:b,rect:f,data:S}}),()=>s({type:He.UnregisterDroppable,key:a,id:r})),[r]),(0,v.useEffect)(()=>{n!==u.current.disabled&&(s({type:He.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:b,over:c,setNodeRef:x}}function Yn(e){let{animation:t,children:n}=e,[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(null),s=ye(n);return!n&&!r&&s&&i(s),W(()=>{if(!a)return;let e=r?.key,n=r?.props.id;e==null||n==null?i(null):Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),v.createElement(v.Fragment,null,n,r?(0,v.cloneElement)(r,{ref:o}):null)}var Xn={x:0,y:0,scaleX:1,scaleY:1};function Zn(e){let{children:t}=e;return v.createElement(An.Provider,{value:kn},v.createElement(Rn.Provider,{value:Xn},t))}var Qn={position:`fixed`,touchAction:`none`},$n=e=>Ee(e)?`transform 250ms ease`:void 0,er=(0,v.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=$n}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Qn,width:s.width,height:s.height,top:s.top,left:s.left,transform:ke.Transform.toString(d),transformOrigin:i&&r?qe(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return v.createElement(n,{className:o,style:f,ref:t},a)}),tr={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:ke.Transform.toString(t)},{transform:ke.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function nr(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return me((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=Sn(a);if(!c)return;let{transform:l}=le(a).getComputedStyle(a),u=nt(l);if(!u)return;let d=typeof t==`function`?t:rr(t);return Tt(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function rr(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...tr,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var ir=0;function ar(e){return(0,v.useMemo)(()=>{if(e!=null)return ir++,ir},[e])}var or=v.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:y,scrollableAncestors:b,scrollableAncestorRects:x,windowRect:S}=Gn(),C=(0,v.useContext)(Rn),w=ar(d?.id),T=Fn(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:b,scrollableAncestorRects:x,transform:C,windowRect:S}),E=on(f),D=nr({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:y}),O=E?g.setRef:void 0;return v.createElement(Zn,null,v.createElement(Yn,{animation:D},d&&w?v.createElement(er,{key:w,id:d.id,ref:O,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:E,style:{zIndex:l,...i},transform:T},n):null))}),sr=e=>e.design&&!(`error`in e.design)?e.design:null;function cr(e){let t=new Map((sr(e)?.steps??[]).map(e=>[e.id,e.done]));return(e.domain.sections.design?.steps??[]).map(e=>({...e,done:t.get(e.id)??!1}))}var lr=e=>{let t=new Set(sr(e)?.questions??[]);return(e.questions??[]).filter(e=>t.has(e.id))},ur=(e,t)=>{let n=new Set((e.units??[]).find(e=>e.id===t)?.blocked_by??[]);return(e.questions??[]).filter(e=>n.has(e.id))};function dr(e){let t=e.value===`TBD`?null:e.value;return e.form===`record-list`?Array.isArray(t)?t:[]:e.form===`scalar`?typeof t==`string`?t:``:Array.isArray(t)?t.join(`
18
18
  `):``}function fr(e,t){return e.form===`record-list`||e.form===`scalar`?t:String(t).split(`
19
- `).map(e=>e.trim()).filter(Boolean)}function pr(e,t,n){return Object.fromEntries(e.filter(e=>JSON.stringify(fr(e,t[e.key]))!==JSON.stringify(fr(e,n[e.key]))).map(e=>[e.key,fr(e,n[e.key])]))}var mr=e=>Array.isArray(e)?!e.length:!e.trim();function hr(e){if(e===`gcf/glossary.md`)return`glossary`;if(e===`gcf/PILLARS.md`)return`pillars`;if(e===`gcf/game.md`)return`vision`;let t=/^gcf\/design\/([a-z0-9-]+)\.md$/.exec(e)?.[1];return t?`units:system:${t}`:null}var gr=e=>/^gcf\/(game|glossary|PILLARS)\.md$/.test(e)||e.startsWith(`gcf/design/`),_r={а:`a`,б:`b`,в:`v`,г:`g`,ґ:`g`,д:`d`,е:`e`,ё:`e`,є:`ie`,ж:`zh`,з:`z`,и:`i`,і:`i`,ї:`i`,й:`i`,к:`k`,л:`l`,м:`m`,н:`n`,о:`o`,п:`p`,р:`r`,с:`s`,т:`t`,у:`u`,ў:`u`,ф:`f`,х:`kh`,ц:`ts`,ч:`ch`,ш:`sh`,щ:`shch`,ъ:``,ы:`y`,ь:``,э:`e`,ю:`iu`,я:`ia`};function vr(e,t,n=`pillar`){let r=[...e.toLowerCase().normalize(`NFD`).replace(/\p{M}/gu,``).normalize(`NFC`)].map(e=>_r[e]??e).join(``).split(/[^a-z0-9]+/).filter(Boolean).slice(0,4);for(;r.length>1&&r.join(`-`).length>32;)r.pop();let i=r.join(`-`).slice(0,32).replace(/-+$/,``);if(!i){let e=1;for(;t(`${n}-${e}`);)e++;return`${n}-${e}`}let a=i;for(let e=2;t(a);e++)a=`${i}-${e}`;return a}function yr(e){let t=e.blocked_by.length>0;return{state:e.ready?`ready`:t?`held by ${e.blocked_by.join(`, `)}`:`TBD ${e.tbd}`,tone:e.ready?`ok`:t?`needs`:`warn`,tip:e.ready?`No TBD and no question: it can go into work`:t?`A question holds it: it cannot go into work until the question is answered and applied${e.tbd?` · TBD ${e.tbd}`:``}`:`${e.tbd} slot${e.tbd===1?` is`:`s are`} TBD`,extra:t&&e.tbd?`TBD ${e.tbd}`:``}}function br(e,t){let n=e.domain.sections.inbox,r=t.category??(t.class===`D2`?`assumption`:`decision`),i=n?.categories?.find(e=>e.id===r);return{label:i?.label??r,help:i?.help??``,needs:!!(i&&n?.groups?.find(e=>e.id===i.group)?.counts)}}var xr=e=>typeof e==`string`&&/^TBD\b/.test(e);function Sr(e){let t=[];for(let n of e.replace(/\r\n/g,`
19
+ `).map(e=>e.trim()).filter(Boolean)}function pr(e,t,n){return Object.fromEntries(e.filter(e=>JSON.stringify(fr(e,t[e.key]))!==JSON.stringify(fr(e,n[e.key]))).map(e=>[e.key,fr(e,n[e.key])]))}var mr=e=>Array.isArray(e)?!e.length:!e.trim();function hr(e){if(e===`GLOSSARY.md`||e===`gcf/glossary.md`)return`glossary`;if(e===`gcf/PILLARS.md`)return`pillars`;if(e===`gcf/game.md`)return`vision`;let t=/^gcf\/design\/([a-z0-9-]+)\.md$/.exec(e)?.[1];return t?`units:system:${t}`:null}var gr=e=>/^gcf\/(game|glossary|PILLARS)\.md$/.test(e)||e===`GLOSSARY.md`||e.startsWith(`gcf/design/`),_r={а:`a`,б:`b`,в:`v`,г:`g`,ґ:`g`,д:`d`,е:`e`,ё:`e`,є:`ie`,ж:`zh`,з:`z`,и:`i`,і:`i`,ї:`i`,й:`i`,к:`k`,л:`l`,м:`m`,н:`n`,о:`o`,п:`p`,р:`r`,с:`s`,т:`t`,у:`u`,ў:`u`,ф:`f`,х:`kh`,ц:`ts`,ч:`ch`,ш:`sh`,щ:`shch`,ъ:``,ы:`y`,ь:``,э:`e`,ю:`iu`,я:`ia`};function vr(e,t,n=`pillar`){let r=[...e.toLowerCase().normalize(`NFD`).replace(/\p{M}/gu,``).normalize(`NFC`)].map(e=>_r[e]??e).join(``).split(/[^a-z0-9]+/).filter(Boolean).slice(0,4);for(;r.length>1&&r.join(`-`).length>32;)r.pop();let i=r.join(`-`).slice(0,32).replace(/-+$/,``);if(!i){let e=1;for(;t(`${n}-${e}`);)e++;return`${n}-${e}`}let a=i;for(let e=2;t(a);e++)a=`${i}-${e}`;return a}function yr(e){let t=e.blocked_by.length>0;return{state:e.ready?`ready`:t?`held by ${e.blocked_by.join(`, `)}`:`TBD ${e.tbd}`,tone:e.ready?`ok`:t?`needs`:`warn`,tip:e.ready?`No TBD and no question: it can go into work`:t?`A question holds it: it cannot go into work until the question is answered and applied${e.tbd?` · TBD ${e.tbd}`:``}`:`${e.tbd} slot${e.tbd===1?` is`:`s are`} TBD`,extra:t&&e.tbd?`TBD ${e.tbd}`:``}}function br(e,t){let n=e.domain.sections.inbox,r=t.category??(t.class===`D2`?`assumption`:`decision`),i=n?.categories?.find(e=>e.id===r);return{label:i?.label??r,help:i?.help??``,needs:!!(i&&n?.groups?.find(e=>e.id===i.group)?.counts)}}var xr=e=>typeof e==`string`&&/^TBD\b/.test(e);function Sr(e){let t=[];for(let n of e.replace(/\r\n/g,`
20
20
  `).split(`
21
21
  `)){let e=/^(#{1,3}) (.*)$/.exec(n);e?t.push({h:e[2],level:e[1].length,body:``}):t.length&&(t[t.length-1].body+=`${n}\n`)}return t.map(e=>({...e,body:e.body.trim()}))}function Cr(e){let t=[],n=[];for(let r of e.split(`
22
22
  `)){let e=/^applied (.+)$/.exec(r),i=/^(\S+) (\S+): (.*)$/.exec(r);e?t.push(e[1]):i&&n.push({outcome:i[1],part:i[2],note:i[3]})}return{applied:t,report:n}}function wr(e,t){let n=[...e.record_keys,...e.optional_record_keys];return[...n,...new Set(t.flatMap(e=>Object.keys(e)).filter(e=>!n.includes(e)))]}function Tr(e,t){if(!t||!Object.hasOwn(e.moves,t))return null;let{args:n,...r}=e.moves[t];return r.kind===`agent`?null:{...r,cmd:t}}var Er=(e,t)=>e.moves.flatMap(e=>Tr(t,e)??[]),Dr=new Set([`verdict:keep`,`decide:go`]),Or=e=>e.danger?`btn-danger`:Dr.has(e.cmd)?`btn-ok`:`btn`,kr=(e,t)=>{let n=e.moves.find(e=>t.moves[e]?.kind===`agent`);return n?t.moves[n]:null},Ar=(e,t)=>!!(t.harness&&kr(e,t)),jr=(e,t)=>!e.when||e.when.is.includes(String(t[e.when.key]??``)),Mr=e=>String(e??``).split(/[\s,]+/).filter(Boolean);function Nr(e,t){return Object.fromEntries(e.filter(e=>jr(e,t)&&t[e.key]!==void 0).map(e=>{let n=t[e.key];return e.kind===`list`?[e.key,(n??[]).map(e=>e.trim()).filter(Boolean)]:e.kind===`ids`||e.kind===`tags`?[e.key,Mr(n)]:[e.key,n]}))}var Pr=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result).replace(/^data:[^,]*,/,``)),r.onerror=()=>n(r.error),r.readAsDataURL(e)}),Fr=(e,t={})=>({...Object.fromEntries(e.flatMap(e=>e.default===void 0?[]:[[e.key,e.default]])),...t});function Ir(e,t){let n=e[t.key];return t.key===`skip_gates`?n===!0?`skip · its own`:n===!1?`wait · its own`:`project`:n==null||n===``||n===0?null:Array.isArray(n)?n.length?n.join(`, `):null:t.kind===`rank`?`#${String(n)}`:String(n)}var Lr=(e,t)=>e.options?.find(e=>e.value===t)?.help??e.help,Rr=(e,t)=>e.length>t?`${e.slice(0,t-1)}…`:e,zr=/^[a-z0-9]+(-[a-z0-9]+)*$/,Br=e=>[...new Set([...Object.keys(sr(e)?.systems??{}),...e.items.flatMap(e=>e.system),...(e.units??[]).map(e=>e.system)])].filter(Boolean).sort();function Vr(e,t){return[{value:``,label:`none`},...e.map(e=>({value:e.name,label:e.goal?`${e.name} · ${Rr(e.goal,48)}`:e.name})),...t&&!e.some(e=>e.name===t)?[{value:t,label:`${t} (not in game.md)`}]:[]]}function Hr(e,t,n){let r=t.of??[`item`];return[{value:``,label:`none`},...[...e.items].filter(e=>!t.of||t.of.includes(e.type)).sort((e,t)=>Number(e.priority===null)-Number(t.priority===null)||(e.priority??0)-(t.priority??0)).map(e=>({value:e.id,label:e.title?`${e.title} (${e.id})`:e.id})),...n&&!e.items.some(e=>e.id===n&&(!t.of||t.of.includes(e.type)))?[{value:n,label:`${n} (not a live ${r.join(` or `)})`}]:[]]}function Ur(e,t,n){if(t===n||!e.includes(t))return null;let r=e.filter(e=>e!==t),i=n===null?r.length:r.indexOf(n);return i<0?null:(r.splice(i,0,t),r.join()===e.join()?null:r)}var Wr=e=>e.running?`running`:e.status;function Gr(e,t,n){let r=Wr(e);if(t===n.runs_from&&r===t)return Tr(n,n.rank)?{act:`rank`}:null;if(t===r)return null;if(t===`running`&&Ar(e,n))return{act:`run`};let i=Er(e,n).find(e=>e.drag===t);return i?{act:`move`,move:i}:null}function Kr(e,t,n,r){if(r)return r;let i=t.filter(e=>e!==n).at(-1);if(!i)return null;let a=e.filter(e=>e!==n);return a[a.indexOf(i)+1]??null}function qr(e,t){let n=e.filter(e=>e!==t),r=e.indexOf(t);return{list:n,self:r<0?n.length:r}}function Jr(e,t,n){let r=Wr(e),i=n.filter(n=>n===r||Gr(e,n,t));return t.sections.graveyard&&Gr(e,`graveyard`,t)?[...i,`graveyard`]:i}var Yr=(e,t)=>({id:e.id,from:Wr(e),target:Wr(e),pos:qr(t,e.id).self});function Xr(e,t,n,r,i){let a=qr(r,e.id);if(t===`ArrowLeft`||t===`ArrowRight`){let r=n.length,o=n[(n.indexOf(e.target)+(t===`ArrowRight`?1:-1)+r)%r];return{...e,target:o,pos:o===i&&e.from===i?a.self:e.pos}}if((t===`ArrowUp`||t===`ArrowDown`)&&e.target===i&&e.from===i){let n=Math.max(0,Math.min(a.list.length,e.pos+(t===`ArrowDown`?1:-1)));return n===e.pos?e:{...e,pos:n}}return e}function Zr(e,t,n,r,i){let a=qr(r,e.id),o=e.target===n.runs_from&&e.from===n.runs_from,s=e.target===e.from&&(!o||e.pos===a.self),c=o?a.list[e.pos]??null:null,l=e.target===`graveyard`?n.sections.graveyard?.label??`Graveyard`:i[e.target]??e.target,u=s?null:Gr(t,e.target,n),d=u?u.act===`rank`?`rank ${e.pos+1}, ${c?`before ${c}`:`last of the ranked`}`:u.act===`run`?`Run: it asks first`:`opens the ${u.move.label} form`:`back where it was`;return{same:s,ranking:o,before:c,where:l,act:d,say:`${e.id} picked up · ${l}: ${d}. Arrows move it, Space drops it, Escape puts it back.`}}var Qr=3e5,$r=e=>e<6e4?`${Math.round(e/1e3)} s`:e<36e5?`${Math.round(e/6e4)} min`:`${Math.round(e/36e5)} h`;function ei({at:e}){let[t,n]=(0,v.useState)(Date.now());(0,v.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),5e3);return()=>clearInterval(e)},[]);let r=Math.max(0,t-Date.parse(e)),i=`Its run log was last written at ${new Date(e).toLocaleTimeString()}`;return r<Qr?(0,I.jsxs)(`span`,{className:`activity`,title:i,children:[(0,I.jsx)(`span`,{className:`dot pulse`,"aria-hidden":`true`}),` active `,$r(r),` ago`]}):(0,I.jsxs)(`span`,{className:`quiet`,title:i,children:[`quiet `,$r(r)]})}var ti=e=>{let t=e.reason??e.error??e.conflict,n=`${typeof e.cost_usd==`number`?` — $${e.cost_usd.toFixed(2)}`:``}${e.handoffs?`, ${e.handoffs} handoff${e.handoffs>1?`s`:``}`:``}${e.process?` — ${e.process}`:``}${e.lessons?`, ${e.lessons} lesson${e.lessons>1?`s`:``}`:``}`;return`${e.id}: ${e.result??`merged`}${t?` — ${t}`:``}${n}`};function ni(e,t,n,r,i=``){let a=[...(n?.orphans??[]).map(e=>`picked up ${ti(e)}`),...n?.gate?[`gate: ${n.gate}`]:[],...(n?.items??[]).map(ti)],o=r.split(`
23
23
  `).filter(Boolean).slice(-3).join(`
24
24
  `),s=!t||(n?.items??[]).some(e=>e.result===`error`||e.result===`conflict`),c=a.length?a.join(`
25
25
  `):o||(t?`ended`:`failed`);return{text:`run ${e.join(`, `)}:\n${c}${i?`\n${i}`:``}`,bad:s}}function ri(e,t){return e.map(e=>{let n=t.find(t=>t.id===e);if(!n?.resumable)return e;let r=n.resume?.ended;return`${e} (${r===`limit`?`paused: limit: resumes its session`:r===`handoff`?`paused: context handoff: a fresh session goes on from the plan`:`interrupted: resumes its kept work`})`}).join(`, `)}var ii=e=>({console:`running — console run`,session:`running — your session`})[e.running_kind??``]??`running`,ai=e=>{let t=new Date(e);return`${[t.getFullYear(),t.getMonth()+1,t.getDate()].map(e=>String(e).padStart(2,`0`)).join(`-`)} ${oi(e)}`},oi=e=>new Date(e).toTimeString().slice(0,5);function si(e,t=new Date){let n=new Date(e);return n.toDateString()===t.toDateString()?oi(e):`${n.toLocaleDateString(void 0,{weekday:`short`,day:`numeric`,month:`short`})} ${oi(e)}`}var ci=e=>e.resume?.ended===`limit`?`The usage limit stopped it past what its run waits for; run it after the reset`:`Its last run stopped; the next run resumes its work`;function li(e){let t={handoff:`context handoff`,limit:`limit`}[e.resume?.ended??``];return t?`paused: ${t}`:`interrupted`}var ui=`The run waits for the usage limit's reset, then goes on by itself; stop the run to end the wait`;function di(e,t=Date.now()){let n=Date.parse(e.resume?.resets??``);if(!e.running||Number.isNaN(n))return null;let r=Math.ceil((n+6e4)/6e4)*6e4;return r>t?new Date(r).toISOString():null}var fi=[/^gcf\/inbox\/in-[0-9a-f]{8}\/attachments\/./,/^gcf\/work\/[a-z0-9]+(-[a-z0-9]+)*\/attachments\/./],pi=e=>fi.some(t=>t.test(e));function mi(e,t,n){if(n===`main`||n===`worktree`)return n;let r=e.items.find(e=>e.id===t)?.run_mode;return r===`main`||r===`worktree`?r:e.run_mode}function hi(e,t){return e.refusal?.code===`clean`?e.refusal.left:/^edits (commit|discard|diff): no change under gcf\//m.test(e.err)&&t.length===1?[]:null}var gi=e=>`propose_${e.replace(/[-:]/g,`_`)}`;function _i(e,t){if(!t)return null;let n=gi(t),r=Object.keys(e).filter(e=>gi(e)===n);return r.find(t=>e[t].propose)??(Object.hasOwn(e,t)?t:r[0])??null}var vi=`default`,yi=e=>/^x[a-z]/.test(e)?`x${e.charAt(1).toUpperCase()}${e.slice(2)}`:e.charAt(0).toUpperCase()+e.slice(1),bi=(e,t)=>e?`Default - project setting (${yi(e)})`:t?`Default (${yi(t)})`:`Default`,xi=(e,t,n)=>t?`Default sets nothing: it runs on the project setting (agent.${e}: ${t})`:n?`Default sets nothing: the default holds (${yi(n)})`:`Default sets nothing: the agent's own ${e} holds`,Si=(e,t)=>(t===`model`||t===`effort`?e.agent?.[t]:null)??null,Ci=(e,t)=>(t===`model`||t===`effort`?e.defaults?.[t]:null)??null,wi=(e,t,n)=>(n&&n!=="default"?n:null)??Si(e,t)??Ci(e,t);function Ti(e,t,n,r){return[...n===null?[]:[{value:r,label:n}],...e.map(e=>({value:e,label:yi(e)})),...t&&t!==r&&!e.includes(t)?[{value:t,label:`${t} (set from the console)`}]:[]]}function Ei({id:e,what:t,presets:n,value:r,onChange:i,compact:a=!1,disabled:o=!1,project:s,fallback:c,auto:l,autoValue:u=vi,from:d,own:f=!1}){let p=r&&r!=="default"?r:u;return(0,I.jsx)(`span`,{className:`a-pick ${a?`compact`:``} ${f?`own`:``}`,children:(0,I.jsx)(`select`,{id:e,className:`input`,"aria-label":a?t:void 0,value:p,disabled:o,title:a?`${t[0].toUpperCase()}${t.slice(1)}: ${d??`what holds`} · the agent's next session takes a change (a resume or a fresh agent)`:l?`Default sets nothing for this run: each item runs on its own ${t}, else the project setting, else the default`:xi(t,s,c),onChange:e=>i(e.target.value),children:Ti(n,p,a?null:l??bi(s,c),u).map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})})}function Di({ctx:e,talk:t}){let n=e.talks.find(e=>e.id===t),r=e.board.presets,[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)({});if((0,v.useEffect)(()=>s({}),[n?.model,n?.effort]),!n||!r||!(r.model.length||r.effort.length))return null;let c=async(n,r)=>{a(!0),s({...o,[n]:r});try{await k.pickTalk(e.project.name,t,{[n]:r}),e.notify(`${n} ${yi(r)}: from the agent's next session`),e.reloadTalks()}catch(t){s({...o,[n]:void 0}),e.notify(t.message,`error`)}finally{a(!1)}},l=e=>{let t=o[e]??n[e];return t&&t!=="default"?t:null},u=l(`model`)||l(`effort`),d=async()=>{a(!0),s({model:vi,effort:vi});try{await k.pickTalk(e.project.name,t,{model:vi,effort:vi}),e.notify(`the thread follows the project's setting: from the agent's next session`),e.reloadTalks()}catch(t){s({}),e.notify(t.message,`error`)}finally{a(!1)}},f=t=>yi(wi(e.board,t)??``)||`the default`;return(0,I.jsxs)(I.Fragment,{children:[[`model`,`effort`].map(t=>(0,I.jsx)(Ei,{what:t,presets:r[t],value:wi(e.board,t,o[t]??n[t]),compact:!0,own:!!l(t),from:l(t)?`this thread's own pick`:Si(e.board,t)?`the project setting (agent.${t})`:`the default`,disabled:i,onChange:e=>void c(t,e)},t)),u&&(0,I.jsxs)(`button`,{type:`button`,className:`a-pick-follow`,"aria-label":`Follow the project setting`,title:`This thread has its own pick (${[l(`model`),l(`effort`)].filter(Boolean).map(e=>yi(e)).join(` · `)}). Take it off: the thread follows the project setting again (${f(`model`)} · ${f(`effort`)}), and a later change in Settings reaches it`,disabled:i,onClick:()=>void d(),children:[(0,I.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M3 12a9 9 0 1 0 3-6.7`}),(0,I.jsx)(`path`,{d:`M3 4v5h5`})]}),`project`]})]})}var Oi=`0.13.0`;function ki(e,t){if(e===void 0)return!1;if(e===null)return!0;let n=e.split(/[.+-]/).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<r.length;e++){let t=n[e]||0;if(t!==r[e])return t>r[e]}return!0}var Ai=(e,t)=>e.extensions?e.extensions[`${t}-aif-ext`]:void 0,ji=e=>Ai(e,e.domain.kind),Mi=e=>e.domain.harness?Ai(e,e.domain.harness):void 0,Ni=e=>ki(ji(e),Oi),Pi=e=>!!e.domain.harness&&ki(Mi(e),`0.13.0`),Fi={main:`in the project folder, one at a time`,worktree:`in its own worktree`},Ii=e=>e&&e!=="default"?e:null,Li=e=>e.answer(null),Ri=1500;function zi(e,t,n){let[r,i]=(0,v.useState)({}),[a,o]=(0,v.useState)(null),s=e?.board.runs,c=!!(s?.paused||s?.active.some(e=>e.mode===`main`)),l=(e&&t?.filter(t=>!(c&&mi(e.board,t,n)===`main`)))?.join(`,`)??``,u=e&&t?.length&&e.board.domain.harness?e.project.name:null,d=(0,v.useRef)(``);return(0,v.useEffect)(()=>{if(!u)return d.current=``,o([]),i({});let e=!0,t=d.current===`${u}/${l}`;d.current=`${u}/${l}`,t||(i({}),o(null));let n=setTimeout(()=>void k.gate(u,l.split(`,`)).then(t=>{if(!e)return;o(t.dirty??[]);let n=new Set(l.split(`,`));i(Object.fromEntries(Object.entries(t.items??{}).flatMap(([e,t])=>t.pass||!n.has(e)?[]:[[e,t.reason]])))}).catch(()=>{e&&(i({}),o([]))}),t?Ri:0);return()=>{e=!1,clearTimeout(n)}},[u,l,e?.board]),{refused:r,dirty:a}}function Bi(e){return`The project folder holds uncommitted changes outside gcf/: ${e.slice(0,5).join(`, `)}${e.length>5?` and ${e.length-5} more`:``}. A main run's code lands among them, and its build and commits meet them: commit them or set them aside first.`}var Vi=e=>[`Commit the loose work in the project folder: a main run is about to start among it.`,`The uncommitted changes outside gcf/: ${e.join(`, `)}.`,`Read the diff of each first. Commit what belongs to the project, with a message that says what it is.`,`A file that looks like it should not go into git (editor noise, a secret, a stray build file): leave it, and tell me which and why.`].join(`
26
- `);function Hi(){return(0,I.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M4 4.5h16v11.5H10.5L6 19.5V16H4z`}),(0,I.jsx)(`path`,{d:`M8.8 10.4l2.1 2.1 4.2-4.2`})]})}function Ui(e,t){return!e.board.domain.chat||!t.length?null:{label:`Commit with agent`,agent:(0,I.jsx)(Hi,{}),title:`A project chat thread: its agent reads the diff and commits these files; nothing runs`,go:()=>void(async()=>{let n=null;try{n=(await k.newTalk(e.project.name)).id,await k.sendTalk(e.project.name,n,{type:`say`,text:Vi(t)})}catch(t){e.notify(t.message,`error`)}n&&(e.reloadTalks(),e.go(`chat`,n))})()}}var Wi=(e,t,n=!1)=>new Promise(r=>Li({ctx:e,ids:t,gate:n,answer:r}));async function Gi(e,t,n=!1){let r=await Wi(e,t,n);return r&&await e.run(r.ids,!1,r.agent),!!r}function Ki(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)({}),i=(0,v.useId)(),{refused:a,dirty:o}=zi(e?.ctx??null,e?.ids??null,n.mode);if((0,v.useEffect)(()=>{Li=e=>{r({}),t(t=>(t?.answer(null),e))}},[]),!e)return null;let{ctx:s,ids:c,gate:l}=e,{board:u}=s,d=c.filter(e=>!a[e]),f=r=>{t(null);let i={model:Ii(n.model),effort:Ii(n.effort),mode:n.mode};e.answer(r?{ids:d,agent:i}:null)},p=u.presets,m=Pi(u)&&p&&(p.model.length||p.effort.length),h=e=>{let t=[e?.model,e?.effort,e?.run_mode].filter(Boolean);return t.length?`its own: ${t.join(` · `)}`:``},g=[Ii(n.model),Ii(n.effort),n.mode].filter(Boolean).join(` · `),_=[...new Set(d.map(e=>mi(u,e,n.mode)))],y=_.length>1?`each where it runs (${_.map(e=>`${e}: ${Fi[e]}`).join(`; `)}), two runs at once`:Fi[_[0]??mi(u,c[0],n.mode)],b=e=>d.filter(t=>mi(u,t,n.mode)===e),x=b(`main`).filter(e=>u.items.find(t=>t.id===e)?.type===`spike`),S=[x.length?`${x.join(`, `)}: a spike on main leaves its code in main; in a worktree only its plan comes back, its code kept as a spike/<id> tag`:``,b(`worktree`).length&&u.runs?.active.some(e=>e.mode===`main`)?`a main run works in the project folder now: a worktree branch merges when that run ends`:``,b(`main`).length&&u.runs?.active.some(e=>e.mode===`main`)?`a main run works in the project folder now: this one waits in the queue`:``].filter(Boolean),C=b(`main`).length>0&&!!o?.length,w=C&&o?Ui(s,o):null;return(0,I.jsx)(R,{onClose:()=>f(!1),dirty:!1,children:(0,I.jsxs)(`div`,{className:`dialog`,role:`dialog`,"aria-modal":!0,"aria-label":`Run ${c.join(`, `)}?`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`h2`,{children:[`Run `,c.join(`, `),`?`]}),(0,I.jsxs)(`p`,{className:`dialog-body`,children:[l?`The run gate picked these. `:``,`One agent session each, `,y,`.`,m?` A model or effort picked here holds for this run only; each item keeps its own.`:u.domain.harness&&!Pi(u)?` This harness is older than run picks: each item runs on its own model.`:``]}),(0,I.jsx)(`ul`,{className:`run-list`,children:c.map(e=>{let t=h(u.items.find(t=>t.id===e));return(0,I.jsxs)(`li`,{className:a[e]?`refused`:void 0,children:[(0,I.jsx)(`span`,{className:`mono`,children:ri([e],u.items)}),a[e]?(0,I.jsxs)(`span`,{className:`small`,children:[`✕ the run gate refuses it now: `,a[e]]}):t&&(0,I.jsx)(`span`,{className:`dim small`,children:t})]},e)})}),m&&[`model`,`effort`].map(e=>(0,I.jsxs)(`div`,{className:`f-field`,children:[(0,I.jsx)(`span`,{className:`f-label`,children:(0,I.jsxs)(`label`,{htmlFor:`${i}-${e}`,children:[e===`model`?`Model`:`Effort`,` for this run`]})}),(0,I.jsx)(Ei,{id:`${i}-${e}`,what:e,presets:p[e],value:n[e],auto:`Default - each item's own`,onChange:t=>r({...n,[e]:t})})]},e)),(0,I.jsxs)(`div`,{className:`f-field`,children:[(0,I.jsx)(`span`,{className:`f-label`,children:(0,I.jsx)(`label`,{htmlFor:`${i}-mode`,children:`Where this run goes`})}),(0,I.jsxs)(`select`,{id:`${i}-mode`,className:`input`,value:n.mode??``,onChange:e=>r({...n,mode:e.target.value===``?void 0:e.target.value}),children:[(0,I.jsxs)(`option`,{value:``,children:[`default: each item's own, else the project's (`,u.run_mode,`)`]}),(0,I.jsxs)(`option`,{value:`main`,children:[`main · `,Fi.main]}),(0,I.jsxs)(`option`,{value:`worktree`,children:[`worktree · `,Fi.worktree]})]}),S.map(e=>(0,I.jsx)(`span`,{className:`f-help`,children:e},e)),C&&o&&(0,I.jsx)(ae,{head:`Loose work in the project folder`,text:`${Bi(o)} Or pick worktree above.`})]}),(0,I.jsxs)(`div`,{className:`dialog-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`btn-line`,onClick:()=>f(!1),children:`Cancel`}),w&&(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-agent`,title:w.title,onClick:()=>{f(!1),w.go()},children:[(0,I.jsx)(Hi,{}),w.label]}),(0,I.jsx)(`button`,{type:`button`,className:`btn-primary`,autoFocus:!0,disabled:!d.length||b(`main`).length>0&&o===null,title:d.length?b(`main`).length>0&&o===null?`Asking the run gate first`:void 0:`The run gate refuses every one of them now`,onClick:()=>f(!0),children:d.length<c.length&&d.length?`Run ${d.join(`, `)}${g?` on ${g}`:``}`:g?`Run on ${g}`:`Run`})]})]})})}function qi(e){let[t,n]=(0,v.useState)(3),[r,i]=(0,v.useState)(!1);return{count:t,setCount:n,busy:r,go:async()=>{i(!0);try{let n=await k.next(e.project.name,t);n.length?(i(!1),await Gi(e,n,!0)):e.notify(`nothing can run now: dependencies, WIP or a run in progress`,`error`)}catch(t){e.notify(t.message,`error`)}i(!1)}}}function Ji({ctx:e}){let{count:t,setCount:n,busy:r,go:i}=qi(e);return(0,I.jsxs)(`div`,{className:`run-next`,title:`The framework's run gate picks them`,children:[(0,I.jsx)(`button`,{disabled:r,onClick:()=>void i(),children:r?`asking the run gate…`:`Run next`}),(0,I.jsx)(`input`,{type:`number`,min:1,max:20,value:t,onChange:e=>n(Math.max(1,Math.min(20,Number(e.target.value)||1))),"aria-label":`How many, 1 to 20`})]})}async function Yi(e,t){await ie(di(t)?`Stop the run of ${t.id}? It ends the wait for the reset: ${t.id} becomes paused: limit, Run resumes it later, and the queue goes on.`:`Stop the run of ${t.id}? It stays ready with its work kept; Run resumes it.`,`Stop`,!0)&&await e.stop(t.id)}function Xi(e){let t=e.domain.sections?.inbox,n=new Set((t?.groups??[]).filter(e=>e.counts).map(e=>e.id)),r=new Set((t?.categories??[]).filter(e=>n.has(e.group)).map(e=>e.id));return{entries:(e.inbox??[]).filter(e=>r.has(e.category)&&!e.later),repeats:n.size?e.inbox_repeats??[]:[]}}function Zi(e){let{entries:t,repeats:n}=Xi(e),r=(e.questions??[]).filter(e=>Qi(e)&&!e.answer);return t.length+n.length+r.length}var Qi=e=>e.category?e.category===`decision`:/^D1\b/.test(e.class??``);function $i(e,t){return e.domain.columns.some(e=>e.human&&e.status===t)}function G(e,t){return e.running?!1:$i(t,e.status)?!0:e.resumable&&e.resume?.ended===`limit`}function ea(e,t=[]){let n=(e.runs?.reports??[]).filter(e=>ni(e.ids,e.ok,e.result,e.err,e.note).bad),r=Xi(e),i=e.items.filter(t=>G(t,e)).sort((e,t)=>(e.priority??1/0)-(t.priority??1/0));return[...n.map(e=>({kind:`report`,report:e})),...e.runs?.paused?[{kind:`queue`}]:[],...e.runs?.autopilot?.stop&&e.runs.autopilot.stop.kind!==`idle`?[{kind:`pilot`,stop:e.runs.autopilot.stop}]:[],...t.flatMap(e=>e.card&&!e.limit_until?[{kind:`chat`,card:e.card,talk:e}]:[]),...e.items.flatMap(e=>e.running&&e.chat_card?[{kind:`chat`,card:e.chat_card,item:e.id}]:[]),...(e.questions??[]).filter(e=>Qi(e)&&!e.answer).map(e=>({kind:`question`,question:e})),...r.entries.map(e=>({kind:`entry`,entry:e})),...r.repeats.map(e=>({kind:`repeat`,repeat:e})),...i.map(e=>({kind:`item`,item:e}))]}var ta=e=>[e.blocked_by.length?`blocked by ${e.blocked_by.join(`, `)}`:``,e.tbd?`TBD ${e.tbd}`:``].filter(Boolean).join(` · `)||(e.ready?`ready`:`not ready`);function na(e,t){return t.running?`running`:e.domain.columns.find(e=>e.status===t.status)?.label??t.status}function ra(e,t,n=[]){let r=e.items.find(e=>e.id===t);if(r){let i=na(e,r),a=n.includes(t)?`the run gate waits for it`:`it lets a run start`;return{id:t,kind:`item`,state:`${i}${r.verified?` · verified`:``}`,tone:r.running?`running`:r.status,tip:`${r.title??t} · ${i} · ${a}`}}let i=e.units?.find(e=>e.id===t);if(i)return{id:t,kind:`unit`,state:ta(i),tone:i.ready?`ok`:`warn`,tip:`design unit, not taken into work · ${i.title??t} · ${i.file}`};let a=e.graveyard?.find(e=>e.id===t);if(a)return{id:t,kind:`grave`,state:`graveyard: it never will be done`,tone:`error`,tip:a.reason??`in the graveyard`};let o=e.history?.find(e=>e.id===t);return o?{id:t,kind:`history`,state:`ended${o.event?`: ${o.event}`:``}`,tone:`ok`,tip:`in history${o.date?` since ${o.date}`:``}`}:{id:t,kind:`unknown`,state:`unknown: no item, unit or graveyard line`,tone:`warn`,tip:`The framework knows no ${t}`}}var ia=e=>e.needs??[],aa=e=>e.needed_by??[];function oa(e,t,n){let r=n&&n!==t.id?e.items.find(e=>e.id===n):void 0;if(!r)return{label:``,dim:!1,self:n===t.id};let i=ia(r).includes(t.id)?`needed by ${r.id}`:ia(t).includes(r.id)?`needs ${r.id}`:``;return{label:i,dim:!i,self:!1}}var sa=(e,t)=>aa(t).length>0||ia(t).some(t=>e.items.some(e=>e.id===t));function ca(e,t){let n=e[t];return n==null||n===``?[]:Array.isArray(n)?n.map(String):[String(n)]}var la=(e,t,n)=>t.every(t=>{let r=n[t.key];return!r?.length||ca(e,t.key).some(e=>r.includes(e))});function ua(e,t){let n=t.trim().toLowerCase();return!n||e.id.includes(n)||(e.title??``).toLowerCase().includes(n)}var da=(e,t)=>e.options?.find(e=>e.value===t)?.label??t;function fa(e,t,n){let r=new Map;for(let n of e)for(let e of ca(n,t.key))r.set(e,(r.get(e)??0)+1);return[...r.keys()].sort().map(e=>({value:e,label:da(t,e),count:r.get(e)??0,on:(n[t.key]??[]).includes(e)}))}function pa(e,t,n){let r=e[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n],{[t]:a,...o}=e;return i.length?{...o,[t]:i}:o}function ma(e,t,n){let r=new Map;for(let e of t){let t=ca(e,n.key);for(let n of t.length?t:[``])r.set(n,[...r.get(n)??[],e])}return[...r.keys()].sort((e,t)=>Number(e===``)-Number(t===``)||e.localeCompare(t)).map(t=>{let i=n.kind===`ids`&&t?e.items.find(e=>e.id===t):void 0,a=i?.title;return{value:t,label:t?a||t:`none`,sub:a?t:``,item:i?i.id:null,items:r.get(t)??[]}})}var ha=window.matchMedia(`(width <= 700px)`),ga={status:`running`,label:`running`,help:`An agent session works on it`},_a=new Set([`priority`,`type`,`gate`,`severity`,`tune_count`,`waits_for`,`blocked`,`needs`,`needed_by`]);function va(e,t){return e.starting?{label:`starting…`,tone:`running`,tip:`The run starts: its agent session opens in a few seconds`}:e.running_kind===`console`?{label:`running — console run`,tone:`running`,tip:`Started from a console (gcf-harness run)`}:e.running_kind===`session`?{label:`running — your session`,tone:`running`,tip:`Your own agent session works on it; release the mark when you are done`}:e.resumable&&!e.running?{label:li(e),tone:`neutral`,tip:ci(e)}:t?{label:`queued`,tone:`queued`,tip:`Waits for the main run going on; starts after it`}:null}var ya=new Set([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,` `,`Enter`,`Escape`,`Tab`]),ba=({text:e,compact:t})=>(0,I.jsx)(`div`,{className:`k-ghost ${t?`compact`:``}`,"aria-hidden":`true`,children:e});function xa({item:e,ctx:t,compact:n,selected:r,onSelect:i,hover:a,lane:o,kb:s}){let{board:c}=t,{domain:l}=c,u=o===void 0?e.id:`${e.id}@${o}`,{attributes:d,listeners:f,setNodeRef:p,isDragging:m}=Wn({id:u,data:{id:e.id}}),h=Jn({id:`before:${u}`,data:{id:e.id},disabled:Wr(e)!==l.runs_from||!l.rank}),g=e=>{p(e),h.setNodeRef(e)},_=c.runs?.queued.includes(e.id)??!1,v=di(e),y=new Map;for(let t of l.fields){let n=t.card?Ir(e,t):null;n!==null&&y.set(t.key,{f:t,v:n})}let b=y.get(`priority`)??[...y.values()].find(e=>e.f.kind===`rank`),x=y.get(`type`),S=y.get(`gate`),C=y.get(`severity`),w=y.get(`waits_for`),T=y.get(`blocked`),E=y.get(`tune_count`),D=[...y.values()].filter(({f:e})=>!_a.has(e.key)&&e.kind!==`rank`),O=va(e,_),k=G(e,c),A=e.plan,ee=Ar(e,l)&&!_&&!e.running,j=()=>t.openItem(e.id),M=l.sections.lessons?e.lessons??0:0,te=y.has(`needs`)?ia(e):[],N=y.has(`needed_by`)?aa(e):[],ne=`Not ended in history: ${te.map(e=>`${e} (${ra(c,e).state})`).join(`, `)}`,P=`They depend on it: ${N.join(`, `)}`,F=oa(c,e,a.id),re=sa(c,e),L={onMouseEnter:()=>re&&a.set(e.id),onMouseLeave:()=>a.id===e.id&&a.set(null),onFocus:t=>{re&&t.target.matches(`:focus-visible`)&&a.set(e.id)},onBlur:t=>{a.id===e.id&&a.set(null),R&&!t.currentTarget.contains(t.relatedTarget)&&s.key(`Tab`)}},R=s.grab?.id===e.id&&s.grab.lane===o,z=!e.running&&!ha.matches,ie=e=>e.target===e.currentTarget||e.target.matches(`.c-open`),B=t=>R?ya.has(t.key)?(t.preventDefault(),t.stopPropagation(),s.key(t.key),!0):!1:t.key!==` `||!z||s.grab||!ie(t)?!1:(t.preventDefault(),t.stopPropagation(),s.pick(e,o),!0),ae=e=>{e.key===` `&&z&&ie(e)&&e.preventDefault()},oe=t=>(0,I.jsxs)(I.Fragment,{children:[s.ghost===e.id&&s.grab?.lane===o&&(0,I.jsx)(ba,{text:s.ghostText,compact:n}),t,R&&(0,I.jsxs)(`div`,{className:`k-note`,role:`note`,children:[(0,I.jsx)(`span`,{className:`k-hint`,children:s.hint}),(0,I.jsx)(`div`,{className:`k-keys`,children:s.keys.map(([e,t])=>(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`kbd`,{children:e}),t]},e))})]})]}),se=z?` · Space picks it up to move it with the keys`:``,ce=[...y.values()].filter(({f:e})=>e.badge).map(({f:e,v:t})=>`${e.key}-${t}`),V=[`card`,n?`compact`:``,...ce,m?`dragging`:``,r?`selected`:``,h.isOver&&!m?`drop-before`:``,F.label||F.self?`lit`:``,F.dim?`dim`:``,R?`lifted`:``].join(` `);if(n)return oe((0,I.jsxs)(`div`,{ref:g,...d,...f,...L,"aria-roledescription":`movable card`,"aria-pressed":R,className:V,"data-card":e.id,title:`${e.id}${e.title?` — ${e.title}`:``}${se}`,onClick:()=>!s.grab&&j(),onKeyUp:ae,onKeyDown:e=>{B(e)||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),j())},children:[(0,I.jsx)(`span`,{className:`c-rank`,children:b?.v??``}),(0,I.jsx)(`span`,{className:`c-id`,children:e.id}),F.label&&(0,I.jsx)(`span`,{className:`c-rel`,children:F.label}),te.length>0&&(0,I.jsxs)(`span`,{className:`c-note mono`,title:ne,children:[`◂`,te.length]}),k?(0,I.jsx)(`span`,{className:`c-needs`,title:`Only you can move it on`,children:`●`}):O?(0,I.jsx)(`span`,{className:`c-mark tone-${O.tone}`,title:O.tip,children:O.label}):null]}));let{role:H,tabIndex:U,"aria-pressed":le,"aria-roledescription":ue,...de}=d;return oe((0,I.jsxs)(`div`,{ref:g,className:V,"data-card":e.id,title:S?Lr(S.f,S.v):void 0,...de,...f,...L,onClick:e=>{!s.grab&&!e.target.closest(`button`)&&j()},onKeyDown:B,onKeyUp:ae,children:[e.running&&e.running_kind!==`session`&&(0,I.jsx)(`span`,{className:`c-flow`,"aria-hidden":`true`}),F.label&&(0,I.jsx)(`span`,{className:`c-rel`,children:F.label}),(0,I.jsxs)(`div`,{className:`c-top`,children:[ee&&(0,I.jsx)(`button`,{role:`checkbox`,"aria-checked":r,"aria-label":`Select ${e.id} for a run`,className:`c-box`,onClick:()=>i(!r),children:r?`☑`:`☐`}),(0,I.jsxs)(`button`,{className:`c-open`,onClick:()=>!s.grab&&j(),"aria-roledescription":z?`movable card`:void 0,"aria-pressed":z?R:void 0,title:se?`Open it${se}`:void 0,"aria-label":`Open ${e.id}${e.title?`: ${e.title}`:``}`,children:[x&&(0,I.jsx)(`span`,{className:`c-type`,title:Lr(x.f,x.v)??x.v,children:x.v.slice(0,3).toUpperCase()}),k&&(0,I.jsx)(`span`,{className:`c-needs`,title:`Only you can move it on`,"aria-label":`needs you`,children:`●`}),(0,I.jsx)(`span`,{className:`c-id`,children:e.id})]}),T&&(0,I.jsx)(`span`,{className:`c-blocked`,role:`img`,tabIndex:0,title:`Blocked: ${T.v} · open the card to read it in Status`,"aria-label":`blocked: ${T.v}`,children:`!`}),b&&(0,I.jsx)(`span`,{className:`c-rank`,title:`Priority rank: lower runs sooner. Drag the card to change it.`,children:b.v})]}),e.title&&(0,I.jsx)(`div`,{className:`c-title`,children:e.title}),(O||e.verified||C)&&(0,I.jsxs)(`div`,{className:`c-marks`,children:[O&&(0,I.jsx)(`span`,{className:`badge tone-${O.tone}`,title:O.tip,children:O.label}),e.verified&&(0,I.jsx)(`span`,{className:`badge tone-ok`,title:`Passed build, tests and review; merges into main at the start of the next run`,children:`✔ verified`}),C&&(0,I.jsxs)(`span`,{className:`c-sev sev-${C.v}`,title:`severity: ${C.v}`,children:[`▲ `,C.v]})]}),v&&(0,I.jsxs)(`div`,{className:`c-limit`,children:[(0,I.jsxs)(`span`,{title:`The run waits for the usage limit's reset, then goes on by itself; stop the run to end the wait`,children:[`◷ limit: resumes `,oi(v)]}),(0,I.jsx)(`button`,{className:`btn-danger`,title:`Ends the wait: the item becomes paused: limit; Run resumes it later`,onClick:()=>void Yi(t,e),children:`Stop`})]}),e.running&&e.running_kind!==`session`&&e.active_at&&!v&&(0,I.jsx)(ei,{at:e.active_at}),w&&(0,I.jsxs)(`div`,{className:`c-waits`,title:w.f.help??`The run gate would refuse it now`,children:[`⧗ waits for `,w.v]}),(typeof e.skip_gates==`boolean`||e.gate_why)&&(0,I.jsxs)(`div`,{className:`c-gates`,children:[typeof e.skip_gates==`boolean`&&(0,I.jsxs)(`span`,{title:e.skip_gates?`Its own gates: each on its second value (milestone go, verdict defer, decision agent, question assume)`:`Its own gates: every one waits for you`,children:[(0,I.jsx)(`span`,{className:`dim`,"aria-hidden":`true`,children:`⇥`}),` `,e.skip_gates?`gates: skip`:`gates: wait`]}),e.gate_why&&(0,I.jsxs)(`span`,{className:`c-gate-why`,title:`Its own verdict stop: ${e.gate_why}`,children:[`verdict: `,e.gate_why]})]}),(0,I.jsxs)(`div`,{className:`c-foot`,children:[A&&(`error`in A?(0,I.jsx)(`span`,{className:`c-plan bad`,title:A.error,children:`plan ✘`}):(0,I.jsxs)(`span`,{className:`c-plan`,title:`Plan checkboxes done / total`,children:[(0,I.jsx)(`span`,{className:`bar`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{style:{width:`${Math.round(100*A.done/Math.max(1,A.tasks))}%`}})}),A.done,`/`,A.tasks]})),E&&(0,I.jsxs)(`span`,{className:`c-note`,title:E.f.help,children:[`· tuned `,E.v,`×`]}),M>0&&(0,I.jsxs)(`span`,{className:`c-note`,title:`What got in its agents' way: lessons in the inbox`,children:[`· `,M,` lesson`,M>1?`s`:``]}),D.map(({f:e,v:t})=>(0,I.jsxs)(`span`,{className:`c-note`,title:Lr(e,t),children:[`· `,e.label,` `,t]},e.key)),te.length>0&&(0,I.jsxs)(`span`,{className:`c-dep`,title:ne,children:[y.get(`needs`)?.f.label??`needs`,` `,te.length]}),N.length>0&&(0,I.jsxs)(`span`,{className:`c-dep`,title:P,children:[y.get(`needed_by`)?.f.label??`needed by`,` `,N.length]})]})]}))}function Sa({status:e,label:t,help:n,count:r,shown:i,wip:a,take:o,end:s,children:c}){let{setNodeRef:l,isOver:u}=Jn({id:e,data:{status:e}});return(0,I.jsxs)(`section`,{ref:l,id:`col-${e}`,className:`column col-${e} ${u?`over`:``} ${o}`,"aria-label":`${t} column`,children:[(0,I.jsxs)(`div`,{className:`col-head`,title:n,tabIndex:0,children:[(0,I.jsx)(`span`,{className:`col-dot`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`col-label`,children:t}),(0,I.jsx)(`span`,{className:`col-count`,children:i===r?r:`${i} of ${r}`}),a]}),(0,I.jsxs)(`div`,{className:`col-body`,children:[r===0?(0,I.jsx)(`div`,{className:`col-empty`,children:e===`running`?`nothing runs`:`empty`}):i===0?(0,I.jsx)(`div`,{className:`col-empty`,children:`none match the filter`}):c,s]})]})}function Ca({status:e,lane:t,label:n,take:r,children:i}){let{setNodeRef:a,isOver:o}=Jn({id:`${e}@${t}`,data:{status:e}});return(0,I.jsx)(`div`,{ref:a,className:`lane-cell ${o?`over`:``} ${r}`,"aria-label":n,children:i})}function wa({label:e,hot:t}){let{setNodeRef:n,isOver:r}=Jn({id:`graveyard`,data:{status:`graveyard`}});return(0,I.jsxs)(`div`,{ref:n,className:`grave ${r?`over`:``} ${t?`k-target`:``}`,"aria-label":`Graveyard drop zone`,children:[(0,I.jsxs)(`span`,{children:[`✝ `,e]}),(0,I.jsx)(`small`,{children:`Drop here: opens the drop form. Nothing ends until you confirm it.`})]})}var Ta=`[data-card], button, input, select, textarea, a, label, [role="button"]`;function Ea(){let e=(0,v.useRef)(void 0);return(0,v.useCallback)(t=>{e.current?.(),e.current=t?Da(t):void 0},[])}function Da(e){let t=null,n=!1,r=r=>{r.pointerType===`mouse`&&r.button===0&&(r.target.closest(Ta)||(t={x:r.clientX,left:e.scrollLeft,id:r.pointerId},n=!1))},i=r=>{if(!t)return;let i=r.clientX-t.x;if(!(!n&&Math.abs(i)<4)){if(!n){n=!0;try{e.setPointerCapture(t.id)}catch{}e.classList.add(`panning`)}e.scrollLeft=t.left-i}},a=()=>{t=null,e.classList.remove(`panning`)},o=e=>{n&&(n=!1,e.stopPropagation(),e.preventDefault())},s=t=>{if(t.shiftKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||e.scrollHeight>e.clientHeight+2)return;let n=t.target.closest(`.col-body`);n&&n.scrollHeight>n.clientHeight||e.scrollWidth<=e.clientWidth||(e.scrollLeft+=t.deltaY,t.preventDefault())};return e.addEventListener(`pointerdown`,r),e.addEventListener(`pointermove`,i),e.addEventListener(`pointerup`,a),e.addEventListener(`pointercancel`,a),e.addEventListener(`click`,o,!0),e.addEventListener(`wheel`,s,{passive:!1}),()=>{e.removeEventListener(`pointerdown`,r),e.removeEventListener(`pointermove`,i),e.removeEventListener(`pointerup`,a),e.removeEventListener(`pointercancel`,a),e.removeEventListener(`click`,o,!0),e.removeEventListener(`wheel`,s)}}var Oa=e=>e.ctrlKey||e.metaKey||e.altKey||e.defaultPrevented||!!document.querySelector(`.modal`)||!!e.target?.closest?.(`input, textarea, select, [contenteditable]`);function ka(){let e=[...document.querySelectorAll(`.board [data-card]`)];return{all:e,at:e.findIndex(e=>e.contains(document.activeElement))}}var Aa=e=>{e&&((e.querySelector(`.c-open`)??e).focus(),e.scrollIntoView({block:`nearest`,inline:`nearest`}))};function ja({ctx:e}){let[t,n]=(0,v.useState)(new Set),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)({}),[s,c]=(0,v.useState)(`none`),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),S=(0,v.useRef)(null),C=Ea(),w=Ge(We(Ht,{activationConstraint:{distance:8}}),We(qt,{activationConstraint:{delay:300,tolerance:8}})),{board:T}=e,E=T.items,{domain:D}=T,O=D.runs_from,k=D.columns.flatMap(e=>e.status===O?[e,ga]:[e]),A=T.runs?.queued??[],ee=[...t].filter(e=>!A.includes(e)&&E.some(t=>t.id===e&&Ar(t,D)&&!t.running)),j=E.filter(e=>Wr(e)===O).map(e=>e.id),M=D.fields.filter(e=>e.filter),te=D.fields.filter(e=>e.group),N=te.find(e=>e.key===s),ne=Object.values(a).reduce((e,t)=>e+t.length,0),P=e=>ua(e,r)&&la(e,M,a)&&(!d||G(e,T)),F=!!(r.trim()||ne||d),re=E.filter(e=>G(e,T)).length,L=D.sections.playtest?.waits[0],R={id:_||b?null:h,set:g};(0,v.useEffect)(()=>{h&&!E.some(e=>e.id===h)&&g(null)},[h,E]);let z=b?E.find(e=>e.id===b.id):void 0,ie=N?ma(T,E,N).map(e=>({...e,shown:e.items.filter(P)})).filter(e=>!F||e.shown.length):[],B=(e,t)=>{let n=N?ie.find(e=>e.value===t)?.items??[]:E,r=new Set(n.filter(t=>t.id===e||P(t)).map(e=>e.id));return j.filter(e=>r.has(e))},ae=b?B(b.id,b.lane):[],oe=z&&(N?ie.some(e=>e.value===b?.lane&&e.items.some(e=>e.id===z.id)):b?.lane===void 0);(0,v.useEffect)(()=>{b&&!oe&&x(null)},[b,oe]);let se=Object.fromEntries(k.map(e=>[e.status,e.label])),ce=z?Jr(z,D,k.map(e=>e.status)):[],V=b&&z?Zr(b,z,D,ae,se):null;(0,v.useEffect)(()=>{b&&(document.getElementById(`col-${b.target}`)?.scrollIntoView({block:`nearest`,inline:`nearest`}),document.querySelector(`.board .k-ghost`)?.scrollIntoView({block:`nearest`}))},[b]),(0,v.useEffect)(()=>{let e=()=>{S.current=null};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[]),(0,v.useEffect)(()=>{let e=S.current;if(!e)return;let t=document.querySelector(`.board [data-card="${CSS.escape(e.id)}"]`),n=document.activeElement;Date.now()>e.until||n&&n!==document.body&&!t?.contains(n)?S.current=null:t&&!t.contains(n)&&Aa(t)}),(0,v.useEffect)(()=>{let t=t=>{if(Oa(t))return;let{all:n,at:r}=ka();if(t.key===`j`||t.key===`k`)t.preventDefault(),Aa(n[r<0?0:Math.max(0,Math.min(n.length-1,r+(t.key===`j`?1:-1)))]);else if(/^[1-9]$/.test(t.key)){let e=document.querySelectorAll(`.board .column, .board .lane-head-col`)[Number(t.key)-1];if(!e)return;t.preventDefault(),e.scrollIntoView({inline:`start`,block:`nearest`,behavior:`smooth`});let n=e.querySelector(`[data-card]`);n?Aa(n):e.querySelector(`.col-head`)?.focus()}else if(t.key===`r`&&r>=0){let i=E.find(e=>e.id===n[r].dataset.card);if(!i||!Ar(i,D)||i.running||A.includes(i.id))return;t.preventDefault(),Gi(e,[i.id])}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)});let H=Tr(D,D.rank),U=(t,n)=>{let r=Ur(j,t,n);r&&H&&e.move({cmd:H.cmd,ids:r})},le=e=>{y(null);let t=e.active.data.current?.id??String(e.active.id),n=E.find(e=>e.id===t),r=e.over;if(!n||!r)return;if(String(r.id).startsWith(`before:`)){let e=r.data.current?.id;if(Wr(n)===O)return U(n.id,e)}let i=String(r.id).startsWith(`before:`)?O:r.data.current?.status??String(r.id);ue(n,i,N?String(r.id).split(`@`)[1]:void 0)},ue=(t,n,r)=>{let i=Gr(t,n,D);if(i?.act===`rank`)return U(t.id,Kr(j,B(t.id,r),t.id,null));if(i?.act===`run`)return void Gi(e,[t.id]);i?e.openMove({title:`${i.move.label} ${t.id}`,id:t.id,move:i.move}):n!==Wr(t)&&e.notify(`no move takes ${t.id} to ${n}: open it for its moves`,`error`)},de={grab:b,ghost:V&&!V.same?V.before:null,ghostText:V?`drops here · ${V.act}`:``,hint:V?`→ ${V.where} · ${V.act}`:``,keys:[[`← →`,`column`],...b?.from===O&&H?[[`↑ ↓`,`rank`]]:[],[`Space`,`drop`],[`Esc`,`put back`]],pick:(e,t)=>{g(null),x({...Yr(e,B(e.id,t)),...N&&{lane:t}})},key:t=>{if(!b||!z||!V)return x(null);if(t===`Escape`||t===`Tab`)return x(null),e.notify(`${b.id}: put back, nothing moved`);if(t!==`ArrowUp`&&t!==`ArrowDown`||H){if(t!==` `&&t!==`Enter`)return x(Xr(b,t,ce,ae,O));if(x(null),S.current={id:b.id,until:Date.now()+1e4},!V.same){if(V.ranking)return U(b.id,Kr(j,ae,b.id,V.before));ue(z,b.target)}}}},fe=V?.ranking&&!V.same&&!V.before&&(0,I.jsx)(ba,{text:de.ghostText,compact:l}),pe=e=>{let t=me??z;return t?b?.target===e?`k-target`:b&&e===b.from||Gr(t,e,D)?`takes`:`no-drop`:``},W=async()=>{await Gi(e,ee)&&n(new Set)},me=_?E.find(e=>e.id===_):void 0,he=(r,i)=>(0,I.jsx)(xa,{item:r,ctx:e,compact:l,hover:R,lane:i,kb:de,selected:t.has(r.id),onSelect:e=>n(t=>{let n=new Set(t);return e?n.add(r.id):n.delete(r.id),n})},r.id),ge=e=>e===L&&D.sections.wip&&T.wip&&(0,I.jsxs)(`span`,{className:`col-wip ${T.wip.over?`over`:``}`,title:D.sections.wip.help,children:[`WIP `,T.wip.count,`/`,T.wip.limit,T.wip.over?` · over`:``]});return(0,I.jsxs)(Bn,{sensors:w,onDragStart:e=>{g(null),x(null),y(e.active.data.current?.id??String(e.active.id))},onDragCancel:()=>y(null),onDragEnd:le,children:[(0,I.jsxs)(`section`,{className:`board`,"aria-label":`Board`,children:[(0,I.jsxs)(`div`,{className:`board-tools ${e.boardTools?``:`shut`}`,children:[(0,I.jsxs)(`div`,{className:`board-row`,children:[(0,I.jsx)(`input`,{className:`input board-search`,type:`search`,"data-search":!0,"aria-label":`Search items by id and title`,value:r,onChange:e=>i(e.target.value),placeholder:`search id or title`}),(0,I.jsxs)(`button`,{className:`pill pill-needs ${d?`on`:``}`,"aria-pressed":d,onClick:()=>f(!d),children:[d?`✓ `:``,`waiting for me · `,re]}),M.length>0&&(0,I.jsxs)(`button`,{className:`btn-line board-filter ${ne?`on`:``}`,"aria-expanded":p,title:`Filter by the fields the domain marks: several at once`,onClick:()=>m(!p),children:[`Filter`,ne?` · ${ne}`:``,` `,p?`▴`:`▾`]}),te.length>0&&(0,I.jsxs)(`label`,{className:`board-group`,children:[`Group by`,(0,I.jsxs)(`select`,{className:`input`,"aria-label":`Group the board in lanes by`,value:N?N.key:`none`,onChange:e=>c(e.target.value),children:[(0,I.jsx)(`option`,{value:`none`,children:`none`}),te.map(e=>(0,I.jsx)(`option`,{value:e.key,children:e.label},e.key))]})]}),(0,I.jsxs)(`button`,{className:`btn-line board-density`,title:`Card density`,onClick:()=>u(!l),children:[`▤ `,l?`compact`:`comfortable`]}),D.harness&&(0,I.jsxs)(`div`,{className:`board-run`,children:[ee.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{className:`btn-accent`,onClick:()=>void W(),children:[`▶ Run selected (`,ee.length,`)`]}),(0,I.jsx)(`button`,{className:`icon-btn bordered`,"aria-label":`Clear selection`,onClick:()=>n(new Set),children:`×`})]}),(0,I.jsx)(`div`,{className:`run-next-accent`,children:(0,I.jsx)(Ji,{ctx:e})})]})]}),p&&M.length>0&&(0,I.jsx)(`div`,{className:`board-filters`,role:`group`,"aria-label":`Filters`,children:M.map(e=>(0,I.jsxs)(`div`,{role:`group`,"aria-label":e.label,title:e.help,children:[(0,I.jsx)(`span`,{className:`bf-label`,children:e.label}),(0,I.jsx)(`div`,{className:`bf-values`,children:fa(E,e,a).map(t=>(0,I.jsxs)(`button`,{className:`bf-chip`,"aria-pressed":t.on,onClick:()=>o(pa(a,e.key,t.value)),children:[t.on?`✓ `:``,t.label,` `,(0,I.jsx)(`span`,{className:`dim`,children:t.count})]},t.value))})]},e.key))}),ne>0&&(0,I.jsxs)(`div`,{className:`board-chips`,children:[M.flatMap(e=>(a[e.key]??[]).map(t=>(0,I.jsxs)(`span`,{className:`bf-picked`,children:[e.label,`: `,da(e,t),(0,I.jsx)(`button`,{"aria-label":`Remove the filter ${e.label}: ${da(e,t)}`,onClick:()=>o(pa(a,e.key,t)),children:`×`})]},`${e.key}:${t}`))),(0,I.jsx)(`button`,{className:`link-btn small`,onClick:()=>{o({}),i(``),f(!1)},children:`clear all`})]}),!M.length&&!te.length&&(0,I.jsx)(`span`,{role:`note`,className:`dim small`,children:`The domain marks no field for filters or lanes: search and “waiting for me” only.`})]}),!N&&(0,I.jsx)(`nav`,{className:`col-jump`,"aria-label":`Columns`,children:k.map(e=>(0,I.jsxs)(`button`,{className:`col-${e.status}`,onClick:()=>document.getElementById(`col-${e.status}`)?.scrollIntoView({inline:`start`,behavior:`smooth`}),children:[e.label,` · `,E.filter(t=>Wr(t)===e.status).length]},e.status))}),N?(0,I.jsxs)(`div`,{className:`lanes`,ref:C,style:{"--cols":k.length},children:[(0,I.jsx)(`div`,{className:`lane-heads`,children:k.map(({status:e,label:t,help:n})=>(0,I.jsxs)(`div`,{className:`lane-head-col col-${e}`,title:n,children:[(0,I.jsx)(`span`,{className:`col-dot`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`col-label`,children:t}),(0,I.jsx)(`span`,{className:`col-count`,children:E.filter(t=>Wr(t)===e).length}),ge(e)]},e))}),!ie.length&&(0,I.jsx)(`p`,{className:`dim lanes-none`,children:`No item matches the search and filters.`}),ie.map(t=>(0,I.jsxs)(`section`,{className:`lane`,"aria-label":`Lane ${t.label}`,children:[(0,I.jsxs)(`div`,{className:`lane-head`,title:t.value?`${N.label}: ${t.value}`:`Items with no ${N.label}`,children:[(0,I.jsx)(`h3`,{className:t.value?``:`dim`,children:t.label}),t.sub&&(0,I.jsx)(`span`,{className:`mono dim`,children:t.sub}),(0,I.jsx)(`span`,{className:`mono dim`,children:t.shown.length===t.items.length?t.items.length:`${t.shown.length} of ${t.items.length}`}),t.item&&(0,I.jsxs)(`button`,{className:`link-btn small`,onClick:()=>e.openItem(t.item??``),children:[`open `,t.item]})]}),(0,I.jsx)(`div`,{className:`lane-row`,children:k.map(({status:e,label:n})=>(0,I.jsxs)(Ca,{status:e,lane:t.value,label:`${t.label} · ${n}`,take:pe(e),children:[t.shown.filter(t=>Wr(t)===e).map(e=>he(e,t.value)),e===O&&t.value===b?.lane&&fe]},e))})]},t.value||`(none)`))]}):(0,I.jsx)(`div`,{className:`columns`,ref:C,children:k.map(({status:e,label:t,help:n})=>{let r=E.filter(t=>Wr(t)===e),i=r.filter(P);return(0,I.jsx)(Sa,{status:e,label:t,help:n,count:r.length,shown:i.length,wip:ge(e),take:pe(e),end:e===O&&fe,children:i.map(e=>he(e))},e)})}),(0,I.jsx)(`div`,{className:`k-say`,role:`status`,"aria-live":`assertive`,children:V?.say??``}),(_||b)&&(0,I.jsxs)(`div`,{className:`drag-help`,children:[(0,I.jsx)(`p`,{role:`status`,children:b?`Moving with the keys: ← → picks the column, ↑ ↓ the rank among ready cards, Space drops it, Esc puts it back. The column you can drop in is outlined; a dimmed one takes no move from here.`:`Drop on a ready card to rank it before that card · on running to run it (it asks first) · onto the column a move names to open that move. Verdicts and decisions are buttons only.`}),D.sections.graveyard&&(_||ce.includes(`graveyard`))&&(0,I.jsx)(wa,{label:D.sections.graveyard.label??`Graveyard`,hot:b?.target===`graveyard`})]})]}),(0,I.jsx)(or,{dropAnimation:null,children:me&&(0,I.jsxs)(`div`,{className:`card overlay ${l?`compact`:``} gate-${me.gate}`,children:[(0,I.jsx)(`span`,{className:`c-id`,children:me.id}),!l&&me.title&&(0,I.jsx)(`div`,{className:`c-title`,children:me.title})]})})]})}function Ma(e){return(0,I.jsxs)(`button`,{type:`button`,className:`tile ${e.needs?`needs`:e.accent?`accent`:``} ${e.on?`on`:e.picked?`picked`:``}`,"data-tile-key":e.dataKey,title:e.tip??`Open: the full text and its moves`,onClick:e.onOpen,children:[(0,I.jsxs)(`span`,{className:`tile-head`,children:[(0,I.jsx)(`span`,{className:`tile-cat tone-${e.tone??`neutral`}`,title:e.catTip,children:e.cat}),e.origin&&(0,I.jsx)(`span`,{className:`tile-origin`,children:e.origin}),e.age&&(0,I.jsx)(`span`,{className:`tile-age`,title:e.ageTip,children:e.age})]}),(0,I.jsx)(`span`,{className:`tile-title`,children:e.title}),(0,I.jsxs)(`span`,{className:`tile-foot`,children:[(0,I.jsx)(`span`,{className:`tile-sub`,children:e.sub}),e.mark&&(0,I.jsx)(`span`,{className:`tile-mark mark-${e.markTone??`quiet`}`,children:e.mark})]})]})}function Na({label:e,tip:t,onClick:n,disabled:r}){return(0,I.jsx)(`button`,{type:`button`,className:`trash-btn`,"aria-label":e,title:t??e,onClick:n,disabled:r,children:(0,I.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M3 6h18`}),(0,I.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,I.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,I.jsx)(`path`,{d:`M10 11v6`}),(0,I.jsx)(`path`,{d:`M14 11v6`})]})})}function Pa({children:e}){return(0,I.jsx)(`div`,{className:`tiles`,children:e})}var Fa={command:[`M12 4a8 8 0 1 0 0 16a8 8 0 1 0 0-16z`,`M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6z`],board:[`M4 5h4v14H4z`,`M10 5h4v9h-4z`,`M16 5h4v6h-4z`],chat:[`M4 5h16v11H10l-5 4v-4H4z`],inbox:[`M4 13l2.2-8h11.6L20 13`,`M4 13v6h16v-6h-5a3 3 0 0 1-6 0z`],design:[`M4 20l1-4.5L15.5 5l3.5 3.5L8.5 19z`,`M13.5 7l3.5 3.5`],runs:[`M12 4a8 8 0 1 0 0 16a8 8 0 1 0 0-16z`,`M10.2 8.6v6.8l5.6-3.4z`],playtest:[`M7.5 8h9a4.5 4.5 0 0 1 4.5 4.5v.5a3 3 0 0 1-5.5 1.7L14.4 13H9.6l-1.1 1.7A3 3 0 0 1 3 13v-.5A4.5 4.5 0 0 1 7.5 8z`,`M8 10v3`,`M6.5 11.5h3`,`M16 10.5h.01`,`M17.5 12h.01`],ended:[`M4 5h16v4H4z`,`M5.5 9v10h13V9`,`M10 13h4`],agent:[`M12 3.5l7 3v5c0 4.3-2.9 7.6-7 9c-4.1-1.4-7-4.7-7-9v-5z`,`M9.5 12l2 2 3.5-4`],metrics:[`M5 19v-6`,`M10 19V6`,`M15 19v-9`,`M20 19V4`]},Ia={command:`c`,board:`b`,chat:`t`,inbox:`i`,design:`d`,runs:`r`,playtest:`p`,ended:`e`,agent:`a`,metrics:`m`},La={command:e=>`${e} wait for you`,chat:e=>`${e} ${e===1?`thread waits`:`threads wait`} for your answer`,inbox:e=>`Needs you: ${e}`},Ra=0;function za(e,t,n,r){if(e.ctrlKey||e.metaKey||e.altKey)return!1;if(Ra&&Date.now()-Ra<1200){if(Ra=0,e.key===`s`)return r(),!0;let i=t.find(t=>Ia[t]===e.key);return i&&n(i),!!i}return e.key===`g`&&(Ra=Date.now()),!1}function Ba(){let[e,t]=(0,v.useState)(()=>new Date);return(0,v.useEffect)(()=>{let e=setInterval(()=>t(new Date),15e3);return()=>clearInterval(e)},[]),e.toTimeString().slice(0,5)}function Va({entries:e,screen:t,go:n}){Ba();let[r,i]=(0,v.useState)(null),a=()=>i(null);return(0,I.jsxs)(`nav`,{className:`side`,"aria-label":`Screens`,children:[e.map(e=>{let r=e.screen===t,o=e.count>0?La[e.screen]?.(e.count)??``:``,s=Ia[e.screen]?`g ${Ia[e.screen]}`:``,c=t=>{let n=t.currentTarget.getBoundingClientRect();i({label:e.label,keys:s,note:o,top:Math.round(n.top+n.height/2)})};return(0,I.jsxs)(`button`,{className:`rail-btn`,"aria-current":r?`page`:void 0,"aria-label":`${e.label}${o?`, ${o}`:``}${s?`, keys ${s}`:``}`,onClick:()=>n(e.screen),onMouseEnter:c,onMouseLeave:a,onFocus:c,onBlur:a,children:[(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(Fa[e.screen]??[`M12 12h.01`]).map(e=>(0,I.jsx)(`path`,{d:e},e))}),e.count>0&&(0,I.jsx)(`span`,{className:`rail-count ${e.needs?`needs`:``}`,"aria-hidden":`true`,children:e.count>99?`99+`:e.count})]},e.screen)}),r&&(0,I.jsxs)(`div`,{className:`rail-tip`,role:`tooltip`,style:{top:r.top},children:[(0,I.jsxs)(`span`,{className:`rail-tip-head`,children:[(0,I.jsx)(`span`,{className:`rail-tip-label`,children:r.label}),r.keys&&(0,I.jsx)(`kbd`,{children:r.keys})]}),r.note&&(0,I.jsx)(`span`,{className:`rail-tip-note`,children:r.note})]})]})}function Ha({entries:e,screen:t,go:n}){let r=[`command`,`board`,`chat`,`inbox`],i=[...e.filter(e=>r.includes(e.screen)),{screen:`more`,label:`More`,count:0}],a=!r.includes(t);return(0,I.jsx)(`nav`,{className:`phone-nav`,"aria-label":`Screens`,children:i.map(e=>(0,I.jsxs)(`button`,{"aria-current":e.screen===t||e.screen===`more`&&a?`page`:void 0,onClick:()=>n(e.screen),children:[(0,I.jsx)(`span`,{className:`count ${e.count?e.needs?`needs`:``:`none`}`,children:e.count||`·`}),e.label]},e.screen))})}var Ua=6e5,Wa=e=>e.kind===`session`?`5h`:e.kind===`weekly_all`?`week`:`${e.scope?.model?.display_name??e.kind}${e.group===`weekly`?` week`:``}`,Ga=e=>e.kind===`session`?`5-hour window`:e.kind===`weekly_all`?`week, all models`:`${e.group===`weekly`?`week, `:``}${e.scope?.model?.display_name??e.kind}`,Ka=e=>e.resets_at?Date.parse(e.resets_at):NaN,qa=(e,t)=>{let n=new Date(e);return n.toDateString()===new Date(t).toDateString()?oi(e):n.getTime()-t<5184e5?`${n.toLocaleDateString(void 0,{weekday:`short`})} ${oi(e)}`:si(e,new Date(t))};function Ja(e,t,n=Date.now()){let r=Qa(t,n),i=e?.failed?[`The board's last /usage ask failed: ${e.failed.error}`]:[];if(!e?.at||!e.limits.length)return{...r,title:[r.title,...i].join(`
26
+ `);function Hi(){return(0,I.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M4 4.5h16v11.5H10.5L6 19.5V16H4z`}),(0,I.jsx)(`path`,{d:`M8.8 10.4l2.1 2.1 4.2-4.2`})]})}function Ui(e,t){return!e.board.domain.chat||!t.length?null:{label:`Commit with agent`,agent:(0,I.jsx)(Hi,{}),title:`A project chat thread: its agent reads the diff and commits these files; nothing runs`,go:()=>void(async()=>{let n=null;try{n=(await k.newTalk(e.project.name)).id,await k.sendTalk(e.project.name,n,{type:`say`,text:Vi(t)})}catch(t){e.notify(t.message,`error`)}n&&(e.reloadTalks(),e.go(`chat`,n))})()}}var Wi=(e,t,n=!1)=>new Promise(r=>Li({ctx:e,ids:t,gate:n,answer:r}));async function Gi(e,t,n=!1){let r=await Wi(e,t,n);return r&&await e.run(r.ids,!1,r.agent),!!r}function Ki(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)({}),i=(0,v.useId)(),{refused:a,dirty:o}=zi(e?.ctx??null,e?.ids??null,n.mode);if((0,v.useEffect)(()=>{Li=e=>{r({}),t(t=>(t?.answer(null),e))}},[]),!e)return null;let{ctx:s,ids:c,gate:l}=e,{board:u}=s,d=c.filter(e=>!a[e]),f=r=>{t(null);let i={model:Ii(n.model),effort:Ii(n.effort),mode:n.mode};e.answer(r?{ids:d,agent:i}:null)},p=u.presets,m=Pi(u)&&p&&(p.model.length||p.effort.length),h=e=>{let t=[e?.model,e?.effort,e?.run_mode].filter(Boolean);return t.length?`its own: ${t.join(` · `)}`:``},g=[Ii(n.model),Ii(n.effort),n.mode].filter(Boolean).join(` · `),_=[...new Set(d.map(e=>mi(u,e,n.mode)))],y=_.length>1?`each where it runs (${_.map(e=>`${e}: ${Fi[e]}`).join(`; `)}), two runs at once`:Fi[_[0]??mi(u,c[0],n.mode)],b=e=>d.filter(t=>mi(u,t,n.mode)===e),x=b(`main`).filter(e=>u.items.find(t=>t.id===e)?.type===`spike`),S=[x.length?`${x.join(`, `)}: a spike on main leaves its code in main; in a worktree only its plan comes back, its code kept as a spike/<id> tag`:``,b(`worktree`).length&&u.runs?.active.some(e=>e.mode===`main`)?`a main run works in the project folder now: a worktree branch merges when that run ends`:``,b(`main`).length&&u.runs?.active.some(e=>e.mode===`main`)?`a main run works in the project folder now: this one waits in the queue`:``].filter(Boolean),C=b(`main`).length>0&&!!o?.length,w=C&&o?Ui(s,o):null;return(0,I.jsx)(R,{onClose:()=>f(!1),dirty:!1,children:(0,I.jsxs)(`div`,{className:`dialog`,role:`dialog`,"aria-modal":!0,"aria-label":`Run ${c.join(`, `)}?`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`h2`,{children:[`Run `,c.join(`, `),`?`]}),(0,I.jsxs)(`p`,{className:`dialog-body`,children:[l?`The run gate picked these. `:``,`One agent session each, `,y,`.`,m?` A model or effort picked here holds for this run only; each item keeps its own.`:u.domain.harness&&!Pi(u)?` This harness is older than run picks: each item runs on its own model.`:``]}),(0,I.jsx)(`ul`,{className:`run-list`,children:c.map(e=>{let t=h(u.items.find(t=>t.id===e));return(0,I.jsxs)(`li`,{className:a[e]?`refused`:void 0,children:[(0,I.jsx)(`span`,{className:`mono`,children:ri([e],u.items)}),a[e]?(0,I.jsxs)(`span`,{className:`small`,children:[`✕ the run gate refuses it now: `,a[e]]}):t&&(0,I.jsx)(`span`,{className:`dim small`,children:t})]},e)})}),m&&[`model`,`effort`].map(e=>(0,I.jsxs)(`div`,{className:`f-field`,children:[(0,I.jsx)(`span`,{className:`f-label`,children:(0,I.jsxs)(`label`,{htmlFor:`${i}-${e}`,children:[e===`model`?`Model`:`Effort`,` for this run`]})}),(0,I.jsx)(Ei,{id:`${i}-${e}`,what:e,presets:p[e],value:n[e],auto:`Default - each item's own`,onChange:t=>r({...n,[e]:t})})]},e)),(0,I.jsxs)(`div`,{className:`f-field`,children:[(0,I.jsx)(`span`,{className:`f-label`,children:(0,I.jsx)(`label`,{htmlFor:`${i}-mode`,children:`Where this run goes`})}),(0,I.jsxs)(`select`,{id:`${i}-mode`,className:`input`,value:n.mode??``,onChange:e=>r({...n,mode:e.target.value===``?void 0:e.target.value}),children:[(0,I.jsxs)(`option`,{value:``,children:[`default: each item's own, else the project's (`,u.run_mode,`)`]}),(0,I.jsxs)(`option`,{value:`main`,children:[`main · `,Fi.main]}),(0,I.jsxs)(`option`,{value:`worktree`,children:[`worktree · `,Fi.worktree]})]}),S.map(e=>(0,I.jsx)(`span`,{className:`f-help`,children:e},e)),C&&o&&(0,I.jsx)(ae,{head:`Loose work in the project folder`,text:`${Bi(o)} Or pick worktree above.`})]}),(0,I.jsxs)(`div`,{className:`dialog-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`btn-line`,onClick:()=>f(!1),children:`Cancel`}),w&&(0,I.jsxs)(`button`,{type:`button`,className:`btn btn-agent`,title:w.title,onClick:()=>{f(!1),w.go()},children:[(0,I.jsx)(Hi,{}),w.label]}),(0,I.jsx)(`button`,{type:`button`,className:`btn-primary`,autoFocus:!0,disabled:!d.length||b(`main`).length>0&&o===null,title:d.length?b(`main`).length>0&&o===null?`Asking the run gate first`:void 0:`The run gate refuses every one of them now`,onClick:()=>f(!0),children:d.length<c.length&&d.length?`Run ${d.join(`, `)}${g?` on ${g}`:``}`:g?`Run on ${g}`:`Run`})]})]})})}function qi(e){let[t,n]=(0,v.useState)(3),[r,i]=(0,v.useState)(!1);return{count:t,setCount:n,busy:r,go:async()=>{i(!0);try{let n=await k.next(e.project.name,t);n.length?(i(!1),await Gi(e,n,!0)):e.notify(`nothing can run now: dependencies, WIP or a run in progress`,`error`)}catch(t){e.notify(t.message,`error`)}i(!1)}}}function Ji({ctx:e}){let{count:t,setCount:n,busy:r,go:i}=qi(e);return(0,I.jsxs)(`div`,{className:`run-next`,title:`The framework's run gate picks them`,children:[(0,I.jsx)(`button`,{disabled:r,onClick:()=>void i(),children:r?`asking the run gate…`:`Run next`}),(0,I.jsx)(`input`,{type:`number`,min:1,max:20,value:t,onChange:e=>n(Math.max(1,Math.min(20,Number(e.target.value)||1))),"aria-label":`How many, 1 to 20`})]})}async function Yi(e,t){await ie(di(t)?`Stop the run of ${t.id}? It ends the wait for the reset: ${t.id} becomes paused: limit, Run resumes it later, and the queue goes on.`:`Stop the run of ${t.id}? It stays ready with its work kept; Run resumes it.`,`Stop`,!0)&&await e.stop(t.id)}function Xi(e){let t=e.domain.sections?.inbox,n=new Set((t?.groups??[]).filter(e=>e.counts).map(e=>e.id)),r=new Set((t?.categories??[]).filter(e=>n.has(e.group)).map(e=>e.id));return{entries:(e.inbox??[]).filter(e=>r.has(e.category)&&!e.later),repeats:n.size?e.inbox_repeats??[]:[]}}function Zi(e){let{entries:t,repeats:n}=Xi(e),r=(e.questions??[]).filter(e=>Qi(e)&&!e.answer);return t.length+n.length+r.length}var Qi=e=>e.category?e.category===`decision`:/^D1\b/.test(e.class??``);function $i(e,t){return e.domain.columns.some(e=>e.human&&e.status===t)}function G(e,t){return e.running?!1:$i(t,e.status)?!0:e.resumable&&e.resume?.ended===`limit`}function ea(e,t=[]){let n=(e.runs?.reports??[]).filter(e=>ni(e.ids,e.ok,e.result,e.err,e.note).bad),r=Xi(e),i=e.items.filter(t=>G(t,e)).sort((e,t)=>(e.priority??1/0)-(t.priority??1/0));return[...n.map(e=>({kind:`report`,report:e})),...e.runs?.paused?[{kind:`queue`}]:[],...e.runs?.autopilot?.stop&&e.runs.autopilot.stop.kind!==`idle`?[{kind:`pilot`,stop:e.runs.autopilot.stop}]:[],...t.flatMap(e=>e.card&&!e.limit_until?[{kind:`chat`,card:e.card,talk:e}]:[]),...e.items.flatMap(e=>e.running&&e.chat_card?[{kind:`chat`,card:e.chat_card,item:e.id}]:[]),...(e.questions??[]).filter(e=>Qi(e)&&!e.answer).map(e=>({kind:`question`,question:e})),...r.entries.map(e=>({kind:`entry`,entry:e})),...r.repeats.map(e=>({kind:`repeat`,repeat:e})),...i.map(e=>({kind:`item`,item:e}))]}var ta=e=>[e.blocked_by.length?`blocked by ${e.blocked_by.join(`, `)}`:``,e.tbd?`TBD ${e.tbd}`:``].filter(Boolean).join(` · `)||(e.ready?`ready`:`not ready`);function na(e,t){return t.running?`running`:e.domain.columns.find(e=>e.status===t.status)?.label??t.status}function ra(e,t,n=[]){let r=e.items.find(e=>e.id===t);if(r){let i=na(e,r),a=n.includes(t)?`the run gate waits for it`:`it lets a run start`;return{id:t,kind:`item`,state:`${i}${r.verified?` · verified`:``}`,tone:r.running?`running`:r.status,tip:`${r.title??t} · ${i} · ${a}`}}let i=e.units?.find(e=>e.id===t);if(i)return{id:t,kind:`unit`,state:ta(i),tone:i.ready?`ok`:`warn`,tip:`design unit, not taken into work · ${i.title??t} · ${i.file}`};let a=e.graveyard?.find(e=>e.id===t);if(a)return{id:t,kind:`grave`,state:`graveyard: it never will be done`,tone:`error`,tip:a.reason??`in the graveyard`};let o=e.history?.find(e=>e.id===t);return o?{id:t,kind:`history`,state:`ended${o.event?`: ${o.event}`:``}`,tone:`ok`,tip:`in history${o.date?` since ${o.date}`:``}`}:{id:t,kind:`unknown`,state:`unknown: no item, unit or graveyard line`,tone:`warn`,tip:`The framework knows no ${t}`}}var ia=e=>e.needs??[],aa=e=>e.needed_by??[];function oa(e,t,n){let r=n&&n!==t.id?e.items.find(e=>e.id===n):void 0;if(!r)return{label:``,dim:!1,self:n===t.id};let i=ia(r).includes(t.id)?`needed by ${r.id}`:ia(t).includes(r.id)?`needs ${r.id}`:``;return{label:i,dim:!i,self:!1}}var sa=(e,t)=>aa(t).length>0||ia(t).some(t=>e.items.some(e=>e.id===t));function ca(e,t){let n=e[t];return n==null||n===``?[]:Array.isArray(n)?n.map(String):[String(n)]}var la=(e,t,n)=>t.every(t=>{let r=n[t.key];return!r?.length||ca(e,t.key).some(e=>r.includes(e))});function ua(e,t){let n=t.trim().toLowerCase();return!n||e.id.includes(n)||(e.title??``).toLowerCase().includes(n)}var da=(e,t)=>e.options?.find(e=>e.value===t)?.label??t;function fa(e,t,n){let r=new Map;for(let n of e)for(let e of ca(n,t.key))r.set(e,(r.get(e)??0)+1);return[...r.keys()].sort().map(e=>({value:e,label:da(t,e),count:r.get(e)??0,on:(n[t.key]??[]).includes(e)}))}function pa(e,t,n){let r=e[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n],{[t]:a,...o}=e;return i.length?{...o,[t]:i}:o}function ma(e,t,n){let r=new Map;for(let e of t){let t=ca(e,n.key);for(let n of t.length?t:[``])r.set(n,[...r.get(n)??[],e])}return[...r.keys()].sort((e,t)=>Number(e===``)-Number(t===``)||e.localeCompare(t)).map(t=>{let i=n.kind===`ids`&&t?e.items.find(e=>e.id===t):void 0,a=i?.title;return{value:t,label:t?a||t:`none`,sub:a?t:``,item:i?i.id:null,items:r.get(t)??[]}})}var ha=window.matchMedia(`(width <= 700px)`),ga={status:`running`,label:`running`,help:`An agent session works on it`},_a=new Set([`priority`,`type`,`gate`,`severity`,`tune_count`,`waits_for`,`blocked`,`needs`,`needed_by`]);function va(e,t){return e.starting?{label:`starting…`,tone:`running`,tip:`The run starts: its agent session opens in a few seconds`}:e.running_kind===`console`?{label:`running — console run`,tone:`running`,tip:`Started from a console (gcf-harness run)`}:e.running_kind===`session`?{label:`running — your session`,tone:`running`,tip:`Your own agent session works on it; release the mark when you are done`}:e.resumable&&!e.running?{label:li(e),tone:`neutral`,tip:ci(e)}:t?{label:`queued`,tone:`queued`,tip:`Waits for the main run going on; starts after it`}:null}var ya=new Set([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,` `,`Enter`,`Escape`,`Tab`]),ba=({text:e,compact:t})=>(0,I.jsx)(`div`,{className:`k-ghost ${t?`compact`:``}`,"aria-hidden":`true`,children:e});function xa({item:e,ctx:t,compact:n,selected:r,onSelect:i,hover:a,lane:o,kb:s}){let{board:c}=t,{domain:l}=c,u=o===void 0?e.id:`${e.id}@${o}`,{attributes:d,listeners:f,setNodeRef:p,isDragging:m}=Wn({id:u,data:{id:e.id}}),h=Jn({id:`before:${u}`,data:{id:e.id},disabled:Wr(e)!==l.runs_from||!l.rank}),g=e=>{p(e),h.setNodeRef(e)},_=c.runs?.queued.includes(e.id)??!1,v=di(e),y=new Map;for(let t of l.fields){let n=t.card?Ir(e,t):null;n!==null&&y.set(t.key,{f:t,v:n})}let b=y.get(`priority`)??[...y.values()].find(e=>e.f.kind===`rank`),x=y.get(`type`),S=y.get(`gate`),C=y.get(`severity`),w=y.get(`waits_for`),T=y.get(`blocked`),E=y.get(`tune_count`),D=[...y.values()].filter(({f:e})=>!_a.has(e.key)&&e.kind!==`rank`),O=va(e,_),k=G(e,c),A=e.plan,ee=Ar(e,l)&&!_&&!e.running,j=()=>t.openItem(e.id),M=l.sections.lessons?e.lessons??0:0,te=y.has(`needs`)?ia(e):[],N=y.has(`needed_by`)?aa(e):[],ne=`Not ended in history: ${te.map(e=>`${e} (${ra(c,e).state})`).join(`, `)}`,P=`They depend on it: ${N.join(`, `)}`,F=oa(c,e,a.id),re=sa(c,e),L={onMouseEnter:()=>re&&a.set(e.id),onMouseLeave:()=>a.id===e.id&&a.set(null),onFocus:t=>{re&&t.target.matches(`:focus-visible`)&&a.set(e.id)},onBlur:t=>{a.id===e.id&&a.set(null),R&&!t.currentTarget.contains(t.relatedTarget)&&s.key(`Tab`)}},R=s.grab?.id===e.id&&s.grab.lane===o,z=!e.running&&!ha.matches,ie=e=>e.target===e.currentTarget||e.target.matches(`.c-open`),B=t=>R?ya.has(t.key)?(t.preventDefault(),t.stopPropagation(),s.key(t.key),!0):!1:t.key!==` `||!z||s.grab||!ie(t)?!1:(t.preventDefault(),t.stopPropagation(),s.pick(e,o),!0),ae=e=>{e.key===` `&&z&&ie(e)&&e.preventDefault()},oe=t=>(0,I.jsxs)(I.Fragment,{children:[s.ghost===e.id&&s.grab?.lane===o&&(0,I.jsx)(ba,{text:s.ghostText,compact:n}),t,R&&(0,I.jsxs)(`div`,{className:`k-note`,role:`note`,children:[(0,I.jsx)(`span`,{className:`k-hint`,children:s.hint}),(0,I.jsx)(`div`,{className:`k-keys`,children:s.keys.map(([e,t])=>(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`kbd`,{children:e}),t]},e))})]})]}),se=z?` · Space picks it up to move it with the keys`:``,ce=[...y.values()].filter(({f:e})=>e.badge).map(({f:e,v:t})=>`${e.key}-${t}`),V=[`card`,n?`compact`:``,...ce,m?`dragging`:``,r?`selected`:``,h.isOver&&!m?`drop-before`:``,F.label||F.self?`lit`:``,F.dim?`dim`:``,R?`lifted`:``].join(` `);if(n)return oe((0,I.jsxs)(`div`,{ref:g,...d,...f,...L,"aria-roledescription":`movable card`,"aria-pressed":R,className:V,"data-card":e.id,title:`${e.id}${e.title?` — ${e.title}`:``}${se}`,onClick:()=>!s.grab&&j(),onKeyUp:ae,onKeyDown:e=>{B(e)||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),j())},children:[(0,I.jsx)(`span`,{className:`c-rank`,children:b?.v??``}),(0,I.jsx)(`span`,{className:`c-id`,children:e.id}),F.label&&(0,I.jsx)(`span`,{className:`c-rel`,children:F.label}),te.length>0&&(0,I.jsxs)(`span`,{className:`c-note mono`,title:ne,children:[`◂`,te.length]}),k?(0,I.jsx)(`span`,{className:`c-needs`,title:`Only you can move it on`,children:`●`}):O?(0,I.jsx)(`span`,{className:`c-mark tone-${O.tone}`,title:O.tip,children:O.label}):null]}));let{role:H,tabIndex:U,"aria-pressed":le,"aria-roledescription":ue,...de}=d;return oe((0,I.jsxs)(`div`,{ref:g,className:V,"data-card":e.id,title:S?Lr(S.f,S.v):void 0,...de,...f,...L,onClick:e=>{!s.grab&&!e.target.closest(`button`)&&j()},onKeyDown:B,onKeyUp:ae,children:[e.running&&e.running_kind!==`session`&&(0,I.jsx)(`span`,{className:`c-flow`,"aria-hidden":`true`}),F.label&&(0,I.jsx)(`span`,{className:`c-rel`,children:F.label}),(0,I.jsxs)(`div`,{className:`c-top`,children:[ee&&(0,I.jsx)(`button`,{role:`checkbox`,"aria-checked":r,"aria-label":`Select ${e.id} for a run`,className:`c-box`,onClick:()=>i(!r),children:r?`☑`:`☐`}),(0,I.jsxs)(`button`,{className:`c-open`,onClick:()=>!s.grab&&j(),"aria-roledescription":z?`movable card`:void 0,"aria-pressed":z?R:void 0,title:se?`Open it${se}`:void 0,"aria-label":`Open ${e.id}${e.title?`: ${e.title}`:``}`,children:[x&&(0,I.jsx)(`span`,{className:`c-type`,title:Lr(x.f,x.v)??x.v,children:x.v.slice(0,3).toUpperCase()}),k&&(0,I.jsx)(`span`,{className:`c-needs`,title:`Only you can move it on`,"aria-label":`needs you`,children:`●`}),(0,I.jsx)(`span`,{className:`c-id`,children:e.id})]}),T&&(0,I.jsx)(`span`,{className:`c-blocked`,role:`img`,tabIndex:0,title:`Blocked: ${T.v} · open the card to read it in Status`,"aria-label":`blocked: ${T.v}`,children:`!`}),b&&(0,I.jsx)(`span`,{className:`c-rank`,title:`Priority rank: lower runs sooner. Drag the card to change it.`,children:b.v})]}),e.title&&(0,I.jsx)(`div`,{className:`c-title`,children:e.title}),(O||e.verified||C)&&(0,I.jsxs)(`div`,{className:`c-marks`,children:[O&&(0,I.jsx)(`span`,{className:`badge tone-${O.tone}`,title:O.tip,children:O.label}),e.verified&&(0,I.jsx)(`span`,{className:`badge tone-ok`,title:`Passed build, tests and review; merges into main at the start of the next run`,children:`✔ verified`}),C&&(0,I.jsxs)(`span`,{className:`c-sev sev-${C.v}`,title:`severity: ${C.v}`,children:[`▲ `,C.v]})]}),v&&(0,I.jsxs)(`div`,{className:`c-limit`,children:[(0,I.jsxs)(`span`,{title:`The run waits for the usage limit's reset, then goes on by itself; stop the run to end the wait`,children:[`◷ limit: resumes `,oi(v)]}),(0,I.jsx)(`button`,{className:`btn-danger`,title:`Ends the wait: the item becomes paused: limit; Run resumes it later`,onClick:()=>void Yi(t,e),children:`Stop`})]}),e.running&&e.running_kind!==`session`&&e.active_at&&!v&&(0,I.jsx)(ei,{at:e.active_at}),w&&(0,I.jsxs)(`div`,{className:`c-waits`,title:w.f.help??`The run gate would refuse it now`,children:[`⧗ waits for `,w.v]}),(typeof e.skip_gates==`boolean`||e.gate_why)&&(0,I.jsxs)(`div`,{className:`c-gates`,children:[typeof e.skip_gates==`boolean`&&(0,I.jsxs)(`span`,{title:e.skip_gates?`Its own gates: each on its second value (milestone go, verdict defer, decision agent, question assume)`:`Its own gates: every one waits for you`,children:[(0,I.jsx)(`span`,{className:`dim`,"aria-hidden":`true`,children:`⇥`}),` `,e.skip_gates?`gates: skip`:`gates: wait`]}),e.gate_why&&(0,I.jsxs)(`span`,{className:`c-gate-why`,title:`Its own verdict stop: ${e.gate_why}`,children:[`verdict: `,e.gate_why]})]}),(0,I.jsxs)(`div`,{className:`c-foot`,children:[A&&(`error`in A?(0,I.jsx)(`span`,{className:`c-plan bad`,title:A.error,children:`plan ✘`}):(0,I.jsxs)(`span`,{className:`c-plan`,title:`Plan checkboxes done / total`,children:[(0,I.jsx)(`span`,{className:`bar`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{style:{width:`${Math.round(100*A.done/Math.max(1,A.tasks))}%`}})}),A.done,`/`,A.tasks]})),E&&(0,I.jsxs)(`span`,{className:`c-note`,title:E.f.help,children:[`· tuned `,E.v,`×`]}),M>0&&(0,I.jsxs)(`span`,{className:`c-note`,title:`What got in its agents' way: lessons in the inbox`,children:[`· `,M,` lesson`,M>1?`s`:``]}),D.map(({f:e,v:t})=>(0,I.jsxs)(`span`,{className:`c-note`,title:Lr(e,t),children:[`· `,e.label,` `,t]},e.key)),te.length>0&&(0,I.jsxs)(`span`,{className:`c-dep`,title:ne,children:[y.get(`needs`)?.f.label??`needs`,` `,te.length]}),N.length>0&&(0,I.jsxs)(`span`,{className:`c-dep`,title:P,children:[y.get(`needed_by`)?.f.label??`needed by`,` `,N.length]})]})]}))}function Sa({status:e,label:t,help:n,count:r,shown:i,wip:a,take:o,end:s,children:c}){let{setNodeRef:l,isOver:u}=Jn({id:e,data:{status:e}});return(0,I.jsxs)(`section`,{ref:l,id:`col-${e}`,className:`column col-${e} ${u?`over`:``} ${o}`,"aria-label":`${t} column`,children:[(0,I.jsxs)(`div`,{className:`col-head`,title:n,tabIndex:0,children:[(0,I.jsx)(`span`,{className:`col-dot`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`col-label`,children:t}),(0,I.jsx)(`span`,{className:`col-count`,children:i===r?r:`${i} of ${r}`}),a]}),(0,I.jsxs)(`div`,{className:`col-body`,children:[r===0?(0,I.jsx)(`div`,{className:`col-empty`,children:e===`running`?`nothing runs`:`empty`}):i===0?(0,I.jsx)(`div`,{className:`col-empty`,children:`none match the filter`}):c,s]})]})}function Ca({status:e,lane:t,label:n,take:r,children:i}){let{setNodeRef:a,isOver:o}=Jn({id:`${e}@${t}`,data:{status:e}});return(0,I.jsx)(`div`,{ref:a,className:`lane-cell ${o?`over`:``} ${r}`,"aria-label":n,children:i})}function wa({label:e,hot:t}){let{setNodeRef:n,isOver:r}=Jn({id:`graveyard`,data:{status:`graveyard`}});return(0,I.jsxs)(`div`,{ref:n,className:`grave ${r?`over`:``} ${t?`k-target`:``}`,"aria-label":`Graveyard drop zone`,children:[(0,I.jsxs)(`span`,{children:[`✝ `,e]}),(0,I.jsx)(`small`,{children:`Drop here: opens the drop form. Nothing ends until you confirm it.`})]})}var Ta=`[data-card], button, input, select, textarea, a, label, [role="button"]`;function Ea(){let e=(0,v.useRef)(void 0);return(0,v.useCallback)(t=>{e.current?.(),e.current=t?Da(t):void 0},[])}function Da(e){let t=null,n=!1,r=r=>{r.pointerType===`mouse`&&r.button===0&&(r.target.closest(Ta)||(t={x:r.clientX,left:e.scrollLeft,id:r.pointerId},n=!1))},i=r=>{if(!t)return;let i=r.clientX-t.x;if(!(!n&&Math.abs(i)<4)){if(!n){n=!0;try{e.setPointerCapture(t.id)}catch{}e.classList.add(`panning`)}e.scrollLeft=t.left-i}},a=()=>{t=null,e.classList.remove(`panning`)},o=e=>{n&&(n=!1,e.stopPropagation(),e.preventDefault())},s=t=>{if(t.shiftKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||e.scrollHeight>e.clientHeight+2)return;let n=t.target.closest(`.col-body`);n&&n.scrollHeight>n.clientHeight||e.scrollWidth<=e.clientWidth||(e.scrollLeft+=t.deltaY,t.preventDefault())};return e.addEventListener(`pointerdown`,r),e.addEventListener(`pointermove`,i),e.addEventListener(`pointerup`,a),e.addEventListener(`pointercancel`,a),e.addEventListener(`click`,o,!0),e.addEventListener(`wheel`,s,{passive:!1}),()=>{e.removeEventListener(`pointerdown`,r),e.removeEventListener(`pointermove`,i),e.removeEventListener(`pointerup`,a),e.removeEventListener(`pointercancel`,a),e.removeEventListener(`click`,o,!0),e.removeEventListener(`wheel`,s)}}var Oa=e=>e.ctrlKey||e.metaKey||e.altKey||e.defaultPrevented||!!document.querySelector(`.modal`)||!!e.target?.closest?.(`input, textarea, select, [contenteditable]`);function ka(){let e=[...document.querySelectorAll(`.board [data-card]`)];return{all:e,at:e.findIndex(e=>e.contains(document.activeElement))}}var Aa=e=>{e&&((e.querySelector(`.c-open`)??e).focus(),e.scrollIntoView({block:`nearest`,inline:`nearest`}))};function ja({ctx:e}){let[t,n]=(0,v.useState)(new Set),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)({}),[s,c]=(0,v.useState)(`none`),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),S=(0,v.useRef)(null),C=Ea(),w=Ge(We(Ht,{activationConstraint:{distance:8}}),We(qt,{activationConstraint:{delay:300,tolerance:8}})),{board:T}=e,E=T.items,{domain:D}=T,O=D.runs_from,k=D.columns.flatMap(e=>e.status===O?[e,ga]:[e]),A=T.runs?.queued??[],ee=[...t].filter(e=>!A.includes(e)&&E.some(t=>t.id===e&&Ar(t,D)&&!t.running)),j=E.filter(e=>Wr(e)===O).map(e=>e.id),M=D.fields.filter(e=>e.filter),te=D.fields.filter(e=>e.group),N=te.find(e=>e.key===s),ne=Object.values(a).reduce((e,t)=>e+t.length,0),P=e=>ua(e,r)&&la(e,M,a)&&(!d||G(e,T)),F=!!(r.trim()||ne||d),re=E.filter(e=>G(e,T)).length,L=D.sections.playtest?.waits[0],R={id:_||b?null:h,set:g};(0,v.useEffect)(()=>{h&&!E.some(e=>e.id===h)&&g(null)},[h,E]);let z=b?E.find(e=>e.id===b.id):void 0,ie=N?ma(T,E,N).map(e=>({...e,shown:e.items.filter(P)})).filter(e=>!F||e.shown.length):[],B=(e,t)=>{let n=N?ie.find(e=>e.value===t)?.items??[]:E,r=new Set(n.filter(t=>t.id===e||P(t)).map(e=>e.id));return j.filter(e=>r.has(e))},ae=b?B(b.id,b.lane):[],oe=z&&(N?ie.some(e=>e.value===b?.lane&&e.items.some(e=>e.id===z.id)):b?.lane===void 0);(0,v.useEffect)(()=>{b&&!oe&&x(null)},[b,oe]);let se=Object.fromEntries(k.map(e=>[e.status,e.label])),ce=z?Jr(z,D,k.map(e=>e.status)):[],V=b&&z?Zr(b,z,D,ae,se):null;(0,v.useEffect)(()=>{b&&(document.getElementById(`col-${b.target}`)?.scrollIntoView({block:`nearest`,inline:`nearest`}),document.querySelector(`.board .k-ghost`)?.scrollIntoView({block:`nearest`}))},[b]),(0,v.useEffect)(()=>{let e=()=>{S.current=null};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[]),(0,v.useEffect)(()=>{let e=S.current;if(!e)return;let t=document.querySelector(`.board [data-card="${CSS.escape(e.id)}"]`),n=document.activeElement;Date.now()>e.until||n&&n!==document.body&&!t?.contains(n)?S.current=null:t&&!t.contains(n)&&Aa(t)}),(0,v.useEffect)(()=>{let e=e=>{if(Oa(e))return;let{all:t,at:n}=ka();if(e.key===`j`||e.key===`k`)e.preventDefault(),Aa(t[n<0?0:Math.max(0,Math.min(t.length-1,n+(e.key===`j`?1:-1)))]);else if(/^[1-9]$/.test(e.key)){let t=document.querySelectorAll(`.board .column, .board .lane-head-col`)[Number(e.key)-1];if(!t)return;e.preventDefault(),t.scrollIntoView({inline:`start`,block:`nearest`,behavior:`smooth`});let n=t.querySelector(`[data-card]`);n?Aa(n):t.querySelector(`.col-head`)?.focus()}else if(e.key===`r`&&n>=0){let r=E.find(e=>e.id===t[n].dataset.card);if(!r||!Ar(r,D)||r.running||A.includes(r.id))return;e.preventDefault(),ue(r.id,!0)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let H=Tr(D,D.rank),U=(t,n)=>{let r=Ur(j,t,n);r&&H&&e.move({cmd:H.cmd,ids:r})},le=e=>{y(null);let t=e.active.data.current?.id??String(e.active.id),n=E.find(e=>e.id===t),r=e.over;if(!n||!r)return;if(String(r.id).startsWith(`before:`)){let e=r.data.current?.id;if(Wr(n)===O)return U(n.id,e)}let i=String(r.id).startsWith(`before:`)?O:r.data.current?.status??String(r.id);de(n,i,N?String(r.id).split(`@`)[1]:void 0)},ue=async(t,n)=>{let r=await Wi(e,[t]);r&&(n&&(S.current={id:t,until:Date.now()+1e4}),await e.run(r.ids,!1,r.agent))},de=(t,n,r,i=!1)=>{let a=Gr(t,n,D);if(a?.act===`rank`)return U(t.id,Kr(j,B(t.id,r),t.id,null));if(a?.act===`run`)return void ue(t.id,i);a?e.openMove({title:`${a.move.label} ${t.id}`,id:t.id,move:a.move}):n!==Wr(t)&&e.notify(`no move takes ${t.id} to ${n}: open it for its moves`,`error`)},fe={grab:b,ghost:V&&!V.same?V.before:null,ghostText:V?`drops here · ${V.act}`:``,hint:V?`→ ${V.where} · ${V.act}`:``,keys:[[`← →`,`column`],...b?.from===O&&H?[[`↑ ↓`,`rank`]]:[],[`Space`,`drop`],[`Esc`,`put back`]],pick:(e,t)=>{g(null),x({...Yr(e,B(e.id,t)),...N&&{lane:t}})},key:t=>{if(!b||!z||!V)return x(null);if(t===`Escape`||t===`Tab`)return x(null),e.notify(`${b.id}: put back, nothing moved`);if(t!==`ArrowUp`&&t!==`ArrowDown`||H){if(t!==` `&&t!==`Enter`)return x(Xr(b,t,ce,ae,O));if(x(null),S.current={id:b.id,until:Date.now()+1e4},!V.same){if(V.ranking)return U(b.id,Kr(j,ae,b.id,V.before));de(z,b.target,void 0,!0)}}}},pe=V?.ranking&&!V.same&&!V.before&&(0,I.jsx)(ba,{text:fe.ghostText,compact:l}),W=e=>{let t=he??z;return t?b?.target===e?`k-target`:b&&e===b.from||Gr(t,e,D)?`takes`:`no-drop`:``},me=async()=>{await Gi(e,ee)&&n(new Set)},he=_?E.find(e=>e.id===_):void 0,ge=(r,i)=>(0,I.jsx)(xa,{item:r,ctx:e,compact:l,hover:R,lane:i,kb:fe,selected:t.has(r.id),onSelect:e=>n(t=>{let n=new Set(t);return e?n.add(r.id):n.delete(r.id),n})},r.id),_e=e=>e===L&&D.sections.wip&&T.wip&&(0,I.jsxs)(`span`,{className:`col-wip ${T.wip.over?`over`:``}`,title:D.sections.wip.help,children:[`WIP `,T.wip.count,`/`,T.wip.limit,T.wip.over?` · over`:``]});return(0,I.jsxs)(Bn,{sensors:w,onDragStart:e=>{g(null),x(null),y(e.active.data.current?.id??String(e.active.id))},onDragCancel:()=>y(null),onDragEnd:le,children:[(0,I.jsxs)(`section`,{className:`board`,"aria-label":`Board`,children:[(0,I.jsxs)(`div`,{className:`board-tools ${e.boardTools?``:`shut`}`,children:[(0,I.jsxs)(`div`,{className:`board-row`,children:[(0,I.jsx)(`input`,{className:`input board-search`,type:`search`,"data-search":!0,"aria-label":`Search items by id and title`,value:r,onChange:e=>i(e.target.value),placeholder:`search id or title`}),(0,I.jsxs)(`button`,{className:`pill pill-needs ${d?`on`:``}`,"aria-pressed":d,onClick:()=>f(!d),children:[d?`✓ `:``,`waiting for me · `,re]}),M.length>0&&(0,I.jsxs)(`button`,{className:`btn-line board-filter ${ne?`on`:``}`,"aria-expanded":p,title:`Filter by the fields the domain marks: several at once`,onClick:()=>m(!p),children:[`Filter`,ne?` · ${ne}`:``,` `,p?`▴`:`▾`]}),te.length>0&&(0,I.jsxs)(`label`,{className:`board-group`,children:[`Group by`,(0,I.jsxs)(`select`,{className:`input`,"aria-label":`Group the board in lanes by`,value:N?N.key:`none`,onChange:e=>c(e.target.value),children:[(0,I.jsx)(`option`,{value:`none`,children:`none`}),te.map(e=>(0,I.jsx)(`option`,{value:e.key,children:e.label},e.key))]})]}),(0,I.jsxs)(`button`,{className:`btn-line board-density`,title:`Card density`,onClick:()=>u(!l),children:[`▤ `,l?`compact`:`comfortable`]}),D.harness&&(0,I.jsxs)(`div`,{className:`board-run`,children:[ee.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{className:`btn-accent`,onClick:()=>void me(),children:[`▶ Run selected (`,ee.length,`)`]}),(0,I.jsx)(`button`,{className:`icon-btn bordered`,"aria-label":`Clear selection`,onClick:()=>n(new Set),children:`×`})]}),(0,I.jsx)(`div`,{className:`run-next-accent`,children:(0,I.jsx)(Ji,{ctx:e})})]})]}),p&&M.length>0&&(0,I.jsx)(`div`,{className:`board-filters`,role:`group`,"aria-label":`Filters`,children:M.map(e=>(0,I.jsxs)(`div`,{role:`group`,"aria-label":e.label,title:e.help,children:[(0,I.jsx)(`span`,{className:`bf-label`,children:e.label}),(0,I.jsx)(`div`,{className:`bf-values`,children:fa(E,e,a).map(t=>(0,I.jsxs)(`button`,{className:`bf-chip`,"aria-pressed":t.on,onClick:()=>o(pa(a,e.key,t.value)),children:[t.on?`✓ `:``,t.label,` `,(0,I.jsx)(`span`,{className:`dim`,children:t.count})]},t.value))})]},e.key))}),ne>0&&(0,I.jsxs)(`div`,{className:`board-chips`,children:[M.flatMap(e=>(a[e.key]??[]).map(t=>(0,I.jsxs)(`span`,{className:`bf-picked`,children:[e.label,`: `,da(e,t),(0,I.jsx)(`button`,{"aria-label":`Remove the filter ${e.label}: ${da(e,t)}`,onClick:()=>o(pa(a,e.key,t)),children:`×`})]},`${e.key}:${t}`))),(0,I.jsx)(`button`,{className:`link-btn small`,onClick:()=>{o({}),i(``),f(!1)},children:`clear all`})]}),!M.length&&!te.length&&(0,I.jsx)(`span`,{role:`note`,className:`dim small`,children:`The domain marks no field for filters or lanes: search and “waiting for me” only.`})]}),!N&&(0,I.jsx)(`nav`,{className:`col-jump`,"aria-label":`Columns`,children:k.map(e=>(0,I.jsxs)(`button`,{className:`col-${e.status}`,onClick:()=>document.getElementById(`col-${e.status}`)?.scrollIntoView({inline:`start`,behavior:`smooth`}),children:[e.label,` · `,E.filter(t=>Wr(t)===e.status).length]},e.status))}),N?(0,I.jsxs)(`div`,{className:`lanes`,ref:C,style:{"--cols":k.length},children:[(0,I.jsx)(`div`,{className:`lane-heads`,children:k.map(({status:e,label:t,help:n})=>(0,I.jsxs)(`div`,{className:`lane-head-col col-${e}`,title:n,children:[(0,I.jsx)(`span`,{className:`col-dot`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`col-label`,children:t}),(0,I.jsx)(`span`,{className:`col-count`,children:E.filter(t=>Wr(t)===e).length}),_e(e)]},e))}),!ie.length&&(0,I.jsx)(`p`,{className:`dim lanes-none`,children:`No item matches the search and filters.`}),ie.map(t=>(0,I.jsxs)(`section`,{className:`lane`,"aria-label":`Lane ${t.label}`,children:[(0,I.jsxs)(`div`,{className:`lane-head`,title:t.value?`${N.label}: ${t.value}`:`Items with no ${N.label}`,children:[(0,I.jsx)(`h3`,{className:t.value?``:`dim`,children:t.label}),t.sub&&(0,I.jsx)(`span`,{className:`mono dim`,children:t.sub}),(0,I.jsx)(`span`,{className:`mono dim`,children:t.shown.length===t.items.length?t.items.length:`${t.shown.length} of ${t.items.length}`}),t.item&&(0,I.jsxs)(`button`,{className:`link-btn small`,onClick:()=>e.openItem(t.item??``),children:[`open `,t.item]})]}),(0,I.jsx)(`div`,{className:`lane-row`,children:k.map(({status:e,label:n})=>(0,I.jsxs)(Ca,{status:e,lane:t.value,label:`${t.label} · ${n}`,take:W(e),children:[t.shown.filter(t=>Wr(t)===e).map(e=>ge(e,t.value)),e===O&&t.value===b?.lane&&pe]},e))})]},t.value||`(none)`))]}):(0,I.jsx)(`div`,{className:`columns`,ref:C,children:k.map(({status:e,label:t,help:n})=>{let r=E.filter(t=>Wr(t)===e),i=r.filter(P);return(0,I.jsx)(Sa,{status:e,label:t,help:n,count:r.length,shown:i.length,wip:_e(e),take:W(e),end:e===O&&pe,children:i.map(e=>ge(e))},e)})}),(0,I.jsx)(`div`,{className:`k-say`,role:`status`,"aria-live":`assertive`,children:V?.say??``}),(_||b)&&(0,I.jsxs)(`div`,{className:`drag-help`,children:[(0,I.jsx)(`p`,{role:`status`,children:b?`Moving with the keys: ← → picks the column, ↑ ↓ the rank among ready cards, Space drops it, Esc puts it back. The column you can drop in is outlined; a dimmed one takes no move from here.`:`Drop on a ready card to rank it before that card · on running to run it (it asks first) · onto the column a move names to open that move. Verdicts and decisions are buttons only.`}),D.sections.graveyard&&(_||ce.includes(`graveyard`))&&(0,I.jsx)(wa,{label:D.sections.graveyard.label??`Graveyard`,hot:b?.target===`graveyard`})]})]}),(0,I.jsx)(or,{dropAnimation:null,children:he&&(0,I.jsxs)(`div`,{className:`card overlay ${l?`compact`:``} gate-${he.gate}`,children:[(0,I.jsx)(`span`,{className:`c-id`,children:he.id}),!l&&he.title&&(0,I.jsx)(`div`,{className:`c-title`,children:he.title})]})})]})}function Ma(e){return(0,I.jsxs)(`button`,{type:`button`,className:`tile ${e.needs?`needs`:e.accent?`accent`:``} ${e.on?`on`:e.picked?`picked`:``}`,"data-tile-key":e.dataKey,title:e.tip??`Open: the full text and its moves`,onClick:e.onOpen,children:[(0,I.jsxs)(`span`,{className:`tile-head`,children:[(0,I.jsx)(`span`,{className:`tile-cat tone-${e.tone??`neutral`}`,title:e.catTip,children:e.cat}),e.origin&&(0,I.jsx)(`span`,{className:`tile-origin`,children:e.origin}),e.age&&(0,I.jsx)(`span`,{className:`tile-age`,title:e.ageTip,children:e.age})]}),(0,I.jsx)(`span`,{className:`tile-title`,children:e.title}),(0,I.jsxs)(`span`,{className:`tile-foot`,children:[(0,I.jsx)(`span`,{className:`tile-sub`,children:e.sub}),e.mark&&(0,I.jsx)(`span`,{className:`tile-mark mark-${e.markTone??`quiet`}`,children:e.mark})]})]})}function Na({label:e,tip:t,onClick:n,disabled:r}){return(0,I.jsx)(`button`,{type:`button`,className:`trash-btn`,"aria-label":e,title:t??e,onClick:n,disabled:r,children:(0,I.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M3 6h18`}),(0,I.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,I.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,I.jsx)(`path`,{d:`M10 11v6`}),(0,I.jsx)(`path`,{d:`M14 11v6`})]})})}function Pa({children:e}){return(0,I.jsx)(`div`,{className:`tiles`,children:e})}var Fa={command:[`M12 4a8 8 0 1 0 0 16a8 8 0 1 0 0-16z`,`M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6z`],board:[`M4 5h4v14H4z`,`M10 5h4v9h-4z`,`M16 5h4v6h-4z`],chat:[`M4 5h16v11H10l-5 4v-4H4z`],inbox:[`M4 13l2.2-8h11.6L20 13`,`M4 13v6h16v-6h-5a3 3 0 0 1-6 0z`],design:[`M4 20l1-4.5L15.5 5l3.5 3.5L8.5 19z`,`M13.5 7l3.5 3.5`],runs:[`M12 4a8 8 0 1 0 0 16a8 8 0 1 0 0-16z`,`M10.2 8.6v6.8l5.6-3.4z`],playtest:[`M7.5 8h9a4.5 4.5 0 0 1 4.5 4.5v.5a3 3 0 0 1-5.5 1.7L14.4 13H9.6l-1.1 1.7A3 3 0 0 1 3 13v-.5A4.5 4.5 0 0 1 7.5 8z`,`M8 10v3`,`M6.5 11.5h3`,`M16 10.5h.01`,`M17.5 12h.01`],ended:[`M4 5h16v4H4z`,`M5.5 9v10h13V9`,`M10 13h4`],agent:[`M12 3.5l7 3v5c0 4.3-2.9 7.6-7 9c-4.1-1.4-7-4.7-7-9v-5z`,`M9.5 12l2 2 3.5-4`],metrics:[`M5 19v-6`,`M10 19V6`,`M15 19v-9`,`M20 19V4`]},Ia={command:`c`,board:`b`,chat:`t`,inbox:`i`,design:`d`,runs:`r`,playtest:`p`,ended:`e`,agent:`a`,metrics:`m`},La={command:e=>`${e} wait for you`,chat:e=>`${e} ${e===1?`thread waits`:`threads wait`} for your answer`,inbox:e=>`Needs you: ${e}`},Ra=0;function za(e,t,n,r){if(e.ctrlKey||e.metaKey||e.altKey)return!1;if(Ra&&Date.now()-Ra<1200){if(Ra=0,e.key===`s`)return r(),!0;let i=t.find(t=>Ia[t]===e.key);return i&&n(i),!!i}return e.key===`g`&&(Ra=Date.now()),!1}function Ba(){let[e,t]=(0,v.useState)(()=>new Date);return(0,v.useEffect)(()=>{let e=setInterval(()=>t(new Date),15e3);return()=>clearInterval(e)},[]),e.toTimeString().slice(0,5)}function Va({entries:e,screen:t,go:n}){Ba();let[r,i]=(0,v.useState)(null),a=()=>i(null);return(0,I.jsxs)(`nav`,{className:`side`,"aria-label":`Screens`,children:[e.map(e=>{let r=e.screen===t,o=e.count>0?La[e.screen]?.(e.count)??``:``,s=Ia[e.screen]?`g ${Ia[e.screen]}`:``,c=t=>{let n=t.currentTarget.getBoundingClientRect();i({label:e.label,keys:s,note:o,top:Math.round(n.top+n.height/2)})};return(0,I.jsxs)(`button`,{className:`rail-btn`,"aria-current":r?`page`:void 0,"aria-label":`${e.label}${o?`, ${o}`:``}${s?`, keys ${s}`:``}`,onClick:()=>n(e.screen),onMouseEnter:c,onMouseLeave:a,onFocus:c,onBlur:a,children:[(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(Fa[e.screen]??[`M12 12h.01`]).map(e=>(0,I.jsx)(`path`,{d:e},e))}),e.count>0&&(0,I.jsx)(`span`,{className:`rail-count ${e.needs?`needs`:``}`,"aria-hidden":`true`,children:e.count>99?`99+`:e.count})]},e.screen)}),r&&(0,I.jsxs)(`div`,{className:`rail-tip`,role:`tooltip`,style:{top:r.top},children:[(0,I.jsxs)(`span`,{className:`rail-tip-head`,children:[(0,I.jsx)(`span`,{className:`rail-tip-label`,children:r.label}),r.keys&&(0,I.jsx)(`kbd`,{children:r.keys})]}),r.note&&(0,I.jsx)(`span`,{className:`rail-tip-note`,children:r.note})]})]})}function Ha({entries:e,screen:t,go:n}){let r=[`command`,`board`,`chat`,`inbox`],i=[...e.filter(e=>r.includes(e.screen)),{screen:`more`,label:`More`,count:0}],a=!r.includes(t);return(0,I.jsx)(`nav`,{className:`phone-nav`,"aria-label":`Screens`,children:i.map(e=>(0,I.jsxs)(`button`,{"aria-current":e.screen===t||e.screen===`more`&&a?`page`:void 0,onClick:()=>n(e.screen),children:[(0,I.jsx)(`span`,{className:`count ${e.count?e.needs?`needs`:``:`none`}`,children:e.count||`·`}),e.label]},e.screen))})}var Ua=6e5,Wa=e=>e.kind===`session`?`5h`:e.kind===`weekly_all`?`week`:`${e.scope?.model?.display_name??e.kind}${e.group===`weekly`?` week`:``}`,Ga=e=>e.kind===`session`?`5-hour window`:e.kind===`weekly_all`?`week, all models`:`${e.group===`weekly`?`week, `:``}${e.scope?.model?.display_name??e.kind}`,Ka=e=>e.resets_at?Date.parse(e.resets_at):NaN,qa=(e,t)=>{let n=new Date(e);return n.toDateString()===new Date(t).toDateString()?oi(e):n.getTime()-t<5184e5?`${n.toLocaleDateString(void 0,{weekday:`short`})} ${oi(e)}`:si(e,new Date(t))};function Ja(e,t,n=Date.now()){let r=Qa(t,n),i=e?.failed?[`The board's last /usage ask failed: ${e.failed.error}`]:[];if(!e?.at||!e.limits.length)return{...r,title:[r.title,...i].join(`
27
27
  `)};let a=e.limits.filter(e=>e.kind===`session`||e.kind===`weekly_all`||e.severity===`critical`),o=a.length?a:e.limits.slice(0,2),s=e=>!(Ka(e)<=n),c=e=>s(e)?`${Wa(e)} ${Math.round(e.percent)}%${e.resets_at&&!Number.isNaN(Ka(e))?` · ${qa(e.resets_at,n)}`:``}`:`${Wa(e)} ?`,l=n-Date.parse(e.at)>Ua||!!e.failed,u=o.map(e=>{let t=Math.max(0,Math.min(100,Math.round(e.percent))),r=e.resets_at&&!Number.isNaN(Ka(e))?qa(e.resets_at,n):``;return s(e)?{name:Wa(e),pct:`${t}%`,used:t,reset:r,warn:e.severity===`critical`||t>=100}:{name:Wa(e),pct:`?`,used:0,reset:``,warn:!1}}),d=!!r.rejected||e.limits.some(e=>s(e)&&(e.severity===`critical`||e.percent>=100)),f=e.limits.map(e=>`${Ga(e)}: ${Math.round(e.percent)}% used, resets ${e.resets_at&&!Number.isNaN(Ka(e))?ai(e.resets_at):`?`}${s(e)?e.severity===`critical`?` (critical)`:``:` (reset since the reading)`}`);return{text:`${o.map(c).join(` | `)}${l?` · old`:``}`,title:[...f,`read ${ai(e.at)}`,...i,`Click to read it now`].join(`
28
28
  `),rejected:d,segs:u,old:l}}var Ya=`No reading yet: a run records the usage limit when Claude reports it, which it does near a limit`,Xa=e=>`${Math.min(100,Math.max(0,Math.round((1-(e.utilization??0))*100)))}% left`,Za=e=>{let t=new Date(typeof e.resetsAt==`number`?e.resetsAt*1e3:NaN);return Number.isNaN(t.getTime())?null:t.toISOString()};function Qa(e,t=Date.now()){if(!e)return{text:`quota ?`,title:Ya};let{unifiedWindows:n,status:r,utilization:i,resetsAt:a}=e.info,o=Object.entries(n??{limit:{utilization:i??(r===`rejected`?1:void 0),resetsAt:a}}).filter(([,e])=>typeof e?.utilization==`number`);if(!o.length)return{text:`quota ?`,title:`The last reading names no share (read ${ai(e.at)})`};let s=o.filter(([,e])=>typeof e.resetsAt!=`number`||e.resetsAt*1e3>t).sort(([,e],[,t])=>(t.utilization??0)-(e.utilization??0)),c=`read ${ai(e.at)}`;if(!s.length)return{text:`quota ?`,title:`The last reading has reset since (${c}): ${Ya}`};let[,l]=s[0],u=s.map(([e,t])=>{let n=Za(t);return`${e}: ${Xa(t)}, resets ${n?ai(n):`?`}`}),d=Za(l),f=d?Date.parse(d)-t<864e5?oi(d):ai(d):`?`,p=r===`rejected`&&(typeof a!=`number`||a*1e3>t),m=p?[`The limit is reached: runs wait for the reset by themselves`]:[];return{text:`quota ${Xa(l)} · resets ${f}`,title:[...u,c,...m].join(`
29
29
  `),rejected:p}}function $a(e,t=Date.now()){let n=e?.info.resetsAt;return e?.info.status!==`rejected`||typeof n!=`number`||n*1e3<=t?null:new Date(n*1e3).toISOString()}var eo=e=>e===!0?`✔`:e===!1?`✘`:`?`,to=e=>e===!0?`met`:e===!1?`unmet`:`you judge`;function no(e,t){(0,v.useEffect)(()=>{if(!e)return;let n=e=>e.key===`Escape`&&!e.defaultPrevented&&t();return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t])}function ro({project:e,projects:t}){let[n,r]=(0,v.useState)(!1);return no(n,()=>r(!1)),(0,I.jsxs)(`div`,{className:`top-switch`,children:[(0,I.jsxs)(`button`,{className:`switch`,onClick:()=>r(!n),"aria-expanded":n,"aria-haspopup":`menu`,title:`Switch project · ${e.path}`,children:[(0,I.jsx)(`span`,{className:`switch-mark`,"aria-hidden":`true`,children:e.name.slice(0,2)}),(0,I.jsx)(`span`,{className:`switch-name`,children:e.name}),(0,I.jsx)(`span`,{className:`switch-caret`,"aria-hidden":`true`,children:`▾`})]}),n&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`menu-scrim`,onClick:()=>r(!1)}),(0,I.jsxs)(`div`,{className:`menu switch-menu`,role:`menu`,"aria-label":`Projects`,children:[t.list.map(n=>(0,I.jsxs)(`div`,{className:`switch-row`,children:[(0,I.jsxs)(`button`,{role:`menuitem`,className:`switch-pick`,onClick:()=>{r(!1),t.choose(n.name)},children:[(0,I.jsxs)(`span`,{className:`switch-pick-name`,children:[n.name===e.name?`● `:``,n.name]}),(0,I.jsx)(`span`,{className:`switch-path`,children:n.path})]}),(0,I.jsx)(Na,{label:`Take the project off the board`,tip:`Take it off the board; its files stay`,onClick:()=>{r(!1),t.remove(n)}})]},n.name)),(0,I.jsx)(`button`,{role:`menuitem`,className:`switch-add`,onClick:()=>{r(!1),t.add()},children:`+ Add a project…`})]})]})]})}function io({ctx:e}){let[t,n]=(0,v.useState)(!1);no(t,()=>n(!1));let{board:r}=e,i=r.domain.sections,a=!r.phase||`error`in r.phase?null:r.phase;if(!a){let e=r.phase&&r.phase.error;return e?(0,I.jsxs)(`span`,{role:`alert`,tabIndex:0,className:`h-chip h-chip-error`,title:`phase: ${e}`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`✘`}),(0,I.jsxs)(`span`,{className:`h-chip-cut`,children:[`phase: `,e]})]}):null}let o=Tr(r.domain,i.phase?.next),s=`${a.criteria.filter(e=>e.met===!0).length} of ${a.criteria.length} criteria met`;return(0,I.jsxs)(`div`,{className:`h-phase`,children:[(0,I.jsxs)(`button`,{className:`h-chip h-phase-btn ${t?`on`:``}`,"aria-expanded":t,"aria-haspopup":`dialog`,title:`Phase ${a.phase} · ${s} · its criteria and next phase`,onClick:()=>n(!t),children:[(0,I.jsx)(`span`,{className:`h-phase-name`,children:a.phase}),(0,I.jsx)(`span`,{className:`h-marks`,"aria-hidden":`true`,children:a.criteria.map(e=>(0,I.jsx)(`span`,{className:`met-${String(e.met)}`,children:eo(e.met)},e.name))}),(0,I.jsxs)(`span`,{className:`h-crit-sum`,children:[`· `,s]}),(0,I.jsx)(`span`,{className:`h-caret`,"aria-hidden":`true`,children:`▾`})]}),t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`menu-scrim`,onClick:()=>n(!1)}),(0,I.jsxs)(`div`,{className:`menu h-phase-menu`,role:`dialog`,"aria-label":`Phase ${a.phase}`,children:[(0,I.jsxs)(`span`,{className:`h-menu-head`,children:[`Phase `,a.phase,` · exit criteria`]}),a.criteria.map(e=>(0,I.jsxs)(`div`,{className:`h-crit met-${String(e.met)}`,children:[(0,I.jsx)(`b`,{"aria-hidden":`true`,children:eo(e.met)}),(0,I.jsxs)(`span`,{className:`h-crit-name`,children:[e.name,` `,(0,I.jsxs)(`span`,{className:`h-crit-state`,children:[`· `,to(e.met)]})]}),(0,I.jsx)(`span`,{}),(0,I.jsx)(`span`,{className:`h-crit-tip`,children:e.detail})]},e.name)),a.next&&o&&(0,I.jsxs)(`button`,{className:`btn-line`,title:o.help??`Opens the phase form`,onClick:()=>{n(!1),o&&e.openMove({title:`Phase ${a.phase} → ${a.next}`,move:{...o,fields:o.fields.map(e=>e.excuses===`phase`?{...e,required:!a.ready}:e)}})},children:[`next phase → `,a.next]})]})]})]})}function ao({ctx:e}){let{board:t}=e,n=t.runs?.autopilot;if(!n)return null;let r=n.stop,i=n.on?r?.kind===`play`?`play`:r?`warn`:`run`:`off`,a=r?r.text:n.on?`taking ${t.build_milestone??`the next milestone`}: it runs the next item itself`:`nothing starts by itself`;return(0,I.jsxs)(`button`,{className:`h-chip h-ap ap-${i}`,"aria-pressed":n.on,title:(n.on?`The autopilot starts the runs by itself and stops when a milestone is built for you to play. An agent never starts a run.`:`The autopilot is off: runs start when you run them.`)+(r?`\n\nNow: ${r.text}`:``)+`\n\nClick to turn it ${n.on?`off`:`on`}; kept in queue.json.`,onClick:()=>void e.setAutopilot(!n.on),children:[(0,I.jsxs)(`span`,{className:`h-ap-label`,children:[(0,I.jsx)(`span`,{className:`h-ap-mark`,"aria-hidden":`true`,children:n.on?`⟳`:`○`}),n.on?`autopilot`:`autopilot off`]}),(0,I.jsx)(`span`,{className:`h-ap-why`,children:a})]})}function oo({ctx:e}){let{board:t}=e,n=t.milestones??[];if(t.build_milestone===void 0||!n.length)return null;let r=e=>n.find(t=>t.name===e)?.goal??``,i=t.build_milestone,a=t.play_milestone;return(0,I.jsxs)(`button`,{className:`h-chip h-ms`,title:[i?`building ${i}: ${r(i)}`:`every milestone is built`,a?`play ${a}: ${r(a)} · Playtest has it`:``].filter(Boolean).join(`
@@ -73,16 +73,22 @@ Error generating stack: `+e.message+`
73
73
  `)}\n\n`}function R_(e,t){return e?`${e}${e.endsWith(`
74
74
  `)?``:`
75
75
  `}${t}`:t}function z_(e){let t=e.split(`
76
- `),n=t.pop()??``,r=[];for(let e of t)if(e.trim())try{let t=JSON.parse(e);t&&typeof t.type==`string`&&r.push(t)}catch{}return{events:r,rest:n}}var B_=` (Recommended)`;function V_(e){let t={live:!1,phase:`idle`,ctx:void 0,bg:[],cost:0,limitUntil:null,waitKind:null,waitAt:null,everStarted:!1,endedIdle:!1,freshQueued:!1},n=0,r=!1,i=new Set;for(let a of e)switch(a.type===`turn`?r=!0:([`session`,`working`,`read`,`agent`].includes(a.type)||a.type===`say`&&a.by===`operator`)&&(r=!1),a.type){case`session`:t.live=!0,t.everStarted=!0,t.endedIdle=!1,t.phase=`ready`,n=0,t.limitUntil=null,i.clear(),a.kind===`handoff`&&(t.ctx=0,t.freshQueued=!1);break;case`session_end`:t.live=!1,t.cost+=a.cost_usd??n,n=0,t.phase=a.code===`idle`?`idle`:`ended`,t.endedIdle=a.code===`idle`,t.bg=[],t.freshQueued=!1,i.clear();break;case`limit`:t.phase=`limit`,t.limitUntil=a.until;break;case`closed`:t.live=!1,t.phase=`ended`,t.endedIdle=!1,t.limitUntil=null,t.bg=[],t.freshQueued=!1,i.clear();break;case`working`:case`read`:case`agent`:t.live&&t.phase!==`limit`&&(t.phase=`working`);break;case`say`:a.by===`operator`&&(t.phase===`waiting`||t.phase===`ready`)&&(t.phase=`working`);break;case`waiting`:t.phase=`waiting`,t.waitKind=a.kind,t.waitAt=a.at;break;case`question`:case`approval`:i.add(a.request_id);break;case`answer`:case`allowed`:case`denied`:case`dropped`:a.request_id&&i.delete(a.request_id),t.phase===`waiting`&&t.waitKind===`card`&&!i.size&&(t.phase=`working`);break;case`timeout`:a.kind===`card`&&i.clear();break;case`interrupt`:t.phase=`working`;break;case`turn`:n=a.total_cost_usd??n,a.context_pct!==void 0&&(t.ctx=a.context_pct);break;case`context`:t.ctx=a.context_pct;break;case`background`:t.bg=a.tasks??[];break;case`handoff`:t.freshQueued=!!(a.error&&t.bg.length)}return t.live&&(t.cost+=n),t.phase===`waiting`&&t.waitKind===`text`&&t.bg.length&&(t.phase=`background`),t.phase===`working`&&r&&t.bg.length&&(t.phase=`background`),t}function H_(e){let t=new Map;for(let n of e)n.type===`question`||n.type===`approval`?t.set(n.request_id,n):n.type===`answer`||n.type===`allowed`||n.type===`dropped`||n.type===`denied`&&n.request_id?t.delete(n.request_id):(n.type===`timeout`&&n.kind===`card`||n.type===`session_end`||n.type===`session`||n.type===`closed`)&&t.clear();return[...t.values()][0]??null}function U_(e){let t=-1;return e.forEach((e,n)=>{e.type===`session`&&e.kind===`handoff`&&(t=n)}),t<0||e.slice(t).some(e=>e.type===`say`&&e.by===`operator`)}var W_={edit:`edit`,shell:`shell`,read:`read`,search:`search`,web:`web`,mcp:`mcp`,skill:`skill`,subagent:`subagent`,other:`other`},G_={operator:`denied by you`,rule:`denied by a deny rule of the project`,timeout:`denied: no answer in time`,engine:`refused by the center itself`},K_=e=>`$${(e??0).toFixed(2)}`,q_=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toTimeString().slice(0,5)},J_=e=>e.kind===`approval`&&e.state!==`waiting`||e.kind===`refused`||e.kind===`line`&&!!e.tech,Y_=e=>e?q_(e):`?`;function X_(e,{talk:t,answerMin:n}){let r=[],i=new Map,a=new Map,o=new Map,s=V_(e),c=0,l=null,u=!1,d=null,f=[],p=(e,t,n,i=null,a={})=>r.push({kind:`line`,at:e.at,mark:t,text:n,tone:i,...a}),m=()=>{for(let e of a.values())e.state===`waiting`&&(e.state=`dropped`,e.dropWhy=`the session closed`)};return e.forEach((h,g)=>{switch(h.type){case`session`:{c++,m();let e=h.model!==void 0||h.effort!==void 0?`model ${h.model??`default`}, effort ${h.effort??`default`}`:null,n=e&&(d===null?h.model||h.effort:e!==d)?` · on ${e}`:``;d=e??d,h.kind===`handoff`?(l=null,p(h,`↻`,(t?`a fresh agent goes on from the summary`:`fresh session · it goes on from the Handoff in the plan`)+n,`running`)):h.kind===`resume`?p(h,`▸`,(t?u?`agent started again after the reset · it remembers the earlier talk`:`agent started again · it remembers the earlier talk`:`session resumed · it remembers the talk`)+n,`running`):p(h,`▸`,(t?`agent started`:`run session started`)+n,`running`);break}case`session_end`:m(),f=[],h.code===`idle`?p(h,`■`,`agent closed after ${n} min with no input · not an error: your next message starts it again`):h.limit_resets?p(h,`■`,`${t?`agent closed at once at the usage limit`:`session ended at the usage limit`} · resets ${h.limit_resets} · ${K_(h.cost_usd)}`,null,{mono:!0}):h.code===`handoff`?p(h,`■`,`session ended for the handoff · ${K_(h.cost_usd)}`,null,{mono:!0}):h.code===`stopped`?p(h,`■`,`session stopped · ${K_(h.cost_usd)}`,null,{mono:!0}):p(h,`■`,`${t&&typeof h.code==`number`?`agent ended (exit ${h.code})`:t?`agent ended`:`session ended`} · ${K_(h.cost_usd)}`,null,{mono:!0});break;case`closed`:{u=!1,m(),f=[];let e=h.dropped?` · ${h.dropped===1?`1 message`:`${h.dropped} messages`} not sent`:``;p(h,`■`,`agent closed by you, with all it started · your next message resumes the talk${e}`);break}case`limit`:{u=!0;let e=s.phase===`limit`&&s.limitUntil===h.until,n=t?` · the agent starts again by itself after the reset and finishes the cut reply. Until then only a message is taken: Stop, card answers and fresh agent are off; close agent ends the wait`:` · the session goes on by itself; a message sent now reaches the agent after the reset`;p(h,`◷`,`limit: resumes ${Y_(h.until)}${e?n:``}`,`neutral`,{box:e,tip:`The usage limit is one for the account. It waits for the reset by itself.`});break}case`say`:if(h.by===`operator`||h.by===`timeout`){let e={kind:`me`,at:h.at,text:h.text,images:h.images??[],byTimeout:h.by===`timeout`,n:h.n,status:h.by===`timeout`?`sent by the timeout: no answer came in ${n} min`:h.retry?`sent again after a crash: it may be a duplicate`:s.phase===`limit`?`accepted · reaches the agent after the reset`:`sent`};i.set(`${c}:${h.n}`,e),r.push(e)}else h.by===`run`?p(h,`›`,`run prompt: ${h.text}`,null,{mono:!0}):l?l.tip=`The center asked the agent: ${h.text}`:t&&u?(u=!1,p(h,`›`,`the center asked the agent after the reset: “${h.text}” · its next text answers this`,null,{box:!0,tip:`say by: engine — the center's own words to the agent`})):p(h,`·`,`the center asked the agent for a summary`,null,{tip:h.text});break;case`read`:{let e=i.get(`${c}:${h.n}`);e&&!e.byTimeout&&(e.status=`${e.status.startsWith(`sent again`)?`sent again after a crash · `:``}${h.assumed?`taken as read: no echo came`:`read ${q_(h.at)}`}`);break}case`agent`:/hit your (session )?limit/i.test(h.text)?r.push({kind:`claude`,at:h.at,text:h.text}):l?l.summary=l.summary?`${l.summary}\n\n${h.text}`:h.text:r.push({kind:`agent`,at:h.at,text:h.text});break;case`question`:{let e={kind:`question`,at:h.at,id:h.request_id,state:`waiting`,questions:h.questions.map(e=>({...e,options:(e.options??[]).map(e=>({raw:e.label,label:e.label.endsWith(` (Recommended)`)?e.label.slice(0,-14):e.label,rec:e.label.endsWith(B_),description:e.description}))}))};a.set(h.request_id,e),o.set(h.request_id,g),r.push(e);break}case`answer`:{let e=a.get(h.request_id);e?.kind===`question`&&(e.state=h.by===`timeout`?`timeout`:`answered`,e.answers=h.answers);break}case`dropped`:{let t=a.get(h.request_id);if(!t)break;let n=e.slice(o.get(h.request_id)??0,g);t.state=`dropped`,t.dropWhy=n.some(e=>e.type===`interrupt`)?`your Stop ended the turn`:n.some(e=>e.type===`session_end`)?`the session closed`:`the turn ended`;break}case`approval`:{let e={kind:`approval`,at:h.at,id:h.request_id,tool:h.tool,what:W_[h.kind]??h.kind,title:h.title,reason:h.reason,always:h.always,...h.always&&h.always_wide?{wide:!0}:{},state:`waiting`};a.set(h.request_id,e),r.push(e);break}case`allowed`:{if(h.by===`yolo`){r.push({kind:`approval`,at:h.at,id:h.request_id,tool:h.tool,what:W_[h.kind]??h.kind,title:h.title,reason:h.reason,state:`auto`});break}let t=a.get(h.request_id);t?.kind===`approval`&&(t.state=h.always?`always`:`once`,t.rule=h.rule??t.always,t.notSaved=!h.always&&!!t.always&&e.slice(Math.max(0,g-2),g).some(e=>e.type===`error`&&e.text.startsWith(`the rule ${t.always} was not saved`)));break}case`run_end`:r.push({kind:`run_end`,at:h.at,end:h});break;case`denied`:{let e=h.request_id?a.get(h.request_id):void 0;e?.kind===`approval`?(e.state=`denied`,e.deniedBy=h.by):h.by===`engine`&&!t?h.tool===`AskUserQuestion`?p(h,`✕`,`question card refused by the center: this run asks nothing (answer time 0)`,`warn`,{box:!0,tech:{tool:`question`,title:`AskUserQuestion`,out:`refused by the center: this run asks nothing`,tone:`warn`},tip:`chat.answer_timeout_min is 0: the session asks no question`}):p(h,`✕`,`${h.tool||`the call`} refused by the center: no one approves a call in a run`,`warn`,{box:!0,tech:{tool:h.kind??(h.tool||`call`),title:h.title||(h.kind?h.tool:``),out:`refused by the center: no one approves a call in a run`,tone:`warn`},mono:!0,tip:`A run asks no permission: its deny rules decide`}):h.by===`engine`?p(h,`✕`,`${h.tool}${h.title?` ${h.title}`:``} — refused by the center: ${h.reason??``}`,`warn`,{box:!0,tech:{tool:h.kind??h.tool,title:h.title||(h.kind?h.tool:``),out:`refused by the center: a main run works here`,tone:`warn`},mono:!0,tip:`The center refused it by itself, with no card: a main run works in the same folder.`}):h.by===`rule`?r.push({kind:`refused`,at:h.at,tool:h.tool,what:h.kind??h.tool,title:h.title??``,why:h.description??``,rule:h.rule,group:h.group,reason:h.reason??``}):p(h,`✕`,`${h.tool}${h.title?` ${h.title}`:``} — ${G_[h.by??``]??`denied`}${h.reason?`: ${h.reason}`:``}`,null,{mono:!0,tech:{tool:h.kind??h.tool,title:h.title||(h.kind?h.tool:``),out:G_[h.by??``]??`denied`}});break}case`timeout`:if(h.kind===`text`)p(h,`◷`,`no answer in ${n} min: the default answer goes to the agent`);else for(let e of a.values())e.state===`waiting`&&(e.kind===`approval`?(e.state=`denied`,e.deniedBy=`timeout`):e.state=`timeout`);break;case`interrupt`:p(h,`‖`,t?`you pressed Stop: the step stopped · the agent waits for your message and closes after ${n} min, as after any reply`:`you pressed Stop: the step stopped, the session stays open`,`neutral`);break;case`waiting`:h.kind===`stop`&&!t&&p(h,`·`,`the agent waits for your message; after a Stop no default answer comes`);break;case`error`:p(h,`✕`,h.text,`error`,{box:!0,mono:!0,tip:`Input that reached no one`});break;case`background`:f=h.tasks??[],p(h,`⟳`,h.tasks?.length?`in the background: ${h.tasks.map(e=>e.description).join(`, `)} · no timer runs, no default answer comes`:`background tasks done`,`running`);break;case`compacted`:p(h,`↧`,`the agent compacted its context by itself`);break;case`handoff`:{if(h.error){let e=l;e?(e.failed=!0,l=null,p(h,`✕`,`the summary failed: ${h.error} · the same agent goes on`,`warn`,{box:!0,tip:`The fresh agent did not start. The talk goes on with the agent you had.`})):f.length?p(h,`◷`,`fresh agent queued: ${h.error} · once the background tasks end it takes over by itself, with no second click`,`neutral`,{box:!0,tip:`Not an error: the summary turn waits for the background tasks`}):p(h,`↻`,`fresh agent: ${h.error} · the agent is a fresh one already and has not had your message: nothing changes`,`neutral`,{box:!0,tip:`Not an error: the press changes nothing`});break}let e=typeof h.pct==`number`?` · context ${h.pct}%`:h.tokens?` · ${Math.round(h.tokens/1e3)}k tokens`:``;if(t){let t=h.by===`operator`?`by you, with fresh agent`:h.by===`threshold`?`past the handoff share`:h.by===`compacted`?`after a compaction`:`handed over`;l={kind:`divider`,at:h.at,by:`${t}${e}`,summary:``,failed:!1},r.push(l)}else p(h,`↻`,`context handoff${typeof h.pct==`number`?` at ${h.pct}%`:``} · the agent writes its Handoff into the plan, a fresh session goes on`,`running`);break}case`proposal`:r.push({kind:`proposal`,at:h.at,id:h.id,move:h.move,fields:h.fields??{}});break;case`step`:{let e=`ok`in h?h.ok:null,t;if(h.step===`plan`)t=`plan converged in ${h.passes} passes`;else if(h.step===`move`)t=`${{submit:`submitted · waits for your verdict`,close:`closed`,block:`blocked`}[h.move]??h.move}${h.text?` · ${h.text}`:``}`;else{let n={dod:`checks (DoD)`,review:`review`,commit:`committed`}[h.step];t=h.step===`commit`&&e?`committed`:h.step===`review`&&e?`review done`:`${n}${e===!0?` green`:e===!1?` red`:`: result unknown · the check ran, its result could not be matched`}`,h.text&&(t+=` · ${h.text}`)}let n=h.step===`plan`;r.push({kind:`step`,at:h.at,mark:n||e===!0?`✔`:e===!1?`✘`:`?`,text:t,tone:n||e===!0?`ok`:e===!1?`error`:`neutral`,unknown:!n&&e===null});break}}}),r}function Z_(e,t,n){let r={};for(let i=0;i<e.length;i++){let a=(t[i]??[]).map(e=>e.endsWith(` (Recommended)`)?e.slice(0,-14):e),o=a.length?a.join(`, `):(n[i]??``).trim();if(!o)return null;r[e[i].question]=o}return r}function Q_(e,t,n){let r=e=>e.id?t.some(t=>t.type===`say`&&t.id===e.id):n>e.after,i=e=>t.slice(e.from).some(t=>t.type===`error`&&/ not sent: /.test(t.text)&&(!t.id||!e.id||t.id===e.id));return e.filter(e=>!r(e)&&!i(e))}var $_=`gcf-chat-tech`,ev=[`expanded`,`collapsed`,`hidden`];function tv(){try{let e=localStorage.getItem($_);return ev.includes(e)?e:`collapsed`}catch{return`collapsed`}}var nv=tv(),rv=new Set,iv=()=>{for(let e of rv)e()};typeof window<`u`&&window.addEventListener(`storage`,e=>{(e.key===$_||e.key===null)&&(nv=tv(),iv())});function av(e){nv=e;try{localStorage.setItem($_,e)}catch{}iv()}function ov(e){return rv.add(e),()=>{rv.delete(e)}}var sv=()=>(0,v.useSyncExternalStore)(ov,()=>nv),cv=!1,lv=new Set,uv=null,dv=0,fv=0,pv=()=>{for(let e of lv)e()};function mv(){let e=++dv;k.yolo().then(t=>{e<fv||(fv=e,cv=t.on,pv())}).catch(()=>{})}function hv(e){if(lv.add(e),!uv){let e=ne(e=>{e.type===`yolo`&&mv()}),t=P(e=>{e&&mv()});uv=()=>{e(),t()},mv()}return()=>{lv.delete(e),lv.size||(uv?.(),uv=null)}}var gv=()=>(0,v.useSyncExternalStore)(hv,()=>cv);async function _v(e){let t=++dv,n=await k.setYolo(e);t<fv||(fv=t,cv=n.on,pv())}var vv=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],yv=10,bv=5242500,xv=7340032,Sv=`png, jpeg, gif or webp · up to 10 a message, 5 MB each, about 7 MB in all with the files`,Cv=/^(https?:|mailto:)/i,wv=[r_,om],Tv={a:({node:e,href:t,children:n})=>t&&Cv.test(t)?(0,I.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,children:n}):(0,I.jsx)(`span`,{children:n}),input:({node:e,type:t,checked:n})=>t===`checkbox`?(0,I.jsx)(`span`,{className:`c-task ${n?`done`:``}`,"aria-label":n?`done`:`not done`,children:n?`☑`:`☐`}):null,img:({src:e,alt:t})=>typeof e==`string`&&Cv.test(e)?(0,I.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:t||e}):(0,I.jsx)(`span`,{children:t}),pre:({node:e})=>(0,I.jsx)(I_,{text:N_(e),lang:F_(e)})},Ev=({text:e})=>(0,I.jsx)(Jp,{remarkPlugins:wv,components:Tv,children:e}),Dv=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toTimeString().slice(0,5)},Ov=e=>`${(e/1024/1024).toFixed(1)} MB`,kv=e=>`$${e.toFixed(2)}`,Av=(...e)=>(0,I.jsx)(`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:e.map(e=>(0,I.jsx)(`path`,{d:e},e))}),jv={file:Av(`M20 11.5l-8.2 8.2a5 5 0 0 1-7.1-7.1l8.6-8.6a3.4 3.4 0 0 1 4.8 4.8l-8.6 8.6a1.7 1.7 0 0 1-2.4-2.4l7.9-7.9`),picture:Av(`M5.5 4.5h13a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2v-11a2 2 0 0 1 2-2z`,`M10.6 10a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0z`,`M20.5 16l-5-5-8 8.5`),fresh:Av(`M20 12a8 8 0 1 1-2.6-5.9`,`M20 4v5h-5`),stop:(0,I.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,I.jsx)(`rect`,{x:`5`,y:`5`,width:`14`,height:`14`,rx:`2`,fill:`currentColor`})}),close:Av(`M6 6l12 12M18 6L6 18`),send:Av(`M21 3L10.5 13.5`,`M21 3l-6.5 18-4-7.5L3 9.5z`)};function Mv(e){let[t,n]=(0,v.useState)([]);return(0,v.useEffect)(()=>{if(n([]),!e)return;let t=``,r=!0;return M(e,()=>{t=``,r=!0},e=>{let i=z_(t+e);t=i.rest;let a=r;r=!1,n(e=>a?i.events:[...e,...i.events])})},[e]),t}var Nv=15e3;function Pv(e){let[t,n]=(0,v.useState)(Date.now());return(0,v.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),t}function Fv({from:e,minutes:t}){let n=Pv(!0),r=Math.max(0,Math.round((Date.parse(e)+t*6e4-n)/1e3));return(0,I.jsxs)(`span`,{"aria-live":`off`,className:`mono`,children:[String(Math.floor(r/60)).padStart(2,`0`),`:`,String(r%60).padStart(2,`0`)]})}var Iv=(e,t)=>{let n=e.board.chat?.answer_timeout_min;return t?n||15:n??15};function Lv({e,part:t,minutes:n,live:r}){let[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(!1),u=r.phase===`limit`,d=e.state===`waiting`&&!u,f=Z_(e.questions,i,o),p=async()=>{f&&(l(!0),await t.send({type:`answer`,request_id:e.id,answers:f}).catch(()=>{}),l(!1))},m=e.state===`answered`?`answered by you`:e.state===`timeout`?`no answer in ${n} min: ${e.questions.every(e=>e.options.some(e=>e.rec))?`the recommended option was taken`:`the default text went to the agent`}`:e.state===`dropped`?`withdrawn: ${e.dropWhy??`the turn ended`}`:u?`off: no card is open during the limit wait`:`waiting for you · the default goes in`;return(0,I.jsxs)(`div`,{role:`group`,"aria-label":`Question from the agent`,className:`c-card ${d?`pending`:``}`,children:[e.questions.map((t,n)=>{let r=e.answers?.[t.question]??``,c=r?r.split(/,\s*/):[],l=i[n]??[],u=(e,t)=>d?l.includes(e):c.includes(t)||c.includes(e),f=r&&!t.options.some(e=>u(e.raw,e.label))?`${e.state===`timeout`?`default text`:`your answer`}: ${r}`:``;return(0,I.jsxs)(`div`,{role:`group`,"aria-label":t.question,className:`c-q`,children:[(0,I.jsxs)(`div`,{className:`c-q-head`,children:[t.header&&(0,I.jsxs)(`span`,{className:`c-q-tag`,children:[`? `,t.header]}),(0,I.jsx)(`span`,{className:`dim small`,children:t.multiSelect?`pick any`:`pick one`}),(0,I.jsx)(`span`,{className:`c-time`,children:Dv(e.at)})]}),(0,I.jsx)(`div`,{className:`c-q-text`,children:t.question}),(0,I.jsx)(`div`,{className:`c-q-options`,children:t.options.map(e=>{let r=u(e.raw,e.label);return(0,I.jsxs)(`button`,{role:t.multiSelect?`checkbox`:`radio`,"aria-checked":r,disabled:!d,className:r?d?`on`:`done`:``,onClick:()=>a(r=>{let i=r[n]??[];return{...r,[n]:t.multiSelect?i.includes(e.raw)?i.filter(t=>t!==e.raw):[...i,e.raw]:i[0]===e.raw?[]:[e.raw]}}),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:r?t.multiSelect?`☑`:`●`:t.multiSelect?`☐`:`○`}),(0,I.jsxs)(`span`,{children:[(0,I.jsxs)(`span`,{className:`c-q-label`,children:[e.label,e.rec&&(0,I.jsx)(`span`,{className:`c-rec`,title:`The agent's default: the timeout takes it`,children:`recommended`})]}),e.description&&(0,I.jsx)(`small`,{children:e.description})]})]},e.raw)})}),d&&(0,I.jsx)(`input`,{className:`input`,"aria-label":`Your own answer to: ${t.question}`,value:o[n]??``,onChange:e=>s({...o,[n]:e.target.value}),placeholder:`Or answer in your own words`}),f&&(0,I.jsxs)(`span`,{className:`c-q-shown`,children:[`✔ `,f]})]},n)}),d&&(0,I.jsxs)(`div`,{className:`c-submit`,children:[(0,I.jsx)(`button`,{className:`btn-primary`,disabled:!f||c,onClick:()=>void p(),children:e.questions.length>1?`Submit answers`:`Submit answer`}),(0,I.jsx)(`span`,{className:`dim small`,children:e.questions.length>1?`One answer goes for the whole card; it cannot be taken back.`:`It cannot be taken back.`})]}),(0,I.jsxs)(`span`,{className:`c-state ${d?`needs`:``}`,children:[m,` `,d&&(0,I.jsx)(Fv,{from:r.waitAt??e.at,minutes:n})]})]})}function Rv({e,part:t,minutes:n,live:r}){let[i,a]=(0,v.useState)(!1),o=e.state===`waiting`&&r.phase!==`limit`,s=async e=>{a(!0),await t.send(e).catch(()=>{}),a(!1)},c=e.state===`auto`?`✔ ran without asking (YOLO)`:e.state===`once`?e.notSaved?`✔ allowed once · the rule was not saved`:`✔ allowed once by you`:e.state===`always`?`✔ allowed always · rule saved for this machine and project: ${e.rule??``}`:e.state===`denied`?`✕ ${G_[e.deniedBy??``]??`denied`}`:e.state===`dropped`?`withdrawn: ${e.dropWhy??`the turn ended`}`:r.phase===`limit`?`off: no card is open during the limit wait`:`waiting for you · denied by itself in`,l=o?`needs`:e.state===`denied`||e.state===`dropped`||e.notSaved?``:`ok`;return(0,I.jsxs)(`div`,{role:`group`,"aria-label":e.state===`auto`?`A call YOLO ran`:`Permission asked by the agent`,className:`c-card ${o?`pending`:``}`,children:[(0,I.jsxs)(`div`,{className:`c-q-head`,children:[(0,I.jsx)(`span`,{className:`c-kind`,title:`The kind of tool call`,children:e.what}),(0,I.jsx)(`span`,{className:`c-ask`,children:e.state===`auto`?`The agent ran`:`The agent asks to run`}),(0,I.jsx)(`span`,{className:`c-time`,children:Dv(e.at)})]}),(0,I.jsx)(`code`,{className:`c-call`,children:e.title}),e.reason&&(0,I.jsxs)(`span`,{className:`c-reason`,children:[`Why: `,e.reason]}),o&&(0,I.jsxs)(`div`,{className:`c-acts`,children:[(0,I.jsx)(`button`,{className:`btn-primary`,disabled:i,onClick:()=>void s({type:`allow`,request_id:e.id}),children:`Allow once`}),e.always&&(0,I.jsx)(`button`,{className:`btn`,disabled:i,title:e.wide?`Allows every call of ${e.always}, with any arguments, in every session of this project on this machine (.claude/settings.local.json)`:`Saves the rule ${e.always} for this machine and this project (.claude/settings.local.json)`,onClick:()=>void s({type:`allow`,request_id:e.id,always:!0}),children:`Always`}),(0,I.jsx)(`button`,{className:`btn-line`,disabled:i,onClick:()=>void s({type:`deny`,request_id:e.id}),children:`Deny`})]}),e.always&&(0,I.jsxs)(`span`,{className:`c-rule`,children:[`always would save: `,e.always,e.wide&&` · every call of this tool, any arguments, in every session of this project`]}),!e.always&&o&&(0,I.jsx)(`span`,{className:`dim small`,children:`no "always" for an edit, a git command, a framework move, a whole tool or server, or a rule too broad`}),(0,I.jsxs)(`span`,{className:`c-state ${l}`,children:[c,` `,o&&(0,I.jsx)(Fv,{from:r.waitAt??e.at,minutes:n})]})]})}function zv({ctx:e,e:t}){let n=t.group?e.board.agent?.groups.find(e=>e.id===t.group):void 0,r=!t.group&&(e.board.agent?.extra??[]).some(e=>(e.pattern?`${e.kind}: ${e.pattern}`:e.kind)===t.rule),i=n?`the deny group ${n.id} (${n.label})`:t.group?`the deny group ${t.group}`:r?`your own deny rule`:`a deny rule of its settings`,a=n&&!n.on?`The group is off now: the next session may do it.`:t.group?`To let the agent do it, turn the group off in Agent permissions: the next session runs without its rules.`:r?`To let the agent do it, remove your rule in Agent permissions: the next session runs without it.`:`The deny rules of the project are in Agent permissions; a change holds from the next session.`;return(0,I.jsxs)(`div`,{role:`group`,"aria-label":`A call a deny rule refused`,className:`c-card c-deny`,children:[(0,I.jsxs)(`div`,{className:`c-q-head`,children:[(0,I.jsxs)(`span`,{className:`c-deny-tool`,title:`The tool the agent called`,children:[`✕ `,t.tool]}),(0,I.jsx)(`span`,{className:`c-ask`,children:`A deny rule refused the agent`}),(0,I.jsx)(`span`,{className:`c-time`,children:Dv(t.at)})]}),(0,I.jsx)(`code`,{className:`c-call`,children:t.title||t.reason}),t.why&&(0,I.jsxs)(`span`,{className:`c-reason`,children:[`It wanted it for: `,(0,I.jsx)(`span`,{className:`c-deny-why`,children:t.why})]}),(0,I.jsxs)(`span`,{className:`c-rule`,children:[`refused by `,i,t.rule?` · rule ${t.rule}`:``]}),(0,I.jsxs)(`div`,{className:`c-deny-foot`,children:[(0,I.jsxs)(`span`,{className:`c-deny-todo ${n&&!n.on?`off`:``}`,children:[`The agent decides by itself how to go on without it. `,a]}),(0,I.jsx)(`button`,{className:`btn`,title:`Opens the Agent screen: its deny groups and rules`,onClick:()=>e.go(`agent`),children:`Agent permissions`})]})]})}function Bv({ctx:e,e:t,part:n}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),l=n.proposals?.find(e=>e.id===t.id),u=r&&(!l||l.state===`offered`)?{...l,id:t.id,state:`accepting`}:l??{id:t.id,state:`offered`},d=_i(e.board.domain.moves,t.move)??t.move,f=Tr(e.board.domain,d),p=f&&!f.fields.some(e=>e.key===`id`)&&typeof t.fields.id==`string`?t.fields.id:void 0,m=p?e.board.items.find(e=>e.id===p):void 0,h=p&&!m?e.board.inbox?.find(e=>e.id===p):void 0,g=d===e.board.domain.sections.questions?.answer,_=p&&g?(e.board.questions??[]).find(e=>e.id===p):void 0,y=u.question??_?.question,b=e=>f?.fields.find(t=>t.key===e)?.label??e,x=d===e.board.domain.new_item,S=(x?[`note`]:[`note`,`reason`,`text`]).find(e=>typeof t.fields[e]==`string`&&t.fields[e]),C=Object.entries(t.fields).filter(([e])=>e!==`title`&&e!==S&&!(p&&e===`id`));for(let e of f?.fields??[])e.kind===`remove`&&t.fields[e.key]===void 0&&C.push([e.key,`by the rule`,!0]);let w=S?t.fields[S]:void 0,T={...f?Fr(f.fields):{},...t.fields},E={talk:n.talk,id:t.id},D=x?`New item`:d,O=p&&!g?`${D} ${p}`:D,k=x?`New item`:g?`Answer to a decision`:Hv(d,f?.label??d),A=u.state===`refused`&&u.refusal?u.refusal:void 0,[ee,j]=(0,v.useState)(!1),M=(0,v.useRef)(null),te=()=>{j(!1),setTimeout(()=>M.current?.focus(),0)},N=async(t=!1)=>{f&&(f.danger&&!t?j(!0):(j(!1),i(!0),o(``),c(!1),await e.move({cmd:f.cmd,...p&&{id:p},...Nr(f.fields,T),proposal:E}),i(!1)))},ne=()=>f&&e.openMove({title:O,id:p,move:f,values:T,body:x?`Filled in from the agent's proposal: every field it proposed. Created and committed at once.`:`Filled in from the agent's proposal: every field it proposed.`,extra:{proposal:E}}),P={offered:`needs`,accepting:`running`,accepted:`ok`,refused:`error`}[u.state],F=x?{offered:`proposed`,accepting:`creating…`,accepted:`created`,refused:`refused`}:{offered:`proposed`,accepting:`making…`,accepted:`made`,refused:`refused`},re={offered:`●`,accepting:`◌`,accepted:`✔`,refused:`✘`}[u.state],L=m?m.running?`running`:m.status:``,R=L===`running`?`running`:e.board.domain.columns.find(e=>e.status===L)?.label??L,z=f?.label??d,ie=u.state===`refused`&&!s;return(0,I.jsxs)(`div`,{role:`group`,"aria-label":`${O} proposed by the agent`,className:`c-card prop ${u.state}`,children:[(0,I.jsxs)(`div`,{className:`c-q-head`,children:[(0,I.jsx)(`span`,{className:`c-prop-what`,title:`The move it proposes: ${d}`,children:k}),(0,I.jsxs)(`span`,{className:`c-prop-state tone-${P}`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:re}),F[u.state]]}),(0,I.jsx)(`span`,{className:`c-time`,children:Dv(t.at)})]}),p&&!g&&(0,I.jsxs)(`div`,{className:`c-prop-target`,children:[(0,I.jsxs)(`div`,{className:`c-prop-target-row`,children:[m?(0,I.jsx)(`button`,{className:`link-btn mono c-prop-id`,title:`Open ${m.id}`,onClick:()=>e.openItem(m.id),children:m.id}):(0,I.jsx)(`span`,{className:`mono c-prop-id`,children:h?.id??p}),(0,I.jsx)(`span`,{className:`c-prop-title`,children:m?m.title:h?h.title??h.text.split(`
77
- `)[0]:``}),m&&u.state!==`accepted`&&(0,I.jsx)(`span`,{className:`badge tone-${L}`,title:`Its status now, read from the board`,children:R})]}),!m&&!h&&u.state!==`accepted`&&(0,I.jsxs)(`span`,{role:`note`,className:`c-prop-warn`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),p,` is not on the board`]}),m&&f&&u.state===`offered`&&!m.moves.includes(f.cmd)&&(0,I.jsxs)(`span`,{role:`note`,className:`c-prop-warn`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),`does not take `,z,` now: the framework will refuse it`]})]}),g&&(0,I.jsxs)(`div`,{className:`c-prop-target`,children:[(0,I.jsx)(`span`,{className:`c-prop-qhead`,children:`The question, as the board first read it`}),(0,I.jsx)(`span`,{className:`c-prop-title c-prop-question`,children:y??`the question is not on the board`}),_?.answer&&_.question===y&&u.state!==`accepted`&&(0,I.jsxs)(`span`,{role:`note`,className:`c-prop-warn`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),`answered already: `,_.answer]})]}),x&&typeof t.fields.title==`string`&&(0,I.jsx)(`span`,{className:`c-prop-title c-prop-new`,children:t.fields.title}),C.length>0&&(0,I.jsx)(`dl`,{className:`c-prop-fields`,children:C.map(([e,t,n])=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:b(e)}),(0,I.jsx)(`dd`,{className:n?`rule`:``,children:String(t)})]},e))}),typeof w==`string`&&w&&S&&(0,I.jsxs)(`div`,{className:`c-prop-note ${x?``:`quote`}`,children:[(0,I.jsx)(`span`,{children:b(S)}),(0,I.jsx)(`div`,{className:`md`,children:(0,I.jsx)(Ev,{text:w})})]}),u.state===`refused`&&s&&(0,I.jsx)(`div`,{role:`status`,className:`c-created`,children:`✔ its files under gcf/ are committed or put back · Try again makes the move`}),ie&&(0,I.jsxs)(`div`,{role:`alert`,className:`c-prop-error`,children:[(0,I.jsx)(`span`,{className:`c-prop-error-head`,children:a?`Commit refused`:`gcf refused it`}),(0,I.jsx)(`span`,{className:`c-prop-error-text`,children:a||u.error}),A&&(0,I.jsx)(__,{ctx:e,refusal:A,error:u.error??``,onError:o,onDone:()=>c(!0)},u.at??``)]}),ee&&f&&(u.state===`offered`||u.state===`refused`)&&(0,I.jsxs)(`div`,{role:`alertdialog`,"aria-label":`${z} ${p??``}?`,className:`c-prop-confirm`,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),te())},children:[(0,I.jsxs)(`span`,{children:[z,` `,p,`? `,f.help?`${f.help}.`:``,` It cannot be taken back from the chat.`]}),(0,I.jsxs)(`div`,{className:`c-acts`,children:[(0,I.jsxs)(`button`,{className:`btn-danger solid`,autoFocus:!0,onClick:()=>void N(!0),children:[`Yes, `,z]}),(0,I.jsx)(`button`,{className:`btn`,onClick:te,children:`Cancel`})]})]}),(u.state===`offered`||u.state===`refused`)&&f&&!ee&&(0,I.jsxs)(`div`,{className:`c-acts`,children:[(0,I.jsx)(`button`,{ref:M,className:f.danger?`btn-danger`:`btn-primary`,title:(f.danger?`Asks first. `:``)+`Runs the move as it is: every field above goes with it`,onClick:()=>void N(),children:u.state===`refused`?`Try again`:x?`Create`:f.label}),(0,I.jsx)(`button`,{className:`btn`,title:`Opens the move's form, filled in`,onClick:ne,children:`Edit…`})]}),u.state===`accepting`&&(0,I.jsxs)(`span`,{className:`c-creating`,children:[(0,I.jsx)(`span`,{className:`dot pulse`,"aria-hidden":`true`}),x?`creating ${u.item??String(t.fields.id??`the item`)}`:O,`: the framework commits it`]}),u.state===`accepted`&&(0,I.jsxs)(`span`,{className:`c-created`,children:[`✔ `,x?`created`:`made: ${z}`,u.item&&(x?`: `:` `),g?(0,I.jsx)(`span`,{children:y??u.item}):u.item&&e.board.items.some(e=>e.id===u.item)?(0,I.jsx)(`button`,{className:`link-btn mono`,onClick:()=>e.openItem(u.item??``),children:u.item}):(0,I.jsx)(`span`,{className:`mono`,children:u.item})]})]})}var Vv={verdict:`Verdict`,decide:`Decision`,block:`Block`,unblock:`Unblock`,drop:`Drop`,depends:`Dependencies`};function Hv(e,t){let[n,r]=e.split(`:`),i=Vv[n];return i?r?`${i} · ${t}`:i:t}function Uv({ctx:e,e:t}){let{domain:n}=e.board,r=Tr(n,n.sections.inbox?.add),i=Tr(n,n.sections.questions?.answer),a=(e.board.questions??[]).filter(e=>e.class===`D1`&&!e.answer),o=t.text.split(`
78
- `)[0].slice(0,120);return(0,I.jsxs)(`div`,{className:`c-agent`,children:[(0,I.jsx)(`span`,{className:`sr`,children:`Agent:`}),(0,I.jsx)(`div`,{className:`c-bubble md`,children:(0,I.jsx)(Ev,{text:t.text})}),(0,I.jsxs)(`div`,{className:`c-agent-acts`,children:[n.new_item&&(0,I.jsx)(`button`,{onClick:()=>e.newItem({title:o,note:t.text}),children:`Create item from this`}),r&&(0,I.jsx)(`button`,{onClick:()=>e.openMove({title:`Add to the inbox`,move:r,values:{text:t.text,category:`idea`},body:`${r.help??``}. From the agent's message.`}),children:`Add to inbox`}),i&&a.length>0&&(0,I.jsx)(`button`,{onClick:()=>e.openMove({title:`Answer a decision with this`,move:{...i,fields:[{key:`id`,label:`Question`,kind:`choice`,required:!0,options:a.map(e=>({value:e.id,label:`${e.id} — ${(e.question??``).slice(0,70)}`}))},...i.fields]},values:{text:t.text},body:`The agent's message becomes your answer to an open decision. Edit it first if you like.`}),children:`Answer a decision`}),(0,I.jsx)(`span`,{className:`c-time`,children:Dv(t.at)})]})]})}function Wv({ctx:e,e:t,part:n}){let r=Tr(e.board.domain,`attach`);return(0,I.jsxs)(`div`,{className:`c-me`,children:[(0,I.jsx)(`span`,{className:`sr`,children:`You:`}),(0,I.jsxs)(`div`,{className:`c-bubble md`,children:[t.byTimeout&&(0,I.jsx)(`span`,{className:`c-default`,children:`default answer`}),t.text&&(0,I.jsx)(`div`,{className:`c-me-text`,children:(0,I.jsx)(Ev,{text:t.text})}),t.images.length>0&&(0,I.jsx)(`div`,{className:`c-imgs`,children:t.images.map(t=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`img`,{src:n.imageUrl(t),alt:t.split(`/`).pop()}),r&&(0,I.jsx)(`button`,{className:`c-attach`,title:`Commit this picture into an item's attachments (gcf item attach)`,onClick:()=>e.openMove({title:`Attach to an item`,move:{...r,fields:[{key:`id`,label:`Item id`,kind:`text`,required:!0},...r.fields]},values:{id:n.item??``,file:n.imagePath(t)}}),children:`attach to item…`})]},t))})]}),(0,I.jsxs)(`span`,{className:`c-me-status`,children:[Dv(t.at),` · `,t.status]})]})}function Gv({ctx:e,part:t}){let n=t.events.findLast(e=>e.type===`run_end`)?.at,r=t.talk!==null,i=Iv(e,r),a=V_(t.events),o=r&&!e.talks.find(e=>e.id===t.talk)?.live,s=X_(t.events,{talk:r,answerMin:i}).map(e=>o&&(e.kind===`question`||e.kind===`approval`)&&e.state===`waiting`?{...e,state:`dropped`,dropWhy:`the agent ended without it`}:e),c=sv(),l=(r,o)=>{switch(r.kind){case`me`:return(0,I.jsx)(Wv,{ctx:e,e:r,part:t},o);case`agent`:return(0,I.jsx)(Uv,{ctx:e,e:r},o);case`claude`:return(0,I.jsxs)(`div`,{className:`c-claude`,title:`Claude's own limit message, as the agent's line`,children:[(0,I.jsxs)(`span`,{children:[`Claude: `,r.text]}),(0,I.jsx)(`span`,{className:`c-time`,children:Dv(r.at)})]},o);case`line`:return(0,I.jsxs)(`div`,{className:`c-line ${r.box?`box`:``} ${r.mono?`mono`:``} ${r.tone?`tone-${r.tone}`:``}`,title:r.tip,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:r.mark}),(0,I.jsx)(`span`,{children:r.text}),(0,I.jsx)(`span`,{className:`c-time`,children:Dv(r.at)})]},o);case`step`:return(0,I.jsxs)(`div`,{className:`c-step tone-${r.tone??`neutral`} ${r.unknown?`unknown`:``}`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:r.mark}),(0,I.jsx)(`span`,{children:r.text}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`c-time`,children:Dv(r.at)})]},o);case`question`:return(0,I.jsx)(Lv,{e:r,part:t,minutes:i,live:a},o);case`approval`:return(0,I.jsx)(Rv,{e:r,part:t,minutes:i,live:a},o);case`proposal`:return(0,I.jsx)(Bv,{ctx:e,e:r,part:t},o);case`refused`:return(0,I.jsx)(zv,{ctx:e,e:r},o);case`run_end`:return(0,I.jsx)(iy,{ctx:e,id:t.item??``,end:r.end,acts:r.at===n},o);case`divider`:return(0,I.jsxs)(`div`,{role:`separator`,"aria-label":`Talk handed to a fresh agent`,className:`c-div ${r.failed?`failed`:``}`,title:r.tip,children:[(0,I.jsxs)(`div`,{className:`c-div-head`,children:[r.failed?`✕ the summary failed · the same agent goes on`:`↻ talk handed to a fresh agent`,(0,I.jsxs)(`span`,{children:[`· `,r.by]}),(0,I.jsx)(`span`,{className:`c-time`,children:Dv(r.at)})]}),r.summary?(0,I.jsxs)(`div`,{className:`c-div-sum`,children:[(0,I.jsx)(`span`,{children:r.failed?`What the agent wrote before the summary failed (no fresh agent starts from it)`:`The summary the fresh agent starts from (read only: correct it with your next message)`}),(0,I.jsx)(`p`,{children:r.summary})]}):!r.failed&&(0,I.jsx)(`span`,{className:`dim small`,children:`the agent is writing the summary…`})]},o)}};return(0,I.jsx)(I.Fragment,{children:s.map((e,n)=>{let r=`${t.key}-${n}`;return!J_(e)||c===`expanded`?l(e,r):c===`hidden`?null:(0,I.jsx)(Yv,{e,children:l(e)},r)})})}function Kv({ctx:e}){return gv()?(0,I.jsx)(`button`,{className:`c-yolo`,title:`Calls run without a card. Deny rules and the main-run refusal still hold. Settings turns it off.`,onClick:()=>e.openSettings(),children:`YOLO`}):null}function qv(e){return e.kind===`refused`?`refused by ${e.group?`deny group ${e.group}`:`a deny rule`}`:e.kind===`line`?e.tech?.out??``:e.kind===`approval`?e.state===`auto`?`ran without asking (YOLO)`:e.state===`once`?e.notSaved?`allowed once · the rule was not saved`:`allowed once by you`:e.state===`always`?`allowed always · rule saved`:e.state===`denied`?G_[e.deniedBy??``]??`denied`:`withdrawn: ${e.dropWhy??`the turn ended`}`:``}function Jv(e){return e.kind===`refused`?`warn`:e.kind===`line`?e.tech?.tone??``:e.kind===`approval`?e.state===`auto`?`warn`:e.state===`once`&&!e.notSaved||e.state===`always`?`ok`:``:``}function Yv({e,children:t}){let[n,r]=(0,v.useState)(!1),[i,a]=e.kind===`approval`?[e.what,e.title]:e.kind===`refused`?[e.what,e.title||e.reason]:e.kind===`line`?[e.tech?.tool??``,e.tech?.title??``]:[``,``],o=Jv(e);return(0,I.jsxs)(`div`,{className:`c-fold ${n?`open`:``}`,children:[(0,I.jsxs)(`button`,{className:`c-fold-head`,"aria-expanded":n,title:n?`Fold it into one line`:`Show the whole card`,onClick:()=>r(!n),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,I.jsx)(`span`,{className:`c-kind`,children:i}),(0,I.jsx)(`span`,{className:`c-fold-title`,children:a}),(0,I.jsxs)(`span`,{className:`c-fold-out ${o?`tone-${o}`:``}`,children:[`· `,qv(e)]}),(0,I.jsx)(`span`,{className:`c-time`,children:Dv(e.at)})]}),n&&t]})}function Xv({ctx:e,live:t}){let n=e.board.context?.handoff_pct??0,r=e.board.context?.compact_pct??0,i=typeof t.ctx==`number`?t.ctx:null,a=i!==null&&n>0&&i>=n-10,o=t.ctx===null?`How full the agent's context is: unknown, the model's window is not known`:`How full the agent's context is${n>0?` · at ${n}% a fresh agent takes over`:` · no handoff`}${r>0?` · at ${r}% the agent compacts`:``}`;return(0,I.jsxs)(`span`,{className:`c-ctx ${a?`near`:``}`,tabIndex:0,title:o,children:[t.ctx===null?`context ?`:i===null?`context —`:`context ${i}%`,(0,I.jsxs)(`span`,{className:`c-ctx-bar`,"aria-hidden":`true`,children:[i!==null&&(0,I.jsx)(`span`,{className:`fill`,style:{width:`${Math.min(100,i)}%`}}),t.ctx===null&&(0,I.jsx)(`span`,{className:`unknown`}),n>0&&(0,I.jsx)(`span`,{className:`mark`,style:{left:`${n}%`}}),r>0&&(0,I.jsx)(`span`,{className:`mark dim`,style:{left:`${r}%`}})]})]})}function Zv({ctx:e,part:t,placeholder:n,route:r,canStop:i=!0,costLabel:a,onSend:o,extra:s,pulse:c,quote:l}){let[u,d]=(0,v.useState)(``),f=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(l)return l.current=e=>{d(t=>R_(t,e));let t=f.current;t?.focus(),requestAnimationFrame(()=>t?.setSelectionRange(t.value.length,t.value.length))},()=>{l.current=null}},[l]);let[p,m]=(0,v.useState)([]),h=(0,v.useRef)([]),g=e=>{h.current=e,m(e)},[_,y]=(0,v.useState)([]),b=(0,v.useRef)([]),x=e=>{b.current=e,y(e)},S=()=>h.current.reduce((e,t)=>e+t.size,0)+b.current.reduce((e,t)=>e+Math.floor((t.data??``).length*3/4),0),[C,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(``),[A,ee]=(0,v.useState)(``),[j,M]=(0,v.useState)(!1),[te,N]=(0,v.useState)(null),[ne,P]=(0,v.useState)(null),[F,re]=(0,v.useState)([]),L=t.talk!==null,R=V_(t.events),z=Iv(e,L),B=R.phase===`limit`,ae=t.events.filter(e=>e.type===`handoff`).length,oe=te!==null&&ae===te,se=!!(L&&e.talks.find(e=>e.id===t.talk)?.live),ce=L&&!se?null:H_(t.events),V=ne!==null&&se&&Date.now()-ne.t<Nv&&!t.events.slice(ne.n).some(e=>e.type===`closed`||e.type===`session`),H=!L&&R.phase===`waiting`&&R.waitKind===`text`&&R.waitAt,U=t.events.filter(e=>e.type===`say`&&e.by===`operator`&&!e.retry).length,le=Q_(F.filter(e=>e.key===t.key),t.events,U);Pv(!!ce||!!H||V);let ue=async e=>{let t=await Promise.all([...e].map(async e=>vv.includes(e.type)&&e.size<=bv?{f:e,data:await Pr(e)}:{f:e,data:``})),n=[],r=[...h.current],i=S()-r.reduce((e,t)=>e+t.size,0);for(let{f:e,data:a}of t){let t=i+r.reduce((e,t)=>e+t.size,0);vv.includes(e.type)?r.length>=yv?n.push(`${e.name}: at most ${yv} pictures a message`):e.size>bv?n.push(`${e.name}: ${Ov(e.size)}, at most 5 MB a picture`):t+e.size>xv?n.push(`${e.name}: the pictures and files of one message come to about 7 MB at most (${Ov(t+e.size)} with it)`):r.push({name:e.name,type:e.type,size:e.size,data:a}):n.push(`${e.name}: ${e.type||`this kind`} is not taken, only png, jpeg, gif and webp`)}g(r),ee(n.join(` · `))},de=async e=>{let t=await Promise.all([...e].map(async e=>({f:e,data:e.size<=bv?await Pr(e):``}))),n=[],r=[...b.current],i=S();for(let{f:e,data:a}of t)r.length>=10?n.push(`${e.name}: at most 10 attachments a message`):e.size>bv?n.push(`${e.name}: ${Ov(e.size)}, at most 5 MB a file`):i+e.size>xv?n.push(`${e.name}: the pictures and files of one message come to about 7 MB at most (${Ov(i+e.size)} with it)`):(r.push({kind:`file`,ref:e.name,data:a}),i+=e.size);x(r),ee(n.join(` · `))},fe=async()=>{if(j||V||!u.trim()&&!p.length&&!_.length)return;M(!0),O(``);let e={text:u,pictures:p,attach:_},n={text:u.trim()||(p.length?`(pictures)`:`(attached)`),after:U+le.length,from:t.events.length,key:t.key,sending:!0};re(e=>[...e,n]),d(``),g([]),x([]),ee(``);try{let r=await o(e),i=r?.key??t.key;re(e=>i===t.key||!t.key?e.map(e=>e===n?{...n,key:i,sending:!1,...r?.id?{id:r.id}:{}}:e):e.filter(e=>e!==n))}catch(t){re(e=>e.filter(e=>e!==n)),d(t=>t?`${e.text}\n${t}`:e.text),g([...e.pictures,...h.current]),x([...e.attach,...b.current]),O(t.message)}M(!1)},pe=async e=>{try{await t.send(e)}catch(e){O(e.message)}},W=()=>{let e=[...t.events].reverse().find(e=>e.type===`say`&&e.by===`operator`),n=e?.type===`say`&&!t.events.some((n,r)=>n.type===`read`&&n.n===e.n&&r>t.events.indexOf(e));R.live&&U_(t.events)&&(R.phase===`working`||R.phase===`background`||R.phase===`waiting`&&R.waitKind===`card`||n)&&N(ae),t.send({type:`handoff`}).catch(e=>{N(null),O(e.message)})},me=async()=>{let n=R.bg.map(e=>e.description).join(`, `);if(!n||await ie(`Close the agent? Its background tasks stop with it: ${n}.`,`Close`,!0)){P({n:t.events.length,t:Date.now()}),N(null);try{await k.closeTalk(e.project.name,t.talk??``)}catch(t){P(null),e.notify(t.message,`error`)}}},he,ge=`neutral`,_e=null;V?(he=`closing the agent and all it started…`,ge=`running`):(j||le.length)&&!R.live&&!B&&L?(he=`starting the agent…`,ge=`running`):B?he=`limit: resumes ${Y_(R.limitUntil)}${L?` · the agent closed; it starts again by itself · only messages until then`:` · waits for the reset by itself`}`:R.freshQueued?(he=`fresh agent queued · it takes over by itself when the background tasks end`,ge=`running`):R.phase===`waiting`&&R.waitKind===`card`&&ce?(he=`waiting for your answer on the card · the default goes in`,ge=`needs`,_e=(0,I.jsx)(Fv,{from:R.waitAt??ce.at,minutes:z})):R.phase===`waiting`&&R.waitKind===`stop`?he=`stopped · waits for your message`:R.phase===`waiting`&&R.waitKind===`text`?L?he=`your turn · the agent closes after ${z} min idle`:(he=`waiting for your reply · the default answer goes in`,ge=`needs`,R.waitAt&&(_e=(0,I.jsx)(Fv,{from:R.waitAt,minutes:z}))):R.phase===`background`?(he=`working in the background: ${R.bg.map(e=>e.description).join(`, `)} · no timer runs`,ge=`running`):R.phase===`ready`&&R.live?(he=`agent ready · waits for your message`,ge=`running`):R.phase===`working`&&R.live?(he=`working…`,ge=`running`):he=R.endedIdle?`agent closed · your next message starts it again`:R.everStarted?L?`agent closed · your next message starts it again`:`session ended`:L?`no agent yet · your first message starts one`:`no session`,oe&&!R.freshQueued&&(he+=` · fresh agent asked for: it takes over when this turn ends`);let ve=i&&R.live&&!B&&R.phase===`working`,ye=L&&!B&&!R.freshQueued&&!oe&&R.everStarted,be=se&&(R.live||B)&&!V,xe=he.split(` · `)[0].replace(/^(working in the background):.*/,`$1`)+(oe&&!R.freshQueued?` · fresh agent asked`:``);return(0,I.jsxs)(`div`,{className:`c-composer`,children:[(0,I.jsxs)(`div`,{className:`c-status`,children:[(0,I.jsxs)(`span`,{className:`c-status-label tone-${ge}`,children:[(0,I.jsx)(`span`,{className:`dot ${ge===`running`?`pulse`:``}`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{role:`status`,title:he,children:xe===`no agent yet`?`no agent`:xe}),_e]}),(0,I.jsxs)(`span`,{className:`c-status-right`,children:[(0,I.jsx)(`span`,{className:`mono dim small c-cost`,tabIndex:0,title:a===`this run`?`What this run cost so far`:`What this thread cost so far: every agent session in it`,children:kv(R.cost)}),(0,I.jsx)(Xv,{ctx:e,live:R})]})]}),c,le.map((e,t)=>(0,I.jsxs)(`span`,{className:`c-out`,role:`status`,children:[`▸ `,e.text.split(`
79
- `)[0].slice(0,80),` ·`,` `,e.sending?`sending…`:B?`accepted · it reaches the agent after the reset`:R.live?`sent · the agent takes it in next`:`starting the agent…`]},t)),r&&(0,I.jsxs)(`span`,{className:`c-route`,children:[`→ `,r]}),(0,I.jsxs)(`div`,{className:`c-input`,onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),ue(e.dataTransfer.files)},children:[_.length>0&&(0,I.jsx)(`div`,{className:`c-pics`,children:_.map((e,t)=>(0,I.jsxs)(`span`,{title:e.kind===`unit`?`Design unit: the agent gets unit ${e.ref} and its file`:e.data===void 0?`Goes with the message as context`:`A file of your machine: the agent reads its copy beside the chat`,children:[e.kind===`item`?`▸`:e.kind===`unit`?`◇`:`▤`,` `,e.ref,(0,I.jsx)(`button`,{"aria-label":`Remove ${e.ref}`,onClick:()=>x(_.filter((e,n)=>n!==t)),children:`×`})]},`${e.kind}:${e.ref}:${t}`))}),p.length>0&&(0,I.jsx)(`div`,{className:`c-pics`,children:p.map((e,t)=>(0,I.jsxs)(`span`,{title:Ov(e.size),children:[`▣ `,e.name,(0,I.jsx)(`button`,{"aria-label":`Remove ${e.name}`,title:`Remove this picture`,onClick:()=>g(p.filter((e,n)=>n!==t)),children:`×`})]},t))}),(0,I.jsx)(`textarea`,{ref:f,"aria-label":`Message to the agent`,rows:4,value:u,onChange:e=>{d(e.target.value),O(``)},onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),fe())},onPaste:e=>{let t=[...e.clipboardData.files].filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),ue(t))},placeholder:n??(B?L?`Write now: the agent takes it in after the reset`:`Write now: it reaches the agent after the reset`:`Message the agent…`)}),(0,I.jsxs)(`div`,{className:`c-tools`,role:`toolbar`,"aria-label":`Message tools`,children:[(e.board.domain.sections.units?[`item`,`unit`]:[`item`]).map(e=>(0,I.jsx)(`button`,{className:`c-chip ${C===e?`on`:``}`,"aria-expanded":e===`unit`?C===e:void 0,title:e===`item`?`Attach an item to the message as context`:`Attach a design unit: pick it from the live units by id and title; the agent gets unit <id> (<file>)`,onClick:()=>{w(C===e?null:e),E(``)},children:`${e===`unit`&&C===e?`▾`:`+`} ${e}`},e)),(0,I.jsxs)(`label`,{className:`c-ico c-pick`,"aria-label":`Attach a file`,title:`Attach a file of your machine as context: the agent reads its copy beside the chat · up to 10 a message, 5 MB each, about 7 MB in all with the pictures`,children:[jv.file,(0,I.jsx)(`input`,{"aria-label":`Attach a file`,type:`file`,multiple:!0,onChange:e=>{e.target.files&&de(e.target.files),e.target.value=``}})]}),(0,I.jsxs)(`label`,{className:`c-ico c-pick`,"aria-label":`Add a picture`,title:`Add a picture · paste or drop it too · ${Sv}`,children:[jv.picture,(0,I.jsx)(`input`,{"aria-label":`Add a picture`,type:`file`,multiple:!0,accept:vv.join(`,`),onChange:e=>{e.target.files&&ue(e.target.files),e.target.value=``}})]}),C===`item`&&(0,I.jsxs)(`select`,{className:`input c-attach-pick`,"aria-label":`The item to attach`,value:``,onChange:e=>{let t=e.target.value;t&&_.length<10&&!_.some(e=>e.kind===`item`&&e.ref===t)&&x([..._,{kind:`item`,ref:t}]),w(null)},children:[(0,I.jsx)(`option`,{value:``,children:`pick an item…`}),e.board.items.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.id},e.id))]}),C===`unit`&&(0,I.jsx)(Qv,{ctx:e,q:T,setQ:E,picked:_.filter(e=>e.kind===`unit`).map(e=>e.ref),onPick:e=>x(_.some(t=>t.kind===`unit`&&t.ref===e)?_.filter(t=>t.kind!==`unit`||t.ref!==e):_.length<10?[..._,{kind:`unit`,ref:e}]:_),onClose:()=>w(null)}),(t.talk!==null||s)&&(0,I.jsx)(`span`,{className:`c-sep`,"aria-hidden":`true`}),t.talk!==null&&(0,I.jsx)(Di,{ctx:e,talk:t.talk}),s,(0,I.jsx)(`span`,{className:`grow`}),L&&(0,I.jsx)(`button`,{className:`c-ico c-fresh ${oe||R.freshQueued?`on`:``}`,"aria-label":`Fresh agent`,disabled:!ye,title:B?`Off while the thread waits for the limit's reset`:R.freshQueued?`Queued already: it takes over when the background tasks end`:oe?`Asked for: the handoff comes when this turn ends`:`A fresh agent goes on from a summary of this talk; the summary cannot be edited first`,onClick:W,children:jv.fresh}),(0,I.jsx)(`button`,{className:`c-ico c-stop`,"aria-label":`Stop`,disabled:!ve,title:B?`Off while it waits for the limit's reset: nothing runs to interrupt`:R.phase===`background`&&R.live?`Off: the agent's turn is over, only its background tasks run; ${L?`Close the agent stops them`:`the item's Stop ends the run with them`}`:ve?`Stop: interrupts the agent's step; the session stays open`:`Stop: works while the agent thinks or answers`,onClick:()=>void pe({type:`interrupt`}),children:jv.stop}),L&&(0,I.jsx)(`button`,{className:`c-ico c-close`,"aria-label":`Close the agent`,disabled:!be,title:V?`Closing: the agent ends within seconds`:`Closes the agent and all it started (dev servers, watchers); your next message resumes the talk`,onClick:()=>void me(),children:jv.close}),(0,I.jsx)(`button`,{className:`c-send`,"aria-label":`Send`,disabled:j||V||!u.trim()&&!p.length&&!_.length,title:`Send · Ctrl+Enter`,onClick:()=>void fe(),children:jv.send})]})]}),A&&(0,I.jsxs)(`span`,{role:`alert`,className:`c-err`,children:[`not added: `,A]}),D&&(0,I.jsxs)(`span`,{role:`alert`,className:`c-err mono`,children:[`not sent: `,D]})]})}function Qv({ctx:e,q:t,setQ:n,picked:r,onPick:i,onClose:a}){let o=t.trim().toLowerCase(),s=(e.board.units??[]).filter(e=>!o||e.id.includes(o)||(e.title??``).toLowerCase().includes(o));return(0,I.jsxs)(`div`,{className:`c-units`,role:`dialog`,"aria-label":`Attach a design unit`,children:[(0,I.jsxs)(`div`,{className:`c-units-head`,children:[(0,I.jsx)(`input`,{className:`input`,type:`search`,"aria-label":`Search design units`,placeholder:`design units: search id or title`,value:t,autoFocus:!0,onChange:e=>n(e.target.value)}),(0,I.jsx)(`button`,{className:`icon-btn`,"aria-label":`Close the unit picker`,onClick:a,children:`×`})]}),(0,I.jsxs)(`div`,{role:`listbox`,"aria-multiselectable":`true`,className:`c-units-list`,children:[s.map(e=>{let t=r.includes(e.id);return(0,I.jsxs)(`button`,{role:`option`,"aria-selected":t,className:`picker-row`,title:e.title??e.id,onClick:()=>i(e.id),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:t?`☑`:`☐`}),(0,I.jsxs)(`span`,{className:`picker-name`,children:[(0,I.jsx)(`span`,{className:`mono`,children:e.id}),e.title&&(0,I.jsx)(`span`,{className:`dim`,children:e.title})]}),(0,I.jsx)(`span`,{className:`picker-state tone-${e.ready?`ok`:`warn`}`,children:ta(e)})]},e.id)}),!s.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`no design unit matches`})]})]})}var $v=({text:e,pictures:t,attach:n})=>({type:`say`,text:e.trim()||(t.length?`(pictures)`:``),...t.length?{images:t.map(e=>({media_type:e.type,data:e.data}))}:{},...n.length?{attach:n}:{}});function ey(e){let t=(0,v.useRef)(null),n=(0,v.useRef)(!0),r=(0,v.useRef)(0),[i,a]=(0,v.useState)(!1),o=e=>{e.style.overflowAnchor=n.current?`none`:``};return(0,v.useEffect)(()=>{let e=t.current;e&&n.current&&(e.scrollTop=e.scrollHeight)},[e]),(0,v.useEffect)(()=>{let e=t.current;if(!e)return;o(e);let r=new ResizeObserver(()=>{n.current&&(e.scrollTop=e.scrollHeight)}),i=()=>{r.disconnect(),r.observe(e);for(let t of e.children)r.observe(t,{box:`border-box`})},a=new MutationObserver(i);return i(),a.observe(e,{childList:!0}),()=>{r.disconnect(),a.disconnect()}},[]),{ref:t,onScroll:()=>{let e=t.current;if(!e)return;let i=e.scrollHeight-e.scrollTop-e.clientHeight<40;(i||e.scrollTop<r.current)&&(n.current=i),r.current=e.scrollTop,o(e),a(!n.current)},away:i,toEnd:()=>{let e=t.current;n.current=!0,a(!1),e&&(o(e),e.scrollTo({top:e.scrollHeight,behavior:`smooth`}))}}}function ty({follow:e}){return e.away?(0,I.jsx)(`div`,{className:`c-to-end`,children:(0,I.jsx)(`button`,{className:`btn`,onClick:e.toEnd,title:`Scroll to the last message`,children:`↓ Latest`})}):null}var ny={submitted:[`submitted`,`ok`,`✔`],blocked:[`blocked`,`blocked`,`!`],failed:[`failed`,`error`,`✘`],paused:[`paused`,`neutral`,`‖`],stopped:[`stopped`,`neutral`,`■`],"no-result":[`no result`,`warn`,`?`],skipped:[`skipped`,`neutral`,`↷`]},ry={blocked:`its question`,failed:`the error`,"no-result":`why no result`,skipped:`why it was skipped`,paused:`why it paused`,stopped:`why it stopped`};function iy({ctx:e,id:t,end:n,acts:r=!0}){let i=typeof n.duration_ms==`number`?Math.round(n.duration_ms/6e4):null,a=[typeof n.cost_usd==`number`?`$${n.cost_usd.toFixed(2)}`:``,i===null?``:i<60?`${i} min`:`${Math.floor(i/60)} h ${String(i%60).padStart(2,`0`)} min`,n.commit?`main ${n.commit}`:``,n.unticked?`${n.unticked} plan task${n.unticked>1?`s`:``} unticked`:``,n.lessons?`${n.lessons} lesson${n.lessons>1?`s`:``} to the Inbox`:``].filter(Boolean),[o,s,c]=ny[n.outcome]??[n.outcome,`neutral`,`·`],l=ay(e,t,n);return(0,I.jsxs)(`div`,{className:`c-card c-end tone-${s}`,role:`note`,"aria-label":`The run of ${t} ended`,children:[(0,I.jsxs)(`div`,{className:`c-end-head`,children:[(0,I.jsx)(`span`,{className:`c-end-mark`,"aria-hidden":`true`,children:c}),(0,I.jsxs)(`strong`,{className:`c-end-title`,children:[`Run ended: `,o]}),n.move&&(0,I.jsxs)(`span`,{className:`c-end-move`,title:`The run's result word`,children:[`move `,n.move]}),n.at&&(0,I.jsx)(`span`,{className:`c-end-time`,children:oi(n.at)})]}),n.reason&&(0,I.jsxs)(`div`,{className:`c-end-reason`,children:[(0,I.jsx)(`span`,{className:`c-end-label`,children:ry[n.outcome]??`reason`}),(0,I.jsx)(`span`,{className:`c-end-why`,children:n.reason})]}),a.length>0&&(0,I.jsx)(`div`,{className:`c-end-facts`,children:a.map((e,t)=>(0,I.jsxs)(`span`,{children:[t>0&&(0,I.jsx)(`span`,{className:`c-end-sep`,"aria-hidden":`true`,children:`·`}),e]},e))}),n.process&&(0,I.jsxs)(`span`,{className:`c-end-process`,children:[`▲ a broken step: `,n.process]}),r&&l&&(0,I.jsx)(`div`,{className:`c-end-acts`,children:(0,I.jsx)(`button`,{className:`btn-primary`,title:l.tip,onClick:l.on,children:l.label})})]})}function ay(e,t,n){let r=e.board.items.find(e=>e.id===t),i=r?Er(r,e.board.domain).find(e=>e.cmd===`unblock`):void 0;return r?.status===`blocked`&&i?{label:`Unblock`,tip:`Its Unblock: your answer goes to its next run`,on:()=>e.openMove({title:`${i.label} ${t}`,id:t,move:i})}:r&&[`awaiting-verdict`,`unplayed`].includes(r.status)?{label:`Verdict`,tip:`Opens Playtest with ${t} open and marked: the build, the platforms, and its verdict`,on:()=>e.go(`playtest`)}:r?.status===`ready`&&!r.running&&n.outcome!==`submitted`?{label:`Run again`,tip:`Starts it again; the run gate may still refuse`,on:()=>void e.run([t])}:null}function oy({ctx:e,id:t,end:n,onShow:r}){let[i,a,o]=ny[n.outcome]??[n.outcome,`neutral`,`·`],s=ay(e,t,n);return(0,I.jsxs)(`div`,{className:`c-end-bar tone-${a}`,role:`status`,"aria-label":`The last run of ${t}`,children:[(0,I.jsx)(`span`,{className:`c-end-mark`,"aria-hidden":`true`,children:o}),(0,I.jsxs)(`span`,{className:`c-end-bar-text`,children:[`Run ended: `,i,n.at&&(0,I.jsxs)(`span`,{className:`c-end-time`,children:[` · `,oi(n.at)]})]}),(0,I.jsx)(`button`,{className:`btn-line`,title:`Scrolls the chat to the run's end card`,onClick:r,children:`Show`}),s&&(0,I.jsx)(`button`,{className:`btn-primary`,title:s.tip,onClick:s.on,children:s.label})]})}var sy=200,cy=8;function ly(e,t,n,r,i){let a=Math.min(600,e-32),o=r??{x:e-a-12,y:n},s=Math.max(0,Math.min(o.x,e-120)),c=Math.max(0,Math.min(o.y,t-sy-cy-i));return{x:s,y:c,width:a,height:Math.max(sy,t-c-cy-i)}}function uy(e,t){return async(...n)=>{if(!e.current){e.current=!0;try{await t(...n)}finally{e.current=!1}}}}var dy=48;function fy(e){let t=e.split(/\r?\n/).filter(e=>e.trim()),n=/^([a-z_]+):(?:\s+(.*))?$/;if(!t.length||!n.test(t[0]))return null;let r=[],i=r[0],a=null,o=null;for(let e of t){let t;if(t=e.match(n))i={key:t[1],rest:t[2]??``,items:[]},r.push(i),a=o=null;else if(t=e.match(/^- (.*)$/)){let e=t[1].match(n);o=e?[e[1],e[2]??``]:null,a=o?{fields:[o]}:{text:t[1]},i.items.push(a)}else(t=e.match(/^\s+([a-z_]+):(?:\s+(.*))?$/))&&a&&`fields`in a?(o=[t[1],t[2]??``],a.fields.push(o)):o?o[1]+=` ${e.trim()}`:a&&`text`in a?a.text+=` ${e.trim()}`:i.rest+=(i.rest?` `:``)+e.trim()}return r.map(e=>{e.items=e.items.map(e=>`fields`in e&&e.fields.length===1?{text:`${e.fields[0][0]}: ${e.fields[0][1]}`}:e);let t=e.items.filter(e=>`fields`in e).map(e=>e.fields),n=t[0]?.map(([e])=>e)??[],r=t.length>1&&t.every(e=>e.length===n.length&&e.every(([e,t],r)=>e===n[r]&&t.length<=dy));return{key:e.key,rest:e.rest,bullets:e.items.filter(e=>`text`in e).map(({text:e})=>{let t=e.match(/^([a-z0-9-]+): (.*)$/);return t?{lead:t[1],text:t[2]}:{lead:null,text:e}}),table:r?{cols:n,rows:t.map(e=>e.map(([,e])=>e))}:null,cards:r?[]:t}})}var py=e=>e.replace(/^(\s*)(?:([#>*+-])|(\d+)([.)]))(?=\s|$)/,(e,t,n,r,i)=>n?`${t}\\${n}`:`${t}${r}\\${i}`),my=e=>e.replace(/_/g,` `);function hy(e,t){let n=e=>e.replaceAll(`\\`,`/`),r=n(t);if(!/^([a-z]:)?\//i.test(r))return r;let i=n(e).replace(/\/+$/,``);return r.toLowerCase().startsWith(`${i.toLowerCase()}/`)?r.slice(i.length+1):null}function gy(e,t){if(/^([a-z][a-z0-9+.-]*:|[/\\#?])/i.test(t))return null;let n=e.split(`/`).slice(0,-1).map(encodeURIComponent).join(`/`),r=n?`http://p/${n}/`:`http://p/`;try{let{pathname:e}=new URL(t,r);return decodeURIComponent(e.slice(1))}catch{return null}}var _y=(e,t)=>{let n=hy(e.path,t);return t=>{let r=n===null?null:gy(n,t);return r&&pi(r)?ee(e.name,r):Qp(t)}},vy=[[/^start: /,`start`],[/^agent: /,`agent`],[/^tool error: /,`toolerr`],[/^denied: /,`denied`],[/^tool: /,`tool`]];function yy(e){let t=[],n=!1;for(let r of e.split(/\r?\n/)){if(!r.trim())continue;let e=r.match(/^\[(\d\d:\d\d:\d\d)\] (.*)$/),i=e?e[1]:``,a=e?e[2]:r,o=n&&!e?`result`:`other`,s=vy.find(([e])=>e.test(a));if(s)o=s[1],a=a.replace(s[0],``),n=!1;else if(/^result:/.test(a)){if(n=!0,a=a.slice(7).trim(),!a)continue;o=`result`}else e&&/^(done|ended) /.test(a)?(o=`summary`,n=!1):e&&(n=!1);t.push({time:i,kind:o,text:a})}return t}var by=e=>/--resume/.test(e)?`session resumed`:/--handoff/.test(e)?`fresh session after handoff`:`run start`;function xy(e){let t={text:``,rect:null,rects:[]},n=window.getSelection();if(!e||!n||n.isCollapsed||!n.rangeCount)return t;let r=n.getRangeAt(0);if(!e.contains(r.commonAncestorContainer))return t;let i=n.toString();return i.trim()?{text:i,rect:r.getBoundingClientRect(),rects:[...r.getClientRects()]}:t}var Sy=(e,t,n)=>e.some(e=>t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom),Cy=200,wy=76,Ty=(0,I.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,I.jsx)(`rect`,{x:`8`,y:`8`,width:`12`,height:`12`,rx:`2`}),(0,I.jsx)(`path`,{d:`M16 8V5a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h3`})]}),Ey=(0,I.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M9 14L4 9l5-5`}),(0,I.jsx)(`path`,{d:`M4 9h10a6 6 0 0 1 6 6v4`})]}),Dy=(e,t)=>({x:Math.max(4,Math.min(e,window.innerWidth-Cy-4)),y:Math.max(4,Math.min(t,window.innerHeight-wy-4))});function Oy({stream:e,onReply:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),o=(0,v.useRef)(null),s=(0,v.useRef)(null),c=(0,v.useRef)(t);c.current=t;let l=!!t;(0,v.useEffect)(()=>{let t=e.current;if(!t)return;let n=e=>{let{text:n,rect:i,rects:a}=xy(t);if(!n||!i)return;let o=!!(e.clientX||e.clientY);if(o&&!Sy(a,e.clientX,e.clientY))return;e.preventDefault(),s.current=document.activeElement;let c=o?Dy(e.clientX,e.clientY):Dy(i.left,i.bottom+4);r({...c,text:n})};return t.addEventListener(`contextmenu`,n),()=>t.removeEventListener(`contextmenu`,n)},[e]),(0,v.useEffect)(()=>{if(!n)return;o.current?.querySelector(`[role="menuitem"]`)?.focus();let e=e=>{o.current?.contains(e.target)||r(null)},t=()=>r(null);return document.addEventListener(`pointerdown`,e,!0),window.addEventListener(`wheel`,t,!0),window.addEventListener(`touchmove`,t,!0),window.addEventListener(`resize`,t),()=>{document.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`wheel`,t,!0),window.removeEventListener(`touchmove`,t,!0),window.removeEventListener(`resize`,t)}},[n]),(0,v.useEffect)(()=>{if(!l||!window.matchMedia(`(pointer: coarse)`).matches)return;let t=()=>{let{text:t,rect:n}=xy(e.current);a(t&&n?{...Dy(n.left,n.bottom+8),text:t}:null)};return document.addEventListener(`selectionchange`,t),window.addEventListener(`scroll`,t,!0),()=>{document.removeEventListener(`selectionchange`,t),window.removeEventListener(`scroll`,t,!0)}},[e,l]);let u=e=>{r(null),e&&s.current?.focus()},d=e=>{r(null),a(null),c.current?.(L_(e))};return(0,I.jsxs)(I.Fragment,{children:[n&&(0,I.jsxs)(`div`,{ref:o,className:`c-sel-menu`,role:`menu`,"aria-label":`Selection`,style:{left:n.x,top:n.y},onKeyDown:e=>{let t=[...o.current?.querySelectorAll(`[role="menuitem"]`)??[]],n=t.indexOf(document.activeElement),r=n=>{e.preventDefault(),t[(n+t.length)%t.length]?.focus()};e.key===`Escape`?(e.preventDefault(),u(!0)):e.key===`ArrowDown`?r(n+1):e.key===`ArrowUp`?r(n-1):e.key===`Home`?r(0):e.key===`End`?r(t.length-1):e.key===`Tab`&&u(!1)},children:[(0,I.jsxs)(`button`,{role:`menuitem`,"aria-label":`Copy`,"aria-keyshortcuts":`Control+C`,tabIndex:-1,onClick:()=>{O_(n.text),u(!0)},children:[Ty,(0,I.jsx)(`span`,{children:`Copy`}),(0,I.jsx)(`kbd`,{children:`Ctrl+C`})]}),l&&(0,I.jsxs)(`button`,{role:`menuitem`,"aria-label":`Reply`,title:`Quotes it into your message`,tabIndex:-1,onClick:()=>d(n.text),children:[Ey,(0,I.jsx)(`span`,{children:`Reply`}),(0,I.jsx)(`span`,{className:`dim`,children:`quotes it`})]})]}),i&&!n&&(0,I.jsxs)(`button`,{className:`c-sel-reply`,style:{left:i.x,top:i.y},onPointerDown:e=>e.preventDefault(),onClick:()=>d(i.text),children:[Ey,`Reply`]})]})}var ky=e=>{if(!e)return``;let t=new Date(e);return`${String(t.getMonth()+1).padStart(2,`0`)}.${String(t.getDate()).padStart(2,`0`)} ${t.toTimeString().slice(0,5)}`};function Ay(e,t,n){let r=e.project.name,i=`proposals`in t?t.proposals:[];return{key:t.id,events:n,talk:t.id,item:t.item,proposals:i,send:n=>k.sendTalk(r,t.id,n).catch(t=>{throw e.notify(t.message,`error`),t}),imageUrl:e=>`/api/p/${encodeURIComponent(r)}/talk/${t.id}/att/${e.split(`/`).pop()}`,imagePath:e=>`.gcf-session/chats/${t.id}/${e}`}}function jy({ctx:e,talk:t}){let n=Mv(j(e.project.name,{talk:t.id})),r=ey(n.length),i=Ay(e,t,n),a=V_(n),o=(0,v.useRef)(null);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`c-stream`,ref:r.ref,onScroll:r.onScroll,role:`log`,"aria-live":`polite`,"aria-relevant":`additions`,children:[!n.length&&(0,I.jsx)(`div`,{className:`tab-empty`,children:t.title?`Your message is sent: the agent starts and takes it in.`:`Write the first message: it starts an agent.`}),(0,I.jsx)(Gv,{ctx:e,part:i})]}),(0,I.jsx)(ty,{follow:r}),(0,I.jsx)(Oy,{stream:r.ref,onReply:e=>o.current?.(e)}),(0,I.jsx)(Zv,{ctx:e,part:i,quote:o,costLabel:`this thread`,placeholder:a.phase===`limit`?`Write now: the agent takes it in after the reset`:a.live?`Message the agent…`:`Message: it starts the agent, who remembers this thread`,onSend:async n=>({id:(await k.sendTalk(e.project.name,t.id,$v(n))).id})})]})}function My({ctx:e,onMade:t}){let n=(0,v.useRef)(null);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`c-stream`,children:(0,I.jsx)(`div`,{className:`tab-empty`,children:`Write the first message: it starts an agent, and its first line becomes the thread's title.`})}),(0,I.jsx)(Zv,{ctx:e,part:{key:`new`,events:[],talk:``,send:async()=>{},imageUrl:()=>``,imagePath:()=>``},costLabel:`this thread`,placeholder:`First message: it makes the thread, and its first line becomes the title`,onSend:async r=>{n.current??=(await k.newTalk(e.project.name)).id;let i=n.current,a=await k.sendTalk(e.project.name,i,$v(r));return e.reloadTalks(),t(i),{id:a.id}}})]})}function Ny({ctx:e,thread:t}){let[n,r]=(0,v.useState)(`all`),{board:i,talks:a}=e;if(!i.domain.chat)return(0,I.jsx)(`div`,{className:`page`,children:(0,I.jsxs)(`div`,{role:`note`,className:`empty-box chat-old`,children:[(0,I.jsx)(`b`,{children:`No project chat in this project`}),(0,I.jsx)(`span`,{children:`Its core is older than 0.12. Runs and their chats still work.`}),(0,I.jsx)(`code`,{children:`update gcf-aif-ext to 0.12`})]})});let o=[...new Set(a.flatMap(e=>e.item?[e.item]:[]))],s=i.items.map(e=>e.id).filter(e=>!o.includes(e)),c=a.filter(e=>n===`all`||e.item===n),l=t===`new`?null:a.find(e=>e.id===t)??(t?null:c[0]),u=t===`new`||!l&&!a.length,d=t=>e.go(`chat`,t),f=new Set((i.inbox??[]).map(e=>e.id));return(0,I.jsxs)(`div`,{className:`chat-screen ${t?`has-thread`:``}`,children:[(0,I.jsxs)(`aside`,{className:`threads`,"aria-label":`Threads of the project chat`,children:[(0,I.jsxs)(`div`,{className:`threads-head`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{children:`Project chat`}),(0,I.jsx)(`button`,{className:`btn`,title:`Start a thread: its title is the first line of your first message`,onClick:()=>d(`new`),children:`+ New thread`})]}),(0,I.jsxs)(`select`,{className:`input`,"aria-label":`Filter threads by item`,value:n,onChange:e=>r(e.target.value),children:[(0,I.jsx)(`option`,{value:`all`,children:`all threads`}),o.map(e=>(0,I.jsxs)(`option`,{value:e,children:[`item: `,e]},e)),s.map(e=>(0,I.jsxs)(`option`,{value:e,children:[`item: `,e,` · no thread yet`]},e))]})]}),(0,I.jsxs)(`div`,{className:`threads-list`,children:[n!==`all`&&!c.length&&(0,I.jsxs)(`div`,{className:`threads-none`,children:[(0,I.jsxs)(`p`,{children:[`No thread for `,n,` yet.`]}),(0,I.jsx)(jo,{label:`Ask about this item`,tip:`Opens the Chat tab of ${n}: your first question makes its bound thread`,glyph:`chat`,onClick:()=>e.openItem(n,`chat`)})]}),c.map(t=>{let n=t.proposals.map(e=>`${e.move??`item-new`} ${e.state}${e.item?` → ${e.item}`:``}`).join(` · `);return(0,I.jsxs)(`button`,{className:`thread-row`,"aria-current":l?.id===t.id?`true`:void 0,onClick:()=>d(t.id),children:[(0,I.jsxs)(`span`,{className:`thread-title`,children:[t.waiting&&(0,I.jsx)(`span`,{className:`needs-dot`,"aria-label":`waiting for you`,title:`A permission or question card waits for you: it is in "waiting for me"`,children:`●`}),(0,I.jsx)(`span`,{className:t.title===null?`dim`:``,children:t.title??`untitled · no message yet`})]}),(0,I.jsxs)(`span`,{className:`thread-meta`,children:[t.item&&(0,I.jsxs)(`span`,{title:`The thread is bound to this item`,children:[`▸ `,t.item]}),t.start&&(0,I.jsxs)(`span`,{title:`Opened from the Design screen: it follows its own skill`,children:[`✎ `,e.board.domain.starts?.[t.start]?.label??t.start]}),t.entry&&(0,I.jsxs)(`span`,{title:`Drafts an item from this inbox entry`,children:[`◇ `,t.entry,f.has(t.entry)?``:` · erased`]}),(0,I.jsx)(`span`,{title:`Last activity`,children:ky(t.last_at??t.created_at)}),(0,I.jsxs)(`span`,{title:`What its agents cost`,children:[`$`,t.cost_usd.toFixed(2)]}),(0,I.jsx)(`span`,{className:t.limit_until?`is-limit`:t.live?`is-live`:``,title:`Whether its agent runs now`,children:t.limit_until?`limit: resumes ${new Date(t.limit_until).toTimeString().slice(0,5)}`:t.live?`agent live`:`agent closed`})]}),n&&(0,I.jsx)(`span`,{className:`thread-props`,children:n})]},t.id)})]})]}),(0,I.jsxs)(`section`,{className:`thread`,"aria-label":`Thread`,children:[(0,I.jsxs)(`div`,{className:`thread-head`,children:[(0,I.jsx)(`button`,{className:`d-back`,"aria-label":`Back to the threads`,onClick:()=>e.go(`chat`),children:`‹`}),(0,I.jsx)(`h2`,{title:l?.title??void 0,children:u?`New thread`:l?.title??`untitled · no message yet`}),!u&&l&&(0,I.jsx)(Kv,{ctx:e}),l?.entry&&(f.has(l.entry)?(0,I.jsxs)(`button`,{className:`btn-line mono`,title:`The inbox entry this thread drafts from: open the inbox`,onClick:()=>e.go(`inbox`),children:[`◇ `,l.entry]}):(0,I.jsxs)(`span`,{className:`mono dim small`,title:`The entry is erased or taken: the thread stays`,children:[`◇ `,l.entry,` · erased`]})),l?.item&&(0,I.jsxs)(`button`,{className:`btn-line mono`,title:`Open the item this thread is bound to`,onClick:()=>e.openItem(l.item??``,`chat`),children:[`▸ `,l.item]})]}),u?(0,I.jsx)(My,{ctx:e,onMade:d}):l?(0,I.jsx)(jy,{ctx:e,talk:l},l.id):(0,I.jsx)(`div`,{className:`c-stream`,children:(0,I.jsx)(`div`,{className:`tab-empty`,children:`This thread is not in the list: pick one.`})})]})]})}function Py({ctx:e,item:t}){let n=e.project.name,[r,i]=(0,v.useState)(``),a=(0,v.useRef)(null),o=Mv(j(n,{item:t.id})),s=e.talks.find(e=>e.item===t.id),c=Mv(s?j(n,{talk:s.id}):null),l=ey(o.length+c.length),u={key:`run`,events:o,talk:null,item:t.id,send:r=>k.sendChat(n,t.id,r).catch(t=>{throw e.notify(t.message,`error`),t}),imageUrl:e=>`/api/p/${encodeURIComponent(n)}/chat/${t.id}/att/${e.split(`/`).pop()}`,imagePath:e=>`.gcf-session/runs/${e}`},d=Ay(e,s??{id:``,item:t.id},c),f=V_(o),p=t.running&&t.running_kind!==`session`&&(f.live||f.phase===`limit`),m=p?u:d,h=t.running&&t.running_kind===`session`,g=(o.at(-1)?.at??``)>(c.at(-1)?.at??``),_=o.flatMap((e,t)=>e.type===`run_end`?[t]:[]),y=o.findLastIndex(e=>e.type===`session`),b=(_.at(-1)??-1)>y?_.at(-2)??-1:_.at(-1)??-1,x=o.slice(b+1).find(e=>e.type===`session`)?.at,S=_.length&&_.at(-1)>y?o[_.at(-1)]:null,C=S?.type===`run_end`&&!g&&c.length>0?S:null;return(0,I.jsxs)(`div`,{className:`item-chat`,children:[(0,I.jsxs)(`div`,{className:`c-stream`,ref:l.ref,onScroll:l.onScroll,role:`log`,"aria-live":`polite`,"aria-relevant":`additions`,children:[!o.length&&!c.length&&(0,I.jsx)(`div`,{className:`tab-empty`,children:h?`An interactive session has no chat on the board: it is your own agent session, in your terminal.`:`No chat yet: it opens with the item's next run. A question now makes ${t.id}'s own thread of the project chat.`}),(g?[`thread`,`run`]:[`run`,`thread`]).map(n=>n===`run`?(0,I.jsxs)(v.Fragment,{children:[g&&c.length>0&&(0,I.jsxs)(`div`,{role:`separator`,className:`c-head c-run-head`,title:`The run started after your questions: its chat goes below, where the stream follows`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`}),`▸ The run of `,t.id,x&&(0,I.jsxs)(`span`,{className:`c-run-sub`,children:[`started `,oi(x)]}),(0,I.jsx)(`span`,{"aria-hidden":`true`})]}),(0,I.jsx)(Gv,{ctx:e,part:u})]},`run`):s&&c.length>0&&(0,I.jsxs)(v.Fragment,{children:[(0,I.jsxs)(`div`,{role:`separator`,className:`c-head`,title:`Its agent knows the item, its plan, its run's log and chat, and its commits`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`}),`Your questions about `,t.id,` · its own thread `,s.id,` of the project chat`,(0,I.jsx)(`span`,{"aria-hidden":`true`})]}),(0,I.jsx)(Gv,{ctx:e,part:d})]},`thread`))]}),(0,I.jsx)(ty,{follow:l}),(0,I.jsx)(Oy,{stream:l.ref,onReply:e=>a.current?.(e)}),C&&(0,I.jsx)(oy,{ctx:e,id:t.id,end:C,onShow:()=>[...l.ref.current?.querySelectorAll(`.c-end`)??[]].at(-1)?.scrollIntoView({block:`center`,behavior:`smooth`})}),(0,I.jsx)(Zv,{ctx:e,part:m,quote:a,costLabel:p?`this run`:`this thread`,pulse:p?(0,I.jsx)(Fy,{item:t,events:o}):void 0,canStop:!0,route:r,placeholder:p?f.phase===`limit`?`Write now: it reaches the agent after the reset`:`Message the agent working on ${t.id}…`:`A question about ${t.id}: it goes to its own thread`,extra:p?(0,I.jsx)(`span`,{className:`a-pick compact`,children:[`model`,`effort`].map(n=>(0,I.jsx)(`select`,{className:`input`,"aria-label":n,disabled:!0,title:`${n}: a run keeps the item's own model and effort`,children:(0,I.jsx)(`option`,{children:yi(wi(e.board,n,t[n])??``)})},n))}):(0,I.jsx)(Kv,{ctx:e}),onSend:async r=>{let a=f.phase===`limit`,o=await k.sendChat(n,t.id,$v(r));return i(o.talk?`the server sent your last message to ${o.talk}, ${t.id}'s own thread`:a?`the server took your last message into the run: it waits for the reset`:`the server sent your last message to the run's session`),o.talk&&e.reloadTalks(),{key:o.talk??u.key,id:o.id}}})]})}function Fy({item:e,events:t}){let n=e.plan&&!(`error`in e.plan)?e.plan:null,r=t.findLastIndex(e=>e.type===`run_end`),i=t.slice(r+1).find(e=>e.type===`session`),a=i&&e.active_at&&e.active_at>=i.at,o=n&&n.tasks?`step ${Math.min(n.done+1,n.tasks)} of ${n.tasks}`:``,s=a?e.doing??``:``,c=i?Math.max(1,Math.round((Date.now()-Date.parse(i.at))/6e4)):0,l=c?c<60?`${c} min`:`${Math.floor(c/60)} h ${String(c%60).padStart(2,`0`)} min`:``;return!o&&!s&&!l?null:(0,I.jsxs)(`div`,{className:`c-pulse`,role:`status`,title:`While the run goes: its plan step, its last tool call (from its log), how long it has gone. Every call is in the Log tab.`,children:[(0,I.jsx)(`span`,{className:`c-pulse-dot`,"aria-hidden":`true`}),o&&(0,I.jsx)(`span`,{className:`c-pulse-step`,children:o}),s&&(0,I.jsx)(`span`,{className:`c-pulse-doing`,children:s}),(0,I.jsx)(`span`,{className:`c-pulse-time`,children:l})]})}var Iy=e=>String(e).padStart(2,`0`),Ly=e=>{let t=new Date(e);return`${Iy(t.getDate())}.${Iy(t.getMonth()+1)} ${oi(e)}`},Ry=e=>{let t=Math.round(e/6e4);return t<60?`${t} min`:`${Math.floor(t/60)} h ${Iy(t%60)} min`},zy=e=>e===null?`?`:e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e),By=e=>e===null?`$?`:`$${e.toFixed(2)}`,Vy={submit:`ok`,close:`ok`,paused:`neutral`,"no-result":`neutral`,block:`blocked`,"not-started":`queued`};function Hy(e){return!e.model&&!e.effort?{text:`on the agent's own model`,picked:!1}:{text:`on ${e.model??`the agent's model`} · ${e.effort??`the agent's effort`}`,picked:!0}}function Uy(e,t,n){if(e.started)return{from:e.started,to:e.ended};let r=n.slice(n.indexOf(e)+1).find(e=>e.items.some(e=>e.id===t));return{from:r?r.ended:null,to:e.ended}}function Wy({ctx:e,run:t,only:n,list:r,onPart:i}){let a=(e,n)=>i(n.id,{kind:e,run:t,item:n,span:Uy(t,n.id,r)}),{board:o}=e,s=e=>o.items.some(t=>t.id===e)||(o.history??[]).some(t=>t.id===e)||(o.graveyard??[]).some(t=>t.id===e),c=t.items.filter(e=>!n||e.id===n),l=n?t.items.filter(e=>e.id!==n).map(e=>e.id):[],u=t.started&&t.started.slice(0,10)===t.ended.slice(0,10);return(0,I.jsxs)(`article`,{className:`run-row`,"aria-label":`Run ended ${t.ended}`,children:[(0,I.jsxs)(`header`,{children:[t.started?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`mono strong`,title:`start → end, on your clock`,children:[Ly(t.started),` → `,u?oi(t.ended):Ly(t.ended)]}),(0,I.jsx)(`span`,{className:`mono dim`,children:Ry(Date.parse(t.ended)-Date.parse(t.started))})]}):(0,I.jsxs)(`span`,{className:`mono strong`,title:`An older run-log line has no start`,children:[`ended `,Ly(t.ended)]}),(0,I.jsx)(`span`,{className:`mono dim`,title:`Run mode`,children:t.mode}),t.cost_usd!==null&&(0,I.jsx)(`span`,{className:`mono`,title:`What the whole run cost`,children:By(t.cost_usd)}),(0,I.jsxs)(`span`,{className:`dim small`,children:[t.items.length,` item`,t.items.length>1?`s`:``]}),l.length>0&&(0,I.jsxs)(`span`,{className:`mono dim small`,children:[`with `,l.join(`, `)]}),!t.id&&(0,I.jsx)(`span`,{className:`dim small run-old`,children:`an older run-log line: no id, no start, no model, no log part`})]}),c.map((t,n)=>{let r=Hy(t);return(0,I.jsxs)(`div`,{className:`run-item`,children:[(0,I.jsxs)(`div`,{className:`run-item-line`,children:[s(t.id)?(0,I.jsx)(`button`,{className:`link-btn mono strong`,onClick:()=>e.openItem(t.id),children:t.id}):(0,I.jsx)(`span`,{className:`mono strong`,children:t.id}),(0,I.jsx)(`span`,{className:`badge mono tone-${Vy[t.result]??`warn`}`,title:`The run-log's result word`,children:t.result}),t.cost_usd!==null&&(0,I.jsx)(`span`,{className:`mono`,children:By(t.cost_usd)}),t.duration_ms!==null&&(0,I.jsx)(`span`,{className:`mono dim`,children:Ry(t.duration_ms)}),(0,I.jsx)(`span`,{className:`grow`}),s(t.id)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`btn-line run-btn`,title:t.log?`The part of ${t.id}'s log this run wrote: bytes ${t.log.from.toLocaleString(`en`)}–${t.log.to.toLocaleString(`en`)}`:`An older line: no log part, the whole log`,onClick:()=>a(`log`,t),children:t.log?`log`:`whole log`}),(0,I.jsx)(jo,{label:`Chat`,tip:`Opens the chat of this run: its conversation with the agent, and a question you send goes to it`,glyph:`chat`,size:`sm`,onClick:()=>a(`chat`,t)})]})]}),t.reason&&(0,I.jsx)(`span`,{className:`mono run-reason`,title:`The reason, word for word`,children:t.reason}),(0,I.jsxs)(`div`,{className:`run-facts mono`,children:[Object.values(t.tokens).some(e=>e!==null)&&(0,I.jsxs)(`span`,{title:`tokens`,children:[`in `,zy(t.tokens.input),` · out `,zy(t.tokens.output),` · cache read`,` `,zy(t.tokens.cache_read)]}),t.turns!==null&&(0,I.jsxs)(`span`,{children:[t.turns,` turns`]}),t.handoffs>0&&(0,I.jsxs)(`span`,{className:`running-text`,children:[`↻ `,t.handoffs,` handoff`,t.handoffs>1?`s`:``]}),(0,I.jsx)(`span`,{className:r.picked?``:`dim`,title:`What it ran on: the run's pick or the item's own; none is the agent's choice`,children:r.text}),t.process&&(0,I.jsxs)(`span`,{className:`warn-text`,title:`A broken step of the run's process`,children:[`! `,t.process]})]})]},`${t.id}-${n}`)})]})}var Gy={p:({children:e})=>(0,I.jsx)(I.Fragment,{children:e})},Ky=[r_],qy=[`status`,`chat`,`file`,`plan`,`log`,`history`,`related`,`lessons`],Jy=[`type`,`system`,`gate`,`milestone`],Yy=null,Xy=window.matchMedia(`(width <= 700px)`),Zy=24,Qy=2e4,$y=()=>(0,v.useSyncExternalStore)(e=>(window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)),()=>`${window.innerWidth}x${window.innerHeight}`);function eb(){$y();let[e,t]=(0,v.useState)(Yy),n=(0,v.useRef)(null),r=Math.round(document.querySelector(`.workspace`)?.getBoundingClientRect().top??48)+6,{x:i,y:a,width:o,height:s}=ly(window.innerWidth,window.innerHeight,r,e,Xy.matches?0:Zy);return{style:{"--win-x":`${i}px`,"--win-y":`${a}px`,"--win-w":`${o}px`,"--win-h":`${s}px`},onPointerDown:e=>{let t=e.target;e.button!==0||Xy.matches||!t.closest(`.d-head`)||t.closest(`button, a, input, select, textarea`)||(n.current={dx:e.clientX-i,dy:e.clientY-a},e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault())},onPointerMove:e=>{n.current&&(Yy={x:e.clientX-n.current.dx,y:e.clientY-n.current.dy},t(Yy))},onPointerUp:()=>{n.current=null},onPointerCancel:()=>{n.current=null},onLostPointerCapture:()=>{n.current=null}}}var tb=new Set([`depends`,`needs`,`needed_by`,`waits_for`]),nb=e=>e.board.domain.fields.some(e=>e.key===`needs`);function rb(e,t,n){let[r,i]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let n=!0;return t&&k.file(e.project.name,t).then(e=>n&&i(e.text),e=>n&&i(e.message)),()=>{n=!1}},[e.project.name,t,n]),(0,v.useEffect)(()=>i(null),[t]),r}function ib({ctx:e,item:t}){let n=n=>(0,I.jsx)(Jp,{urlTransform:_y(e.project,t.file),components:Gy,children:py(n)}),r=rb(e,t.file,JSON.stringify(t)),[i,a]=(0,v.useState)(!1);if(r===null)return(0,I.jsx)(`p`,{className:`tab-note`,children:`reading…`});let o=r.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/),s=o?r.slice(o[0].length):r,c=fy(s);return(0,I.jsxs)(`div`,{className:`file-tab`,children:[(0,I.jsx)(`div`,{className:`tab-path`,children:t.file}),o&&(0,I.jsxs)(`div`,{className:`file-front`,children:[(0,I.jsxs)(`button`,{"aria-expanded":i,title:`The item's data block: what the board and the core read`,onClick:()=>a(!i),children:[i?`▾`:`▸`,` front matter`,(0,I.jsxs)(`span`,{className:`dim`,children:[o[1].split(/\r?\n/).length,` lines`]})]}),i&&(0,I.jsx)(`pre`,{className:`frontmatter`,children:o[1]})]}),c?c.map((e,t)=>(0,I.jsxs)(`section`,{className:`file-sec`,children:[(0,I.jsx)(`h3`,{children:my(e.key)}),e.rest&&(0,I.jsx)(`p`,{children:n(e.rest)}),e.bullets.length>0&&(0,I.jsx)(`ul`,{children:e.bullets.map((e,t)=>(0,I.jsxs)(`li`,{children:[e.lead&&(0,I.jsxs)(`span`,{className:`file-lead`,children:[e.lead,`: `]}),n(e.text)]},t))}),e.cards.length>0&&(0,I.jsx)(`ol`,{className:`file-cards`,children:e.cards.map((e,t)=>(0,I.jsx)(`li`,{children:e.map(([e,t],r)=>(0,I.jsxs)(`span`,{className:`file-card-row`,children:[(0,I.jsx)(`span`,{children:my(e)}),(0,I.jsx)(`span`,{children:n(t)})]},r))},t))}),e.table&&(0,I.jsxs)(`table`,{className:`file-table`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsx)(`tr`,{children:e.table.cols.map((e,t)=>(0,I.jsx)(`th`,{children:my(e)},t))})}),(0,I.jsx)(`tbody`,{children:e.table.rows.map((e,t)=>(0,I.jsx)(`tr`,{children:e.map((e,t)=>(0,I.jsx)(`td`,{children:n(e)},t))},t))})]})]},t)):(0,I.jsx)(`div`,{className:`md`,children:(0,I.jsx)(Jp,{urlTransform:_y(e.project,t.file),remarkPlugins:Ky,children:s})})]})}function ab({ctx:e,item:t}){let n=t.plan,r=rb(e,t.plan_file,`${JSON.stringify(n)} ${e.board.plans_rev??0}`);return t.plan_file?(0,I.jsxs)(`div`,{className:`plan-tab`,children:[n&&!(`error`in n)&&(0,I.jsxs)(`div`,{className:`plan-head`,title:`Plan checkboxes done / total`,children:[(0,I.jsxs)(`span`,{children:[n.done,` / `,n.tasks,` checked`]}),(0,I.jsx)(`span`,{className:`bar ok`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{style:{width:`${Math.round(100*n.done/Math.max(1,n.tasks))}%`}})})]}),n&&`error`in n&&(0,I.jsxs)(`div`,{role:`alert`,className:`plan-error`,children:[(0,I.jsx)(`span`,{children:`✘ The framework cannot read the plan`}),(0,I.jsx)(`pre`,{children:n.error})]}),(0,I.jsx)(`div`,{className:`tab-path`,children:t.plan_file}),r===null?(0,I.jsx)(`p`,{className:`tab-note`,children:`reading…`}):(0,I.jsx)(`div`,{className:`md`,children:(0,I.jsx)(Jp,{urlTransform:_y(e.project,t.plan_file),remarkPlugins:Ky,children:r})})]}):(0,I.jsx)(`p`,{className:`tab-note`,children:`No plan yet: the run writes the plan first.`})}function ob({ctx:e,item:t}){let[n,r]=(0,v.useState)(``),i=(0,v.useRef)(null);return(0,v.useEffect)(()=>F(e.project.name,t.id,()=>r(``),e=>r(t=>(t+e).slice(-262144))),[e.project.name,t.id]),(0,v.useEffect)(()=>{i.current?.scrollIntoView({block:`end`})},[n]),t.running_kind===`session`&&t.running?(0,I.jsx)(`div`,{className:`tab-empty`,children:`An interactive session writes no log. It is your own agent session: follow it in your terminal.`}):(0,I.jsxs)(`div`,{className:`log`,"aria-live":`polite`,"aria-relevant":`additions`,children:[(0,I.jsx)(ub,{text:n}),(0,I.jsx)(`div`,{ref:i})]})}function sb({ctx:e,id:t,part:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),s=n.item.log;return(0,v.useEffect)(()=>{let n=!0;return(s?k.logPart(e.project.name,t,s.from,s.to):k.file(e.project.name,`.gcf-session/runs/${t}.log`).then(e=>({...e,cut:0}))).then(e=>n&&i(e),e=>n&&o(e.message)),()=>{n=!1}},[e.project.name,t,s]),a?(0,I.jsxs)(`p`,{className:`tab-note error-text`,children:[`✘ `,a]}):r?(0,I.jsxs)(`div`,{className:`log`,children:[r.cut>0&&(0,I.jsxs)(`div`,{className:`tab-note`,children:[`…the first `,r.cut.toLocaleString(`en`),` bytes of this part are cut: 2 MB at most`]}),(0,I.jsx)(ub,{text:r.text})]}):(0,I.jsx)(`p`,{className:`tab-note`,children:`reading…`})}var cb=400;function lb({text:e}){let[t,n]=(0,v.useState)(!1);return t||e.length<=cb?(0,I.jsx)(`span`,{children:e}):(0,I.jsxs)(`span`,{children:[e.slice(0,cb),`…`,` `,(0,I.jsxs)(`button`,{type:`button`,className:`link-btn small`,onClick:()=>n(!0),children:[`all `,e.length,` characters`]})]})}function ub({text:e}){let t=yy(e);return(0,I.jsxs)(I.Fragment,{children:[!t.length&&(0,I.jsx)(`div`,{className:`tab-empty`,children:`no output yet`}),t.map((e,t)=>e.kind===`start`?(0,I.jsxs)(`div`,{className:`log-start`,children:[(0,I.jsxs)(`span`,{children:[`▸ `,by(e.text),` · `,e.time]}),(0,I.jsx)(`span`,{children:e.text})]},t):e.kind===`summary`?(0,I.jsxs)(`div`,{className:`log-summary`,children:[`■ `,e.time,` `,e.text]},t):(0,I.jsxs)(`div`,{className:`log-line log-${e.kind}`,children:[(0,I.jsx)(`span`,{children:e.time}),(0,I.jsx)(lb,{text:e.text})]},t))]})}function db({ctx:e,id:t,part:n}){let r=Mv(j(e.project.name,{item:t})),{from:i,to:a}=n.span,[o,s]=[i?Date.parse(i):-1/0,Date.parse(a)],c=r.filter(e=>Date.parse(e.at)>=o&&Date.parse(e.at)<=s),l=(0,v.useRef)(null),u={key:`part-${n.run.ended}`,events:c,talk:null,item:t,send:async()=>{},imageUrl:n=>`/api/p/${encodeURIComponent(e.project.name)}/chat/${t}/att/${n.split(`/`).pop()}`,imagePath:e=>`.gcf-session/runs/${e}`};return(0,I.jsxs)(`div`,{className:`item-chat part`,children:[(0,I.jsxs)(`div`,{className:`c-stream`,role:`log`,ref:l,children:[!c.length&&(0,I.jsx)(`div`,{className:`tab-empty`,children:`No chat event in this run's time.`}),(0,I.jsx)(Gv,{ctx:e,part:u})]}),(0,I.jsx)(Oy,{stream:l})]})}function fb({ctx:e,item:t,f:n}){let r=Ir(t,n),i=t[n.key],a=n.kind===`ids`||n.key===`parent`?Array.isArray(i)?i:[i]:null;if(!a)return(0,I.jsx)(I.Fragment,{children:r});let o=new Set(e.board.items.map(e=>e.id)),s=new Set((e.board.history??[]).map(e=>e.id)),c=new Set((e.board.graveyard??[]).map(e=>e.id));return(0,I.jsx)(I.Fragment,{children:a.map(t=>o.has(String(t))?(0,I.jsx)(`button`,{className:`link-btn mono`,onClick:()=>e.openItem(String(t)),children:String(t)},String(t)):s.has(String(t))?(0,I.jsxs)(`span`,{className:`fact-ended`,title:`ended: accepted, in history`,children:[String(t),` ✔`]},String(t)):c.has(String(t))?(0,I.jsxs)(`span`,{className:`fact-ended`,title:`ended: in the graveyard`,children:[String(t),` ✝`]},String(t)):(0,I.jsxs)(`span`,{className:`fact-ended`,title:`not on the board: no item has this id`,children:[String(t),` ?`]},String(t)))})}function pb(e){let t=Math.max(0,Math.round((Date.now()-Date.parse(e))/6e4));return Number.isNaN(t)?``:t<60?`${t} min`:t<1440?`${Math.round(t/60)} h`:`${Math.round(t/1440)} d`}function mb({ctx:e,e:t}){let{domain:n}=e.board,r=Tr(n,n.sections.inbox?.drop),{title:i,rest:a}=Lo(t),[o,s]=(0,v.useState)(!1),c=e.talks.find(e=>e.entry===t.id&&e.title),l=$a(e.board.quota),u=async()=>{if(c)return e.go(`chat`,c.id);s(!0);try{let n=await k.draft(e.project.name,t.id);e.reloadTalks(),e.go(`chat`,n.thread)}catch(t){e.notify(t.message,`error`)}s(!1)};return(0,I.jsxs)(`div`,{className:`d-lesson`,children:[(0,I.jsxs)(`span`,{className:`d-lesson-side`,children:[(0,I.jsx)(`span`,{children:t.detail??``}),t.at&&(0,I.jsx)(`span`,{className:`d-lesson-age`,children:pb(t.at)})]}),(0,I.jsxs)(`span`,{className:`d-lesson-main`,children:[(0,I.jsx)(`span`,{className:`d-lesson-text`,children:t.text}),(0,I.jsxs)(`span`,{className:`d-lesson-acts`,children:[n.new_item&&(0,I.jsx)(`button`,{className:`btn`,title:`Opens the new-item form from this lesson; the lesson is erased when the item is created`,onClick:()=>e.newItem({from:t.id,title:i,note:a}),children:`→ Item`}),n.chat&&n.new_item&&(0,I.jsx)(jo,{size:`sm`,glyph:`draft`,label:`Draft with agent`,off:!c&&!!l,starting:o,hasThread:!!c,tip:c?`Opens its thread ${c.id}; sends nothing`:l?`Off until ${oi(l)}: the usage limit holds`:`Opens a project chat thread on this lesson: the agent proposes an item from it, or says none is needed`,onClick:()=>void(o||u())}),r&&(0,I.jsx)(Na,{label:`Erase`,tip:`Erase the lesson (gcf inbox drop)`,onClick:()=>e.erase(r.cmd,t.id)})]})]})]})}function hb({ctx:e,id:t,waits:n}){let r=ra(e.board,t,n),i={item:``,unit:`unit`,grave:`✝`,history:`✔`,unknown:`?`}[r.kind],a=e.board.items.find(e=>e.id===t)?.type;return(0,I.jsxs)(`div`,{className:`dep-line`,title:r.tip,children:[(0,I.jsx)(`span`,{className:`mono dim`,children:r.kind===`item`?(a??``).slice(0,3).toUpperCase():i}),(0,I.jsxs)(`span`,{className:`dep-what`,children:[r.kind===`unit`||r.kind===`unknown`?(0,I.jsx)(`span`,{className:`mono`,children:t}):(0,I.jsx)(`button`,{className:`link-btn mono`,onClick:()=>e.openItem(t),children:t}),(0,I.jsx)(`span`,{className:`dep-state tone-${r.tone}`,children:r.state})]})]})}function gb({ctx:e,item:t}){let{domain:n}=e.board,r=n.fields.find(e=>e.key===`depends`),i=r?.edit&&t.moves.includes(r.edit)?Tr(n,r.edit):null,a=ia(t),o=aa(t),s=t.waits_for??[],c=(e,t)=>n.fields.find(t=>t.key===e)?.label??t;return(0,I.jsxs)(`section`,{className:`d-deps`,"aria-label":`Dependencies`,children:[(0,I.jsxs)(`div`,{className:`d-deps-head`,children:[(0,I.jsx)(`span`,{children:`Dependencies`}),i&&(0,I.jsx)(`button`,{className:`btn`,disabled:t.running,title:t.running?`Not while it runs`:`Add or remove a dependency: the depends move`,onClick:()=>e.openMove({title:`Dependencies of ${t.id}`,id:t.id,move:i}),children:`Edit…`})]}),(0,I.jsxs)(`div`,{className:`d-deps-cols`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`d-deps-sub`,title:`Its depends that have not ended in history`,children:[c(`needs`,`needs`),` · `,a.length]}),!a.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`nothing: every dependency has ended`}),a.map(t=>(0,I.jsx)(hb,{ctx:e,id:t,waits:s},t)),a.length>0&&(0,I.jsxs)(`span`,{className:`dim small`,children:[`⧗`,` `,s.length?`the run gate waits for ${s.join(`, `)}`:`none of them holds a run back`]})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`d-deps-sub`,title:`The items on the board whose depends name it`,children:[c(`needed_by`,`needed by`),` · `,o.length]}),!o.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`no item depends on it`}),o.map(t=>(0,I.jsx)(hb,{ctx:e,id:t,waits:[]},t))]})]})]})}var _b=(e,t)=>e.split(/[^a-z0-9-]+/).includes(t),vb={run:[`run`,`an agent run`],thread:[`thread`,`a board chat`],session:[`session`,`your own agent session`],operator:[`operator`,`you: a console or the board`]};function yb({ctx:e,id:t,onPart:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(new Set),{board:l}=e,u=Ni(l),d=JSON.stringify([l.head,l.items.find(e=>e.id===t)?.running,l.runs?.reports?.length]);if((0,v.useEffect)(()=>{if(!u)return;let n=!0;return k.history(e.project.name,t).then(e=>{n&&(i(e),o(``))},e=>n&&o(e.message)),()=>{n=!1}},[e.project.name,t,u,d]),!u)return(0,I.jsxs)(`div`,{role:`note`,className:`empty-box chat-old`,children:[(0,I.jsxs)(`b`,{children:[`History needs gcf-aif-ext ≥ `,Oi.replace(/\.0$/,``),`: this project has`,` `,ji(l)??`an older one`,`.`]}),(0,I.jsx)(`code`,{children:`update gcf-aif-ext`})]});if(a)return(0,I.jsxs)(`p`,{className:`tab-note error-text`,children:[`✘ `,a]});if(!r)return(0,I.jsx)(`p`,{className:`tab-note`,children:`reading…`});let f=l.domain.moves;return(0,I.jsxs)(`div`,{className:`history`,children:[(0,I.jsxs)(`section`,{"aria-label":`Its moves`,children:[(0,I.jsx)(`span`,{className:`d-deps-sub`,children:`Its moves · newest first`}),!r.moves.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`no move yet`}),(0,I.jsx)(`ol`,{className:`h-moves`,children:r.moves.map((e,n)=>{let r=f[e.move],i=e.by?vb[e.by]:null,a=s.has(n);return(0,I.jsxs)(`li`,{children:[(0,I.jsxs)(`button`,{"aria-expanded":a,title:e.subject,onClick:()=>{let e=new Set(s);a?e.delete(n):e.add(n),c(e)},children:[(0,I.jsx)(`span`,{className:`mono dim`,children:Ly(e.at)}),(0,I.jsxs)(`span`,{className:r?`h-move`:`h-move mono`,title:r?`move ${e.move}${r.help?` · ${r.help}`:``}`:`move ${e.move}: the domain has no form for it`,children:[r?.label??e.move,!_b(e.subject,t)&&(0,I.jsxs)(`span`,{className:`dim small`,children:[` · `,e.subject]})]}),(0,I.jsx)(`span`,{className:i?`small`:`dim small`,title:i?i[1]:`A commit older than the framework's marks: who made it is not known`,children:i?i[0]:`unknown`}),(0,I.jsxs)(`span`,{className:`mono small`,children:[a?`▾`:`▸`,` `,e.commit]})]}),a&&(0,I.jsx)(`code`,{className:`h-subject`,children:e.subject})]},`${e.commit}-${n}`)})})]}),(0,I.jsxs)(`section`,{"aria-label":`Its runs`,children:[(0,I.jsx)(`span`,{className:`d-deps-sub`,children:`Its runs`}),Pi(l)?r.runs.length?r.runs.map((i,a)=>(0,I.jsx)(Wy,{ctx:e,run:i,only:t,list:r.runs,onPart:(e,t)=>n(t)},i.id??`old-${i.ended}-${a}`)):(0,I.jsx)(`span`,{className:`dim small`,children:`no run in the run log`}):(0,I.jsx)(`span`,{className:`dim small`,children:l.domain.harness?`Past runs need gcf-harness-aif-ext ≥ ${Oi.replace(/\.0$/,``)}.`:`No harness: its runs went from a console.`})]})]})}function bb({ctx:e,item:t}){let{board:n}=e,r=t.parent?n.items.find(e=>e.id===t.parent):void 0,i=r?r.children.filter(e=>e!==t.id):t.parent?n.items.filter(e=>e.parent===t.parent&&e.id!==t.id).map(e=>e.id):[],a=n.domain.sections.graveyard?.match,o=a?ca(t,a):[],s=o.length?(n.graveyard??[]).filter(e=>e.tags.some(e=>o.includes(e))):[];return(0,I.jsxs)(`div`,{className:`related`,children:[(0,I.jsx)(`section`,{"aria-label":`Siblings`,children:t.parent?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`d-deps-sub`,children:[`Siblings under `,r?.title??t.parent,` · `,i.length,` `,(0,I.jsx)(`button`,{className:`link-btn mono`,onClick:()=>e.openItem(t.parent??``),children:t.parent})]}),i.map(t=>{let r=ra(n,t);return(0,I.jsxs)(`button`,{className:`rel-row`,title:r.tip,onClick:()=>e.openItem(t),children:[(0,I.jsx)(`span`,{className:`mono`,children:t}),(0,I.jsx)(`span`,{className:`badge tone-${r.tone}`,children:r.state})]},t)})]}):(0,I.jsx)(`span`,{className:`dim small`,children:t.children.length?`A feature with no parent: its children are listed above.`:`No parent feature: it has no siblings.`})}),a&&n.domain.sections.graveyard&&(0,I.jsxs)(`section`,{"aria-label":`Graveyard hits`,children:[(0,I.jsxs)(`span`,{className:`d-deps-sub`,children:[`Did we kill this before? Graveyard lines tagged with its `,a,o.length?`: ${o.join(`, `)}`:``]}),!s.length&&(0,I.jsx)(`span`,{className:`dim small`,children:o.length?`No graveyard line holds ${o.join(`, `)}.`:`It has no ${a} to match.`}),s.map((t,n)=>(0,I.jsxs)(`button`,{className:`rel-grave`,onClick:()=>e.openItem(t.id),children:[(0,I.jsxs)(`span`,{className:`rel-grave-line`,children:[t.type&&(0,I.jsx)(`span`,{className:`mono dim`,children:t.type.slice(0,3).toUpperCase()}),(0,I.jsxs)(`span`,{className:`mono strong`,children:[`✝ `,t.id]}),t.tags.map(e=>(0,I.jsxs)(`span`,{className:`mono small ${o.includes(e)?`strong`:`dim`}`,children:[`#`,e]},e))]}),t.reason&&(0,I.jsx)(`span`,{className:`small`,children:t.reason})]},`${t.id}-${n}`))]}),(0,I.jsx)(`span`,{className:`dim small`,children:`Its dependencies are above, under Dependencies.`})]})}function xb({id:e,part:t,onClear:n}){let r=Ly(t.run.started??t.run.ended),i=t.item.log,a=t.kind===`log`?i?`The part of the log the run of ${r} wrote: bytes ${i.from.toLocaleString(`en`)}–${i.to.toLocaleString(`en`)}. ${e}'s log holds every run.`:`A run older than log parts (ended ${Ly(t.run.ended)}): its whole log.`:`The chat of the run of ${r}.`;return(0,I.jsxs)(`div`,{role:`note`,className:`part-note`,children:[(0,I.jsx)(`span`,{children:a}),(0,I.jsx)(`button`,{className:`icon-btn`,"aria-label":t.kind===`log`?`Show the whole log`:`Show the whole chat`,title:`Back to the whole log and chat`,onClick:n,children:`×`})]})}function Sb({ctx:e,id:t,part:n,onClose:r}){let[i,a]=(0,v.useState)(n??null),[o,s]=(0,v.useState)(!1),c=eb(),{board:l}=e,u=l.history?.find(e=>e.id===t),d=l.graveyard?.find(e=>e.id===t),f=l.domain.sections;return(0,I.jsxs)(`aside`,{className:`drawer`,"aria-label":`Item ${t}`,...c,children:[(0,I.jsx)(`div`,{className:`d-head`,title:`Drag to move the window`,children:(0,I.jsxs)(`div`,{className:`d-top`,children:[(0,I.jsx)(`button`,{className:`d-back`,"aria-label":`Back`,onClick:r,children:`‹`}),(0,I.jsxs)(`div`,{className:`d-name`,children:[(0,I.jsxs)(`div`,{className:`d-meta`,children:[(0,I.jsx)(`span`,{className:d?`error-text`:`ok-text`,children:d?f.graveyard?.label??`graveyard`:f.history?.label??`history`}),d?.type&&(0,I.jsx)(`span`,{className:`d-dot`,children:d.type})]}),(0,I.jsx)(`h2`,{children:(0,I.jsx)(`span`,{className:`d-id`,children:t})})]}),(0,I.jsx)(`button`,{className:`icon-btn bordered d-close`,"aria-label":`Close`,onClick:r,children:`×`})]})}),(0,I.jsxs)(`div`,{role:`tablist`,className:`d-tabs`,children:[(0,I.jsx)(`button`,{role:`tab`,"aria-selected":o,onClick:()=>{s(!0),a(null)},children:`Status`}),(0,I.jsx)(`button`,{role:`tab`,"aria-selected":!o&&!i,onClick:()=>{s(!1),a(null)},children:`History`}),i&&(0,I.jsx)(`button`,{role:`tab`,"aria-selected":!0,children:i.kind===`log`?`Log`:`Chat`})]}),(0,I.jsx)(`div`,{className:`d-body`,children:(0,I.jsxs)(`div`,{role:`tabpanel`,className:`d-panel`,children:[o&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`dl`,{className:`facts`,children:d?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`reason`}),(0,I.jsx)(`dd`,{children:d.reason??`—`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`tags`}),(0,I.jsx)(`dd`,{className:`mono`,children:d.tags.map(e=>`#${e}`).join(` `)||`—`})]})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`event`}),(0,I.jsx)(`dd`,{children:u?.event??`—`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`date`}),(0,I.jsx)(`dd`,{children:u?.date??`—`})]})]})}),(0,I.jsxs)(`p`,{className:`d-ended dim small`,children:[d?`It ended in the graveyard`:`It ended in history`,`; it keeps its History.`]})]}),!o&&!i&&(0,I.jsx)(yb,{ctx:e,id:t,onPart:e=>{s(!1),a(e)}}),i&&(0,I.jsx)(xb,{id:t,part:i,onClear:()=>a(null)}),i?.kind===`log`&&(0,I.jsx)(sb,{ctx:e,id:t,part:i}),i?.kind===`chat`&&(0,I.jsx)(db,{ctx:e,id:t,part:i})]})})]})}function Cb(e){let t=(0,v.useRef)(!1);return(0,v.useEffect)(()=>{if(!t.current)return;t.current=!1;let n=document.activeElement;(!n||n===document.body)&&e()?.focus()}),(0,v.useCallback)(e=>{if(e)return()=>{e===document.activeElement&&(t.current=!0)}},[])}function wb({ctx:e,item:t,tab:n,part:r,onClose:i}){let[a,o]=(0,v.useState)(qy.includes(n)?n:t.blocked||t.waits_for?.length?`status`:t.running&&t.running_kind!==`session`?`chat`:`file`),[s,c]=(0,v.useState)(r??null),l=s&&s.kind===a?s:null,[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(!1),g=t.running&&!t.starting,_=e.board.runs?.queued.includes(t.id)??!1,y=e.board.runs?.active.some(e=>e.ids.includes(t.id))??!1,b=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!m)return void(b.current=!1);if(y&&(b.current=!0),g||_||b.current&&!y)return h(!1);let e=setTimeout(()=>h(!1),Qy);return()=>clearTimeout(e)},[m,g,_,y]);let x=f!==null||m||!!t.starting,S=(0,v.useRef)(null),C=Cb(()=>S.current?.querySelector(`button:not(:disabled)`)),w=async n=>{await e.run([t.id],n)&&h(!0)},T=(0,v.useRef)(!1),E=uy(T,async()=>{p(`gate`);try{if(!await se())return;p(`run`),await w(!1)}finally{p(null)}}),D=uy(T,async()=>{p(`fresh`);try{let n=await ae();await ie(`This drops the agent's context; its files are kept.`,`Start fresh`,!0,{title:`Start ${t.id} fresh?`,warn:n.length?{...oe(n),head:`It runs on main, among loose work`}:void 0,other:Ui(e,n)??void 0})&&await w(!0)}finally{p(null)}}),O=uy(T,async()=>{let n=t.denied_group??``;p(`allow`);try{if(!await e.move({cmd:`permissions`,off:[n]})||!await e.move({cmd:`unblock`,id:t.id}))return;await w(!1)}finally{p(null)}}),A=eb(),{domain:j}=e.board,M=j.sections.lessons?Eo(e.board.inbox??[],t.id):[],te=Er(t,j),N=kr(t,j),ne=Ar(t,j),P=di(t),F=t.running?{label:`running`,help:`An agent session works on it; its status: ${t.status}`}:j.columns.find(e=>e.status===t.status),re=G(t,e.board),L=typeof t.blocked==`string`&&t.blocked?t.blocked:null,R=t.waits_for??[],z=zi(e,ne&&!_&&!t.running?[t.id]:null),B=z.refused[t.id]??null,ae=async()=>mi(e.board,t.id)===`main`?z.dirty??await k.gate(e.project.name,[t.id]).then(e=>e.dirty??[],()=>[]):[],oe=e=>({head:`Loose work in the project folder`,text:Bi(e)}),se=async()=>{let n=await ae();return!n.length||ie(`${t.id} runs on main, in the project folder. A warning, not a refusal: you judge.`,`Run anyway`,!1,{title:`Run ${t.id} here anyway?`,warn:oe(n),other:Ui(e,n)??void 0})},ce=t.plan&&!(`error`in t.plan)?t.plan:null,V=e=>({...Object.fromEntries(e.fields.filter(e=>e.presets).map(e=>[e.key,`default`])),...Object.fromEntries(j.fields.filter(n=>n.edit===e.cmd&&typeof t[n.key]==`string`).map(e=>[e.key,t[e.key]]))}),H=n=>e.openMove({title:`${n.label} ${t.id}`,id:t.id,move:n,values:V(n)}),U=e=>e.edit&&t.moves.includes(e.edit)?Tr(j,e.edit):null,le=n=>Ir(t,n)===null&&(n.key===`model`||n.key===`effort`)?e.board.agent?.[n.key]??null:null,ue=j.fields.filter(e=>e.key===`model`||e.key===`effort`),de=n=>yi(Ir(t,n)??le(n)??Ci(e.board,n.key)??`default`),fe=e=>`${e.label}: ${Ir(t,e)===null?le(e)===null?`nothing set: the default holds`:`the project's (Settings, agent.*)`:`its own`}`,pe=ue[0]&&!t.running?U(ue[0]):null,W=Jy.map(e=>j.fields.find(t=>t.key===e)).filter(e=>!!e&&Ir(t,e)!==null),me=j.fields.filter(n=>n.key!==`blocked`&&!(Jy.includes(n.key)&&!U(n))&&!(nb(e)?tb.has(n.key):n.key===`waits_for`)&&(ue.includes(n)?n===ue[0]:Ir(t,n)!==null)),he=[t.running?ii(t):null,P?`limit: resumes ${oi(P)}`:null,t.resumable&&!t.running?li(t):null,_?`queued`:null,t.verified?`✔ verified`:null].filter(Boolean);return(0,I.jsxs)(`aside`,{className:`drawer`,"aria-label":`Item ${t.id}`,...A,children:[(0,I.jsxs)(`div`,{className:`d-head`,title:Xy.matches?void 0:`Drag to move the window`,children:[(0,I.jsxs)(`div`,{className:`d-top`,children:[(0,I.jsx)(`button`,{className:`d-back`,"aria-label":`Back`,onClick:i,children:`‹`}),(0,I.jsxs)(`div`,{className:`d-name`,children:[(0,I.jsxs)(`div`,{className:`d-meta`,children:[re?(0,I.jsxs)(`span`,{className:`d-needs`,title:`status: ${F?.label??t.status} · ${F?.help??``} Only you can move it on.`,children:[`● `,F?.label??t.status]}):(0,I.jsx)(`span`,{className:`d-status`,title:`status: ${F?.label??t.status}${F?.help?` · ${F.help}`:``}`,children:F?.label??t.status}),W.map(e=>(0,I.jsx)(`span`,{className:`d-dot ${e.key===`gate`?`gate-text gate-${t.gate}`:``}`,title:`${e.label}: ${Ir(t,e)}${e.help?` · ${e.help}`:``}`,children:Ir(t,e)},e.key)),he.map(e=>(0,I.jsx)(`span`,{className:`d-state d-dot`,title:e.startsWith(`limit`)?ui:e.startsWith(`paused`)||e===`interrupted`?ci(t):void 0,children:e},e)),t.running&&t.running_kind!==`session`&&t.active_at&&!P&&(0,I.jsx)(ei,{at:t.active_at})]}),(0,I.jsxs)(`h2`,{children:[(0,I.jsx)(`span`,{className:`d-id`,children:t.id}),t.title&&(0,I.jsxs)(`span`,{className:`d-title`,children:[`(`,t.title,`)`]})]})]}),(0,I.jsx)(`button`,{className:`icon-btn bordered d-close`,"aria-label":`Close`,onClick:i,children:`×`})]}),(0,I.jsxs)(`div`,{className:`d-acts`,ref:S,children:[t.running&&t.running_kind===`session`&&(0,I.jsx)(`button`,{className:`btn`,title:`A session's mark makes it running; your own session goes on`,onClick:async()=>{await ie(`Release the session mark on ${t.id}?`,`Release mark`)&&e.move({cmd:`release`,id:t.id})},children:`Release mark`}),g&&t.running_kind!==`session`&&(0,I.jsx)(`button`,{className:`btn-danger`,title:P?`Ends the wait for the reset: it becomes paused: limit, and Run resumes it later`:`Stops the agent session; the item stays ready and its work is kept`,onClick:()=>void Yi(e,t),children:`Stop`}),_&&(0,I.jsx)(`button`,{className:`btn`,title:`Takes it out of the run queue; it asks nothing`,onClick:()=>void e.unqueue(t.id),children:`Remove from queue`}),ne&&!_&&!g&&(0,I.jsx)(`button`,{className:`btn-primary`,ref:C,onClick:()=>x||void E(),disabled:B!==null,"aria-disabled":x||void 0,"aria-busy":f===`gate`||f===`run`||m||t.starting,title:B?`The run gate refuses it now: ${B}`:t.resumable?`Goes on from where its last run stopped`:N?.help??`Starts at once: you named this item. The run gate may still refuse; the run report says why.`,children:f===`gate`?`Asking the gate…`:f===`run`||m||t.starting?`Starting…`:t.resumable?`Resume`:N?.label??`Run`}),ne&&!_&&!t.running&&t.resume&&t.resume.ended!==`handoff`&&(0,I.jsx)(`button`,{className:`btn`,ref:C,disabled:B!==null,"aria-disabled":x||void 0,"aria-busy":f===`fresh`,title:B?`The run gate refuses it now: ${B}`:`A new agent session: the kept one, and what it knew, is dropped`,onClick:()=>x||void D(),children:f===`fresh`?`Asking the gate…`:`Start fresh`}),!t.running&&te.filter(e=>!e.rare).map(e=>(0,I.jsx)(`button`,{className:Or(e),title:e.help,disabled:x,onClick:()=>H(e),children:e.label},e.cmd)),te.some(e=>e.rare)&&(0,I.jsxs)(`button`,{className:`btn-line`,"aria-expanded":u,onClick:()=>d(!u),children:[u?`▾`:`▸`,` More`]}),u&&te.filter(e=>e.rare).map(e=>(0,I.jsx)(`button`,{className:Or(e),title:e.help,disabled:x,onClick:()=>H(e),children:e.label},e.cmd))]})]}),(0,I.jsx)(`div`,{role:`tablist`,className:`d-tabs`,children:qy.filter(e=>e!==`lessons`||j.sections.lessons).map(e=>(0,I.jsxs)(`button`,{role:`tab`,"aria-selected":e===a,onClick:()=>o(e),children:[e[0].toUpperCase()+e.slice(1),e===`lessons`?` (${M.length})`:``]},e))}),(0,I.jsx)(`div`,{className:`d-body`,children:(0,I.jsxs)(`div`,{role:`tabpanel`,className:`d-panel ${a===`chat`&&!l?`chat`:``}`,children:[a===`status`&&(0,I.jsxs)(I.Fragment,{children:[t.run_end&&!t.running&&(0,I.jsx)(iy,{ctx:e,id:t.id,end:t.run_end}),L&&(0,I.jsxs)(`div`,{role:`note`,className:`d-blocked`,children:[(0,I.jsx)(`span`,{children:`! Blocked`}),(0,I.jsx)(`span`,{children:L}),t.denied_group&&(0,I.jsxs)(`div`,{className:`d-allow`,children:[(0,I.jsx)(`button`,{className:`btn-primary`,ref:C,"aria-disabled":x||void 0,"aria-busy":f===`allow`,title:`Three steps in one: the deny group ${t.denied_group} off for every agent run (Agent permissions turns it back on), the unblock, the run`,onClick:()=>x||void O(),children:f===`allow`?`Allowing…`:`Allow ${t.denied_group} and run again`}),(0,I.jsx)(`span`,{className:`dim small`,children:`the group off, the unblock, the run`})]})]}),B?(0,I.jsxs)(`div`,{className:`d-waits`,children:[`⧗ the run gate refuses it now: `,B]}):R.length>0&&(0,I.jsxs)(`div`,{className:`d-waits`,children:[`⧗ waits for `,R.join(`, `),` — the run gate would refuse it now`]}),t.running&&ce&&(0,I.jsxs)(`div`,{className:`d-run`,children:[(0,I.jsx)(`div`,{className:`d-run-head`,children:`This run`}),(0,I.jsxs)(`div`,{className:`live-plan`,title:`Plan checkboxes done / total`,children:[(0,I.jsx)(`span`,{children:`tasks`}),(0,I.jsx)(`span`,{className:`bar`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{style:{width:`${Math.round(100*ce.done/Math.max(1,ce.tasks))}%`}})}),(0,I.jsxs)(`span`,{className:`mono`,children:[ce.done,` of `,ce.tasks]})]})]}),(0,I.jsxs)(`dl`,{className:`facts`,children:[me.map(n=>n===ue[0]?(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:ue.map(e=>e.label).join(` / `)}),(0,I.jsxs)(`dd`,{title:ue.map(fe).join(` · `),children:[ue.map(de).join(` / `),pe&&(0,I.jsx)(`button`,{className:`link-btn`,title:pe.help,onClick:()=>H(pe),children:`change`})]})]},n.key):(0,I.jsxs)(`div`,{title:n.help,children:[(0,I.jsx)(`dt`,{children:n.label}),(0,I.jsxs)(`dd`,{title:Lr(n,Ir(t,n)??``),children:[(0,I.jsx)(fb,{ctx:e,item:t,f:n}),U(n)&&(0,I.jsx)(`button`,{className:`link-btn`,title:U(n)?.help,onClick:()=>H(U(n)),children:`change`})]})]},n.key)),t.since&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`waits since`}),(0,I.jsxs)(`dd`,{title:t.since,children:[t.since_at?`${ai(t.since_at)} · `:``,(0,I.jsx)(`span`,{className:`mono`,children:t.since.slice(0,7)})]})]})]}),nb(e)&&(0,I.jsx)(gb,{ctx:e,item:t}),(t.attachments??[]).length>0&&(0,I.jsx)(`div`,{className:`entry-atts`,role:`group`,"aria-label":`Attachments`,children:(t.attachments??[]).map(t=>(0,I.jsxs)(`a`,{className:`entry-att`,title:t,href:ee(e.project.name,t),target:`_blank`,rel:`noreferrer`,children:[`▣ `,t.split(`/`).pop()]},t))})]}),a===`lessons`&&(0,I.jsxs)(`div`,{className:`d-lessons`,children:[!M.length&&(0,I.jsx)(`span`,{className:`d-lessons-none`,children:`No lesson from its sessions yet.`}),M.map(t=>(0,I.jsx)(mb,{ctx:e,e:t},t.id))]}),l&&(0,I.jsx)(xb,{id:t.id,part:l,onClear:()=>c(null)}),a===`chat`&&(l?(0,I.jsx)(db,{ctx:e,id:t.id,part:l}):(0,I.jsx)(Py,{ctx:e,item:t})),a===`file`&&(0,I.jsx)(ib,{ctx:e,item:t}),a===`plan`&&(0,I.jsx)(ab,{ctx:e,item:t}),a===`log`&&(l?(0,I.jsx)(sb,{ctx:e,id:t.id,part:l}):(0,I.jsx)(ob,{ctx:e,item:t})),a===`history`&&(0,I.jsx)(yb,{ctx:e,id:t.id,onPart:e=>{c(e),o(e.kind)}}),a===`related`&&(0,I.jsx)(bb,{ctx:e,item:t})]})})]})}function Tb({ctx:e}){let{history:t=[],graveyard:n=[]}=e.board,{sections:r}=e.board.domain;return(0,I.jsxs)(`section`,{className:`page ended`,"aria-label":`Ended`,children:[r.history&&(0,I.jsxs)(`section`,{"aria-label":r.history.label??`History`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[r.history.label??`History`,(0,I.jsx)(`span`,{className:`dim`,children:t.length}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),!t.length&&(0,I.jsx)(`p`,{className:`dim small`,children:`Nothing ended yet.`}),t.length>0&&(0,I.jsx)(`div`,{className:`ended-list`,children:[...t].reverse().map((t,n)=>(0,I.jsxs)(`button`,{className:`ended-row`,title:`Open its History`,onClick:()=>e.openItem(t.id),children:[(0,I.jsx)(`span`,{className:`mono`,children:t.id}),(0,I.jsx)(`span`,{className:`ok-text small`,title:`What ended it`,children:t.event}),(0,I.jsx)(`span`,{className:`mono dim small`,children:t.date})]},`${t.id}-${n}`))})]}),r.graveyard&&(0,I.jsxs)(`section`,{"aria-label":r.graveyard.label??`Graveyard`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[r.graveyard.label??`Graveyard`,(0,I.jsx)(`span`,{className:`dim`,children:n.length}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),!n.length&&(0,I.jsx)(`p`,{className:`dim small`,children:`Nothing was killed or dropped.`}),[...n].reverse().map((t,n)=>(0,I.jsxs)(`button`,{className:`grave-row`,title:`Open its History`,onClick:()=>e.openItem(t.id),children:[(0,I.jsxs)(`div`,{className:`grave-line`,children:[t.type&&(0,I.jsx)(`span`,{className:`mono dim small`,title:t.type,children:t.type.slice(0,3).toUpperCase()}),(0,I.jsx)(`span`,{className:`mono grave-id`,children:t.id}),t.tags.map(e=>(0,I.jsxs)(`span`,{className:`mono small entry-tag`,children:[`#`,e]},e))]}),t.reason&&(0,I.jsx)(`p`,{children:t.reason})]},`${t.id}-${n}`))]})]})}var Eb=60;function Db(e,t){let n=[...e.items].filter(e=>e.id!==t).sort((e,t)=>Number(e.priority===null)-Number(t.priority===null)||(e.priority??0)-(t.priority??0)).map(t=>({id:t.id,title:t.title??``,kind:t.type.slice(0,3).toUpperCase(),state:na(e,t),tone:t.running?`running`:t.status})),r=(e.units??[]).map(e=>({id:e.id,title:e.title??``,kind:`unit`,state:ta(e),tone:e.ready?`ok`:`warn`}));return[...n,...r]}function Ob({board:e,value:t,self:n,onChange:r,inputId:i,folded:a=!1}){let[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!a),u=o.trim().toLowerCase(),d=Db(e,n),f=d.filter(e=>!u||e.id.includes(u)||e.title.toLowerCase().includes(u)),p=f.slice(0,u?40:Eb),m=e=>{r(t.includes(e)?t.filter(t=>t!==e):[...t,e]),s(``)},h=e=>d.find(t=>t.id===e)?.title;return(0,I.jsxs)(`div`,{className:`picker`,children:[(0,I.jsxs)(`div`,{className:`picker-chips`,children:[!t.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`no dependency`}),t.map(t=>{let r=ra(e,t),i=t===n||r.kind===`unknown`||r.kind===`grave`,a=t===n?`itself`:r.state,o=h(t);return(0,I.jsxs)(`span`,{className:`picker-chip ${i?`bad`:``}`,title:a,children:[o?`${Rr(o,48)} (${t})`:t,(0,I.jsx)(`span`,{className:`dim`,children:a}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`Take ${o||t} out`,onClick:()=>m(t),children:`×`})]},t)}),(0,I.jsx)(`button`,{type:`button`,className:`picker-fold`,"aria-expanded":c,title:c?`Fold the list; the picked ones stay`:`Open the list of items and design units`,onClick:()=>l(!c),children:c?`▾ Hide the list`:`▸ Pick by title`})]}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{id:i,className:`input`,value:o,"aria-label":`Search items and design units`,placeholder:`search items and design units by title`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),p.length===1&&m(p[0].id))}}),(0,I.jsxs)(`div`,{role:`listbox`,"aria-multiselectable":!0,"aria-label":`Items and design units`,className:`picker-list`,children:[p.map(e=>{let n=t.includes(e.id);return(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:`picker-row`,onClick:()=>m(e.id),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:n?`☑`:`☐`}),(0,I.jsx)(`span`,{className:`mono dim`,children:e.kind}),(0,I.jsxs)(`span`,{className:`picker-label`,children:[e.title||e.id,` `,e.title&&(0,I.jsxs)(`span`,{className:`mono dim`,children:[`(`,e.id,`)`]})]}),(0,I.jsx)(`span`,{className:`picker-state tone-${e.tone}`,children:e.state})]},`${e.kind}:${e.id}`)}),!p.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`nothing matches`}),f.length>p.length&&(0,I.jsxs)(`span`,{className:`dim small`,children:[f.length-p.length,` more: type to narrow`]})]}),(0,I.jsxs)(`span`,{className:`dim small`,children:[t.length,` `,t.length===1?`dependency`:`dependencies`]})]})]})}function kb({ctx:e,id:t,current:n,open:r,onClose:i}){let{move:a,values:o={}}=r,[s,c]=(0,v.useState)(()=>[...new Set([...n,...Mr(o.add)].filter(e=>!Mr(o.remove).includes(e)))]),[l,u]=(0,v.useState)(!1),d=s.filter(e=>!n.includes(e)),f=n.filter(e=>!s.includes(e)),p=d.length>0||f.length>0;return(0,I.jsx)(R,{onClose:i,dirty:p,children:(0,I.jsxs)(`form`,{className:`dialog wide`,role:`dialog`,"aria-modal":!0,"aria-label":`Dependencies of ${t}`,onClick:e=>e.stopPropagation(),onSubmit:async n=>{n.preventDefault();let[s,c]=!p&&r.extra?[Mr(o.add),Mr(o.remove)]:[d,f];if(!s.length&&!c.length)return i();u(!0);let l=await e.move({cmd:a.cmd,id:t,...s.length?{add:s}:{},...c.length?{remove:c}:{},...r.extra});u(!1),l&&i()},children:[(0,I.jsxs)(`h2`,{children:[`Dependencies of `,t]}),(0,I.jsxs)(`p`,{className:`dialog-body`,children:[r.body?`${r.body} `:a.help?`${a.help}. `:``,`Tick what it waits for, untick what it no longer does. The framework refuses the item itself, a graveyard line and a cycle.`]}),(0,I.jsx)(Ob,{board:e.board,value:s,self:t,onChange:c}),(0,I.jsxs)(`div`,{className:`dialog-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`btn-line`,onClick:i,disabled:l,children:`Cancel`}),(0,I.jsx)(`button`,{type:`submit`,className:`btn-primary`,disabled:l,children:l?`Committing…`:`Save`})]})]})})}var Ab={tags:[`tags`,`short words, comma-separated`],list:[`one per line`,`a list: one entry per line`],slug:[`slug`,`lowercase letters, digits and hyphens`]},jb=[{value:``,label:`By the rule (default)`,help:`the command's own rule: a removal item when the item's code is in main`},{value:`yes`,label:`Yes, its code is in main`,help:`a new item deletes its code from the main build`},{value:`no`,label:`No`,help:`no removal item`}],Mb=`The phase's exit gate reads it: milestone-done closes the phase when nothing open of its milestone is left`,Nb=(e,t)=>t.from===`milestones`?sr(e)?.milestones??null:null,Pb={you:`you`,agent:`an agent`,automation:`automation`};function Fb({id:e,rows:t,value:n,onChange:r}){return(0,I.jsx)(`select`,{id:e,className:`input`,value:n,onChange:e=>r(e.target.value),children:t.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function Ib({id:e,board:t,value:n,onChange:r}){let[i,a]=(0,v.useState)(``),o=Br(t),s=Mr(n),c=i.trim().toLowerCase(),l=o.filter(e=>!s.includes(e)&&(!c||e.includes(c))).slice(0,14),u=c!==``&&!o.includes(c)&&!s.includes(c),d=u&&zr.test(c),f=(e,t)=>{r((t?[...s,e]:s.filter(t=>t!==e)).join(`, `)),t&&a(``)};return(0,I.jsxs)(`div`,{className:`picker`,children:[(0,I.jsxs)(`div`,{className:`picker-chips`,children:[s.map(e=>(0,I.jsxs)(`span`,{className:`picker-chip mono`,children:[e,!o.includes(e)&&(0,I.jsx)(`span`,{className:`f-new`,children:`new`}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`Take ${e} out`,onClick:()=>f(e,!1),children:`×`})]},e)),!s.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`no subsystem`})]}),(0,I.jsx)(`input`,{id:e,className:`input mono f-search`,value:i,"aria-label":`Subsystems`,placeholder:`search the known subsystems, or type a new slug`,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.key===`Enter`||e.key===`,`)&&(e.preventDefault(),d?f(c,!0):l.length===1&&f(l[0],!0))}}),(0,I.jsxs)(`div`,{className:`f-sugg`,children:[d&&(0,I.jsxs)(`button`,{type:`button`,className:`new`,onClick:()=>f(c,!0),children:[`+ new subsystem “`,c,`”`]}),l.map(e=>(0,I.jsxs)(`button`,{type:`button`,onClick:()=>f(e,!0),children:[`+ `,e]},e))]}),u&&!d&&(0,I.jsx)(`span`,{role:`alert`,className:`f-warn`,children:`a new subsystem is a slug: lowercase letters, digits and hyphens`})]})}function Lb({field:e,options:t,value:n,onChange:r}){return(0,I.jsx)(`div`,{role:`radiogroup`,"aria-label":e.label,className:`f-choice ${t.length>4?`wrap`:``}`,children:t.map(e=>(0,I.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n===e.value,title:e.help,onClick:()=>r(e.value),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:n===e.value?`●`:`○`}),(0,I.jsxs)(`span`,{children:[e.label||e.value||`—`,e.help&&(0,I.jsx)(`small`,{children:e.help})]})]},e.value))})}function Rb({id:e,field:t,value:n,onChange:r,presets:i,board:a,self:o,newItem:s,details:c}){if(t.kind===`file`)return(0,I.jsx)(Bb,{id:e,value:n,onChange:r});let l=Array.isArray(n)?n.join(`
80
- `):String(n??``);if(t.kind===`ids`&&t.single)return(0,I.jsx)(Fb,{id:e,rows:Hr(a,t,l),value:l,onChange:r});if(t.kind===`ids`)return(0,I.jsx)(Ob,{board:a,inputId:e,value:Mr(l),self:o,folded:s,onChange:e=>r(e.join(`, `))});if(s&&t.key===`system`)return(0,I.jsx)(Ib,{id:e,board:a,value:l,onChange:r});if(c)return(0,I.jsx)(Lb,{field:t,options:[{value:``,label:`no detail`},...c.map(e=>({value:e,label:e}))],value:l,onChange:r});if(t.presets)return(0,I.jsx)(Ei,{id:e,what:t.presets,presets:i?.[t.presets]??[],value:l,project:Si(a,t.presets),fallback:Ci(a,t.presets),onChange:r});let u=Nb(a,t);if(u)return(0,I.jsx)(Fb,{id:e,rows:Vr(u,l),value:l,onChange:r});let d=[`slug`,`ids`,`tags`].includes(t.kind)?`mono`:``;if(t.kind===`remove`)return(0,I.jsx)(Lb,{field:t,options:jb,value:n===!0?`yes`:n===!1?`no`:``,onChange:e=>r(e===`yes`||e!==`no`&&void 0)});if(t.kind===`choice`){let e=t.options??[];return(0,I.jsx)(Lb,{field:t,options:e,value:l,onChange:r})}let f=t.kind===`tags`?Mr(l).map(e=>({label:`#${e}`,tip:`tag`})):[];return(0,I.jsxs)(I.Fragment,{children:[t.kind===`longtext`||t.kind===`list`?(0,I.jsx)(`textarea`,{id:e,className:`input`,value:l,required:t.required,rows:t.kind===`longtext`?4:3,placeholder:t.kind===`list`?`one per line`:void 0,onChange:e=>r(t.kind===`list`?e.target.value.split(`
81
- `):e.target.value)}):(0,I.jsx)(`input`,{id:e,className:`input ${d}`,value:l,required:t.required,list:t.kind===`text`&&t.key===`id`?`move-form-ids`:void 0,pattern:t.kind===`slug`?`[a-z0-9]+(-[a-z0-9]+)*`:void 0,placeholder:t.kind===`tags`?`feel, touch`:t.kind===`slug`?`win-feedback`:void 0,onChange:e=>r(e.target.value)}),f.length>0&&(0,I.jsx)(`div`,{className:`f-chips`,children:f.map((e,t)=>(0,I.jsx)(`span`,{title:e.tip,children:e.label},t))})]})}var zb=10485760;function Bb({id:e,value:t,onChange:n}){let[r,i]=(0,v.useState)(``),a=typeof t==`string`?t.split(/[\\/]/).pop():t?.name;return(0,I.jsxs)(`div`,{className:`f-file`,children:[(0,I.jsxs)(`label`,{className:`f-file-btn`,children:[(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M20 11.5l-8.2 8.2a5 5 0 0 1-7.1-7.1l8.6-8.6a3.4 3.4 0 0 1 4.8 4.8l-8.6 8.6a1.7 1.7 0 0 1-2.4-2.4l7.9-7.9`})}),a?`Another file…`:`Choose a file…`,(0,I.jsx)(`input`,{id:e,type:`file`,onChange:async e=>{let t=e.target.files?.[0];if(e.target.value=``,t){if(t.size>zb)return i(`${t.name}: over 10 MB, the most an attachment takes`);i(``),n({name:t.name,data:await Pr(t)})}}})]}),(0,I.jsx)(`span`,{className:`f-file-name ${a?`mono`:`dim`}`,title:a,children:a??`no file yet`}),r&&(0,I.jsx)(`span`,{className:`f-err`,children:r})]})}var Vb=e=>(Array.isArray(e)?e.join(`
82
- `):String(e??``)).trim();function Hb({ctx:e,open:t,onClose:n}){let{move:r}=t,{domain:i}=e.board,a=(0,v.useId)(),o=r.cmd===i.new_item,s=o&&r.fields.some(e=>e.key===`blocked`),c=i.sections.inbox,l=r.cmd===c?.category?(e.board.inbox??[]).find(e=>e.id===t.id):void 0,[u]=(0,v.useState)(()=>Fr(r.fields,l?{category:l.category,detail:l.detail??``,...t.values}:t.values)),[d,f]=(0,v.useState)(u),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(void 0),[S,C]=(0,v.useState)(()=>Vb(u.blocked)?!0:null),w=S??d.type===`asset`,T=e=>c?.categories?.find(t=>t.id===e),E=l?T(d.category):void 0,D=(e,t)=>{g(``),y(!1),x(void 0),f(l&&e===`category`?{...d,category:t,detail:t===l.category?l.detail??``:``}:{...d,[e]:t})},O=t.body??(l?`${r.help?`${r.help}. `:``}Now ${T(l.category)?.label??l.category}${l.detail?` · ${l.detail}`:``}, from ${Pb[l.origin]??l.origin}${l.item?` on ${l.item}`:``}: the origin stays.${E&&!E.later&&l.later?` ${E.label} never waits in Later: it leaves Later.`:``}`:o?Vb(u.from)?`From ${Vb(u.from)}: its first line is the title, the rest the note. The entry is erased when the item is created.`:`Created and committed at once. Its id comes from the title.`:r.help),k=new Map(e.board.items.map(e=>[e.id,e.running?`running`:e.status])),A=t.id?e.board.items.find(e=>e.id===t.id):void 0,ee=r.fields.some(e=>e.required&&jr(e,d)&&(e.kind===`choice`&&!Vb(d[e.key])||e.kind===`file`&&d[e.key]===void 0)),j=async i=>{i.preventDefault(),x(void 0);let a=Nr(r.fields,d);if(s&&!w)delete a.blocked;else if(s&&!Vb(d.blocked))return g(`Start blocked: say what it waits for`);m(!0);let o=await e.moveIn({cmd:r.cmd,id:t.id,...a,...t.extra});m(!1),o.ok?n():(g(o.err),y(o.refused),x(o.refusal))},M=t=>{if(Nb(e.board,t))return Mb;if(t.kind===`ids`&&t.single)return`one live ${(t.of??[`item`]).join(` or `)}, by its title`;if(E?.details&&t.key===`detail`)return`${E.label} takes one of its own details`;if(o&&t.key===`system`||s&&t.key===`blocked`)return;if(t.excuses!==`plan`||!A)return t.help;let n=A.plan;return n?`error`in n?`the plan cannot be read: ${n.error}`:n.tasks-n.done?`${n.tasks-n.done} of ${n.tasks} plan tasks are unticked: say why it goes anyway`:`every plan task is ticked: leave it empty`:`the item has no plan file`};return(0,I.jsx)(R,{onClose:n,dirty:Object.entries(d).some(([e,t])=>Vb(t)!==Vb(u[e])),children:(0,I.jsxs)(`form`,{className:`dialog ${r.fields.length>6?`wide`:``}`,role:`dialog`,"aria-modal":!0,"aria-label":t.title,onClick:e=>e.stopPropagation(),onSubmit:j,children:[(0,I.jsx)(`h2`,{children:t.title}),O&&(0,I.jsx)(`p`,{className:`dialog-body`,children:O}),(0,I.jsx)(`datalist`,{id:`move-form-ids`,children:[...k.keys()].map(e=>(0,I.jsx)(`option`,{value:e},e))}),r.fields.filter(e=>!e.hidden&&jr(e,d)).map(n=>{let r=`${a}-${n.key}`,i=Ab[n.kind],c=Vb(d[n.key]),l=M(n),u=E&&n.key===`detail`?E.details:null,f=s&&n.key===`blocked`?`Waits for something outside`:o&&n.key===`system`?n.label.replace(/, comma-separated/i,``):n.label;return(0,I.jsxs)(`div`,{className:`f-field`,children:[(0,I.jsxs)(`span`,{className:`f-label`,children:[n.kind===`choice`||n.kind===`remove`||u?(0,I.jsxs)(`span`,{className:`f-label-text`,title:n.help,children:[f,n.required?` (required)`:``]}):(0,I.jsxs)(`label`,{htmlFor:r,title:n.help,children:[f,n.required?` (required)`:``]}),i&&(0,I.jsx)(`span`,{title:i[1],children:i[0]})]}),s&&n.key===`blocked`?(0,I.jsxs)(`div`,{className:`f-check`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>{g(``),C(e.target.checked)}}),(0,I.jsx)(`span`,{children:`Start blocked`})]}),w&&(0,I.jsx)(`input`,{id:r,className:`input`,value:c,"aria-label":`Why it starts blocked`,placeholder:d.type===`asset`?`file needed: the final lock icon`:`what it waits for`,onChange:e=>D(n.key,e.target.value)}),(0,I.jsx)(`span`,{className:`field-help`,children:w?`It is created blocked with this reason: the runner takes it only after Unblock. A file brought later: Unblock with file: <path>, and its run takes it in.`:`Off: it is created ready. On: it waits for something outside, a file, an answer, an access.`})]}):(0,I.jsx)(Rb,{id:r,field:n,value:d[n.key],presets:e.board.presets,board:e.board,self:t.id??Vb(d.id),newItem:o,details:u,onChange:e=>D(n.key,e)}),l&&n.kind!==`choice`&&!n.presets&&(0,I.jsx)(`span`,{className:`field-help`,children:l}),n.max&&!u&&(0,I.jsxs)(`span`,{"aria-live":`polite`,className:`f-count ${c.length>n.max?`over`:``}`,children:[c.length,` / `,n.max]})]},n.key)}),h&&(b?(0,I.jsx)(y_,{ctx:e,refusal:b,error:h}):(0,I.jsx)(B,{error:h,refused:_})),(0,I.jsxs)(`div`,{className:`dialog-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`btn-line`,onClick:n,disabled:p,children:`Cancel`}),(0,I.jsx)(`button`,{type:`submit`,className:r.danger?`btn-danger`:`btn-primary`,disabled:p||ee,children:p?`Running…`:r.label})]})]})})}function Ub({ctx:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),l=(0,v.useRef)(0),{project:u,notify:d,board:f}=e,p=f.domain.sections.playtest,m=f.settings?.find(e=>e.key===`tune_limit`),h=m?m.value??m.default:null,g=Tr(f.domain,f.domain.sections.inbox?.add),_=p?.category,y=JSON.stringify(f.items.filter(e=>(p?.waits??[]).includes(e.status)));(0,v.useEffect)(()=>{let e=++l.current;k.playtest(u.name).then(t=>e===l.current&&n(t),e=>d(e.message,`error`))},[y,u.name,d]);let b=async()=>{await ie(`Run the project's build command (dod.build)? It can take minutes.`,`Build`)&&(o(!0),await k.playtestBuild(u.name).then(e=>i(e),e=>d(e.message,`error`)),o(!1))};if(!t)return(0,I.jsx)(`div`,{className:`page`,role:`status`,children:(0,I.jsx)(`p`,{className:`dim`,children:`Reading the session…`})});let x=new Map;for(let e of t.items){let t=e.system[0]??`(no system)`;x.set(t,[...x.get(t)??[],e])}let S=r?.commit===t.commit?r.build:null,C=[(t.main?t.branch!==t.main:/^(HEAD|work\/)/.test(t.branch??``))?`not ${t.main??`main`}: a build of another branch`:null,t.dirty?`uncommitted changes`:null].filter(Boolean);return(0,I.jsxs)(`section`,{className:`page playtest`,"aria-label":`Playtest`,children:[(0,I.jsxs)(`div`,{className:`page-head`,children:[(0,I.jsx)(`h1`,{children:`Playtest`}),(0,I.jsxs)(`p`,{children:[`Build, play, then judge each item. `,t.items.length,` wait`,t.items.length===1?`s`:``,` for you.`]})]}),(0,I.jsxs)(`section`,{className:`pt-build`,"aria-label":`The build to play`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`pt-build-label`,children:`The build to play`}),(0,I.jsxs)(`span`,{className:`mono pt-build-ref`,children:[t.branch,` · `,t.commit]}),(0,I.jsx)(`span`,{className:C.length?`warn-text`:`dim small`,children:C.length?C.join(` · `):`no warnings: on main, nothing uncommitted`}),(0,I.jsx)(`span`,{role:`status`,className:`mono small ${S?S.ok?`ok-text`:`error-text`:`dim`}`,children:S?S.skipped?`no build command: dod.build is not set`:S.ok?`built: green`:`build failed: ${S.problems.join(`; `)}`:`not built in this session`})]}),(0,I.jsxs)(`button`,{className:`btn-primary pt-build-btn`,disabled:a,onClick:()=>void b(),children:[a&&(0,I.jsx)(`span`,{className:`dot pulse`,"aria-hidden":`true`}),a?`Building…`:`Build`]})]}),(t.milestones??[]).map(n=>{let r=f.milestones?.find(e=>e.name===n.name),i=r?.ids??[],a=r?.units??[],o=t.platforms?.length?t.platforms:[...new Set(i.flatMap(e=>f.items.find(t=>t.id===e)?.play_on??[]))];return(0,I.jsxs)(`section`,{className:`pt-ms`,"aria-label":`Milestone ${n.name}`,children:[(0,I.jsxs)(`div`,{className:`pt-ms-top`,children:[(0,I.jsxs)(`div`,{className:`pt-ms-head`,children:[(0,I.jsxs)(`div`,{className:`pt-ms-line`,children:[(0,I.jsx)(`span`,{className:`pt-ms-cap`,children:`Milestone`}),(0,I.jsx)(`span`,{className:`pt-ms-name`,children:n.name}),(0,I.jsx)(`span`,{className:`pt-ms-state ${r?.built?`built`:``}`,children:r?.played?`played`:r?.built?`built`:`building`}),(0,I.jsxs)(`span`,{className:`pt-ms-counts`,children:[n.to_play,` to play`,n.building||n.blocked?` · still building ${n.building}${n.blocked?`, blocked ${n.blocked}`:``}`:``]})]}),n.goal&&(0,I.jsx)(`span`,{className:`pt-ms-goal`,children:n.goal})]}),(0,I.jsxs)(`button`,{className:`btn-ok pt-ms-keep`,title:`Keep every item of it that waits for play, in one commit (verdict keep --milestone); tune or kill an item on its own first`,onClick:()=>void(async()=>{await ie(`Keep milestone ${n.name}: every item of it that waits for play?`,`Keep`)&&await e.move({cmd:`milestone-keep`,id:n.name})})(),children:[`Keep `,n.name]})]}),n.play&&(0,I.jsxs)(`div`,{className:`pt-ms-play`,children:[(0,I.jsx)(`span`,{children:`play:`}),(0,I.jsx)(`span`,{children:n.play})]}),(0,I.jsxs)(`div`,{className:`pt-ms-where`,children:[(0,I.jsx)(`span`,{children:`where to play`}),(0,I.jsx)(`span`,{title:`A hint, never a condition: the session's platforms, else its items' play_on`,children:o.length?o.join(` · `):`no platforms in the read`})]}),a.length>0&&(0,I.jsxs)(`span`,{className:`pt-ms-units`,children:[a.length,` design unit`,a.length>1?`s`:``,` not carded:`,` `,a.map(e=>e.id).join(`, `)]}),i.length>0&&(0,I.jsx)(`div`,{role:`list`,className:`pt-ms-rows`,children:i.map(t=>{let n=f.items.find(e=>e.id===t),r=f.domain.columns.find(e=>e.status===n?.status),i=n?.play_on??[];return(0,I.jsxs)(`div`,{role:`listitem`,className:`pt-ms-row ${e.itemOpen===t?`on`:``}`,children:[(0,I.jsxs)(`button`,{disabled:!n,onClick:()=>n&&e.openItem(t,`file`),children:[(0,I.jsx)(`span`,{className:`mono strong`,children:t}),n?.title&&(0,I.jsx)(`span`,{children:n.title})]}),(0,I.jsx)(`span`,{className:`pt-ms-st`,children:n?`${n.running?`running`:r?.label??n.status} on this board`:`not on the board`}),(0,I.jsxs)(`span`,{className:`pt-ms-on`,children:[`Play on `,(0,I.jsx)(`span`,{children:i.length?i.join(` · `):`—`})]})]},t)})})]},n.name)}),!t.items.length&&(0,I.jsx)(`div`,{className:`empty-box`,children:`Nothing waits for play.`}),[...x].map(([t,n])=>(0,I.jsxs)(`section`,{className:`pt-group`,"aria-label":t,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[t,(0,I.jsx)(`span`,{className:`dim`,children:n.length}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`wide-only`,children:(0,I.jsx)(Pa,{children:n.map(t=>{let n=f.items.find(e=>e.id===t.id),r=f.domain.columns.find(e=>e.status===t.status),i=[(t.play_on??[]).length?`play on ${(t.play_on??[]).join(`, `)}`:``,t.status===`unplayed`?`unplayed: nobody played it yet`:r?.label??t.status,n?.since?`built at ${n.since.slice(0,7)}`:``,n?.tune_count?`tuned ${n.tune_count}${h?` of ${h}`:`×`}`:``];return(0,I.jsx)(Ma,{cat:n?`${n.type.slice(0,3).toUpperCase()} · ${n.gate}`:t.id,tone:n?.gate,origin:n?.running?`running`:r?.label??t.status,title:t.title??t.id,sub:i.filter(Boolean).join(` · `),mark:t.title?t.id:``,needs:n?G(n,f):!1,on:e.itemOpen===t.id,onOpen:()=>e.openItem(t.id,`file`)},t.id)})})}),(0,I.jsx)(`div`,{className:`phone-only pt-rows`,children:n.map(t=>{let n=f.items.find(e=>e.id===t.id),r=n?Er(n,f.domain).filter(e=>p?.verdicts.includes(e.cmd)):[],i=f.domain.columns.find(e=>e.status===t.status);return(0,I.jsxs)(`div`,{className:`pt-item gate-${n?.gate??``}`,children:[(0,I.jsxs)(`button`,{className:`pt-open`,onClick:()=>e.openItem(t.id),children:[(0,I.jsx)(`span`,{className:`mono pt-id`,children:t.id}),(t.title??t.intent)&&(0,I.jsx)(`span`,{className:`pt-title`,children:t.title??t.intent}),(0,I.jsxs)(`span`,{className:`dim small`,children:[i?.label??t.status,n?.tune_count?` · tuned ${n.tune_count}×`:``]})]}),(0,I.jsxs)(`dl`,{className:`pt-check`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`Check`}),(0,I.jsx)(`dd`,{children:t.question})]}),t.reach.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`Get there`}),(0,I.jsx)(`dd`,{children:t.reach.join(`; `)})]}),t.feel.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`Feel`}),(0,I.jsx)(`dd`,{children:t.feel.join(`; `)})]}),(t.play_on??[]).length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`Play on`}),(0,I.jsx)(`dd`,{children:(t.play_on??[]).join(`; `)})]})]}),(0,I.jsx)(`div`,{className:`pt-acts`,children:r.map(n=>(0,I.jsx)(`button`,{className:Or(n),title:n.help,onClick:()=>e.openMove({title:`${n.label} ${t.id}`,id:t.id,move:n}),children:n.label},n.cmd))})]},t.id)})})]},t)),g&&_&&(0,I.jsxs)(`section`,{className:`pt-note`,"aria-label":`A note from the playtest`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`A note from the playtest`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),s.trim()&&await e.move({cmd:g.cmd,text:s,category:_})&&c(``)},children:[(0,I.jsx)(`textarea`,{className:`input`,"aria-label":`A note from the playtest`,rows:2,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},title:`Ctrl+Enter adds`,placeholder:`What you noticed: it goes to the inbox as ${_}`}),(0,I.jsx)(`button`,{type:`submit`,className:`btn`,disabled:!s.trim(),children:`To the inbox`})]})]})]})}var Wb=(e,t)=>e.kind===t.kind&&e.pattern===t.pattern;function Gb({r:e}){return(0,I.jsxs)(`code`,{className:`rule-text`,children:[(0,I.jsxs)(`span`,{className:`dim`,children:[e.kind,`:`]}),` `,e.pattern]})}function Kb({ctx:e}){let[t,n]=(0,v.useState)(``),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),s=e.board.agent,c=e.board.context;if(!s)return(0,I.jsx)(`div`,{className:`page`,children:(0,I.jsx)(`p`,{className:`dim`,children:`This core reports no agent permissions: update it.`})});let l=s.extra??[],u=(s.rules?.deny??[]).filter(e=>!l.some(t=>Wb(t,e))),d=s.rules?.allow??[],f=async(t,n)=>{i(t);let r=await e.move({cmd:`permissions`,...n});return i(null),r};return(0,I.jsxs)(`section`,{className:`page agent`,"aria-label":`Agent`,children:[(0,I.jsxs)(`div`,{className:`page-head`,children:[(0,I.jsx)(`h1`,{children:`Agent`}),(0,I.jsx)(`p`,{children:`What agent runs may not do. A run allows everything but the deny rules. A deny rule stops an accident, not a rewording: an agent that means it can say the same thing another way.`})]}),(0,I.jsxs)(`section`,{"aria-label":`Deny groups`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Deny groups`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`ag-groups`,children:s.groups.map(e=>(0,I.jsxs)(`button`,{role:`checkbox`,"aria-checked":e.on,disabled:r!==null,className:`ag-group ${e.on?`on`:``}`,onClick:()=>void f(e.id,{[e.on?`off`:`on`]:[e.id]}),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:e.on?`☑`:`☐`}),(0,I.jsxs)(`span`,{className:`ag-group-label`,children:[e.label.split(`: `)[0],e.label.includes(`: `)&&(0,I.jsx)(`small`,{children:e.label.slice(e.label.indexOf(`: `)+2)})]}),(0,I.jsx)(`span`,{className:`ag-state`,children:r===e.id?`…`:e.on?`denied`:`allowed`})]},e.id))}),(0,I.jsx)(`span`,{className:`dim small`,children:`A command a run refused blocks its item with “needs permission: <command>”: untick its group, or remove the own rule that refused it, and run it again.`}),u.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{className:`btn-line ag-base`,"aria-expanded":a,onClick:()=>o(!a),children:[a?`▾`:`▸`,` the rules the ticked groups add · `,u.length]}),a&&(0,I.jsx)(`div`,{className:`ag-base-list`,children:u.map(e=>(0,I.jsx)(Gb,{r:e},`${e.kind}:${e.pattern}`))})]})]}),(0,I.jsxs)(`section`,{"aria-label":`Own deny rules`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Own deny rules`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),!s.deny_extra.length&&(0,I.jsx)(`span`,{className:`dim`,children:`No own rule yet.`}),s.deny_extra.map((e,t)=>(0,I.jsxs)(`div`,{className:`ag-rule`,children:[l[t]?(0,I.jsx)(Gb,{r:l[t]}):(0,I.jsx)(`code`,{className:`rule-text`,children:e}),l[t]&&`${l[t].kind}: ${l[t].pattern}`!==e&&(0,I.jsxs)(`span`,{className:`mono dim small`,title:`Claude's form is taken too; the list shows every rule neutral`,children:[`entered as `,e]}),(0,I.jsx)(Na,{label:`Remove the rule`,tip:`Remove · runs may do this again`,disabled:r!==null,onClick:()=>void f(`undeny:${e}`,{undeny:[e]})})]},e)),(0,I.jsxs)(`form`,{className:`ag-add`,onSubmit:async e=>{e.preventDefault(),t.trim()&&await f(`add`,{deny:[t.trim()]})&&n(``)},children:[(0,I.jsx)(`input`,{className:`input mono`,"aria-label":`A deny rule`,value:t,onChange:e=>n(e.target.value),placeholder:`shell: curl * · read: ~/.aws/** · mcp: server__tool · or Bash(curl *)`}),(0,I.jsx)(`button`,{type:`submit`,className:`btn`,disabled:!t.trim()||r!==null,children:r===`add`?`Adding…`:`Deny`})]}),(0,I.jsx)(`span`,{className:`dim small`,children:`Write it neutral, kind: pattern, with the kinds edit, shell, read, search, web, mcp, skill, subagent, other. Claude's form, Bash(curl *), is taken too. The core refuses a rule of neither form.`})]}),(0,I.jsxs)(`section`,{"aria-label":`Allow rules`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Allow rules`,(0,I.jsx)(`span`,{className:`dim sub`,children:`agent.allow in gcf/config.yml`}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),!d.length&&(0,I.jsx)(`span`,{className:`dim`,children:`No allow rule. Runs allow everything but the deny rules anyway; an allow rule lets an agent run without bypass skip asking. Always on a project chat card saves its rule in .claude/settings.local.json instead, for this machine.`}),d.map(e=>(0,I.jsx)(`div`,{className:`ag-rule`,children:(0,I.jsx)(Gb,{r:e})},`${e.kind}:${e.pattern}`))]}),c&&(0,I.jsxs)(`section`,{"aria-label":`Context`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Context`,(0,I.jsx)(`span`,{className:`dim sub`,children:`read only · set in Settings`}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`ag-ctx`,children:[{key:`context_handoff_pct`,label:`handoff at`,value:c.handoff_pct?`${c.handoff_pct}%`:`never`,tip:`At this share of the window a session hands its item to a fresh one`},{key:`context_window`,label:`window`,value:c.window?`${c.window.toLocaleString()} tokens`:`the model's`,tip:`The context window the share is of`},{key:`auto_compact_pct`,label:`compacts at`,value:c.compact_pct?`${c.compact_pct}%`:`its own default`,tip:`Where the agent compacts its context`}].map(e=>(0,I.jsxs)(`div`,{className:`ag-ctx-box`,title:e.tip,children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`span`,{className:`mono`,children:e.value}),(0,I.jsxs)(`code`,{children:[`gcf/config.yml · `,e.key]})]},e.key))})]})]})}var qb=`gcf-theme`;function Jb(){try{let e=JSON.parse(localStorage.getItem(qb)??`null`);return e&&typeof e.id==`string`&&e.tokens&&typeof e.tokens==`object`?e:null}catch{return null}}var Yb=Jb(),Xb=new Set;function Zb(e){Yb=e;try{e?localStorage.setItem(qb,JSON.stringify(e)):localStorage.removeItem(qb)}catch{}for(let e of Xb)e()}var Qb=()=>Yb,$b=()=>(0,v.useSyncExternalStore)(e=>(Xb.add(e),()=>Xb.delete(e)),Qb),ex=[];function tx(e,t){for(let t of ex)e.style.removeProperty(t);ex=[];let n=[],r=getComputedStyle(e);for(let[i,a]of Object.entries(t?.tokens??{})){let t=`--gcf-${i}`;r.getPropertyValue(t)?(e.style.setProperty(t,a),ex.push(t)):n.push(i)}return document.body.style.background=t?.tokens.bg??``,document.documentElement.style.colorScheme=t?.scheme??``,n}function nx({ctx:e}){let t=e.board.settings;if(!t)return(0,I.jsxs)(`div`,{className:`page`,children:[(0,I.jsx)(sx,{}),(0,I.jsx)(ux,{}),(0,I.jsx)(`p`,{className:`dim`,children:`This core reports no settings: update it.`})]});let n=[...new Set(t.map(e=>e.group??`Settings`))];return(0,I.jsxs)(`section`,{className:`page settings`,"aria-label":`Settings`,children:[(0,I.jsxs)(`div`,{className:`page-head`,children:[(0,I.jsx)(`h1`,{children:`Settings`}),(0,I.jsx)(`p`,{children:`Every key of gcf/config.yml you set, and the agents' language. Save commits one key; the core refuses a value its rules do not take. An empty value goes back to the default.`})]}),(0,I.jsx)(sx,{}),(0,I.jsx)(ux,{}),n.map(n=>(0,I.jsxs)(`section`,{"aria-label":n,className:`set-group`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[n,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),n===`Autonomy`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`set-intro`,children:`Every stop that waits for you, for the whole project (gates: in gcf/config.yml). A card may hold its own gates. Each change is one commit.`}),(0,I.jsx)(ix,{ctx:e,settings:t})]}),t.filter(e=>(e.group??`Settings`)===n).map(t=>n===`Autonomy`&&t.kind===`mode`&&t.options?(0,I.jsx)(ax,{ctx:e,s:t},t.key):(0,I.jsx)(ox,{ctx:e,s:t},`${t.key}=${t.value}`))]},n))]})}var rx=[{name:`Careful`,help:`Every gate waits for you; the autopilot is off`,keys:{"gates.milestone":`wait`,"gates.verdict":`wait`,"gates.decision":`wait`,"gates.question":`wait`},pilot:!1},{name:`Autonomous`,help:`The agent decides its spikes and assumes instead of asking; it stops for a built milestone and an item’s own verdict; runs in worktrees; the autopilot is on`,keys:{"gates.milestone":`wait`,"gates.verdict":`wait`,"gates.decision":`agent`,"gates.question":`assume`,run_mode:`worktree`},pilot:!0}];function ix({ctx:e,settings:t}){let n=e=>{let n=t.find(t=>t.key===e);return String(n?.value??n?.default??``)},r=e.board.runs?.autopilot?.on??!1,i=rx.find(e=>e.pilot===r&&Object.entries(e.keys).every(([e,t])=>n(e)===t)),a=async t=>{await e.move({cmd:`config-preset`,pairs:t.keys})&&r!==t.pilot&&await e.setAutopilot(t.pilot)};return(0,I.jsxs)(`div`,{className:`set-presets`,children:[(0,I.jsx)(`div`,{role:`group`,"aria-label":`Presets`,className:`set-preset-btns`,children:rx.map(e=>(0,I.jsx)(`button`,{className:i===e?`btn-primary`:`btn`,"aria-pressed":i===e,title:e.help,onClick:()=>void a(e),children:e.name},e.name))}),(0,I.jsxs)(`div`,{className:`set-preset-now`,children:[(0,I.jsx)(`span`,{className:i?``:`own`,title:i?`The keys match ${i.name}: ${i.help}`:`The keys match neither preset`,children:i?`now: ${i.name}`:`now: your own`}),(0,I.jsxs)(`span`,{className:`mono`,children:[`autopilot `,r?`on`:`off`,` · run_mode `,n(`run_mode`)||e.board.run_mode]})]}),(0,I.jsx)(`button`,{className:`btn-line set-preset-agent`,title:`The deny groups and rules the agent works under`,onClick:()=>e.go(`agent`),children:`Agent permissions`})]})}function ax({ctx:e,s:t}){let[n,r]=(0,v.useState)(!1),i=String(t.value??t.default??``),a=t.options??[],o=async a=>{a===i||n||(r(!0),await e.move({cmd:`config-set`,key:t.key,value:a}),r(!1))};return(0,I.jsxs)(`div`,{className:`set-row set-gate`,children:[(0,I.jsxs)(`div`,{className:`set-what`,children:[(0,I.jsx)(`span`,{className:`mono`,children:t.key}),(0,I.jsx)(`span`,{children:t.label})]}),(0,I.jsxs)(`div`,{className:`set-how`,children:[(0,I.jsx)(`div`,{role:`radiogroup`,"aria-label":t.key,className:`set-seg`,onKeyDown:e=>{let t={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key];if(!t||!a.length||(e.preventDefault(),n))return;let r=(Math.max(0,a.indexOf(i))+t+a.length)%a.length;e.currentTarget.querySelectorAll(`[role="radio"]`)[r]?.focus(),o(a[r])},children:a.map((e,r)=>(0,I.jsx)(`button`,{role:`radio`,"aria-checked":e===i,"aria-disabled":n,tabIndex:e===i||!a.includes(i)&&r===0?0:-1,title:`gcf config set ${t.key} --value=${e}: one commit`,onClick:()=>void o(e),children:e},e))}),(0,I.jsxs)(`span`,{className:`dim small`,children:[t.value===null?`not set: the default holds (${t.default})`:`default ${t.default}`,` `,`· `,t.file??`gcf/config.yml`]})]})]})}function ox({ctx:e,s:t}){let n=t.value??(t.kind===`mode`?t.default:null),r=n===null?``:String(n),[i,a]=(0,v.useState)(r),[o,s]=(0,v.useState)(!1),c=i!==r,l=`set-${t.key}`,u=t.presets?Ci(e.board,t.presets):null,d=t.default===null||t.default===``?u?yi(u):t.kind===`word`?`the agent's`:`none`:`${t.default}${t.kind===`share`?`%`:``}`,f=t.options,p=async n=>{n.preventDefault(),s(!0),await e.move({cmd:`config-set`,key:t.key,value:i}),s(!1)},m=t.presets?(0,I.jsx)(Ei,{id:l,what:t.presets,presets:e.board.presets?.[t.presets]??[],value:i,fallback:u,autoValue:``,onChange:a}):f&&t.kind===`mode`?(0,I.jsx)(`select`,{id:l,className:`input mono`,value:i,onChange:e=>a(e.target.value),children:[...f,...i&&!f.includes(i)?[i]:[]].map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))}):f?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{id:l,className:`input mono`,value:i,list:`${l}-options`,onChange:e=>a(e.target.value),placeholder:`not set · default ${d}`}),(0,I.jsx)(`datalist`,{id:`${l}-options`,children:f.map(e=>(0,I.jsx)(`option`,{value:e},e))})]}):t.kind===`command`?(0,I.jsx)(`textarea`,{id:l,className:`input mono set-command`,rows:3,value:i,onChange:e=>a(e.target.value),placeholder:`not set`}):(0,I.jsx)(`input`,{id:l,className:`input mono`,value:i,onChange:e=>a(e.target.value),inputMode:t.kind===`number`||t.kind===`share`?`decimal`:`text`,placeholder:t.kind===`word`?`not set · ${d}`:`not set`});return(0,I.jsxs)(`form`,{className:`set-row`,onSubmit:p,children:[(0,I.jsxs)(`div`,{className:`set-what`,children:[(0,I.jsx)(`label`,{htmlFor:l,className:`mono`,children:t.key}),(0,I.jsx)(`span`,{children:t.label})]}),(0,I.jsxs)(`div`,{className:`set-how`,children:[(0,I.jsxs)(`div`,{className:`set-ctl`,children:[m,t.kind===`share`&&(0,I.jsx)(`span`,{className:`mono dim`,children:`%`}),(0,I.jsx)(`button`,{type:`submit`,className:`btn`,disabled:!c||o,title:`Commits gcf config set ${t.key} --value=…; the core refuses a value its rules do not take`,children:o?`Saving…`:`Save`})]}),(0,I.jsxs)(`span`,{className:`dim small`,children:[t.value===null?`not set: the default holds (${d})`:`default ${d}`,` `,`· `,t.file??`gcf/config.yml`]})]})]})}function sx(){let e=$b(),[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(``);return(0,v.useEffect)(()=>{k.themes().then(n,e=>i(e.message))},[]),(0,I.jsxs)(`section`,{"aria-label":`Theme`,className:`set-group`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Board · this browser`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsxs)(`div`,{className:`set-row`,children:[(0,I.jsxs)(`div`,{className:`set-what`,children:[(0,I.jsx)(`label`,{htmlFor:`set-theme`,className:`mono`,children:`theme`}),(0,I.jsx)(`span`,{children:`Colours of the board in this browser. The phone and the desk can differ.`})]}),(0,I.jsxs)(`div`,{className:`set-how`,children:[(0,I.jsx)(`div`,{className:`set-ctl`,children:(0,I.jsxs)(`select`,{id:`set-theme`,className:`input`,value:e?.id??``,onChange:e=>{let n=t?.find(t=>t.id===e.target.value);Zb(n&&`tokens`in n?n:null)},children:[(0,I.jsx)(`option`,{value:``,children:`Dark (built-in)`}),t?.map(e=>`tokens`in e?(0,I.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.scheme,`)`]},e.id):(0,I.jsxs)(`option`,{value:e.id,disabled:!0,children:[e.id,`: `,e.error]},e.id))]})}),(0,I.jsx)(`span`,{className:`dim small`,children:r||`Applies at once. The board ships its own; a JSON file in ~/.gcf/themes adds one or replaces one of its id: reload the page after changing it.`})]})]}),(0,I.jsx)(lx,{})]})}var cx=[{v:`expanded`,label:`Expanded`,help:`every card in full`,now:`Every technical card in full`},{v:`collapsed`,label:`Collapsed into a line`,help:`one line each; a click opens it (the default)`,now:`One line each; a click opens the card`},{v:`hidden`,label:`Hidden`,help:`only a card that waits for you`,now:`Gone from the stream; a card that waits for you stays`}];function lx(){let e=sv();return(0,I.jsxs)(`div`,{className:`set-row`,children:[(0,I.jsxs)(`div`,{className:`set-what`,children:[(0,I.jsx)(`span`,{id:`set-chat-tech`,className:`mono set-name`,children:`technical cards`}),(0,I.jsx)(`span`,{children:`A permission card no longer waiting, a refusal, a call YOLO ran. A card that waits for you is always open in full; text, questions, proposals and steps never fold.`})]}),(0,I.jsxs)(`div`,{className:`set-how set-tech-how`,children:[(0,I.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":`set-chat-tech`,className:`set-seg set-tech`,onKeyDown:t=>{let n={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key];if(!n)return;t.preventDefault();let r=(cx.findIndex(t=>t.v===e)+n+cx.length)%cx.length;t.currentTarget.querySelectorAll(`[role="radio"]`)[r]?.focus(),av(cx[r].v)},children:cx.map(t=>(0,I.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t.v===e,tabIndex:t.v===e?0:-1,title:t.help,onClick:()=>av(t.v),children:t.label},t.v))}),(0,I.jsxs)(`div`,{className:`set-tech-line`,"aria-hidden":`true`,children:[(0,I.jsx)(`span`,{children:`▸`}),(0,I.jsx)(`span`,{className:`stl-tool`,children:`shell`}),(0,I.jsx)(`span`,{className:`stl-title`,children:`npm run levels:list`}),(0,I.jsx)(`span`,{className:`stl-yolo`,children:`· ran without asking (YOLO)`}),(0,I.jsx)(`span`,{className:`stl-at`,children:`09:02`})]}),(0,I.jsxs)(`span`,{className:`dim small`,children:[cx.find(t=>t.v===e)?.now,` · applies at once, in every tab of this browser`]})]})]})}function ux(){let e=gv(),[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),s=async e=>{t||(i(e),n(!0),o(``),await _v(e).catch(e=>o(e.message)),n(!1))},c=t?r:e;return(0,I.jsxs)(`section`,{"aria-label":`This machine`,className:`set-group`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Board · this machine`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsxs)(`div`,{className:`set-row`,children:[(0,I.jsxs)(`div`,{className:`set-what`,children:[(0,I.jsx)(`span`,{id:`set-yolo-name`,className:`mono set-name set-yolo-name${c?` on`:``}`,children:`YOLO`}),(0,I.jsx)(`span`,{children:`The threads of the project chat ask no permission: the center allows each call itself. Deny rules, the main-run refusal and question cards stay. Every project on this machine; from the next call.`})]}),(0,I.jsxs)(`div`,{className:`set-how set-yolo${c?` on`:``}`,children:[(0,I.jsxs)(`button`,{id:`set-yolo`,type:`button`,role:`switch`,"aria-checked":c,"aria-labelledby":`set-yolo-name`,"aria-describedby":`set-yolo-risk`,className:`set-switch`,onClick:()=>void s(!c),children:[(0,I.jsx)(`span`,{className:`set-switch-track`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{className:`set-switch-knob`})}),c?`on`:`off`]}),(0,I.jsxs)(`p`,{id:`set-yolo-risk`,className:`set-yolo-risk`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),(0,I.jsx)(`span`,{children:`Calls run unseen, as in a task run: a framework move that changes the project (integrate, close, design discard, inbox drop), an edit of AGENTS.md or CLAUDE.md, which stays after YOLO goes off, and a command that gets round a deny rule run too.`})]}),a&&(0,I.jsx)(`span`,{role:`alert`,className:`set-yolo-err`,children:a}),(0,I.jsx)(`span`,{className:`mono set-yolo-file`,children:`~/.gcf/chat-yolo`})]})]})]})}var dx=e=>e===null?`-`:`$${e.toFixed(2)}`,fx=e=>`${e} run${e===1?``:`s`}`,px=(e,t=1)=>e===null?`-`:e.toFixed(t),mx=e=>Object.entries(e).map(([e,t])=>`${e} ${t}`).join(`, `);function hx({ctx:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(``),a=(0,v.useRef)(0),{project:o}=e,s=(e.board.runs?.reports??[]).map(e=>e.id).join(),c=e.board.items.filter(e=>e.running).map(e=>e.id).join();(0,v.useEffect)(()=>{let e=++a.current;k.metrics(o.name).then(t=>{e===a.current&&(n(t),i(``))},t=>e===a.current&&i(t.message))},[s,c,o.name]);let l=(0,I.jsxs)(`div`,{className:`page-head`,children:[(0,I.jsx)(`h1`,{children:`Metrics`}),(0,I.jsx)(`p`,{children:`What the runs did and what they cost (gcf-harness metrics).`})]});if(r)return(0,I.jsxs)(`section`,{className:`page metrics`,children:[l,(0,I.jsxs)(`div`,{className:`empty-box`,children:[`No metrics: `,r]})]});if(!t)return(0,I.jsxs)(`section`,{className:`page metrics`,role:`status`,children:[l,(0,I.jsx)(`p`,{className:`dim`,children:`Reading the metrics…`})]});let u=t.runs;if(!u.count)return(0,I.jsxs)(`section`,{className:`page metrics`,children:[l,(0,I.jsx)(`div`,{className:`empty-box`,children:`No runs yet. Each run the board or a console starts adds to these numbers: what it reached, its handoffs, checks and cost.`})]});let d=u.share===null?``:` (${Math.round(u.share*100)}%)`,f=u.avg_duration_ms===null?null:u.avg_duration_ms/6e4,p=[[String(u.count),`runs${Object.keys(u.results).length?` · ${mx(u.results)}`:``}`],[`${u.reached} of ${u.finished}`,`reached submit or close${d}`],[dx(u.cost_usd),`${dx(u.avg_cost_usd)} a run · ${px(f,0)} min · ${px(u.avg_turns,0)} turns`],[String(u.handoffs),`context handoffs`],[String(t.plan.checks),`plan checks · ${t.plan.items} items · ${t.plan.failed} failed`],[String(t.verify.attempts),`DoD attempts · ${t.verify.red} red${t.verify.red?` (${mx(t.verify.failing)})`:``}`],[String(t.guard.count),`guard firings${t.guard.count?` · ${mx(t.guard.by_hook)}`:``}`],[String(u.outside_implement),`code outside aif-implement`],[String(u.unverified),`moved without a green verify`]],m=t.items??[],h=Math.max(...m.map(e=>e.cost_usd),.01),g=(t.by_day??[]).slice(-14),_=Math.max(...g.map(e=>e.cost_usd),.01),y=(t.by_week??[]).at(-1),b=new Set(e.board.items.map(e=>e.id));return(0,I.jsxs)(`section`,{className:`page metrics`,"aria-label":`Metrics`,children:[l,(0,I.jsxs)(`section`,{"aria-label":`Runs`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Runs`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`mt-tiles`,children:p.map(([e,t])=>(0,I.jsxs)(`div`,{className:`mt-tile`,children:[(0,I.jsx)(`span`,{className:`mono`,children:e}),(0,I.jsx)(`span`,{children:t})]},t))}),Object.keys(u.blocks).length>0&&(0,I.jsxs)(`div`,{className:`mt-blocks`,children:[(0,I.jsx)(`span`,{className:`dim`,children:`block reasons:`}),Object.entries(u.blocks).map(([e,t])=>(0,I.jsxs)(`span`,{children:[e,` `,(0,I.jsx)(`b`,{className:`mono`,children:t})]},e))]})]}),t.items?(0,I.jsxs)(`section`,{"aria-label":`Cost per item`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Cost per item`,(0,I.jsx)(`span`,{className:`dim sub`,children:`over all its runs`}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),m.map(t=>(0,I.jsxs)(`div`,{className:`mt-item`,children:[(0,I.jsx)(`button`,{className:`link-btn mono`,disabled:!b.has(t.id),onClick:()=>e.openItem(t.id),children:t.id}),(0,I.jsx)(`span`,{className:`mt-bar`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{style:{width:`${Math.round(100*t.cost_usd/h)}%`}})}),(0,I.jsx)(`span`,{className:`mono`,children:dx(t.cost_usd)}),(0,I.jsx)(`span`,{className:`dim small`,title:`last ${t.last}`,children:fx(t.runs)})]},t.id))]}):(0,I.jsx)(`p`,{className:`dim`,children:`Cost per item, day and week needs gcf-harness-aif-ext 0.9.5.`}),g.length>0&&(0,I.jsxs)(`section`,{"aria-label":`Cost per day`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Cost per day`,y&&(0,I.jsxs)(`span`,{className:`dim sub`,children:[`this week `,dx(y.cost_usd)]}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`mt-days`,children:g.map(e=>(0,I.jsxs)(`div`,{title:`${e.day}: ${dx(e.cost_usd)}, ${fx(e.runs)}`,children:[(0,I.jsx)(`span`,{className:`mono small`,children:dx(e.cost_usd)}),(0,I.jsx)(`span`,{className:`mt-col`,"aria-hidden":`true`,style:{height:`${Math.max(2,Math.round(80*e.cost_usd/_))}px`}}),(0,I.jsx)(`span`,{className:`mono dim small`,children:e.day.slice(5).replace(`-`,`.`)})]},e.day))})]})]})}function gx({ctx:e,r:t}){let{text:n,bad:r}=ni(t.ids,t.ok,t.result,t.err),i=n.split(`
83
- `).slice(1),a=!r&&/paused/.test(n),o=r?`error`:a?`neutral`:`ok`,s=new Set(e.board.items.map(e=>e.id));return(0,I.jsxs)(`article`,{className:`report tone-${o}`,"aria-label":`Run report: ${t.ids.join(`, `)}`,children:[(0,I.jsxs)(`div`,{className:`report-head`,children:[(0,I.jsx)(`span`,{className:`report-kind`,children:r?`run failed`:a?`run paused`:`run ended`}),(0,I.jsx)(`span`,{className:`report-title`,children:t.ids.join(`, `)}),(0,I.jsx)(`span`,{className:`report-time`,children:oi(t.at)}),(0,I.jsx)(`button`,{className:`icon-btn report-close`,"aria-label":`Close the report`,onClick:()=>void k.closeReport(e.project.name,t.id).catch(t=>e.notify(t.message,`error`)),children:`×`})]}),(0,I.jsx)(`div`,{className:`report-lines`,children:i.map((n,r)=>{let i=n.indexOf(`: `),a=n.slice(0,i);if(i<0||!s.has(a))return(0,I.jsx)(`div`,{className:`report-line plain`,children:n},r);let o=n.slice(i),c=t.result?.items?.find(e=>e.id===a)?.process,l=c?` — ${c}`:``,u=l?o.indexOf(l):-1;return(0,I.jsxs)(`div`,{className:`report-line`,children:[(0,I.jsx)(`button`,{className:`link-btn`,onClick:()=>e.openItem(a),children:a}),u<0?o:o.slice(0,u),u>=0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`report-warn`,title:`A process note from the framework`,children:l}),o.slice(u+l.length)]})]},r)})}),t.note&&(0,I.jsx)(`div`,{className:`report-note`,children:t.note})]})}var _x=e=>{let t=e.resume?.resets;return t?Number.isNaN(Date.parse(t))?t:oi(t):`?`};function vx(e,t){let{board:n}=e,{domain:r}=n,i=e=>r.columns.find(t=>t.status===e.status),a=new Set(r.sections.playtest?.waits??[]),o=(t,r)=>({key:`item:${t.id}`,cat:`${t.type.slice(0,3).toUpperCase()} · ${t.gate}`,tone:t.gate,origin:t.running?`running`:i(t)?.label??t.status,title:t.title||t.id,sub:r,mark:t.title?t.id:``,needs:G(t,n),on:e.itemOpen===t.id,onOpen:()=>e.openItem(t.id)}),s=t.flatMap(e=>e.kind===`item`?[e.item]:[]),c=t.some(e=>e.kind===`queue`)?[{key:`queue`,cat:`RUN`,tone:`needs`,origin:`queue paused`,title:`the run queue`,sub:n.runs?.paused_by===`limit`?`A run ended paused: limit by itself. Resume the queue after the reset${n.runs?.paused_until?` (${si(n.runs.paused_until)})`:``}.`:`A run failed in a way the next one would repeat. Fix what its report names, then resume.`,needs:!0,tip:`Open Runs: Resume queue is there`,onOpen:()=>e.go(`runs`)}]:[],l=n.runs?.autopilot,u=t.flatMap(t=>{if(t.kind!==`pilot`)return[];let{stop:r}=t;if(r.kind===`play`){let t=(n.milestones??[]).find(e=>e.name===r.milestone),i=(t?.items[`awaiting-verdict`]??0)+(t?.items.unplayed??0);return[{key:`pilot`,cat:`MILESTONE · ${r.milestone} · built`,tone:`unplayed`,origin:`the autopilot stands`,title:r.text,sub:t?.play?`play: ${t.play}`:t?.goal??``,mark:i?`${i} to play`:``,markTone:`needs`,needs:!0,play:!0,tip:`${t?.play?`Its play question: ${t.play} · `:``}Open Playtest: Keep ${r.milestone} keeps all of it that waits for play`,onOpen:()=>e.go(`playtest`)}]}let i=l?.guarded[0],a=r.kind===`empty`?{sub:`Card its units on Design`,open:()=>e.go(`design`)}:r.kind===`dirty`?{sub:`Commit or stash it, or pick worktree runs in Settings`,open:()=>e.openSettings()}:r.kind===`no-move`&&i?{sub:`It takes ${i} again once its file changes · turn it on in the header`,open:()=>e.openItem(i)}:{sub:``,open:()=>e.go(`runs`)};return[{key:`pilot`,cat:`AUTOPILOT · ${r.kind===`no-move`?`off by itself`:`stands`}`,tone:`warn`,origin:l?.on?`on, waiting`:`off`,title:r.text,sub:a.sub,mark:``,needs:!0,play:!1,tip:[r.text,a.sub].filter(Boolean).join(` · `),onOpen:a.open}]}),d=u.filter(e=>e.play),f=u.filter(e=>!e.play),p=s.filter(e=>!$i(n,e.status)).map(e=>o(e,`Hit the usage limit (resets ${_x(e)}); its session is kept. Resume is in its window; while the limit holds, the run waits for the reset.`)),m=t.flatMap(t=>{if(t.kind!==`chat`)return[];let{card:n,talk:r}=t,i=r?`${r.title??`untitled thread`}${r.item?` · ${r.item}`:``} · project chat`:`${t.item} · run chat`;return[{key:`chat:${n.request_id}`,cat:n.kind===`approval`?`permission · ${n.tool??``}`:`question`,tone:`needs`,origin:i,title:n.text,sub:n.reason??``,needs:!0,tip:`Open its chat: the card is answered there`,onOpen:()=>r?e.go(`chat`,r.id):e.openItem(t.item??``,`chat`)}]}),h=t.flatMap(t=>{let n=t.kind===`entry`?rs(e,t.entry,!0):t.kind===`repeat`?as(e,`${t.repeat.category}:${t.repeat.detail}`,!0):null;return n?[{...n,key:n.dataKey??n.title}]:[]}),g=r.sections.inbox?.groups?.find(e=>e.counts)?.label??`Inbox`,_=t.flatMap(e=>e.kind===`report`?[e.report]:[]),v=t.flatMap(t=>t.kind===`question`?[{...is(e,t.question,!0),key:t.question.id}]:[]),y=s.filter(e=>$i(n,e.status)),b=e=>`${e.blocked??i(e)?.help??``}${e.tune_count?` · tuned ${e.tune_count}×`:``}`,x=r.columns.filter(e=>$i(n,e.status)&&!a.has(e.status)).map(e=>({key:e.status,label:e.label,tiles:y.filter(t=>t.status===e.status).map(e=>o(e,b(e)))}));return[{key:`runs`,label:`Runs that need you`,tiles:[...f,...c,...p],reports:_},{key:`chat`,label:`Answer in a chat`,tiles:m},{key:`answer`,label:`Answer`,tiles:v},{key:`inbox`,label:`Inbox: ${g}`,tiles:h},{key:`play`,label:`Play and judge`,tiles:[...d,...y.filter(e=>a.has(e.status)).map(e=>o(e,b(e)))]},...x].filter(e=>e.reports?.length||e.tiles.length)}function yx({ctx:e}){let t=ea(e.board,e.talks),n=vx(e,t),r=e.board.domain.starts&&sr(e.board)?cr(e.board):[],i=r.some(e=>e.id===`work`&&e.done)?0:r.filter(e=>!e.done).length;return(0,I.jsxs)(`section`,{className:`feed`,"aria-label":`Waiting for me`,children:[(0,I.jsxs)(`div`,{className:`feed-head`,children:[(0,I.jsx)(`span`,{className:`feed-total`,children:t.length}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{children:`waiting for me`}),(0,I.jsx)(`span`,{children:`Only you can move these on. Everything else runs or waits on the queue, the clock or a trigger.`})]})]}),!t.length&&!i&&(0,I.jsx)(`div`,{className:`feed-empty`,children:`Nothing waits for you. Runs go on by themselves.`}),[...i>0?[{key:`design`,label:`Start the game`,tiles:[{key:`design`,cat:`DESIGN`,origin:`${i} of ${r.length} steps left`,title:`The game starts with its design: ${i} of ${r.length} steps to the first work.`,sub:r.find(e=>!e.done)?.label??``,tip:`Open Design`,onOpen:()=>e.go(`design`)}]}]:[],...n].map(t=>(0,I.jsxs)(`section`,{className:`feed-group`,"aria-label":t.label,children:[(0,I.jsxs)(`h2`,{children:[t.label,(0,I.jsx)(`span`,{className:`count needs`,children:(t.reports?.length??0)+t.tiles.length}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),t.reports?.map(t=>(0,I.jsx)(gx,{ctx:e,r:t},t.id)),t.tiles.length?(0,I.jsx)(Pa,{children:t.tiles.map(({key:e,...t})=>(0,I.jsx)(Ma,{...t},e))}):null]},t.key))]})}function bx({ctx:e}){let{board:t}=e,n=t.runs,r=e=>t.items.find(t=>t.id===e),i=(n?.active??[]).flatMap(e=>{let t=e.ids.map(r).find(e=>e?.running)??r(e.ids[0]);return t?[{run:e,item:t}]:[]}),a=new Set(i.map(e=>e.item.id)),o=t.items.filter(e=>e.running&&!a.has(e.id)),s=(n?.reports??[]).filter(e=>!ea(t).some(t=>t.kind===`report`&&t.report.id===e.id)),c=n?.queued??[],l=!!t.domain.harness;return(0,I.jsxs)(`aside`,{className:`live`,"aria-label":`Live runs`,children:[(0,I.jsxs)(`div`,{className:`live-head`,children:[(0,I.jsx)(`h2`,{children:`Live`}),l&&(0,I.jsx)(Ji,{ctx:e})]}),s.length>0&&(0,I.jsx)(`div`,{className:`live-reports`,children:[...s].reverse().map(t=>(0,I.jsx)(gx,{ctx:e,r:t},t.id))}),!l&&(0,I.jsx)(`div`,{role:`note`,className:`live-note`,children:t.extensions_error?`No run: .ai-factory.json cannot be read, so the board knows no harness. Fix the file; every manual move works meanwhile.`:`No harness in this project: nothing runs from the board. Items, moves, verdicts, the inbox and settings all work.`}),l&&!i.length&&!o.length&&(0,I.jsx)(`div`,{className:`live-note`,children:n?.paused?`Nothing runs: the queue is paused.`:`Nothing runs now.`}),i.map(({run:t,item:n})=>{let r=di(n),i=n.plan&&!(`error`in n.plan)?n.plan:null;return(0,I.jsxs)(`article`,{className:`live-run`,children:[(0,I.jsxs)(`div`,{className:`live-run-head`,children:[(0,I.jsxs)(`button`,{className:`live-run-id`,onClick:()=>e.openItem(n.id),children:[(0,I.jsx)(`span`,{children:n.id}),n.title&&(0,I.jsx)(`small`,{children:n.title})]}),!r&&n.active_at&&(0,I.jsx)(ei,{at:n.active_at})]}),r&&(0,I.jsxs)(`div`,{className:`live-limit`,title:`The usage limit is one for the account. The run waits for the reset by itself and goes on in the same session; the queue waits behind it.`,children:[`◷ limit: resumes `,oi(r),(0,I.jsx)(`span`,{children:`waits for the reset by itself · Stop ends the wait: paused: limit, the queue goes on`})]}),t.ids.length>1&&(0,I.jsxs)(`span`,{className:`live-batch`,children:[`item `,t.ids.indexOf(n.id)+1,` of `,t.ids.length,`: `,t.ids.join(`, `)]}),i&&(0,I.jsxs)(`div`,{className:`live-plan`,title:`Plan checkboxes done / total`,children:[(0,I.jsx)(`span`,{children:`tasks`}),(0,I.jsx)(`span`,{className:`bar`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{style:{width:`${Math.round(100*i.done/Math.max(1,i.tasks))}%`}})}),(0,I.jsxs)(`span`,{className:`mono`,children:[i.done,` of `,i.tasks]})]}),(0,I.jsxs)(`div`,{className:`live-run-foot`,children:[(0,I.jsxs)(`span`,{children:[`this board · `,t.mode,` · started `,oi(t.started),t.model||t.effort?` · on ${[t.model,t.effort].filter(Boolean).join(` · `)}`:``]}),(0,I.jsx)(`button`,{className:`btn`,onClick:()=>e.openItem(n.id),children:`Follow`}),(0,I.jsx)(`button`,{className:`btn-danger`,title:r?`Ends the wait for the reset: it becomes paused: limit, Run resumes it later, and the queue goes on`:`Stops the agent session; the item stays ready and its work is kept`,onClick:()=>void Yi(e,n),children:`Stop`})]})]},t.started+n.id)}),o.map(t=>(0,I.jsxs)(`button`,{className:`live-other`,onClick:()=>e.openItem(t.id),children:[(0,I.jsxs)(`span`,{className:`live-other-kind`,children:[`◐ `,ii(t),t.running_kind!==`session`&&t.active_at&&(0,I.jsx)(ei,{at:t.active_at})]}),(0,I.jsx)(`span`,{className:`live-other-id`,children:t.id}),(0,I.jsx)(`span`,{className:`live-other-note`,children:t.running_kind===`session`?`no log: an interactive session`:`no run report: started from a console`})]},t.id)),l&&(0,I.jsxs)(`section`,{className:`live-queue`,"aria-label":`Run queue`,children:[(0,I.jsxs)(`h3`,{children:[`Queue · `,c.length,n?.paused?` · paused`:``]}),!c.length&&(0,I.jsx)(`span`,{className:`live-empty`,children:`empty`}),c.map((t,i)=>{let a=r(t)?.waits_for??[],o=n?.queued_with?.[t];return(0,I.jsxs)(`div`,{className:`live-q`,children:[(0,I.jsxs)(`span`,{className:`mono`,children:[`#`,i+1]}),(0,I.jsxs)(`button`,{className:`live-q-id`,onClick:()=>e.openItem(t),children:[(0,I.jsx)(`span`,{children:t}),o&&(0,I.jsxs)(`small`,{title:`What it will run on: this run's pick`,children:[`on `,[o.model??`its own model`,o.effort].filter(Boolean).join(` · `)]}),a.length>0&&(0,I.jsxs)(`small`,{children:[`⧗ waits for `,a.join(`, `)]})]}),(0,I.jsx)(Na,{label:`Remove from queue`,tip:`Remove from queue; it asks nothing`,onClick:()=>void e.unqueue(t)})]},t)})]}),(n?.acts??[]).length>0&&(0,I.jsxs)(`section`,{className:`live-acts`,"aria-label":`What ran by itself`,children:[(0,I.jsx)(`h3`,{children:`What ran by itself`}),[...n?.acts??[]].reverse().slice(0,12).map((e,t)=>(0,I.jsxs)(`div`,{className:`live-act`,children:[(0,I.jsx)(`span`,{children:oi(e.at)}),(0,I.jsx)(`span`,{children:e.text})]},t))]})]})}function xx({ctx:e}){return(0,I.jsxs)(`div`,{className:`command`,children:[(0,I.jsx)(yx,{ctx:e}),(0,I.jsx)(bx,{ctx:e})]})}var Sx=[`start`,`pillars`,`vision`,`glossary`,`units`,`questions`,`designer`],Cx={start:`Start`,pillars:`Pillars`,vision:`Vision & scope`,glossary:`Glossary`,units:`Units`,questions:`Questions`,designer:`Designer`},wx=[`mechanic`,`resource`,`rule`,`constraint`,`entity`],Tx={line:`One line`,lines:`Lines: one per line`,records:`Records: each record's keys side by side; add or remove a record`},Ex=[[`Your GDD is kept`,`in gcf/source/, each section anchored: a new version shows what changed.`],[`Design units`,`in gcf/design/, by subsystem: each slot is a word-for-word quote of the GDD, or TBD.`],[`Their order`,`in backlog.md.`],[`Questions`,`here and in Inbox: what the GDD leaves open (Decision needed) and what the agent assumed (Assumption to check).`],[`Drafts of the vision and the glossary`,`you confirm them in the thread.`],[`Pillar candidates`,`for the pillars step.`],[`Nothing on the board`,`no item is made: a unit becomes work only when you take it into work.`]],Dx=e=>e.replace(/_/g,` `),Ox=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function kx(e,t,n=!1){let r=e.board.domain.starts?.[t],[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=$a(e.board.quota),l=t=>n?s(t):e.notify(t,`error`),u=c?`Off until ${oi(c)}: the usage limit holds for the account. The forms work without an agent.`:i?`Opening a new thread of the project chat…`:`${r?.help??``} · opens a new thread of the project chat with ${r?.skill??`its skill`}, and goes to it`,d=async n=>{a(!0),s(``);try{let r=await k.start(e.project.name,t,n);e.reloadTalks(),e.go(`chat`,r.thread)}catch(e){l(e.message)}a(!1)};return{s:r,busy:i,err:o,off:!!c||i,tip:u,go:d,pick:async e=>{if(!/\.md$/i.test(e.name))return l(`${e.name} is not markdown: save a Word or Google document as .md first`);if(e.size>5242880)return l(`${e.name} is ${(e.size/1048576).toFixed(1)} MB: a GDD is up to 5 MB`);await d({file:{name:e.name,text:await e.text()}})}}}function Ax({st:e,k:t,unit:n,system:r,primary:i}){let a=e.s;return a?(0,I.jsx)(jo,{label:e.busy?`Starting…`:a.label,tip:e.tip,glyph:Ao(t),primary:i,starting:e.busy,off:e.off||a.takes===`unit`&&!n||a.takes===`system`&&!r,onClick:()=>void e.go(a.takes===`unit`?{unit:n}:a.takes===`system`?{system:r}:{}),file:a.takes===`file`?t=>void e.pick(t):void 0}):null}function jx({ctx:e,k:t,unit:n,system:r,named:i,primary:a}){let o=kx(e,t);if(!o.s)return null;let s=(0,I.jsx)(Ax,{st:o,k:t,unit:n,system:r,primary:a});return i?(0,I.jsxs)(`span`,{className:`agent-act`,children:[s,o.busy?`Starting…`:o.s.label]}):s}function Mx({ctx:e,k:t,primary:n}){let r=kx(e,t,!0);return r.s?(0,I.jsxs)(`div`,{className:`design-way`,children:[(0,I.jsxs)(`div`,{className:`design-way-head`,children:[(0,I.jsx)(Ax,{st:r,k:t,primary:n}),(0,I.jsx)(`span`,{className:`design-way-label`,children:r.busy?`Starting…`:r.s.label})]}),(0,I.jsx)(`span`,{className:`design-note`,children:r.s.help}),r.s.takes===`file`&&(0,I.jsx)(`span`,{className:`design-fine`,children:`.md, up to 5 MB · a Word or Google document: save it as markdown first`}),r.err&&(0,I.jsx)(`span`,{role:`alert`,className:`design-err`,children:r.err})]}):null}function Nx({ctx:e,label:t,big:n}){let r=kx(e,`ingest`);return r.s?(0,I.jsxs)(`label`,{className:`design-pick${n?` big`:``}${r.off?` off`:``}`,title:r.tip,"aria-disabled":r.off||void 0,children:[r.busy?`Starting…`:t,(0,I.jsx)(`input`,{type:`file`,accept:`.md,text/markdown`,"aria-label":n?`Pick the same GDD again`:`Import a new version: pick the GDD`,disabled:r.off,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&r.pick(t)}})]}):null}function Px({ctx:e,k:t,label:n,help:r}){let i=kx(e,t),[a,o]=(0,v.useState)(``);if(!i.s)return null;let s=`design-rev-${t}`;return(0,I.jsxs)(`div`,{className:`design-panel`,children:[(0,I.jsx)(`label`,{htmlFor:s,className:`design-revise-label`,children:n}),(0,I.jsx)(`span`,{className:`design-note`,children:r}),(0,I.jsxs)(`div`,{className:`design-revise-row`,children:[(0,I.jsx)(`input`,{id:s,className:`design-input`,placeholder:`what to change, in your words`,value:a,onChange:e=>o(e.target.value)}),(0,I.jsx)(jo,{label:i.busy?`Starting…`:i.s.label,tip:!i.off&&!a.trim()?`Say first what to change`:i.tip,glyph:Ao(t),starting:i.busy,off:i.off||!a.trim(),onClick:()=>void i.go({text:a})})]})]})}function Fx({label:e,aria:t,v:n,onChange:r,name:i}){let a=xr(n);return(0,I.jsxs)(`label`,{className:`design-cell`,children:[(0,I.jsx)(`span`,{children:e}),(0,I.jsx)(`input`,{className:`design-input${a?` tbd`:``}${i?` strong`:``}`,"aria-label":t,placeholder:a?`TBD`:``,value:a?``:n,onChange:e=>r(e.target.value===``&&a?`TBD`:e.target.value)})]})}function Ix({f:e,value:t,edited:n,compact:r,onChange:i,toText:a}){let o=e.form===`scalar`?`line`:e.form===`record-list`?`records`:`lines`,s=`design-f-${e.key}`,c=Dx(e.key),l=e.value===`TBD`&&mr(t),u=o===`records`&&Array.isArray(t)?t:[],d=u.reduce((e,t)=>e+Object.values(t).filter(xr).length,0),f=mr(t),p=l?[`TBD`,e.note].filter(Boolean).join(` · `):f?[e.required?`empty`:``,e.note].filter(Boolean).join(` · `):``,m=(0,I.jsxs)(`div`,{className:`design-fhead${r?` compact`:``}`,children:[(0,I.jsx)(`label`,{htmlFor:s,className:`design-fkey`,children:c}),!r&&o===`lines`&&(0,I.jsx)(`span`,{className:`design-fkind`,title:Tx.lines,children:`one per line`}),(l||d>0)&&(0,I.jsx)(`span`,{className:`design-tbd-badge`,title:l?`To be decided: the slot is open. A unit with a TBD cannot go into work`:`${d} record value${d>1?`s are`:` is`} TBD`,children:l?`TBD`:`TBD ${d}`}),n&&(0,I.jsx)(`span`,{className:`design-changed`,children:`changed`}),(0,I.jsx)(`span`,{className:`design-spacer`}),e.required?f&&!l?(0,I.jsx)(`span`,{className:`design-req empty`,title:`Required: the part does not hold without it`,children:`● required · empty`}):(0,I.jsx)(`span`,{className:`design-req`,title:`Required: it cannot be left empty (TBD keeps it open)`,children:`● required`}):(0,I.jsx)(`span`,{className:`design-req opt`,title:`Optional: it may stay empty`,children:`optional`})]}),h=e.note&&(0,I.jsx)(`span`,{className:r?`design-fnote small`:`design-fnote`,children:e.note});if(!e.exact){let t=e.value,n=Array.isArray(t)?t.map(e=>typeof e==`object`?Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(` · `):e).join(`
76
+ `),n=t.pop()??``,r=[];for(let e of t)if(e.trim())try{let t=JSON.parse(e);t&&typeof t.type==`string`&&r.push(t)}catch{}return{events:r,rest:n}}var B_=` (Recommended)`;function V_(e){let t={live:!1,phase:`idle`,ctx:void 0,bg:[],cost:0,limitUntil:null,waitKind:null,waitAt:null,everStarted:!1,endedIdle:!1,freshQueued:!1,tasks:[]},n=0,r=!1,i=new Set;for(let a of e)switch(a.type===`turn`?r=!0:([`session`,`working`,`read`,`agent`].includes(a.type)||a.type===`say`&&a.by===`operator`)&&(r=!1),a.type){case`session`:t.live=!0,t.everStarted=!0,t.endedIdle=!1,t.phase=`ready`,n=0,t.limitUntil=null,i.clear(),a.kind===`handoff`&&(t.ctx=0,t.freshQueued=!1);break;case`session_end`:t.live=!1,t.cost+=a.cost_usd??n,n=0,t.phase=a.code===`idle`?`idle`:`ended`,t.endedIdle=a.code===`idle`,t.bg=[],t.freshQueued=!1,i.clear();break;case`limit`:t.phase=`limit`,t.limitUntil=a.until;break;case`closed`:t.live=!1,t.phase=`ended`,t.endedIdle=!1,t.limitUntil=null,t.bg=[],t.freshQueued=!1,i.clear();break;case`working`:case`read`:case`agent`:t.live&&t.phase!==`limit`&&(t.phase=`working`);break;case`say`:a.by===`operator`&&(t.phase===`waiting`||t.phase===`ready`)&&(t.phase=`working`);break;case`waiting`:t.phase=`waiting`,t.waitKind=a.kind,t.waitAt=a.at;break;case`question`:case`approval`:i.add(a.request_id);break;case`answer`:case`allowed`:case`denied`:case`dropped`:a.request_id&&i.delete(a.request_id),t.phase===`waiting`&&t.waitKind===`card`&&!i.size&&(t.phase=`working`);break;case`timeout`:a.kind===`card`&&i.clear();break;case`interrupt`:t.phase=`working`;break;case`turn`:n=a.total_cost_usd??n,a.context_pct!==void 0&&(t.ctx=a.context_pct);break;case`context`:t.ctx=a.context_pct;break;case`background`:t.bg=a.tasks??[];break;case`handoff`:t.freshQueued=!!(a.error&&t.bg.length)}return t.live&&(t.cost+=n),t.tasks=[...H_(e).values()].filter(e=>e.state===`running`).map(e=>({id:e.id,run:e.run,kind:e.what,agent:e.agent,description:e.description,doing:e.doing,calls:e.calls,at:e.at})),t.phase===`waiting`&&t.waitKind===`text`&&t.bg.length&&(t.phase=`background`),t.phase===`working`&&r&&t.bg.length&&(t.phase=`background`),t}function H_(e){let t=new Map,n=new Map,r=new Set,i=(e,t)=>Date.parse(t)-Date.parse(e.at);return e.forEach((e,a)=>{if(e.type===`session`||e.type===`session_end`||e.type===`closed`){for(let e of n.values())e.state===`running`&&(e.state=`stopped`);n.clear(),r=new Set}else if(e.type===`background`){let t=new Set((e.tasks??[]).map(e=>e.id));for(let a of r){let r=n.get(a);t.has(a)||r?.state!==`running`||(r.state=`done`,r.doing=null,r.ms??=i(r,e.at))}r=t}else if(e.type===`task`){let r=n.get(e.id);(!r||e.phase===`start`&&r.state!==`running`)&&(r={kind:`task`,at:e.at,id:e.id,run:a,what:`task`,agent:null,description:``,prompt:``,doing:null,calls:null,ms:null,state:`running`,status:null,summary:``,background:!1},n.set(e.id,r),t.set(a,r)),e.kind&&r.what===`task`&&(r.what=e.kind),e.agent&&(r.agent??=e.agent),e.description&&!r.description&&(r.description=e.description),e.prompt&&!r.prompt&&(r.prompt=e.prompt),e.background&&(r.background=!0),typeof e.calls==`number`&&(r.calls=e.calls),e.phase===`progress`&&(e.doing&&r.state===`running`&&(r.doing=e.doing),typeof e.ms==`number`&&(r.ms=e.ms)),e.phase===`end`&&(r.status=e.status??null,r.state=!e.status||e.status===`completed`?`done`:/kill|stop/.test(e.status)?`stopped`:`failed`,r.summary=e.summary??r.summary,r.doing=null,r.ms=typeof e.ms==`number`?e.ms:i(r,e.at))}}),t}function U_(e){let t=new Map;for(let n of e)n.type===`question`||n.type===`approval`?t.set(n.request_id,n):n.type===`answer`||n.type===`allowed`||n.type===`dropped`||n.type===`denied`&&n.request_id?t.delete(n.request_id):(n.type===`timeout`&&n.kind===`card`||n.type===`session_end`||n.type===`session`||n.type===`closed`)&&t.clear();return[...t.values()][0]??null}function W_(e){let t=-1;return e.forEach((e,n)=>{e.type===`session`&&e.kind===`handoff`&&(t=n)}),t<0||e.slice(t).some(e=>e.type===`say`&&e.by===`operator`)}var G_={edit:`edit`,shell:`shell`,read:`read`,search:`search`,web:`web`,mcp:`mcp`,skill:`skill`,subagent:`subagent`,other:`other`},K_={operator:`denied by you`,rule:`denied by a deny rule of the project`,timeout:`denied: no answer in time`,engine:`refused by the center itself`},q_=e=>`$${(e??0).toFixed(2)}`,J_=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toTimeString().slice(0,5)},Y_=e=>e.kind===`approval`&&e.state!==`waiting`||e.kind===`refused`||e.kind===`line`&&!!e.tech,X_=e=>e?J_(e):`?`;function Z_(e,{talk:t,answerMin:n}){let r=[],i=new Map,a=new Map,o=new Map,s=V_(e),c=0,l=null,u=!1,d=null,f=[],p=(e,t,n,i=null,a={})=>r.push({kind:`line`,at:e.at,mark:t,text:n,tone:i,...a}),m=H_(e),h=m.size>0,g=()=>{for(let e of a.values())e.state===`waiting`&&(e.state=`dropped`,e.dropWhy=`the session closed`)};return e.forEach((_,v)=>{switch(_.type){case`session`:{c++,g();let e=_.model!==void 0||_.effort!==void 0?`model ${_.model??`default`}, effort ${_.effort??`default`}`:null,n=e&&(d===null?_.model||_.effort:e!==d)?` · on ${e}`:``;d=e??d,_.kind===`handoff`?(l=null,p(_,`↻`,(t?`a fresh agent goes on from the summary`:`fresh session · it goes on from the Handoff in the plan`)+n,`running`)):_.kind===`resume`?p(_,`▸`,(t?u?`agent started again after the reset · it remembers the earlier talk`:`agent started again · it remembers the earlier talk`:`session resumed · it remembers the talk`)+n,`running`):p(_,`▸`,(t?`agent started`:`run session started`)+n,`running`);break}case`session_end`:g(),f=[],_.code===`idle`?p(_,`■`,`agent closed after ${n} min with no input · not an error: your next message starts it again`):_.limit_resets?p(_,`■`,`${t?`agent closed at once at the usage limit`:`session ended at the usage limit`} · resets ${_.limit_resets} · ${q_(_.cost_usd)}`,null,{mono:!0}):_.code===`handoff`?p(_,`■`,`session ended for the handoff · ${q_(_.cost_usd)}`,null,{mono:!0}):_.code===`stopped`?p(_,`■`,`session stopped · ${q_(_.cost_usd)}`,null,{mono:!0}):p(_,`■`,`${t&&typeof _.code==`number`?`agent ended (exit ${_.code})`:t?`agent ended`:`session ended`} · ${q_(_.cost_usd)}`,null,{mono:!0});break;case`closed`:{u=!1,g(),f=[];let e=_.dropped?` · ${_.dropped===1?`1 message`:`${_.dropped} messages`} not sent`:``;p(_,`■`,`agent closed by you, with all it started · your next message resumes the talk${e}`);break}case`limit`:{u=!0;let e=s.phase===`limit`&&s.limitUntil===_.until,n=t?` · the agent starts again by itself after the reset and finishes the cut reply. Until then only a message is taken: Stop, card answers and fresh agent are off; close agent ends the wait`:` · the session goes on by itself; a message sent now reaches the agent after the reset`;p(_,`◷`,`limit: resumes ${X_(_.until)}${e?n:``}`,`neutral`,{box:e,tip:`The usage limit is one for the account. It waits for the reset by itself.`});break}case`say`:if(_.by===`operator`||_.by===`timeout`){let e={kind:`me`,at:_.at,text:_.text,images:_.images??[],byTimeout:_.by===`timeout`,n:_.n,status:_.by===`timeout`?`sent by the timeout: no answer came in ${n} min`:_.retry?`sent again after a crash: it may be a duplicate`:s.phase===`limit`?`accepted · reaches the agent after the reset`:`sent`};i.set(`${c}:${_.n}`,e),r.push(e)}else _.by===`run`?p(_,`›`,`run prompt: ${_.text}`,null,{mono:!0}):l?l.tip=`The center asked the agent: ${_.text}`:t&&u?(u=!1,p(_,`›`,`the center asked the agent after the reset: “${_.text}” · its next text answers this`,null,{box:!0,tip:`say by: engine — the center's own words to the agent`})):p(_,`·`,`the center asked the agent for a summary`,null,{tip:_.text});break;case`read`:{let e=i.get(`${c}:${_.n}`);e&&!e.byTimeout&&(e.status=`${e.status.startsWith(`sent again`)?`sent again after a crash · `:``}${_.assumed?`taken as read: no echo came`:`read ${J_(_.at)}`}`);break}case`agent`:/hit your (session )?limit/i.test(_.text)?r.push({kind:`claude`,at:_.at,text:_.text}):l?l.summary=l.summary?`${l.summary}\n\n${_.text}`:_.text:r.push({kind:`agent`,at:_.at,text:_.text});break;case`question`:{let e={kind:`question`,at:_.at,id:_.request_id,state:`waiting`,questions:_.questions.map(e=>({...e,options:(e.options??[]).map(e=>({raw:e.label,label:e.label.endsWith(` (Recommended)`)?e.label.slice(0,-14):e.label,rec:e.label.endsWith(B_),description:e.description}))}))};a.set(_.request_id,e),o.set(_.request_id,v),r.push(e);break}case`answer`:{let e=a.get(_.request_id);e?.kind===`question`&&(e.state=_.by===`timeout`?`timeout`:`answered`,e.answers=_.answers);break}case`dropped`:{let t=a.get(_.request_id);if(!t)break;let n=e.slice(o.get(_.request_id)??0,v);t.state=`dropped`,t.dropWhy=n.some(e=>e.type===`interrupt`)?`your Stop ended the turn`:n.some(e=>e.type===`session_end`)?`the session closed`:`the turn ended`;break}case`approval`:{let e={kind:`approval`,at:_.at,id:_.request_id,tool:_.tool,what:G_[_.kind]??_.kind,title:_.title,reason:_.reason,always:_.always,..._.always&&_.always_wide?{wide:!0}:{},state:`waiting`};a.set(_.request_id,e),r.push(e);break}case`allowed`:{if(_.by===`yolo`){r.push({kind:`approval`,at:_.at,id:_.request_id,tool:_.tool,what:G_[_.kind]??_.kind,title:_.title,reason:_.reason,state:`auto`});break}let t=a.get(_.request_id);t?.kind===`approval`&&(t.state=_.always?`always`:`once`,t.rule=_.rule??t.always,t.notSaved=!_.always&&!!t.always&&e.slice(Math.max(0,v-2),v).some(e=>e.type===`error`&&e.text.startsWith(`the rule ${t.always} was not saved`)));break}case`run_end`:r.push({kind:`run_end`,at:_.at,end:_});break;case`denied`:{let e=_.request_id?a.get(_.request_id):void 0;e?.kind===`approval`?(e.state=`denied`,e.deniedBy=_.by):_.by===`engine`&&!t?_.tool===`AskUserQuestion`?p(_,`✕`,`question card refused by the center: this run asks nothing (answer time 0)`,`warn`,{box:!0,tech:{tool:`question`,title:`AskUserQuestion`,out:`refused by the center: this run asks nothing`,tone:`warn`},tip:`chat.answer_timeout_min is 0: the session asks no question`}):p(_,`✕`,`${_.tool||`the call`} refused by the center: no one approves a call in a run`,`warn`,{box:!0,tech:{tool:_.kind??(_.tool||`call`),title:_.title||(_.kind?_.tool:``),out:`refused by the center: no one approves a call in a run`,tone:`warn`},mono:!0,tip:`A run asks no permission: its deny rules decide`}):_.by===`engine`?p(_,`✕`,`${_.tool}${_.title?` ${_.title}`:``} — refused by the center: ${_.reason??``}`,`warn`,{box:!0,tech:{tool:_.kind??_.tool,title:_.title||(_.kind?_.tool:``),out:`refused by the center: a main run works here`,tone:`warn`},mono:!0,tip:`The center refused it by itself, with no card: a main run works in the same folder.`}):_.by===`rule`?r.push({kind:`refused`,at:_.at,tool:_.tool,what:_.kind??_.tool,title:_.title??``,why:_.description??``,rule:_.rule,group:_.group,reason:_.reason??``}):p(_,`✕`,`${_.tool}${_.title?` ${_.title}`:``} — ${K_[_.by??``]??`denied`}${_.reason?`: ${_.reason}`:``}`,null,{mono:!0,tech:{tool:_.kind??_.tool,title:_.title||(_.kind?_.tool:``),out:K_[_.by??``]??`denied`}});break}case`timeout`:if(_.kind===`text`)p(_,`◷`,`no answer in ${n} min: the default answer goes to the agent`);else for(let e of a.values())e.state===`waiting`&&(e.kind===`approval`?(e.state=`denied`,e.deniedBy=`timeout`):e.state=`timeout`);break;case`interrupt`:p(_,`‖`,t?`you pressed Stop: the step stopped · the agent waits for your message and closes after ${n} min, as after any reply`:`you pressed Stop: the step stopped, the session stays open`,`neutral`);break;case`waiting`:_.kind===`stop`&&!t&&p(_,`·`,`the agent waits for your message; after a Stop no default answer comes`);break;case`error`:p(_,`✕`,_.text,`error`,{box:!0,mono:!0,tip:`Input that reached no one`});break;case`task`:{let e=m.get(v);e&&r.push(e);break}case`background`:if(f=_.tasks??[],h)break;p(_,`⟳`,_.tasks?.length?`in the background: ${_.tasks.map(e=>e.description).join(`, `)} · no timer runs, no default answer comes`:`background tasks done`,`running`);break;case`compacted`:p(_,`↧`,`the agent compacted its context by itself`);break;case`handoff`:{if(_.error){let e=l;e?(e.failed=!0,l=null,p(_,`✕`,`the summary failed: ${_.error} · the same agent goes on`,`warn`,{box:!0,tip:`The fresh agent did not start. The talk goes on with the agent you had.`})):f.length?p(_,`◷`,`fresh agent queued: ${_.error} · once the background tasks end it takes over by itself, with no second click`,`neutral`,{box:!0,tip:`Not an error: the summary turn waits for the background tasks`}):p(_,`↻`,`fresh agent: ${_.error} · the agent is a fresh one already and has not had your message: nothing changes`,`neutral`,{box:!0,tip:`Not an error: the press changes nothing`});break}let e=typeof _.pct==`number`?` · context ${_.pct}%`:_.tokens?` · ${Math.round(_.tokens/1e3)}k tokens`:``;if(t){let t=_.by===`operator`?`by you, with fresh agent`:_.by===`threshold`?`past the handoff share`:_.by===`compacted`?`after a compaction`:`handed over`;l={kind:`divider`,at:_.at,by:`${t}${e}`,summary:``,failed:!1},r.push(l)}else p(_,`↻`,`context handoff${typeof _.pct==`number`?` at ${_.pct}%`:``} · the agent writes its Handoff into the plan, a fresh session goes on`,`running`);break}case`proposal`:r.push({kind:`proposal`,at:_.at,id:_.id,move:_.move,fields:_.fields??{}});break;case`step`:{let e=`ok`in _?_.ok:null,t;if(_.step===`plan`)t=`plan converged in ${_.passes} passes`;else if(_.step===`move`)t=`${{submit:`submitted · waits for your verdict`,close:`closed`,block:`blocked`}[_.move]??_.move}${_.text?` · ${_.text}`:``}`;else{let n={dod:`checks (DoD)`,review:`review`,commit:`committed`}[_.step];t=_.step===`commit`&&e?`committed`:_.step===`review`&&e?`review done`:`${n}${e===!0?` green`:e===!1?` red`:`: result unknown · the check ran, its result could not be matched`}`,_.text&&(t+=` · ${_.text}`)}let n=_.step===`plan`;r.push({kind:`step`,at:_.at,mark:n||e===!0?`✔`:e===!1?`✘`:`?`,text:t,tone:n||e===!0?`ok`:e===!1?`error`:`neutral`,unknown:!n&&e===null});break}}}),r}function Q_(e,t,n){let r={};for(let i=0;i<e.length;i++){let a=(t[i]??[]).map(e=>e.endsWith(` (Recommended)`)?e.slice(0,-14):e),o=a.length?a.join(`, `):(n[i]??``).trim();if(!o)return null;r[e[i].question]=o}return r}function $_(e,t,n){let r=e=>e.id?t.some(t=>t.type===`say`&&t.id===e.id):n>e.after,i=e=>t.slice(e.from).some(t=>t.type===`error`&&/ not sent: /.test(t.text)&&(!t.id||!e.id||t.id===e.id));return e.filter(e=>!r(e)&&!i(e))}var ev=`gcf-chat-tech`,tv=[`expanded`,`collapsed`,`hidden`];function nv(){try{let e=localStorage.getItem(ev);return tv.includes(e)?e:`collapsed`}catch{return`collapsed`}}var rv=nv(),iv=new Set,av=()=>{for(let e of iv)e()};typeof window<`u`&&window.addEventListener(`storage`,e=>{(e.key===ev||e.key===null)&&(rv=nv(),av())});function ov(e){rv=e;try{localStorage.setItem(ev,e)}catch{}av()}function sv(e){return iv.add(e),()=>{iv.delete(e)}}var cv=()=>(0,v.useSyncExternalStore)(sv,()=>rv),lv=!1,uv=new Set,dv=null,fv=0,pv=0,mv=()=>{for(let e of uv)e()};function hv(){let e=++fv;k.yolo().then(t=>{e<pv||(pv=e,lv=t.on,mv())}).catch(()=>{})}function gv(e){if(uv.add(e),!dv){let e=ne(e=>{e.type===`yolo`&&hv()}),t=P(e=>{e&&hv()});dv=()=>{e(),t()},hv()}return()=>{uv.delete(e),uv.size||(dv?.(),dv=null)}}var _v=()=>(0,v.useSyncExternalStore)(gv,()=>lv);async function vv(e){let t=++fv,n=await k.setYolo(e);t<pv||(pv=t,lv=n.on,mv())}var yv=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],bv=10,xv=5242500,Sv=7340032,Cv=`png, jpeg, gif or webp · up to 10 a message, 5 MB each, about 7 MB in all with the files`,wv=/^(https?:|mailto:)/i,Tv=[r_,om],Ev={a:({node:e,href:t,children:n})=>t&&wv.test(t)?(0,I.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,children:n}):(0,I.jsx)(`span`,{children:n}),input:({node:e,type:t,checked:n})=>t===`checkbox`?(0,I.jsx)(`span`,{className:`c-task ${n?`done`:``}`,"aria-label":n?`done`:`not done`,children:n?`☑`:`☐`}):null,img:({src:e,alt:t})=>typeof e==`string`&&wv.test(e)?(0,I.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:t||e}):(0,I.jsx)(`span`,{children:t}),pre:({node:e})=>(0,I.jsx)(I_,{text:N_(e),lang:F_(e)})},Dv=({text:e})=>(0,I.jsx)(Jp,{remarkPlugins:Tv,components:Ev,children:e}),Ov=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toTimeString().slice(0,5)},kv=e=>`${(e/1024/1024).toFixed(1)} MB`,Av=e=>`$${e.toFixed(2)}`,jv=(...e)=>(0,I.jsx)(`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:e.map(e=>(0,I.jsx)(`path`,{d:e},e))}),Mv={file:jv(`M20 11.5l-8.2 8.2a5 5 0 0 1-7.1-7.1l8.6-8.6a3.4 3.4 0 0 1 4.8 4.8l-8.6 8.6a1.7 1.7 0 0 1-2.4-2.4l7.9-7.9`),picture:jv(`M5.5 4.5h13a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2h-13a2 2 0 0 1-2-2v-11a2 2 0 0 1 2-2z`,`M10.6 10a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0z`,`M20.5 16l-5-5-8 8.5`),fresh:jv(`M20 12a8 8 0 1 1-2.6-5.9`,`M20 4v5h-5`),stop:(0,I.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,I.jsx)(`rect`,{x:`5`,y:`5`,width:`14`,height:`14`,rx:`2`,fill:`currentColor`})}),close:jv(`M6 6l12 12M18 6L6 18`),send:jv(`M21 3L10.5 13.5`,`M21 3l-6.5 18-4-7.5L3 9.5z`)};function Nv(e){let[t,n]=(0,v.useState)([]);return(0,v.useEffect)(()=>{if(n([]),!e)return;let t=``,r=!0;return M(e,()=>{t=``,r=!0},e=>{let i=z_(t+e);t=i.rest;let a=r;r=!1,n(e=>a?i.events:[...e,...i.events])})},[e]),t}var Pv=15e3;function Fv(e){let[t,n]=(0,v.useState)(Date.now());return(0,v.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),t}function Iv({from:e,minutes:t}){let n=Fv(!0),r=Math.max(0,Math.round((Date.parse(e)+t*6e4-n)/1e3));return(0,I.jsxs)(`span`,{"aria-live":`off`,className:`mono`,children:[String(Math.floor(r/60)).padStart(2,`0`),`:`,String(r%60).padStart(2,`0`)]})}var Lv=(e,t)=>{let n=e.board.chat?.answer_timeout_min;return t?n||15:n??15};function Rv({e,part:t,minutes:n,live:r}){let[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(!1),u=r.phase===`limit`,d=e.state===`waiting`&&!u,f=Q_(e.questions,i,o),p=async()=>{f&&(l(!0),await t.send({type:`answer`,request_id:e.id,answers:f}).catch(()=>{}),l(!1))},m=e.state===`answered`?`answered by you`:e.state===`timeout`?`no answer in ${n} min: ${e.questions.every(e=>e.options.some(e=>e.rec))?`the recommended option was taken`:`the default text went to the agent`}`:e.state===`dropped`?`withdrawn: ${e.dropWhy??`the turn ended`}`:u?`off: no card is open during the limit wait`:`waiting for you · the default goes in`;return(0,I.jsxs)(`div`,{role:`group`,"aria-label":`Question from the agent`,className:`c-card ${d?`pending`:``}`,children:[e.questions.map((t,n)=>{let r=e.answers?.[t.question]??``,c=r?r.split(/,\s*/):[],l=i[n]??[],u=(e,t)=>d?l.includes(e):c.includes(t)||c.includes(e),f=r&&!t.options.some(e=>u(e.raw,e.label))?`${e.state===`timeout`?`default text`:`your answer`}: ${r}`:``;return(0,I.jsxs)(`div`,{role:`group`,"aria-label":t.question,className:`c-q`,children:[(0,I.jsxs)(`div`,{className:`c-q-head`,children:[t.header&&(0,I.jsxs)(`span`,{className:`c-q-tag`,children:[`? `,t.header]}),(0,I.jsx)(`span`,{className:`dim small`,children:t.multiSelect?`pick any`:`pick one`}),(0,I.jsx)(`span`,{className:`c-time`,children:Ov(e.at)})]}),(0,I.jsx)(`div`,{className:`c-q-text`,children:t.question}),(0,I.jsx)(`div`,{className:`c-q-options`,children:t.options.map(e=>{let r=u(e.raw,e.label);return(0,I.jsxs)(`button`,{role:t.multiSelect?`checkbox`:`radio`,"aria-checked":r,disabled:!d,className:r?d?`on`:`done`:``,onClick:()=>a(r=>{let i=r[n]??[];return{...r,[n]:t.multiSelect?i.includes(e.raw)?i.filter(t=>t!==e.raw):[...i,e.raw]:i[0]===e.raw?[]:[e.raw]}}),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:r?t.multiSelect?`☑`:`●`:t.multiSelect?`☐`:`○`}),(0,I.jsxs)(`span`,{children:[(0,I.jsxs)(`span`,{className:`c-q-label`,children:[e.label,e.rec&&(0,I.jsx)(`span`,{className:`c-rec`,title:`The agent's default: the timeout takes it`,children:`recommended`})]}),e.description&&(0,I.jsx)(`small`,{children:e.description})]})]},e.raw)})}),d&&(0,I.jsx)(`input`,{className:`input`,"aria-label":`Your own answer to: ${t.question}`,value:o[n]??``,onChange:e=>s({...o,[n]:e.target.value}),placeholder:`Or answer in your own words`}),f&&(0,I.jsxs)(`span`,{className:`c-q-shown`,children:[`✔ `,f]})]},n)}),d&&(0,I.jsxs)(`div`,{className:`c-submit`,children:[(0,I.jsx)(`button`,{className:`btn-primary`,disabled:!f||c,onClick:()=>void p(),children:e.questions.length>1?`Submit answers`:`Submit answer`}),(0,I.jsx)(`span`,{className:`dim small`,children:e.questions.length>1?`One answer goes for the whole card; it cannot be taken back.`:`It cannot be taken back.`})]}),(0,I.jsxs)(`span`,{className:`c-state ${d?`needs`:``}`,children:[m,` `,d&&(0,I.jsx)(Iv,{from:r.waitAt??e.at,minutes:n})]})]})}function zv({e,part:t,minutes:n,live:r}){let[i,a]=(0,v.useState)(!1),o=e.state===`waiting`&&r.phase!==`limit`,s=async e=>{a(!0),await t.send(e).catch(()=>{}),a(!1)},c=e.state===`auto`?`✔ ran without asking (YOLO)`:e.state===`once`?e.notSaved?`✔ allowed once · the rule was not saved`:`✔ allowed once by you`:e.state===`always`?`✔ allowed always · rule saved for this machine and project: ${e.rule??``}`:e.state===`denied`?`✕ ${K_[e.deniedBy??``]??`denied`}`:e.state===`dropped`?`withdrawn: ${e.dropWhy??`the turn ended`}`:r.phase===`limit`?`off: no card is open during the limit wait`:`waiting for you · denied by itself in`,l=o?`needs`:e.state===`denied`||e.state===`dropped`||e.notSaved?``:`ok`;return(0,I.jsxs)(`div`,{role:`group`,"aria-label":e.state===`auto`?`A call YOLO ran`:`Permission asked by the agent`,className:`c-card ${o?`pending`:``}`,children:[(0,I.jsxs)(`div`,{className:`c-q-head`,children:[(0,I.jsx)(`span`,{className:`c-kind`,title:`The kind of tool call`,children:e.what}),(0,I.jsx)(`span`,{className:`c-ask`,children:e.state===`auto`?`The agent ran`:`The agent asks to run`}),(0,I.jsx)(`span`,{className:`c-time`,children:Ov(e.at)})]}),(0,I.jsx)(`code`,{className:`c-call`,children:e.title}),e.reason&&(0,I.jsxs)(`span`,{className:`c-reason`,children:[`Why: `,e.reason]}),o&&(0,I.jsxs)(`div`,{className:`c-acts`,children:[(0,I.jsx)(`button`,{className:`btn-primary`,disabled:i,onClick:()=>void s({type:`allow`,request_id:e.id}),children:`Allow once`}),e.always&&(0,I.jsx)(`button`,{className:`btn`,disabled:i,title:e.wide?`Allows every call of ${e.always}, with any arguments, in every session of this project on this machine (.claude/settings.local.json)`:`Saves the rule ${e.always} for this machine and this project (.claude/settings.local.json)`,onClick:()=>void s({type:`allow`,request_id:e.id,always:!0}),children:`Always`}),(0,I.jsx)(`button`,{className:`btn-line`,disabled:i,onClick:()=>void s({type:`deny`,request_id:e.id}),children:`Deny`})]}),e.always&&(0,I.jsxs)(`span`,{className:`c-rule`,children:[`always would save: `,e.always,e.wide&&` · every call of this tool, any arguments, in every session of this project`]}),!e.always&&o&&(0,I.jsx)(`span`,{className:`dim small`,children:`no "always" for an edit, a git command, a framework move, a whole tool or server, or a rule too broad`}),(0,I.jsxs)(`span`,{className:`c-state ${l}`,children:[c,` `,o&&(0,I.jsx)(Iv,{from:r.waitAt??e.at,minutes:n})]})]})}function Bv({ctx:e,e:t}){let n=t.group?e.board.agent?.groups.find(e=>e.id===t.group):void 0,r=!t.group&&(e.board.agent?.extra??[]).some(e=>(e.pattern?`${e.kind}: ${e.pattern}`:e.kind)===t.rule),i=n?`the deny group ${n.id} (${n.label})`:t.group?`the deny group ${t.group}`:r?`your own deny rule`:`a deny rule of its settings`,a=n&&!n.on?`The group is off now: the next session may do it.`:t.group?`To let the agent do it, turn the group off in Agent permissions: the next session runs without its rules.`:r?`To let the agent do it, remove your rule in Agent permissions: the next session runs without it.`:`The deny rules of the project are in Agent permissions; a change holds from the next session.`;return(0,I.jsxs)(`div`,{role:`group`,"aria-label":`A call a deny rule refused`,className:`c-card c-deny`,children:[(0,I.jsxs)(`div`,{className:`c-q-head`,children:[(0,I.jsxs)(`span`,{className:`c-deny-tool`,title:`The tool the agent called`,children:[`✕ `,t.tool]}),(0,I.jsx)(`span`,{className:`c-ask`,children:`A deny rule refused the agent`}),(0,I.jsx)(`span`,{className:`c-time`,children:Ov(t.at)})]}),(0,I.jsx)(`code`,{className:`c-call`,children:t.title||t.reason}),t.why&&(0,I.jsxs)(`span`,{className:`c-reason`,children:[`It wanted it for: `,(0,I.jsx)(`span`,{className:`c-deny-why`,children:t.why})]}),(0,I.jsxs)(`span`,{className:`c-rule`,children:[`refused by `,i,t.rule?` · rule ${t.rule}`:``]}),(0,I.jsxs)(`div`,{className:`c-deny-foot`,children:[(0,I.jsxs)(`span`,{className:`c-deny-todo ${n&&!n.on?`off`:``}`,children:[`The agent decides by itself how to go on without it. `,a]}),(0,I.jsx)(`button`,{className:`btn`,title:`Opens the Agent screen: its deny groups and rules`,onClick:()=>e.go(`agent`),children:`Agent permissions`})]})]})}function Vv({ctx:e,e:t,part:n}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),l=n.proposals?.find(e=>e.id===t.id),u=r&&(!l||l.state===`offered`)?{...l,id:t.id,state:`accepting`}:l??{id:t.id,state:`offered`},d=_i(e.board.domain.moves,t.move)??t.move,f=Tr(e.board.domain,d),p=f&&!f.fields.some(e=>e.key===`id`)&&typeof t.fields.id==`string`?t.fields.id:void 0,m=p?e.board.items.find(e=>e.id===p):void 0,h=p&&!m?e.board.inbox?.find(e=>e.id===p):void 0,g=d===e.board.domain.sections.questions?.answer,_=p&&g?(e.board.questions??[]).find(e=>e.id===p):void 0,y=u.question??_?.question,b=e=>f?.fields.find(t=>t.key===e)?.label??e,x=d===e.board.domain.new_item,S=(x?[`note`]:[`note`,`reason`,`text`]).find(e=>typeof t.fields[e]==`string`&&t.fields[e]),C=Object.entries(t.fields).filter(([e])=>e!==`title`&&e!==S&&!(p&&e===`id`));for(let e of f?.fields??[])e.kind===`remove`&&t.fields[e.key]===void 0&&C.push([e.key,`by the rule`,!0]);let w=S?t.fields[S]:void 0,T={...f?Fr(f.fields):{},...t.fields},E={talk:n.talk,id:t.id},D=x?`New item`:d,O=p&&!g?`${D} ${p}`:D,k=x?`New item`:g?`Answer to a decision`:Uv(d,f?.label??d),A=u.state===`refused`&&u.refusal?u.refusal:void 0,[ee,j]=(0,v.useState)(!1),M=(0,v.useRef)(null),te=()=>{j(!1),setTimeout(()=>M.current?.focus(),0)},N=async(t=!1)=>{f&&(f.danger&&!t?j(!0):(j(!1),i(!0),o(``),c(!1),await e.move({cmd:f.cmd,...p&&{id:p},...Nr(f.fields,T),proposal:E}),i(!1)))},ne=()=>f&&e.openMove({title:O,id:p,move:f,values:T,body:x?`Filled in from the agent's proposal: every field it proposed. Created and committed at once.`:`Filled in from the agent's proposal: every field it proposed.`,extra:{proposal:E}}),P={offered:`needs`,accepting:`running`,accepted:`ok`,refused:`error`}[u.state],F=x?{offered:`proposed`,accepting:`creating…`,accepted:`created`,refused:`refused`}:{offered:`proposed`,accepting:`making…`,accepted:`made`,refused:`refused`},re={offered:`●`,accepting:`◌`,accepted:`✔`,refused:`✘`}[u.state],L=m?m.running?`running`:m.status:``,R=L===`running`?`running`:e.board.domain.columns.find(e=>e.status===L)?.label??L,z=f?.label??d,ie=u.state===`refused`&&!s;return(0,I.jsxs)(`div`,{role:`group`,"aria-label":`${O} proposed by the agent`,className:`c-card prop ${u.state}`,children:[(0,I.jsxs)(`div`,{className:`c-q-head`,children:[(0,I.jsx)(`span`,{className:`c-prop-what`,title:`The move it proposes: ${d}`,children:k}),(0,I.jsxs)(`span`,{className:`c-prop-state tone-${P}`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:re}),F[u.state]]}),(0,I.jsx)(`span`,{className:`c-time`,children:Ov(t.at)})]}),p&&!g&&(0,I.jsxs)(`div`,{className:`c-prop-target`,children:[(0,I.jsxs)(`div`,{className:`c-prop-target-row`,children:[m?(0,I.jsx)(`button`,{className:`link-btn mono c-prop-id`,title:`Open ${m.id}`,onClick:()=>e.openItem(m.id),children:m.id}):(0,I.jsx)(`span`,{className:`mono c-prop-id`,children:h?.id??p}),(0,I.jsx)(`span`,{className:`c-prop-title`,children:m?m.title:h?h.title??h.text.split(`
77
+ `)[0]:``}),m&&u.state!==`accepted`&&(0,I.jsx)(`span`,{className:`badge tone-${L}`,title:`Its status now, read from the board`,children:R})]}),!m&&!h&&u.state!==`accepted`&&(0,I.jsxs)(`span`,{role:`note`,className:`c-prop-warn`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),p,` is not on the board`]}),m&&f&&u.state===`offered`&&!m.moves.includes(f.cmd)&&(0,I.jsxs)(`span`,{role:`note`,className:`c-prop-warn`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),`does not take `,z,` now: the framework will refuse it`]})]}),g&&(0,I.jsxs)(`div`,{className:`c-prop-target`,children:[(0,I.jsx)(`span`,{className:`c-prop-qhead`,children:`The question, as the board first read it`}),(0,I.jsx)(`span`,{className:`c-prop-title c-prop-question`,children:y??`the question is not on the board`}),_?.answer&&_.question===y&&u.state!==`accepted`&&(0,I.jsxs)(`span`,{role:`note`,className:`c-prop-warn`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),`answered already: `,_.answer]})]}),x&&typeof t.fields.title==`string`&&(0,I.jsx)(`span`,{className:`c-prop-title c-prop-new`,children:t.fields.title}),C.length>0&&(0,I.jsx)(`dl`,{className:`c-prop-fields`,children:C.map(([e,t,n])=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:b(e)}),(0,I.jsx)(`dd`,{className:n?`rule`:``,children:String(t)})]},e))}),typeof w==`string`&&w&&S&&(0,I.jsxs)(`div`,{className:`c-prop-note ${x?``:`quote`}`,children:[(0,I.jsx)(`span`,{children:b(S)}),(0,I.jsx)(`div`,{className:`md`,children:(0,I.jsx)(Dv,{text:w})})]}),u.state===`refused`&&s&&(0,I.jsx)(`div`,{role:`status`,className:`c-created`,children:`✔ its files under gcf/ are committed or put back · Try again makes the move`}),ie&&(0,I.jsxs)(`div`,{role:`alert`,className:`c-prop-error`,children:[(0,I.jsx)(`span`,{className:`c-prop-error-head`,children:a?`Commit refused`:`gcf refused it`}),(0,I.jsx)(`span`,{className:`c-prop-error-text`,children:a||u.error}),A&&(0,I.jsx)(__,{ctx:e,refusal:A,error:u.error??``,onError:o,onDone:()=>c(!0)},u.at??``)]}),ee&&f&&(u.state===`offered`||u.state===`refused`)&&(0,I.jsxs)(`div`,{role:`alertdialog`,"aria-label":`${z} ${p??``}?`,className:`c-prop-confirm`,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),te())},children:[(0,I.jsxs)(`span`,{children:[z,` `,p,`? `,f.help?`${f.help}.`:``,` It cannot be taken back from the chat.`]}),(0,I.jsxs)(`div`,{className:`c-acts`,children:[(0,I.jsxs)(`button`,{className:`btn-danger solid`,autoFocus:!0,onClick:()=>void N(!0),children:[`Yes, `,z]}),(0,I.jsx)(`button`,{className:`btn`,onClick:te,children:`Cancel`})]})]}),(u.state===`offered`||u.state===`refused`)&&f&&!ee&&(0,I.jsxs)(`div`,{className:`c-acts`,children:[(0,I.jsx)(`button`,{ref:M,className:f.danger?`btn-danger`:`btn-primary`,title:(f.danger?`Asks first. `:``)+`Runs the move as it is: every field above goes with it`,onClick:()=>void N(),children:u.state===`refused`?`Try again`:x?`Create`:f.label}),(0,I.jsx)(`button`,{className:`btn`,title:`Opens the move's form, filled in`,onClick:ne,children:`Edit…`})]}),u.state===`accepting`&&(0,I.jsxs)(`span`,{className:`c-creating`,children:[(0,I.jsx)(`span`,{className:`dot pulse`,"aria-hidden":`true`}),x?`creating ${u.item??String(t.fields.id??`the item`)}`:O,`: the framework commits it`]}),u.state===`accepted`&&(0,I.jsxs)(`span`,{className:`c-created`,children:[`✔ `,x?`created`:`made: ${z}`,u.item&&(x?`: `:` `),g?(0,I.jsx)(`span`,{children:y??u.item}):u.item&&e.board.items.some(e=>e.id===u.item)?(0,I.jsx)(`button`,{className:`link-btn mono`,onClick:()=>e.openItem(u.item??``),children:u.item}):(0,I.jsx)(`span`,{className:`mono`,children:u.item})]})]})}var Hv={verdict:`Verdict`,decide:`Decision`,block:`Block`,unblock:`Unblock`,drop:`Drop`,depends:`Dependencies`};function Uv(e,t){let[n,r]=e.split(`:`),i=Hv[n];return i?r?`${i} · ${t}`:i:t}function Wv({ctx:e,e:t}){let{domain:n}=e.board,r=Tr(n,n.sections.inbox?.add),i=Tr(n,n.sections.questions?.answer),a=(e.board.questions??[]).filter(e=>e.class===`D1`&&!e.answer),o=t.text.split(`
78
+ `)[0].slice(0,120);return(0,I.jsxs)(`div`,{className:`c-agent`,children:[(0,I.jsx)(`span`,{className:`sr`,children:`Agent:`}),(0,I.jsx)(`div`,{className:`c-bubble md`,children:(0,I.jsx)(Dv,{text:t.text})}),(0,I.jsxs)(`div`,{className:`c-agent-acts`,children:[n.new_item&&(0,I.jsx)(`button`,{onClick:()=>e.newItem({title:o,note:t.text}),children:`Create item from this`}),r&&(0,I.jsx)(`button`,{onClick:()=>e.openMove({title:`Add to the inbox`,move:r,values:{text:t.text,category:`idea`},body:`${r.help??``}. From the agent's message.`}),children:`Add to inbox`}),i&&a.length>0&&(0,I.jsx)(`button`,{onClick:()=>e.openMove({title:`Answer a decision with this`,move:{...i,fields:[{key:`id`,label:`Question`,kind:`choice`,required:!0,options:a.map(e=>({value:e.id,label:`${e.id} — ${(e.question??``).slice(0,70)}`}))},...i.fields]},values:{text:t.text},body:`The agent's message becomes your answer to an open decision. Edit it first if you like.`}),children:`Answer a decision`}),(0,I.jsx)(`span`,{className:`c-time`,children:Ov(t.at)})]})]})}function Gv({ctx:e,e:t,part:n}){let r=Tr(e.board.domain,`attach`);return(0,I.jsxs)(`div`,{className:`c-me`,children:[(0,I.jsx)(`span`,{className:`sr`,children:`You:`}),(0,I.jsxs)(`div`,{className:`c-bubble md`,children:[t.byTimeout&&(0,I.jsx)(`span`,{className:`c-default`,children:`default answer`}),t.text&&(0,I.jsx)(`div`,{className:`c-me-text`,children:(0,I.jsx)(Dv,{text:t.text})}),t.images.length>0&&(0,I.jsx)(`div`,{className:`c-imgs`,children:t.images.map(t=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`img`,{src:n.imageUrl(t),alt:t.split(`/`).pop()}),r&&(0,I.jsx)(`button`,{className:`c-attach`,title:`Commit this picture into an item's attachments (gcf item attach)`,onClick:()=>e.openMove({title:`Attach to an item`,move:{...r,fields:[{key:`id`,label:`Item id`,kind:`text`,required:!0},...r.fields]},values:{id:n.item??``,file:n.imagePath(t)}}),children:`attach to item…`})]},t))})]}),(0,I.jsxs)(`span`,{className:`c-me-status`,children:[Ov(t.at),` · `,t.status]})]})}function Kv({ctx:e,part:t}){let n=t.events.findLast(e=>e.type===`run_end`)?.at,r=t.talk!==null,i=Lv(e,r),a=V_(t.events),o=r&&!e.talks.find(e=>e.id===t.talk)?.live,s=Z_(t.events,{talk:r,answerMin:i}).map(e=>o&&(e.kind===`question`||e.kind===`approval`)&&e.state===`waiting`?{...e,state:`dropped`,dropWhy:`the agent ended without it`}:o&&e.kind===`task`&&e.state===`running`?{...e,state:`stopped`}:e),c=cv(),l=(r,o)=>{switch(r.kind){case`me`:return(0,I.jsx)(Gv,{ctx:e,e:r,part:t},o);case`agent`:return(0,I.jsx)(Wv,{ctx:e,e:r},o);case`claude`:return(0,I.jsxs)(`div`,{className:`c-claude`,title:`Claude's own limit message, as the agent's line`,children:[(0,I.jsxs)(`span`,{children:[`Claude: `,r.text]}),(0,I.jsx)(`span`,{className:`c-time`,children:Ov(r.at)})]},o);case`line`:return(0,I.jsxs)(`div`,{className:`c-line ${r.box?`box`:``} ${r.mono?`mono`:``} ${r.tone?`tone-${r.tone}`:``}`,title:r.tip,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:r.mark}),(0,I.jsx)(`span`,{children:r.text}),(0,I.jsx)(`span`,{className:`c-time`,children:Ov(r.at)})]},o);case`step`:return(0,I.jsxs)(`div`,{className:`c-step tone-${r.tone??`neutral`} ${r.unknown?`unknown`:``}`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:r.mark}),(0,I.jsx)(`span`,{children:r.text}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`c-time`,children:Ov(r.at)})]},o);case`question`:return(0,I.jsx)(Rv,{e:r,part:t,minutes:i,live:a},o);case`approval`:return(0,I.jsx)(zv,{e:r,part:t,minutes:i,live:a},o);case`proposal`:return(0,I.jsx)(Vv,{ctx:e,e:r,part:t},o);case`refused`:return(0,I.jsx)(Bv,{ctx:e,e:r},o);case`task`:return(0,I.jsx)(ey,{e:r},o);case`run_end`:return(0,I.jsx)(uy,{ctx:e,id:t.item??``,end:r.end,acts:r.at===n},o);case`divider`:return(0,I.jsxs)(`div`,{role:`separator`,"aria-label":`Talk handed to a fresh agent`,className:`c-div ${r.failed?`failed`:``}`,title:r.tip,children:[(0,I.jsxs)(`div`,{className:`c-div-head`,children:[r.failed?`✕ the summary failed · the same agent goes on`:`↻ talk handed to a fresh agent`,(0,I.jsxs)(`span`,{children:[`· `,r.by]}),(0,I.jsx)(`span`,{className:`c-time`,children:Ov(r.at)})]}),r.summary?(0,I.jsxs)(`div`,{className:`c-div-sum`,children:[(0,I.jsx)(`span`,{children:r.failed?`What the agent wrote before the summary failed (no fresh agent starts from it)`:`The summary the fresh agent starts from (read only: correct it with your next message)`}),(0,I.jsx)(`p`,{children:r.summary})]}):!r.failed&&(0,I.jsx)(`span`,{className:`dim small`,children:`the agent is writing the summary…`})]},o)}},u=new Map;return(0,I.jsx)(I.Fragment,{children:s.map(e=>{let n=`${e.kind}@${e.at}`,r=u.get(n)??0;u.set(n,r+1);let i=`${t.key}-${n}-${r}`;return!Y_(e)||c===`expanded`?l(e,i):c===`hidden`?null:(0,I.jsx)(Xv,{e,children:l(e)},i)})})}function qv({ctx:e}){return _v()?(0,I.jsx)(`button`,{className:`c-yolo`,title:`Calls run without a card. Deny rules and the main-run refusal still hold. Settings turns it off.`,onClick:()=>e.openSettings(),children:`YOLO`}):null}function Jv(e){return e.kind===`refused`?`refused by ${e.group?`deny group ${e.group}`:`a deny rule`}`:e.kind===`line`?e.tech?.out??``:e.kind===`approval`?e.state===`auto`?`ran without asking (YOLO)`:e.state===`once`?e.notSaved?`allowed once · the rule was not saved`:`allowed once by you`:e.state===`always`?`allowed always · rule saved`:e.state===`denied`?K_[e.deniedBy??``]??`denied`:`withdrawn: ${e.dropWhy??`the turn ended`}`:``}function Yv(e){return e.kind===`refused`?`warn`:e.kind===`line`?e.tech?.tone??``:e.kind===`approval`?e.state===`auto`?`warn`:e.state===`once`&&!e.notSaved||e.state===`always`?`ok`:``:``}function Xv({e,children:t}){let[n,r]=(0,v.useState)(!1),[i,a]=e.kind===`approval`?[e.what,e.title]:e.kind===`refused`?[e.what,e.title||e.reason]:e.kind===`line`?[e.tech?.tool??``,e.tech?.title??``]:[``,``],o=Yv(e);return(0,I.jsxs)(`div`,{className:`c-fold ${n?`open`:``}`,children:[(0,I.jsxs)(`button`,{className:`c-fold-head`,"aria-expanded":n,title:n?`Fold it into one line`:`Show the whole card`,onClick:()=>r(!n),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,I.jsx)(`span`,{className:`c-kind`,children:i}),(0,I.jsx)(`span`,{className:`c-fold-title`,children:a}),(0,I.jsxs)(`span`,{className:`c-fold-out ${o?`tone-${o}`:``}`,children:[`· `,Jv(e)]}),(0,I.jsx)(`span`,{className:`c-time`,children:Ov(e.at)})]}),n&&t]})}var Zv=e=>{let t=Math.max(0,Math.round(e/1e3));return t<60?`${t} s`:t<3600?`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`:`${Math.floor(t/3600)} h ${String(Math.floor(t/60)%60).padStart(2,`0`)} min`},Qv=(e,t)=>e===`agent`?`subagent${t?` ${t}`:``}`:e,$v={done:[`done`,`ok`],failed:[`failed`,`warn`],stopped:[`stopped`,``]};function ey({e}){let[t,n]=(0,v.useState)(!1),r=e.state===`running`,i=Fv(r),a=r?i-Date.parse(e.at):e.ms,[o,s]=r?[e.doing??`working…`,`running`]:$v[e.state]??[e.state,``],c=[e.state===`failed`&&e.status?e.status:``,e.calls===null?``:`${e.calls} call${e.calls===1?``:`s`}`,a!==null&&Number.isFinite(a)?Zv(a):``].filter(Boolean);return(0,I.jsxs)(`div`,{className:`c-fold c-task ${t?`open`:``}`,"data-task":e.id,"data-run":e.run,children:[(0,I.jsxs)(`button`,{className:`c-fold-head`,"aria-expanded":t,title:t?`Fold it into one line`:`What it was told and what it reported`,onClick:()=>n(!t),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:t?`▾`:`▸`}),(0,I.jsx)(`span`,{className:`c-kind`,children:Qv(e.what,e.agent)}),(0,I.jsx)(`span`,{className:`c-fold-title`,children:e.description||e.id}),(0,I.jsxs)(`span`,{className:`c-fold-out ${s?`tone-${s}`:``}`,children:[`· `,o,c.length>0&&` · ${c.join(` · `)}`]}),(0,I.jsx)(`span`,{className:`c-time`,children:Ov(e.at)})]}),t&&(0,I.jsxs)(`div`,{className:`c-task-body`,children:[e.prompt&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`c-task-label`,children:`Told`}),(0,I.jsx)(`p`,{children:e.prompt})]}),e.summary&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`c-task-label`,children:`Reported`}),(0,I.jsx)(`p`,{children:e.summary})]}),!e.prompt&&!e.summary&&(0,I.jsx)(`span`,{className:`dim small`,children:r?`its report comes when it ends`:`it left no report`})]})]})}function ty({tasks:e}){let t=Fv(e.length>0);if(!e.length)return null;let n=e=>{let t=document.querySelector(`.c-task[data-task="${CSS.escape(e.id)}"][data-run="${e.run}"]`);t?.scrollIntoView({block:`center`,behavior:`smooth`}),t?.querySelector(`.c-fold-head`)?.focus()};return(0,I.jsx)(`div`,{className:`c-tasks`,role:`list`,"aria-label":`Running beside the agent`,children:e.map(e=>(0,I.jsxs)(`button`,{role:`listitem`,className:`c-task-chip`,title:`${Qv(e.kind,e.agent)}: ${e.description}${e.doing?` · now: ${e.doing}`:``}${e.calls===null?``:` · ${e.calls} calls`} · its line in the chat`,onClick:()=>n(e),children:[(0,I.jsx)(`span`,{className:`dot pulse`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`c-task-what`,children:e.description||Qv(e.kind,e.agent)}),e.doing&&(0,I.jsx)(`span`,{className:`c-task-doing`,children:e.doing}),(0,I.jsx)(`span`,{className:`mono c-task-time`,children:Zv(t-Date.parse(e.at))})]},`${e.id}@${e.run}`))})}function ny({ctx:e,live:t}){let n=e.board.context?.handoff_pct??0,r=e.board.context?.compact_pct??0,i=typeof t.ctx==`number`?t.ctx:null,a=i!==null&&n>0&&i>=n-10,o=t.ctx===null?`How full the agent's context is: unknown, the model's window is not known`:`How full the agent's context is${n>0?` · at ${n}% a fresh agent takes over`:` · no handoff`}${r>0?` · at ${r}% the agent compacts`:``}`;return(0,I.jsxs)(`span`,{className:`c-ctx ${a?`near`:``}`,tabIndex:0,title:o,children:[t.ctx===null?`context ?`:i===null?`context —`:`context ${i}%`,(0,I.jsxs)(`span`,{className:`c-ctx-bar`,"aria-hidden":`true`,children:[i!==null&&(0,I.jsx)(`span`,{className:`fill`,style:{width:`${Math.min(100,i)}%`}}),t.ctx===null&&(0,I.jsx)(`span`,{className:`unknown`}),n>0&&(0,I.jsx)(`span`,{className:`mark`,style:{left:`${n}%`}}),r>0&&(0,I.jsx)(`span`,{className:`mark dim`,style:{left:`${r}%`}})]})]})}function ry({ctx:e,part:t,placeholder:n,route:r,canStop:i=!0,costLabel:a,onSend:o,extra:s,pulse:c,quote:l}){let[u,d]=(0,v.useState)(``),f=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(l)return l.current=e=>{d(t=>R_(t,e));let t=f.current;t?.focus(),requestAnimationFrame(()=>t?.setSelectionRange(t.value.length,t.value.length))},()=>{l.current=null}},[l]);let[p,m]=(0,v.useState)([]),h=(0,v.useRef)([]),g=e=>{h.current=e,m(e)},[_,y]=(0,v.useState)([]),b=(0,v.useRef)([]),x=e=>{b.current=e,y(e)},S=()=>h.current.reduce((e,t)=>e+t.size,0)+b.current.reduce((e,t)=>e+Math.floor((t.data??``).length*3/4),0),[C,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(``),[A,ee]=(0,v.useState)(``),[j,M]=(0,v.useState)(!1),[te,N]=(0,v.useState)(null),[ne,P]=(0,v.useState)(null),[F,re]=(0,v.useState)([]),L=t.talk!==null,R=V_(t.events),z=Lv(e,L),B=R.phase===`limit`,ae=t.events.filter(e=>e.type===`handoff`).length,oe=te!==null&&ae===te,se=!!(L&&e.talks.find(e=>e.id===t.talk)?.live),ce=L&&!se?null:U_(t.events),V=ne!==null&&se&&Date.now()-ne.t<Pv&&!t.events.slice(ne.n).some(e=>e.type===`closed`||e.type===`session`),H=!L&&R.phase===`waiting`&&R.waitKind===`text`&&R.waitAt,U=t.events.filter(e=>e.type===`say`&&e.by===`operator`&&!e.retry).length,le=$_(F.filter(e=>e.key===t.key),t.events,U);Fv(!!ce||!!H||V);let ue=async e=>{let t=await Promise.all([...e].map(async e=>yv.includes(e.type)&&e.size<=xv?{f:e,data:await Pr(e)}:{f:e,data:``})),n=[],r=[...h.current],i=S()-r.reduce((e,t)=>e+t.size,0);for(let{f:e,data:a}of t){let t=i+r.reduce((e,t)=>e+t.size,0);yv.includes(e.type)?r.length>=bv?n.push(`${e.name}: at most ${bv} pictures a message`):e.size>xv?n.push(`${e.name}: ${kv(e.size)}, at most 5 MB a picture`):t+e.size>Sv?n.push(`${e.name}: the pictures and files of one message come to about 7 MB at most (${kv(t+e.size)} with it)`):r.push({name:e.name,type:e.type,size:e.size,data:a}):n.push(`${e.name}: ${e.type||`this kind`} is not taken, only png, jpeg, gif and webp`)}g(r),ee(n.join(` · `))},de=async e=>{let t=await Promise.all([...e].map(async e=>({f:e,data:e.size<=xv?await Pr(e):``}))),n=[],r=[...b.current],i=S();for(let{f:e,data:a}of t)r.length>=10?n.push(`${e.name}: at most 10 attachments a message`):e.size>xv?n.push(`${e.name}: ${kv(e.size)}, at most 5 MB a file`):i+e.size>Sv?n.push(`${e.name}: the pictures and files of one message come to about 7 MB at most (${kv(i+e.size)} with it)`):(r.push({kind:`file`,ref:e.name,data:a}),i+=e.size);x(r),ee(n.join(` · `))},fe=async()=>{if(j||V||!u.trim()&&!p.length&&!_.length)return;M(!0),O(``);let e={text:u,pictures:p,attach:_},n={text:u.trim()||(p.length?`(pictures)`:`(attached)`),after:U+le.length,from:t.events.length,key:t.key,sending:!0};re(e=>[...e,n]),d(``),g([]),x([]),ee(``);try{let r=await o(e),i=r?.key??t.key;re(e=>i===t.key||!t.key?e.map(e=>e===n?{...n,key:i,sending:!1,...r?.id?{id:r.id}:{}}:e):e.filter(e=>e!==n))}catch(t){re(e=>e.filter(e=>e!==n)),d(t=>t?`${e.text}\n${t}`:e.text),g([...e.pictures,...h.current]),x([...e.attach,...b.current]),O(t.message)}M(!1)},pe=async e=>{try{await t.send(e)}catch(e){O(e.message)}},W=()=>{let e=[...t.events].reverse().find(e=>e.type===`say`&&e.by===`operator`),n=e?.type===`say`&&!t.events.some((n,r)=>n.type===`read`&&n.n===e.n&&r>t.events.indexOf(e));R.live&&W_(t.events)&&(R.phase===`working`||R.phase===`background`||R.phase===`waiting`&&R.waitKind===`card`||n)&&N(ae),t.send({type:`handoff`}).catch(e=>{N(null),O(e.message)})},me=async()=>{let n=R.bg.map(e=>e.description).join(`, `);if(!n||await ie(`Close the agent? Its background tasks stop with it: ${n}.`,`Close`,!0)){P({n:t.events.length,t:Date.now()}),N(null);try{await k.closeTalk(e.project.name,t.talk??``)}catch(t){P(null),e.notify(t.message,`error`)}}},he,ge=`neutral`,_e=null;V?(he=`closing the agent and all it started…`,ge=`running`):(j||le.length)&&!R.live&&!B&&L?(he=`starting the agent…`,ge=`running`):B?he=`limit: resumes ${X_(R.limitUntil)}${L?` · the agent closed; it starts again by itself · only messages until then`:` · waits for the reset by itself`}`:R.freshQueued?(he=`fresh agent queued · it takes over by itself when the background tasks end`,ge=`running`):R.phase===`waiting`&&R.waitKind===`card`&&ce?(he=`waiting for your answer on the card · the default goes in`,ge=`needs`,_e=(0,I.jsx)(Iv,{from:R.waitAt??ce.at,minutes:z})):R.phase===`waiting`&&R.waitKind===`stop`?he=`stopped · waits for your message`:R.phase===`waiting`&&R.waitKind===`text`?L?he=`your turn · the agent closes after ${z} min idle`:(he=`waiting for your reply · the default answer goes in`,ge=`needs`,R.waitAt&&(_e=(0,I.jsx)(Iv,{from:R.waitAt,minutes:z}))):R.phase===`background`?(he=`working in the background: ${R.bg.map(e=>e.description).join(`, `)} · no timer runs`,ge=`running`):R.phase===`ready`&&R.live?(he=`agent ready · waits for your message`,ge=`running`):R.phase===`working`&&R.live?(he=`working…`,ge=`running`):he=R.endedIdle?`agent closed · your next message starts it again`:R.everStarted?L?`agent closed · your next message starts it again`:`session ended`:L?`no agent yet · your first message starts one`:`no session`,oe&&!R.freshQueued&&(he+=` · fresh agent asked for: it takes over when this turn ends`);let ve=i&&R.live&&!B&&R.phase===`working`,ye=L&&!B&&!R.freshQueued&&!oe&&R.everStarted,be=se&&(R.live||B)&&!V,xe=he.split(` · `)[0].replace(/^(working in the background):.*/,`$1`)+(oe&&!R.freshQueued?` · fresh agent asked`:``);return(0,I.jsxs)(`div`,{className:`c-composer`,children:[(0,I.jsxs)(`div`,{className:`c-status`,children:[(0,I.jsxs)(`span`,{className:`c-status-label tone-${ge}`,children:[(0,I.jsx)(`span`,{className:`dot ${ge===`running`?`pulse`:``}`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{role:`status`,title:he,children:xe===`no agent yet`?`no agent`:xe}),_e]}),(0,I.jsxs)(`span`,{className:`c-status-right`,children:[(0,I.jsx)(`span`,{className:`mono dim small c-cost`,tabIndex:0,title:a===`this run`?`What this run cost so far`:`What this thread cost so far: every agent session in it`,children:Av(R.cost)}),(0,I.jsx)(ny,{ctx:e,live:R})]})]}),c,(0,I.jsx)(ty,{tasks:R.live&&(!L||se)?R.tasks:[]}),le.map((e,t)=>(0,I.jsxs)(`span`,{className:`c-out`,role:`status`,children:[`▸ `,e.text.split(`
79
+ `)[0].slice(0,80),` ·`,` `,e.sending?`sending…`:B?`accepted · it reaches the agent after the reset`:R.live?`sent · the agent takes it in next`:`starting the agent…`]},t)),r&&(0,I.jsxs)(`span`,{className:`c-route`,children:[`→ `,r]}),(0,I.jsxs)(`div`,{className:`c-input`,onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),ue(e.dataTransfer.files)},children:[_.length>0&&(0,I.jsx)(`div`,{className:`c-pics`,children:_.map((e,t)=>(0,I.jsxs)(`span`,{title:e.kind===`unit`?`Design unit: the agent gets unit ${e.ref} and its file`:e.data===void 0?`Goes with the message as context`:`A file of your machine: the agent reads its copy beside the chat`,children:[e.kind===`item`?`▸`:e.kind===`unit`?`◇`:`▤`,` `,e.ref,(0,I.jsx)(`button`,{"aria-label":`Remove ${e.ref}`,onClick:()=>x(_.filter((e,n)=>n!==t)),children:`×`})]},`${e.kind}:${e.ref}:${t}`))}),p.length>0&&(0,I.jsx)(`div`,{className:`c-pics`,children:p.map((e,t)=>(0,I.jsxs)(`span`,{title:kv(e.size),children:[`▣ `,e.name,(0,I.jsx)(`button`,{"aria-label":`Remove ${e.name}`,title:`Remove this picture`,onClick:()=>g(p.filter((e,n)=>n!==t)),children:`×`})]},t))}),(0,I.jsx)(`textarea`,{ref:f,"aria-label":`Message to the agent`,rows:4,value:u,onChange:e=>{d(e.target.value),O(``)},onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),fe())},onPaste:e=>{let t=[...e.clipboardData.files].filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),ue(t))},placeholder:n??(B?L?`Write now: the agent takes it in after the reset`:`Write now: it reaches the agent after the reset`:`Message the agent…`)}),(0,I.jsxs)(`div`,{className:`c-tools`,role:`toolbar`,"aria-label":`Message tools`,children:[(e.board.domain.sections.units?[`item`,`unit`]:[`item`]).map(e=>(0,I.jsx)(`button`,{className:`c-chip ${C===e?`on`:``}`,"aria-expanded":e===`unit`?C===e:void 0,title:e===`item`?`Attach an item to the message as context`:`Attach a design unit: pick it from the live units by id and title; the agent gets unit <id> (<file>)`,onClick:()=>{w(C===e?null:e),E(``)},children:`${e===`unit`&&C===e?`▾`:`+`} ${e}`},e)),(0,I.jsxs)(`label`,{className:`c-ico c-pick`,"aria-label":`Attach a file`,title:`Attach a file of your machine as context: the agent reads its copy beside the chat · up to 10 a message, 5 MB each, about 7 MB in all with the pictures`,children:[Mv.file,(0,I.jsx)(`input`,{"aria-label":`Attach a file`,type:`file`,multiple:!0,onChange:e=>{e.target.files&&de(e.target.files),e.target.value=``}})]}),(0,I.jsxs)(`label`,{className:`c-ico c-pick`,"aria-label":`Add a picture`,title:`Add a picture · paste or drop it too · ${Cv}`,children:[Mv.picture,(0,I.jsx)(`input`,{"aria-label":`Add a picture`,type:`file`,multiple:!0,accept:yv.join(`,`),onChange:e=>{e.target.files&&ue(e.target.files),e.target.value=``}})]}),C===`item`&&(0,I.jsxs)(`select`,{className:`input c-attach-pick`,"aria-label":`The item to attach`,value:``,onChange:e=>{let t=e.target.value;t&&_.length<10&&!_.some(e=>e.kind===`item`&&e.ref===t)&&x([..._,{kind:`item`,ref:t}]),w(null)},children:[(0,I.jsx)(`option`,{value:``,children:`pick an item…`}),e.board.items.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.id},e.id))]}),C===`unit`&&(0,I.jsx)(iy,{ctx:e,q:T,setQ:E,picked:_.filter(e=>e.kind===`unit`).map(e=>e.ref),onPick:e=>x(_.some(t=>t.kind===`unit`&&t.ref===e)?_.filter(t=>t.kind!==`unit`||t.ref!==e):_.length<10?[..._,{kind:`unit`,ref:e}]:_),onClose:()=>w(null)}),(t.talk!==null||s)&&(0,I.jsx)(`span`,{className:`c-sep`,"aria-hidden":`true`}),t.talk!==null&&(0,I.jsx)(Di,{ctx:e,talk:t.talk}),s,(0,I.jsx)(`span`,{className:`grow`}),L&&(0,I.jsx)(`button`,{className:`c-ico c-fresh ${oe||R.freshQueued?`on`:``}`,"aria-label":`Fresh agent`,disabled:!ye,title:B?`Off while the thread waits for the limit's reset`:R.freshQueued?`Queued already: it takes over when the background tasks end`:oe?`Asked for: the handoff comes when this turn ends`:`A fresh agent goes on from a summary of this talk; the summary cannot be edited first`,onClick:W,children:Mv.fresh}),(0,I.jsx)(`button`,{className:`c-ico c-stop`,"aria-label":`Stop`,disabled:!ve,title:B?`Off while it waits for the limit's reset: nothing runs to interrupt`:R.phase===`background`&&R.live?`Off: the agent's turn is over, only its background tasks run; ${L?`Close the agent stops them`:`the item's Stop ends the run with them`}`:ve?`Stop: interrupts the agent's step; the session stays open`:`Stop: works while the agent thinks or answers`,onClick:()=>void pe({type:`interrupt`}),children:Mv.stop}),L&&(0,I.jsx)(`button`,{className:`c-ico c-close`,"aria-label":`Close the agent`,disabled:!be,title:V?`Closing: the agent ends within seconds`:`Closes the agent and all it started (dev servers, watchers); your next message resumes the talk`,onClick:()=>void me(),children:Mv.close}),(0,I.jsx)(`button`,{className:`c-send`,"aria-label":`Send`,disabled:j||V||!u.trim()&&!p.length&&!_.length,title:`Send · Ctrl+Enter`,onClick:()=>void fe(),children:Mv.send})]})]}),A&&(0,I.jsxs)(`span`,{role:`alert`,className:`c-err`,children:[`not added: `,A]}),D&&(0,I.jsxs)(`span`,{role:`alert`,className:`c-err mono`,children:[`not sent: `,D]})]})}function iy({ctx:e,q:t,setQ:n,picked:r,onPick:i,onClose:a}){let o=t.trim().toLowerCase(),s=(e.board.units??[]).filter(e=>!o||e.id.includes(o)||(e.title??``).toLowerCase().includes(o));return(0,I.jsxs)(`div`,{className:`c-units`,role:`dialog`,"aria-label":`Attach a design unit`,children:[(0,I.jsxs)(`div`,{className:`c-units-head`,children:[(0,I.jsx)(`input`,{className:`input`,type:`search`,"aria-label":`Search design units`,placeholder:`design units: search id or title`,value:t,autoFocus:!0,onChange:e=>n(e.target.value)}),(0,I.jsx)(`button`,{className:`icon-btn`,"aria-label":`Close the unit picker`,onClick:a,children:`×`})]}),(0,I.jsxs)(`div`,{role:`listbox`,"aria-multiselectable":`true`,className:`c-units-list`,children:[s.map(e=>{let t=r.includes(e.id);return(0,I.jsxs)(`button`,{role:`option`,"aria-selected":t,className:`picker-row`,title:e.title??e.id,onClick:()=>i(e.id),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:t?`☑`:`☐`}),(0,I.jsxs)(`span`,{className:`picker-name`,children:[(0,I.jsx)(`span`,{className:`mono`,children:e.id}),e.title&&(0,I.jsx)(`span`,{className:`dim`,children:e.title})]}),(0,I.jsx)(`span`,{className:`picker-state tone-${e.ready?`ok`:`warn`}`,children:ta(e)})]},e.id)}),!s.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`no design unit matches`})]})]})}var ay=({text:e,pictures:t,attach:n})=>({type:`say`,text:e.trim()||(t.length?`(pictures)`:``),...t.length?{images:t.map(e=>({media_type:e.type,data:e.data}))}:{},...n.length?{attach:n}:{}});function oy(e){let t=(0,v.useRef)(null),n=(0,v.useRef)(!0),r=(0,v.useRef)(0),[i,a]=(0,v.useState)(!1),o=e=>{e.style.overflowAnchor=n.current?`none`:``};return(0,v.useEffect)(()=>{let e=t.current;e&&n.current&&(e.scrollTop=e.scrollHeight)},[e]),(0,v.useEffect)(()=>{let e=t.current;if(!e)return;o(e);let r=new ResizeObserver(()=>{n.current&&(e.scrollTop=e.scrollHeight)}),i=()=>{r.disconnect(),r.observe(e);for(let t of e.children)r.observe(t,{box:`border-box`})},a=new MutationObserver(i);return i(),a.observe(e,{childList:!0}),()=>{r.disconnect(),a.disconnect()}},[]),{ref:t,onScroll:()=>{let e=t.current;if(!e)return;let i=e.scrollHeight-e.scrollTop-e.clientHeight<40;(i||e.scrollTop<r.current)&&(n.current=i),r.current=e.scrollTop,o(e),a(!n.current)},away:i,toEnd:()=>{let e=t.current;n.current=!0,a(!1),e&&(o(e),e.scrollTo({top:e.scrollHeight,behavior:`smooth`}))}}}function sy({follow:e}){return e.away?(0,I.jsx)(`div`,{className:`c-to-end`,children:(0,I.jsx)(`button`,{className:`btn`,onClick:e.toEnd,title:`Scroll to the last message`,children:`↓ Latest`})}):null}var cy={submitted:[`submitted`,`ok`,`✔`],blocked:[`blocked`,`blocked`,`!`],failed:[`failed`,`error`,`✘`],paused:[`paused`,`neutral`,`‖`],stopped:[`stopped`,`neutral`,`■`],"no-result":[`no result`,`warn`,`?`],skipped:[`skipped`,`neutral`,`↷`]},ly={blocked:`its question`,failed:`the error`,"no-result":`why no result`,skipped:`why it was skipped`,paused:`why it paused`,stopped:`why it stopped`};function uy({ctx:e,id:t,end:n,acts:r=!0}){let i=typeof n.duration_ms==`number`?Math.round(n.duration_ms/6e4):null,a=[typeof n.cost_usd==`number`?`$${n.cost_usd.toFixed(2)}`:``,i===null?``:i<60?`${i} min`:`${Math.floor(i/60)} h ${String(i%60).padStart(2,`0`)} min`,n.dod?`DoD ${n.dod}`:``,n.review?`review ${n.review}`:``,n.commit?`main ${n.commit}`:``,n.unticked?`${n.unticked} plan task${n.unticked>1?`s`:``} unticked`:``,n.lessons?`${n.lessons} lesson${n.lessons>1?`s`:``} to the Inbox`:``].filter(Boolean),[o,s,c]=cy[n.outcome]??[n.outcome,`neutral`,`·`],l=dy(e,t,n);return(0,I.jsxs)(`div`,{className:`c-card c-end tone-${s}`,role:`note`,"aria-label":`The run of ${t} ended`,children:[(0,I.jsxs)(`div`,{className:`c-end-head`,children:[(0,I.jsx)(`span`,{className:`c-end-mark`,"aria-hidden":`true`,children:c}),(0,I.jsxs)(`strong`,{className:`c-end-title`,children:[`Run ended: `,o]}),n.move&&(0,I.jsxs)(`span`,{className:`c-end-move`,title:`The run's result word`,children:[`move `,n.move]}),n.at&&(0,I.jsx)(`span`,{className:`c-end-time`,children:oi(n.at)})]}),n.reason&&(0,I.jsxs)(`div`,{className:`c-end-reason`,children:[(0,I.jsx)(`span`,{className:`c-end-label`,children:ly[n.outcome]??`reason`}),(0,I.jsx)(`span`,{className:`c-end-why`,children:n.reason})]}),a.length>0&&(0,I.jsx)(`div`,{className:`c-end-facts`,children:a.map((e,t)=>(0,I.jsxs)(`span`,{children:[t>0&&(0,I.jsx)(`span`,{className:`c-end-sep`,"aria-hidden":`true`,children:`·`}),e]},e))}),n.process&&(0,I.jsxs)(`span`,{className:`c-end-process`,children:[`▲ a broken step: `,n.process]}),n.left&&(0,I.jsxs)(`span`,{className:`c-end-process`,title:`A rerun goes on in that worktree, with these files`,children:[n.left.files,` file`,n.left.files>1?`s`:``,` left uncommitted in`,` `,(0,I.jsx)(`span`,{className:`mono`,children:n.left.worktree})]}),r&&l&&(0,I.jsx)(`div`,{className:`c-end-acts`,children:(0,I.jsx)(`button`,{className:`btn-primary`,title:l.tip,onClick:l.on,children:l.label})})]})}function dy(e,t,n){let r=e.board.items.find(e=>e.id===t),i=r?Er(r,e.board.domain).find(e=>e.cmd===`unblock`):void 0;return r?.status===`blocked`&&i?{label:`Unblock`,tip:`Its Unblock: your answer goes to its next run`,on:()=>e.openMove({title:`${i.label} ${t}`,id:t,move:i})}:r&&[`awaiting-verdict`,`unplayed`].includes(r.status)?{label:`Verdict`,tip:`Opens Playtest with ${t} open and marked: the build, the platforms, and its verdict`,on:()=>e.go(`playtest`)}:r?.status===`ready`&&!r.running&&n.outcome!==`submitted`?{label:`Run again`,tip:`Starts it again; the run gate may still refuse`,on:()=>void e.run([t])}:null}function fy({ctx:e,id:t,end:n,onShow:r}){let[i,a,o]=cy[n.outcome]??[n.outcome,`neutral`,`·`],s=dy(e,t,n);return(0,I.jsxs)(`div`,{className:`c-end-bar tone-${a}`,role:`status`,"aria-label":`The last run of ${t}`,children:[(0,I.jsx)(`span`,{className:`c-end-mark`,"aria-hidden":`true`,children:o}),(0,I.jsxs)(`span`,{className:`c-end-bar-text`,children:[`Run ended: `,i,n.at&&(0,I.jsxs)(`span`,{className:`c-end-time`,children:[` · `,oi(n.at)]})]}),(0,I.jsx)(`button`,{className:`btn-line`,title:`Scrolls the chat to the run's end card`,onClick:r,children:`Show`}),s&&(0,I.jsx)(`button`,{className:`btn-primary`,title:s.tip,onClick:s.on,children:s.label})]})}var py=200,my=8;function hy(e,t,n,r,i){let a=Math.min(600,e-32),o=r??{x:e-a-12,y:n},s=Math.max(0,Math.min(o.x,e-120)),c=Math.max(0,Math.min(o.y,t-py-my-i));return{x:s,y:c,width:a,height:Math.max(py,t-c-my-i)}}function gy(e,t){return async(...n)=>{if(!e.current){e.current=!0;try{await t(...n)}finally{e.current=!1}}}}var _y=48;function vy(e){let t=e.split(/\r?\n/).filter(e=>e.trim()),n=/^([a-z_]+):(?:\s+(.*))?$/;if(!t.length||!n.test(t[0]))return null;let r=[],i=r[0],a=null,o=null;for(let e of t){let t;if(t=e.match(n))i={key:t[1],rest:t[2]??``,items:[]},r.push(i),a=o=null;else if(t=e.match(/^- (.*)$/)){let e=t[1].match(n);o=e?[e[1],e[2]??``]:null,a=o?{fields:[o]}:{text:t[1]},i.items.push(a)}else(t=e.match(/^\s+([a-z_]+):(?:\s+(.*))?$/))&&a&&`fields`in a?(o=[t[1],t[2]??``],a.fields.push(o)):o?o[1]+=` ${e.trim()}`:a&&`text`in a?a.text+=` ${e.trim()}`:i.rest+=(i.rest?` `:``)+e.trim()}return r.map(e=>{e.items=e.items.map(e=>`fields`in e&&e.fields.length===1?{text:`${e.fields[0][0]}: ${e.fields[0][1]}`}:e);let t=e.items.filter(e=>`fields`in e).map(e=>e.fields),n=t[0]?.map(([e])=>e)??[],r=t.length>1&&t.every(e=>e.length===n.length&&e.every(([e,t],r)=>e===n[r]&&t.length<=_y));return{key:e.key,rest:e.rest,bullets:e.items.filter(e=>`text`in e).map(({text:e})=>{let t=e.match(/^([a-z0-9-]+): (.*)$/);return t?{lead:t[1],text:t[2]}:{lead:null,text:e}}),table:r?{cols:n,rows:t.map(e=>e.map(([,e])=>e))}:null,cards:r?[]:t}})}var yy=e=>e.replace(/^(\s*)(?:([#>*+-])|(\d+)([.)]))(?=\s|$)/,(e,t,n,r,i)=>n?`${t}\\${n}`:`${t}${r}\\${i}`),by=e=>e.replace(/_/g,` `),xy=/^\s*(```|~~~)/,Sy=/^## +(.+?)\s*$/,Cy=/^(context|decisions|tasks|pillar_check|verification):\s*$/,wy=/^(tasks|handoff|outcome)\b/i,Ty=/^tasks\b/i;function Ey(e){let t=null,n=[],r=[],i=!1;for(let a of e.replace(/\r\n/g,`
80
+ `).split(`
81
+ `)){xy.test(a)&&(i=!i);let e=i?null:Sy.exec(a),o=i?null:Cy.exec(a),s=i||r.length||t!==null?null:/^# +(.+?)\s*$/.exec(a);if(s)t=s[1];else if(e||o){let t=(e??o)[1];r.push({key:t,kind:e?`md`:`block`,body:``,open:wy.test(t),lines:[]})}else r.length?r.at(-1).lines.push(a):n.push(a)}return{title:t,lead:n.join(`
82
+ `).trim(),folds:r.map(({lines:e,...t})=>({...t,body:e.join(`
83
+ `).trim()}))}}function Dy(e){if(!Ty.test(e.key))return null;let t=[{name:null,tasks:[]}],n=null;for(let r of e.body.split(`
84
+ `)){let e=/^### +(.+?)\s*$/.exec(r),i=/^\s*- \[([ xX])\] +(.*)$/.exec(r);if(e)t.push({name:e[1],tasks:[]}),n=null;else if(i)n={done:i[1]!==` `,text:i[2]},t.at(-1).tasks.push(n);else if(n&&/^\s+\S/.test(r))n.text+=` ${r.trim()}`;else if(!r.trim())n=null;else return null}let r=t.filter(e=>e.tasks.length);return r.length?r:null}function Oy(e){if(Ty.test(e.key)){let t=e.body.match(/^\s*- \[[ xX]\] /gm)??[],n=e.body.match(/^\s*- \[[xX]\] /gm)??[];return t.length?`${n.length} / ${t.length}`:``}if(e.kind!==`block`)return``;let t=e.body.split(`
85
+ `).filter(e=>/^- /.test(e)).length;return e.key===`decisions`?`${t} decision${t===1?``:`s`}`:t?`${t} line${t===1?``:`s`}`:``}function ky(e,t){let n=e=>e.replaceAll(`\\`,`/`),r=n(t);if(!/^([a-z]:)?\//i.test(r))return r;let i=n(e).replace(/\/+$/,``);return r.toLowerCase().startsWith(`${i.toLowerCase()}/`)?r.slice(i.length+1):null}function Ay(e,t){if(/^([a-z][a-z0-9+.-]*:|[/\\#?])/i.test(t))return null;let n=e.split(`/`).slice(0,-1).map(encodeURIComponent).join(`/`),r=n?`http://p/${n}/`:`http://p/`;try{let{pathname:e}=new URL(t,r);return decodeURIComponent(e.slice(1))}catch{return null}}var jy=(e,t)=>{let n=ky(e.path,t);return t=>{let r=n===null?null:Ay(n,t);return r&&pi(r)?ee(e.name,r):Qp(t)}},My=[[/^start: /,`start`],[/^agent: /,`agent`],[/^tool error: /,`toolerr`],[/^denied: /,`denied`],[/^tool: /,`tool`]];function Ny(e){let t=[],n=!1;for(let r of e.split(/\r?\n/)){if(!r.trim())continue;let e=r.match(/^\[(\d\d:\d\d:\d\d)\] (.*)$/),i=e?e[1]:``,a=e?e[2]:r,o=n&&!e?`result`:`other`,s=My.find(([e])=>e.test(a));if(s)o=s[1],a=a.replace(s[0],``),n=!1;else if(/^result:/.test(a)){if(n=!0,a=a.slice(7).trim(),!a)continue;o=`result`}else e&&/^(done|ended) /.test(a)?(o=`summary`,n=!1):e&&(n=!1);t.push({time:i,kind:o,text:a})}return t}var Py=e=>/--resume/.test(e)?`session resumed`:/--handoff/.test(e)?`fresh session after handoff`:`run start`;function Fy(e){let t={text:``,rect:null,rects:[]},n=window.getSelection();if(!e||!n||n.isCollapsed||!n.rangeCount)return t;let r=n.getRangeAt(0);if(!e.contains(r.commonAncestorContainer))return t;let i=n.toString();return i.trim()?{text:i,rect:r.getBoundingClientRect(),rects:[...r.getClientRects()]}:t}var Iy=(e,t,n)=>e.some(e=>t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom),Ly=200,Ry=76,zy=(0,I.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,I.jsx)(`rect`,{x:`8`,y:`8`,width:`12`,height:`12`,rx:`2`}),(0,I.jsx)(`path`,{d:`M16 8V5a1 1 0 0 0-1-1H5a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h3`})]}),By=(0,I.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M9 14L4 9l5-5`}),(0,I.jsx)(`path`,{d:`M4 9h10a6 6 0 0 1 6 6v4`})]}),Vy=(e,t)=>({x:Math.max(4,Math.min(e,window.innerWidth-Ly-4)),y:Math.max(4,Math.min(t,window.innerHeight-Ry-4))});function Hy({stream:e,onReply:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),o=(0,v.useRef)(null),s=(0,v.useRef)(null),c=(0,v.useRef)(t);c.current=t;let l=!!t;(0,v.useEffect)(()=>{let t=e.current;if(!t)return;let n=e=>{let{text:n,rect:i,rects:a}=Fy(t);if(!n||!i)return;let o=!!(e.clientX||e.clientY);if(o&&!Iy(a,e.clientX,e.clientY))return;e.preventDefault(),s.current=document.activeElement;let c=o?Vy(e.clientX,e.clientY):Vy(i.left,i.bottom+4);r({...c,text:n})};return t.addEventListener(`contextmenu`,n),()=>t.removeEventListener(`contextmenu`,n)},[e]),(0,v.useEffect)(()=>{if(!n)return;o.current?.querySelector(`[role="menuitem"]`)?.focus();let e=e=>{o.current?.contains(e.target)||r(null)},t=()=>r(null);return document.addEventListener(`pointerdown`,e,!0),window.addEventListener(`wheel`,t,!0),window.addEventListener(`touchmove`,t,!0),window.addEventListener(`resize`,t),()=>{document.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`wheel`,t,!0),window.removeEventListener(`touchmove`,t,!0),window.removeEventListener(`resize`,t)}},[n]),(0,v.useEffect)(()=>{if(!l||!window.matchMedia(`(pointer: coarse)`).matches)return;let t=()=>{let{text:t,rect:n}=Fy(e.current);a(t&&n?{...Vy(n.left,n.bottom+8),text:t}:null)};return document.addEventListener(`selectionchange`,t),window.addEventListener(`scroll`,t,!0),()=>{document.removeEventListener(`selectionchange`,t),window.removeEventListener(`scroll`,t,!0)}},[e,l]);let u=e=>{r(null),e&&s.current?.focus()},d=e=>{r(null),a(null),c.current?.(L_(e))};return(0,I.jsxs)(I.Fragment,{children:[n&&(0,I.jsxs)(`div`,{ref:o,className:`c-sel-menu`,role:`menu`,"aria-label":`Selection`,style:{left:n.x,top:n.y},onKeyDown:e=>{let t=[...o.current?.querySelectorAll(`[role="menuitem"]`)??[]],n=t.indexOf(document.activeElement),r=n=>{e.preventDefault(),t[(n+t.length)%t.length]?.focus()};e.key===`Escape`?(e.preventDefault(),u(!0)):e.key===`ArrowDown`?r(n+1):e.key===`ArrowUp`?r(n-1):e.key===`Home`?r(0):e.key===`End`?r(t.length-1):e.key===`Tab`&&u(!1)},children:[(0,I.jsxs)(`button`,{role:`menuitem`,"aria-label":`Copy`,"aria-keyshortcuts":`Control+C`,tabIndex:-1,onClick:()=>{O_(n.text),u(!0)},children:[zy,(0,I.jsx)(`span`,{children:`Copy`}),(0,I.jsx)(`kbd`,{children:`Ctrl+C`})]}),l&&(0,I.jsxs)(`button`,{role:`menuitem`,"aria-label":`Reply`,title:`Quotes it into your message`,tabIndex:-1,onClick:()=>d(n.text),children:[By,(0,I.jsx)(`span`,{children:`Reply`}),(0,I.jsx)(`span`,{className:`dim`,children:`quotes it`})]})]}),i&&!n&&(0,I.jsxs)(`button`,{className:`c-sel-reply`,style:{left:i.x,top:i.y},onPointerDown:e=>e.preventDefault(),onClick:()=>d(i.text),children:[By,`Reply`]})]})}var Uy=e=>{if(!e)return``;let t=new Date(e);return`${String(t.getMonth()+1).padStart(2,`0`)}.${String(t.getDate()).padStart(2,`0`)} ${t.toTimeString().slice(0,5)}`};function Wy(e,t,n){let r=e.project.name,i=`proposals`in t?t.proposals:[];return{key:t.id,events:n,talk:t.id,item:t.item,proposals:i,send:n=>k.sendTalk(r,t.id,n).catch(t=>{throw e.notify(t.message,`error`),t}),imageUrl:e=>`/api/p/${encodeURIComponent(r)}/talk/${t.id}/att/${e.split(`/`).pop()}`,imagePath:e=>`.gcf-session/chats/${t.id}/${e}`}}function Gy({ctx:e,talk:t}){let n=Nv(j(e.project.name,{talk:t.id})),r=oy(n.length),i=Wy(e,t,n),a=V_(n),o=(0,v.useRef)(null);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`c-stream`,ref:r.ref,onScroll:r.onScroll,role:`log`,"aria-live":`polite`,"aria-relevant":`additions`,children:[!n.length&&(0,I.jsx)(`div`,{className:`tab-empty`,children:t.title?`Your message is sent: the agent starts and takes it in.`:`Write the first message: it starts an agent.`}),(0,I.jsx)(Kv,{ctx:e,part:i})]}),(0,I.jsx)(sy,{follow:r}),(0,I.jsx)(Hy,{stream:r.ref,onReply:e=>o.current?.(e)}),(0,I.jsx)(ry,{ctx:e,part:i,quote:o,costLabel:`this thread`,placeholder:a.phase===`limit`?`Write now: the agent takes it in after the reset`:a.live?`Message the agent…`:`Message: it starts the agent, who remembers this thread`,onSend:async n=>({id:(await k.sendTalk(e.project.name,t.id,ay(n))).id})})]})}function Ky({ctx:e,onMade:t}){let n=(0,v.useRef)(null);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`c-stream`,children:(0,I.jsx)(`div`,{className:`tab-empty`,children:`Write the first message: it starts an agent, and its first line becomes the thread's title.`})}),(0,I.jsx)(ry,{ctx:e,part:{key:`new`,events:[],talk:``,send:async()=>{},imageUrl:()=>``,imagePath:()=>``},costLabel:`this thread`,placeholder:`First message: it makes the thread, and its first line becomes the title`,onSend:async r=>{n.current??=(await k.newTalk(e.project.name)).id;let i=n.current,a=await k.sendTalk(e.project.name,i,ay(r));return e.reloadTalks(),t(i),{id:a.id}}})]})}function qy({ctx:e,thread:t}){let[n,r]=(0,v.useState)(`all`),{board:i,talks:a}=e;if(!i.domain.chat)return(0,I.jsx)(`div`,{className:`page`,children:(0,I.jsxs)(`div`,{role:`note`,className:`empty-box chat-old`,children:[(0,I.jsx)(`b`,{children:`No project chat in this project`}),(0,I.jsx)(`span`,{children:`Its core is older than 0.12. Runs and their chats still work.`}),(0,I.jsx)(`code`,{children:`update gcf-aif-ext to 0.12`})]})});let o=[...new Set(a.flatMap(e=>e.item?[e.item]:[]))],s=i.items.map(e=>e.id).filter(e=>!o.includes(e)),c=a.filter(e=>n===`all`||e.item===n),l=t===`new`?null:a.find(e=>e.id===t)??(t?null:c[0]),u=t===`new`||!l&&!a.length,d=t=>e.go(`chat`,t),f=new Set((i.inbox??[]).map(e=>e.id));return(0,I.jsxs)(`div`,{className:`chat-screen ${t?`has-thread`:``}`,children:[(0,I.jsxs)(`aside`,{className:`threads`,"aria-label":`Threads of the project chat`,children:[(0,I.jsxs)(`div`,{className:`threads-head`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{children:`Project chat`}),(0,I.jsx)(`button`,{className:`btn`,title:`Start a thread: its title is the first line of your first message`,onClick:()=>d(`new`),children:`+ New thread`})]}),(0,I.jsxs)(`select`,{className:`input`,"aria-label":`Filter threads by item`,value:n,onChange:e=>r(e.target.value),children:[(0,I.jsx)(`option`,{value:`all`,children:`all threads`}),o.map(e=>(0,I.jsxs)(`option`,{value:e,children:[`item: `,e]},e)),s.map(e=>(0,I.jsxs)(`option`,{value:e,children:[`item: `,e,` · no thread yet`]},e))]})]}),(0,I.jsxs)(`div`,{className:`threads-list`,children:[n!==`all`&&!c.length&&(0,I.jsxs)(`div`,{className:`threads-none`,children:[(0,I.jsxs)(`p`,{children:[`No thread for `,n,` yet.`]}),(0,I.jsx)(jo,{label:`Ask about this item`,tip:`Opens the Chat tab of ${n}: your first question makes its bound thread`,glyph:`chat`,onClick:()=>e.openItem(n,`chat`)})]}),c.map(t=>{let n=t.proposals.map(e=>`${e.move??`item-new`} ${e.state}${e.item?` → ${e.item}`:``}`).join(` · `);return(0,I.jsxs)(`button`,{className:`thread-row`,"aria-current":l?.id===t.id?`true`:void 0,onClick:()=>d(t.id),children:[(0,I.jsxs)(`span`,{className:`thread-title`,children:[t.waiting&&(0,I.jsx)(`span`,{className:`needs-dot`,"aria-label":`waiting for you`,title:`A permission or question card waits for you: it is in "waiting for me"`,children:`●`}),(0,I.jsx)(`span`,{className:t.title===null?`dim`:``,children:t.title??`untitled · no message yet`})]}),(0,I.jsxs)(`span`,{className:`thread-meta`,children:[t.item&&(0,I.jsxs)(`span`,{title:`The thread is bound to this item`,children:[`▸ `,t.item]}),t.start&&(0,I.jsxs)(`span`,{title:`Opened from the Design screen: it follows its own skill`,children:[`✎ `,e.board.domain.starts?.[t.start]?.label??t.start]}),t.entry&&(0,I.jsxs)(`span`,{title:`Drafts an item from this inbox entry`,children:[`◇ `,t.entry,f.has(t.entry)?``:` · erased`]}),(0,I.jsx)(`span`,{title:`Last activity`,children:Uy(t.last_at??t.created_at)}),(0,I.jsxs)(`span`,{title:`What its agents cost`,children:[`$`,t.cost_usd.toFixed(2)]}),(0,I.jsx)(`span`,{className:t.limit_until?`is-limit`:t.live?`is-live`:``,title:`Whether its agent runs now`,children:t.limit_until?`limit: resumes ${new Date(t.limit_until).toTimeString().slice(0,5)}`:t.live?`agent live`:`agent closed`})]}),n&&(0,I.jsx)(`span`,{className:`thread-props`,children:n})]},t.id)})]})]}),(0,I.jsxs)(`section`,{className:`thread`,"aria-label":`Thread`,children:[(0,I.jsxs)(`div`,{className:`thread-head`,children:[(0,I.jsx)(`button`,{className:`d-back`,"aria-label":`Back to the threads`,onClick:()=>e.go(`chat`),children:`‹`}),(0,I.jsx)(`h2`,{title:l?.title??void 0,children:u?`New thread`:l?.title??`untitled · no message yet`}),!u&&l&&(0,I.jsx)(qv,{ctx:e}),l?.entry&&(f.has(l.entry)?(0,I.jsxs)(`button`,{className:`btn-line mono`,title:`The inbox entry this thread drafts from: open the inbox`,onClick:()=>e.go(`inbox`),children:[`◇ `,l.entry]}):(0,I.jsxs)(`span`,{className:`mono dim small`,title:`The entry is erased or taken: the thread stays`,children:[`◇ `,l.entry,` · erased`]})),l?.item&&(0,I.jsxs)(`button`,{className:`btn-line mono`,title:`Open the item this thread is bound to`,onClick:()=>e.openItem(l.item??``,`chat`),children:[`▸ `,l.item]})]}),u?(0,I.jsx)(Ky,{ctx:e,onMade:d}):l?(0,I.jsx)(Gy,{ctx:e,talk:l},l.id):(0,I.jsx)(`div`,{className:`c-stream`,children:(0,I.jsx)(`div`,{className:`tab-empty`,children:`This thread is not in the list: pick one.`})})]})]})}function Jy({ctx:e,item:t}){let n=e.project.name,[r,i]=(0,v.useState)(``),a=(0,v.useRef)(null),o=Nv(j(n,{item:t.id})),s=e.talks.find(e=>e.item===t.id),c=Nv(s?j(n,{talk:s.id}):null),l=oy(o.length+c.length),u={key:`run`,events:o,talk:null,item:t.id,send:r=>k.sendChat(n,t.id,r).catch(t=>{throw e.notify(t.message,`error`),t}),imageUrl:e=>`/api/p/${encodeURIComponent(n)}/chat/${t.id}/att/${e.split(`/`).pop()}`,imagePath:e=>`.gcf-session/runs/${e}`},d=Wy(e,s??{id:``,item:t.id},c),f=V_(o),p=t.running&&t.running_kind!==`session`&&(f.live||f.phase===`limit`),m=p?u:d,h=t.running&&t.running_kind===`session`,g=(o.at(-1)?.at??``)>(c.at(-1)?.at??``),_=o.flatMap((e,t)=>e.type===`run_end`?[t]:[]),y=o.findLastIndex(e=>e.type===`session`),b=(_.at(-1)??-1)>y?_.at(-2)??-1:_.at(-1)??-1,x=o.slice(b+1).find(e=>e.type===`session`)?.at,S=_.length&&_.at(-1)>y?o[_.at(-1)]:null,C=S?.type===`run_end`&&!g&&c.length>0?S:null;return(0,I.jsxs)(`div`,{className:`item-chat`,children:[(0,I.jsxs)(`div`,{className:`c-stream`,ref:l.ref,onScroll:l.onScroll,role:`log`,"aria-live":`polite`,"aria-relevant":`additions`,children:[!o.length&&!c.length&&(0,I.jsx)(`div`,{className:`tab-empty`,children:h?`An interactive session has no chat on the board: it is your own agent session, in your terminal.`:`No chat yet: it opens with the item's next run. A question now makes ${t.id}'s own thread of the project chat.`}),(g?[`thread`,`run`]:[`run`,`thread`]).map(n=>n===`run`?(0,I.jsxs)(v.Fragment,{children:[g&&c.length>0&&(0,I.jsxs)(`div`,{role:`separator`,className:`c-head c-run-head`,title:`The run started after your questions: its chat goes below, where the stream follows`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`}),`▸ The run of `,t.id,x&&(0,I.jsxs)(`span`,{className:`c-run-sub`,children:[`started `,oi(x)]}),(0,I.jsx)(`span`,{"aria-hidden":`true`})]}),(0,I.jsx)(Kv,{ctx:e,part:u})]},`run`):s&&c.length>0&&(0,I.jsxs)(v.Fragment,{children:[(0,I.jsxs)(`div`,{role:`separator`,className:`c-head`,title:`Its agent knows the item, its plan, its run's log and chat, and its commits`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`}),`Your questions about `,t.id,` · its own thread `,s.id,` of the project chat`,(0,I.jsx)(`span`,{"aria-hidden":`true`})]}),(0,I.jsx)(Kv,{ctx:e,part:d})]},`thread`))]}),(0,I.jsx)(sy,{follow:l}),(0,I.jsx)(Hy,{stream:l.ref,onReply:e=>a.current?.(e)}),C&&(0,I.jsx)(fy,{ctx:e,id:t.id,end:C,onShow:()=>[...l.ref.current?.querySelectorAll(`.c-end`)??[]].at(-1)?.scrollIntoView({block:`center`,behavior:`smooth`})}),(0,I.jsx)(ry,{ctx:e,part:m,quote:a,costLabel:p?`this run`:`this thread`,pulse:p?(0,I.jsx)(Yy,{item:t,events:o}):void 0,canStop:!0,route:r,placeholder:p?f.phase===`limit`?`Write now: it reaches the agent after the reset`:`Message the agent working on ${t.id}…`:`A question about ${t.id}: it goes to its own thread`,extra:p?(0,I.jsx)(`span`,{className:`a-pick compact`,children:[`model`,`effort`].map(n=>(0,I.jsx)(`select`,{className:`input`,"aria-label":n,disabled:!0,title:`${n}: a run keeps the item's own model and effort`,children:(0,I.jsx)(`option`,{children:yi(wi(e.board,n,t[n])??``)})},n))}):(0,I.jsx)(qv,{ctx:e}),onSend:async r=>{let a=f.phase===`limit`,o=await k.sendChat(n,t.id,ay(r));return i(o.talk?`the server sent your last message to ${o.talk}, ${t.id}'s own thread`:a?`the server took your last message into the run: it waits for the reset`:`the server sent your last message to the run's session`),o.talk&&e.reloadTalks(),{key:o.talk??u.key,id:o.id}}})]})}function Yy({item:e,events:t}){let n=e.plan&&!(`error`in e.plan)?e.plan:null,r=t.findLastIndex(e=>e.type===`run_end`),i=t.slice(r+1).find(e=>e.type===`session`),a=i&&e.active_at&&e.active_at>=i.at,o=n&&n.tasks?`step ${Math.min(n.done+1,n.tasks)} of ${n.tasks}`:``,s=a?e.doing??``:``,c=i?Math.max(1,Math.round((Date.now()-Date.parse(i.at))/6e4)):0,l=c?c<60?`${c} min`:`${Math.floor(c/60)} h ${String(c%60).padStart(2,`0`)} min`:``;return!o&&!s&&!l?null:(0,I.jsxs)(`div`,{className:`c-pulse`,role:`status`,title:`While the run goes: its plan step, its last tool call (from its log), how long it has gone. Every call is in the Log tab.`,children:[(0,I.jsx)(`span`,{className:`c-pulse-dot`,"aria-hidden":`true`}),o&&(0,I.jsx)(`span`,{className:`c-pulse-step`,children:o}),s&&(0,I.jsx)(`span`,{className:`c-pulse-doing`,children:s}),(0,I.jsx)(`span`,{className:`c-pulse-time`,children:l})]})}var Xy=e=>String(e).padStart(2,`0`),Zy=e=>{let t=new Date(e);return`${Xy(t.getDate())}.${Xy(t.getMonth()+1)} ${oi(e)}`},Qy=e=>{let t=Math.round(e/6e4);return t<60?`${t} min`:`${Math.floor(t/60)} h ${Xy(t%60)} min`},$y=e=>e===null?`?`:e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e),eb=e=>e===null?`$?`:`$${e.toFixed(2)}`,tb={submit:`ok`,close:`ok`,paused:`neutral`,"no-result":`neutral`,block:`blocked`,"not-started":`queued`};function nb(e){return!e.model&&!e.effort?{text:`on the agent's own model`,picked:!1}:{text:`on ${e.model??`the agent's model`} · ${e.effort??`the agent's effort`}`,picked:!0}}function rb(e,t,n){if(e.started)return{from:e.started,to:e.ended};let r=n.slice(n.indexOf(e)+1).find(e=>e.items.some(e=>e.id===t));return{from:r?r.ended:null,to:e.ended}}function ib({ctx:e,run:t,only:n,list:r,onPart:i}){let a=(e,n)=>i(n.id,{kind:e,run:t,item:n,span:rb(t,n.id,r)}),{board:o}=e,s=e=>o.items.some(t=>t.id===e)||(o.history??[]).some(t=>t.id===e)||(o.graveyard??[]).some(t=>t.id===e),c=t.items.filter(e=>!n||e.id===n),l=n?t.items.filter(e=>e.id!==n).map(e=>e.id):[],u=t.started&&t.started.slice(0,10)===t.ended.slice(0,10);return(0,I.jsxs)(`article`,{className:`run-row`,"aria-label":`Run ended ${t.ended}`,children:[(0,I.jsxs)(`header`,{children:[t.started?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`mono strong`,title:`start → end, on your clock`,children:[Zy(t.started),` → `,u?oi(t.ended):Zy(t.ended)]}),(0,I.jsx)(`span`,{className:`mono dim`,children:Qy(Date.parse(t.ended)-Date.parse(t.started))})]}):(0,I.jsxs)(`span`,{className:`mono strong`,title:`An older run-log line has no start`,children:[`ended `,Zy(t.ended)]}),(0,I.jsx)(`span`,{className:`mono dim`,title:`Run mode`,children:t.mode}),t.cost_usd!==null&&(0,I.jsx)(`span`,{className:`mono`,title:`What the whole run cost`,children:eb(t.cost_usd)}),(0,I.jsxs)(`span`,{className:`dim small`,children:[t.items.length,` item`,t.items.length>1?`s`:``]}),l.length>0&&(0,I.jsxs)(`span`,{className:`mono dim small`,children:[`with `,l.join(`, `)]}),!t.id&&(0,I.jsx)(`span`,{className:`dim small run-old`,children:`an older run-log line: no id, no start, no model, no log part`})]}),c.map((t,n)=>{let r=nb(t);return(0,I.jsxs)(`div`,{className:`run-item`,children:[(0,I.jsxs)(`div`,{className:`run-item-line`,children:[s(t.id)?(0,I.jsx)(`button`,{className:`link-btn mono strong`,onClick:()=>e.openItem(t.id),children:t.id}):(0,I.jsx)(`span`,{className:`mono strong`,children:t.id}),(0,I.jsx)(`span`,{className:`badge mono tone-${tb[t.result]??`warn`}`,title:`The run-log's result word`,children:t.result}),t.cost_usd!==null&&(0,I.jsx)(`span`,{className:`mono`,children:eb(t.cost_usd)}),t.duration_ms!==null&&(0,I.jsx)(`span`,{className:`mono dim`,children:Qy(t.duration_ms)}),(0,I.jsx)(`span`,{className:`grow`}),s(t.id)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`btn-line run-btn`,title:t.log?`The part of ${t.id}'s log this run wrote: bytes ${t.log.from.toLocaleString(`en`)}–${t.log.to.toLocaleString(`en`)}`:`An older line: no log part, the whole log`,onClick:()=>a(`log`,t),children:t.log?`log`:`whole log`}),(0,I.jsx)(jo,{label:`Chat`,tip:`Opens the chat of this run: its conversation with the agent, and a question you send goes to it`,glyph:`chat`,size:`sm`,onClick:()=>a(`chat`,t)})]})]}),t.reason&&(0,I.jsx)(`span`,{className:`mono run-reason`,title:`The reason, word for word`,children:t.reason}),(0,I.jsxs)(`div`,{className:`run-facts mono`,children:[Object.values(t.tokens).some(e=>e!==null)&&(0,I.jsxs)(`span`,{title:`tokens`,children:[`in `,$y(t.tokens.input),` · out `,$y(t.tokens.output),` · cache read`,` `,$y(t.tokens.cache_read)]}),t.turns!==null&&(0,I.jsxs)(`span`,{children:[t.turns,` turns`]}),t.handoffs>0&&(0,I.jsxs)(`span`,{className:`running-text`,children:[`↻ `,t.handoffs,` handoff`,t.handoffs>1?`s`:``]}),(0,I.jsx)(`span`,{className:r.picked?``:`dim`,title:`What it ran on: the run's pick or the item's own; none is the agent's choice`,children:r.text}),t.process&&(0,I.jsxs)(`span`,{className:`warn-text`,title:`A broken step of the run's process`,children:[`! `,t.process]})]})]},`${t.id}-${n}`)})]})}var ab={p:({children:e})=>(0,I.jsx)(I.Fragment,{children:e})},ob=[r_],sb=[`status`,`chat`,`file`,`plan`,`log`,`history`,`related`,`lessons`],cb=[`type`,`system`,`gate`,`milestone`],lb=null,ub=window.matchMedia(`(width <= 700px)`),db=24,fb=2e4,pb=()=>(0,v.useSyncExternalStore)(e=>(window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)),()=>`${window.innerWidth}x${window.innerHeight}`);function mb(){pb();let[e,t]=(0,v.useState)(lb),n=(0,v.useRef)(null),r=Math.round(document.querySelector(`.workspace`)?.getBoundingClientRect().top??48)+6,{x:i,y:a,width:o,height:s}=hy(window.innerWidth,window.innerHeight,r,e,ub.matches?0:db);return{style:{"--win-x":`${i}px`,"--win-y":`${a}px`,"--win-w":`${o}px`,"--win-h":`${s}px`},onPointerDown:e=>{let t=e.target;e.button!==0||ub.matches||!t.closest(`.d-head`)||t.closest(`button, a, input, select, textarea`)||(n.current={dx:e.clientX-i,dy:e.clientY-a},e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault())},onPointerMove:e=>{n.current&&(lb={x:e.clientX-n.current.dx,y:e.clientY-n.current.dy},t(lb))},onPointerUp:()=>{n.current=null},onPointerCancel:()=>{n.current=null},onLostPointerCapture:()=>{n.current=null}}}var hb=new Set([`depends`,`needs`,`needed_by`,`waits_for`]),gb=e=>e.board.domain.fields.some(e=>e.key===`needs`);function _b(e,t,n){let[r,i]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let n=!0;return t&&k.file(e.project.name,t).then(e=>n&&i(e.text),e=>n&&i(e.message)),()=>{n=!1}},[e.project.name,t,n]),(0,v.useEffect)(()=>i(null),[t]),r}var vb=(e,t)=>e.map((e,n)=>(0,I.jsxs)(`section`,{className:`file-sec`,children:[(0,I.jsx)(`h3`,{children:by(e.key)}),e.rest&&(0,I.jsx)(`p`,{children:t(e.rest)}),e.bullets.length>0&&(0,I.jsx)(`ul`,{children:e.bullets.map((e,n)=>(0,I.jsxs)(`li`,{children:[e.lead&&(0,I.jsxs)(`span`,{className:`file-lead`,children:[e.lead,`: `]}),t(e.text)]},n))}),e.cards.length>0&&(0,I.jsx)(`ol`,{className:`file-cards`,children:e.cards.map((e,n)=>(0,I.jsx)(`li`,{children:e.map(([e,n],r)=>(0,I.jsxs)(`span`,{className:`file-card-row`,children:[(0,I.jsx)(`span`,{children:by(e)}),(0,I.jsx)(`span`,{children:t(n)})]},r))},n))}),e.table&&(0,I.jsxs)(`table`,{className:`file-table`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsx)(`tr`,{children:e.table.cols.map((e,t)=>(0,I.jsx)(`th`,{children:by(e)},t))})}),(0,I.jsx)(`tbody`,{children:e.table.rows.map((e,n)=>(0,I.jsx)(`tr`,{children:e.map((e,n)=>(0,I.jsx)(`td`,{children:t(e)},n))},n))})]})]},n));function yb({ctx:e,item:t}){let n=n=>(0,I.jsx)(Jp,{urlTransform:jy(e.project,t.file),components:ab,children:yy(n)}),r=_b(e,t.file,JSON.stringify(t)),[i,a]=(0,v.useState)(!1);if(r===null)return(0,I.jsx)(`p`,{className:`tab-note`,children:`reading…`});let o=r.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/),s=o?r.slice(o[0].length):r,c=vy(s);return(0,I.jsxs)(`div`,{className:`file-tab`,children:[(0,I.jsx)(`div`,{className:`tab-path`,children:t.file}),o&&(0,I.jsxs)(`div`,{className:`file-front`,children:[(0,I.jsxs)(`button`,{"aria-expanded":i,title:`The item's data block: what the board and the core read`,onClick:()=>a(!i),children:[i?`▾`:`▸`,` front matter`,(0,I.jsxs)(`span`,{className:`dim`,children:[o[1].split(/\r?\n/).length,` lines`]})]}),i&&(0,I.jsx)(`pre`,{className:`frontmatter`,children:o[1]})]}),c?vb(c,n):(0,I.jsx)(`div`,{className:`md`,children:(0,I.jsx)(Jp,{urlTransform:jy(e.project,t.file),remarkPlugins:ob,children:s})})]})}function bb({ctx:e,item:t}){let n=t.plan,r=_b(e,t.plan_file,`${JSON.stringify(n)} ${e.board.plans_rev??0}`);return t.plan_file?(0,I.jsxs)(`div`,{className:`plan-tab`,children:[n&&!(`error`in n)&&(0,I.jsxs)(`div`,{className:`plan-head`,title:`Plan checkboxes done / total`,children:[(0,I.jsxs)(`span`,{children:[n.done,` / `,n.tasks,` checked`]}),(0,I.jsx)(`span`,{className:`bar ok`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{style:{width:`${Math.round(100*n.done/Math.max(1,n.tasks))}%`}})})]}),n&&`error`in n&&(0,I.jsxs)(`div`,{role:`alert`,className:`plan-error`,children:[(0,I.jsx)(`span`,{children:`✘ The framework cannot read the plan`}),(0,I.jsx)(`pre`,{children:n.error})]}),(0,I.jsx)(`div`,{className:`tab-path`,children:t.plan_file}),r===null?(0,I.jsx)(`p`,{className:`tab-note`,children:`reading…`}):(0,I.jsx)(xb,{ctx:e,item:t,text:r})]}):(0,I.jsx)(`p`,{className:`tab-note`,children:`No plan yet: the run writes the plan first.`})}function xb({ctx:e,item:t,text:n}){let r=jy(e.project,t.plan_file??``),i=e=>(0,I.jsx)(Jp,{urlTransform:r,components:ab,children:yy(e)}),a=e=>(0,I.jsx)(`div`,{className:`md`,children:(0,I.jsx)(Jp,{urlTransform:r,remarkPlugins:ob,children:e})}),{title:o,lead:s,folds:c}=Ey(n);return c.length?(0,I.jsxs)(`div`,{className:`plan-folds`,children:[o&&(0,I.jsx)(`h3`,{className:`plan-title`,children:o}),s&&a(s),c.map((e,t)=>(0,I.jsx)(Cb,{f:e,children:Sb(e,i,a)},`${e.key}-${t}`))]}):a(n)}function Sb(e,t,n){let r=Dy(e);if(r)return(0,I.jsx)(`div`,{className:`plan-tasks`,children:r.map((e,n)=>(0,I.jsxs)(`div`,{className:`plan-phase`,children:[e.name&&(0,I.jsxs)(`div`,{className:`plan-phase-head`,children:[(0,I.jsx)(`span`,{children:e.name}),(0,I.jsxs)(`span`,{className:`dim`,children:[e.tasks.filter(e=>e.done).length,` / `,e.tasks.length]})]}),(0,I.jsx)(`ul`,{children:e.tasks.map((e,n)=>(0,I.jsxs)(`li`,{className:e.done?`done`:``,children:[(0,I.jsx)(`span`,{className:`plan-box`,role:`img`,"aria-label":e.done?`done`:`to do`,children:e.done?`☑`:`☐`}),(0,I.jsx)(`span`,{children:t(e.text)})]},n))})]},n))});let i=e.kind===`block`?vy(`${e.key}:\n${e.body}`):null;return i?vb(i,t):n(e.body)}function Cb({f:e,children:t}){let[n,r]=(0,v.useState)(e.open),i=Oy(e);return(0,I.jsxs)(`section`,{className:`plan-fold ${n?`open`:``}`,children:[(0,I.jsxs)(`button`,{className:`plan-fold-head`,"aria-expanded":n,onClick:()=>r(!n),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,I.jsx)(`span`,{className:`plan-fold-name`,children:e.kind===`block`?by(e.key):e.key}),i&&(0,I.jsx)(`span`,{className:`plan-fold-count`,children:i})]}),n&&(0,I.jsx)(`div`,{className:`plan-fold-body`,children:t})]})}function wb({ctx:e,item:t}){let[n,r]=(0,v.useState)(``),i=(0,v.useRef)(null);return(0,v.useEffect)(()=>F(e.project.name,t.id,()=>r(``),e=>r(t=>(t+e).slice(-262144))),[e.project.name,t.id]),(0,v.useEffect)(()=>{i.current?.scrollIntoView({block:`end`})},[n]),t.running_kind===`session`&&t.running?(0,I.jsx)(`div`,{className:`tab-empty`,children:`An interactive session writes no log. It is your own agent session: follow it in your terminal.`}):(0,I.jsxs)(`div`,{className:`log`,"aria-live":`polite`,"aria-relevant":`additions`,children:[(0,I.jsx)(Ob,{text:n}),(0,I.jsx)(`div`,{ref:i})]})}function Tb({ctx:e,id:t,part:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),s=n.item.log;return(0,v.useEffect)(()=>{let n=!0;return(s?k.logPart(e.project.name,t,s.from,s.to):k.file(e.project.name,`.gcf-session/runs/${t}.log`).then(e=>({...e,cut:0}))).then(e=>n&&i(e),e=>n&&o(e.message)),()=>{n=!1}},[e.project.name,t,s]),a?(0,I.jsxs)(`p`,{className:`tab-note error-text`,children:[`✘ `,a]}):r?(0,I.jsxs)(`div`,{className:`log`,children:[r.cut>0&&(0,I.jsxs)(`div`,{className:`tab-note`,children:[`…the first `,r.cut.toLocaleString(`en`),` bytes of this part are cut: 2 MB at most`]}),(0,I.jsx)(Ob,{text:r.text})]}):(0,I.jsx)(`p`,{className:`tab-note`,children:`reading…`})}var Eb=400;function Db({text:e}){let[t,n]=(0,v.useState)(!1);return t||e.length<=Eb?(0,I.jsx)(`span`,{children:e}):(0,I.jsxs)(`span`,{children:[e.slice(0,Eb),`…`,` `,(0,I.jsxs)(`button`,{type:`button`,className:`link-btn small`,onClick:()=>n(!0),children:[`all `,e.length,` characters`]})]})}function Ob({text:e}){let t=Ny(e);return(0,I.jsxs)(I.Fragment,{children:[!t.length&&(0,I.jsx)(`div`,{className:`tab-empty`,children:`no output yet`}),t.map((e,t)=>e.kind===`start`?(0,I.jsxs)(`div`,{className:`log-start`,children:[(0,I.jsxs)(`span`,{children:[`▸ `,Py(e.text),` · `,e.time]}),(0,I.jsx)(`span`,{children:e.text})]},t):e.kind===`summary`?(0,I.jsxs)(`div`,{className:`log-summary`,children:[`■ `,e.time,` `,e.text]},t):(0,I.jsxs)(`div`,{className:`log-line log-${e.kind}`,children:[(0,I.jsx)(`span`,{children:e.time}),(0,I.jsx)(Db,{text:e.text})]},t))]})}function kb({ctx:e,id:t,part:n}){let r=Nv(j(e.project.name,{item:t})),{from:i,to:a}=n.span,[o,s]=[i?Date.parse(i):-1/0,Date.parse(a)],c=r.filter(e=>Date.parse(e.at)>=o&&Date.parse(e.at)<=s),l=(0,v.useRef)(null),u={key:`part-${n.run.ended}`,events:c,talk:null,item:t,send:async()=>{},imageUrl:n=>`/api/p/${encodeURIComponent(e.project.name)}/chat/${t}/att/${n.split(`/`).pop()}`,imagePath:e=>`.gcf-session/runs/${e}`};return(0,I.jsxs)(`div`,{className:`item-chat part`,children:[(0,I.jsxs)(`div`,{className:`c-stream`,role:`log`,ref:l,children:[!c.length&&(0,I.jsx)(`div`,{className:`tab-empty`,children:`No chat event in this run's time.`}),(0,I.jsx)(Kv,{ctx:e,part:u})]}),(0,I.jsx)(Hy,{stream:l})]})}function Ab({ctx:e,item:t,f:n}){let r=Ir(t,n),i=t[n.key],a=n.kind===`ids`||n.key===`parent`?Array.isArray(i)?i:[i]:null;if(!a)return(0,I.jsx)(I.Fragment,{children:r});let o=new Set(e.board.items.map(e=>e.id)),s=new Set((e.board.history??[]).map(e=>e.id)),c=new Set((e.board.graveyard??[]).map(e=>e.id));return(0,I.jsx)(I.Fragment,{children:a.map(t=>o.has(String(t))?(0,I.jsx)(`button`,{className:`link-btn mono`,onClick:()=>e.openItem(String(t)),children:String(t)},String(t)):s.has(String(t))?(0,I.jsxs)(`span`,{className:`fact-ended`,title:`ended: accepted, in history`,children:[String(t),` ✔`]},String(t)):c.has(String(t))?(0,I.jsxs)(`span`,{className:`fact-ended`,title:`ended: in the graveyard`,children:[String(t),` ✝`]},String(t)):(0,I.jsxs)(`span`,{className:`fact-ended`,title:`not on the board: no item has this id`,children:[String(t),` ?`]},String(t)))})}function jb(e){let t=Math.max(0,Math.round((Date.now()-Date.parse(e))/6e4));return Number.isNaN(t)?``:t<60?`${t} min`:t<1440?`${Math.round(t/60)} h`:`${Math.round(t/1440)} d`}function Mb({ctx:e,e:t}){let{domain:n}=e.board,r=Tr(n,n.sections.inbox?.drop),{title:i,rest:a}=Lo(t),[o,s]=(0,v.useState)(!1),c=e.talks.find(e=>e.entry===t.id&&e.title),l=$a(e.board.quota),u=async()=>{if(c)return e.go(`chat`,c.id);s(!0);try{let n=await k.draft(e.project.name,t.id);e.reloadTalks(),e.go(`chat`,n.thread)}catch(t){e.notify(t.message,`error`)}s(!1)};return(0,I.jsxs)(`div`,{className:`d-lesson`,children:[(0,I.jsxs)(`span`,{className:`d-lesson-side`,children:[(0,I.jsx)(`span`,{children:t.detail??``}),t.at&&(0,I.jsx)(`span`,{className:`d-lesson-age`,children:jb(t.at)})]}),(0,I.jsxs)(`span`,{className:`d-lesson-main`,children:[(0,I.jsx)(`span`,{className:`d-lesson-text`,children:t.text}),(0,I.jsxs)(`span`,{className:`d-lesson-acts`,children:[n.new_item&&(0,I.jsx)(`button`,{className:`btn`,title:`Opens the new-item form from this lesson; the lesson is erased when the item is created`,onClick:()=>e.newItem({from:t.id,title:i,note:a}),children:`→ Item`}),n.chat&&n.new_item&&(0,I.jsx)(jo,{size:`sm`,glyph:`draft`,label:`Draft with agent`,off:!c&&!!l,starting:o,hasThread:!!c,tip:c?`Opens its thread ${c.id}; sends nothing`:l?`Off until ${oi(l)}: the usage limit holds`:`Opens a project chat thread on this lesson: the agent proposes an item from it, or says none is needed`,onClick:()=>void(o||u())}),r&&(0,I.jsx)(Na,{label:`Erase`,tip:`Erase the lesson (gcf inbox drop)`,onClick:()=>e.erase(r.cmd,t.id)})]})]})]})}function Nb({ctx:e,id:t,waits:n}){let r=ra(e.board,t,n),i={item:``,unit:`unit`,grave:`✝`,history:`✔`,unknown:`?`}[r.kind],a=e.board.items.find(e=>e.id===t)?.type;return(0,I.jsxs)(`div`,{className:`dep-line`,title:r.tip,children:[(0,I.jsx)(`span`,{className:`mono dim`,children:r.kind===`item`?(a??``).slice(0,3).toUpperCase():i}),(0,I.jsxs)(`span`,{className:`dep-what`,children:[r.kind===`unit`||r.kind===`unknown`?(0,I.jsx)(`span`,{className:`mono`,children:t}):(0,I.jsx)(`button`,{className:`link-btn mono`,onClick:()=>e.openItem(t),children:t}),(0,I.jsx)(`span`,{className:`dep-state tone-${r.tone}`,children:r.state})]})]})}function Pb({ctx:e,item:t}){let{domain:n}=e.board,r=n.fields.find(e=>e.key===`depends`),i=r?.edit&&t.moves.includes(r.edit)?Tr(n,r.edit):null,a=ia(t),o=aa(t),s=t.waits_for??[],c=(e,t)=>n.fields.find(t=>t.key===e)?.label??t;return(0,I.jsxs)(`section`,{className:`d-deps`,"aria-label":`Dependencies`,children:[(0,I.jsxs)(`div`,{className:`d-deps-head`,children:[(0,I.jsx)(`span`,{children:`Dependencies`}),i&&(0,I.jsx)(`button`,{className:`btn`,disabled:t.running,title:t.running?`Not while it runs`:`Add or remove a dependency: the depends move`,onClick:()=>e.openMove({title:`Dependencies of ${t.id}`,id:t.id,move:i}),children:`Edit…`})]}),(0,I.jsxs)(`div`,{className:`d-deps-cols`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`d-deps-sub`,title:`Its depends that have not ended in history`,children:[c(`needs`,`needs`),` · `,a.length]}),!a.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`nothing: every dependency has ended`}),a.map(t=>(0,I.jsx)(Nb,{ctx:e,id:t,waits:s},t)),a.length>0&&(0,I.jsxs)(`span`,{className:`dim small`,children:[`⧗`,` `,s.length?`the run gate waits for ${s.join(`, `)}`:`none of them holds a run back`]})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`span`,{className:`d-deps-sub`,title:`The items on the board whose depends name it`,children:[c(`needed_by`,`needed by`),` · `,o.length]}),!o.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`no item depends on it`}),o.map(t=>(0,I.jsx)(Nb,{ctx:e,id:t,waits:[]},t))]})]})]})}var Fb=(e,t)=>e.split(/[^a-z0-9-]+/).includes(t),Ib={run:[`run`,`an agent run`],thread:[`thread`,`a board chat`],session:[`session`,`your own agent session`],operator:[`operator`,`you: a console or the board`]};function Lb({ctx:e,id:t,onPart:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(new Set),{board:l}=e,u=Ni(l),d=JSON.stringify([l.head,l.items.find(e=>e.id===t)?.running,l.runs?.reports?.length]);if((0,v.useEffect)(()=>{if(!u)return;let n=!0;return k.history(e.project.name,t).then(e=>{n&&(i(e),o(``))},e=>n&&o(e.message)),()=>{n=!1}},[e.project.name,t,u,d]),!u)return(0,I.jsxs)(`div`,{role:`note`,className:`empty-box chat-old`,children:[(0,I.jsxs)(`b`,{children:[`History needs gcf-aif-ext ≥ `,Oi.replace(/\.0$/,``),`: this project has`,` `,ji(l)??`an older one`,`.`]}),(0,I.jsx)(`code`,{children:`update gcf-aif-ext`})]});if(a)return(0,I.jsxs)(`p`,{className:`tab-note error-text`,children:[`✘ `,a]});if(!r)return(0,I.jsx)(`p`,{className:`tab-note`,children:`reading…`});let f=l.domain.moves;return(0,I.jsxs)(`div`,{className:`history`,children:[(0,I.jsxs)(`section`,{"aria-label":`Its moves`,children:[(0,I.jsx)(`span`,{className:`d-deps-sub`,children:`Its moves · newest first`}),!r.moves.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`no move yet`}),(0,I.jsx)(`ol`,{className:`h-moves`,children:r.moves.map((e,n)=>{let r=f[e.move],i=e.by?Ib[e.by]:null,a=s.has(n);return(0,I.jsxs)(`li`,{children:[(0,I.jsxs)(`button`,{"aria-expanded":a,title:e.subject,onClick:()=>{let e=new Set(s);a?e.delete(n):e.add(n),c(e)},children:[(0,I.jsx)(`span`,{className:`mono dim`,children:Zy(e.at)}),(0,I.jsxs)(`span`,{className:r?`h-move`:`h-move mono`,title:r?`move ${e.move}${r.help?` · ${r.help}`:``}`:`move ${e.move}: the domain has no form for it`,children:[r?.label??e.move,!Fb(e.subject,t)&&(0,I.jsxs)(`span`,{className:`dim small`,children:[` · `,e.subject]})]}),(0,I.jsx)(`span`,{className:i?`small`:`dim small`,title:i?i[1]:`A commit older than the framework's marks: who made it is not known`,children:i?i[0]:`unknown`}),(0,I.jsxs)(`span`,{className:`mono small`,children:[a?`▾`:`▸`,` `,e.commit]})]}),a&&(0,I.jsx)(`code`,{className:`h-subject`,children:e.subject})]},`${e.commit}-${n}`)})})]}),(0,I.jsxs)(`section`,{"aria-label":`Its runs`,children:[(0,I.jsx)(`span`,{className:`d-deps-sub`,children:`Its runs`}),Pi(l)?r.runs.length?r.runs.map((i,a)=>(0,I.jsx)(ib,{ctx:e,run:i,only:t,list:r.runs,onPart:(e,t)=>n(t)},i.id??`old-${i.ended}-${a}`)):(0,I.jsx)(`span`,{className:`dim small`,children:`no run in the run log`}):(0,I.jsx)(`span`,{className:`dim small`,children:l.domain.harness?`Past runs need gcf-harness-aif-ext ≥ ${Oi.replace(/\.0$/,``)}.`:`No harness: its runs went from a console.`})]})]})}function Rb({ctx:e,item:t}){let{board:n}=e,r=t.parent?n.items.find(e=>e.id===t.parent):void 0,i=r?r.children.filter(e=>e!==t.id):t.parent?n.items.filter(e=>e.parent===t.parent&&e.id!==t.id).map(e=>e.id):[],a=n.domain.sections.graveyard?.match,o=a?ca(t,a):[],s=o.length?(n.graveyard??[]).filter(e=>e.tags.some(e=>o.includes(e))):[];return(0,I.jsxs)(`div`,{className:`related`,children:[(0,I.jsx)(`section`,{"aria-label":`Siblings`,children:t.parent?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`d-deps-sub`,children:[`Siblings under `,r?.title??t.parent,` · `,i.length,` `,(0,I.jsx)(`button`,{className:`link-btn mono`,onClick:()=>e.openItem(t.parent??``),children:t.parent})]}),i.map(t=>{let r=ra(n,t);return(0,I.jsxs)(`button`,{className:`rel-row`,title:r.tip,onClick:()=>e.openItem(t),children:[(0,I.jsx)(`span`,{className:`mono`,children:t}),(0,I.jsx)(`span`,{className:`badge tone-${r.tone}`,children:r.state})]},t)})]}):(0,I.jsx)(`span`,{className:`dim small`,children:t.children.length?`A feature with no parent: its children are listed above.`:`No parent feature: it has no siblings.`})}),a&&n.domain.sections.graveyard&&(0,I.jsxs)(`section`,{"aria-label":`Graveyard hits`,children:[(0,I.jsxs)(`span`,{className:`d-deps-sub`,children:[`Did we kill this before? Graveyard lines tagged with its `,a,o.length?`: ${o.join(`, `)}`:``]}),!s.length&&(0,I.jsx)(`span`,{className:`dim small`,children:o.length?`No graveyard line holds ${o.join(`, `)}.`:`It has no ${a} to match.`}),s.map((t,n)=>(0,I.jsxs)(`button`,{className:`rel-grave`,onClick:()=>e.openItem(t.id),children:[(0,I.jsxs)(`span`,{className:`rel-grave-line`,children:[t.type&&(0,I.jsx)(`span`,{className:`mono dim`,children:t.type.slice(0,3).toUpperCase()}),(0,I.jsxs)(`span`,{className:`mono strong`,children:[`✝ `,t.id]}),t.tags.map(e=>(0,I.jsxs)(`span`,{className:`mono small ${o.includes(e)?`strong`:`dim`}`,children:[`#`,e]},e))]}),t.reason&&(0,I.jsx)(`span`,{className:`small`,children:t.reason})]},`${t.id}-${n}`))]}),(0,I.jsx)(`span`,{className:`dim small`,children:`Its dependencies are above, under Dependencies.`})]})}function zb({id:e,part:t,onClear:n}){let r=Zy(t.run.started??t.run.ended),i=t.item.log,a=t.kind===`log`?i?`The part of the log the run of ${r} wrote: bytes ${i.from.toLocaleString(`en`)}–${i.to.toLocaleString(`en`)}. ${e}'s log holds every run.`:`A run older than log parts (ended ${Zy(t.run.ended)}): its whole log.`:`The chat of the run of ${r}.`;return(0,I.jsxs)(`div`,{role:`note`,className:`part-note`,children:[(0,I.jsx)(`span`,{children:a}),(0,I.jsx)(`button`,{className:`icon-btn`,"aria-label":t.kind===`log`?`Show the whole log`:`Show the whole chat`,title:`Back to the whole log and chat`,onClick:n,children:`×`})]})}function Bb({ctx:e,id:t,part:n,onClose:r}){let[i,a]=(0,v.useState)(n??null),[o,s]=(0,v.useState)(!1),c=mb(),{board:l}=e,u=l.history?.find(e=>e.id===t),d=l.graveyard?.find(e=>e.id===t),f=l.domain.sections;return(0,I.jsxs)(`aside`,{className:`drawer`,"aria-label":`Item ${t}`,...c,children:[(0,I.jsx)(`div`,{className:`d-head`,title:`Drag to move the window`,children:(0,I.jsxs)(`div`,{className:`d-top`,children:[(0,I.jsx)(`button`,{className:`d-back`,"aria-label":`Back`,onClick:r,children:`‹`}),(0,I.jsxs)(`div`,{className:`d-name`,children:[(0,I.jsxs)(`div`,{className:`d-meta`,children:[(0,I.jsx)(`span`,{className:d?`error-text`:`ok-text`,children:d?f.graveyard?.label??`graveyard`:f.history?.label??`history`}),d?.type&&(0,I.jsx)(`span`,{className:`d-dot`,children:d.type})]}),(0,I.jsx)(`h2`,{children:(0,I.jsx)(`span`,{className:`d-id`,children:t})})]}),(0,I.jsx)(`button`,{className:`icon-btn bordered d-close`,"aria-label":`Close`,onClick:r,children:`×`})]})}),(0,I.jsxs)(`div`,{role:`tablist`,className:`d-tabs`,children:[(0,I.jsx)(`button`,{role:`tab`,"aria-selected":o,onClick:()=>{s(!0),a(null)},children:`Status`}),(0,I.jsx)(`button`,{role:`tab`,"aria-selected":!o&&!i,onClick:()=>{s(!1),a(null)},children:`History`}),i&&(0,I.jsx)(`button`,{role:`tab`,"aria-selected":!0,children:i.kind===`log`?`Log`:`Chat`})]}),(0,I.jsx)(`div`,{className:`d-body`,children:(0,I.jsxs)(`div`,{role:`tabpanel`,className:`d-panel`,children:[o&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`dl`,{className:`facts`,children:d?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`reason`}),(0,I.jsx)(`dd`,{children:d.reason??`—`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`tags`}),(0,I.jsx)(`dd`,{className:`mono`,children:d.tags.map(e=>`#${e}`).join(` `)||`—`})]})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`event`}),(0,I.jsx)(`dd`,{children:u?.event??`—`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`date`}),(0,I.jsx)(`dd`,{children:u?.date??`—`})]})]})}),(0,I.jsxs)(`p`,{className:`d-ended dim small`,children:[d?`It ended in the graveyard`:`It ended in history`,`; it keeps its History.`]})]}),!o&&!i&&(0,I.jsx)(Lb,{ctx:e,id:t,onPart:e=>{s(!1),a(e)}}),i&&(0,I.jsx)(zb,{id:t,part:i,onClear:()=>a(null)}),i?.kind===`log`&&(0,I.jsx)(Tb,{ctx:e,id:t,part:i}),i?.kind===`chat`&&(0,I.jsx)(kb,{ctx:e,id:t,part:i})]})})]})}function Vb(e){let t=(0,v.useRef)(!1);return(0,v.useEffect)(()=>{if(!t.current)return;t.current=!1;let n=document.activeElement;(!n||n===document.body)&&e()?.focus()}),(0,v.useCallback)(e=>{if(e)return()=>{e===document.activeElement&&(t.current=!0)}},[])}function Hb({ctx:e,item:t,tab:n,part:r,onClose:i}){let[a,o]=(0,v.useState)(sb.includes(n)?n:t.blocked||t.waits_for?.length?`status`:t.running&&t.running_kind!==`session`?`chat`:`file`),[s,c]=(0,v.useState)(r??null),l=s&&s.kind===a?s:null,[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(!1),g=t.running&&!t.starting,_=e.board.runs?.queued.includes(t.id)??!1,y=e.board.runs?.active.some(e=>e.ids.includes(t.id))??!1,b=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!m)return void(b.current=!1);if(y&&(b.current=!0),g||_||b.current&&!y)return h(!1);let e=setTimeout(()=>h(!1),fb);return()=>clearTimeout(e)},[m,g,_,y]);let x=f!==null||m||!!t.starting,S=(0,v.useRef)(null),C=Vb(()=>S.current?.querySelector(`button:not(:disabled)`)),w=async n=>{await e.run([t.id],n)&&h(!0)},T=(0,v.useRef)(!1),E=gy(T,async()=>{p(`gate`);try{if(!await se())return;p(`run`),await w(!1)}finally{p(null)}}),D=gy(T,async()=>{p(`fresh`);try{let n=await ae();await ie(`This drops the agent's context; its files are kept.`,`Start fresh`,!0,{title:`Start ${t.id} fresh?`,warn:n.length?{...oe(n),head:`It runs on main, among loose work`}:void 0,other:Ui(e,n)??void 0})&&await w(!0)}finally{p(null)}}),O=gy(T,async()=>{let n=t.denied_group??``;p(`allow`);try{if(!await e.move({cmd:`permissions`,off:[n]})||!await e.move({cmd:`unblock`,id:t.id}))return;await w(!1)}finally{p(null)}}),A=mb(),{domain:j}=e.board,M=j.sections.lessons?Eo(e.board.inbox??[],t.id):[],te=Er(t,j),N=kr(t,j),ne=Ar(t,j),P=di(t),F=t.running?{label:`running`,help:`An agent session works on it; its status: ${t.status}`}:j.columns.find(e=>e.status===t.status),re=G(t,e.board),L=typeof t.blocked==`string`&&t.blocked?t.blocked:null,R=t.waits_for??[],z=zi(e,ne&&!_&&!t.running?[t.id]:null),B=z.refused[t.id]??null,ae=async()=>mi(e.board,t.id)===`main`?z.dirty??await k.gate(e.project.name,[t.id]).then(e=>e.dirty??[],()=>[]):[],oe=e=>({head:`Loose work in the project folder`,text:Bi(e)}),se=async()=>{let n=await ae();return!n.length||ie(`${t.id} runs on main, in the project folder. A warning, not a refusal: you judge.`,`Run anyway`,!1,{title:`Run ${t.id} here anyway?`,warn:oe(n),other:Ui(e,n)??void 0})},ce=t.plan&&!(`error`in t.plan)?t.plan:null,V=e=>({...Object.fromEntries(e.fields.filter(e=>e.presets).map(e=>[e.key,`default`])),...Object.fromEntries(j.fields.filter(n=>n.edit===e.cmd&&typeof t[n.key]==`string`).map(e=>[e.key,t[e.key]]))}),H=n=>e.openMove({title:`${n.label} ${t.id}`,id:t.id,move:n,values:V(n)}),U=e=>e.edit&&t.moves.includes(e.edit)?Tr(j,e.edit):null,le=n=>Ir(t,n)===null&&(n.key===`model`||n.key===`effort`)?e.board.agent?.[n.key]??null:null,ue=j.fields.filter(e=>e.key===`model`||e.key===`effort`),de=n=>yi(Ir(t,n)??le(n)??Ci(e.board,n.key)??`default`),fe=e=>`${e.label}: ${Ir(t,e)===null?le(e)===null?`nothing set: the default holds`:`the project's (Settings, agent.*)`:`its own`}`,pe=ue[0]&&!t.running?U(ue[0]):null,W=cb.map(e=>j.fields.find(t=>t.key===e)).filter(e=>!!e&&Ir(t,e)!==null),me=j.fields.filter(n=>n.key!==`blocked`&&!(cb.includes(n.key)&&!U(n))&&!(gb(e)?hb.has(n.key):n.key===`waits_for`)&&(ue.includes(n)?n===ue[0]:Ir(t,n)!==null)),he=[t.running?ii(t):null,P?`limit: resumes ${oi(P)}`:null,t.resumable&&!t.running?li(t):null,_?`queued`:null,t.verified?`✔ verified`:null].filter(Boolean);return(0,I.jsxs)(`aside`,{className:`drawer`,"aria-label":`Item ${t.id}`,...A,children:[(0,I.jsxs)(`div`,{className:`d-head`,title:ub.matches?void 0:`Drag to move the window`,children:[(0,I.jsxs)(`div`,{className:`d-top`,children:[(0,I.jsx)(`button`,{className:`d-back`,"aria-label":`Back`,onClick:i,children:`‹`}),(0,I.jsxs)(`div`,{className:`d-name`,children:[(0,I.jsxs)(`div`,{className:`d-meta`,children:[re?(0,I.jsxs)(`span`,{className:`d-needs`,title:`status: ${F?.label??t.status} · ${F?.help??``} Only you can move it on.`,children:[`● `,F?.label??t.status]}):(0,I.jsx)(`span`,{className:`d-status`,title:`status: ${F?.label??t.status}${F?.help?` · ${F.help}`:``}`,children:F?.label??t.status}),W.map(e=>(0,I.jsx)(`span`,{className:`d-dot ${e.key===`gate`?`gate-text gate-${t.gate}`:``}`,title:`${e.label}: ${Ir(t,e)}${e.help?` · ${e.help}`:``}`,children:Ir(t,e)},e.key)),he.map(e=>(0,I.jsx)(`span`,{className:`d-state d-dot`,title:e.startsWith(`limit`)?ui:e.startsWith(`paused`)||e===`interrupted`?ci(t):void 0,children:e},e)),t.running&&t.running_kind!==`session`&&t.active_at&&!P&&(0,I.jsx)(ei,{at:t.active_at})]}),(0,I.jsxs)(`h2`,{children:[(0,I.jsx)(`span`,{className:`d-id`,children:t.id}),t.title&&(0,I.jsxs)(`span`,{className:`d-title`,children:[`(`,t.title,`)`]})]})]}),(0,I.jsx)(`button`,{className:`icon-btn bordered d-close`,"aria-label":`Close`,onClick:i,children:`×`})]}),(0,I.jsxs)(`div`,{className:`d-acts`,ref:S,children:[t.running&&t.running_kind===`session`&&(0,I.jsx)(`button`,{className:`btn`,title:`A session's mark makes it running; your own session goes on`,onClick:async()=>{await ie(`Release the session mark on ${t.id}?`,`Release mark`)&&e.move({cmd:`release`,id:t.id})},children:`Release mark`}),g&&t.running_kind!==`session`&&(0,I.jsx)(`button`,{className:`btn-danger`,title:P?`Ends the wait for the reset: it becomes paused: limit, and Run resumes it later`:`Stops the agent session; the item stays ready and its work is kept`,onClick:()=>void Yi(e,t),children:`Stop`}),_&&(0,I.jsx)(`button`,{className:`btn`,title:`Takes it out of the run queue; it asks nothing`,onClick:()=>void e.unqueue(t.id),children:`Remove from queue`}),ne&&!_&&!g&&(0,I.jsx)(`button`,{className:`btn-primary`,ref:C,onClick:()=>x||void E(),disabled:B!==null,"aria-disabled":x||void 0,"aria-busy":f===`gate`||f===`run`||m||t.starting,title:B?`The run gate refuses it now: ${B}`:t.resumable?`Goes on from where its last run stopped`:N?.help??`Starts at once: you named this item. The run gate may still refuse; the run report says why.`,children:f===`gate`?`Asking the gate…`:f===`run`||m||t.starting?`Starting…`:t.resumable?`Resume`:N?.label??`Run`}),ne&&!_&&!t.running&&t.resume&&t.resume.ended!==`handoff`&&(0,I.jsx)(`button`,{className:`btn`,ref:C,disabled:B!==null,"aria-disabled":x||void 0,"aria-busy":f===`fresh`,title:B?`The run gate refuses it now: ${B}`:`A new agent session: the kept one, and what it knew, is dropped`,onClick:()=>x||void D(),children:f===`fresh`?`Asking the gate…`:`Start fresh`}),!t.running&&te.filter(e=>!e.rare).map(e=>(0,I.jsx)(`button`,{className:Or(e),title:e.help,disabled:x,onClick:()=>H(e),children:e.label},e.cmd)),te.some(e=>e.rare)&&(0,I.jsxs)(`button`,{className:`btn-line`,"aria-expanded":u,onClick:()=>d(!u),children:[u?`▾`:`▸`,` More`]}),u&&te.filter(e=>e.rare).map(e=>(0,I.jsx)(`button`,{className:Or(e),title:e.help,disabled:x,onClick:()=>H(e),children:e.label},e.cmd))]})]}),(0,I.jsx)(`div`,{role:`tablist`,className:`d-tabs`,children:sb.filter(e=>e!==`lessons`||j.sections.lessons).map(e=>(0,I.jsxs)(`button`,{role:`tab`,"aria-selected":e===a,onClick:()=>o(e),children:[e[0].toUpperCase()+e.slice(1),e===`lessons`?` (${M.length})`:``]},e))}),(0,I.jsx)(`div`,{className:`d-body`,children:(0,I.jsxs)(`div`,{role:`tabpanel`,className:`d-panel ${a===`chat`&&!l?`chat`:``}`,children:[a===`status`&&(0,I.jsxs)(I.Fragment,{children:[t.run_end&&!t.running&&(0,I.jsx)(uy,{ctx:e,id:t.id,end:t.run_end}),L&&(0,I.jsxs)(`div`,{role:`note`,className:`d-blocked`,children:[(0,I.jsx)(`span`,{children:`! Blocked`}),(0,I.jsx)(`span`,{children:L}),t.denied_group&&(0,I.jsxs)(`div`,{className:`d-allow`,children:[(0,I.jsx)(`button`,{className:`btn-primary`,ref:C,"aria-disabled":x||void 0,"aria-busy":f===`allow`,title:`Three steps in one: the deny group ${t.denied_group} off for every agent run (Agent permissions turns it back on), the unblock, the run`,onClick:()=>x||void O(),children:f===`allow`?`Allowing…`:`Allow ${t.denied_group} and run again`}),(0,I.jsx)(`span`,{className:`dim small`,children:`the group off, the unblock, the run`})]})]}),B?(0,I.jsxs)(`div`,{className:`d-waits`,children:[`⧗ the run gate refuses it now: `,B]}):R.length>0&&(0,I.jsxs)(`div`,{className:`d-waits`,children:[`⧗ waits for `,R.join(`, `),` — the run gate would refuse it now`]}),t.running&&ce&&(0,I.jsxs)(`div`,{className:`d-run`,children:[(0,I.jsx)(`div`,{className:`d-run-head`,children:`This run`}),(0,I.jsxs)(`div`,{className:`live-plan`,title:`Plan checkboxes done / total`,children:[(0,I.jsx)(`span`,{children:`tasks`}),(0,I.jsx)(`span`,{className:`bar`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{style:{width:`${Math.round(100*ce.done/Math.max(1,ce.tasks))}%`}})}),(0,I.jsxs)(`span`,{className:`mono`,children:[ce.done,` of `,ce.tasks]})]})]}),(0,I.jsxs)(`dl`,{className:`facts`,children:[me.map(n=>n===ue[0]?(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:ue.map(e=>e.label).join(` / `)}),(0,I.jsxs)(`dd`,{title:ue.map(fe).join(` · `),children:[ue.map(de).join(` / `),pe&&(0,I.jsx)(`button`,{className:`link-btn`,title:pe.help,onClick:()=>H(pe),children:`change`})]})]},n.key):(0,I.jsxs)(`div`,{title:n.help,children:[(0,I.jsx)(`dt`,{children:n.label}),(0,I.jsxs)(`dd`,{title:Lr(n,Ir(t,n)??``),children:[(0,I.jsx)(Ab,{ctx:e,item:t,f:n}),U(n)&&(0,I.jsx)(`button`,{className:`link-btn`,title:U(n)?.help,onClick:()=>H(U(n)),children:`change`})]})]},n.key)),t.since&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`waits since`}),(0,I.jsxs)(`dd`,{title:t.since,children:[t.since_at?`${ai(t.since_at)} · `:``,(0,I.jsx)(`span`,{className:`mono`,children:t.since.slice(0,7)})]})]})]}),gb(e)&&(0,I.jsx)(Pb,{ctx:e,item:t}),(t.attachments??[]).length>0&&(0,I.jsx)(`div`,{className:`entry-atts`,role:`group`,"aria-label":`Attachments`,children:(t.attachments??[]).map(t=>(0,I.jsxs)(`a`,{className:`entry-att`,title:t,href:ee(e.project.name,t),target:`_blank`,rel:`noreferrer`,children:[`▣ `,t.split(`/`).pop()]},t))})]}),a===`lessons`&&(0,I.jsxs)(`div`,{className:`d-lessons`,children:[!M.length&&(0,I.jsx)(`span`,{className:`d-lessons-none`,children:`No lesson from its sessions yet.`}),M.map(t=>(0,I.jsx)(Mb,{ctx:e,e:t},t.id))]}),l&&(0,I.jsx)(zb,{id:t.id,part:l,onClear:()=>c(null)}),a===`chat`&&(l?(0,I.jsx)(kb,{ctx:e,id:t.id,part:l}):(0,I.jsx)(Jy,{ctx:e,item:t})),a===`file`&&(0,I.jsx)(yb,{ctx:e,item:t}),a===`plan`&&(0,I.jsx)(bb,{ctx:e,item:t}),a===`log`&&(l?(0,I.jsx)(Tb,{ctx:e,id:t.id,part:l}):(0,I.jsx)(wb,{ctx:e,item:t})),a===`history`&&(0,I.jsx)(Lb,{ctx:e,id:t.id,onPart:e=>{c(e),o(e.kind)}}),a===`related`&&(0,I.jsx)(Rb,{ctx:e,item:t})]})})]})}function Ub({ctx:e}){let{history:t=[],graveyard:n=[]}=e.board,{sections:r}=e.board.domain;return(0,I.jsxs)(`section`,{className:`page ended`,"aria-label":`Ended`,children:[r.history&&(0,I.jsxs)(`section`,{"aria-label":r.history.label??`History`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[r.history.label??`History`,(0,I.jsx)(`span`,{className:`dim`,children:t.length}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),!t.length&&(0,I.jsx)(`p`,{className:`dim small`,children:`Nothing ended yet.`}),t.length>0&&(0,I.jsx)(`div`,{className:`ended-list`,children:[...t].reverse().map((t,n)=>(0,I.jsxs)(`button`,{className:`ended-row`,title:`Open its History`,onClick:()=>e.openItem(t.id),children:[(0,I.jsx)(`span`,{className:`mono`,children:t.id}),(0,I.jsx)(`span`,{className:`ok-text small`,title:`What ended it`,children:t.event}),(0,I.jsx)(`span`,{className:`mono dim small`,children:t.date})]},`${t.id}-${n}`))})]}),r.graveyard&&(0,I.jsxs)(`section`,{"aria-label":r.graveyard.label??`Graveyard`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[r.graveyard.label??`Graveyard`,(0,I.jsx)(`span`,{className:`dim`,children:n.length}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),!n.length&&(0,I.jsx)(`p`,{className:`dim small`,children:`Nothing was killed or dropped.`}),[...n].reverse().map((t,n)=>(0,I.jsxs)(`button`,{className:`grave-row`,title:`Open its History`,onClick:()=>e.openItem(t.id),children:[(0,I.jsxs)(`div`,{className:`grave-line`,children:[t.type&&(0,I.jsx)(`span`,{className:`mono dim small`,title:t.type,children:t.type.slice(0,3).toUpperCase()}),(0,I.jsx)(`span`,{className:`mono grave-id`,children:t.id}),t.tags.map(e=>(0,I.jsxs)(`span`,{className:`mono small entry-tag`,children:[`#`,e]},e))]}),t.reason&&(0,I.jsx)(`p`,{children:t.reason})]},`${t.id}-${n}`))]})]})}var Wb=60;function Gb(e,t){let n=[...e.items].filter(e=>e.id!==t).sort((e,t)=>Number(e.priority===null)-Number(t.priority===null)||(e.priority??0)-(t.priority??0)).map(t=>({id:t.id,title:t.title??``,kind:t.type.slice(0,3).toUpperCase(),state:na(e,t),tone:t.running?`running`:t.status})),r=(e.units??[]).map(e=>({id:e.id,title:e.title??``,kind:`unit`,state:ta(e),tone:e.ready?`ok`:`warn`}));return[...n,...r]}function Kb({board:e,value:t,self:n,onChange:r,inputId:i,folded:a=!1}){let[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!a),u=o.trim().toLowerCase(),d=Gb(e,n),f=d.filter(e=>!u||e.id.includes(u)||e.title.toLowerCase().includes(u)),p=f.slice(0,u?40:Wb),m=e=>{r(t.includes(e)?t.filter(t=>t!==e):[...t,e]),s(``)},h=e=>d.find(t=>t.id===e)?.title;return(0,I.jsxs)(`div`,{className:`picker`,children:[(0,I.jsxs)(`div`,{className:`picker-chips`,children:[!t.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`no dependency`}),t.map(t=>{let r=ra(e,t),i=t===n||r.kind===`unknown`||r.kind===`grave`,a=t===n?`itself`:r.state,o=h(t);return(0,I.jsxs)(`span`,{className:`picker-chip ${i?`bad`:``}`,title:a,children:[o?`${Rr(o,48)} (${t})`:t,(0,I.jsx)(`span`,{className:`dim`,children:a}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`Take ${o||t} out`,onClick:()=>m(t),children:`×`})]},t)}),(0,I.jsx)(`button`,{type:`button`,className:`picker-fold`,"aria-expanded":c,title:c?`Fold the list; the picked ones stay`:`Open the list of items and design units`,onClick:()=>l(!c),children:c?`▾ Hide the list`:`▸ Pick by title`})]}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{id:i,className:`input`,value:o,"aria-label":`Search items and design units`,placeholder:`search items and design units by title`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),p.length===1&&m(p[0].id))}}),(0,I.jsxs)(`div`,{role:`listbox`,"aria-multiselectable":!0,"aria-label":`Items and design units`,className:`picker-list`,children:[p.map(e=>{let n=t.includes(e.id);return(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:`picker-row`,onClick:()=>m(e.id),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:n?`☑`:`☐`}),(0,I.jsx)(`span`,{className:`mono dim`,children:e.kind}),(0,I.jsxs)(`span`,{className:`picker-label`,children:[e.title||e.id,` `,e.title&&(0,I.jsxs)(`span`,{className:`mono dim`,children:[`(`,e.id,`)`]})]}),(0,I.jsx)(`span`,{className:`picker-state tone-${e.tone}`,children:e.state})]},`${e.kind}:${e.id}`)}),!p.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`nothing matches`}),f.length>p.length&&(0,I.jsxs)(`span`,{className:`dim small`,children:[f.length-p.length,` more: type to narrow`]})]}),(0,I.jsxs)(`span`,{className:`dim small`,children:[t.length,` `,t.length===1?`dependency`:`dependencies`]})]})]})}function qb({ctx:e,id:t,current:n,open:r,onClose:i}){let{move:a,values:o={}}=r,[s,c]=(0,v.useState)(()=>[...new Set([...n,...Mr(o.add)].filter(e=>!Mr(o.remove).includes(e)))]),[l,u]=(0,v.useState)(!1),d=s.filter(e=>!n.includes(e)),f=n.filter(e=>!s.includes(e)),p=d.length>0||f.length>0;return(0,I.jsx)(R,{onClose:i,dirty:p,children:(0,I.jsxs)(`form`,{className:`dialog wide`,role:`dialog`,"aria-modal":!0,"aria-label":`Dependencies of ${t}`,onClick:e=>e.stopPropagation(),onSubmit:async n=>{n.preventDefault();let[s,c]=!p&&r.extra?[Mr(o.add),Mr(o.remove)]:[d,f];if(!s.length&&!c.length)return i();u(!0);let l=await e.move({cmd:a.cmd,id:t,...s.length?{add:s}:{},...c.length?{remove:c}:{},...r.extra});u(!1),l&&i()},children:[(0,I.jsxs)(`h2`,{children:[`Dependencies of `,t]}),(0,I.jsxs)(`p`,{className:`dialog-body`,children:[r.body?`${r.body} `:a.help?`${a.help}. `:``,`Tick what it waits for, untick what it no longer does. The framework refuses the item itself, a graveyard line and a cycle.`]}),(0,I.jsx)(Kb,{board:e.board,value:s,self:t,onChange:c}),(0,I.jsxs)(`div`,{className:`dialog-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`btn-line`,onClick:i,disabled:l,children:`Cancel`}),(0,I.jsx)(`button`,{type:`submit`,className:`btn-primary`,disabled:l,children:l?`Committing…`:`Save`})]})]})})}var Jb={tags:[`tags`,`short words, comma-separated`],list:[`one per line`,`a list: one entry per line`],slug:[`slug`,`lowercase letters, digits and hyphens`]},Yb=[{value:``,label:`By the rule (default)`,help:`the command's own rule: a removal item when the item's code is in main`},{value:`yes`,label:`Yes, its code is in main`,help:`a new item deletes its code from the main build`},{value:`no`,label:`No`,help:`no removal item`}],Xb=`The phase's exit gate reads it: milestone-done closes the phase when nothing open of its milestone is left`,Zb=(e,t)=>t.from===`milestones`?sr(e)?.milestones??null:null,Qb={you:`you`,agent:`an agent`,automation:`automation`};function $b({id:e,rows:t,value:n,onChange:r}){return(0,I.jsx)(`select`,{id:e,className:`input`,value:n,onChange:e=>r(e.target.value),children:t.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function ex({id:e,board:t,value:n,onChange:r}){let[i,a]=(0,v.useState)(``),o=Br(t),s=Mr(n),c=i.trim().toLowerCase(),l=o.filter(e=>!s.includes(e)&&(!c||e.includes(c))).slice(0,14),u=c!==``&&!o.includes(c)&&!s.includes(c),d=u&&zr.test(c),f=(e,t)=>{r((t?[...s,e]:s.filter(t=>t!==e)).join(`, `)),t&&a(``)};return(0,I.jsxs)(`div`,{className:`picker`,children:[(0,I.jsxs)(`div`,{className:`picker-chips`,children:[s.map(e=>(0,I.jsxs)(`span`,{className:`picker-chip mono`,children:[e,!o.includes(e)&&(0,I.jsx)(`span`,{className:`f-new`,children:`new`}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`Take ${e} out`,onClick:()=>f(e,!1),children:`×`})]},e)),!s.length&&(0,I.jsx)(`span`,{className:`dim small`,children:`no subsystem`})]}),(0,I.jsx)(`input`,{id:e,className:`input mono f-search`,value:i,"aria-label":`Subsystems`,placeholder:`search the known subsystems, or type a new slug`,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.key===`Enter`||e.key===`,`)&&(e.preventDefault(),d?f(c,!0):l.length===1&&f(l[0],!0))}}),(0,I.jsxs)(`div`,{className:`f-sugg`,children:[d&&(0,I.jsxs)(`button`,{type:`button`,className:`new`,onClick:()=>f(c,!0),children:[`+ new subsystem “`,c,`”`]}),l.map(e=>(0,I.jsxs)(`button`,{type:`button`,onClick:()=>f(e,!0),children:[`+ `,e]},e))]}),u&&!d&&(0,I.jsx)(`span`,{role:`alert`,className:`f-warn`,children:`a new subsystem is a slug: lowercase letters, digits and hyphens`})]})}function tx({field:e,options:t,value:n,onChange:r}){return(0,I.jsx)(`div`,{role:`radiogroup`,"aria-label":e.label,className:`f-choice ${t.length>4?`wrap`:``}`,children:t.map(e=>(0,I.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n===e.value,title:e.help,onClick:()=>r(e.value),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:n===e.value?`●`:`○`}),(0,I.jsxs)(`span`,{children:[e.label||e.value||`—`,e.help&&(0,I.jsx)(`small`,{children:e.help})]})]},e.value))})}function nx({id:e,field:t,value:n,onChange:r,presets:i,board:a,self:o,newItem:s,details:c}){if(t.kind===`file`)return(0,I.jsx)(ix,{id:e,value:n,onChange:r});let l=Array.isArray(n)?n.join(`
86
+ `):String(n??``);if(t.kind===`ids`&&t.single)return(0,I.jsx)($b,{id:e,rows:Hr(a,t,l),value:l,onChange:r});if(t.kind===`ids`)return(0,I.jsx)(Kb,{board:a,inputId:e,value:Mr(l),self:o,folded:s,onChange:e=>r(e.join(`, `))});if(s&&t.key===`system`)return(0,I.jsx)(ex,{id:e,board:a,value:l,onChange:r});if(c)return(0,I.jsx)(tx,{field:t,options:[{value:``,label:`no detail`},...c.map(e=>({value:e,label:e}))],value:l,onChange:r});if(t.presets)return(0,I.jsx)(Ei,{id:e,what:t.presets,presets:i?.[t.presets]??[],value:l,project:Si(a,t.presets),fallback:Ci(a,t.presets),onChange:r});let u=Zb(a,t);if(u)return(0,I.jsx)($b,{id:e,rows:Vr(u,l),value:l,onChange:r});let d=[`slug`,`ids`,`tags`].includes(t.kind)?`mono`:``;if(t.kind===`remove`)return(0,I.jsx)(tx,{field:t,options:Yb,value:n===!0?`yes`:n===!1?`no`:``,onChange:e=>r(e===`yes`||e!==`no`&&void 0)});if(t.kind===`choice`){let e=t.options??[];return(0,I.jsx)(tx,{field:t,options:e,value:l,onChange:r})}let f=t.kind===`tags`?Mr(l).map(e=>({label:`#${e}`,tip:`tag`})):[];return(0,I.jsxs)(I.Fragment,{children:[t.kind===`longtext`||t.kind===`list`?(0,I.jsx)(`textarea`,{id:e,className:`input`,value:l,required:t.required,rows:t.kind===`longtext`?4:3,placeholder:t.kind===`list`?`one per line`:void 0,onChange:e=>r(t.kind===`list`?e.target.value.split(`
87
+ `):e.target.value)}):(0,I.jsx)(`input`,{id:e,className:`input ${d}`,value:l,required:t.required,list:t.kind===`text`&&t.key===`id`?`move-form-ids`:void 0,pattern:t.kind===`slug`?`[a-z0-9]+(-[a-z0-9]+)*`:void 0,placeholder:t.kind===`tags`?`feel, touch`:t.kind===`slug`?`win-feedback`:void 0,onChange:e=>r(e.target.value)}),f.length>0&&(0,I.jsx)(`div`,{className:`f-chips`,children:f.map((e,t)=>(0,I.jsx)(`span`,{title:e.tip,children:e.label},t))})]})}var rx=10485760;function ix({id:e,value:t,onChange:n}){let[r,i]=(0,v.useState)(``),a=typeof t==`string`?t.split(/[\\/]/).pop():t?.name;return(0,I.jsxs)(`div`,{className:`f-file`,children:[(0,I.jsxs)(`label`,{className:`f-file-btn`,children:[(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M20 11.5l-8.2 8.2a5 5 0 0 1-7.1-7.1l8.6-8.6a3.4 3.4 0 0 1 4.8 4.8l-8.6 8.6a1.7 1.7 0 0 1-2.4-2.4l7.9-7.9`})}),a?`Another file…`:`Choose a file…`,(0,I.jsx)(`input`,{id:e,type:`file`,onChange:async e=>{let t=e.target.files?.[0];if(e.target.value=``,t){if(t.size>rx)return i(`${t.name}: over 10 MB, the most an attachment takes`);i(``),n({name:t.name,data:await Pr(t)})}}})]}),(0,I.jsx)(`span`,{className:`f-file-name ${a?`mono`:`dim`}`,title:a,children:a??`no file yet`}),r&&(0,I.jsx)(`span`,{className:`f-err`,children:r})]})}var ax=e=>(Array.isArray(e)?e.join(`
88
+ `):String(e??``)).trim();function ox({ctx:e,open:t,onClose:n}){let{move:r}=t,{domain:i}=e.board,a=(0,v.useId)(),o=r.cmd===i.new_item,s=o&&r.fields.some(e=>e.key===`blocked`),c=i.sections.inbox,l=r.cmd===c?.category?(e.board.inbox??[]).find(e=>e.id===t.id):void 0,[u]=(0,v.useState)(()=>Fr(r.fields,l?{category:l.category,detail:l.detail??``,...t.values}:t.values)),[d,f]=(0,v.useState)(u),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(void 0),[S,C]=(0,v.useState)(()=>ax(u.blocked)?!0:null),w=S??d.type===`asset`,T=e=>c?.categories?.find(t=>t.id===e),E=l?T(d.category):void 0,D=(e,t)=>{g(``),y(!1),x(void 0),f(l&&e===`category`?{...d,category:t,detail:t===l.category?l.detail??``:``}:{...d,[e]:t})},O=t.body??(l?`${r.help?`${r.help}. `:``}Now ${T(l.category)?.label??l.category}${l.detail?` · ${l.detail}`:``}, from ${Qb[l.origin]??l.origin}${l.item?` on ${l.item}`:``}: the origin stays.${E&&!E.later&&l.later?` ${E.label} never waits in Later: it leaves Later.`:``}`:o?ax(u.from)?`From ${ax(u.from)}: its first line is the title, the rest the note. The entry is erased when the item is created.`:`Created and committed at once. Its id comes from the title.`:r.help),k=new Map(e.board.items.map(e=>[e.id,e.running?`running`:e.status])),A=t.id?e.board.items.find(e=>e.id===t.id):void 0,ee=r.fields.some(e=>e.required&&jr(e,d)&&(e.kind===`choice`&&!ax(d[e.key])||e.kind===`file`&&d[e.key]===void 0)),j=async i=>{i.preventDefault(),x(void 0);let a=Nr(r.fields,d);if(s&&!w)delete a.blocked;else if(s&&!ax(d.blocked))return g(`Start blocked: say what it waits for`);m(!0);let o=await e.moveIn({cmd:r.cmd,id:t.id,...a,...t.extra});m(!1),o.ok?n():(g(o.err),y(o.refused),x(o.refusal))},M=t=>{if(Zb(e.board,t))return Xb;if(t.kind===`ids`&&t.single)return`one live ${(t.of??[`item`]).join(` or `)}, by its title`;if(E?.details&&t.key===`detail`)return`${E.label} takes one of its own details`;if(o&&t.key===`system`||s&&t.key===`blocked`)return;if(t.excuses!==`plan`||!A)return t.help;let n=A.plan;return n?`error`in n?`the plan cannot be read: ${n.error}`:n.tasks-n.done?`${n.tasks-n.done} of ${n.tasks} plan tasks are unticked: say why it goes anyway`:`every plan task is ticked: leave it empty`:`the item has no plan file`};return(0,I.jsx)(R,{onClose:n,dirty:Object.entries(d).some(([e,t])=>ax(t)!==ax(u[e])),children:(0,I.jsxs)(`form`,{className:`dialog ${r.fields.length>6?`wide`:``}`,role:`dialog`,"aria-modal":!0,"aria-label":t.title,onClick:e=>e.stopPropagation(),onSubmit:j,children:[(0,I.jsx)(`h2`,{children:t.title}),O&&(0,I.jsx)(`p`,{className:`dialog-body`,children:O}),(0,I.jsx)(`datalist`,{id:`move-form-ids`,children:[...k.keys()].map(e=>(0,I.jsx)(`option`,{value:e},e))}),r.fields.filter(e=>!e.hidden&&jr(e,d)).map(n=>{let r=`${a}-${n.key}`,i=Jb[n.kind],c=ax(d[n.key]),l=M(n),u=E&&n.key===`detail`?E.details:null,f=s&&n.key===`blocked`?`Waits for something outside`:o&&n.key===`system`?n.label.replace(/, comma-separated/i,``):n.label;return(0,I.jsxs)(`div`,{className:`f-field`,children:[(0,I.jsxs)(`span`,{className:`f-label`,children:[n.kind===`choice`||n.kind===`remove`||u?(0,I.jsxs)(`span`,{className:`f-label-text`,title:n.help,children:[f,n.required?` (required)`:``]}):(0,I.jsxs)(`label`,{htmlFor:r,title:n.help,children:[f,n.required?` (required)`:``]}),i&&(0,I.jsx)(`span`,{title:i[1],children:i[0]})]}),s&&n.key===`blocked`?(0,I.jsxs)(`div`,{className:`f-check`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>{g(``),C(e.target.checked)}}),(0,I.jsx)(`span`,{children:`Start blocked`})]}),w&&(0,I.jsx)(`input`,{id:r,className:`input`,value:c,"aria-label":`Why it starts blocked`,placeholder:d.type===`asset`?`file needed: the final lock icon`:`what it waits for`,onChange:e=>D(n.key,e.target.value)}),(0,I.jsx)(`span`,{className:`field-help`,children:w?`It is created blocked with this reason: the runner takes it only after Unblock. A file brought later: Unblock with file: <path>, and its run takes it in.`:`Off: it is created ready. On: it waits for something outside, a file, an answer, an access.`})]}):(0,I.jsx)(nx,{id:r,field:n,value:d[n.key],presets:e.board.presets,board:e.board,self:t.id??ax(d.id),newItem:o,details:u,onChange:e=>D(n.key,e)}),l&&n.kind!==`choice`&&!n.presets&&(0,I.jsx)(`span`,{className:`field-help`,children:l}),n.max&&!u&&(0,I.jsxs)(`span`,{"aria-live":`polite`,className:`f-count ${c.length>n.max?`over`:``}`,children:[c.length,` / `,n.max]})]},n.key)}),h&&(b?(0,I.jsx)(y_,{ctx:e,refusal:b,error:h}):(0,I.jsx)(B,{error:h,refused:_})),(0,I.jsxs)(`div`,{className:`dialog-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`btn-line`,onClick:n,disabled:p,children:`Cancel`}),(0,I.jsx)(`button`,{type:`submit`,className:r.danger?`btn-danger`:`btn-primary`,disabled:p||ee,children:p?`Running…`:r.label})]})]})})}function sx({ctx:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),l=(0,v.useRef)(0),{project:u,notify:d,board:f}=e,p=f.domain.sections.playtest,m=f.settings?.find(e=>e.key===`tune_limit`),h=m?m.value??m.default:null,g=Tr(f.domain,f.domain.sections.inbox?.add),_=p?.category,y=JSON.stringify(f.items.filter(e=>(p?.waits??[]).includes(e.status)));(0,v.useEffect)(()=>{let e=++l.current;k.playtest(u.name).then(t=>e===l.current&&n(t),e=>d(e.message,`error`))},[y,u.name,d]);let b=async()=>{await ie(`Run the project's build command (dod.build)? It can take minutes.`,`Build`)&&(o(!0),await k.playtestBuild(u.name).then(e=>i(e),e=>d(e.message,`error`)),o(!1))};if(!t)return(0,I.jsx)(`div`,{className:`page`,role:`status`,children:(0,I.jsx)(`p`,{className:`dim`,children:`Reading the session…`})});let x=new Map;for(let e of t.items){let t=e.system[0]??`(no system)`;x.set(t,[...x.get(t)??[],e])}let S=r?.commit===t.commit?r.build:null,C=[(t.main?t.branch!==t.main:/^(HEAD|work\/)/.test(t.branch??``))?`not ${t.main??`main`}: a build of another branch`:null,t.dirty?`uncommitted changes`:null].filter(Boolean);return(0,I.jsxs)(`section`,{className:`page playtest`,"aria-label":`Playtest`,children:[(0,I.jsxs)(`div`,{className:`page-head`,children:[(0,I.jsx)(`h1`,{children:`Playtest`}),(0,I.jsxs)(`p`,{children:[`Build, play, then judge each item. `,t.items.length,` wait`,t.items.length===1?`s`:``,` for you.`]})]}),(0,I.jsxs)(`section`,{className:`pt-build`,"aria-label":`The build to play`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`pt-build-label`,children:`The build to play`}),(0,I.jsxs)(`span`,{className:`mono pt-build-ref`,children:[t.branch,` · `,t.commit]}),(0,I.jsx)(`span`,{className:C.length?`warn-text`:`dim small`,children:C.length?C.join(` · `):`no warnings: on main, nothing uncommitted`}),(0,I.jsx)(`span`,{role:`status`,className:`mono small ${S?S.ok?`ok-text`:`error-text`:`dim`}`,children:S?S.skipped?`no build command: dod.build is not set`:S.ok?`built: green`:`build failed: ${S.problems.join(`; `)}`:`not built in this session`})]}),(0,I.jsxs)(`button`,{className:`btn-primary pt-build-btn`,disabled:a,onClick:()=>void b(),children:[a&&(0,I.jsx)(`span`,{className:`dot pulse`,"aria-hidden":`true`}),a?`Building…`:`Build`]})]}),(t.milestones??[]).map(n=>{let r=f.milestones?.find(e=>e.name===n.name),i=r?.ids??[],a=r?.units??[],o=t.platforms?.length?t.platforms:[...new Set(i.flatMap(e=>f.items.find(t=>t.id===e)?.play_on??[]))];return(0,I.jsxs)(`section`,{className:`pt-ms`,"aria-label":`Milestone ${n.name}`,children:[(0,I.jsxs)(`div`,{className:`pt-ms-top`,children:[(0,I.jsxs)(`div`,{className:`pt-ms-head`,children:[(0,I.jsxs)(`div`,{className:`pt-ms-line`,children:[(0,I.jsx)(`span`,{className:`pt-ms-cap`,children:`Milestone`}),(0,I.jsx)(`span`,{className:`pt-ms-name`,children:n.name}),(0,I.jsx)(`span`,{className:`pt-ms-state ${r?.built?`built`:``}`,children:r?.played?`played`:r?.built?`built`:`building`}),(0,I.jsxs)(`span`,{className:`pt-ms-counts`,children:[n.to_play,` to play`,n.building||n.blocked?` · still building ${n.building}${n.blocked?`, blocked ${n.blocked}`:``}`:``]})]}),n.goal&&(0,I.jsx)(`span`,{className:`pt-ms-goal`,children:n.goal})]}),(0,I.jsxs)(`button`,{className:`btn-ok pt-ms-keep`,title:`Keep every item of it that waits for play, in one commit (verdict keep --milestone); tune or kill an item on its own first`,onClick:()=>void(async()=>{await ie(`Keep milestone ${n.name}: every item of it that waits for play?`,`Keep`)&&await e.move({cmd:`milestone-keep`,id:n.name})})(),children:[`Keep `,n.name]})]}),n.play&&(0,I.jsxs)(`div`,{className:`pt-ms-play`,children:[(0,I.jsx)(`span`,{children:`play:`}),(0,I.jsx)(`span`,{children:n.play})]}),(0,I.jsxs)(`div`,{className:`pt-ms-where`,children:[(0,I.jsx)(`span`,{children:`where to play`}),(0,I.jsx)(`span`,{title:`A hint, never a condition: the session's platforms, else its items' play_on`,children:o.length?o.join(` · `):`no platforms in the read`})]}),a.length>0&&(0,I.jsxs)(`span`,{className:`pt-ms-units`,children:[a.length,` design unit`,a.length>1?`s`:``,` not carded:`,` `,a.map(e=>e.id).join(`, `)]}),i.length>0&&(0,I.jsx)(`div`,{role:`list`,className:`pt-ms-rows`,children:i.map(t=>{let n=f.items.find(e=>e.id===t),r=f.domain.columns.find(e=>e.status===n?.status),i=n?.play_on??[];return(0,I.jsxs)(`div`,{role:`listitem`,className:`pt-ms-row ${e.itemOpen===t?`on`:``}`,children:[(0,I.jsxs)(`button`,{disabled:!n,onClick:()=>n&&e.openItem(t,`file`),children:[(0,I.jsx)(`span`,{className:`mono strong`,children:t}),n?.title&&(0,I.jsx)(`span`,{children:n.title})]}),(0,I.jsx)(`span`,{className:`pt-ms-st`,children:n?`${n.running?`running`:r?.label??n.status} on this board`:`not on the board`}),(0,I.jsxs)(`span`,{className:`pt-ms-on`,children:[`Play on `,(0,I.jsx)(`span`,{children:i.length?i.join(` · `):`—`})]})]},t)})})]},n.name)}),!t.items.length&&(0,I.jsx)(`div`,{className:`empty-box`,children:`Nothing waits for play.`}),[...x].map(([t,n])=>(0,I.jsxs)(`section`,{className:`pt-group`,"aria-label":t,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[t,(0,I.jsx)(`span`,{className:`dim`,children:n.length}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`wide-only`,children:(0,I.jsx)(Pa,{children:n.map(t=>{let n=f.items.find(e=>e.id===t.id),r=f.domain.columns.find(e=>e.status===t.status),i=[(t.play_on??[]).length?`play on ${(t.play_on??[]).join(`, `)}`:``,t.status===`unplayed`?`unplayed: nobody played it yet`:r?.label??t.status,n?.since?`built at ${n.since.slice(0,7)}`:``,n?.tune_count?`tuned ${n.tune_count}${h?` of ${h}`:`×`}`:``];return(0,I.jsx)(Ma,{cat:n?`${n.type.slice(0,3).toUpperCase()} · ${n.gate}`:t.id,tone:n?.gate,origin:n?.running?`running`:r?.label??t.status,title:t.title??t.id,sub:i.filter(Boolean).join(` · `),mark:t.title?t.id:``,needs:n?G(n,f):!1,on:e.itemOpen===t.id,onOpen:()=>e.openItem(t.id,`file`)},t.id)})})}),(0,I.jsx)(`div`,{className:`phone-only pt-rows`,children:n.map(t=>{let n=f.items.find(e=>e.id===t.id),r=n?Er(n,f.domain).filter(e=>p?.verdicts.includes(e.cmd)):[],i=f.domain.columns.find(e=>e.status===t.status);return(0,I.jsxs)(`div`,{className:`pt-item gate-${n?.gate??``}`,children:[(0,I.jsxs)(`button`,{className:`pt-open`,onClick:()=>e.openItem(t.id),children:[(0,I.jsx)(`span`,{className:`mono pt-id`,children:t.id}),(t.title??t.intent)&&(0,I.jsx)(`span`,{className:`pt-title`,children:t.title??t.intent}),(0,I.jsxs)(`span`,{className:`dim small`,children:[i?.label??t.status,n?.tune_count?` · tuned ${n.tune_count}×`:``]})]}),(0,I.jsxs)(`dl`,{className:`pt-check`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`Check`}),(0,I.jsx)(`dd`,{children:t.question})]}),t.reach.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`Get there`}),(0,I.jsx)(`dd`,{children:t.reach.join(`; `)})]}),t.feel.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`Feel`}),(0,I.jsx)(`dd`,{children:t.feel.join(`; `)})]}),(t.play_on??[]).length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:`Play on`}),(0,I.jsx)(`dd`,{children:(t.play_on??[]).join(`; `)})]})]}),(0,I.jsx)(`div`,{className:`pt-acts`,children:r.map(n=>(0,I.jsx)(`button`,{className:Or(n),title:n.help,onClick:()=>e.openMove({title:`${n.label} ${t.id}`,id:t.id,move:n}),children:n.label},n.cmd))})]},t.id)})})]},t)),g&&_&&(0,I.jsxs)(`section`,{className:`pt-note`,"aria-label":`A note from the playtest`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`A note from the playtest`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),s.trim()&&await e.move({cmd:g.cmd,text:s,category:_})&&c(``)},children:[(0,I.jsx)(`textarea`,{className:`input`,"aria-label":`A note from the playtest`,rows:2,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},title:`Ctrl+Enter adds`,placeholder:`What you noticed: it goes to the inbox as ${_}`}),(0,I.jsx)(`button`,{type:`submit`,className:`btn`,disabled:!s.trim(),children:`To the inbox`})]})]})]})}var cx=(e,t)=>e.kind===t.kind&&e.pattern===t.pattern;function lx({r:e}){return(0,I.jsxs)(`code`,{className:`rule-text`,children:[(0,I.jsxs)(`span`,{className:`dim`,children:[e.kind,`:`]}),` `,e.pattern]})}function ux({ctx:e}){let[t,n]=(0,v.useState)(``),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),s=e.board.agent,c=e.board.context;if(!s)return(0,I.jsx)(`div`,{className:`page`,children:(0,I.jsx)(`p`,{className:`dim`,children:`This core reports no agent permissions: update it.`})});let l=s.extra??[],u=(s.rules?.deny??[]).filter(e=>!l.some(t=>cx(t,e))),d=s.rules?.allow??[],f=async(t,n)=>{i(t);let r=await e.move({cmd:`permissions`,...n});return i(null),r};return(0,I.jsxs)(`section`,{className:`page agent`,"aria-label":`Agent`,children:[(0,I.jsxs)(`div`,{className:`page-head`,children:[(0,I.jsx)(`h1`,{children:`Agent`}),(0,I.jsx)(`p`,{children:`What agent runs may not do. A run allows everything but the deny rules. A deny rule stops an accident, not a rewording: an agent that means it can say the same thing another way.`})]}),(0,I.jsxs)(`section`,{"aria-label":`Deny groups`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Deny groups`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`ag-groups`,children:s.groups.map(e=>(0,I.jsxs)(`button`,{role:`checkbox`,"aria-checked":e.on,disabled:r!==null,className:`ag-group ${e.on?`on`:``}`,onClick:()=>void f(e.id,{[e.on?`off`:`on`]:[e.id]}),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:e.on?`☑`:`☐`}),(0,I.jsxs)(`span`,{className:`ag-group-label`,children:[e.label.split(`: `)[0],e.label.includes(`: `)&&(0,I.jsx)(`small`,{children:e.label.slice(e.label.indexOf(`: `)+2)})]}),(0,I.jsx)(`span`,{className:`ag-state`,children:r===e.id?`…`:e.on?`denied`:`allowed`})]},e.id))}),(0,I.jsx)(`span`,{className:`dim small`,children:`A command a run refused blocks its item with “needs permission: <command>”: untick its group, or remove the own rule that refused it, and run it again.`}),u.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{className:`btn-line ag-base`,"aria-expanded":a,onClick:()=>o(!a),children:[a?`▾`:`▸`,` the rules the ticked groups add · `,u.length]}),a&&(0,I.jsx)(`div`,{className:`ag-base-list`,children:u.map(e=>(0,I.jsx)(lx,{r:e},`${e.kind}:${e.pattern}`))})]})]}),(0,I.jsxs)(`section`,{"aria-label":`Own deny rules`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Own deny rules`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),!s.deny_extra.length&&(0,I.jsx)(`span`,{className:`dim`,children:`No own rule yet.`}),s.deny_extra.map((e,t)=>(0,I.jsxs)(`div`,{className:`ag-rule`,children:[l[t]?(0,I.jsx)(lx,{r:l[t]}):(0,I.jsx)(`code`,{className:`rule-text`,children:e}),l[t]&&`${l[t].kind}: ${l[t].pattern}`!==e&&(0,I.jsxs)(`span`,{className:`mono dim small`,title:`Claude's form is taken too; the list shows every rule neutral`,children:[`entered as `,e]}),(0,I.jsx)(Na,{label:`Remove the rule`,tip:`Remove · runs may do this again`,disabled:r!==null,onClick:()=>void f(`undeny:${e}`,{undeny:[e]})})]},e)),(0,I.jsxs)(`form`,{className:`ag-add`,onSubmit:async e=>{e.preventDefault(),t.trim()&&await f(`add`,{deny:[t.trim()]})&&n(``)},children:[(0,I.jsx)(`input`,{className:`input mono`,"aria-label":`A deny rule`,value:t,onChange:e=>n(e.target.value),placeholder:`shell: curl * · read: ~/.aws/** · mcp: server__tool · or Bash(curl *)`}),(0,I.jsx)(`button`,{type:`submit`,className:`btn`,disabled:!t.trim()||r!==null,children:r===`add`?`Adding…`:`Deny`})]}),(0,I.jsx)(`span`,{className:`dim small`,children:`Write it neutral, kind: pattern, with the kinds edit, shell, read, search, web, mcp, skill, subagent, other. Claude's form, Bash(curl *), is taken too. The core refuses a rule of neither form.`})]}),(0,I.jsxs)(`section`,{"aria-label":`Allow rules`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Allow rules`,(0,I.jsx)(`span`,{className:`dim sub`,children:`agent.allow in gcf/config.yml`}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),!d.length&&(0,I.jsx)(`span`,{className:`dim`,children:`No allow rule. Runs allow everything but the deny rules anyway; an allow rule lets an agent run without bypass skip asking. Always on a project chat card saves its rule in .claude/settings.local.json instead, for this machine.`}),d.map(e=>(0,I.jsx)(`div`,{className:`ag-rule`,children:(0,I.jsx)(lx,{r:e})},`${e.kind}:${e.pattern}`))]}),c&&(0,I.jsxs)(`section`,{"aria-label":`Context`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Context`,(0,I.jsx)(`span`,{className:`dim sub`,children:`read only · set in Settings`}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`ag-ctx`,children:[{key:`context_handoff_pct`,label:`handoff at`,value:c.handoff_pct?`${c.handoff_pct}%`:`never`,tip:`At this share of the window a session hands its item to a fresh one`},{key:`context_window`,label:`window`,value:c.window?`${c.window.toLocaleString()} tokens`:`the model's`,tip:`The context window the share is of`},{key:`auto_compact_pct`,label:`compacts at`,value:c.compact_pct?`${c.compact_pct}%`:`its own default`,tip:`Where the agent compacts its context`}].map(e=>(0,I.jsxs)(`div`,{className:`ag-ctx-box`,title:e.tip,children:[(0,I.jsx)(`span`,{children:e.label}),(0,I.jsx)(`span`,{className:`mono`,children:e.value}),(0,I.jsxs)(`code`,{children:[`gcf/config.yml · `,e.key]})]},e.key))})]})]})}var dx=`gcf-theme`;function fx(){try{let e=JSON.parse(localStorage.getItem(dx)??`null`);return e&&typeof e.id==`string`&&e.tokens&&typeof e.tokens==`object`?e:null}catch{return null}}var px=fx(),mx=new Set;function hx(e){px=e;try{e?localStorage.setItem(dx,JSON.stringify(e)):localStorage.removeItem(dx)}catch{}for(let e of mx)e()}var gx=()=>px,_x=()=>(0,v.useSyncExternalStore)(e=>(mx.add(e),()=>mx.delete(e)),gx),vx=[];function yx(e,t){for(let t of vx)e.style.removeProperty(t);vx=[];let n=[],r=getComputedStyle(e);for(let[i,a]of Object.entries(t?.tokens??{})){let t=`--gcf-${i}`;r.getPropertyValue(t)?(e.style.setProperty(t,a),vx.push(t)):n.push(i)}return document.body.style.background=t?.tokens.bg??``,document.documentElement.style.colorScheme=t?.scheme??``,n}function bx({ctx:e}){let t=e.board.settings;if(!t)return(0,I.jsxs)(`div`,{className:`page`,children:[(0,I.jsx)(Tx,{}),(0,I.jsx)(Ox,{}),(0,I.jsx)(`p`,{className:`dim`,children:`This core reports no settings: update it.`})]});let n=[...new Set(t.map(e=>e.group??`Settings`))];return(0,I.jsxs)(`section`,{className:`page settings`,"aria-label":`Settings`,children:[(0,I.jsxs)(`div`,{className:`page-head`,children:[(0,I.jsx)(`h1`,{children:`Settings`}),(0,I.jsx)(`p`,{children:`Every key of gcf/config.yml you set, and the agents' language. Save commits one key; the core refuses a value its rules do not take. An empty value goes back to the default.`})]}),(0,I.jsx)(Tx,{}),(0,I.jsx)(Ox,{}),n.map(n=>(0,I.jsxs)(`section`,{"aria-label":n,className:`set-group`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[n,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),n===`Autonomy`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`set-intro`,children:`Every stop that waits for you, for the whole project (gates: in gcf/config.yml). A card may hold its own gates. Each change is one commit.`}),(0,I.jsx)(Sx,{ctx:e,settings:t})]}),t.filter(e=>(e.group??`Settings`)===n).map(t=>n===`Autonomy`&&t.kind===`mode`&&t.options?(0,I.jsx)(Cx,{ctx:e,s:t},t.key):(0,I.jsx)(wx,{ctx:e,s:t},`${t.key}=${t.value}`))]},n))]})}var xx=[{name:`Careful`,help:`Every gate waits for you; the autopilot is off`,keys:{"gates.milestone":`wait`,"gates.verdict":`wait`,"gates.decision":`wait`,"gates.question":`wait`},pilot:!1},{name:`Autonomous`,help:`The agent decides its spikes and assumes instead of asking; it stops for a built milestone and an item’s own verdict; runs in worktrees; the autopilot is on`,keys:{"gates.milestone":`wait`,"gates.verdict":`wait`,"gates.decision":`agent`,"gates.question":`assume`,run_mode:`worktree`},pilot:!0}];function Sx({ctx:e,settings:t}){let n=e=>{let n=t.find(t=>t.key===e);return String(n?.value??n?.default??``)},r=e.board.runs?.autopilot?.on??!1,i=xx.find(e=>e.pilot===r&&Object.entries(e.keys).every(([e,t])=>n(e)===t)),a=async t=>{await e.move({cmd:`config-preset`,pairs:t.keys})&&r!==t.pilot&&await e.setAutopilot(t.pilot)};return(0,I.jsxs)(`div`,{className:`set-presets`,children:[(0,I.jsx)(`div`,{role:`group`,"aria-label":`Presets`,className:`set-preset-btns`,children:xx.map(e=>(0,I.jsx)(`button`,{className:i===e?`btn-primary`:`btn`,"aria-pressed":i===e,title:e.help,onClick:()=>void a(e),children:e.name},e.name))}),(0,I.jsxs)(`div`,{className:`set-preset-now`,children:[(0,I.jsx)(`span`,{className:i?``:`own`,title:i?`The keys match ${i.name}: ${i.help}`:`The keys match neither preset`,children:i?`now: ${i.name}`:`now: your own`}),(0,I.jsxs)(`span`,{className:`mono`,children:[`autopilot `,r?`on`:`off`,` · run_mode `,n(`run_mode`)||e.board.run_mode]})]}),(0,I.jsx)(`button`,{className:`btn-line set-preset-agent`,title:`The deny groups and rules the agent works under`,onClick:()=>e.go(`agent`),children:`Agent permissions`})]})}function Cx({ctx:e,s:t}){let[n,r]=(0,v.useState)(!1),i=String(t.value??t.default??``),a=t.options??[],o=async a=>{a===i||n||(r(!0),await e.move({cmd:`config-set`,key:t.key,value:a}),r(!1))};return(0,I.jsxs)(`div`,{className:`set-row set-gate`,children:[(0,I.jsxs)(`div`,{className:`set-what`,children:[(0,I.jsx)(`span`,{className:`mono`,children:t.key}),(0,I.jsx)(`span`,{children:t.label})]}),(0,I.jsxs)(`div`,{className:`set-how`,children:[(0,I.jsx)(`div`,{role:`radiogroup`,"aria-label":t.key,className:`set-seg`,onKeyDown:e=>{let t={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key];if(!t||!a.length||(e.preventDefault(),n))return;let r=(Math.max(0,a.indexOf(i))+t+a.length)%a.length;e.currentTarget.querySelectorAll(`[role="radio"]`)[r]?.focus(),o(a[r])},children:a.map((e,r)=>(0,I.jsx)(`button`,{role:`radio`,"aria-checked":e===i,"aria-disabled":n,tabIndex:e===i||!a.includes(i)&&r===0?0:-1,title:`gcf config set ${t.key} --value=${e}: one commit`,onClick:()=>void o(e),children:e},e))}),(0,I.jsxs)(`span`,{className:`dim small`,children:[t.value===null?`not set: the default holds (${t.default})`:`default ${t.default}`,` `,`· `,t.file??`gcf/config.yml`]})]})]})}function wx({ctx:e,s:t}){let n=t.value??(t.kind===`mode`?t.default:null),r=n===null?``:String(n),[i,a]=(0,v.useState)(r),[o,s]=(0,v.useState)(!1),c=i!==r,l=`set-${t.key}`,u=t.presets?Ci(e.board,t.presets):null,d=t.default===null||t.default===``?u?yi(u):t.kind===`word`?`the agent's`:`none`:`${t.default}${t.kind===`share`?`%`:``}`,f=t.options,p=async n=>{n.preventDefault(),s(!0),await e.move({cmd:`config-set`,key:t.key,value:i}),s(!1)},m=t.presets?(0,I.jsx)(Ei,{id:l,what:t.presets,presets:e.board.presets?.[t.presets]??[],value:i,fallback:u,autoValue:``,onChange:a}):f&&t.kind===`mode`?(0,I.jsx)(`select`,{id:l,className:`input mono`,value:i,onChange:e=>a(e.target.value),children:[...f,...i&&!f.includes(i)?[i]:[]].map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))}):f?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{id:l,className:`input mono`,value:i,list:`${l}-options`,onChange:e=>a(e.target.value),placeholder:`not set · default ${d}`}),(0,I.jsx)(`datalist`,{id:`${l}-options`,children:f.map(e=>(0,I.jsx)(`option`,{value:e},e))})]}):t.kind===`command`?(0,I.jsx)(`textarea`,{id:l,className:`input mono set-command`,rows:3,value:i,onChange:e=>a(e.target.value),placeholder:`not set`}):(0,I.jsx)(`input`,{id:l,className:`input mono`,value:i,onChange:e=>a(e.target.value),inputMode:t.kind===`number`||t.kind===`share`?`decimal`:`text`,placeholder:t.kind===`word`?`not set · ${d}`:`not set`});return(0,I.jsxs)(`form`,{className:`set-row`,onSubmit:p,children:[(0,I.jsxs)(`div`,{className:`set-what`,children:[(0,I.jsx)(`label`,{htmlFor:l,className:`mono`,children:t.key}),(0,I.jsx)(`span`,{children:t.label})]}),(0,I.jsxs)(`div`,{className:`set-how`,children:[(0,I.jsxs)(`div`,{className:`set-ctl`,children:[m,t.kind===`share`&&(0,I.jsx)(`span`,{className:`mono dim`,children:`%`}),(0,I.jsx)(`button`,{type:`submit`,className:`btn`,disabled:!c||o,title:`Commits gcf config set ${t.key} --value=…; the core refuses a value its rules do not take`,children:o?`Saving…`:`Save`})]}),(0,I.jsxs)(`span`,{className:`dim small`,children:[t.value===null?`not set: the default holds (${d})`:`default ${d}`,` `,`· `,t.file??`gcf/config.yml`]})]})]})}function Tx(){let e=_x(),[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(``);return(0,v.useEffect)(()=>{k.themes().then(n,e=>i(e.message))},[]),(0,I.jsxs)(`section`,{"aria-label":`Theme`,className:`set-group`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Board · this browser`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsxs)(`div`,{className:`set-row`,children:[(0,I.jsxs)(`div`,{className:`set-what`,children:[(0,I.jsx)(`label`,{htmlFor:`set-theme`,className:`mono`,children:`theme`}),(0,I.jsx)(`span`,{children:`Colours of the board in this browser. The phone and the desk can differ.`})]}),(0,I.jsxs)(`div`,{className:`set-how`,children:[(0,I.jsx)(`div`,{className:`set-ctl`,children:(0,I.jsxs)(`select`,{id:`set-theme`,className:`input`,value:e?.id??``,onChange:e=>{let n=t?.find(t=>t.id===e.target.value);hx(n&&`tokens`in n?n:null)},children:[(0,I.jsx)(`option`,{value:``,children:`Dark (built-in)`}),t?.map(e=>`tokens`in e?(0,I.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.scheme,`)`]},e.id):(0,I.jsxs)(`option`,{value:e.id,disabled:!0,children:[e.id,`: `,e.error]},e.id))]})}),(0,I.jsx)(`span`,{className:`dim small`,children:r||`Applies at once. The board ships its own; a JSON file in ~/.gcf/themes adds one or replaces one of its id: reload the page after changing it.`})]})]}),(0,I.jsx)(Dx,{})]})}var Ex=[{v:`expanded`,label:`Expanded`,help:`every card in full`,now:`Every technical card in full`},{v:`collapsed`,label:`Collapsed into a line`,help:`one line each; a click opens it (the default)`,now:`One line each; a click opens the card`},{v:`hidden`,label:`Hidden`,help:`only a card that waits for you`,now:`Gone from the stream; a card that waits for you stays`}];function Dx(){let e=cv();return(0,I.jsxs)(`div`,{className:`set-row`,children:[(0,I.jsxs)(`div`,{className:`set-what`,children:[(0,I.jsx)(`span`,{id:`set-chat-tech`,className:`mono set-name`,children:`technical cards`}),(0,I.jsx)(`span`,{children:`A permission card no longer waiting, a refusal, a call YOLO ran. A card that waits for you is always open in full; text, questions, proposals and steps never fold.`})]}),(0,I.jsxs)(`div`,{className:`set-how set-tech-how`,children:[(0,I.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":`set-chat-tech`,className:`set-seg set-tech`,onKeyDown:t=>{let n={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[t.key];if(!n)return;t.preventDefault();let r=(Ex.findIndex(t=>t.v===e)+n+Ex.length)%Ex.length;t.currentTarget.querySelectorAll(`[role="radio"]`)[r]?.focus(),ov(Ex[r].v)},children:Ex.map(t=>(0,I.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t.v===e,tabIndex:t.v===e?0:-1,title:t.help,onClick:()=>ov(t.v),children:t.label},t.v))}),(0,I.jsxs)(`div`,{className:`set-tech-line`,"aria-hidden":`true`,children:[(0,I.jsx)(`span`,{children:`▸`}),(0,I.jsx)(`span`,{className:`stl-tool`,children:`shell`}),(0,I.jsx)(`span`,{className:`stl-title`,children:`npm run levels:list`}),(0,I.jsx)(`span`,{className:`stl-yolo`,children:`· ran without asking (YOLO)`}),(0,I.jsx)(`span`,{className:`stl-at`,children:`09:02`})]}),(0,I.jsxs)(`span`,{className:`dim small`,children:[Ex.find(t=>t.v===e)?.now,` · applies at once, in every tab of this browser`]})]})]})}function Ox(){let e=_v(),[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),s=async e=>{t||(i(e),n(!0),o(``),await vv(e).catch(e=>o(e.message)),n(!1))},c=t?r:e;return(0,I.jsxs)(`section`,{"aria-label":`This machine`,className:`set-group`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Board · this machine`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsxs)(`div`,{className:`set-row`,children:[(0,I.jsxs)(`div`,{className:`set-what`,children:[(0,I.jsx)(`span`,{id:`set-yolo-name`,className:`mono set-name set-yolo-name${c?` on`:``}`,children:`YOLO`}),(0,I.jsx)(`span`,{children:`The threads of the project chat ask no permission: the center allows each call itself. Deny rules, the main-run refusal and question cards stay. Every project on this machine; from the next call.`})]}),(0,I.jsxs)(`div`,{className:`set-how set-yolo${c?` on`:``}`,children:[(0,I.jsxs)(`button`,{id:`set-yolo`,type:`button`,role:`switch`,"aria-checked":c,"aria-labelledby":`set-yolo-name`,"aria-describedby":`set-yolo-risk`,className:`set-switch`,onClick:()=>void s(!c),children:[(0,I.jsx)(`span`,{className:`set-switch-track`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{className:`set-switch-knob`})}),c?`on`:`off`]}),(0,I.jsxs)(`p`,{id:`set-yolo-risk`,className:`set-yolo-risk`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),(0,I.jsx)(`span`,{children:`Calls run unseen, as in a task run: a framework move that changes the project (integrate, close, design discard, inbox drop), an edit of AGENTS.md or CLAUDE.md, which stays after YOLO goes off, and a command that gets round a deny rule run too.`})]}),a&&(0,I.jsx)(`span`,{role:`alert`,className:`set-yolo-err`,children:a}),(0,I.jsx)(`span`,{className:`mono set-yolo-file`,children:`~/.gcf/chat-yolo`})]})]})]})}var kx=e=>e===null?`-`:`$${e.toFixed(2)}`,Ax=e=>`${e} run${e===1?``:`s`}`,jx=(e,t=1)=>e===null?`-`:e.toFixed(t),Mx=e=>Object.entries(e).map(([e,t])=>`${e} ${t}`).join(`, `);function Nx({ctx:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(``),a=(0,v.useRef)(0),{project:o}=e,s=(e.board.runs?.reports??[]).map(e=>e.id).join(),c=e.board.items.filter(e=>e.running).map(e=>e.id).join();(0,v.useEffect)(()=>{let e=++a.current;k.metrics(o.name).then(t=>{e===a.current&&(n(t),i(``))},t=>e===a.current&&i(t.message))},[s,c,o.name]);let l=(0,I.jsxs)(`div`,{className:`page-head`,children:[(0,I.jsx)(`h1`,{children:`Metrics`}),(0,I.jsx)(`p`,{children:`What the runs did and what they cost (gcf-harness metrics).`})]});if(r)return(0,I.jsxs)(`section`,{className:`page metrics`,children:[l,(0,I.jsxs)(`div`,{className:`empty-box`,children:[`No metrics: `,r]})]});if(!t)return(0,I.jsxs)(`section`,{className:`page metrics`,role:`status`,children:[l,(0,I.jsx)(`p`,{className:`dim`,children:`Reading the metrics…`})]});let u=t.runs;if(!u.count)return(0,I.jsxs)(`section`,{className:`page metrics`,children:[l,(0,I.jsx)(`div`,{className:`empty-box`,children:`No runs yet. Each run the board or a console starts adds to these numbers: what it reached, its handoffs, checks and cost.`})]});let d=u.share===null?``:` (${Math.round(u.share*100)}%)`,f=u.avg_duration_ms===null?null:u.avg_duration_ms/6e4,p=[[String(u.count),`runs${Object.keys(u.results).length?` · ${Mx(u.results)}`:``}`],[`${u.reached} of ${u.finished}`,`reached submit or close${d}`],[kx(u.cost_usd),`${kx(u.avg_cost_usd)} a run · ${jx(f,0)} min · ${jx(u.avg_turns,0)} turns`],[String(u.handoffs),`context handoffs`],[String(t.plan.checks),`plan checks · ${t.plan.items} items · ${t.plan.failed} failed`],[String(t.verify.attempts),`DoD attempts · ${t.verify.red} red${t.verify.red?` (${Mx(t.verify.failing)})`:``}`],[String(t.guard.count),`guard firings${t.guard.count?` · ${Mx(t.guard.by_hook)}`:``}`],[String(u.outside_implement),`code outside aif-implement`],[String(u.unverified),`moved without a green verify`]],m=t.items??[],h=Math.max(...m.map(e=>e.cost_usd),.01),g=(t.by_day??[]).slice(-14),_=Math.max(...g.map(e=>e.cost_usd),.01),y=(t.by_week??[]).at(-1),b=new Set(e.board.items.map(e=>e.id));return(0,I.jsxs)(`section`,{className:`page metrics`,"aria-label":`Metrics`,children:[l,(0,I.jsxs)(`section`,{"aria-label":`Runs`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Runs`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`mt-tiles`,children:p.map(([e,t])=>(0,I.jsxs)(`div`,{className:`mt-tile`,children:[(0,I.jsx)(`span`,{className:`mono`,children:e}),(0,I.jsx)(`span`,{children:t})]},t))}),Object.keys(u.blocks).length>0&&(0,I.jsxs)(`div`,{className:`mt-blocks`,children:[(0,I.jsx)(`span`,{className:`dim`,children:`block reasons:`}),Object.entries(u.blocks).map(([e,t])=>(0,I.jsxs)(`span`,{children:[e,` `,(0,I.jsx)(`b`,{className:`mono`,children:t})]},e))]})]}),t.items?(0,I.jsxs)(`section`,{"aria-label":`Cost per item`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Cost per item`,(0,I.jsx)(`span`,{className:`dim sub`,children:`over all its runs`}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),m.map(t=>(0,I.jsxs)(`div`,{className:`mt-item`,children:[(0,I.jsx)(`button`,{className:`link-btn mono`,disabled:!b.has(t.id),onClick:()=>e.openItem(t.id),children:t.id}),(0,I.jsx)(`span`,{className:`mt-bar`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{style:{width:`${Math.round(100*t.cost_usd/h)}%`}})}),(0,I.jsx)(`span`,{className:`mono`,children:kx(t.cost_usd)}),(0,I.jsx)(`span`,{className:`dim small`,title:`last ${t.last}`,children:Ax(t.runs)})]},t.id))]}):(0,I.jsx)(`p`,{className:`dim`,children:`Cost per item, day and week needs gcf-harness-aif-ext 0.9.5.`}),g.length>0&&(0,I.jsxs)(`section`,{"aria-label":`Cost per day`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Cost per day`,y&&(0,I.jsxs)(`span`,{className:`dim sub`,children:[`this week `,kx(y.cost_usd)]}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`mt-days`,children:g.map(e=>(0,I.jsxs)(`div`,{title:`${e.day}: ${kx(e.cost_usd)}, ${Ax(e.runs)}`,children:[(0,I.jsx)(`span`,{className:`mono small`,children:kx(e.cost_usd)}),(0,I.jsx)(`span`,{className:`mt-col`,"aria-hidden":`true`,style:{height:`${Math.max(2,Math.round(80*e.cost_usd/_))}px`}}),(0,I.jsx)(`span`,{className:`mono dim small`,children:e.day.slice(5).replace(`-`,`.`)})]},e.day))})]})]})}function Px({ctx:e,r:t}){let{text:n,bad:r}=ni(t.ids,t.ok,t.result,t.err),i=n.split(`
89
+ `).slice(1),a=!r&&/paused/.test(n),o=r?`error`:a?`neutral`:`ok`,s=new Set(e.board.items.map(e=>e.id));return(0,I.jsxs)(`article`,{className:`report tone-${o}`,"aria-label":`Run report: ${t.ids.join(`, `)}`,children:[(0,I.jsxs)(`div`,{className:`report-head`,children:[(0,I.jsx)(`span`,{className:`report-kind`,children:r?`run failed`:a?`run paused`:`run ended`}),(0,I.jsx)(`span`,{className:`report-title`,children:t.ids.join(`, `)}),(0,I.jsx)(`span`,{className:`report-time`,children:oi(t.at)}),(0,I.jsx)(`button`,{className:`icon-btn report-close`,"aria-label":`Close the report`,onClick:()=>void k.closeReport(e.project.name,t.id).catch(t=>e.notify(t.message,`error`)),children:`×`})]}),(0,I.jsx)(`div`,{className:`report-lines`,children:i.map((n,r)=>{let i=n.indexOf(`: `),a=n.slice(0,i);if(i<0||!s.has(a))return(0,I.jsx)(`div`,{className:`report-line plain`,children:n},r);let o=n.slice(i),c=t.result?.items?.find(e=>e.id===a)?.process,l=c?` — ${c}`:``,u=l?o.indexOf(l):-1;return(0,I.jsxs)(`div`,{className:`report-line`,children:[(0,I.jsx)(`button`,{className:`link-btn`,onClick:()=>e.openItem(a),children:a}),u<0?o:o.slice(0,u),u>=0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`report-warn`,title:`A process note from the framework`,children:l}),o.slice(u+l.length)]})]},r)})}),t.note&&(0,I.jsx)(`div`,{className:`report-note`,children:t.note})]})}var Fx=e=>{let t=e.resume?.resets;return t?Number.isNaN(Date.parse(t))?t:oi(t):`?`};function Ix(e,t){let{board:n}=e,{domain:r}=n,i=e=>r.columns.find(t=>t.status===e.status),a=new Set(r.sections.playtest?.waits??[]),o=(t,r)=>({key:`item:${t.id}`,cat:`${t.type.slice(0,3).toUpperCase()} · ${t.gate}`,tone:t.gate,origin:t.running?`running`:i(t)?.label??t.status,title:t.title||t.id,sub:r,mark:t.title?t.id:``,needs:G(t,n),on:e.itemOpen===t.id,onOpen:()=>e.openItem(t.id)}),s=t.flatMap(e=>e.kind===`item`?[e.item]:[]),c=t.some(e=>e.kind===`queue`)?[{key:`queue`,cat:`RUN`,tone:`needs`,origin:`queue paused`,title:`the run queue`,sub:n.runs?.paused_by===`limit`?`A run ended paused: limit by itself. Resume the queue after the reset${n.runs?.paused_until?` (${si(n.runs.paused_until)})`:``}.`:`A run failed in a way the next one would repeat. Fix what its report names, then resume.`,needs:!0,tip:`Open Runs: Resume queue is there`,onOpen:()=>e.go(`runs`)}]:[],l=n.runs?.autopilot,u=t.flatMap(t=>{if(t.kind!==`pilot`)return[];let{stop:r}=t;if(r.kind===`play`){let t=(n.milestones??[]).find(e=>e.name===r.milestone),i=(t?.items[`awaiting-verdict`]??0)+(t?.items.unplayed??0);return[{key:`pilot`,cat:`MILESTONE · ${r.milestone} · built`,tone:`unplayed`,origin:`the autopilot stands`,title:r.text,sub:t?.play?`play: ${t.play}`:t?.goal??``,mark:i?`${i} to play`:``,markTone:`needs`,needs:!0,play:!0,tip:`${t?.play?`Its play question: ${t.play} · `:``}Open Playtest: Keep ${r.milestone} keeps all of it that waits for play`,onOpen:()=>e.go(`playtest`)}]}let i=l?.guarded[0],a=r.kind===`empty`?{sub:`Card its units on Design`,open:()=>e.go(`design`)}:r.kind===`dirty`?{sub:`Commit or stash it, or pick worktree runs in Settings`,open:()=>e.openSettings()}:r.kind===`no-move`&&i?{sub:`It takes ${i} again once its file changes · turn it on in the header`,open:()=>e.openItem(i)}:{sub:``,open:()=>e.go(`runs`)};return[{key:`pilot`,cat:`AUTOPILOT · ${r.kind===`no-move`?`off by itself`:`stands`}`,tone:`warn`,origin:l?.on?`on, waiting`:`off`,title:r.text,sub:a.sub,mark:``,needs:!0,play:!1,tip:[r.text,a.sub].filter(Boolean).join(` · `),onOpen:a.open}]}),d=u.filter(e=>e.play),f=u.filter(e=>!e.play),p=s.filter(e=>!$i(n,e.status)).map(e=>o(e,`Hit the usage limit (resets ${Fx(e)}); its session is kept. Resume is in its window; while the limit holds, the run waits for the reset.`)),m=t.flatMap(t=>{if(t.kind!==`chat`)return[];let{card:n,talk:r}=t,i=r?`${r.title??`untitled thread`}${r.item?` · ${r.item}`:``} · project chat`:`${t.item} · run chat`;return[{key:`chat:${n.request_id}`,cat:n.kind===`approval`?`permission · ${n.tool??``}`:`question`,tone:`needs`,origin:i,title:n.text,sub:n.reason??``,needs:!0,tip:`Open its chat: the card is answered there`,onOpen:()=>r?e.go(`chat`,r.id):e.openItem(t.item??``,`chat`)}]}),h=t.flatMap(t=>{let n=t.kind===`entry`?rs(e,t.entry,!0):t.kind===`repeat`?as(e,`${t.repeat.category}:${t.repeat.detail}`,!0):null;return n?[{...n,key:n.dataKey??n.title}]:[]}),g=r.sections.inbox?.groups?.find(e=>e.counts)?.label??`Inbox`,_=t.flatMap(e=>e.kind===`report`?[e.report]:[]),v=t.flatMap(t=>t.kind===`question`?[{...is(e,t.question,!0),key:t.question.id}]:[]),y=s.filter(e=>$i(n,e.status)),b=e=>`${e.blocked??i(e)?.help??``}${e.tune_count?` · tuned ${e.tune_count}×`:``}`,x=r.columns.filter(e=>$i(n,e.status)&&!a.has(e.status)).map(e=>({key:e.status,label:e.label,tiles:y.filter(t=>t.status===e.status).map(e=>o(e,b(e)))}));return[{key:`runs`,label:`Runs that need you`,tiles:[...f,...c,...p],reports:_},{key:`chat`,label:`Answer in a chat`,tiles:m},{key:`answer`,label:`Answer`,tiles:v},{key:`inbox`,label:`Inbox: ${g}`,tiles:h},{key:`play`,label:`Play and judge`,tiles:[...d,...y.filter(e=>a.has(e.status)).map(e=>o(e,b(e)))]},...x].filter(e=>e.reports?.length||e.tiles.length)}function Lx({ctx:e}){let t=ea(e.board,e.talks),n=Ix(e,t),r=e.board.domain.starts&&sr(e.board)?cr(e.board):[],i=r.some(e=>e.id===`work`&&e.done)?0:r.filter(e=>!e.done).length;return(0,I.jsxs)(`section`,{className:`feed`,"aria-label":`Waiting for me`,children:[(0,I.jsxs)(`div`,{className:`feed-head`,children:[(0,I.jsx)(`span`,{className:`feed-total`,children:t.length}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{children:`waiting for me`}),(0,I.jsx)(`span`,{children:`Only you can move these on. Everything else runs or waits on the queue, the clock or a trigger.`})]})]}),!t.length&&!i&&(0,I.jsx)(`div`,{className:`feed-empty`,children:`Nothing waits for you. Runs go on by themselves.`}),[...i>0?[{key:`design`,label:`Start the game`,tiles:[{key:`design`,cat:`DESIGN`,origin:`${i} of ${r.length} steps left`,title:`The game starts with its design: ${i} of ${r.length} steps to the first work.`,sub:r.find(e=>!e.done)?.label??``,tip:`Open Design`,onOpen:()=>e.go(`design`)}]}]:[],...n].map(t=>(0,I.jsxs)(`section`,{className:`feed-group`,"aria-label":t.label,children:[(0,I.jsxs)(`h2`,{children:[t.label,(0,I.jsx)(`span`,{className:`count needs`,children:(t.reports?.length??0)+t.tiles.length}),(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),t.reports?.map(t=>(0,I.jsx)(Px,{ctx:e,r:t},t.id)),t.tiles.length?(0,I.jsx)(Pa,{children:t.tiles.map(({key:e,...t})=>(0,I.jsx)(Ma,{...t},e))}):null]},t.key))]})}function Rx({ctx:e}){let{board:t}=e,n=t.runs,r=e=>t.items.find(t=>t.id===e),i=(n?.active??[]).flatMap(e=>{let t=e.ids.map(r).find(e=>e?.running)??r(e.ids[0]);return t?[{run:e,item:t}]:[]}),a=new Set(i.map(e=>e.item.id)),o=t.items.filter(e=>e.running&&!a.has(e.id)),s=(n?.reports??[]).filter(e=>!ea(t).some(t=>t.kind===`report`&&t.report.id===e.id)),c=n?.queued??[],l=!!t.domain.harness;return(0,I.jsxs)(`aside`,{className:`live`,"aria-label":`Live runs`,children:[(0,I.jsxs)(`div`,{className:`live-head`,children:[(0,I.jsx)(`h2`,{children:`Live`}),l&&(0,I.jsx)(Ji,{ctx:e})]}),s.length>0&&(0,I.jsx)(`div`,{className:`live-reports`,children:[...s].reverse().map(t=>(0,I.jsx)(Px,{ctx:e,r:t},t.id))}),!l&&(0,I.jsx)(`div`,{role:`note`,className:`live-note`,children:t.extensions_error?`No run: .ai-factory.json cannot be read, so the board knows no harness. Fix the file; every manual move works meanwhile.`:`No harness in this project: nothing runs from the board. Items, moves, verdicts, the inbox and settings all work.`}),l&&!i.length&&!o.length&&(0,I.jsx)(`div`,{className:`live-note`,children:n?.paused?`Nothing runs: the queue is paused.`:`Nothing runs now.`}),i.map(({run:t,item:n})=>{let r=di(n),i=n.plan&&!(`error`in n.plan)?n.plan:null;return(0,I.jsxs)(`article`,{className:`live-run`,children:[(0,I.jsxs)(`div`,{className:`live-run-head`,children:[(0,I.jsxs)(`button`,{className:`live-run-id`,onClick:()=>e.openItem(n.id),children:[(0,I.jsx)(`span`,{children:n.id}),n.title&&(0,I.jsx)(`small`,{children:n.title})]}),!r&&n.active_at&&(0,I.jsx)(ei,{at:n.active_at})]}),r&&(0,I.jsxs)(`div`,{className:`live-limit`,title:`The usage limit is one for the account. The run waits for the reset by itself and goes on in the same session; the queue waits behind it.`,children:[`◷ limit: resumes `,oi(r),(0,I.jsx)(`span`,{children:`waits for the reset by itself · Stop ends the wait: paused: limit, the queue goes on`})]}),t.ids.length>1&&(0,I.jsxs)(`span`,{className:`live-batch`,children:[`item `,t.ids.indexOf(n.id)+1,` of `,t.ids.length,`: `,t.ids.join(`, `)]}),i&&(0,I.jsxs)(`div`,{className:`live-plan`,title:`Plan checkboxes done / total`,children:[(0,I.jsx)(`span`,{children:`tasks`}),(0,I.jsx)(`span`,{className:`bar`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{style:{width:`${Math.round(100*i.done/Math.max(1,i.tasks))}%`}})}),(0,I.jsxs)(`span`,{className:`mono`,children:[i.done,` of `,i.tasks]})]}),(0,I.jsxs)(`div`,{className:`live-run-foot`,children:[(0,I.jsxs)(`span`,{children:[`this board · `,t.mode,` · started `,oi(t.started),t.model||t.effort?` · on ${[t.model,t.effort].filter(Boolean).join(` · `)}`:``]}),(0,I.jsx)(`button`,{className:`btn`,onClick:()=>e.openItem(n.id),children:`Follow`}),(0,I.jsx)(`button`,{className:`btn-danger`,title:r?`Ends the wait for the reset: it becomes paused: limit, Run resumes it later, and the queue goes on`:`Stops the agent session; the item stays ready and its work is kept`,onClick:()=>void Yi(e,n),children:`Stop`})]})]},t.started+n.id)}),o.map(t=>(0,I.jsxs)(`button`,{className:`live-other`,onClick:()=>e.openItem(t.id),children:[(0,I.jsxs)(`span`,{className:`live-other-kind`,children:[`◐ `,ii(t),t.running_kind!==`session`&&t.active_at&&(0,I.jsx)(ei,{at:t.active_at})]}),(0,I.jsx)(`span`,{className:`live-other-id`,children:t.id}),(0,I.jsx)(`span`,{className:`live-other-note`,children:t.running_kind===`session`?`no log: an interactive session`:`no run report: started from a console`})]},t.id)),l&&(0,I.jsxs)(`section`,{className:`live-queue`,"aria-label":`Run queue`,children:[(0,I.jsxs)(`h3`,{children:[`Queue · `,c.length,n?.paused?` · paused`:``]}),!c.length&&(0,I.jsx)(`span`,{className:`live-empty`,children:`empty`}),c.map((t,i)=>{let a=r(t)?.waits_for??[],o=n?.queued_with?.[t];return(0,I.jsxs)(`div`,{className:`live-q`,children:[(0,I.jsxs)(`span`,{className:`mono`,children:[`#`,i+1]}),(0,I.jsxs)(`button`,{className:`live-q-id`,onClick:()=>e.openItem(t),children:[(0,I.jsx)(`span`,{children:t}),o&&(0,I.jsxs)(`small`,{title:`What it will run on: this run's pick`,children:[`on `,[o.model??`its own model`,o.effort].filter(Boolean).join(` · `)]}),a.length>0&&(0,I.jsxs)(`small`,{children:[`⧗ waits for `,a.join(`, `)]})]}),(0,I.jsx)(Na,{label:`Remove from queue`,tip:`Remove from queue; it asks nothing`,onClick:()=>void e.unqueue(t)})]},t)})]}),(n?.acts??[]).length>0&&(0,I.jsxs)(`section`,{className:`live-acts`,"aria-label":`What ran by itself`,children:[(0,I.jsx)(`h3`,{children:`What ran by itself`}),[...n?.acts??[]].reverse().slice(0,12).map((e,t)=>(0,I.jsxs)(`div`,{className:`live-act`,children:[(0,I.jsx)(`span`,{children:oi(e.at)}),(0,I.jsx)(`span`,{children:e.text})]},t))]})]})}function zx({ctx:e}){return(0,I.jsxs)(`div`,{className:`command`,children:[(0,I.jsx)(Lx,{ctx:e}),(0,I.jsx)(Rx,{ctx:e})]})}var Bx=[`start`,`pillars`,`vision`,`glossary`,`units`,`questions`,`designer`],Vx={start:`Start`,pillars:`Pillars`,vision:`Vision & scope`,glossary:`Glossary`,units:`Units`,questions:`Questions`,designer:`Designer`},Hx=[`mechanic`,`resource`,`rule`,`constraint`,`entity`],Ux={line:`One line`,lines:`Lines: one per line`,records:`Records: each record's keys side by side; add or remove a record`},Wx=[[`Your GDD is kept`,`in gcf/source/, each section anchored: a new version shows what changed.`],[`Design units`,`in gcf/design/, by subsystem: each slot is a word-for-word quote of the GDD, or TBD.`],[`Their order`,`in backlog.md.`],[`Questions`,`here and in Inbox: what the GDD leaves open (Decision needed) and what the agent assumed (Assumption to check).`],[`Drafts of the vision and the glossary`,`you confirm them in the thread.`],[`Pillar candidates`,`for the pillars step.`],[`Nothing on the board`,`no item is made: a unit becomes work only when you take it into work.`]],Gx=e=>e.replace(/_/g,` `),Kx=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function qx(e,t,n=!1){let r=e.board.domain.starts?.[t],[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),c=$a(e.board.quota),l=t=>n?s(t):e.notify(t,`error`),u=c?`Off until ${oi(c)}: the usage limit holds for the account. The forms work without an agent.`:i?`Opening a new thread of the project chat…`:`${r?.help??``} · opens a new thread of the project chat with ${r?.skill??`its skill`}, and goes to it`,d=async n=>{a(!0),s(``);try{let r=await k.start(e.project.name,t,n);e.reloadTalks(),e.go(`chat`,r.thread)}catch(e){l(e.message)}a(!1)};return{s:r,busy:i,err:o,off:!!c||i,tip:u,go:d,pick:async e=>{if(!/\.md$/i.test(e.name))return l(`${e.name} is not markdown: save a Word or Google document as .md first`);if(e.size>5242880)return l(`${e.name} is ${(e.size/1048576).toFixed(1)} MB: a GDD is up to 5 MB`);await d({file:{name:e.name,text:await e.text()}})}}}function Jx({st:e,k:t,unit:n,system:r,primary:i}){let a=e.s;return a?(0,I.jsx)(jo,{label:e.busy?`Starting…`:a.label,tip:e.tip,glyph:Ao(t),primary:i,starting:e.busy,off:e.off||a.takes===`unit`&&!n||a.takes===`system`&&!r,onClick:()=>void e.go(a.takes===`unit`?{unit:n}:a.takes===`system`?{system:r}:{}),file:a.takes===`file`?t=>void e.pick(t):void 0}):null}function Yx({ctx:e,k:t,unit:n,system:r,named:i,primary:a}){let o=qx(e,t);if(!o.s)return null;let s=(0,I.jsx)(Jx,{st:o,k:t,unit:n,system:r,primary:a});return i?(0,I.jsxs)(`span`,{className:`agent-act`,children:[s,o.busy?`Starting…`:o.s.label]}):s}function Xx({ctx:e,k:t,primary:n}){let r=qx(e,t,!0);return r.s?(0,I.jsxs)(`div`,{className:`design-way`,children:[(0,I.jsxs)(`div`,{className:`design-way-head`,children:[(0,I.jsx)(Jx,{st:r,k:t,primary:n}),(0,I.jsx)(`span`,{className:`design-way-label`,children:r.busy?`Starting…`:r.s.label})]}),(0,I.jsx)(`span`,{className:`design-note`,children:r.s.help}),r.s.takes===`file`&&(0,I.jsx)(`span`,{className:`design-fine`,children:`.md, up to 5 MB · a Word or Google document: save it as markdown first`}),r.err&&(0,I.jsx)(`span`,{role:`alert`,className:`design-err`,children:r.err})]}):null}function Zx({ctx:e,label:t,big:n}){let r=qx(e,`ingest`);return r.s?(0,I.jsxs)(`label`,{className:`design-pick${n?` big`:``}${r.off?` off`:``}`,title:r.tip,"aria-disabled":r.off||void 0,children:[r.busy?`Starting…`:t,(0,I.jsx)(`input`,{type:`file`,accept:`.md,text/markdown`,"aria-label":n?`Pick the same GDD again`:`Import a new version: pick the GDD`,disabled:r.off,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&r.pick(t)}})]}):null}function Qx({ctx:e,k:t,label:n,help:r}){let i=qx(e,t),[a,o]=(0,v.useState)(``);if(!i.s)return null;let s=`design-rev-${t}`;return(0,I.jsxs)(`div`,{className:`design-panel`,children:[(0,I.jsx)(`label`,{htmlFor:s,className:`design-revise-label`,children:n}),(0,I.jsx)(`span`,{className:`design-note`,children:r}),(0,I.jsxs)(`div`,{className:`design-revise-row`,children:[(0,I.jsx)(`input`,{id:s,className:`design-input`,placeholder:`what to change, in your words`,value:a,onChange:e=>o(e.target.value)}),(0,I.jsx)(jo,{label:i.busy?`Starting…`:i.s.label,tip:!i.off&&!a.trim()?`Say first what to change`:i.tip,glyph:Ao(t),starting:i.busy,off:i.off||!a.trim(),onClick:()=>void i.go({text:a})})]})]})}function $x({label:e,aria:t,v:n,onChange:r,name:i}){let a=xr(n);return(0,I.jsxs)(`label`,{className:`design-cell`,children:[(0,I.jsx)(`span`,{children:e}),(0,I.jsx)(`input`,{className:`design-input${a?` tbd`:``}${i?` strong`:``}`,"aria-label":t,placeholder:a?`TBD`:``,value:a?``:n,onChange:e=>r(e.target.value===``&&a?`TBD`:e.target.value)})]})}function eS({f:e,value:t,edited:n,compact:r,onChange:i,toText:a}){let o=e.form===`scalar`?`line`:e.form===`record-list`?`records`:`lines`,s=`design-f-${e.key}`,c=Gx(e.key),l=e.value===`TBD`&&mr(t),u=o===`records`&&Array.isArray(t)?t:[],d=u.reduce((e,t)=>e+Object.values(t).filter(xr).length,0),f=mr(t),p=l?[`TBD`,e.note].filter(Boolean).join(` · `):f?[e.required?`empty`:``,e.note].filter(Boolean).join(` · `):``,m=(0,I.jsxs)(`div`,{className:`design-fhead${r?` compact`:``}`,children:[(0,I.jsx)(`label`,{htmlFor:s,className:`design-fkey`,children:c}),!r&&o===`lines`&&(0,I.jsx)(`span`,{className:`design-fkind`,title:Ux.lines,children:`one per line`}),(l||d>0)&&(0,I.jsx)(`span`,{className:`design-tbd-badge`,title:l?`To be decided: the slot is open. A unit with a TBD cannot go into work`:`${d} record value${d>1?`s are`:` is`} TBD`,children:l?`TBD`:`TBD ${d}`}),n&&(0,I.jsx)(`span`,{className:`design-changed`,children:`changed`}),(0,I.jsx)(`span`,{className:`design-spacer`}),e.required?f&&!l?(0,I.jsx)(`span`,{className:`design-req empty`,title:`Required: the part does not hold without it`,children:`● required · empty`}):(0,I.jsx)(`span`,{className:`design-req`,title:`Required: it cannot be left empty (TBD keeps it open)`,children:`● required`}):(0,I.jsx)(`span`,{className:`design-req opt`,title:`Optional: it may stay empty`,children:`optional`})]}),h=e.note&&(0,I.jsx)(`span`,{className:r?`design-fnote small`:`design-fnote`,children:e.note});if(!e.exact){let t=e.value,n=Array.isArray(t)?t.map(e=>typeof e==`object`?Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(` · `):e).join(`
84
90
  `):String(t??``);return(0,I.jsxs)(`div`,{className:`design-field`,children:[m,!r&&h,(0,I.jsxs)(`div`,{className:`design-ro${r?` compact`:``}`,title:`This slot holds text the form cannot keep (a comment, prose): edit as text edits the whole part`,children:[(0,I.jsx)(`span`,{className:`design-ro-text`,children:n}),(0,I.jsxs)(`span`,{className:`design-ro-side`,children:[!r&&(0,I.jsx)(`span`,{children:`read only`}),(0,I.jsx)(`button`,{className:`design-ro-btn`,onClick:a,children:`edit as text`})]})]}),!r&&(0,I.jsx)(`span`,{className:`design-ro-why`,children:`it holds text a form cannot keep: edit the part as text`}),r&&h]})}if(o===`line`)return(0,I.jsxs)(`div`,{className:`design-field`,children:[m,!r&&h,(0,I.jsx)(`input`,{id:s,className:`design-input${l?` tbd`:``}`,value:String(t),title:r?e.note??void 0:void 0,disabled:e.header&&e.key===`type`,placeholder:p,onChange:e=>i(e.target.value)}),r&&h]});if(o===`lines`)return(0,I.jsxs)(`div`,{className:`design-field`,children:[m,h,(0,I.jsx)(`textarea`,{id:s,className:`design-input design-lines${l?` tbd`:``}`,"aria-label":`${c}: one per line`,rows:Math.max(2,String(t).split(`
85
- `).length+1),value:String(t),placeholder:p,onChange:e=>i(e.target.value)})]});let g=wr(e,u),_=(e,t,n)=>i(u.map((r,i)=>i===e?{...r,[t]:n}:r));return(0,I.jsxs)(`div`,{className:`design-field`,children:[m,h,(0,I.jsxs)(`div`,{className:`design-recs`,id:s,children:[(0,I.jsxs)(`div`,{className:`design-rec-headrow`,"aria-hidden":`true`,children:[g.map(e=>(0,I.jsx)(`span`,{children:Dx(e)},e)),(0,I.jsx)(`span`,{className:`design-rec-gap`})]}),u.map((e,t)=>(0,I.jsxs)(`div`,{className:`design-rec-row`,children:[g.map(n=>n===`id`?(0,I.jsxs)(`span`,{className:`design-cell`,children:[(0,I.jsx)(`span`,{children:`id`}),(0,I.jsx)(`span`,{className:`design-rec-id`,children:e.id||`made from the name on save`})]},n):(0,I.jsx)(Fx,{label:Dx(n),aria:`${c} ${t+1}: ${Dx(n)}`,v:e[n]??``,onChange:e=>_(t,n,e)},n)),(0,I.jsx)(Na,{label:`Remove record ${t+1} of ${c}`,onClick:()=>i(u.filter((e,n)=>n!==t))})]},t)),l&&(0,I.jsx)(`span`,{className:`design-tbd-none`,children:`TBD: no record yet`}),(0,I.jsx)(`button`,{className:`design-add`,title:`Add a record: each key empty`,onClick:()=>i([...u,Object.fromEntries(g.map(e=>[e,``]))]),children:`+ record`})]})]})}function Lx({ctx:e,f:t,value:n,saved:r,onChange:i}){let a=Tr(e.board.domain,e.board.domain.sections.design?.retire),o=sr(e.board)?.pillars??[],s=n,c=Array.isArray(r)?r:[],l=wr(t,s).filter(e=>e!==`id`&&e!==`name`),u=(e,t,n)=>i(s.map((r,i)=>i===e?{...r,[t]:n}:r)),d=new Set([...c,...s].map(e=>e.id).filter(Boolean)),[f,p]=(0,v.useState)(null);return(0,I.jsxs)(`div`,{className:`design-pillars`,children:[s.map((t,n)=>{let r=t.id??``,f=c.find(e=>e.id===r),m=!!(r&&f),h=(t.name??``).trim(),g=(f?.name??``).trim(),_=h?vr(h,e=>e!==r&&d.has(e)):``,v=o.find(e=>e.id===r)?.units,y=v===void 0?m?``:`not saved yet`:`${v} ${v===1?`unit cites`:`units cite`} it`;return(0,I.jsxs)(`article`,{className:`design-pillar-card`,children:[(0,I.jsxs)(`div`,{className:`design-pillar-top`,children:[(0,I.jsxs)(`div`,{className:`design-pillar-head`,children:[(0,I.jsx)(`span`,{className:`design-pillar-title${!h&&m?` mono`:``}`,children:h||(m?r:`New pillar`)}),(0,I.jsxs)(`span`,{className:`design-pillar-line`,children:[(0,I.jsx)(`code`,{title:m?`The pillar's id: units cite it in pillars:. The system keeps it; a new name renames it after the save.`:`A new pillar gets its id from its name`,children:m?r:h?`its id: ${_}`:`its id comes from its name`}),(0,I.jsx)(`span`,{title:`Units whose pillars cite it`,children:y})]})]}),m&&!g&&(0,I.jsx)(jx,{ctx:e,k:`name-pillars`}),m&&a&&(0,I.jsx)(`button`,{className:`design-danger small`,title:`The game no longer holds it: units left with no pillar read pillars: TBD`,onClick:()=>p(r),children:`Retire…`}),!m&&(0,I.jsx)(Na,{label:`Remove record ${n+1} of pillars`,tip:`Remove this pillar: it is not saved yet`,onClick:()=>i(s.filter((e,t)=>t!==n))})]}),(0,I.jsxs)(`label`,{className:`design-cell`,children:[(0,I.jsx)(`span`,{children:`name`}),(0,I.jsx)(`input`,{className:`design-input strong`,"aria-label":`Pillar ${n+1}: name`,placeholder:m?`no name yet: a few words you know it by`:`a few words you know it by`,value:t.name??``,onChange:e=>u(n,`name`,e.target.value)})]}),m&&g&&h&&h!==g&&_!==r&&(0,I.jsxs)(`span`,{className:`design-note`,children:[`↻ Save renames `,r,` → `,_,` wherever it is cited: a second commit after the save.`]}),l.map(e=>(0,I.jsx)(Fx,{label:Dx(e),aria:`Pillar ${n+1}: ${Dx(e)}`,v:t[e]??``,onChange:t=>u(n,e,t)},e))]},n)}),(0,I.jsxs)(`button`,{className:`design-add`,title:`A new pillar: name, statement, invariant, review question; its id comes from its name`,onClick:()=>i([...s,Object.fromEntries([`name`,...l].map(e=>[e,``]))]),children:[`+ pillar · `,s.length,` of 2 to 7`]}),f&&(0,I.jsx)(Zx,{ctx:e,kind:`retire`,id:f,onClose:()=>p(null)})]})}function Rx({ctx:e,kind:t,name:n,rows:r=18}){let i=e.board.domain.sections.design,[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(!1),b=()=>k.designPart(e.project.name,t,n).then(e=>{let t=Object.fromEntries(e.fields.map(e=>[e.key,dr(e)]));o(e),c(t),u(t),m(e.text),g(``)},e=>g(e.message)),x=a?pr(a.fields,s,l):{},S=Object.keys(x).length,C=S>0||d&&p!==a?.text,w=sr(e.board)?.unrecorded??[],T=`${e.board.head??``} ${w.join(`,`)}`;if((0,v.useEffect)(()=>{C||b()},[t,n,T]),h)return(0,I.jsxs)(`p`,{className:`error-text`,children:[`✘ `,h]});if(!a||!i)return(0,I.jsxs)(`p`,{className:`dim`,children:[`reading `,n,`…`]});let E=async()=>{y(!0);let r=await e.move({id:n,kind:t,base:a.base??void 0,...d?{cmd:i.save_text,text:p}:{cmd:i.save,fields:JSON.stringify(x)}});y(!1),r&&(f(!1),await b())},D=!!(a.file&&w.includes(a.file)),O=C&&!_,A=r=>t===`doc`&&n===`pillars`&&r.key===`pillars`&&r.exact?(0,I.jsx)(Lx,{ctx:e,f:r,value:l[r.key],saved:s[r.key],onChange:e=>u({...l,[r.key]:e})},r.key):(0,I.jsx)(Ix,{f:r,value:l[r.key],edited:r.key in x,compact:t===`unit`&&!!r.header,onChange:e=>u({...l,[r.key]:e}),toText:()=>f(!0)},r.key),ee=a.fields.filter(e=>t===`unit`&&e.header),j=a.fields.filter(e=>!(t===`unit`&&e.header));return(0,I.jsxs)(`div`,{className:`design-form`,children:[d?(0,I.jsxs)(`div`,{className:`design-astext`,children:[(0,I.jsxs)(`span`,{className:`design-note`,children:[`The whole `,t===`unit`?`unit`:`part`,` as text, as it is in`,` `,a.file??`its file`,`. Save text writes all of it.`]}),(0,I.jsx)(`textarea`,{className:`design-input design-text`,"aria-label":`${n} as text`,rows:r,value:p,onChange:e=>m(e.target.value)})]}):t===`unit`?(0,I.jsxs)(`div`,{className:`design-fields`,children:[(0,I.jsxs)(`div`,{className:`design-group`,children:[(0,I.jsx)(`h3`,{className:`design-h3`,children:`Header`}),(0,I.jsx)(`div`,{className:`design-header-grid`,children:ee.map(A)})]}),(0,I.jsxs)(`div`,{className:`design-group`,children:[(0,I.jsxs)(`h3`,{className:`design-h3`,children:[`Blocks of a `,a.type]}),(0,I.jsx)(`div`,{className:`design-fields`,children:j.map(A)})]})]}):(0,I.jsx)(`div`,{className:`design-fields`,children:j.map(A)}),(0,I.jsxs)(`div`,{className:`design-savebar`,children:[D&&(0,I.jsxs)(`span`,{className:`design-wait`,children:[`⧗ `,a.file,` holds a change not recorded yet, a draft perhaps: you see it in the form, and Save records it along with your edits.`]}),(0,I.jsxs)(`span`,{className:`design-base`,title:`The part as read: a save is refused if the file changed since`,children:[t===`unit`?`${a.file} · `:``,`read at `,a.base??`—`]}),(0,I.jsx)(`span`,{className:`design-spacer`}),d?(0,I.jsx)(`button`,{className:`design-textbtn`,title:`Back to the form; the text edits are dropped`,onClick:()=>{m(a.text),f(!1)},children:`back to the form`}):(0,I.jsx)(`button`,{className:`design-textbtn`,title:a.fields.some(e=>!e.exact)?`A slot holds text the form cannot keep: edit the whole part as text`:`Edit the whole part as text, as it is in its file`,onClick:()=>f(!0),children:`edit as text`}),(0,I.jsx)(`button`,{className:`design-revert`,disabled:!C||_,title:`Drop the changes`,onClick:()=>void b(),children:`Revert`}),(0,I.jsx)(`button`,{className:`design-save`,disabled:!O,title:D&&C?`gcf design save: your changes and the waiting change of ${a.file}, in one commit`:C?d?`gcf design save: the whole part as text; refused if it changed since it was read`:`gcf design save: only the changed fields; refused if the part changed since it was read, or if the save adds a finding of the design check`:`Nothing changed yet`,onClick:()=>void E(),children:_?`Saving…`:d?`Save text`:S?`Save ${S} ${S===1?`change`:`changes`}`:`Save`})]})]})}function zx({ctx:e,d:t,part:n,go:r}){let i=cr(e.board),a=i.filter(e=>e.done).length,o=i.length>0&&a===i.length,s=e.board.units??[],c=s.filter(e=>e.ready).length,l=lr(e.board).filter(e=>e.class!==`D2`&&!e.answer).length,u={start:`${a}/${i.length}`,pillars:String(t.pillars.length),vision:t.game?`✔`:`–`,glossary:String(t.glossary??0),units:String(s.length),questions:String(l),designer:``},d={start:`${a} of ${i.length} steps done`,pillars:`${t.pillars.length} pillars`,vision:t.game?`game.md exists`:`no game.md yet`,glossary:`${t.glossary??0} terms`,units:`${s.length} live units · ${c} ready`,questions:`${l} waiting for your answer`,designer:`Export the whole design as one markdown file, or import it back`},f=e=>e===`questions`&&l?` needs`:e===`start`&&o?` ok`:``,p=o?[...Sx.slice(1),Sx[0]]:Sx,m=`${a} of ${i.length} steps done`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`nav`,{className:`design-nav`,"aria-label":`Parts of the design`,children:[(0,I.jsxs)(`div`,{className:`design-nav-head`,children:[(0,I.jsx)(`h1`,{children:`Design`}),(0,I.jsx)(`span`,{title:`design.steps: what the framework counts done`,children:m})]}),p.map(e=>(0,I.jsxs)(`button`,{className:`design-nav-btn`,"aria-current":e===n||void 0,title:d[e],onClick:()=>r(e),children:[(0,I.jsx)(`span`,{children:Cx[e]}),u[e]&&(0,I.jsx)(`span`,{className:`design-count${f(e)}`,children:u[e]})]},e)),(0,I.jsx)(`p`,{className:`design-nav-note`,children:`Nothing here is work yet: a unit becomes a card on the board only when it is taken into work.`})]}),(0,I.jsxs)(`div`,{className:`design-bar`,children:[(0,I.jsxs)(`div`,{className:`design-bar-head`,children:[(0,I.jsx)(`h1`,{children:`Design`}),(0,I.jsx)(`span`,{children:m})]}),(0,I.jsx)(`div`,{role:`tablist`,"aria-label":`Parts of the design`,className:`design-bar-tabs`,children:p.map(e=>(0,I.jsxs)(`button`,{role:`tab`,className:`design-bar-tab`,"aria-selected":e===n,title:d[e],onClick:()=>r(e),children:[Cx[e],u[e]&&(0,I.jsx)(`span`,{className:`design-count${f(e)}`,children:u[e]})]},e))})]})]})}function Bx({ctx:e,d:t,go:n}){let r=e.board.domain.sections.design,i=Tr(e.board.domain,r?.commit),a=Tr(e.board.domain,r?.discard),o=t.unrecorded,[s,c]=(0,v.useState)(null);return o.length?(0,I.jsxs)(`section`,{className:`design-unrec`,"aria-label":`Not recorded yet`,children:[(0,I.jsxs)(`div`,{className:`design-unrec-main`,children:[(0,I.jsxs)(`div`,{className:`design-unrec-head`,children:[(0,I.jsx)(`h2`,{children:`Not recorded yet`}),(0,I.jsxs)(`span`,{children:[o.length===1?`1 file waits`:`${o.length} files wait`,` to be recorded`]})]}),(0,I.jsx)(`div`,{className:`design-unrec-files`,children:o.map(e=>{let t=hr(e);return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`code`,{title:`Written by a design thread or an agent's draft; git has not recorded it yet`,children:e}),t&&(0,I.jsx)(`button`,{className:`design-open`,title:`Edit it in its part's form: a save of the part records the draft along with your edits`,onClick:()=>n(t),children:`open in its form →`})]},e)})}),(0,I.jsx)(`span`,{className:`design-note`,children:`Look it over, then record it: one commit. Or edit it in its form: the save takes it along. A save that touches another waiting file waits for it.`})]}),(0,I.jsxs)(`div`,{className:`design-unrec-acts`,children:[i&&(0,I.jsx)(`button`,{className:`design-rec`,title:t.blocking?`gcf design commit: refused while the design check has findings; the dialog gives the framework's answer`:`gcf design commit: one commit of the files that wait`,onClick:()=>c(`record`),children:`Record design…`}),a&&o.some(gr)&&(0,I.jsx)(`button`,{className:`design-danger`,title:`gcf design discard: the draft's files as the last record has them, a new one deleted; it asks first`,onClick:()=>c(`discard`),children:`Discard draft…`})]}),s&&(0,I.jsx)(Zx,{ctx:e,kind:s,onClose:()=>c(null)})]}):null}function Vx({ctx:e,d:t,go:n}){let r=e.board.units??[];return t.blocking?(0,I.jsxs)(`section`,{className:`design-findings`,"aria-label":`Findings of the design check`,children:[(0,I.jsxs)(`div`,{className:`design-findings-head`,title:`design.blocking: findings of the design check that hold every commit`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`!`}),(0,I.jsxs)(`span`,{children:[Ox(t.blocking,`blocking finding`),` of the design check: nothing commits until the check is clean. A save that clears the last one goes.`]})]}),(0,I.jsx)(`ul`,{children:(t.findings??[]).map((e,t)=>{let i=r.some(t=>t.id===e.id);return(0,I.jsxs)(`li`,{children:[(0,I.jsxs)(`span`,{className:`design-find-where`,children:[(0,I.jsx)(`code`,{className:`design-find-check`,title:`The check that found it`,children:e.check}),(0,I.jsxs)(`code`,{children:[e.file,e.line==null?``:`:${e.line}`]})]}),(0,I.jsxs)(`span`,{className:`design-find-main`,children:[(0,I.jsx)(`span`,{className:`design-find-msg`,children:e.message}),i?(0,I.jsxs)(`button`,{className:`design-find-open`,title:`Open the unit ${e.id}`,onClick:()=>n(`units:${e.id}`),children:[`open `,e.id,` →`]}):e.id&&(0,I.jsx)(`span`,{className:`design-find-id`,title:`${e.id} is not a unit: fix it in ${e.file}`,children:e.id})]})]},t)})})]}):null}function Hx({ctx:e,file:t,importing:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),s=async()=>{if(o(!a),!a)try{i((await k.file(e.project.name,t)).text)}catch{i(``)}},c=Sr(r??``);return(0,I.jsxs)(`div`,{className:`design-source-card`,children:[(0,I.jsxs)(`div`,{className:`design-source-row`,children:[(0,I.jsx)(`code`,{children:t}),(0,I.jsx)(`button`,{className:`design-small-btn`,"aria-expanded":a,title:`Its text as kept in gcf/source/, by its anchored sections`,onClick:()=>void s(),children:a?`hide`:`view`}),!n&&(0,I.jsx)(Nx,{ctx:e,label:`Import a new version`})]}),n&&(0,I.jsxs)(`div`,{role:`status`,className:`design-importing`,children:[(0,I.jsx)(`span`,{children:`Import unfinished: pick the same GDD again to go on.`}),(0,I.jsx)(Nx,{ctx:e,label:`Pick the same GDD again`,big:!0})]}),a&&(0,I.jsxs)(`div`,{className:`design-gdd`,children:[(0,I.jsxs)(`span`,{className:`design-gdd-head`,children:[t,` · `,c.filter(e=>e.level>1).length,` sections, each anchored`]}),r!==null&&!c.length&&(0,I.jsx)(`span`,{className:`design-gdd-none`,children:`The board could not read the GDD's text.`}),c.map((e,t)=>(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:e.level===1?`top`:void 0,children:e.h}),e.body&&(0,I.jsx)(`p`,{children:e.body})]},t))]})]})}function Ux({ctx:e,d:t,go:n}){let r=e.board.domain.starts??{},i=cr(e.board),a=e.board.units??[],o=lr(e.board),[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)(!1),d=i.filter(e=>e.done).length,f=i.length>0&&d===i.length,p=i.find(e=>!e.done)?.id,m=o.filter(e=>e.class!==`D2`&&!e.answer).length,h=a.filter(e=>e.ready),g=a.filter(e=>e.blocked_by.length),_=Object.keys(t.systems).length,y=t.pillars.some(e=>!e.name),b={design:a.length||t.game?[`${Ox(a.length,`design unit`)} in ${Ox(_,`subsystem`)}`,t.game?`the vision written (game.md)`:`no vision yet`,t.glossary?`${t.glossary} glossary terms`:``,t.sources[0]?`imported from ${t.sources[0].file.split(`/`).pop()}`:``].filter(Boolean).join(` · `):`nothing yet: no design unit, no vision`,pillars:t.pillars.length?`${Ox(t.pillars.length,`pillar`)}: ${t.pillars.map(e=>e.name||`${e.id} (no name yet)`).join(`, `)}`:`no pillar yet: 2 to 7`,questions:m?`${m} waiting for your answer`:o.length?`none waits for your answer`:`no question yet`,work:h.length?`${Ox(h.length,`ready unit`)}: ${h.map(e=>e.id).join(`, `)}`:a.length?`no unit is ready yet: each has a TBD or a question`:`no unit yet`},x=(e,t,r)=>(0,I.jsxs)(`button`,{className:`design-link${r?` big`:``}`,onClick:()=>n(e),children:[t,` →`]});return(0,I.jsxs)(`section`,{className:`design-sec design-start`,"aria-label":`Start`,children:[(0,I.jsxs)(`div`,{className:`design-start-head`,children:[(0,I.jsx)(`h2`,{children:f?`The design is set`:d===0?`A game starts with its design`:`From an idea to the first work`}),(0,I.jsx)(`p`,{children:f?`All four steps are done. The pillars and the units change all along the project: their parts are on the left, and Start stays at the end of the list.`:d===0?`Four steps from an idea to the first work. Begin with the game design: bring a GDD, or talk the game through with an agent.`:`Four steps, each done or not by the framework's count. A done step stays here: you may go back to any of them.`})]}),(0,I.jsx)(`ol`,{className:`design-steps`,children:i.map((a,o)=>{let d=a.id===p,f=s[a.id]??(!a.done&&d),_=(a.starts??[]).filter(e=>r[e]&&r[e].takes!==`unit`&&(e!==`name-pillars`||y));return(0,I.jsxs)(`li`,{className:`design-step`,children:[(0,I.jsxs)(`div`,{className:`design-step-rail`,"aria-hidden":`true`,children:[(0,I.jsx)(`span`,{className:`design-step-mark${a.done?` done`:d?` cur`:``}`,children:a.done?`✔`:o+1}),o<i.length-1&&(0,I.jsx)(`span`,{className:`design-step-line`})]}),(0,I.jsxs)(`div`,{className:`design-step-body${d?` cur`:``}`,children:[(0,I.jsxs)(`button`,{className:`design-step-toggle`,"aria-expanded":f,title:f?`Fold the step`:`Open the step and its ways in`,onClick:()=>c({...s,[a.id]:!f}),children:[(0,I.jsxs)(`span`,{className:`design-step-text`,children:[(0,I.jsxs)(`span`,{className:`design-step-titles`,children:[(0,I.jsx)(`span`,{className:`design-step-title${!a.done&&!d?` later`:``}`,children:a.label}),(0,I.jsx)(`span`,{className:`design-step-state${a.done?` done`:d?` cur`:``}`,title:a.done?`The framework counts this step done (design.steps); you may go back to it at any time`:`Not done yet, by the framework's count (design.steps)`,children:a.done?`done`:d?`next`:`not done`})]}),(0,I.jsx)(`span`,{className:`design-step-summary`,children:b[a.id]??``})]}),(0,I.jsx)(`span`,{className:`design-step-fold`,children:f?`Close`:a.done?`Go back to it`:`Open`})]}),f&&(0,I.jsxs)(`div`,{className:`design-step-open`,children:[(0,I.jsx)(`p`,{className:`design-step-help`,children:a.help}),a.id===`design`&&(0,I.jsxs)(`div`,{className:`design-step-design`,children:[(0,I.jsx)(`div`,{className:`design-ways`,children:_.map((t,n)=>(0,I.jsx)(Mx,{ctx:e,k:t,primary:n===0},t))}),x(`units`,`or write units by hand`),(0,I.jsxs)(`div`,{className:`design-learn`,children:[(0,I.jsxs)(`button`,{className:`design-learn-btn`,"aria-expanded":l,title:`What the import writes into the project`,onClick:()=>u(!l),children:[l?`▾ `:`▸ `,`What an import gives`]}),l&&(0,I.jsx)(`dl`,{children:Ex.map(([e,t])=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:e}),(0,I.jsx)(`dd`,{children:t})]},e))})]}),t.sources.length>0&&(0,I.jsxs)(`div`,{className:`design-sources`,children:[(0,I.jsx)(`h3`,{className:`design-h3`,children:`GDD sources`}),t.sources.map(t=>(0,I.jsx)(Hx,{ctx:e,file:t.file,importing:t.importing},t.file))]})]}),a.id!==`design`&&(_.length>0||a.id===`pillars`)&&(0,I.jsxs)(`div`,{className:`design-step-ways`,children:[_.map((t,n)=>(0,I.jsx)(jx,{ctx:e,k:t,named:!0,primary:n===0},t)),a.id===`pillars`&&x(`pillars`,`or write them by hand`)]}),a.id===`questions`&&(0,I.jsxs)(`div`,{className:`design-step-list`,children:[x(`questions`,`${m} waiting for your answer`,!0),g.length>0&&(0,I.jsxs)(`div`,{className:`design-held-list`,children:[(0,I.jsx)(`span`,{children:`Units a question holds`}),g.map(e=>(0,I.jsxs)(`button`,{title:`Open the unit`,onClick:()=>n(`units:${e.id}`),children:[(0,I.jsx)(`span`,{className:`design-held-id`,children:e.id}),(0,I.jsxs)(`span`,{className:`design-held-by`,children:[`held by `,e.blocked_by.join(`, `)]})]},e.id))]})]}),a.id===`work`&&(0,I.jsxs)(`div`,{className:`design-step-list`,children:[h.map(e=>(0,I.jsxs)(`button`,{className:`design-ready`,title:`Open the unit: Fill TBDs with agent takes it into work on your word`,onClick:()=>n(`units:${e.id}`),children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`span`,{className:`design-held-id`,children:e.id}),(0,I.jsx)(`span`,{className:`design-ready-mark`,children:`ready`})]}),(0,I.jsx)(`span`,{className:`design-ready-title`,children:e.title})]},e.id)),x(`units`,`pick a ready unit`),(0,I.jsx)(`span`,{className:`design-fine`,children:`In the unit, Fill TBDs with agent goes through it with you; it goes into work only when you say so.`})]})]})]})]},a.id)})})]})}function Wx({ctx:e,d:t}){let n=!t.pillars.length,r=t.pillars.filter(e=>!e.name).length;return(0,I.jsxs)(`section`,{className:`design-sec`,"aria-label":`Pillars`,children:[(0,I.jsxs)(`div`,{className:`design-head`,children:[(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`h2`,{children:`Pillars`}),(0,I.jsx)(`span`,{className:`design-lead`,children:`What the game always holds: every unit and every review answers to them. One part, gcf/PILLARS.md: Save writes all of them together.`})]}),!n&&(0,I.jsx)(jx,{ctx:e,k:`pillars`})]}),n&&(0,I.jsxs)(`div`,{className:`design-empty-panel`,children:[(0,I.jsx)(`h3`,{children:`PILLARS.md is empty`}),(0,I.jsx)(`span`,{className:`design-empty-text`,children:`The interview starts from candidates the agent draws from the vision and the units: you keep 2 to 7, each with what it forbids and the question a review asks. The draft waits under Not recorded yet until you record it.`}),(0,I.jsx)(jx,{ctx:e,k:`pillars`,primary:!0}),(0,I.jsx)(`span`,{className:`design-fine`,children:`Or write one by hand below.`})]}),r>0&&(0,I.jsxs)(`div`,{className:`design-unnamed`,role:`note`,children:[(0,I.jsxs)(`span`,{children:[r===1?`1 pillar has`:`${r} pillars have`,` no name yet: it shows its id until one is given`]}),(0,I.jsx)(jx,{ctx:e,k:`name-pillars`})]}),(0,I.jsx)(Rx,{ctx:e,kind:`doc`,name:`pillars`,rows:14}),!n&&(0,I.jsx)(Px,{ctx:e,k:`revise-pillars`,label:`Revise with agent`,help:`Say what to change: the agent proposes, you confirm in the thread.`})]})}function Gx({ctx:e,d:t}){return(0,I.jsxs)(`section`,{className:`design-sec`,"aria-label":`Vision and scope`,children:[(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`h2`,{children:`Vision & scope`}),(0,I.jsx)(`code`,{className:`design-path`,children:`gcf/game.md`})]}),!t.game&&(0,I.jsxs)(`div`,{className:`design-panel design-novision`,children:[(0,I.jsx)(`span`,{children:`No vision yet. An import drafts it from the GDD; Create with agent writes it in an interview.`}),(0,I.jsx)(jx,{ctx:e,k:`vision`}),(0,I.jsx)(`span`,{className:`design-fine`,children:`Or write it by hand below.`})]}),(0,I.jsx)(Rx,{ctx:e,kind:`doc`,name:`game`}),t.game&&(0,I.jsx)(Px,{ctx:e,k:`revise-vision`,label:`Change with agent`,help:`The vision, the scope or the milestones, in your words.`})]})}function Kx({ctx:e,d:t}){let n=t.glossary??0;return(0,I.jsxs)(`section`,{className:`design-sec`,"aria-label":`Glossary`,children:[(0,I.jsxs)(`div`,{className:`design-head`,children:[(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`h2`,{children:`Glossary`}),(0,I.jsxs)(`span`,{className:`design-path`,children:[`gcf/glossary.md · `,n,` terms`]})]}),(0,I.jsx)(jx,{ctx:e,k:`draft-glossary`,primary:!n})]}),!n&&(0,I.jsxs)(`p`,{className:`design-empty`,children:[`No glossary yet. Draft with agent writes one from the vision and the units; it waits under Not recorded yet for you to record, edit or discard.`,(0,I.jsx)(`span`,{className:`design-fine design-empty-fine`,children:`Or write it by hand below.`})]}),(0,I.jsx)(Rx,{ctx:e,kind:`doc`,name:`glossary`})]})}function qx({ctx:e,d:t,onClose:n,onMade:r}){let i=e.board.domain.sections.design,a=Tr(e.board.domain,i?.new_unit),o=Object.keys(t.systems),s=e=>a?.fields.find(t=>t.key===e),c=s(`type`)?.options?.map(e=>e.value)??wx,[l,u]=(0,v.useState)({system:o[0]??``,type:c.includes(`mechanic`)?`mechanic`:c[0]??``,title:``}),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(void 0),[h,g]=(0,v.useState)(!1);if(!a)return null;let _=(e,t)=>{u({...l,[e]:t}),f(``),m(void 0)},y=(e,t)=>`${s(e)?.label??t} *`,b=!!l.system&&!o.includes(l.system),x=b&&!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(l.system),S=async()=>{let t=[!l.system.trim()&&y(`system`,`Subsystem`),!l.title.trim()&&y(`title`,`Title`)].filter(Boolean);if(t.length)return f(`${t.join(`, `)}: required`);if(x)return f(`system: a subsystem is a lowercase slug (letters, digits, hyphens), e.g. tray-input`);m(void 0),g(!0);let n=await e.moveOut({cmd:a.cmd,...l,fields:`{}`});g(!1);let i=n.out.split(`
86
- `)[0].trim();n.ok&&i?r(i):(f(n.err||`The framework refused it: its answer is in the notice.`),m(n.refusal))};return(0,I.jsx)(R,{onClose:n,dirty:h||!!l.title,children:(0,I.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Add a design unit`,className:`design-dialog`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`design-dialog-head`,children:[(0,I.jsx)(`h2`,{children:`Add a design unit`}),(0,I.jsxs)(`span`,{children:[a.help,`. Every block of its type starts TBD; it lands at the end of its subsystem's file and of backlog.md, and opens.`]})]}),(0,I.jsxs)(`div`,{className:`design-dialog-field`,children:[(0,I.jsx)(`span`,{children:y(`system`,`Subsystem`)}),o.length>0&&(0,I.jsx)(`div`,{role:`radiogroup`,"aria-label":`Existing subsystems`,className:`design-sys-chips`,children:o.map(e=>(0,I.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===l.system,className:`design-sys-chip${e===l.system?` on`:``}`,onClick:()=>_(`system`,e),children:e},e))}),(0,I.jsx)(`input`,{className:`design-input mono${x?` bad`:b?` new`:``}`,"aria-label":o.length?`New subsystem`:`No subsystem yet: name the first one`,value:b?l.system:``,placeholder:o.length?`or a new one: tray-input`:`a new subsystem: tray-input`,onChange:e=>_(`system`,e.target.value.trim())}),b&&(0,I.jsx)(`span`,{className:`design-sys-note${x?` bad`:``}`,children:x?`A subsystem is a lowercase slug: letters, digits and hyphens, e.g. tray-input`:`New: gcf/design/${l.system}.md starts with this unit`})]}),(0,I.jsxs)(`label`,{className:`design-dialog-field`,children:[(0,I.jsx)(`span`,{children:y(`type`,`Type`)}),(0,I.jsx)(`select`,{className:`design-input`,value:l.type,onChange:e=>_(`type`,e.target.value),children:c.map(e=>(0,I.jsx)(`option`,{children:e},e))})]}),(0,I.jsxs)(`label`,{className:`design-dialog-field`,children:[(0,I.jsx)(`span`,{children:y(`title`,`Title`)}),(0,I.jsx)(`input`,{className:`design-input`,value:l.title,onChange:e=>_(`title`,e.target.value)})]}),(0,I.jsxs)(`code`,{className:`design-dialog-cmd`,children:[`gcf design save --kind unit --system `,l.system||`<subsystem>`,` --type`,` `,l.type||`<type>`,` --title `,l.title?(e=>/\s/.test(e)?`"${e}"`:e)(l.title):`<title>`]}),d&&(0,I.jsx)(Jx,{ctx:e,error:d,refusal:p}),(0,I.jsxs)(`div`,{className:`design-dialog-acts`,children:[(0,I.jsx)(`button`,{className:`design-cancel`,disabled:h,onClick:n,children:`Cancel`}),(0,I.jsx)(`button`,{className:`design-prim`,disabled:h,onClick:()=>void S(),children:h?`Working…`:`Add unit`})]})]})})}function Jx({ctx:e,error:t,refusal:n}){return(0,I.jsxs)(`div`,{role:`alert`,className:`design-dialog-err`,children:[(0,I.jsx)(`span`,{children:t}),n&&(0,I.jsx)(v_,{ctx:e,refusal:n,error:t,again:`the button below tries again`},n.paths.join(`
87
- `))]})}var Yx={record:()=>`Record the design`,discard:()=>`Discard the draft?`,retire:e=>`Retire pillar ${e}`,drop:e=>`Drop unit ${e}`},Xx={record:`Record design`,discard:`Discard draft`,retire:`Retire`,drop:`Drop`};function Zx({ctx:e,kind:t,id:n=``,onClose:r}){let i=e.board.domain.sections.design,a={record:i?.commit,discard:i?.discard,retire:i?.retire,drop:i?.drop}[t],o=Tr(e.board.domain,a),s=(e.board.units??[]).find(e=>e.id===n),[c,l]=(0,v.useState)(t===`drop`&&s?{tags:s.system}:{}),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(void 0),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(null);if(!o||!a)return null;let y=sr(e.board)?.unrecorded??[],b=t===`record`?y:t===`discard`?y.filter(gr):[],x=o.fields.filter(e=>!e.hidden),S=(e.board.domain.moves[a]?.args??[]).join(` `).replace(`{id}`,n),C=t===`discard`?`${o.help??``}. These files go back:`:o.help??``,w=async()=>{if(g)return r();p(void 0);let i=x.filter(e=>e.required&&!c[e.key]?.trim());if(i.length)return d(`${i.map(e=>e.label).join(`, `)}: required`);h(!0);let o=await e.moveOut({cmd:a,...n?{id:n}:{},...Nr(x,c)});if(h(!1),p(o.refusal),!o.ok)return d(o.err||o.out||`The framework refused it.`);if(t!==`drop`)return r();_({type:s?.type??``,reason:c.reason??``,tags:(c.tags??``).split(/[,\s]+/).filter(Boolean)})};return(0,I.jsx)(R,{onClose:r,dirty:m||Object.values(c).some(Boolean),children:(0,I.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":g?`Unit dropped`:Yx[t](n),className:`design-dialog`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`design-dialog-head`,children:[(0,I.jsx)(`h2`,{children:g?`Unit dropped`:Yx[t](n)}),!g&&C&&(0,I.jsx)(`span`,{children:C})]}),g&&(0,I.jsxs)(`div`,{className:`design-grave`,children:[(0,I.jsx)(`span`,{children:`In the graveyard (Ended), as an item's line`}),(0,I.jsxs)(`div`,{className:`design-grave-line`,children:[(0,I.jsx)(`code`,{children:n}),(0,I.jsx)(`span`,{className:`design-grave-type`,children:g.type}),(0,I.jsx)(`span`,{className:`design-grave-reason`,children:g.reason}),(0,I.jsx)(`span`,{className:`design-grave-tags`,children:g.tags.map(e=>(0,I.jsxs)(`span`,{children:[`#`,e]},e))})]})]}),!g&&b.length>0&&(0,I.jsx)(`div`,{className:`design-dialog-files`,children:b.map(e=>(0,I.jsx)(`code`,{children:e},e))}),!g&&x.map(e=>(0,I.jsxs)(`label`,{className:`design-dialog-field`,children:[(0,I.jsxs)(`span`,{children:[e.label,e.required?` *`:``]}),e.kind===`longtext`?(0,I.jsx)(`textarea`,{className:`design-input`,rows:3,value:c[e.key]??``,onChange:t=>l({...c,[e.key]:t.target.value})}):e.kind===`choice`?(0,I.jsx)(`select`,{className:`design-input`,value:c[e.key]??``,onChange:t=>l({...c,[e.key]:t.target.value}),children:(e.options??[]).map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,I.jsx)(`input`,{className:`design-input`,value:c[e.key]??``,onChange:t=>l({...c,[e.key]:t.target.value})})]},e.key)),!g&&(0,I.jsx)(`code`,{className:`design-dialog-cmd`,children:S}),u&&(0,I.jsx)(Jx,{ctx:e,error:u,refusal:f}),(0,I.jsxs)(`div`,{className:`design-dialog-acts`,children:[!g&&(0,I.jsx)(`button`,{className:`design-cancel`,disabled:m,onClick:r,children:`Cancel`}),(0,I.jsx)(`button`,{className:`design-prim${o.danger&&!g?` danger`:``}`,disabled:m,onClick:()=>void w(),children:m?`Working…`:g?`Done`:Xx[t]})]})]})})}function Qx(e,t){let[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=!0;return k.designPart(e.project.name,`system`,t).then(e=>{let t=e.fields.find(e=>e.key===`purpose`)?.value,i=Array.isArray(t)?t.join(` · `):typeof t==`string`?t:``;n&&r(e.exists?i||`TBD`:`no part yet`)},()=>n&&r(``)),()=>{n=!1}},[t,e.board.head]),n}function $x({ctx:e,system:t,list:n,open:r,go:i}){let a=sr(e.board)?.systems[t],o=Qx(e,t);return(0,I.jsxs)(`section`,{className:`design-sys`,"aria-label":`Subsystem ${t}`,children:[(0,I.jsxs)(`div`,{className:`design-sys-head`,children:[(0,I.jsxs)(`span`,{className:`design-sys-name`,children:[(0,I.jsx)(`span`,{children:t}),a&&(0,I.jsxs)(`span`,{className:`design-sys-sub`,title:`From design.systems: units, ready, values (filled slots) and TBDs in gcf/design/${t}.md`,children:[Ox(a.units,`unit`),` · `,a.ready,` ready · `,a.values,` values ·`,` `,a.tbd?`TBD ${a.tbd}`:`no TBD`]})]}),(0,I.jsxs)(`div`,{className:`design-sys-row`,children:[(0,I.jsxs)(`button`,{className:`design-purpose${r===`system:${t}`?` on`:``}`,title:`Open the subsystem's purpose in its form`,onClick:()=>i(`units:system:${t}`),children:[(0,I.jsx)(`span`,{className:`design-purpose-k`,children:`Purpose`}),(0,I.jsx)(`span`,{className:`design-purpose-v`,children:o}),(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`›`})]}),(0,I.jsx)(jx,{ctx:e,k:`draft-system`,system:t})]})]}),(0,I.jsxs)(`div`,{className:`design-sys-rows`,children:[n.map(e=>{let t=yr(e);return(0,I.jsxs)(`button`,{className:`design-unit-row${r===e.id?` on`:``}`,"aria-current":r===e.id||void 0,title:t.tip,onClick:()=>i(`units:${e.id}`),children:[(0,I.jsxs)(`span`,{className:`design-unit-top`,children:[(0,I.jsx)(`span`,{className:`design-unit-title`,children:e.title??e.id}),(0,I.jsx)(`span`,{className:`design-pill tone-${t.tone}`,children:t.state})]}),(0,I.jsxs)(`span`,{className:`design-unit-meta`,children:[(0,I.jsx)(`span`,{children:e.type}),(0,I.jsxs)(`span`,{children:[`(`,e.id,`)`]}),t.extra&&(0,I.jsx)(`span`,{className:`warn`,children:t.extra})]})]},e.id)}),!n.length&&(0,I.jsx)(`span`,{className:`design-none`,children:`no unit yet`})]})]})}function eS({ctx:e,d:t,open:n,go:r}){let i=e.board.units??[],a=Tr(e.board.domain,e.board.domain.sections.design?.drop),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=Map.groupBy(i,e=>e.system),d=[...new Set([...Object.keys(t.systems),...u.keys()])],f=n?.startsWith(`system:`)?n.slice(7):null,p=i.find(e=>e.id===n),m=(0,I.jsx)(`button`,{className:`design-back`,onClick:()=>r(`units`),children:`‹ Units`}),h=p&&yr(p);return(0,I.jsxs)(`section`,{className:`design-units${p||f?` has-open`:``}`,"aria-label":`Units`,children:[(0,I.jsxs)(`div`,{className:`design-unit-list`,children:[(0,I.jsxs)(`div`,{className:`design-head`,children:[(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`h2`,{children:`Units`}),(0,I.jsxs)(`span`,{className:`design-path small`,children:[i.length,` live units · `,i.filter(e=>e.ready).length,` ready`]})]}),e.board.domain.sections.design?.new_unit&&(0,I.jsx)(`button`,{className:`design-add-unit`,title:`A new unit: subsystem, type, title; its id comes from the title, every block starts TBD`,onClick:()=>s(!0),children:`+ Add unit`})]}),!d.length&&(0,I.jsx)(`p`,{className:`design-empty`,children:`No design unit yet. An import or Create with agent writes the first ones; Add unit writes one by hand.`}),d.map(t=>(0,I.jsx)($x,{ctx:e,system:t,list:u.get(t)??[],open:n,go:r},t))]}),!p&&!f&&d.length>0&&(0,I.jsx)(`div`,{className:`design-pick-one`,children:`Open a unit to see its form.`}),p&&h&&(0,I.jsxs)(`article`,{className:`design-open-part`,"aria-label":`Unit ${p.id}`,children:[m,(0,I.jsxs)(`div`,{className:`design-unit-head`,children:[(0,I.jsxs)(`span`,{className:`design-unit-id`,children:[(0,I.jsx)(`code`,{children:p.id}),(0,I.jsx)(`span`,{className:`tone-${h.tone}`,children:p.ready?`ready: no TBD, no question`:p.blocked_by.length?`held by ${p.blocked_by.join(`, `)}${p.tbd?` · TBD ${p.tbd}`:``}`:`TBD ${p.tbd}`})]}),(0,I.jsx)(`h2`,{children:p.title??p.id}),(0,I.jsxs)(`span`,{className:`design-path`,children:[p.type,` · `,p.file]})]}),(0,I.jsxs)(`div`,{className:`design-unit-acts`,children:[(0,I.jsx)(jx,{ctx:e,k:`card`,unit:p.id,primary:!0}),(0,I.jsx)(jx,{ctx:e,k:`debate-unit`,unit:p.id}),(0,I.jsx)(`span`,{className:`design-spacer`}),a&&(0,I.jsx)(Na,{label:`Drop the unit`,tip:`Drop…: the unit leaves the design into the graveyard, with the reason; it asks first`,onClick:()=>l(p.id)})]}),(0,I.jsx)(`span`,{className:`design-fine design-unit-hint`,children:`Fill TBDs with agent goes through the TBDs with you; it goes into work only on your word.`}),(0,I.jsxs)(`div`,{className:`design-held`,children:[(0,I.jsx)(`h3`,{className:`design-h3`,children:`Questions that hold it`}),!ur(e.board,p.id).length&&(0,I.jsx)(`span`,{className:`design-none`,children:`No question holds it.`}),ur(e.board,p.id).map(t=>(0,I.jsx)(Do,{ctx:e,q:t},t.id))]}),(0,I.jsx)(Rx,{ctx:e,kind:`unit`,name:p.id,rows:24},p.id)]}),f&&(0,I.jsxs)(`article`,{className:`design-open-part`,"aria-label":`Subsystem ${f}`,children:[m,(0,I.jsxs)(`div`,{className:`design-head`,children:[(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`span`,{className:`design-kicker`,children:`subsystem`}),(0,I.jsx)(`h2`,{className:`mono`,children:f})]}),(0,I.jsx)(jx,{ctx:e,k:`draft-system`,system:f})]}),(0,I.jsx)(Rx,{ctx:e,kind:`system`,name:f},f)]}),c&&(0,I.jsx)(Zx,{ctx:e,kind:`drop`,id:c,onClose:()=>{l(null),n===c&&r(`units`)}}),o&&(0,I.jsx)(qx,{ctx:e,d:t,onClose:()=>s(!1),onMade:e=>{s(!1),r(`units:${e}`)}})]})}function tS({ctx:e}){let t=lr(e.board),n=t.filter(e=>e.class!==`D2`),r=t.filter(e=>e.class===`D2`),[i,a]=(0,v.useState)(!1),o=n.filter(e=>!e.answer).length,s=t=>{let n=br(e.board,t),r=`q:${t.id}`,i=t.sys&&t.sys!==`-`?t.sys:``;return(0,I.jsx)(Ma,{cat:n.label,catTip:n.help,tone:n.needs?`needs`:void 0,needs:n.needs&&!t.answer,origin:t.origin??`agent`,title:(t.class===`D2`?t.assumed:t.question)??t.id,sub:t.blocks?`blocks ${t.blocks}`:i,mark:t.answer?`✔ answered`:t.proposed?`a proposal`:void 0,markTone:t.answer?`ok`:`text`,on:e.detailKey===r,onOpen:()=>e.openDetail({key:r,render:e=>{let n=lr(e.board).find(e=>e.id===t.id);if(!n)return null;let r=br(e.board,n);return{cat:r.label,catTip:r.help,tone:r.needs?`needs`:void 0,origin:n.origin??`agent`,body:(0,I.jsx)(Do,{ctx:e,q:n})}}})},t.id)},c=t=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`design-desk`,children:(0,I.jsx)(Pa,{children:t.map(s)})}),(0,I.jsx)(`div`,{className:`design-phone`,children:t.map(t=>(0,I.jsx)(Do,{ctx:e,q:t},t.id))})]});return(0,I.jsxs)(`section`,{className:`design-sec design-qs`,"aria-label":`Questions`,children:[(0,I.jsx)(`div`,{className:`design-head`,children:(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`h2`,{children:`Questions`}),(0,I.jsx)(`span`,{className:`design-lead`,children:`What the design leaves open. Inbox lists the same questions: one record, answered in either place.`}),(0,I.jsx)(jx,{ctx:e,k:`debate`})]})}),!t.length&&(0,I.jsx)(`p`,{className:`design-empty`,children:`No open question. An import or a review with agent writes them here.`}),n.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`h3`,{className:`design-h3`,children:[`Waiting for your answer`,(0,I.jsxs)(`span`,{className:`design-h3-count`,children:[o,` waiting · `,n.length-o,` answered`]})]}),c(n)]}),r.length>0&&(0,I.jsxs)(`button`,{className:`design-fold`,"aria-expanded":i,onClick:()=>a(!i),children:[i?`▾ `:`▸ `,br(e.board,r[0]).label,` · `,r.length]}),i&&c(r)]})}function nS({ctx:e}){let t=e.board.domain.sections.design,[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=async()=>{let t=await fetch(A(e.project.name));if(!t.ok)throw Error(await t.text());return t.text()},l=async()=>{r(`export`);try{let e=await c(),t=document.createElement(`a`);t.href=URL.createObjectURL(new Blob([e],{type:`text/markdown`})),t.download=`design.md`,t.click(),setTimeout(()=>URL.revokeObjectURL(t.href),0),a(e)}catch(t){e.notify(t.message,`error`)}r(null)},u=async()=>{if(i!==null)return a(null);try{a(await c())}catch(t){e.notify(t.message,`error`)}},d=async n=>{if(!t)return;r(`import`),s(null);let i=await e.moveOut({cmd:t.import,bundle:await n.text()});r(null),!i.ok&&i.refusal&&E_(i.refusal,i.err);let a=Cr(i.out);(i.ok||a.applied.length||a.report.length)&&s({name:n.name,...a})};return(0,I.jsxs)(`section`,{className:`design-sec`,"aria-label":`Designer`,children:[(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`h2`,{children:`Designer`}),(0,I.jsx)(`span`,{className:`design-lead design-narrow`,children:`For a designer who edits the design like a document: the whole of it in one markdown file, out and back, without an agent.`})]}),(0,I.jsxs)(`div`,{className:`design-cards`,children:[(0,I.jsxs)(`div`,{className:`design-card`,children:[(0,I.jsx)(`h3`,{children:`Export`}),(0,I.jsx)(`span`,{children:`One markdown file: the pillars, the vision, the glossary and every unit. Its gcf:part comments mark each part: keep them, the import reads them.`}),(0,I.jsx)(`button`,{className:`design-card-btn`,disabled:n===`export`,title:`gcf design export: downloads the file`,onClick:()=>void l(),children:n===`export`?`Exporting…`:`Export`})]}),t&&(0,I.jsxs)(`div`,{className:`design-card`,children:[(0,I.jsx)(`h3`,{children:`Import`}),(0,I.jsx)(`span`,{children:`Brings the edited file back. A part changed in the project since the export is reported, never overwritten.`}),(0,I.jsxs)(`label`,{className:`design-card-btn design-pick-plain${n===`import`?` off`:``}`,title:`gcf design import --commit: pick the edited .md`,children:[n===`import`?`Importing…`:`Import`,(0,I.jsx)(`input`,{type:`file`,accept:`.md,text/markdown`,"aria-label":`Import the designer's file`,disabled:n===`import`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&d(t)}})]})]})]}),o&&(0,I.jsxs)(`section`,{role:`status`,"aria-label":`Import report`,className:`design-report`,children:[(0,I.jsxs)(`h3`,{children:[o.name,` imported`]}),(0,I.jsxs)(`div`,{className:`design-report-list`,children:[(0,I.jsx)(`span`,{children:`Written`}),o.applied.map(e=>(0,I.jsxs)(`code`,{className:`design-applied`,children:[`✔ `,e]},e))]}),o.report.length>0&&(0,I.jsxs)(`div`,{className:`design-report-list`,children:[(0,I.jsx)(`span`,{children:`Not written: reported, kept as they are in the project`}),o.report.map(e=>(0,I.jsxs)(`div`,{className:`design-reported`,children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`code`,{children:e.part}),(0,I.jsx)(`span`,{className:`design-outcome`,children:e.outcome})]}),(0,I.jsx)(`span`,{className:`design-reported-note`,children:e.note})]},e.part))]})]}),(0,I.jsxs)(`div`,{className:`design-export-wrap`,children:[(0,I.jsxs)(`button`,{className:`design-fold mono`,"aria-expanded":i!==null,title:`The file Export gives right now, the same as the download`,onClick:()=>void u(),children:[i===null?`▸ `:`▾ `,`What Export gives · design.md`]}),i!==null&&(0,I.jsx)(`div`,{className:`design-export`,children:i.split(`
88
- `).map((e,t)=>(0,I.jsx)(`div`,{className:/^<!-- gcf:/.test(e)?`marker`:/^<!--/.test(e)?`comment`:void 0,children:e||` `},t))})]})]})}function rS({ctx:e,arg:t}){let[n,...r]=(t??``).split(`:`),i=Sx.includes(n)?n:`start`,a=r.join(`:`)||null,o=t=>e.go(`design`,t),s=sr(e.board),c=e.board.design&&`error`in e.board.design?e.board.design.error:``,l=$a(e.board.quota);return(0,I.jsxs)(`div`,{className:`design-screen part-${i}`,children:[s&&(0,I.jsx)(zx,{ctx:e,d:s,part:i,go:o}),(0,I.jsx)(`div`,{className:`design-main`,children:s&&(0,I.jsxs)(`div`,{className:`design-content`,children:[l&&(0,I.jsxs)(`div`,{role:`note`,className:`design-limit`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),(0,I.jsxs)(`span`,{children:[`Off until `,oi(l),`: the usage limit holds for the account. The forms work without an agent.`]})]}),(0,I.jsx)(Bx,{ctx:e,d:s,go:o}),(0,I.jsx)(Vx,{ctx:e,d:s,go:o}),i===`start`&&(0,I.jsx)(Ux,{ctx:e,d:s,go:o}),i===`pillars`&&(0,I.jsx)(Wx,{ctx:e,d:s}),i===`vision`&&(0,I.jsx)(Gx,{ctx:e,d:s}),i===`glossary`&&(0,I.jsx)(Kx,{ctx:e,d:s}),i===`units`&&(0,I.jsx)(eS,{ctx:e,d:s,open:a,go:o}),i===`questions`&&(0,I.jsx)(tS,{ctx:e}),i===`designer`&&(0,I.jsx)(nS,{ctx:e})]})}),c&&(0,I.jsx)(`div`,{role:`alert`,"aria-label":`The design check cannot run`,className:`design-cannot`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{children:`Design · the design check cannot run`}),(0,I.jsx)(`code`,{children:c}),(0,I.jsx)(`span`,{children:`The board reads the design with its check; until the check runs, no part of the design shows. The rest of the board works. The screen comes back by itself with the next read.`})]})})]})}function iS({ctx:e,spec:t,onClose:n}){let r=eb(),i=t.render(e),a=!i;return(0,v.useEffect)(()=>{a&&n()},[a,n]),i?(0,I.jsxs)(`aside`,{className:`drawer detail-win`,"aria-label":`Detail window`,...r,children:[(0,I.jsx)(`div`,{className:`d-head`,title:`Drag to move the window`,children:(0,I.jsxs)(`div`,{className:`d-top detail-top`,children:[(0,I.jsx)(`button`,{className:`d-back`,"aria-label":`Back`,onClick:n,children:`‹`}),(0,I.jsx)(`span`,{className:`tile-cat tone-${i.tone??`neutral`}`,title:i.catTip,children:i.cat}),i.origin&&(0,I.jsx)(`span`,{className:`tile-origin`,title:`where it came from: it never changes`,children:i.origin}),i.age&&(0,I.jsx)(`span`,{className:`detail-age`,title:i.ageTip,children:i.age}),(0,I.jsx)(`span`,{className:`detail-esc`,"aria-hidden":`true`,children:`Esc`}),(0,I.jsx)(`button`,{className:`icon-btn bordered d-close`,"aria-label":`Close`,title:`Close · Esc`,onClick:n,children:`×`})]})}),(0,I.jsx)(`div`,{className:`d-body detail-body`,children:i.body})]}):null}var aS=[[`run`,`An agent session works on an item; the board starts it through the harness`],[`running`,`The column of the items an agent session works on now`],[`queue`,`Runs in the project folder go one at a time; the next waits in the queue`],[`worktree / main`,`Where a run works: its own git worktree (several at once) or the folder`],[`handoff`,`At the context share a session hands its item to a fresh one, from the plan`],[`usage limit`,`A run waits for the limit to reset, then goes on by itself; Stop ends the wait`],[`resume`,`A rerun goes on in the session or worktree the last run left`],[`permissions`,`What agent runs may not do: deny groups and custom rules`]];function oS(e){return[...e.terms.map(e=>({group:`Terms`,term:e.term,help:e.help})),...e.columns.map(e=>({group:`Columns`,term:e.label,help:e.help})),...Object.entries(e.moves).flatMap(([e,t])=>t.help?[{group:`Moves`,term:e===t.label?e:`${t.label} (${e})`,help:t.help}]:[]),...e.fields.flatMap(e=>[...e.help?[{group:`Fields`,term:e.label,help:e.help}]:[],...(e.options??[]).flatMap(t=>t.help?[{group:`Fields`,term:`${e.label}: ${t.label}`,help:t.help}]:[])]),...aS.map(([e,t])=>({group:`Runs`,term:e,help:t}))]}var sS=[[`Space on a card`,`Pick the card up to move it without the mouse: ← → the column, ↑ ↓ its rank among ready cards, Space drops it, Esc puts it back`],[`Right click on chat text`,`With text selected: Copy, or Reply (it quotes the text into your message). On a phone, the Reply button under the selection`],[`/`,`Search: the board's filter on the board, the inbox's on the inbox, Help's in Help`],[`i`,`Quick capture: a new inbox entry, from any screen`],[`n`,`New item`],[`j / k`,`Move between cards`],[`Enter`,`Opens the focused card; in the inbox field adds the entry, Shift+Enter breaks the line`],[`Esc`,`Closes a dialog, a menu, Help or the item's window; a dialog with typed text stays`],[`r`,`Runs the focused card: it asks first, the card is not opened`],[`1–7`,`Focus a column`],[`?`,`Help`],[`j / k on Inbox`,`Move between records; Enter opens the record's window, s Sort…, l Later or Back, e Erase, Esc closes the window`],[`g, then a letter`,`Go to a screen: g c Command, g b Board, g t Chat, g i Inbox, g d Design, g r Runs, g p Playtest, g e Ended, g a Agent, g s Settings, g m Metrics`],[`Ctrl+Enter`,`Sends a chat message`]];function cS({domain:e,onClose:t}){let[n,r]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=e=>e.key===`Escape`&&!e.defaultPrevented&&!document.querySelector(`.modal`)&&t();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let i=n.trim().toLowerCase(),a=[...oS(e),...sS.map(([e,t])=>({group:`Keys`,term:e,help:t}))].filter(e=>!i||`${e.term} ${e.help}`.toLowerCase().includes(i)),o=[...new Set(a.map(e=>e.group))];return(0,I.jsxs)(`aside`,{className:`help`,role:`dialog`,"aria-label":`Help`,children:[(0,I.jsxs)(`div`,{className:`help-head`,children:[(0,I.jsx)(`h2`,{children:`Help`}),(0,I.jsx)(`button`,{className:`icon-btn`,"aria-label":`Close help`,onClick:t,children:`×`})]}),(0,I.jsx)(`div`,{className:`help-search`,children:(0,I.jsx)(`input`,{className:`input`,type:`search`,"aria-label":`Search the help`,value:n,onChange:e=>r(e.target.value),placeholder:`search a word: handoff, gate, unplayed…`,autoFocus:!0})}),(0,I.jsxs)(`div`,{className:`help-body`,children:[!a.length&&(0,I.jsxs)(`p`,{className:`dim`,children:[`Nothing found for “`,n,`”.`]}),o.map(e=>{let t=a.filter(t=>t.group===e);return(0,I.jsxs)(`section`,{"aria-label":e,children:[(0,I.jsxs)(`h3`,{children:[e,` · `,t.length]}),(0,I.jsx)(`dl`,{children:t.map((e,t)=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:e.term}),(0,I.jsx)(`dd`,{children:e.help})]},`${e.term}-${t}`))})]},e)})]})]})}var lS=50,uS=Date.now();function dS({ctx:e,id:t}){let[n,r]=(0,v.useState)(``);(0,v.useEffect)(()=>F(e.project.name,t,()=>r(``),e=>r(t=>(t+e).slice(-32768))),[e.project.name,t]);let i=yy(n).filter(e=>e.kind!==`start`).slice(-6);return(0,I.jsxs)(`div`,{className:`runs-log`,"aria-live":`polite`,"aria-label":`Live log`,children:[!i.length&&(0,I.jsx)(`span`,{className:`dim`,children:`no output yet`}),i.map((e,t)=>(0,I.jsxs)(`div`,{className:`log-${e.kind}`,children:[(0,I.jsx)(`span`,{className:`dim`,children:e.time}),(0,I.jsx)(`span`,{title:e.text,children:e.text})]},t))]})}var fS=(e,t)=>e&&(e.model||e.effort)?`on ${e.model??`its own model`} · ${e.effort??`its own effort`} · ${t}`:`on its own model`;function pS({ctx:e,run:t,list:n}){let r=`run:${t.id??`old-${t.ended}`}`,i=t.started&&t.started.slice(0,10)===t.ended.slice(0,10)?oi(t.ended):Ly(t.ended),a=`${t.items.length} item${t.items.length>1?`s`:``}`,o=Date.parse(t.ended)>uS,s=[...new Set(t.items.map(e=>e.result))],c=s.some(e=>Vy[e]!==`ok`),l=t=>e.board.items.find(e=>e.id===t)?.title||t;return(0,I.jsx)(Ma,{cat:t.started?`${Ly(t.started)} → ${i}`:`ended ${i}`,origin:t.mode,age:t.started?Ry(Date.parse(t.ended)-Date.parse(t.started)):``,title:t.items.map(e=>l(e.id)).join(` · `),sub:`${By(t.cost_usd)} · ${a}${o?` · this session`:``}`,mark:s.join(` · `),markTone:c?`warn`:`ok`,accent:o,on:e.detailKey===r,tip:`Open: its items, their stats and logs`,onOpen:()=>e.openDetail({key:r,render:e=>({cat:`Run · ${t.mode}`,origin:a,age:By(t.cost_usd),body:(0,I.jsx)(Wy,{ctx:e,run:t,list:n,onPart:(t,n)=>e.openItem(t,n.kind,n)})})})})}var mS=e=>`its own: ${e.model??`default`} · ${e.effort??`default`}`;function hS({ctx:e}){let{board:t}=e,n=t.runs,r=e=>t.items.find(t=>t.id===e),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(lS),[c,l]=(0,v.useState)(``),u=qi(e),d=Pi(t),f=(n?.reports??[]).map(e=>e.id).join(` `),p=(0,v.useRef)(0);(0,v.useEffect)(()=>{if(!d)return;let t=++p.current;k.pastRuns(e.project.name,o+1).then(e=>{t===p.current&&(a(e),l(``))},e=>t===p.current&&l(e.message))},[e.project.name,o,d,f,n?.active.length]);let m=(n?.active??[]).flatMap(e=>{let t=e.ids.map(r).find(e=>e?.running)??r(e.ids[0]);return t?[{run:e,item:t}]:[]}),h=new Set(m.map(e=>e.item.id)),g=t.items.filter(e=>e.running&&!h.has(e.id)),_=n?.queued??[],y=(i??[]).slice(0,o);return(0,I.jsxs)(`section`,{className:`page runs`,"aria-label":`Runs`,children:[(0,I.jsxs)(`div`,{className:`runs-head`,children:[(0,I.jsx)(`h1`,{children:`Runs`}),(0,I.jsxs)(`span`,{className:`mono dim`,title:`Where runs work`,children:[`runs: `,t.run_mode]}),(0,I.jsxs)(`div`,{className:`run-next runs-start`,title:`The run gate picks them; the dialog asks for a model and effort for this run${d?``:` (not with this harness)`}`,children:[(0,I.jsx)(`button`,{disabled:u.busy,onClick:()=>void u.go(),children:u.busy?`asking the run gate…`:`Run next`}),(0,I.jsx)(`input`,{type:`number`,min:1,max:20,value:u.count,onChange:e=>u.setCount(Math.max(1,Math.min(20,Number(e.target.value)||1))),"aria-label":`How many to run, 1 to 20`})]})]}),(0,I.jsxs)(`section`,{"aria-label":`Active runs`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Active`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),!m.length&&!g.length&&(0,I.jsx)(`p`,{className:`empty-box`,children:n?.paused?`Nothing runs: the queue is paused.`:`Nothing runs now.`}),m.map(({run:t,item:n})=>{let r=di(n),i=!!(t.model||t.effort);return(0,I.jsxs)(`article`,{className:`runs-active`,children:[(0,I.jsxs)(`div`,{className:`runs-active-top`,children:[(0,I.jsxs)(`div`,{className:`runs-active-name`,children:[(0,I.jsx)(`span`,{className:`mono strong`,children:n.id}),n.title&&(0,I.jsx)(`span`,{className:`dim small`,children:n.title})]}),!r&&n.active_at&&(0,I.jsx)(ei,{at:n.active_at})]}),(0,I.jsxs)(`div`,{className:`runs-facts mono`,children:[(0,I.jsx)(`span`,{children:t.mode}),(0,I.jsxs)(`span`,{children:[`started `,oi(t.started)]}),(0,I.jsxs)(`span`,{children:[Math.max(1,Math.round((Date.now()-Date.parse(t.started))/6e4)),` min`]}),(0,I.jsx)(`span`,{className:i?``:`dim`,title:`The model and effort of this run; ${mS(n)}`,children:fS(t,`this run's pick`)}),i&&(0,I.jsx)(`span`,{className:`dim`,children:mS(n)})]}),t.ids.length>1&&(0,I.jsxs)(`span`,{className:`mono dim small`,children:[`item `,t.ids.indexOf(n.id)+1,` of `,t.ids.length,`: `,t.ids.join(`, `)]}),r&&(0,I.jsxs)(`span`,{className:`runs-limit mono`,children:[`◷ limit: resumes `,oi(r),` · waits for the reset by itself`]}),(0,I.jsx)(dS,{ctx:e,id:n.id}),(0,I.jsxs)(`div`,{className:`runs-acts`,children:[(0,I.jsx)(`button`,{className:`btn`,onClick:()=>e.openItem(n.id,`log`),children:`Whole log`}),(0,I.jsx)(`button`,{className:`btn-danger`,title:r?`Ends the wait for the reset: paused: limit`:`Stops the agent session; the item stays ready and its work is kept`,onClick:()=>void Yi(e,n),children:`Stop`})]})]},t.started+n.id)}),g.map(t=>(0,I.jsxs)(`button`,{className:`runs-other`,onClick:()=>e.openItem(t.id),children:[(0,I.jsx)(`span`,{className:`mono strong`,children:t.id}),(0,I.jsxs)(`span`,{className:`running-text small`,children:[`◐ `,ii(t)]})]},t.id))]}),(0,I.jsxs)(`section`,{"aria-label":`Queue`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Queue · `,_.length,n?.paused?` · paused`:``,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),n?.paused&&(0,I.jsx)(`button`,{className:`btn runs-resume`,onClick:()=>void e.resumeQueue(),children:`queue paused — resume`}),!_.length&&(0,I.jsx)(`span`,{className:`dim`,children:`empty`}),_.map((t,i)=>{let a=r(t)?.waits_for??[],o=n?.queued_with?.[t];return(0,I.jsxs)(`div`,{className:`runs-q`,role:`button`,tabIndex:0,title:`Open ${t}`,onClick:()=>e.openItem(t),onKeyDown:n=>{n.target!==n.currentTarget||n.key!==`Enter`&&n.key!==` `||(n.preventDefault(),e.openItem(t))},children:[(0,I.jsxs)(`div`,{className:`runs-q-line`,children:[(0,I.jsxs)(`span`,{className:`mono dim`,children:[`#`,i+1]}),(0,I.jsx)(`span`,{className:`mono strong`,children:t}),(0,I.jsx)(`span`,{className:`mono small ${o?``:`dim`}`,title:`What it will run on`,children:fS(o,`for this run`)}),a.length>0&&(0,I.jsxs)(`span`,{className:`dim small`,children:[`⧗ waits for `,a.join(`, `)]})]}),(0,I.jsx)(Na,{label:`Remove from queue`,tip:`Remove from queue; it asks nothing`,onClick:n=>{n.stopPropagation(),e.unqueue(t)}})]},t)})]}),(0,I.jsxs)(`section`,{"aria-label":`Past runs`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Past runs`,i?` · ${y.length}${i.length>o?`+`:``}`:``,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),!d&&(0,I.jsxs)(`div`,{role:`note`,className:`empty-box chat-old`,children:[(0,I.jsx)(`span`,{children:`Past runs need gcf-harness-aif-ext ≥ 0.13: this harness keeps no run record the board can read. Active runs show above.`}),(0,I.jsx)(`code`,{children:`update gcf-harness-aif-ext`})]}),d&&c&&(0,I.jsxs)(`p`,{role:`alert`,className:`error-text`,children:[`✘ `,c]}),d&&!i&&!c&&(0,I.jsx)(`p`,{className:`dim`,children:`reading the run log…`}),d&&i&&!i.length&&(0,I.jsx)(`p`,{className:`dim`,children:`No run in the run log yet.`}),y.length>0&&(0,I.jsx)(`div`,{className:`wide-only`,children:(0,I.jsx)(Pa,{children:y.map((t,n)=>(0,I.jsx)(pS,{ctx:e,run:t,list:i??[]},t.id??`old-${t.ended}-${n}`))})}),(0,I.jsx)(`div`,{className:`phone-only runs-rows`,children:y.map((t,n)=>(0,I.jsx)(Wy,{ctx:e,run:t,list:i??[],onPart:(t,n)=>e.openItem(t,n.kind,n)},t.id??`old-${t.ended}-${n}`))}),i&&i.length>0&&(0,I.jsxs)(`div`,{className:`runs-more`,children:[(0,I.jsx)(`span`,{className:`dim small`,children:i.length>o?`${o} shown · ${lS} at a time, newest first`:`all ${i.length} shown · newest first`}),i.length>o&&(0,I.jsxs)(`button`,{className:`btn-line`,onClick:()=>s(o+lS),children:[`Show `,lS,` more`]})]})]})]})}function gS(e,t){let n=t.filter(t=>!e.has(t));for(let t of n)e.set(t,{});return n}function _S(e,t){if(!t.size)return e;let n=e.domain.runs_from;return{...e,items:e.items.map(e=>t.has(e.id)&&!e.running&&e.status===n?{...e,running:!0,running_kind:`board`,starting:!0}:e)}}function vS(e,t,n){let r=new Set(t.items.filter(e=>e.running).map(e=>e.id)),i=new Map;for(let[a,o]of e){let e=t.items.find(e=>e.id===a);if(e&&!e.running&&e.status===t.domain.runs_from){if(o.after!==void 0&&n>o.after){let e=t.runs?.active.find(e=>e.ids.includes(a));if(!e||e.ids.some(e=>r.has(e)))continue}i.set(a,o)}}return i}function yS(e){let t=e.title??e.tool;return`${t.length>80?`${t.slice(0,79)}…`:t} (${e.group?`deny group ${e.group}`:`a deny rule`})`}var bS=(e,t)=>e?t.filter(t=>!e.has(t)):[];function xS(e,t,n){let r=(0,v.useRef)(null),i=(0,v.useRef)({entries:e,tell:n});i.current={entries:e,tell:n};let a=e.map(e=>e.key).join(` `);(0,v.useEffect)(()=>{if(!t)return;let{entries:e,tell:n}=i.current,a=new Set(bS(r.current,e.map(e=>e.key)));for(let t of e)a.has(t.key)&&n(t);r.current=new Set([...r.current??[],...e.map(e=>e.key)])},[a,t])}var SS=[`command`,`board`,`chat`,`inbox`,`design`,`runs`,`playtest`,`ended`,`agent`,`metrics`,`more`],CS=`gcf-board-tools`,wS={command:`Command`,board:`Board`,chat:`Chat`,inbox:`Inbox`,design:`Design`,runs:`Runs`,playtest:`Playtest`,ended:`Ended`,agent:`Agent`,metrics:`Metrics`,more:`More`},TS={design:`The game design: pillars, vision, units`,runs:`What runs, what waits, what ran`,playtest:`What waits for a playtest, by subsystem`,ended:`Accepted items and the graveyard`,agent:`What runs may not do`,metrics:`What the runs did and cost`};function ES(e){let t=e.domain.sections,n={inbox:t.inbox||t.questions,design:t.design&&e.domain.starts,playtest:t.playtest,ended:t.history||t.graveyard,metrics:e.domain.harness,runs:e.domain.harness};return SS.filter(e=>e!==`more`&&(!(e in n)||n[e]))}function DS({project:e,projects:t,screen:n,arg:r,go:i,notify:a}){let[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(void 0),[m,h]=(0,v.useState)(void 0),[g,_]=(0,v.useState)(0),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(!1),[A,ee]=(0,v.useState)(!1),[j,M]=(0,v.useState)(()=>{try{return localStorage.getItem(CS)!==`shut`}catch{return!0}}),[te,N]=(0,v.useState)(!1),P=(0,v.useRef)(new Set),F=(0,v.useRef)(new Map),re=(0,v.useRef)(se()),L=(0,v.useCallback)(()=>{let t=re.current.send();return k.board(e.name).then(e=>{if(!re.current.lands(t))return;let n=To(e,P.current);F.current=vS(F.current,n,t),s(_S(n,F.current)),l(``)},e=>re.current.lands(t)&&l(e.message))},[e.name]),z=!!o?.domain.chat,ie=(0,v.useRef)(0),B=(0,v.useCallback)(()=>{let t=++ie.current;k.talks(e.name).then(e=>{t===ie.current&&(S(e),w(!0))},()=>t===ie.current&&S([]))},[e.name]);(0,v.useEffect)(()=>(L(),ne(t=>{(t.type===`board`&&t.project===e.name||t.type===`quota`)&&L(),t.type===`talks`&&t.project===e.name&&B()},()=>{L(),B()})),[L,B,e.name]),(0,v.useEffect)(()=>{z&&B()},[z,B]);let ae=(0,v.useRef)(()=>{});(0,v.useEffect)(()=>{let e=e=>ae.current(e);return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let oe=async(t,n,r=!1)=>{try{let i=await k.move(e.name,t),o=r||i.held===!0;(i.ok||!o)&&a(i.ok?i.out||`done`:i.err||i.out,i.ok?`ok`:`error`),!i.ok&&i.refusal&&!r&&!n&&t.proposal===void 0&&E_(i.refusal,i.err||i.out);let s=L();return n&&await s,{ok:i.ok,out:i.out,err:i.ok?``:i.err||i.out,refused:!i.ok,...i.refusal&&{refusal:i.refusal}}}catch(e){return r||a(e.message,`error`),{ok:!1,out:``,err:e.message,refused:!1}}},ce=e=>oe(e,!0),V=async e=>(await oe(e,!1)).ok,H=e=>oe(e,!1,!0),U=(e,t)=>{P.current.add(t),s(e=>e&&To(e,P.current)),V({cmd:e,id:t}).finally(()=>{P.current.delete(t),L()})},le=async(t,n=!1,r)=>{let i=gS(F.current,t);s(e=>e&&_S(e,F.current));try{let o=await k.run(e.name,t,n,r),s=[r?.model,r?.effort,r?.mode].filter(Boolean).join(`, `),c=o.queued??[];for(let e of i)c.includes(e)?F.current.delete(e):F.current.has(e)&&F.current.set(e,{after:re.current.last()});let l=t.filter(e=>!c.includes(e));return a(`${[l.length?`run started: ${l.join(`, `)}`:``,c.length?`queued behind the main run: ${c.join(`, `)}`:``].filter(Boolean).join(` · `)}${s?` · on ${s} for this run`:``}`),L(),!0}catch(e){a(e.message,`error`);for(let e of i)F.current.delete(e);return L(),!1}},ue=async t=>{try{let n=await k.stop(e.name,t);a(n.ok?n.out:n.err||n.out,n.ok?`ok`:`error`),L()}catch(e){a(e.message,`error`)}},de=async t=>{await k.unqueue(e.name,t).catch(e=>a(e.message,`error`)),L()},fe=async()=>{await k.resumeQueue(e.name).catch(e=>a(e.message,`error`)),L()},pe=async t=>{await k.autopilot(e.name,t).catch(e=>a(e.message,`error`)),L()},W=async()=>{await k.askUsage().catch(e=>a(e.message,`error`))},me=(o?.items??[]).flatMap(e=>e.run_end?[{key:`${e.id}@${e.run_end.at}`,text:`${e.id}: ${e.run_end.outcome}`}]:[]),he=!!o;xS(me,he,e=>a(`run ended: ${e.text} — its card is in its chat`));let ge=(o?.items??[]).flatMap(e=>e.denied?[{key:`${e.id}@${e.denied.at}`,text:`${e.id}: ${yS(e.denied)}`,open:()=>{d(e.id),p(`chat`),h(void 0),_(e=>e+1),b(null)}}]:[]),_e=x.flatMap(e=>e.denied?[{key:`${e.id}@${e.denied.at}`,text:`${e.title??`a thread`}: ${yS(e.denied)}`,open:()=>i(`chat`,e.id)}]:[]),ve=e=>a(`agent refused: ${e.text} — its card is in its chat`,`warn`,e.open,`Open its card`);xS(ge,he,ve),xS(_e,C,ve);let ye=o?.runs?.autopilot?.stop,be=ye?.kind===`play`?ye.text:``;if((0,v.useEffect)(()=>{be&&a(be)},[be,a]),!o)return(0,I.jsx)(`main`,{className:`boot`,role:`status`,children:c?(0,I.jsxs)(`span`,{className:`boot-error`,role:`alert`,children:[`✘ `,c]}):`reading gcf board --json…`});let xe=(e={})=>{let t=Tr(o.domain,o.domain.new_item);t&&E({title:`New item`,move:t,values:{title:e.title??``,from:e.from,...e.note?{note:e.note}:{}}})},Se=o.domain.fields.find(e=>e.key===`depends`)?.edit,Ce=T?.id&&T.move.cmd===Se?o.items.find(e=>e.id===T.id):void 0,we={project:e,board:o,notify:a,move:V,moveOut:ce,moveIn:H,erase:U,run:le,stop:ue,unqueue:de,resumeQueue:fe,setAutopilot:pe,askUsage:W,boardTools:j,toggleBoardTools:()=>{try{localStorage.setItem(CS,j?`shut`:`open`)}catch{}M(!j)},openItem:(e,t,n)=>{d(e),p(t),h(n),_(e=>e+1),b(null)},openDetail:e=>{d(null),b(e)},closeDetail:()=>b(null),detailKey:y?.key??null,itemOpen:u,openMove:E,newItem:xe,go:i,openSettings:()=>{O(!1),N(!1),ee(!0)},talks:x,reloadTalks:B},Te=o.items.find(e=>e.id===u),Ee=!Te&&u?[...o.history??[],...o.graveyard??[]].some(e=>e.id===u):!1;ae.current=e=>{if(e.key===`Escape`&&(u||y)&&!e.defaultPrevented&&!document.querySelector(`.modal`)){let t=e.target?.closest?.(`input, textarea, select, [contenteditable]`);t?t.blur():D||(d(null),b(null));return}if(Oa(e)||document.querySelector(`.modal`))return;if(za(e,ES(o),i,()=>{O(!1),N(!1),ee(!0)})){e.preventDefault(),e.stopImmediatePropagation();return}let t=Tr(o.domain,o.domain.sections.inbox?.add);if(e.key===`?`)O(!0);else if(e.key===`/`){let e=document.querySelector(D?`.help input`:`.screen [data-search], .screen input[type="search"]`);if(!e)return;!D&&!j&&e.matches(`[data-search]`)?(we.toggleBoardTools(),requestAnimationFrame(()=>{e.focus(),e.select()})):(e.focus(),e.select())}else if(e.key===`n`&&o.domain.new_item)xe();else if(e.key===`i`&&t)E({title:`Add to the inbox`,move:t,values:{}});else return;e.preventDefault()};let De=ES(o),Oe=De.includes(n)||n===`more`?n:`command`,ke=ea(o,x).length,Ae=Zi(o),je=De.map(e=>({screen:e,label:wS[e],count:e===`command`?ke:e===`inbox`?Ae:e===`chat`?x.filter(e=>e.waiting).length:0,needs:e===`command`||e===`chat`||e===`inbox`}));return(0,I.jsxs)(`div`,{className:`project`,children:[(0,I.jsx)(Va,{entries:je,screen:Oe,go:i}),(0,I.jsxs)(`div`,{className:`project-main`,children:[(0,I.jsx)(fo,{ctx:we,screen:Oe,projects:t,waiting:ke,onWaiting:()=>i(`command`),onHelp:()=>O(!D),onSettings:()=>{O(!1),N(!1),ee(!A)}}),(0,I.jsxs)(`div`,{className:`workspace`,children:[(0,I.jsxs)(`main`,{className:`screen screen-${Oe}`,children:[Oe!==`command`&&(o.runs?.reports??[]).length>0&&(0,I.jsx)(`div`,{className:`report-strip`,"aria-label":`Run reports`,children:[...o.runs?.reports??[]].reverse().map(e=>(0,I.jsx)(gx,{ctx:we,r:e},e.id))}),c&&(0,I.jsxs)(`div`,{role:`alert`,className:`read-fail`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`✘`}),(0,I.jsxs)(`span`,{children:[c,` · The board shows the last good read.`]})]}),Oe===`command`&&(0,I.jsx)(xx,{ctx:we}),Oe===`board`&&(0,I.jsx)(ja,{ctx:we}),Oe===`chat`&&(0,I.jsx)(Ny,{ctx:we,thread:r}),Oe===`inbox`&&(0,I.jsx)(ps,{ctx:we}),Oe===`design`&&(0,I.jsx)(rS,{ctx:we,arg:r}),Oe===`runs`&&(0,I.jsx)(hS,{ctx:we}),Oe===`playtest`&&(0,I.jsx)(Ub,{ctx:we}),Oe===`ended`&&(0,I.jsx)(Tb,{ctx:we}),Oe===`metrics`&&(0,I.jsx)(hx,{ctx:we}),Oe===`agent`&&(0,I.jsx)(Kb,{ctx:we}),Oe===`more`&&(0,I.jsxs)(`div`,{className:`page more`,children:[je.filter(e=>e.screen in TS).map(e=>(0,I.jsxs)(`button`,{className:`more-row`,onClick:()=>i(e.screen),children:[(0,I.jsx)(`span`,{className:`more-label`,children:e.label}),(0,I.jsx)(`span`,{className:`more-sub`,children:TS[e.screen]})]},e.screen)),(0,I.jsxs)(`button`,{className:`more-row`,onClick:()=>{N(!1),ee(!0)},children:[(0,I.jsx)(`span`,{className:`more-label`,children:`Settings`}),(0,I.jsx)(`span`,{className:`more-sub`,children:`gcf/config.yml, one save each; this browser's theme`})]}),(0,I.jsxs)(`button`,{className:`more-row`,onClick:()=>O(!0),children:[(0,I.jsx)(`span`,{className:`more-label`,children:`Help`}),(0,I.jsx)(`span`,{className:`more-sub`,children:`Every word the board uses, the moves, the fields`})]}),(0,I.jsxs)(`h2`,{className:`section-h more-head`,children:[`Projects`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),t.list.map(n=>(0,I.jsxs)(`div`,{className:`more-proj`,children:[(0,I.jsxs)(`button`,{className:`more-row`,"aria-current":n.name===e.name?`true`:void 0,onClick:()=>t.choose(n.name),children:[(0,I.jsxs)(`span`,{className:`more-label`,children:[n.name===e.name?`● `:``,n.name]}),(0,I.jsx)(`span`,{className:`more-sub mono`,children:n.path})]}),(0,I.jsx)(Na,{label:`Remove ${n.name} from the board`,tip:`Take it off the board; its files stay`,onClick:()=>t.remove(n)})]},n.name)),(0,I.jsx)(`button`,{className:`more-row`,onClick:t.add,children:(0,I.jsx)(`span`,{className:`more-label`,children:`+ Add a project…`})})]})]}),Te&&(0,I.jsx)(wb,{ctx:we,item:Te,tab:f,part:m,onClose:()=>d(null)},`${Te.id} ${f??``} ${g}`),y&&!Te&&!Ee&&(0,I.jsx)(iS,{ctx:we,spec:y,onClose:()=>b(null)},y.key),Ee&&u&&(0,I.jsx)(Sb,{ctx:we,id:u,part:m,onClose:()=>d(null)},`${u} ${g}`)]}),(0,I.jsx)(po,{ctx:we})]}),(0,I.jsx)(Ha,{entries:je,screen:Oe,go:i}),T&&Ce?(0,I.jsx)(kb,{ctx:we,id:Ce.id,current:Ce.depends,open:T,onClose:()=>E(null)},`${T.move.cmd} ${Ce.id}`):T&&(0,I.jsx)(Hb,{ctx:we,open:T,onClose:()=>E(null)},`${T.move.cmd} ${T.id??``} ${T.title}`),(0,I.jsx)(D_,{ctx:we}),D&&(0,I.jsx)(cS,{domain:o.domain,onClose:()=>O(!1)}),A&&(0,I.jsx)(R,{onClose:()=>ee(!1),dirty:te,children:(0,I.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,className:`settings-dialog`,onClick:e=>e.stopPropagation(),onInput:e=>{e.target.matches(`input:not([type=file]), textarea`)&&N(!0)},children:[(0,I.jsx)(`button`,{className:`icon-btn bordered settings-close`,"aria-label":`Close the settings`,title:`Close · Esc`,autoFocus:!0,onClick:()=>ee(!1),children:`×`}),(0,I.jsx)(nx,{ctx:we})]})}),(0,I.jsx)(Ki,{})]})}function OS(){let[e=``,t=``,n]=location.hash.slice(1).split(`/`).map(e=>{try{return decodeURIComponent(e)}catch{return``}});return{name:e,screen:SS.includes(t)?t:`command`,arg:n||void 0}}function kS({onAdded:e,notify:t,onCancel:n}){let[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``);return(0,I.jsxs)(`form`,{className:`form add-project`,onSubmit:async n=>{n.preventDefault();try{e(await k.addProject(r.trim(),a.trim())),i(``),o(``)}catch(e){t(e.message,`error`)}},children:[(0,I.jsxs)(`label`,{className:`field`,children:[(0,I.jsx)(`span`,{className:`field-label`,children:`Project folder`}),(0,I.jsx)(`input`,{className:`input`,placeholder:`C:\\games\\zombie-puzzle`,value:r,onChange:e=>i(e.target.value),required:!0,autoFocus:!0}),(0,I.jsx)(`span`,{className:`field-help`,children:`A folder with gcf/ in it (ai-factory gcf init).`})]}),(0,I.jsxs)(`label`,{className:`field`,children:[(0,I.jsx)(`span`,{className:`field-label`,children:`Name`}),(0,I.jsx)(`input`,{className:`input`,placeholder:`optional: the folder's name`,value:a,onChange:e=>o(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`dialog-actions`,children:[n&&(0,I.jsx)(`button`,{type:`button`,className:`btn-line`,onClick:n,children:`Cancel`}),(0,I.jsx)(`button`,{type:`submit`,className:`btn-primary`,children:`Add project`})]})]})}function AS({closed:e}){return(0,I.jsx)(`div`,{className:`gone`,role:`alertdialog`,"aria-label":`The board's server is gone`,children:(0,I.jsxs)(`div`,{className:`gone-box`,children:[(0,I.jsx)(`span`,{className:`gone-title`,children:e?`The board was started again`:`The board's server is gone`}),(0,I.jsxs)(`span`,{className:`gone-text`,children:[`This page shows the last read and cannot act. Runs started from it go on by themselves.`,` `,e?`Open the board again from its link: the desktop shortcut, or the URL with ?t= that gcf-board printed.`:`Start gcf-board again; the page reconnects by itself.`]}),!e&&(0,I.jsxs)(`span`,{role:`status`,className:`gone-retry`,children:[(0,I.jsx)(`span`,{className:`dot pulse`,"aria-hidden":`true`}),`trying `,location.host,` again…`]})]})})}function jS(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(OS()),[i,a]=(0,v.useState)([]),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=(0,v.useRef)(void 0),d=(0,v.useRef)(null),f=$b(),p=(0,v.useCallback)((e,t=`ok`,n,r)=>{let i=Date.now()+Math.random();a(a=>[...a,{id:i,text:e,kind:t,open:n,openLabel:r}]),setTimeout(()=>a(e=>e.filter(e=>e.id!==i)),t===`error`||n?12e3:4e3)},[]);(0,v.useEffect)(()=>{k.projects().then(t,e=>p(e.message,`error`));let e=()=>r(OS());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[p]),(0,v.useLayoutEffect)(()=>{if(!d.current)return;let e=tx(d.current,f);e.length&&p(`Theme ${f?.name}: this board has no token ${e.join(`, `)}`,`error`)},[f,p]),(0,v.useEffect)(()=>{f&&k.themes().then(e=>{if(Qb()?.id!==f.id)return;let t=e.find(e=>e.id===f.id);t&&`tokens`in t?JSON.stringify(t)!==JSON.stringify(f)&&Zb(t):(Zb(null),p(`Theme ${f.name} ${t?`cannot be read: ${t.error}`:`is gone`}: back to dark`,`error`))},()=>{})},[]),(0,v.useEffect)(()=>P((e,t)=>{(e||t)&&(clearTimeout(u.current),u.current=void 0),e?l(null):t?l(`closed`):u.current??=setTimeout(()=>l(`retry`),3e3)}),[]);let m=(e,t,n)=>{location.hash=`${encodeURIComponent(e)}/${t}${n?`/${encodeURIComponent(n)}`:``}`},h=e?.find(e=>e.name===n.name)??e?.[0]??null,g=e=>{t(t=>[...t??[],e]),s(!1),m(e.name,`command`)},_={list:e??[],choose:e=>m(e,n.screen),add:()=>s(!0),remove:async e=>{if(await ie(`Take ${e.name} off the board? Its files stay as they are.`,`Remove`,!0))try{await k.removeProject(e.name),t(t=>t?.filter(t=>t.name!==e.name)??null)}catch(e){p(e.message,`error`)}}};return(0,I.jsxs)(`div`,{className:`app`,"data-gcf":`b`,ref:d,children:[!e&&(0,I.jsx)(`div`,{className:`boot`,children:`reading the projects…`}),e&&!e.length&&(0,I.jsxs)(`main`,{className:`welcome`,children:[(0,I.jsx)(`h1`,{children:`GCF board`}),(0,I.jsx)(`p`,{children:`No project yet. Add a folder that has gcf/ (ai-factory gcf init).`}),(0,I.jsx)(kS,{notify:p,onAdded:g})]}),h&&(0,I.jsx)(DS,{project:h,projects:_,screen:n.screen,arg:n.arg,go:(e,t)=>m(h.name,e,t),notify:p},h.name),o&&(0,I.jsx)(R,{onClose:()=>s(!1),dirty:!1,children:(0,I.jsxs)(`div`,{className:`dialog`,role:`dialog`,"aria-modal":!0,"aria-label":`Add a project`,onClick:e=>e.stopPropagation(),children:[(0,I.jsx)(`h2`,{children:`Add a project`}),(0,I.jsx)(kS,{notify:p,onAdded:g,onCancel:()=>s(!1)})]})}),c&&(0,I.jsx)(AS,{closed:c===`closed`}),(0,I.jsx)(oe,{}),(0,I.jsx)(`div`,{className:`toasts`,role:`status`,children:i.map(e=>(0,I.jsxs)(`div`,{className:`toast ${e.kind}`,children:[e.open?(0,I.jsxs)(`button`,{className:`toast-text toast-open`,onClick:()=>{e.open?.(),a(t=>t.filter(t=>t.id!==e.id))},children:[(0,I.jsx)(`span`,{children:e.text}),(0,I.jsxs)(`span`,{className:`toast-link`,children:[e.openLabel??`Open`,` ›`]})]}):(0,I.jsx)(`span`,{className:`toast-text`,children:e.text}),(0,I.jsx)(`button`,{className:`toast-close`,"aria-label":`Close`,onClick:()=>a(t=>t.filter(t=>t.id!==e.id)),children:`×`})]},e.id))})]})}(0,y.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(v.StrictMode,{children:(0,I.jsx)(jS,{})}));
91
+ `).length+1),value:String(t),placeholder:p,onChange:e=>i(e.target.value)})]});let g=wr(e,u),_=(e,t,n)=>i(u.map((r,i)=>i===e?{...r,[t]:n}:r));return(0,I.jsxs)(`div`,{className:`design-field`,children:[m,h,(0,I.jsxs)(`div`,{className:`design-recs`,id:s,children:[(0,I.jsxs)(`div`,{className:`design-rec-headrow`,"aria-hidden":`true`,children:[g.map(e=>(0,I.jsx)(`span`,{children:Gx(e)},e)),(0,I.jsx)(`span`,{className:`design-rec-gap`})]}),u.map((e,t)=>(0,I.jsxs)(`div`,{className:`design-rec-row`,children:[g.map(n=>n===`id`?(0,I.jsxs)(`span`,{className:`design-cell`,children:[(0,I.jsx)(`span`,{children:`id`}),(0,I.jsx)(`span`,{className:`design-rec-id`,children:e.id||`made from the name on save`})]},n):(0,I.jsx)($x,{label:Gx(n),aria:`${c} ${t+1}: ${Gx(n)}`,v:e[n]??``,onChange:e=>_(t,n,e)},n)),(0,I.jsx)(Na,{label:`Remove record ${t+1} of ${c}`,onClick:()=>i(u.filter((e,n)=>n!==t))})]},t)),l&&(0,I.jsx)(`span`,{className:`design-tbd-none`,children:`TBD: no record yet`}),(0,I.jsx)(`button`,{className:`design-add`,title:`Add a record: each key empty`,onClick:()=>i([...u,Object.fromEntries(g.map(e=>[e,``]))]),children:`+ record`})]})]})}function tS({ctx:e,f:t,value:n,saved:r,onChange:i}){let a=Tr(e.board.domain,e.board.domain.sections.design?.retire),o=sr(e.board)?.pillars??[],s=n,c=Array.isArray(r)?r:[],l=wr(t,s).filter(e=>e!==`id`&&e!==`name`),u=(e,t,n)=>i(s.map((r,i)=>i===e?{...r,[t]:n}:r)),d=new Set([...c,...s].map(e=>e.id).filter(Boolean)),[f,p]=(0,v.useState)(null);return(0,I.jsxs)(`div`,{className:`design-pillars`,children:[s.map((t,n)=>{let r=t.id??``,f=c.find(e=>e.id===r),m=!!(r&&f),h=(t.name??``).trim(),g=(f?.name??``).trim(),_=h?vr(h,e=>e!==r&&d.has(e)):``,v=o.find(e=>e.id===r)?.units,y=v===void 0?m?``:`not saved yet`:`${v} ${v===1?`unit cites`:`units cite`} it`;return(0,I.jsxs)(`article`,{className:`design-pillar-card`,children:[(0,I.jsxs)(`div`,{className:`design-pillar-top`,children:[(0,I.jsxs)(`div`,{className:`design-pillar-head`,children:[(0,I.jsx)(`span`,{className:`design-pillar-title${!h&&m?` mono`:``}`,children:h||(m?r:`New pillar`)}),(0,I.jsxs)(`span`,{className:`design-pillar-line`,children:[(0,I.jsx)(`code`,{title:m?`The pillar's id: units cite it in pillars:. The system keeps it; a new name renames it after the save.`:`A new pillar gets its id from its name`,children:m?r:h?`its id: ${_}`:`its id comes from its name`}),(0,I.jsx)(`span`,{title:`Units whose pillars cite it`,children:y})]})]}),m&&!g&&(0,I.jsx)(Yx,{ctx:e,k:`name-pillars`}),m&&a&&(0,I.jsx)(`button`,{className:`design-danger small`,title:`The game no longer holds it: units left with no pillar read pillars: TBD`,onClick:()=>p(r),children:`Retire…`}),!m&&(0,I.jsx)(Na,{label:`Remove record ${n+1} of pillars`,tip:`Remove this pillar: it is not saved yet`,onClick:()=>i(s.filter((e,t)=>t!==n))})]}),(0,I.jsxs)(`label`,{className:`design-cell`,children:[(0,I.jsx)(`span`,{children:`name`}),(0,I.jsx)(`input`,{className:`design-input strong`,"aria-label":`Pillar ${n+1}: name`,placeholder:m?`no name yet: a few words you know it by`:`a few words you know it by`,value:t.name??``,onChange:e=>u(n,`name`,e.target.value)})]}),m&&g&&h&&h!==g&&_!==r&&(0,I.jsxs)(`span`,{className:`design-note`,children:[`↻ Save renames `,r,` → `,_,` wherever it is cited: a second commit after the save.`]}),l.map(e=>(0,I.jsx)($x,{label:Gx(e),aria:`Pillar ${n+1}: ${Gx(e)}`,v:t[e]??``,onChange:t=>u(n,e,t)},e))]},n)}),(0,I.jsxs)(`button`,{className:`design-add`,title:`A new pillar: name, statement, invariant, review question; its id comes from its name`,onClick:()=>i([...s,Object.fromEntries([`name`,...l].map(e=>[e,``]))]),children:[`+ pillar · `,s.length,` of 2 to 7`]}),f&&(0,I.jsx)(hS,{ctx:e,kind:`retire`,id:f,onClose:()=>p(null)})]})}function nS({ctx:e,kind:t,name:n,rows:r=18}){let i=e.board.domain.sections.design,[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(!1),b=()=>k.designPart(e.project.name,t,n).then(e=>{let t=Object.fromEntries(e.fields.map(e=>[e.key,dr(e)]));o(e),c(t),u(t),m(e.text),g(``)},e=>g(e.message)),x=a?pr(a.fields,s,l):{},S=Object.keys(x).length,C=S>0||d&&p!==a?.text,w=sr(e.board)?.unrecorded??[],T=`${e.board.head??``} ${w.join(`,`)}`;if((0,v.useEffect)(()=>{C||b()},[t,n,T]),h)return(0,I.jsxs)(`p`,{className:`error-text`,children:[`✘ `,h]});if(!a||!i)return(0,I.jsxs)(`p`,{className:`dim`,children:[`reading `,n,`…`]});let E=async()=>{y(!0);let r=await e.move({id:n,kind:t,base:a.base??void 0,...d?{cmd:i.save_text,text:p}:{cmd:i.save,fields:JSON.stringify(x)}});y(!1),r&&(f(!1),await b())},D=!!(a.file&&w.includes(a.file)),O=C&&!_,A=r=>t===`doc`&&n===`pillars`&&r.key===`pillars`&&r.exact?(0,I.jsx)(tS,{ctx:e,f:r,value:l[r.key],saved:s[r.key],onChange:e=>u({...l,[r.key]:e})},r.key):(0,I.jsx)(eS,{f:r,value:l[r.key],edited:r.key in x,compact:t===`unit`&&!!r.header,onChange:e=>u({...l,[r.key]:e}),toText:()=>f(!0)},r.key),ee=a.fields.filter(e=>t===`unit`&&e.header),j=a.fields.filter(e=>!(t===`unit`&&e.header));return(0,I.jsxs)(`div`,{className:`design-form`,children:[d?(0,I.jsxs)(`div`,{className:`design-astext`,children:[(0,I.jsxs)(`span`,{className:`design-note`,children:[`The whole `,t===`unit`?`unit`:`part`,` as text, as it is in`,` `,a.file??`its file`,`. Save text writes all of it.`]}),(0,I.jsx)(`textarea`,{className:`design-input design-text`,"aria-label":`${n} as text`,rows:r,value:p,onChange:e=>m(e.target.value)})]}):t===`unit`?(0,I.jsxs)(`div`,{className:`design-fields`,children:[(0,I.jsxs)(`div`,{className:`design-group`,children:[(0,I.jsx)(`h3`,{className:`design-h3`,children:`Header`}),(0,I.jsx)(`div`,{className:`design-header-grid`,children:ee.map(A)})]}),(0,I.jsxs)(`div`,{className:`design-group`,children:[(0,I.jsxs)(`h3`,{className:`design-h3`,children:[`Blocks of a `,a.type]}),(0,I.jsx)(`div`,{className:`design-fields`,children:j.map(A)})]})]}):(0,I.jsx)(`div`,{className:`design-fields`,children:j.map(A)}),(0,I.jsxs)(`div`,{className:`design-savebar`,children:[D&&(0,I.jsxs)(`span`,{className:`design-wait`,children:[`⧗ `,a.file,` holds a change not recorded yet, a draft perhaps: you see it in the form, and Save records it along with your edits.`]}),(0,I.jsxs)(`span`,{className:`design-base`,title:`The part as read: a save is refused if the file changed since`,children:[t===`unit`?`${a.file} · `:``,`read at `,a.base??`—`]}),(0,I.jsx)(`span`,{className:`design-spacer`}),d?(0,I.jsx)(`button`,{className:`design-textbtn`,title:`Back to the form; the text edits are dropped`,onClick:()=>{m(a.text),f(!1)},children:`back to the form`}):(0,I.jsx)(`button`,{className:`design-textbtn`,title:a.fields.some(e=>!e.exact)?`A slot holds text the form cannot keep: edit the whole part as text`:`Edit the whole part as text, as it is in its file`,onClick:()=>f(!0),children:`edit as text`}),(0,I.jsx)(`button`,{className:`design-revert`,disabled:!C||_,title:`Drop the changes`,onClick:()=>void b(),children:`Revert`}),(0,I.jsx)(`button`,{className:`design-save`,disabled:!O,title:D&&C?`gcf design save: your changes and the waiting change of ${a.file}, in one commit`:C?d?`gcf design save: the whole part as text; refused if it changed since it was read`:`gcf design save: only the changed fields; refused if the part changed since it was read, or if the save adds a finding of the design check`:`Nothing changed yet`,onClick:()=>void E(),children:_?`Saving…`:d?`Save text`:S?`Save ${S} ${S===1?`change`:`changes`}`:`Save`})]})]})}function rS({ctx:e,d:t,part:n,go:r}){let i=cr(e.board),a=i.filter(e=>e.done).length,o=i.length>0&&a===i.length,s=e.board.units??[],c=s.filter(e=>e.ready).length,l=lr(e.board).filter(e=>e.class!==`D2`&&!e.answer).length,u={start:`${a}/${i.length}`,pillars:String(t.pillars.length),vision:t.game?`✔`:`–`,glossary:String(t.glossary??0),units:String(s.length),questions:String(l),designer:``},d={start:`${a} of ${i.length} steps done`,pillars:`${t.pillars.length} pillars`,vision:t.game?`game.md exists`:`no game.md yet`,glossary:`${t.glossary??0} terms`,units:`${s.length} live units · ${c} ready`,questions:`${l} waiting for your answer`,designer:`Export the whole design as one markdown file, or import it back`},f=e=>e===`questions`&&l?` needs`:e===`start`&&o?` ok`:``,p=o?[...Bx.slice(1),Bx[0]]:Bx,m=`${a} of ${i.length} steps done`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`nav`,{className:`design-nav`,"aria-label":`Parts of the design`,children:[(0,I.jsxs)(`div`,{className:`design-nav-head`,children:[(0,I.jsx)(`h1`,{children:`Design`}),(0,I.jsx)(`span`,{title:`design.steps: what the framework counts done`,children:m})]}),p.map(e=>(0,I.jsxs)(`button`,{className:`design-nav-btn`,"aria-current":e===n||void 0,title:d[e],onClick:()=>r(e),children:[(0,I.jsx)(`span`,{children:Vx[e]}),u[e]&&(0,I.jsx)(`span`,{className:`design-count${f(e)}`,children:u[e]})]},e)),(0,I.jsx)(`p`,{className:`design-nav-note`,children:`Nothing here is work yet: a unit becomes a card on the board only when it is taken into work.`})]}),(0,I.jsxs)(`div`,{className:`design-bar`,children:[(0,I.jsxs)(`div`,{className:`design-bar-head`,children:[(0,I.jsx)(`h1`,{children:`Design`}),(0,I.jsx)(`span`,{children:m})]}),(0,I.jsx)(`div`,{role:`tablist`,"aria-label":`Parts of the design`,className:`design-bar-tabs`,children:p.map(e=>(0,I.jsxs)(`button`,{role:`tab`,className:`design-bar-tab`,"aria-selected":e===n,title:d[e],onClick:()=>r(e),children:[Vx[e],u[e]&&(0,I.jsx)(`span`,{className:`design-count${f(e)}`,children:u[e]})]},e))})]})]})}function iS({ctx:e,d:t,go:n}){let r=e.board.domain.sections.design,i=Tr(e.board.domain,r?.commit),a=Tr(e.board.domain,r?.discard),o=t.unrecorded,[s,c]=(0,v.useState)(null);return o.length?(0,I.jsxs)(`section`,{className:`design-unrec`,"aria-label":`Not recorded yet`,children:[(0,I.jsxs)(`div`,{className:`design-unrec-main`,children:[(0,I.jsxs)(`div`,{className:`design-unrec-head`,children:[(0,I.jsx)(`h2`,{children:`Not recorded yet`}),(0,I.jsxs)(`span`,{children:[o.length===1?`1 file waits`:`${o.length} files wait`,` to be recorded`]})]}),(0,I.jsx)(`div`,{className:`design-unrec-files`,children:o.map(e=>{let t=hr(e);return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`code`,{title:`Written by a design thread or an agent's draft; git has not recorded it yet`,children:e}),t&&(0,I.jsx)(`button`,{className:`design-open`,title:`Edit it in its part's form: a save of the part records the draft along with your edits`,onClick:()=>n(t),children:`open in its form →`})]},e)})}),(0,I.jsx)(`span`,{className:`design-note`,children:`Look it over, then record it: one commit. Or edit it in its form: the save takes it along. A save that touches another waiting file waits for it.`})]}),(0,I.jsxs)(`div`,{className:`design-unrec-acts`,children:[i&&(0,I.jsx)(`button`,{className:`design-rec`,title:t.blocking?`gcf design commit: refused while the design check has findings; the dialog gives the framework's answer`:`gcf design commit: one commit of the files that wait`,onClick:()=>c(`record`),children:`Record design…`}),a&&o.some(gr)&&(0,I.jsx)(`button`,{className:`design-danger`,title:`gcf design discard: the draft's files as the last record has them, a new one deleted; it asks first`,onClick:()=>c(`discard`),children:`Discard draft…`})]}),s&&(0,I.jsx)(hS,{ctx:e,kind:s,onClose:()=>c(null)})]}):null}function aS({ctx:e,d:t,go:n}){let r=e.board.units??[];return t.blocking?(0,I.jsxs)(`section`,{className:`design-findings`,"aria-label":`Findings of the design check`,children:[(0,I.jsxs)(`div`,{className:`design-findings-head`,title:`design.blocking: findings of the design check that hold every commit`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`!`}),(0,I.jsxs)(`span`,{children:[Kx(t.blocking,`blocking finding`),` of the design check: nothing commits until the check is clean. A save that clears the last one goes.`]})]}),(0,I.jsx)(`ul`,{children:(t.findings??[]).map((e,t)=>{let i=r.some(t=>t.id===e.id);return(0,I.jsxs)(`li`,{children:[(0,I.jsxs)(`span`,{className:`design-find-where`,children:[(0,I.jsx)(`code`,{className:`design-find-check`,title:`The check that found it`,children:e.check}),(0,I.jsxs)(`code`,{children:[e.file,e.line==null?``:`:${e.line}`]})]}),(0,I.jsxs)(`span`,{className:`design-find-main`,children:[(0,I.jsx)(`span`,{className:`design-find-msg`,children:e.message}),i?(0,I.jsxs)(`button`,{className:`design-find-open`,title:`Open the unit ${e.id}`,onClick:()=>n(`units:${e.id}`),children:[`open `,e.id,` →`]}):e.id&&(0,I.jsx)(`span`,{className:`design-find-id`,title:`${e.id} is not a unit: fix it in ${e.file}`,children:e.id})]})]},t)})})]}):null}function oS({ctx:e,file:t,importing:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),s=async()=>{if(o(!a),!a)try{i((await k.file(e.project.name,t)).text)}catch{i(``)}},c=Sr(r??``);return(0,I.jsxs)(`div`,{className:`design-source-card`,children:[(0,I.jsxs)(`div`,{className:`design-source-row`,children:[(0,I.jsx)(`code`,{children:t}),(0,I.jsx)(`button`,{className:`design-small-btn`,"aria-expanded":a,title:`Its text as kept in gcf/source/, by its anchored sections`,onClick:()=>void s(),children:a?`hide`:`view`}),!n&&(0,I.jsx)(Zx,{ctx:e,label:`Import a new version`})]}),n&&(0,I.jsxs)(`div`,{role:`status`,className:`design-importing`,children:[(0,I.jsx)(`span`,{children:`Import unfinished: pick the same GDD again to go on.`}),(0,I.jsx)(Zx,{ctx:e,label:`Pick the same GDD again`,big:!0})]}),a&&(0,I.jsxs)(`div`,{className:`design-gdd`,children:[(0,I.jsxs)(`span`,{className:`design-gdd-head`,children:[t,` · `,c.filter(e=>e.level>1).length,` sections, each anchored`]}),r!==null&&!c.length&&(0,I.jsx)(`span`,{className:`design-gdd-none`,children:`The board could not read the GDD's text.`}),c.map((e,t)=>(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:e.level===1?`top`:void 0,children:e.h}),e.body&&(0,I.jsx)(`p`,{children:e.body})]},t))]})]})}function sS({ctx:e,d:t,go:n}){let r=e.board.domain.starts??{},i=cr(e.board),a=e.board.units??[],o=lr(e.board),[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)(!1),d=i.filter(e=>e.done).length,f=i.length>0&&d===i.length,p=i.find(e=>!e.done)?.id,m=o.filter(e=>e.class!==`D2`&&!e.answer).length,h=a.filter(e=>e.ready),g=a.filter(e=>e.blocked_by.length),_=Object.keys(t.systems).length,y=t.pillars.some(e=>!e.name),b={design:a.length||t.game?[`${Kx(a.length,`design unit`)} in ${Kx(_,`subsystem`)}`,t.game?`the vision written (game.md)`:`no vision yet`,t.glossary?`${t.glossary} glossary terms`:``,t.sources[0]?`imported from ${t.sources[0].file.split(`/`).pop()}`:``].filter(Boolean).join(` · `):`nothing yet: no design unit, no vision`,pillars:t.pillars.length?`${Kx(t.pillars.length,`pillar`)}: ${t.pillars.map(e=>e.name||`${e.id} (no name yet)`).join(`, `)}`:`no pillar yet: 2 to 7`,questions:m?`${m} waiting for your answer`:o.length?`none waits for your answer`:`no question yet`,work:h.length?`${Kx(h.length,`ready unit`)}: ${h.map(e=>e.id).join(`, `)}`:a.length?`no unit is ready yet: each has a TBD or a question`:`no unit yet`},x=(e,t,r)=>(0,I.jsxs)(`button`,{className:`design-link${r?` big`:``}`,onClick:()=>n(e),children:[t,` →`]});return(0,I.jsxs)(`section`,{className:`design-sec design-start`,"aria-label":`Start`,children:[(0,I.jsxs)(`div`,{className:`design-start-head`,children:[(0,I.jsx)(`h2`,{children:f?`The design is set`:d===0?`A game starts with its design`:`From an idea to the first work`}),(0,I.jsx)(`p`,{children:f?`All four steps are done. The pillars and the units change all along the project: their parts are on the left, and Start stays at the end of the list.`:d===0?`Four steps from an idea to the first work. Begin with the game design: bring a GDD, or talk the game through with an agent.`:`Four steps, each done or not by the framework's count. A done step stays here: you may go back to any of them.`})]}),(0,I.jsx)(`ol`,{className:`design-steps`,children:i.map((a,o)=>{let d=a.id===p,f=s[a.id]??(!a.done&&d),_=(a.starts??[]).filter(e=>r[e]&&r[e].takes!==`unit`&&(e!==`name-pillars`||y));return(0,I.jsxs)(`li`,{className:`design-step`,children:[(0,I.jsxs)(`div`,{className:`design-step-rail`,"aria-hidden":`true`,children:[(0,I.jsx)(`span`,{className:`design-step-mark${a.done?` done`:d?` cur`:``}`,children:a.done?`✔`:o+1}),o<i.length-1&&(0,I.jsx)(`span`,{className:`design-step-line`})]}),(0,I.jsxs)(`div`,{className:`design-step-body${d?` cur`:``}`,children:[(0,I.jsxs)(`button`,{className:`design-step-toggle`,"aria-expanded":f,title:f?`Fold the step`:`Open the step and its ways in`,onClick:()=>c({...s,[a.id]:!f}),children:[(0,I.jsxs)(`span`,{className:`design-step-text`,children:[(0,I.jsxs)(`span`,{className:`design-step-titles`,children:[(0,I.jsx)(`span`,{className:`design-step-title${!a.done&&!d?` later`:``}`,children:a.label}),(0,I.jsx)(`span`,{className:`design-step-state${a.done?` done`:d?` cur`:``}`,title:a.done?`The framework counts this step done (design.steps); you may go back to it at any time`:`Not done yet, by the framework's count (design.steps)`,children:a.done?`done`:d?`next`:`not done`})]}),(0,I.jsx)(`span`,{className:`design-step-summary`,children:b[a.id]??``})]}),(0,I.jsx)(`span`,{className:`design-step-fold`,children:f?`Close`:a.done?`Go back to it`:`Open`})]}),f&&(0,I.jsxs)(`div`,{className:`design-step-open`,children:[(0,I.jsx)(`p`,{className:`design-step-help`,children:a.help}),a.id===`design`&&(0,I.jsxs)(`div`,{className:`design-step-design`,children:[(0,I.jsx)(`div`,{className:`design-ways`,children:_.map((t,n)=>(0,I.jsx)(Xx,{ctx:e,k:t,primary:n===0},t))}),x(`units`,`or write units by hand`),(0,I.jsxs)(`div`,{className:`design-learn`,children:[(0,I.jsxs)(`button`,{className:`design-learn-btn`,"aria-expanded":l,title:`What the import writes into the project`,onClick:()=>u(!l),children:[l?`▾ `:`▸ `,`What an import gives`]}),l&&(0,I.jsx)(`dl`,{children:Wx.map(([e,t])=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:e}),(0,I.jsx)(`dd`,{children:t})]},e))})]}),t.sources.length>0&&(0,I.jsxs)(`div`,{className:`design-sources`,children:[(0,I.jsx)(`h3`,{className:`design-h3`,children:`GDD sources`}),t.sources.map(t=>(0,I.jsx)(oS,{ctx:e,file:t.file,importing:t.importing},t.file))]})]}),a.id!==`design`&&(_.length>0||a.id===`pillars`)&&(0,I.jsxs)(`div`,{className:`design-step-ways`,children:[_.map((t,n)=>(0,I.jsx)(Yx,{ctx:e,k:t,named:!0,primary:n===0},t)),a.id===`pillars`&&x(`pillars`,`or write them by hand`)]}),a.id===`questions`&&(0,I.jsxs)(`div`,{className:`design-step-list`,children:[x(`questions`,`${m} waiting for your answer`,!0),g.length>0&&(0,I.jsxs)(`div`,{className:`design-held-list`,children:[(0,I.jsx)(`span`,{children:`Units a question holds`}),g.map(e=>(0,I.jsxs)(`button`,{title:`Open the unit`,onClick:()=>n(`units:${e.id}`),children:[(0,I.jsx)(`span`,{className:`design-held-id`,children:e.id}),(0,I.jsxs)(`span`,{className:`design-held-by`,children:[`held by `,e.blocked_by.join(`, `)]})]},e.id))]})]}),a.id===`work`&&(0,I.jsxs)(`div`,{className:`design-step-list`,children:[h.map(e=>(0,I.jsxs)(`button`,{className:`design-ready`,title:`Open the unit: Fill TBDs with agent takes it into work on your word`,onClick:()=>n(`units:${e.id}`),children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`span`,{className:`design-held-id`,children:e.id}),(0,I.jsx)(`span`,{className:`design-ready-mark`,children:`ready`})]}),(0,I.jsx)(`span`,{className:`design-ready-title`,children:e.title})]},e.id)),x(`units`,`pick a ready unit`),(0,I.jsx)(`span`,{className:`design-fine`,children:`In the unit, Fill TBDs with agent goes through it with you; it goes into work only when you say so.`})]})]})]})]},a.id)})})]})}function cS({ctx:e,d:t}){let n=!t.pillars.length,r=t.pillars.filter(e=>!e.name).length;return(0,I.jsxs)(`section`,{className:`design-sec`,"aria-label":`Pillars`,children:[(0,I.jsxs)(`div`,{className:`design-head`,children:[(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`h2`,{children:`Pillars`}),(0,I.jsx)(`span`,{className:`design-lead`,children:`What the game always holds: every unit and every review answers to them. One part, gcf/PILLARS.md: Save writes all of them together.`})]}),!n&&(0,I.jsx)(Yx,{ctx:e,k:`pillars`})]}),n&&(0,I.jsxs)(`div`,{className:`design-empty-panel`,children:[(0,I.jsx)(`h3`,{children:`PILLARS.md is empty`}),(0,I.jsx)(`span`,{className:`design-empty-text`,children:`The interview starts from candidates the agent draws from the vision and the units: you keep 2 to 7, each with what it forbids and the question a review asks. The draft waits under Not recorded yet until you record it.`}),(0,I.jsx)(Yx,{ctx:e,k:`pillars`,primary:!0}),(0,I.jsx)(`span`,{className:`design-fine`,children:`Or write one by hand below.`})]}),r>0&&(0,I.jsxs)(`div`,{className:`design-unnamed`,role:`note`,children:[(0,I.jsxs)(`span`,{children:[r===1?`1 pillar has`:`${r} pillars have`,` no name yet: it shows its id until one is given`]}),(0,I.jsx)(Yx,{ctx:e,k:`name-pillars`})]}),(0,I.jsx)(nS,{ctx:e,kind:`doc`,name:`pillars`,rows:14}),!n&&(0,I.jsx)(Qx,{ctx:e,k:`revise-pillars`,label:`Revise with agent`,help:`Say what to change: the agent proposes, you confirm in the thread.`})]})}function lS({ctx:e,d:t}){return(0,I.jsxs)(`section`,{className:`design-sec`,"aria-label":`Vision and scope`,children:[(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`h2`,{children:`Vision & scope`}),(0,I.jsx)(`code`,{className:`design-path`,children:`gcf/game.md`})]}),!t.game&&(0,I.jsxs)(`div`,{className:`design-panel design-novision`,children:[(0,I.jsx)(`span`,{children:`No vision yet. An import drafts it from the GDD; Create with agent writes it in an interview.`}),(0,I.jsx)(Yx,{ctx:e,k:`vision`}),(0,I.jsx)(`span`,{className:`design-fine`,children:`Or write it by hand below.`})]}),(0,I.jsx)(nS,{ctx:e,kind:`doc`,name:`game`}),t.game&&(0,I.jsx)(Qx,{ctx:e,k:`revise-vision`,label:`Change with agent`,help:`The vision, the scope or the milestones, in your words.`})]})}function uS({ctx:e,d:t}){let n=t.glossary??0;return(0,I.jsxs)(`section`,{className:`design-sec`,"aria-label":`Glossary`,children:[(0,I.jsxs)(`div`,{className:`design-head`,children:[(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`h2`,{children:`Glossary`}),(0,I.jsxs)(`span`,{className:`design-path`,children:[`GLOSSARY.md · `,n,` terms`]})]}),(0,I.jsx)(Yx,{ctx:e,k:`draft-glossary`,primary:!n&&!t.glossary_old})]}),t.glossary_old&&(0,I.jsx)(`p`,{className:`design-empty warn-text`,role:`note`,children:`gcf/glossary.md is read no more (core 0.21): move it to GLOSSARY.md with git mv, give it a purpose line, turn each not: into avoid: (a word wrong in every document) and move units: into gcf/game.md. Until then its words hold nowhere.`}),!n&&!t.glossary_old&&(0,I.jsxs)(`p`,{className:`design-empty`,children:[`No glossary yet. Draft with agent writes one from the vision and the units; it waits under Not recorded yet for you to record, edit or discard.`,(0,I.jsx)(`span`,{className:`design-fine design-empty-fine`,children:`Or write it by hand below.`})]}),(0,I.jsx)(nS,{ctx:e,kind:`doc`,name:`glossary`})]})}function dS({ctx:e,d:t,onClose:n,onMade:r}){let i=e.board.domain.sections.design,a=Tr(e.board.domain,i?.new_unit),o=Object.keys(t.systems),s=e=>a?.fields.find(t=>t.key===e),c=s(`type`)?.options?.map(e=>e.value)??Hx,[l,u]=(0,v.useState)({system:o[0]??``,type:c.includes(`mechanic`)?`mechanic`:c[0]??``,title:``}),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(void 0),[h,g]=(0,v.useState)(!1);if(!a)return null;let _=(e,t)=>{u({...l,[e]:t}),f(``),m(void 0)},y=(e,t)=>`${s(e)?.label??t} *`,b=!!l.system&&!o.includes(l.system),x=b&&!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(l.system),S=async()=>{let t=[!l.system.trim()&&y(`system`,`Subsystem`),!l.title.trim()&&y(`title`,`Title`)].filter(Boolean);if(t.length)return f(`${t.join(`, `)}: required`);if(x)return f(`system: a subsystem is a lowercase slug (letters, digits, hyphens), e.g. tray-input`);m(void 0),g(!0);let n=await e.moveOut({cmd:a.cmd,...l,fields:`{}`});g(!1);let i=n.out.split(`
92
+ `)[0].trim();n.ok&&i?r(i):(f(n.err||`The framework refused it: its answer is in the notice.`),m(n.refusal))};return(0,I.jsx)(R,{onClose:n,dirty:h||!!l.title,children:(0,I.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Add a design unit`,className:`design-dialog`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`design-dialog-head`,children:[(0,I.jsx)(`h2`,{children:`Add a design unit`}),(0,I.jsxs)(`span`,{children:[a.help,`. Every block of its type starts TBD; it lands at the end of its subsystem's file and of backlog.md, and opens.`]})]}),(0,I.jsxs)(`div`,{className:`design-dialog-field`,children:[(0,I.jsx)(`span`,{children:y(`system`,`Subsystem`)}),o.length>0&&(0,I.jsx)(`div`,{role:`radiogroup`,"aria-label":`Existing subsystems`,className:`design-sys-chips`,children:o.map(e=>(0,I.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e===l.system,className:`design-sys-chip${e===l.system?` on`:``}`,onClick:()=>_(`system`,e),children:e},e))}),(0,I.jsx)(`input`,{className:`design-input mono${x?` bad`:b?` new`:``}`,"aria-label":o.length?`New subsystem`:`No subsystem yet: name the first one`,value:b?l.system:``,placeholder:o.length?`or a new one: tray-input`:`a new subsystem: tray-input`,onChange:e=>_(`system`,e.target.value.trim())}),b&&(0,I.jsx)(`span`,{className:`design-sys-note${x?` bad`:``}`,children:x?`A subsystem is a lowercase slug: letters, digits and hyphens, e.g. tray-input`:`New: gcf/design/${l.system}.md starts with this unit`})]}),(0,I.jsxs)(`label`,{className:`design-dialog-field`,children:[(0,I.jsx)(`span`,{children:y(`type`,`Type`)}),(0,I.jsx)(`select`,{className:`design-input`,value:l.type,onChange:e=>_(`type`,e.target.value),children:c.map(e=>(0,I.jsx)(`option`,{children:e},e))})]}),(0,I.jsxs)(`label`,{className:`design-dialog-field`,children:[(0,I.jsx)(`span`,{children:y(`title`,`Title`)}),(0,I.jsx)(`input`,{className:`design-input`,value:l.title,onChange:e=>_(`title`,e.target.value)})]}),(0,I.jsxs)(`code`,{className:`design-dialog-cmd`,children:[`gcf design save --kind unit --system `,l.system||`<subsystem>`,` --type`,` `,l.type||`<type>`,` --title `,l.title?(e=>/\s/.test(e)?`"${e}"`:e)(l.title):`<title>`]}),d&&(0,I.jsx)(fS,{ctx:e,error:d,refusal:p}),(0,I.jsxs)(`div`,{className:`design-dialog-acts`,children:[(0,I.jsx)(`button`,{className:`design-cancel`,disabled:h,onClick:n,children:`Cancel`}),(0,I.jsx)(`button`,{className:`design-prim`,disabled:h,onClick:()=>void S(),children:h?`Working…`:`Add unit`})]})]})})}function fS({ctx:e,error:t,refusal:n}){return(0,I.jsxs)(`div`,{role:`alert`,className:`design-dialog-err`,children:[(0,I.jsx)(`span`,{children:t}),n&&(0,I.jsx)(v_,{ctx:e,refusal:n,error:t,again:`the button below tries again`},n.paths.join(`
93
+ `))]})}var pS={record:()=>`Record the design`,discard:()=>`Discard the draft?`,retire:e=>`Retire pillar ${e}`,drop:e=>`Drop unit ${e}`},mS={record:`Record design`,discard:`Discard draft`,retire:`Retire`,drop:`Drop`};function hS({ctx:e,kind:t,id:n=``,onClose:r}){let i=e.board.domain.sections.design,a={record:i?.commit,discard:i?.discard,retire:i?.retire,drop:i?.drop}[t],o=Tr(e.board.domain,a),s=(e.board.units??[]).find(e=>e.id===n),[c,l]=(0,v.useState)(t===`drop`&&s?{tags:s.system}:{}),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(void 0),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(null);if(!o||!a)return null;let y=sr(e.board)?.unrecorded??[],b=t===`record`?y:t===`discard`?y.filter(gr):[],x=o.fields.filter(e=>!e.hidden),S=(e.board.domain.moves[a]?.args??[]).join(` `).replace(`{id}`,n),C=t===`discard`?`${o.help??``}. These files go back:`:o.help??``,w=async()=>{if(g)return r();p(void 0);let i=x.filter(e=>e.required&&!c[e.key]?.trim());if(i.length)return d(`${i.map(e=>e.label).join(`, `)}: required`);h(!0);let o=await e.moveOut({cmd:a,...n?{id:n}:{},...Nr(x,c)});if(h(!1),p(o.refusal),!o.ok)return d(o.err||o.out||`The framework refused it.`);if(t!==`drop`)return r();_({type:s?.type??``,reason:c.reason??``,tags:(c.tags??``).split(/[,\s]+/).filter(Boolean)})};return(0,I.jsx)(R,{onClose:r,dirty:m||Object.values(c).some(Boolean),children:(0,I.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":g?`Unit dropped`:pS[t](n),className:`design-dialog`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`design-dialog-head`,children:[(0,I.jsx)(`h2`,{children:g?`Unit dropped`:pS[t](n)}),!g&&C&&(0,I.jsx)(`span`,{children:C})]}),g&&(0,I.jsxs)(`div`,{className:`design-grave`,children:[(0,I.jsx)(`span`,{children:`In the graveyard (Ended), as an item's line`}),(0,I.jsxs)(`div`,{className:`design-grave-line`,children:[(0,I.jsx)(`code`,{children:n}),(0,I.jsx)(`span`,{className:`design-grave-type`,children:g.type}),(0,I.jsx)(`span`,{className:`design-grave-reason`,children:g.reason}),(0,I.jsx)(`span`,{className:`design-grave-tags`,children:g.tags.map(e=>(0,I.jsxs)(`span`,{children:[`#`,e]},e))})]})]}),!g&&b.length>0&&(0,I.jsx)(`div`,{className:`design-dialog-files`,children:b.map(e=>(0,I.jsx)(`code`,{children:e},e))}),!g&&x.map(e=>(0,I.jsxs)(`label`,{className:`design-dialog-field`,children:[(0,I.jsxs)(`span`,{children:[e.label,e.required?` *`:``]}),e.kind===`longtext`?(0,I.jsx)(`textarea`,{className:`design-input`,rows:3,value:c[e.key]??``,onChange:t=>l({...c,[e.key]:t.target.value})}):e.kind===`choice`?(0,I.jsx)(`select`,{className:`design-input`,value:c[e.key]??``,onChange:t=>l({...c,[e.key]:t.target.value}),children:(e.options??[]).map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,I.jsx)(`input`,{className:`design-input`,value:c[e.key]??``,onChange:t=>l({...c,[e.key]:t.target.value})})]},e.key)),!g&&(0,I.jsx)(`code`,{className:`design-dialog-cmd`,children:S}),u&&(0,I.jsx)(fS,{ctx:e,error:u,refusal:f}),(0,I.jsxs)(`div`,{className:`design-dialog-acts`,children:[!g&&(0,I.jsx)(`button`,{className:`design-cancel`,disabled:m,onClick:r,children:`Cancel`}),(0,I.jsx)(`button`,{className:`design-prim${o.danger&&!g?` danger`:``}`,disabled:m,onClick:()=>void w(),children:m?`Working…`:g?`Done`:mS[t]})]})]})})}function gS(e,t){let[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=!0;return k.designPart(e.project.name,`system`,t).then(e=>{let t=e.fields.find(e=>e.key===`purpose`)?.value,i=Array.isArray(t)?t.join(` · `):typeof t==`string`?t:``;n&&r(e.exists?i||`TBD`:`no part yet`)},()=>n&&r(``)),()=>{n=!1}},[t,e.board.head]),n}function _S({ctx:e,system:t,list:n,open:r,go:i}){let a=sr(e.board)?.systems[t],o=gS(e,t);return(0,I.jsxs)(`section`,{className:`design-sys`,"aria-label":`Subsystem ${t}`,children:[(0,I.jsxs)(`div`,{className:`design-sys-head`,children:[(0,I.jsxs)(`span`,{className:`design-sys-name`,children:[(0,I.jsx)(`span`,{children:t}),a&&(0,I.jsxs)(`span`,{className:`design-sys-sub`,title:`From design.systems: units, ready, values (filled slots) and TBDs in gcf/design/${t}.md`,children:[Kx(a.units,`unit`),` · `,a.ready,` ready · `,a.values,` values ·`,` `,a.tbd?`TBD ${a.tbd}`:`no TBD`]})]}),(0,I.jsxs)(`div`,{className:`design-sys-row`,children:[(0,I.jsxs)(`button`,{className:`design-purpose${r===`system:${t}`?` on`:``}`,title:`Open the subsystem's purpose in its form`,onClick:()=>i(`units:system:${t}`),children:[(0,I.jsx)(`span`,{className:`design-purpose-k`,children:`Purpose`}),(0,I.jsx)(`span`,{className:`design-purpose-v`,children:o}),(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`›`})]}),(0,I.jsx)(Yx,{ctx:e,k:`draft-system`,system:t})]})]}),(0,I.jsxs)(`div`,{className:`design-sys-rows`,children:[n.map(e=>{let t=yr(e);return(0,I.jsxs)(`button`,{className:`design-unit-row${r===e.id?` on`:``}`,"aria-current":r===e.id||void 0,title:t.tip,onClick:()=>i(`units:${e.id}`),children:[(0,I.jsxs)(`span`,{className:`design-unit-top`,children:[(0,I.jsx)(`span`,{className:`design-unit-title`,children:e.title??e.id}),(0,I.jsx)(`span`,{className:`design-pill tone-${t.tone}`,children:t.state})]}),(0,I.jsxs)(`span`,{className:`design-unit-meta`,children:[(0,I.jsx)(`span`,{children:e.type}),(0,I.jsxs)(`span`,{children:[`(`,e.id,`)`]}),t.extra&&(0,I.jsx)(`span`,{className:`warn`,children:t.extra})]})]},e.id)}),!n.length&&(0,I.jsx)(`span`,{className:`design-none`,children:`no unit yet`})]})]})}function vS({ctx:e,d:t,open:n,go:r}){let i=e.board.units??[],a=Tr(e.board.domain,e.board.domain.sections.design?.drop),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=Map.groupBy(i,e=>e.system),d=[...new Set([...Object.keys(t.systems),...u.keys()])],f=n?.startsWith(`system:`)?n.slice(7):null,p=i.find(e=>e.id===n),m=(0,I.jsx)(`button`,{className:`design-back`,onClick:()=>r(`units`),children:`‹ Units`}),h=p&&yr(p);return(0,I.jsxs)(`section`,{className:`design-units${p||f?` has-open`:``}`,"aria-label":`Units`,children:[(0,I.jsxs)(`div`,{className:`design-unit-list`,children:[(0,I.jsxs)(`div`,{className:`design-head`,children:[(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`h2`,{children:`Units`}),(0,I.jsxs)(`span`,{className:`design-path small`,children:[i.length,` live units · `,i.filter(e=>e.ready).length,` ready`]})]}),e.board.domain.sections.design?.new_unit&&(0,I.jsx)(`button`,{className:`design-add-unit`,title:`A new unit: subsystem, type, title; its id comes from the title, every block starts TBD`,onClick:()=>s(!0),children:`+ Add unit`})]}),!d.length&&(0,I.jsx)(`p`,{className:`design-empty`,children:`No design unit yet. An import or Create with agent writes the first ones; Add unit writes one by hand.`}),d.map(t=>(0,I.jsx)(_S,{ctx:e,system:t,list:u.get(t)??[],open:n,go:r},t))]}),!p&&!f&&d.length>0&&(0,I.jsx)(`div`,{className:`design-pick-one`,children:`Open a unit to see its form.`}),p&&h&&(0,I.jsxs)(`article`,{className:`design-open-part`,"aria-label":`Unit ${p.id}`,children:[m,(0,I.jsxs)(`div`,{className:`design-unit-head`,children:[(0,I.jsxs)(`span`,{className:`design-unit-id`,children:[(0,I.jsx)(`code`,{children:p.id}),(0,I.jsx)(`span`,{className:`tone-${h.tone}`,children:p.ready?`ready: no TBD, no question`:p.blocked_by.length?`held by ${p.blocked_by.join(`, `)}${p.tbd?` · TBD ${p.tbd}`:``}`:`TBD ${p.tbd}`})]}),(0,I.jsx)(`h2`,{children:p.title??p.id}),(0,I.jsxs)(`span`,{className:`design-path`,children:[p.type,` · `,p.file]})]}),(0,I.jsxs)(`div`,{className:`design-unit-acts`,children:[(0,I.jsx)(Yx,{ctx:e,k:`card`,unit:p.id,primary:!0}),(0,I.jsx)(Yx,{ctx:e,k:`debate-unit`,unit:p.id}),(0,I.jsx)(`span`,{className:`design-spacer`}),a&&(0,I.jsx)(Na,{label:`Drop the unit`,tip:`Drop…: the unit leaves the design into the graveyard, with the reason; it asks first`,onClick:()=>l(p.id)})]}),(0,I.jsx)(`span`,{className:`design-fine design-unit-hint`,children:`Fill TBDs with agent goes through the TBDs with you; it goes into work only on your word.`}),(0,I.jsxs)(`div`,{className:`design-held`,children:[(0,I.jsx)(`h3`,{className:`design-h3`,children:`Questions that hold it`}),!ur(e.board,p.id).length&&(0,I.jsx)(`span`,{className:`design-none`,children:`No question holds it.`}),ur(e.board,p.id).map(t=>(0,I.jsx)(Do,{ctx:e,q:t},t.id))]}),(0,I.jsx)(nS,{ctx:e,kind:`unit`,name:p.id,rows:24},p.id)]}),f&&(0,I.jsxs)(`article`,{className:`design-open-part`,"aria-label":`Subsystem ${f}`,children:[m,(0,I.jsxs)(`div`,{className:`design-head`,children:[(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`span`,{className:`design-kicker`,children:`subsystem`}),(0,I.jsx)(`h2`,{className:`mono`,children:f})]}),(0,I.jsx)(Yx,{ctx:e,k:`draft-system`,system:f})]}),(0,I.jsx)(nS,{ctx:e,kind:`system`,name:f},f)]}),c&&(0,I.jsx)(hS,{ctx:e,kind:`drop`,id:c,onClose:()=>{l(null),n===c&&r(`units`)}}),o&&(0,I.jsx)(dS,{ctx:e,d:t,onClose:()=>s(!1),onMade:e=>{s(!1),r(`units:${e}`)}})]})}function yS({ctx:e}){let t=lr(e.board),n=t.filter(e=>e.class!==`D2`),r=t.filter(e=>e.class===`D2`),[i,a]=(0,v.useState)(!1),o=n.filter(e=>!e.answer).length,s=t=>{let n=br(e.board,t),r=`q:${t.id}`,i=t.sys&&t.sys!==`-`?t.sys:``;return(0,I.jsx)(Ma,{cat:n.label,catTip:n.help,tone:n.needs?`needs`:void 0,needs:n.needs&&!t.answer,origin:t.origin??`agent`,title:(t.class===`D2`?t.assumed:t.question)??t.id,sub:t.blocks?`blocks ${t.blocks}`:i,mark:t.answer?`✔ answered`:t.proposed?`a proposal`:void 0,markTone:t.answer?`ok`:`text`,on:e.detailKey===r,onOpen:()=>e.openDetail({key:r,render:e=>{let n=lr(e.board).find(e=>e.id===t.id);if(!n)return null;let r=br(e.board,n);return{cat:r.label,catTip:r.help,tone:r.needs?`needs`:void 0,origin:n.origin??`agent`,body:(0,I.jsx)(Do,{ctx:e,q:n})}}})},t.id)},c=t=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`design-desk`,children:(0,I.jsx)(Pa,{children:t.map(s)})}),(0,I.jsx)(`div`,{className:`design-phone`,children:t.map(t=>(0,I.jsx)(Do,{ctx:e,q:t},t.id))})]});return(0,I.jsxs)(`section`,{className:`design-sec design-qs`,"aria-label":`Questions`,children:[(0,I.jsx)(`div`,{className:`design-head`,children:(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`h2`,{children:`Questions`}),(0,I.jsx)(`span`,{className:`design-lead`,children:`What the design leaves open. Inbox lists the same questions: one record, answered in either place.`}),(0,I.jsx)(Yx,{ctx:e,k:`debate`})]})}),!t.length&&(0,I.jsx)(`p`,{className:`design-empty`,children:`No open question. An import or a review with agent writes them here.`}),n.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`h3`,{className:`design-h3`,children:[`Waiting for your answer`,(0,I.jsxs)(`span`,{className:`design-h3-count`,children:[o,` waiting · `,n.length-o,` answered`]})]}),c(n)]}),r.length>0&&(0,I.jsxs)(`button`,{className:`design-fold`,"aria-expanded":i,onClick:()=>a(!i),children:[i?`▾ `:`▸ `,br(e.board,r[0]).label,` · `,r.length]}),i&&c(r)]})}function bS({ctx:e}){let t=e.board.domain.sections.design,[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=async()=>{let t=await fetch(A(e.project.name));if(!t.ok)throw Error(await t.text());return t.text()},l=async()=>{r(`export`);try{let e=await c(),t=document.createElement(`a`);t.href=URL.createObjectURL(new Blob([e],{type:`text/markdown`})),t.download=`design.md`,t.click(),setTimeout(()=>URL.revokeObjectURL(t.href),0),a(e)}catch(t){e.notify(t.message,`error`)}r(null)},u=async()=>{if(i!==null)return a(null);try{a(await c())}catch(t){e.notify(t.message,`error`)}},d=async n=>{if(!t)return;r(`import`),s(null);let i=await e.moveOut({cmd:t.import,bundle:await n.text()});r(null),!i.ok&&i.refusal&&E_(i.refusal,i.err);let a=Cr(i.out);(i.ok||a.applied.length||a.report.length)&&s({name:n.name,...a})};return(0,I.jsxs)(`section`,{className:`design-sec`,"aria-label":`Designer`,children:[(0,I.jsxs)(`div`,{className:`design-head-main`,children:[(0,I.jsx)(`h2`,{children:`Designer`}),(0,I.jsx)(`span`,{className:`design-lead design-narrow`,children:`For a designer who edits the design like a document: the whole of it in one markdown file, out and back, without an agent.`})]}),(0,I.jsxs)(`div`,{className:`design-cards`,children:[(0,I.jsxs)(`div`,{className:`design-card`,children:[(0,I.jsx)(`h3`,{children:`Export`}),(0,I.jsx)(`span`,{children:`One markdown file: the pillars, the vision, the glossary and every unit. Its gcf:part comments mark each part: keep them, the import reads them.`}),(0,I.jsx)(`button`,{className:`design-card-btn`,disabled:n===`export`,title:`gcf design export: downloads the file`,onClick:()=>void l(),children:n===`export`?`Exporting…`:`Export`})]}),t&&(0,I.jsxs)(`div`,{className:`design-card`,children:[(0,I.jsx)(`h3`,{children:`Import`}),(0,I.jsx)(`span`,{children:`Brings the edited file back. A part changed in the project since the export is reported, never overwritten.`}),(0,I.jsxs)(`label`,{className:`design-card-btn design-pick-plain${n===`import`?` off`:``}`,title:`gcf design import --commit: pick the edited .md`,children:[n===`import`?`Importing…`:`Import`,(0,I.jsx)(`input`,{type:`file`,accept:`.md,text/markdown`,"aria-label":`Import the designer's file`,disabled:n===`import`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&d(t)}})]})]})]}),o&&(0,I.jsxs)(`section`,{role:`status`,"aria-label":`Import report`,className:`design-report`,children:[(0,I.jsxs)(`h3`,{children:[o.name,` imported`]}),(0,I.jsxs)(`div`,{className:`design-report-list`,children:[(0,I.jsx)(`span`,{children:`Written`}),o.applied.map(e=>(0,I.jsxs)(`code`,{className:`design-applied`,children:[`✔ `,e]},e))]}),o.report.length>0&&(0,I.jsxs)(`div`,{className:`design-report-list`,children:[(0,I.jsx)(`span`,{children:`Not written: reported, kept as they are in the project`}),o.report.map(e=>(0,I.jsxs)(`div`,{className:`design-reported`,children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`code`,{children:e.part}),(0,I.jsx)(`span`,{className:`design-outcome`,children:e.outcome})]}),(0,I.jsx)(`span`,{className:`design-reported-note`,children:e.note})]},e.part))]})]}),(0,I.jsxs)(`div`,{className:`design-export-wrap`,children:[(0,I.jsxs)(`button`,{className:`design-fold mono`,"aria-expanded":i!==null,title:`The file Export gives right now, the same as the download`,onClick:()=>void u(),children:[i===null?`▸ `:`▾ `,`What Export gives · design.md`]}),i!==null&&(0,I.jsx)(`div`,{className:`design-export`,children:i.split(`
94
+ `).map((e,t)=>(0,I.jsx)(`div`,{className:/^<!-- gcf:/.test(e)?`marker`:/^<!--/.test(e)?`comment`:void 0,children:e||` `},t))})]})]})}function xS({ctx:e,arg:t}){let[n,...r]=(t??``).split(`:`),i=Bx.includes(n)?n:`start`,a=r.join(`:`)||null,o=t=>e.go(`design`,t),s=sr(e.board),c=e.board.design&&`error`in e.board.design?e.board.design.error:``,l=$a(e.board.quota);return(0,I.jsxs)(`div`,{className:`design-screen part-${i}`,children:[s&&(0,I.jsx)(rS,{ctx:e,d:s,part:i,go:o}),(0,I.jsx)(`div`,{className:`design-main`,children:s&&(0,I.jsxs)(`div`,{className:`design-content`,children:[l&&(0,I.jsxs)(`div`,{role:`note`,className:`design-limit`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),(0,I.jsxs)(`span`,{children:[`Off until `,oi(l),`: the usage limit holds for the account. The forms work without an agent.`]})]}),(0,I.jsx)(iS,{ctx:e,d:s,go:o}),(0,I.jsx)(aS,{ctx:e,d:s,go:o}),i===`start`&&(0,I.jsx)(sS,{ctx:e,d:s,go:o}),i===`pillars`&&(0,I.jsx)(cS,{ctx:e,d:s}),i===`vision`&&(0,I.jsx)(lS,{ctx:e,d:s}),i===`glossary`&&(0,I.jsx)(uS,{ctx:e,d:s}),i===`units`&&(0,I.jsx)(vS,{ctx:e,d:s,open:a,go:o}),i===`questions`&&(0,I.jsx)(yS,{ctx:e}),i===`designer`&&(0,I.jsx)(bS,{ctx:e})]})}),c&&(0,I.jsx)(`div`,{role:`alert`,"aria-label":`The design check cannot run`,className:`design-cannot`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{children:`Design · the design check cannot run`}),(0,I.jsx)(`code`,{children:c}),(0,I.jsx)(`span`,{children:`The board reads the design with its check; until the check runs, no part of the design shows. The rest of the board works. The screen comes back by itself with the next read.`})]})})]})}function SS({ctx:e,spec:t,onClose:n}){let r=mb(),i=t.render(e),a=!i;return(0,v.useEffect)(()=>{a&&n()},[a,n]),i?(0,I.jsxs)(`aside`,{className:`drawer detail-win`,"aria-label":`Detail window`,...r,children:[(0,I.jsx)(`div`,{className:`d-head`,title:`Drag to move the window`,children:(0,I.jsxs)(`div`,{className:`d-top detail-top`,children:[(0,I.jsx)(`button`,{className:`d-back`,"aria-label":`Back`,onClick:n,children:`‹`}),(0,I.jsx)(`span`,{className:`tile-cat tone-${i.tone??`neutral`}`,title:i.catTip,children:i.cat}),i.origin&&(0,I.jsx)(`span`,{className:`tile-origin`,title:`where it came from: it never changes`,children:i.origin}),i.age&&(0,I.jsx)(`span`,{className:`detail-age`,title:i.ageTip,children:i.age}),(0,I.jsx)(`span`,{className:`detail-esc`,"aria-hidden":`true`,children:`Esc`}),(0,I.jsx)(`button`,{className:`icon-btn bordered d-close`,"aria-label":`Close`,title:`Close · Esc`,onClick:n,children:`×`})]})}),(0,I.jsx)(`div`,{className:`d-body detail-body`,children:i.body})]}):null}var CS=[[`run`,`An agent session works on an item; the board starts it through the harness`],[`running`,`The column of the items an agent session works on now`],[`queue`,`Runs in the project folder go one at a time; the next waits in the queue`],[`worktree / main`,`Where a run works: its own git worktree (several at once) or the folder`],[`handoff`,`At the context share a session hands its item to a fresh one, from the plan`],[`usage limit`,`A run waits for the limit to reset, then goes on by itself; Stop ends the wait`],[`resume`,`A rerun goes on in the session or worktree the last run left`],[`permissions`,`What agent runs may not do: deny groups and custom rules`]];function wS(e){return[...e.terms.map(e=>({group:`Terms`,term:e.term,help:e.help})),...e.columns.map(e=>({group:`Columns`,term:e.label,help:e.help})),...Object.entries(e.moves).flatMap(([e,t])=>t.help?[{group:`Moves`,term:e===t.label?e:`${t.label} (${e})`,help:t.help}]:[]),...e.fields.flatMap(e=>[...e.help?[{group:`Fields`,term:e.label,help:e.help}]:[],...(e.options??[]).flatMap(t=>t.help?[{group:`Fields`,term:`${e.label}: ${t.label}`,help:t.help}]:[])]),...CS.map(([e,t])=>({group:`Runs`,term:e,help:t}))]}var TS=[[`Space on a card`,`Pick the card up to move it without the mouse: ← → the column, ↑ ↓ its rank among ready cards, Space drops it, Esc puts it back`],[`Right click on chat text`,`With text selected: Copy, or Reply (it quotes the text into your message). On a phone, the Reply button under the selection`],[`/`,`Search: the board's filter on the board, the inbox's on the inbox, Help's in Help`],[`i`,`Quick capture: a new inbox entry, from any screen`],[`n`,`New item`],[`j / k`,`Move between cards`],[`Enter`,`Opens the focused card; in the inbox field adds the entry, Shift+Enter breaks the line`],[`Esc`,`Closes a dialog, a menu, Help or the item's window; a dialog with typed text stays`],[`r`,`Runs the focused card: it asks first, the card is not opened`],[`1–7`,`Focus a column`],[`?`,`Help`],[`j / k on Inbox`,`Move between records; Enter opens the record's window, s Sort…, l Later or Back, e Erase, Esc closes the window`],[`g, then a letter`,`Go to a screen: g c Command, g b Board, g t Chat, g i Inbox, g d Design, g r Runs, g p Playtest, g e Ended, g a Agent, g s Settings, g m Metrics`],[`Ctrl+Enter`,`Sends a chat message`]];function ES({domain:e,onClose:t}){let[n,r]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=e=>e.key===`Escape`&&!e.defaultPrevented&&!document.querySelector(`.modal`)&&t();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let i=n.trim().toLowerCase(),a=[...wS(e),...TS.map(([e,t])=>({group:`Keys`,term:e,help:t}))].filter(e=>!i||`${e.term} ${e.help}`.toLowerCase().includes(i)),o=[...new Set(a.map(e=>e.group))];return(0,I.jsxs)(`aside`,{className:`help`,role:`dialog`,"aria-label":`Help`,children:[(0,I.jsxs)(`div`,{className:`help-head`,children:[(0,I.jsx)(`h2`,{children:`Help`}),(0,I.jsx)(`button`,{className:`icon-btn`,"aria-label":`Close help`,onClick:t,children:`×`})]}),(0,I.jsx)(`div`,{className:`help-search`,children:(0,I.jsx)(`input`,{className:`input`,type:`search`,"aria-label":`Search the help`,value:n,onChange:e=>r(e.target.value),placeholder:`search a word: handoff, gate, unplayed…`,autoFocus:!0})}),(0,I.jsxs)(`div`,{className:`help-body`,children:[!a.length&&(0,I.jsxs)(`p`,{className:`dim`,children:[`Nothing found for “`,n,`”.`]}),o.map(e=>{let t=a.filter(t=>t.group===e);return(0,I.jsxs)(`section`,{"aria-label":e,children:[(0,I.jsxs)(`h3`,{children:[e,` · `,t.length]}),(0,I.jsx)(`dl`,{children:t.map((e,t)=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`dt`,{children:e.term}),(0,I.jsx)(`dd`,{children:e.help})]},`${e.term}-${t}`))})]},e)})]})]})}var DS=50,OS=Date.now();function kS({ctx:e,id:t}){let[n,r]=(0,v.useState)(``);(0,v.useEffect)(()=>F(e.project.name,t,()=>r(``),e=>r(t=>(t+e).slice(-32768))),[e.project.name,t]);let i=Ny(n).filter(e=>e.kind!==`start`).slice(-6);return(0,I.jsxs)(`div`,{className:`runs-log`,"aria-live":`polite`,"aria-label":`Live log`,children:[!i.length&&(0,I.jsx)(`span`,{className:`dim`,children:`no output yet`}),i.map((e,t)=>(0,I.jsxs)(`div`,{className:`log-${e.kind}`,children:[(0,I.jsx)(`span`,{className:`dim`,children:e.time}),(0,I.jsx)(`span`,{title:e.text,children:e.text})]},t))]})}var AS=(e,t)=>e&&(e.model||e.effort)?`on ${e.model??`its own model`} · ${e.effort??`its own effort`} · ${t}`:`on its own model`;function jS({ctx:e,run:t,list:n}){let r=`run:${t.id??`old-${t.ended}`}`,i=t.started&&t.started.slice(0,10)===t.ended.slice(0,10)?oi(t.ended):Zy(t.ended),a=`${t.items.length} item${t.items.length>1?`s`:``}`,o=Date.parse(t.ended)>OS,s=[...new Set(t.items.map(e=>e.result))],c=s.some(e=>tb[e]!==`ok`),l=t=>e.board.items.find(e=>e.id===t)?.title||t;return(0,I.jsx)(Ma,{cat:t.started?`${Zy(t.started)} → ${i}`:`ended ${i}`,origin:t.mode,age:t.started?Qy(Date.parse(t.ended)-Date.parse(t.started)):``,title:t.items.map(e=>l(e.id)).join(` · `),sub:`${eb(t.cost_usd)} · ${a}${o?` · this session`:``}`,mark:s.join(` · `),markTone:c?`warn`:`ok`,accent:o,on:e.detailKey===r,tip:`Open: its items, their stats and logs`,onOpen:()=>e.openDetail({key:r,render:e=>({cat:`Run · ${t.mode}`,origin:a,age:eb(t.cost_usd),body:(0,I.jsx)(ib,{ctx:e,run:t,list:n,onPart:(t,n)=>e.openItem(t,n.kind,n)})})})})}var MS=e=>`its own: ${e.model??`default`} · ${e.effort??`default`}`;function NS({ctx:e}){let{board:t}=e,n=t.runs,r=e=>t.items.find(t=>t.id===e),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(DS),[c,l]=(0,v.useState)(``),u=qi(e),d=Pi(t),f=(n?.reports??[]).map(e=>e.id).join(` `),p=(0,v.useRef)(0);(0,v.useEffect)(()=>{if(!d)return;let t=++p.current;k.pastRuns(e.project.name,o+1).then(e=>{t===p.current&&(a(e),l(``))},e=>t===p.current&&l(e.message))},[e.project.name,o,d,f,n?.active.length]);let m=(n?.active??[]).flatMap(e=>{let t=e.ids.map(r).find(e=>e?.running)??r(e.ids[0]);return t?[{run:e,item:t}]:[]}),h=new Set(m.map(e=>e.item.id)),g=t.items.filter(e=>e.running&&!h.has(e.id)),_=n?.queued??[],y=(i??[]).slice(0,o);return(0,I.jsxs)(`section`,{className:`page runs`,"aria-label":`Runs`,children:[(0,I.jsxs)(`div`,{className:`runs-head`,children:[(0,I.jsx)(`h1`,{children:`Runs`}),(0,I.jsxs)(`span`,{className:`mono dim`,title:`Where runs work`,children:[`runs: `,t.run_mode]}),(0,I.jsxs)(`div`,{className:`run-next runs-start`,title:`The run gate picks them; the dialog asks for a model and effort for this run${d?``:` (not with this harness)`}`,children:[(0,I.jsx)(`button`,{disabled:u.busy,onClick:()=>void u.go(),children:u.busy?`asking the run gate…`:`Run next`}),(0,I.jsx)(`input`,{type:`number`,min:1,max:20,value:u.count,onChange:e=>u.setCount(Math.max(1,Math.min(20,Number(e.target.value)||1))),"aria-label":`How many to run, 1 to 20`})]})]}),(0,I.jsxs)(`section`,{"aria-label":`Active runs`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Active`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),!m.length&&!g.length&&(0,I.jsx)(`p`,{className:`empty-box`,children:n?.paused?`Nothing runs: the queue is paused.`:`Nothing runs now.`}),m.map(({run:t,item:n})=>{let r=di(n),i=!!(t.model||t.effort);return(0,I.jsxs)(`article`,{className:`runs-active`,children:[(0,I.jsxs)(`div`,{className:`runs-active-top`,children:[(0,I.jsxs)(`div`,{className:`runs-active-name`,children:[(0,I.jsx)(`span`,{className:`mono strong`,children:n.id}),n.title&&(0,I.jsx)(`span`,{className:`dim small`,children:n.title})]}),!r&&n.active_at&&(0,I.jsx)(ei,{at:n.active_at})]}),(0,I.jsxs)(`div`,{className:`runs-facts mono`,children:[(0,I.jsx)(`span`,{children:t.mode}),(0,I.jsxs)(`span`,{children:[`started `,oi(t.started)]}),(0,I.jsxs)(`span`,{children:[Math.max(1,Math.round((Date.now()-Date.parse(t.started))/6e4)),` min`]}),(0,I.jsx)(`span`,{className:i?``:`dim`,title:`The model and effort of this run; ${MS(n)}`,children:AS(t,`this run's pick`)}),i&&(0,I.jsx)(`span`,{className:`dim`,children:MS(n)})]}),t.ids.length>1&&(0,I.jsxs)(`span`,{className:`mono dim small`,children:[`item `,t.ids.indexOf(n.id)+1,` of `,t.ids.length,`: `,t.ids.join(`, `)]}),r&&(0,I.jsxs)(`span`,{className:`runs-limit mono`,children:[`◷ limit: resumes `,oi(r),` · waits for the reset by itself`]}),(0,I.jsx)(kS,{ctx:e,id:n.id}),(0,I.jsxs)(`div`,{className:`runs-acts`,children:[(0,I.jsx)(`button`,{className:`btn`,onClick:()=>e.openItem(n.id,`log`),children:`Whole log`}),(0,I.jsx)(`button`,{className:`btn-danger`,title:r?`Ends the wait for the reset: paused: limit`:`Stops the agent session; the item stays ready and its work is kept`,onClick:()=>void Yi(e,n),children:`Stop`})]})]},t.started+n.id)}),g.map(t=>(0,I.jsxs)(`button`,{className:`runs-other`,onClick:()=>e.openItem(t.id),children:[(0,I.jsx)(`span`,{className:`mono strong`,children:t.id}),(0,I.jsxs)(`span`,{className:`running-text small`,children:[`◐ `,ii(t)]})]},t.id))]}),(0,I.jsxs)(`section`,{"aria-label":`Queue`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Queue · `,_.length,n?.paused?` · paused`:``,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),n?.paused&&(0,I.jsx)(`button`,{className:`btn runs-resume`,onClick:()=>void e.resumeQueue(),children:`queue paused — resume`}),!_.length&&(0,I.jsx)(`span`,{className:`dim`,children:`empty`}),_.map((t,i)=>{let a=r(t)?.waits_for??[],o=n?.queued_with?.[t];return(0,I.jsxs)(`div`,{className:`runs-q`,role:`button`,tabIndex:0,title:`Open ${t}`,onClick:()=>e.openItem(t),onKeyDown:n=>{n.target!==n.currentTarget||n.key!==`Enter`&&n.key!==` `||(n.preventDefault(),e.openItem(t))},children:[(0,I.jsxs)(`div`,{className:`runs-q-line`,children:[(0,I.jsxs)(`span`,{className:`mono dim`,children:[`#`,i+1]}),(0,I.jsx)(`span`,{className:`mono strong`,children:t}),(0,I.jsx)(`span`,{className:`mono small ${o?``:`dim`}`,title:`What it will run on`,children:AS(o,`for this run`)}),a.length>0&&(0,I.jsxs)(`span`,{className:`dim small`,children:[`⧗ waits for `,a.join(`, `)]})]}),(0,I.jsx)(Na,{label:`Remove from queue`,tip:`Remove from queue; it asks nothing`,onClick:n=>{n.stopPropagation(),e.unqueue(t)}})]},t)})]}),(0,I.jsxs)(`section`,{"aria-label":`Past runs`,children:[(0,I.jsxs)(`h2`,{className:`section-h`,children:[`Past runs`,i?` · ${y.length}${i.length>o?`+`:``}`:``,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),!d&&(0,I.jsxs)(`div`,{role:`note`,className:`empty-box chat-old`,children:[(0,I.jsx)(`span`,{children:`Past runs need gcf-harness-aif-ext ≥ 0.13: this harness keeps no run record the board can read. Active runs show above.`}),(0,I.jsx)(`code`,{children:`update gcf-harness-aif-ext`})]}),d&&c&&(0,I.jsxs)(`p`,{role:`alert`,className:`error-text`,children:[`✘ `,c]}),d&&!i&&!c&&(0,I.jsx)(`p`,{className:`dim`,children:`reading the run log…`}),d&&i&&!i.length&&(0,I.jsx)(`p`,{className:`dim`,children:`No run in the run log yet.`}),y.length>0&&(0,I.jsx)(`div`,{className:`wide-only`,children:(0,I.jsx)(Pa,{children:y.map((t,n)=>(0,I.jsx)(jS,{ctx:e,run:t,list:i??[]},t.id??`old-${t.ended}-${n}`))})}),(0,I.jsx)(`div`,{className:`phone-only runs-rows`,children:y.map((t,n)=>(0,I.jsx)(ib,{ctx:e,run:t,list:i??[],onPart:(t,n)=>e.openItem(t,n.kind,n)},t.id??`old-${t.ended}-${n}`))}),i&&i.length>0&&(0,I.jsxs)(`div`,{className:`runs-more`,children:[(0,I.jsx)(`span`,{className:`dim small`,children:i.length>o?`${o} shown · ${DS} at a time, newest first`:`all ${i.length} shown · newest first`}),i.length>o&&(0,I.jsxs)(`button`,{className:`btn-line`,onClick:()=>s(o+DS),children:[`Show `,DS,` more`]})]})]})]})}function PS(e,t){let n=t.filter(t=>!e.has(t));for(let t of n)e.set(t,{});return n}function FS(e,t){if(!t.size)return e;let n=e.domain.runs_from;return{...e,items:e.items.map(e=>t.has(e.id)&&!e.running&&e.status===n?{...e,running:!0,running_kind:`board`,starting:!0}:e)}}function IS(e,t,n){let r=new Set(t.items.filter(e=>e.running).map(e=>e.id)),i=new Map;for(let[a,o]of e){let e=t.items.find(e=>e.id===a);if(e&&!e.running&&e.status===t.domain.runs_from){if(o.after!==void 0&&n>o.after){let e=t.runs?.active.find(e=>e.ids.includes(a));if(!e||e.ids.some(e=>r.has(e)))continue}i.set(a,o)}}return i}function LS(e){let t=e.title??e.tool;return`${t.length>80?`${t.slice(0,79)}…`:t} (${e.group?`deny group ${e.group}`:`a deny rule`})`}var RS=(e,t)=>e?t.filter(t=>!e.has(t)):[];function zS(e,t,n){let r=(0,v.useRef)(null),i=(0,v.useRef)({entries:e,tell:n});i.current={entries:e,tell:n};let a=e.map(e=>e.key).join(` `);(0,v.useEffect)(()=>{if(!t)return;let{entries:e,tell:n}=i.current,a=new Set(RS(r.current,e.map(e=>e.key)));for(let t of e)a.has(t.key)&&n(t);r.current=new Set([...r.current??[],...e.map(e=>e.key)])},[a,t])}var BS=[`command`,`board`,`chat`,`inbox`,`design`,`runs`,`playtest`,`ended`,`agent`,`metrics`,`more`],VS=`gcf-board-tools`,HS={command:`Command`,board:`Board`,chat:`Chat`,inbox:`Inbox`,design:`Design`,runs:`Runs`,playtest:`Playtest`,ended:`Ended`,agent:`Agent`,metrics:`Metrics`,more:`More`},US={design:`The game design: pillars, vision, units`,runs:`What runs, what waits, what ran`,playtest:`What waits for a playtest, by subsystem`,ended:`Accepted items and the graveyard`,agent:`What runs may not do`,metrics:`What the runs did and cost`};function WS(e){let t=e.domain.sections,n={inbox:t.inbox||t.questions,design:t.design&&e.domain.starts,playtest:t.playtest,ended:t.history||t.graveyard,metrics:e.domain.harness,runs:e.domain.harness};return BS.filter(e=>e!==`more`&&(!(e in n)||n[e]))}function GS({project:e,projects:t,screen:n,arg:r,go:i,notify:a}){let[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(void 0),[m,h]=(0,v.useState)(void 0),[g,_]=(0,v.useState)(0),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(!1),[A,ee]=(0,v.useState)(!1),[j,M]=(0,v.useState)(()=>{try{return localStorage.getItem(VS)!==`shut`}catch{return!0}}),[te,N]=(0,v.useState)(!1),P=(0,v.useRef)(new Set),F=(0,v.useRef)(new Map),re=(0,v.useRef)(se()),L=(0,v.useCallback)(()=>{let t=re.current.send();return k.board(e.name).then(e=>{if(!re.current.lands(t))return;let n=To(e,P.current);F.current=IS(F.current,n,t),s(FS(n,F.current)),l(``)},e=>re.current.lands(t)&&l(e.message))},[e.name]),z=!!o?.domain.chat,ie=(0,v.useRef)(0),B=(0,v.useCallback)(()=>{let t=++ie.current;k.talks(e.name).then(e=>{t===ie.current&&(S(e),w(!0))},()=>t===ie.current&&S([]))},[e.name]);(0,v.useEffect)(()=>(L(),ne(t=>{(t.type===`board`&&t.project===e.name||t.type===`quota`)&&L(),t.type===`talks`&&t.project===e.name&&B()},()=>{L(),B()})),[L,B,e.name]),(0,v.useEffect)(()=>{z&&B()},[z,B]);let ae=(0,v.useRef)(()=>{});(0,v.useEffect)(()=>{let e=e=>ae.current(e);return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let oe=async(t,n,r=!1)=>{try{let i=await k.move(e.name,t),o=r||i.held===!0;(i.ok||!o)&&a(i.ok?i.out||`done`:i.err||i.out,i.ok?`ok`:`error`),!i.ok&&i.refusal&&!r&&!n&&t.proposal===void 0&&E_(i.refusal,i.err||i.out);let s=L();return n&&await s,{ok:i.ok,out:i.out,err:i.ok?``:i.err||i.out,refused:!i.ok,...i.refusal&&{refusal:i.refusal}}}catch(e){return r||a(e.message,`error`),{ok:!1,out:``,err:e.message,refused:!1}}},ce=e=>oe(e,!0),V=async e=>(await oe(e,!1)).ok,H=e=>oe(e,!1,!0),U=(e,t)=>{P.current.add(t),s(e=>e&&To(e,P.current)),V({cmd:e,id:t}).finally(()=>{P.current.delete(t),L()})},le=async(t,n=!1,r)=>{let i=PS(F.current,t);s(e=>e&&FS(e,F.current));try{let o=await k.run(e.name,t,n,r),s=[r?.model,r?.effort,r?.mode].filter(Boolean).join(`, `),c=o.queued??[];for(let e of i)c.includes(e)?F.current.delete(e):F.current.has(e)&&F.current.set(e,{after:re.current.last()});let l=t.filter(e=>!c.includes(e));return a(`${[l.length?`run started: ${l.join(`, `)}`:``,c.length?`queued behind the main run: ${c.join(`, `)}`:``].filter(Boolean).join(` · `)}${s?` · on ${s} for this run`:``}`),L(),!0}catch(e){a(e.message,`error`);for(let e of i)F.current.delete(e);return L(),!1}},ue=async t=>{try{let n=await k.stop(e.name,t);a(n.ok?n.out:n.err||n.out,n.ok?`ok`:`error`),L()}catch(e){a(e.message,`error`)}},de=async t=>{await k.unqueue(e.name,t).catch(e=>a(e.message,`error`)),L()},fe=async()=>{await k.resumeQueue(e.name).catch(e=>a(e.message,`error`)),L()},pe=async t=>{await k.autopilot(e.name,t).catch(e=>a(e.message,`error`)),L()},W=async()=>{await k.askUsage().catch(e=>a(e.message,`error`))},me=(o?.items??[]).flatMap(e=>e.run_end?[{key:`${e.id}@${e.run_end.at}`,text:`${e.id}: ${e.run_end.outcome}`}]:[]),he=!!o;zS(me,he,e=>a(`run ended: ${e.text} — its card is in its chat`));let ge=(o?.items??[]).flatMap(e=>e.denied?[{key:`${e.id}@${e.denied.at}`,text:`${e.id}: ${LS(e.denied)}`,open:()=>{d(e.id),p(`chat`),h(void 0),_(e=>e+1),b(null)}}]:[]),_e=x.flatMap(e=>e.denied?[{key:`${e.id}@${e.denied.at}`,text:`${e.title??`a thread`}: ${LS(e.denied)}`,open:()=>i(`chat`,e.id)}]:[]),ve=e=>a(`agent refused: ${e.text} — its card is in its chat`,`warn`,e.open,`Open its card`);zS(ge,he,ve),zS(_e,C,ve);let ye=o?.runs?.autopilot?.stop,be=ye?.kind===`play`?ye.text:``;if((0,v.useEffect)(()=>{be&&a(be)},[be,a]),!o)return(0,I.jsx)(`main`,{className:`boot`,role:`status`,children:c?(0,I.jsxs)(`span`,{className:`boot-error`,role:`alert`,children:[`✘ `,c]}):`reading gcf board --json…`});let xe=(e={})=>{let t=Tr(o.domain,o.domain.new_item);t&&E({title:`New item`,move:t,values:{title:e.title??``,from:e.from,...e.note?{note:e.note}:{}}})},Se=o.domain.fields.find(e=>e.key===`depends`)?.edit,Ce=T?.id&&T.move.cmd===Se?o.items.find(e=>e.id===T.id):void 0,we={project:e,board:o,notify:a,move:V,moveOut:ce,moveIn:H,erase:U,run:le,stop:ue,unqueue:de,resumeQueue:fe,setAutopilot:pe,askUsage:W,boardTools:j,toggleBoardTools:()=>{try{localStorage.setItem(VS,j?`shut`:`open`)}catch{}M(!j)},openItem:(e,t,n)=>{d(e),p(t),h(n),_(e=>e+1),b(null)},openDetail:e=>{d(null),b(e)},closeDetail:()=>b(null),detailKey:y?.key??null,itemOpen:u,openMove:E,newItem:xe,go:i,openSettings:()=>{O(!1),N(!1),ee(!0)},talks:x,reloadTalks:B},Te=o.items.find(e=>e.id===u),Ee=!Te&&u?[...o.history??[],...o.graveyard??[]].some(e=>e.id===u):!1;ae.current=e=>{if(e.key===`Escape`&&(u||y)&&!e.defaultPrevented&&!document.querySelector(`.modal`)){let t=e.target?.closest?.(`input, textarea, select, [contenteditable]`);t?t.blur():D||(d(null),b(null));return}if(Oa(e)||document.querySelector(`.modal`))return;if(za(e,WS(o),i,()=>{O(!1),N(!1),ee(!0)})){e.preventDefault(),e.stopImmediatePropagation();return}let t=Tr(o.domain,o.domain.sections.inbox?.add);if(e.key===`?`)O(!0);else if(e.key===`/`){let e=document.querySelector(D?`.help input`:`.screen [data-search], .screen input[type="search"]`);if(!e)return;!D&&!j&&e.matches(`[data-search]`)?(we.toggleBoardTools(),requestAnimationFrame(()=>{e.focus(),e.select()})):(e.focus(),e.select())}else if(e.key===`n`&&o.domain.new_item)xe();else if(e.key===`i`&&t)E({title:`Add to the inbox`,move:t,values:{}});else return;e.preventDefault()};let De=WS(o),Oe=De.includes(n)||n===`more`?n:`command`,ke=ea(o,x).length,Ae=Zi(o),je=De.map(e=>({screen:e,label:HS[e],count:e===`command`?ke:e===`inbox`?Ae:e===`chat`?x.filter(e=>e.waiting).length:0,needs:e===`command`||e===`chat`||e===`inbox`}));return(0,I.jsxs)(`div`,{className:`project`,children:[(0,I.jsx)(Va,{entries:je,screen:Oe,go:i}),(0,I.jsxs)(`div`,{className:`project-main`,children:[(0,I.jsx)(fo,{ctx:we,screen:Oe,projects:t,waiting:ke,onWaiting:()=>i(`command`),onHelp:()=>O(!D),onSettings:()=>{O(!1),N(!1),ee(!A)}}),(0,I.jsxs)(`div`,{className:`workspace`,children:[(0,I.jsxs)(`main`,{className:`screen screen-${Oe}`,children:[Oe!==`command`&&(o.runs?.reports??[]).length>0&&(0,I.jsx)(`div`,{className:`report-strip`,"aria-label":`Run reports`,children:[...o.runs?.reports??[]].reverse().map(e=>(0,I.jsx)(Px,{ctx:we,r:e},e.id))}),c&&(0,I.jsxs)(`div`,{role:`alert`,className:`read-fail`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`✘`}),(0,I.jsxs)(`span`,{children:[c,` · The board shows the last good read.`]})]}),Oe===`command`&&(0,I.jsx)(zx,{ctx:we}),Oe===`board`&&(0,I.jsx)(ja,{ctx:we}),Oe===`chat`&&(0,I.jsx)(qy,{ctx:we,thread:r}),Oe===`inbox`&&(0,I.jsx)(ps,{ctx:we}),Oe===`design`&&(0,I.jsx)(xS,{ctx:we,arg:r}),Oe===`runs`&&(0,I.jsx)(NS,{ctx:we}),Oe===`playtest`&&(0,I.jsx)(sx,{ctx:we}),Oe===`ended`&&(0,I.jsx)(Ub,{ctx:we}),Oe===`metrics`&&(0,I.jsx)(Nx,{ctx:we}),Oe===`agent`&&(0,I.jsx)(ux,{ctx:we}),Oe===`more`&&(0,I.jsxs)(`div`,{className:`page more`,children:[je.filter(e=>e.screen in US).map(e=>(0,I.jsxs)(`button`,{className:`more-row`,onClick:()=>i(e.screen),children:[(0,I.jsx)(`span`,{className:`more-label`,children:e.label}),(0,I.jsx)(`span`,{className:`more-sub`,children:US[e.screen]})]},e.screen)),(0,I.jsxs)(`button`,{className:`more-row`,onClick:()=>{N(!1),ee(!0)},children:[(0,I.jsx)(`span`,{className:`more-label`,children:`Settings`}),(0,I.jsx)(`span`,{className:`more-sub`,children:`gcf/config.yml, one save each; this browser's theme`})]}),(0,I.jsxs)(`button`,{className:`more-row`,onClick:()=>O(!0),children:[(0,I.jsx)(`span`,{className:`more-label`,children:`Help`}),(0,I.jsx)(`span`,{className:`more-sub`,children:`Every word the board uses, the moves, the fields`})]}),(0,I.jsxs)(`h2`,{className:`section-h more-head`,children:[`Projects`,(0,I.jsx)(`span`,{className:`rule`,"aria-hidden":`true`})]}),t.list.map(n=>(0,I.jsxs)(`div`,{className:`more-proj`,children:[(0,I.jsxs)(`button`,{className:`more-row`,"aria-current":n.name===e.name?`true`:void 0,onClick:()=>t.choose(n.name),children:[(0,I.jsxs)(`span`,{className:`more-label`,children:[n.name===e.name?`● `:``,n.name]}),(0,I.jsx)(`span`,{className:`more-sub mono`,children:n.path})]}),(0,I.jsx)(Na,{label:`Remove ${n.name} from the board`,tip:`Take it off the board; its files stay`,onClick:()=>t.remove(n)})]},n.name)),(0,I.jsx)(`button`,{className:`more-row`,onClick:t.add,children:(0,I.jsx)(`span`,{className:`more-label`,children:`+ Add a project…`})})]})]}),Te&&(0,I.jsx)(Hb,{ctx:we,item:Te,tab:f,part:m,onClose:()=>d(null)},`${Te.id} ${f??``} ${g}`),y&&!Te&&!Ee&&(0,I.jsx)(SS,{ctx:we,spec:y,onClose:()=>b(null)},y.key),Ee&&u&&(0,I.jsx)(Bb,{ctx:we,id:u,part:m,onClose:()=>d(null)},`${u} ${g}`)]}),(0,I.jsx)(po,{ctx:we})]}),(0,I.jsx)(Ha,{entries:je,screen:Oe,go:i}),T&&Ce?(0,I.jsx)(qb,{ctx:we,id:Ce.id,current:Ce.depends,open:T,onClose:()=>E(null)},`${T.move.cmd} ${Ce.id}`):T&&(0,I.jsx)(ox,{ctx:we,open:T,onClose:()=>E(null)},`${T.move.cmd} ${T.id??``} ${T.title}`),(0,I.jsx)(D_,{ctx:we}),D&&(0,I.jsx)(ES,{domain:o.domain,onClose:()=>O(!1)}),A&&(0,I.jsx)(R,{onClose:()=>ee(!1),dirty:te,children:(0,I.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,className:`settings-dialog`,onClick:e=>e.stopPropagation(),onInput:e=>{e.target.matches(`input:not([type=file]), textarea`)&&N(!0)},children:[(0,I.jsx)(`button`,{className:`icon-btn bordered settings-close`,"aria-label":`Close the settings`,title:`Close · Esc`,autoFocus:!0,onClick:()=>ee(!1),children:`×`}),(0,I.jsx)(bx,{ctx:we})]})}),(0,I.jsx)(Ki,{})]})}function KS(){let[e=``,t=``,n]=location.hash.slice(1).split(`/`).map(e=>{try{return decodeURIComponent(e)}catch{return``}});return{name:e,screen:BS.includes(t)?t:`command`,arg:n||void 0}}function qS({onAdded:e,notify:t,onCancel:n}){let[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``);return(0,I.jsxs)(`form`,{className:`form add-project`,onSubmit:async n=>{n.preventDefault();try{e(await k.addProject(r.trim(),a.trim())),i(``),o(``)}catch(e){t(e.message,`error`)}},children:[(0,I.jsxs)(`label`,{className:`field`,children:[(0,I.jsx)(`span`,{className:`field-label`,children:`Project folder`}),(0,I.jsx)(`input`,{className:`input`,placeholder:`C:\\games\\zombie-puzzle`,value:r,onChange:e=>i(e.target.value),required:!0,autoFocus:!0}),(0,I.jsx)(`span`,{className:`field-help`,children:`A folder with gcf/ in it (ai-factory gcf init).`})]}),(0,I.jsxs)(`label`,{className:`field`,children:[(0,I.jsx)(`span`,{className:`field-label`,children:`Name`}),(0,I.jsx)(`input`,{className:`input`,placeholder:`optional: the folder's name`,value:a,onChange:e=>o(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`dialog-actions`,children:[n&&(0,I.jsx)(`button`,{type:`button`,className:`btn-line`,onClick:n,children:`Cancel`}),(0,I.jsx)(`button`,{type:`submit`,className:`btn-primary`,children:`Add project`})]})]})}function JS({closed:e}){return(0,I.jsx)(`div`,{className:`gone`,role:`alertdialog`,"aria-label":`The board's server is gone`,children:(0,I.jsxs)(`div`,{className:`gone-box`,children:[(0,I.jsx)(`span`,{className:`gone-title`,children:e?`The board was started again`:`The board's server is gone`}),(0,I.jsxs)(`span`,{className:`gone-text`,children:[`This page shows the last read and cannot act. Runs started from it go on by themselves.`,` `,e?`Open the board again from its link: the desktop shortcut, or the URL with ?t= that gcf-board printed.`:`Start gcf-board again; the page reconnects by itself.`]}),!e&&(0,I.jsxs)(`span`,{role:`status`,className:`gone-retry`,children:[(0,I.jsx)(`span`,{className:`dot pulse`,"aria-hidden":`true`}),`trying `,location.host,` again…`]})]})})}function YS(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(KS()),[i,a]=(0,v.useState)([]),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=(0,v.useRef)(void 0),d=(0,v.useRef)(null),f=_x(),p=(0,v.useCallback)((e,t=`ok`,n,r)=>{let i=Date.now()+Math.random();a(a=>[...a,{id:i,text:e,kind:t,open:n,openLabel:r}]),setTimeout(()=>a(e=>e.filter(e=>e.id!==i)),t===`error`||n?12e3:4e3)},[]);(0,v.useEffect)(()=>{k.projects().then(t,e=>p(e.message,`error`));let e=()=>r(KS());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[p]),(0,v.useLayoutEffect)(()=>{if(!d.current)return;let e=yx(d.current,f);e.length&&p(`Theme ${f?.name}: this board has no token ${e.join(`, `)}`,`error`)},[f,p]),(0,v.useEffect)(()=>{f&&k.themes().then(e=>{if(gx()?.id!==f.id)return;let t=e.find(e=>e.id===f.id);t&&`tokens`in t?JSON.stringify(t)!==JSON.stringify(f)&&hx(t):(hx(null),p(`Theme ${f.name} ${t?`cannot be read: ${t.error}`:`is gone`}: back to dark`,`error`))},()=>{})},[]),(0,v.useEffect)(()=>P((e,t)=>{(e||t)&&(clearTimeout(u.current),u.current=void 0),e?l(null):t?l(`closed`):u.current??=setTimeout(()=>l(`retry`),3e3)}),[]);let m=(e,t,n)=>{location.hash=`${encodeURIComponent(e)}/${t}${n?`/${encodeURIComponent(n)}`:``}`},h=e?.find(e=>e.name===n.name)??e?.[0]??null,g=e=>{t(t=>[...t??[],e]),s(!1),m(e.name,`command`)},_={list:e??[],choose:e=>m(e,n.screen),add:()=>s(!0),remove:async e=>{if(await ie(`Take ${e.name} off the board? Its files stay as they are.`,`Remove`,!0))try{await k.removeProject(e.name),t(t=>t?.filter(t=>t.name!==e.name)??null)}catch(e){p(e.message,`error`)}}};return(0,I.jsxs)(`div`,{className:`app`,"data-gcf":`b`,ref:d,children:[!e&&(0,I.jsx)(`div`,{className:`boot`,children:`reading the projects…`}),e&&!e.length&&(0,I.jsxs)(`main`,{className:`welcome`,children:[(0,I.jsx)(`h1`,{children:`GCF board`}),(0,I.jsx)(`p`,{children:`No project yet. Add a folder that has gcf/ (ai-factory gcf init).`}),(0,I.jsx)(qS,{notify:p,onAdded:g})]}),h&&(0,I.jsx)(GS,{project:h,projects:_,screen:n.screen,arg:n.arg,go:(e,t)=>m(h.name,e,t),notify:p},h.name),o&&(0,I.jsx)(R,{onClose:()=>s(!1),dirty:!1,children:(0,I.jsxs)(`div`,{className:`dialog`,role:`dialog`,"aria-modal":!0,"aria-label":`Add a project`,onClick:e=>e.stopPropagation(),children:[(0,I.jsx)(`h2`,{children:`Add a project`}),(0,I.jsx)(qS,{notify:p,onAdded:g,onCancel:()=>s(!1)})]})}),c&&(0,I.jsx)(JS,{closed:c===`closed`}),(0,I.jsx)(oe,{}),(0,I.jsx)(`div`,{className:`toasts`,role:`status`,children:i.map(e=>(0,I.jsxs)(`div`,{className:`toast ${e.kind}`,children:[e.open?(0,I.jsxs)(`button`,{className:`toast-text toast-open`,onClick:()=>{e.open?.(),a(t=>t.filter(t=>t.id!==e.id))},children:[(0,I.jsx)(`span`,{children:e.text}),(0,I.jsxs)(`span`,{className:`toast-link`,children:[e.openLabel??`Open`,` ›`]})]}):(0,I.jsx)(`span`,{className:`toast-text`,children:e.text}),(0,I.jsx)(`button`,{className:`toast-close`,"aria-label":`Close`,onClick:()=>a(t=>t.filter(t=>t.id!==e.id)),children:`×`})]},e.id))})]})}(0,y.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(v.StrictMode,{children:(0,I.jsx)(YS,{})}));