syntaur 0.52.1 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/dashboard/dist/assets/{_basePickBy-C43WHjwB.js → _basePickBy-Q1PSZECa.js} +1 -1
- package/dashboard/dist/assets/{_baseUniq-CYbaTZn6.js → _baseUniq-B6uu69P0.js} +1 -1
- package/dashboard/dist/assets/{arc-LYux4b4A.js → arc-D15ezD9f.js} +1 -1
- package/dashboard/dist/assets/{architectureDiagram-2XIMDMQ5-2XZ4AO-Q.js → architectureDiagram-2XIMDMQ5-C4z3OUp7.js} +1 -1
- package/dashboard/dist/assets/{blockDiagram-WCTKOSBZ-RVzofvxs.js → blockDiagram-WCTKOSBZ-G0PvoF7N.js} +1 -1
- package/dashboard/dist/assets/{c4Diagram-IC4MRINW-BWuzxq1W.js → c4Diagram-IC4MRINW-DjSpuJsk.js} +1 -1
- package/dashboard/dist/assets/channel-B5BNb_on.js +1 -0
- package/dashboard/dist/assets/{chunk-4BX2VUAB-DAZTQBFD.js → chunk-4BX2VUAB-De4HdhLn.js} +1 -1
- package/dashboard/dist/assets/{chunk-55IACEB6-aErv59-Z.js → chunk-55IACEB6-BMkP7lSs.js} +1 -1
- package/dashboard/dist/assets/{chunk-FMBD7UC4-Ac1njHPs.js → chunk-FMBD7UC4-BUb4B6J_.js} +1 -1
- package/dashboard/dist/assets/{chunk-JSJVCQXG-CXZ9h-Qh.js → chunk-JSJVCQXG-Bdfjf5kD.js} +1 -1
- package/dashboard/dist/assets/{chunk-KX2RTZJC-BMug6AM8.js → chunk-KX2RTZJC-Dce-ALzt.js} +1 -1
- package/dashboard/dist/assets/{chunk-NQ4KR5QH-CE2gTkgQ.js → chunk-NQ4KR5QH-VC0KVDkQ.js} +1 -1
- package/dashboard/dist/assets/{chunk-QZHKN3VN-BP77B6aE.js → chunk-QZHKN3VN-kXnhYlzI.js} +1 -1
- package/dashboard/dist/assets/{chunk-WL4C6EOR-BFCjxTBt.js → chunk-WL4C6EOR-Beh261rr.js} +1 -1
- package/dashboard/dist/assets/classDiagram-VBA2DB6C-RAXR887a.js +1 -0
- package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-RAXR887a.js +1 -0
- package/dashboard/dist/assets/clone-CHQli9jV.js +1 -0
- package/dashboard/dist/assets/{cose-bilkent-S5V4N54A-BaBbktHz.js → cose-bilkent-S5V4N54A-CuPhgVEA.js} +1 -1
- package/dashboard/dist/assets/{dagre-KLK3FWXG-BKHq-7nV.js → dagre-KLK3FWXG-CDkxfqOw.js} +1 -1
- package/dashboard/dist/assets/{diagram-E7M64L7V-D_7rF1de.js → diagram-E7M64L7V-iTkQbEMa.js} +1 -1
- package/dashboard/dist/assets/{diagram-IFDJBPK2-0DARNDMt.js → diagram-IFDJBPK2-BtpYU53Z.js} +1 -1
- package/dashboard/dist/assets/{diagram-P4PSJMXO-yxW3Kf_2.js → diagram-P4PSJMXO-uGWbmH4Y.js} +1 -1
- package/dashboard/dist/assets/{erDiagram-INFDFZHY-Cz0TQwSt.js → erDiagram-INFDFZHY-DenLyLIm.js} +1 -1
- package/dashboard/dist/assets/{flowDiagram-PKNHOUZH-CSqvyQQ-.js → flowDiagram-PKNHOUZH-66j4-vCO.js} +1 -1
- package/dashboard/dist/assets/{ganttDiagram-A5KZAMGK-CTnKqO8b.js → ganttDiagram-A5KZAMGK-SVF_TA4w.js} +1 -1
- package/dashboard/dist/assets/{gitGraphDiagram-K3NZZRJ6-XXd-teNb.js → gitGraphDiagram-K3NZZRJ6-SVxQTBZM.js} +1 -1
- package/dashboard/dist/assets/{graph-B4CU7qcg.js → graph-CPhRysBU.js} +1 -1
- package/dashboard/dist/assets/{index-DVlJo6ML.js → index-Bq02M5BX.js} +2 -2
- package/dashboard/dist/assets/{infoDiagram-LFFYTUFH-Byg8ONC-.js → infoDiagram-LFFYTUFH-DC3jz7Mz.js} +1 -1
- package/dashboard/dist/assets/{ishikawaDiagram-PHBUUO56-CxIBgWzX.js → ishikawaDiagram-PHBUUO56-Z2onT5Ea.js} +1 -1
- package/dashboard/dist/assets/{journeyDiagram-4ABVD52K-B5bkVWwU.js → journeyDiagram-4ABVD52K-BX8qpaJE.js} +1 -1
- package/dashboard/dist/assets/{kanban-definition-K7BYSVSG-Dk7in6rm.js → kanban-definition-K7BYSVSG-fR2BiIKL.js} +1 -1
- package/dashboard/dist/assets/{layout-CHTqaQdN.js → layout-lnW6QNdh.js} +1 -1
- package/dashboard/dist/assets/{linear-CYIPmrB7.js → linear-douFRX7V.js} +1 -1
- package/dashboard/dist/assets/{mermaid.core-DVqEZA64.js → mermaid.core-D9FaILqM.js} +4 -4
- package/dashboard/dist/assets/{mindmap-definition-YRQLILUH-DuButrJ_.js → mindmap-definition-YRQLILUH-DEHosmEM.js} +1 -1
- package/dashboard/dist/assets/{pieDiagram-SKSYHLDU-2_OFBvEh.js → pieDiagram-SKSYHLDU-DW9Kqq4N.js} +1 -1
- package/dashboard/dist/assets/{quadrantDiagram-337W2JSQ-SVSc32Dh.js → quadrantDiagram-337W2JSQ-B5FqdsN-.js} +1 -1
- package/dashboard/dist/assets/{requirementDiagram-Z7DCOOCP-BMGSuWfa.js → requirementDiagram-Z7DCOOCP-qFH8L_CI.js} +1 -1
- package/dashboard/dist/assets/{sankeyDiagram-WA2Y5GQK-D-avy7EY.js → sankeyDiagram-WA2Y5GQK-CFXjjTmg.js} +1 -1
- package/dashboard/dist/assets/{sequenceDiagram-2WXFIKYE-Bs99nMFa.js → sequenceDiagram-2WXFIKYE-BFa1eUWT.js} +1 -1
- package/dashboard/dist/assets/{stateDiagram-RAJIS63D-JhL8F7oI.js → stateDiagram-RAJIS63D-D3Uwuidx.js} +1 -1
- package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-CVx5T-km.js +1 -0
- package/dashboard/dist/assets/{timeline-definition-YZTLITO2-Bbh2iS1g.js → timeline-definition-YZTLITO2-Qe6hh_yt.js} +1 -1
- package/dashboard/dist/assets/{treemap-KZPCXAKY-CaCEb8hx.js → treemap-KZPCXAKY-CvDfsGUo.js} +1 -1
- package/dashboard/dist/assets/{vennDiagram-LZ73GAT5-CT5EUXLy.js → vennDiagram-LZ73GAT5-aNTXgH77.js} +1 -1
- package/dashboard/dist/assets/{xychartDiagram-JWTSCODW-CJdsKO1g.js → xychartDiagram-JWTSCODW-0dsre7bb.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/package.json +1 -1
- package/platforms/claude-code/.claude-plugin/plugin.json +1 -1
- package/platforms/codex/.codex-plugin/plugin.json +1 -1
- package/platforms/hermes/plugins/syntaur/__pycache__/__init__.cpython-312.pyc +0 -0
- package/platforms/hermes/plugins/syntaur/__pycache__/boundary.cpython-312.pyc +0 -0
- package/dashboard/dist/assets/channel-BKNr2oYy.js +0 -1
- package/dashboard/dist/assets/classDiagram-VBA2DB6C-rbtd_tGD.js +0 -1
- package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-rbtd_tGD.js +0 -1
- package/dashboard/dist/assets/clone-CAR6bvYc.js +0 -1
- package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-aEecSSls.js +0 -1
|
@@ -552,7 +552,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
|
|
|
552
552
|
While dragging, use the arrow keys to move the item.
|
|
553
553
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
554
554
|
`},ML={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 FL(e){let{announcements:t=ML,container:n,hiddenTextDescribedById:s,screenReaderInstructions:o=_L}=e;const{announce:i,announcement:c}=LL(),u=Ic("DndLiveRegion"),[d,m]=p.useState(!1);if(p.useEffect(()=>{m(!0)},[]),OL(p.useMemo(()=>({onDragStart(g){let{active:y}=g;i(t.onDragStart({active:y}))},onDragMove(g){let{active:y,over:b}=g;t.onDragMove&&i(t.onDragMove({active:y,over:b}))},onDragOver(g){let{active:y,over:b}=g;i(t.onDragOver({active:y,over:b}))},onDragEnd(g){let{active:y,over:b}=g;i(t.onDragEnd({active:y,over:b}))},onDragCancel(g){let{active:y,over:b}=g;i(t.onDragCancel({active:y,over:b}))}}),[i,t])),!d)return null;const h=Dt.createElement(Dt.Fragment,null,Dt.createElement(DL,{id:s,value:o.draggable}),Dt.createElement($L,{id:u,announcement:c}));return n?Fs.createPortal(h,n):h}var Nn;(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"})(Nn||(Nn={}));function Qd(){}function ko(e,t){return p.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function If(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p.useMemo(()=>[...t].filter(s=>s!=null),[...t])}const ss=Object.freeze({x:0,y:0});function E1(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function zL(e,t){const n=Yd(e);if(!n)return"0 0";const s={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return s.x+"% "+s.y+"%"}function T1(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return n-s}function BL(e,t){let{data:{value:n}}=e,{data:{value:s}}=t;return s-n}function qw(e){let{left:t,top:n,height:s,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+s},{x:t+o,y:n+s}]}function R1(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Gw(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const _f=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const o=Gw(t,t.left,t.top),i=[];for(const c of s){const{id:u}=c,d=n.get(u);if(d){const m=E1(Gw(d),o);i.push({id:u,data:{droppableContainer:c,value:m}})}}return i.sort(T1)},UL=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const o=qw(t),i=[];for(const c of s){const{id:u}=c,d=n.get(u);if(d){const m=qw(d),h=o.reduce((y,b,C)=>y+E1(m[C],b),0),g=Number((h/4).toFixed(4));i.push({id:u,data:{droppableContainer:c,value:g}})}}return i.sort(T1)};function VL(e,t){const n=Math.max(t.top,e.top),s=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),c=o-s,u=i-n;if(s<o&&n<i){const d=t.width*t.height,m=e.width*e.height,h=c*u,g=h/(d+m-h);return Number(g.toFixed(4))}return 0}const HL=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:s}=e;const o=[];for(const i of s){const{id:c}=i,u=n.get(c);if(u){const d=VL(u,t);d>0&&o.push({id:c,data:{droppableContainer:i,value:d}})}}return o.sort(BL)};function WL(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function A1(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ss}function KL(e){return function(n){for(var s=arguments.length,o=new Array(s>1?s-1:0),i=1;i<s;i++)o[i-1]=arguments[i];return o.reduce((c,u)=>({...c,top:c.top+e*u.y,bottom:c.bottom+e*u.y,left:c.left+e*u.x,right:c.right+e*u.x}),{...n})}}const qL=KL(1);function P1(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function GL(e,t,n){const s=P1(t);if(!s)return e;const{scaleX:o,scaleY:i,x:c,y:u}=s,d=e.left-c-(1-o)*parseFloat(n),m=e.top-u-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),h=o?e.width/o:e.width,g=i?e.height/i:e.height;return{width:h,height:g,top:m,right:d+h,bottom:m+g,left:d}}const YL={ignoreTransform:!1};function Hi(e,t){t===void 0&&(t=YL);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:m,transformOrigin:h}=er(e).getComputedStyle(e);m&&(n=GL(n,m,h))}const{top:s,left:o,width:i,height:c,bottom:u,right:d}=n;return{top:s,left:o,width:i,height:c,bottom:u,right:d}}function Yw(e){return Hi(e,{ignoreTransform:!0})}function QL(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function JL(e,t){return t===void 0&&(t=er(e).getComputedStyle(e)),t.position==="fixed"}function XL(e,t){t===void 0&&(t=er(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function Mf(e,t){const n=[];function s(o){if(t!=null&&n.length>=t||!o)return n;if(Ix(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Lc(o)||S1(o)||n.includes(o))return n;const i=er(e).getComputedStyle(o);return o!==e&&XL(o,i)&&n.push(o),JL(o,i)?n:s(o.parentNode)}return e?s(e):n}function D1(e){const[t]=Mf(e,1);return t??null}function vh(e){return!$f||!e?null:Ui(e)?e:Ox(e)?Ix(e)||e===Vi(e).scrollingElement?window:Lc(e)?e:null:null}function $1(e){return Ui(e)?e.scrollX:e.scrollLeft}function L1(e){return Ui(e)?e.scrollY:e.scrollTop}function yg(e){return{x:$1(e),y:L1(e)}}var Ln;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Ln||(Ln={}));function O1(e){return!$f||!e?!1:e===document.scrollingElement}function I1(e){const t={x:0,y:0},n=O1(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,c=e.scrollTop>=s.y,u=e.scrollLeft>=s.x;return{isTop:o,isLeft:i,isBottom:c,isRight:u,maxScroll:s,minScroll:t}}const ZL={x:.2,y:.2};function e4(e,t,n,s,o){let{top:i,left:c,right:u,bottom:d}=n;s===void 0&&(s=10),o===void 0&&(o=ZL);const{isTop:m,isBottom:h,isLeft:g,isRight:y}=I1(e),b={x:0,y:0},C={x:0,y:0},j={height:t.height*o.y,width:t.width*o.x};return!m&&i<=t.top+j.height?(b.y=Ln.Backward,C.y=s*Math.abs((t.top+j.height-i)/j.height)):!h&&d>=t.bottom-j.height&&(b.y=Ln.Forward,C.y=s*Math.abs((t.bottom-j.height-d)/j.height)),!y&&u>=t.right-j.width?(b.x=Ln.Forward,C.x=s*Math.abs((t.right-j.width-u)/j.width)):!g&&c<=t.left+j.width&&(b.x=Ln.Backward,C.x=s*Math.abs((t.left+j.width-c)/j.width)),{direction:b,speed:C}}function t4(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:c}=window;return{top:0,left:0,right:i,bottom:c,width:i,height:c}}const{top:t,left:n,right:s,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:s,bottom:o,width:e.clientWidth,height:e.clientHeight}}function _1(e){return e.reduce((t,n)=>ji(t,yg(n)),ss)}function n4(e){return e.reduce((t,n)=>t+$1(n),0)}function r4(e){return e.reduce((t,n)=>t+L1(n),0)}function M1(e,t){if(t===void 0&&(t=Hi),!e)return;const{top:n,left:s,bottom:o,right:i}=t(e);D1(e)&&(o<=0||i<=0||n>=window.innerHeight||s>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const s4=[["x",["left","right"],n4],["y",["top","bottom"],r4]];class _x{constructor(t,n){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;const s=Mf(n),o=_1(s);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,c,u]of s4)for(const d of c)Object.defineProperty(this,d,{get:()=>{const m=u(s),h=o[i]-m;return this.rect[d]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Zl{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var s;return(s=this.target)==null?void 0:s.removeEventListener(...n)})},this.target=t}add(t,n,s){var o;(o=this.target)==null||o.addEventListener(t,n,s),this.listeners.push([t,n,s])}}function o4(e){const{EventTarget:t}=er(e);return e instanceof t?e:Vi(e)}function wh(e,t){const n=Math.abs(e.x),s=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+s**2)>t:"x"in t&&"y"in t?n>t.x&&s>t.y:"x"in t?n>t.x:"y"in t?s>t.y:!1}var Mr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Mr||(Mr={}));function Qw(e){e.preventDefault()}function a4(e){e.stopPropagation()}var wt;(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"})(wt||(wt={}));const F1={start:[wt.Space,wt.Enter],cancel:[wt.Esc],end:[wt.Space,wt.Enter,wt.Tab]},i4=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case wt.Right:return{...n,x:n.x+25};case wt.Left:return{...n,x:n.x-25};case wt.Down:return{...n,y:n.y+25};case wt.Up:return{...n,y:n.y-25}}};class Wi{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Zl(Vi(n)),this.windowListeners=new Zl(er(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Mr.Resize,this.handleCancel),this.windowListeners.add(Mr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Mr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,s=t.node.current;s&&M1(s),n(ss)}handleKeyDown(t){if(Of(t)){const{active:n,context:s,options:o}=this.props,{keyboardCodes:i=F1,coordinateGetter:c=i4,scrollBehavior:u="smooth"}=o,{code:d}=t;if(i.end.includes(d)){this.handleEnd(t);return}if(i.cancel.includes(d)){this.handleCancel(t);return}const{collisionRect:m}=s.current,h=m?{x:m.left,y:m.top}:ss;this.referenceCoordinates||(this.referenceCoordinates=h);const g=c(t,{active:n,context:s.current,currentCoordinates:h});if(g){const y=xc(g,h),b={x:0,y:0},{scrollableAncestors:C}=s.current;for(const j of C){const v=t.code,{isTop:k,isRight:E,isLeft:S,isBottom:T,maxScroll:P,minScroll:R}=I1(j),A=t4(j),$={x:Math.min(v===wt.Right?A.right-A.width/2:A.right,Math.max(v===wt.Right?A.left:A.left+A.width/2,g.x)),y:Math.min(v===wt.Down?A.bottom-A.height/2:A.bottom,Math.max(v===wt.Down?A.top:A.top+A.height/2,g.y))},M=v===wt.Right&&!E||v===wt.Left&&!S,_=v===wt.Down&&!T||v===wt.Up&&!k;if(M&&$.x!==g.x){const D=j.scrollLeft+y.x,V=v===wt.Right&&D<=P.x||v===wt.Left&&D>=R.x;if(V&&!y.y){j.scrollTo({left:D,behavior:u});return}V?b.x=j.scrollLeft-D:b.x=v===wt.Right?j.scrollLeft-P.x:j.scrollLeft-R.x,b.x&&j.scrollBy({left:-b.x,behavior:u});break}else if(_&&$.y!==g.y){const D=j.scrollTop+y.y,V=v===wt.Down&&D<=P.y||v===wt.Up&&D>=R.y;if(V&&!y.x){j.scrollTo({top:D,behavior:u});return}V?b.y=j.scrollTop-D:b.y=v===wt.Down?j.scrollTop-P.y:j.scrollTop-R.y,b.y&&j.scrollBy({top:-b.y,behavior:u});break}}this.handleMove(t,ji(xc(g,this.referenceCoordinates),b))}}}handleMove(t,n){const{onMove:s}=this.props;t.preventDefault(),s(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Wi.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:s=F1,onActivation:o}=t,{active:i}=n;const{code:c}=e.nativeEvent;if(s.start.includes(c)){const u=i.activatorNode.current;return u&&e.target!==u?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function Jw(e){return!!(e&&"distance"in e)}function Xw(e){return!!(e&&"delay"in e)}class Mx{constructor(t,n,s){var o;s===void 0&&(s=o4(t.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=t,this.events=n;const{event:i}=t,{target:c}=i;this.props=t,this.events=n,this.document=Vi(c),this.documentListeners=new Zl(this.document),this.listeners=new Zl(s),this.windowListeners=new Zl(er(c)),this.initialCoordinates=(o=Yd(i))!=null?o:ss,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(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:s}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Mr.Resize,this.handleCancel),this.windowListeners.add(Mr.DragStart,Qw),this.windowListeners.add(Mr.VisibilityChange,this.handleCancel),this.windowListeners.add(Mr.ContextMenu,Qw),this.documentListeners.add(Mr.Keydown,this.handleKeydown),n){if(s!=null&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Xw(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Jw(n)){this.handlePending(n);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(t,n){const{active:s,onPending:o}=this.props;o(s,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Mr.Click,a4,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Mr.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:s,initialCoordinates:o,props:i}=this,{onMove:c,options:{activationConstraint:u}}=i;if(!o)return;const d=(n=Yd(t))!=null?n:ss,m=xc(o,d);if(!s&&u){if(Jw(u)){if(u.tolerance!=null&&wh(m,u.tolerance))return this.handleCancel();if(wh(m,u.distance))return this.handleStart()}if(Xw(u)&&wh(m,u.tolerance))return this.handleCancel();this.handlePending(u,m);return}t.cancelable&&t.preventDefault(),c(d)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===wt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const l4={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Ki extends Mx{constructor(t){const{event:n}=t,s=Vi(n.target);super(t,l4,s)}}Ki.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return!n.isPrimary||n.button!==0?!1:(s==null||s({event:n}),!0)}}];const c4={move:{name:"mousemove"},end:{name:"mouseup"}};var bg;(function(e){e[e.RightClick=2]="RightClick"})(bg||(bg={}));class u4 extends Mx{constructor(t){super(t,c4,Vi(t.event.target))}}u4.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;return n.button===bg.RightClick?!1:(s==null||s({event:n}),!0)}}];const jh={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class d4 extends Mx{constructor(t){super(t,jh)}static setup(){return window.addEventListener(jh.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(jh.move.name,t)};function t(){}}}d4.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:s}=t;const{touches:o}=n;return o.length>1?!1:(s==null||s({event:n}),!0)}}];var ec;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(ec||(ec={}));var Jd;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Jd||(Jd={}));function f4(e){let{acceleration:t,activator:n=ec.Pointer,canScroll:s,draggingRect:o,enabled:i,interval:c=5,order:u=Jd.TreeOrder,pointerCoordinates:d,scrollableAncestors:m,scrollableAncestorRects:h,delta:g,threshold:y}=e;const b=m4({delta:g,disabled:!i}),[C,j]=EL(),v=p.useRef({x:0,y:0}),k=p.useRef({x:0,y:0}),E=p.useMemo(()=>{switch(n){case ec.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case ec.DraggableRect:return o}},[n,o,d]),S=p.useRef(null),T=p.useCallback(()=>{const R=S.current;if(!R)return;const A=v.current.x*k.current.x,$=v.current.y*k.current.y;R.scrollBy(A,$)},[]),P=p.useMemo(()=>u===Jd.TreeOrder?[...m].reverse():m,[u,m]);p.useEffect(()=>{if(!i||!m.length||!E){j();return}for(const R of P){if((s==null?void 0:s(R))===!1)continue;const A=m.indexOf(R),$=h[A];if(!$)continue;const{direction:M,speed:_}=e4(R,$,E,t,y);for(const D of["x","y"])b[D][M[D]]||(_[D]=0,M[D]=0);if(_.x>0||_.y>0){j(),S.current=R,C(T,c),v.current=_,k.current=M;return}}v.current={x:0,y:0},k.current={x:0,y:0},j()},[t,T,s,j,i,c,JSON.stringify(E),JSON.stringify(b),C,m,P,h,JSON.stringify(y)])}const p4={x:{[Ln.Backward]:!1,[Ln.Forward]:!1},y:{[Ln.Backward]:!1,[Ln.Forward]:!1}};function m4(e){let{delta:t,disabled:n}=e;const s=Gd(t);return Oc(o=>{if(n||!s||!o)return p4;const i={x:Math.sign(t.x-s.x),y:Math.sign(t.y-s.y)};return{x:{[Ln.Backward]:o.x[Ln.Backward]||i.x===-1,[Ln.Forward]:o.x[Ln.Forward]||i.x===1},y:{[Ln.Backward]:o.y[Ln.Backward]||i.y===-1,[Ln.Forward]:o.y[Ln.Forward]||i.y===1}}},[n,t,s])}function h4(e,t){const n=t!=null?e.get(t):void 0,s=n?n.node.current:null;return Oc(o=>{var i;return t==null?null:(i=s??o)!=null?i:null},[s,t])}function g4(e,t){return p.useMemo(()=>e.reduce((n,s)=>{const{sensor:o}=s,i=o.activators.map(c=>({eventName:c.eventName,handler:t(c.handler,s)}));return[...n,...i]},[]),[e,t])}var yc;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(yc||(yc={}));var vg;(function(e){e.Optimized="optimized"})(vg||(vg={}));const Zw=new Map;function x4(e,t){let{dragging:n,dependencies:s,config:o}=t;const[i,c]=p.useState(null),{frequency:u,measure:d,strategy:m}=o,h=p.useRef(e),g=v(),y=gc(g),b=p.useCallback(function(k){k===void 0&&(k=[]),!y.current&&c(E=>E===null?k:E.concat(k.filter(S=>!E.includes(S))))},[y]),C=p.useRef(null),j=Oc(k=>{if(g&&!n)return Zw;if(!k||k===Zw||h.current!==e||i!=null){const E=new Map;for(let S of e){if(!S)continue;if(i&&i.length>0&&!i.includes(S.id)&&S.rect.current){E.set(S.id,S.rect.current);continue}const T=S.node.current,P=T?new _x(d(T),T):null;S.rect.current=P,P&&E.set(S.id,P)}return E}return k},[e,i,n,g,d]);return p.useEffect(()=>{h.current=e},[e]),p.useEffect(()=>{g||b()},[n,g]),p.useEffect(()=>{i&&i.length>0&&c(null)},[JSON.stringify(i)]),p.useEffect(()=>{g||typeof u!="number"||C.current!==null||(C.current=setTimeout(()=>{b(),C.current=null},u))},[u,g,b,...s]),{droppableRects:j,measureDroppableContainers:b,measuringScheduled:i!=null};function v(){switch(m){case yc.Always:return!1;case yc.BeforeDragging:return n;default:return!n}}}function Fx(e,t){return Oc(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function y4(e,t){return Fx(e,t)}function b4(e){let{callback:t,disabled:n}=e;const s=Lf(t),o=p.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(s)},[s,n]);return p.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Ff(e){let{callback:t,disabled:n}=e;const s=Lf(t),o=p.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(s)},[n]);return p.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function v4(e){return new _x(Hi(e),e)}function ej(e,t,n){t===void 0&&(t=v4);const[s,o]=p.useState(null);function i(){o(d=>{if(!e)return null;if(e.isConnected===!1){var m;return(m=d??n)!=null?m:null}const h=t(e);return JSON.stringify(d)===JSON.stringify(h)?d:h})}const c=b4({callback(d){if(e)for(const m of d){const{type:h,target:g}=m;if(h==="childList"&&g instanceof HTMLElement&&g.contains(e)){i();break}}}}),u=Ff({callback:i});return ns(()=>{i(),e?(u==null||u.observe(e),c==null||c.observe(document.body,{childList:!0,subtree:!0})):(u==null||u.disconnect(),c==null||c.disconnect())},[e]),s}function w4(e){const t=Fx(e);return A1(e,t)}const tj=[];function j4(e){const t=p.useRef(e),n=Oc(s=>e?s&&s!==tj&&e&&t.current&&e.parentNode===t.current.parentNode?s:Mf(e):tj,[e]);return p.useEffect(()=>{t.current=e},[e]),n}function k4(e){const[t,n]=p.useState(null),s=p.useRef(e),o=p.useCallback(i=>{const c=vh(i.target);c&&n(u=>u?(u.set(c,yg(c)),new Map(u)):null)},[]);return p.useEffect(()=>{const i=s.current;if(e!==i){c(i);const u=e.map(d=>{const m=vh(d);return m?(m.addEventListener("scroll",o,{passive:!0}),[m,yg(m)]):null}).filter(d=>d!=null);n(u.length?new Map(u):null),s.current=e}return()=>{c(e),c(i)};function c(u){u.forEach(d=>{const m=vh(d);m==null||m.removeEventListener("scroll",o)})}},[o,e]),p.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,c)=>ji(i,c),ss):_1(e):ss,[e,t])}function nj(e,t){t===void 0&&(t=[]);const n=p.useRef(null);return p.useEffect(()=>{n.current=null},t),p.useEffect(()=>{const s=e!==ss;s&&!n.current&&(n.current=e),!s&&n.current&&(n.current=null)},[e]),n.current?xc(e,n.current):ss}function S4(e){p.useEffect(()=>{if(!$f)return;const t=e.map(n=>{let{sensor:s}=n;return s.setup==null?void 0:s.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function N4(e,t){return p.useMemo(()=>e.reduce((n,s)=>{let{eventName:o,handler:i}=s;return n[o]=c=>{i(c,t)},n},{}),[e,t])}function z1(e){return p.useMemo(()=>e?QL(e):null,[e])}const rj=[];function C4(e,t){t===void 0&&(t=Hi);const[n]=e,s=z1(n?er(n):null),[o,i]=p.useState(rj);function c(){i(()=>e.length?e.map(d=>O1(d)?s:new _x(t(d),d)):rj)}const u=Ff({callback:c});return ns(()=>{u==null||u.disconnect(),c(),e.forEach(d=>u==null?void 0:u.observe(d))},[e]),o}function B1(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Lc(t)?t:e}function E4(e){let{measure:t}=e;const[n,s]=p.useState(null),o=p.useCallback(m=>{for(const{target:h}of m)if(Lc(h)){s(g=>{const y=t(h);return g?{...g,width:y.width,height:y.height}:y});break}},[t]),i=Ff({callback:o}),c=p.useCallback(m=>{const h=B1(m);i==null||i.disconnect(),h&&(i==null||i.observe(h)),s(h?t(h):null)},[t,i]),[u,d]=qd(c);return p.useMemo(()=>({nodeRef:u,rect:n,setRef:d}),[n,u,d])}const T4=[{sensor:Ki,options:{}},{sensor:Wi,options:{}}],R4={current:{}},Ad={draggable:{measure:Yw},droppable:{measure:Yw,strategy:yc.WhileDragging,frequency:vg.Optimized},dragOverlay:{measure:Hi}};class tc extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,s;return(n=(s=this.get(t))==null?void 0:s.node.current)!=null?n:void 0}}const A4={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new tc,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Qd},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ad,measureDroppableContainers:Qd,windowRect:null,measuringScheduled:!1},U1={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Qd,draggableNodes:new Map,over:null,measureDroppableContainers:Qd},_c=p.createContext(U1),V1=p.createContext(A4);function P4(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new tc}}}function D4(e,t){switch(t.type){case Nn.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Nn.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 Nn.DragEnd:case Nn.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Nn.RegisterDroppable:{const{element:n}=t,{id:s}=n,o=new tc(e.droppable.containers);return o.set(s,n),{...e,droppable:{...e.droppable,containers:o}}}case Nn.SetDroppableDisabled:{const{id:n,key:s,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||s!==i.key)return e;const c=new tc(e.droppable.containers);return c.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:c}}}case Nn.UnregisterDroppable:{const{id:n,key:s}=t,o=e.droppable.containers.get(n);if(!o||s!==o.key)return e;const i=new tc(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function $4(e){let{disabled:t}=e;const{active:n,activatorEvent:s,draggableNodes:o}=p.useContext(_c),i=Gd(s),c=Gd(n==null?void 0:n.id);return p.useEffect(()=>{if(!t&&!s&&i&&c!=null){if(!Of(i)||document.activeElement===i.target)return;const u=o.get(c);if(!u)return;const{activatorNode:d,node:m}=u;if(!d.current&&!m.current)return;requestAnimationFrame(()=>{for(const h of[d.current,m.current]){if(!h)continue;const g=AL(h);if(g){g.focus();break}}})}},[s,t,o,c,i]),null}function H1(e,t){let{transform:n,...s}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...s}),n):n}function L4(e){return p.useMemo(()=>({draggable:{...Ad.draggable,...e==null?void 0:e.draggable},droppable:{...Ad.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Ad.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function O4(e){let{activeNode:t,measure:n,initialRect:s,config:o=!0}=e;const i=p.useRef(!1),{x:c,y:u}=typeof o=="boolean"?{x:o,y:o}:o;ns(()=>{if(!c&&!u||!t){i.current=!1;return}if(i.current||!s)return;const m=t==null?void 0:t.node.current;if(!m||m.isConnected===!1)return;const h=n(m),g=A1(h,s);if(c||(g.x=0),u||(g.y=0),i.current=!0,Math.abs(g.x)>0||Math.abs(g.y)>0){const y=D1(m);y&&y.scrollBy({top:g.y,left:g.x})}},[t,c,u,s,n])}const zf=p.createContext({...ss,scaleX:1,scaleY:1});var bo;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(bo||(bo={}));const Bf=p.memo(function(t){var n,s,o,i;let{id:c,accessibility:u,autoScroll:d=!0,children:m,sensors:h=T4,collisionDetection:g=HL,measuring:y,modifiers:b,...C}=t;const j=p.useReducer(D4,void 0,P4),[v,k]=j,[E,S]=IL(),[T,P]=p.useState(bo.Uninitialized),R=T===bo.Initialized,{draggable:{active:A,nodes:$,translate:M},droppable:{containers:_}}=v,D=A!=null?$.get(A):null,V=p.useRef({initial:null,translated:null}),K=p.useMemo(()=>{var te;return A!=null?{id:A,data:(te=D==null?void 0:D.data)!=null?te:R4,rect:V}:null},[A,D]),I=p.useRef(null),[F,q]=p.useState(null),[Z,z]=p.useState(null),G=gc(C,Object.values(C)),L=Ic("DndDescribedBy",c),H=p.useMemo(()=>_.getEnabled(),[_]),re=L4(y),{droppableRects:U,measureDroppableContainers:ue,measuringScheduled:ge}=x4(H,{dragging:R,dependencies:[M.x,M.y],config:re.droppable}),se=h4($,A),ye=p.useMemo(()=>Z?Yd(Z):null,[Z]),Se=pe(),Te=y4(se,re.draggable.measure);O4({activeNode:A!=null?$.get(A):null,config:Se.layoutShiftCompensation,initialRect:Te,measure:re.draggable.measure});const Pe=ej(se,re.draggable.measure,Te),Ke=ej(se?se.parentElement:null),ct=p.useRef({activatorEvent:null,active:null,activeNode:se,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:$,draggingNode:null,draggingNodeRect:null,droppableContainers:_,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),et=_.getNodeFor((n=ct.current.over)==null?void 0:n.id),ot=E4({measure:re.dragOverlay.measure}),X=(s=ot.nodeRef.current)!=null?s:se,Me=R?(o=ot.rect)!=null?o:Pe:null,Ce=!!(ot.nodeRef.current&&ot.rect),Ie=w4(Ce?null:Pe),Ye=z1(X?er(X):null),Fe=j4(R?et??se:null),Ze=C4(Fe),Je=H1(b,{transform:{x:M.x-Ie.x,y:M.y-Ie.y,scaleX:1,scaleY:1},activatorEvent:Z,active:K,activeNodeRect:Pe,containerNodeRect:Ke,draggingNodeRect:Me,over:ct.current.over,overlayNodeRect:ot.rect,scrollableAncestors:Fe,scrollableAncestorRects:Ze,windowRect:Ye}),Ot=ye?ji(ye,M):null,yt=k4(Fe),dt=nj(yt),le=nj(yt,[Pe]),Y=ji(Je,dt),fe=Me?qL(Me,Je):null,ne=K&&fe?g({active:K,collisionRect:fe,droppableRects:U,droppableContainers:H,pointerCoordinates:Ot}):null,he=R1(ne,"id"),[De,ut]=p.useState(null),ae=Ce?Je:ji(Je,le),be=WL(ae,(i=De==null?void 0:De.rect)!=null?i:null,Pe),Le=p.useRef(null),at=p.useCallback((te,xe)=>{let{sensor:Oe,options:tt}=xe;if(I.current==null)return;const ve=$.get(I.current);if(!ve)return;const Nt=te.nativeEvent,It=new Oe({active:I.current,activeNode:ve,event:Nt,options:tt,context:ct,onAbort(jt){if(!$.get(jt))return;const{onDragAbort:Rt}=G.current,oe={id:jt};Rt==null||Rt(oe),E({type:"onDragAbort",event:oe})},onPending(jt,wn,Rt,oe){if(!$.get(jt))return;const{onDragPending:nt}=G.current,bt={id:jt,constraint:wn,initialCoordinates:Rt,offset:oe};nt==null||nt(bt),E({type:"onDragPending",event:bt})},onStart(jt){const wn=I.current;if(wn==null)return;const Rt=$.get(wn);if(!Rt)return;const{onDragStart:oe}=G.current,Ue={activatorEvent:Nt,active:{id:wn,data:Rt.data,rect:V}};Fs.unstable_batchedUpdates(()=>{oe==null||oe(Ue),P(bo.Initializing),k({type:Nn.DragStart,initialCoordinates:jt,active:wn}),E({type:"onDragStart",event:Ue}),q(Le.current),z(Nt)})},onMove(jt){k({type:Nn.DragMove,coordinates:jt})},onEnd:en(Nn.DragEnd),onCancel:en(Nn.DragCancel)});Le.current=It;function en(jt){return async function(){const{active:Rt,collisions:oe,over:Ue,scrollAdjustedTranslate:nt}=ct.current;let bt=null;if(Rt&&nt){const{cancelDrop:tr}=G.current;bt={activatorEvent:Nt,active:Rt,collisions:oe,delta:nt,over:Ue},jt===Nn.DragEnd&&typeof tr=="function"&&await Promise.resolve(tr(bt))&&(jt=Nn.DragCancel)}I.current=null,Fs.unstable_batchedUpdates(()=>{k({type:jt}),P(bo.Uninitialized),ut(null),q(null),z(null),Le.current=null;const tr=jt===Nn.DragEnd?"onDragEnd":"onDragCancel";if(bt){const qr=G.current[tr];qr==null||qr(bt),E({type:tr,event:bt})}})}}},[$]),Be=p.useCallback((te,xe)=>(Oe,tt)=>{const ve=Oe.nativeEvent,Nt=$.get(tt);if(I.current!==null||!Nt||ve.dndKit||ve.defaultPrevented)return;const It={active:Nt};te(Oe,xe.options,It)===!0&&(ve.dndKit={capturedBy:xe.sensor},I.current=tt,at(Oe,xe))},[$,at]),kt=g4(h,Be);S4(h),ns(()=>{Pe&&T===bo.Initializing&&P(bo.Initialized)},[Pe,T]),p.useEffect(()=>{const{onDragMove:te}=G.current,{active:xe,activatorEvent:Oe,collisions:tt,over:ve}=ct.current;if(!xe||!Oe)return;const Nt={active:xe,activatorEvent:Oe,collisions:tt,delta:{x:Y.x,y:Y.y},over:ve};Fs.unstable_batchedUpdates(()=>{te==null||te(Nt),E({type:"onDragMove",event:Nt})})},[Y.x,Y.y]),p.useEffect(()=>{const{active:te,activatorEvent:xe,collisions:Oe,droppableContainers:tt,scrollAdjustedTranslate:ve}=ct.current;if(!te||I.current==null||!xe||!ve)return;const{onDragOver:Nt}=G.current,It=tt.get(he),en=It&&It.rect.current?{id:It.id,rect:It.rect.current,data:It.data,disabled:It.disabled}:null,jt={active:te,activatorEvent:xe,collisions:Oe,delta:{x:ve.x,y:ve.y},over:en};Fs.unstable_batchedUpdates(()=>{ut(en),Nt==null||Nt(jt),E({type:"onDragOver",event:jt})})},[he]),ns(()=>{ct.current={activatorEvent:Z,active:K,activeNode:se,collisionRect:fe,collisions:ne,droppableRects:U,draggableNodes:$,draggingNode:X,draggingNodeRect:Me,droppableContainers:_,over:De,scrollableAncestors:Fe,scrollAdjustedTranslate:Y},V.current={initial:Me,translated:fe}},[K,se,ne,fe,$,X,Me,U,_,De,Fe,Y]),f4({...Se,delta:M,draggingRect:fe,pointerCoordinates:Ot,scrollableAncestors:Fe,scrollableAncestorRects:Ze});const St=p.useMemo(()=>({active:K,activeNode:se,activeNodeRect:Pe,activatorEvent:Z,collisions:ne,containerNodeRect:Ke,dragOverlay:ot,draggableNodes:$,droppableContainers:_,droppableRects:U,over:De,measureDroppableContainers:ue,scrollableAncestors:Fe,scrollableAncestorRects:Ze,measuringConfiguration:re,measuringScheduled:ge,windowRect:Ye}),[K,se,Pe,Z,ne,Ke,ot,$,_,U,De,ue,Fe,Ze,re,ge,Ye]),_t=p.useMemo(()=>({activatorEvent:Z,activators:kt,active:K,activeNodeRect:Pe,ariaDescribedById:{draggable:L},dispatch:k,draggableNodes:$,over:De,measureDroppableContainers:ue}),[Z,kt,K,Pe,k,L,$,De,ue]);return Dt.createElement(C1.Provider,{value:S},Dt.createElement(_c.Provider,{value:_t},Dt.createElement(V1.Provider,{value:St},Dt.createElement(zf.Provider,{value:be},m)),Dt.createElement($4,{disabled:(u==null?void 0:u.restoreFocus)===!1})),Dt.createElement(FL,{...u,hiddenTextDescribedById:L}));function pe(){const te=(F==null?void 0:F.autoScrollEnabled)===!1,xe=typeof d=="object"?d.enabled===!1:d===!1,Oe=R&&!te&&!xe;return typeof d=="object"?{...d,enabled:Oe}:{enabled:Oe}}}),I4=p.createContext(null),sj="button",_4="Draggable";function M4(e){let{id:t,data:n,disabled:s=!1,attributes:o}=e;const i=Ic(_4),{activators:c,activatorEvent:u,active:d,activeNodeRect:m,ariaDescribedById:h,draggableNodes:g,over:y}=p.useContext(_c),{role:b=sj,roleDescription:C="draggable",tabIndex:j=0}=o??{},v=(d==null?void 0:d.id)===t,k=p.useContext(v?zf:I4),[E,S]=qd(),[T,P]=qd(),R=N4(c,t),A=gc(n);ns(()=>(g.set(t,{id:t,key:i,node:E,activatorNode:T,data:A}),()=>{const M=g.get(t);M&&M.key===i&&g.delete(t)}),[g,t]);const $=p.useMemo(()=>({role:b,tabIndex:j,"aria-disabled":s,"aria-pressed":v&&b===sj?!0:void 0,"aria-roledescription":C,"aria-describedby":h.draggable}),[s,b,j,v,C,h.draggable]);return{active:d,activatorEvent:u,activeNodeRect:m,attributes:$,isDragging:v,listeners:s?void 0:R,node:E,over:y,setNodeRef:S,setActivatorNodeRef:P,transform:k}}function W1(){return p.useContext(V1)}const F4="Droppable",z4={timeout:25};function B4(e){let{data:t,disabled:n=!1,id:s,resizeObserverConfig:o}=e;const i=Ic(F4),{active:c,dispatch:u,over:d,measureDroppableContainers:m}=p.useContext(_c),h=p.useRef({disabled:n}),g=p.useRef(!1),y=p.useRef(null),b=p.useRef(null),{disabled:C,updateMeasurementsFor:j,timeout:v}={...z4,...o},k=gc(j??s),E=p.useCallback(()=>{if(!g.current){g.current=!0;return}b.current!=null&&clearTimeout(b.current),b.current=setTimeout(()=>{m(Array.isArray(k.current)?k.current:[k.current]),b.current=null},v)},[v]),S=Ff({callback:E,disabled:C||!c}),T=p.useCallback(($,M)=>{S&&(M&&(S.unobserve(M),g.current=!1),$&&S.observe($))},[S]),[P,R]=qd(T),A=gc(t);return p.useEffect(()=>{!S||!P.current||(S.disconnect(),g.current=!1,S.observe(P.current))},[P,S]),p.useEffect(()=>(u({type:Nn.RegisterDroppable,element:{id:s,key:i,disabled:n,node:P,rect:y,data:A}}),()=>u({type:Nn.UnregisterDroppable,key:i,id:s})),[s]),p.useEffect(()=>{n!==h.current.disabled&&(u({type:Nn.SetDroppableDisabled,id:s,key:i,disabled:n}),h.current.disabled=n)},[s,i,n,u]),{active:c,rect:y,isOver:(d==null?void 0:d.id)===s,node:P,over:d,setNodeRef:R}}function U4(e){let{animation:t,children:n}=e;const[s,o]=p.useState(null),[i,c]=p.useState(null),u=Gd(n);return!n&&!s&&u&&o(u),ns(()=>{if(!i)return;const d=s==null?void 0:s.key,m=s==null?void 0:s.props.id;if(d==null||m==null){o(null);return}Promise.resolve(t(m,i)).then(()=>{o(null)})},[t,s,i]),Dt.createElement(Dt.Fragment,null,n,s?p.cloneElement(s,{ref:c}):null)}const V4={x:0,y:0,scaleX:1,scaleY:1};function H4(e){let{children:t}=e;return Dt.createElement(_c.Provider,{value:U1},Dt.createElement(zf.Provider,{value:V4},t))}const W4={position:"fixed",touchAction:"none"},K4=e=>Of(e)?"transform 250ms ease":void 0,q4=p.forwardRef((e,t)=>{let{as:n,activatorEvent:s,adjustScale:o,children:i,className:c,rect:u,style:d,transform:m,transition:h=K4}=e;if(!u)return null;const g=o?m:{...m,scaleX:1,scaleY:1},y={...W4,width:u.width,height:u.height,top:u.top,left:u.left,transform:rs.Transform.toString(g),transformOrigin:o&&s?zL(s,u):void 0,transition:typeof h=="function"?h(s):h,...d};return Dt.createElement(n,{className:c,style:y,ref:t},i)}),G4=e=>t=>{let{active:n,dragOverlay:s}=t;const o={},{styles:i,className:c}=e;if(i!=null&&i.active)for(const[u,d]of Object.entries(i.active))d!==void 0&&(o[u]=n.node.style.getPropertyValue(u),n.node.style.setProperty(u,d));if(i!=null&&i.dragOverlay)for(const[u,d]of Object.entries(i.dragOverlay))d!==void 0&&s.node.style.setProperty(u,d);return c!=null&&c.active&&n.node.classList.add(c.active),c!=null&&c.dragOverlay&&s.node.classList.add(c.dragOverlay),function(){for(const[d,m]of Object.entries(o))n.node.style.setProperty(d,m);c!=null&&c.active&&n.node.classList.remove(c.active)}},Y4=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:rs.Transform.toString(t)},{transform:rs.Transform.toString(n)}]},Q4={duration:250,easing:"ease",keyframes:Y4,sideEffects:G4({styles:{active:{opacity:"0"}}})};function J4(e){let{config:t,draggableNodes:n,droppableContainers:s,measuringConfiguration:o}=e;return Lf((i,c)=>{if(t===null)return;const u=n.get(i);if(!u)return;const d=u.node.current;if(!d)return;const m=B1(c);if(!m)return;const{transform:h}=er(c).getComputedStyle(c),g=P1(h);if(!g)return;const y=typeof t=="function"?t:X4(t);return M1(d,o.draggable.measure),y({active:{id:i,data:u.data,node:d,rect:o.draggable.measure(d)},draggableNodes:n,dragOverlay:{node:c,rect:o.dragOverlay.measure(m)},droppableContainers:s,measuringConfiguration:o,transform:g})})}function X4(e){const{duration:t,easing:n,sideEffects:s,keyframes:o}={...Q4,...e};return i=>{let{active:c,dragOverlay:u,transform:d,...m}=i;if(!t)return;const h={x:u.rect.left-c.rect.left,y:u.rect.top-c.rect.top},g={scaleX:d.scaleX!==1?c.rect.width*d.scaleX/u.rect.width:1,scaleY:d.scaleY!==1?c.rect.height*d.scaleY/u.rect.height:1},y={x:d.x-h.x,y:d.y-h.y,...g},b=o({...m,active:c,dragOverlay:u,transform:{initial:d,final:y}}),[C]=b,j=b[b.length-1];if(JSON.stringify(C)===JSON.stringify(j))return;const v=s==null?void 0:s({active:c,dragOverlay:u,...m}),k=u.node.animate(b,{duration:t,easing:n,fill:"forwards"});return new Promise(E=>{k.onfinish=()=>{v==null||v(),E()}})}}let oj=0;function Z4(e){return p.useMemo(()=>{if(e!=null)return oj++,oj},[e])}const eO=Dt.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:s,style:o,transition:i,modifiers:c,wrapperElement:u="div",className:d,zIndex:m=999}=e;const{activatorEvent:h,active:g,activeNodeRect:y,containerNodeRect:b,draggableNodes:C,droppableContainers:j,dragOverlay:v,over:k,measuringConfiguration:E,scrollableAncestors:S,scrollableAncestorRects:T,windowRect:P}=W1(),R=p.useContext(zf),A=Z4(g==null?void 0:g.id),$=H1(c,{activatorEvent:h,active:g,activeNodeRect:y,containerNodeRect:b,draggingNodeRect:v.rect,over:k,overlayNodeRect:v.rect,scrollableAncestors:S,scrollableAncestorRects:T,transform:R,windowRect:P}),M=Fx(y),_=J4({config:s,draggableNodes:C,droppableContainers:j,measuringConfiguration:E}),D=M?v.setRef:void 0;return Dt.createElement(H4,null,Dt.createElement(U4,{animation:_},g&&A?Dt.createElement(q4,{key:A,id:g.id,ref:D,as:u,activatorEvent:h,adjustScale:t,className:d,transition:i,rect:M,style:{zIndex:m,...o},transform:$},n):null))});function qi(e,t,n){const s=e.slice();return s.splice(n<0?s.length+n:n,0,s.splice(t,1)[0]),s}function tO(e,t){return e.reduce((n,s,o)=>{const i=t.get(s);return i&&(n[o]=i),n},Array(e.length))}function ud(e){return e!==null&&e>=0}function nO(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function rO(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const zx=e=>{let{rects:t,activeIndex:n,overIndex:s,index:o}=e;const i=qi(t,s,n),c=t[o],u=i[o];return!u||!c?null:{x:u.left-c.left,y:u.top-c.top,scaleX:u.width/c.width,scaleY:u.height/c.height}},dd={scaleX:1,scaleY:1},Bx=e=>{var t;let{activeIndex:n,activeNodeRect:s,index:o,rects:i,overIndex:c}=e;const u=(t=i[n])!=null?t:s;if(!u)return null;if(o===n){const m=i[c];return m?{x:0,y:n<c?m.top+m.height-(u.top+u.height):m.top-u.top,...dd}:null}const d=sO(i,o,n);return o>n&&o<=c?{x:0,y:-u.height-d,...dd}:o<n&&o>=c?{x:0,y:u.height+d,...dd}:{x:0,y:0,...dd}};function sO(e,t,n){const s=e[t],o=e[t-1],i=e[t+1];return s?n<t?o?s.top-(o.top+o.height):i?i.top-(s.top+s.height):0:i?i.top-(s.top+s.height):o?s.top-(o.top+o.height):0:0}const K1="Sortable",q1=Dt.createContext({activeIndex:-1,containerId:K1,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:zx,disabled:{draggable:!1,droppable:!1}});function Uf(e){let{children:t,id:n,items:s,strategy:o=zx,disabled:i=!1}=e;const{active:c,dragOverlay:u,droppableRects:d,over:m,measureDroppableContainers:h}=W1(),g=Ic(K1,n),y=u.rect!==null,b=p.useMemo(()=>s.map(R=>typeof R=="object"&&"id"in R?R.id:R),[s]),C=c!=null,j=c?b.indexOf(c.id):-1,v=m?b.indexOf(m.id):-1,k=p.useRef(b),E=!nO(b,k.current),S=v!==-1&&j===-1||E,T=rO(i);ns(()=>{E&&C&&h(b)},[E,b,C,h]),p.useEffect(()=>{k.current=b},[b]);const P=p.useMemo(()=>({activeIndex:j,containerId:g,disabled:T,disableTransforms:S,items:b,overIndex:v,useDragOverlay:y,sortedRects:tO(b,d),strategy:o}),[j,g,T.draggable,T.droppable,S,b,v,d,y,o]);return Dt.createElement(q1.Provider,{value:P},t)}const oO=e=>{let{id:t,items:n,activeIndex:s,overIndex:o}=e;return qi(n,s,o).indexOf(t)},aO=e=>{let{containerId:t,isSorting:n,wasDragging:s,index:o,items:i,newIndex:c,previousItems:u,previousContainerId:d,transition:m}=e;return!m||!s||u!==i&&o===c?!1:n?!0:c!==o&&t===d},iO={duration:200,easing:"ease"},G1="transform",lO=rs.Transition.toString({property:G1,duration:0,easing:"linear"}),cO={roleDescription:"sortable"};function uO(e){let{disabled:t,index:n,node:s,rect:o}=e;const[i,c]=p.useState(null),u=p.useRef(n);return ns(()=>{if(!t&&n!==u.current&&s.current){const d=o.current;if(d){const m=Hi(s.current,{ignoreTransform:!0}),h={x:d.left-m.left,y:d.top-m.top,scaleX:d.width/m.width,scaleY:d.height/m.height};(h.x||h.y)&&c(h)}}n!==u.current&&(u.current=n)},[t,n,s,o]),p.useEffect(()=>{i&&c(null)},[i]),i}function Vf(e){let{animateLayoutChanges:t=aO,attributes:n,disabled:s,data:o,getNewIndex:i=oO,id:c,strategy:u,resizeObserverConfig:d,transition:m=iO}=e;const{items:h,containerId:g,activeIndex:y,disabled:b,disableTransforms:C,sortedRects:j,overIndex:v,useDragOverlay:k,strategy:E}=p.useContext(q1),S=dO(s,b),T=h.indexOf(c),P=p.useMemo(()=>({sortable:{containerId:g,index:T,items:h},...o}),[g,o,T,h]),R=p.useMemo(()=>h.slice(h.indexOf(c)),[h,c]),{rect:A,node:$,isOver:M,setNodeRef:_}=B4({id:c,data:P,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...d}}),{active:D,activatorEvent:V,activeNodeRect:K,attributes:I,setNodeRef:F,listeners:q,isDragging:Z,over:z,setActivatorNodeRef:G,transform:L}=M4({id:c,data:P,attributes:{...cO,...n},disabled:S.draggable}),H=CL(_,F),re=!!D,U=re&&!C&&ud(y)&&ud(v),ue=!k&&Z,ge=ue&&U?L:null,ye=U?ge??(u??E)({rects:j,activeNodeRect:K,activeIndex:y,overIndex:v,index:T}):null,Se=ud(y)&&ud(v)?i({id:c,items:h,activeIndex:y,overIndex:v}):T,Te=D==null?void 0:D.id,Pe=p.useRef({activeId:Te,items:h,newIndex:Se,containerId:g}),Ke=h!==Pe.current.items,ct=t({active:D,containerId:g,isDragging:Z,isSorting:re,id:c,index:T,items:h,newIndex:Pe.current.newIndex,previousItems:Pe.current.items,previousContainerId:Pe.current.containerId,transition:m,wasDragging:Pe.current.activeId!=null}),et=uO({disabled:!ct,index:T,node:$,rect:A});return p.useEffect(()=>{re&&Pe.current.newIndex!==Se&&(Pe.current.newIndex=Se),g!==Pe.current.containerId&&(Pe.current.containerId=g),h!==Pe.current.items&&(Pe.current.items=h)},[re,Se,g,h]),p.useEffect(()=>{if(Te===Pe.current.activeId)return;if(Te!=null&&Pe.current.activeId==null){Pe.current.activeId=Te;return}const X=setTimeout(()=>{Pe.current.activeId=Te},50);return()=>clearTimeout(X)},[Te]),{active:D,activeIndex:y,attributes:I,data:P,rect:A,index:T,newIndex:Se,items:h,isOver:M,isSorting:re,isDragging:Z,listeners:q,node:$,overIndex:v,over:z,setNodeRef:H,setActivatorNodeRef:G,setDroppableNodeRef:_,setDraggableNodeRef:F,transform:et??ye,transition:ot()};function ot(){if(et||Ke&&Pe.current.newIndex===T)return lO;if(!(ue&&!Of(V)||!m)&&(re||ct))return rs.Transition.toString({...m,property:G1})}}function dO(e,t){var n,s;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(s=e==null?void 0:e.droppable)!=null?s:t.droppable}}function Xd(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const fO=[wt.Down,wt.Right,wt.Up,wt.Left],Y1=(e,t)=>{let{context:{active:n,collisionRect:s,droppableRects:o,droppableContainers:i,over:c,scrollableAncestors:u}}=t;if(fO.includes(e.code)){if(e.preventDefault(),!n||!s)return;const d=[];i.getEnabled().forEach(g=>{if(!g||g!=null&&g.disabled)return;const y=o.get(g.id);if(y)switch(e.code){case wt.Down:s.top<y.top&&d.push(g);break;case wt.Up:s.top>y.top&&d.push(g);break;case wt.Left:s.left>y.left&&d.push(g);break;case wt.Right:s.left<y.left&&d.push(g);break}});const m=UL({collisionRect:s,droppableRects:o,droppableContainers:d});let h=R1(m,"id");if(h===(c==null?void 0:c.id)&&m.length>1&&(h=m[1].id),h!=null){const g=i.get(n.id),y=i.get(h),b=y?o.get(y.id):null,C=y==null?void 0:y.node.current;if(C&&b&&g&&y){const v=Mf(C).some((R,A)=>u[A]!==R),k=Q1(g,y),E=pO(g,y),S=v||!k?{x:0,y:0}:{x:E?s.width-b.width:0,y:E?s.height-b.height:0},T={x:b.left,y:b.top};return S.x&&S.y?T:xc(T,S)}}}};function Q1(e,t){return!Xd(e)||!Xd(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function pO(e,t){return!Xd(e)||!Xd(t)||!Q1(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function xt({label:e="Loading dashboard data…"}){return r.jsx("div",{className:"flex min-h-[240px] items-center justify-center",children:r.jsx("div",{className:"chrome-card !px-4 !py-3",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:e})})})}function Tt({title:e="Something went wrong",error:t,action:n}){return r.jsx("div",{className:"rounded-lg border border-error-foreground/30 bg-error px-4 py-5",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-semibold text-error-foreground",children:e}),r.jsx("p",{className:"text-sm leading-6 text-error-foreground/90",children:t}),n?r.jsx("div",{className:"pt-2",children:n}):null]})})}function Pd({command:e,description:t,example:n}){return r.jsxs("div",{className:"rounded-lg border border-border/70 bg-code px-3 py-3 text-code-foreground shadow-sm",children:[r.jsx("code",{className:"block overflow-x-auto font-mono text-sm",children:e}),t?r.jsx("p",{className:"mt-2 text-sm text-code-foreground/80",children:t}):null,n?r.jsx("p",{className:"mt-2 font-mono text-xs text-code-foreground/60",children:n}):null]})}function He({title:e,description:t,children:n,className:s,actions:o}){return r.jsxs("section",{className:we("surface-panel space-y-3",s),children:[e||o?r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[e?r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e}):null,t?r.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),o]}):null,n]})}function mO({help:e,compact:t=!1}){const n=t?(e==null?void 0:e.firstProjectChecklist.slice(0,3))??[]:(e==null?void 0:e.firstProjectChecklist)??[];return r.jsx(He,{title:t?"Getting Started Refresher":"Getting Started",description:t?"A fast reminder of the real flow for creating and running work in Syntaur.":"A first-run checklist that maps to the current CLI and dashboard flow.",actions:r.jsx(Ee,{className:"text-sm font-semibold text-primary hover:underline",to:"/help",children:"Open full help"}),children:r.jsx("div",{className:"space-y-3",children:n.map((s,o)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:o+1}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:s.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:s.detail}),s.command?r.jsx(Pd,{command:s.command.command,example:s.command.example}):null]})]})},s.title))})})}const kh={review:"{total} items ready for your review","review.singular":"Review {title}",ready_to_implement:"{total} plans ready to implement — start with {title}","ready_to_implement.singular":"Start implementing {title}",ready_for_planning:"{total} assignments ready to plan — start with {title}","ready_for_planning.singular":"Plan {title}",in_progress:"Resume {title} ({total} in progress)","in_progress.singular":"Resume {title}",draft:"Shape your {total} drafts — start with {title}","draft.singular":"Shape {title}",blocked:"Unblock {title} ({total} blocked)","blocked.singular":"Unblock {title}",stale:"Triage {total} stale items","stale.singular":"Triage {title} — sitting stale",clean:"You’re all clear. Nothing needs you right now."},aa={emptyStateCleanTitle:"You’re all clear",emptyStateCleanCTA:"Browse projects",recentSessionsEmptyTitle:"No recent sessions",recentSessionsEmptyHint:"Use /grab-assignment or `syntaur track-session` to register one.",recentSessionsCopyPathLabel:"Copy path",recentSessionsCopyPathDisabled:"Session has no path",recentSessionsCopyFallbackHint:"Press ⌘C to copy"};function hO(e,t){return e.replace(/\{(\w+)\}/g,(n,s)=>String(t[s]??`{${s}}`))}function gO({hero:e,itemsById:t}){const n=fn();if(e.kind==="clean")return r.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-border/60 bg-background/60 p-6 shadow-sm",children:[r.jsx("p",{className:"eyebrow",children:aa.emptyStateCleanTitle}),r.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:kh.clean}),r.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"When work shows up — a draft, a review, a stale row — it’ll surface here."}),r.jsx("div",{className:"mt-4",children:r.jsx(Ee,{to:`${n}/projects`,className:"shell-action shell-action--cta",children:aa.emptyStateCleanCTA})})]});const s=e.itemId?t[e.itemId]:void 0,o=(s==null?void 0:s.assignmentTitle)??"",i=kh[e.copyKey]??kh[e.kind],c=hO(i,{total:e.total,title:o}),u=s?xO(s,n):`${n}/assignments`;return r.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-primary/20 bg-primary/5 p-6 shadow-sm",children:[r.jsx("p",{className:"eyebrow",children:"What needs you today"}),r.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:c}),s?r.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["In ",r.jsx("span",{className:"font-medium text-foreground",children:s.projectTitle??"Standalone"})," ","· status ",r.jsx("span",{className:"font-medium text-foreground",children:s.status})]}):null,r.jsx("div",{className:"mt-4",children:r.jsxs(Ee,{to:u,className:"shell-action shell-action--cta",children:["Open ",o||"assignment"]})})]})}function xO(e,t){return e.projectSlug?`${t}${e.href}`:e.href}const Ux=["kanban","list","table"],J1=["title","status","priority","assignee","dependencies","created","updated"],yO=["asc","desc"],bO=["comfortable","compact"],vO=["none","status","type","priority","assignee","project"],wO=["last_24h","last_7d","last_30d","last_90d","older_7d","older_30d"];function ze(e){const t=e===void 0?[]:Array.isArray(e)?e:[e],n=[];for(const s of t){if(typeof s!="string")continue;const o=s.trim();!o||o==="all"||n.includes(o)||n.push(o)}return n}function jO(e,t){const n=ze(e),s=ze(t);return n.length===s.length&&n.every(o=>s.includes(o))}const kO={defaultView:"kanban",sortField:"updated",sortDirection:"desc",density:"comfortable",grouping:"none",filters:{status:"all",type:"all",priority:"all",assignee:"all",project:"all",activity:"all"}},bc={version:1,global:kO,projects:{}};function Sh(e){return e==="table"?"table":"kanban"}function SO(e,t){return t?{...e,...t}:{...e}}function X1(e,t){const n=e.global;if(t===null)return n;const s=e.projects[t];return s?{defaultView:s.defaultView??n.defaultView,sortField:s.sortField??n.sortField,sortDirection:s.sortDirection??n.sortDirection,density:n.density,grouping:s.grouping??n.grouping,filters:SO(n.filters,s.filters)}:n}const NO=["low","medium","high","critical"],Hf={status:{kind:"enum"},priority:{kind:"ordinal",order:NO},type:{kind:"enum"},assignee:{kind:"string",noneSentinel:!0},project:{kind:"string",noneSentinel:!0},tag:{kind:"list",get:e=>e.tags},tags:{kind:"list"},archived:{kind:"bool"},title:{kind:"substring"},search:{kind:"substring",get:e=>e.searchText??e.title},created:{kind:"timestamp"},updated:{kind:"timestamp"},completedat:{kind:"timestamp",get:e=>e.completedAt},statusage:{kind:"duration",get:e=>e.statusAge},phase:{kind:"enum"},disposition:{kind:"enum"},phaseage:{kind:"duration",get:e=>e.phaseAge},hasrealobjective:{kind:"bool",get:e=>e.hasRealObjective},acrealtotal:{kind:"number",get:e=>e.acRealTotal},acrealchecked:{kind:"number",get:e=>e.acRealChecked},acallchecked:{kind:"bool",get:e=>e.acAllChecked},planexists:{kind:"bool",get:e=>e.planExists},planapproved:{kind:"bool",get:e=>e.planApproved},workspaceset:{kind:"bool",get:e=>e.workspaceSet},implementationstarted:{kind:"bool",get:e=>e.implementationStarted},depssatisfied:{kind:"bool",get:e=>e.depsSatisfied},unresolvedquestions:{kind:"number",get:e=>e.unresolvedQuestions},progressstaledays:{kind:"duration",get:e=>e.progressStaleDays},blocked:{kind:"bool"},parked:{kind:"bool"},reviewrequested:{kind:"bool",get:e=>e.reviewRequested},pinned:{kind:"bool"}};function CO(e,t){return e[t.toLowerCase()]??null}function jr(e,t,n){return e.get?e.get(n):n[t]??n[t.toLowerCase()]}class kr extends Error{constructor(t){super(t.map(n=>`${n.message} (at ${n.pos})`).join("; ")),this.errors=t,this.name="CompileError"}}function Z1(e){const[t,n,s]=e.split("-").map(c=>parseInt(c,10)),o=new Date(t,n-1,s).getTime(),i=new Date(t,n-1,s+1).getTime();return[o,i]}function wg(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.length>0){const t=Date.parse(e);return Number.isNaN(t)?null:t}return null}function nc(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){const t=Number(e);return Number.isFinite(t)?t:null}return null}function Nh(e,t){return typeof e=="string"&&e.toLowerCase()===t.toLowerCase()}function EO(e){return e==null||e===""}function Dd(e,t,n,s){switch(e.kind){case"enum":case"string":return e.noneSentinel&&n.raw.toLowerCase()==="none"?o=>EO(jr(e,t,o)):o=>Nh(jr(e,t,o),n.raw);case"substring":return o=>{const i=jr(e,t,o);return typeof i=="string"&&i.toLowerCase().includes(n.raw.toLowerCase())};case"bool":{const o=n.raw.toLowerCase();if(o!=="true"&&o!=="false")throw new kr([{pos:n.pos,message:`Field "${t}" is boolean — use ${t}:true or ${t}:false`}]);const i=o==="true";return c=>{const u=jr(e,t,c),d=typeof u=="boolean"?u:u==="true"?!0:u==="false"||u===null||u===void 0||u===""?!1:null;return d!==null&&d===i}}case"number":{const o=n.num??nc(n.raw);if(o===null)throw new kr([{pos:n.pos,message:`Field "${t}" is numeric — "${n.raw}" is not a number`}]);return i=>nc(jr(e,t,i))===o}case"ordinal":return o=>Nh(jr(e,t,o),n.raw);case"list":return o=>{const i=jr(e,t,o);return Array.isArray(i)&&i.some(c=>Nh(c,n.raw))};case"timestamp":{if(n.type==="date"){const[o,i]=Z1(n.raw);return c=>{const u=wg(jr(e,t,c));return u!==null&&u>=o&&u<i}}throw new kr([{pos:n.pos,message:`Field "${t}" is a timestamp — use a comparison (e.g. ${t} > -36h) or an absolute date (${t}:2026-06-01)`}])}case"duration":throw new kr([{pos:s,message:`Field "${t}" is a duration — use a comparison (e.g. ${t} > 3d)`}])}}function TO(e,t,n,s){const o=(i,c)=>{switch(n){case"<":return i<c;case">":return i>c;case"<=":return i<=c;case">=":return i>=c;case"=":return i===c;case"!=":return i!==c;default:return!1}};switch(e.kind){case"number":{const i=s.num??nc(s.raw);if(i===null)throw new kr([{pos:s.pos,message:`"${s.raw}" is not a number (field "${t}")`}]);return c=>{const u=nc(jr(e,t,c));return u!==null&&o(u,i)}}case"ordinal":{const i=e.order??[],c=i.findIndex(u=>u.toLowerCase()===s.raw.toLowerCase());if(c<0)throw new kr([{pos:s.pos,message:`"${s.raw}" is not a valid ${t} (expected one of: ${i.join(", ")})`}]);return u=>{const d=jr(e,t,u),m=typeof d=="string"?i.findIndex(h=>h.toLowerCase()===d.toLowerCase()):-1;return m>=0&&o(m,c)}}case"timestamp":{if(s.type==="duration"){const c=(s.sign===0?-1:s.sign??-1)*(s.num??0);return(u,d)=>{const m=wg(jr(e,t,u));return m!==null&&o(m,d.now+c)}}if(s.type==="date"){const[i,c]=Z1(s.raw);return u=>{const d=wg(jr(e,t,u));if(d===null)return!1;switch(n){case"<":return d<i;case"<=":return d<c;case">":return d>=c;case">=":return d>=i;case"=":return d>=i&&d<c;case"!=":return d<i||d>=c;default:return!1}}}throw new kr([{pos:s.pos,message:`Compare timestamp field "${t}" to a duration (e.g. -36h) or a date (YYYY-MM-DD)`}])}case"duration":{if(s.type!=="duration")throw new kr([{pos:s.pos,message:`Compare duration field "${t}" to a duration literal (e.g. 3d)`}]);const i=s.num??0;return c=>{const u=nc(jr(e,t,c));return u!==null&&o(u,i)}}case"enum":case"string":case"substring":case"list":{if(n==="=")return Dd(e,t,s,s.pos);if(n==="!="){const i=Dd(e,t,s,s.pos);return(c,u)=>!i(c,u)}throw new kr([{pos:s.pos,message:`Field "${t}" does not support ordering comparisons (use ":" or "=").`}])}case"bool":{if(n==="="||n==="!="){const i=Dd(e,t,s,s.pos);return n==="="?i:(c,u)=>!i(c,u)}throw new kr([{pos:s.pos,message:`Field "${t}" is boolean — use ${t}:true / ${t}:false`}])}}}function RO(e,t){const n=CO(t,e.field);if(!n)throw new kr([{pos:e.pos,message:`Unknown field "${e.field}"`}]);if(e.op===":"){const s=e.values.map(o=>Dd(n,e.field,o,e.pos));return s.length===1?s[0]:(o,i)=>s.some(c=>c(o,i))}return TO(n,e.field,e.op,e.values[0])}function rc(e,t){switch(e.kind){case"all":return()=>!0;case"atom":return RO(e,t);case"not":{const n=rc(e.child,t);return(s,o)=>!n(s,o)}case"and":{const n=e.children.map(s=>rc(s,t));return(s,o)=>n.every(i=>i(s,o))}case"or":{const n=e.children.map(s=>rc(s,t));return(s,o)=>n.some(i=>i(s,o))}}}class ui extends Error{constructor(t,n){super(n),this.pos=t,this.name="LexError"}}const AO={h:36e5,d:864e5,w:7*864e5,m:30*864e5,mo:30*864e5,y:365*864e5},PO=/[A-Za-z_]/,DO=/[A-Za-z0-9_-]/,$O=/^\d{4}-\d{2}-\d{2}/;function LO(e){const t=[];let n=0;const s=(o,i)=>{let c=n;for(;c<e.length&&/\d/.test(e[c]);)c++;const u=e.slice(n,c);let d="";for(;c<e.length&&/[a-z]/i.test(e[c]);)d+=e[c],c++;if(n=c,d.length>0){const m=AO[d.toLowerCase()];if(m===void 0)throw new ui(o,`Unknown duration unit "${d}" (expected h, d, w, m, mo, or y)`);return{type:"DURATION",text:e.slice(o,c),pos:o,num:parseInt(u,10)*m,sign:i}}return i!==0?{type:"NUMBER",text:e.slice(o,c),pos:o,num:i*parseInt(u,10)}:{type:"NUMBER",text:u,pos:o,num:parseInt(u,10)}};for(;n<e.length;){const o=e[n],i=n;if(o===" "||o===" "||o===`
|
|
555
|
-
`||o==="\r"){n++;continue}if(o==="("){t.push({type:"LPAREN",text:o,pos:i}),n++;continue}if(o===")"){t.push({type:"RPAREN",text:o,pos:i}),n++;continue}if(o===","){t.push({type:"COMMA",text:o,pos:i}),n++;continue}if(o===":"){t.push({type:"COLON",text:o,pos:i}),n++;continue}if(o==="*"){t.push({type:"STAR",text:o,pos:i}),n++;continue}if(o==="<"||o===">"){e[n+1]==="="?(t.push({type:"OP",text:o+"=",pos:i}),n+=2):(t.push({type:"OP",text:o,pos:i}),n++);continue}if(o==="!"){if(e[n+1]==="="){t.push({type:"OP",text:"!=",pos:i}),n+=2;continue}throw new ui(i,'Unexpected "!" (did you mean "!="?)')}if(o==="="){n+=e[n+1]==="="?2:1,t.push({type:"OP",text:"=",pos:i});continue}if(o==='"'||o==="'"){const c=o;let u=n+1,d="";for(;u<e.length&&e[u]!==c;)e[u]==="\\"&&u+1<e.length?(d+=e[u+1],u+=2):(d+=e[u],u++);if(u>=e.length)throw new ui(i,"Unterminated string literal");t.push({type:"STRING",text:d,pos:i}),n=u+1;continue}if(o==="-"||o==="+"){if(/\d/.test(e[n+1]??"")){const c=o==="-"?-1:1;n++,t.push(s(i,c));continue}if(o==="-"){t.push({type:"MINUS",text:"-",pos:i}),n++;continue}throw new ui(i,'Unexpected "+"')}if(/\d/.test(o)){const c=e.slice(n).match($O);if(c){t.push({type:"DATE",text:c[0],pos:i}),n+=c[0].length;continue}t.push(s(i,0));continue}if(PO.test(o)){let c=n+1;for(;c<e.length&&DO.test(e[c]);)c++;const u=e.slice(n,c),d=u.toLowerCase();d==="and"?t.push({type:"AND",text:u,pos:i}):d==="or"?t.push({type:"OR",text:u,pos:i}):d==="not"?t.push({type:"NOT",text:u,pos:i}):t.push({type:"IDENT",text:u,pos:i}),n=c;continue}throw new ui(i,`Unexpected character "${o}"`)}return t.push({type:"EOF",text:"",pos:e.length}),t}class Xo extends Error{constructor(t,n){super(n),this.pos=t,this.name="ParseError"}}const OO=new Set(["IDENT","STRING","NUMBER","DATE","DURATION"]),IO=new Set(["IDENT","NOT","MINUS","LPAREN","STAR"]);class _O{constructor(t){Xm(this,"pos",0);this.tokens=t}peek(){return this.tokens[this.pos]}next(){return this.tokens[this.pos++]}expect(t,n){const s=this.peek();if(s.type!==t)throw new Xo(s.pos,`Expected ${n}, got "${s.text||s.type}"`);return this.next()}parseQuery(){if(this.peek().type==="EOF")return{kind:"all"};const t=this.orExpr(),n=this.peek();if(n.type!=="EOF")throw new Xo(n.pos,`Unexpected "${n.text}" — unbalanced parentheses or stray token`);return t}orExpr(){const t=[this.andExpr()];for(;this.peek().type==="OR";)this.next(),t.push(this.andExpr());return t.length===1?t[0]:{kind:"or",children:t}}andExpr(){const t=[this.unary()];for(;;){const n=this.peek();if(n.type==="AND")this.next(),t.push(this.unary());else if(IO.has(n.type))t.push(this.unary());else break}return t.length===1?t[0]:{kind:"and",children:t}}unary(){const t=this.peek();if(t.type==="NOT")return this.next(),{kind:"not",child:this.unary()};if(t.type==="MINUS"){this.next();const n=this.peek();if(n.type!=="IDENT")throw new Xo(n.pos,'Expected a field atom after "-" negation');return{kind:"not",child:this.atom()}}return this.primary()}primary(){const t=this.peek();if(t.type==="LPAREN"){this.next();const n=this.orExpr();return this.expect("RPAREN",'")"'),n}if(t.type==="STAR")return this.next(),{kind:"all"};if(t.type==="IDENT")return this.atom();throw new Xo(t.pos,`Expected a field, "(", "*", or NOT — got "${t.text||"end of query"}"`)}atom(){const t=this.expect("IDENT","a field name"),n=this.peek();if(n.type==="COLON"){this.next();const s=this.valueOrList();return{kind:"atom",field:t.text,op:":",values:s,pos:t.pos}}if(n.type==="OP"){this.next();const s=this.value();return{kind:"atom",field:t.text,op:n.text,values:[s],pos:t.pos}}throw new Xo(n.pos,`Expected ":" or a comparison operator after field "${t.text}"`)}valueOrList(){if(this.peek().type==="LPAREN"){this.next();const t=[this.value()];for(;this.peek().type==="COMMA";)this.next(),t.push(this.value());return this.expect("RPAREN",'")" to close the value list'),t}return[this.value()]}value(){const t=this.peek();if(!OO.has(t.type))throw new Xo(t.pos,`Expected a value, got "${t.text||t.type}"`);switch(this.next(),t.type){case"STRING":return{type:"string",raw:t.text,pos:t.pos};case"NUMBER":return{type:"number",raw:t.text,num:t.num,pos:t.pos};case"DATE":return{type:"date",raw:t.text,pos:t.pos};case"DURATION":return{type:"duration",raw:t.text,num:t.num,sign:t.sign??0,pos:t.pos};default:return{type:"word",raw:t.text,pos:t.pos}}}}function Wf(e){try{const t=LO(e);return{ast:new _O(t).parseQuery(),errors:[]}}catch(t){if(t instanceof ui||t instanceof Xo)return{ast:null,errors:[{pos:t.pos,message:t.message}]};throw t}}function Vx(e,t=Hf){const n=Wf(e);if(!n.ast)return{query:null,errors:n.errors};try{return{query:{predicate:rc(n.ast,t),ast:n.ast},errors:[]}}catch(s){if(s instanceof kr)return{query:null,errors:s.errors};throw s}}const MO=/^[A-Za-z_][A-Za-z0-9_-]*$/,FO=new Set(["and","or","not"]);function eN(e){return MO.test(e)&&!FO.has(e.toLowerCase())?e:tN(e)}function tN(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}const nN="__unassigned__",rN="__standalone__",zO={last_24h:"24h",last_7d:"7d",last_30d:"30d",last_90d:"90d",older_7d:"7d",older_30d:"30d"};function BO(e){return e.startsWith("older_")?"<":">="}const Hx=["status","type","priority","assignee","project","tags"],UO=["created","updated"];function VO(e){var i;const t={};for(const c of Hx){const u=ze(e[c]);u.length&&(t[c]=u)}const n=(i=e.search)==null?void 0:i.trim();n&&(t.search=n);let s=e.activity&&e.activity!=="all"?e.activity:void 0;const o=e.dateRange;if(o){const c=HO(o);if(c)s||(s=c);else{const u=WO(o);u&&(t.dateRange=u)}}return s&&(t.activity=s),t}function HO(e){return e.field!=="updated"||!e.preset?null:e.preset==="older_7d"?"stale":e.preset==="last_7d"?"fresh":null}function WO(e){if(e.preset)return{field:e.field,preset:e.preset};const t=e.from&&e.from.length>0?e.from:void 0,n=e.to&&e.to.length>0?e.to:void 0;if(!t&&!n)return null;const s={field:e.field};return t&&(s.from=t),n&&(s.to=n),s}function sc(e){const t=VO(e),n=[];for(const s of Hx){const o=t[s]??[];o.length&&n.push(KO(s,o))}return t.search&&n.push(`search:${tN(t.search)}`),t.activity==="stale"?n.push("updated < -7d"):t.activity==="fresh"&&n.push("updated >= -7d"),t.dateRange&&n.push(...GO(t.dateRange)),n.join(" AND ")}function KO(e,t){const n=t.map(s=>qO(e,s));return n.length===1?`${e}:${n[0]}`:`${e}:(${n.join(", ")})`}function qO(e,t){return e==="assignee"&&t===nN||e==="project"&&t===rN?"none":eN(t)}function GO(e){if(e.preset)return[`${e.field} ${BO(e.preset)} -${zO[e.preset]}`];const t=[];return e.from&&t.push(`${e.field} >= ${e.from}`),e.to&&t.push(`${e.field} <= ${e.to}`),t}function oc(e){const t=Wf(e);if(!t.ast)return null;const n=YO(t.ast);if(n===null)return null;const s={},o=new Set,i=new Map;for(const c of n){const u=QO(c);if(!u)return null;switch(u.kind){case"value":{if(o.has(u.field))return null;o.add(u.field),s[u.field]=u.values;break}case"search":{if(o.has("search"))return null;o.add("search"),s.search=u.text;break}case"activity":{if(o.has("activity"))return null;o.add("activity"),s.activity=u.activity;break}case"datePreset":{const d=`date:${u.field}`;if(o.has(d)||i.has(u.field))return null;o.add(d),s.dateRange={field:u.field,preset:u.preset};break}case"dateBound":{const d=`date:${u.field}`;if(o.has(d))return null;const m=i.get(u.field)??{};if(u.bound==="from"){if(m.from!==void 0)return null;m.from=u.date}else{if(m.to!==void 0)return null;m.to=u.date}i.set(u.field,m);break}}}if(i.size>1)return null;for(const[c,u]of i){if(s.dateRange)return null;const d={field:c};u.from!==void 0&&(d.from=u.from),u.to!==void 0&&(d.to=u.to),s.dateRange=d}return s}function YO(e){if(e.kind==="all")return[];if(e.kind==="atom")return[e];if(e.kind==="and"){const t=[];for(const n of e.children){if(n.kind!=="atom")return null;t.push(n)}return t}return null}function QO(e){const t=e.field.toLowerCase();if(e.op===":"){if(Hx.includes(t)){const o=t,i=[];for(const c of e.values){const u=tI(o,c);if(u===null)return null;i.push(u)}return i.length===0?null:{kind:"value",field:o,values:i}}return t==="search"?e.values.length!==1?null:{kind:"search",text:e.values[0].raw}:null}if(!UO.includes(t))return null;const n=t;if(e.values.length!==1)return null;const s=e.values[0];return s.type==="duration"?JO(n,e.op,s):s.type==="date"?e.op===">="?{kind:"dateBound",field:n,bound:"from",date:s.raw}:e.op==="<="?{kind:"dateBound",field:n,bound:"to",date:s.raw}:null:null}function JO(e,t,n){if(n.sign!==-1)return null;const s=XO(n.raw);if(e==="updated"){if(t==="<"&&s==="7d")return{kind:"activity",activity:"stale"};if(t===">="&&s==="7d")return{kind:"activity",activity:"fresh"}}const o=eI(t,s);return o?{kind:"datePreset",field:e,preset:o}:null}function XO(e){return e.replace(/^[-+]/,"")}const ZO={">=":{"24h":"last_24h","7d":"last_7d","30d":"last_30d","90d":"last_90d"},"<":{"7d":"older_7d","30d":"older_30d"}};function eI(e,t){return e!==">="&&e!=="<"?null:ZO[e][t]??null}function tI(e,t){const n=t.raw;return e==="assignee"&&n.toLowerCase()==="none"?nN:e==="project"&&n.toLowerCase()==="none"?rN:n}const Ch=["title","status","priority","assignee","dependencies","created","updated"],nI=["small","wide","tall","large"],rI={status:"all",priority:"all",assignee:"all",project:"all",activity:"all"},aj="2026-05-21T00:00:00Z";function Eh(e,t,n){return{id:e,name:t,workspace:null,entityType:"assignment",config:{viewMode:"list",filters:{...rI,...n},sortField:"updated",sortDirection:"desc",listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}},createdAt:aj,updatedAt:aj}}const wo={version:1,views:[Eh("default-recently-updated","Recently updated",{}),Eh("default-high-priority","High priority",{priority:"high"}),Eh("default-stale","Stale",{activity:"stale"})],dashboard:{version:1,slots:[{id:"slot-0",widget:{kind:"agent-sessions"}},{id:"slot-1",widget:{kind:"saved-view",viewId:"default-recently-updated"}},{id:"slot-2",widget:{kind:"saved-view",viewId:"default-high-priority"}},{id:"slot-3",widget:{kind:"saved-view",viewId:"default-stale"}},{id:"slot-4",widget:{kind:"inventories"}}]}};function sN(e,t){const n=ze(e.filters.project),s=n.length===0||n.length===1&&n[0]===t,o=e.filters.activity,i=typeof e.filters.search=="string"&&e.filters.search.trim().length>0,c=e.filters.query,u=typeof c=="string"&&c.trim().length>0&&oc(c)===null;return s&&(!o||o==="all")&&!i&&!u}function oN(e,t){switch(t.kind){case"global":return e.workspace===null;case"workspace":return e.workspace===t.workspace||e.workspace===null;case"project":return e.workspace===t.workspace||e.workspace===null?sN(e.config,t.slug):!1}}const aN=`syntaur.savedViews.cache.v${wo.version}`;let ki=sI(),Zo=null,Wx=null;const jg=new Set,Zd=new Set;let iN=0;function lN(){return++iN}function kg(e){return e===iN}function sI(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(aN);if(!e)return null;const t=JSON.parse(e);return t.version!==wo.version?null:t}catch{return null}}function oI(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(aN,JSON.stringify(e))}catch{}}function cN(e){ki=e,Wx=null,oI(e);for(const t of jg)t(e);for(const t of Zd)t(null)}function aI(e){Wx=e;for(const t of Zd)t(e)}function uN(e){if(!e||typeof e!="object")return wo;const t=e;return t.version!==wo.version||!Array.isArray(t.views)||!t.dashboard?wo:t}function ij(){if(Zo)return Zo;const e=lN();return Zo=fetch("/api/saved-views").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=uN(t);return kg(e)&&cN(n),Zo=null,ki??n}).catch(t=>{const n=t instanceof Error?t:new Error(String(t));return kg(e)&&aI(n),Zo=null,ki??wo}),Zo}function Kx(){const[e,t]=p.useState(()=>ki??wo),[n,s]=p.useState(()=>ki===null),[o,i]=p.useState(!1),[c,u]=p.useState(()=>Wx);return p.useEffect(()=>{let m=!1;ki===null&&s(!0),ij().then(y=>{m||(t(y),s(!1),i(!0))});const h=y=>{m||(t(y),s(!1),i(!0),u(null))},g=y=>{m||(u(y),s(!1),i(!0))};return jg.add(h),Zd.add(g),()=>{m=!0,jg.delete(h),Zd.delete(g)}},[]),{file:e,loading:n,ready:o,error:c,refetch:()=>{Zo=null,s(!0),u(null),i(!1),ij()}}}function Mc(){const{file:e,loading:t}=Kx();return{views:e.views,loading:t}}function dN(){const{file:e,loading:t}=Kx();return{layout:e.dashboard,loading:t}}function So(e){const{file:t,loading:n,ready:s,error:o,refetch:i}=Kx();return e?{view:t.views.find(u=>u.id===e)??null,loading:n,ready:s,error:o,refetch:i}:{view:null,loading:!1,ready:!0,error:null,refetch:i}}async function Kf(e,t,n){const s=lN(),o=await fetch(t,{method:e,headers:n!==void 0?{"Content-Type":"application/json"}:void 0,body:n!==void 0?JSON.stringify(n):void 0});if(!o.ok){const c=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(c.error??`HTTP ${o.status}`)}const i=uN(await o.json());return kg(s)&&cN(i),i}function Pi(e){return Kf("POST","/api/saved-views",e)}function ef(e,t){return Kf("PATCH",`/api/saved-views/${encodeURIComponent(e)}`,t)}function iI(e){return Kf("DELETE",`/api/saved-views/${encodeURIComponent(e)}`)}function Sg(e){return Kf("PUT","/api/dashboard",{slots:e})}const lI=["top","right","bottom","left"],No=Math.min,Sr=Math.max,tf=Math.round,fd=Math.floor,Ss=e=>({x:e,y:e}),cI={left:"right",right:"left",bottom:"top",top:"bottom"};function Ng(e,t,n){return Sr(e,No(t,n))}function Vs(e,t){return typeof e=="function"?e(t):e}function Hs(e){return e.split("-")[0]}function Gi(e){return e.split("-")[1]}function qx(e){return e==="x"?"y":"x"}function Gx(e){return e==="y"?"height":"width"}function ws(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Yx(e){return qx(ws(e))}function uI(e,t,n){n===void 0&&(n=!1);const s=Gi(e),o=Yx(e),i=Gx(o);let c=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(c=nf(c)),[c,nf(c)]}function dI(e){const t=nf(e);return[Cg(e),t,Cg(t)]}function Cg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const lj=["left","right"],cj=["right","left"],fI=["top","bottom"],pI=["bottom","top"];function mI(e,t,n){switch(e){case"top":case"bottom":return n?t?cj:lj:t?lj:cj;case"left":case"right":return t?fI:pI;default:return[]}}function hI(e,t,n,s){const o=Gi(e);let i=mI(Hs(e),n==="start",s);return o&&(i=i.map(c=>c+"-"+o),t&&(i=i.concat(i.map(Cg)))),i}function nf(e){const t=Hs(e);return cI[t]+e.slice(t.length)}function gI(e){return{top:0,right:0,bottom:0,left:0,...e}}function fN(e){return typeof e!="number"?gI(e):{top:e,right:e,bottom:e,left:e}}function rf(e){const{x:t,y:n,width:s,height:o}=e;return{width:s,height:o,top:n,left:t,right:t+s,bottom:n+o,x:t,y:n}}function uj(e,t,n){let{reference:s,floating:o}=e;const i=ws(t),c=Yx(t),u=Gx(c),d=Hs(t),m=i==="y",h=s.x+s.width/2-o.width/2,g=s.y+s.height/2-o.height/2,y=s[u]/2-o[u]/2;let b;switch(d){case"top":b={x:h,y:s.y-o.height};break;case"bottom":b={x:h,y:s.y+s.height};break;case"right":b={x:s.x+s.width,y:g};break;case"left":b={x:s.x-o.width,y:g};break;default:b={x:s.x,y:s.y}}switch(Gi(t)){case"start":b[c]-=y*(n&&m?-1:1);break;case"end":b[c]+=y*(n&&m?-1:1);break}return b}async function xI(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:i,rects:c,elements:u,strategy:d}=e,{boundary:m="clippingAncestors",rootBoundary:h="viewport",elementContext:g="floating",altBoundary:y=!1,padding:b=0}=Vs(t,e),C=fN(b),v=u[y?g==="floating"?"reference":"floating":g],k=rf(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(v)))==null||n?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(u.floating)),boundary:m,rootBoundary:h,strategy:d})),E=g==="floating"?{x:s,y:o,width:c.floating.width,height:c.floating.height}:c.reference,S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u.floating)),T=await(i.isElement==null?void 0:i.isElement(S))?await(i.getScale==null?void 0:i.getScale(S))||{x:1,y:1}:{x:1,y:1},P=rf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:E,offsetParent:S,strategy:d}):E);return{top:(k.top-P.top+C.top)/T.y,bottom:(P.bottom-k.bottom+C.bottom)/T.y,left:(k.left-P.left+C.left)/T.x,right:(P.right-k.right+C.right)/T.x}}const yI=50,bI=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:i=[],platform:c}=n,u=c.detectOverflow?c:{...c,detectOverflow:xI},d=await(c.isRTL==null?void 0:c.isRTL(t));let m=await c.getElementRects({reference:e,floating:t,strategy:o}),{x:h,y:g}=uj(m,s,d),y=s,b=0;const C={};for(let j=0;j<i.length;j++){const v=i[j];if(!v)continue;const{name:k,fn:E}=v,{x:S,y:T,data:P,reset:R}=await E({x:h,y:g,initialPlacement:s,placement:y,strategy:o,middlewareData:C,rects:m,platform:u,elements:{reference:e,floating:t}});h=S??h,g=T??g,C[k]={...C[k],...P},R&&b<yI&&(b++,typeof R=="object"&&(R.placement&&(y=R.placement),R.rects&&(m=R.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:o}):R.rects),{x:h,y:g}=uj(m,y,d)),j=-1)}return{x:h,y:g,placement:y,strategy:o,middlewareData:C}},vI=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:i,platform:c,elements:u,middlewareData:d}=t,{element:m,padding:h=0}=Vs(e,t)||{};if(m==null)return{};const g=fN(h),y={x:n,y:s},b=Yx(o),C=Gx(b),j=await c.getDimensions(m),v=b==="y",k=v?"top":"left",E=v?"bottom":"right",S=v?"clientHeight":"clientWidth",T=i.reference[C]+i.reference[b]-y[b]-i.floating[C],P=y[b]-i.reference[b],R=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m));let A=R?R[S]:0;(!A||!await(c.isElement==null?void 0:c.isElement(R)))&&(A=u.floating[S]||i.floating[C]);const $=T/2-P/2,M=A/2-j[C]/2-1,_=No(g[k],M),D=No(g[E],M),V=_,K=A-j[C]-D,I=A/2-j[C]/2+$,F=Ng(V,I,K),q=!d.arrow&&Gi(o)!=null&&I!==F&&i.reference[C]/2-(I<V?_:D)-j[C]/2<0,Z=q?I<V?I-V:I-K:0;return{[b]:y[b]+Z,data:{[b]:F,centerOffset:I-F-Z,...q&&{alignmentOffset:Z}},reset:q}}}),wI=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:o,middlewareData:i,rects:c,initialPlacement:u,platform:d,elements:m}=t,{mainAxis:h=!0,crossAxis:g=!0,fallbackPlacements:y,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:j=!0,...v}=Vs(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const k=Hs(o),E=ws(u),S=Hs(u)===u,T=await(d.isRTL==null?void 0:d.isRTL(m.floating)),P=y||(S||!j?[nf(u)]:dI(u)),R=C!=="none";!y&&R&&P.push(...hI(u,j,C,T));const A=[u,...P],$=await d.detectOverflow(t,v),M=[];let _=((s=i.flip)==null?void 0:s.overflows)||[];if(h&&M.push($[k]),g){const I=uI(o,c,T);M.push($[I[0]],$[I[1]])}if(_=[..._,{placement:o,overflows:M}],!M.every(I=>I<=0)){var D,V;const I=(((D=i.flip)==null?void 0:D.index)||0)+1,F=A[I];if(F&&(!(g==="alignment"?E!==ws(F):!1)||_.every(z=>ws(z.placement)===E?z.overflows[0]>0:!0)))return{data:{index:I,overflows:_},reset:{placement:F}};let q=(V=_.filter(Z=>Z.overflows[0]<=0).sort((Z,z)=>Z.overflows[1]-z.overflows[1])[0])==null?void 0:V.placement;if(!q)switch(b){case"bestFit":{var K;const Z=(K=_.filter(z=>{if(R){const G=ws(z.placement);return G===E||G==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(G=>G>0).reduce((G,L)=>G+L,0)]).sort((z,G)=>z[1]-G[1])[0])==null?void 0:K[0];Z&&(q=Z);break}case"initialPlacement":q=u;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function dj(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function fj(e){return lI.some(t=>e[t]>=0)}const jI=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:o="referenceHidden",...i}=Vs(e,t);switch(o){case"referenceHidden":{const c=await s.detectOverflow(t,{...i,elementContext:"reference"}),u=dj(c,n.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:fj(u)}}}case"escaped":{const c=await s.detectOverflow(t,{...i,altBoundary:!0}),u=dj(c,n.floating);return{data:{escapedOffsets:u,escaped:fj(u)}}}default:return{}}}}},pN=new Set(["left","top"]);async function kI(e,t){const{placement:n,platform:s,elements:o}=e,i=await(s.isRTL==null?void 0:s.isRTL(o.floating)),c=Hs(n),u=Gi(n),d=ws(n)==="y",m=pN.has(c)?-1:1,h=i&&d?-1:1,g=Vs(t,e);let{mainAxis:y,crossAxis:b,alignmentAxis:C}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return u&&typeof C=="number"&&(b=u==="end"?C*-1:C),d?{x:b*h,y:y*m}:{x:y*m,y:b*h}}const SI=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:o,y:i,placement:c,middlewareData:u}=t,d=await kI(t,e);return c===((n=u.offset)==null?void 0:n.placement)&&(s=u.arrow)!=null&&s.alignmentOffset?{}:{x:o+d.x,y:i+d.y,data:{...d,placement:c}}}}},NI=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:o,platform:i}=t,{mainAxis:c=!0,crossAxis:u=!1,limiter:d={fn:k=>{let{x:E,y:S}=k;return{x:E,y:S}}},...m}=Vs(e,t),h={x:n,y:s},g=await i.detectOverflow(t,m),y=ws(Hs(o)),b=qx(y);let C=h[b],j=h[y];if(c){const k=b==="y"?"top":"left",E=b==="y"?"bottom":"right",S=C+g[k],T=C-g[E];C=Ng(S,C,T)}if(u){const k=y==="y"?"top":"left",E=y==="y"?"bottom":"right",S=j+g[k],T=j-g[E];j=Ng(S,j,T)}const v=d.fn({...t,[b]:C,[y]:j});return{...v,data:{x:v.x-n,y:v.y-s,enabled:{[b]:c,[y]:u}}}}}},CI=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:o,rects:i,middlewareData:c}=t,{offset:u=0,mainAxis:d=!0,crossAxis:m=!0}=Vs(e,t),h={x:n,y:s},g=ws(o),y=qx(g);let b=h[y],C=h[g];const j=Vs(u,t),v=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(d){const S=y==="y"?"height":"width",T=i.reference[y]-i.floating[S]+v.mainAxis,P=i.reference[y]+i.reference[S]-v.mainAxis;b<T?b=T:b>P&&(b=P)}if(m){var k,E;const S=y==="y"?"width":"height",T=pN.has(Hs(o)),P=i.reference[g]-i.floating[S]+(T&&((k=c.offset)==null?void 0:k[g])||0)+(T?0:v.crossAxis),R=i.reference[g]+i.reference[S]+(T?0:((E=c.offset)==null?void 0:E[g])||0)-(T?v.crossAxis:0);C<P?C=P:C>R&&(C=R)}return{[y]:b,[g]:C}}}},EI=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:o,rects:i,platform:c,elements:u}=t,{apply:d=()=>{},...m}=Vs(e,t),h=await c.detectOverflow(t,m),g=Hs(o),y=Gi(o),b=ws(o)==="y",{width:C,height:j}=i.floating;let v,k;g==="top"||g==="bottom"?(v=g,k=y===(await(c.isRTL==null?void 0:c.isRTL(u.floating))?"start":"end")?"left":"right"):(k=g,v=y==="end"?"top":"bottom");const E=j-h.top-h.bottom,S=C-h.left-h.right,T=No(j-h[v],E),P=No(C-h[k],S),R=!t.middlewareData.shift;let A=T,$=P;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&($=S),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(A=E),R&&!y){const _=Sr(h.left,0),D=Sr(h.right,0),V=Sr(h.top,0),K=Sr(h.bottom,0);b?$=C-2*(_!==0||D!==0?_+D:Sr(h.left,h.right)):A=j-2*(V!==0||K!==0?V+K:Sr(h.top,h.bottom))}await d({...t,availableWidth:$,availableHeight:A});const M=await c.getDimensions(u.floating);return C!==M.width||j!==M.height?{reset:{rects:!0}}:{}}}};function qf(){return typeof window<"u"}function Yi(e){return mN(e)?(e.nodeName||"").toLowerCase():"#document"}function Tr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Es(e){var t;return(t=(mN(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function mN(e){return qf()?e instanceof Node||e instanceof Tr(e).Node:!1}function os(e){return qf()?e instanceof Element||e instanceof Tr(e).Element:!1}function Ks(e){return qf()?e instanceof HTMLElement||e instanceof Tr(e).HTMLElement:!1}function pj(e){return!qf()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Tr(e).ShadowRoot}function Fc(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=as(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&o!=="inline"&&o!=="contents"}function TI(e){return/^(table|td|th)$/.test(Yi(e))}function Gf(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const RI=/transform|translate|scale|rotate|perspective|filter/,AI=/paint|layout|strict|content/,Qo=e=>!!e&&e!=="none";let Th;function Qx(e){const t=os(e)?as(e):e;return Qo(t.transform)||Qo(t.translate)||Qo(t.scale)||Qo(t.rotate)||Qo(t.perspective)||!Jx()&&(Qo(t.backdropFilter)||Qo(t.filter))||RI.test(t.willChange||"")||AI.test(t.contain||"")}function PI(e){let t=Co(e);for(;Ks(t)&&!Di(t);){if(Qx(t))return t;if(Gf(t))return null;t=Co(t)}return null}function Jx(){return Th==null&&(Th=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Th}function Di(e){return/^(html|body|#document)$/.test(Yi(e))}function as(e){return Tr(e).getComputedStyle(e)}function Yf(e){return os(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Co(e){if(Yi(e)==="html")return e;const t=e.assignedSlot||e.parentNode||pj(e)&&e.host||Es(e);return pj(t)?t.host:t}function hN(e){const t=Co(e);return Di(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ks(t)&&Fc(t)?t:hN(t)}function vc(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=hN(e),i=o===((s=e.ownerDocument)==null?void 0:s.body),c=Tr(o);if(i){const u=Eg(c);return t.concat(c,c.visualViewport||[],Fc(o)?o:[],u&&n?vc(u):[])}else return t.concat(o,vc(o,[],n))}function Eg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function gN(e){const t=as(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=Ks(e),i=o?e.offsetWidth:n,c=o?e.offsetHeight:s,u=tf(n)!==i||tf(s)!==c;return u&&(n=i,s=c),{width:n,height:s,$:u}}function Xx(e){return os(e)?e:e.contextElement}function Si(e){const t=Xx(e);if(!Ks(t))return Ss(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:i}=gN(t);let c=(i?tf(n.width):n.width)/s,u=(i?tf(n.height):n.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!u||!Number.isFinite(u))&&(u=1),{x:c,y:u}}const DI=Ss(0);function xN(e){const t=Tr(e);return!Jx()||!t.visualViewport?DI:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $I(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Tr(e)?!1:t}function da(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Xx(e);let c=Ss(1);t&&(s?os(s)&&(c=Si(s)):c=Si(e));const u=$I(i,n,s)?xN(i):Ss(0);let d=(o.left+u.x)/c.x,m=(o.top+u.y)/c.y,h=o.width/c.x,g=o.height/c.y;if(i){const y=Tr(i),b=s&&os(s)?Tr(s):s;let C=y,j=Eg(C);for(;j&&s&&b!==C;){const v=Si(j),k=j.getBoundingClientRect(),E=as(j),S=k.left+(j.clientLeft+parseFloat(E.paddingLeft))*v.x,T=k.top+(j.clientTop+parseFloat(E.paddingTop))*v.y;d*=v.x,m*=v.y,h*=v.x,g*=v.y,d+=S,m+=T,C=Tr(j),j=Eg(C)}}return rf({width:h,height:g,x:d,y:m})}function Qf(e,t){const n=Yf(e).scrollLeft;return t?t.left+n:da(Es(e)).left+n}function yN(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Qf(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function LI(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const i=o==="fixed",c=Es(s),u=t?Gf(t.floating):!1;if(s===c||u&&i)return n;let d={scrollLeft:0,scrollTop:0},m=Ss(1);const h=Ss(0),g=Ks(s);if((g||!g&&!i)&&((Yi(s)!=="body"||Fc(c))&&(d=Yf(s)),g)){const b=da(s);m=Si(s),h.x=b.x+s.clientLeft,h.y=b.y+s.clientTop}const y=c&&!g&&!i?yN(c,d):Ss(0);return{width:n.width*m.x,height:n.height*m.y,x:n.x*m.x-d.scrollLeft*m.x+h.x+y.x,y:n.y*m.y-d.scrollTop*m.y+h.y+y.y}}function OI(e){return Array.from(e.getClientRects())}function II(e){const t=Es(e),n=Yf(e),s=e.ownerDocument.body,o=Sr(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),i=Sr(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+Qf(e);const u=-n.scrollTop;return as(s).direction==="rtl"&&(c+=Sr(t.clientWidth,s.clientWidth)-o),{width:o,height:i,x:c,y:u}}const mj=25;function _I(e,t){const n=Tr(e),s=Es(e),o=n.visualViewport;let i=s.clientWidth,c=s.clientHeight,u=0,d=0;if(o){i=o.width,c=o.height;const h=Jx();(!h||h&&t==="fixed")&&(u=o.offsetLeft,d=o.offsetTop)}const m=Qf(s);if(m<=0){const h=s.ownerDocument,g=h.body,y=getComputedStyle(g),b=h.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,C=Math.abs(s.clientWidth-g.clientWidth-b);C<=mj&&(i-=C)}else m<=mj&&(i+=m);return{width:i,height:c,x:u,y:d}}function MI(e,t){const n=da(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,i=Ks(e)?Si(e):Ss(1),c=e.clientWidth*i.x,u=e.clientHeight*i.y,d=o*i.x,m=s*i.y;return{width:c,height:u,x:d,y:m}}function hj(e,t,n){let s;if(t==="viewport")s=_I(e,n);else if(t==="document")s=II(Es(e));else if(os(t))s=MI(t,n);else{const o=xN(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return rf(s)}function bN(e,t){const n=Co(e);return n===t||!os(n)||Di(n)?!1:as(n).position==="fixed"||bN(n,t)}function FI(e,t){const n=t.get(e);if(n)return n;let s=vc(e,[],!1).filter(u=>os(u)&&Yi(u)!=="body"),o=null;const i=as(e).position==="fixed";let c=i?Co(e):e;for(;os(c)&&!Di(c);){const u=as(c),d=Qx(c);!d&&u.position==="fixed"&&(o=null),(i?!d&&!o:!d&&u.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Fc(c)&&!d&&bN(e,c))?s=s.filter(h=>h!==c):o=u,c=Co(c)}return t.set(e,s),s}function zI(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const c=[...n==="clippingAncestors"?Gf(t)?[]:FI(t,this._c):[].concat(n),s],u=hj(t,c[0],o);let d=u.top,m=u.right,h=u.bottom,g=u.left;for(let y=1;y<c.length;y++){const b=hj(t,c[y],o);d=Sr(b.top,d),m=No(b.right,m),h=No(b.bottom,h),g=Sr(b.left,g)}return{width:m-g,height:h-d,x:g,y:d}}function BI(e){const{width:t,height:n}=gN(e);return{width:t,height:n}}function UI(e,t,n){const s=Ks(t),o=Es(t),i=n==="fixed",c=da(e,!0,i,t);let u={scrollLeft:0,scrollTop:0};const d=Ss(0);function m(){d.x=Qf(o)}if(s||!s&&!i)if((Yi(t)!=="body"||Fc(o))&&(u=Yf(t)),s){const b=da(t,!0,i,t);d.x=b.x+t.clientLeft,d.y=b.y+t.clientTop}else o&&m();i&&!s&&o&&m();const h=o&&!s&&!i?yN(o,u):Ss(0),g=c.left+u.scrollLeft-d.x-h.x,y=c.top+u.scrollTop-d.y-h.y;return{x:g,y,width:c.width,height:c.height}}function Rh(e){return as(e).position==="static"}function gj(e,t){if(!Ks(e)||as(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Es(e)===n&&(n=n.ownerDocument.body),n}function vN(e,t){const n=Tr(e);if(Gf(e))return n;if(!Ks(e)){let o=Co(e);for(;o&&!Di(o);){if(os(o)&&!Rh(o))return o;o=Co(o)}return n}let s=gj(e,t);for(;s&&TI(s)&&Rh(s);)s=gj(s,t);return s&&Di(s)&&Rh(s)&&!Qx(s)?n:s||PI(e)||n}const VI=async function(e){const t=this.getOffsetParent||vN,n=this.getDimensions,s=await n(e.floating);return{reference:UI(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function HI(e){return as(e).direction==="rtl"}const WI={convertOffsetParentRelativeRectToViewportRelativeRect:LI,getDocumentElement:Es,getClippingRect:zI,getOffsetParent:vN,getElementRects:VI,getClientRects:OI,getDimensions:BI,getScale:Si,isElement:os,isRTL:HI};function wN(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function KI(e,t){let n=null,s;const o=Es(e);function i(){var u;clearTimeout(s),(u=n)==null||u.disconnect(),n=null}function c(u,d){u===void 0&&(u=!1),d===void 0&&(d=1),i();const m=e.getBoundingClientRect(),{left:h,top:g,width:y,height:b}=m;if(u||t(),!y||!b)return;const C=fd(g),j=fd(o.clientWidth-(h+y)),v=fd(o.clientHeight-(g+b)),k=fd(h),S={rootMargin:-C+"px "+-j+"px "+-v+"px "+-k+"px",threshold:Sr(0,No(1,d))||1};let T=!0;function P(R){const A=R[0].intersectionRatio;if(A!==d){if(!T)return c();A?c(!1,A):s=setTimeout(()=>{c(!1,1e-7)},1e3)}A===1&&!wN(m,e.getBoundingClientRect())&&c(),T=!1}try{n=new IntersectionObserver(P,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(P,S)}n.observe(e)}return c(!0),i}function qI(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:d=!1}=s,m=Xx(e),h=o||i?[...m?vc(m):[],...t?vc(t):[]]:[];h.forEach(k=>{o&&k.addEventListener("scroll",n,{passive:!0}),i&&k.addEventListener("resize",n)});const g=m&&u?KI(m,n):null;let y=-1,b=null;c&&(b=new ResizeObserver(k=>{let[E]=k;E&&E.target===m&&b&&t&&(b.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var S;(S=b)==null||S.observe(t)})),n()}),m&&!d&&b.observe(m),t&&b.observe(t));let C,j=d?da(e):null;d&&v();function v(){const k=da(e);j&&!wN(j,k)&&n(),j=k,C=requestAnimationFrame(v)}return n(),()=>{var k;h.forEach(E=>{o&&E.removeEventListener("scroll",n),i&&E.removeEventListener("resize",n)}),g==null||g(),(k=b)==null||k.disconnect(),b=null,d&&cancelAnimationFrame(C)}}const GI=SI,YI=NI,QI=wI,JI=EI,XI=jI,xj=vI,ZI=CI,e_=(e,t,n)=>{const s=new Map,o={platform:WI,...n},i={...o.platform,_c:s};return bI(e,t,{...o,platform:i})};var t_=typeof document<"u",n_=function(){},$d=t_?p.useLayoutEffect:n_;function sf(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!sf(e[s],t[s]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,o[s]))return!1;for(s=n;s--!==0;){const i=o[s];if(!(i==="_owner"&&e.$$typeof)&&!sf(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function jN(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function yj(e,t){const n=jN(e);return Math.round(t*n)/n}function Ah(e){const t=p.useRef(e);return $d(()=>{t.current=e}),t}function r_(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:o,elements:{reference:i,floating:c}={},transform:u=!0,whileElementsMounted:d,open:m}=e,[h,g]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[y,b]=p.useState(s);sf(y,s)||b(s);const[C,j]=p.useState(null),[v,k]=p.useState(null),E=p.useCallback(z=>{z!==R.current&&(R.current=z,j(z))},[]),S=p.useCallback(z=>{z!==A.current&&(A.current=z,k(z))},[]),T=i||C,P=c||v,R=p.useRef(null),A=p.useRef(null),$=p.useRef(h),M=d!=null,_=Ah(d),D=Ah(o),V=Ah(m),K=p.useCallback(()=>{if(!R.current||!A.current)return;const z={placement:t,strategy:n,middleware:y};D.current&&(z.platform=D.current),e_(R.current,A.current,z).then(G=>{const L={...G,isPositioned:V.current!==!1};I.current&&!sf($.current,L)&&($.current=L,Fs.flushSync(()=>{g(L)}))})},[y,t,n,D,V]);$d(()=>{m===!1&&$.current.isPositioned&&($.current.isPositioned=!1,g(z=>({...z,isPositioned:!1})))},[m]);const I=p.useRef(!1);$d(()=>(I.current=!0,()=>{I.current=!1}),[]),$d(()=>{if(T&&(R.current=T),P&&(A.current=P),T&&P){if(_.current)return _.current(T,P,K);K()}},[T,P,K,_,M]);const F=p.useMemo(()=>({reference:R,floating:A,setReference:E,setFloating:S}),[E,S]),q=p.useMemo(()=>({reference:T,floating:P}),[T,P]),Z=p.useMemo(()=>{const z={position:n,left:0,top:0};if(!q.floating)return z;const G=yj(q.floating,h.x),L=yj(q.floating,h.y);return u?{...z,transform:"translate("+G+"px, "+L+"px)",...jN(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:L}},[n,u,q.floating,h.x,h.y]);return p.useMemo(()=>({...h,update:K,refs:F,elements:q,floatingStyles:Z}),[h,K,F,q,Z])}const s_=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:o}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?xj({element:s.current,padding:o}).fn(n):{}:s?xj({element:s,padding:o}).fn(n):{}}}},o_=(e,t)=>{const n=GI(e);return{name:n.name,fn:n.fn,options:[e,t]}},a_=(e,t)=>{const n=YI(e);return{name:n.name,fn:n.fn,options:[e,t]}},i_=(e,t)=>({fn:ZI(e).fn,options:[e,t]}),l_=(e,t)=>{const n=QI(e);return{name:n.name,fn:n.fn,options:[e,t]}},c_=(e,t)=>{const n=JI(e);return{name:n.name,fn:n.fn,options:[e,t]}},u_=(e,t)=>{const n=XI(e);return{name:n.name,fn:n.fn,options:[e,t]}},d_=(e,t)=>{const n=s_(e);return{name:n.name,fn:n.fn,options:[e,t]}};var f_="Arrow",kN=p.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...i}=e;return r.jsx(vn.svg,{...i,ref:t,width:s,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});kN.displayName=f_;var p_=kN;function m_(e){const[t,n]=p.useState(void 0);return jo(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let c,u;if("borderBoxSize"in i){const d=i.borderBoxSize,m=Array.isArray(d)?d[0]:d;c=m.inlineSize,u=m.blockSize}else c=e.offsetWidth,u=e.offsetHeight;n({width:c,height:u})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var Zx="Popper",[SN,NN]=pa(Zx),[h_,CN]=SN(Zx),EN=e=>{const{__scopePopper:t,children:n}=e,[s,o]=p.useState(null);return r.jsx(h_,{scope:t,anchor:s,onAnchorChange:o,children:n})};EN.displayName=Zx;var TN="PopperAnchor",RN=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,i=CN(TN,n),c=p.useRef(null),u=qn(t,c),d=p.useRef(null);return p.useEffect(()=>{const m=d.current;d.current=(s==null?void 0:s.current)||c.current,m!==d.current&&i.onAnchorChange(d.current)}),s?null:r.jsx(vn.div,{...o,ref:u})});RN.displayName=TN;var ey="PopperContent",[g_,x_]=SN(ey),AN=p.forwardRef((e,t)=>{var ye,Se,Te,Pe,Ke,ct;const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:i="center",alignOffset:c=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:m=[],collisionPadding:h=0,sticky:g="partial",hideWhenDetached:y=!1,updatePositionStrategy:b="optimized",onPlaced:C,...j}=e,v=CN(ey,n),[k,E]=p.useState(null),S=qn(t,et=>E(et)),[T,P]=p.useState(null),R=m_(T),A=(R==null?void 0:R.width)??0,$=(R==null?void 0:R.height)??0,M=s+(i!=="center"?"-"+i:""),_=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},D=Array.isArray(m)?m:[m],V=D.length>0,K={padding:_,boundary:D.filter(b_),altBoundary:V},{refs:I,floatingStyles:F,placement:q,isPositioned:Z,middlewareData:z}=r_({strategy:"fixed",placement:M,whileElementsMounted:(...et)=>qI(...et,{animationFrame:b==="always"}),elements:{reference:v.anchor},middleware:[o_({mainAxis:o+$,alignmentAxis:c}),d&&a_({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?i_():void 0,...K}),d&&l_({...K}),c_({...K,apply:({elements:et,rects:ot,availableWidth:X,availableHeight:Me})=>{const{width:Ce,height:Ie}=ot.reference,Ye=et.floating.style;Ye.setProperty("--radix-popper-available-width",`${X}px`),Ye.setProperty("--radix-popper-available-height",`${Me}px`),Ye.setProperty("--radix-popper-anchor-width",`${Ce}px`),Ye.setProperty("--radix-popper-anchor-height",`${Ie}px`)}}),T&&d_({element:T,padding:u}),v_({arrowWidth:A,arrowHeight:$}),y&&u_({strategy:"referenceHidden",...K})]}),[G,L]=$N(q),H=ca(C);jo(()=>{Z&&(H==null||H())},[Z,H]);const re=(ye=z.arrow)==null?void 0:ye.x,U=(Se=z.arrow)==null?void 0:Se.y,ue=((Te=z.arrow)==null?void 0:Te.centerOffset)!==0,[ge,se]=p.useState();return jo(()=>{k&&se(window.getComputedStyle(k).zIndex)},[k]),r.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:Z?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[(Pe=z.transformOrigin)==null?void 0:Pe.x,(Ke=z.transformOrigin)==null?void 0:Ke.y].join(" "),...((ct=z.hide)==null?void 0:ct.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(g_,{scope:n,placedSide:G,onArrowChange:P,arrowX:re,arrowY:U,shouldHideArrow:ue,children:r.jsx(vn.div,{"data-side":G,"data-align":L,...j,ref:S,style:{...j.style,animation:Z?void 0:"none"}})})})});AN.displayName=ey;var PN="PopperArrow",y_={top:"bottom",right:"left",bottom:"top",left:"right"},DN=p.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,i=x_(PN,s),c=y_[i.placedSide];return r.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:r.jsx(p_,{...o,ref:n,style:{...o.style,display:"block"}})})});DN.displayName=PN;function b_(e){return e!==null}var v_=e=>({name:"transformOrigin",options:e,fn(t){var v,k,E;const{placement:n,rects:s,middlewareData:o}=t,c=((v=o.arrow)==null?void 0:v.centerOffset)!==0,u=c?0:e.arrowWidth,d=c?0:e.arrowHeight,[m,h]=$N(n),g={start:"0%",center:"50%",end:"100%"}[h],y=(((k=o.arrow)==null?void 0:k.x)??0)+u/2,b=(((E=o.arrow)==null?void 0:E.y)??0)+d/2;let C="",j="";return m==="bottom"?(C=c?g:`${y}px`,j=`${-d}px`):m==="top"?(C=c?g:`${y}px`,j=`${s.floating.height+d}px`):m==="right"?(C=`${-d}px`,j=c?g:`${b}px`):m==="left"&&(C=`${s.floating.width+d}px`,j=c?g:`${b}px`),{data:{x:C,y:j}}}});function $N(e){const[t,n="center"]=e.split("-");return[t,n]}var w_=EN,j_=RN,k_=AN,S_=DN,N_=Symbol("radix.slottable");function C_(e){const t=({children:n})=>r.jsx(r.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=N_,t}var E_=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),T_="VisuallyHidden",LN=p.forwardRef((e,t)=>r.jsx(vn.span,{...e,ref:t,style:{...E_,...e.style}}));LN.displayName=T_;var R_=LN,[Jf]=pa("Tooltip",[NN]),Xf=NN(),ON="TooltipProvider",A_=700,Tg="tooltip.open",[P_,ty]=Jf(ON),IN=e=>{const{__scopeTooltip:t,delayDuration:n=A_,skipDelayDuration:s=300,disableHoverableContent:o=!1,children:i}=e,c=p.useRef(!0),u=p.useRef(!1),d=p.useRef(0);return p.useEffect(()=>{const m=d.current;return()=>window.clearTimeout(m)},[]),r.jsx(P_,{scope:t,isOpenDelayedRef:c,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(d.current),c.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>c.current=!0,s)},[s]),isPointerInTransitRef:u,onPointerInTransitChange:p.useCallback(m=>{u.current=m},[]),disableHoverableContent:o,children:i})};IN.displayName=ON;var wc="Tooltip",[D_,zc]=Jf(wc),_N=e=>{const{__scopeTooltip:t,children:n,open:s,defaultOpen:o,onOpenChange:i,disableHoverableContent:c,delayDuration:u}=e,d=ty(wc,e.__scopeTooltip),m=Xf(t),[h,g]=p.useState(null),y=bi(),b=p.useRef(0),C=c??d.disableHoverableContent,j=u??d.delayDuration,v=p.useRef(!1),[k,E]=Af({prop:s,defaultProp:o??!1,onChange:A=>{A?(d.onOpen(),document.dispatchEvent(new CustomEvent(Tg))):d.onClose(),i==null||i(A)},caller:wc}),S=p.useMemo(()=>k?v.current?"delayed-open":"instant-open":"closed",[k]),T=p.useCallback(()=>{window.clearTimeout(b.current),b.current=0,v.current=!1,E(!0)},[E]),P=p.useCallback(()=>{window.clearTimeout(b.current),b.current=0,E(!1)},[E]),R=p.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{v.current=!0,E(!0),b.current=0},j)},[j,E]);return p.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),r.jsx(w_,{...m,children:r.jsx(D_,{scope:t,contentId:y,open:k,stateAttribute:S,trigger:h,onTriggerChange:g,onTriggerEnter:p.useCallback(()=>{d.isOpenDelayedRef.current?R():T()},[d.isOpenDelayedRef,R,T]),onTriggerLeave:p.useCallback(()=>{C?P():(window.clearTimeout(b.current),b.current=0)},[P,C]),onOpen:T,onClose:P,disableHoverableContent:C,children:n})})};_N.displayName=wc;var Rg="TooltipTrigger",MN=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,o=zc(Rg,n),i=ty(Rg,n),c=Xf(n),u=p.useRef(null),d=qn(t,u,o.onTriggerChange),m=p.useRef(!1),h=p.useRef(!1),g=p.useCallback(()=>m.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),r.jsx(j_,{asChild:!0,...c,children:r.jsx(vn.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...s,ref:d,onPointerMove:Zt(e.onPointerMove,y=>{y.pointerType!=="touch"&&!h.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),h.current=!0)}),onPointerLeave:Zt(e.onPointerLeave,()=>{o.onTriggerLeave(),h.current=!1}),onPointerDown:Zt(e.onPointerDown,()=>{o.open&&o.onClose(),m.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:Zt(e.onFocus,()=>{m.current||o.onOpen()}),onBlur:Zt(e.onBlur,o.onClose),onClick:Zt(e.onClick,o.onClose)})})});MN.displayName=Rg;var ny="TooltipPortal",[$_,L_]=Jf(ny,{forceMount:void 0}),FN=e=>{const{__scopeTooltip:t,forceMount:n,children:s,container:o}=e,i=zc(ny,t);return r.jsx($_,{scope:t,forceMount:n,children:r.jsx(ma,{present:n||i.open,children:r.jsx(wx,{asChild:!0,container:o,children:s})})})};FN.displayName=ny;var $i="TooltipContent",zN=p.forwardRef((e,t)=>{const n=L_($i,e.__scopeTooltip),{forceMount:s=n.forceMount,side:o="top",...i}=e,c=zc($i,e.__scopeTooltip);return r.jsx(ma,{present:s||c.open,children:c.disableHoverableContent?r.jsx(BN,{side:o,...i,ref:t}):r.jsx(O_,{side:o,...i,ref:t})})}),O_=p.forwardRef((e,t)=>{const n=zc($i,e.__scopeTooltip),s=ty($i,e.__scopeTooltip),o=p.useRef(null),i=qn(t,o),[c,u]=p.useState(null),{trigger:d,onClose:m}=n,h=o.current,{onPointerInTransitChange:g}=s,y=p.useCallback(()=>{u(null),g(!1)},[g]),b=p.useCallback((C,j)=>{const v=C.currentTarget,k={x:C.clientX,y:C.clientY},E=z_(k,v.getBoundingClientRect()),S=B_(k,E),T=U_(j.getBoundingClientRect()),P=H_([...S,...T]);u(P),g(!0)},[g]);return p.useEffect(()=>()=>y(),[y]),p.useEffect(()=>{if(d&&h){const C=v=>b(v,h),j=v=>b(v,d);return d.addEventListener("pointerleave",C),h.addEventListener("pointerleave",j),()=>{d.removeEventListener("pointerleave",C),h.removeEventListener("pointerleave",j)}}},[d,h,b,y]),p.useEffect(()=>{if(c){const C=j=>{const v=j.target,k={x:j.clientX,y:j.clientY},E=(d==null?void 0:d.contains(v))||(h==null?void 0:h.contains(v)),S=!V_(k,c);E?y():S&&(y(),m())};return document.addEventListener("pointermove",C),()=>document.removeEventListener("pointermove",C)}},[d,h,c,m,y]),r.jsx(BN,{...e,ref:i})}),[I_,__]=Jf(wc,{isInside:!1}),M_=C_("TooltipContent"),BN=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:s,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:c,...u}=e,d=zc($i,n),m=Xf(n),{onClose:h}=d;return p.useEffect(()=>(document.addEventListener(Tg,h),()=>document.removeEventListener(Tg,h)),[h]),p.useEffect(()=>{if(d.trigger){const g=y=>{const b=y.target;b!=null&&b.contains(d.trigger)&&h()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,h]),r.jsx(vx,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:h,children:r.jsxs(k_,{"data-state":d.stateAttribute,...m,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[r.jsx(M_,{children:s}),r.jsx(I_,{scope:n,isInside:!0,children:r.jsx(R_,{id:d.contentId,role:"tooltip",children:o||s})})]})})});zN.displayName=$i;var UN="TooltipArrow",F_=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,o=Xf(n);return __(UN,n).isInside?null:r.jsx(S_,{...o,...s,ref:t})});F_.displayName=UN;function z_(e,t){const n=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,s,o,i)){case i:return"left";case o:return"right";case n:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function B_(e,t,n=5){const s=[];switch(t){case"top":s.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":s.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":s.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":s.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return s}function U_(e){const{top:t,right:n,bottom:s,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:s},{x:o,y:s}]}function V_(e,t){const{x:n,y:s}=e;let o=!1;for(let i=0,c=t.length-1;i<t.length;c=i++){const u=t[i],d=t[c],m=u.x,h=u.y,g=d.x,y=d.y;h>s!=y>s&&n<(g-m)*(s-h)/(y-h)+m&&(o=!o)}return o}function H_(e){const t=e.slice();return t.sort((n,s)=>n.x<s.x?-1:n.x>s.x?1:n.y<s.y?-1:n.y>s.y?1:0),W_(t)}function W_(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const o=e[s];for(;t.length>=2;){const i=t[t.length-1],c=t[t.length-2];if((i.x-c.x)*(o.y-c.y)>=(i.y-c.y)*(o.x-c.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let s=e.length-1;s>=0;s--){const o=e[s];for(;n.length>=2;){const i=n[n.length-1],c=n[n.length-2];if((i.x-c.x)*(o.y-c.y)>=(i.y-c.y)*(o.x-c.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var K_=IN,q_=_N,G_=MN,Y_=FN,VN=zN;const ia=K_,Nr=q_,Cr=G_,ur=p.forwardRef(({className:e,sideOffset:t=4,...n},s)=>r.jsx(Y_,{children:r.jsx(VN,{ref:s,sideOffset:t,className:we("z-50 overflow-hidden rounded-md border border-border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));ur.displayName=VN.displayName;function ry({items:e,align:t="end"}){const[n,s]=p.useState(!1),[o,i]=p.useState(null),c=p.useRef(null);if(p.useEffect(()=>{if(!n){i(null);return}function d(h){c.current&&!c.current.contains(h.target)&&s(!1)}function m(h){h.key==="Escape"&&s(!1)}return document.addEventListener("mousedown",d),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",m)}},[n]),e.length===0)return null;function u(d,m){const h=d.icon,g=we("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition",m&&"pl-8",d.disabled?"opacity-50 cursor-not-allowed":d.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),y=m?d.active?r.jsx(Rr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):r.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):h?r.jsx(h,{className:"h-4 w-4 shrink-0"}):null,b=r.jsxs(r.Fragment,{children:[y,r.jsx("span",{className:"block min-w-0 truncate",children:d.label})]});if(d.disabled){const C=r.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:r.jsx("button",{type:"button",disabled:!0,className:g,children:b})});return d.disabledReason?r.jsxs(Nr,{children:[r.jsx(Cr,{asChild:!0,children:C}),r.jsx(ur,{side:"left",children:d.disabledReason})]},d.key):r.jsx("div",{children:C},d.key)}return d.href?r.jsx(Ee,{to:d.href,className:g,onClick:()=>s(!1),children:b},d.key):r.jsx("button",{type:"button",className:g,onClick:()=>{var C;(C=d.onSelect)==null||C.call(d),s(!1)},children:b},d.key)}return r.jsxs("div",{className:"relative",ref:c,children:[r.jsx("button",{type:"button",onClick:()=>s(d=>!d),className:"shell-action",title:"More actions","aria-haspopup":"true","aria-expanded":n,children:r.jsx(GA,{className:"h-4 w-4"})}),n&&r.jsx("div",{className:we("absolute top-full mt-1 z-30 min-w-[220px] rounded-md border border-border/70 bg-background shadow-lg py-1",t==="end"?"right-0":"left-0"),children:r.jsx(ia,{delayDuration:200,children:e.map(d=>{if(d.submenu&&d.submenu.length>0){const m=d.icon,h=o===d.key;return r.jsxs("div",{children:[r.jsxs("button",{type:"button",className:we("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition hover:bg-foreground/5"),"aria-expanded":h,onClick:()=>i(h?null:d.key),children:[m?r.jsx(m,{className:"h-4 w-4 shrink-0"}):null,r.jsx("span",{className:"block min-w-0 flex-1 truncate",children:d.label}),h?r.jsx(pr,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):r.jsx(Rk,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]}),h?d.submenu.map(g=>u(g,!0)):null]},d.key)}return u(d,!1)})})})]})}function bj(e){const t=Date.parse(e);return Number.isNaN(t)?!1:Date.now()-t>10080*60*1e3}const Q_={last_24h:1440*60*1e3,last_7d:10080*60*1e3,last_30d:720*60*60*1e3,last_90d:2160*60*60*1e3,older_7d:10080*60*1e3,older_30d:720*60*60*1e3};function J_(e){const[t,n,s]=e.split("-").map(Number);return new Date(t,n-1,s,0,0,0,0).getTime()}function X_(e){const[t,n,s]=e.split("-").map(Number);return new Date(t,n-1,s,23,59,59,999).getTime()}function Z_(e,t,n=Date.now()){if(!t)return!0;const s=t.field==="created"?e.created??e.updated:e.updated,o=Date.parse(s);if(Number.isNaN(o))return!1;if(t.preset){const u=Q_[t.preset];return u===void 0?!0:t.preset.startsWith("older_")?n-o>u:o>=n-u&&o<=n}const i=t.from&&t.from.length>0?t.from:void 0,c=t.to&&t.to.length>0?t.to:void 0;return!i&&!c?!0:!(i&&o<J_(i)||c&&o>X_(c))}function e5(e,t,n={}){const{workspace:s,search:o,includeArchived:i}=n;if(e.archived===!0&&!i)return!1;const c=ze(t.status),u=ze(t.priority),d=ze(t.type),m=ze(t.assignee),h=ze(t.project),g=ze(t.tags),{activity:y}=t;if(s){if(s==="_ungrouped"){if(e.projectWorkspace!=null)return!1}else if(e.projectWorkspace!==s)return!1}if(c.length&&!c.includes(e.status)||u.length&&!u.includes(e.priority)||d.length&&!d.includes(e.type??"")||y==="stale"&&!bj(e.updated)||y==="fresh"&&bj(e.updated))return!1;if(m.length){const b=e.assignee??"__unassigned__";if(!m.includes(b))return!1}if(h.length&&!h.some(C=>C==="__standalone__"?e.projectSlug==null:e.projectSlug===C))return!1;if(g.length){const b=e.tags??[];if(!g.some(C=>b.includes(C)))return!1}if(!Z_(e,t.dateRange))return!1;if(o){const b=o.trim().toLowerCase();if(b&&!`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`.toLowerCase().includes(b))return!1}return!0}function jc(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}const Ld={phaseLadder:[{phase:"draft",when:"*",next:"Fill in the objective and acceptance criteria"},{phase:"ready_for_planning",when:"hasRealObjective:true AND acRealTotal > 0",next:"Write a plan and get it approved"},{phase:"ready_to_implement",when:"planApproved:true",next:"Start implementing"},{phase:"in_progress",when:"planApproved:true AND implementationStarted:true",next:"Finish acceptance criteria, then request review"},{phase:"review",when:"acAllChecked:true OR reviewRequested:true",next:"Complete, or address review feedback"}],disposition:[{when:"parked:true",is:"parked"},{when:"blocked:true",is:"blocked"},{when:null,is:"active"}],headline:{terminal:"passthrough",parked:"parked",blocked:"blocked",active:"phase"}};function t5(e,t,n=()=>null){const s=[],o=new Set(t.statuses.map(u=>u.id));e.phaseLadder.length===0&&s.push("phaseLadder must have at least one rung");for(const u of e.phaseLadder){o.has(u.phase)||s.push(`phaseLadder rung "${u.phase}" is not a defined status id`);const d=u.when==="*"?null:n(u.when);d&&s.push(`phaseLadder rung "${u.phase}": invalid condition — ${d}`)}const i=new Set(["active","blocked","parked"]);for(const u of e.disposition)if(i.has(u.is)||s.push(`disposition "${u.is}" is not valid (expected active, blocked, or parked — terminal is never a rule)`),u.when!==null){const d=n(u.when);d&&s.push(`disposition rule "${u.is}": invalid condition — ${d}`)}const c=e.disposition.map((u,d)=>u.when===null?d:-1).filter(u=>u>=0);c.length===0?s.push("disposition rules must end with an `else:` arm (a rule with when: null)"):c.length>1?s.push("disposition rules must have exactly one `else:` arm (when: null)"):c[0]!==e.disposition.length-1&&s.push("the `else:` arm (when: null) must be the LAST disposition rule — rules after it are unreachable");for(const u of["parked","blocked"])o.has(e.headline[u])||s.push(`headline.${u} → "${e.headline[u]}" is not a defined status id (add the definition or run migrate-derive)`);return s}const HN={statuses:[{id:"pending",label:"Pending"},{id:"in_progress",label:"In Progress"},{id:"blocked",label:"Blocked"},{id:"review",label:"Review"},{id:"completed",label:"Completed"},{id:"failed",label:"Failed"}],order:["pending","in_progress","blocked","review","completed","failed"],transitions:[],transitionsCustom:!1,custom:!1,derive:Ld,deriveCustom:!1,knownCommands:[],factDeclarations:[],rawFacts:[]};let ac=null,ea=null;function n5(){return ac?Promise.resolve(ac):ea||(ea=fetch("/api/config/statuses").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(ac=e,ea=null,e)).catch(()=>(ea=null,HN)),ea)}function ha(){const[e,t]=p.useState(()=>ac??HN);return p.useEffect(()=>{n5().then(t)},[]),e}function vj(){ac=null,ea=null}function Bc(e,t){const n=e.statuses.find(s=>s.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}const wj={critical:0,high:1,medium:2,low:3};function pd(e){return Date.parse(e??"")||0}function Uc(e,t,n){return[...e].sort((o,i)=>{let c=0;switch(t){case"title":c=o.title.localeCompare(i.title);break;case"status":c=o.status.localeCompare(i.status);break;case"priority":c=(wj[o.priority]??99)-(wj[i.priority]??99);break;case"assignee":c=(o.assignee??"").localeCompare(i.assignee??"");break;case"dependencies":c=o.dependsOn.length-i.dependsOn.length;break;case"created":c=pd(o.created)-pd(i.created);break;case"updated":c=pd(o.updated)-pd(i.updated);break}return n==="asc"?c:-c})}function r5(e){const t=`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`;return{...e.facts??{},status:e.status,phase:e.phase,disposition:e.disposition,priority:e.priority,type:e.type,assignee:e.assignee,project:e.projectSlug,tags:e.tags,archived:e.archived,title:e.title,created:e.created,updated:e.updated,completedAt:e.completedAt,statusAge:e.statusAge,phaseAge:e.phaseAge,searchText:t}}function WN(e,t,n={}){const{workspace:s,includeArchived:o=!1,now:i=Date.now()}=n,c={now:i};return e.filter(u=>{if(u.archived===!0&&!o)return!1;if(s){if(s==="_ungrouped"){if(u.projectWorkspace!=null)return!1}else if(u.projectWorkspace!==s)return!1}if(!t)return!0;const d=r5(u);return t.predicate(d,c)})}const Zf={hasrealobjective:{kind:"bool",get:e=>e.hasRealObjective},acrealtotal:{kind:"number",get:e=>e.acRealTotal},acrealchecked:{kind:"number",get:e=>e.acRealChecked},acallchecked:{kind:"bool",get:e=>e.acAllChecked},planexists:{kind:"bool",get:e=>e.planExists},planapproved:{kind:"bool",get:e=>e.planApproved},workspaceset:{kind:"bool",get:e=>e.workspaceSet},implementationstarted:{kind:"bool",get:e=>e.implementationStarted},depssatisfied:{kind:"bool",get:e=>e.depsSatisfied},unresolvedquestions:{kind:"number",get:e=>e.unresolvedQuestions},blocked:{kind:"bool"},parked:{kind:"bool"},reviewrequested:{kind:"bool",get:e=>e.reviewRequested},pinned:{kind:"bool"}};function ep(e){const t=e.name,n={fact:t,approved:`${t}Approved`,changesRequested:`${t}ChangesRequested`,by:`${t}By`,approvedBy:`${t}ApprovedBy`},s=e.type==="attestation"?[n.fact,n.approved,n.changesRequested,n.by,n.approvedBy].map(o=>o.toLowerCase()):[n.fact.toLowerCase()];return{storageKey:t,exports:n,registryKeys:s}}function s5(e){const t=[];for(const n of e??[]){if(!n||typeof n.name!="string")continue;const s=n.name.trim();if(!/^[a-z][a-zA-Z0-9]*$/.test(s))continue;const o=(n.type??"").trim();if(o==="bool"||o==="number")t.push({name:s,type:o});else if(o==="attestation"){const i=(n.binds??"none").toString().trim()||"none";(i==="plan"||i==="commit"||i==="none")&&t.push({name:s,type:"attestation",binds:i})}}return t}function Ag(e){const t=[],n=new Map;for(const s of Object.keys(Zf))n.set(s,"built-in");for(const s of Object.keys(Hf))n.set(s,"built-in");for(const s of e??[]){const o=((s==null?void 0:s.name)??"").trim();if(!/^[a-z][a-zA-Z0-9]*$/.test(o)){t.push(`fact "${(s==null?void 0:s.name)??""}": invalid name — must match /^[a-z][a-zA-Z0-9]*$/`);continue}const i=(s.type??"").trim();if(i!=="bool"&&i!=="number"&&i!=="attestation"){t.push(`fact "${o}": invalid type "${s.type??""}" — expected bool, number, or attestation`);continue}if(i==="attestation"){const m=(s.binds??"none").toString().trim()||"none";if(m!=="plan"&&m!=="commit"&&m!=="none"){t.push(`fact "${o}": invalid binds "${s.binds}" — expected plan, commit, or none`);continue}}const u=ep(i==="attestation"?{name:o,type:i}:{name:o,type:i}).registryKeys,d=u.find(m=>n.has(m));if(d!==void 0){const m=n.get(d);m==="built-in"?t.push(`fact "${o}": exported field "${d}" collides with a built-in field`):m===o?t.push(`fact "${o}": duplicate declaration (a fact named "${o}" is already declared)`):t.push(`fact "${o}": exported field "${d}" collides with fact "${m}"`);continue}for(const m of u)n.set(m,o)}return t}function o5(e){const t=new Set([...Object.keys(Zf),...Object.keys(Hf)]),n=[];for(const s of e){const o=ep(s).registryKeys;if(!o.some(i=>t.has(i))){for(const i of o)t.add(i);n.push(s)}}return n}function KN(e,t){const n=ep(t);t.type==="attestation"?(e[n.exports.fact.toLowerCase()]={kind:"bool",get:s=>s[n.exports.fact]},e[n.exports.approved.toLowerCase()]={kind:"bool",get:s=>s[n.exports.approved]},e[n.exports.changesRequested.toLowerCase()]={kind:"bool",get:s=>s[n.exports.changesRequested]},e[n.exports.by.toLowerCase()]={kind:"list",get:s=>s[n.exports.by]},e[n.exports.approvedBy.toLowerCase()]={kind:"list",get:s=>s[n.exports.approvedBy]}):e[n.exports.fact.toLowerCase()]={kind:t.type,get:s=>s[n.exports.fact]}}function sy(e){const t={...Zf};for(const n of e)KN(t,n);return t}function qN(e){const t={...Hf};for(const n of e)KN(t,n);return t}function GN(e){const t=["status","priority","type","assignee","project","tag","tags","archived","title","search","created","updated","completedAt","statusAge","phase","disposition","phaseAge","hasRealObjective","acRealTotal","acRealChecked","acAllChecked","planExists","planApproved","workspaceSet","implementationStarted","depsSatisfied","unresolvedQuestions","progressStaleDays","blocked","parked","reviewRequested","pinned"],n=[];for(const s of e){const o=ep(s);s.type==="attestation"?n.push(o.exports.fact,o.exports.approved,o.exports.changesRequested,o.exports.by,o.exports.approvedBy):n.push(o.exports.fact)}return[...t,...n]}function Et({title:e,description:t,actions:n}){return r.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 px-4 py-6 text-center",children:r.jsxs("div",{className:"mx-auto max-w-xl space-y-2",children:[r.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t}),n?r.jsx("div",{className:"flex flex-wrap justify-center gap-3 pt-2",children:n}):null]})})}const Li='a, button, input, select, textarea, [contenteditable="true"], [role="button"], [data-no-drag]';function tp({columns:e,items:t,getItemId:n,getColumnId:s,renderCard:o,canDrop:i,onMove:c,getExternalDragData:u,onCardContextMenu:d,emptyMessage:m="No cards in this column.",hiddenColumnIds:h,onHideColumn:g,compact:y=!1,dragDisabled:b=!1}){const C=p.useMemo(()=>new Set(h??[]),[h]),j=p.useMemo(()=>e.filter(I=>!C.has(I.id)),[e,C]),v=p.useMemo(()=>e.filter(I=>C.has(I.id)),[e,C]),[k,E]=p.useState(null),[S,T]=p.useState(null),P=p.useRef(null),R=p.useMemo(()=>new Map(t.map(I=>[n(I),I])),[n,t]),A=p.useMemo(()=>j.map(I=>({column:I,items:t.filter(F=>s(F)===I.id)})),[j,s,t]),$=k?R.get(k)??null:null;function M(I){if(!$)return{allowed:!1};const F=s($);return(i==null?void 0:i({item:$,fromColumnId:F,toColumnId:I}))??{allowed:!0}}function _(){E(null),T(null)}function D(I,F,q){if(b)return;const Z=(u==null?void 0:u(F))??null;!c&&!Z||(I.dataTransfer.effectAllowed="move",I.dataTransfer.setData("text/plain",q),Z&&I.dataTransfer.setData("application/json",JSON.stringify(Z)),c&&E(q))}function V(I,F,q){b||!c||!$||!M(F).allowed||(I.preventDefault(),I.dataTransfer.dropEffect="move",T(z=>(z==null?void 0:z.columnId)===F&&z.index===q?z:{columnId:F,index:q}))}async function K(I,F,q){var H;if(I.preventDefault(),b||!c||!$){_();return}const Z=s($),G=(((H=A.find(re=>re.column.id===Z))==null?void 0:H.items)??[]).findIndex(re=>n(re)===n($));if(!M(F).allowed||G<0){_();return}if(Z===F&&(q===G||q===G+1)){_();return}try{await c({item:$,fromColumnId:Z,toColumnId:F,fromIndex:G,toIndex:q})}finally{_()}}return r.jsxs("div",{className:"relative overflow-x-auto pb-2",style:{scrollbarColor:"oklch(var(--border)) transparent",scrollbarWidth:"thin"},children:[v.length>0&&g?r.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Hidden:"}),v.map(I=>r.jsxs("button",{type:"button",onClick:()=>g(I.id),className:"rounded-full border border-dashed border-border/60 px-2 py-0.5 hover:border-border hover:text-foreground",title:`Restore "${I.title}" column`,children:[I.title," ×"]},I.id))]}):null,r.jsx("div",{className:we("grid min-w-max grid-flow-col gap-4",y?"auto-cols-[minmax(240px,280px)]":"auto-cols-[minmax(300px,360px)]"),children:A.map(({column:I,items:F})=>{const q=M(I.id),Z=(S==null?void 0:S.columnId)===I.id;return r.jsxs("section",{className:we("flex flex-col rounded-lg border border-border/60 bg-card/85 shadow-sm",y?"min-h-[200px] p-2":"min-h-[320px] p-3",$&&!q.allowed?"border-dashed opacity-65":"",$&&q.allowed?"border-primary/30 bg-accent/30":"",Z?"ring-2 ring-ring/30":""),title:$&&!q.allowed?q.reason:void 0,children:[r.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h2",{className:we("font-semibold uppercase tracking-[0.16em] text-muted-foreground",y?"text-xs":"text-sm"),children:I.title}),I.description&&!y?r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:I.description}):null]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs font-semibold text-foreground",children:F.length}),g?r.jsx("button",{type:"button",onClick:()=>g(I.id),className:"rounded-full border border-transparent px-1.5 py-0.5 text-xs text-muted-foreground hover:border-border hover:text-foreground",title:`Hide "${I.title}" column`,"aria-label":`Hide column ${I.title}`,children:"×"}):null]})]}),r.jsxs("div",{className:"flex flex-1 flex-col gap-3",onDragOver:z=>V(z,I.id,F.length),onDrop:z=>K(z,I.id,F.length),children:[F.length===0?b?r.jsx("div",{className:"flex min-h-[128px] items-center justify-center rounded-lg border border-border/60 bg-background/50 px-4 text-center text-sm text-muted-foreground",children:typeof m=="function"?m(I):m}):r.jsx(a5,{active:(S==null?void 0:S.columnId)===I.id&&S.index===0,disabled:!!$&&!q.allowed,children:typeof m=="function"?m(I):m}):null,F.map((z,G)=>{const L=n(z),H=k===L;return r.jsxs(p.Fragment,{children:[r.jsx("div",{className:we("h-2 rounded-full transition",(S==null?void 0:S.columnId)===I.id&&S.index===G?"bg-primary/70":"bg-transparent"),onDragOver:re=>V(re,I.id,G),onDrop:re=>K(re,I.id,G)}),r.jsx("div",{draggable:!b&&!!(c||u),onMouseDown:re=>{P.current=re.target},onDragStart:re=>{const U=P.current;if(U!=null&&U.closest(Li)){re.preventDefault();return}D(re,z,L)},onDragEnd:_,onContextMenu:re=>{if(!d)return;const U=re.target;U!=null&&U.closest(Li)||d(z,re)},className:we("transition",!b&&(c||u)?"cursor-grab active:cursor-grabbing":"",H?"scale-[0.98] opacity-50":""),children:o(z,{dragging:H})})]},L)}),F.length>0&&!b?r.jsx("div",{className:we("mt-1 rounded-md border border-dashed px-3 py-2 text-center text-xs text-muted-foreground transition",(S==null?void 0:S.columnId)===I.id&&S.index===F.length?"border-primary/50 bg-primary/10 text-foreground":"border-border/60",$&&!q.allowed?"opacity-40":""),children:"Drop here to place at the end"}):null]})]},I.id)})})]})}function a5({active:e,disabled:t,children:n}){return r.jsx("div",{className:we("flex min-h-[128px] items-center justify-center rounded-lg border border-dashed px-4 text-center text-sm text-muted-foreground transition",e?"border-primary/60 bg-primary/10 text-foreground":"border-border/60 bg-background/50",t?"opacity-45":""),children:n})}const Yl="border-status-pending-foreground/30 bg-status-pending text-status-pending-foreground",Ph="border-status-in-progress-foreground/30 bg-status-in-progress text-status-in-progress-foreground",i5="border-status-blocked-foreground/30 bg-status-blocked text-status-blocked-foreground",l5="border-status-review-foreground/30 bg-status-review text-status-review-foreground",c5="border-status-completed-foreground/30 bg-status-completed text-status-completed-foreground",u5="border-status-failed-foreground/30 bg-status-failed text-status-failed-foreground",d5="border-status-archived-foreground/30 bg-status-archived text-status-archived-foreground",of={draft:{label:"Draft",description:"Just-created stub; not yet shaped.",className:Yl,icon:zi},pending:{label:"Pending",description:"Waiting to start or waiting on dependencies.",className:Yl,icon:UA},ready_for_planning:{label:"Ready for Planning",description:"Objective and acceptance criteria written; awaiting a plan.",className:Yl,icon:Pk},ready_to_implement:{label:"Ready to Implement",description:"Plan written and approved; ready to start coding.",className:Ph,icon:cP},in_progress:{label:"In Progress",description:"Actively being worked on.",className:Ph,icon:ix},blocked:{label:"Blocked",description:"Blocked by an explicit obstacle that needs intervention.",className:i5,icon:Ud},review:{label:"Review",description:"Ready for inspection or approval.",className:l5,icon:fP},completed:{label:"Completed",description:"Finished successfully.",className:c5,icon:rx},failed:{label:"Failed",description:"Could not be completed as planned.",className:u5,icon:Ud},active:{label:"Active",description:"The project has active or review work in flight.",className:Ph,icon:lg},stopped:{label:"Stopped",description:"Session ended without completing.",className:Yl,icon:zA},archived:{label:"Archived",description:"Hidden from normal views; restorable from the Archive page.",className:d5,icon:lg}};function af(e){const t=of[e];return t||{className:Yl,icon:lg,label:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase()),description:`Status: ${e}`}}function YN(e,t){return we("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full border px-2.5 py-0.5 text-xs font-medium tracking-normal","shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0)] dark:shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0.04)]",af(e).className,t)}function bn({status:e,className:t,showIcon:n=!0,progress:s}){const o=af(e),i=o.icon,c=s&&s.total>0,u=c?Math.min(1,Math.max(0,s.checked/s.total)):0,d=c?`${o.label} — ${o.description} (${s.checked}/${s.total} criteria)`:`${o.label} — ${o.description}`,m=n?c?r.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"absolute inset-0 h-full w-full -rotate-90",children:[r.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"1.5"}),r.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeDasharray:2*Math.PI*7,strokeDashoffset:2*Math.PI*7*(1-u)})]}),r.jsx(i,{className:"h-2.5 w-2.5"})]}):r.jsx(i,{className:"h-3.5 w-3.5 shrink-0"}):null;return r.jsxs("span",{title:d,className:YN(e,t),children:[m,r.jsx("span",{className:"min-w-0 truncate",children:o.label})]})}function np(e){var t;return((t=of[e])==null?void 0:t.description)??`Status: ${e}`}const QN={definitions:[{id:"feature",label:"Feature"},{id:"bug",label:"Bug"},{id:"refactor",label:"Refactor"},{id:"research",label:"Research"},{id:"chore",label:"Chore"}],default:"feature",custom:!1};let Od=null,ei=null;function f5(){return Od?Promise.resolve(Od):ei||(ei=fetch("/api/config/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Od=e,ei=null,e)).catch(()=>(ei=null,QN)),ei)}function rp(){const[e,t]=p.useState(()=>Od??QN);return p.useEffect(()=>{f5().then(t)},[]),e}function Ni(e,t){if(!t)return"—";const n=e.definitions.find(s=>s.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function p5(e,t){return t?e.definitions.find(n=>n.id===t)??null:null}function ga({type:e,className:t,compact:n=!1}){const s=rp();if(!e)return null;const o=p5(s,e),i=(o==null?void 0:o.label)??e.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase()),c=o!=null&&o.color?{backgroundColor:`color-mix(in oklch, ${o.color} 18%, transparent)`,borderColor:`color-mix(in oklch, ${o.color} 50%, transparent)`,color:o.color}:void 0;return r.jsx("span",{title:(o==null?void 0:o.description)??`Type: ${i}`,style:c,className:we("inline-flex items-center whitespace-nowrap rounded-full border text-xs capitalize",n?"px-2 py-0.5":"px-2.5 py-1",!c&&"border-border/60 text-muted-foreground",t),children:i})}async function Vc(e){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{return await navigator.clipboard.writeText(e),!0}catch{}return m5(e)}function m5(e){try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}function Br({value:e,label:t,disabled:n=!1,disabledReason:s,onError:o}){const[i,c]=p.useState(!1);async function u(){n||(await Vc(e)?(c(!0),setTimeout(()=>c(!1),1500)):o==null||o(new Error("Copy to clipboard failed in this context.")))}return n?r.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:s??"Copy unavailable","aria-label":t??"Copy",children:r.jsx(Vd,{className:"h-3 w-3","aria-hidden":"true"})}):r.jsx("button",{type:"button",onClick:u,className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 rounded",title:i?"Copied!":t??`Copy: ${e}`,"aria-label":t??"Copy",children:i?r.jsx(Rr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):r.jsx(Vd,{className:"h-3 w-3","aria-hidden":"true"})})}function h5(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function g5({items:e,statusOrder:t,sortField:n,sortDirection:s,listSectionVisibility:o,compact:i=!1}){const c=ha(),[u,d]=p.useState(()=>new Set(o.collapsed));p.useEffect(()=>{d(new Set(o.collapsed))},[o]);const m=h=>{d(g=>{const y=new Set(g);return y.has(h)?y.delete(h):y.add(h),y})};return r.jsx("div",{className:we("space-y-2",i?"space-y-1.5":"space-y-3"),children:t.map(h=>{const g=Uc(e.filter(C=>C.status===h),n,s);if(g.length===0)return null;const y=!u.has(h),b=Bc(c,h);return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/90",children:[r.jsxs("button",{type:"button",onClick:()=>m(h),className:we("flex w-full items-center gap-2 text-left",i?"px-3 py-2 text-xs":"px-4 py-3 text-sm"),children:[r.jsx(pr,{className:we("text-muted-foreground transition-transform",i?"h-3.5 w-3.5":"h-4 w-4",y?"":"-rotate-90")}),r.jsx("span",{className:"font-semibold text-foreground",children:b}),r.jsx("span",{className:we("rounded-full border border-border/60 text-muted-foreground",i?"px-1.5 py-0 text-[10px]":"px-2 py-0.5 text-xs"),children:g.length})]}),y&&r.jsx("ul",{className:we("divide-y divide-border/40 border-t border-border/40",i?"text-xs":"text-sm"),children:g.map(C=>{const j=h5(C);return r.jsx("li",{children:r.jsxs(Ee,{to:j,className:we("flex items-center gap-3 hover:bg-muted/40",i?"px-3 py-1.5":"px-4 py-2.5"),children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:C.title}),C.projectTitle?r.jsx("span",{className:"hidden truncate text-muted-foreground sm:inline",children:C.projectTitle}):null,r.jsx("span",{className:"shrink-0 text-muted-foreground",children:zn(C.updated)})]})},`${C.projectSlug??"standalone"}:${C.id}`)})})]},h)})})}function x5(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function y5({items:e,sortField:t,sortDirection:n,tableColumnVisibility:s,compact:o=!1}){const i=new Set(s.hidden);i.delete("title");const c=h=>!i.has(h),u=Uc(e,t,n),d=o?"py-2 pr-3":"py-3 pr-4",m=o?"text-xs":"text-sm";return r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:we("w-full text-left",m),children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[c("title")?r.jsx("th",{className:we("font-medium",d),children:"Assignment"}):null,c("status")?r.jsx("th",{className:we("font-medium",d),children:"Status"}):null,c("priority")?r.jsx("th",{className:we("font-medium",d),children:"Priority"}):null,c("assignee")?r.jsx("th",{className:we("font-medium",d),children:"Assignee"}):null,c("dependencies")?r.jsx("th",{className:we("font-medium",d),children:"Dependencies"}):null,c("created")?r.jsx("th",{className:we("font-medium",d),children:"Created"}):null,c("updated")?r.jsx("th",{className:we("font-medium",d),children:"Updated"}):null]})}),r.jsx("tbody",{children:u.map(h=>{const g=x5(h),y=`${h.projectSlug??"standalone"}:${h.id}`;return r.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[c("title")?r.jsxs("td",{className:d,children:[r.jsx(Ee,{to:g,className:"font-semibold text-foreground hover:text-primary",children:h.title}),h.projectTitle?r.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:h.projectTitle}):null]}):null,c("status")?r.jsx("td",{className:d,children:r.jsx(bn,{status:h.status,className:"max-w-[150px]"})}):null,c("priority")?r.jsx("td",{className:we("capitalize text-muted-foreground",d),children:h.priority}):null,c("assignee")?r.jsx("td",{className:we("text-muted-foreground",d),children:h.assignee??"Unassigned"}):null,c("dependencies")?r.jsx("td",{className:we("text-muted-foreground",d),children:h.dependsOn.length}):null,c("created")?r.jsx("td",{className:we("text-muted-foreground",d),children:zn(h.created)}):null,c("updated")?r.jsx("td",{className:we("text-muted-foreground",d),children:zn(h.updated)}):null]},y)})})]})})}function JN({view:e,compact:t,emptyDescription:n}){const{data:s,loading:o,error:i}=Cf(),c=ha(),u=p.useMemo(()=>c.order.map(h=>({id:h,title:Bc(c,h),description:np(h)})),[c]),d=p.useMemo(()=>qN(c.factDeclarations),[c.factDeclarations]),m=p.useMemo(()=>{if(!s)return[];const h=e.config.filters.query??sc(e.config.filters);let g=null;h.trim()!==""&&(g=Vx(h,d).query);const y=WN(s.assignments,g,{workspace:e.workspace});return Uc(y,e.config.sortField,e.config.sortDirection)},[s,e,d]);if(o&&!s)return r.jsx(xt,{label:"Loading assignments…"});if(i)return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load assignments"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i})]});if(m.length===0)return r.jsx(Et,{title:"No assignments match this view.",description:n??"Adjust the view's filters to surface different work."});switch(e.config.viewMode){case"kanban":return r.jsx(tp,{compact:t,dragDisabled:!0,columns:u,items:m,getItemId:h=>h.slug||h.id,getColumnId:h=>h.status,hiddenColumnIds:e.config.kanbanColumnVisibility.hidden,renderCard:h=>t?r.jsx(b5,{item:h}):r.jsx(v5,{item:h})});case"list":return r.jsx(g5,{items:m,statusOrder:c.order,sortField:e.config.sortField,sortDirection:e.config.sortDirection,listSectionVisibility:e.config.listSectionVisibility,compact:t});case"table":return r.jsx(y5,{items:m,sortField:e.config.sortField,sortDirection:e.config.sortDirection,tableColumnVisibility:e.config.tableColumnVisibility,compact:t})}}function b5({item:e}){const t=jc(e);return r.jsxs("div",{className:we("rounded-md border border-border/60 bg-background/85 p-2 shadow-sm"),children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),r.jsx(bn,{status:e.status,className:"max-w-[150px]"})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",children:[r.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),r.jsx("span",{className:"shrink-0",children:zn(e.updated)})]}),e.id?r.jsxs("p",{className:"mt-1 inline-flex items-center gap-1 font-mono text-[10px] text-muted-foreground/70",children:[e.id.slice(0,8),r.jsx(Br,{value:e.id})]}):null]})}function v5({item:e}){const t=jc(e);return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),r.jsx(bn,{status:e.status,className:"max-w-[150px]"})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[r.jsx(ga,{type:e.type,compact:!0}),r.jsx("span",{className:"text-xs capitalize text-muted-foreground",children:e.priority})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),r.jsx("span",{className:"shrink-0",children:zn(e.updated)})]})]})}function w5({viewId:e,onPickAnother:t}){const{view:n,loading:s,error:o,refetch:i}=So(e);return s?r.jsx(xt,{label:"Loading view…"}):o?r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load view"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o.message}),r.jsx("button",{type:"button",onClick:()=>i(),className:"shell-action mt-3",children:"Retry"})]}):n?r.jsx(JN,{view:n,compact:!0,emptyDescription:"Adjust the view's filters to surface different work, or pick another widget for this slot."}):r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"View no longer exists"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"The saved view this slot was bound to has been deleted."}),r.jsx("button",{type:"button",onClick:t,className:"shell-action mt-3",children:"Pick another widget"})]})}function XN({sessions:e}){return r.jsxs("aside",{"aria-labelledby":"overview-sessions-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsx("header",{className:"border-b border-border/40 px-4 py-3",children:r.jsx("h3",{id:"overview-sessions-title",className:"text-sm font-semibold text-foreground",children:"Recent Sessions"})}),e.length===0?r.jsxs("div",{className:"px-4 py-6 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:aa.recentSessionsEmptyTitle}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:aa.recentSessionsEmptyHint})]}):r.jsx("ul",{className:"divide-y divide-border/40",children:e.map(t=>r.jsx("li",{children:r.jsx(j5,{session:t})},t.sessionId))})]})}function j5({session:e}){const t=fn(),[n,s]=p.useState(!1),o=k5(e,t),i=S5(e),c=!e.path;return r.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:o,className:"block text-sm font-medium text-foreground hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:e.agent}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[i," · ",Wk(e.started)]}),n&&e.path?r.jsxs("div",{className:"mt-1 space-y-0.5",children:[r.jsx("code",{className:"block w-full select-all rounded bg-muted/40 px-1.5 py-0.5 text-xs text-foreground",children:e.path}),r.jsx("p",{className:"text-[10px] text-muted-foreground",children:aa.recentSessionsCopyFallbackHint})]}):null]}),r.jsx(Br,{value:e.path,label:aa.recentSessionsCopyPathLabel,disabled:c,disabledReason:aa.recentSessionsCopyPathDisabled,onError:()=>s(!0)})]})}function k5(e,t){return e.projectSlug&&e.assignmentSlug?`${t}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`:(!e.projectSlug&&e.assignmentSlug,"/agent-sessions")}function S5(e){return e.assignmentSlug&&e.projectSlug?`${e.projectSlug}/${e.assignmentSlug}`:e.assignmentSlug?`standalone/${e.assignmentSlug}`:"standalone"}const N5={last_24h:1440*60*1e3,last_7d:10080*60*1e3,last_30d:720*60*60*1e3,last_90d:2160*60*60*1e3,older_7d:10080*60*1e3,older_30d:720*60*60*1e3};function ta(e){if(!e)return 0;const t=Date.parse(e);return Number.isNaN(t)?0:t}function C5(e,t,n=Date.now()){const s=ta(e);if(t.preset){const c=N5[t.preset];return c?t.preset.startsWith("older_")?s<n-c:s>=n-c:!0}const o=t.from?Date.parse(`${t.from}T00:00:00.000Z`):null,i=t.to?Date.parse(`${t.to}T23:59:59.999Z`):null;return!(o!==null&&Number.isFinite(o)&&s<o||i!==null&&Number.isFinite(i)&&s>i)}function E5(e,t,n=Date.now()){const{dateRange:s,project:o,agent:i,sessionStatus:c}=t,u=new Set(o??[]),d=new Set(i??[]),m=new Set(c??[]);return e.filter(h=>{if(s&&!C5(h.started,s,n))return!1;if(u.size>0){const g=h.projectSlug??"__standalone__";if(!u.has(g))return!1}if(d.size>0&&!Array.from(d).some(y=>y.toLowerCase()===h.agent.toLowerCase()))return!1;if(m.size>0){let g=!1;for(const y of m){switch(y){case"active":h.status==="active"&&(g=!0);break;case"ended":(h.status==="completed"||h.status==="stopped")&&(g=!0);break;case"tracked":g=!0;break}if(g)break}if(!g)return!1}return!0})}function T5(e,t,n){return[...e].sort((o,i)=>{let c=0;switch(t){case"started":c=ta(o.started)-ta(i.started);break;case"lastActivity":c=ta(o.updatedAt)-ta(i.updatedAt);break;case"projectName":{const u=o.projectSlug??"",d=i.projectSlug??"";c=u.localeCompare(d);break}case"agentName":c=o.agent.localeCompare(i.agent);break;default:c=ta(o.started)-ta(i.started);break}return n==="asc"?c:-c})}function R5(e,t){return t==null||Number.isNaN(t)||t<=0?e:e.slice(0,t)}function A5({view:e,emptyDescription:t}){const{data:n,loading:s,error:o}=Ef(),i=p.useMemo(()=>{if(!n)return[];const c=n.sessions??[],{config:u}=e,d=u.filters,m={dateRange:d.dateRange?{...d.dateRange,field:"started"}:void 0,project:ze(d.project),agent:ze(d.agent),sessionStatus:ze(d.sessionStatus),limit:u.limit};let h=E5(c,m);return h=T5(h,u.sortField,u.sortDirection),h=R5(h,u.limit),h},[n,e]);return s&&!n?r.jsx(xt,{label:"Loading sessions…"}):o?r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load sessions"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o})]}):i.length===0?r.jsx(Et,{title:"No sessions match this view.",description:t??"Adjust the view's filters to surface different sessions."}):r.jsx(XN,{sessions:i})}function P5({activeViewId:e,onSelectView:t,onCreateNew:n}){const{views:s,loading:o}=Mc(),[i,c]=p.useState(!1),u=p.useRef(null),d=p.useMemo(()=>s.filter(g=>g.entityType==="session"),[s]);p.useEffect(()=>{if(!i)return;function g(b){u.current&&!u.current.contains(b.target)&&c(!1)}function y(b){b.key==="Escape"&&c(!1)}return document.addEventListener("mousedown",g),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",y)}},[i]);const m=e?s.find(g=>g.id===e)??null:null,h=o?"Session views…":m?m.name:"Session views";return r.jsxs("div",{className:"relative",ref:u,children:[r.jsxs("button",{type:"button",disabled:o,onClick:()=>c(g=>!g),className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background disabled:opacity-50","aria-haspopup":"true","aria-expanded":i,title:"Session views",children:[r.jsx("span",{className:"max-w-[160px] truncate",children:h}),r.jsx(pr,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),i&&r.jsxs("div",{className:"absolute right-0 top-full z-30 mt-1 min-w-[240px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:[r.jsxs("button",{type:"button",onClick:()=>{c(!1),t(null)},className:we("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",!e&&"font-semibold text-foreground"),children:[r.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:e?null:r.jsx(Rr,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),r.jsx("span",{children:"All sessions"})]}),d.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"my-1 border-t border-border/40"}),d.map(g=>{const y=g.id===e;return r.jsxs("button",{type:"button",onClick:()=>{c(!1),t(g.id)},className:we("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",y&&"font-semibold text-foreground"),children:[r.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:y?r.jsx(Rr,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null}),r.jsx("span",{className:"truncate",children:g.name})]},g.id)})]}),r.jsx("div",{className:"my-1 border-t border-border/40"}),r.jsxs("button",{type:"button",onClick:()=>{c(!1),n()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5 text-muted-foreground",children:[r.jsx(Lt,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),r.jsx("span",{children:"Create new view…"})]})]})]})}const D5={__unassigned__:"Unassigned",__standalone__:"No project"};function yn({options:e,value:t,onChange:n,allLabel:s="Any",className:o,disabled:i,ariaLabel:c}){const[u,d]=p.useState(!1),m=p.useRef(null),h=p.useRef(null),g=p.useRef([]),y=p.useMemo(()=>{const E=new Set(e.map(T=>T.value)),S=t.filter(T=>!E.has(T)).map(T=>({value:T,label:D5[T]??T}));return[...e,...S]},[e,t]),b=p.useMemo(()=>new Set(t),[t]);p.useEffect(()=>{if(!u)return;function E(S){m.current&&!m.current.contains(S.target)&&d(!1)}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[u]),p.useEffect(()=>{var E;u&&((E=g.current[0])==null||E.focus())},[u]);const C=p.useMemo(()=>{if(t.length===0)return s;if(t.length===1){const E=y.find(S=>S.value===t[0]);return E?E.label:t[0]}return`${t.length} selected`},[t,y,s]);function j(E){n(b.has(E)?t.filter(S=>S!==E):[...t,E])}function v(E){var T;const S=Math.max(0,Math.min(E,y.length-1));(T=g.current[S])==null||T.focus()}function k(E){var R;const S=g.current,T=document.activeElement,P=S.findIndex(A=>A===T);E.key==="ArrowDown"?(E.preventDefault(),v(P<0?0:P+1)):E.key==="ArrowUp"?(E.preventDefault(),v(P<0?y.length-1:P-1)):E.key==="Home"?(E.preventDefault(),v(0)):E.key==="End"?(E.preventDefault(),v(y.length-1)):E.key==="Escape"&&(E.preventDefault(),d(!1),(R=h.current)==null||R.focus())}return r.jsxs("div",{className:"relative",ref:m,children:[r.jsxs("button",{type:"button",ref:h,disabled:i,"aria-haspopup":"menu","aria-expanded":u,"aria-label":c,onClick:()=>d(E=>!E),onKeyDown:E=>{!u&&(E.key==="ArrowDown"||E.key==="ArrowUp")&&(E.preventDefault(),d(!0))},className:we("editor-input inline-flex items-center justify-between gap-1.5 text-left",t.length>0&&"border-foreground/40 text-foreground",o),children:[r.jsx("span",{className:"truncate",children:C}),r.jsx(pr,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),u?r.jsxs("div",{role:"menu","aria-label":c,onKeyDown:k,className:"absolute left-0 top-full z-30 mt-1 max-h-72 min-w-[200px] overflow-auto rounded-md border border-border/70 bg-background py-1 shadow-lg",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pb-1",children:[r.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===y.length,onClick:()=>n(y.map(E=>E.value)),children:"Select all"}),r.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===0,onClick:()=>n([]),children:"Clear"})]}),y.length===0?r.jsx("p",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"No options"}):y.map((E,S)=>{const T=b.has(E.value);return r.jsxs("button",{ref:P=>{g.current[S]=P},type:"button",role:"menuitemcheckbox","aria-checked":T,tabIndex:-1,onClick:()=>j(E.value),className:we("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",T?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{className:we("flex h-4 w-4 shrink-0 items-center justify-center rounded border",T?"border-foreground bg-foreground text-background":"border-border/70"),"aria-hidden":"true",children:T?r.jsx(Rr,{className:"h-3 w-3"}):null}),r.jsx("span",{className:"truncate",children:E.label})]},E.value)})]}):null]})}const jj={last_24h:"Last 24 hours",last_7d:"Last 7 days",last_30d:"Last 30 days",last_90d:"Last 90 days",older_7d:"Older than 7 days",older_30d:"Older than 30 days"},$5=["updated","created"];function sp({value:e,onChange:t,className:n,ariaLabel:s="Date range filter"}){const[o,i]=p.useState(!1),c=p.useRef(null),u=(e==null?void 0:e.field)??"updated",d=!!(e&&!e.preset&&(e.from||e.to)),[m,h]=p.useState(d);p.useEffect(()=>h(d),[d]),p.useEffect(()=>{if(!o)return;function k(S){c.current&&!c.current.contains(S.target)&&i(!1)}function E(S){S.key==="Escape"&&i(!1)}return document.addEventListener("mousedown",k),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",E)}},[o]);const g=!!(e&&(e.preset||e.from||e.to)),y=p.useMemo(()=>!g||!e?"Any date":e.preset?`${u}: ${jj[e.preset]??e.preset}`:`${u}: ${e.from||"…"} → ${e.to||"…"}`,[g,e,u]);function b(k){t(e?{...e,field:k}:{field:k,preset:"",from:"",to:""})}function C(k){h(!1),t({field:u,preset:k,from:"",to:""})}function j(){h(!1),t(null)}function v(k,E){const S={field:u,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""};t({...S,[k]:E})}return r.jsxs("div",{className:"relative",ref:c,children:[r.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":o,"aria-label":s,onClick:()=>i(k=>!k),className:we("editor-input inline-flex items-center justify-between gap-1.5 text-left",g&&"border-foreground/40 text-foreground",n),children:[r.jsx("span",{className:"truncate",children:y}),r.jsx(pr,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),o?r.jsxs("div",{className:"absolute left-0 top-full z-30 mt-1 w-64 rounded-md border border-border/70 bg-background p-2 shadow-lg",children:[r.jsx("div",{className:"mb-2 inline-flex rounded-md border border-border/60 bg-background/80 p-0.5",children:$5.map(k=>r.jsx("button",{type:"button","aria-pressed":u===k,onClick:()=>b(k),className:we("rounded-sm px-2.5 py-1 text-xs font-medium capitalize transition",u===k?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:k},k))}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Dh,{label:"Any date",selected:!g,onClick:j}),wO.map(k=>r.jsx(Dh,{label:jj[k],selected:(e==null?void 0:e.preset)===k,onClick:()=>C(k)},k)),r.jsx(Dh,{label:"Custom range…",selected:m,onClick:()=>{h(!0),t({field:u,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""})}})]}),m?r.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-border/60 pt-2",children:[r.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["From",r.jsx("input",{type:"date",value:(e==null?void 0:e.from)??"",max:(e==null?void 0:e.to)||void 0,onChange:k=>v("from",k.target.value),className:"editor-input w-40"})]}),r.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["To",r.jsx("input",{type:"date",value:(e==null?void 0:e.to)??"",min:(e==null?void 0:e.from)||void 0,onChange:k=>v("to",k.target.value),className:"editor-input w-40"})]})]}):null]}):null]})}function Dh({label:e,selected:t,onClick:n}){return r.jsxs("button",{type:"button",onClick:n,className:we("flex w-full items-center justify-between gap-2 rounded px-2 py-1.5 text-left text-sm transition hover:bg-foreground/5",t?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{children:e}),t?r.jsx(Rr,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}):null]})}const L5=new Set(["status","type","priority","assignee","project","tags","activity","dateRange","search","query","sessionStatus","agent"]);function O5(e,t){const n={};for(const[s,o]of Object.entries(e))L5.has(s)||(n[s]=o);return{...n,...t}}function lf(e,t,n){return{...e,viewMode:t.viewMode,filters:O5(e.filters,t.filters),sortField:t.sortField,sortDirection:t.sortDirection,limit:t.limit,listSectionVisibility:{collapsed:[...n.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...n.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...n.tableColumnVisibility.hidden]}}}function I5(e,t){var y,b;const n={},s=ze(e.status);s.length&&(n.status=s);const o=ze(e.type);o.length&&(n.type=o);const i=ze(e.priority);i.length&&(n.priority=i);const c=ze(e.assignee);c.length&&(n.assignee=c);const u=ze(e.tags);if(u.length&&(n.tags=u),t&&t!=="all")n.project=[t];else{const C=ze(e.project);C.length&&(n.project=C)}e.activity&&e.activity!=="all"&&(n.activity=e.activity);const d=ze(e.sessionStatus);d.length&&(n.sessionStatus=d);const m=ze(e.agent);m.length&&(n.agent=m),e.dateRange&&(n.dateRange=e.dateRange);const h=(y=e.search)==null?void 0:y.trim();h&&(n.search=h);const g=(b=e.query)==null?void 0:b.trim();return g&&(n.query=g),n}function Oi(e){const t={viewMode:e.state.viewMode,filters:I5(e.state.filters,e.context.projectSlug),sortField:e.state.sortField,sortDirection:e.state.sortDirection,listSectionVisibility:{collapsed:[...e.state.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...e.state.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...e.state.tableColumnVisibility.hidden]}};return{name:e.name.trim(),workspace:e.context.workspace,config:t}}const ti={viewMode:"kanban",sortField:"updated",sortDirection:"desc"},md={sortField:"started",sortDirection:"desc"};function ZN(e,t){const{config:n}=Oi({name:"",context:{workspace:t,projectSlug:null},state:{viewMode:e.viewMode,filters:e.filters,sortField:e.sortField,sortDirection:e.sortDirection,listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}}}),s={...n};return e.limit!==void 0&&e.limit>0&&(s.limit=e.limit),{workspace:t,config:s}}function oy(e,t){const{config:n}=Oi({name:"",context:{workspace:t,projectSlug:null},state:{viewMode:"list",filters:e.filters,sortField:e.sortField,sortDirection:e.sortDirection,listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}}}),s={...n};return e.limit!==void 0&&e.limit>0&&(s.limit=e.limit),{workspace:t,config:s}}function la(e){if(!e)return;if(e.preset)return{field:e.field,preset:e.preset};const t=e.from&&e.from.length>0?e.from:void 0,n=e.to&&e.to.length>0?e.to:void 0;if(!t&&!n)return;const s={field:e.field};return t&&(s.from=t),n&&(s.to=n),s}function op(e){return e?{field:e.field,preset:e.preset??"",from:e.from??"",to:e.to??""}:null}function eC(e,t){var s,o,i,c,u,d,m,h,g,y,b,C,j,v,k;const{config:n}=e;if((s=t.setViewMode)==null||s.call(t,n.viewMode),(o=t.setStatusFilter)==null||o.call(t,ze(n.filters.status)),(i=t.setTypeFilter)==null||i.call(t,ze(n.filters.type)),(c=t.setPriorityFilter)==null||c.call(t,ze(n.filters.priority)),(u=t.setAssigneeFilter)==null||u.call(t,ze(n.filters.assignee)),(d=t.setProjectFilter)==null||d.call(t,ze(n.filters.project)),(m=t.setTagsFilter)==null||m.call(t,ze(n.filters.tags)),(h=t.setDateRange)==null||h.call(t,op(n.filters.dateRange)),(g=t.setSearch)==null||g.call(t,n.filters.search??""),(y=t.setQuery)==null||y.call(t,n.filters.query??sc(n.filters)),t.setActivityFilter){const E=n.filters.activity??"all";t.setActivityFilter(E==="fresh"||E==="stale"?E:"all")}(b=t.setSortField)==null||b.call(t,n.sortField),(C=t.setSortDirection)==null||C.call(t,n.sortDirection),(j=t.setListSectionVisibility)==null||j.call(t,{collapsed:[...n.listSectionVisibility.collapsed]}),(v=t.setKanbanColumnVisibility)==null||v.call(t,{hidden:[...n.kanbanColumnVisibility.hidden]}),(k=t.setTableColumnVisibility)==null||k.call(t,{hidden:[...n.tableColumnVisibility.hidden]})}function Id(e){return e?`/w/${e}/views`:"/views"}function tC(e){return`${Id(e.workspace)}/${encodeURIComponent(e.id)}`}function nC(e){const t=e.workspace?`/w/${e.workspace}`:"",n=ze(e.config.filters.project);return n.length===1&&n[0]!=="__standalone__"&&sN(e.config,n[0])?`${t}/projects/${n[0]}?tab=assignments&loadView=${encodeURIComponent(e.id)}`:`${t}/assignments?loadView=${encodeURIComponent(e.id)}`}const _5=["critical","high","medium","low"],M5={last_24h:"last 24 hours",last_7d:"last 7 days",last_30d:"last 30 days",last_90d:"last 90 days",older_7d:"older than 7 days",older_30d:"older than 30 days"};function F5(e){if(e.preset)return`${e.field} ${M5[e.preset]??e.preset}`;const t=e.from??"…",n=e.to??"…";return`${e.field} ${t}→${n}`}function rC(e){var o,i;const t=(o=e.query)==null?void 0:o.trim();if(t&&oc(t)===null)return`query: ${t}`;const n=[];for(const c of["status","priority","type","assignee","project","tags"]){const u=ze(e[c]);u.length&&n.push(`${c}=${u.join(", ")}`)}e.activity&&e.activity!=="all"&&n.push(`activity=${e.activity}`),e.dateRange&&n.push(F5(e.dateRange));const s=(i=e.search)==null?void 0:i.trim();return s&&n.push(`search="${s}"`),n.join(" · ")||"no filters"}const kj=80,z5=["started","lastActivity","projectName","agentName"],B5={started:"Start time",lastActivity:"Last updated",projectName:"Project",agentName:"Agent"},U5=[{value:"active",label:"Active"},{value:"ended",label:"Ended"},{value:"tracked",label:"Tracked"},{value:"untracked",label:"Untracked"}];function sC({open:e,onOpenChange:t,initialView:n,onSubmit:s}){const o=!!n,{data:i}=Cs(),{data:c}=Ef(),[u,d]=p.useState(""),[m,h]=p.useState([]),[g,y]=p.useState([]),[b,C]=p.useState([]),[j,v]=p.useState(null),[k,E]=p.useState(md.sortField),[S,T]=p.useState(md.sortDirection),[P,R]=p.useState(""),[A,$]=p.useState(!1),[M,_]=p.useState(null);function D(){h([]),y([]),C([]),v(null),E(md.sortField),T(md.sortDirection),R("")}p.useEffect(()=>{if(e)if(_(null),$(!1),n){const z=n.config.filters;d(n.name),h(ze(z.project)),y(ze(z.agent)),C(ze(z.sessionStatus)),v(op(z.dateRange)),E(n.config.sortField),T(n.config.sortDirection),R(n.config.limit!==void 0?String(n.config.limit):"")}else d(""),D()},[e,n]);const V=p.useMemo(()=>[{value:"__standalone__",label:"No project"},...(i??[]).map(G=>({value:G.slug,label:G.title}))],[i]),K=p.useMemo(()=>{const z=new Set;for(const G of(c==null?void 0:c.sessions)??[])G.agent&&z.add(G.agent);return Array.from(z).sort().map(G=>({value:G,label:G}))},[c]),I=u.trim(),F=I.length>0&&I.length<=kj,q=P.trim()===""?void 0:parseInt(P.trim(),10),Z=P.trim()===""||Number.isFinite(q)&&q!==void 0&&q>0&&q<=500;return r.jsx(On,{open:e,onOpenChange:t,children:r.jsx(Rn,{className:"max-w-lg",children:r.jsxs("form",{className:"space-y-4",onSubmit:async z=>{if(z.preventDefault(),!F||!Z||A)return;$(!0),_(null);const G=la(j),L=G?{...G,field:"started"}:void 0,H={filters:{project:m,agent:g,sessionStatus:b,dateRange:L},sortField:k,sortDirection:S,limit:q};try{await s(I,H)}catch(re){_(re instanceof Error?re.message:String(re)),$(!1)}},children:[r.jsx(Zn,{children:r.jsx(An,{children:o?"Edit session view":"Create session view"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:"create-session-view-name",children:"Name"}),r.jsx("input",{id:"create-session-view-name",type:"text",value:u,autoFocus:!0,required:!0,maxLength:kj,onChange:z=>d(z.target.value),placeholder:"View name",className:"w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[r.jsx(ni,{label:"Date range (session start)",children:r.jsx(sp,{className:"w-full",value:j,onChange:v})}),r.jsx(ni,{label:"Project",children:r.jsx(yn,{ariaLabel:"Project filter",className:"w-full",allLabel:"All projects",options:V,value:m,onChange:h})}),r.jsx(ni,{label:"Agent",children:r.jsx(yn,{ariaLabel:"Agent filter",className:"w-full",allLabel:"All agents",options:K,value:g,onChange:y})}),r.jsx(ni,{label:"Session status",children:r.jsx(yn,{ariaLabel:"Session status filter",className:"w-full",allLabel:"All statuses",options:U5,value:b,onChange:C})}),r.jsx(ni,{label:"Sort by",className:"sm:col-span-2",children:r.jsxs("div",{className:"flex gap-2",children:[r.jsx("select",{value:k,onChange:z=>E(z.target.value),className:"editor-input w-full",children:z5.map(z=>r.jsx("option",{value:z,children:B5[z]??z},z))}),r.jsx("button",{type:"button",onClick:()=>T(z=>z==="asc"?"desc":"asc"),className:"shell-action shrink-0",title:S==="asc"?"Ascending":"Descending",children:S==="asc"?"Asc":"Desc"})]})}),r.jsxs(ni,{label:"Max results",className:"sm:col-span-2",children:[r.jsx("input",{type:"number",min:1,max:500,value:P,onChange:z=>R(z.target.value),placeholder:"No limit",className:"editor-input w-full"}),Z?null:r.jsx("p",{className:"mt-1 text-xs text-error-foreground",children:"Limit must be between 1 and 500"})]})]}),M?r.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:M}):null,r.jsxs(Ar,{className:"sm:justify-between",children:[r.jsx("button",{type:"button",onClick:D,className:"shell-action",disabled:A,children:"Clear all"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:A,children:"Cancel"}),r.jsx("button",{type:"submit",disabled:!F||!Z||A,className:"shell-action shell-action--cta disabled:opacity-50",children:A?"Saving…":o?"Save changes":"Create view"})]})]})]})})})}function ni({label:e,className:t,children:n}){return r.jsxs("label",{className:`space-y-1 ${t??""}`,children:[r.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:e}),n]})}const V5=4e3;function Ao(){const[e,t]=p.useState(null),n=p.useRef(null),s=p.useCallback(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null),t(null)},[]),o=p.useCallback((i,c="error")=>{n.current!==null&&clearTimeout(n.current),t({id:Date.now()+Math.random(),message:i,kind:c}),n.current=setTimeout(()=>{t(null),n.current=null},V5)},[]);return p.useEffect(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),{toast:e,showToast:o,dismissToast:s}}function xa({toast:e,onDismiss:t}){if(!e)return null;const n=e.kind==="error";return r.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex max-w-sm",role:"status","aria-live":"polite",children:r.jsx("button",{type:"button",onClick:t,className:we("syntaur-toast pointer-events-auto rounded-md border px-4 py-3 text-sm font-medium shadow-lg transition",n?"border-error-foreground/30 bg-error text-error-foreground hover:opacity-90":"border-success-foreground/30 bg-success text-success-foreground hover:opacity-90"),children:e.message},e.id)})}function $h({title:e,message:t,onPickAnother:n}){return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:e}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t}),n?r.jsx("button",{type:"button",onClick:n,className:"shell-action mt-3",children:"Pick another widget"}):null]})}function H5({viewId:e,slotId:t,onPickAnother:n}){const{data:s,loading:o,error:i}=Ef(),{view:c,loading:u,ready:d}=So(e??null),{layout:m}=dN(),{showToast:h}=Ao(),[g,y]=p.useState(!1),b=p.useCallback(async v=>{if(!t)return;const k=m.slots.map(E=>E.id===t?{...E,widget:v?{kind:"agent-sessions",viewId:v}:{kind:"agent-sessions"}}:E);try{await Sg(k)}catch(E){h(E instanceof Error?E.message:"Failed to update widget")}},[m,t,h]);async function C(v,k){const{workspace:E,config:S}=oy(k,null);try{const P=(await Pi({name:v,workspace:E,config:S,entityType:"session"})).views.find(R=>R.name===v&&R.entityType==="session");P&&await b(P.id),y(!1),h(`Created session view "${v}"`)}catch(T){throw h(T instanceof Error?T.message:"Failed to create session view"),T}}let j;return e?u&&!d?j=r.jsx(xt,{label:"Loading view…"}):c?c.entityType!=="session"?j=r.jsx($h,{title:"Wrong view type",message:"This widget is bound to an assignment view. Choose a session view above, or pick a different widget.",onPickAnother:n}):j=r.jsx(A5,{view:c,emptyDescription:"Adjust the view's filters to surface different sessions, or pick another widget for this slot."}):j=r.jsx($h,{title:"View no longer exists",message:"The saved view this widget was bound to has been deleted. Pick another session view above, or choose a different widget.",onPickAnother:n}):o&&!s?j=r.jsx(xt,{label:"Loading sessions…"}):i?j=r.jsx($h,{title:"Couldn't load sessions",message:i}):j=r.jsx(XN,{sessions:(s==null?void 0:s.sessions)??[]}),r.jsxs("div",{className:"space-y-2",children:[t?r.jsx("div",{className:"flex items-center justify-between gap-2",children:r.jsx(P5,{activeViewId:e??null,onSelectView:v=>void b(v),onCreateNew:()=>y(!0)})}):null,j,r.jsx(sC,{open:g,onOpenChange:y,workspace:null,onSubmit:C})]})}const W5=5;function K5(){const{data:e,loading:t,error:n}=cS();if(t&&!e)return r.jsx(xt,{label:"Loading inventories…"});if(n)return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load inventories"}),r.jsx("p",{className:"mt-1 text-xs",children:n})]});const o=((e==null?void 0:e.inventories)??[]).slice(0,W5);return r.jsxs("aside",{"aria-labelledby":"overview-inventories-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsxs("header",{className:"flex items-center justify-between border-b border-border/40 px-4 py-3",children:[r.jsx("h3",{id:"overview-inventories-title",className:"text-sm font-semibold text-foreground",children:"Inventories"}),r.jsx(Ee,{to:"/inventories",className:"text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),o.length===0?r.jsxs("div",{className:"px-4 py-6 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"No inventories yet."}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:"Create one to track leased resources across agents."})]}):r.jsx("ul",{className:"divide-y divide-border/40",children:o.map(i=>{const c=i.inventory,u=i.active_leases.length,d=i.members.length,m=c.display_name??c.slug;return r.jsx("li",{children:r.jsxs(Ee,{to:`/inventories/${encodeURIComponent(c.slug)}`,className:"flex items-center gap-3 px-4 py-2.5 text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:m}),r.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[u,"/",d," leased"]})]})},c.slug)})})]})}function q5(e){let t=0,n=0;for(const s of e.daily)t+=s.total_tokens,n+=s.total_cost;return{tokens:t,cost:n}}function Sj({filters:e,metric:t}){const n=e??{},{data:s,loading:o,error:i}=S3(n),c=t==="cost"?"Spend":"Token Usage",u=`/usage?${pg(n).toString()}`;let d;if(o&&!s)d=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"});else if(i&&!s)d=r.jsxs("div",{className:"text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load usage"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i})]});else if(!s||s.daily.length===0)d=r.jsx("p",{className:"text-sm text-muted-foreground",children:"No usage for these filters."});else{const{tokens:m,cost:h}=q5(s),g=t==="cost"?{label:"Total spend",value:Ai(h)}:{label:"Total tokens",value:Ri(m)},y=t==="cost"?{label:"Tokens",value:Ri(m)}:{label:"Spend",value:Ai(h)};d=r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(Nj,{label:g.label,value:g.value,emphasize:!0}),r.jsx(Nj,{label:y.label,value:y.value})]})}return r.jsxs("aside",{className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-border/40 px-4 py-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("h3",{className:"text-sm font-semibold text-foreground",children:c}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",title:Nw(n),children:Nw(n)})]}),r.jsx(Ee,{to:u,className:"shrink-0 text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),r.jsx("div",{className:"px-4 py-4",children:d})]})}function Nj({label:e,value:t,emphasize:n}){return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e}),r.jsx("p",{className:n?"text-2xl font-semibold tabular-nums text-foreground":"text-lg font-semibold tabular-nums text-foreground",children:t})]})}const G5={"7d":"7 days","30d":"30 days","90d":"90 days",all:"All time",custom:"Custom"};function Y5(e){return e.kind==="token-usage"||e.kind==="spend"?e.filters??{}:{}}const ri="bg-background border border-border rounded px-2 py-1 text-sm text-foreground";function Cj({config:e,open:t,onSave:n,onCancel:s}){const o=e.kind==="spend"?"Configure Spend":"Configure Token Usage",{data:i}=Cs(),{data:c}=fa(),{data:u}=uS(t),[d,m]=p.useState("30d"),[h,g]=p.useState(""),[y,b]=p.useState(""),[C,j]=p.useState(""),[v,k]=p.useState(""),[E,S]=p.useState(""),[T,P]=p.useState(""),[R,A]=p.useState(!1),[$,M]=p.useState(null);p.useEffect(()=>{if(!t)return;const F=Y5(e);m(F.window??"30d"),g(F.since??""),b(F.until??""),j(F.project??""),k(F.workspace??""),S(F.model??""),P(F.tool??""),A(!1),M(null)},[t,e]);function _(){return Dc({window:d,since:d==="custom"?h:void 0,until:d==="custom"?y:void 0,project:C||void 0,workspace:v||void 0,model:E||void 0,tool:T||void 0})}async function D(F){if(F.preventDefault(),R)return;const q=_(),Z=p3(q);if(!Z.ok){M(Z.errors.join("; "));return}A(!0),M(null);const z=e.kind==="token-usage"?{kind:"token-usage",filters:q}:e.kind==="spend"?{kind:"spend",filters:q}:e;try{await n(z)}catch(G){M(G instanceof Error?G.message:String(G)),A(!1)}}const V=(i==null?void 0:i.map(F=>F.slug))??[],K=(c==null?void 0:c.workspaces)??[],I=(c==null?void 0:c.hasUngrouped)??!1;return r.jsx(On,{open:t,onOpenChange:F=>{F||s()},children:r.jsx(Rn,{className:"max-w-md",children:r.jsxs("form",{onSubmit:D,children:[r.jsx(Zn,{children:r.jsx(An,{children:o})}),r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Window"}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:Nf.map(F=>r.jsx("button",{type:"button",onClick:()=>m(F),className:"rounded px-2.5 py-1 text-sm border "+(F===d?"border-primary bg-primary/10 text-foreground":"border-border text-muted-foreground hover:text-foreground"),children:G5[F]},F))})]}),d==="custom"?r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Since"}),r.jsx("input",{type:"date",value:h,onChange:F=>g(F.target.value),className:ri})]}),r.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Until"}),r.jsx("input",{type:"date",value:y,onChange:F=>b(F.target.value),className:ri})]})]}):null,r.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Workspace"}),r.jsxs("select",{value:v,onChange:F=>{k(F.target.value),F.target.value&&j("")},className:ri,children:[r.jsx("option",{value:"",children:"All workspaces"}),I?r.jsx("option",{value:"_ungrouped",children:"(ungrouped)"}):null,K.map(F=>r.jsx("option",{value:F,children:F},F))]})]}),r.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Project"}),r.jsxs("select",{value:C,onChange:F=>{j(F.target.value),F.target.value&&k("")},className:ri,children:[r.jsx("option",{value:"",children:"All projects"}),V.map(F=>r.jsx("option",{value:F,children:F},F))]})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Model"}),r.jsxs("select",{value:E,onChange:F=>S(F.target.value),className:ri,children:[r.jsx("option",{value:"",children:"All models"}),((u==null?void 0:u.models)??[]).map(F=>r.jsx("option",{value:F,children:F},F))]})]}),r.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Tool"}),r.jsxs("select",{value:T,onChange:F=>P(F.target.value),className:ri,children:[r.jsx("option",{value:"",children:"All tools"}),((u==null?void 0:u.tools)??[]).map(F=>r.jsx("option",{value:F,children:F},F))]})]})]}),$?r.jsx("p",{className:"text-xs text-destructive",role:"alert",children:$}):null]}),r.jsxs(Ar,{className:"sm:justify-between",children:[r.jsx("button",{type:"button",onClick:s,disabled:R,className:"shell-action",children:"Cancel"}),r.jsx("button",{type:"submit",disabled:R,className:"shell-action shell-action--cta",children:R?"Saving…":"Save"})]})]})})})}const ay={"saved-view":{title:"Saved view",icon:$k,render:(e,t)=>e.kind!=="saved-view"?null:p.createElement(w5,{viewId:e.viewId,onPickAnother:t.onPickAnother})},"agent-sessions":{title:"Agent sessions",icon:vf,render:(e,t)=>e.kind!=="agent-sessions"?null:p.createElement(H5,{viewId:e.viewId,slotId:t.slotId,onPickAnother:t.onPickAnother})},inventories:{title:"Inventories",icon:kf,render:()=>p.createElement(K5)},"token-usage":{title:"Token Usage",icon:eP,render:e=>e.kind!=="token-usage"?null:p.createElement(Sj,{filters:e.filters,metric:"tokens"}),ConfigEditor:Cj},spend:{title:"Spend",icon:Rc,render:e=>e.kind!=="spend"?null:p.createElement(Sj,{filters:e.filters,metric:"cost"}),ConfigEditor:Cj}},Q5={small:"min-h-[320px]",wide:"xl:col-span-2 min-h-[320px]",tall:"min-h-[560px]",large:"xl:col-span-2 min-h-[560px]"},oC={small:"Small",wide:"Wide",tall:"Tall",large:"Large"};function J5({slot:e,onReplace:t,onRemove:n,onResize:s,onConfigChange:o}){const[i,c]=p.useState(!1),{attributes:u,listeners:d,setNodeRef:m,setActivatorNodeRef:h,transform:g,transition:y,isDragging:b}=Vf({id:e.id}),C={transform:rs.Translate.toString(g),transition:y,zIndex:b?50:void 0,position:b?"relative":void 0},j=r.jsx("button",{ref:h,...u,...d,type:"button","aria-label":"Drag to reorder widget",className:"touch-none cursor-grab text-muted-foreground/40 transition hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:cursor-grabbing",children:r.jsx(Fi,{className:"h-4 w-4","aria-hidden":"true"})}),v=e.size??"small",k=Q5[v];if(e.widget===null)return r.jsxs("div",{ref:m,style:C,className:we("relative flex items-center justify-center rounded-lg border border-dashed border-border/60 bg-card/40 p-3 shadow-sm",k,b&&"opacity-0"),children:[r.jsx("div",{className:"absolute left-2 top-2",children:j}),r.jsxs("button",{type:"button",onClick:t,className:"shell-action inline-flex items-center gap-2",children:[r.jsx(Lt,{className:"h-4 w-4"}),"Add widget"]})]});const E=ay[e.widget.kind];if(!E)return r.jsx("div",{ref:m,style:C,className:we("overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",k,b&&"opacity-0"),children:r.jsxs("div",{className:"flex items-start gap-2",children:[j,r.jsxs("div",{className:"flex-1 rounded-md border border-border/60 bg-background/60 px-3 py-2 text-sm text-muted-foreground",children:["Unknown widget kind: ",e.widget.kind]})]})});const S=E.icon,T=E.ConfigEditor;return r.jsxs("div",{ref:m,style:C,className:we("overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",k,b&&"opacity-0"),children:[r.jsxs("header",{className:"mb-2 flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[j,r.jsx(S,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.jsx("span",{className:"truncate",children:r.jsx(Z5,{slot:e,fallback:E.title})})]}),r.jsx(ry,{items:[{key:"replace",label:"Replace…",icon:uP,onSelect:t},...E.ConfigEditor?[{key:"configure",label:"Configure…",icon:hP,onSelect:()=>c(!0)}]:[],{key:"size",label:"Size",icon:aP,submenu:nI.map(P=>({key:`size-${P}`,label:oC[P],active:P===v,onSelect:()=>s(P)}))},{key:"remove",label:"Remove",icon:Tn,destructive:!0,onSelect:n}]})]}),r.jsx("div",{children:E.render(e.widget,{slotId:e.id,onPickAnother:t})}),T?r.jsx(T,{config:e.widget,open:i,onSave:async P=>{await o(P),c(!1)},onCancel:()=>c(!1)}):null]})}function X5({slot:e}){const t=e.widget?ay[e.widget.kind]:null,n=t==null?void 0:t.icon,s=e.widget===null?"Empty widget slot":(t==null?void 0:t.title)??`Unknown widget kind: ${e.widget.kind}`,o=oC[e.size??"small"];return r.jsx("div",{"aria-hidden":"true",className:"w-72 rounded-lg border border-border/70 bg-card/95 p-3 shadow-xl ring-1 ring-foreground/10",children:r.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[r.jsx(Fi,{className:"h-4 w-4","aria-hidden":"true"}),n?r.jsx(n,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null,r.jsx("span",{className:"min-w-0 flex-1 truncate",children:s}),r.jsx("span",{className:"text-[10px] tracking-normal text-muted-foreground/70",children:o})]})})}function Z5({slot:e,fallback:t}){var o,i;const n=((o=e.widget)==null?void 0:o.kind)==="saved-view"?e.widget.viewId:null,{view:s}=So(n);return((i=e.widget)==null?void 0:i.kind)==="saved-view"&&s?r.jsx(r.Fragment,{children:s.name}):r.jsx(r.Fragment,{children:t})}const eM=["agent-sessions","inventories","token-usage","spend"];function tM({open:e,onOpenChange:t,onSelect:n}){const{views:s,loading:o}=Mc();function i(c){n(c),t(!1)}return r.jsx(On,{open:e,onOpenChange:t,children:r.jsxs(Rn,{className:"max-w-xl",children:[r.jsxs(Zn,{children:[r.jsx(An,{children:"Add a widget"}),r.jsx(Hr,{children:"Choose a built-in widget, an assignment view, or a session view."})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Built-in widgets"}),r.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:eM.map(c=>{const u=ay[c],d=u.icon;return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>i({kind:c}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx(d,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),r.jsx("span",{className:"font-medium text-foreground",children:u.title})]})},c)})})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Saved views"}),o?r.jsx("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm text-muted-foreground",children:"Loading saved views…"}):s.length===0?r.jsxs("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"No saved views yet"}),r.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Save a view from the assignments page first."," ",r.jsx(Ee,{to:"/views",className:"text-foreground underline hover:opacity-80",children:"Manage views →"})]})]}):r.jsxs("div",{className:"space-y-3",children:[s.some(c=>c.entityType!=="session")&&r.jsxs("div",{children:[r.jsx("h4",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Assignments"}),r.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:s.filter(c=>c.entityType!=="session").map(c=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>i({kind:"saved-view",viewId:c.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:c.name}),c.workspace!==null?r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] text-muted-foreground",title:`Scoped to workspace: ${c.workspace}`,children:c.workspace}):null,r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] capitalize text-muted-foreground",children:c.config.viewMode})]})},c.id))})]}),s.some(c=>c.entityType==="session")&&r.jsxs("div",{children:[r.jsx("h4",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Sessions"}),r.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:s.filter(c=>c.entityType==="session").map(c=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>i({kind:"agent-sessions",viewId:c.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:c.name}),c.workspace!==null?r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] text-muted-foreground",title:`Scoped to workspace: ${c.workspace}`,children:c.workspace}):null]})},c.id))})]})]}),!o&&s.some(c=>c.workspace!==null)?r.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Workspace-scoped views on the global Overview will only show items from that workspace."}):null]})]})})}const nM=(e,{currentCoordinates:t,context:n})=>{var g;const s=e.code==="ArrowRight"||e.code==="ArrowDown"?1:e.code==="ArrowLeft"||e.code==="ArrowUp"?-1:0;if(s===0)return;e.preventDefault();const o=n.over??n.active,i=(g=o==null?void 0:o.data.current)==null?void 0:g.sortable,c=i==null?void 0:i.items;if(!o||!c)return t;const u=c.indexOf(o.id);if(u===-1)return t;const d=c[u+s],m=d===void 0?null:n.droppableRects.get(d),h=n.collisionRect;return!m||!h?t:{x:m.left+(m.width-h.width)/2,y:m.top+(m.height-h.height)/2}};function rM(){const{data:e,error:t,refetch:n}=g3(),{data:s}=aS(),{layout:o}=dN(),[i,c]=p.useState(!1),[u,d]=p.useState(null),[m,h]=p.useState(null),[g,y]=p.useState(o.slots),[b,C]=p.useState(null);p.useEffect(()=>{y(o.slots)},[o.slots]);const j=If(ko(Ki,{activationConstraint:{distance:8}}),ko(Wi,{coordinateGetter:nM}));Ro("list:overview"),Yt({keys:"r",description:"Refresh",scope:"list:overview",handler:()=>{n()}});const v=p.useCallback(_=>{d(_),c(!0)},[]),k=p.useCallback(async(_,D)=>{h(null),y(_);try{await Sg(_)}catch(V){y(D),h(V instanceof Error?V.message:String(V))}},[]),E=p.useCallback(_=>{if(u===null)return;const D=g.map((V,K)=>K===u?{...V,widget:_}:V);d(null),k(D,g)},[g,u,k]),S=p.useCallback(_=>{const D=g.map((V,K)=>K===_?{...V,widget:null}:V);k(D,g)},[g,k]),T=p.useCallback((_,D)=>{const V=g.map((K,I)=>I===_?{...K,size:D}:K);k(V,g)},[g,k]),P=p.useCallback(_=>{const{active:D,over:V}=_;if(C(null),!V||D.id===V.id)return;const K=g.findIndex(q=>q.id===D.id),I=g.findIndex(q=>q.id===V.id);if(K===-1||I===-1)return;const F=qi(g,K,I);k(F,g)},[g,k]),R=p.useCallback(_=>{C(String(_.active.id))},[]),A=g.find(_=>_.id===b)??null,$=p.useCallback(async(_,D)=>{const V=g,K=g.map((I,F)=>F===_?{...I,widget:D}:I);h(null),y(K);try{await Sg(K)}catch(I){y(V);const F=I instanceof Error?I.message:String(I);throw h(F),I instanceof Error?I:new Error(F)}},[g]),M={};if(e)for(const _ of Object.keys(e.segments))for(const D of e.segments[_].items)M[D.id]=D;return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("header",{className:"space-y-2",children:[r.jsx("p",{className:"eyebrow",children:"Workspace Overview"}),r.jsx("h1",{className:"text-4xl font-semibold tracking-display text-foreground md:text-5xl",children:"What needs you today"})]}),e?r.jsx(gO,{hero:e.hero,itemsById:M}):t?r.jsx(Tt,{error:t}):r.jsx(xt,{label:"Loading overview…"}),e!=null&&e.firstRun?r.jsx(mO,{help:s}):null,m?r.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Couldn't save dashboard layout: ",m]}):null,r.jsxs(Bf,{sensors:j,collisionDetection:_f,onDragStart:R,onDragCancel:()=>C(null),onDragEnd:P,children:[r.jsx(Uf,{items:g.map(_=>_.id),strategy:zx,children:r.jsx("div",{className:"grid grid-flow-dense grid-cols-1 gap-4 xl:grid-cols-2",children:g.map((_,D)=>r.jsx(J5,{slot:_,index:D,onReplace:()=>v(D),onRemove:()=>S(D),onResize:V=>T(D,V),onConfigChange:V=>$(D,V)},_.id))})}),r.jsx(eO,{dropAnimation:null,children:A?r.jsx(X5,{slot:A}):null})]}),e!=null&&e.serverStats?r.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx(lx,{className:"h-3 w-3","aria-hidden":"true"}),r.jsxs("span",{children:["● ",e.serverStats.totalPorts," ports ·"," ",e.serverStats.deadSessions>0?`${e.serverStats.deadSessions} dead`:"all healthy"]})]}):null,r.jsx(tM,{open:i,onOpenChange:_=>{c(_),_||d(null)},onSelect:E})]})}function sM({term:e,description:t}){return r.jsx("span",{title:t,className:"cursor-help rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-xs font-medium text-foreground underline decoration-dotted underline-offset-4",children:e})}function oM(){const{data:e,loading:t,error:n}=aS(),{openCheatsheet:s}=To();return t?r.jsx(xt,{label:"Loading help…"}):n||!e?r.jsx(Tt,{error:n||"Help content is unavailable."}):r.jsxs("div",{className:"space-y-5",children:[r.jsx(He,{title:"Keyboard Shortcuts",description:"Navigate the dashboard without reaching for the mouse.",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 rounded-md border border-border/70 bg-background/80 px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent",children:"Open shortcuts cheatsheet"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["or press ",r.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"?"})," ","anywhere. ",ks("Mod+k")," opens the command palette."]})]})}),r.jsx(He,{title:"What Syntaur Is",description:e.whatIsSyntaur.summary,children:r.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:e.whatIsSyntaur.bullets.map(o=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3 text-sm leading-6 text-muted-foreground",children:o},o))})}),r.jsx(He,{title:"Getting Started",children:r.jsx("div",{className:"space-y-3",children:e.workflow.map((o,i)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:i+1}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?r.jsx(Pd,{command:o.command.command,description:o.command.description,example:o.command.example}):null,o.href?r.jsx(Ee,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open the related surface"}):null]})]})},o.title))})}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsxs(He,{title:"Core Concepts",children:[r.jsx("div",{className:"flex flex-wrap gap-2",children:e.coreConcepts.map(o=>r.jsx(sM,{term:o.term,description:o.description},o.term))}),r.jsx("div",{className:"grid gap-3 pt-2",children:e.coreConcepts.map(o=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:o.term}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description})]},o.term))})]}),r.jsx(He,{title:"Status Guide",children:r.jsx("div",{className:"space-y-3",children:e.statusGuide.map(o=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(bn,{status:o.status}),r.jsx("p",{className:"font-semibold text-foreground",children:o.meaning})]}),r.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:o.useWhen})]},o.status))})})]}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsx(He,{title:"Ownership And File Rules",children:r.jsx("div",{className:"space-y-3",children:e.ownershipRules.map(o=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:o.label}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description}),r.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:o.files.map(i=>r.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 font-mono text-xs text-foreground",children:i},i))})]},o.label))})}),r.jsx(He,{title:"How To Navigate The Dashboard",children:r.jsx("div",{className:"space-y-3",children:e.navigation.map(o=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:o.label}),r.jsx(Ee,{className:"text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open"})]}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description})]},o.label))})})]}),r.jsx(He,{title:"CLI Quick Reference",children:r.jsx("div",{className:"grid gap-3 xl:grid-cols-2",children:e.commands.map(o=>r.jsx(Pd,{command:o.command,description:o.description,example:o.example},o.command))})}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsx(He,{title:"FAQ",children:r.jsx("div",{className:"space-y-3",children:e.faq.map(o=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:o.question}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.answer})]},o.question))})}),r.jsx(He,{title:"First Project Checklist",children:r.jsx("div",{className:"space-y-3",children:e.firstProjectChecklist.map((o,i)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:i+1}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?r.jsx(Pd,{command:o.command.command,example:o.command.example}):null,o.href?r.jsx(Ee,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open the related surface"}):null]})]})},o.title))})})]})]})}function iy({children:e}){return r.jsx("div",{className:"chrome-card flex flex-col gap-2 !p-2.5 md:flex-row md:flex-wrap md:items-center",children:e})}const ap=p.forwardRef(({value:e,onChange:t,placeholder:n="Search"},s)=>r.jsxs("label",{className:"relative flex min-w-[220px] flex-1 items-center",children:[r.jsx(Eo,{className:"pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground"}),r.jsx("input",{ref:s,value:e,onChange:o=>t(o.target.value),placeholder:n,className:"h-9 w-full rounded-md border border-border/60 bg-background/90 pl-9 pr-3 text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-ring/30"})]}));ap.displayName="SearchInput";function ip({value:e,options:t,onChange:n}){return r.jsx("div",{className:"inline-flex rounded-md border border-border/60 bg-background/80 p-1",children:t.map(s=>r.jsx("button",{type:"button","aria-pressed":e===s.value,onClick:()=>n(s.value),className:we("rounded-sm px-2.5 py-1.5 text-sm font-medium transition",e===s.value?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:s.label},s.value))})}const aM={completed:"bg-status-completed-foreground",in_progress:"bg-status-in-progress-foreground",review:"bg-status-review-foreground",blocked:"bg-status-blocked-foreground",failed:"bg-status-failed-foreground",pending:"bg-status-pending-foreground"},Ej=["bg-primary","bg-secondary","bg-accent-coral","bg-accent-teal","bg-accent-amber"];function cf({progress:e,className:t,showLegend:n=!1}){const s=ha(),o=p.useMemo(()=>{let c=0;return(s.order.length>0?s.order:Object.keys(e).filter(d=>d!=="total")).map(d=>({key:d,className:aM[d]??Ej[c++%Ej.length]}))},[s.order,e]),i=o.filter(c=>(e[c.key]??0)>0);return r.jsxs("div",{className:we("space-y-2",t),children:[r.jsx("div",{className:"flex h-1.5 w-full overflow-hidden rounded-lg border border-border/70 bg-muted/60",children:e.total===0?r.jsx("div",{className:"h-full w-full bg-muted"}):i.map(c=>r.jsx("div",{className:c.className,style:{width:`${(e[c.key]??0)/e.total*100}%`},title:`${Sn(c.key)}: ${e[c.key]??0}`},c.key))}),n?r.jsx("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:o.map(c=>r.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-background/80 px-2 py-1",children:[r.jsx("span",{className:we("h-2 w-2 rounded-full",c.className)}),r.jsx("span",{children:Sn(c.key)}),r.jsx("span",{className:"font-medium text-foreground",children:e[c.key]??0})]},c.key))}):null]})}const iM=["pending","active","blocked","failed","completed"],ly=iM,lM=["draft","pending","ready_for_planning","ready_to_implement","in_progress","blocked","review","completed","failed"];function aC(e){return e&&e.length>0?e:[...lM]}function cM(e,t,n){if(t<0||t>=e.length)return e;const s=[...e],[o]=s.splice(t,1),i=t<n?n-1:n;return s.splice(Math.max(0,Math.min(i,s.length)),0,o),s}const uM=220,hd=8;function iC({anchor:e,items:t,onClose:n}){const s=p.useRef(null),[o,i]=p.useState(null);return p.useLayoutEffect(()=>{if(!e){i(null);return}const c=s.current,u=(c==null?void 0:c.offsetWidth)??uM,d=(c==null?void 0:c.offsetHeight)??0,m=Math.max(hd,window.innerWidth-u-hd),h=Math.max(hd,window.innerHeight-d-hd);i({left:Math.min(e.x,m),top:Math.min(e.y,h)})},[e]),p.useEffect(()=>{if(!e)return;function c(m){s.current&&!s.current.contains(m.target)&&n()}function u(m){m.key==="Escape"&&n()}function d(){n()}return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),document.addEventListener("contextmenu",c),window.addEventListener("scroll",d,!0),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u),document.removeEventListener("contextmenu",c),window.removeEventListener("scroll",d,!0)}},[e,n]),!e||t.length===0?null:r.jsx("div",{ref:s,role:"menu",className:"fixed z-50 min-w-[220px] rounded-md border border-border/70 bg-background py-1 shadow-lg",style:{left:(o==null?void 0:o.left)??e.x,top:(o==null?void 0:o.top)??e.y,visibility:o?"visible":"hidden"},children:r.jsx(ia,{delayDuration:200,children:t.map(c=>{const u=c.icon,d=we("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition",c.disabled?"cursor-not-allowed opacity-50":c.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),m=r.jsxs(r.Fragment,{children:[u?r.jsx(u,{className:"h-4 w-4 shrink-0"}):null,r.jsx("span",{className:"block min-w-0 truncate",children:c.label})]});if(c.disabled){const h=r.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:r.jsx("button",{type:"button",disabled:!0,className:d,children:m})});return c.disabledReason?r.jsxs(Nr,{children:[r.jsx(Cr,{asChild:!0,children:h}),r.jsx(ur,{side:"left",children:c.disabledReason})]},c.key):r.jsx("div",{children:h},c.key)}return c.href?r.jsx(Ee,{to:c.href,className:d,onClick:()=>n(),children:m},c.key):r.jsx("button",{type:"button",className:d,onClick:()=>{var h;(h=c.onSelect)==null||h.call(c),n()},children:m},c.key)})})})}const dM="__ungrouped__";function cy({open:e,onOpenChange:t,currentWorkspace:n,onSubmit:s,title:o="Move to workspace",description:i="Pick the workspace this item should belong to."}){const{data:c,loading:u}=fa(),[d,m]=p.useState(n),[h,g]=p.useState(!1),[y,b]=p.useState(null);p.useEffect(()=>{e&&(m(n),b(null))},[e,n]);const C=p.useMemo(()=>[...((c==null?void 0:c.workspaces)??[]).map(E=>({key:E,label:E,value:E})),{key:dM,label:"Ungrouped",value:null}],[c]),j=!h&&d!==n;async function v(){if(j){g(!0),b(null);try{await s(d),t(!1)}catch(k){b(k instanceof Error?k.message:"Failed to move item")}finally{g(!1)}}}return r.jsx(On,{open:e,onOpenChange:k=>h?void 0:t(k),children:r.jsxs(Rn,{children:[r.jsxs(Zn,{children:[r.jsx(An,{children:o}),r.jsx(Hr,{children:i})]}),r.jsx("div",{className:"my-2 max-h-[320px] overflow-y-auto rounded-md border border-border/60",children:u&&C.length===0?r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-sm text-muted-foreground",children:[r.jsx(ix,{className:"h-4 w-4 animate-spin"})," Loading workspaces…"]}):C.map(k=>{const E=k.value===n,S=k.value===d;return r.jsxs("button",{type:"button",disabled:E||h,onClick:()=>m(k.value),className:we("flex w-full items-center justify-between px-3 py-2 text-left text-sm transition",E?"cursor-not-allowed bg-foreground/5 text-muted-foreground":S?"bg-accent/40 text-foreground":"hover:bg-foreground/5"),children:[r.jsxs("span",{className:we("block min-w-0 truncate",k.value===null?"italic text-muted-foreground":""),children:[k.label,E?r.jsx("span",{className:"ml-2 text-xs",children:"(current)"}):null]}),S?r.jsx(Rr,{className:"h-4 w-4 text-foreground"}):null]},k.key)})}),y?r.jsx("p",{className:"text-sm text-destructive",role:"alert",children:y}):null,r.jsxs(Ar,{children:[r.jsx("button",{type:"button",onClick:()=>t(!1),disabled:h,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"button",onClick:v,disabled:!j,className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:h?"Moving…":"Move"})]})]})})}function Tj(){const{workspace:e}=Bt(),t=fn(),n=zt(),{data:s,loading:o,error:i,refetch:c}=Cs(),u=p.useRef(null);Ro("list:projects");const[d,m]=p.useState(""),[h,g]=p.useState("all"),[y,b]=p.useState("all"),[C,j]=p.useState("updated"),[v,k]=ls(),E=v.get("view"),S=E==="table"||E==="kanban"?E:"cards",T=z=>{k(G=>{const L=new URLSearchParams(G);return z==="cards"?L.delete("view"):L.set("view",z),L})},[P,R]=p.useState({}),[A,$]=p.useState(null),[M,_]=p.useState(null),D=p.useMemo(()=>s?s.filter(z=>{if(e){if(e==="_ungrouped"){if(z.workspace!==null)return!1}else if(z.workspace!==e)return!1}return h!=="all"&&z.status!==h||y!=="all"&&!z.tags.includes(y)?!1:d.trim()?`${z.title} ${z.tags.join(" ")} ${z.slug}`.toLowerCase().includes(d.toLowerCase()):!0}).sort((z,G)=>mM(z,G,C)):[],[s,d,h,y,C,e]),V=D.map(z=>`${z.slug}:${z.status}`).join("|");p.useEffect(()=>{R(hM(D))},[V,C]);const K=p.useMemo(()=>{const z=new Map(D.map(G=>[G.slug,G]));return ly.flatMap(G=>(P[G]??D.filter(H=>H.status===G).map(H=>H.slug)).map(H=>z.get(H)).filter(H=>!!H))},[D,P]),{visibleItems:I,visibleIndexByKey:F}=p.useMemo(()=>{const z=S==="kanban"?K:D,G=new Map;return z.forEach((L,H)=>G.set(L.slug,H)),{visibleItems:z,visibleIndexByKey:G}},[S,D,K]),{hotkeyRowProps:q}=$c(I,{scope:"list:projects",onOpen:z=>n(`${t}/projects/${z.slug}`)});if(Yt({keys:"/",scope:"list:projects",description:"Focus filter",handler:()=>{var z;return(z=u.current)==null?void 0:z.focus()}}),Yt({keys:"r",scope:"list:projects",description:"Refresh",handler:()=>c()}),o)return r.jsx(xt,{label:"Loading projects…"});if(i||!s)return r.jsx(Tt,{error:i||"Project list is unavailable."});const Z=Array.from(new Set(s.flatMap(z=>z.tags))).sort();return r.jsxs("div",{className:"space-y-5",children:[r.jsxs(iy,{children:[r.jsx(ap,{ref:u,value:d,onChange:m,placeholder:"Search by project title or tag"}),r.jsxs("select",{value:h,onChange:z=>g(z.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All statuses"}),r.jsx("option",{value:"pending",children:"Pending"}),r.jsx("option",{value:"active",children:"Active"}),r.jsx("option",{value:"blocked",children:"Blocked"}),r.jsx("option",{value:"failed",children:"Failed"}),r.jsx("option",{value:"completed",children:"Completed"})]}),r.jsxs("select",{value:y,onChange:z=>b(z.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All tags"}),Z.map(z=>r.jsx("option",{value:z,children:z},z))]}),r.jsxs("select",{value:C,onChange:z=>j(z.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"updated",children:"Sort: Updated"}),r.jsx("option",{value:"created",children:"Sort: Created"}),r.jsx("option",{value:"title",children:"Sort: Title"}),r.jsx("option",{value:"attention",children:"Sort: Attention"})]}),r.jsx(ip,{value:S,onChange:z=>T(z),options:[{value:"cards",label:"Cards"},{value:"table",label:"Table"},{value:"kanban",label:"Kanban"}]})]}),D.length===0?s.length===0?r.jsxs("div",{className:"rounded-frame border border-border/60 bg-card px-6 py-16 text-center",children:[r.jsx("p",{className:"eyebrow mx-auto justify-center",children:"Start here"}),r.jsx("h2",{className:"mx-auto mt-4 max-w-2xl text-3xl font-semibold tracking-display text-foreground md:text-4xl",children:"The task manager built for agents, by agents"}),r.jsx("p",{className:"mx-auto mt-3 max-w-xl text-sm leading-6 text-muted-foreground",children:"A project groups assignments, resources, and memories under one objective. Markdown stays authoritative — the dashboard is just a view."}),r.jsxs("div",{className:"mt-6 flex flex-wrap justify-center gap-3",children:[r.jsx(Ee,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create your first project"}),r.jsx(Ee,{className:"shell-action",to:"/help",children:"Read the spec"})]})]}):r.jsx(Et,{title:"No projects match these filters",description:"Adjust the current search and filters or create a new project.",actions:r.jsx(Ee,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create Project"})}):S==="cards"?r.jsx("div",{className:"grid gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:D.map((z,G)=>r.jsxs(Ee,{to:`${t}/projects/${z.slug}`,className:"block rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm transition hover:border-primary/40 hover:shadow-md",...q(G),children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:z.title}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",zn(z.updated)]})]}),r.jsx(bn,{status:z.status})]}),r.jsxs("div",{className:"mt-4 space-y-3",children:[r.jsx(cf,{progress:z.progress,showLegend:!0}),r.jsx("div",{className:"flex flex-wrap gap-2",children:z.tags.map(L=>r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:L},L))}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("p",{className:"text-muted-foreground",children:"Needs attention"}),r.jsx("p",{className:"mt-1 font-semibold text-foreground",children:z.needsAttention.blockedCount+z.needsAttention.failedCount})]}),r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("p",{className:"text-muted-foreground",children:"Assignments"}),r.jsx("p",{className:"mt-1 font-semibold text-foreground",children:z.progress.total})]})]})]})]},z.slug))}):S==="table"?r.jsx(He,{title:`${D.length} project${D.length===1?"":"s"}`,children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[r.jsx("th",{className:"pb-3 font-medium",children:"Project"}),r.jsx("th",{className:"pb-3 font-medium",children:"Status"}),r.jsx("th",{className:"pb-3 font-medium",children:"Progress"}),r.jsx("th",{className:"pb-3 font-medium",children:"Attention"}),r.jsx("th",{className:"pb-3 font-medium",children:"Updated"})]})}),r.jsx("tbody",{children:D.map((z,G)=>r.jsxs("tr",{className:"border-b border-border/50 last:border-0",...q(G),children:[r.jsxs("td",{className:"py-4 pr-4",children:[r.jsx(Ee,{to:`${t}/projects/${z.slug}`,className:"font-semibold text-foreground hover:text-primary",children:z.title}),r.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:z.tags.map(L=>r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:L},L))})]}),r.jsx("td",{className:"py-4 pr-4",children:r.jsx(bn,{status:z.status})}),r.jsx("td",{className:"py-4 pr-4",children:r.jsx("div",{className:"min-w-[220px]",children:r.jsx(cf,{progress:z.progress})})}),r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:z.needsAttention.blockedCount+z.needsAttention.failedCount}),r.jsx("td",{className:"py-4 text-muted-foreground",children:zn(z.updated)})]},z.slug))})]})})}):r.jsx(tp,{columns:pM,items:K,getItemId:z=>z.slug,getColumnId:z=>z.status,canDrop:({fromColumnId:z,toColumnId:G})=>({allowed:!0,reason:z===G?void 0:"This will set a manual status override on the project."}),onMove:({item:z,fromColumnId:G,toColumnId:L,fromIndex:H,toIndex:re})=>{if(G===L){const U=P[G]??D.filter(ue=>ue.status===G).map(ue=>ue.slug);R(ue=>({...ue,[G]:cM(U,H,re)}));return}fetch(`/api/projects/${z.slug}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:L})}).then(()=>{window.location.reload()})},getExternalDragData:z=>({type:"project",id:z.slug}),onCardContextMenu:(z,G)=>{G.preventDefault(),$({project:z,anchor:{x:G.clientX,y:G.clientY}})},emptyMessage:z=>`No ${z.title.toLowerCase()} projects.`,renderCard:(z,{dragging:G})=>{const L=F.get(z.slug)??-1;return r.jsx("div",{...L>=0?q(L):{},children:r.jsx(gM,{project:z,dragging:G})})}}),r.jsx(iC,{anchor:(A==null?void 0:A.anchor)??null,items:A?[{key:"edit",label:"Edit",icon:zi,onSelect:()=>n(`${t}/projects/${A.project.slug}`)},{key:"move",label:"Move to workspace…",icon:jf,onSelect:()=>_(A.project)}]:[],onClose:()=>$(null)}),r.jsx(cy,{open:M!==null,onOpenChange:z=>{z||_(null)},currentWorkspace:(M==null?void 0:M.workspace)??null,title:"Move project to workspace",onSubmit:async z=>{if(!M)return;const G=await fetch(`/api/projects/${encodeURIComponent(M.slug)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:z})});if(!G.ok){const L=await G.json().catch(()=>({}));throw new Error(L.error||"Failed to move project")}c()}}),r.jsx("div",{className:"rounded-lg border border-border/60 bg-card/80 p-3 text-sm text-muted-foreground",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(ax,{className:"mt-0.5 h-4 w-4"}),r.jsxs("p",{children:["Project status is derived from assignment state by default.",S==="kanban"?" Drag projects between columns or use":" Use"," the status override on the project detail page to set a manual status."]})]})})]})}const fM={pending:"Pending",active:"Active",blocked:"Blocked",failed:"Failed",completed:"Completed"},pM=ly.map(e=>({id:e,title:fM[e],description:np(e)}));function mM(e,t,n){switch(n){case"created":return t.created.localeCompare(e.created);case"title":return e.title.localeCompare(t.title);case"attention":return Rj(t)-Rj(e);case"updated":default:return t.updated.localeCompare(e.updated)}}function Rj(e){return e.needsAttention.failedCount*10+e.needsAttention.blockedCount*5+e.needsAttention.openQuestions}function hM(e){return Object.fromEntries(ly.map(t=>[t,e.filter(n=>n.status===t).map(n=>n.slug)]))}function gM({project:e,dragging:t}){const n=fn();return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Ee,{to:`${n}/projects/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",zn(e.updated)]})]}),r.jsx(bn,{status:e.status})]}),r.jsx("div",{className:"mt-4",children:r.jsx(cf,{progress:e.progress})}),r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.tags.map(s=>r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:s},s)),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.progress.total," assignments"]}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.needsAttention.blockedCount+e.needsAttention.failedCount," needs attention"]})]}),r.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:t?"Reordering within status":"Derived project lane"})]})}function uf({title:e,description:t,actions:n,className:s}){return r.jsxs("div",{className:we("flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",s),children:[r.jsxs("div",{className:"space-y-1",children:[e?r.jsx("h1",{className:"text-xl font-semibold tracking-tight text-foreground sm:text-2xl",children:e}):null,t?r.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:t}):null]}),n?r.jsx("div",{className:"flex flex-wrap items-center gap-3",children:n}):null]})}function xM(){return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-status-archived-foreground/30 bg-status-archived px-2 py-0.5 text-xs font-medium text-status-archived-foreground",children:[r.jsx(wf,{className:"h-3 w-3"}),"Archived"]})}function Aj(e){return e.projectSlug?`/projects/${e.projectSlug}/assignments/${e.slug}`:`/assignments/${e.id}`}function yM(){const{data:e,loading:t,error:n,refetch:s}=x3(),[o,i]=p.useState(null),[c,u]=p.useState(null),[d,m]=p.useState({}),{toast:h,showToast:g,dismissToast:y}=Ao();async function b(S,T,P){i(T),u(null);try{const R=await fetch(S,{method:"POST",headers:{"Content-Type":"application/json"}});if(!R.ok){const A=await R.json().catch(()=>null);throw new Error((A==null?void 0:A.error)||`HTTP ${R.status}`)}s(),g(P,"success")}catch(R){u(R instanceof Error?R.message:"Restore failed")}finally{i(null)}}function C(S){return b(`/api/projects/${S.slug}/unarchive`,`project:${S.slug}`,"Project restored")}function j(S){const T=S.projectSlug?`/api/projects/${S.projectSlug}/assignments/${S.slug}/unarchive`:`/api/assignments/${S.id}/unarchive`;return b(T,`assignment:${S.id}`,"Assignment restored")}if(t)return r.jsx(xt,{label:"Loading archived content…"});if(n)return r.jsx(Tt,{error:n});const v=(e==null?void 0:e.projects)??[],k=(e==null?void 0:e.assignments)??[],E=v.length===0&&k.length===0;return r.jsxs("div",{className:"space-y-6",children:[r.jsx(xa,{toast:h,onDismiss:y}),r.jsx(uf,{title:"Archive",description:"Archived projects and individually-archived assignments. Restoring a project also brings back its cascade-hidden assignments; assignments archived on their own stay archived until restored here."}),c?r.jsx("div",{className:"rounded border border-status-failed-foreground/30 bg-status-failed px-3 py-2 text-sm text-status-failed-foreground",children:c}):null,E?r.jsx(Et,{title:"Nothing archived",description:"Archived projects and assignments will appear here, ready to restore."}):r.jsxs(r.Fragment,{children:[v.length>0&&r.jsx(He,{title:"Archived Projects",description:"Restoring a project unhides every cascade-hidden assignment; individually-archived children stay archived.",children:r.jsx("ul",{className:"divide-y divide-border",children:v.map(S=>{const T=d[S.slug]??!1;return r.jsxs("li",{className:"py-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs("button",{type:"button",onClick:()=>m(P=>({...P,[S.slug]:!T})),className:"inline-flex items-center gap-1.5 text-left text-sm font-medium text-foreground hover:text-foreground/80","aria-expanded":T,children:[T?r.jsx(pr,{className:"h-4 w-4"}):r.jsx(Rk,{className:"h-4 w-4"}),r.jsx(sx,{className:"h-4 w-4 text-muted-foreground"}),S.title,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",S.assignments.length," assignment",S.assignments.length===1?"":"s",")"]})]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Archived ",S.archivedAt?Ur(S.archivedAt):"with no timestamp",S.archivedReason?` · ${S.archivedReason}`:""]}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[r.jsx(Ee,{to:`/projects/${S.slug}`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Open"}),r.jsxs("button",{type:"button",onClick:()=>C(S),disabled:o===`project:${S.slug}`,className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[r.jsx(Fd,{className:"h-3 w-3"}),"Restore"]})]})]}),T&&S.assignments.length>0&&r.jsx("ul",{className:"mt-2 space-y-1 pl-9",children:S.assignments.map(P=>r.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-sm",children:[r.jsx(Ee,{to:Aj(P),className:"text-foreground hover:text-foreground/80",children:P.title}),r.jsx(bn,{status:P.status,showIcon:!1}),r.jsx("span",{className:"text-xs text-muted-foreground",children:P.archived?"Archived individually — stays archived after restore":"Hidden via project — returns on restore"})]},P.id))})]},S.slug)})})}),k.length>0&&r.jsx(He,{title:"Archived Assignments",description:"Individually-archived assignments whose project is still active.",children:r.jsx("ul",{className:"divide-y divide-border",children:k.map(S=>r.jsxs("li",{className:"flex flex-wrap items-center gap-3 py-3",children:[r.jsx(Ee,{to:Aj(S),className:"text-sm font-medium text-foreground hover:text-foreground/80",children:S.title}),r.jsx(bn,{status:S.status,showIcon:!1}),r.jsx(xM,{}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.projectTitle??"Standalone"," · Archived"," ",S.archivedAt?Ur(S.archivedAt):"with no timestamp",S.archivedReason?` · ${S.archivedReason}`:""]}),r.jsxs("button",{type:"button",onClick:()=>j(S),disabled:o===`assignment:${S.id}`,className:"ml-auto inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[r.jsx(Fd,{className:"h-3 w-3"}),"Restore"]})]},S.id))})})]})]})}const Pj="inline-flex max-w-[14rem] items-center gap-1 whitespace-nowrap rounded-full border px-2 py-0.5 text-[11px] font-semibold tracking-wide border-border/60 text-muted-foreground",Dj="block min-w-0 truncate";function uy({externalIds:e,className:t}){return e.length===0?null:r.jsx("span",{className:we("flex flex-wrap items-center gap-1.5",t),children:e.map((n,s)=>{const o=`${n.system}:${n.id}`,i=`${n.system}:${n.id}:${s}`;return n.url!=null&&n.url.length>0?r.jsxs("a",{href:n.url??void 0,target:"_blank",rel:"noopener noreferrer",className:we(Pj,"transition-colors hover:text-foreground hover:border-foreground/40"),title:`Open ${o} in ${n.system}`,children:[r.jsx("span",{className:Dj,children:o}),r.jsx(Mi,{className:"h-2.5 w-2.5 shrink-0"})]},i):r.jsx("span",{className:Pj,title:o,children:r.jsx("span",{className:Dj,children:o})},i)})})}const bM={default:"chrome-card",info:"rounded-lg border border-primary/30 bg-primary/5 p-3 dark:border-primary/40 dark:bg-primary/10",warn:"rounded-lg border border-warning-foreground/30 bg-warning p-3",danger:"rounded-lg border border-error-foreground/30 bg-error p-3",success:"rounded-lg border border-success-foreground/30 bg-success p-3"};function Fn({label:e,value:t,description:n,icon:s,tone:o="default",to:i}){const c=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:e}),r.jsx("p",{className:"text-2xl font-semibold text-foreground",children:t})]}),s?r.jsx("span",{className:"rounded-md border border-border/60 bg-background/80 p-1.5 text-muted-foreground",children:r.jsx(s,{className:"h-5 w-5"})}):null]}),n?r.jsx("p",{className:"mt-2 text-sm leading-5 text-muted-foreground",children:n}):null]}),u=we(bM[o],i?"block transition hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40":"");return i?r.jsx(Ee,{to:i,className:u,children:c}):r.jsx("article",{className:u,children:c})}function $j(e){const t=vM(e),n=p.forwardRef((s,o)=>{const{children:i,...c}=s,u=p.Children.toArray(i),d=u.find(jM);if(d){const m=d.props.children,h=u.map(g=>g===d?p.Children.count(m)>1?p.Children.only(null):p.isValidElement(m)?m.props.children:null:g);return r.jsx(t,{...c,ref:o,children:p.isValidElement(m)?p.cloneElement(m,void 0,h):null})}return r.jsx(t,{...c,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function vM(e){const t=p.forwardRef((n,s)=>{const{children:o,...i}=n;if(p.isValidElement(o)){const c=SM(o),u=kM(i,o.props);return o.type!==p.Fragment&&(u.ref=s?Rf(s,c):c),p.cloneElement(o,u)}return p.Children.count(o)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var wM=Symbol("radix.slottable");function jM(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===wM}function kM(e,t){const n={...t};for(const s in t){const o=e[s],i=t[s];/^on[A-Z]/.test(s)?o&&i?n[s]=(...u)=>{const d=i(...u);return o(...u),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...i}:s==="className"&&(n[s]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function SM(e){var s,o;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function NM(e){const t=e+"CollectionProvider",[n,s]=pa(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=j=>{const{scope:v,children:k}=j,E=Dt.useRef(null),S=Dt.useRef(new Map).current;return r.jsx(o,{scope:v,itemMap:S,collectionRef:E,children:k})};c.displayName=t;const u=e+"CollectionSlot",d=$j(u),m=Dt.forwardRef((j,v)=>{const{scope:k,children:E}=j,S=i(u,k),T=qn(v,S.collectionRef);return r.jsx(d,{ref:T,children:E})});m.displayName=u;const h=e+"CollectionItemSlot",g="data-radix-collection-item",y=$j(h),b=Dt.forwardRef((j,v)=>{const{scope:k,children:E,...S}=j,T=Dt.useRef(null),P=qn(v,T),R=i(h,k);return Dt.useEffect(()=>(R.itemMap.set(T,{ref:T,...S}),()=>void R.itemMap.delete(T))),r.jsx(y,{[g]:"",ref:P,children:E})});b.displayName=h;function C(j){const v=i(e+"CollectionConsumer",j);return Dt.useCallback(()=>{const E=v.collectionRef.current;if(!E)return[];const S=Array.from(E.querySelectorAll(`[${g}]`));return Array.from(v.itemMap.values()).sort((R,A)=>S.indexOf(R.ref.current)-S.indexOf(A.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:c,Slot:m,ItemSlot:b},C,s]}var CM=p.createContext(void 0);function lC(e){const t=p.useContext(CM);return e||t||"ltr"}var Lh="rovingFocusGroup.onEntryFocus",EM={bubbles:!1,cancelable:!0},Hc="RovingFocusGroup",[Pg,cC,TM]=NM(Hc),[RM,uC]=pa(Hc,[TM]),[AM,PM]=RM(Hc),dC=p.forwardRef((e,t)=>r.jsx(Pg.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Pg.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(DM,{...e,ref:t})})}));dC.displayName=Hc;var DM=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:i,currentTabStopId:c,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:d,onEntryFocus:m,preventScrollOnEntryFocus:h=!1,...g}=e,y=p.useRef(null),b=qn(t,y),C=lC(i),[j,v]=Af({prop:c,defaultProp:u??null,onChange:d,caller:Hc}),[k,E]=p.useState(!1),S=ca(m),T=cC(n),P=p.useRef(!1),[R,A]=p.useState(0);return p.useEffect(()=>{const $=y.current;if($)return $.addEventListener(Lh,S),()=>$.removeEventListener(Lh,S)},[S]),r.jsx(AM,{scope:n,orientation:s,dir:C,loop:o,currentTabStopId:j,onItemFocus:p.useCallback($=>v($),[v]),onItemShiftTab:p.useCallback(()=>E(!0),[]),onFocusableItemAdd:p.useCallback(()=>A($=>$+1),[]),onFocusableItemRemove:p.useCallback(()=>A($=>$-1),[]),children:r.jsx(vn.div,{tabIndex:k||R===0?-1:0,"data-orientation":s,...g,ref:b,style:{outline:"none",...e.style},onMouseDown:Zt(e.onMouseDown,()=>{P.current=!0}),onFocus:Zt(e.onFocus,$=>{const M=!P.current;if($.target===$.currentTarget&&M&&!k){const _=new CustomEvent(Lh,EM);if($.currentTarget.dispatchEvent(_),!_.defaultPrevented){const D=T().filter(q=>q.focusable),V=D.find(q=>q.active),K=D.find(q=>q.id===j),F=[V,K,...D].filter(Boolean).map(q=>q.ref.current);mC(F,h)}}P.current=!1}),onBlur:Zt(e.onBlur,()=>E(!1))})})}),fC="RovingFocusGroupItem",pC=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:i,children:c,...u}=e,d=bi(),m=i||d,h=PM(fC,n),g=h.currentTabStopId===m,y=cC(n),{onFocusableItemAdd:b,onFocusableItemRemove:C,currentTabStopId:j}=h;return p.useEffect(()=>{if(s)return b(),()=>C()},[s,b,C]),r.jsx(Pg.ItemSlot,{scope:n,id:m,focusable:s,active:o,children:r.jsx(vn.span,{tabIndex:g?0:-1,"data-orientation":h.orientation,...u,ref:t,onMouseDown:Zt(e.onMouseDown,v=>{s?h.onItemFocus(m):v.preventDefault()}),onFocus:Zt(e.onFocus,()=>h.onItemFocus(m)),onKeyDown:Zt(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){h.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const k=OM(v,h.orientation,h.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let S=y().filter(T=>T.focusable).map(T=>T.ref.current);if(k==="last")S.reverse();else if(k==="prev"||k==="next"){k==="prev"&&S.reverse();const T=S.indexOf(v.currentTarget);S=h.loop?IM(S,T+1):S.slice(T+1)}setTimeout(()=>mC(S))}}),children:typeof c=="function"?c({isCurrentTabStop:g,hasTabStop:j!=null}):c})})});pC.displayName=fC;var $M={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function LM(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function OM(e,t,n){const s=LM(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return $M[s]}function mC(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function IM(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var _M=dC,MM=pC,lp="Tabs",[FM]=pa(lp,[uC]),hC=uC(),[zM,dy]=FM(lp),gC=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:i,orientation:c="horizontal",dir:u,activationMode:d="automatic",...m}=e,h=lC(u),[g,y]=Af({prop:s,onChange:o,defaultProp:i??"",caller:lp});return r.jsx(zM,{scope:n,baseId:bi(),value:g,onValueChange:y,orientation:c,dir:h,activationMode:d,children:r.jsx(vn.div,{dir:h,"data-orientation":c,...m,ref:t})})});gC.displayName=lp;var xC="TabsList",yC=p.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,i=dy(xC,n),c=hC(n);return r.jsx(_M,{asChild:!0,...c,orientation:i.orientation,dir:i.dir,loop:s,children:r.jsx(vn.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});yC.displayName=xC;var bC="TabsTrigger",vC=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...i}=e,c=dy(bC,n),u=hC(n),d=kC(c.baseId,s),m=SC(c.baseId,s),h=s===c.value;return r.jsx(MM,{asChild:!0,...u,focusable:!o,active:h,children:r.jsx(vn.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":m,"data-state":h?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...i,ref:t,onMouseDown:Zt(e.onMouseDown,g=>{!o&&g.button===0&&g.ctrlKey===!1?c.onValueChange(s):g.preventDefault()}),onKeyDown:Zt(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&c.onValueChange(s)}),onFocus:Zt(e.onFocus,()=>{const g=c.activationMode!=="manual";!h&&!o&&g&&c.onValueChange(s)})})})});vC.displayName=bC;var wC="TabsContent",jC=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:i,...c}=e,u=dy(wC,n),d=kC(u.baseId,s),m=SC(u.baseId,s),h=s===u.value,g=p.useRef(h);return p.useEffect(()=>{const y=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(y)},[]),r.jsx(ma,{present:o||h,children:({present:y})=>r.jsx(vn.div,{"data-state":h?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":d,hidden:!y,id:m,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:y&&i})})});jC.displayName=wC;function kC(e,t){return`${e}-trigger-${t}`}function SC(e,t){return`${e}-content-${t}`}var NC=gC,CC=yC,Dg=vC,$g=jC;function fy({value:e,onValueChange:t,items:n,className:s}){return r.jsxs(NC,{value:e,onValueChange:t,className:s,children:[r.jsx(CC,{className:"scrollbar-none flex gap-2 overflow-x-auto rounded-md border border-border/70 bg-card/80 p-1",children:n.map(o=>r.jsxs(Dg,{value:o.value,className:we("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:[r.jsx("span",{children:o.label}),typeof o.count=="number"?r.jsx("span",{className:"rounded-full bg-background/20 px-2 py-0.5 text-xs data-[state=active]:bg-background/20",children:o.count}):null]},o.value))}),n.map(o=>r.jsx($g,{value:o.value,className:"pt-3",children:o.content},o.value))]})}const BM="modulepreload",UM=function(e){return"/"+e},Lj={},VM=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let c=function(m){return Promise.all(m.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),d=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));o=c(n.map(m=>{if(m=UM(m),m in Lj)return;Lj[m]=!0;const h=m.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${g}`))return;const y=document.createElement("link");if(y.rel=h?"stylesheet":BM,h||(y.as="script"),y.crossOrigin="",y.href=m,d&&y.setAttribute("nonce",d),document.head.appendChild(y),h)return new Promise((b,C)=>{y.addEventListener("load",b),y.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${m}`)))})}))}function i(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return o.then(c=>{for(const u of c||[])u.status==="rejected"&&i(u.reason);return t().catch(i)})};function HM({definition:e,className:t,nodeRoutes:n={}}){const s=p.useRef(null),[o,i]=p.useState(null),[c,u]=p.useState(!0),d=zt(),m=document.documentElement.classList.contains("dark")?"dark":"default";return p.useEffect(()=>{let h=!1;async function g(){if(s.current)try{const y=(await VM(async()=>{const{default:j}=await import("./mermaid.core-DVqEZA64.js").then(v=>v.bF);return{default:j}},[])).default;if(y.initialize({startOnLoad:!1,theme:"base",themeVariables:WM(m==="dark")}),h)return;const b=`mermaid-${Date.now()}`,{svg:C}=await y.render(b,e);if(h||!s.current)return;s.current.innerHTML=C,KM(s.current,n,d),u(!1)}catch(y){h||(i(y instanceof Error?y.message:"Failed to render graph"),u(!1))}}return u(!0),i(null),g(),()=>{h=!0}},[e,d,n,m]),o?r.jsxs("div",{className:we("rounded-lg border border-border bg-card p-4",t),children:[r.jsxs("p",{className:"text-sm text-error-foreground",children:["Failed to render dependency graph: ",o]}),r.jsx("pre",{className:"mt-2 text-xs text-muted-foreground overflow-auto",children:e})]}):r.jsxs("div",{className:we("rounded-lg border border-border bg-card p-4",t),children:[c&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."}),r.jsx("div",{ref:s,className:"overflow-auto"})]})}function WM(e){const t=document.documentElement,n=g=>{const y=getComputedStyle(t).getPropertyValue(g).trim();return y?`oklch(${y})`:""},s=n("--card"),o=n("--card-foreground"),i=n("--border"),c=n("--primary"),u=n("--primary-foreground"),d=n("--muted"),m=n("--muted-foreground"),h=n("--secondary");return{background:s,primaryColor:s,primaryTextColor:o,primaryBorderColor:i,secondaryColor:d,secondaryTextColor:o,secondaryBorderColor:i,tertiaryColor:d,tertiaryTextColor:m,tertiaryBorderColor:i,lineColor:e?m:i,textColor:o,mainBkg:s,nodeBkg:s,nodeTextColor:o,nodeBorder:i,clusterBkg:d,clusterBorder:i,edgeLabelBackground:s,titleColor:o,activeTaskBkgColor:c,activeTaskBorderColor:c,altBackground:d,labelColor:o,errorBkgColor:h,errorTextColor:u}}function KM(e,t,n){var s;for(const o of e.querySelectorAll(".node")){const i=((s=o.textContent)==null?void 0:s.replace(/\s+/g," ").trim())??"",c=t[i];if(!c)continue;o.style.cursor="pointer",o.setAttribute("role","link"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`Open ${i}`);const u=()=>n(c);o.addEventListener("click",u),o.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),u())})}}function qM(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const GM=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,YM=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,QM={};function Oj(e,t){return(QM.jsx?YM:GM).test(e)}const JM=/[ \t\n\f\r]/g;function XM(e){return typeof e=="object"?e.type==="text"?Ij(e.value):!1:Ij(e)}function Ij(e){return e.replace(JM,"")===""}class Wc{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Wc.prototype.normal={};Wc.prototype.property={};Wc.prototype.space=void 0;function EC(e,t){const n={},s={};for(const o of e)Object.assign(n,o.property),Object.assign(s,o.normal);return new Wc(n,s,t)}function Lg(e){return e.toLowerCase()}class mr{constructor(t,n){this.attribute=n,this.property=t}}mr.prototype.attribute="";mr.prototype.booleanish=!1;mr.prototype.boolean=!1;mr.prototype.commaOrSpaceSeparated=!1;mr.prototype.commaSeparated=!1;mr.prototype.defined=!1;mr.prototype.mustUseProperty=!1;mr.prototype.number=!1;mr.prototype.overloadedBoolean=!1;mr.prototype.property="";mr.prototype.spaceSeparated=!1;mr.prototype.space=void 0;let ZM=0;const mt=ya(),gn=ya(),Og=ya(),Re=ya(),Vt=ya(),Ci=ya(),vr=ya();function ya(){return 2**++ZM}const Ig=Object.freeze(Object.defineProperty({__proto__:null,boolean:mt,booleanish:gn,commaOrSpaceSeparated:vr,commaSeparated:Ci,number:Re,overloadedBoolean:Og,spaceSeparated:Vt},Symbol.toStringTag,{value:"Module"})),Oh=Object.keys(Ig);class py extends mr{constructor(t,n,s,o){let i=-1;if(super(t,n),_j(this,"space",o),typeof s=="number")for(;++i<Oh.length;){const c=Oh[i];_j(this,Oh[i],(s&Ig[c])===Ig[c])}}}py.prototype.defined=!0;function _j(e,t,n){n&&(e[t]=n)}function Qi(e){const t={},n={};for(const[s,o]of Object.entries(e.properties)){const i=new py(s,e.transform(e.attributes||{},s),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(i.mustUseProperty=!0),t[s]=i,n[Lg(s)]=s,n[Lg(i.attribute)]=s}return new Wc(t,n,e.space)}const TC=Qi({properties:{ariaActiveDescendant:null,ariaAtomic:gn,ariaAutoComplete:null,ariaBusy:gn,ariaChecked:gn,ariaColCount:Re,ariaColIndex:Re,ariaColSpan:Re,ariaControls:Vt,ariaCurrent:null,ariaDescribedBy:Vt,ariaDetails:null,ariaDisabled:gn,ariaDropEffect:Vt,ariaErrorMessage:null,ariaExpanded:gn,ariaFlowTo:Vt,ariaGrabbed:gn,ariaHasPopup:null,ariaHidden:gn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Vt,ariaLevel:Re,ariaLive:null,ariaModal:gn,ariaMultiLine:gn,ariaMultiSelectable:gn,ariaOrientation:null,ariaOwns:Vt,ariaPlaceholder:null,ariaPosInSet:Re,ariaPressed:gn,ariaReadOnly:gn,ariaRelevant:null,ariaRequired:gn,ariaRoleDescription:Vt,ariaRowCount:Re,ariaRowIndex:Re,ariaRowSpan:Re,ariaSelected:gn,ariaSetSize:Re,ariaSort:null,ariaValueMax:Re,ariaValueMin:Re,ariaValueNow:Re,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function RC(e,t){return t in e?e[t]:t}function AC(e,t){return RC(e,t.toLowerCase())}const eF=Qi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ci,acceptCharset:Vt,accessKey:Vt,action:null,allow:null,allowFullScreen:mt,allowPaymentRequest:mt,allowUserMedia:mt,alt:null,as:null,async:mt,autoCapitalize:null,autoComplete:Vt,autoFocus:mt,autoPlay:mt,blocking:Vt,capture:null,charSet:null,checked:mt,cite:null,className:Vt,cols:Re,colSpan:null,content:null,contentEditable:gn,controls:mt,controlsList:Vt,coords:Re|Ci,crossOrigin:null,data:null,dateTime:null,decoding:null,default:mt,defer:mt,dir:null,dirName:null,disabled:mt,download:Og,draggable:gn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:mt,formTarget:null,headers:Vt,height:Re,hidden:Og,high:Re,href:null,hrefLang:null,htmlFor:Vt,httpEquiv:Vt,id:null,imageSizes:null,imageSrcSet:null,inert:mt,inputMode:null,integrity:null,is:null,isMap:mt,itemId:null,itemProp:Vt,itemRef:Vt,itemScope:mt,itemType:Vt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:mt,low:Re,manifest:null,max:null,maxLength:Re,media:null,method:null,min:null,minLength:Re,multiple:mt,muted:mt,name:null,nonce:null,noModule:mt,noValidate:mt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:mt,optimum:Re,pattern:null,ping:Vt,placeholder:null,playsInline:mt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:mt,referrerPolicy:null,rel:Vt,required:mt,reversed:mt,rows:Re,rowSpan:Re,sandbox:Vt,scope:null,scoped:mt,seamless:mt,selected:mt,shadowRootClonable:mt,shadowRootDelegatesFocus:mt,shadowRootMode:null,shape:null,size:Re,sizes:null,slot:null,span:Re,spellCheck:gn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Re,step:null,style:null,tabIndex:Re,target:null,title:null,translate:null,type:null,typeMustMatch:mt,useMap:null,value:gn,width:Re,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Vt,axis:null,background:null,bgColor:null,border:Re,borderColor:null,bottomMargin:Re,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:mt,declare:mt,event:null,face:null,frame:null,frameBorder:null,hSpace:Re,leftMargin:Re,link:null,longDesc:null,lowSrc:null,marginHeight:Re,marginWidth:Re,noResize:mt,noHref:mt,noShade:mt,noWrap:mt,object:null,profile:null,prompt:null,rev:null,rightMargin:Re,rules:null,scheme:null,scrolling:gn,standby:null,summary:null,text:null,topMargin:Re,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Re,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:mt,disableRemotePlayback:mt,prefix:null,property:null,results:Re,security:null,unselectable:null},space:"html",transform:AC}),tF=Qi({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:vr,accentHeight:Re,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Re,amplitude:Re,arabicForm:null,ascent:Re,attributeName:null,attributeType:null,azimuth:Re,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Re,by:null,calcMode:null,capHeight:Re,className:Vt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Re,diffuseConstant:Re,direction:null,display:null,dur:null,divisor:Re,dominantBaseline:null,download:mt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Re,enableBackground:null,end:null,event:null,exponent:Re,externalResourcesRequired:null,fill:null,fillOpacity:Re,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Ci,g2:Ci,glyphName:Ci,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Re,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Re,horizOriginX:Re,horizOriginY:Re,id:null,ideographic:Re,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Re,k:Re,k1:Re,k2:Re,k3:Re,k4:Re,kernelMatrix:vr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Re,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Re,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Re,overlineThickness:Re,paintOrder:null,panose1:null,path:null,pathLength:Re,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Vt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Re,pointsAtY:Re,pointsAtZ:Re,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:vr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:vr,rev:vr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:vr,requiredFeatures:vr,requiredFonts:vr,requiredFormats:vr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Re,specularExponent:Re,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Re,strikethroughThickness:Re,string:null,stroke:null,strokeDashArray:vr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Re,strokeOpacity:Re,strokeWidth:null,style:null,surfaceScale:Re,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:vr,tabIndex:Re,tableValues:null,target:null,targetX:Re,targetY:Re,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:vr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Re,underlineThickness:Re,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Re,values:null,vAlphabetic:Re,vMathematical:Re,vectorEffect:null,vHanging:Re,vIdeographic:Re,version:null,vertAdvY:Re,vertOriginX:Re,vertOriginY:Re,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Re,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:RC}),PC=Qi({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),DC=Qi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:AC}),$C=Qi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),nF={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},rF=/[A-Z]/g,Mj=/-[a-z]/g,sF=/^data[-\w.:]+$/i;function oF(e,t){const n=Lg(t);let s=t,o=mr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&sF.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(Mj,iF);s="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!Mj.test(i)){let c=i.replace(rF,aF);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}o=py}return new o(s,t)}function aF(e){return"-"+e.toLowerCase()}function iF(e){return e.charAt(1).toUpperCase()}const lF=EC([TC,eF,PC,DC,$C],"html"),my=EC([TC,tF,PC,DC,$C],"svg");function cF(e){return e.join(" ").trim()}var si={},Ih,Fj;function uF(){if(Fj)return Ih;Fj=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,d=`
|
|
555
|
+
`||o==="\r"){n++;continue}if(o==="("){t.push({type:"LPAREN",text:o,pos:i}),n++;continue}if(o===")"){t.push({type:"RPAREN",text:o,pos:i}),n++;continue}if(o===","){t.push({type:"COMMA",text:o,pos:i}),n++;continue}if(o===":"){t.push({type:"COLON",text:o,pos:i}),n++;continue}if(o==="*"){t.push({type:"STAR",text:o,pos:i}),n++;continue}if(o==="<"||o===">"){e[n+1]==="="?(t.push({type:"OP",text:o+"=",pos:i}),n+=2):(t.push({type:"OP",text:o,pos:i}),n++);continue}if(o==="!"){if(e[n+1]==="="){t.push({type:"OP",text:"!=",pos:i}),n+=2;continue}throw new ui(i,'Unexpected "!" (did you mean "!="?)')}if(o==="="){n+=e[n+1]==="="?2:1,t.push({type:"OP",text:"=",pos:i});continue}if(o==='"'||o==="'"){const c=o;let u=n+1,d="";for(;u<e.length&&e[u]!==c;)e[u]==="\\"&&u+1<e.length?(d+=e[u+1],u+=2):(d+=e[u],u++);if(u>=e.length)throw new ui(i,"Unterminated string literal");t.push({type:"STRING",text:d,pos:i}),n=u+1;continue}if(o==="-"||o==="+"){if(/\d/.test(e[n+1]??"")){const c=o==="-"?-1:1;n++,t.push(s(i,c));continue}if(o==="-"){t.push({type:"MINUS",text:"-",pos:i}),n++;continue}throw new ui(i,'Unexpected "+"')}if(/\d/.test(o)){const c=e.slice(n).match($O);if(c){t.push({type:"DATE",text:c[0],pos:i}),n+=c[0].length;continue}t.push(s(i,0));continue}if(PO.test(o)){let c=n+1;for(;c<e.length&&DO.test(e[c]);)c++;const u=e.slice(n,c),d=u.toLowerCase();d==="and"?t.push({type:"AND",text:u,pos:i}):d==="or"?t.push({type:"OR",text:u,pos:i}):d==="not"?t.push({type:"NOT",text:u,pos:i}):t.push({type:"IDENT",text:u,pos:i}),n=c;continue}throw new ui(i,`Unexpected character "${o}"`)}return t.push({type:"EOF",text:"",pos:e.length}),t}class Xo extends Error{constructor(t,n){super(n),this.pos=t,this.name="ParseError"}}const OO=new Set(["IDENT","STRING","NUMBER","DATE","DURATION"]),IO=new Set(["IDENT","NOT","MINUS","LPAREN","STAR"]);class _O{constructor(t){Xm(this,"pos",0);this.tokens=t}peek(){return this.tokens[this.pos]}next(){return this.tokens[this.pos++]}expect(t,n){const s=this.peek();if(s.type!==t)throw new Xo(s.pos,`Expected ${n}, got "${s.text||s.type}"`);return this.next()}parseQuery(){if(this.peek().type==="EOF")return{kind:"all"};const t=this.orExpr(),n=this.peek();if(n.type!=="EOF")throw new Xo(n.pos,`Unexpected "${n.text}" — unbalanced parentheses or stray token`);return t}orExpr(){const t=[this.andExpr()];for(;this.peek().type==="OR";)this.next(),t.push(this.andExpr());return t.length===1?t[0]:{kind:"or",children:t}}andExpr(){const t=[this.unary()];for(;;){const n=this.peek();if(n.type==="AND")this.next(),t.push(this.unary());else if(IO.has(n.type))t.push(this.unary());else break}return t.length===1?t[0]:{kind:"and",children:t}}unary(){const t=this.peek();if(t.type==="NOT")return this.next(),{kind:"not",child:this.unary()};if(t.type==="MINUS"){this.next();const n=this.peek();if(n.type!=="IDENT")throw new Xo(n.pos,'Expected a field atom after "-" negation');return{kind:"not",child:this.atom()}}return this.primary()}primary(){const t=this.peek();if(t.type==="LPAREN"){this.next();const n=this.orExpr();return this.expect("RPAREN",'")"'),n}if(t.type==="STAR")return this.next(),{kind:"all"};if(t.type==="IDENT")return this.atom();throw new Xo(t.pos,`Expected a field, "(", "*", or NOT — got "${t.text||"end of query"}"`)}atom(){const t=this.expect("IDENT","a field name"),n=this.peek();if(n.type==="COLON"){this.next();const s=this.valueOrList();return{kind:"atom",field:t.text,op:":",values:s,pos:t.pos}}if(n.type==="OP"){this.next();const s=this.value();return{kind:"atom",field:t.text,op:n.text,values:[s],pos:t.pos}}throw new Xo(n.pos,`Expected ":" or a comparison operator after field "${t.text}"`)}valueOrList(){if(this.peek().type==="LPAREN"){this.next();const t=[this.value()];for(;this.peek().type==="COMMA";)this.next(),t.push(this.value());return this.expect("RPAREN",'")" to close the value list'),t}return[this.value()]}value(){const t=this.peek();if(!OO.has(t.type))throw new Xo(t.pos,`Expected a value, got "${t.text||t.type}"`);switch(this.next(),t.type){case"STRING":return{type:"string",raw:t.text,pos:t.pos};case"NUMBER":return{type:"number",raw:t.text,num:t.num,pos:t.pos};case"DATE":return{type:"date",raw:t.text,pos:t.pos};case"DURATION":return{type:"duration",raw:t.text,num:t.num,sign:t.sign??0,pos:t.pos};default:return{type:"word",raw:t.text,pos:t.pos}}}}function Wf(e){try{const t=LO(e);return{ast:new _O(t).parseQuery(),errors:[]}}catch(t){if(t instanceof ui||t instanceof Xo)return{ast:null,errors:[{pos:t.pos,message:t.message}]};throw t}}function Vx(e,t=Hf){const n=Wf(e);if(!n.ast)return{query:null,errors:n.errors};try{return{query:{predicate:rc(n.ast,t),ast:n.ast},errors:[]}}catch(s){if(s instanceof kr)return{query:null,errors:s.errors};throw s}}const MO=/^[A-Za-z_][A-Za-z0-9_-]*$/,FO=new Set(["and","or","not"]);function eN(e){return MO.test(e)&&!FO.has(e.toLowerCase())?e:tN(e)}function tN(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}const nN="__unassigned__",rN="__standalone__",zO={last_24h:"24h",last_7d:"7d",last_30d:"30d",last_90d:"90d",older_7d:"7d",older_30d:"30d"};function BO(e){return e.startsWith("older_")?"<":">="}const Hx=["status","type","priority","assignee","project","tags"],UO=["created","updated"];function VO(e){var i;const t={};for(const c of Hx){const u=ze(e[c]);u.length&&(t[c]=u)}const n=(i=e.search)==null?void 0:i.trim();n&&(t.search=n);let s=e.activity&&e.activity!=="all"?e.activity:void 0;const o=e.dateRange;if(o){const c=HO(o);if(c)s||(s=c);else{const u=WO(o);u&&(t.dateRange=u)}}return s&&(t.activity=s),t}function HO(e){return e.field!=="updated"||!e.preset?null:e.preset==="older_7d"?"stale":e.preset==="last_7d"?"fresh":null}function WO(e){if(e.preset)return{field:e.field,preset:e.preset};const t=e.from&&e.from.length>0?e.from:void 0,n=e.to&&e.to.length>0?e.to:void 0;if(!t&&!n)return null;const s={field:e.field};return t&&(s.from=t),n&&(s.to=n),s}function sc(e){const t=VO(e),n=[];for(const s of Hx){const o=t[s]??[];o.length&&n.push(KO(s,o))}return t.search&&n.push(`search:${tN(t.search)}`),t.activity==="stale"?n.push("updated < -7d"):t.activity==="fresh"&&n.push("updated >= -7d"),t.dateRange&&n.push(...GO(t.dateRange)),n.join(" AND ")}function KO(e,t){const n=t.map(s=>qO(e,s));return n.length===1?`${e}:${n[0]}`:`${e}:(${n.join(", ")})`}function qO(e,t){return e==="assignee"&&t===nN||e==="project"&&t===rN?"none":eN(t)}function GO(e){if(e.preset)return[`${e.field} ${BO(e.preset)} -${zO[e.preset]}`];const t=[];return e.from&&t.push(`${e.field} >= ${e.from}`),e.to&&t.push(`${e.field} <= ${e.to}`),t}function oc(e){const t=Wf(e);if(!t.ast)return null;const n=YO(t.ast);if(n===null)return null;const s={},o=new Set,i=new Map;for(const c of n){const u=QO(c);if(!u)return null;switch(u.kind){case"value":{if(o.has(u.field))return null;o.add(u.field),s[u.field]=u.values;break}case"search":{if(o.has("search"))return null;o.add("search"),s.search=u.text;break}case"activity":{if(o.has("activity"))return null;o.add("activity"),s.activity=u.activity;break}case"datePreset":{const d=`date:${u.field}`;if(o.has(d)||i.has(u.field))return null;o.add(d),s.dateRange={field:u.field,preset:u.preset};break}case"dateBound":{const d=`date:${u.field}`;if(o.has(d))return null;const m=i.get(u.field)??{};if(u.bound==="from"){if(m.from!==void 0)return null;m.from=u.date}else{if(m.to!==void 0)return null;m.to=u.date}i.set(u.field,m);break}}}if(i.size>1)return null;for(const[c,u]of i){if(s.dateRange)return null;const d={field:c};u.from!==void 0&&(d.from=u.from),u.to!==void 0&&(d.to=u.to),s.dateRange=d}return s}function YO(e){if(e.kind==="all")return[];if(e.kind==="atom")return[e];if(e.kind==="and"){const t=[];for(const n of e.children){if(n.kind!=="atom")return null;t.push(n)}return t}return null}function QO(e){const t=e.field.toLowerCase();if(e.op===":"){if(Hx.includes(t)){const o=t,i=[];for(const c of e.values){const u=tI(o,c);if(u===null)return null;i.push(u)}return i.length===0?null:{kind:"value",field:o,values:i}}return t==="search"?e.values.length!==1?null:{kind:"search",text:e.values[0].raw}:null}if(!UO.includes(t))return null;const n=t;if(e.values.length!==1)return null;const s=e.values[0];return s.type==="duration"?JO(n,e.op,s):s.type==="date"?e.op===">="?{kind:"dateBound",field:n,bound:"from",date:s.raw}:e.op==="<="?{kind:"dateBound",field:n,bound:"to",date:s.raw}:null:null}function JO(e,t,n){if(n.sign!==-1)return null;const s=XO(n.raw);if(e==="updated"){if(t==="<"&&s==="7d")return{kind:"activity",activity:"stale"};if(t===">="&&s==="7d")return{kind:"activity",activity:"fresh"}}const o=eI(t,s);return o?{kind:"datePreset",field:e,preset:o}:null}function XO(e){return e.replace(/^[-+]/,"")}const ZO={">=":{"24h":"last_24h","7d":"last_7d","30d":"last_30d","90d":"last_90d"},"<":{"7d":"older_7d","30d":"older_30d"}};function eI(e,t){return e!==">="&&e!=="<"?null:ZO[e][t]??null}function tI(e,t){const n=t.raw;return e==="assignee"&&n.toLowerCase()==="none"?nN:e==="project"&&n.toLowerCase()==="none"?rN:n}const Ch=["title","status","priority","assignee","dependencies","created","updated"],nI=["small","wide","tall","large"],rI={status:"all",priority:"all",assignee:"all",project:"all",activity:"all"},aj="2026-05-21T00:00:00Z";function Eh(e,t,n){return{id:e,name:t,workspace:null,entityType:"assignment",config:{viewMode:"list",filters:{...rI,...n},sortField:"updated",sortDirection:"desc",listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}},createdAt:aj,updatedAt:aj}}const wo={version:1,views:[Eh("default-recently-updated","Recently updated",{}),Eh("default-high-priority","High priority",{priority:"high"}),Eh("default-stale","Stale",{activity:"stale"})],dashboard:{version:1,slots:[{id:"slot-0",widget:{kind:"agent-sessions"}},{id:"slot-1",widget:{kind:"saved-view",viewId:"default-recently-updated"}},{id:"slot-2",widget:{kind:"saved-view",viewId:"default-high-priority"}},{id:"slot-3",widget:{kind:"saved-view",viewId:"default-stale"}},{id:"slot-4",widget:{kind:"inventories"}}]}};function sN(e,t){const n=ze(e.filters.project),s=n.length===0||n.length===1&&n[0]===t,o=e.filters.activity,i=typeof e.filters.search=="string"&&e.filters.search.trim().length>0,c=e.filters.query,u=typeof c=="string"&&c.trim().length>0&&oc(c)===null;return s&&(!o||o==="all")&&!i&&!u}function oN(e,t){switch(t.kind){case"global":return e.workspace===null;case"workspace":return e.workspace===t.workspace||e.workspace===null;case"project":return e.workspace===t.workspace||e.workspace===null?sN(e.config,t.slug):!1}}const aN=`syntaur.savedViews.cache.v${wo.version}`;let ki=sI(),Zo=null,Wx=null;const jg=new Set,Zd=new Set;let iN=0;function lN(){return++iN}function kg(e){return e===iN}function sI(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(aN);if(!e)return null;const t=JSON.parse(e);return t.version!==wo.version?null:t}catch{return null}}function oI(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(aN,JSON.stringify(e))}catch{}}function cN(e){ki=e,Wx=null,oI(e);for(const t of jg)t(e);for(const t of Zd)t(null)}function aI(e){Wx=e;for(const t of Zd)t(e)}function uN(e){if(!e||typeof e!="object")return wo;const t=e;return t.version!==wo.version||!Array.isArray(t.views)||!t.dashboard?wo:t}function ij(){if(Zo)return Zo;const e=lN();return Zo=fetch("/api/saved-views").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=uN(t);return kg(e)&&cN(n),Zo=null,ki??n}).catch(t=>{const n=t instanceof Error?t:new Error(String(t));return kg(e)&&aI(n),Zo=null,ki??wo}),Zo}function Kx(){const[e,t]=p.useState(()=>ki??wo),[n,s]=p.useState(()=>ki===null),[o,i]=p.useState(!1),[c,u]=p.useState(()=>Wx);return p.useEffect(()=>{let m=!1;ki===null&&s(!0),ij().then(y=>{m||(t(y),s(!1),i(!0))});const h=y=>{m||(t(y),s(!1),i(!0),u(null))},g=y=>{m||(u(y),s(!1),i(!0))};return jg.add(h),Zd.add(g),()=>{m=!0,jg.delete(h),Zd.delete(g)}},[]),{file:e,loading:n,ready:o,error:c,refetch:()=>{Zo=null,s(!0),u(null),i(!1),ij()}}}function Mc(){const{file:e,loading:t}=Kx();return{views:e.views,loading:t}}function dN(){const{file:e,loading:t}=Kx();return{layout:e.dashboard,loading:t}}function So(e){const{file:t,loading:n,ready:s,error:o,refetch:i}=Kx();return e?{view:t.views.find(u=>u.id===e)??null,loading:n,ready:s,error:o,refetch:i}:{view:null,loading:!1,ready:!0,error:null,refetch:i}}async function Kf(e,t,n){const s=lN(),o=await fetch(t,{method:e,headers:n!==void 0?{"Content-Type":"application/json"}:void 0,body:n!==void 0?JSON.stringify(n):void 0});if(!o.ok){const c=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(c.error??`HTTP ${o.status}`)}const i=uN(await o.json());return kg(s)&&cN(i),i}function Pi(e){return Kf("POST","/api/saved-views",e)}function ef(e,t){return Kf("PATCH",`/api/saved-views/${encodeURIComponent(e)}`,t)}function iI(e){return Kf("DELETE",`/api/saved-views/${encodeURIComponent(e)}`)}function Sg(e){return Kf("PUT","/api/dashboard",{slots:e})}const lI=["top","right","bottom","left"],No=Math.min,Sr=Math.max,tf=Math.round,fd=Math.floor,Ss=e=>({x:e,y:e}),cI={left:"right",right:"left",bottom:"top",top:"bottom"};function Ng(e,t,n){return Sr(e,No(t,n))}function Vs(e,t){return typeof e=="function"?e(t):e}function Hs(e){return e.split("-")[0]}function Gi(e){return e.split("-")[1]}function qx(e){return e==="x"?"y":"x"}function Gx(e){return e==="y"?"height":"width"}function ws(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Yx(e){return qx(ws(e))}function uI(e,t,n){n===void 0&&(n=!1);const s=Gi(e),o=Yx(e),i=Gx(o);let c=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(c=nf(c)),[c,nf(c)]}function dI(e){const t=nf(e);return[Cg(e),t,Cg(t)]}function Cg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const lj=["left","right"],cj=["right","left"],fI=["top","bottom"],pI=["bottom","top"];function mI(e,t,n){switch(e){case"top":case"bottom":return n?t?cj:lj:t?lj:cj;case"left":case"right":return t?fI:pI;default:return[]}}function hI(e,t,n,s){const o=Gi(e);let i=mI(Hs(e),n==="start",s);return o&&(i=i.map(c=>c+"-"+o),t&&(i=i.concat(i.map(Cg)))),i}function nf(e){const t=Hs(e);return cI[t]+e.slice(t.length)}function gI(e){return{top:0,right:0,bottom:0,left:0,...e}}function fN(e){return typeof e!="number"?gI(e):{top:e,right:e,bottom:e,left:e}}function rf(e){const{x:t,y:n,width:s,height:o}=e;return{width:s,height:o,top:n,left:t,right:t+s,bottom:n+o,x:t,y:n}}function uj(e,t,n){let{reference:s,floating:o}=e;const i=ws(t),c=Yx(t),u=Gx(c),d=Hs(t),m=i==="y",h=s.x+s.width/2-o.width/2,g=s.y+s.height/2-o.height/2,y=s[u]/2-o[u]/2;let b;switch(d){case"top":b={x:h,y:s.y-o.height};break;case"bottom":b={x:h,y:s.y+s.height};break;case"right":b={x:s.x+s.width,y:g};break;case"left":b={x:s.x-o.width,y:g};break;default:b={x:s.x,y:s.y}}switch(Gi(t)){case"start":b[c]-=y*(n&&m?-1:1);break;case"end":b[c]+=y*(n&&m?-1:1);break}return b}async function xI(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:i,rects:c,elements:u,strategy:d}=e,{boundary:m="clippingAncestors",rootBoundary:h="viewport",elementContext:g="floating",altBoundary:y=!1,padding:b=0}=Vs(t,e),C=fN(b),v=u[y?g==="floating"?"reference":"floating":g],k=rf(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(v)))==null||n?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(u.floating)),boundary:m,rootBoundary:h,strategy:d})),E=g==="floating"?{x:s,y:o,width:c.floating.width,height:c.floating.height}:c.reference,S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u.floating)),T=await(i.isElement==null?void 0:i.isElement(S))?await(i.getScale==null?void 0:i.getScale(S))||{x:1,y:1}:{x:1,y:1},P=rf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:E,offsetParent:S,strategy:d}):E);return{top:(k.top-P.top+C.top)/T.y,bottom:(P.bottom-k.bottom+C.bottom)/T.y,left:(k.left-P.left+C.left)/T.x,right:(P.right-k.right+C.right)/T.x}}const yI=50,bI=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:i=[],platform:c}=n,u=c.detectOverflow?c:{...c,detectOverflow:xI},d=await(c.isRTL==null?void 0:c.isRTL(t));let m=await c.getElementRects({reference:e,floating:t,strategy:o}),{x:h,y:g}=uj(m,s,d),y=s,b=0;const C={};for(let j=0;j<i.length;j++){const v=i[j];if(!v)continue;const{name:k,fn:E}=v,{x:S,y:T,data:P,reset:R}=await E({x:h,y:g,initialPlacement:s,placement:y,strategy:o,middlewareData:C,rects:m,platform:u,elements:{reference:e,floating:t}});h=S??h,g=T??g,C[k]={...C[k],...P},R&&b<yI&&(b++,typeof R=="object"&&(R.placement&&(y=R.placement),R.rects&&(m=R.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:o}):R.rects),{x:h,y:g}=uj(m,y,d)),j=-1)}return{x:h,y:g,placement:y,strategy:o,middlewareData:C}},vI=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:i,platform:c,elements:u,middlewareData:d}=t,{element:m,padding:h=0}=Vs(e,t)||{};if(m==null)return{};const g=fN(h),y={x:n,y:s},b=Yx(o),C=Gx(b),j=await c.getDimensions(m),v=b==="y",k=v?"top":"left",E=v?"bottom":"right",S=v?"clientHeight":"clientWidth",T=i.reference[C]+i.reference[b]-y[b]-i.floating[C],P=y[b]-i.reference[b],R=await(c.getOffsetParent==null?void 0:c.getOffsetParent(m));let A=R?R[S]:0;(!A||!await(c.isElement==null?void 0:c.isElement(R)))&&(A=u.floating[S]||i.floating[C]);const $=T/2-P/2,M=A/2-j[C]/2-1,_=No(g[k],M),D=No(g[E],M),V=_,K=A-j[C]-D,I=A/2-j[C]/2+$,F=Ng(V,I,K),q=!d.arrow&&Gi(o)!=null&&I!==F&&i.reference[C]/2-(I<V?_:D)-j[C]/2<0,Z=q?I<V?I-V:I-K:0;return{[b]:y[b]+Z,data:{[b]:F,centerOffset:I-F-Z,...q&&{alignmentOffset:Z}},reset:q}}}),wI=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:o,middlewareData:i,rects:c,initialPlacement:u,platform:d,elements:m}=t,{mainAxis:h=!0,crossAxis:g=!0,fallbackPlacements:y,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:j=!0,...v}=Vs(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const k=Hs(o),E=ws(u),S=Hs(u)===u,T=await(d.isRTL==null?void 0:d.isRTL(m.floating)),P=y||(S||!j?[nf(u)]:dI(u)),R=C!=="none";!y&&R&&P.push(...hI(u,j,C,T));const A=[u,...P],$=await d.detectOverflow(t,v),M=[];let _=((s=i.flip)==null?void 0:s.overflows)||[];if(h&&M.push($[k]),g){const I=uI(o,c,T);M.push($[I[0]],$[I[1]])}if(_=[..._,{placement:o,overflows:M}],!M.every(I=>I<=0)){var D,V;const I=(((D=i.flip)==null?void 0:D.index)||0)+1,F=A[I];if(F&&(!(g==="alignment"?E!==ws(F):!1)||_.every(z=>ws(z.placement)===E?z.overflows[0]>0:!0)))return{data:{index:I,overflows:_},reset:{placement:F}};let q=(V=_.filter(Z=>Z.overflows[0]<=0).sort((Z,z)=>Z.overflows[1]-z.overflows[1])[0])==null?void 0:V.placement;if(!q)switch(b){case"bestFit":{var K;const Z=(K=_.filter(z=>{if(R){const G=ws(z.placement);return G===E||G==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(G=>G>0).reduce((G,L)=>G+L,0)]).sort((z,G)=>z[1]-G[1])[0])==null?void 0:K[0];Z&&(q=Z);break}case"initialPlacement":q=u;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function dj(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function fj(e){return lI.some(t=>e[t]>=0)}const jI=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:o="referenceHidden",...i}=Vs(e,t);switch(o){case"referenceHidden":{const c=await s.detectOverflow(t,{...i,elementContext:"reference"}),u=dj(c,n.reference);return{data:{referenceHiddenOffsets:u,referenceHidden:fj(u)}}}case"escaped":{const c=await s.detectOverflow(t,{...i,altBoundary:!0}),u=dj(c,n.floating);return{data:{escapedOffsets:u,escaped:fj(u)}}}default:return{}}}}},pN=new Set(["left","top"]);async function kI(e,t){const{placement:n,platform:s,elements:o}=e,i=await(s.isRTL==null?void 0:s.isRTL(o.floating)),c=Hs(n),u=Gi(n),d=ws(n)==="y",m=pN.has(c)?-1:1,h=i&&d?-1:1,g=Vs(t,e);let{mainAxis:y,crossAxis:b,alignmentAxis:C}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return u&&typeof C=="number"&&(b=u==="end"?C*-1:C),d?{x:b*h,y:y*m}:{x:y*m,y:b*h}}const SI=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:o,y:i,placement:c,middlewareData:u}=t,d=await kI(t,e);return c===((n=u.offset)==null?void 0:n.placement)&&(s=u.arrow)!=null&&s.alignmentOffset?{}:{x:o+d.x,y:i+d.y,data:{...d,placement:c}}}}},NI=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:o,platform:i}=t,{mainAxis:c=!0,crossAxis:u=!1,limiter:d={fn:k=>{let{x:E,y:S}=k;return{x:E,y:S}}},...m}=Vs(e,t),h={x:n,y:s},g=await i.detectOverflow(t,m),y=ws(Hs(o)),b=qx(y);let C=h[b],j=h[y];if(c){const k=b==="y"?"top":"left",E=b==="y"?"bottom":"right",S=C+g[k],T=C-g[E];C=Ng(S,C,T)}if(u){const k=y==="y"?"top":"left",E=y==="y"?"bottom":"right",S=j+g[k],T=j-g[E];j=Ng(S,j,T)}const v=d.fn({...t,[b]:C,[y]:j});return{...v,data:{x:v.x-n,y:v.y-s,enabled:{[b]:c,[y]:u}}}}}},CI=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:o,rects:i,middlewareData:c}=t,{offset:u=0,mainAxis:d=!0,crossAxis:m=!0}=Vs(e,t),h={x:n,y:s},g=ws(o),y=qx(g);let b=h[y],C=h[g];const j=Vs(u,t),v=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(d){const S=y==="y"?"height":"width",T=i.reference[y]-i.floating[S]+v.mainAxis,P=i.reference[y]+i.reference[S]-v.mainAxis;b<T?b=T:b>P&&(b=P)}if(m){var k,E;const S=y==="y"?"width":"height",T=pN.has(Hs(o)),P=i.reference[g]-i.floating[S]+(T&&((k=c.offset)==null?void 0:k[g])||0)+(T?0:v.crossAxis),R=i.reference[g]+i.reference[S]+(T?0:((E=c.offset)==null?void 0:E[g])||0)-(T?v.crossAxis:0);C<P?C=P:C>R&&(C=R)}return{[y]:b,[g]:C}}}},EI=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:o,rects:i,platform:c,elements:u}=t,{apply:d=()=>{},...m}=Vs(e,t),h=await c.detectOverflow(t,m),g=Hs(o),y=Gi(o),b=ws(o)==="y",{width:C,height:j}=i.floating;let v,k;g==="top"||g==="bottom"?(v=g,k=y===(await(c.isRTL==null?void 0:c.isRTL(u.floating))?"start":"end")?"left":"right"):(k=g,v=y==="end"?"top":"bottom");const E=j-h.top-h.bottom,S=C-h.left-h.right,T=No(j-h[v],E),P=No(C-h[k],S),R=!t.middlewareData.shift;let A=T,$=P;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&($=S),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(A=E),R&&!y){const _=Sr(h.left,0),D=Sr(h.right,0),V=Sr(h.top,0),K=Sr(h.bottom,0);b?$=C-2*(_!==0||D!==0?_+D:Sr(h.left,h.right)):A=j-2*(V!==0||K!==0?V+K:Sr(h.top,h.bottom))}await d({...t,availableWidth:$,availableHeight:A});const M=await c.getDimensions(u.floating);return C!==M.width||j!==M.height?{reset:{rects:!0}}:{}}}};function qf(){return typeof window<"u"}function Yi(e){return mN(e)?(e.nodeName||"").toLowerCase():"#document"}function Tr(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Es(e){var t;return(t=(mN(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function mN(e){return qf()?e instanceof Node||e instanceof Tr(e).Node:!1}function os(e){return qf()?e instanceof Element||e instanceof Tr(e).Element:!1}function Ks(e){return qf()?e instanceof HTMLElement||e instanceof Tr(e).HTMLElement:!1}function pj(e){return!qf()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Tr(e).ShadowRoot}function Fc(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=as(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&o!=="inline"&&o!=="contents"}function TI(e){return/^(table|td|th)$/.test(Yi(e))}function Gf(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const RI=/transform|translate|scale|rotate|perspective|filter/,AI=/paint|layout|strict|content/,Qo=e=>!!e&&e!=="none";let Th;function Qx(e){const t=os(e)?as(e):e;return Qo(t.transform)||Qo(t.translate)||Qo(t.scale)||Qo(t.rotate)||Qo(t.perspective)||!Jx()&&(Qo(t.backdropFilter)||Qo(t.filter))||RI.test(t.willChange||"")||AI.test(t.contain||"")}function PI(e){let t=Co(e);for(;Ks(t)&&!Di(t);){if(Qx(t))return t;if(Gf(t))return null;t=Co(t)}return null}function Jx(){return Th==null&&(Th=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Th}function Di(e){return/^(html|body|#document)$/.test(Yi(e))}function as(e){return Tr(e).getComputedStyle(e)}function Yf(e){return os(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Co(e){if(Yi(e)==="html")return e;const t=e.assignedSlot||e.parentNode||pj(e)&&e.host||Es(e);return pj(t)?t.host:t}function hN(e){const t=Co(e);return Di(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ks(t)&&Fc(t)?t:hN(t)}function vc(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=hN(e),i=o===((s=e.ownerDocument)==null?void 0:s.body),c=Tr(o);if(i){const u=Eg(c);return t.concat(c,c.visualViewport||[],Fc(o)?o:[],u&&n?vc(u):[])}else return t.concat(o,vc(o,[],n))}function Eg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function gN(e){const t=as(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=Ks(e),i=o?e.offsetWidth:n,c=o?e.offsetHeight:s,u=tf(n)!==i||tf(s)!==c;return u&&(n=i,s=c),{width:n,height:s,$:u}}function Xx(e){return os(e)?e:e.contextElement}function Si(e){const t=Xx(e);if(!Ks(t))return Ss(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:i}=gN(t);let c=(i?tf(n.width):n.width)/s,u=(i?tf(n.height):n.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!u||!Number.isFinite(u))&&(u=1),{x:c,y:u}}const DI=Ss(0);function xN(e){const t=Tr(e);return!Jx()||!t.visualViewport?DI:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $I(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Tr(e)?!1:t}function da(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Xx(e);let c=Ss(1);t&&(s?os(s)&&(c=Si(s)):c=Si(e));const u=$I(i,n,s)?xN(i):Ss(0);let d=(o.left+u.x)/c.x,m=(o.top+u.y)/c.y,h=o.width/c.x,g=o.height/c.y;if(i){const y=Tr(i),b=s&&os(s)?Tr(s):s;let C=y,j=Eg(C);for(;j&&s&&b!==C;){const v=Si(j),k=j.getBoundingClientRect(),E=as(j),S=k.left+(j.clientLeft+parseFloat(E.paddingLeft))*v.x,T=k.top+(j.clientTop+parseFloat(E.paddingTop))*v.y;d*=v.x,m*=v.y,h*=v.x,g*=v.y,d+=S,m+=T,C=Tr(j),j=Eg(C)}}return rf({width:h,height:g,x:d,y:m})}function Qf(e,t){const n=Yf(e).scrollLeft;return t?t.left+n:da(Es(e)).left+n}function yN(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Qf(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function LI(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const i=o==="fixed",c=Es(s),u=t?Gf(t.floating):!1;if(s===c||u&&i)return n;let d={scrollLeft:0,scrollTop:0},m=Ss(1);const h=Ss(0),g=Ks(s);if((g||!g&&!i)&&((Yi(s)!=="body"||Fc(c))&&(d=Yf(s)),g)){const b=da(s);m=Si(s),h.x=b.x+s.clientLeft,h.y=b.y+s.clientTop}const y=c&&!g&&!i?yN(c,d):Ss(0);return{width:n.width*m.x,height:n.height*m.y,x:n.x*m.x-d.scrollLeft*m.x+h.x+y.x,y:n.y*m.y-d.scrollTop*m.y+h.y+y.y}}function OI(e){return Array.from(e.getClientRects())}function II(e){const t=Es(e),n=Yf(e),s=e.ownerDocument.body,o=Sr(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),i=Sr(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let c=-n.scrollLeft+Qf(e);const u=-n.scrollTop;return as(s).direction==="rtl"&&(c+=Sr(t.clientWidth,s.clientWidth)-o),{width:o,height:i,x:c,y:u}}const mj=25;function _I(e,t){const n=Tr(e),s=Es(e),o=n.visualViewport;let i=s.clientWidth,c=s.clientHeight,u=0,d=0;if(o){i=o.width,c=o.height;const h=Jx();(!h||h&&t==="fixed")&&(u=o.offsetLeft,d=o.offsetTop)}const m=Qf(s);if(m<=0){const h=s.ownerDocument,g=h.body,y=getComputedStyle(g),b=h.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,C=Math.abs(s.clientWidth-g.clientWidth-b);C<=mj&&(i-=C)}else m<=mj&&(i+=m);return{width:i,height:c,x:u,y:d}}function MI(e,t){const n=da(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,i=Ks(e)?Si(e):Ss(1),c=e.clientWidth*i.x,u=e.clientHeight*i.y,d=o*i.x,m=s*i.y;return{width:c,height:u,x:d,y:m}}function hj(e,t,n){let s;if(t==="viewport")s=_I(e,n);else if(t==="document")s=II(Es(e));else if(os(t))s=MI(t,n);else{const o=xN(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return rf(s)}function bN(e,t){const n=Co(e);return n===t||!os(n)||Di(n)?!1:as(n).position==="fixed"||bN(n,t)}function FI(e,t){const n=t.get(e);if(n)return n;let s=vc(e,[],!1).filter(u=>os(u)&&Yi(u)!=="body"),o=null;const i=as(e).position==="fixed";let c=i?Co(e):e;for(;os(c)&&!Di(c);){const u=as(c),d=Qx(c);!d&&u.position==="fixed"&&(o=null),(i?!d&&!o:!d&&u.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Fc(c)&&!d&&bN(e,c))?s=s.filter(h=>h!==c):o=u,c=Co(c)}return t.set(e,s),s}function zI(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const c=[...n==="clippingAncestors"?Gf(t)?[]:FI(t,this._c):[].concat(n),s],u=hj(t,c[0],o);let d=u.top,m=u.right,h=u.bottom,g=u.left;for(let y=1;y<c.length;y++){const b=hj(t,c[y],o);d=Sr(b.top,d),m=No(b.right,m),h=No(b.bottom,h),g=Sr(b.left,g)}return{width:m-g,height:h-d,x:g,y:d}}function BI(e){const{width:t,height:n}=gN(e);return{width:t,height:n}}function UI(e,t,n){const s=Ks(t),o=Es(t),i=n==="fixed",c=da(e,!0,i,t);let u={scrollLeft:0,scrollTop:0};const d=Ss(0);function m(){d.x=Qf(o)}if(s||!s&&!i)if((Yi(t)!=="body"||Fc(o))&&(u=Yf(t)),s){const b=da(t,!0,i,t);d.x=b.x+t.clientLeft,d.y=b.y+t.clientTop}else o&&m();i&&!s&&o&&m();const h=o&&!s&&!i?yN(o,u):Ss(0),g=c.left+u.scrollLeft-d.x-h.x,y=c.top+u.scrollTop-d.y-h.y;return{x:g,y,width:c.width,height:c.height}}function Rh(e){return as(e).position==="static"}function gj(e,t){if(!Ks(e)||as(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Es(e)===n&&(n=n.ownerDocument.body),n}function vN(e,t){const n=Tr(e);if(Gf(e))return n;if(!Ks(e)){let o=Co(e);for(;o&&!Di(o);){if(os(o)&&!Rh(o))return o;o=Co(o)}return n}let s=gj(e,t);for(;s&&TI(s)&&Rh(s);)s=gj(s,t);return s&&Di(s)&&Rh(s)&&!Qx(s)?n:s||PI(e)||n}const VI=async function(e){const t=this.getOffsetParent||vN,n=this.getDimensions,s=await n(e.floating);return{reference:UI(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function HI(e){return as(e).direction==="rtl"}const WI={convertOffsetParentRelativeRectToViewportRelativeRect:LI,getDocumentElement:Es,getClippingRect:zI,getOffsetParent:vN,getElementRects:VI,getClientRects:OI,getDimensions:BI,getScale:Si,isElement:os,isRTL:HI};function wN(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function KI(e,t){let n=null,s;const o=Es(e);function i(){var u;clearTimeout(s),(u=n)==null||u.disconnect(),n=null}function c(u,d){u===void 0&&(u=!1),d===void 0&&(d=1),i();const m=e.getBoundingClientRect(),{left:h,top:g,width:y,height:b}=m;if(u||t(),!y||!b)return;const C=fd(g),j=fd(o.clientWidth-(h+y)),v=fd(o.clientHeight-(g+b)),k=fd(h),S={rootMargin:-C+"px "+-j+"px "+-v+"px "+-k+"px",threshold:Sr(0,No(1,d))||1};let T=!0;function P(R){const A=R[0].intersectionRatio;if(A!==d){if(!T)return c();A?c(!1,A):s=setTimeout(()=>{c(!1,1e-7)},1e3)}A===1&&!wN(m,e.getBoundingClientRect())&&c(),T=!1}try{n=new IntersectionObserver(P,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(P,S)}n.observe(e)}return c(!0),i}function qI(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:d=!1}=s,m=Xx(e),h=o||i?[...m?vc(m):[],...t?vc(t):[]]:[];h.forEach(k=>{o&&k.addEventListener("scroll",n,{passive:!0}),i&&k.addEventListener("resize",n)});const g=m&&u?KI(m,n):null;let y=-1,b=null;c&&(b=new ResizeObserver(k=>{let[E]=k;E&&E.target===m&&b&&t&&(b.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var S;(S=b)==null||S.observe(t)})),n()}),m&&!d&&b.observe(m),t&&b.observe(t));let C,j=d?da(e):null;d&&v();function v(){const k=da(e);j&&!wN(j,k)&&n(),j=k,C=requestAnimationFrame(v)}return n(),()=>{var k;h.forEach(E=>{o&&E.removeEventListener("scroll",n),i&&E.removeEventListener("resize",n)}),g==null||g(),(k=b)==null||k.disconnect(),b=null,d&&cancelAnimationFrame(C)}}const GI=SI,YI=NI,QI=wI,JI=EI,XI=jI,xj=vI,ZI=CI,e_=(e,t,n)=>{const s=new Map,o={platform:WI,...n},i={...o.platform,_c:s};return bI(e,t,{...o,platform:i})};var t_=typeof document<"u",n_=function(){},$d=t_?p.useLayoutEffect:n_;function sf(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!sf(e[s],t[s]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,o[s]))return!1;for(s=n;s--!==0;){const i=o[s];if(!(i==="_owner"&&e.$$typeof)&&!sf(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function jN(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function yj(e,t){const n=jN(e);return Math.round(t*n)/n}function Ah(e){const t=p.useRef(e);return $d(()=>{t.current=e}),t}function r_(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:o,elements:{reference:i,floating:c}={},transform:u=!0,whileElementsMounted:d,open:m}=e,[h,g]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[y,b]=p.useState(s);sf(y,s)||b(s);const[C,j]=p.useState(null),[v,k]=p.useState(null),E=p.useCallback(z=>{z!==R.current&&(R.current=z,j(z))},[]),S=p.useCallback(z=>{z!==A.current&&(A.current=z,k(z))},[]),T=i||C,P=c||v,R=p.useRef(null),A=p.useRef(null),$=p.useRef(h),M=d!=null,_=Ah(d),D=Ah(o),V=Ah(m),K=p.useCallback(()=>{if(!R.current||!A.current)return;const z={placement:t,strategy:n,middleware:y};D.current&&(z.platform=D.current),e_(R.current,A.current,z).then(G=>{const L={...G,isPositioned:V.current!==!1};I.current&&!sf($.current,L)&&($.current=L,Fs.flushSync(()=>{g(L)}))})},[y,t,n,D,V]);$d(()=>{m===!1&&$.current.isPositioned&&($.current.isPositioned=!1,g(z=>({...z,isPositioned:!1})))},[m]);const I=p.useRef(!1);$d(()=>(I.current=!0,()=>{I.current=!1}),[]),$d(()=>{if(T&&(R.current=T),P&&(A.current=P),T&&P){if(_.current)return _.current(T,P,K);K()}},[T,P,K,_,M]);const F=p.useMemo(()=>({reference:R,floating:A,setReference:E,setFloating:S}),[E,S]),q=p.useMemo(()=>({reference:T,floating:P}),[T,P]),Z=p.useMemo(()=>{const z={position:n,left:0,top:0};if(!q.floating)return z;const G=yj(q.floating,h.x),L=yj(q.floating,h.y);return u?{...z,transform:"translate("+G+"px, "+L+"px)",...jN(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:G,top:L}},[n,u,q.floating,h.x,h.y]);return p.useMemo(()=>({...h,update:K,refs:F,elements:q,floatingStyles:Z}),[h,K,F,q,Z])}const s_=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:o}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?xj({element:s.current,padding:o}).fn(n):{}:s?xj({element:s,padding:o}).fn(n):{}}}},o_=(e,t)=>{const n=GI(e);return{name:n.name,fn:n.fn,options:[e,t]}},a_=(e,t)=>{const n=YI(e);return{name:n.name,fn:n.fn,options:[e,t]}},i_=(e,t)=>({fn:ZI(e).fn,options:[e,t]}),l_=(e,t)=>{const n=QI(e);return{name:n.name,fn:n.fn,options:[e,t]}},c_=(e,t)=>{const n=JI(e);return{name:n.name,fn:n.fn,options:[e,t]}},u_=(e,t)=>{const n=XI(e);return{name:n.name,fn:n.fn,options:[e,t]}},d_=(e,t)=>{const n=s_(e);return{name:n.name,fn:n.fn,options:[e,t]}};var f_="Arrow",kN=p.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...i}=e;return r.jsx(vn.svg,{...i,ref:t,width:s,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});kN.displayName=f_;var p_=kN;function m_(e){const[t,n]=p.useState(void 0);return jo(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let c,u;if("borderBoxSize"in i){const d=i.borderBoxSize,m=Array.isArray(d)?d[0]:d;c=m.inlineSize,u=m.blockSize}else c=e.offsetWidth,u=e.offsetHeight;n({width:c,height:u})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var Zx="Popper",[SN,NN]=pa(Zx),[h_,CN]=SN(Zx),EN=e=>{const{__scopePopper:t,children:n}=e,[s,o]=p.useState(null);return r.jsx(h_,{scope:t,anchor:s,onAnchorChange:o,children:n})};EN.displayName=Zx;var TN="PopperAnchor",RN=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,i=CN(TN,n),c=p.useRef(null),u=qn(t,c),d=p.useRef(null);return p.useEffect(()=>{const m=d.current;d.current=(s==null?void 0:s.current)||c.current,m!==d.current&&i.onAnchorChange(d.current)}),s?null:r.jsx(vn.div,{...o,ref:u})});RN.displayName=TN;var ey="PopperContent",[g_,x_]=SN(ey),AN=p.forwardRef((e,t)=>{var ye,Se,Te,Pe,Ke,ct;const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:i="center",alignOffset:c=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:m=[],collisionPadding:h=0,sticky:g="partial",hideWhenDetached:y=!1,updatePositionStrategy:b="optimized",onPlaced:C,...j}=e,v=CN(ey,n),[k,E]=p.useState(null),S=qn(t,et=>E(et)),[T,P]=p.useState(null),R=m_(T),A=(R==null?void 0:R.width)??0,$=(R==null?void 0:R.height)??0,M=s+(i!=="center"?"-"+i:""),_=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},D=Array.isArray(m)?m:[m],V=D.length>0,K={padding:_,boundary:D.filter(b_),altBoundary:V},{refs:I,floatingStyles:F,placement:q,isPositioned:Z,middlewareData:z}=r_({strategy:"fixed",placement:M,whileElementsMounted:(...et)=>qI(...et,{animationFrame:b==="always"}),elements:{reference:v.anchor},middleware:[o_({mainAxis:o+$,alignmentAxis:c}),d&&a_({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?i_():void 0,...K}),d&&l_({...K}),c_({...K,apply:({elements:et,rects:ot,availableWidth:X,availableHeight:Me})=>{const{width:Ce,height:Ie}=ot.reference,Ye=et.floating.style;Ye.setProperty("--radix-popper-available-width",`${X}px`),Ye.setProperty("--radix-popper-available-height",`${Me}px`),Ye.setProperty("--radix-popper-anchor-width",`${Ce}px`),Ye.setProperty("--radix-popper-anchor-height",`${Ie}px`)}}),T&&d_({element:T,padding:u}),v_({arrowWidth:A,arrowHeight:$}),y&&u_({strategy:"referenceHidden",...K})]}),[G,L]=$N(q),H=ca(C);jo(()=>{Z&&(H==null||H())},[Z,H]);const re=(ye=z.arrow)==null?void 0:ye.x,U=(Se=z.arrow)==null?void 0:Se.y,ue=((Te=z.arrow)==null?void 0:Te.centerOffset)!==0,[ge,se]=p.useState();return jo(()=>{k&&se(window.getComputedStyle(k).zIndex)},[k]),r.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:Z?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[(Pe=z.transformOrigin)==null?void 0:Pe.x,(Ke=z.transformOrigin)==null?void 0:Ke.y].join(" "),...((ct=z.hide)==null?void 0:ct.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(g_,{scope:n,placedSide:G,onArrowChange:P,arrowX:re,arrowY:U,shouldHideArrow:ue,children:r.jsx(vn.div,{"data-side":G,"data-align":L,...j,ref:S,style:{...j.style,animation:Z?void 0:"none"}})})})});AN.displayName=ey;var PN="PopperArrow",y_={top:"bottom",right:"left",bottom:"top",left:"right"},DN=p.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,i=x_(PN,s),c=y_[i.placedSide];return r.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:r.jsx(p_,{...o,ref:n,style:{...o.style,display:"block"}})})});DN.displayName=PN;function b_(e){return e!==null}var v_=e=>({name:"transformOrigin",options:e,fn(t){var v,k,E;const{placement:n,rects:s,middlewareData:o}=t,c=((v=o.arrow)==null?void 0:v.centerOffset)!==0,u=c?0:e.arrowWidth,d=c?0:e.arrowHeight,[m,h]=$N(n),g={start:"0%",center:"50%",end:"100%"}[h],y=(((k=o.arrow)==null?void 0:k.x)??0)+u/2,b=(((E=o.arrow)==null?void 0:E.y)??0)+d/2;let C="",j="";return m==="bottom"?(C=c?g:`${y}px`,j=`${-d}px`):m==="top"?(C=c?g:`${y}px`,j=`${s.floating.height+d}px`):m==="right"?(C=`${-d}px`,j=c?g:`${b}px`):m==="left"&&(C=`${s.floating.width+d}px`,j=c?g:`${b}px`),{data:{x:C,y:j}}}});function $N(e){const[t,n="center"]=e.split("-");return[t,n]}var w_=EN,j_=RN,k_=AN,S_=DN,N_=Symbol("radix.slottable");function C_(e){const t=({children:n})=>r.jsx(r.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=N_,t}var E_=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),T_="VisuallyHidden",LN=p.forwardRef((e,t)=>r.jsx(vn.span,{...e,ref:t,style:{...E_,...e.style}}));LN.displayName=T_;var R_=LN,[Jf]=pa("Tooltip",[NN]),Xf=NN(),ON="TooltipProvider",A_=700,Tg="tooltip.open",[P_,ty]=Jf(ON),IN=e=>{const{__scopeTooltip:t,delayDuration:n=A_,skipDelayDuration:s=300,disableHoverableContent:o=!1,children:i}=e,c=p.useRef(!0),u=p.useRef(!1),d=p.useRef(0);return p.useEffect(()=>{const m=d.current;return()=>window.clearTimeout(m)},[]),r.jsx(P_,{scope:t,isOpenDelayedRef:c,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(d.current),c.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>c.current=!0,s)},[s]),isPointerInTransitRef:u,onPointerInTransitChange:p.useCallback(m=>{u.current=m},[]),disableHoverableContent:o,children:i})};IN.displayName=ON;var wc="Tooltip",[D_,zc]=Jf(wc),_N=e=>{const{__scopeTooltip:t,children:n,open:s,defaultOpen:o,onOpenChange:i,disableHoverableContent:c,delayDuration:u}=e,d=ty(wc,e.__scopeTooltip),m=Xf(t),[h,g]=p.useState(null),y=bi(),b=p.useRef(0),C=c??d.disableHoverableContent,j=u??d.delayDuration,v=p.useRef(!1),[k,E]=Af({prop:s,defaultProp:o??!1,onChange:A=>{A?(d.onOpen(),document.dispatchEvent(new CustomEvent(Tg))):d.onClose(),i==null||i(A)},caller:wc}),S=p.useMemo(()=>k?v.current?"delayed-open":"instant-open":"closed",[k]),T=p.useCallback(()=>{window.clearTimeout(b.current),b.current=0,v.current=!1,E(!0)},[E]),P=p.useCallback(()=>{window.clearTimeout(b.current),b.current=0,E(!1)},[E]),R=p.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{v.current=!0,E(!0),b.current=0},j)},[j,E]);return p.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),r.jsx(w_,{...m,children:r.jsx(D_,{scope:t,contentId:y,open:k,stateAttribute:S,trigger:h,onTriggerChange:g,onTriggerEnter:p.useCallback(()=>{d.isOpenDelayedRef.current?R():T()},[d.isOpenDelayedRef,R,T]),onTriggerLeave:p.useCallback(()=>{C?P():(window.clearTimeout(b.current),b.current=0)},[P,C]),onOpen:T,onClose:P,disableHoverableContent:C,children:n})})};_N.displayName=wc;var Rg="TooltipTrigger",MN=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,o=zc(Rg,n),i=ty(Rg,n),c=Xf(n),u=p.useRef(null),d=qn(t,u,o.onTriggerChange),m=p.useRef(!1),h=p.useRef(!1),g=p.useCallback(()=>m.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),r.jsx(j_,{asChild:!0,...c,children:r.jsx(vn.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...s,ref:d,onPointerMove:Zt(e.onPointerMove,y=>{y.pointerType!=="touch"&&!h.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),h.current=!0)}),onPointerLeave:Zt(e.onPointerLeave,()=>{o.onTriggerLeave(),h.current=!1}),onPointerDown:Zt(e.onPointerDown,()=>{o.open&&o.onClose(),m.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:Zt(e.onFocus,()=>{m.current||o.onOpen()}),onBlur:Zt(e.onBlur,o.onClose),onClick:Zt(e.onClick,o.onClose)})})});MN.displayName=Rg;var ny="TooltipPortal",[$_,L_]=Jf(ny,{forceMount:void 0}),FN=e=>{const{__scopeTooltip:t,forceMount:n,children:s,container:o}=e,i=zc(ny,t);return r.jsx($_,{scope:t,forceMount:n,children:r.jsx(ma,{present:n||i.open,children:r.jsx(wx,{asChild:!0,container:o,children:s})})})};FN.displayName=ny;var $i="TooltipContent",zN=p.forwardRef((e,t)=>{const n=L_($i,e.__scopeTooltip),{forceMount:s=n.forceMount,side:o="top",...i}=e,c=zc($i,e.__scopeTooltip);return r.jsx(ma,{present:s||c.open,children:c.disableHoverableContent?r.jsx(BN,{side:o,...i,ref:t}):r.jsx(O_,{side:o,...i,ref:t})})}),O_=p.forwardRef((e,t)=>{const n=zc($i,e.__scopeTooltip),s=ty($i,e.__scopeTooltip),o=p.useRef(null),i=qn(t,o),[c,u]=p.useState(null),{trigger:d,onClose:m}=n,h=o.current,{onPointerInTransitChange:g}=s,y=p.useCallback(()=>{u(null),g(!1)},[g]),b=p.useCallback((C,j)=>{const v=C.currentTarget,k={x:C.clientX,y:C.clientY},E=z_(k,v.getBoundingClientRect()),S=B_(k,E),T=U_(j.getBoundingClientRect()),P=H_([...S,...T]);u(P),g(!0)},[g]);return p.useEffect(()=>()=>y(),[y]),p.useEffect(()=>{if(d&&h){const C=v=>b(v,h),j=v=>b(v,d);return d.addEventListener("pointerleave",C),h.addEventListener("pointerleave",j),()=>{d.removeEventListener("pointerleave",C),h.removeEventListener("pointerleave",j)}}},[d,h,b,y]),p.useEffect(()=>{if(c){const C=j=>{const v=j.target,k={x:j.clientX,y:j.clientY},E=(d==null?void 0:d.contains(v))||(h==null?void 0:h.contains(v)),S=!V_(k,c);E?y():S&&(y(),m())};return document.addEventListener("pointermove",C),()=>document.removeEventListener("pointermove",C)}},[d,h,c,m,y]),r.jsx(BN,{...e,ref:i})}),[I_,__]=Jf(wc,{isInside:!1}),M_=C_("TooltipContent"),BN=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:s,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:c,...u}=e,d=zc($i,n),m=Xf(n),{onClose:h}=d;return p.useEffect(()=>(document.addEventListener(Tg,h),()=>document.removeEventListener(Tg,h)),[h]),p.useEffect(()=>{if(d.trigger){const g=y=>{const b=y.target;b!=null&&b.contains(d.trigger)&&h()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,h]),r.jsx(vx,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:h,children:r.jsxs(k_,{"data-state":d.stateAttribute,...m,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[r.jsx(M_,{children:s}),r.jsx(I_,{scope:n,isInside:!0,children:r.jsx(R_,{id:d.contentId,role:"tooltip",children:o||s})})]})})});zN.displayName=$i;var UN="TooltipArrow",F_=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...s}=e,o=Xf(n);return __(UN,n).isInside?null:r.jsx(S_,{...o,...s,ref:t})});F_.displayName=UN;function z_(e,t){const n=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,s,o,i)){case i:return"left";case o:return"right";case n:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function B_(e,t,n=5){const s=[];switch(t){case"top":s.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":s.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":s.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":s.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return s}function U_(e){const{top:t,right:n,bottom:s,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:s},{x:o,y:s}]}function V_(e,t){const{x:n,y:s}=e;let o=!1;for(let i=0,c=t.length-1;i<t.length;c=i++){const u=t[i],d=t[c],m=u.x,h=u.y,g=d.x,y=d.y;h>s!=y>s&&n<(g-m)*(s-h)/(y-h)+m&&(o=!o)}return o}function H_(e){const t=e.slice();return t.sort((n,s)=>n.x<s.x?-1:n.x>s.x?1:n.y<s.y?-1:n.y>s.y?1:0),W_(t)}function W_(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const o=e[s];for(;t.length>=2;){const i=t[t.length-1],c=t[t.length-2];if((i.x-c.x)*(o.y-c.y)>=(i.y-c.y)*(o.x-c.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let s=e.length-1;s>=0;s--){const o=e[s];for(;n.length>=2;){const i=n[n.length-1],c=n[n.length-2];if((i.x-c.x)*(o.y-c.y)>=(i.y-c.y)*(o.x-c.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var K_=IN,q_=_N,G_=MN,Y_=FN,VN=zN;const ia=K_,Nr=q_,Cr=G_,ur=p.forwardRef(({className:e,sideOffset:t=4,...n},s)=>r.jsx(Y_,{children:r.jsx(VN,{ref:s,sideOffset:t,className:we("z-50 overflow-hidden rounded-md border border-border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));ur.displayName=VN.displayName;function ry({items:e,align:t="end"}){const[n,s]=p.useState(!1),[o,i]=p.useState(null),c=p.useRef(null);if(p.useEffect(()=>{if(!n){i(null);return}function d(h){c.current&&!c.current.contains(h.target)&&s(!1)}function m(h){h.key==="Escape"&&s(!1)}return document.addEventListener("mousedown",d),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",m)}},[n]),e.length===0)return null;function u(d,m){const h=d.icon,g=we("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition",m&&"pl-8",d.disabled?"opacity-50 cursor-not-allowed":d.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),y=m?d.active?r.jsx(Rr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):r.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):h?r.jsx(h,{className:"h-4 w-4 shrink-0"}):null,b=r.jsxs(r.Fragment,{children:[y,r.jsx("span",{className:"block min-w-0 truncate",children:d.label})]});if(d.disabled){const C=r.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:r.jsx("button",{type:"button",disabled:!0,className:g,children:b})});return d.disabledReason?r.jsxs(Nr,{children:[r.jsx(Cr,{asChild:!0,children:C}),r.jsx(ur,{side:"left",children:d.disabledReason})]},d.key):r.jsx("div",{children:C},d.key)}return d.href?r.jsx(Ee,{to:d.href,className:g,onClick:()=>s(!1),children:b},d.key):r.jsx("button",{type:"button",className:g,onClick:()=>{var C;(C=d.onSelect)==null||C.call(d),s(!1)},children:b},d.key)}return r.jsxs("div",{className:"relative",ref:c,children:[r.jsx("button",{type:"button",onClick:()=>s(d=>!d),className:"shell-action",title:"More actions","aria-haspopup":"true","aria-expanded":n,children:r.jsx(GA,{className:"h-4 w-4"})}),n&&r.jsx("div",{className:we("absolute top-full mt-1 z-30 min-w-[220px] rounded-md border border-border/70 bg-background shadow-lg py-1",t==="end"?"right-0":"left-0"),children:r.jsx(ia,{delayDuration:200,children:e.map(d=>{if(d.submenu&&d.submenu.length>0){const m=d.icon,h=o===d.key;return r.jsxs("div",{children:[r.jsxs("button",{type:"button",className:we("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition hover:bg-foreground/5"),"aria-expanded":h,onClick:()=>i(h?null:d.key),children:[m?r.jsx(m,{className:"h-4 w-4 shrink-0"}):null,r.jsx("span",{className:"block min-w-0 flex-1 truncate",children:d.label}),h?r.jsx(pr,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):r.jsx(Rk,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]}),h?d.submenu.map(g=>u(g,!0)):null]},d.key)}return u(d,!1)})})})]})}function bj(e){const t=Date.parse(e);return Number.isNaN(t)?!1:Date.now()-t>10080*60*1e3}const Q_={last_24h:1440*60*1e3,last_7d:10080*60*1e3,last_30d:720*60*60*1e3,last_90d:2160*60*60*1e3,older_7d:10080*60*1e3,older_30d:720*60*60*1e3};function J_(e){const[t,n,s]=e.split("-").map(Number);return new Date(t,n-1,s,0,0,0,0).getTime()}function X_(e){const[t,n,s]=e.split("-").map(Number);return new Date(t,n-1,s,23,59,59,999).getTime()}function Z_(e,t,n=Date.now()){if(!t)return!0;const s=t.field==="created"?e.created??e.updated:e.updated,o=Date.parse(s);if(Number.isNaN(o))return!1;if(t.preset){const u=Q_[t.preset];return u===void 0?!0:t.preset.startsWith("older_")?n-o>u:o>=n-u&&o<=n}const i=t.from&&t.from.length>0?t.from:void 0,c=t.to&&t.to.length>0?t.to:void 0;return!i&&!c?!0:!(i&&o<J_(i)||c&&o>X_(c))}function e5(e,t,n={}){const{workspace:s,search:o,includeArchived:i}=n;if(e.archived===!0&&!i)return!1;const c=ze(t.status),u=ze(t.priority),d=ze(t.type),m=ze(t.assignee),h=ze(t.project),g=ze(t.tags),{activity:y}=t;if(s){if(s==="_ungrouped"){if(e.projectWorkspace!=null)return!1}else if(e.projectWorkspace!==s)return!1}if(c.length&&!c.includes(e.status)||u.length&&!u.includes(e.priority)||d.length&&!d.includes(e.type??"")||y==="stale"&&!bj(e.updated)||y==="fresh"&&bj(e.updated))return!1;if(m.length){const b=e.assignee??"__unassigned__";if(!m.includes(b))return!1}if(h.length&&!h.some(C=>C==="__standalone__"?e.projectSlug==null:e.projectSlug===C))return!1;if(g.length){const b=e.tags??[];if(!g.some(C=>b.includes(C)))return!1}if(!Z_(e,t.dateRange))return!1;if(o){const b=o.trim().toLowerCase();if(b&&!`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`.toLowerCase().includes(b))return!1}return!0}function jc(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}const Ld={phaseLadder:[{phase:"draft",when:"*",next:"Fill in the objective and acceptance criteria"},{phase:"ready_for_planning",when:"hasRealObjective:true AND acRealTotal > 0",next:"Write a plan and get it approved"},{phase:"ready_to_implement",when:"planApproved:true",next:"Start implementing"},{phase:"in_progress",when:"planApproved:true AND implementationStarted:true",next:"Finish acceptance criteria, then request review"},{phase:"review",when:"acAllChecked:true OR reviewRequested:true",next:"Complete, or address review feedback"}],disposition:[{when:"parked:true",is:"parked"},{when:"blocked:true",is:"blocked"},{when:null,is:"active"}],headline:{terminal:"passthrough",parked:"parked",blocked:"blocked",active:"phase"}};function t5(e,t,n=()=>null){const s=[],o=new Set(t.statuses.map(u=>u.id));e.phaseLadder.length===0&&s.push("phaseLadder must have at least one rung");for(const u of e.phaseLadder){o.has(u.phase)||s.push(`phaseLadder rung "${u.phase}" is not a defined status id`);const d=u.when==="*"?null:n(u.when);d&&s.push(`phaseLadder rung "${u.phase}": invalid condition — ${d}`)}const i=new Set(["active","blocked","parked"]);for(const u of e.disposition)if(i.has(u.is)||s.push(`disposition "${u.is}" is not valid (expected active, blocked, or parked — terminal is never a rule)`),u.when!==null){const d=n(u.when);d&&s.push(`disposition rule "${u.is}": invalid condition — ${d}`)}const c=e.disposition.map((u,d)=>u.when===null?d:-1).filter(u=>u>=0);c.length===0?s.push("disposition rules must end with an `else:` arm (a rule with when: null)"):c.length>1?s.push("disposition rules must have exactly one `else:` arm (when: null)"):c[0]!==e.disposition.length-1&&s.push("the `else:` arm (when: null) must be the LAST disposition rule — rules after it are unreachable");for(const u of["parked","blocked"])o.has(e.headline[u])||s.push(`headline.${u} → "${e.headline[u]}" is not a defined status id (add the definition or run migrate-derive)`);return s}const HN={statuses:[{id:"pending",label:"Pending"},{id:"in_progress",label:"In Progress"},{id:"blocked",label:"Blocked"},{id:"review",label:"Review"},{id:"completed",label:"Completed"},{id:"failed",label:"Failed"}],order:["pending","in_progress","blocked","review","completed","failed"],transitions:[],transitionsCustom:!1,custom:!1,derive:Ld,deriveCustom:!1,knownCommands:[],factDeclarations:[],rawFacts:[]};let ac=null,ea=null;function n5(){return ac?Promise.resolve(ac):ea||(ea=fetch("/api/config/statuses").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(ac=e,ea=null,e)).catch(()=>(ea=null,HN)),ea)}function ha(){const[e,t]=p.useState(()=>ac??HN);return p.useEffect(()=>{n5().then(t)},[]),e}function vj(){ac=null,ea=null}function Bc(e,t){const n=e.statuses.find(s=>s.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}const wj={critical:0,high:1,medium:2,low:3};function pd(e){return Date.parse(e??"")||0}function Uc(e,t,n){return[...e].sort((o,i)=>{let c=0;switch(t){case"title":c=o.title.localeCompare(i.title);break;case"status":c=o.status.localeCompare(i.status);break;case"priority":c=(wj[o.priority]??99)-(wj[i.priority]??99);break;case"assignee":c=(o.assignee??"").localeCompare(i.assignee??"");break;case"dependencies":c=o.dependsOn.length-i.dependsOn.length;break;case"created":c=pd(o.created)-pd(i.created);break;case"updated":c=pd(o.updated)-pd(i.updated);break}return n==="asc"?c:-c})}function r5(e){const t=`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`;return{...e.facts??{},status:e.status,phase:e.phase,disposition:e.disposition,priority:e.priority,type:e.type,assignee:e.assignee,project:e.projectSlug,tags:e.tags,archived:e.archived,title:e.title,created:e.created,updated:e.updated,completedAt:e.completedAt,statusAge:e.statusAge,phaseAge:e.phaseAge,searchText:t}}function WN(e,t,n={}){const{workspace:s,includeArchived:o=!1,now:i=Date.now()}=n,c={now:i};return e.filter(u=>{if(u.archived===!0&&!o)return!1;if(s){if(s==="_ungrouped"){if(u.projectWorkspace!=null)return!1}else if(u.projectWorkspace!==s)return!1}if(!t)return!0;const d=r5(u);return t.predicate(d,c)})}const Zf={hasrealobjective:{kind:"bool",get:e=>e.hasRealObjective},acrealtotal:{kind:"number",get:e=>e.acRealTotal},acrealchecked:{kind:"number",get:e=>e.acRealChecked},acallchecked:{kind:"bool",get:e=>e.acAllChecked},planexists:{kind:"bool",get:e=>e.planExists},planapproved:{kind:"bool",get:e=>e.planApproved},workspaceset:{kind:"bool",get:e=>e.workspaceSet},implementationstarted:{kind:"bool",get:e=>e.implementationStarted},depssatisfied:{kind:"bool",get:e=>e.depsSatisfied},unresolvedquestions:{kind:"number",get:e=>e.unresolvedQuestions},blocked:{kind:"bool"},parked:{kind:"bool"},reviewrequested:{kind:"bool",get:e=>e.reviewRequested},pinned:{kind:"bool"}};function ep(e){const t=e.name,n={fact:t,approved:`${t}Approved`,changesRequested:`${t}ChangesRequested`,by:`${t}By`,approvedBy:`${t}ApprovedBy`},s=e.type==="attestation"?[n.fact,n.approved,n.changesRequested,n.by,n.approvedBy].map(o=>o.toLowerCase()):[n.fact.toLowerCase()];return{storageKey:t,exports:n,registryKeys:s}}function s5(e){const t=[];for(const n of e??[]){if(!n||typeof n.name!="string")continue;const s=n.name.trim();if(!/^[a-z][a-zA-Z0-9]*$/.test(s))continue;const o=(n.type??"").trim();if(o==="bool"||o==="number")t.push({name:s,type:o});else if(o==="attestation"){const i=(n.binds??"none").toString().trim()||"none";(i==="plan"||i==="commit"||i==="none")&&t.push({name:s,type:"attestation",binds:i})}}return t}function Ag(e){const t=[],n=new Map;for(const s of Object.keys(Zf))n.set(s,"built-in");for(const s of Object.keys(Hf))n.set(s,"built-in");for(const s of e??[]){const o=((s==null?void 0:s.name)??"").trim();if(!/^[a-z][a-zA-Z0-9]*$/.test(o)){t.push(`fact "${(s==null?void 0:s.name)??""}": invalid name — must match /^[a-z][a-zA-Z0-9]*$/`);continue}const i=(s.type??"").trim();if(i!=="bool"&&i!=="number"&&i!=="attestation"){t.push(`fact "${o}": invalid type "${s.type??""}" — expected bool, number, or attestation`);continue}if(i==="attestation"){const m=(s.binds??"none").toString().trim()||"none";if(m!=="plan"&&m!=="commit"&&m!=="none"){t.push(`fact "${o}": invalid binds "${s.binds}" — expected plan, commit, or none`);continue}}const u=ep(i==="attestation"?{name:o,type:i}:{name:o,type:i}).registryKeys,d=u.find(m=>n.has(m));if(d!==void 0){const m=n.get(d);m==="built-in"?t.push(`fact "${o}": exported field "${d}" collides with a built-in field`):m===o?t.push(`fact "${o}": duplicate declaration (a fact named "${o}" is already declared)`):t.push(`fact "${o}": exported field "${d}" collides with fact "${m}"`);continue}for(const m of u)n.set(m,o)}return t}function o5(e){const t=new Set([...Object.keys(Zf),...Object.keys(Hf)]),n=[];for(const s of e){const o=ep(s).registryKeys;if(!o.some(i=>t.has(i))){for(const i of o)t.add(i);n.push(s)}}return n}function KN(e,t){const n=ep(t);t.type==="attestation"?(e[n.exports.fact.toLowerCase()]={kind:"bool",get:s=>s[n.exports.fact]},e[n.exports.approved.toLowerCase()]={kind:"bool",get:s=>s[n.exports.approved]},e[n.exports.changesRequested.toLowerCase()]={kind:"bool",get:s=>s[n.exports.changesRequested]},e[n.exports.by.toLowerCase()]={kind:"list",get:s=>s[n.exports.by]},e[n.exports.approvedBy.toLowerCase()]={kind:"list",get:s=>s[n.exports.approvedBy]}):e[n.exports.fact.toLowerCase()]={kind:t.type,get:s=>s[n.exports.fact]}}function sy(e){const t={...Zf};for(const n of e)KN(t,n);return t}function qN(e){const t={...Hf};for(const n of e)KN(t,n);return t}function GN(e){const t=["status","priority","type","assignee","project","tag","tags","archived","title","search","created","updated","completedAt","statusAge","phase","disposition","phaseAge","hasRealObjective","acRealTotal","acRealChecked","acAllChecked","planExists","planApproved","workspaceSet","implementationStarted","depsSatisfied","unresolvedQuestions","progressStaleDays","blocked","parked","reviewRequested","pinned"],n=[];for(const s of e){const o=ep(s);s.type==="attestation"?n.push(o.exports.fact,o.exports.approved,o.exports.changesRequested,o.exports.by,o.exports.approvedBy):n.push(o.exports.fact)}return[...t,...n]}function Et({title:e,description:t,actions:n}){return r.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 px-4 py-6 text-center",children:r.jsxs("div",{className:"mx-auto max-w-xl space-y-2",children:[r.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t}),n?r.jsx("div",{className:"flex flex-wrap justify-center gap-3 pt-2",children:n}):null]})})}const Li='a, button, input, select, textarea, [contenteditable="true"], [role="button"], [data-no-drag]';function tp({columns:e,items:t,getItemId:n,getColumnId:s,renderCard:o,canDrop:i,onMove:c,getExternalDragData:u,onCardContextMenu:d,emptyMessage:m="No cards in this column.",hiddenColumnIds:h,onHideColumn:g,compact:y=!1,dragDisabled:b=!1}){const C=p.useMemo(()=>new Set(h??[]),[h]),j=p.useMemo(()=>e.filter(I=>!C.has(I.id)),[e,C]),v=p.useMemo(()=>e.filter(I=>C.has(I.id)),[e,C]),[k,E]=p.useState(null),[S,T]=p.useState(null),P=p.useRef(null),R=p.useMemo(()=>new Map(t.map(I=>[n(I),I])),[n,t]),A=p.useMemo(()=>j.map(I=>({column:I,items:t.filter(F=>s(F)===I.id)})),[j,s,t]),$=k?R.get(k)??null:null;function M(I){if(!$)return{allowed:!1};const F=s($);return(i==null?void 0:i({item:$,fromColumnId:F,toColumnId:I}))??{allowed:!0}}function _(){E(null),T(null)}function D(I,F,q){if(b)return;const Z=(u==null?void 0:u(F))??null;!c&&!Z||(I.dataTransfer.effectAllowed="move",I.dataTransfer.setData("text/plain",q),Z&&I.dataTransfer.setData("application/json",JSON.stringify(Z)),c&&E(q))}function V(I,F,q){b||!c||!$||!M(F).allowed||(I.preventDefault(),I.dataTransfer.dropEffect="move",T(z=>(z==null?void 0:z.columnId)===F&&z.index===q?z:{columnId:F,index:q}))}async function K(I,F,q){var H;if(I.preventDefault(),b||!c||!$){_();return}const Z=s($),G=(((H=A.find(re=>re.column.id===Z))==null?void 0:H.items)??[]).findIndex(re=>n(re)===n($));if(!M(F).allowed||G<0){_();return}if(Z===F&&(q===G||q===G+1)){_();return}try{await c({item:$,fromColumnId:Z,toColumnId:F,fromIndex:G,toIndex:q})}finally{_()}}return r.jsxs("div",{className:"relative overflow-x-auto pb-2",style:{scrollbarColor:"oklch(var(--border)) transparent",scrollbarWidth:"thin"},children:[v.length>0&&g?r.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Hidden:"}),v.map(I=>r.jsxs("button",{type:"button",onClick:()=>g(I.id),className:"rounded-full border border-dashed border-border/60 px-2 py-0.5 hover:border-border hover:text-foreground",title:`Restore "${I.title}" column`,children:[I.title," ×"]},I.id))]}):null,r.jsx("div",{className:we("grid min-w-max grid-flow-col gap-4",y?"auto-cols-[minmax(240px,280px)]":"auto-cols-[minmax(300px,360px)]"),children:A.map(({column:I,items:F})=>{const q=M(I.id),Z=(S==null?void 0:S.columnId)===I.id;return r.jsxs("section",{className:we("flex flex-col rounded-lg border border-border/60 bg-card/85 shadow-sm",y?"min-h-[200px] p-2":"min-h-[320px] p-3",$&&!q.allowed?"border-dashed opacity-65":"",$&&q.allowed?"border-primary/30 bg-accent/30":"",Z?"ring-2 ring-ring/30":""),title:$&&!q.allowed?q.reason:void 0,children:[r.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h2",{className:we("font-semibold uppercase tracking-[0.16em] text-muted-foreground",y?"text-xs":"text-sm"),children:I.title}),I.description&&!y?r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:I.description}):null]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs font-semibold text-foreground",children:F.length}),g?r.jsx("button",{type:"button",onClick:()=>g(I.id),className:"rounded-full border border-transparent px-1.5 py-0.5 text-xs text-muted-foreground hover:border-border hover:text-foreground",title:`Hide "${I.title}" column`,"aria-label":`Hide column ${I.title}`,children:"×"}):null]})]}),r.jsxs("div",{className:"flex flex-1 flex-col gap-3",onDragOver:z=>V(z,I.id,F.length),onDrop:z=>K(z,I.id,F.length),children:[F.length===0?b?r.jsx("div",{className:"flex min-h-[128px] items-center justify-center rounded-lg border border-border/60 bg-background/50 px-4 text-center text-sm text-muted-foreground",children:typeof m=="function"?m(I):m}):r.jsx(a5,{active:(S==null?void 0:S.columnId)===I.id&&S.index===0,disabled:!!$&&!q.allowed,children:typeof m=="function"?m(I):m}):null,F.map((z,G)=>{const L=n(z),H=k===L;return r.jsxs(p.Fragment,{children:[r.jsx("div",{className:we("h-2 rounded-full transition",(S==null?void 0:S.columnId)===I.id&&S.index===G?"bg-primary/70":"bg-transparent"),onDragOver:re=>V(re,I.id,G),onDrop:re=>K(re,I.id,G)}),r.jsx("div",{draggable:!b&&!!(c||u),onMouseDown:re=>{P.current=re.target},onDragStart:re=>{const U=P.current;if(U!=null&&U.closest(Li)){re.preventDefault();return}D(re,z,L)},onDragEnd:_,onContextMenu:re=>{if(!d)return;const U=re.target;U!=null&&U.closest(Li)||d(z,re)},className:we("transition",!b&&(c||u)?"cursor-grab active:cursor-grabbing":"",H?"scale-[0.98] opacity-50":""),children:o(z,{dragging:H})})]},L)}),F.length>0&&!b?r.jsx("div",{className:we("mt-1 rounded-md border border-dashed px-3 py-2 text-center text-xs text-muted-foreground transition",(S==null?void 0:S.columnId)===I.id&&S.index===F.length?"border-primary/50 bg-primary/10 text-foreground":"border-border/60",$&&!q.allowed?"opacity-40":""),children:"Drop here to place at the end"}):null]})]},I.id)})})]})}function a5({active:e,disabled:t,children:n}){return r.jsx("div",{className:we("flex min-h-[128px] items-center justify-center rounded-lg border border-dashed px-4 text-center text-sm text-muted-foreground transition",e?"border-primary/60 bg-primary/10 text-foreground":"border-border/60 bg-background/50",t?"opacity-45":""),children:n})}const Yl="border-status-pending-foreground/30 bg-status-pending text-status-pending-foreground",Ph="border-status-in-progress-foreground/30 bg-status-in-progress text-status-in-progress-foreground",i5="border-status-blocked-foreground/30 bg-status-blocked text-status-blocked-foreground",l5="border-status-review-foreground/30 bg-status-review text-status-review-foreground",c5="border-status-completed-foreground/30 bg-status-completed text-status-completed-foreground",u5="border-status-failed-foreground/30 bg-status-failed text-status-failed-foreground",d5="border-status-archived-foreground/30 bg-status-archived text-status-archived-foreground",of={draft:{label:"Draft",description:"Just-created stub; not yet shaped.",className:Yl,icon:zi},pending:{label:"Pending",description:"Waiting to start or waiting on dependencies.",className:Yl,icon:UA},ready_for_planning:{label:"Ready for Planning",description:"Objective and acceptance criteria written; awaiting a plan.",className:Yl,icon:Pk},ready_to_implement:{label:"Ready to Implement",description:"Plan written and approved; ready to start coding.",className:Ph,icon:cP},in_progress:{label:"In Progress",description:"Actively being worked on.",className:Ph,icon:ix},blocked:{label:"Blocked",description:"Blocked by an explicit obstacle that needs intervention.",className:i5,icon:Ud},review:{label:"Review",description:"Ready for inspection or approval.",className:l5,icon:fP},completed:{label:"Completed",description:"Finished successfully.",className:c5,icon:rx},failed:{label:"Failed",description:"Could not be completed as planned.",className:u5,icon:Ud},active:{label:"Active",description:"The project has active or review work in flight.",className:Ph,icon:lg},stopped:{label:"Stopped",description:"Session ended without completing.",className:Yl,icon:zA},archived:{label:"Archived",description:"Hidden from normal views; restorable from the Archive page.",className:d5,icon:lg}};function af(e){const t=of[e];return t||{className:Yl,icon:lg,label:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase()),description:`Status: ${e}`}}function YN(e,t){return we("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full border px-2.5 py-0.5 text-xs font-medium tracking-normal","shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0)] dark:shadow-[inset_0_0_0_1px_oklch(100%_0_0_/_0.04)]",af(e).className,t)}function bn({status:e,className:t,showIcon:n=!0,progress:s}){const o=af(e),i=o.icon,c=s&&s.total>0,u=c?Math.min(1,Math.max(0,s.checked/s.total)):0,d=c?`${o.label} — ${o.description} (${s.checked}/${s.total} criteria)`:`${o.label} — ${o.description}`,m=n?c?r.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[r.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"absolute inset-0 h-full w-full -rotate-90",children:[r.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"1.5"}),r.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeDasharray:2*Math.PI*7,strokeDashoffset:2*Math.PI*7*(1-u)})]}),r.jsx(i,{className:"h-2.5 w-2.5"})]}):r.jsx(i,{className:"h-3.5 w-3.5 shrink-0"}):null;return r.jsxs("span",{title:d,className:YN(e,t),children:[m,r.jsx("span",{className:"min-w-0 truncate",children:o.label})]})}function np(e){var t;return((t=of[e])==null?void 0:t.description)??`Status: ${e}`}const QN={definitions:[{id:"feature",label:"Feature"},{id:"bug",label:"Bug"},{id:"refactor",label:"Refactor"},{id:"research",label:"Research"},{id:"chore",label:"Chore"}],default:"feature",custom:!1};let Od=null,ei=null;function f5(){return Od?Promise.resolve(Od):ei||(ei=fetch("/api/config/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Od=e,ei=null,e)).catch(()=>(ei=null,QN)),ei)}function rp(){const[e,t]=p.useState(()=>Od??QN);return p.useEffect(()=>{f5().then(t)},[]),e}function Ni(e,t){if(!t)return"—";const n=e.definitions.find(s=>s.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function p5(e,t){return t?e.definitions.find(n=>n.id===t)??null:null}function ga({type:e,className:t,compact:n=!1}){const s=rp();if(!e)return null;const o=p5(s,e),i=(o==null?void 0:o.label)??e.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase()),c=o!=null&&o.color?{backgroundColor:`color-mix(in oklch, ${o.color} 18%, transparent)`,borderColor:`color-mix(in oklch, ${o.color} 50%, transparent)`,color:o.color}:void 0;return r.jsx("span",{title:(o==null?void 0:o.description)??`Type: ${i}`,style:c,className:we("inline-flex items-center whitespace-nowrap rounded-full border text-xs capitalize",n?"px-2 py-0.5":"px-2.5 py-1",!c&&"border-border/60 text-muted-foreground",t),children:i})}async function Vc(e){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{return await navigator.clipboard.writeText(e),!0}catch{}return m5(e)}function m5(e){try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}function Br({value:e,label:t,disabled:n=!1,disabledReason:s,onError:o}){const[i,c]=p.useState(!1);async function u(){n||(await Vc(e)?(c(!0),setTimeout(()=>c(!1),1500)):o==null||o(new Error("Copy to clipboard failed in this context.")))}return n?r.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:s??"Copy unavailable","aria-label":t??"Copy",children:r.jsx(Vd,{className:"h-3 w-3","aria-hidden":"true"})}):r.jsx("button",{type:"button",onClick:u,className:"text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 rounded",title:i?"Copied!":t??`Copy: ${e}`,"aria-label":t??"Copy",children:i?r.jsx(Rr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):r.jsx(Vd,{className:"h-3 w-3","aria-hidden":"true"})})}function h5(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function g5({items:e,statusOrder:t,sortField:n,sortDirection:s,listSectionVisibility:o,compact:i=!1}){const c=ha(),[u,d]=p.useState(()=>new Set(o.collapsed));p.useEffect(()=>{d(new Set(o.collapsed))},[o]);const m=h=>{d(g=>{const y=new Set(g);return y.has(h)?y.delete(h):y.add(h),y})};return r.jsx("div",{className:we("space-y-2",i?"space-y-1.5":"space-y-3"),children:t.map(h=>{const g=Uc(e.filter(C=>C.status===h),n,s);if(g.length===0)return null;const y=!u.has(h),b=Bc(c,h);return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/90",children:[r.jsxs("button",{type:"button",onClick:()=>m(h),className:we("flex w-full items-center gap-2 text-left",i?"px-3 py-2 text-xs":"px-4 py-3 text-sm"),children:[r.jsx(pr,{className:we("text-muted-foreground transition-transform",i?"h-3.5 w-3.5":"h-4 w-4",y?"":"-rotate-90")}),r.jsx("span",{className:"font-semibold text-foreground",children:b}),r.jsx("span",{className:we("rounded-full border border-border/60 text-muted-foreground",i?"px-1.5 py-0 text-[10px]":"px-2 py-0.5 text-xs"),children:g.length})]}),y&&r.jsx("ul",{className:we("divide-y divide-border/40 border-t border-border/40",i?"text-xs":"text-sm"),children:g.map(C=>{const j=h5(C);return r.jsx("li",{children:r.jsxs(Ee,{to:j,className:we("flex items-center gap-3 hover:bg-muted/40",i?"px-3 py-1.5":"px-4 py-2.5"),children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:C.title}),C.projectTitle?r.jsx("span",{className:"hidden truncate text-muted-foreground sm:inline",children:C.projectTitle}):null,r.jsx("span",{className:"shrink-0 text-muted-foreground",children:zn(C.updated)})]})},`${C.projectSlug??"standalone"}:${C.id}`)})})]},h)})})}function x5(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function y5({items:e,sortField:t,sortDirection:n,tableColumnVisibility:s,compact:o=!1}){const i=new Set(s.hidden);i.delete("title");const c=h=>!i.has(h),u=Uc(e,t,n),d=o?"py-2 pr-3":"py-3 pr-4",m=o?"text-xs":"text-sm";return r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:we("w-full text-left",m),children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[c("title")?r.jsx("th",{className:we("font-medium",d),children:"Assignment"}):null,c("status")?r.jsx("th",{className:we("font-medium",d),children:"Status"}):null,c("priority")?r.jsx("th",{className:we("font-medium",d),children:"Priority"}):null,c("assignee")?r.jsx("th",{className:we("font-medium",d),children:"Assignee"}):null,c("dependencies")?r.jsx("th",{className:we("font-medium",d),children:"Dependencies"}):null,c("created")?r.jsx("th",{className:we("font-medium",d),children:"Created"}):null,c("updated")?r.jsx("th",{className:we("font-medium",d),children:"Updated"}):null]})}),r.jsx("tbody",{children:u.map(h=>{const g=x5(h),y=`${h.projectSlug??"standalone"}:${h.id}`;return r.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[c("title")?r.jsxs("td",{className:d,children:[r.jsx(Ee,{to:g,className:"font-semibold text-foreground hover:text-primary",children:h.title}),h.projectTitle?r.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:h.projectTitle}):null]}):null,c("status")?r.jsx("td",{className:d,children:r.jsx(bn,{status:h.status,className:"max-w-[150px]"})}):null,c("priority")?r.jsx("td",{className:we("capitalize text-muted-foreground",d),children:h.priority}):null,c("assignee")?r.jsx("td",{className:we("text-muted-foreground",d),children:h.assignee??"Unassigned"}):null,c("dependencies")?r.jsx("td",{className:we("text-muted-foreground",d),children:h.dependsOn.length}):null,c("created")?r.jsx("td",{className:we("text-muted-foreground",d),children:zn(h.created)}):null,c("updated")?r.jsx("td",{className:we("text-muted-foreground",d),children:zn(h.updated)}):null]},y)})})]})})}function JN({view:e,compact:t,emptyDescription:n}){const{data:s,loading:o,error:i}=Cf(),c=ha(),u=p.useMemo(()=>c.order.map(h=>({id:h,title:Bc(c,h),description:np(h)})),[c]),d=p.useMemo(()=>qN(c.factDeclarations),[c.factDeclarations]),m=p.useMemo(()=>{if(!s)return[];const h=e.config.filters.query??sc(e.config.filters);let g=null;h.trim()!==""&&(g=Vx(h,d).query);const y=WN(s.assignments,g,{workspace:e.workspace});return Uc(y,e.config.sortField,e.config.sortDirection)},[s,e,d]);if(o&&!s)return r.jsx(xt,{label:"Loading assignments…"});if(i)return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load assignments"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i})]});if(m.length===0)return r.jsx(Et,{title:"No assignments match this view.",description:n??"Adjust the view's filters to surface different work."});switch(e.config.viewMode){case"kanban":return r.jsx(tp,{compact:t,dragDisabled:!0,columns:u,items:m,getItemId:h=>h.slug||h.id,getColumnId:h=>h.status,hiddenColumnIds:e.config.kanbanColumnVisibility.hidden,renderCard:h=>t?r.jsx(b5,{item:h}):r.jsx(v5,{item:h})});case"list":return r.jsx(g5,{items:m,statusOrder:c.order,sortField:e.config.sortField,sortDirection:e.config.sortDirection,listSectionVisibility:e.config.listSectionVisibility,compact:t});case"table":return r.jsx(y5,{items:m,sortField:e.config.sortField,sortDirection:e.config.sortDirection,tableColumnVisibility:e.config.tableColumnVisibility,compact:t})}}function b5({item:e}){const t=jc(e);return r.jsxs("div",{className:we("rounded-md border border-border/60 bg-background/85 p-2 shadow-sm"),children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),r.jsx(bn,{status:e.status,className:"max-w-[150px]"})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",children:[r.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),r.jsx("span",{className:"shrink-0",children:zn(e.updated)})]}),e.id?r.jsxs("p",{className:"mt-1 inline-flex items-center gap-1 font-mono text-[10px] text-muted-foreground/70",children:[e.id.slice(0,8),r.jsx(Br,{value:e.id})]}):null]})}function v5({item:e}){const t=jc(e);return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),r.jsx(bn,{status:e.status,className:"max-w-[150px]"})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[r.jsx(ga,{type:e.type,compact:!0}),r.jsx("span",{className:"text-xs capitalize text-muted-foreground",children:e.priority})]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),r.jsx("span",{className:"shrink-0",children:zn(e.updated)})]})]})}function w5({viewId:e,onPickAnother:t}){const{view:n,loading:s,error:o,refetch:i}=So(e);return s?r.jsx(xt,{label:"Loading view…"}):o?r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load view"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o.message}),r.jsx("button",{type:"button",onClick:()=>i(),className:"shell-action mt-3",children:"Retry"})]}):n?r.jsx(JN,{view:n,compact:!0,emptyDescription:"Adjust the view's filters to surface different work, or pick another widget for this slot."}):r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"View no longer exists"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"The saved view this slot was bound to has been deleted."}),r.jsx("button",{type:"button",onClick:t,className:"shell-action mt-3",children:"Pick another widget"})]})}function XN({sessions:e}){return r.jsxs("aside",{"aria-labelledby":"overview-sessions-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsx("header",{className:"border-b border-border/40 px-4 py-3",children:r.jsx("h3",{id:"overview-sessions-title",className:"text-sm font-semibold text-foreground",children:"Recent Sessions"})}),e.length===0?r.jsxs("div",{className:"px-4 py-6 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:aa.recentSessionsEmptyTitle}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:aa.recentSessionsEmptyHint})]}):r.jsx("ul",{className:"divide-y divide-border/40",children:e.map(t=>r.jsx("li",{children:r.jsx(j5,{session:t})},t.sessionId))})]})}function j5({session:e}){const t=fn(),[n,s]=p.useState(!1),o=k5(e,t),i=S5(e),c=!e.path;return r.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx(Ee,{to:o,className:"block text-sm font-medium text-foreground hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:e.agent}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[i," · ",Wk(e.started)]}),n&&e.path?r.jsxs("div",{className:"mt-1 space-y-0.5",children:[r.jsx("code",{className:"block w-full select-all rounded bg-muted/40 px-1.5 py-0.5 text-xs text-foreground",children:e.path}),r.jsx("p",{className:"text-[10px] text-muted-foreground",children:aa.recentSessionsCopyFallbackHint})]}):null]}),r.jsx(Br,{value:e.path,label:aa.recentSessionsCopyPathLabel,disabled:c,disabledReason:aa.recentSessionsCopyPathDisabled,onError:()=>s(!0)})]})}function k5(e,t){return e.projectSlug&&e.assignmentSlug?`${t}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`:(!e.projectSlug&&e.assignmentSlug,"/agent-sessions")}function S5(e){return e.assignmentSlug&&e.projectSlug?`${e.projectSlug}/${e.assignmentSlug}`:e.assignmentSlug?`standalone/${e.assignmentSlug}`:"standalone"}const N5={last_24h:1440*60*1e3,last_7d:10080*60*1e3,last_30d:720*60*60*1e3,last_90d:2160*60*60*1e3,older_7d:10080*60*1e3,older_30d:720*60*60*1e3};function ta(e){if(!e)return 0;const t=Date.parse(e);return Number.isNaN(t)?0:t}function C5(e,t,n=Date.now()){const s=ta(e);if(t.preset){const c=N5[t.preset];return c?t.preset.startsWith("older_")?s<n-c:s>=n-c:!0}const o=t.from?Date.parse(`${t.from}T00:00:00.000Z`):null,i=t.to?Date.parse(`${t.to}T23:59:59.999Z`):null;return!(o!==null&&Number.isFinite(o)&&s<o||i!==null&&Number.isFinite(i)&&s>i)}function E5(e,t,n=Date.now()){const{dateRange:s,project:o,agent:i,sessionStatus:c}=t,u=new Set(o??[]),d=new Set(i??[]),m=new Set(c??[]);return e.filter(h=>{if(s&&!C5(h.started,s,n))return!1;if(u.size>0){const g=h.projectSlug??"__standalone__";if(!u.has(g))return!1}if(d.size>0&&!Array.from(d).some(y=>y.toLowerCase()===h.agent.toLowerCase()))return!1;if(m.size>0){let g=!1;for(const y of m){switch(y){case"active":h.status==="active"&&(g=!0);break;case"ended":(h.status==="completed"||h.status==="stopped")&&(g=!0);break;case"tracked":g=!0;break}if(g)break}if(!g)return!1}return!0})}function T5(e,t,n){return[...e].sort((o,i)=>{let c=0;switch(t){case"started":c=ta(o.started)-ta(i.started);break;case"lastActivity":c=ta(o.updatedAt)-ta(i.updatedAt);break;case"projectName":{const u=o.projectSlug??"",d=i.projectSlug??"";c=u.localeCompare(d);break}case"agentName":c=o.agent.localeCompare(i.agent);break;default:c=ta(o.started)-ta(i.started);break}return n==="asc"?c:-c})}function R5(e,t){return t==null||Number.isNaN(t)||t<=0?e:e.slice(0,t)}function A5({view:e,emptyDescription:t}){const{data:n,loading:s,error:o}=Ef(),i=p.useMemo(()=>{if(!n)return[];const c=n.sessions??[],{config:u}=e,d=u.filters,m={dateRange:d.dateRange?{...d.dateRange,field:"started"}:void 0,project:ze(d.project),agent:ze(d.agent),sessionStatus:ze(d.sessionStatus),limit:u.limit};let h=E5(c,m);return h=T5(h,u.sortField,u.sortDirection),h=R5(h,u.limit),h},[n,e]);return s&&!n?r.jsx(xt,{label:"Loading sessions…"}):o?r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load sessions"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o})]}):i.length===0?r.jsx(Et,{title:"No sessions match this view.",description:t??"Adjust the view's filters to surface different sessions."}):r.jsx(XN,{sessions:i})}function P5({activeViewId:e,onSelectView:t,onCreateNew:n}){const{views:s,loading:o}=Mc(),[i,c]=p.useState(!1),u=p.useRef(null),d=p.useMemo(()=>s.filter(g=>g.entityType==="session"),[s]);p.useEffect(()=>{if(!i)return;function g(b){u.current&&!u.current.contains(b.target)&&c(!1)}function y(b){b.key==="Escape"&&c(!1)}return document.addEventListener("mousedown",g),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",y)}},[i]);const m=e?s.find(g=>g.id===e)??null:null,h=o?"Session views…":m?m.name:"Session views";return r.jsxs("div",{className:"relative",ref:u,children:[r.jsxs("button",{type:"button",disabled:o,onClick:()=>c(g=>!g),className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background disabled:opacity-50","aria-haspopup":"true","aria-expanded":i,title:"Session views",children:[r.jsx("span",{className:"max-w-[160px] truncate",children:h}),r.jsx(pr,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),i&&r.jsxs("div",{className:"absolute right-0 top-full z-30 mt-1 min-w-[240px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:[r.jsxs("button",{type:"button",onClick:()=>{c(!1),t(null)},className:we("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",!e&&"font-semibold text-foreground"),children:[r.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:e?null:r.jsx(Rr,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),r.jsx("span",{children:"All sessions"})]}),d.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"my-1 border-t border-border/40"}),d.map(g=>{const y=g.id===e;return r.jsxs("button",{type:"button",onClick:()=>{c(!1),t(g.id)},className:we("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",y&&"font-semibold text-foreground"),children:[r.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:y?r.jsx(Rr,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null}),r.jsx("span",{className:"truncate",children:g.name})]},g.id)})]}),r.jsx("div",{className:"my-1 border-t border-border/40"}),r.jsxs("button",{type:"button",onClick:()=>{c(!1),n()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5 text-muted-foreground",children:[r.jsx(Lt,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),r.jsx("span",{children:"Create new view…"})]})]})]})}const D5={__unassigned__:"Unassigned",__standalone__:"No project"};function yn({options:e,value:t,onChange:n,allLabel:s="Any",className:o,disabled:i,ariaLabel:c}){const[u,d]=p.useState(!1),m=p.useRef(null),h=p.useRef(null),g=p.useRef([]),y=p.useMemo(()=>{const E=new Set(e.map(T=>T.value)),S=t.filter(T=>!E.has(T)).map(T=>({value:T,label:D5[T]??T}));return[...e,...S]},[e,t]),b=p.useMemo(()=>new Set(t),[t]);p.useEffect(()=>{if(!u)return;function E(S){m.current&&!m.current.contains(S.target)&&d(!1)}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[u]),p.useEffect(()=>{var E;u&&((E=g.current[0])==null||E.focus())},[u]);const C=p.useMemo(()=>{if(t.length===0)return s;if(t.length===1){const E=y.find(S=>S.value===t[0]);return E?E.label:t[0]}return`${t.length} selected`},[t,y,s]);function j(E){n(b.has(E)?t.filter(S=>S!==E):[...t,E])}function v(E){var T;const S=Math.max(0,Math.min(E,y.length-1));(T=g.current[S])==null||T.focus()}function k(E){var R;const S=g.current,T=document.activeElement,P=S.findIndex(A=>A===T);E.key==="ArrowDown"?(E.preventDefault(),v(P<0?0:P+1)):E.key==="ArrowUp"?(E.preventDefault(),v(P<0?y.length-1:P-1)):E.key==="Home"?(E.preventDefault(),v(0)):E.key==="End"?(E.preventDefault(),v(y.length-1)):E.key==="Escape"&&(E.preventDefault(),d(!1),(R=h.current)==null||R.focus())}return r.jsxs("div",{className:"relative",ref:m,children:[r.jsxs("button",{type:"button",ref:h,disabled:i,"aria-haspopup":"menu","aria-expanded":u,"aria-label":c,onClick:()=>d(E=>!E),onKeyDown:E=>{!u&&(E.key==="ArrowDown"||E.key==="ArrowUp")&&(E.preventDefault(),d(!0))},className:we("editor-input inline-flex items-center justify-between gap-1.5 text-left",t.length>0&&"border-foreground/40 text-foreground",o),children:[r.jsx("span",{className:"truncate",children:C}),r.jsx(pr,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),u?r.jsxs("div",{role:"menu","aria-label":c,onKeyDown:k,className:"absolute left-0 top-full z-30 mt-1 max-h-72 min-w-[200px] overflow-auto rounded-md border border-border/70 bg-background py-1 shadow-lg",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pb-1",children:[r.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===y.length,onClick:()=>n(y.map(E=>E.value)),children:"Select all"}),r.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===0,onClick:()=>n([]),children:"Clear"})]}),y.length===0?r.jsx("p",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"No options"}):y.map((E,S)=>{const T=b.has(E.value);return r.jsxs("button",{ref:P=>{g.current[S]=P},type:"button",role:"menuitemcheckbox","aria-checked":T,tabIndex:-1,onClick:()=>j(E.value),className:we("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",T?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{className:we("flex h-4 w-4 shrink-0 items-center justify-center rounded border",T?"border-foreground bg-foreground text-background":"border-border/70"),"aria-hidden":"true",children:T?r.jsx(Rr,{className:"h-3 w-3"}):null}),r.jsx("span",{className:"truncate",children:E.label})]},E.value)})]}):null]})}const jj={last_24h:"Last 24 hours",last_7d:"Last 7 days",last_30d:"Last 30 days",last_90d:"Last 90 days",older_7d:"Older than 7 days",older_30d:"Older than 30 days"},$5=["updated","created"];function sp({value:e,onChange:t,className:n,ariaLabel:s="Date range filter"}){const[o,i]=p.useState(!1),c=p.useRef(null),u=(e==null?void 0:e.field)??"updated",d=!!(e&&!e.preset&&(e.from||e.to)),[m,h]=p.useState(d);p.useEffect(()=>h(d),[d]),p.useEffect(()=>{if(!o)return;function k(S){c.current&&!c.current.contains(S.target)&&i(!1)}function E(S){S.key==="Escape"&&i(!1)}return document.addEventListener("mousedown",k),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",E)}},[o]);const g=!!(e&&(e.preset||e.from||e.to)),y=p.useMemo(()=>!g||!e?"Any date":e.preset?`${u}: ${jj[e.preset]??e.preset}`:`${u}: ${e.from||"…"} → ${e.to||"…"}`,[g,e,u]);function b(k){t(e?{...e,field:k}:{field:k,preset:"",from:"",to:""})}function C(k){h(!1),t({field:u,preset:k,from:"",to:""})}function j(){h(!1),t(null)}function v(k,E){const S={field:u,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""};t({...S,[k]:E})}return r.jsxs("div",{className:"relative",ref:c,children:[r.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":o,"aria-label":s,onClick:()=>i(k=>!k),className:we("editor-input inline-flex items-center justify-between gap-1.5 text-left",g&&"border-foreground/40 text-foreground",n),children:[r.jsx("span",{className:"truncate",children:y}),r.jsx(pr,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),o?r.jsxs("div",{className:"absolute left-0 top-full z-30 mt-1 w-64 rounded-md border border-border/70 bg-background p-2 shadow-lg",children:[r.jsx("div",{className:"mb-2 inline-flex rounded-md border border-border/60 bg-background/80 p-0.5",children:$5.map(k=>r.jsx("button",{type:"button","aria-pressed":u===k,onClick:()=>b(k),className:we("rounded-sm px-2.5 py-1 text-xs font-medium capitalize transition",u===k?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:k},k))}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Dh,{label:"Any date",selected:!g,onClick:j}),wO.map(k=>r.jsx(Dh,{label:jj[k],selected:(e==null?void 0:e.preset)===k,onClick:()=>C(k)},k)),r.jsx(Dh,{label:"Custom range…",selected:m,onClick:()=>{h(!0),t({field:u,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""})}})]}),m?r.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-border/60 pt-2",children:[r.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["From",r.jsx("input",{type:"date",value:(e==null?void 0:e.from)??"",max:(e==null?void 0:e.to)||void 0,onChange:k=>v("from",k.target.value),className:"editor-input w-40"})]}),r.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["To",r.jsx("input",{type:"date",value:(e==null?void 0:e.to)??"",min:(e==null?void 0:e.from)||void 0,onChange:k=>v("to",k.target.value),className:"editor-input w-40"})]})]}):null]}):null]})}function Dh({label:e,selected:t,onClick:n}){return r.jsxs("button",{type:"button",onClick:n,className:we("flex w-full items-center justify-between gap-2 rounded px-2 py-1.5 text-left text-sm transition hover:bg-foreground/5",t?"text-foreground":"text-muted-foreground"),children:[r.jsx("span",{children:e}),t?r.jsx(Rr,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}):null]})}const L5=new Set(["status","type","priority","assignee","project","tags","activity","dateRange","search","query","sessionStatus","agent"]);function O5(e,t){const n={};for(const[s,o]of Object.entries(e))L5.has(s)||(n[s]=o);return{...n,...t}}function lf(e,t,n){return{...e,viewMode:t.viewMode,filters:O5(e.filters,t.filters),sortField:t.sortField,sortDirection:t.sortDirection,limit:t.limit,listSectionVisibility:{collapsed:[...n.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...n.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...n.tableColumnVisibility.hidden]}}}function I5(e,t){var y,b;const n={},s=ze(e.status);s.length&&(n.status=s);const o=ze(e.type);o.length&&(n.type=o);const i=ze(e.priority);i.length&&(n.priority=i);const c=ze(e.assignee);c.length&&(n.assignee=c);const u=ze(e.tags);if(u.length&&(n.tags=u),t&&t!=="all")n.project=[t];else{const C=ze(e.project);C.length&&(n.project=C)}e.activity&&e.activity!=="all"&&(n.activity=e.activity);const d=ze(e.sessionStatus);d.length&&(n.sessionStatus=d);const m=ze(e.agent);m.length&&(n.agent=m),e.dateRange&&(n.dateRange=e.dateRange);const h=(y=e.search)==null?void 0:y.trim();h&&(n.search=h);const g=(b=e.query)==null?void 0:b.trim();return g&&(n.query=g),n}function Oi(e){const t={viewMode:e.state.viewMode,filters:I5(e.state.filters,e.context.projectSlug),sortField:e.state.sortField,sortDirection:e.state.sortDirection,listSectionVisibility:{collapsed:[...e.state.listSectionVisibility.collapsed]},kanbanColumnVisibility:{hidden:[...e.state.kanbanColumnVisibility.hidden]},tableColumnVisibility:{hidden:[...e.state.tableColumnVisibility.hidden]}};return{name:e.name.trim(),workspace:e.context.workspace,config:t}}const ti={viewMode:"kanban",sortField:"updated",sortDirection:"desc"},md={sortField:"started",sortDirection:"desc"};function ZN(e,t){const{config:n}=Oi({name:"",context:{workspace:t,projectSlug:null},state:{viewMode:e.viewMode,filters:e.filters,sortField:e.sortField,sortDirection:e.sortDirection,listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}}}),s={...n};return e.limit!==void 0&&e.limit>0&&(s.limit=e.limit),{workspace:t,config:s}}function oy(e,t){const{config:n}=Oi({name:"",context:{workspace:t,projectSlug:null},state:{viewMode:"list",filters:e.filters,sortField:e.sortField,sortDirection:e.sortDirection,listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}}}),s={...n};return e.limit!==void 0&&e.limit>0&&(s.limit=e.limit),{workspace:t,config:s}}function la(e){if(!e)return;if(e.preset)return{field:e.field,preset:e.preset};const t=e.from&&e.from.length>0?e.from:void 0,n=e.to&&e.to.length>0?e.to:void 0;if(!t&&!n)return;const s={field:e.field};return t&&(s.from=t),n&&(s.to=n),s}function op(e){return e?{field:e.field,preset:e.preset??"",from:e.from??"",to:e.to??""}:null}function eC(e,t){var s,o,i,c,u,d,m,h,g,y,b,C,j,v,k;const{config:n}=e;if((s=t.setViewMode)==null||s.call(t,n.viewMode),(o=t.setStatusFilter)==null||o.call(t,ze(n.filters.status)),(i=t.setTypeFilter)==null||i.call(t,ze(n.filters.type)),(c=t.setPriorityFilter)==null||c.call(t,ze(n.filters.priority)),(u=t.setAssigneeFilter)==null||u.call(t,ze(n.filters.assignee)),(d=t.setProjectFilter)==null||d.call(t,ze(n.filters.project)),(m=t.setTagsFilter)==null||m.call(t,ze(n.filters.tags)),(h=t.setDateRange)==null||h.call(t,op(n.filters.dateRange)),(g=t.setSearch)==null||g.call(t,n.filters.search??""),(y=t.setQuery)==null||y.call(t,n.filters.query??sc(n.filters)),t.setActivityFilter){const E=n.filters.activity??"all";t.setActivityFilter(E==="fresh"||E==="stale"?E:"all")}(b=t.setSortField)==null||b.call(t,n.sortField),(C=t.setSortDirection)==null||C.call(t,n.sortDirection),(j=t.setListSectionVisibility)==null||j.call(t,{collapsed:[...n.listSectionVisibility.collapsed]}),(v=t.setKanbanColumnVisibility)==null||v.call(t,{hidden:[...n.kanbanColumnVisibility.hidden]}),(k=t.setTableColumnVisibility)==null||k.call(t,{hidden:[...n.tableColumnVisibility.hidden]})}function Id(e){return e?`/w/${e}/views`:"/views"}function tC(e){return`${Id(e.workspace)}/${encodeURIComponent(e.id)}`}function nC(e){const t=e.workspace?`/w/${e.workspace}`:"",n=ze(e.config.filters.project);return n.length===1&&n[0]!=="__standalone__"&&sN(e.config,n[0])?`${t}/projects/${n[0]}?tab=assignments&loadView=${encodeURIComponent(e.id)}`:`${t}/assignments?loadView=${encodeURIComponent(e.id)}`}const _5=["critical","high","medium","low"],M5={last_24h:"last 24 hours",last_7d:"last 7 days",last_30d:"last 30 days",last_90d:"last 90 days",older_7d:"older than 7 days",older_30d:"older than 30 days"};function F5(e){if(e.preset)return`${e.field} ${M5[e.preset]??e.preset}`;const t=e.from??"…",n=e.to??"…";return`${e.field} ${t}→${n}`}function rC(e){var o,i;const t=(o=e.query)==null?void 0:o.trim();if(t&&oc(t)===null)return`query: ${t}`;const n=[];for(const c of["status","priority","type","assignee","project","tags"]){const u=ze(e[c]);u.length&&n.push(`${c}=${u.join(", ")}`)}e.activity&&e.activity!=="all"&&n.push(`activity=${e.activity}`),e.dateRange&&n.push(F5(e.dateRange));const s=(i=e.search)==null?void 0:i.trim();return s&&n.push(`search="${s}"`),n.join(" · ")||"no filters"}const kj=80,z5=["started","lastActivity","projectName","agentName"],B5={started:"Start time",lastActivity:"Last updated",projectName:"Project",agentName:"Agent"},U5=[{value:"active",label:"Active"},{value:"ended",label:"Ended"},{value:"tracked",label:"Tracked"},{value:"untracked",label:"Untracked"}];function sC({open:e,onOpenChange:t,initialView:n,onSubmit:s}){const o=!!n,{data:i}=Cs(),{data:c}=Ef(),[u,d]=p.useState(""),[m,h]=p.useState([]),[g,y]=p.useState([]),[b,C]=p.useState([]),[j,v]=p.useState(null),[k,E]=p.useState(md.sortField),[S,T]=p.useState(md.sortDirection),[P,R]=p.useState(""),[A,$]=p.useState(!1),[M,_]=p.useState(null);function D(){h([]),y([]),C([]),v(null),E(md.sortField),T(md.sortDirection),R("")}p.useEffect(()=>{if(e)if(_(null),$(!1),n){const z=n.config.filters;d(n.name),h(ze(z.project)),y(ze(z.agent)),C(ze(z.sessionStatus)),v(op(z.dateRange)),E(n.config.sortField),T(n.config.sortDirection),R(n.config.limit!==void 0?String(n.config.limit):"")}else d(""),D()},[e,n]);const V=p.useMemo(()=>[{value:"__standalone__",label:"No project"},...(i??[]).map(G=>({value:G.slug,label:G.title}))],[i]),K=p.useMemo(()=>{const z=new Set;for(const G of(c==null?void 0:c.sessions)??[])G.agent&&z.add(G.agent);return Array.from(z).sort().map(G=>({value:G,label:G}))},[c]),I=u.trim(),F=I.length>0&&I.length<=kj,q=P.trim()===""?void 0:parseInt(P.trim(),10),Z=P.trim()===""||Number.isFinite(q)&&q!==void 0&&q>0&&q<=500;return r.jsx(On,{open:e,onOpenChange:t,children:r.jsx(Rn,{className:"max-w-lg",children:r.jsxs("form",{className:"space-y-4",onSubmit:async z=>{if(z.preventDefault(),!F||!Z||A)return;$(!0),_(null);const G=la(j),L=G?{...G,field:"started"}:void 0,H={filters:{project:m,agent:g,sessionStatus:b,dateRange:L},sortField:k,sortDirection:S,limit:q};try{await s(I,H)}catch(re){_(re instanceof Error?re.message:String(re)),$(!1)}},children:[r.jsx(Zn,{children:r.jsx(An,{children:o?"Edit session view":"Create session view"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:"create-session-view-name",children:"Name"}),r.jsx("input",{id:"create-session-view-name",type:"text",value:u,autoFocus:!0,required:!0,maxLength:kj,onChange:z=>d(z.target.value),placeholder:"View name",className:"w-full rounded-md border border-border/70 bg-background px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[r.jsx(ni,{label:"Date range (session start)",children:r.jsx(sp,{className:"w-full",value:j,onChange:v})}),r.jsx(ni,{label:"Project",children:r.jsx(yn,{ariaLabel:"Project filter",className:"w-full",allLabel:"All projects",options:V,value:m,onChange:h})}),r.jsx(ni,{label:"Agent",children:r.jsx(yn,{ariaLabel:"Agent filter",className:"w-full",allLabel:"All agents",options:K,value:g,onChange:y})}),r.jsx(ni,{label:"Session status",children:r.jsx(yn,{ariaLabel:"Session status filter",className:"w-full",allLabel:"All statuses",options:U5,value:b,onChange:C})}),r.jsx(ni,{label:"Sort by",className:"sm:col-span-2",children:r.jsxs("div",{className:"flex gap-2",children:[r.jsx("select",{value:k,onChange:z=>E(z.target.value),className:"editor-input w-full",children:z5.map(z=>r.jsx("option",{value:z,children:B5[z]??z},z))}),r.jsx("button",{type:"button",onClick:()=>T(z=>z==="asc"?"desc":"asc"),className:"shell-action shrink-0",title:S==="asc"?"Ascending":"Descending",children:S==="asc"?"Asc":"Desc"})]})}),r.jsxs(ni,{label:"Max results",className:"sm:col-span-2",children:[r.jsx("input",{type:"number",min:1,max:500,value:P,onChange:z=>R(z.target.value),placeholder:"No limit",className:"editor-input w-full"}),Z?null:r.jsx("p",{className:"mt-1 text-xs text-error-foreground",children:"Limit must be between 1 and 500"})]})]}),M?r.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:M}):null,r.jsxs(Ar,{className:"sm:justify-between",children:[r.jsx("button",{type:"button",onClick:D,className:"shell-action",disabled:A,children:"Clear all"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:A,children:"Cancel"}),r.jsx("button",{type:"submit",disabled:!F||!Z||A,className:"shell-action shell-action--cta disabled:opacity-50",children:A?"Saving…":o?"Save changes":"Create view"})]})]})]})})})}function ni({label:e,className:t,children:n}){return r.jsxs("label",{className:`space-y-1 ${t??""}`,children:[r.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:e}),n]})}const V5=4e3;function Ao(){const[e,t]=p.useState(null),n=p.useRef(null),s=p.useCallback(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null),t(null)},[]),o=p.useCallback((i,c="error")=>{n.current!==null&&clearTimeout(n.current),t({id:Date.now()+Math.random(),message:i,kind:c}),n.current=setTimeout(()=>{t(null),n.current=null},V5)},[]);return p.useEffect(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),{toast:e,showToast:o,dismissToast:s}}function xa({toast:e,onDismiss:t}){if(!e)return null;const n=e.kind==="error";return r.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex max-w-sm",role:"status","aria-live":"polite",children:r.jsx("button",{type:"button",onClick:t,className:we("syntaur-toast pointer-events-auto rounded-md border px-4 py-3 text-sm font-medium shadow-lg transition",n?"border-error-foreground/30 bg-error text-error-foreground hover:opacity-90":"border-success-foreground/30 bg-success text-success-foreground hover:opacity-90"),children:e.message},e.id)})}function $h({title:e,message:t,onPickAnother:n}){return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:e}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t}),n?r.jsx("button",{type:"button",onClick:n,className:"shell-action mt-3",children:"Pick another widget"}):null]})}function H5({viewId:e,slotId:t,onPickAnother:n}){const{data:s,loading:o,error:i}=Ef(),{view:c,loading:u,ready:d}=So(e??null),{layout:m}=dN(),{showToast:h}=Ao(),[g,y]=p.useState(!1),b=p.useCallback(async v=>{if(!t)return;const k=m.slots.map(E=>E.id===t?{...E,widget:v?{kind:"agent-sessions",viewId:v}:{kind:"agent-sessions"}}:E);try{await Sg(k)}catch(E){h(E instanceof Error?E.message:"Failed to update widget")}},[m,t,h]);async function C(v,k){const{workspace:E,config:S}=oy(k,null);try{const P=(await Pi({name:v,workspace:E,config:S,entityType:"session"})).views.find(R=>R.name===v&&R.entityType==="session");P&&await b(P.id),y(!1),h(`Created session view "${v}"`)}catch(T){throw h(T instanceof Error?T.message:"Failed to create session view"),T}}let j;return e?u&&!d?j=r.jsx(xt,{label:"Loading view…"}):c?c.entityType!=="session"?j=r.jsx($h,{title:"Wrong view type",message:"This widget is bound to an assignment view. Choose a session view above, or pick a different widget.",onPickAnother:n}):j=r.jsx(A5,{view:c,emptyDescription:"Adjust the view's filters to surface different sessions, or pick another widget for this slot."}):j=r.jsx($h,{title:"View no longer exists",message:"The saved view this widget was bound to has been deleted. Pick another session view above, or choose a different widget.",onPickAnother:n}):o&&!s?j=r.jsx(xt,{label:"Loading sessions…"}):i?j=r.jsx($h,{title:"Couldn't load sessions",message:i}):j=r.jsx(XN,{sessions:(s==null?void 0:s.sessions)??[]}),r.jsxs("div",{className:"space-y-2",children:[t?r.jsx("div",{className:"flex items-center justify-between gap-2",children:r.jsx(P5,{activeViewId:e??null,onSelectView:v=>void b(v),onCreateNew:()=>y(!0)})}):null,j,r.jsx(sC,{open:g,onOpenChange:y,workspace:null,onSubmit:C})]})}const W5=5;function K5(){const{data:e,loading:t,error:n}=cS();if(t&&!e)return r.jsx(xt,{label:"Loading inventories…"});if(n)return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load inventories"}),r.jsx("p",{className:"mt-1 text-xs",children:n})]});const o=((e==null?void 0:e.inventories)??[]).slice(0,W5);return r.jsxs("aside",{"aria-labelledby":"overview-inventories-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsxs("header",{className:"flex items-center justify-between border-b border-border/40 px-4 py-3",children:[r.jsx("h3",{id:"overview-inventories-title",className:"text-sm font-semibold text-foreground",children:"Inventories"}),r.jsx(Ee,{to:"/inventories",className:"text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),o.length===0?r.jsxs("div",{className:"px-4 py-6 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"No inventories yet."}),r.jsx("p",{className:"mt-1 text-muted-foreground",children:"Create one to track leased resources across agents."})]}):r.jsx("ul",{className:"divide-y divide-border/40",children:o.map(i=>{const c=i.inventory,u=i.active_leases.length,d=i.members.length,m=c.display_name??c.slug;return r.jsx("li",{children:r.jsxs(Ee,{to:`/inventories/${encodeURIComponent(c.slug)}`,className:"flex items-center gap-3 px-4 py-2.5 text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:m}),r.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[u,"/",d," leased"]})]})},c.slug)})})]})}function q5(e){let t=0,n=0;for(const s of e.daily)t+=s.total_tokens,n+=s.total_cost;return{tokens:t,cost:n}}function Sj({filters:e,metric:t}){const n=e??{},{data:s,loading:o,error:i}=S3(n),c=t==="cost"?"Spend":"Token Usage",u=`/usage?${pg(n).toString()}`;let d;if(o&&!s)d=r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"});else if(i&&!s)d=r.jsxs("div",{className:"text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load usage"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i})]});else if(!s||s.daily.length===0)d=r.jsx("p",{className:"text-sm text-muted-foreground",children:"No usage for these filters."});else{const{tokens:m,cost:h}=q5(s),g=t==="cost"?{label:"Total spend",value:Ai(h)}:{label:"Total tokens",value:Ri(m)},y=t==="cost"?{label:"Tokens",value:Ri(m)}:{label:"Spend",value:Ai(h)};d=r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(Nj,{label:g.label,value:g.value,emphasize:!0}),r.jsx(Nj,{label:y.label,value:y.value})]})}return r.jsxs("aside",{className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[r.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-border/40 px-4 py-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("h3",{className:"text-sm font-semibold text-foreground",children:c}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",title:Nw(n),children:Nw(n)})]}),r.jsx(Ee,{to:u,className:"shrink-0 text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),r.jsx("div",{className:"px-4 py-4",children:d})]})}function Nj({label:e,value:t,emphasize:n}){return r.jsxs("div",{className:"space-y-0.5",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e}),r.jsx("p",{className:n?"text-2xl font-semibold tabular-nums text-foreground":"text-lg font-semibold tabular-nums text-foreground",children:t})]})}const G5={"7d":"7 days","30d":"30 days","90d":"90 days",all:"All time",custom:"Custom"};function Y5(e){return e.kind==="token-usage"||e.kind==="spend"?e.filters??{}:{}}const ri="bg-background border border-border rounded px-2 py-1 text-sm text-foreground";function Cj({config:e,open:t,onSave:n,onCancel:s}){const o=e.kind==="spend"?"Configure Spend":"Configure Token Usage",{data:i}=Cs(),{data:c}=fa(),{data:u}=uS(t),[d,m]=p.useState("30d"),[h,g]=p.useState(""),[y,b]=p.useState(""),[C,j]=p.useState(""),[v,k]=p.useState(""),[E,S]=p.useState(""),[T,P]=p.useState(""),[R,A]=p.useState(!1),[$,M]=p.useState(null);p.useEffect(()=>{if(!t)return;const F=Y5(e);m(F.window??"30d"),g(F.since??""),b(F.until??""),j(F.project??""),k(F.workspace??""),S(F.model??""),P(F.tool??""),A(!1),M(null)},[t,e]);function _(){return Dc({window:d,since:d==="custom"?h:void 0,until:d==="custom"?y:void 0,project:C||void 0,workspace:v||void 0,model:E||void 0,tool:T||void 0})}async function D(F){if(F.preventDefault(),R)return;const q=_(),Z=p3(q);if(!Z.ok){M(Z.errors.join("; "));return}A(!0),M(null);const z=e.kind==="token-usage"?{kind:"token-usage",filters:q}:e.kind==="spend"?{kind:"spend",filters:q}:e;try{await n(z)}catch(G){M(G instanceof Error?G.message:String(G)),A(!1)}}const V=(i==null?void 0:i.map(F=>F.slug))??[],K=(c==null?void 0:c.workspaces)??[],I=(c==null?void 0:c.hasUngrouped)??!1;return r.jsx(On,{open:t,onOpenChange:F=>{F||s()},children:r.jsx(Rn,{className:"max-w-md",children:r.jsxs("form",{onSubmit:D,children:[r.jsx(Zn,{children:r.jsx(An,{children:o})}),r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Window"}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:Nf.map(F=>r.jsx("button",{type:"button",onClick:()=>m(F),className:"rounded px-2.5 py-1 text-sm border "+(F===d?"border-primary bg-primary/10 text-foreground":"border-border text-muted-foreground hover:text-foreground"),children:G5[F]},F))})]}),d==="custom"?r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Since"}),r.jsx("input",{type:"date",value:h,onChange:F=>g(F.target.value),className:ri})]}),r.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Until"}),r.jsx("input",{type:"date",value:y,onChange:F=>b(F.target.value),className:ri})]})]}):null,r.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Workspace"}),r.jsxs("select",{value:v,onChange:F=>{k(F.target.value),F.target.value&&j("")},className:ri,children:[r.jsx("option",{value:"",children:"All workspaces"}),I?r.jsx("option",{value:"_ungrouped",children:"(ungrouped)"}):null,K.map(F=>r.jsx("option",{value:F,children:F},F))]})]}),r.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Project"}),r.jsxs("select",{value:C,onChange:F=>{j(F.target.value),F.target.value&&k("")},className:ri,children:[r.jsx("option",{value:"",children:"All projects"}),V.map(F=>r.jsx("option",{value:F,children:F},F))]})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Model"}),r.jsxs("select",{value:E,onChange:F=>S(F.target.value),className:ri,children:[r.jsx("option",{value:"",children:"All models"}),((u==null?void 0:u.models)??[]).map(F=>r.jsx("option",{value:F,children:F},F))]})]}),r.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Tool"}),r.jsxs("select",{value:T,onChange:F=>P(F.target.value),className:ri,children:[r.jsx("option",{value:"",children:"All tools"}),((u==null?void 0:u.tools)??[]).map(F=>r.jsx("option",{value:F,children:F},F))]})]})]}),$?r.jsx("p",{className:"text-xs text-destructive",role:"alert",children:$}):null]}),r.jsxs(Ar,{className:"sm:justify-between",children:[r.jsx("button",{type:"button",onClick:s,disabled:R,className:"shell-action",children:"Cancel"}),r.jsx("button",{type:"submit",disabled:R,className:"shell-action shell-action--cta",children:R?"Saving…":"Save"})]})]})})})}const ay={"saved-view":{title:"Saved view",icon:$k,render:(e,t)=>e.kind!=="saved-view"?null:p.createElement(w5,{viewId:e.viewId,onPickAnother:t.onPickAnother})},"agent-sessions":{title:"Agent sessions",icon:vf,render:(e,t)=>e.kind!=="agent-sessions"?null:p.createElement(H5,{viewId:e.viewId,slotId:t.slotId,onPickAnother:t.onPickAnother})},inventories:{title:"Inventories",icon:kf,render:()=>p.createElement(K5)},"token-usage":{title:"Token Usage",icon:eP,render:e=>e.kind!=="token-usage"?null:p.createElement(Sj,{filters:e.filters,metric:"tokens"}),ConfigEditor:Cj},spend:{title:"Spend",icon:Rc,render:e=>e.kind!=="spend"?null:p.createElement(Sj,{filters:e.filters,metric:"cost"}),ConfigEditor:Cj}},Q5={small:"min-h-[320px]",wide:"xl:col-span-2 min-h-[320px]",tall:"min-h-[560px]",large:"xl:col-span-2 min-h-[560px]"},oC={small:"Small",wide:"Wide",tall:"Tall",large:"Large"};function J5({slot:e,onReplace:t,onRemove:n,onResize:s,onConfigChange:o}){const[i,c]=p.useState(!1),{attributes:u,listeners:d,setNodeRef:m,setActivatorNodeRef:h,transform:g,transition:y,isDragging:b}=Vf({id:e.id}),C={transform:rs.Translate.toString(g),transition:y,zIndex:b?50:void 0,position:b?"relative":void 0},j=r.jsx("button",{ref:h,...u,...d,type:"button","aria-label":"Drag to reorder widget",className:"touch-none cursor-grab text-muted-foreground/40 transition hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:cursor-grabbing",children:r.jsx(Fi,{className:"h-4 w-4","aria-hidden":"true"})}),v=e.size??"small",k=Q5[v];if(e.widget===null)return r.jsxs("div",{ref:m,style:C,className:we("relative flex items-center justify-center rounded-lg border border-dashed border-border/60 bg-card/40 p-3 shadow-sm",k,b&&"opacity-0"),children:[r.jsx("div",{className:"absolute left-2 top-2",children:j}),r.jsxs("button",{type:"button",onClick:t,className:"shell-action inline-flex items-center gap-2",children:[r.jsx(Lt,{className:"h-4 w-4"}),"Add widget"]})]});const E=ay[e.widget.kind];if(!E)return r.jsx("div",{ref:m,style:C,className:we("overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",k,b&&"opacity-0"),children:r.jsxs("div",{className:"flex items-start gap-2",children:[j,r.jsxs("div",{className:"flex-1 rounded-md border border-border/60 bg-background/60 px-3 py-2 text-sm text-muted-foreground",children:["Unknown widget kind: ",e.widget.kind]})]})});const S=E.icon,T=E.ConfigEditor;return r.jsxs("div",{ref:m,style:C,className:we("overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",k,b&&"opacity-0"),children:[r.jsxs("header",{className:"mb-2 flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[j,r.jsx(S,{className:"h-3.5 w-3.5","aria-hidden":"true"}),r.jsx("span",{className:"truncate",children:r.jsx(Z5,{slot:e,fallback:E.title})})]}),r.jsx(ry,{items:[{key:"replace",label:"Replace…",icon:uP,onSelect:t},...E.ConfigEditor?[{key:"configure",label:"Configure…",icon:hP,onSelect:()=>c(!0)}]:[],{key:"size",label:"Size",icon:aP,submenu:nI.map(P=>({key:`size-${P}`,label:oC[P],active:P===v,onSelect:()=>s(P)}))},{key:"remove",label:"Remove",icon:Tn,destructive:!0,onSelect:n}]})]}),r.jsx("div",{children:E.render(e.widget,{slotId:e.id,onPickAnother:t})}),T?r.jsx(T,{config:e.widget,open:i,onSave:async P=>{await o(P),c(!1)},onCancel:()=>c(!1)}):null]})}function X5({slot:e}){const t=e.widget?ay[e.widget.kind]:null,n=t==null?void 0:t.icon,s=e.widget===null?"Empty widget slot":(t==null?void 0:t.title)??`Unknown widget kind: ${e.widget.kind}`,o=oC[e.size??"small"];return r.jsx("div",{"aria-hidden":"true",className:"w-72 rounded-lg border border-border/70 bg-card/95 p-3 shadow-xl ring-1 ring-foreground/10",children:r.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[r.jsx(Fi,{className:"h-4 w-4","aria-hidden":"true"}),n?r.jsx(n,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null,r.jsx("span",{className:"min-w-0 flex-1 truncate",children:s}),r.jsx("span",{className:"text-[10px] tracking-normal text-muted-foreground/70",children:o})]})})}function Z5({slot:e,fallback:t}){var o,i;const n=((o=e.widget)==null?void 0:o.kind)==="saved-view"?e.widget.viewId:null,{view:s}=So(n);return((i=e.widget)==null?void 0:i.kind)==="saved-view"&&s?r.jsx(r.Fragment,{children:s.name}):r.jsx(r.Fragment,{children:t})}const eM=["agent-sessions","inventories","token-usage","spend"];function tM({open:e,onOpenChange:t,onSelect:n}){const{views:s,loading:o}=Mc();function i(c){n(c),t(!1)}return r.jsx(On,{open:e,onOpenChange:t,children:r.jsxs(Rn,{className:"max-w-xl",children:[r.jsxs(Zn,{children:[r.jsx(An,{children:"Add a widget"}),r.jsx(Hr,{children:"Choose a built-in widget, an assignment view, or a session view."})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Built-in widgets"}),r.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:eM.map(c=>{const u=ay[c],d=u.icon;return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>i({kind:c}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx(d,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),r.jsx("span",{className:"font-medium text-foreground",children:u.title})]})},c)})})]}),r.jsxs("section",{className:"space-y-2",children:[r.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Saved views"}),o?r.jsx("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm text-muted-foreground",children:"Loading saved views…"}):s.length===0?r.jsxs("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm",children:[r.jsx("p",{className:"font-medium text-foreground",children:"No saved views yet"}),r.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Save a view from the assignments page first."," ",r.jsx(Ee,{to:"/views",className:"text-foreground underline hover:opacity-80",children:"Manage views →"})]})]}):r.jsxs("div",{className:"space-y-3",children:[s.some(c=>c.entityType!=="session")&&r.jsxs("div",{children:[r.jsx("h4",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Assignments"}),r.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:s.filter(c=>c.entityType!=="session").map(c=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>i({kind:"saved-view",viewId:c.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:c.name}),c.workspace!==null?r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] text-muted-foreground",title:`Scoped to workspace: ${c.workspace}`,children:c.workspace}):null,r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] capitalize text-muted-foreground",children:c.config.viewMode})]})},c.id))})]}),s.some(c=>c.entityType==="session")&&r.jsxs("div",{children:[r.jsx("h4",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Sessions"}),r.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:s.filter(c=>c.entityType==="session").map(c=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>i({kind:"agent-sessions",viewId:c.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:c.name}),c.workspace!==null?r.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] text-muted-foreground",title:`Scoped to workspace: ${c.workspace}`,children:c.workspace}):null]})},c.id))})]})]}),!o&&s.some(c=>c.workspace!==null)?r.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Workspace-scoped views on the global Overview will only show items from that workspace."}):null]})]})})}const nM=(e,{currentCoordinates:t,context:n})=>{var g;const s=e.code==="ArrowRight"||e.code==="ArrowDown"?1:e.code==="ArrowLeft"||e.code==="ArrowUp"?-1:0;if(s===0)return;e.preventDefault();const o=n.over??n.active,i=(g=o==null?void 0:o.data.current)==null?void 0:g.sortable,c=i==null?void 0:i.items;if(!o||!c)return t;const u=c.indexOf(o.id);if(u===-1)return t;const d=c[u+s],m=d===void 0?null:n.droppableRects.get(d),h=n.collisionRect;return!m||!h?t:{x:m.left+(m.width-h.width)/2,y:m.top+(m.height-h.height)/2}};function rM(){const{data:e,error:t,refetch:n}=g3(),{data:s}=aS(),{layout:o}=dN(),[i,c]=p.useState(!1),[u,d]=p.useState(null),[m,h]=p.useState(null),[g,y]=p.useState(o.slots),[b,C]=p.useState(null);p.useEffect(()=>{y(o.slots)},[o.slots]);const j=If(ko(Ki,{activationConstraint:{distance:8}}),ko(Wi,{coordinateGetter:nM}));Ro("list:overview"),Yt({keys:"r",description:"Refresh",scope:"list:overview",handler:()=>{n()}});const v=p.useCallback(_=>{d(_),c(!0)},[]),k=p.useCallback(async(_,D)=>{h(null),y(_);try{await Sg(_)}catch(V){y(D),h(V instanceof Error?V.message:String(V))}},[]),E=p.useCallback(_=>{if(u===null)return;const D=g.map((V,K)=>K===u?{...V,widget:_}:V);d(null),k(D,g)},[g,u,k]),S=p.useCallback(_=>{const D=g.map((V,K)=>K===_?{...V,widget:null}:V);k(D,g)},[g,k]),T=p.useCallback((_,D)=>{const V=g.map((K,I)=>I===_?{...K,size:D}:K);k(V,g)},[g,k]),P=p.useCallback(_=>{const{active:D,over:V}=_;if(C(null),!V||D.id===V.id)return;const K=g.findIndex(q=>q.id===D.id),I=g.findIndex(q=>q.id===V.id);if(K===-1||I===-1)return;const F=qi(g,K,I);k(F,g)},[g,k]),R=p.useCallback(_=>{C(String(_.active.id))},[]),A=g.find(_=>_.id===b)??null,$=p.useCallback(async(_,D)=>{const V=g,K=g.map((I,F)=>F===_?{...I,widget:D}:I);h(null),y(K);try{await Sg(K)}catch(I){y(V);const F=I instanceof Error?I.message:String(I);throw h(F),I instanceof Error?I:new Error(F)}},[g]),M={};if(e)for(const _ of Object.keys(e.segments))for(const D of e.segments[_].items)M[D.id]=D;return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("header",{className:"space-y-2",children:[r.jsx("p",{className:"eyebrow",children:"Workspace Overview"}),r.jsx("h1",{className:"text-4xl font-semibold tracking-display text-foreground md:text-5xl",children:"What needs you today"})]}),e?r.jsx(gO,{hero:e.hero,itemsById:M}):t?r.jsx(Tt,{error:t}):r.jsx(xt,{label:"Loading overview…"}),e!=null&&e.firstRun?r.jsx(mO,{help:s}):null,m?r.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Couldn't save dashboard layout: ",m]}):null,r.jsxs(Bf,{sensors:j,collisionDetection:_f,onDragStart:R,onDragCancel:()=>C(null),onDragEnd:P,children:[r.jsx(Uf,{items:g.map(_=>_.id),strategy:zx,children:r.jsx("div",{className:"grid grid-flow-dense grid-cols-1 gap-4 xl:grid-cols-2",children:g.map((_,D)=>r.jsx(J5,{slot:_,index:D,onReplace:()=>v(D),onRemove:()=>S(D),onResize:V=>T(D,V),onConfigChange:V=>$(D,V)},_.id))})}),r.jsx(eO,{dropAnimation:null,children:A?r.jsx(X5,{slot:A}):null})]}),e!=null&&e.serverStats?r.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx(lx,{className:"h-3 w-3","aria-hidden":"true"}),r.jsxs("span",{children:["● ",e.serverStats.totalPorts," ports ·"," ",e.serverStats.deadSessions>0?`${e.serverStats.deadSessions} dead`:"all healthy"]})]}):null,r.jsx(tM,{open:i,onOpenChange:_=>{c(_),_||d(null)},onSelect:E})]})}function sM({term:e,description:t}){return r.jsx("span",{title:t,className:"cursor-help rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-xs font-medium text-foreground underline decoration-dotted underline-offset-4",children:e})}function oM(){const{data:e,loading:t,error:n}=aS(),{openCheatsheet:s}=To();return t?r.jsx(xt,{label:"Loading help…"}):n||!e?r.jsx(Tt,{error:n||"Help content is unavailable."}):r.jsxs("div",{className:"space-y-5",children:[r.jsx(He,{title:"Keyboard Shortcuts",description:"Navigate the dashboard without reaching for the mouse.",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 rounded-md border border-border/70 bg-background/80 px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent",children:"Open shortcuts cheatsheet"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["or press ",r.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"?"})," ","anywhere. ",ks("Mod+k")," opens the command palette."]})]})}),r.jsx(He,{title:"What Syntaur Is",description:e.whatIsSyntaur.summary,children:r.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:e.whatIsSyntaur.bullets.map(o=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3 text-sm leading-6 text-muted-foreground",children:o},o))})}),r.jsx(He,{title:"Getting Started",children:r.jsx("div",{className:"space-y-3",children:e.workflow.map((o,i)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:i+1}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?r.jsx(Pd,{command:o.command.command,description:o.command.description,example:o.command.example}):null,o.href?r.jsx(Ee,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open the related surface"}):null]})]})},o.title))})}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsxs(He,{title:"Core Concepts",children:[r.jsx("div",{className:"flex flex-wrap gap-2",children:e.coreConcepts.map(o=>r.jsx(sM,{term:o.term,description:o.description},o.term))}),r.jsx("div",{className:"grid gap-3 pt-2",children:e.coreConcepts.map(o=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:o.term}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description})]},o.term))})]}),r.jsx(He,{title:"Status Guide",children:r.jsx("div",{className:"space-y-3",children:e.statusGuide.map(o=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(bn,{status:o.status}),r.jsx("p",{className:"font-semibold text-foreground",children:o.meaning})]}),r.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:o.useWhen})]},o.status))})})]}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsx(He,{title:"Ownership And File Rules",children:r.jsx("div",{className:"space-y-3",children:e.ownershipRules.map(o=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:o.label}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description}),r.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:o.files.map(i=>r.jsx("span",{className:"rounded-full border border-border/60 bg-card/90 px-2.5 py-1 font-mono text-xs text-foreground",children:i},i))})]},o.label))})}),r.jsx(He,{title:"How To Navigate The Dashboard",children:r.jsx("div",{className:"space-y-3",children:e.navigation.map(o=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:o.label}),r.jsx(Ee,{className:"text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open"})]}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description})]},o.label))})})]}),r.jsx(He,{title:"CLI Quick Reference",children:r.jsx("div",{className:"grid gap-3 xl:grid-cols-2",children:e.commands.map(o=>r.jsx(Pd,{command:o.command,description:o.description,example:o.example},o.command))})}),r.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[r.jsx(He,{title:"FAQ",children:r.jsx("div",{className:"space-y-3",children:e.faq.map(o=>r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:o.question}),r.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.answer})]},o.question))})}),r.jsx(He,{title:"First Project Checklist",children:r.jsx("div",{className:"space-y-3",children:e.firstProjectChecklist.map((o,i)=>r.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-xs font-semibold text-background",children:i+1}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),r.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?r.jsx(Pd,{command:o.command.command,example:o.command.example}):null,o.href?r.jsx(Ee,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open the related surface"}):null]})]})},o.title))})})]})]})}function iy({children:e}){return r.jsx("div",{className:"chrome-card flex flex-col gap-2 !p-2.5 md:flex-row md:flex-wrap md:items-center",children:e})}const ap=p.forwardRef(({value:e,onChange:t,placeholder:n="Search"},s)=>r.jsxs("label",{className:"relative flex min-w-[220px] flex-1 items-center",children:[r.jsx(Eo,{className:"pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground"}),r.jsx("input",{ref:s,value:e,onChange:o=>t(o.target.value),placeholder:n,className:"h-9 w-full rounded-md border border-border/60 bg-background/90 pl-9 pr-3 text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-ring/30"})]}));ap.displayName="SearchInput";function ip({value:e,options:t,onChange:n}){return r.jsx("div",{className:"inline-flex rounded-md border border-border/60 bg-background/80 p-1",children:t.map(s=>r.jsx("button",{type:"button","aria-pressed":e===s.value,onClick:()=>n(s.value),className:we("rounded-sm px-2.5 py-1.5 text-sm font-medium transition",e===s.value?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:s.label},s.value))})}const aM={completed:"bg-status-completed-foreground",in_progress:"bg-status-in-progress-foreground",review:"bg-status-review-foreground",blocked:"bg-status-blocked-foreground",failed:"bg-status-failed-foreground",pending:"bg-status-pending-foreground"},Ej=["bg-primary","bg-secondary","bg-accent-coral","bg-accent-teal","bg-accent-amber"];function cf({progress:e,className:t,showLegend:n=!1}){const s=ha(),o=p.useMemo(()=>{let c=0;return(s.order.length>0?s.order:Object.keys(e).filter(d=>d!=="total")).map(d=>({key:d,className:aM[d]??Ej[c++%Ej.length]}))},[s.order,e]),i=o.filter(c=>(e[c.key]??0)>0);return r.jsxs("div",{className:we("space-y-2",t),children:[r.jsx("div",{className:"flex h-1.5 w-full overflow-hidden rounded-lg border border-border/70 bg-muted/60",children:e.total===0?r.jsx("div",{className:"h-full w-full bg-muted"}):i.map(c=>r.jsx("div",{className:c.className,style:{width:`${(e[c.key]??0)/e.total*100}%`},title:`${Sn(c.key)}: ${e[c.key]??0}`},c.key))}),n?r.jsx("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:o.map(c=>r.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-background/80 px-2 py-1",children:[r.jsx("span",{className:we("h-2 w-2 rounded-full",c.className)}),r.jsx("span",{children:Sn(c.key)}),r.jsx("span",{className:"font-medium text-foreground",children:e[c.key]??0})]},c.key))}):null]})}const iM=["pending","active","blocked","failed","completed"],ly=iM,lM=["draft","pending","ready_for_planning","ready_to_implement","in_progress","blocked","review","completed","failed"];function aC(e){return e&&e.length>0?e:[...lM]}function cM(e,t,n){if(t<0||t>=e.length)return e;const s=[...e],[o]=s.splice(t,1),i=t<n?n-1:n;return s.splice(Math.max(0,Math.min(i,s.length)),0,o),s}const uM=220,hd=8;function iC({anchor:e,items:t,onClose:n}){const s=p.useRef(null),[o,i]=p.useState(null);return p.useLayoutEffect(()=>{if(!e){i(null);return}const c=s.current,u=(c==null?void 0:c.offsetWidth)??uM,d=(c==null?void 0:c.offsetHeight)??0,m=Math.max(hd,window.innerWidth-u-hd),h=Math.max(hd,window.innerHeight-d-hd);i({left:Math.min(e.x,m),top:Math.min(e.y,h)})},[e]),p.useEffect(()=>{if(!e)return;function c(m){s.current&&!s.current.contains(m.target)&&n()}function u(m){m.key==="Escape"&&n()}function d(){n()}return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),document.addEventListener("contextmenu",c),window.addEventListener("scroll",d,!0),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u),document.removeEventListener("contextmenu",c),window.removeEventListener("scroll",d,!0)}},[e,n]),!e||t.length===0?null:r.jsx("div",{ref:s,role:"menu",className:"fixed z-50 min-w-[220px] rounded-md border border-border/70 bg-background py-1 shadow-lg",style:{left:(o==null?void 0:o.left)??e.x,top:(o==null?void 0:o.top)??e.y,visibility:o?"visible":"hidden"},children:r.jsx(ia,{delayDuration:200,children:t.map(c=>{const u=c.icon,d=we("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition",c.disabled?"cursor-not-allowed opacity-50":c.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),m=r.jsxs(r.Fragment,{children:[u?r.jsx(u,{className:"h-4 w-4 shrink-0"}):null,r.jsx("span",{className:"block min-w-0 truncate",children:c.label})]});if(c.disabled){const h=r.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:r.jsx("button",{type:"button",disabled:!0,className:d,children:m})});return c.disabledReason?r.jsxs(Nr,{children:[r.jsx(Cr,{asChild:!0,children:h}),r.jsx(ur,{side:"left",children:c.disabledReason})]},c.key):r.jsx("div",{children:h},c.key)}return c.href?r.jsx(Ee,{to:c.href,className:d,onClick:()=>n(),children:m},c.key):r.jsx("button",{type:"button",className:d,onClick:()=>{var h;(h=c.onSelect)==null||h.call(c),n()},children:m},c.key)})})})}const dM="__ungrouped__";function cy({open:e,onOpenChange:t,currentWorkspace:n,onSubmit:s,title:o="Move to workspace",description:i="Pick the workspace this item should belong to."}){const{data:c,loading:u}=fa(),[d,m]=p.useState(n),[h,g]=p.useState(!1),[y,b]=p.useState(null);p.useEffect(()=>{e&&(m(n),b(null))},[e,n]);const C=p.useMemo(()=>[...((c==null?void 0:c.workspaces)??[]).map(E=>({key:E,label:E,value:E})),{key:dM,label:"Ungrouped",value:null}],[c]),j=!h&&d!==n;async function v(){if(j){g(!0),b(null);try{await s(d),t(!1)}catch(k){b(k instanceof Error?k.message:"Failed to move item")}finally{g(!1)}}}return r.jsx(On,{open:e,onOpenChange:k=>h?void 0:t(k),children:r.jsxs(Rn,{children:[r.jsxs(Zn,{children:[r.jsx(An,{children:o}),r.jsx(Hr,{children:i})]}),r.jsx("div",{className:"my-2 max-h-[320px] overflow-y-auto rounded-md border border-border/60",children:u&&C.length===0?r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-sm text-muted-foreground",children:[r.jsx(ix,{className:"h-4 w-4 animate-spin"})," Loading workspaces…"]}):C.map(k=>{const E=k.value===n,S=k.value===d;return r.jsxs("button",{type:"button",disabled:E||h,onClick:()=>m(k.value),className:we("flex w-full items-center justify-between px-3 py-2 text-left text-sm transition",E?"cursor-not-allowed bg-foreground/5 text-muted-foreground":S?"bg-accent/40 text-foreground":"hover:bg-foreground/5"),children:[r.jsxs("span",{className:we("block min-w-0 truncate",k.value===null?"italic text-muted-foreground":""),children:[k.label,E?r.jsx("span",{className:"ml-2 text-xs",children:"(current)"}):null]}),S?r.jsx(Rr,{className:"h-4 w-4 text-foreground"}):null]},k.key)})}),y?r.jsx("p",{className:"text-sm text-destructive",role:"alert",children:y}):null,r.jsxs(Ar,{children:[r.jsx("button",{type:"button",onClick:()=>t(!1),disabled:h,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),r.jsx("button",{type:"button",onClick:v,disabled:!j,className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:h?"Moving…":"Move"})]})]})})}function Tj(){const{workspace:e}=Bt(),t=fn(),n=zt(),{data:s,loading:o,error:i,refetch:c}=Cs(),u=p.useRef(null);Ro("list:projects");const[d,m]=p.useState(""),[h,g]=p.useState("all"),[y,b]=p.useState("all"),[C,j]=p.useState("updated"),[v,k]=ls(),E=v.get("view"),S=E==="table"||E==="kanban"?E:"cards",T=z=>{k(G=>{const L=new URLSearchParams(G);return z==="cards"?L.delete("view"):L.set("view",z),L})},[P,R]=p.useState({}),[A,$]=p.useState(null),[M,_]=p.useState(null),D=p.useMemo(()=>s?s.filter(z=>{if(e){if(e==="_ungrouped"){if(z.workspace!==null)return!1}else if(z.workspace!==e)return!1}return h!=="all"&&z.status!==h||y!=="all"&&!z.tags.includes(y)?!1:d.trim()?`${z.title} ${z.tags.join(" ")} ${z.slug}`.toLowerCase().includes(d.toLowerCase()):!0}).sort((z,G)=>mM(z,G,C)):[],[s,d,h,y,C,e]),V=D.map(z=>`${z.slug}:${z.status}`).join("|");p.useEffect(()=>{R(hM(D))},[V,C]);const K=p.useMemo(()=>{const z=new Map(D.map(G=>[G.slug,G]));return ly.flatMap(G=>(P[G]??D.filter(H=>H.status===G).map(H=>H.slug)).map(H=>z.get(H)).filter(H=>!!H))},[D,P]),{visibleItems:I,visibleIndexByKey:F}=p.useMemo(()=>{const z=S==="kanban"?K:D,G=new Map;return z.forEach((L,H)=>G.set(L.slug,H)),{visibleItems:z,visibleIndexByKey:G}},[S,D,K]),{hotkeyRowProps:q}=$c(I,{scope:"list:projects",onOpen:z=>n(`${t}/projects/${z.slug}`)});if(Yt({keys:"/",scope:"list:projects",description:"Focus filter",handler:()=>{var z;return(z=u.current)==null?void 0:z.focus()}}),Yt({keys:"r",scope:"list:projects",description:"Refresh",handler:()=>c()}),o)return r.jsx(xt,{label:"Loading projects…"});if(i||!s)return r.jsx(Tt,{error:i||"Project list is unavailable."});const Z=Array.from(new Set(s.flatMap(z=>z.tags))).sort();return r.jsxs("div",{className:"space-y-5",children:[r.jsxs(iy,{children:[r.jsx(ap,{ref:u,value:d,onChange:m,placeholder:"Search by project title or tag"}),r.jsxs("select",{value:h,onChange:z=>g(z.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All statuses"}),r.jsx("option",{value:"pending",children:"Pending"}),r.jsx("option",{value:"active",children:"Active"}),r.jsx("option",{value:"blocked",children:"Blocked"}),r.jsx("option",{value:"failed",children:"Failed"}),r.jsx("option",{value:"completed",children:"Completed"})]}),r.jsxs("select",{value:y,onChange:z=>b(z.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All tags"}),Z.map(z=>r.jsx("option",{value:z,children:z},z))]}),r.jsxs("select",{value:C,onChange:z=>j(z.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"updated",children:"Sort: Updated"}),r.jsx("option",{value:"created",children:"Sort: Created"}),r.jsx("option",{value:"title",children:"Sort: Title"}),r.jsx("option",{value:"attention",children:"Sort: Attention"})]}),r.jsx(ip,{value:S,onChange:z=>T(z),options:[{value:"cards",label:"Cards"},{value:"table",label:"Table"},{value:"kanban",label:"Kanban"}]})]}),D.length===0?s.length===0?r.jsxs("div",{className:"rounded-frame border border-border/60 bg-card px-6 py-16 text-center",children:[r.jsx("p",{className:"eyebrow mx-auto justify-center",children:"Start here"}),r.jsx("h2",{className:"mx-auto mt-4 max-w-2xl text-3xl font-semibold tracking-display text-foreground md:text-4xl",children:"The task manager built for agents, by agents"}),r.jsx("p",{className:"mx-auto mt-3 max-w-xl text-sm leading-6 text-muted-foreground",children:"A project groups assignments, resources, and memories under one objective. Markdown stays authoritative — the dashboard is just a view."}),r.jsxs("div",{className:"mt-6 flex flex-wrap justify-center gap-3",children:[r.jsx(Ee,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create your first project"}),r.jsx(Ee,{className:"shell-action",to:"/help",children:"Read the spec"})]})]}):r.jsx(Et,{title:"No projects match these filters",description:"Adjust the current search and filters or create a new project.",actions:r.jsx(Ee,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create Project"})}):S==="cards"?r.jsx("div",{className:"grid gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:D.map((z,G)=>r.jsxs(Ee,{to:`${t}/projects/${z.slug}`,className:"block rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm transition hover:border-primary/40 hover:shadow-md",...q(G),children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:z.title}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",zn(z.updated)]})]}),r.jsx(bn,{status:z.status})]}),r.jsxs("div",{className:"mt-4 space-y-3",children:[r.jsx(cf,{progress:z.progress,showLegend:!0}),r.jsx("div",{className:"flex flex-wrap gap-2",children:z.tags.map(L=>r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:L},L))}),r.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("p",{className:"text-muted-foreground",children:"Needs attention"}),r.jsx("p",{className:"mt-1 font-semibold text-foreground",children:z.needsAttention.blockedCount+z.needsAttention.failedCount})]}),r.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[r.jsx("p",{className:"text-muted-foreground",children:"Assignments"}),r.jsx("p",{className:"mt-1 font-semibold text-foreground",children:z.progress.total})]})]})]})]},z.slug))}):S==="table"?r.jsx(He,{title:`${D.length} project${D.length===1?"":"s"}`,children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[r.jsx("th",{className:"pb-3 font-medium",children:"Project"}),r.jsx("th",{className:"pb-3 font-medium",children:"Status"}),r.jsx("th",{className:"pb-3 font-medium",children:"Progress"}),r.jsx("th",{className:"pb-3 font-medium",children:"Attention"}),r.jsx("th",{className:"pb-3 font-medium",children:"Updated"})]})}),r.jsx("tbody",{children:D.map((z,G)=>r.jsxs("tr",{className:"border-b border-border/50 last:border-0",...q(G),children:[r.jsxs("td",{className:"py-4 pr-4",children:[r.jsx(Ee,{to:`${t}/projects/${z.slug}`,className:"font-semibold text-foreground hover:text-primary",children:z.title}),r.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:z.tags.map(L=>r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:L},L))})]}),r.jsx("td",{className:"py-4 pr-4",children:r.jsx(bn,{status:z.status})}),r.jsx("td",{className:"py-4 pr-4",children:r.jsx("div",{className:"min-w-[220px]",children:r.jsx(cf,{progress:z.progress})})}),r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:z.needsAttention.blockedCount+z.needsAttention.failedCount}),r.jsx("td",{className:"py-4 text-muted-foreground",children:zn(z.updated)})]},z.slug))})]})})}):r.jsx(tp,{columns:pM,items:K,getItemId:z=>z.slug,getColumnId:z=>z.status,canDrop:({fromColumnId:z,toColumnId:G})=>({allowed:!0,reason:z===G?void 0:"This will set a manual status override on the project."}),onMove:({item:z,fromColumnId:G,toColumnId:L,fromIndex:H,toIndex:re})=>{if(G===L){const U=P[G]??D.filter(ue=>ue.status===G).map(ue=>ue.slug);R(ue=>({...ue,[G]:cM(U,H,re)}));return}fetch(`/api/projects/${z.slug}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:L})}).then(()=>{window.location.reload()})},getExternalDragData:z=>({type:"project",id:z.slug}),onCardContextMenu:(z,G)=>{G.preventDefault(),$({project:z,anchor:{x:G.clientX,y:G.clientY}})},emptyMessage:z=>`No ${z.title.toLowerCase()} projects.`,renderCard:(z,{dragging:G})=>{const L=F.get(z.slug)??-1;return r.jsx("div",{...L>=0?q(L):{},children:r.jsx(gM,{project:z,dragging:G})})}}),r.jsx(iC,{anchor:(A==null?void 0:A.anchor)??null,items:A?[{key:"edit",label:"Edit",icon:zi,onSelect:()=>n(`${t}/projects/${A.project.slug}`)},{key:"move",label:"Move to workspace…",icon:jf,onSelect:()=>_(A.project)}]:[],onClose:()=>$(null)}),r.jsx(cy,{open:M!==null,onOpenChange:z=>{z||_(null)},currentWorkspace:(M==null?void 0:M.workspace)??null,title:"Move project to workspace",onSubmit:async z=>{if(!M)return;const G=await fetch(`/api/projects/${encodeURIComponent(M.slug)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:z})});if(!G.ok){const L=await G.json().catch(()=>({}));throw new Error(L.error||"Failed to move project")}c()}}),r.jsx("div",{className:"rounded-lg border border-border/60 bg-card/80 p-3 text-sm text-muted-foreground",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(ax,{className:"mt-0.5 h-4 w-4"}),r.jsxs("p",{children:["Project status is derived from assignment state by default.",S==="kanban"?" Drag projects between columns or use":" Use"," the status override on the project detail page to set a manual status."]})]})})]})}const fM={pending:"Pending",active:"Active",blocked:"Blocked",failed:"Failed",completed:"Completed"},pM=ly.map(e=>({id:e,title:fM[e],description:np(e)}));function mM(e,t,n){switch(n){case"created":return t.created.localeCompare(e.created);case"title":return e.title.localeCompare(t.title);case"attention":return Rj(t)-Rj(e);case"updated":default:return t.updated.localeCompare(e.updated)}}function Rj(e){return e.needsAttention.failedCount*10+e.needsAttention.blockedCount*5+e.needsAttention.openQuestions}function hM(e){return Object.fromEntries(ly.map(t=>[t,e.filter(n=>n.status===t).map(n=>n.slug)]))}function gM({project:e,dragging:t}){const n=fn();return r.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Ee,{to:`${n}/projects/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",zn(e.updated)]})]}),r.jsx(bn,{status:e.status})]}),r.jsx("div",{className:"mt-4",children:r.jsx(cf,{progress:e.progress})}),r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.tags.map(s=>r.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:s},s)),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.progress.total," assignments"]}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.needsAttention.blockedCount+e.needsAttention.failedCount," needs attention"]})]}),r.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:t?"Reordering within status":"Derived project lane"})]})}function uf({title:e,description:t,actions:n,className:s}){return r.jsxs("div",{className:we("flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",s),children:[r.jsxs("div",{className:"space-y-1",children:[e?r.jsx("h1",{className:"text-xl font-semibold tracking-tight text-foreground sm:text-2xl",children:e}):null,t?r.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:t}):null]}),n?r.jsx("div",{className:"flex flex-wrap items-center gap-3",children:n}):null]})}function xM(){return r.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-status-archived-foreground/30 bg-status-archived px-2 py-0.5 text-xs font-medium text-status-archived-foreground",children:[r.jsx(wf,{className:"h-3 w-3"}),"Archived"]})}function Aj(e){return e.projectSlug?`/projects/${e.projectSlug}/assignments/${e.slug}`:`/assignments/${e.id}`}function yM(){const{data:e,loading:t,error:n,refetch:s}=x3(),[o,i]=p.useState(null),[c,u]=p.useState(null),[d,m]=p.useState({}),{toast:h,showToast:g,dismissToast:y}=Ao();async function b(S,T,P){i(T),u(null);try{const R=await fetch(S,{method:"POST",headers:{"Content-Type":"application/json"}});if(!R.ok){const A=await R.json().catch(()=>null);throw new Error((A==null?void 0:A.error)||`HTTP ${R.status}`)}s(),g(P,"success")}catch(R){u(R instanceof Error?R.message:"Restore failed")}finally{i(null)}}function C(S){return b(`/api/projects/${S.slug}/unarchive`,`project:${S.slug}`,"Project restored")}function j(S){const T=S.projectSlug?`/api/projects/${S.projectSlug}/assignments/${S.slug}/unarchive`:`/api/assignments/${S.id}/unarchive`;return b(T,`assignment:${S.id}`,"Assignment restored")}if(t)return r.jsx(xt,{label:"Loading archived content…"});if(n)return r.jsx(Tt,{error:n});const v=(e==null?void 0:e.projects)??[],k=(e==null?void 0:e.assignments)??[],E=v.length===0&&k.length===0;return r.jsxs("div",{className:"space-y-6",children:[r.jsx(xa,{toast:h,onDismiss:y}),r.jsx(uf,{title:"Archive",description:"Archived projects and individually-archived assignments. Restoring a project also brings back its cascade-hidden assignments; assignments archived on their own stay archived until restored here."}),c?r.jsx("div",{className:"rounded border border-status-failed-foreground/30 bg-status-failed px-3 py-2 text-sm text-status-failed-foreground",children:c}):null,E?r.jsx(Et,{title:"Nothing archived",description:"Archived projects and assignments will appear here, ready to restore."}):r.jsxs(r.Fragment,{children:[v.length>0&&r.jsx(He,{title:"Archived Projects",description:"Restoring a project unhides every cascade-hidden assignment; individually-archived children stay archived.",children:r.jsx("ul",{className:"divide-y divide-border",children:v.map(S=>{const T=d[S.slug]??!1;return r.jsxs("li",{className:"py-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs("button",{type:"button",onClick:()=>m(P=>({...P,[S.slug]:!T})),className:"inline-flex items-center gap-1.5 text-left text-sm font-medium text-foreground hover:text-foreground/80","aria-expanded":T,children:[T?r.jsx(pr,{className:"h-4 w-4"}):r.jsx(Rk,{className:"h-4 w-4"}),r.jsx(sx,{className:"h-4 w-4 text-muted-foreground"}),S.title,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",S.assignments.length," assignment",S.assignments.length===1?"":"s",")"]})]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Archived ",S.archivedAt?Ur(S.archivedAt):"with no timestamp",S.archivedReason?` · ${S.archivedReason}`:""]}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[r.jsx(Ee,{to:`/projects/${S.slug}`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Open"}),r.jsxs("button",{type:"button",onClick:()=>C(S),disabled:o===`project:${S.slug}`,className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[r.jsx(Fd,{className:"h-3 w-3"}),"Restore"]})]})]}),T&&S.assignments.length>0&&r.jsx("ul",{className:"mt-2 space-y-1 pl-9",children:S.assignments.map(P=>r.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-sm",children:[r.jsx(Ee,{to:Aj(P),className:"text-foreground hover:text-foreground/80",children:P.title}),r.jsx(bn,{status:P.status,showIcon:!1}),r.jsx("span",{className:"text-xs text-muted-foreground",children:P.archived?"Archived individually — stays archived after restore":"Hidden via project — returns on restore"})]},P.id))})]},S.slug)})})}),k.length>0&&r.jsx(He,{title:"Archived Assignments",description:"Individually-archived assignments whose project is still active.",children:r.jsx("ul",{className:"divide-y divide-border",children:k.map(S=>r.jsxs("li",{className:"flex flex-wrap items-center gap-3 py-3",children:[r.jsx(Ee,{to:Aj(S),className:"text-sm font-medium text-foreground hover:text-foreground/80",children:S.title}),r.jsx(bn,{status:S.status,showIcon:!1}),r.jsx(xM,{}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.projectTitle??"Standalone"," · Archived"," ",S.archivedAt?Ur(S.archivedAt):"with no timestamp",S.archivedReason?` · ${S.archivedReason}`:""]}),r.jsxs("button",{type:"button",onClick:()=>j(S),disabled:o===`assignment:${S.id}`,className:"ml-auto inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground disabled:opacity-50",children:[r.jsx(Fd,{className:"h-3 w-3"}),"Restore"]})]},S.id))})})]})]})}const Pj="inline-flex max-w-[14rem] items-center gap-1 whitespace-nowrap rounded-full border px-2 py-0.5 text-[11px] font-semibold tracking-wide border-border/60 text-muted-foreground",Dj="block min-w-0 truncate";function uy({externalIds:e,className:t}){return e.length===0?null:r.jsx("span",{className:we("flex flex-wrap items-center gap-1.5",t),children:e.map((n,s)=>{const o=`${n.system}:${n.id}`,i=`${n.system}:${n.id}:${s}`;return n.url!=null&&n.url.length>0?r.jsxs("a",{href:n.url??void 0,target:"_blank",rel:"noopener noreferrer",className:we(Pj,"transition-colors hover:text-foreground hover:border-foreground/40"),title:`Open ${o} in ${n.system}`,children:[r.jsx("span",{className:Dj,children:o}),r.jsx(Mi,{className:"h-2.5 w-2.5 shrink-0"})]},i):r.jsx("span",{className:Pj,title:o,children:r.jsx("span",{className:Dj,children:o})},i)})})}const bM={default:"chrome-card",info:"rounded-lg border border-primary/30 bg-primary/5 p-3 dark:border-primary/40 dark:bg-primary/10",warn:"rounded-lg border border-warning-foreground/30 bg-warning p-3",danger:"rounded-lg border border-error-foreground/30 bg-error p-3",success:"rounded-lg border border-success-foreground/30 bg-success p-3"};function Fn({label:e,value:t,description:n,icon:s,tone:o="default",to:i}){const c=r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:e}),r.jsx("p",{className:"text-2xl font-semibold text-foreground",children:t})]}),s?r.jsx("span",{className:"rounded-md border border-border/60 bg-background/80 p-1.5 text-muted-foreground",children:r.jsx(s,{className:"h-5 w-5"})}):null]}),n?r.jsx("p",{className:"mt-2 text-sm leading-5 text-muted-foreground",children:n}):null]}),u=we(bM[o],i?"block transition hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40":"");return i?r.jsx(Ee,{to:i,className:u,children:c}):r.jsx("article",{className:u,children:c})}function $j(e){const t=vM(e),n=p.forwardRef((s,o)=>{const{children:i,...c}=s,u=p.Children.toArray(i),d=u.find(jM);if(d){const m=d.props.children,h=u.map(g=>g===d?p.Children.count(m)>1?p.Children.only(null):p.isValidElement(m)?m.props.children:null:g);return r.jsx(t,{...c,ref:o,children:p.isValidElement(m)?p.cloneElement(m,void 0,h):null})}return r.jsx(t,{...c,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function vM(e){const t=p.forwardRef((n,s)=>{const{children:o,...i}=n;if(p.isValidElement(o)){const c=SM(o),u=kM(i,o.props);return o.type!==p.Fragment&&(u.ref=s?Rf(s,c):c),p.cloneElement(o,u)}return p.Children.count(o)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var wM=Symbol("radix.slottable");function jM(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===wM}function kM(e,t){const n={...t};for(const s in t){const o=e[s],i=t[s];/^on[A-Z]/.test(s)?o&&i?n[s]=(...u)=>{const d=i(...u);return o(...u),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...i}:s==="className"&&(n[s]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function SM(e){var s,o;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function NM(e){const t=e+"CollectionProvider",[n,s]=pa(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),c=j=>{const{scope:v,children:k}=j,E=Dt.useRef(null),S=Dt.useRef(new Map).current;return r.jsx(o,{scope:v,itemMap:S,collectionRef:E,children:k})};c.displayName=t;const u=e+"CollectionSlot",d=$j(u),m=Dt.forwardRef((j,v)=>{const{scope:k,children:E}=j,S=i(u,k),T=qn(v,S.collectionRef);return r.jsx(d,{ref:T,children:E})});m.displayName=u;const h=e+"CollectionItemSlot",g="data-radix-collection-item",y=$j(h),b=Dt.forwardRef((j,v)=>{const{scope:k,children:E,...S}=j,T=Dt.useRef(null),P=qn(v,T),R=i(h,k);return Dt.useEffect(()=>(R.itemMap.set(T,{ref:T,...S}),()=>void R.itemMap.delete(T))),r.jsx(y,{[g]:"",ref:P,children:E})});b.displayName=h;function C(j){const v=i(e+"CollectionConsumer",j);return Dt.useCallback(()=>{const E=v.collectionRef.current;if(!E)return[];const S=Array.from(E.querySelectorAll(`[${g}]`));return Array.from(v.itemMap.values()).sort((R,A)=>S.indexOf(R.ref.current)-S.indexOf(A.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:c,Slot:m,ItemSlot:b},C,s]}var CM=p.createContext(void 0);function lC(e){const t=p.useContext(CM);return e||t||"ltr"}var Lh="rovingFocusGroup.onEntryFocus",EM={bubbles:!1,cancelable:!0},Hc="RovingFocusGroup",[Pg,cC,TM]=NM(Hc),[RM,uC]=pa(Hc,[TM]),[AM,PM]=RM(Hc),dC=p.forwardRef((e,t)=>r.jsx(Pg.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Pg.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(DM,{...e,ref:t})})}));dC.displayName=Hc;var DM=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:i,currentTabStopId:c,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:d,onEntryFocus:m,preventScrollOnEntryFocus:h=!1,...g}=e,y=p.useRef(null),b=qn(t,y),C=lC(i),[j,v]=Af({prop:c,defaultProp:u??null,onChange:d,caller:Hc}),[k,E]=p.useState(!1),S=ca(m),T=cC(n),P=p.useRef(!1),[R,A]=p.useState(0);return p.useEffect(()=>{const $=y.current;if($)return $.addEventListener(Lh,S),()=>$.removeEventListener(Lh,S)},[S]),r.jsx(AM,{scope:n,orientation:s,dir:C,loop:o,currentTabStopId:j,onItemFocus:p.useCallback($=>v($),[v]),onItemShiftTab:p.useCallback(()=>E(!0),[]),onFocusableItemAdd:p.useCallback(()=>A($=>$+1),[]),onFocusableItemRemove:p.useCallback(()=>A($=>$-1),[]),children:r.jsx(vn.div,{tabIndex:k||R===0?-1:0,"data-orientation":s,...g,ref:b,style:{outline:"none",...e.style},onMouseDown:Zt(e.onMouseDown,()=>{P.current=!0}),onFocus:Zt(e.onFocus,$=>{const M=!P.current;if($.target===$.currentTarget&&M&&!k){const _=new CustomEvent(Lh,EM);if($.currentTarget.dispatchEvent(_),!_.defaultPrevented){const D=T().filter(q=>q.focusable),V=D.find(q=>q.active),K=D.find(q=>q.id===j),F=[V,K,...D].filter(Boolean).map(q=>q.ref.current);mC(F,h)}}P.current=!1}),onBlur:Zt(e.onBlur,()=>E(!1))})})}),fC="RovingFocusGroupItem",pC=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:i,children:c,...u}=e,d=bi(),m=i||d,h=PM(fC,n),g=h.currentTabStopId===m,y=cC(n),{onFocusableItemAdd:b,onFocusableItemRemove:C,currentTabStopId:j}=h;return p.useEffect(()=>{if(s)return b(),()=>C()},[s,b,C]),r.jsx(Pg.ItemSlot,{scope:n,id:m,focusable:s,active:o,children:r.jsx(vn.span,{tabIndex:g?0:-1,"data-orientation":h.orientation,...u,ref:t,onMouseDown:Zt(e.onMouseDown,v=>{s?h.onItemFocus(m):v.preventDefault()}),onFocus:Zt(e.onFocus,()=>h.onItemFocus(m)),onKeyDown:Zt(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){h.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const k=OM(v,h.orientation,h.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let S=y().filter(T=>T.focusable).map(T=>T.ref.current);if(k==="last")S.reverse();else if(k==="prev"||k==="next"){k==="prev"&&S.reverse();const T=S.indexOf(v.currentTarget);S=h.loop?IM(S,T+1):S.slice(T+1)}setTimeout(()=>mC(S))}}),children:typeof c=="function"?c({isCurrentTabStop:g,hasTabStop:j!=null}):c})})});pC.displayName=fC;var $M={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function LM(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function OM(e,t,n){const s=LM(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return $M[s]}function mC(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function IM(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var _M=dC,MM=pC,lp="Tabs",[FM]=pa(lp,[uC]),hC=uC(),[zM,dy]=FM(lp),gC=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:i,orientation:c="horizontal",dir:u,activationMode:d="automatic",...m}=e,h=lC(u),[g,y]=Af({prop:s,onChange:o,defaultProp:i??"",caller:lp});return r.jsx(zM,{scope:n,baseId:bi(),value:g,onValueChange:y,orientation:c,dir:h,activationMode:d,children:r.jsx(vn.div,{dir:h,"data-orientation":c,...m,ref:t})})});gC.displayName=lp;var xC="TabsList",yC=p.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,i=dy(xC,n),c=hC(n);return r.jsx(_M,{asChild:!0,...c,orientation:i.orientation,dir:i.dir,loop:s,children:r.jsx(vn.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});yC.displayName=xC;var bC="TabsTrigger",vC=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...i}=e,c=dy(bC,n),u=hC(n),d=kC(c.baseId,s),m=SC(c.baseId,s),h=s===c.value;return r.jsx(MM,{asChild:!0,...u,focusable:!o,active:h,children:r.jsx(vn.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":m,"data-state":h?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...i,ref:t,onMouseDown:Zt(e.onMouseDown,g=>{!o&&g.button===0&&g.ctrlKey===!1?c.onValueChange(s):g.preventDefault()}),onKeyDown:Zt(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&c.onValueChange(s)}),onFocus:Zt(e.onFocus,()=>{const g=c.activationMode!=="manual";!h&&!o&&g&&c.onValueChange(s)})})})});vC.displayName=bC;var wC="TabsContent",jC=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:i,...c}=e,u=dy(wC,n),d=kC(u.baseId,s),m=SC(u.baseId,s),h=s===u.value,g=p.useRef(h);return p.useEffect(()=>{const y=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(y)},[]),r.jsx(ma,{present:o||h,children:({present:y})=>r.jsx(vn.div,{"data-state":h?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":d,hidden:!y,id:m,tabIndex:0,...c,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:y&&i})})});jC.displayName=wC;function kC(e,t){return`${e}-trigger-${t}`}function SC(e,t){return`${e}-content-${t}`}var NC=gC,CC=yC,Dg=vC,$g=jC;function fy({value:e,onValueChange:t,items:n,className:s}){return r.jsxs(NC,{value:e,onValueChange:t,className:s,children:[r.jsx(CC,{className:"scrollbar-none flex gap-2 overflow-x-auto rounded-md border border-border/70 bg-card/80 p-1",children:n.map(o=>r.jsxs(Dg,{value:o.value,className:we("inline-flex items-center gap-2 rounded-sm px-3 py-1.5 text-sm font-medium text-muted-foreground transition","data-[state=active]:bg-foreground data-[state=active]:text-background"),children:[r.jsx("span",{children:o.label}),typeof o.count=="number"?r.jsx("span",{className:"rounded-full bg-background/20 px-2 py-0.5 text-xs data-[state=active]:bg-background/20",children:o.count}):null]},o.value))}),n.map(o=>r.jsx($g,{value:o.value,className:"pt-3",children:o.content},o.value))]})}const BM="modulepreload",UM=function(e){return"/"+e},Lj={},VM=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let c=function(m){return Promise.all(m.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),d=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));o=c(n.map(m=>{if(m=UM(m),m in Lj)return;Lj[m]=!0;const h=m.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${g}`))return;const y=document.createElement("link");if(y.rel=h?"stylesheet":BM,h||(y.as="script"),y.crossOrigin="",y.href=m,d&&y.setAttribute("nonce",d),document.head.appendChild(y),h)return new Promise((b,C)=>{y.addEventListener("load",b),y.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${m}`)))})}))}function i(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return o.then(c=>{for(const u of c||[])u.status==="rejected"&&i(u.reason);return t().catch(i)})};function HM({definition:e,className:t,nodeRoutes:n={}}){const s=p.useRef(null),[o,i]=p.useState(null),[c,u]=p.useState(!0),d=zt(),m=document.documentElement.classList.contains("dark")?"dark":"default";return p.useEffect(()=>{let h=!1;async function g(){if(s.current)try{const y=(await VM(async()=>{const{default:j}=await import("./mermaid.core-D9FaILqM.js").then(v=>v.bF);return{default:j}},[])).default;if(y.initialize({startOnLoad:!1,theme:"base",themeVariables:WM(m==="dark")}),h)return;const b=`mermaid-${Date.now()}`,{svg:C}=await y.render(b,e);if(h||!s.current)return;s.current.innerHTML=C,KM(s.current,n,d),u(!1)}catch(y){h||(i(y instanceof Error?y.message:"Failed to render graph"),u(!1))}}return u(!0),i(null),g(),()=>{h=!0}},[e,d,n,m]),o?r.jsxs("div",{className:we("rounded-lg border border-border bg-card p-4",t),children:[r.jsxs("p",{className:"text-sm text-error-foreground",children:["Failed to render dependency graph: ",o]}),r.jsx("pre",{className:"mt-2 text-xs text-muted-foreground overflow-auto",children:e})]}):r.jsxs("div",{className:we("rounded-lg border border-border bg-card p-4",t),children:[c&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."}),r.jsx("div",{ref:s,className:"overflow-auto"})]})}function WM(e){const t=document.documentElement,n=g=>{const y=getComputedStyle(t).getPropertyValue(g).trim();return y?`oklch(${y})`:""},s=n("--card"),o=n("--card-foreground"),i=n("--border"),c=n("--primary"),u=n("--primary-foreground"),d=n("--muted"),m=n("--muted-foreground"),h=n("--secondary");return{background:s,primaryColor:s,primaryTextColor:o,primaryBorderColor:i,secondaryColor:d,secondaryTextColor:o,secondaryBorderColor:i,tertiaryColor:d,tertiaryTextColor:m,tertiaryBorderColor:i,lineColor:e?m:i,textColor:o,mainBkg:s,nodeBkg:s,nodeTextColor:o,nodeBorder:i,clusterBkg:d,clusterBorder:i,edgeLabelBackground:s,titleColor:o,activeTaskBkgColor:c,activeTaskBorderColor:c,altBackground:d,labelColor:o,errorBkgColor:h,errorTextColor:u}}function KM(e,t,n){var s;for(const o of e.querySelectorAll(".node")){const i=((s=o.textContent)==null?void 0:s.replace(/\s+/g," ").trim())??"",c=t[i];if(!c)continue;o.style.cursor="pointer",o.setAttribute("role","link"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`Open ${i}`);const u=()=>n(c);o.addEventListener("click",u),o.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),u())})}}function qM(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const GM=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,YM=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,QM={};function Oj(e,t){return(QM.jsx?YM:GM).test(e)}const JM=/[ \t\n\f\r]/g;function XM(e){return typeof e=="object"?e.type==="text"?Ij(e.value):!1:Ij(e)}function Ij(e){return e.replace(JM,"")===""}class Wc{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Wc.prototype.normal={};Wc.prototype.property={};Wc.prototype.space=void 0;function EC(e,t){const n={},s={};for(const o of e)Object.assign(n,o.property),Object.assign(s,o.normal);return new Wc(n,s,t)}function Lg(e){return e.toLowerCase()}class mr{constructor(t,n){this.attribute=n,this.property=t}}mr.prototype.attribute="";mr.prototype.booleanish=!1;mr.prototype.boolean=!1;mr.prototype.commaOrSpaceSeparated=!1;mr.prototype.commaSeparated=!1;mr.prototype.defined=!1;mr.prototype.mustUseProperty=!1;mr.prototype.number=!1;mr.prototype.overloadedBoolean=!1;mr.prototype.property="";mr.prototype.spaceSeparated=!1;mr.prototype.space=void 0;let ZM=0;const mt=ya(),gn=ya(),Og=ya(),Re=ya(),Vt=ya(),Ci=ya(),vr=ya();function ya(){return 2**++ZM}const Ig=Object.freeze(Object.defineProperty({__proto__:null,boolean:mt,booleanish:gn,commaOrSpaceSeparated:vr,commaSeparated:Ci,number:Re,overloadedBoolean:Og,spaceSeparated:Vt},Symbol.toStringTag,{value:"Module"})),Oh=Object.keys(Ig);class py extends mr{constructor(t,n,s,o){let i=-1;if(super(t,n),_j(this,"space",o),typeof s=="number")for(;++i<Oh.length;){const c=Oh[i];_j(this,Oh[i],(s&Ig[c])===Ig[c])}}}py.prototype.defined=!0;function _j(e,t,n){n&&(e[t]=n)}function Qi(e){const t={},n={};for(const[s,o]of Object.entries(e.properties)){const i=new py(s,e.transform(e.attributes||{},s),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(i.mustUseProperty=!0),t[s]=i,n[Lg(s)]=s,n[Lg(i.attribute)]=s}return new Wc(t,n,e.space)}const TC=Qi({properties:{ariaActiveDescendant:null,ariaAtomic:gn,ariaAutoComplete:null,ariaBusy:gn,ariaChecked:gn,ariaColCount:Re,ariaColIndex:Re,ariaColSpan:Re,ariaControls:Vt,ariaCurrent:null,ariaDescribedBy:Vt,ariaDetails:null,ariaDisabled:gn,ariaDropEffect:Vt,ariaErrorMessage:null,ariaExpanded:gn,ariaFlowTo:Vt,ariaGrabbed:gn,ariaHasPopup:null,ariaHidden:gn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Vt,ariaLevel:Re,ariaLive:null,ariaModal:gn,ariaMultiLine:gn,ariaMultiSelectable:gn,ariaOrientation:null,ariaOwns:Vt,ariaPlaceholder:null,ariaPosInSet:Re,ariaPressed:gn,ariaReadOnly:gn,ariaRelevant:null,ariaRequired:gn,ariaRoleDescription:Vt,ariaRowCount:Re,ariaRowIndex:Re,ariaRowSpan:Re,ariaSelected:gn,ariaSetSize:Re,ariaSort:null,ariaValueMax:Re,ariaValueMin:Re,ariaValueNow:Re,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function RC(e,t){return t in e?e[t]:t}function AC(e,t){return RC(e,t.toLowerCase())}const eF=Qi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ci,acceptCharset:Vt,accessKey:Vt,action:null,allow:null,allowFullScreen:mt,allowPaymentRequest:mt,allowUserMedia:mt,alt:null,as:null,async:mt,autoCapitalize:null,autoComplete:Vt,autoFocus:mt,autoPlay:mt,blocking:Vt,capture:null,charSet:null,checked:mt,cite:null,className:Vt,cols:Re,colSpan:null,content:null,contentEditable:gn,controls:mt,controlsList:Vt,coords:Re|Ci,crossOrigin:null,data:null,dateTime:null,decoding:null,default:mt,defer:mt,dir:null,dirName:null,disabled:mt,download:Og,draggable:gn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:mt,formTarget:null,headers:Vt,height:Re,hidden:Og,high:Re,href:null,hrefLang:null,htmlFor:Vt,httpEquiv:Vt,id:null,imageSizes:null,imageSrcSet:null,inert:mt,inputMode:null,integrity:null,is:null,isMap:mt,itemId:null,itemProp:Vt,itemRef:Vt,itemScope:mt,itemType:Vt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:mt,low:Re,manifest:null,max:null,maxLength:Re,media:null,method:null,min:null,minLength:Re,multiple:mt,muted:mt,name:null,nonce:null,noModule:mt,noValidate:mt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:mt,optimum:Re,pattern:null,ping:Vt,placeholder:null,playsInline:mt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:mt,referrerPolicy:null,rel:Vt,required:mt,reversed:mt,rows:Re,rowSpan:Re,sandbox:Vt,scope:null,scoped:mt,seamless:mt,selected:mt,shadowRootClonable:mt,shadowRootDelegatesFocus:mt,shadowRootMode:null,shape:null,size:Re,sizes:null,slot:null,span:Re,spellCheck:gn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Re,step:null,style:null,tabIndex:Re,target:null,title:null,translate:null,type:null,typeMustMatch:mt,useMap:null,value:gn,width:Re,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Vt,axis:null,background:null,bgColor:null,border:Re,borderColor:null,bottomMargin:Re,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:mt,declare:mt,event:null,face:null,frame:null,frameBorder:null,hSpace:Re,leftMargin:Re,link:null,longDesc:null,lowSrc:null,marginHeight:Re,marginWidth:Re,noResize:mt,noHref:mt,noShade:mt,noWrap:mt,object:null,profile:null,prompt:null,rev:null,rightMargin:Re,rules:null,scheme:null,scrolling:gn,standby:null,summary:null,text:null,topMargin:Re,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Re,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:mt,disableRemotePlayback:mt,prefix:null,property:null,results:Re,security:null,unselectable:null},space:"html",transform:AC}),tF=Qi({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:vr,accentHeight:Re,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Re,amplitude:Re,arabicForm:null,ascent:Re,attributeName:null,attributeType:null,azimuth:Re,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Re,by:null,calcMode:null,capHeight:Re,className:Vt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Re,diffuseConstant:Re,direction:null,display:null,dur:null,divisor:Re,dominantBaseline:null,download:mt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Re,enableBackground:null,end:null,event:null,exponent:Re,externalResourcesRequired:null,fill:null,fillOpacity:Re,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Ci,g2:Ci,glyphName:Ci,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Re,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Re,horizOriginX:Re,horizOriginY:Re,id:null,ideographic:Re,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Re,k:Re,k1:Re,k2:Re,k3:Re,k4:Re,kernelMatrix:vr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Re,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Re,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Re,overlineThickness:Re,paintOrder:null,panose1:null,path:null,pathLength:Re,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Vt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Re,pointsAtY:Re,pointsAtZ:Re,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:vr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:vr,rev:vr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:vr,requiredFeatures:vr,requiredFonts:vr,requiredFormats:vr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Re,specularExponent:Re,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Re,strikethroughThickness:Re,string:null,stroke:null,strokeDashArray:vr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Re,strokeOpacity:Re,strokeWidth:null,style:null,surfaceScale:Re,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:vr,tabIndex:Re,tableValues:null,target:null,targetX:Re,targetY:Re,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:vr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Re,underlineThickness:Re,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Re,values:null,vAlphabetic:Re,vMathematical:Re,vectorEffect:null,vHanging:Re,vIdeographic:Re,version:null,vertAdvY:Re,vertOriginX:Re,vertOriginY:Re,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Re,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:RC}),PC=Qi({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),DC=Qi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:AC}),$C=Qi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),nF={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},rF=/[A-Z]/g,Mj=/-[a-z]/g,sF=/^data[-\w.:]+$/i;function oF(e,t){const n=Lg(t);let s=t,o=mr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&sF.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(Mj,iF);s="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!Mj.test(i)){let c=i.replace(rF,aF);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}o=py}return new o(s,t)}function aF(e){return"-"+e.toLowerCase()}function iF(e){return e.charAt(1).toUpperCase()}const lF=EC([TC,eF,PC,DC,$C],"html"),my=EC([TC,tF,PC,DC,$C],"svg");function cF(e){return e.join(" ").trim()}var si={},Ih,Fj;function uF(){if(Fj)return Ih;Fj=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,u=/^\s+|\s+$/g,d=`
|
|
556
556
|
`,m="/",h="*",g="",y="comment",b="declaration";function C(v,k){if(typeof v!="string")throw new TypeError("First argument must be a string");if(!v)return[];k=k||{};var E=1,S=1;function T(I){var F=I.match(t);F&&(E+=F.length);var q=I.lastIndexOf(d);S=~q?I.length-q:S+I.length}function P(){var I={line:E,column:S};return function(F){return F.position=new R(I),M(),F}}function R(I){this.start=I,this.end={line:E,column:S},this.source=k.source}R.prototype.content=v;function A(I){var F=new Error(k.source+":"+E+":"+S+": "+I);if(F.reason=I,F.filename=k.source,F.line=E,F.column=S,F.source=v,!k.silent)throw F}function $(I){var F=I.exec(v);if(F){var q=F[0];return T(q),v=v.slice(q.length),F}}function M(){$(n)}function _(I){var F;for(I=I||[];F=D();)F!==!1&&I.push(F);return I}function D(){var I=P();if(!(m!=v.charAt(0)||h!=v.charAt(1))){for(var F=2;g!=v.charAt(F)&&(h!=v.charAt(F)||m!=v.charAt(F+1));)++F;if(F+=2,g===v.charAt(F-1))return A("End of comment missing");var q=v.slice(2,F-2);return S+=2,T(q),v=v.slice(F),S+=2,I({type:y,comment:q})}}function V(){var I=P(),F=$(s);if(F){if(D(),!$(o))return A("property missing ':'");var q=$(i),Z=I({type:b,property:j(F[0].replace(e,g)),value:q?j(q[0].replace(e,g)):g});return $(c),Z}}function K(){var I=[];_(I);for(var F;F=V();)F!==!1&&(I.push(F),_(I));return I}return M(),K()}function j(v){return v?v.replace(u,g):g}return Ih=C,Ih}var zj;function dF(){if(zj)return si;zj=1;var e=si&&si.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(si,"__esModule",{value:!0}),si.default=n;const t=e(uF());function n(s,o){let i=null;if(!s||typeof s!="string")return i;const c=(0,t.default)(s),u=typeof o=="function";return c.forEach(d=>{if(d.type!=="declaration")return;const{property:m,value:h}=d;u?o(m,h,d):h&&(i=i||{},i[m]=h)}),i}return si}var Fl={},Bj;function fF(){if(Bj)return Fl;Bj=1,Object.defineProperty(Fl,"__esModule",{value:!0}),Fl.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,i=function(m){return!m||n.test(m)||e.test(m)},c=function(m,h){return h.toUpperCase()},u=function(m,h){return"".concat(h,"-")},d=function(m,h){return h===void 0&&(h={}),i(m)?m:(m=m.toLowerCase(),h.reactCompat?m=m.replace(o,u):m=m.replace(s,u),m.replace(t,c))};return Fl.camelCase=d,Fl}var zl,Uj;function pF(){if(Uj)return zl;Uj=1;var e=zl&&zl.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},t=e(dF()),n=fF();function s(o,i){var c={};return!o||typeof o!="string"||(0,t.default)(o,function(u,d){u&&d&&(c[(0,n.camelCase)(u,i)]=d)}),c}return s.default=s,zl=s,zl}var mF=pF();const hF=xf(mF),LC=OC("end"),hy=OC("start");function OC(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function gF(e){const t=hy(e),n=LC(e);if(t&&n)return{start:t,end:n}}function ic(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Vj(e.position):"start"in e||"end"in e?Vj(e):"line"in e||"column"in e?_g(e):""}function _g(e){return Hj(e&&e.line)+":"+Hj(e&&e.column)}function Vj(e){return _g(e&&e.start)+"-"+_g(e&&e.end)}function Hj(e){return e&&typeof e=="number"?e:1}class Gn extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let o="",i={},c=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?o=t:!i.cause&&t&&(c=!0,o=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof s=="string"){const d=s.indexOf(":");d===-1?i.ruleId=s:(i.source=s.slice(0,d),i.ruleId=s.slice(d+1))}if(!i.place&&i.ancestors&&i.ancestors){const d=i.ancestors[i.ancestors.length-1];d&&(i.place=d.position)}const u=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=u?u.line:void 0,this.name=ic(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=c&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Gn.prototype.file="";Gn.prototype.name="";Gn.prototype.reason="";Gn.prototype.message="";Gn.prototype.stack="";Gn.prototype.column=void 0;Gn.prototype.line=void 0;Gn.prototype.ancestors=void 0;Gn.prototype.cause=void 0;Gn.prototype.fatal=void 0;Gn.prototype.place=void 0;Gn.prototype.ruleId=void 0;Gn.prototype.source=void 0;const gy={}.hasOwnProperty,xF=new Map,yF=/[A-Z]/g,bF=new Set(["table","tbody","thead","tfoot","tr"]),vF=new Set(["td","th"]),IC="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function wF(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=RF(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=TF(n,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?my:lF,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=_C(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function _C(e,t,n){if(t.type==="element")return jF(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return kF(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return NF(e,t,n);if(t.type==="mdxjsEsm")return SF(e,t);if(t.type==="root")return CF(e,t,n);if(t.type==="text")return EF(e,t)}function jF(e,t,n){const s=e.schema;let o=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(o=my,e.schema=o),e.ancestors.push(t);const i=FC(e,t.tagName,!1),c=AF(e,t);let u=yy(e,t);return bF.has(t.tagName)&&(u=u.filter(function(d){return typeof d=="string"?!XM(d):!0})),MC(e,c,i,t),xy(c,u),e.ancestors.pop(),e.schema=s,e.create(t,i,c,n)}function kF(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}kc(e,t.position)}function SF(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);kc(e,t.position)}function NF(e,t,n){const s=e.schema;let o=s;t.name==="svg"&&s.space==="html"&&(o=my,e.schema=o),e.ancestors.push(t);const i=t.name===null?e.Fragment:FC(e,t.name,!0),c=PF(e,t),u=yy(e,t);return MC(e,c,i,t),xy(c,u),e.ancestors.pop(),e.schema=s,e.create(t,i,c,n)}function CF(e,t,n){const s={};return xy(s,yy(e,t)),e.create(t,e.Fragment,s,n)}function EF(e,t){return t.value}function MC(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function xy(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function TF(e,t,n){return s;function s(o,i,c,u){const m=Array.isArray(c.children)?n:t;return u?m(i,c,u):m(i,c)}}function RF(e,t){return n;function n(s,o,i,c){const u=Array.isArray(i.children),d=hy(s);return t(o,i,c,u,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function AF(e,t){const n={};let s,o;for(o in t.properties)if(o!=="children"&&gy.call(t.properties,o)){const i=DF(e,o,t.properties[o]);if(i){const[c,u]=i;e.tableCellAlignToStyle&&c==="align"&&typeof u=="string"&&vF.has(t.tagName)?s=u:n[c]=u}}if(s){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function PF(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const i=s.data.estree.body[0];i.type;const c=i.expression;c.type;const u=c.properties[0];u.type,Object.assign(n,e.evaluater.evaluateExpression(u.argument))}else kc(e,t.position);else{const o=s.name;let i;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const u=s.value.data.estree.body[0];u.type,i=e.evaluater.evaluateExpression(u.expression)}else kc(e,t.position);else i=s.value===null?!0:s.value;n[o]=i}return n}function yy(e,t){const n=[];let s=-1;const o=e.passKeys?new Map:xF;for(;++s<t.children.length;){const i=t.children[s];let c;if(e.passKeys){const d=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(d){const m=o.get(d)||0;c=d+"-"+m,o.set(d,m+1)}}const u=_C(e,i,c);u!==void 0&&n.push(u)}return n}function DF(e,t,n){const s=oF(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?qM(n):cF(n)),s.property==="style"){let o=typeof n=="object"?n:$F(e,String(n));return e.stylePropertyNameCase==="css"&&(o=LF(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&s.space?nF[s.property]||s.property:s.attribute,n]}}function $F(e,t){try{return hF(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const s=n,o=new Gn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=IC+"#cannot-parse-style-attribute",o}}function FC(e,t,n){let s;if(!n)s={type:"Literal",value:t};else if(t.includes(".")){const o=t.split(".");let i=-1,c;for(;++i<o.length;){const u=Oj(o[i])?{type:"Identifier",name:o[i]}:{type:"Literal",value:o[i]};c=c?{type:"MemberExpression",object:c,property:u,computed:!!(i&&u.type==="Literal"),optional:!1}:u}s=c}else s=Oj(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const o=s.value;return gy.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(s);kc(e)}function kc(e,t){const n=new Gn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=IC+"#cannot-handle-mdx-estrees-without-createevaluater",n}function LF(e){const t={};let n;for(n in e)gy.call(e,n)&&(t[OF(n)]=e[n]);return t}function OF(e){let t=e.replace(yF,IF);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function IF(e){return"-"+e.toLowerCase()}const _h={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},_F={};function MF(e,t){const n=_F,s=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return zC(e,s,o)}function zC(e,t,n){if(FF(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Wj(e.children,t,n)}return Array.isArray(e)?Wj(e,t,n):""}function Wj(e,t,n){const s=[];let o=-1;for(;++o<e.length;)s[o]=zC(e[o],t,n);return s.join("")}function FF(e){return!!(e&&typeof e=="object")}const Kj=document.createElement("i");function by(e){const t="&"+e+";";Kj.innerHTML=t;const n=Kj.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Ns(e,t,n,s){const o=e.length;let i=0,c;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,s.length<1e4)c=Array.from(s),c.unshift(t,n),e.splice(...c);else for(n&&e.splice(t,n);i<s.length;)c=s.slice(i,i+1e4),c.unshift(t,0),e.splice(...c),i+=1e4,t+=1e4}function Fr(e,t){return e.length>0?(Ns(e,e.length,0,t),e):t}const qj={}.hasOwnProperty;function zF(e){const t={};let n=-1;for(;++n<e.length;)BF(t,e[n]);return t}function BF(e,t){let n;for(n in t){const o=(qj.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let c;if(i)for(c in i){qj.call(o,c)||(o[c]=[]);const u=i[c];UF(o[c],Array.isArray(u)?u:u?[u]:[])}}}function UF(e,t){let n=-1;const s=[];for(;++n<t.length;)(t[n].add==="after"?e:s).push(t[n]);Ns(e,0,0,s)}function BC(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ei(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const vs=Po(/[A-Za-z]/),Er=Po(/[\dA-Za-z]/),VF=Po(/[#-'*+\--9=?A-Z^-~]/);function Mg(e){return e!==null&&(e<32||e===127)}const Fg=Po(/\d/),HF=Po(/[\dA-Fa-f]/),WF=Po(/[!-/:-@[-`{-~]/);function lt(e){return e!==null&&e<-2}function fr(e){return e!==null&&(e<0||e===32)}function $t(e){return e===-2||e===-1||e===32}const KF=Po(new RegExp("\\p{P}|\\p{S}","u")),qF=Po(/\s/);function Po(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Ji(e){const t=[];let n=-1,s=0,o=0;for(;++n<e.length;){const i=e.charCodeAt(n);let c="";if(i===37&&Er(e.charCodeAt(n+1))&&Er(e.charCodeAt(n+2)))o=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(c=String.fromCharCode(i));else if(i>55295&&i<57344){const u=e.charCodeAt(n+1);i<56320&&u>56319&&u<57344?(c=String.fromCharCode(i,u),o=1):c="�"}else c=String.fromCharCode(i);c&&(t.push(e.slice(s,n),encodeURIComponent(c)),s=n+o+1,c=""),o&&(n+=o,o=0)}return t.join("")+e.slice(s)}function Ht(e,t,n,s){const o=s?s-1:Number.POSITIVE_INFINITY;let i=0;return c;function c(d){return $t(d)?(e.enter(n),u(d)):t(d)}function u(d){return $t(d)&&i++<o?(e.consume(d),u):(e.exit(n),t(d))}}const GF={tokenize:YF};function YF(e){const t=e.attempt(this.parser.constructs.contentInitial,s,o);let n;return t;function s(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),Ht(e,t,"linePrefix")}function o(u){return e.enter("paragraph"),i(u)}function i(u){const d=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,c(u)}function c(u){if(u===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(u);return}return lt(u)?(e.consume(u),e.exit("chunkText"),i):(e.consume(u),c)}}const QF={tokenize:JF},Gj={tokenize:XF};function JF(e){const t=this,n=[];let s=0,o,i,c;return u;function u(S){if(s<n.length){const T=n[s];return t.containerState=T[1],e.attempt(T[0].continuation,d,m)(S)}return m(S)}function d(S){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&E();const T=t.events.length;let P=T,R;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){R=t.events[P][1].end;break}k(s);let A=T;for(;A<t.events.length;)t.events[A][1].end={...R},A++;return Ns(t.events,P+1,0,t.events.slice(T)),t.events.length=A,m(S)}return u(S)}function m(S){if(s===n.length){if(!o)return y(S);if(o.currentConstruct&&o.currentConstruct.concrete)return C(S);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Gj,h,g)(S)}function h(S){return o&&E(),k(s),y(S)}function g(S){return t.parser.lazy[t.now().line]=s!==n.length,c=t.now().offset,C(S)}function y(S){return t.containerState={},e.attempt(Gj,b,C)(S)}function b(S){return s++,n.push([t.currentConstruct,t.containerState]),y(S)}function C(S){if(S===null){o&&E(),k(0),e.consume(S);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),j(S)}function j(S){if(S===null){v(e.exit("chunkFlow"),!0),k(0),e.consume(S);return}return lt(S)?(e.consume(S),v(e.exit("chunkFlow")),s=0,t.interrupt=void 0,u):(e.consume(S),j)}function v(S,T){const P=t.sliceStream(S);if(T&&P.push(null),S.previous=i,i&&(i.next=S),i=S,o.defineSkip(S.start),o.write(P),t.parser.lazy[S.start.line]){let R=o.events.length;for(;R--;)if(o.events[R][1].start.offset<c&&(!o.events[R][1].end||o.events[R][1].end.offset>c))return;const A=t.events.length;let $=A,M,_;for(;$--;)if(t.events[$][0]==="exit"&&t.events[$][1].type==="chunkFlow"){if(M){_=t.events[$][1].end;break}M=!0}for(k(s),R=A;R<t.events.length;)t.events[R][1].end={..._},R++;Ns(t.events,$+1,0,t.events.slice(A)),t.events.length=R}}function k(S){let T=n.length;for(;T-- >S;){const P=n[T];t.containerState=P[1],P[0].exit.call(t,e)}n.length=S}function E(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function XF(e,t,n){return Ht(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Yj(e){if(e===null||fr(e)||qF(e))return 1;if(KF(e))return 2}function vy(e,t,n){const s=[];let o=-1;for(;++o<e.length;){const i=e[o].resolveAll;i&&!s.includes(i)&&(t=i(t,n),s.push(i))}return t}const zg={name:"attention",resolveAll:ZF,tokenize:e6};function ZF(e,t){let n=-1,s,o,i,c,u,d,m,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(s=n;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[s][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;d=e[s][1].end.offset-e[s][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const g={...e[s][1].end},y={...e[n][1].start};Qj(g,-d),Qj(y,d),c={type:d>1?"strongSequence":"emphasisSequence",start:g,end:{...e[s][1].end}},u={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:y},i={type:d>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},o={type:d>1?"strong":"emphasis",start:{...c.start},end:{...u.end}},e[s][1].end={...c.start},e[n][1].start={...u.end},m=[],e[s][1].end.offset-e[s][1].start.offset&&(m=Fr(m,[["enter",e[s][1],t],["exit",e[s][1],t]])),m=Fr(m,[["enter",o,t],["enter",c,t],["exit",c,t],["enter",i,t]]),m=Fr(m,vy(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),m=Fr(m,[["exit",i,t],["enter",u,t],["exit",u,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,m=Fr(m,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,Ns(e,s-1,n-s+3,m),n=s+m.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function e6(e,t){const n=this.parser.constructs.attentionMarkers.null,s=this.previous,o=Yj(s);let i;return c;function c(d){return i=d,e.enter("attentionSequence"),u(d)}function u(d){if(d===i)return e.consume(d),u;const m=e.exit("attentionSequence"),h=Yj(d),g=!h||h===2&&o||n.includes(d),y=!o||o===2&&h||n.includes(s);return m._open=!!(i===42?g:g&&(o||!y)),m._close=!!(i===42?y:y&&(h||!g)),t(d)}}function Qj(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const t6={name:"autolink",tokenize:n6};function n6(e,t,n){let s=0;return o;function o(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(b){return vs(b)?(e.consume(b),c):b===64?n(b):m(b)}function c(b){return b===43||b===45||b===46||Er(b)?(s=1,u(b)):m(b)}function u(b){return b===58?(e.consume(b),s=0,d):(b===43||b===45||b===46||Er(b))&&s++<32?(e.consume(b),u):(s=0,m(b))}function d(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):b===null||b===32||b===60||Mg(b)?n(b):(e.consume(b),d)}function m(b){return b===64?(e.consume(b),h):VF(b)?(e.consume(b),m):n(b)}function h(b){return Er(b)?g(b):n(b)}function g(b){return b===46?(e.consume(b),s=0,h):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):y(b)}function y(b){if((b===45||Er(b))&&s++<63){const C=b===45?y:g;return e.consume(b),C}return n(b)}}const cp={partial:!0,tokenize:r6};function r6(e,t,n){return s;function s(i){return $t(i)?Ht(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||lt(i)?t(i):n(i)}}const UC={continuation:{tokenize:o6},exit:a6,name:"blockQuote",tokenize:s6};function s6(e,t,n){const s=this;return o;function o(c){if(c===62){const u=s.containerState;return u.open||(e.enter("blockQuote",{_container:!0}),u.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),i}return n(c)}function i(c){return $t(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function o6(e,t,n){const s=this;return o;function o(c){return $t(c)?Ht(e,i,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):i(c)}function i(c){return e.attempt(UC,t,n)(c)}}function a6(e){e.exit("blockQuote")}const VC={name:"characterEscape",tokenize:i6};function i6(e,t,n){return s;function s(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return WF(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const HC={name:"characterReference",tokenize:l6};function l6(e,t,n){const s=this;let o=0,i,c;return u;function u(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),d}function d(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),m):(e.enter("characterReferenceValue"),i=31,c=Er,h(g))}function m(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,c=HF,h):(e.enter("characterReferenceValue"),i=7,c=Fg,h(g))}function h(g){if(g===59&&o){const y=e.exit("characterReferenceValue");return c===Er&&!by(s.sliceSerialize(y))?n(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(g)&&o++<i?(e.consume(g),h):n(g)}}const Jj={partial:!0,tokenize:u6},Xj={concrete:!0,name:"codeFenced",tokenize:c6};function c6(e,t,n){const s=this,o={partial:!0,tokenize:P};let i=0,c=0,u;return d;function d(R){return m(R)}function m(R){const A=s.events[s.events.length-1];return i=A&&A[1].type==="linePrefix"?A[2].sliceSerialize(A[1],!0).length:0,u=R,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(R)}function h(R){return R===u?(c++,e.consume(R),h):c<3?n(R):(e.exit("codeFencedFenceSequence"),$t(R)?Ht(e,g,"whitespace")(R):g(R))}function g(R){return R===null||lt(R)?(e.exit("codeFencedFence"),s.interrupt?t(R):e.check(Jj,j,T)(R)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),y(R))}function y(R){return R===null||lt(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(R)):$t(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ht(e,b,"whitespace")(R)):R===96&&R===u?n(R):(e.consume(R),y)}function b(R){return R===null||lt(R)?g(R):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),C(R))}function C(R){return R===null||lt(R)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(R)):R===96&&R===u?n(R):(e.consume(R),C)}function j(R){return e.attempt(o,T,v)(R)}function v(R){return e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),k}function k(R){return i>0&&$t(R)?Ht(e,E,"linePrefix",i+1)(R):E(R)}function E(R){return R===null||lt(R)?e.check(Jj,j,T)(R):(e.enter("codeFlowValue"),S(R))}function S(R){return R===null||lt(R)?(e.exit("codeFlowValue"),E(R)):(e.consume(R),S)}function T(R){return e.exit("codeFenced"),t(R)}function P(R,A,$){let M=0;return _;function _(F){return R.enter("lineEnding"),R.consume(F),R.exit("lineEnding"),D}function D(F){return R.enter("codeFencedFence"),$t(F)?Ht(R,V,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):V(F)}function V(F){return F===u?(R.enter("codeFencedFenceSequence"),K(F)):$(F)}function K(F){return F===u?(M++,R.consume(F),K):M>=c?(R.exit("codeFencedFenceSequence"),$t(F)?Ht(R,I,"whitespace")(F):I(F)):$(F)}function I(F){return F===null||lt(F)?(R.exit("codeFencedFence"),A(F)):$(F)}}}function u6(e,t,n){const s=this;return o;function o(c){return c===null?n(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),i)}function i(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}const Mh={name:"codeIndented",tokenize:f6},d6={partial:!0,tokenize:p6};function f6(e,t,n){const s=this;return o;function o(m){return e.enter("codeIndented"),Ht(e,i,"linePrefix",5)(m)}function i(m){const h=s.events[s.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?c(m):n(m)}function c(m){return m===null?d(m):lt(m)?e.attempt(d6,c,d)(m):(e.enter("codeFlowValue"),u(m))}function u(m){return m===null||lt(m)?(e.exit("codeFlowValue"),c(m)):(e.consume(m),u)}function d(m){return e.exit("codeIndented"),t(m)}}function p6(e,t,n){const s=this;return o;function o(c){return s.parser.lazy[s.now().line]?n(c):lt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):Ht(e,i,"linePrefix",5)(c)}function i(c){const u=s.events[s.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):lt(c)?o(c):n(c)}}const m6={name:"codeText",previous:g6,resolve:h6,tokenize:x6};function h6(e){let t=e.length-4,n=3,s,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s<t;)if(e[s][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(s=n-1,t++;++s<=t;)o===void 0?s!==t&&e[s][1].type!=="lineEnding"&&(o=s):(s===t||e[s][1].type==="lineEnding")&&(e[o][1].type="codeTextData",s!==o+2&&(e[o][1].end=e[s-1][1].end,e.splice(o+2,s-o-2),t-=s-o-2,s=o+2),o=void 0);return e}function g6(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function x6(e,t,n){let s=0,o,i;return c;function c(g){return e.enter("codeText"),e.enter("codeTextSequence"),u(g)}function u(g){return g===96?(e.consume(g),s++,u):(e.exit("codeTextSequence"),d(g))}function d(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),d):g===96?(i=e.enter("codeTextSequence"),o=0,h(g)):lt(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),d):(e.enter("codeTextData"),m(g))}function m(g){return g===null||g===32||g===96||lt(g)?(e.exit("codeTextData"),d(g)):(e.consume(g),m)}function h(g){return g===96?(e.consume(g),o++,h):o===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(i.type="codeTextData",m(g))}}class y6{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const s=n??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(t,s):t>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const o=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return s&&Bl(this.left,s),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Bl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Bl(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Bl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Bl(this.left,n.reverse())}}}function Bl(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function WC(e){const t={};let n=-1,s,o,i,c,u,d,m;const h=new y6(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(s=h.get(n),n&&s[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(d=s[1]._tokenizer.events,i=0,i<d.length&&d[i][1].type==="lineEndingBlank"&&(i+=2),i<d.length&&d[i][1].type==="content"))for(;++i<d.length&&d[i][1].type!=="content";)d[i][1].type==="chunkText"&&(d[i][1]._isInFirstContentOfListItem=!0,i++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,b6(h,n)),n=t[n],m=!0);else if(s[1]._container){for(i=n,o=void 0;i--;)if(c=h.get(i),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(o&&(h.get(o)[1].type="lineEndingBlank"),c[1].type="lineEnding",o=i);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;o&&(s[1].end={...h.get(o)[1].start},u=h.slice(o,n),u.unshift(s),h.splice(o,n-o+1,u))}}return Ns(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!m}function b6(e,t){const n=e.get(t)[1],s=e.get(t)[2];let o=t-1;const i=[];let c=n._tokenizer;c||(c=s.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const u=c.events,d=[],m={};let h,g,y=-1,b=n,C=0,j=0;const v=[j];for(;b;){for(;e.get(++o)[1]!==b;);i.push(o),b._tokenizer||(h=s.sliceStream(b),b.next||h.push(null),g&&c.defineSkip(b.start),b._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(h),b._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),g=b,b=b.next}for(b=n;++y<u.length;)u[y][0]==="exit"&&u[y-1][0]==="enter"&&u[y][1].type===u[y-1][1].type&&u[y][1].start.line!==u[y][1].end.line&&(j=y+1,v.push(j),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(c.events=[],b?(b._tokenizer=void 0,b.previous=void 0):v.pop(),y=v.length;y--;){const k=u.slice(v[y],v[y+1]),E=i.pop();d.push([E,E+k.length-1]),e.splice(E,2,k)}for(d.reverse(),y=-1;++y<d.length;)m[C+d[y][0]]=C+d[y][1],C+=d[y][1]-d[y][0]-1;return m}const v6={resolve:j6,tokenize:k6},w6={partial:!0,tokenize:S6};function j6(e){return WC(e),e}function k6(e,t){let n;return s;function s(u){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(u)}function o(u){return u===null?i(u):lt(u)?e.check(w6,c,i)(u):(e.consume(u),o)}function i(u){return e.exit("chunkContent"),e.exit("content"),t(u)}function c(u){return e.consume(u),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function S6(e,t,n){const s=this;return o;function o(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Ht(e,i,"linePrefix")}function i(c){if(c===null||lt(c))return n(c);const u=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?t(c):e.interrupt(s.parser.constructs.flow,n,t)(c)}}function KC(e,t,n,s,o,i,c,u,d){const m=d||Number.POSITIVE_INFINITY;let h=0;return g;function g(k){return k===60?(e.enter(s),e.enter(o),e.enter(i),e.consume(k),e.exit(i),y):k===null||k===32||k===41||Mg(k)?n(k):(e.enter(s),e.enter(c),e.enter(u),e.enter("chunkString",{contentType:"string"}),j(k))}function y(k){return k===62?(e.enter(i),e.consume(k),e.exit(i),e.exit(o),e.exit(s),t):(e.enter(u),e.enter("chunkString",{contentType:"string"}),b(k))}function b(k){return k===62?(e.exit("chunkString"),e.exit(u),y(k)):k===null||k===60||lt(k)?n(k):(e.consume(k),k===92?C:b)}function C(k){return k===60||k===62||k===92?(e.consume(k),b):b(k)}function j(k){return!h&&(k===null||k===41||fr(k))?(e.exit("chunkString"),e.exit(u),e.exit(c),e.exit(s),t(k)):h<m&&k===40?(e.consume(k),h++,j):k===41?(e.consume(k),h--,j):k===null||k===32||k===40||Mg(k)?n(k):(e.consume(k),k===92?v:j)}function v(k){return k===40||k===41||k===92?(e.consume(k),j):j(k)}}function qC(e,t,n,s,o,i){const c=this;let u=0,d;return m;function m(b){return e.enter(s),e.enter(o),e.consume(b),e.exit(o),e.enter(i),h}function h(b){return u>999||b===null||b===91||b===93&&!d||b===94&&!u&&"_hiddenFootnoteSupport"in c.parser.constructs?n(b):b===93?(e.exit(i),e.enter(o),e.consume(b),e.exit(o),e.exit(s),t):lt(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),g(b))}function g(b){return b===null||b===91||b===93||lt(b)||u++>999?(e.exit("chunkString"),h(b)):(e.consume(b),d||(d=!$t(b)),b===92?y:g)}function y(b){return b===91||b===92||b===93?(e.consume(b),u++,g):g(b)}}function GC(e,t,n,s,o,i){let c;return u;function u(y){return y===34||y===39||y===40?(e.enter(s),e.enter(o),e.consume(y),e.exit(o),c=y===40?41:y,d):n(y)}function d(y){return y===c?(e.enter(o),e.consume(y),e.exit(o),e.exit(s),t):(e.enter(i),m(y))}function m(y){return y===c?(e.exit(i),d(c)):y===null?n(y):lt(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),Ht(e,m,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===c||y===null||lt(y)?(e.exit("chunkString"),m(y)):(e.consume(y),y===92?g:h)}function g(y){return y===c||y===92?(e.consume(y),h):h(y)}}function lc(e,t){let n;return s;function s(o){return lt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,s):$t(o)?Ht(e,s,n?"linePrefix":"lineSuffix")(o):t(o)}}const N6={name:"definition",tokenize:E6},C6={partial:!0,tokenize:T6};function E6(e,t,n){const s=this;let o;return i;function i(b){return e.enter("definition"),c(b)}function c(b){return qC.call(s,e,u,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function u(b){return o=Ei(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),d):n(b)}function d(b){return fr(b)?lc(e,m)(b):m(b)}function m(b){return KC(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function h(b){return e.attempt(C6,g,g)(b)}function g(b){return $t(b)?Ht(e,y,"whitespace")(b):y(b)}function y(b){return b===null||lt(b)?(e.exit("definition"),s.parser.defined.push(o),t(b)):n(b)}}function T6(e,t,n){return s;function s(u){return fr(u)?lc(e,o)(u):n(u)}function o(u){return GC(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function i(u){return $t(u)?Ht(e,c,"whitespace")(u):c(u)}function c(u){return u===null||lt(u)?t(u):n(u)}}const R6={name:"hardBreakEscape",tokenize:A6};function A6(e,t,n){return s;function s(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return lt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const P6={name:"headingAtx",resolve:D6,tokenize:$6};function D6(e,t){let n=e.length-2,s=3,o,i;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(o={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},i={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},Ns(e,s,n-s+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function $6(e,t,n){let s=0;return o;function o(h){return e.enter("atxHeading"),i(h)}function i(h){return e.enter("atxHeadingSequence"),c(h)}function c(h){return h===35&&s++<6?(e.consume(h),c):h===null||fr(h)?(e.exit("atxHeadingSequence"),u(h)):n(h)}function u(h){return h===35?(e.enter("atxHeadingSequence"),d(h)):h===null||lt(h)?(e.exit("atxHeading"),t(h)):$t(h)?Ht(e,u,"whitespace")(h):(e.enter("atxHeadingText"),m(h))}function d(h){return h===35?(e.consume(h),d):(e.exit("atxHeadingSequence"),u(h))}function m(h){return h===null||h===35||fr(h)?(e.exit("atxHeadingText"),u(h)):(e.consume(h),m)}}const L6=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Zj=["pre","script","style","textarea"],O6={concrete:!0,name:"htmlFlow",resolveTo:M6,tokenize:F6},I6={partial:!0,tokenize:B6},_6={partial:!0,tokenize:z6};function M6(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function F6(e,t,n){const s=this;let o,i,c,u,d;return m;function m(U){return h(U)}function h(U){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(U),g}function g(U){return U===33?(e.consume(U),y):U===47?(e.consume(U),i=!0,j):U===63?(e.consume(U),o=3,s.interrupt?t:L):vs(U)?(e.consume(U),c=String.fromCharCode(U),v):n(U)}function y(U){return U===45?(e.consume(U),o=2,b):U===91?(e.consume(U),o=5,u=0,C):vs(U)?(e.consume(U),o=4,s.interrupt?t:L):n(U)}function b(U){return U===45?(e.consume(U),s.interrupt?t:L):n(U)}function C(U){const ue="CDATA[";return U===ue.charCodeAt(u++)?(e.consume(U),u===ue.length?s.interrupt?t:V:C):n(U)}function j(U){return vs(U)?(e.consume(U),c=String.fromCharCode(U),v):n(U)}function v(U){if(U===null||U===47||U===62||fr(U)){const ue=U===47,ge=c.toLowerCase();return!ue&&!i&&Zj.includes(ge)?(o=1,s.interrupt?t(U):V(U)):L6.includes(c.toLowerCase())?(o=6,ue?(e.consume(U),k):s.interrupt?t(U):V(U)):(o=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(U):i?E(U):S(U))}return U===45||Er(U)?(e.consume(U),c+=String.fromCharCode(U),v):n(U)}function k(U){return U===62?(e.consume(U),s.interrupt?t:V):n(U)}function E(U){return $t(U)?(e.consume(U),E):_(U)}function S(U){return U===47?(e.consume(U),_):U===58||U===95||vs(U)?(e.consume(U),T):$t(U)?(e.consume(U),S):_(U)}function T(U){return U===45||U===46||U===58||U===95||Er(U)?(e.consume(U),T):P(U)}function P(U){return U===61?(e.consume(U),R):$t(U)?(e.consume(U),P):S(U)}function R(U){return U===null||U===60||U===61||U===62||U===96?n(U):U===34||U===39?(e.consume(U),d=U,A):$t(U)?(e.consume(U),R):$(U)}function A(U){return U===d?(e.consume(U),d=null,M):U===null||lt(U)?n(U):(e.consume(U),A)}function $(U){return U===null||U===34||U===39||U===47||U===60||U===61||U===62||U===96||fr(U)?P(U):(e.consume(U),$)}function M(U){return U===47||U===62||$t(U)?S(U):n(U)}function _(U){return U===62?(e.consume(U),D):n(U)}function D(U){return U===null||lt(U)?V(U):$t(U)?(e.consume(U),D):n(U)}function V(U){return U===45&&o===2?(e.consume(U),q):U===60&&o===1?(e.consume(U),Z):U===62&&o===4?(e.consume(U),H):U===63&&o===3?(e.consume(U),L):U===93&&o===5?(e.consume(U),G):lt(U)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(I6,re,K)(U)):U===null||lt(U)?(e.exit("htmlFlowData"),K(U)):(e.consume(U),V)}function K(U){return e.check(_6,I,re)(U)}function I(U){return e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),F}function F(U){return U===null||lt(U)?K(U):(e.enter("htmlFlowData"),V(U))}function q(U){return U===45?(e.consume(U),L):V(U)}function Z(U){return U===47?(e.consume(U),c="",z):V(U)}function z(U){if(U===62){const ue=c.toLowerCase();return Zj.includes(ue)?(e.consume(U),H):V(U)}return vs(U)&&c.length<8?(e.consume(U),c+=String.fromCharCode(U),z):V(U)}function G(U){return U===93?(e.consume(U),L):V(U)}function L(U){return U===62?(e.consume(U),H):U===45&&o===2?(e.consume(U),L):V(U)}function H(U){return U===null||lt(U)?(e.exit("htmlFlowData"),re(U)):(e.consume(U),H)}function re(U){return e.exit("htmlFlow"),t(U)}}function z6(e,t,n){const s=this;return o;function o(c){return lt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),i):n(c)}function i(c){return s.parser.lazy[s.now().line]?n(c):t(c)}}function B6(e,t,n){return s;function s(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(cp,t,n)}}const U6={name:"htmlText",tokenize:V6};function V6(e,t,n){const s=this;let o,i,c;return u;function u(L){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(L),d}function d(L){return L===33?(e.consume(L),m):L===47?(e.consume(L),P):L===63?(e.consume(L),S):vs(L)?(e.consume(L),$):n(L)}function m(L){return L===45?(e.consume(L),h):L===91?(e.consume(L),i=0,C):vs(L)?(e.consume(L),E):n(L)}function h(L){return L===45?(e.consume(L),b):n(L)}function g(L){return L===null?n(L):L===45?(e.consume(L),y):lt(L)?(c=g,Z(L)):(e.consume(L),g)}function y(L){return L===45?(e.consume(L),b):g(L)}function b(L){return L===62?q(L):L===45?y(L):g(L)}function C(L){const H="CDATA[";return L===H.charCodeAt(i++)?(e.consume(L),i===H.length?j:C):n(L)}function j(L){return L===null?n(L):L===93?(e.consume(L),v):lt(L)?(c=j,Z(L)):(e.consume(L),j)}function v(L){return L===93?(e.consume(L),k):j(L)}function k(L){return L===62?q(L):L===93?(e.consume(L),k):j(L)}function E(L){return L===null||L===62?q(L):lt(L)?(c=E,Z(L)):(e.consume(L),E)}function S(L){return L===null?n(L):L===63?(e.consume(L),T):lt(L)?(c=S,Z(L)):(e.consume(L),S)}function T(L){return L===62?q(L):S(L)}function P(L){return vs(L)?(e.consume(L),R):n(L)}function R(L){return L===45||Er(L)?(e.consume(L),R):A(L)}function A(L){return lt(L)?(c=A,Z(L)):$t(L)?(e.consume(L),A):q(L)}function $(L){return L===45||Er(L)?(e.consume(L),$):L===47||L===62||fr(L)?M(L):n(L)}function M(L){return L===47?(e.consume(L),q):L===58||L===95||vs(L)?(e.consume(L),_):lt(L)?(c=M,Z(L)):$t(L)?(e.consume(L),M):q(L)}function _(L){return L===45||L===46||L===58||L===95||Er(L)?(e.consume(L),_):D(L)}function D(L){return L===61?(e.consume(L),V):lt(L)?(c=D,Z(L)):$t(L)?(e.consume(L),D):M(L)}function V(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),o=L,K):lt(L)?(c=V,Z(L)):$t(L)?(e.consume(L),V):(e.consume(L),I)}function K(L){return L===o?(e.consume(L),o=void 0,F):L===null?n(L):lt(L)?(c=K,Z(L)):(e.consume(L),K)}function I(L){return L===null||L===34||L===39||L===60||L===61||L===96?n(L):L===47||L===62||fr(L)?M(L):(e.consume(L),I)}function F(L){return L===47||L===62||fr(L)?M(L):n(L)}function q(L){return L===62?(e.consume(L),e.exit("htmlTextData"),e.exit("htmlText"),t):n(L)}function Z(L){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),z}function z(L){return $t(L)?Ht(e,G,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):G(L)}function G(L){return e.enter("htmlTextData"),c(L)}}const wy={name:"labelEnd",resolveAll:q6,resolveTo:G6,tokenize:Y6},H6={tokenize:Q6},W6={tokenize:J6},K6={tokenize:X6};function q6(e){let t=-1;const n=[];for(;++t<e.length;){const s=e[t][1];if(n.push(e[t]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const o=s.type==="labelImage"?4:2;s.type="data",t+=o}}return e.length!==n.length&&Ns(e,0,e.length,n),e}function G6(e,t){let n=e.length,s=0,o,i,c,u;for(;n--;)if(o=e[n][1],i){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(c){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(i=n,o.type!=="labelLink")){s=2;break}}else o.type==="labelEnd"&&(c=n);const d={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},m={type:"label",start:{...e[i][1].start},end:{...e[c][1].end}},h={type:"labelText",start:{...e[i+s+2][1].end},end:{...e[c-2][1].start}};return u=[["enter",d,t],["enter",m,t]],u=Fr(u,e.slice(i+1,i+s+3)),u=Fr(u,[["enter",h,t]]),u=Fr(u,vy(t.parser.constructs.insideSpan.null,e.slice(i+s+4,c-3),t)),u=Fr(u,[["exit",h,t],e[c-2],e[c-1],["exit",m,t]]),u=Fr(u,e.slice(c+1)),u=Fr(u,[["exit",d,t]]),Ns(e,i,e.length,u),e}function Y6(e,t,n){const s=this;let o=s.events.length,i,c;for(;o--;)if((s.events[o][1].type==="labelImage"||s.events[o][1].type==="labelLink")&&!s.events[o][1]._balanced){i=s.events[o][1];break}return u;function u(y){return i?i._inactive?g(y):(c=s.parser.defined.includes(Ei(s.sliceSerialize({start:i.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(y),e.exit("labelMarker"),e.exit("labelEnd"),d):n(y)}function d(y){return y===40?e.attempt(H6,h,c?h:g)(y):y===91?e.attempt(W6,h,c?m:g)(y):c?h(y):g(y)}function m(y){return e.attempt(K6,h,g)(y)}function h(y){return t(y)}function g(y){return i._balanced=!0,n(y)}}function Q6(e,t,n){return s;function s(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),o}function o(g){return fr(g)?lc(e,i)(g):i(g)}function i(g){return g===41?h(g):KC(e,c,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function c(g){return fr(g)?lc(e,d)(g):h(g)}function u(g){return n(g)}function d(g){return g===34||g===39||g===40?GC(e,m,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):h(g)}function m(g){return fr(g)?lc(e,h)(g):h(g)}function h(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),t):n(g)}}function J6(e,t,n){const s=this;return o;function o(u){return qC.call(s,e,i,c,"reference","referenceMarker","referenceString")(u)}function i(u){return s.parser.defined.includes(Ei(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(u):n(u)}function c(u){return n(u)}}function X6(e,t,n){return s;function s(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),o}function o(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const Z6={name:"labelStartImage",resolveAll:wy.resolveAll,tokenize:ez};function ez(e,t,n){const s=this;return o;function o(u){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(u),e.exit("labelImageMarker"),i}function i(u){return u===91?(e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelImage"),c):n(u)}function c(u){return u===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(u):t(u)}}const tz={name:"labelStartLink",resolveAll:wy.resolveAll,tokenize:nz};function nz(e,t,n){const s=this;return o;function o(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),i}function i(c){return c===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(c):t(c)}}const Fh={name:"lineEnding",tokenize:rz};function rz(e,t){return n;function n(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Ht(e,t,"linePrefix")}}const _d={name:"thematicBreak",tokenize:sz};function sz(e,t,n){let s=0,o;return i;function i(m){return e.enter("thematicBreak"),c(m)}function c(m){return o=m,u(m)}function u(m){return m===o?(e.enter("thematicBreakSequence"),d(m)):s>=3&&(m===null||lt(m))?(e.exit("thematicBreak"),t(m)):n(m)}function d(m){return m===o?(e.consume(m),s++,d):(e.exit("thematicBreakSequence"),$t(m)?Ht(e,u,"whitespace")(m):u(m))}}const lr={continuation:{tokenize:lz},exit:uz,name:"list",tokenize:iz},oz={partial:!0,tokenize:dz},az={partial:!0,tokenize:cz};function iz(e,t,n){const s=this,o=s.events[s.events.length-1];let i=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,c=0;return u;function u(b){const C=s.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(C==="listUnordered"?!s.containerState.marker||b===s.containerState.marker:Fg(b)){if(s.containerState.type||(s.containerState.type=C,e.enter(C,{_container:!0})),C==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(_d,n,m)(b):m(b);if(!s.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(b)}return n(b)}function d(b){return Fg(b)&&++c<10?(e.consume(b),d):(!s.interrupt||c<2)&&(s.containerState.marker?b===s.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),m(b)):n(b)}function m(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||b,e.check(cp,s.interrupt?n:h,e.attempt(oz,y,g))}function h(b){return s.containerState.initialBlankLine=!0,i++,y(b)}function g(b){return $t(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),y):n(b)}function y(b){return s.containerState.size=i+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function lz(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(cp,o,i);function o(u){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Ht(e,t,"listItemIndent",s.containerState.size+1)(u)}function i(u){return s.containerState.furtherBlankLines||!$t(u)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(u)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(az,t,c)(u))}function c(u){return s.containerState._closeFlow=!0,s.interrupt=void 0,Ht(e,e.attempt(lr,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function cz(e,t,n){const s=this;return Ht(e,o,"listItemIndent",s.containerState.size+1);function o(i){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?t(i):n(i)}}function uz(e){e.exit(this.containerState.type)}function dz(e,t,n){const s=this;return Ht(e,o,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(i){const c=s.events[s.events.length-1];return!$t(i)&&c&&c[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const e0={name:"setextUnderline",resolveTo:fz,tokenize:pz};function fz(e,t){let n=e.length,s,o,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(o=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",i?(e.splice(o,0,["enter",c,t]),e.splice(i+1,0,["exit",e[s][1],t]),e[s][1].end={...e[i][1].end}):e[s][1]=c,e.push(["exit",c,t]),e}function pz(e,t,n){const s=this;let o;return i;function i(m){let h=s.events.length,g;for(;h--;)if(s.events[h][1].type!=="lineEnding"&&s.events[h][1].type!=="linePrefix"&&s.events[h][1].type!=="content"){g=s.events[h][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||g)?(e.enter("setextHeadingLine"),o=m,c(m)):n(m)}function c(m){return e.enter("setextHeadingLineSequence"),u(m)}function u(m){return m===o?(e.consume(m),u):(e.exit("setextHeadingLineSequence"),$t(m)?Ht(e,d,"lineSuffix")(m):d(m))}function d(m){return m===null||lt(m)?(e.exit("setextHeadingLine"),t(m)):n(m)}}const mz={tokenize:hz};function hz(e){const t=this,n=e.attempt(cp,s,e.attempt(this.parser.constructs.flowInitial,o,Ht(e,e.attempt(this.parser.constructs.flow,o,e.attempt(v6,o)),"linePrefix")));return n;function s(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const gz={resolveAll:QC()},xz=YC("string"),yz=YC("text");function YC(e){return{resolveAll:QC(e==="text"?bz:void 0),tokenize:t};function t(n){const s=this,o=this.parser.constructs[e],i=n.attempt(o,c,u);return c;function c(h){return m(h)?i(h):u(h)}function u(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),d}function d(h){return m(h)?(n.exit("data"),i(h)):(n.consume(h),d)}function m(h){if(h===null)return!0;const g=o[h];let y=-1;if(g)for(;++y<g.length;){const b=g[y];if(!b.previous||b.previous.call(s,s.previous))return!0}return!1}}}function QC(e){return t;function t(n,s){let o=-1,i;for(;++o<=n.length;)i===void 0?n[o]&&n[o][1].type==="data"&&(i=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==i+2&&(n[i][1].end=n[o-1][1].end,n.splice(i+2,o-i-2),o=i+2),i=void 0);return e?e(n,s):n}}function bz(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],o=t.sliceStream(s);let i=o.length,c=-1,u=0,d;for(;i--;){const m=o[i];if(typeof m=="string"){for(c=m.length;m.charCodeAt(c-1)===32;)u++,c--;if(c)break;c=-1}else if(m===-2)d=!0,u++;else if(m!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(u=0),u){const m={type:n===e.length||d||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?c:s.start._bufferIndex+c,_index:s.start._index+i,line:s.end.line,column:s.end.column-u,offset:s.end.offset-u},end:{...s.end}};s.end={...m.start},s.start.offset===s.end.offset?Object.assign(s,m):(e.splice(n,0,["enter",m,t],["exit",m,t]),n+=2)}n++}return e}const vz={42:lr,43:lr,45:lr,48:lr,49:lr,50:lr,51:lr,52:lr,53:lr,54:lr,55:lr,56:lr,57:lr,62:UC},wz={91:N6},jz={[-2]:Mh,[-1]:Mh,32:Mh},kz={35:P6,42:_d,45:[e0,_d],60:O6,61:e0,95:_d,96:Xj,126:Xj},Sz={38:HC,92:VC},Nz={[-5]:Fh,[-4]:Fh,[-3]:Fh,33:Z6,38:HC,42:zg,60:[t6,U6],91:tz,92:[R6,VC],93:wy,95:zg,96:m6},Cz={null:[zg,gz]},Ez={null:[42,95]},Tz={null:[]},Rz=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Ez,contentInitial:wz,disable:Tz,document:vz,flow:kz,flowInitial:jz,insideSpan:Cz,string:Sz,text:Nz},Symbol.toStringTag,{value:"Module"}));function Az(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},i=[];let c=[],u=[];const d={attempt:A(P),check:A(R),consume:E,enter:S,exit:T,interrupt:A(R,{interrupt:!0})},m={code:null,containerState:{},defineSkip:j,events:[],now:C,parser:e,previous:null,sliceSerialize:y,sliceStream:b,write:g};let h=t.tokenize.call(m,d);return t.resolveAll&&i.push(t),m;function g(D){return c=Fr(c,D),v(),c[c.length-1]!==null?[]:($(t,0),m.events=vy(i,m.events,m),m.events)}function y(D,V){return Dz(b(D),V)}function b(D){return Pz(c,D)}function C(){const{_bufferIndex:D,_index:V,line:K,column:I,offset:F}=s;return{_bufferIndex:D,_index:V,line:K,column:I,offset:F}}function j(D){o[D.line]=D.column,_()}function v(){let D;for(;s._index<c.length;){const V=c[s._index];if(typeof V=="string")for(D=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===D&&s._bufferIndex<V.length;)k(V.charCodeAt(s._bufferIndex));else k(V)}}function k(D){h=h(D)}function E(D){lt(D)?(s.line++,s.column=1,s.offset+=D===-3?2:1,_()):D!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===c[s._index].length&&(s._bufferIndex=-1,s._index++)),m.previous=D}function S(D,V){const K=V||{};return K.type=D,K.start=C(),m.events.push(["enter",K,m]),u.push(K),K}function T(D){const V=u.pop();return V.end=C(),m.events.push(["exit",V,m]),V}function P(D,V){$(D,V.from)}function R(D,V){V.restore()}function A(D,V){return K;function K(I,F,q){let Z,z,G,L;return Array.isArray(I)?re(I):"tokenize"in I?re([I]):H(I);function H(se){return ye;function ye(Se){const Te=Se!==null&&se[Se],Pe=Se!==null&&se.null,Ke=[...Array.isArray(Te)?Te:Te?[Te]:[],...Array.isArray(Pe)?Pe:Pe?[Pe]:[]];return re(Ke)(Se)}}function re(se){return Z=se,z=0,se.length===0?q:U(se[z])}function U(se){return ye;function ye(Se){return L=M(),G=se,se.partial||(m.currentConstruct=se),se.name&&m.parser.constructs.disable.null.includes(se.name)?ge():se.tokenize.call(V?Object.assign(Object.create(m),V):m,d,ue,ge)(Se)}}function ue(se){return D(G,L),F}function ge(se){return L.restore(),++z<Z.length?U(Z[z]):q}}}function $(D,V){D.resolveAll&&!i.includes(D)&&i.push(D),D.resolve&&Ns(m.events,V,m.events.length-V,D.resolve(m.events.slice(V),m)),D.resolveTo&&(m.events=D.resolveTo(m.events,m))}function M(){const D=C(),V=m.previous,K=m.currentConstruct,I=m.events.length,F=Array.from(u);return{from:I,restore:q};function q(){s=D,m.previous=V,m.currentConstruct=K,m.events.length=I,u=F,_()}}function _(){s.line in o&&s.column<2&&(s.column=o[s.line],s.offset+=o[s.line]-1)}}function Pz(e,t){const n=t.start._index,s=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex;let c;if(n===o)c=[e[n].slice(s,i)];else{if(c=e.slice(n,o),s>-1){const u=c[0];typeof u=="string"?c[0]=u.slice(s):c.shift()}i>0&&c.push(e[o].slice(0,i))}return c}function Dz(e,t){let n=-1;const s=[];let o;for(;++n<e.length;){const i=e[n];let c;if(typeof i=="string")c=i;else switch(i){case-5:{c="\r";break}case-4:{c=`
|
|
557
557
|
`;break}case-3:{c=`\r
|
|
558
558
|
`;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&o)continue;c=" ";break}default:c=String.fromCharCode(i)}o=i===-2,s.push(c)}return s.join("")}function $z(e){const s={constructs:zF([Rz,...(e||{}).extensions||[]]),content:o(GF),defined:[],document:o(QF),flow:o(mz),lazy:{},string:o(xz),text:o(yz)};return s;function o(i){return c;function c(u){return Az(s,i,u)}}}function Lz(e){for(;!WC(e););return e}const t0=/[\0\t\n\r]/g;function Oz(){let e=1,t="",n=!0,s;return o;function o(i,c,u){const d=[];let m,h,g,y,b;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(c||void 0).decode(i)),g=0,t="",n&&(i.charCodeAt(0)===65279&&g++,n=void 0);g<i.length;){if(t0.lastIndex=g,m=t0.exec(i),y=m&&m.index!==void 0?m.index:i.length,b=i.charCodeAt(y),!m){t=i.slice(g);break}if(b===10&&g===y&&s)d.push(-3),s=void 0;else switch(s&&(d.push(-5),s=void 0),g<y&&(d.push(i.slice(g,y)),e+=y-g),b){case 0:{d.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,d.push(-2);e++<h;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:s=!0,e=1}g=y+1}return u&&(s&&d.push(-5),t&&d.push(t),d.push(null)),d}}const Iz=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function _z(e){return e.replace(Iz,Mz)}function Mz(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const o=n.charCodeAt(1),i=o===120||o===88;return BC(n.slice(i?2:1),i?16:10)}return by(n)||e}const JC={}.hasOwnProperty;function Fz(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),zz(n)(Lz($z(n).document().write(Oz()(e,t,!0))))}function zz(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ye),autolinkProtocol:M,autolinkEmail:M,atxHeading:i(X),blockQuote:i(Pe),characterEscape:M,characterReference:M,codeFenced:i(Ke),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:i(Ke,c),codeText:i(ct,c),codeTextData:M,data:M,codeFlowValue:M,definition:i(et),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:i(ot),hardBreakEscape:i(Me),hardBreakTrailing:i(Me),htmlFlow:i(Ce,c),htmlFlowData:M,htmlText:i(Ce,c),htmlTextData:M,image:i(Ie),label:c,link:i(Ye),listItem:i(Ze),listItemValue:y,listOrdered:i(Fe,g),listUnordered:i(Fe),paragraph:i(Je),reference:U,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:i(X),strong:i(Ot),thematicBreak:i(dt)},exit:{atxHeading:d(),atxHeadingSequence:P,autolink:d(),autolinkEmail:Te,autolinkProtocol:Se,blockQuote:d(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:ge,characterReferenceMarkerNumeric:ge,characterReferenceValue:se,characterReference:ye,codeFenced:d(v),codeFencedFence:j,codeFencedFenceInfo:b,codeFencedFenceMeta:C,codeFlowValue:_,codeIndented:d(k),codeText:d(F),codeTextData:_,data:_,definition:d(),definitionDestinationString:T,definitionLabelString:E,definitionTitleString:S,emphasis:d(),hardBreakEscape:d(V),hardBreakTrailing:d(V),htmlFlow:d(K),htmlFlowData:_,htmlText:d(I),htmlTextData:_,image:d(Z),label:G,labelText:z,lineEnding:D,link:d(q),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:ue,resourceDestinationString:L,resourceTitleString:H,resource:re,setextHeading:d($),setextHeadingLineSequence:A,setextHeadingText:R,strong:d(),thematicBreak:d()}};XC(t,(e||{}).mdastExtensions||[]);const n={};return s;function s(le){let Y={type:"root",children:[]};const fe={stack:[Y],tokenStack:[],config:t,enter:u,exit:m,buffer:c,resume:h,data:n},ne=[];let he=-1;for(;++he<le.length;)if(le[he][1].type==="listOrdered"||le[he][1].type==="listUnordered")if(le[he][0]==="enter")ne.push(he);else{const De=ne.pop();he=o(le,De,he)}for(he=-1;++he<le.length;){const De=t[le[he][0]];JC.call(De,le[he][1].type)&&De[le[he][1].type].call(Object.assign({sliceSerialize:le[he][2].sliceSerialize},fe),le[he][1])}if(fe.tokenStack.length>0){const De=fe.tokenStack[fe.tokenStack.length-1];(De[1]||n0).call(fe,void 0,De[0])}for(Y.position={start:mo(le.length>0?le[0][1].start:{line:1,column:1,offset:0}),end:mo(le.length>0?le[le.length-2][1].end:{line:1,column:1,offset:0})},he=-1;++he<t.transforms.length;)Y=t.transforms[he](Y)||Y;return Y}function o(le,Y,fe){let ne=Y-1,he=-1,De=!1,ut,ae,be,Le;for(;++ne<=fe;){const at=le[ne];switch(at[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{at[0]==="enter"?he++:he--,Le=void 0;break}case"lineEndingBlank":{at[0]==="enter"&&(ut&&!Le&&!he&&!be&&(be=ne),Le=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Le=void 0}if(!he&&at[0]==="enter"&&at[1].type==="listItemPrefix"||he===-1&&at[0]==="exit"&&(at[1].type==="listUnordered"||at[1].type==="listOrdered")){if(ut){let Be=ne;for(ae=void 0;Be--;){const kt=le[Be];if(kt[1].type==="lineEnding"||kt[1].type==="lineEndingBlank"){if(kt[0]==="exit")continue;ae&&(le[ae][1].type="lineEndingBlank",De=!0),kt[1].type="lineEnding",ae=Be}else if(!(kt[1].type==="linePrefix"||kt[1].type==="blockQuotePrefix"||kt[1].type==="blockQuotePrefixWhitespace"||kt[1].type==="blockQuoteMarker"||kt[1].type==="listItemIndent"))break}be&&(!ae||be<ae)&&(ut._spread=!0),ut.end=Object.assign({},ae?le[ae][1].start:at[1].end),le.splice(ae||ne,0,["exit",ut,at[2]]),ne++,fe++}if(at[1].type==="listItemPrefix"){const Be={type:"listItem",_spread:!1,start:Object.assign({},at[1].start),end:void 0};ut=Be,le.splice(ne,0,["enter",Be,at[2]]),ne++,fe++,be=void 0,Le=!0}}}return le[Y][1]._spread=De,fe}function i(le,Y){return fe;function fe(ne){u.call(this,le(ne),ne),Y&&Y.call(this,ne)}}function c(){this.stack.push({type:"fragment",children:[]})}function u(le,Y,fe){this.stack[this.stack.length-1].children.push(le),this.stack.push(le),this.tokenStack.push([Y,fe||void 0]),le.position={start:mo(Y.start),end:void 0}}function d(le){return Y;function Y(fe){le&&le.call(this,fe),m.call(this,fe)}}function m(le,Y){const fe=this.stack.pop(),ne=this.tokenStack.pop();if(ne)ne[0].type!==le.type&&(Y?Y.call(this,le,ne[0]):(ne[1]||n0).call(this,le,ne[0]));else throw new Error("Cannot close `"+le.type+"` ("+ic({start:le.start,end:le.end})+"): it’s not open");fe.position.end=mo(le.end)}function h(){return MF(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function y(le){if(this.data.expectingFirstListItemValue){const Y=this.stack[this.stack.length-2];Y.start=Number.parseInt(this.sliceSerialize(le),10),this.data.expectingFirstListItemValue=void 0}}function b(){const le=this.resume(),Y=this.stack[this.stack.length-1];Y.lang=le}function C(){const le=this.resume(),Y=this.stack[this.stack.length-1];Y.meta=le}function j(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const le=this.resume(),Y=this.stack[this.stack.length-1];Y.value=le.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const le=this.resume(),Y=this.stack[this.stack.length-1];Y.value=le.replace(/(\r?\n|\r)$/g,"")}function E(le){const Y=this.resume(),fe=this.stack[this.stack.length-1];fe.label=Y,fe.identifier=Ei(this.sliceSerialize(le)).toLowerCase()}function S(){const le=this.resume(),Y=this.stack[this.stack.length-1];Y.title=le}function T(){const le=this.resume(),Y=this.stack[this.stack.length-1];Y.url=le}function P(le){const Y=this.stack[this.stack.length-1];if(!Y.depth){const fe=this.sliceSerialize(le).length;Y.depth=fe}}function R(){this.data.setextHeadingSlurpLineEnding=!0}function A(le){const Y=this.stack[this.stack.length-1];Y.depth=this.sliceSerialize(le).codePointAt(0)===61?1:2}function $(){this.data.setextHeadingSlurpLineEnding=void 0}function M(le){const fe=this.stack[this.stack.length-1].children;let ne=fe[fe.length-1];(!ne||ne.type!=="text")&&(ne=yt(),ne.position={start:mo(le.start),end:void 0},fe.push(ne)),this.stack.push(ne)}function _(le){const Y=this.stack.pop();Y.value+=this.sliceSerialize(le),Y.position.end=mo(le.end)}function D(le){const Y=this.stack[this.stack.length-1];if(this.data.atHardBreak){const fe=Y.children[Y.children.length-1];fe.position.end=mo(le.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Y.type)&&(M.call(this,le),_.call(this,le))}function V(){this.data.atHardBreak=!0}function K(){const le=this.resume(),Y=this.stack[this.stack.length-1];Y.value=le}function I(){const le=this.resume(),Y=this.stack[this.stack.length-1];Y.value=le}function F(){const le=this.resume(),Y=this.stack[this.stack.length-1];Y.value=le}function q(){const le=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";le.type+="Reference",le.referenceType=Y,delete le.url,delete le.title}else delete le.identifier,delete le.label;this.data.referenceType=void 0}function Z(){const le=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";le.type+="Reference",le.referenceType=Y,delete le.url,delete le.title}else delete le.identifier,delete le.label;this.data.referenceType=void 0}function z(le){const Y=this.sliceSerialize(le),fe=this.stack[this.stack.length-2];fe.label=_z(Y),fe.identifier=Ei(Y).toLowerCase()}function G(){const le=this.stack[this.stack.length-1],Y=this.resume(),fe=this.stack[this.stack.length-1];if(this.data.inReference=!0,fe.type==="link"){const ne=le.children;fe.children=ne}else fe.alt=Y}function L(){const le=this.resume(),Y=this.stack[this.stack.length-1];Y.url=le}function H(){const le=this.resume(),Y=this.stack[this.stack.length-1];Y.title=le}function re(){this.data.inReference=void 0}function U(){this.data.referenceType="collapsed"}function ue(le){const Y=this.resume(),fe=this.stack[this.stack.length-1];fe.label=Y,fe.identifier=Ei(this.sliceSerialize(le)).toLowerCase(),this.data.referenceType="full"}function ge(le){this.data.characterReferenceType=le.type}function se(le){const Y=this.sliceSerialize(le),fe=this.data.characterReferenceType;let ne;fe?(ne=BC(Y,fe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ne=by(Y);const he=this.stack[this.stack.length-1];he.value+=ne}function ye(le){const Y=this.stack.pop();Y.position.end=mo(le.end)}function Se(le){_.call(this,le);const Y=this.stack[this.stack.length-1];Y.url=this.sliceSerialize(le)}function Te(le){_.call(this,le);const Y=this.stack[this.stack.length-1];Y.url="mailto:"+this.sliceSerialize(le)}function Pe(){return{type:"blockquote",children:[]}}function Ke(){return{type:"code",lang:null,meta:null,value:""}}function ct(){return{type:"inlineCode",value:""}}function et(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ot(){return{type:"emphasis",children:[]}}function X(){return{type:"heading",depth:0,children:[]}}function Me(){return{type:"break"}}function Ce(){return{type:"html",value:""}}function Ie(){return{type:"image",title:null,url:"",alt:null}}function Ye(){return{type:"link",title:null,url:"",children:[]}}function Fe(le){return{type:"list",ordered:le.type==="listOrdered",start:null,spread:le._spread,children:[]}}function Ze(le){return{type:"listItem",spread:le._spread,checked:null,children:[]}}function Je(){return{type:"paragraph",children:[]}}function Ot(){return{type:"strong",children:[]}}function yt(){return{type:"text",value:""}}function dt(){return{type:"thematicBreak"}}}function mo(e){return{line:e.line,column:e.column,offset:e.offset}}function XC(e,t){let n=-1;for(;++n<t.length;){const s=t[n];Array.isArray(s)?XC(e,s):Bz(e,s)}}function Bz(e,t){let n;for(n in t)if(JC.call(t,n))switch(n){case"canContainEols":{const s=t[n];s&&e[n].push(...s);break}case"transforms":{const s=t[n];s&&e[n].push(...s);break}case"enter":case"exit":{const s=t[n];s&&Object.assign(e[n],s);break}}}function n0(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ic({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ic({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ic({start:t.start,end:t.end})+") is still open")}function Uz(e){const t=this;t.parser=n;function n(s){return Fz(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Vz(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Hz(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -577,7 +577,7 @@ ${R.stderr}`:R instanceof Error?R.message:String(R))}finally{b(!1)}}}const P=r.j
|
|
|
577
577
|
`).trim(),i=[...t.slice(0,n),...t.slice(s)].join(`
|
|
578
578
|
`).replace(/\n{3,}/g,`
|
|
579
579
|
|
|
580
|
-
`).trim();return{hasSection:!0,todosMarkdown:o,remaining:i}}function uU({projectSlug:e,dependencies:t,blockedReason:n}){const[s,o]=p.useState(!1);if(t.length===0)return null;const i=t.filter(u=>u.status!=="completed"&&u.status!=="review"),c=i.length===0;return c&&!s?r.jsxs("button",{type:"button",onClick:()=>o(!0),className:"flex w-full items-center gap-2 rounded-lg border border-success-foreground/30 bg-success/70 px-4 py-2.5 text-left transition hover:bg-success",children:[r.jsx(rx,{className:"h-4 w-4 shrink-0 text-success-foreground"}),r.jsxs("span",{className:"text-sm font-medium text-success-foreground",children:["All ",t.length," ",t.length===1?"dependency":"dependencies"," resolved"]}),r.jsx(pr,{className:"ml-auto h-4 w-4 text-success-foreground"})]}):r.jsxs("div",{className:"space-y-3",children:[i.length>0&&r.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-warning-foreground/30 bg-warning px-4 py-3",children:[r.jsx(Ud,{className:"mt-0.5 h-4 w-4 shrink-0 text-warning-foreground"}),r.jsxs("div",{className:"text-sm text-warning-foreground",children:[r.jsxs("strong",{children:[i.length," ",i.length===1?"dependency is":"dependencies are"," not yet completed."]}),n&&r.jsxs("p",{className:"mt-1 text-warning-foreground/80",children:["Blocked reason: ",n]})]})]}),r.jsx(He,{title:"Dependencies",description:`${t.length-i.length} of ${t.length} resolved`,actions:c?r.jsx("button",{type:"button",onClick:()=>o(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:"Collapse"}):void 0,children:r.jsx("div",{className:"divide-y divide-border/40",children:t.map(u=>r.jsxs(Ee,{to:`/projects/${e}/assignments/${u.slug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[r.jsx(bn,{status:u.status}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:u.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:u.slug})]}),u.assignee&&r.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:u.assignee}),r.jsx(Bd,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},u.slug))})})]})}function dU({links:e}){const t=fn();if(e.length===0)return null;const n=e.filter(o=>!o.isReverse),s=e.filter(o=>o.isReverse);return r.jsx(He,{title:"Linked Assignments",description:`${e.length} ${e.length===1?"link":"links"}`,children:r.jsxs("div",{className:"divide-y divide-border/40",children:[n.map(o=>r.jsxs(Ee,{to:`${t}/projects/${o.projectSlug}/assignments/${o.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[r.jsx(Ek,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),r.jsx(bn,{status:o.status}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.slug})]}),r.jsx(Bd,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`fwd-${o.slug}`)),s.map(o=>r.jsxs(Ee,{to:`${t}/projects/${o.projectSlug}/assignments/${o.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[r.jsx(zd,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),r.jsx(bn,{status:o.status}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.slug})]}),r.jsx(Bd,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`rev-${o.slug}`))]})})}function fU(e){const t=new Map;for(const s of e)t.set(s.id,{entry:s,replies:[]});const n=[];for(const s of e){const o=t.get(s.id);s.replyTo&&t.has(s.replyTo)?t.get(s.replyTo).replies.push(o):n.push(o)}return n}function pU(e,t){return e===null?`/api/assignments/${encodeURIComponent(t)}/comments`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments`}function qE({projectSlug:e,assignmentSlug:t,entries:n}){const[s,o]=p.useState(n);p.useEffect(()=>{o(n)},[n]);const i=p.useMemo(()=>fU(s),[s]),[c,u]=p.useState(""),[d,m]=p.useState("note"),[h,g]=p.useState(!1),[y,b]=p.useState(null);async function C(v){var S;if(v.preventDefault(),!c.trim())return;g(!0),b(null);const k=`tmp-${Date.now()}`,E={id:k,timestamp:new Date().toISOString(),author:"human",type:d,body:c,resolved:d==="question"?!1:void 0};o(T=>[...T,E]);try{const T=await fetch(pU(e,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:c,type:d})});if(!T.ok){const A=await T.text();throw new Error(A||`HTTP ${T.status}`)}const P=await T.json().catch(()=>null),R=(S=P==null?void 0:P.comment)==null?void 0:S.id;o(A=>A.map($=>$.id===k?{...$,id:R??$.id}:$)),u(""),window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(T){b(T instanceof Error?T.message:String(T)),o(P=>P.filter(R=>R.id!==k))}finally{g(!1)}}async function j(v,k){o(E=>E.map(S=>S.id===v?{...S,resolved:k}:S));try{const E=e===null?`/api/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(v)}/resolved`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(v)}/resolved`,S=await fetch(E,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({resolved:k})});if(!S.ok)throw new Error(`HTTP ${S.status}`);window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(E){b(E instanceof Error?E.message:String(E)),o(S=>S.map(T=>T.id===v?{...T,resolved:!k}:T))}}return r.jsx(He,{title:"Comments",description:"Threaded questions, notes, and feedback. Questions can be resolved once answered.",children:r.jsxs("div",{className:"space-y-4",children:[i.map(v=>r.jsx(GE,{node:v,onToggleResolved:j,depth:0},v.entry.id)),r.jsxs("form",{onSubmit:C,className:"mt-6 space-y-2 border-t border-border pt-4",children:[r.jsx("label",{className:"block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Add comment"}),r.jsx("textarea",{value:c,onChange:v=>u(v.target.value),className:"w-full rounded border border-border bg-background p-2 text-sm",rows:3,placeholder:"Ask a question, leave a note, or give feedback…"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("select",{value:d,onChange:v=>m(v.target.value),className:"rounded border border-border bg-background px-2 py-1 text-xs",children:[r.jsx("option",{value:"note",children:"note"}),r.jsx("option",{value:"question",children:"question"}),r.jsx("option",{value:"feedback",children:"feedback"})]}),r.jsx("button",{type:"submit",disabled:h||!c.trim(),className:"shell-action",children:h?"Posting…":"Post comment"}),y?r.jsx("span",{className:"text-xs text-error-foreground",children:y}):null]})]})]})})}function GE({node:e,depth:t,onToggleResolved:n}){const{entry:s,replies:o}=e,i=s.type==="question";return r.jsxs("div",{className:we("space-y-2",t>0&&"ml-4 border-l border-border pl-4"),children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{className:"font-mono",children:s.id}),r.jsx("span",{children:"·"}),r.jsx("span",{children:s.timestamp}),r.jsx("span",{children:"·"}),r.jsx("span",{className:"font-medium text-foreground",children:s.author}),r.jsx("span",{children:"·"}),r.jsx("span",{className:we("rounded px-1.5 py-0.5 font-mono text-[10px] uppercase",i&&"bg-warning text-warning-foreground",s.type==="feedback"&&"bg-info text-info-foreground",s.type==="note"&&"bg-muted text-muted-foreground"),children:s.type}),i?r.jsxs("button",{type:"button",onClick:()=>n(s.id,!s.resolved),className:we("inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium",s.resolved?"bg-success text-success-foreground hover:bg-success/80":"bg-muted text-muted-foreground hover:bg-muted/80"),title:s.resolved?"Mark unresolved":"Mark resolved",children:[s.resolved?r.jsx(rx,{className:"h-3 w-3"}):r.jsx(BA,{className:"h-3 w-3"}),s.resolved?"resolved":"open"]}):null,s.replyTo?r.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[r.jsx(dP,{className:"h-3 w-3"}),s.replyTo]}):null]}),r.jsx(xn,{content:s.body}),o.length>0?r.jsx("div",{className:"space-y-2",children:o.map(c=>r.jsx(GE,{node:c,depth:t+1,onToggleResolved:n},c.entry.id))}):null]})}const mU=["review","complete","shape","plan-ready","implement","unblock","start","block","fail","reopen"];function $0(){var ut,ae,be,Le,at,Be,kt,St,_t,pe;const{slug:e,aslug:t}=Bt(),n=zt(),s=fn(),[o,i]=ls(),[c,u]=p.useState(null),{toast:d,showToast:m,dismissToast:h}=Ao(),[g,y]=p.useState(null),[b,C]=p.useState(null),[j,v]=p.useState(null),[k,E]=p.useState(null),[S,T]=p.useState(!1),[P,R]=p.useState(!1),[A,$]=p.useState(0),M=o.get("tab")??"summary",_=ha(),{data:D,loading:V,error:K,refetch:I}=y3(e,t),{data:F}=iS(e),{data:q}=hx(),{data:Z,loading:z,error:G}=v3(e,t),{data:L,loading:H,error:re}=j3(e,t),U=p.useMemo(()=>{if(!D||!F)return[];const te=new Map(F.assignments.map(xe=>[xe.slug,xe]));return D.dependsOn.map(xe=>{const Oe=te.get(xe);return{slug:xe,title:(Oe==null?void 0:Oe.title)??xe,status:(Oe==null?void 0:Oe.status)??"pending",priority:(Oe==null?void 0:Oe.priority)??"medium",assignee:(Oe==null?void 0:Oe.assignee)??null}})},[D,F]),ue=U.filter(te=>te.status!=="completed"&&te.status!=="review");Ro("assignment");const ge=p.useMemo(()=>((F==null?void 0:F.assignments)??[]).map(te=>te.slug),[F]),se=t?ge.indexOf(t):-1,ye=se>0?ge[se-1]:null,Se=se>=0&&se<ge.length-1?ge[se+1]:null,Te=`${s}/projects/${e}/assignments/${t}`;Yt({keys:"e",scope:"assignment",description:"Edit assignment",handler:()=>n(`${Te}/edit`)}),Yt({keys:"p",scope:"assignment",description:"Edit plan",handler:()=>n(`${Te}/plan/edit`)}),Yt({keys:"h",scope:"assignment",description:"Append handoff",handler:()=>n(`${Te}/handoff/edit`)}),Yt({keys:"d",scope:"assignment",description:"Append decision record",handler:()=>n(`${Te}/decision-record/edit`)}),Yt({keys:"s",scope:"assignment",description:"Edit scratchpad",handler:()=>n(`${Te}/scratchpad/edit`)}),Yt({keys:"[",scope:"assignment",description:"Previous assignment in project",enabled:!!ye,handler:()=>ye&&n(`${s}/projects/${e}/assignments/${ye}`)}),Yt({keys:"]",scope:"assignment",description:"Next assignment in project",enabled:!!Se,handler:()=>Se&&n(`${s}/projects/${e}/assignments/${Se}`)});const Pe=p.useMemo(()=>D?lU(D.body):{acceptanceCriteria:[],summaryBody:""},[D]),Ke=p.useMemo(()=>cU(Pe.summaryBody),[Pe.summaryBody]),ct=Pe.acceptanceCriteria,et=ct.filter(te=>te.checked).length,ot=ct.length>0&&et===ct.length,X=p.useRef(ot),Me=p.useRef(!1);if(p.useEffect(()=>{if(D){if(!Me.current){X.current=ot,Me.current=!0;return}ot&&!X.current&&$(te=>te+1),X.current=ot}},[ot,D]),V)return r.jsx(xt,{label:"Loading assignment workspace…"});if(K||!D||!e||!t)return r.jsx(Tt,{error:K||"Assignment not found."});const Ce=e,Ie=t,Ye=ct.length>0?{checked:et,total:ct.length}:void 0,Fe=D.availableTransitions??[],Ze=Fe.filter(te=>!te.disabled&&te.targetStatus!==D.status),Je=mU.map(te=>Ze.find(xe=>xe.command===te)).find(Boolean)??Ze[0]??null,Ot=[];if(q!=null&&q.sessions)for(const te of q.sessions)for(const xe of te.windows)for(const Oe of xe.panes)((ut=Oe.assignment)==null?void 0:ut.project)===e&&((ae=Oe.assignment)==null?void 0:ae.slug)===t&&Ot.push({sessionName:te.name,command:Oe.command,urls:Oe.urls});async function yt(te){u(null);try{await RE(Ce,Ie,te),I()}catch(xe){u(xe.message)}}async function dt(te){u(null);try{const xe=await fetch(`/api/projects/${Ce}/assignments/${Ie}/${te?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!xe.ok){const Oe=await xe.json().catch(()=>null);throw new Error((Oe==null?void 0:Oe.error)||`HTTP ${xe.status}`)}I(),m(te?"Assignment archived":"Assignment restored","success")}catch(xe){u(xe.message)}}async function le(){R(!0);try{await U8(Ce,Ie),n(`${s}/projects/${Ce}`)}catch(te){u(te.message),R(!1),T(!1)}}async function Y(te,xe){u(null),y(te.command);try{return await TE(Ce,Ie,te,xe),I(),!0}catch(Oe){return u(Oe.message),!1}finally{y(null)}}function fe(te){if(AE(te)){C(te);return}Y(te)}async function ne(te,xe){v(null),E(te);try{const Oe=await fetch(`/api/projects/${Ce}/assignments/${Ie}/acceptance-criteria/${te}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({checked:xe})}),tt=await Oe.json();if(!Oe.ok)throw new Error(tt.error||`HTTP ${Oe.status}`);I()}catch(Oe){v(Oe.message)}finally{E(null)}}const he=[...Ze.filter(te=>te!==Je).map(te=>({key:`transition-${te.command}`,label:te.label,onSelect:()=>fe(te),disabled:g===te.command})),...Fe.filter(te=>te.disabled||te.targetStatus===D.status).map(te=>({key:`transition-${te.command}`,label:te.label,disabled:!0,disabledReason:te.targetStatus===D.status?`Already ${D.status.replace(/_/g," ")}`:te.disabledReason??te.warning??te.description})),..._.statuses.map(te=>({key:`override-${te.id}`,label:`Override → ${te.label}`,onSelect:()=>yt(te.id),disabled:te.id===D.status,disabledReason:te.id===D.status?"Already in this status":void 0})),{key:"edit-assignment",label:"Edit assignment source",icon:QA,href:`${s}/projects/${e}/assignments/${t}/edit`},{key:"edit-plan",label:"Edit plan",icon:pP,href:`${s}/projects/${e}/assignments/${t}/plan/edit`},{key:"edit-scratchpad",label:"Edit scratchpad",icon:ih,href:`${s}/projects/${e}/assignments/${t}/scratchpad/edit`},{key:"append-handoff",label:"Append handoff",icon:Bd,href:`${s}/projects/${e}/assignments/${t}/handoff/edit`},{key:"append-decision",label:"Append decision",icon:ZA,href:`${s}/projects/${e}/assignments/${t}/decision-record/edit`},{key:D.archived?"unarchive":"archive",label:D.archived?"Restore assignment":"Archive assignment",icon:D.archived?Fd:wf,onSelect:()=>dt(!D.archived)},{key:"delete",label:"Delete assignment",icon:Tn,destructive:!0,onSelect:()=>T(!0)}],De=(Je==null?void 0:Je.command)==="review";return r.jsxs("div",{className:"space-y-5",children:[r.jsx(xa,{toast:d,onDismiss:h}),r.jsxs("div",{className:"sticky top-12 z-20 rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm backdrop-blur",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(bn,{status:D.status,progress:Ye}),D.phase&&D.phase!==D.status&&r.jsxs("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-[11px] text-muted-foreground",title:"Phase dimension — how far along the work is, independent of blockage",children:["phase: ",D.phase]}),D.disposition&&D.disposition!=="active"&&r.jsx("span",{className:"rounded-full border border-warning-foreground/40 px-2 py-0.5 text-[11px] text-warning-foreground",title:"Disposition dimension — orthogonal to phase",children:D.disposition}),r.jsx(ga,{type:D.type}),r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:D.title}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Updated ",Wk(D.updated)]}),ue.length>0&&r.jsxs("span",{className:"text-xs text-warning-foreground",children:["⚠ ",ue.length," unmet dep",ue.length===1?"":"s"]}),r.jsx(uy,{externalIds:D.externalIds}),r.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[r.jsx(WE,{target:{kind:"assignment",id:D.id},worktreePath:((be=D.workspace)==null?void 0:be.worktreePath)??null,repository:((Le=D.workspace)==null?void 0:Le.repository)??null}),!((at=D.workspace)!=null&&at.worktreePath)&&e&&t&&r.jsx(KE,{projectSlug:e,assignmentSlug:t,defaultBranch:`syntaur/${e}/${t}`,onCreated:()=>I()}),Je&&r.jsx("button",{type:"button",title:Je.warning||Je.description,disabled:g===Je.command,onClick:()=>fe(Je),className:we("shell-action disabled:cursor-not-allowed disabled:opacity-50",Je.warning&&"border-warning-foreground/40",De&&A>0&&"send-to-review-glow"),children:r.jsx("span",{children:g===Je.command?"Working…":Je.label})},De?`review-${A}`:Je.command),r.jsx(ry,{items:he,align:"end"})]})]}),c?r.jsx("p",{className:"mt-4 rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:c}):null,D.blockedReason?r.jsxs("div",{className:"mt-4 rounded-md border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:[r.jsx("strong",{children:"Blocked reason:"})," ",D.blockedReason]}):null,D.override&&D.derived&&D.derived.derivedStatus!==D.status?r.jsxs("div",{className:"mt-4 rounded-md border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:[r.jsxs("strong",{children:["Pinned to ",D.status]})," by ",D.override.source,D.override.reason?r.jsxs(r.Fragment,{children:[" — “",D.override.reason,"”"]}):null," · ","would otherwise be ",r.jsx("strong",{children:D.derived.derivedStatus})]}):null,(Be=D.derived)!=null&&Be.nextAction?r.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:[r.jsx("span",{className:"font-medium text-foreground",children:"Next:"})," ",D.derived.nextAction]}):null]}),D.derived&&(Object.keys(D.derived.customFacts??{}).length>0||(D.derived.attestations??[]).length>0)?r.jsx(He,{title:"Facts",description:"Custom asserted facts and review attestations, materialized server-side.",children:r.jsxs("div",{className:"space-y-3",children:[Object.keys(D.derived.customFacts??{}).length>0&&r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Object.entries(D.derived.customFacts??{}).map(([te,xe])=>r.jsxs("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-[11px] text-muted-foreground",children:[te,": ",r.jsx("span",{className:"font-medium text-foreground",children:String(xe)})]},te))}),(D.derived.attestations??[]).map(te=>r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("span",{className:"text-[11px] font-medium text-foreground",children:te.fact}),r.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["(",te.binds,")"]}),te.records.length===0?r.jsx("span",{className:"text-[11px] text-muted-foreground",children:"— no attestations yet"}):te.records.map(xe=>r.jsxs("span",{title:`${xe.verdict}${xe.note?` — ${xe.note}`:""}${xe.stale?" (stale — revision moved)":""} · ${xe.at}`,className:we("rounded-full border px-2 py-0.5 text-[11px]",xe.stale?"border-border/40 text-muted-foreground line-through":xe.verdict==="approved"?"border-success-foreground/40 text-success-foreground":"border-warning-foreground/40 text-warning-foreground"),children:[xe.actor,": ",xe.verdict==="approved"?"approved":"changes",xe.stale?" (stale)":""]},xe.actor))]},te.fact))]})}):null,U.length>0&&r.jsx(uU,{projectSlug:e,dependencies:U,blockedReason:D.blockedReason}),D.enrichedLinks&&D.enrichedLinks.length>0&&r.jsx(dU,{links:D.enrichedLinks}),D.referencedBy&&D.referencedBy.length>0&&r.jsx(He,{title:"Referenced by",description:"Other assignments whose Todos, progress, comments, or handoffs link to this one.",children:r.jsx("ul",{className:"space-y-2",children:D.referencedBy.map(te=>{const xe=te.sourceProjectSlug===null?`/assignments/${te.sourceId}`:`${s}/projects/${te.sourceProjectSlug}/assignments/${te.sourceSlug}`;return r.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[r.jsx(Ee,{to:xe,className:"text-foreground hover:text-primary",children:te.sourceTitle}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",te.mentions," mention",te.mentions===1?"":"s",")"]}),te.sourceProjectSlug===null?r.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"}):null]},te.sourceId)})})}),r.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]",children:[r.jsx("div",{className:"space-y-4",children:r.jsx(fy,{value:M,onValueChange:te=>i({tab:te}),items:[{value:"summary",label:"Summary",content:r.jsxs("div",{className:"space-y-5",children:[Pe.acceptanceCriteria.length>0?r.jsx(He,{title:"Acceptance Criteria",description:"These checkboxes update the source assignment markdown.",children:r.jsxs("div",{className:"space-y-3",children:[j?r.jsx("p",{className:"rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:j}):null,Pe.acceptanceCriteria.map((te,xe)=>{const Oe=k!==null;return r.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-border/60 bg-background/80 px-3 py-3",children:[r.jsx("input",{type:"checkbox",checked:te.checked,disabled:Oe,onChange:tt=>ne(xe,tt.target.checked),className:"mt-1 h-4 w-4 rounded border-border text-primary"}),r.jsx("span",{className:"criterion-label text-sm leading-6","data-checked":te.checked,children:te.text})]},`${xe}-${te.text}`)})]})}):null,Ke.hasSection?r.jsx(He,{title:"Todos",description:"Checklist of work items from assignment.md. Links point to plan files.",children:r.jsx(xn,{content:Ke.todosMarkdown,emptyState:"No todos yet."})}):null,r.jsx(He,{title:"Assignment Summary",children:r.jsx(xn,{content:Ke.remaining,emptyState:Pe.acceptanceCriteria.length>0||Ke.hasSection?"No additional summary markdown beyond the acceptance criteria and todos.":"This assignment does not have summary markdown yet."})})]})},{value:"plan",label:"Plan",count:D.plan?1:0,content:D.plan?r.jsx("div",{className:"space-y-5",children:r.jsxs(He,{title:"Plan",description:"Shows plan.md only. Versioned plans (plan-v2.md, ...) linked from the Todos section are not yet rendered here — open them from the filesystem.",actions:r.jsxs(Ee,{className:"shell-action",to:`${s}/projects/${e}/assignments/${t}/plan/edit`,children:[r.jsx(ih,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit Plan"})]}),children:[r.jsx("div",{className:"mb-4",children:r.jsx(bn,{status:D.plan.status})}),r.jsx(xn,{content:D.plan.body,emptyState:"No plan content yet."})]})}):r.jsx(Et,{title:"No plan yet",description:"Plan files are optional and versioned. Run /plan-assignment to create plan.md (or plan-v2.md, ...) and link it from the Todos section."})},{value:"scratchpad",label:"Scratchpad",count:D.scratchpad?1:0,content:D.scratchpad?r.jsx(He,{title:"Scratchpad",actions:r.jsxs(Ee,{className:"shell-action",to:`${s}/projects/${e}/assignments/${t}/scratchpad/edit`,children:[r.jsx(ih,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit Scratchpad"})]}),children:r.jsx(xn,{content:D.scratchpad.body,emptyState:"Scratchpad is empty."})}):r.jsx(Et,{title:"No scratchpad yet",description:"Scratchpad notes appear here when you use the Edit Scratchpad action."})},{value:"handoff",label:"Handoff",count:((kt=D.handoff)==null?void 0:kt.handoffCount)??0,content:r.jsx("div",{className:"space-y-5",children:D.handoff?r.jsx(He,{children:r.jsx(xn,{content:D.handoff.body,emptyState:"No handoff history yet."})}):r.jsx(Et,{title:"No handoff log yet",description:"Handoffs appear here when an agent runs /complete-assignment or you append one manually."})})},{value:"progress",label:"Progress",count:((St=D.progress)==null?void 0:St.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:D.progress&&D.progress.entries.length>0?r.jsx(He,{title:"Progress",description:"Reverse-chronological log of work done on this assignment. Agents append entries via progress.md.",children:r.jsx("ol",{className:"space-y-4",children:D.progress.entries.map((te,xe)=>r.jsxs("li",{className:"border-l-2 border-border pl-3",children:[r.jsx("div",{className:"text-xs font-mono text-muted-foreground",children:te.timestamp}),r.jsx(xn,{content:te.body})]},`${te.timestamp}-${xe}`))})}):r.jsx(Et,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((_t=D.comments)==null?void 0:_t.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:D.comments&&D.comments.entries.length>0?r.jsx(qE,{projectSlug:e,assignmentSlug:t,entries:D.comments.entries}):r.jsx(Et,{title:"No comments yet",description:"Comments appear here when agents or humans post via `syntaur comment` or the dashboard."})})},{value:"decisions",label:"Decisions",count:((pe=D.decisionRecord)==null?void 0:pe.decisionCount)??0,content:r.jsx("div",{className:"space-y-5",children:D.decisionRecord?r.jsx(He,{children:r.jsx(xn,{content:D.decisionRecord.body,emptyState:"No decision history yet."})}):r.jsx(Et,{title:"No decision record yet",description:"Decision records appear here when you append one via the Append Decision action."})})}]})}),r.jsxs("div",{className:"min-w-0 space-y-5",children:[r.jsx(He,{title:"Details",children:r.jsxs("dl",{className:"space-y-3 text-sm",children:[r.jsx(ho,{label:"ID",value:D.id,copyable:!0}),r.jsx(ho,{label:"Priority",value:D.priority}),D.assignee&&r.jsx(ho,{label:"Assignee",value:D.assignee}),r.jsx(ho,{label:"Updated",value:`${Hk(D.updated)} · Created ${Vk(D.created)}`}),D.workspace.repository&&r.jsx(ho,{label:"Repository",value:D.workspace.repository,copyable:!0}),D.workspace.worktreePath&&r.jsx(ho,{label:"Worktree",value:D.workspace.worktreePath,copyable:!0}),D.workspace.branch&&r.jsx(ho,{label:"Branch",value:D.workspace.branch,copyable:!0}),D.workspace.parentBranch&&r.jsx(ho,{label:"Parent branch",value:D.workspace.parentBranch,copyable:!0}),D.externalIds.map((te,xe)=>r.jsx(hU,{entry:te},`${te.system}:${te.id}:${xe}`))]})}),Ot.length>0&&r.jsx(He,{title:"Servers",children:r.jsx("div",{className:"space-y-2",children:Ot.map((te,xe)=>r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-sm",children:[r.jsx("span",{className:"min-w-0 max-w-full truncate rounded bg-muted/60 px-1.5 py-0.5 font-mono text-xs",title:te.command,children:te.command}),r.jsx("span",{className:"min-w-0 max-w-full truncate text-xs text-muted-foreground",title:te.sessionName,children:te.sessionName}),te.urls.map(Oe=>r.jsxs("a",{href:Oe,target:"_blank",rel:"noopener noreferrer",title:Oe,className:"inline-flex min-w-0 max-w-full items-center gap-1 rounded border border-primary/30 bg-primary/5 px-1.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/10 dark:border-primary/40 dark:bg-primary/10 dark:hover:bg-primary/20",children:[r.jsx("span",{className:"min-w-0 truncate",children:Oe.replace("http://localhost:",":")}),r.jsx(Mi,{className:"h-2.5 w-2.5 shrink-0"})]},Oe))]},xe))})}),r.jsx($E,{sessions:Z==null?void 0:Z.sessions,loading:z,error:G,onError:te=>m(te.message,"error"),onNotice:te=>m(te,"success")}),r.jsx(LE,{summary:L==null?void 0:L.summary,loading:H,error:re})]})]}),r.jsx(OE,{open:b!==null,action:b,assignmentTitle:D.title,loading:g===(b==null?void 0:b.command),onOpenChange:te=>{te||C(null)},onConfirm:async te=>{if(!b)return;await Y(b,te)&&C(null)}}),r.jsx(ba,{open:S,title:"Delete assignment?",description:`This will permanently delete "${D.title}" and all its files (plan, scratchpad, handoff, decision record). This cannot be undone.`,confirmLabel:"Delete Assignment",destructive:!0,loading:P,onOpenChange:te=>{te||T(!1)},onConfirm:le})]})}function ho({label:e,value:t,copyable:n}){return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e}),r.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[r.jsx("span",{className:"block min-w-0 truncate",title:t,children:t}),n&&t!=="—"&&r.jsx(Br,{value:t})]})]})}function hU({entry:e}){const t=e.url!=null&&e.url.length>0;return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e.system}),r.jsx("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:t?r.jsxs("a",{href:e.url??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${e.system}:${e.id} in ${e.system}`,className:"flex items-center gap-1.5 min-w-0 text-primary hover:underline",children:[r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id}),r.jsx(Mi,{className:"h-2.5 w-2.5 shrink-0"})]}):r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id})})]})}function gU(){var R,A,$,M,_,D,V,K;const{id:e}=Bt(),[t,n]=ls(),s=t.get("tab")??"summary",{data:o,loading:i,error:c,refetch:u}=b3(e),{data:d,loading:m,error:h}=w3(e),{data:g,loading:y,error:b}=k3(o==null?void 0:o.slug),[C,j]=p.useState(!1),[v,k]=p.useState(null),{toast:E,showToast:S,dismissToast:T}=Ao();async function P(I){if(e){k(null);try{const F=await fetch(`/api/assignments/${e}/${I?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!F.ok){const q=await F.json().catch(()=>null);throw new Error((q==null?void 0:q.error)||`HTTP ${F.status}`)}u(),S(I?"Assignment archived":"Assignment restored","success")}catch(F){k(F instanceof Error?F.message:"Archive failed")}}}return i?r.jsx(xt,{}):c?r.jsx(Tt,{error:c}):o?r.jsxs("div",{className:"space-y-6",children:[r.jsx(xa,{toast:E,onDismiss:T}),r.jsxs("header",{className:"space-y-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(bn,{status:o.status}),r.jsx(ga,{type:o.type}),r.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:o.id}),r.jsx(uy,{externalIds:o.externalIds}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[r.jsx(WE,{target:{kind:"assignment",id:o.id},worktreePath:((R=o.workspace)==null?void 0:R.worktreePath)??null,repository:((A=o.workspace)==null?void 0:A.repository)??null,size:"compact"}),!(($=o.workspace)!=null&&$.worktreePath)&&r.jsx(KE,{assignmentId:o.id,defaultBranch:`syntaur/${o.slug}`,onCreated:()=>u()}),r.jsxs("button",{type:"button",onClick:()=>j(!0),className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:[r.jsx(jf,{className:"h-3 w-3"}),"Move to workspace…"]}),r.jsx(Ee,{to:`/assignments/${o.id}/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit"}),r.jsxs("button",{type:"button",onClick:()=>P(!o.archived),className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",title:o.archived?"Restore this assignment":"Archive this assignment",children:[o.archived?r.jsx(Fd,{className:"h-3 w-3"}):r.jsx(wf,{className:"h-3 w-3"}),o.archived?"Restore":"Archive"]})]})]}),r.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:o.title}),o.blockedReason?r.jsxs("p",{className:"text-sm text-warning-foreground",children:["Blocked: ",o.blockedReason]}):null,v?r.jsx("p",{className:"text-sm text-status-failed-foreground",children:v}):null]}),r.jsx(He,{title:"Details",children:r.jsxs("dl",{className:"space-y-3 text-sm",children:[r.jsx(go,{label:"ID",value:o.id,copyable:!0}),r.jsx(go,{label:"Priority",value:o.priority}),o.assignee&&r.jsx(go,{label:"Assignee",value:o.assignee}),r.jsx(go,{label:"Updated",value:`${Hk(o.updated)} · Created ${Vk(o.created)}`}),o.workspace.repository&&r.jsx(go,{label:"Repository",value:o.workspace.repository,copyable:!0}),o.workspace.worktreePath&&r.jsx(go,{label:"Worktree",value:o.workspace.worktreePath,copyable:!0}),o.workspace.branch&&r.jsx(go,{label:"Branch",value:o.workspace.branch,copyable:!0}),o.workspace.parentBranch&&r.jsx(go,{label:"Parent branch",value:o.workspace.parentBranch,copyable:!0}),o.externalIds.map((I,F)=>r.jsx(xU,{entry:I},`${I.system}:${I.id}:${F}`))]})}),o.referencedBy&&o.referencedBy.length>0?r.jsx(He,{title:"Referenced by",description:"Other assignments whose bodies link to this one.",children:r.jsx("ul",{className:"space-y-2",children:o.referencedBy.map(I=>r.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[r.jsx(Ee,{to:I.sourceProjectSlug===null?`/assignments/${I.sourceId}`:`/projects/${I.sourceProjectSlug}/assignments/${I.sourceSlug}`,className:"text-foreground hover:text-primary",children:I.sourceTitle}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",I.mentions," mention",I.mentions===1?"":"s",")"]})]},I.sourceId))})}):null,r.jsx($E,{sessions:d==null?void 0:d.sessions,loading:m,error:h,onError:I=>S(I.message,"error"),onNotice:I=>S(I,"success")}),r.jsx(LE,{summary:g==null?void 0:g.summary,loading:y,error:b}),r.jsx(fy,{value:s,onValueChange:I=>n({tab:I}),items:[{value:"summary",label:"Summary",content:r.jsx("div",{className:"space-y-5",children:r.jsx(He,{title:"Assignment",children:r.jsx(xn,{content:o.body,emptyState:"This assignment does not have summary markdown yet."})})})},{value:"progress",label:"Progress",count:((M=o.progress)==null?void 0:M.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:o.progress&&o.progress.entries.length>0?r.jsx(He,{title:"Progress",description:"Reverse-chronological log of work done on this assignment.",children:r.jsx("ol",{className:"space-y-4",children:o.progress.entries.map((I,F)=>r.jsxs("li",{className:"border-l-2 border-border pl-3",children:[r.jsx("div",{className:"text-xs font-mono text-muted-foreground",children:I.timestamp}),r.jsx(xn,{content:I.body})]},`${I.timestamp}-${F}`))})}):r.jsx(Et,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((_=o.comments)==null?void 0:_.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:r.jsx(qE,{projectSlug:null,assignmentSlug:o.id,entries:((D=o.comments)==null?void 0:D.entries)??[]})})},{value:"plan",label:"Plan",content:r.jsx("div",{className:"space-y-5",children:o.plan?r.jsxs(He,{children:[r.jsx(xn,{content:o.plan.body,emptyState:"Plan file exists but is empty."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${o.id}/plan/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit plan"})})]}):r.jsx(Et,{title:"No plan file yet",description:"Create one via the CLI or `/plan-assignment`."})})},{value:"scratchpad",label:"Scratchpad",content:r.jsx("div",{className:"space-y-5",children:o.scratchpad?r.jsxs(He,{children:[r.jsx(xn,{content:o.scratchpad.body,emptyState:"Scratchpad is empty."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${o.id}/scratchpad/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit scratchpad"})})]}):r.jsx(Et,{title:"No scratchpad yet",description:"Scratchpad is scaffolded at assignment creation time."})})},{value:"handoff",label:"Handoff",count:((V=o.handoff)==null?void 0:V.handoffCount)??0,content:r.jsx("div",{className:"space-y-5",children:o.handoff?r.jsxs(He,{children:[r.jsx(xn,{content:o.handoff.body,emptyState:"No handoff history yet."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${o.id}/handoff/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Append handoff"})})]}):r.jsx(Et,{title:"No handoff log yet",description:"Handoffs appear here when an agent appends one."})})},{value:"decisions",label:"Decisions",count:((K=o.decisionRecord)==null?void 0:K.decisionCount)??0,content:r.jsx("div",{className:"space-y-5",children:o.decisionRecord?r.jsxs(He,{children:[r.jsx(xn,{content:o.decisionRecord.body,emptyState:"No decision history yet."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${o.id}/decision-record/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Append decision"})})]}):r.jsx(Et,{title:"No decision record yet",description:"Decision records appear here once appended."})})}]}),r.jsx(cy,{open:C,onOpenChange:j,currentWorkspace:o.projectWorkspace,title:"Move assignment to workspace",description:"Standalone assignments belong to a project-workspace via the workspaceGroup frontmatter field.",onSubmit:async I=>{const F=await fetch(`/api/assignments/${encodeURIComponent(o.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:I})});if(!F.ok){const q=await F.json().catch(()=>({}));throw new Error(q.error||"Failed to move assignment")}u()}})]}):r.jsx(Tt,{error:"Assignment not found"})}function go({label:e,value:t,copyable:n}){return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e}),r.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[r.jsx("span",{className:"truncate",title:t,children:t}),n&&t!=="—"&&r.jsx(Br,{value:t})]})]})}function xU({entry:e}){const t=e.url!=null&&e.url.length>0;return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e.system}),r.jsx("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:t?r.jsxs("a",{href:e.url??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${e.system}:${e.id} in ${e.system}`,className:"flex items-center gap-1.5 min-w-0 text-primary hover:underline",children:[r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id}),r.jsx(Mi,{className:"h-2.5 w-2.5 shrink-0"})]}):r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id})})]})}function yU({currentStatus:e,availableTransitions:t,onSelect:n,disabled:s=!1,className:o}){const[i,c]=p.useState(!1),[u,d]=p.useState(null),[m,h]=p.useState(0),g=p.useRef(null),y=p.useRef(null),b=p.useId(),C=af(e),j=C.icon,v=p.useCallback(P=>{c(!1),P&&requestAnimationFrame(()=>{var R;(R=g.current)==null||R.focus()})},[]),k=p.useCallback(()=>{var R;const P=(R=g.current)==null?void 0:R.getBoundingClientRect();P&&d({top:P.top,left:P.left,width:P.width,bottom:P.bottom})},[]);p.useLayoutEffect(()=>{i&&k()},[i,k]),p.useEffect(()=>{if(!i)return;const P=()=>k();return window.addEventListener("scroll",P,!0),window.addEventListener("resize",P),()=>{window.removeEventListener("scroll",P,!0),window.removeEventListener("resize",P)}},[i,k]),p.useEffect(()=>{if(!i)return;const P=R=>{var $,M;const A=R.target;A&&(($=y.current)!=null&&$.contains(A)||(M=g.current)!=null&&M.contains(A)||v(!1))};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[i,v]),p.useEffect(()=>{i&&h(0)},[i,t.length]);function E(P){(P.key==="Enter"||P.key===" "||P.key==="ArrowDown")&&(P.preventDefault(),c(!0))}function S(P){if(t.length===0){P.key==="Escape"&&(P.preventDefault(),v(!0));return}if(P.key==="ArrowDown")P.preventDefault(),h(R=>(R+1)%t.length);else if(P.key==="ArrowUp")P.preventDefault(),h(R=>(R-1+t.length)%t.length);else if(P.key==="Home")P.preventDefault(),h(0);else if(P.key==="End")P.preventDefault(),h(t.length-1);else if(P.key==="Enter"){P.preventDefault();const R=t[m];R&&(n(R),v(!0))}else P.key==="Escape"&&(P.preventDefault(),v(!0))}function T(P){n(P),v(!1)}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:g,type:"button","data-no-drag":!0,disabled:s,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?b:void 0,onClick:()=>{s||c(P=>!P)},onKeyDown:E,title:`Status: ${C.label}. Click to change.`,className:we(YN(e,o),"cursor-pointer transition hover:brightness-95 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",s&&"cursor-not-allowed opacity-60"),children:[r.jsx(j,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"min-w-0 truncate",children:C.label})]}),i&&u&&typeof document<"u"?Fs.createPortal(r.jsx("div",{ref:y,id:b,role:"menu",tabIndex:-1,autoFocus:!0,onKeyDown:S,style:{position:"fixed",top:u.bottom+6,left:u.left,minWidth:Math.max(u.width,180),zIndex:60},className:"rounded-md border border-border/70 bg-popover py-1 text-sm text-popover-foreground shadow-lg",children:t.length===0?r.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No transitions available from this status."}):t.map((P,R)=>{const A=af(P.targetStatus),$=A.icon,M=R===m;return r.jsxs("button",{type:"button",role:"menuitem","data-no-drag":!0,onMouseEnter:()=>h(R),onClick:()=>T(P),title:P.warning||P.description,className:we("flex w-full flex-col items-stretch gap-0.5 px-3 py-1.5 text-left text-sm transition",M?"bg-foreground/5":"hover:bg-foreground/5"),children:[r.jsxs("span",{className:"flex items-center justify-between gap-2",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx($,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate",children:P.label})]}),r.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:A.label})]}),P.warning?r.jsx("span",{className:"text-[11px] leading-snug text-warning-foreground",children:P.warning}):null]},`${P.command}:${P.targetStatus}`)})}),document.body):null]})}function YE({title:e,detailHref:t,onSave:n,disabled:s=!1}){const[o,i]=p.useState(!1);return o?r.jsx(bU,{initialTitle:e,disabled:s,onSave:n,onExit:()=>i(!1)}):r.jsxs("div",{className:"group flex items-baseline gap-1.5",children:[r.jsx("button",{type:"button","data-no-drag":!0,disabled:s,onClick:()=>{s||i(!0)},className:we("text-left text-base font-semibold text-foreground transition hover:text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 rounded-sm",s&&"cursor-not-allowed opacity-60"),title:"Click to rename",children:e}),r.jsx(Ee,{to:t,"data-no-drag":!0,"aria-label":"Open detail page",title:"Open detail page",onClick:c=>c.stopPropagation(),className:"text-muted-foreground opacity-0 transition group-hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 rounded-sm",children:r.jsx(Mi,{className:"h-3.5 w-3.5"})})]})}function bU({initialTitle:e,disabled:t,onSave:n,onExit:s}){const o=p.useRef(e),[i,c]=p.useState(e),[u,d]=p.useState(!1),[m,h]=p.useState(!1),g=p.useRef(null),y=p.useRef(!1);p.useEffect(()=>{const v=g.current;v&&(v.focus(),v.select())},[]);const b=p.useCallback(()=>{var v;h(!0),window.setTimeout(()=>h(!1),260),(v=g.current)==null||v.focus()},[]),C=p.useCallback(async()=>{if(y.current)return;const v=i.trim();if(v.length===0){b();return}if(v===o.current){s();return}y.current=!0,d(!0);try{await n(v)}catch{}finally{d(!1),s()}},[i,s,n,b]);function j(v){v.key==="Enter"?(v.preventDefault(),C()):v.key==="Escape"&&(v.preventDefault(),y.current=!0,s())}return r.jsx("input",{ref:g,type:"text","data-no-drag":!0,disabled:t||u,value:i,onChange:v=>c(v.target.value),onKeyDown:j,onBlur:()=>void C(),className:we("w-full rounded-sm border border-border bg-background px-1.5 py-0.5 text-base font-semibold text-foreground outline-none transition focus:border-ring focus:ring-1 focus:ring-ring",m&&"syntaur-input-shake",u&&"opacity-70")})}function QE(e){const t=zt(),n=p.useRef(null),s=p.useRef(!1),o=p.useCallback(()=>{const c=n.current,u=!!(c!=null&&c.querySelector('[aria-expanded="true"]')),d=!!document.querySelector('[role="menu"]'),m=document.activeElement,h=!!(m&&(c!=null&&c.contains(m))&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"));s.current=u||d||h},[]),i=p.useCallback(c=>{if(s.current)return;const u=c.target;!u||u.closest(Li)||t(e)},[t,e]);return{containerRef:n,onMouseDown:o,onClick:i}}const L0=/[A-Za-z0-9_-]/;function O0(e,t){const n=Math.max(0,Math.min(t,e.length)),s=vU(e,n);if(s)return s;let o=n;for(;o>0&&L0.test(e[o-1]);)o--;let i=n;for(;i<e.length&&L0.test(e[i]);)i++;const c=e.slice(o,n),u=e.slice(0,o),d=u.match(/([A-Za-z_][A-Za-z0-9_-]*)\s*(:|>=|<=|!=|=|>|<)\s*$/);if(d)return{kind:"value",field:d[1].toLowerCase(),partial:c,tokenStart:o,tokenEnd:i};const m=u.match(/([A-Za-z_][A-Za-z0-9_-]*)\s*:\s*\([^)]*,\s*$/);return m?{kind:"value",field:m[1].toLowerCase(),partial:c,tokenStart:o,tokenEnd:i}:{kind:"field",partial:c,tokenStart:o,tokenEnd:i}}function vU(e,t){let n=-1;for(let d=t-1;d>=0;d--)if(e[d]==='"'&&(d===0||e[d-1]!=="\\")){n=d;break}if(n<0)return null;for(let d=n+1;d<t;d++)if(e[d]==='"'&&e[d-1]!=="\\")return null;let s=t;for(;s<e.length&&!(e[s]==='"'&&e[s-1]!=="\\");)s++;const o=e.slice(n+1,t),c=e.slice(0,n).match(/([A-Za-z_][A-Za-z0-9_-]*)\s*(:|>=|<=|!=|=|>|<)\s*$/);return{kind:"value",field:c?c[1].toLowerCase():"",partial:o,tokenStart:n,tokenEnd:s<e.length?s+1:s}}function wU(e,t){const n=GN(t),s=e.toLowerCase();if(s==="")return n;const o=[],i=[];for(const c of n){const u=c.toLowerCase();u.startsWith(s)?o.push(c):u.includes(s)&&i.push(c)}return[...o,...i]}function jU(e,t,n,s){const o=e.toLowerCase();let i=[];switch(o){case"status":i=[...n.statuses];break;case"priority":i=[...n.priorities];break;case"type":i=[...n.types];break;case"assignee":i=["none",...n.assignees];break;case"project":i=["none",...n.projects];break;case"tag":case"tags":i=[...n.tags];break;case"archived":case"pinned":case"blocked":case"parked":i=["true","false"];break;default:{const u=s[o];(u==null?void 0:u.kind)==="bool"&&(i=["true","false"]);break}}if(!i.length)return[];const c=t.toLowerCase();return c===""?i:i.filter(u=>u.toLowerCase().startsWith(c))}function kU(e,t,n){let s;return t.kind==="field"?s=`${n}:`:s=eN(n),{text:e.slice(0,t.tokenStart)+s+e.slice(t.tokenEnd),caret:t.tokenStart+s.length}}const SU=180;function NU(e,t){const[n,s]=p.useState(e);return p.useEffect(()=>{const o=setTimeout(()=>s(e),t);return()=>clearTimeout(o)},[e,t]),n}function CU({value:e,onChange:t,onCompiled:n,registry:s,declarations:o,valueSources:i,placeholder:c="AQL query (e.g. status:active AND priority:high)",className:u}){const d=p.useRef(null),m=p.useRef(null),h=NU(e,SU),[g,y]=p.useState([]),[b,C]=p.useState([]),[j,v]=p.useState("field"),[k,E]=p.useState(-1),[S,T]=p.useState(!1),P=p.useRef(e.length);p.useEffect(()=>{if(h.trim()===""){y([]),n==null||n(null);return}const I=Vx(h,s);I.errors.length>0?(y(I.errors),n==null||n(null)):(y([]),n==null||n(I.query))},[h,s,n]);const R=p.useCallback((I,F)=>{const q=O0(I,F);if(!q){C([]),T(!1);return}if(q.kind==="field"){const Z=wU(q.partial,o);C(Z),v("field"),T(Z.length>0)}else{const Z=jU(q.field,q.partial,i,s);C(Z),v("value"),T(Z.length>0)}E(-1)},[o,i,s]),A=p.useCallback(I=>{const F=I.target.value,q=I.target.selectionStart??F.length;P.current=q,t(F),R(F,q)},[t,R]),$=p.useCallback(I=>{const F=d.current,q=(F==null?void 0:F.selectionStart)??P.current,Z=O0(e,q);if(!Z)return;const{text:z,caret:G}=kU(e,Z,I);t(z),T(!1),C([]),requestAnimationFrame(()=>{d.current&&(d.current.focus(),d.current.setSelectionRange(G,G),P.current=G)})},[e,t]),M=p.useCallback(I=>{if(!(!S||b.length===0))switch(I.key){case"ArrowDown":I.preventDefault(),E(F=>Math.min(F+1,b.length-1));break;case"ArrowUp":I.preventDefault(),E(F=>Math.max(F-1,-1));break;case"Enter":case"Tab":k>=0&&(I.preventDefault(),$(b[k]));break;case"Escape":T(!1),C([]);break}},[S,b,k,$]),_=p.useRef(null),D=p.useCallback(()=>{_.current=setTimeout(()=>T(!1),120)},[]);p.useEffect(()=>()=>{_.current!==null&&clearTimeout(_.current)},[]);const V=p.useCallback(()=>{var F;const I=((F=d.current)==null?void 0:F.selectionStart)??e.length;R(e,I)},[e,R]);p.useEffect(()=>{var I,F;S&&((F=(I=m.current)==null?void 0:I.querySelector('[aria-selected="true"]'))==null||F.scrollIntoView({block:"nearest"}))},[k,S]);const K=g.length>0&&h.trim()!=="";return r.jsxs("div",{className:`relative flex flex-col gap-1 ${u??""}`,children:[r.jsx("input",{ref:d,type:"text",value:e,onChange:A,onKeyDown:M,onBlur:D,onFocus:V,placeholder:c,"aria-label":"AQL query input","aria-expanded":S,"aria-haspopup":"listbox","aria-autocomplete":"list",autoComplete:"off",spellCheck:!1,className:["h-9 w-full rounded-md border bg-background px-3 py-1.5 font-mono text-sm text-foreground outline-none transition",K?"border-destructive focus:border-destructive focus:ring-2 focus:ring-destructive/30":"border-border/60 focus:border-primary focus:ring-2 focus:ring-ring/30"].join(" ")}),S&&b.length>0&&r.jsx("ul",{ref:m,role:"listbox","aria-label":j==="field"?"Field suggestions":"Value suggestions",className:"absolute top-full z-50 mt-1 max-h-56 w-full overflow-y-auto rounded-md border border-border bg-popover py-1 shadow-md",children:b.map((I,F)=>r.jsx("li",{role:"option","aria-selected":F===k,onMouseDown:q=>{q.preventDefault(),$(I)},className:["cursor-pointer px-3 py-1.5 font-mono text-sm",F===k?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"].join(" "),children:I},I))}),K&&r.jsx("ul",{className:"space-y-0.5",role:"status","aria-live":"polite",children:g.map((I,F)=>r.jsxs("li",{className:"font-mono text-xs text-destructive",children:["at ",I.pos,": ",I.message]},F))})]})}const I0=Ux;function bd(e){return e==="1"?"stale":e==="0"?"fresh":"all"}function EU(e,t){return e.toString()===t.toString()}function _0(){const{workspace:e}=Bt(),t=fn(),n=zt(),s=p.useRef(null);Ro("list:assignments");const{data:o,loading:i,error:c,refetch:u}=Cf(),d=ha(),m=rp(),[h,g]=ls(),y=e?`w:${e}`:null,b=wE(y),C=p.useRef(void 0),j=p.useMemo(()=>aC(d.order),[d]),v=p.useMemo(()=>{const B={};for(const J of j)B[J]=Bc(d,J);return B},[j,d]),k=p.useMemo(()=>j.map(B=>({id:B,title:v[B]??B,description:np(B)})),[j,v]),E=p.useMemo(()=>m.definitions.map(B=>({id:B.id,title:Ni(m,B.id),description:B.description})),[m]),S="__unknown_type__",T=p.useMemo(()=>new Set(["all",...j]),[j]),P=h.get("view"),R=h.get("status"),A=h.get("stale"),$=P&&I0.includes(P)?P:"kanban";function M(B){if(!B)return[];const J=[];for(const me of B.split(",")){const _e=me.trim();!_e||_e==="all"||!T.has(_e)||J.includes(_e)||J.push(_e)}return J}const _=p.useCallback(B=>{g(J=>{const me=new URLSearchParams(J);return B==="kanban"?me.delete("view"):me.set("view",B),me})},[g]),[D,V]=p.useState(""),[K,I]=p.useState(()=>M(R)),[F,q]=p.useState(()=>ze(b.filters.priority)),[Z,z]=p.useState(()=>ze(b.filters.type)),[G,L]=p.useState(()=>ze(b.filters.assignee)),[H,re]=p.useState(()=>ze(b.filters.project)),[U,ue]=p.useState(()=>ze(b.filters.tags)),[ge,se]=p.useState(null),[ye,Se]=p.useState(()=>bd(A)),[Te,Pe]=p.useState(()=>sc({status:M(R),priority:ze(b.filters.priority),type:ze(b.filters.type),assignee:ze(b.filters.assignee),project:ze(b.filters.project),tags:ze(b.filters.tags),activity:bd(A)})),[Ke,ct]=p.useState(()=>b.sortField),[et,ot]=p.useState(()=>b.sortDirection),[X,Me]=p.useState(()=>({hidden:[]})),[Ce,Ie]=p.useState(()=>({hidden:[]})),[Ye,Fe]=p.useState(()=>b.grouping),Ze=Ye==="type"?"type":"status",[Je,Ot]=p.useState(()=>new Set),[yt,dt]=p.useState([]),{toast:le,showToast:Y,dismissToast:fe}=Ao(),[ne,he]=p.useState(null),[De,ut]=p.useState(null),[ae,be]=p.useState(null),[Le,at]=p.useState(null),[Be,kt]=p.useState(null),[St,_t]=p.useState(null),[pe,te]=p.useState(null),[xe,Oe]=p.useState(null),[tt,ve]=p.useState(null),[Nt,It]=p.useState(!1),[en,jt]=p.useState(!1),wn=e?{kind:"workspace",workspace:e}:{kind:"global"},Rt=h.get("loadView"),{view:oe,loading:Ue,error:nt}=So(Rt),{view:bt,loading:tr,error:qr}=So(tt),Ts=p.useRef(null);p.useEffect(()=>{dt((o==null?void 0:o.assignments)??[])},[o]),p.useEffect(()=>{tt&&!tr&&!qr&&!bt&&ve(null)},[bt,qr,tt,tr]),p.useEffect(()=>{ve(null),Ts.current=null,se(null),V("")},[e]);const qc=p.useRef({status:R,stale:A});p.useEffect(()=>{const B=M(R),J=bd(A);jO(B,K)||I(B),J!==ye&&Se(J);const me=qc.current,_e=me.status!==R||me.stale!==A;qc.current={status:R,stale:A},_e&&on({status:B,activity:J})},[ye,A,K,R]),p.useEffect(()=>{C.current===y&&g(B=>{const J=new URLSearchParams(B);return K.length===0?J.delete("status"):J.set("status",K.join(",")),ye==="all"?J.delete("stale"):ye==="stale"?J.set("stale","1"):J.set("stale","0"),EU(B,J)?B:J})},[ye,y,g,K]),p.useEffect(()=>{q(ze(b.filters.priority)),z(ze(b.filters.type)),L(ze(b.filters.assignee)),re(ze(b.filters.project)),ue(ze(b.filters.tags)),ct(b.sortField),ot(b.sortDirection),Fe(b.grouping)},[b.filters.priority,b.filters.type,b.filters.assignee,b.filters.project,b.filters.tags,b.sortField,b.sortDirection,b.grouping]),p.useEffect(()=>{if(C.current===y)return;let B=!1;return Oy().then(J=>{if(B||C.current===y)return;const me=X1(J,y),_e=me.defaultView,ft=ze(me.filters.status),vt=me.filters.activity??"all",Mt=new URLSearchParams(window.location.search);let hr=!1;const un=new URLSearchParams(Mt);Mt.get("view")===null&&_e!=="kanban"&&I0.includes(_e)&&(un.set("view",_e),hr=!0),Mt.get("status")===null&&ft.length>0&&(un.set("status",ft.join(",")),I(ft),hr=!0),Mt.get("stale")===null&&vt!=="all"&&(un.set("stale",vt==="stale"?"1":"0"),Se(vt),hr=!0),hr&&g(un,{replace:!0});const pn=M(un.get("status")),mn=un.get("stale")===null?vt:bd(un.get("stale"));Pe(sc({status:pn,priority:ze(me.filters.priority),type:ze(me.filters.type),assignee:ze(me.filters.assignee),project:ze(me.filters.project),tags:ze(me.filters.tags),activity:mn==="fresh"||mn==="stale"?mn:"all"})),queueMicrotask(()=>{C.current=y})}),()=>{B=!0}},[y]);const ht=p.useCallback(B=>{(y===null?kE(B):SE(y,B)).catch(me=>{console.warn("Failed to persist view prefs:",me)})},[y]),Gc=p.useCallback(B=>{_(B),ht({defaultView:B})},[_,ht]),tl=p.useRef(null);tl.current={status:K,priority:F,type:Z,assignee:G,project:H,tags:U,activity:ye,dateRange:ge,search:D};const Yc=p.useCallback((B={})=>{const J=tl.current;return{status:J.status,priority:J.priority,type:J.type,assignee:J.assignee,project:J.project,tags:J.tags,activity:J.activity,dateRange:la(J.dateRange),search:J.search,...B}},[]),on=p.useCallback((B={})=>{Pe(sc(Yc(B)))},[Yc]),Qc=p.useCallback(B=>{I(B),ht({filters:{status:B}}),on({status:B})},[ht,on]),Jc=p.useCallback(B=>{q(B),ht({filters:{priority:B}}),on({priority:B})},[ht,on]),Xc=p.useCallback(B=>{z(B),ht({filters:{type:B}}),on({type:B})},[ht,on]),bp=p.useCallback(B=>{L(B),ht({filters:{assignee:B}}),on({assignee:B})},[ht,on]),vp=p.useCallback(B=>{re(B),ht({filters:{project:B}}),on({project:B})},[ht,on]),tn=p.useCallback(B=>{ue(B),ht({filters:{tags:B}}),on({tags:B})},[ht,on]),wp=p.useCallback(B=>{Se(B),ht({filters:{activity:B}}),on({activity:B})},[ht,on]),nl=p.useCallback(B=>{V(B),on({search:B})},[on]),Zc=p.useCallback(B=>{se(B),on({dateRange:la(B)})},[on]),qs=p.useCallback(B=>{ct(B),ht({sortField:B})},[ht]),va=p.useCallback(B=>{ot(B),ht({sortDirection:B})},[ht]),eu=p.useCallback(B=>{Fe(B),ht({grouping:B})},[ht]),wa=p.useCallback(B=>{Pe(B);const J=oc(B);J&&(I(ze(J.status)),q(ze(J.priority)),z(ze(J.type)),L(ze(J.assignee)),re(ze(J.project)),ue(ze(J.tags)),V(J.search??""),Se(J.activity&&J.activity!=="all"?J.activity:"all"),se(op(J.dateRange)))},[]),cn=p.useMemo(()=>oc(Te)!==null,[Te]),ja=p.useCallback(()=>{const J=oc(Te)!==null?{status:K,priority:F,type:Z,assignee:G,project:H,tags:U,activity:ye,dateRange:la(ge),search:D}:{};return{viewMode:$,filters:{...J,query:Te},sortField:Ke,sortDirection:et,listSectionVisibility:{collapsed:[...Je]},kanbanColumnVisibility:X,tableColumnVisibility:Ce}},[$,Te,K,F,Z,G,H,U,ye,ge,D,Ke,et,Je,X,Ce]),Bn=p.useCallback(B=>{eC(B,{setViewMode:_,setQuery:Pe,setStatusFilter:J=>{I(J),ht({filters:{status:J}})},setPriorityFilter:J=>{q(J),ht({filters:{priority:J}})},setTypeFilter:J=>{z(J),ht({filters:{type:J}})},setAssigneeFilter:J=>{L(J),ht({filters:{assignee:J}})},setProjectFilter:J=>{re(J),ht({filters:{project:J}})},setTagsFilter:J=>{ue(J),ht({filters:{tags:J}})},setActivityFilter:J=>{Se(J),ht({filters:{activity:J}})},setDateRange:se,setSearch:V,setSortField:qs,setSortDirection:va,setListSectionVisibility:J=>Ot(new Set(J.collapsed)),setKanbanColumnVisibility:Me,setTableColumnVisibility:Ie}),ve(B.id)},[_,ht,qs,va]),jp=p.useCallback(B=>{Bn(B),Ts.current=B.id,g(J=>{const me=new URLSearchParams(J);return me.set("loadView",B.id),me},{replace:!0})},[Bn,g]),kp=p.useCallback(async B=>{try{const J=Oi({name:B,context:{workspace:e??null,projectSlug:null},state:ja()}),me=await Pi(J),_e=me.views[me.views.length-1];ve((_e==null?void 0:_e.id)??null),_e&&(Ts.current=_e.id,g(ft=>{const vt=new URLSearchParams(ft);return vt.set("loadView",_e.id),vt},{replace:!0})),It(!1),jt(!1),Y(`Saved view "${B}"`,"success")}catch(J){throw Y(J instanceof Error?J.message:"Failed to save view","error"),J}},[ja,g,Y,e]),Sp=p.useCallback(async()=>{if(!(!tt||!bt))try{const B=Oi({name:bt.name,context:{workspace:e??null,projectSlug:null},state:ja()}),J=lf(bt.config,B.config,B.config);await ef(tt,{config:J}),Y("View updated","success")}catch(B){Y(B instanceof Error?B.message:"Failed to update view","error")}},[ja,bt,tt,Y,e]);p.useEffect(()=>{if(!Rt){Ts.current=null;return}if(Ts.current!==Rt&&(tt&&tt!==Rt&&ve(null),!Ue)){if(nt){Y("Couldn't load saved view — try again","error");return}if(oe){Ts.current=Rt,Bn(oe),g(B=>{const J=new URLSearchParams(B);return J.delete("loadView"),J},{replace:!0});return}Ts.current=Rt,Y("Saved view no longer exists","error"),g(B=>{const J=new URLSearchParams(B);return J.delete("loadView"),J},{replace:!0})}},[Rt,oe,Ue,nt,tt,Bn,g,Y]);const Yn=p.useMemo(()=>yt.filter(B=>e?e==="_ungrouped"?B.projectWorkspace===null:B.projectWorkspace===e:!0),[yt,e]),ka=p.useMemo(()=>Array.from(new Set(Yn.map(B=>B.status))).sort(),[Yn]),Gs=p.useMemo(()=>Array.from(new Set(Yn.map(B=>B.priority))).sort(),[Yn]),Do=p.useMemo(()=>Array.from(new Set(Yn.map(B=>B.assignee??"__unassigned__"))).sort(),[Yn]),tu=p.useMemo(()=>Array.from(new Map(Yn.filter(B=>B.projectSlug!==null).map(B=>[B.projectSlug,B.projectTitle]))).sort(([,B],[,J])=>B.localeCompare(J)),[Yn]),nu=p.useMemo(()=>Array.from(new Set(Yn.flatMap(B=>B.tags??[]))).sort(),[Yn]),$o=p.useMemo(()=>qN(d.factDeclarations),[d.factDeclarations]),rl=p.useMemo(()=>Te.trim()===""?null:Vx(Te,$o).query,[Te,$o]),Jt=p.useMemo(()=>WN(yt,rl,{workspace:e}),[yt,rl,e]),Gr=p.useMemo(()=>Uc(Jt,Ke,et),[Jt,Ke,et]),sl=p.useMemo(()=>{if(Ye==="none")return[{id:"__all__",label:"All assignments",items:Jt}];if(Ye==="type"){const B=m.definitions.map(_e=>({id:_e.id,label:Ni(m,_e.id),items:Jt.filter(ft=>ft.type===_e.id)})),J=new Set(m.definitions.map(_e=>_e.id)),me=Jt.filter(_e=>!_e.type||!J.has(_e.type));return me.length>0&&B.push({id:S,label:"Other",items:me}),B}if(Ye==="priority")return["critical","high","medium","low"].map(J=>({id:J,label:J.charAt(0).toUpperCase()+J.slice(1),items:Jt.filter(me=>me.priority===J)}));if(Ye==="assignee")return Array.from(new Set(Jt.map(J=>J.assignee??"__unassigned__"))).sort().map(J=>({id:J,label:J==="__unassigned__"?"Unassigned":J,items:Jt.filter(me=>(me.assignee??"__unassigned__")===J)}));if(Ye==="project"){const B=new Map;for(const J of Jt){const me=J.projectSlug??"__standalone__",_e=J.projectTitle??"Standalone";B.has(me)||B.set(me,_e)}return Array.from(B.entries()).sort(([,J],[,me])=>J.localeCompare(me)).map(([J,me])=>({id:J,label:me,items:Jt.filter(_e=>(_e.projectSlug??"__standalone__")===J)}))}return j.map(B=>({id:B,label:v[B]??B,items:Jt.filter(J=>J.status===B)}))},[Ye,Jt,m,j,v]),ol=p.useMemo(()=>{const B=new Set(m.definitions.map(me=>me.id));return Jt.some(me=>!me.type||!B.has(me.type))?[...E,{id:S,title:"Other",description:"Assignments with no recognized type."}]:E},[E,m,Jt]),{visibleItems:Pt,visibleIndexByKey:al}=p.useMemo(()=>{let B;if($==="table")B=Gr;else if($==="kanban"){const me=new Set(m.definitions.map(_e=>_e.id));Ze==="type"?B=[...m.definitions.flatMap(_e=>Jt.filter(ft=>ft.type===_e.id)),...Jt.filter(_e=>!_e.type||!me.has(_e.type))]:B=j.flatMap(_e=>Jt.filter(ft=>ft.status===_e))}else B=sl.flatMap(me=>me.items);const J=new Map;return B.forEach((me,_e)=>J.set(ln(me),_e)),{visibleItems:B,visibleIndexByKey:J}},[$,Gr,sl,Ze,m,Jt,j]),{hotkeyRowProps:Sa}=$c(Pt,{scope:"list:assignments",onOpen:B=>{if(B.projectSlug===null){n(`/assignments/${B.id}`);return}const J=B.projectWorkspace?`/w/${B.projectWorkspace}`:t;n(`${J}/projects/${B.projectSlug}/assignments/${B.slug}`)}});if(Yt({keys:"/",scope:"list:assignments",description:"Focus filter",handler:()=>{var B;return(B=s.current)==null?void 0:B.focus()}}),Yt({keys:"r",scope:"list:assignments",description:"Refresh",handler:()=>u()}),i)return r.jsx(xt,{label:"Loading assignments board…"});if(c||!o)return r.jsx(Tt,{error:c||"Assignments board is unavailable."});async function Na({item:B,toColumnId:J,action:me,reason:_e}){he(ln(B));const ft=yt;dt(vt=>vt.map(Mt=>ln(Mt)===ln(B)?{...Mt,status:J,blockedReason:J==="blocked"?_e??Mt.blockedReason:null}:Mt));try{if(B.projectSlug===null){if(!me)throw new Error("Standalone assignments require a transition action, not status override.");const Mt=await fetch(`/api/assignments/${encodeURIComponent(B.id)}/transitions/${encodeURIComponent(me.command)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_e?{reason:_e}:{})});if(!Mt.ok)throw new Error((await Mt.json()).error??`HTTP ${Mt.status}`);const un=(await Mt.json()).assignment;dt(pn=>pn.map(mn=>ln(mn)===ln(B)?{...mn,status:un.status,blockedReason:un.blockedReason,availableTransitions:un.availableTransitions,updated:un.updated}:mn));return}const vt=me?await TE(B.projectSlug,B.slug,me,_e):await RE(B.projectSlug,B.slug,J);return dt(Mt=>Mt.map(hr=>ln(hr)===ln(B)?{...hr,status:vt.status,blockedReason:vt.blockedReason,availableTransitions:vt.availableTransitions,updated:vt.updated}:hr)),u(),!0}catch(vt){return dt(ft),Y(vt.message,"error"),!1}finally{he(null)}}async function Ys({item:B,toColumnId:J,action:me}){if(B.status===J)return;const _e=me??Hl(B,J);if(_e!=null&&_e.disabled){Y(_e.disabledReason||`Cannot move this assignment to ${J}.`,"error");return}if(_e&&AE(_e)){at({item:B,toColumnId:J,action:_e});return}await Na({item:B,toColumnId:J,action:_e})}async function Ca(B,J){if(J===B.title)return;const me=ln(B),_e=yt;dt(ft=>ft.map(vt=>ln(vt)===me?{...vt,title:J}:vt)),he(me);try{const ft=B.projectSlug===null?await H8({id:B.id,title:J}):await V8({projectSlug:B.projectSlug,assignmentSlug:B.slug,title:J});dt(vt=>vt.map(Mt=>ln(Mt)===me?{...Mt,title:ft.title,updated:ft.updated}:Mt)),u()}catch(ft){throw dt(_e),Y(ft.message,"error"),ft}finally{he(null)}}function ru(B){Ot(J=>{const me=new Set(J);return me.has(B)?me.delete(B):me.add(B),me})}function il(B){Ke===B?va(et==="asc"?"desc":"asc"):(qs(B),va("asc"))}const In=De?yt.find(B=>ln(B)===De)??null:null;function us(B,J){B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",J),ut(J)}function Pr(){ut(null),be(null)}function ds(B,J){if(!In)return;const me=Hl(In,J);In.status===J||me!=null&&me.disabled||(B.preventDefault(),B.dataTransfer.dropEffect="move",be(J))}function Lo(B,J){ae===J&&!B.currentTarget.contains(B.relatedTarget)&&be(null)}function Oo(B,J){if(B.preventDefault(),!In||In.status===J){Pr();return}Pr(),Ys({item:In,toColumnId:J})}function Un({field:B,children:J}){const me=Ke===B;return r.jsx("th",{className:"pb-3 font-medium",children:r.jsxs("button",{type:"button",onClick:()=>il(B),className:"inline-flex items-center gap-1 hover:text-foreground",children:[J,me?et==="asc"?r.jsx(Ak,{className:"h-3 w-3"}):r.jsx(pr,{className:"h-3 w-3"}):null]})})}return r.jsxs("div",{className:"space-y-5","data-density":b.density,children:[r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs(Ee,{to:`${t}/assignments/new`,className:"inline-flex h-9 items-center gap-2 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90",children:[r.jsx(Lt,{className:"h-4 w-4"}),"New Assignment"]})}),r.jsxs(iy,{children:[r.jsx(CU,{className:"w-full md:min-w-[320px] md:flex-1",value:Te,onChange:wa,registry:$o,declarations:d.factDeclarations,valueSources:{statuses:d.order,priorities:Gs,types:m.definitions.map(B=>B.id),assignees:Do.filter(B=>B!=="__unassigned__"),projects:tu.map(([B])=>B),tags:nu}}),cn?null:r.jsx("span",{className:"inline-flex items-center rounded-md border border-amber-500/40 bg-amber-500/10 px-2 py-1 text-xs font-medium text-amber-700 dark:text-amber-300",title:"This query uses features the chips can't represent (OR / NOT / grouping / advanced fields). Edit it in the query box; the chips are read-only until it becomes chip-representable again.",children:"advanced query — edit in the box"}),r.jsx(ap,{ref:s,value:D,onChange:cn?nl:()=>{},placeholder:"Search assignments or projects"}),r.jsx(yn,{ariaLabel:"Status filter",className:"max-w-[180px]",allLabel:"All statuses",disabled:!cn,options:ka.map(B=>({value:B,label:v[B]??B})),value:K,onChange:Qc}),r.jsx(yn,{ariaLabel:"Priority filter",className:"max-w-[180px]",allLabel:"All priorities",disabled:!cn,options:Gs.map(B=>({value:B,label:B[0].toUpperCase()+B.slice(1)})),value:F,onChange:Jc}),r.jsx(yn,{ariaLabel:"Type filter",className:"max-w-[180px]",allLabel:"All types",disabled:!cn,options:m.definitions.map(B=>({value:B.id,label:Ni(m,B.id)})),value:Z,onChange:Xc}),r.jsx(yn,{ariaLabel:"Assignee filter",className:"max-w-[180px]",allLabel:"All assignees",disabled:!cn,options:[{value:"__unassigned__",label:"Unassigned"},...Do.filter(B=>B!=="__unassigned__").map(B=>({value:B,label:B}))],value:G,onChange:bp}),r.jsx(yn,{ariaLabel:"Project filter",className:"max-w-[180px]",allLabel:"All projects",disabled:!cn,options:[{value:"__standalone__",label:"Standalone"},...tu.map(([B,J])=>({value:B,label:J}))],value:H,onChange:vp}),r.jsx(yn,{ariaLabel:"Tags filter",className:"max-w-[180px]",allLabel:"Any tags",disabled:!cn,options:nu.map(B=>({value:B,label:B})),value:U,onChange:tn}),r.jsx(sp,{className:"max-w-[200px]",value:ge,onChange:cn?Zc:()=>{}}),r.jsxs("select",{value:ye,disabled:!cn,onChange:B=>wp(B.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All activity"}),r.jsx("option",{value:"stale",children:"Stale only"}),r.jsx("option",{value:"fresh",children:"Fresh only"})]}),r.jsx("select",{value:$==="kanban"?Ze:Ye,onChange:B=>eu(B.target.value),className:"editor-input max-w-[180px]",title:"Group by",children:vO.map(B=>{const J=$==="kanban"&&B!=="status"&&B!=="type",me=B==="none"?"No grouping":`Group: ${B.charAt(0).toUpperCase()+B.slice(1)}`;return r.jsx("option",{value:B,disabled:J,children:J?`${me} (list only)`:me},B)})}),r.jsx(ip,{value:$,onChange:B=>Gc(B),options:[{value:"table",label:"Table"},{value:"list",label:"List"},{value:"kanban",label:"Kanban"}]}),$==="table"?r.jsx(yE,{visibility:Ce,onChange:Ie}):null,r.jsx(CE,{scope:wn,loadedViewId:tt,onApply:jp,onOpenSaveDialog:()=>{jt(!1),It(!0)}}),r.jsx("button",{type:"button",onClick:()=>{bt?Sp():(jt(!1),It(!0))},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:bt?`Update ${bt.name}`:"Save current view",children:bt?`Update '${bt.name}'`:"Save view"}),bt?r.jsx("button",{type:"button",onClick:()=>{jt(!0),It(!0)},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Save as new view",children:"Save as new…"}):null]}),o.assignments.length===0?r.jsx(Et,{title:"No assignments yet",description:"Assignments appear here once projects contain concrete work items.",actions:r.jsxs(Ee,{className:"shell-action shell-action--cta",to:`${t}/projects`,children:[r.jsx(sx,{className:"h-4 w-4"}),r.jsx("span",{children:"Browse Projects"})]})}):Jt.length===0?r.jsx(Et,{title:"No assignments match these filters",description:"Adjust the search term or filters to show assignments across all projects again."}):$==="table"?(()=>{const B=new Set(Ce.hidden),J=me=>me==="title"||!B.has(me);return r.jsx(He,{title:`${Gr.length} assignment${Gr.length===1?"":"s"}`,children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[J("title")?r.jsx(Un,{field:"title",children:"Assignment"}):null,J("status")?r.jsx(Un,{field:"status",children:"Status"}):null,r.jsx("th",{className:"py-2 pr-4 text-xs font-medium uppercase tracking-wider",children:"Type"}),J("priority")?r.jsx(Un,{field:"priority",children:"Priority"}):null,J("assignee")?r.jsx(Un,{field:"assignee",children:"Assignee"}):null,J("dependencies")?r.jsx(Un,{field:"dependencies",children:"Dependencies"}):null,J("created")?r.jsx(Un,{field:"created",children:"Created"}):null,J("updated")?r.jsx(Un,{field:"updated",children:"Updated"}):null]})}),r.jsx("tbody",{children:Gr.map((me,_e)=>r.jsxs(RU,{detailHref:jc(me),className:"cursor-pointer border-b border-border/50 transition hover:bg-muted/40 last:border-0",...Sa(_e),children:[J("title")?r.jsxs("td",{className:"py-4 pr-4",children:[r.jsx(YE,{title:me.title,detailHref:jc(me),onSave:ft=>Ca(me,ft),disabled:ne===ln(me)}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:me.projectTitle??r.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"})}),r.jsxs("p",{className:"mt-0.5 inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:me.id,children:[me.id.slice(0,8),r.jsx(Br,{value:me.id})]})]}):null,J("status")?r.jsx("td",{className:"py-4 pr-4",children:r.jsx("select",{value:me.status,disabled:ne===ln(me),onChange:ft=>Ys({item:me,toColumnId:ft.target.value}),className:we("appearance-none rounded-full border px-2.5 py-0.5 text-xs font-semibold tracking-wide outline-none","cursor-pointer bg-[length:12px] bg-[right_6px_center] bg-no-repeat pr-6",`bg-[url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E")]`,(of[me.status]??of.pending).className,ne===ln(me)&&"animate-pulse opacity-60"),children:j.map(ft=>{const vt=me.status===ft?void 0:Hl(me,ft),Mt=(vt==null?void 0:vt.disabled)??!1;return r.jsx("option",{value:ft,disabled:Mt,title:Mt?(vt==null?void 0:vt.disabledReason)??void 0:void 0,children:v[ft]},ft)})})}):null,r.jsx("td",{className:"py-4 pr-4",children:r.jsx(ga,{type:me.type,compact:!0})}),J("priority")?r.jsx("td",{className:"py-4 pr-4 capitalize text-muted-foreground",children:me.priority}):null,J("assignee")?r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:me.assignee??"Unassigned"}):null,J("dependencies")?r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:me.dependsOn.length}):null,J("created")?r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:zn(me.created)}):null,J("updated")?r.jsx("td",{className:"py-4 text-muted-foreground",children:zn(me.updated)}):null]},ln(me)))})]})})})})():$==="list"?r.jsx("div",{className:"space-y-3",children:sl.map(({id:B,label:J,items:me})=>{var un;if(me.length===0&&!(In&&Ye==="status"))return null;const _e=!Je.has(B),ft=Ye==="status",vt=ft&&In?In.status!==B&&!((un=Hl(In,B))!=null&&un.disabled):!1,Mt=ft&&In?In.status!==B&&!vt:!1,hr=ft&&ae===B;return r.jsxs("div",{className:we("rounded-lg border border-border/60 bg-card/90 transition",hr&&vt&&"ring-2 ring-ring/30",Mt&&"border-dashed opacity-65"),onDragOver:ft?pn=>ds(pn,B):void 0,onDragLeave:ft?pn=>Lo(pn,B):void 0,onDrop:ft?pn=>Oo(pn,B):void 0,children:[r.jsxs("button",{type:"button",onClick:()=>ru(B),className:"flex w-full items-center gap-2 px-4 py-3 text-left",children:[r.jsx(pr,{className:`h-4 w-4 text-muted-foreground transition-transform ${_e?"":"-rotate-90"}`}),r.jsx("span",{className:"font-semibold text-foreground",children:J}),r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:me.length})]}),_e&&me.length>0&&r.jsx("div",{className:"space-y-3 px-4 pb-4",children:me.map(pn=>{const mn=ln(pn),Io=De===mn,su=al.get(mn)??-1,Ea=ft;return r.jsx("div",{draggable:Ea,onDragStart:Ea?fs=>us(fs,mn):void 0,onDragEnd:Ea?Pr:void 0,...su>=0?Sa(su):{},className:we("transition",Ea&&"cursor-grab active:cursor-grabbing",Io&&"scale-[0.98] opacity-50"),children:r.jsx(M0,{assignment:pn,dragging:Io,transitioning:ne===mn,onPillSelect:fs=>void Ys({item:pn,toColumnId:fs.targetStatus,action:fs}),onRenameTitle:fs=>Ca(pn,fs)})},mn)})})]},B)})}):r.jsx(tp,{columns:Ze==="type"?ol:k,items:Jt,getItemId:ln,getColumnId:B=>Ze==="type"?B.type&&m.definitions.some(J=>J.id===B.type)?B.type:S:B.status,canDrop:({item:B,fromColumnId:J,toColumnId:me})=>{if(J===me)return{allowed:!0};const _e=Hl(B,me);return _e!=null&&_e.disabled?{allowed:!1,reason:_e.disabledReason||_e.description}:{allowed:!0,reason:_e?_e.warning||_e.description:`Move to ${me} (direct status change).`}},onMove:Ze==="type"?void 0:({item:B,toColumnId:J})=>Ys({item:B,toColumnId:J}),dragDisabled:Ze==="type",getExternalDragData:B=>B.projectSlug===null?{type:"standalone-assignment",id:B.id}:{type:"project-assignment",id:B.id},onCardContextMenu:(B,J)=>{J.preventDefault(),kt({item:B,anchor:{x:J.clientX,y:J.clientY}})},emptyMessage:B=>`No ${B.title.toLowerCase()} assignments.`,hiddenColumnIds:X.hidden,onHideColumn:B=>Me(J=>({hidden:J.hidden.includes(B)?J.hidden.filter(_e=>_e!==B):[...J.hidden,B]})),renderCard:(B,{dragging:J})=>{const me=al.get(ln(B))??-1;return r.jsx("div",{...me>=0?Sa(me):{},children:r.jsx(M0,{assignment:B,dragging:J,transitioning:ne===ln(B),onPillSelect:_e=>void Ys({item:B,toColumnId:_e.targetStatus,action:_e}),onRenameTitle:_e=>Ca(B,_e)})})}}),r.jsx(xa,{toast:le,onDismiss:fe}),r.jsx(NE,{open:Nt,onOpenChange:B=>{It(B),B||jt(!1)},initialName:en&&bt?`${bt.name} (copy)`:"",title:en?"Save as new view":"Save view",onSubmit:kp}),r.jsx(OE,{open:Le!==null,action:(Le==null?void 0:Le.action)??null,assignmentTitle:(Le==null?void 0:Le.item.title)??"Assignment",loading:ne===(Le?ln(Le.item):null),onOpenChange:B=>{B||at(null)},onConfirm:async B=>{if(!Le)return;const J=Le;await Na({item:J.item,toColumnId:J.toColumnId,action:J.action,reason:B})&&at(null)}}),r.jsx(iC,{anchor:(Be==null?void 0:Be.anchor)??null,items:Be?TU(Be.item,{onEdit:()=>{const B=Be.item,J=B.projectSlug===null?`/assignments/${B.id}`:`${B.projectWorkspace?`/w/${B.projectWorkspace}`:t}/projects/${B.projectSlug}/assignments/${B.slug}`;n(J)},onDelete:()=>_t(Be.item),onMove:()=>Oe(Be.item)}):[],onClose:()=>kt(null)}),r.jsx(ba,{open:St!==null,title:"Delete assignment?",description:St?`"${St.title}" will be permanently removed. This cannot be undone.`:"",confirmLabel:"Delete",destructive:!0,loading:pe!==null,onOpenChange:B=>{!B&&pe===null&&_t(null)},onConfirm:async()=>{if(!St||St.projectSlug===null){_t(null);return}const B=ln(St);te(B);try{const J=await fetch(`/api/projects/${encodeURIComponent(St.projectSlug)}/assignments/${encodeURIComponent(St.slug)}`,{method:"DELETE"});if(!J.ok){const me=await J.json().catch(()=>({}));throw new Error(me.error||"Failed to delete assignment")}_t(null),u()}catch(J){alert(J instanceof Error?J.message:"Failed to delete assignment")}finally{te(null)}}}),r.jsx(cy,{open:xe!==null,onOpenChange:B=>{B||Oe(null)},currentWorkspace:(xe==null?void 0:xe.projectWorkspace)??null,title:"Move assignment to workspace",description:"Standalone assignments belong to a project-workspace via the workspaceGroup frontmatter field.",onSubmit:async B=>{if(!xe)return;const J=await fetch(`/api/assignments/${encodeURIComponent(xe.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:B})});if(!J.ok){const me=await J.json().catch(()=>({}));throw new Error(me.error||"Failed to move assignment")}u()}})]})}function TU(e,t){const n=[{key:"edit",label:"Edit",icon:zi,onSelect:t.onEdit}];return e.projectSlug!==null?n.push({key:"delete",label:"Delete",icon:Tn,destructive:!0,onSelect:t.onDelete}):n.push({key:"move",label:"Move to workspace…",icon:jf,onSelect:t.onMove}),n}function RU({detailHref:e,children:t,className:n,...s}){const o=QE(e);return r.jsx("tr",{...s,ref:o.containerRef,className:n,onMouseDown:o.onMouseDown,onClick:o.onClick,children:t})}function M0({assignment:e,dragging:t,transitioning:n,onPillSelect:s,onRenameTitle:o}){var d;const i=jc(e),c=!!(s&&o),u=QE(i);return r.jsxs("div",{ref:c?u.containerRef:void 0,className:we("vp-card rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",c&&"cursor-pointer"),onMouseDown:c?u.onMouseDown:void 0,onClick:c?u.onClick:void 0,children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[c?r.jsx(YE,{title:e.title,detailHref:i,onSave:o,disabled:n}):r.jsx(Ee,{to:i,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"text-sm text-muted-foreground",children:e.projectTitle??r.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"})}),r.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:e.id??"",children:[(d=e.id)==null?void 0:d.slice(0,8),e.id&&r.jsx(Br,{value:e.id})]})]}),c?r.jsx(yU,{currentStatus:e.status,availableTransitions:e.availableTransitions,onSelect:s,disabled:n,className:"max-w-[150px]"}):r.jsx(bn,{status:e.status,className:"max-w-[150px]"})]}),e.blockedReason?r.jsx("p",{className:"mt-3 rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-sm text-warning-foreground",children:e.blockedReason}):null,r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[r.jsx(ga,{type:e.type}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:e.priority}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:e.assignee??"Unassigned"}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.dependsOn.length," dependencies"]})]}),r.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:[r.jsx("span",{children:n?"Updating":t?"Dragging":"Source-first"}),r.jsx("span",{children:zn(e.updated)})]})]})}function Hl(e,t){return e.availableTransitions.find(n=>n.targetStatus===t)}function ln(e){return e.id||e.slug||"unknown"}function Kr(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?/);if(!t)return{order:[],blocks:new Map,body:e};const n=t[1],s=e.slice(t[0].length),o=n.split(`
|
|
580
|
+
`).trim();return{hasSection:!0,todosMarkdown:o,remaining:i}}function uU({projectSlug:e,dependencies:t,blockedReason:n}){const[s,o]=p.useState(!1);if(t.length===0)return null;const i=t.filter(u=>u.status!=="completed"&&u.status!=="review"),c=i.length===0;return c&&!s?r.jsxs("button",{type:"button",onClick:()=>o(!0),className:"flex w-full items-center gap-2 rounded-lg border border-success-foreground/30 bg-success/70 px-4 py-2.5 text-left transition hover:bg-success",children:[r.jsx(rx,{className:"h-4 w-4 shrink-0 text-success-foreground"}),r.jsxs("span",{className:"text-sm font-medium text-success-foreground",children:["All ",t.length," ",t.length===1?"dependency":"dependencies"," resolved"]}),r.jsx(pr,{className:"ml-auto h-4 w-4 text-success-foreground"})]}):r.jsxs("div",{className:"space-y-3",children:[i.length>0&&r.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-warning-foreground/30 bg-warning px-4 py-3",children:[r.jsx(Ud,{className:"mt-0.5 h-4 w-4 shrink-0 text-warning-foreground"}),r.jsxs("div",{className:"text-sm text-warning-foreground",children:[r.jsxs("strong",{children:[i.length," ",i.length===1?"dependency is":"dependencies are"," not yet completed."]}),n&&r.jsxs("p",{className:"mt-1 text-warning-foreground/80",children:["Blocked reason: ",n]})]})]}),r.jsx(He,{title:"Dependencies",description:`${t.length-i.length} of ${t.length} resolved`,actions:c?r.jsx("button",{type:"button",onClick:()=>o(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:"Collapse"}):void 0,children:r.jsx("div",{className:"divide-y divide-border/40",children:t.map(u=>r.jsxs(Ee,{to:`/projects/${e}/assignments/${u.slug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[r.jsx(bn,{status:u.status}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:u.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:u.slug})]}),u.assignee&&r.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:u.assignee}),r.jsx(Bd,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},u.slug))})})]})}function dU({links:e}){const t=fn();if(e.length===0)return null;const n=e.filter(o=>!o.isReverse),s=e.filter(o=>o.isReverse);return r.jsx(He,{title:"Linked Assignments",description:`${e.length} ${e.length===1?"link":"links"}`,children:r.jsxs("div",{className:"divide-y divide-border/40",children:[n.map(o=>r.jsxs(Ee,{to:`${t}/projects/${o.projectSlug}/assignments/${o.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[r.jsx(Ek,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),r.jsx(bn,{status:o.status}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.slug})]}),r.jsx(Bd,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`fwd-${o.slug}`)),s.map(o=>r.jsxs(Ee,{to:`${t}/projects/${o.projectSlug}/assignments/${o.assignmentSlug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[r.jsx(zd,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),r.jsx(bn,{status:o.status}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.title}),r.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.slug})]}),r.jsx(Bd,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`rev-${o.slug}`))]})})}function fU(e){const t=new Map;for(const s of e)t.set(s.id,{entry:s,replies:[]});const n=[];for(const s of e){const o=t.get(s.id);s.replyTo&&t.has(s.replyTo)?t.get(s.replyTo).replies.push(o):n.push(o)}return n}function pU(e,t){return e===null?`/api/assignments/${encodeURIComponent(t)}/comments`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments`}function qE({projectSlug:e,assignmentSlug:t,entries:n}){const[s,o]=p.useState(n);p.useEffect(()=>{o(n)},[n]);const i=p.useMemo(()=>fU(s),[s]),[c,u]=p.useState(""),[d,m]=p.useState("note"),[h,g]=p.useState(!1),[y,b]=p.useState(null);async function C(v){var S;if(v.preventDefault(),!c.trim())return;g(!0),b(null);const k=`tmp-${Date.now()}`,E={id:k,timestamp:new Date().toISOString(),author:"human",type:d,body:c,resolved:d==="question"?!1:void 0};o(T=>[...T,E]);try{const T=await fetch(pU(e,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:c,type:d})});if(!T.ok){const A=await T.text();throw new Error(A||`HTTP ${T.status}`)}const P=await T.json().catch(()=>null),R=(S=P==null?void 0:P.comment)==null?void 0:S.id;o(A=>A.map($=>$.id===k?{...$,id:R??$.id}:$)),u(""),window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(T){b(T instanceof Error?T.message:String(T)),o(P=>P.filter(R=>R.id!==k))}finally{g(!1)}}async function j(v,k){o(E=>E.map(S=>S.id===v?{...S,resolved:k}:S));try{const E=e===null?`/api/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(v)}/resolved`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(v)}/resolved`,S=await fetch(E,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({resolved:k})});if(!S.ok)throw new Error(`HTTP ${S.status}`);window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(E){b(E instanceof Error?E.message:String(E)),o(S=>S.map(T=>T.id===v?{...T,resolved:!k}:T))}}return r.jsx(He,{title:"Comments",description:"Threaded questions, notes, and feedback. Questions can be resolved once answered.",children:r.jsxs("div",{className:"space-y-4",children:[i.map(v=>r.jsx(GE,{node:v,onToggleResolved:j,depth:0},v.entry.id)),r.jsxs("form",{onSubmit:C,className:"mt-6 space-y-2 border-t border-border pt-4",children:[r.jsx("label",{className:"block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Add comment"}),r.jsx("textarea",{value:c,onChange:v=>u(v.target.value),className:"w-full rounded border border-border bg-background p-2 text-sm",rows:3,placeholder:"Ask a question, leave a note, or give feedback…"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("select",{value:d,onChange:v=>m(v.target.value),className:"rounded border border-border bg-background px-2 py-1 text-xs",children:[r.jsx("option",{value:"note",children:"note"}),r.jsx("option",{value:"question",children:"question"}),r.jsx("option",{value:"feedback",children:"feedback"})]}),r.jsx("button",{type:"submit",disabled:h||!c.trim(),className:"shell-action",children:h?"Posting…":"Post comment"}),y?r.jsx("span",{className:"text-xs text-error-foreground",children:y}):null]})]})]})})}function GE({node:e,depth:t,onToggleResolved:n}){const{entry:s,replies:o}=e,i=s.type==="question";return r.jsxs("div",{className:we("space-y-2",t>0&&"ml-4 border-l border-border pl-4"),children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{className:"font-mono",children:s.id}),r.jsx("span",{children:"·"}),r.jsx("span",{children:s.timestamp}),r.jsx("span",{children:"·"}),r.jsx("span",{className:"font-medium text-foreground",children:s.author}),r.jsx("span",{children:"·"}),r.jsx("span",{className:we("rounded px-1.5 py-0.5 font-mono text-[10px] uppercase",i&&"bg-warning text-warning-foreground",s.type==="feedback"&&"bg-info text-info-foreground",s.type==="note"&&"bg-muted text-muted-foreground"),children:s.type}),i?r.jsxs("button",{type:"button",onClick:()=>n(s.id,!s.resolved),className:we("inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium",s.resolved?"bg-success text-success-foreground hover:bg-success/80":"bg-muted text-muted-foreground hover:bg-muted/80"),title:s.resolved?"Mark unresolved":"Mark resolved",children:[s.resolved?r.jsx(rx,{className:"h-3 w-3"}):r.jsx(BA,{className:"h-3 w-3"}),s.resolved?"resolved":"open"]}):null,s.replyTo?r.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[r.jsx(dP,{className:"h-3 w-3"}),s.replyTo]}):null]}),r.jsx(xn,{content:s.body}),o.length>0?r.jsx("div",{className:"space-y-2",children:o.map(c=>r.jsx(GE,{node:c,depth:t+1,onToggleResolved:n},c.entry.id))}):null]})}const mU=["review","complete","shape","plan-ready","implement","unblock","start","block","fail","reopen"];function $0(){var ut,ae,be,Le,at,Be,kt,St,_t,pe;const{slug:e,aslug:t}=Bt(),n=zt(),s=fn(),[o,i]=ls(),[c,u]=p.useState(null),{toast:d,showToast:m,dismissToast:h}=Ao(),[g,y]=p.useState(null),[b,C]=p.useState(null),[j,v]=p.useState(null),[k,E]=p.useState(null),[S,T]=p.useState(!1),[P,R]=p.useState(!1),[A,$]=p.useState(0),M=o.get("tab")??"summary",_=ha(),{data:D,loading:V,error:K,refetch:I}=y3(e,t),{data:F}=iS(e),{data:q}=hx(),{data:Z,loading:z,error:G}=v3(e,t),{data:L,loading:H,error:re}=j3(e,t),U=p.useMemo(()=>{if(!D||!F)return[];const te=new Map(F.assignments.map(xe=>[xe.slug,xe]));return D.dependsOn.map(xe=>{const Oe=te.get(xe);return{slug:xe,title:(Oe==null?void 0:Oe.title)??xe,status:(Oe==null?void 0:Oe.status)??"pending",priority:(Oe==null?void 0:Oe.priority)??"medium",assignee:(Oe==null?void 0:Oe.assignee)??null}})},[D,F]),ue=U.filter(te=>te.status!=="completed"&&te.status!=="review");Ro("assignment");const ge=p.useMemo(()=>((F==null?void 0:F.assignments)??[]).map(te=>te.slug),[F]),se=t?ge.indexOf(t):-1,ye=se>0?ge[se-1]:null,Se=se>=0&&se<ge.length-1?ge[se+1]:null,Te=`${s}/projects/${e}/assignments/${t}`;Yt({keys:"e",scope:"assignment",description:"Edit assignment",handler:()=>n(`${Te}/edit`)}),Yt({keys:"p",scope:"assignment",description:"Edit plan",handler:()=>n(`${Te}/plan/edit`)}),Yt({keys:"h",scope:"assignment",description:"Append handoff",handler:()=>n(`${Te}/handoff/edit`)}),Yt({keys:"d",scope:"assignment",description:"Append decision record",handler:()=>n(`${Te}/decision-record/edit`)}),Yt({keys:"s",scope:"assignment",description:"Edit scratchpad",handler:()=>n(`${Te}/scratchpad/edit`)}),Yt({keys:"[",scope:"assignment",description:"Previous assignment in project",enabled:!!ye,handler:()=>ye&&n(`${s}/projects/${e}/assignments/${ye}`)}),Yt({keys:"]",scope:"assignment",description:"Next assignment in project",enabled:!!Se,handler:()=>Se&&n(`${s}/projects/${e}/assignments/${Se}`)});const Pe=p.useMemo(()=>D?lU(D.body):{acceptanceCriteria:[],summaryBody:""},[D]),Ke=p.useMemo(()=>cU(Pe.summaryBody),[Pe.summaryBody]),ct=Pe.acceptanceCriteria,et=ct.filter(te=>te.checked).length,ot=ct.length>0&&et===ct.length,X=p.useRef(ot),Me=p.useRef(!1);if(p.useEffect(()=>{if(D){if(!Me.current){X.current=ot,Me.current=!0;return}ot&&!X.current&&$(te=>te+1),X.current=ot}},[ot,D]),V)return r.jsx(xt,{label:"Loading assignment workspace…"});if(K||!D||!e||!t)return r.jsx(Tt,{error:K||"Assignment not found."});const Ce=e,Ie=t,Ye=ct.length>0?{checked:et,total:ct.length}:void 0,Fe=D.availableTransitions??[],Ze=Fe.filter(te=>!te.disabled&&te.targetStatus!==D.status),Je=mU.map(te=>Ze.find(xe=>xe.command===te)).find(Boolean)??Ze[0]??null,Ot=[];if(q!=null&&q.sessions)for(const te of q.sessions)for(const xe of te.windows)for(const Oe of xe.panes)((ut=Oe.assignment)==null?void 0:ut.project)===e&&((ae=Oe.assignment)==null?void 0:ae.slug)===t&&Ot.push({sessionName:te.name,command:Oe.command,urls:Oe.urls});async function yt(te){u(null);try{await RE(Ce,Ie,te),I()}catch(xe){u(xe.message)}}async function dt(te){u(null);try{const xe=await fetch(`/api/projects/${Ce}/assignments/${Ie}/${te?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!xe.ok){const Oe=await xe.json().catch(()=>null);throw new Error((Oe==null?void 0:Oe.error)||`HTTP ${xe.status}`)}I(),m(te?"Assignment archived":"Assignment restored","success")}catch(xe){u(xe.message)}}async function le(){R(!0);try{await U8(Ce,Ie),n(`${s}/projects/${Ce}`)}catch(te){u(te.message),R(!1),T(!1)}}async function Y(te,xe){u(null),y(te.command);try{return await TE(Ce,Ie,te,xe),I(),!0}catch(Oe){return u(Oe.message),!1}finally{y(null)}}function fe(te){if(AE(te)){C(te);return}Y(te)}async function ne(te,xe){v(null),E(te);try{const Oe=await fetch(`/api/projects/${Ce}/assignments/${Ie}/acceptance-criteria/${te}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({checked:xe})}),tt=await Oe.json();if(!Oe.ok)throw new Error(tt.error||`HTTP ${Oe.status}`);I()}catch(Oe){v(Oe.message)}finally{E(null)}}const he=[...Ze.filter(te=>te!==Je).map(te=>({key:`transition-${te.command}`,label:te.label,onSelect:()=>fe(te),disabled:g===te.command})),...Fe.filter(te=>te.disabled||te.targetStatus===D.status).map(te=>({key:`transition-${te.command}`,label:te.label,disabled:!0,disabledReason:te.targetStatus===D.status?`Already ${D.status.replace(/_/g," ")}`:te.disabledReason??te.warning??te.description})),..._.statuses.map(te=>({key:`override-${te.id}`,label:`Override → ${te.label}`,onSelect:()=>yt(te.id),disabled:te.id===D.status,disabledReason:te.id===D.status?"Already in this status":void 0})),{key:"edit-assignment",label:"Edit assignment source",icon:QA,href:`${s}/projects/${e}/assignments/${t}/edit`},{key:"edit-plan",label:"Edit plan",icon:pP,href:`${s}/projects/${e}/assignments/${t}/plan/edit`},{key:"edit-scratchpad",label:"Edit scratchpad",icon:ih,href:`${s}/projects/${e}/assignments/${t}/scratchpad/edit`},{key:"append-handoff",label:"Append handoff",icon:Bd,href:`${s}/projects/${e}/assignments/${t}/handoff/edit`},{key:"append-decision",label:"Append decision",icon:ZA,href:`${s}/projects/${e}/assignments/${t}/decision-record/edit`},{key:D.archived?"unarchive":"archive",label:D.archived?"Restore assignment":"Archive assignment",icon:D.archived?Fd:wf,onSelect:()=>dt(!D.archived)},{key:"delete",label:"Delete assignment",icon:Tn,destructive:!0,onSelect:()=>T(!0)}],De=(Je==null?void 0:Je.command)==="review";return r.jsxs("div",{className:"space-y-5",children:[r.jsx(xa,{toast:d,onDismiss:h}),r.jsxs("div",{className:"sticky top-12 z-20 rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm backdrop-blur",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(bn,{status:D.status,progress:Ye}),D.phase&&D.phase!==D.status&&r.jsxs("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-[11px] text-muted-foreground",title:"Phase dimension — how far along the work is, independent of blockage",children:["phase: ",D.phase]}),D.disposition&&D.disposition!=="active"&&r.jsx("span",{className:"rounded-full border border-warning-foreground/40 px-2 py-0.5 text-[11px] text-warning-foreground",title:"Disposition dimension — orthogonal to phase",children:D.disposition}),r.jsx(ga,{type:D.type}),r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:D.title}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Updated ",Wk(D.updated)]}),ue.length>0&&r.jsxs("span",{className:"text-xs text-warning-foreground",children:["⚠ ",ue.length," unmet dep",ue.length===1?"":"s"]}),r.jsx(uy,{externalIds:D.externalIds}),r.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[r.jsx(WE,{target:{kind:"assignment",id:D.id},worktreePath:((be=D.workspace)==null?void 0:be.worktreePath)??null,repository:((Le=D.workspace)==null?void 0:Le.repository)??null}),!((at=D.workspace)!=null&&at.worktreePath)&&e&&t&&r.jsx(KE,{projectSlug:e,assignmentSlug:t,defaultBranch:`syntaur/${e}/${t}`,onCreated:()=>I()}),Je&&r.jsx("button",{type:"button",title:Je.warning||Je.description,disabled:g===Je.command,onClick:()=>fe(Je),className:we("shell-action disabled:cursor-not-allowed disabled:opacity-50",Je.warning&&"border-warning-foreground/40",De&&A>0&&"send-to-review-glow"),children:r.jsx("span",{children:g===Je.command?"Working…":Je.label})},De?`review-${A}`:Je.command),r.jsx(ry,{items:he,align:"end"})]})]}),c?r.jsx("p",{className:"mt-4 rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:c}):null,D.blockedReason?r.jsxs("div",{className:"mt-4 rounded-md border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:[r.jsx("strong",{children:"Blocked reason:"})," ",D.blockedReason]}):null,D.override&&D.derived&&D.derived.derivedStatus!==D.status?r.jsxs("div",{className:"mt-4 rounded-md border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:[r.jsxs("strong",{children:["Pinned to ",D.status]})," by ",D.override.source,D.override.reason?r.jsxs(r.Fragment,{children:[" — “",D.override.reason,"”"]}):null," · ","would otherwise be ",r.jsx("strong",{children:D.derived.derivedStatus})]}):null,(Be=D.derived)!=null&&Be.nextAction?r.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:[r.jsx("span",{className:"font-medium text-foreground",children:"Next:"})," ",D.derived.nextAction]}):null]}),D.derived&&(Object.keys(D.derived.customFacts??{}).length>0||(D.derived.attestations??[]).length>0)?r.jsx(He,{title:"Facts",description:"Custom asserted facts and review attestations, materialized server-side.",children:r.jsxs("div",{className:"space-y-3",children:[Object.keys(D.derived.customFacts??{}).length>0&&r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Object.entries(D.derived.customFacts??{}).map(([te,xe])=>r.jsxs("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-[11px] text-muted-foreground",children:[te,": ",r.jsx("span",{className:"font-medium text-foreground",children:String(xe)})]},te))}),(D.derived.attestations??[]).map(te=>r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("span",{className:"text-[11px] font-medium text-foreground",children:te.fact}),r.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["(",te.binds,")"]}),te.records.length===0?r.jsx("span",{className:"text-[11px] text-muted-foreground",children:"— no attestations yet"}):te.records.map(xe=>r.jsxs("span",{title:`${xe.verdict}${xe.note?` — ${xe.note}`:""}${xe.stale?" (stale — revision moved)":""} · ${xe.at}`,className:we("rounded-full border px-2 py-0.5 text-[11px]",xe.stale?"border-border/40 text-muted-foreground line-through":xe.verdict==="approved"?"border-success-foreground/40 text-success-foreground":"border-warning-foreground/40 text-warning-foreground"),children:[xe.actor,": ",xe.verdict==="approved"?"approved":"changes",xe.stale?" (stale)":""]},xe.actor))]},te.fact))]})}):null,U.length>0&&r.jsx(uU,{projectSlug:e,dependencies:U,blockedReason:D.blockedReason}),D.enrichedLinks&&D.enrichedLinks.length>0&&r.jsx(dU,{links:D.enrichedLinks}),D.referencedBy&&D.referencedBy.length>0&&r.jsx(He,{title:"Referenced by",description:"Other assignments whose Todos, progress, comments, or handoffs link to this one.",children:r.jsx("ul",{className:"space-y-2",children:D.referencedBy.map(te=>{const xe=te.sourceProjectSlug===null?`/assignments/${te.sourceId}`:`${s}/projects/${te.sourceProjectSlug}/assignments/${te.sourceSlug}`;return r.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[r.jsx(Ee,{to:xe,className:"text-foreground hover:text-primary",children:te.sourceTitle}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",te.mentions," mention",te.mentions===1?"":"s",")"]}),te.sourceProjectSlug===null?r.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"}):null]},te.sourceId)})})}),r.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]",children:[r.jsx("div",{className:"space-y-4",children:r.jsx(fy,{value:M,onValueChange:te=>i({tab:te}),items:[{value:"summary",label:"Summary",content:r.jsxs("div",{className:"space-y-5",children:[Pe.acceptanceCriteria.length>0?r.jsx(He,{title:"Acceptance Criteria",description:"These checkboxes update the source assignment markdown.",children:r.jsxs("div",{className:"space-y-3",children:[j?r.jsx("p",{className:"rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:j}):null,Pe.acceptanceCriteria.map((te,xe)=>{const Oe=k!==null;return r.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-border/60 bg-background/80 px-3 py-3",children:[r.jsx("input",{type:"checkbox",checked:te.checked,disabled:Oe,onChange:tt=>ne(xe,tt.target.checked),className:"mt-1 h-4 w-4 rounded border-border text-primary"}),r.jsx("span",{className:"criterion-label text-sm leading-6","data-checked":te.checked,children:te.text})]},`${xe}-${te.text}`)})]})}):null,Ke.hasSection?r.jsx(He,{title:"Todos",description:"Checklist of work items from assignment.md. Links point to plan files.",children:r.jsx(xn,{content:Ke.todosMarkdown,emptyState:"No todos yet."})}):null,r.jsx(He,{title:"Assignment Summary",children:r.jsx(xn,{content:Ke.remaining,emptyState:Pe.acceptanceCriteria.length>0||Ke.hasSection?"No additional summary markdown beyond the acceptance criteria and todos.":"This assignment does not have summary markdown yet."})})]})},{value:"plan",label:"Plan",count:D.plan?1:0,content:D.plan?r.jsx("div",{className:"space-y-5",children:r.jsxs(He,{title:"Plan",description:"Shows plan.md only. Versioned plans (plan-v2.md, ...) linked from the Todos section are not yet rendered here — open them from the filesystem.",actions:r.jsxs(Ee,{className:"shell-action",to:`${s}/projects/${e}/assignments/${t}/plan/edit`,children:[r.jsx(ih,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit Plan"})]}),children:[r.jsx("div",{className:"mb-4",children:r.jsx(bn,{status:D.plan.status})}),r.jsx(xn,{content:D.plan.body,emptyState:"No plan content yet."})]})}):r.jsx(Et,{title:"No plan yet",description:"Plan files are optional and versioned. Run /plan-assignment to create plan.md (or plan-v2.md, ...) and link it from the Todos section."})},{value:"scratchpad",label:"Scratchpad",count:D.scratchpad?1:0,content:D.scratchpad?r.jsx(He,{title:"Scratchpad",actions:r.jsxs(Ee,{className:"shell-action",to:`${s}/projects/${e}/assignments/${t}/scratchpad/edit`,children:[r.jsx(ih,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit Scratchpad"})]}),children:r.jsx(xn,{content:D.scratchpad.body,emptyState:"Scratchpad is empty."})}):r.jsx(Et,{title:"No scratchpad yet",description:"Scratchpad notes appear here when you use the Edit Scratchpad action."})},{value:"handoff",label:"Handoff",count:((kt=D.handoff)==null?void 0:kt.handoffCount)??0,content:r.jsx("div",{className:"space-y-5",children:D.handoff?r.jsx(He,{children:r.jsx(xn,{content:D.handoff.body,emptyState:"No handoff history yet."})}):r.jsx(Et,{title:"No handoff log yet",description:"Handoffs appear here when an agent runs /complete-assignment or you append one manually."})})},{value:"progress",label:"Progress",count:((St=D.progress)==null?void 0:St.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:D.progress&&D.progress.entries.length>0?r.jsx(He,{title:"Progress",description:"Reverse-chronological log of work done on this assignment. Agents append entries via progress.md.",children:r.jsx("ol",{className:"space-y-4",children:D.progress.entries.map((te,xe)=>r.jsxs("li",{className:"border-l-2 border-border pl-3",children:[r.jsx("div",{className:"text-xs font-mono text-muted-foreground",children:te.timestamp}),r.jsx(xn,{content:te.body})]},`${te.timestamp}-${xe}`))})}):r.jsx(Et,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((_t=D.comments)==null?void 0:_t.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:D.comments&&D.comments.entries.length>0?r.jsx(qE,{projectSlug:e,assignmentSlug:t,entries:D.comments.entries}):r.jsx(Et,{title:"No comments yet",description:"Comments appear here when agents or humans post via `syntaur comment` or the dashboard."})})},{value:"decisions",label:"Decisions",count:((pe=D.decisionRecord)==null?void 0:pe.decisionCount)??0,content:r.jsx("div",{className:"space-y-5",children:D.decisionRecord?r.jsx(He,{children:r.jsx(xn,{content:D.decisionRecord.body,emptyState:"No decision history yet."})}):r.jsx(Et,{title:"No decision record yet",description:"Decision records appear here when you append one via the Append Decision action."})})}]})}),r.jsxs("div",{className:"min-w-0 space-y-5",children:[r.jsx(He,{title:"Details",children:r.jsxs("dl",{className:"space-y-3 text-sm",children:[r.jsx(ho,{label:"ID",value:D.id,copyable:!0}),r.jsx(ho,{label:"Priority",value:D.priority}),D.assignee&&r.jsx(ho,{label:"Assignee",value:D.assignee}),r.jsx(ho,{label:"Updated",value:`${Hk(D.updated)} · Created ${Vk(D.created)}`}),D.workspace.repository&&r.jsx(ho,{label:"Repository",value:D.workspace.repository,copyable:!0}),D.workspace.worktreePath&&r.jsx(ho,{label:"Worktree",value:D.workspace.worktreePath,copyable:!0}),D.workspace.branch&&r.jsx(ho,{label:"Branch",value:D.workspace.branch,copyable:!0}),D.workspace.parentBranch&&r.jsx(ho,{label:"Parent branch",value:D.workspace.parentBranch,copyable:!0}),D.externalIds.map((te,xe)=>r.jsx(hU,{entry:te},`${te.system}:${te.id}:${xe}`))]})}),Ot.length>0&&r.jsx(He,{title:"Servers",children:r.jsx("div",{className:"space-y-2",children:Ot.map((te,xe)=>r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-sm",children:[r.jsx("span",{className:"min-w-0 max-w-full truncate rounded bg-muted/60 px-1.5 py-0.5 font-mono text-xs",title:te.command,children:te.command}),r.jsx("span",{className:"min-w-0 max-w-full truncate text-xs text-muted-foreground",title:te.sessionName,children:te.sessionName}),te.urls.map(Oe=>r.jsxs("a",{href:Oe,target:"_blank",rel:"noopener noreferrer",title:Oe,className:"inline-flex min-w-0 max-w-full items-center gap-1 rounded border border-primary/30 bg-primary/5 px-1.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/10 dark:border-primary/40 dark:bg-primary/10 dark:hover:bg-primary/20",children:[r.jsx("span",{className:"min-w-0 truncate",children:Oe.replace("http://localhost:",":")}),r.jsx(Mi,{className:"h-2.5 w-2.5 shrink-0"})]},Oe))]},xe))})}),r.jsx($E,{sessions:Z==null?void 0:Z.sessions,loading:z,error:G,onError:te=>m(te.message,"error"),onNotice:te=>m(te,"success")}),r.jsx(LE,{summary:L==null?void 0:L.summary,loading:H,error:re})]})]}),r.jsx(OE,{open:b!==null,action:b,assignmentTitle:D.title,loading:g===(b==null?void 0:b.command),onOpenChange:te=>{te||C(null)},onConfirm:async te=>{if(!b)return;await Y(b,te)&&C(null)}}),r.jsx(ba,{open:S,title:"Delete assignment?",description:`This will permanently delete "${D.title}" and all its files (plan, scratchpad, handoff, decision record). This cannot be undone.`,confirmLabel:"Delete Assignment",destructive:!0,loading:P,onOpenChange:te=>{te||T(!1)},onConfirm:le})]})}function ho({label:e,value:t,copyable:n}){return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e}),r.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[r.jsx("span",{className:"block min-w-0 truncate",title:t,children:t}),n&&t!=="—"&&r.jsx(Br,{value:t})]})]})}function hU({entry:e}){const t=e.url!=null&&e.url.length>0;return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e.system}),r.jsx("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:t?r.jsxs("a",{href:e.url??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${e.system}:${e.id} in ${e.system}`,className:"flex items-center gap-1.5 min-w-0 text-primary hover:underline",children:[r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id}),r.jsx(Mi,{className:"h-2.5 w-2.5 shrink-0"})]}):r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id})})]})}function gU(){var R,A,$,M,_,D,V,K;const{id:e}=Bt(),[t,n]=ls(),s=t.get("tab")??"summary",{data:o,loading:i,error:c,refetch:u}=b3(e),{data:d,loading:m,error:h}=w3(e),{data:g,loading:y,error:b}=k3(o==null?void 0:o.slug),[C,j]=p.useState(!1),[v,k]=p.useState(null),{toast:E,showToast:S,dismissToast:T}=Ao();async function P(I){if(e){k(null);try{const F=await fetch(`/api/assignments/${e}/${I?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!F.ok){const q=await F.json().catch(()=>null);throw new Error((q==null?void 0:q.error)||`HTTP ${F.status}`)}u(),S(I?"Assignment archived":"Assignment restored","success")}catch(F){k(F instanceof Error?F.message:"Archive failed")}}}return i?r.jsx(xt,{}):c?r.jsx(Tt,{error:c}):o?r.jsxs("div",{className:"space-y-6",children:[r.jsx(xa,{toast:E,onDismiss:T}),r.jsxs("header",{className:"space-y-2",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(bn,{status:o.status}),r.jsx(ga,{type:o.type}),r.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:o.id}),r.jsx(uy,{externalIds:o.externalIds}),r.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[r.jsx(WE,{target:{kind:"assignment",id:o.id},worktreePath:((R=o.workspace)==null?void 0:R.worktreePath)??null,repository:((A=o.workspace)==null?void 0:A.repository)??null,size:"compact"}),!(($=o.workspace)!=null&&$.worktreePath)&&r.jsx(KE,{assignmentId:o.id,defaultBranch:`syntaur/${o.slug}`,onCreated:()=>u()}),r.jsxs("button",{type:"button",onClick:()=>j(!0),className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:[r.jsx(jf,{className:"h-3 w-3"}),"Move to workspace…"]}),r.jsx(Ee,{to:`/assignments/${o.id}/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit"}),r.jsxs("button",{type:"button",onClick:()=>P(!o.archived),className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",title:o.archived?"Restore this assignment":"Archive this assignment",children:[o.archived?r.jsx(Fd,{className:"h-3 w-3"}):r.jsx(wf,{className:"h-3 w-3"}),o.archived?"Restore":"Archive"]})]})]}),r.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:o.title}),o.blockedReason?r.jsxs("p",{className:"text-sm text-warning-foreground",children:["Blocked: ",o.blockedReason]}):null,v?r.jsx("p",{className:"text-sm text-status-failed-foreground",children:v}):null]}),o.referencedBy&&o.referencedBy.length>0?r.jsx(He,{title:"Referenced by",description:"Other assignments whose bodies link to this one.",children:r.jsx("ul",{className:"space-y-2",children:o.referencedBy.map(I=>r.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[r.jsx(Ee,{to:I.sourceProjectSlug===null?`/assignments/${I.sourceId}`:`/projects/${I.sourceProjectSlug}/assignments/${I.sourceSlug}`,className:"text-foreground hover:text-primary",children:I.sourceTitle}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",I.mentions," mention",I.mentions===1?"":"s",")"]})]},I.sourceId))})}):null,r.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]",children:[r.jsx("div",{className:"space-y-4",children:r.jsx(fy,{value:s,onValueChange:I=>n({tab:I}),items:[{value:"summary",label:"Summary",content:r.jsx("div",{className:"space-y-5",children:r.jsx(He,{title:"Assignment",children:r.jsx(xn,{content:o.body,emptyState:"This assignment does not have summary markdown yet."})})})},{value:"progress",label:"Progress",count:((M=o.progress)==null?void 0:M.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:o.progress&&o.progress.entries.length>0?r.jsx(He,{title:"Progress",description:"Reverse-chronological log of work done on this assignment.",children:r.jsx("ol",{className:"space-y-4",children:o.progress.entries.map((I,F)=>r.jsxs("li",{className:"border-l-2 border-border pl-3",children:[r.jsx("div",{className:"text-xs font-mono text-muted-foreground",children:I.timestamp}),r.jsx(xn,{content:I.body})]},`${I.timestamp}-${F}`))})}):r.jsx(Et,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((_=o.comments)==null?void 0:_.entryCount)??0,content:r.jsx("div",{className:"space-y-5",children:r.jsx(qE,{projectSlug:null,assignmentSlug:o.id,entries:((D=o.comments)==null?void 0:D.entries)??[]})})},{value:"plan",label:"Plan",content:r.jsx("div",{className:"space-y-5",children:o.plan?r.jsxs(He,{children:[r.jsx(xn,{content:o.plan.body,emptyState:"Plan file exists but is empty."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${o.id}/plan/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit plan"})})]}):r.jsx(Et,{title:"No plan file yet",description:"Create one via the CLI or `/plan-assignment`."})})},{value:"scratchpad",label:"Scratchpad",content:r.jsx("div",{className:"space-y-5",children:o.scratchpad?r.jsxs(He,{children:[r.jsx(xn,{content:o.scratchpad.body,emptyState:"Scratchpad is empty."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${o.id}/scratchpad/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Edit scratchpad"})})]}):r.jsx(Et,{title:"No scratchpad yet",description:"Scratchpad is scaffolded at assignment creation time."})})},{value:"handoff",label:"Handoff",count:((V=o.handoff)==null?void 0:V.handoffCount)??0,content:r.jsx("div",{className:"space-y-5",children:o.handoff?r.jsxs(He,{children:[r.jsx(xn,{content:o.handoff.body,emptyState:"No handoff history yet."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${o.id}/handoff/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Append handoff"})})]}):r.jsx(Et,{title:"No handoff log yet",description:"Handoffs appear here when an agent appends one."})})},{value:"decisions",label:"Decisions",count:((K=o.decisionRecord)==null?void 0:K.decisionCount)??0,content:r.jsx("div",{className:"space-y-5",children:o.decisionRecord?r.jsxs(He,{children:[r.jsx(xn,{content:o.decisionRecord.body,emptyState:"No decision history yet."}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(Ee,{to:`/assignments/${o.id}/decision-record/edit`,className:"rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:border-foreground/40 hover:text-foreground",children:"Append decision"})})]}):r.jsx(Et,{title:"No decision record yet",description:"Decision records appear here once appended."})})}]})}),r.jsxs("div",{className:"min-w-0 space-y-5",children:[r.jsx(He,{title:"Details",children:r.jsxs("dl",{className:"space-y-3 text-sm",children:[r.jsx(go,{label:"ID",value:o.id,copyable:!0}),r.jsx(go,{label:"Priority",value:o.priority}),o.assignee&&r.jsx(go,{label:"Assignee",value:o.assignee}),r.jsx(go,{label:"Updated",value:`${Hk(o.updated)} · Created ${Vk(o.created)}`}),o.workspace.repository&&r.jsx(go,{label:"Repository",value:o.workspace.repository,copyable:!0}),o.workspace.worktreePath&&r.jsx(go,{label:"Worktree",value:o.workspace.worktreePath,copyable:!0}),o.workspace.branch&&r.jsx(go,{label:"Branch",value:o.workspace.branch,copyable:!0}),o.workspace.parentBranch&&r.jsx(go,{label:"Parent branch",value:o.workspace.parentBranch,copyable:!0}),o.externalIds.map((I,F)=>r.jsx(xU,{entry:I},`${I.system}:${I.id}:${F}`))]})}),r.jsx($E,{sessions:d==null?void 0:d.sessions,loading:m,error:h,onError:I=>S(I.message,"error"),onNotice:I=>S(I,"success")}),r.jsx(LE,{summary:g==null?void 0:g.summary,loading:y,error:b})]})]}),r.jsx(cy,{open:C,onOpenChange:j,currentWorkspace:o.projectWorkspace,title:"Move assignment to workspace",description:"Standalone assignments belong to a project-workspace via the workspaceGroup frontmatter field.",onSubmit:async I=>{const F=await fetch(`/api/assignments/${encodeURIComponent(o.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:I})});if(!F.ok){const q=await F.json().catch(()=>({}));throw new Error(q.error||"Failed to move assignment")}u()}})]}):r.jsx(Tt,{error:"Assignment not found"})}function go({label:e,value:t,copyable:n}){return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e}),r.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[r.jsx("span",{className:"truncate",title:t,children:t}),n&&t!=="—"&&r.jsx(Br,{value:t})]})]})}function xU({entry:e}){const t=e.url!=null&&e.url.length>0;return r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("dt",{className:"text-muted-foreground",children:e.system}),r.jsx("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:t?r.jsxs("a",{href:e.url??void 0,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${e.system}:${e.id} in ${e.system}`,className:"flex items-center gap-1.5 min-w-0 text-primary hover:underline",children:[r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id}),r.jsx(Mi,{className:"h-2.5 w-2.5 shrink-0"})]}):r.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id})})]})}function yU({currentStatus:e,availableTransitions:t,onSelect:n,disabled:s=!1,className:o}){const[i,c]=p.useState(!1),[u,d]=p.useState(null),[m,h]=p.useState(0),g=p.useRef(null),y=p.useRef(null),b=p.useId(),C=af(e),j=C.icon,v=p.useCallback(P=>{c(!1),P&&requestAnimationFrame(()=>{var R;(R=g.current)==null||R.focus()})},[]),k=p.useCallback(()=>{var R;const P=(R=g.current)==null?void 0:R.getBoundingClientRect();P&&d({top:P.top,left:P.left,width:P.width,bottom:P.bottom})},[]);p.useLayoutEffect(()=>{i&&k()},[i,k]),p.useEffect(()=>{if(!i)return;const P=()=>k();return window.addEventListener("scroll",P,!0),window.addEventListener("resize",P),()=>{window.removeEventListener("scroll",P,!0),window.removeEventListener("resize",P)}},[i,k]),p.useEffect(()=>{if(!i)return;const P=R=>{var $,M;const A=R.target;A&&(($=y.current)!=null&&$.contains(A)||(M=g.current)!=null&&M.contains(A)||v(!1))};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[i,v]),p.useEffect(()=>{i&&h(0)},[i,t.length]);function E(P){(P.key==="Enter"||P.key===" "||P.key==="ArrowDown")&&(P.preventDefault(),c(!0))}function S(P){if(t.length===0){P.key==="Escape"&&(P.preventDefault(),v(!0));return}if(P.key==="ArrowDown")P.preventDefault(),h(R=>(R+1)%t.length);else if(P.key==="ArrowUp")P.preventDefault(),h(R=>(R-1+t.length)%t.length);else if(P.key==="Home")P.preventDefault(),h(0);else if(P.key==="End")P.preventDefault(),h(t.length-1);else if(P.key==="Enter"){P.preventDefault();const R=t[m];R&&(n(R),v(!0))}else P.key==="Escape"&&(P.preventDefault(),v(!0))}function T(P){n(P),v(!1)}return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:g,type:"button","data-no-drag":!0,disabled:s,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?b:void 0,onClick:()=>{s||c(P=>!P)},onKeyDown:E,title:`Status: ${C.label}. Click to change.`,className:we(YN(e,o),"cursor-pointer transition hover:brightness-95 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",s&&"cursor-not-allowed opacity-60"),children:[r.jsx(j,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"min-w-0 truncate",children:C.label})]}),i&&u&&typeof document<"u"?Fs.createPortal(r.jsx("div",{ref:y,id:b,role:"menu",tabIndex:-1,autoFocus:!0,onKeyDown:S,style:{position:"fixed",top:u.bottom+6,left:u.left,minWidth:Math.max(u.width,180),zIndex:60},className:"rounded-md border border-border/70 bg-popover py-1 text-sm text-popover-foreground shadow-lg",children:t.length===0?r.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No transitions available from this status."}):t.map((P,R)=>{const A=af(P.targetStatus),$=A.icon,M=R===m;return r.jsxs("button",{type:"button",role:"menuitem","data-no-drag":!0,onMouseEnter:()=>h(R),onClick:()=>T(P),title:P.warning||P.description,className:we("flex w-full flex-col items-stretch gap-0.5 px-3 py-1.5 text-left text-sm transition",M?"bg-foreground/5":"hover:bg-foreground/5"),children:[r.jsxs("span",{className:"flex items-center justify-between gap-2",children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[r.jsx($,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate",children:P.label})]}),r.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:A.label})]}),P.warning?r.jsx("span",{className:"text-[11px] leading-snug text-warning-foreground",children:P.warning}):null]},`${P.command}:${P.targetStatus}`)})}),document.body):null]})}function YE({title:e,detailHref:t,onSave:n,disabled:s=!1}){const[o,i]=p.useState(!1);return o?r.jsx(bU,{initialTitle:e,disabled:s,onSave:n,onExit:()=>i(!1)}):r.jsxs("div",{className:"group flex items-baseline gap-1.5",children:[r.jsx("button",{type:"button","data-no-drag":!0,disabled:s,onClick:()=>{s||i(!0)},className:we("text-left text-base font-semibold text-foreground transition hover:text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 rounded-sm",s&&"cursor-not-allowed opacity-60"),title:"Click to rename",children:e}),r.jsx(Ee,{to:t,"data-no-drag":!0,"aria-label":"Open detail page",title:"Open detail page",onClick:c=>c.stopPropagation(),className:"text-muted-foreground opacity-0 transition group-hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 rounded-sm",children:r.jsx(Mi,{className:"h-3.5 w-3.5"})})]})}function bU({initialTitle:e,disabled:t,onSave:n,onExit:s}){const o=p.useRef(e),[i,c]=p.useState(e),[u,d]=p.useState(!1),[m,h]=p.useState(!1),g=p.useRef(null),y=p.useRef(!1);p.useEffect(()=>{const v=g.current;v&&(v.focus(),v.select())},[]);const b=p.useCallback(()=>{var v;h(!0),window.setTimeout(()=>h(!1),260),(v=g.current)==null||v.focus()},[]),C=p.useCallback(async()=>{if(y.current)return;const v=i.trim();if(v.length===0){b();return}if(v===o.current){s();return}y.current=!0,d(!0);try{await n(v)}catch{}finally{d(!1),s()}},[i,s,n,b]);function j(v){v.key==="Enter"?(v.preventDefault(),C()):v.key==="Escape"&&(v.preventDefault(),y.current=!0,s())}return r.jsx("input",{ref:g,type:"text","data-no-drag":!0,disabled:t||u,value:i,onChange:v=>c(v.target.value),onKeyDown:j,onBlur:()=>void C(),className:we("w-full rounded-sm border border-border bg-background px-1.5 py-0.5 text-base font-semibold text-foreground outline-none transition focus:border-ring focus:ring-1 focus:ring-ring",m&&"syntaur-input-shake",u&&"opacity-70")})}function QE(e){const t=zt(),n=p.useRef(null),s=p.useRef(!1),o=p.useCallback(()=>{const c=n.current,u=!!(c!=null&&c.querySelector('[aria-expanded="true"]')),d=!!document.querySelector('[role="menu"]'),m=document.activeElement,h=!!(m&&(c!=null&&c.contains(m))&&(m.tagName==="INPUT"||m.tagName==="TEXTAREA"));s.current=u||d||h},[]),i=p.useCallback(c=>{if(s.current)return;const u=c.target;!u||u.closest(Li)||t(e)},[t,e]);return{containerRef:n,onMouseDown:o,onClick:i}}const L0=/[A-Za-z0-9_-]/;function O0(e,t){const n=Math.max(0,Math.min(t,e.length)),s=vU(e,n);if(s)return s;let o=n;for(;o>0&&L0.test(e[o-1]);)o--;let i=n;for(;i<e.length&&L0.test(e[i]);)i++;const c=e.slice(o,n),u=e.slice(0,o),d=u.match(/([A-Za-z_][A-Za-z0-9_-]*)\s*(:|>=|<=|!=|=|>|<)\s*$/);if(d)return{kind:"value",field:d[1].toLowerCase(),partial:c,tokenStart:o,tokenEnd:i};const m=u.match(/([A-Za-z_][A-Za-z0-9_-]*)\s*:\s*\([^)]*,\s*$/);return m?{kind:"value",field:m[1].toLowerCase(),partial:c,tokenStart:o,tokenEnd:i}:{kind:"field",partial:c,tokenStart:o,tokenEnd:i}}function vU(e,t){let n=-1;for(let d=t-1;d>=0;d--)if(e[d]==='"'&&(d===0||e[d-1]!=="\\")){n=d;break}if(n<0)return null;for(let d=n+1;d<t;d++)if(e[d]==='"'&&e[d-1]!=="\\")return null;let s=t;for(;s<e.length&&!(e[s]==='"'&&e[s-1]!=="\\");)s++;const o=e.slice(n+1,t),c=e.slice(0,n).match(/([A-Za-z_][A-Za-z0-9_-]*)\s*(:|>=|<=|!=|=|>|<)\s*$/);return{kind:"value",field:c?c[1].toLowerCase():"",partial:o,tokenStart:n,tokenEnd:s<e.length?s+1:s}}function wU(e,t){const n=GN(t),s=e.toLowerCase();if(s==="")return n;const o=[],i=[];for(const c of n){const u=c.toLowerCase();u.startsWith(s)?o.push(c):u.includes(s)&&i.push(c)}return[...o,...i]}function jU(e,t,n,s){const o=e.toLowerCase();let i=[];switch(o){case"status":i=[...n.statuses];break;case"priority":i=[...n.priorities];break;case"type":i=[...n.types];break;case"assignee":i=["none",...n.assignees];break;case"project":i=["none",...n.projects];break;case"tag":case"tags":i=[...n.tags];break;case"archived":case"pinned":case"blocked":case"parked":i=["true","false"];break;default:{const u=s[o];(u==null?void 0:u.kind)==="bool"&&(i=["true","false"]);break}}if(!i.length)return[];const c=t.toLowerCase();return c===""?i:i.filter(u=>u.toLowerCase().startsWith(c))}function kU(e,t,n){let s;return t.kind==="field"?s=`${n}:`:s=eN(n),{text:e.slice(0,t.tokenStart)+s+e.slice(t.tokenEnd),caret:t.tokenStart+s.length}}const SU=180;function NU(e,t){const[n,s]=p.useState(e);return p.useEffect(()=>{const o=setTimeout(()=>s(e),t);return()=>clearTimeout(o)},[e,t]),n}function CU({value:e,onChange:t,onCompiled:n,registry:s,declarations:o,valueSources:i,placeholder:c="AQL query (e.g. status:active AND priority:high)",className:u}){const d=p.useRef(null),m=p.useRef(null),h=NU(e,SU),[g,y]=p.useState([]),[b,C]=p.useState([]),[j,v]=p.useState("field"),[k,E]=p.useState(-1),[S,T]=p.useState(!1),P=p.useRef(e.length);p.useEffect(()=>{if(h.trim()===""){y([]),n==null||n(null);return}const I=Vx(h,s);I.errors.length>0?(y(I.errors),n==null||n(null)):(y([]),n==null||n(I.query))},[h,s,n]);const R=p.useCallback((I,F)=>{const q=O0(I,F);if(!q){C([]),T(!1);return}if(q.kind==="field"){const Z=wU(q.partial,o);C(Z),v("field"),T(Z.length>0)}else{const Z=jU(q.field,q.partial,i,s);C(Z),v("value"),T(Z.length>0)}E(-1)},[o,i,s]),A=p.useCallback(I=>{const F=I.target.value,q=I.target.selectionStart??F.length;P.current=q,t(F),R(F,q)},[t,R]),$=p.useCallback(I=>{const F=d.current,q=(F==null?void 0:F.selectionStart)??P.current,Z=O0(e,q);if(!Z)return;const{text:z,caret:G}=kU(e,Z,I);t(z),T(!1),C([]),requestAnimationFrame(()=>{d.current&&(d.current.focus(),d.current.setSelectionRange(G,G),P.current=G)})},[e,t]),M=p.useCallback(I=>{if(!(!S||b.length===0))switch(I.key){case"ArrowDown":I.preventDefault(),E(F=>Math.min(F+1,b.length-1));break;case"ArrowUp":I.preventDefault(),E(F=>Math.max(F-1,-1));break;case"Enter":case"Tab":k>=0&&(I.preventDefault(),$(b[k]));break;case"Escape":T(!1),C([]);break}},[S,b,k,$]),_=p.useRef(null),D=p.useCallback(()=>{_.current=setTimeout(()=>T(!1),120)},[]);p.useEffect(()=>()=>{_.current!==null&&clearTimeout(_.current)},[]);const V=p.useCallback(()=>{var F;const I=((F=d.current)==null?void 0:F.selectionStart)??e.length;R(e,I)},[e,R]);p.useEffect(()=>{var I,F;S&&((F=(I=m.current)==null?void 0:I.querySelector('[aria-selected="true"]'))==null||F.scrollIntoView({block:"nearest"}))},[k,S]);const K=g.length>0&&h.trim()!=="";return r.jsxs("div",{className:`relative flex flex-col gap-1 ${u??""}`,children:[r.jsx("input",{ref:d,type:"text",value:e,onChange:A,onKeyDown:M,onBlur:D,onFocus:V,placeholder:c,"aria-label":"AQL query input","aria-expanded":S,"aria-haspopup":"listbox","aria-autocomplete":"list",autoComplete:"off",spellCheck:!1,className:["h-9 w-full rounded-md border bg-background px-3 py-1.5 font-mono text-sm text-foreground outline-none transition",K?"border-destructive focus:border-destructive focus:ring-2 focus:ring-destructive/30":"border-border/60 focus:border-primary focus:ring-2 focus:ring-ring/30"].join(" ")}),S&&b.length>0&&r.jsx("ul",{ref:m,role:"listbox","aria-label":j==="field"?"Field suggestions":"Value suggestions",className:"absolute top-full z-50 mt-1 max-h-56 w-full overflow-y-auto rounded-md border border-border bg-popover py-1 shadow-md",children:b.map((I,F)=>r.jsx("li",{role:"option","aria-selected":F===k,onMouseDown:q=>{q.preventDefault(),$(I)},className:["cursor-pointer px-3 py-1.5 font-mono text-sm",F===k?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"].join(" "),children:I},I))}),K&&r.jsx("ul",{className:"space-y-0.5",role:"status","aria-live":"polite",children:g.map((I,F)=>r.jsxs("li",{className:"font-mono text-xs text-destructive",children:["at ",I.pos,": ",I.message]},F))})]})}const I0=Ux;function bd(e){return e==="1"?"stale":e==="0"?"fresh":"all"}function EU(e,t){return e.toString()===t.toString()}function _0(){const{workspace:e}=Bt(),t=fn(),n=zt(),s=p.useRef(null);Ro("list:assignments");const{data:o,loading:i,error:c,refetch:u}=Cf(),d=ha(),m=rp(),[h,g]=ls(),y=e?`w:${e}`:null,b=wE(y),C=p.useRef(void 0),j=p.useMemo(()=>aC(d.order),[d]),v=p.useMemo(()=>{const B={};for(const J of j)B[J]=Bc(d,J);return B},[j,d]),k=p.useMemo(()=>j.map(B=>({id:B,title:v[B]??B,description:np(B)})),[j,v]),E=p.useMemo(()=>m.definitions.map(B=>({id:B.id,title:Ni(m,B.id),description:B.description})),[m]),S="__unknown_type__",T=p.useMemo(()=>new Set(["all",...j]),[j]),P=h.get("view"),R=h.get("status"),A=h.get("stale"),$=P&&I0.includes(P)?P:"kanban";function M(B){if(!B)return[];const J=[];for(const me of B.split(",")){const _e=me.trim();!_e||_e==="all"||!T.has(_e)||J.includes(_e)||J.push(_e)}return J}const _=p.useCallback(B=>{g(J=>{const me=new URLSearchParams(J);return B==="kanban"?me.delete("view"):me.set("view",B),me})},[g]),[D,V]=p.useState(""),[K,I]=p.useState(()=>M(R)),[F,q]=p.useState(()=>ze(b.filters.priority)),[Z,z]=p.useState(()=>ze(b.filters.type)),[G,L]=p.useState(()=>ze(b.filters.assignee)),[H,re]=p.useState(()=>ze(b.filters.project)),[U,ue]=p.useState(()=>ze(b.filters.tags)),[ge,se]=p.useState(null),[ye,Se]=p.useState(()=>bd(A)),[Te,Pe]=p.useState(()=>sc({status:M(R),priority:ze(b.filters.priority),type:ze(b.filters.type),assignee:ze(b.filters.assignee),project:ze(b.filters.project),tags:ze(b.filters.tags),activity:bd(A)})),[Ke,ct]=p.useState(()=>b.sortField),[et,ot]=p.useState(()=>b.sortDirection),[X,Me]=p.useState(()=>({hidden:[]})),[Ce,Ie]=p.useState(()=>({hidden:[]})),[Ye,Fe]=p.useState(()=>b.grouping),Ze=Ye==="type"?"type":"status",[Je,Ot]=p.useState(()=>new Set),[yt,dt]=p.useState([]),{toast:le,showToast:Y,dismissToast:fe}=Ao(),[ne,he]=p.useState(null),[De,ut]=p.useState(null),[ae,be]=p.useState(null),[Le,at]=p.useState(null),[Be,kt]=p.useState(null),[St,_t]=p.useState(null),[pe,te]=p.useState(null),[xe,Oe]=p.useState(null),[tt,ve]=p.useState(null),[Nt,It]=p.useState(!1),[en,jt]=p.useState(!1),wn=e?{kind:"workspace",workspace:e}:{kind:"global"},Rt=h.get("loadView"),{view:oe,loading:Ue,error:nt}=So(Rt),{view:bt,loading:tr,error:qr}=So(tt),Ts=p.useRef(null);p.useEffect(()=>{dt((o==null?void 0:o.assignments)??[])},[o]),p.useEffect(()=>{tt&&!tr&&!qr&&!bt&&ve(null)},[bt,qr,tt,tr]),p.useEffect(()=>{ve(null),Ts.current=null,se(null),V("")},[e]);const qc=p.useRef({status:R,stale:A});p.useEffect(()=>{const B=M(R),J=bd(A);jO(B,K)||I(B),J!==ye&&Se(J);const me=qc.current,_e=me.status!==R||me.stale!==A;qc.current={status:R,stale:A},_e&&on({status:B,activity:J})},[ye,A,K,R]),p.useEffect(()=>{C.current===y&&g(B=>{const J=new URLSearchParams(B);return K.length===0?J.delete("status"):J.set("status",K.join(",")),ye==="all"?J.delete("stale"):ye==="stale"?J.set("stale","1"):J.set("stale","0"),EU(B,J)?B:J})},[ye,y,g,K]),p.useEffect(()=>{q(ze(b.filters.priority)),z(ze(b.filters.type)),L(ze(b.filters.assignee)),re(ze(b.filters.project)),ue(ze(b.filters.tags)),ct(b.sortField),ot(b.sortDirection),Fe(b.grouping)},[b.filters.priority,b.filters.type,b.filters.assignee,b.filters.project,b.filters.tags,b.sortField,b.sortDirection,b.grouping]),p.useEffect(()=>{if(C.current===y)return;let B=!1;return Oy().then(J=>{if(B||C.current===y)return;const me=X1(J,y),_e=me.defaultView,ft=ze(me.filters.status),vt=me.filters.activity??"all",Mt=new URLSearchParams(window.location.search);let hr=!1;const un=new URLSearchParams(Mt);Mt.get("view")===null&&_e!=="kanban"&&I0.includes(_e)&&(un.set("view",_e),hr=!0),Mt.get("status")===null&&ft.length>0&&(un.set("status",ft.join(",")),I(ft),hr=!0),Mt.get("stale")===null&&vt!=="all"&&(un.set("stale",vt==="stale"?"1":"0"),Se(vt),hr=!0),hr&&g(un,{replace:!0});const pn=M(un.get("status")),mn=un.get("stale")===null?vt:bd(un.get("stale"));Pe(sc({status:pn,priority:ze(me.filters.priority),type:ze(me.filters.type),assignee:ze(me.filters.assignee),project:ze(me.filters.project),tags:ze(me.filters.tags),activity:mn==="fresh"||mn==="stale"?mn:"all"})),queueMicrotask(()=>{C.current=y})}),()=>{B=!0}},[y]);const ht=p.useCallback(B=>{(y===null?kE(B):SE(y,B)).catch(me=>{console.warn("Failed to persist view prefs:",me)})},[y]),Gc=p.useCallback(B=>{_(B),ht({defaultView:B})},[_,ht]),tl=p.useRef(null);tl.current={status:K,priority:F,type:Z,assignee:G,project:H,tags:U,activity:ye,dateRange:ge,search:D};const Yc=p.useCallback((B={})=>{const J=tl.current;return{status:J.status,priority:J.priority,type:J.type,assignee:J.assignee,project:J.project,tags:J.tags,activity:J.activity,dateRange:la(J.dateRange),search:J.search,...B}},[]),on=p.useCallback((B={})=>{Pe(sc(Yc(B)))},[Yc]),Qc=p.useCallback(B=>{I(B),ht({filters:{status:B}}),on({status:B})},[ht,on]),Jc=p.useCallback(B=>{q(B),ht({filters:{priority:B}}),on({priority:B})},[ht,on]),Xc=p.useCallback(B=>{z(B),ht({filters:{type:B}}),on({type:B})},[ht,on]),bp=p.useCallback(B=>{L(B),ht({filters:{assignee:B}}),on({assignee:B})},[ht,on]),vp=p.useCallback(B=>{re(B),ht({filters:{project:B}}),on({project:B})},[ht,on]),tn=p.useCallback(B=>{ue(B),ht({filters:{tags:B}}),on({tags:B})},[ht,on]),wp=p.useCallback(B=>{Se(B),ht({filters:{activity:B}}),on({activity:B})},[ht,on]),nl=p.useCallback(B=>{V(B),on({search:B})},[on]),Zc=p.useCallback(B=>{se(B),on({dateRange:la(B)})},[on]),qs=p.useCallback(B=>{ct(B),ht({sortField:B})},[ht]),va=p.useCallback(B=>{ot(B),ht({sortDirection:B})},[ht]),eu=p.useCallback(B=>{Fe(B),ht({grouping:B})},[ht]),wa=p.useCallback(B=>{Pe(B);const J=oc(B);J&&(I(ze(J.status)),q(ze(J.priority)),z(ze(J.type)),L(ze(J.assignee)),re(ze(J.project)),ue(ze(J.tags)),V(J.search??""),Se(J.activity&&J.activity!=="all"?J.activity:"all"),se(op(J.dateRange)))},[]),cn=p.useMemo(()=>oc(Te)!==null,[Te]),ja=p.useCallback(()=>{const J=oc(Te)!==null?{status:K,priority:F,type:Z,assignee:G,project:H,tags:U,activity:ye,dateRange:la(ge),search:D}:{};return{viewMode:$,filters:{...J,query:Te},sortField:Ke,sortDirection:et,listSectionVisibility:{collapsed:[...Je]},kanbanColumnVisibility:X,tableColumnVisibility:Ce}},[$,Te,K,F,Z,G,H,U,ye,ge,D,Ke,et,Je,X,Ce]),Bn=p.useCallback(B=>{eC(B,{setViewMode:_,setQuery:Pe,setStatusFilter:J=>{I(J),ht({filters:{status:J}})},setPriorityFilter:J=>{q(J),ht({filters:{priority:J}})},setTypeFilter:J=>{z(J),ht({filters:{type:J}})},setAssigneeFilter:J=>{L(J),ht({filters:{assignee:J}})},setProjectFilter:J=>{re(J),ht({filters:{project:J}})},setTagsFilter:J=>{ue(J),ht({filters:{tags:J}})},setActivityFilter:J=>{Se(J),ht({filters:{activity:J}})},setDateRange:se,setSearch:V,setSortField:qs,setSortDirection:va,setListSectionVisibility:J=>Ot(new Set(J.collapsed)),setKanbanColumnVisibility:Me,setTableColumnVisibility:Ie}),ve(B.id)},[_,ht,qs,va]),jp=p.useCallback(B=>{Bn(B),Ts.current=B.id,g(J=>{const me=new URLSearchParams(J);return me.set("loadView",B.id),me},{replace:!0})},[Bn,g]),kp=p.useCallback(async B=>{try{const J=Oi({name:B,context:{workspace:e??null,projectSlug:null},state:ja()}),me=await Pi(J),_e=me.views[me.views.length-1];ve((_e==null?void 0:_e.id)??null),_e&&(Ts.current=_e.id,g(ft=>{const vt=new URLSearchParams(ft);return vt.set("loadView",_e.id),vt},{replace:!0})),It(!1),jt(!1),Y(`Saved view "${B}"`,"success")}catch(J){throw Y(J instanceof Error?J.message:"Failed to save view","error"),J}},[ja,g,Y,e]),Sp=p.useCallback(async()=>{if(!(!tt||!bt))try{const B=Oi({name:bt.name,context:{workspace:e??null,projectSlug:null},state:ja()}),J=lf(bt.config,B.config,B.config);await ef(tt,{config:J}),Y("View updated","success")}catch(B){Y(B instanceof Error?B.message:"Failed to update view","error")}},[ja,bt,tt,Y,e]);p.useEffect(()=>{if(!Rt){Ts.current=null;return}if(Ts.current!==Rt&&(tt&&tt!==Rt&&ve(null),!Ue)){if(nt){Y("Couldn't load saved view — try again","error");return}if(oe){Ts.current=Rt,Bn(oe),g(B=>{const J=new URLSearchParams(B);return J.delete("loadView"),J},{replace:!0});return}Ts.current=Rt,Y("Saved view no longer exists","error"),g(B=>{const J=new URLSearchParams(B);return J.delete("loadView"),J},{replace:!0})}},[Rt,oe,Ue,nt,tt,Bn,g,Y]);const Yn=p.useMemo(()=>yt.filter(B=>e?e==="_ungrouped"?B.projectWorkspace===null:B.projectWorkspace===e:!0),[yt,e]),ka=p.useMemo(()=>Array.from(new Set(Yn.map(B=>B.status))).sort(),[Yn]),Gs=p.useMemo(()=>Array.from(new Set(Yn.map(B=>B.priority))).sort(),[Yn]),Do=p.useMemo(()=>Array.from(new Set(Yn.map(B=>B.assignee??"__unassigned__"))).sort(),[Yn]),tu=p.useMemo(()=>Array.from(new Map(Yn.filter(B=>B.projectSlug!==null).map(B=>[B.projectSlug,B.projectTitle]))).sort(([,B],[,J])=>B.localeCompare(J)),[Yn]),nu=p.useMemo(()=>Array.from(new Set(Yn.flatMap(B=>B.tags??[]))).sort(),[Yn]),$o=p.useMemo(()=>qN(d.factDeclarations),[d.factDeclarations]),rl=p.useMemo(()=>Te.trim()===""?null:Vx(Te,$o).query,[Te,$o]),Jt=p.useMemo(()=>WN(yt,rl,{workspace:e}),[yt,rl,e]),Gr=p.useMemo(()=>Uc(Jt,Ke,et),[Jt,Ke,et]),sl=p.useMemo(()=>{if(Ye==="none")return[{id:"__all__",label:"All assignments",items:Jt}];if(Ye==="type"){const B=m.definitions.map(_e=>({id:_e.id,label:Ni(m,_e.id),items:Jt.filter(ft=>ft.type===_e.id)})),J=new Set(m.definitions.map(_e=>_e.id)),me=Jt.filter(_e=>!_e.type||!J.has(_e.type));return me.length>0&&B.push({id:S,label:"Other",items:me}),B}if(Ye==="priority")return["critical","high","medium","low"].map(J=>({id:J,label:J.charAt(0).toUpperCase()+J.slice(1),items:Jt.filter(me=>me.priority===J)}));if(Ye==="assignee")return Array.from(new Set(Jt.map(J=>J.assignee??"__unassigned__"))).sort().map(J=>({id:J,label:J==="__unassigned__"?"Unassigned":J,items:Jt.filter(me=>(me.assignee??"__unassigned__")===J)}));if(Ye==="project"){const B=new Map;for(const J of Jt){const me=J.projectSlug??"__standalone__",_e=J.projectTitle??"Standalone";B.has(me)||B.set(me,_e)}return Array.from(B.entries()).sort(([,J],[,me])=>J.localeCompare(me)).map(([J,me])=>({id:J,label:me,items:Jt.filter(_e=>(_e.projectSlug??"__standalone__")===J)}))}return j.map(B=>({id:B,label:v[B]??B,items:Jt.filter(J=>J.status===B)}))},[Ye,Jt,m,j,v]),ol=p.useMemo(()=>{const B=new Set(m.definitions.map(me=>me.id));return Jt.some(me=>!me.type||!B.has(me.type))?[...E,{id:S,title:"Other",description:"Assignments with no recognized type."}]:E},[E,m,Jt]),{visibleItems:Pt,visibleIndexByKey:al}=p.useMemo(()=>{let B;if($==="table")B=Gr;else if($==="kanban"){const me=new Set(m.definitions.map(_e=>_e.id));Ze==="type"?B=[...m.definitions.flatMap(_e=>Jt.filter(ft=>ft.type===_e.id)),...Jt.filter(_e=>!_e.type||!me.has(_e.type))]:B=j.flatMap(_e=>Jt.filter(ft=>ft.status===_e))}else B=sl.flatMap(me=>me.items);const J=new Map;return B.forEach((me,_e)=>J.set(ln(me),_e)),{visibleItems:B,visibleIndexByKey:J}},[$,Gr,sl,Ze,m,Jt,j]),{hotkeyRowProps:Sa}=$c(Pt,{scope:"list:assignments",onOpen:B=>{if(B.projectSlug===null){n(`/assignments/${B.id}`);return}const J=B.projectWorkspace?`/w/${B.projectWorkspace}`:t;n(`${J}/projects/${B.projectSlug}/assignments/${B.slug}`)}});if(Yt({keys:"/",scope:"list:assignments",description:"Focus filter",handler:()=>{var B;return(B=s.current)==null?void 0:B.focus()}}),Yt({keys:"r",scope:"list:assignments",description:"Refresh",handler:()=>u()}),i)return r.jsx(xt,{label:"Loading assignments board…"});if(c||!o)return r.jsx(Tt,{error:c||"Assignments board is unavailable."});async function Na({item:B,toColumnId:J,action:me,reason:_e}){he(ln(B));const ft=yt;dt(vt=>vt.map(Mt=>ln(Mt)===ln(B)?{...Mt,status:J,blockedReason:J==="blocked"?_e??Mt.blockedReason:null}:Mt));try{if(B.projectSlug===null){if(!me)throw new Error("Standalone assignments require a transition action, not status override.");const Mt=await fetch(`/api/assignments/${encodeURIComponent(B.id)}/transitions/${encodeURIComponent(me.command)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_e?{reason:_e}:{})});if(!Mt.ok)throw new Error((await Mt.json()).error??`HTTP ${Mt.status}`);const un=(await Mt.json()).assignment;dt(pn=>pn.map(mn=>ln(mn)===ln(B)?{...mn,status:un.status,blockedReason:un.blockedReason,availableTransitions:un.availableTransitions,updated:un.updated}:mn));return}const vt=me?await TE(B.projectSlug,B.slug,me,_e):await RE(B.projectSlug,B.slug,J);return dt(Mt=>Mt.map(hr=>ln(hr)===ln(B)?{...hr,status:vt.status,blockedReason:vt.blockedReason,availableTransitions:vt.availableTransitions,updated:vt.updated}:hr)),u(),!0}catch(vt){return dt(ft),Y(vt.message,"error"),!1}finally{he(null)}}async function Ys({item:B,toColumnId:J,action:me}){if(B.status===J)return;const _e=me??Hl(B,J);if(_e!=null&&_e.disabled){Y(_e.disabledReason||`Cannot move this assignment to ${J}.`,"error");return}if(_e&&AE(_e)){at({item:B,toColumnId:J,action:_e});return}await Na({item:B,toColumnId:J,action:_e})}async function Ca(B,J){if(J===B.title)return;const me=ln(B),_e=yt;dt(ft=>ft.map(vt=>ln(vt)===me?{...vt,title:J}:vt)),he(me);try{const ft=B.projectSlug===null?await H8({id:B.id,title:J}):await V8({projectSlug:B.projectSlug,assignmentSlug:B.slug,title:J});dt(vt=>vt.map(Mt=>ln(Mt)===me?{...Mt,title:ft.title,updated:ft.updated}:Mt)),u()}catch(ft){throw dt(_e),Y(ft.message,"error"),ft}finally{he(null)}}function ru(B){Ot(J=>{const me=new Set(J);return me.has(B)?me.delete(B):me.add(B),me})}function il(B){Ke===B?va(et==="asc"?"desc":"asc"):(qs(B),va("asc"))}const In=De?yt.find(B=>ln(B)===De)??null:null;function us(B,J){B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",J),ut(J)}function Pr(){ut(null),be(null)}function ds(B,J){if(!In)return;const me=Hl(In,J);In.status===J||me!=null&&me.disabled||(B.preventDefault(),B.dataTransfer.dropEffect="move",be(J))}function Lo(B,J){ae===J&&!B.currentTarget.contains(B.relatedTarget)&&be(null)}function Oo(B,J){if(B.preventDefault(),!In||In.status===J){Pr();return}Pr(),Ys({item:In,toColumnId:J})}function Un({field:B,children:J}){const me=Ke===B;return r.jsx("th",{className:"pb-3 font-medium",children:r.jsxs("button",{type:"button",onClick:()=>il(B),className:"inline-flex items-center gap-1 hover:text-foreground",children:[J,me?et==="asc"?r.jsx(Ak,{className:"h-3 w-3"}):r.jsx(pr,{className:"h-3 w-3"}):null]})})}return r.jsxs("div",{className:"space-y-5","data-density":b.density,children:[r.jsx("div",{className:"flex items-center justify-end",children:r.jsxs(Ee,{to:`${t}/assignments/new`,className:"inline-flex h-9 items-center gap-2 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90",children:[r.jsx(Lt,{className:"h-4 w-4"}),"New Assignment"]})}),r.jsxs(iy,{children:[r.jsx(CU,{className:"w-full md:min-w-[320px] md:flex-1",value:Te,onChange:wa,registry:$o,declarations:d.factDeclarations,valueSources:{statuses:d.order,priorities:Gs,types:m.definitions.map(B=>B.id),assignees:Do.filter(B=>B!=="__unassigned__"),projects:tu.map(([B])=>B),tags:nu}}),cn?null:r.jsx("span",{className:"inline-flex items-center rounded-md border border-amber-500/40 bg-amber-500/10 px-2 py-1 text-xs font-medium text-amber-700 dark:text-amber-300",title:"This query uses features the chips can't represent (OR / NOT / grouping / advanced fields). Edit it in the query box; the chips are read-only until it becomes chip-representable again.",children:"advanced query — edit in the box"}),r.jsx(ap,{ref:s,value:D,onChange:cn?nl:()=>{},placeholder:"Search assignments or projects"}),r.jsx(yn,{ariaLabel:"Status filter",className:"max-w-[180px]",allLabel:"All statuses",disabled:!cn,options:ka.map(B=>({value:B,label:v[B]??B})),value:K,onChange:Qc}),r.jsx(yn,{ariaLabel:"Priority filter",className:"max-w-[180px]",allLabel:"All priorities",disabled:!cn,options:Gs.map(B=>({value:B,label:B[0].toUpperCase()+B.slice(1)})),value:F,onChange:Jc}),r.jsx(yn,{ariaLabel:"Type filter",className:"max-w-[180px]",allLabel:"All types",disabled:!cn,options:m.definitions.map(B=>({value:B.id,label:Ni(m,B.id)})),value:Z,onChange:Xc}),r.jsx(yn,{ariaLabel:"Assignee filter",className:"max-w-[180px]",allLabel:"All assignees",disabled:!cn,options:[{value:"__unassigned__",label:"Unassigned"},...Do.filter(B=>B!=="__unassigned__").map(B=>({value:B,label:B}))],value:G,onChange:bp}),r.jsx(yn,{ariaLabel:"Project filter",className:"max-w-[180px]",allLabel:"All projects",disabled:!cn,options:[{value:"__standalone__",label:"Standalone"},...tu.map(([B,J])=>({value:B,label:J}))],value:H,onChange:vp}),r.jsx(yn,{ariaLabel:"Tags filter",className:"max-w-[180px]",allLabel:"Any tags",disabled:!cn,options:nu.map(B=>({value:B,label:B})),value:U,onChange:tn}),r.jsx(sp,{className:"max-w-[200px]",value:ge,onChange:cn?Zc:()=>{}}),r.jsxs("select",{value:ye,disabled:!cn,onChange:B=>wp(B.target.value),className:"editor-input max-w-[180px]",children:[r.jsx("option",{value:"all",children:"All activity"}),r.jsx("option",{value:"stale",children:"Stale only"}),r.jsx("option",{value:"fresh",children:"Fresh only"})]}),r.jsx("select",{value:$==="kanban"?Ze:Ye,onChange:B=>eu(B.target.value),className:"editor-input max-w-[180px]",title:"Group by",children:vO.map(B=>{const J=$==="kanban"&&B!=="status"&&B!=="type",me=B==="none"?"No grouping":`Group: ${B.charAt(0).toUpperCase()+B.slice(1)}`;return r.jsx("option",{value:B,disabled:J,children:J?`${me} (list only)`:me},B)})}),r.jsx(ip,{value:$,onChange:B=>Gc(B),options:[{value:"table",label:"Table"},{value:"list",label:"List"},{value:"kanban",label:"Kanban"}]}),$==="table"?r.jsx(yE,{visibility:Ce,onChange:Ie}):null,r.jsx(CE,{scope:wn,loadedViewId:tt,onApply:jp,onOpenSaveDialog:()=>{jt(!1),It(!0)}}),r.jsx("button",{type:"button",onClick:()=>{bt?Sp():(jt(!1),It(!0))},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:bt?`Update ${bt.name}`:"Save current view",children:bt?`Update '${bt.name}'`:"Save view"}),bt?r.jsx("button",{type:"button",onClick:()=>{jt(!0),It(!0)},className:"inline-flex items-center gap-1.5 rounded-md border border-border/60 bg-background/60 px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-background",title:"Save as new view",children:"Save as new…"}):null]}),o.assignments.length===0?r.jsx(Et,{title:"No assignments yet",description:"Assignments appear here once projects contain concrete work items.",actions:r.jsxs(Ee,{className:"shell-action shell-action--cta",to:`${t}/projects`,children:[r.jsx(sx,{className:"h-4 w-4"}),r.jsx("span",{children:"Browse Projects"})]})}):Jt.length===0?r.jsx(Et,{title:"No assignments match these filters",description:"Adjust the search term or filters to show assignments across all projects again."}):$==="table"?(()=>{const B=new Set(Ce.hidden),J=me=>me==="title"||!B.has(me);return r.jsx(He,{title:`${Gr.length} assignment${Gr.length===1?"":"s"}`,children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[J("title")?r.jsx(Un,{field:"title",children:"Assignment"}):null,J("status")?r.jsx(Un,{field:"status",children:"Status"}):null,r.jsx("th",{className:"py-2 pr-4 text-xs font-medium uppercase tracking-wider",children:"Type"}),J("priority")?r.jsx(Un,{field:"priority",children:"Priority"}):null,J("assignee")?r.jsx(Un,{field:"assignee",children:"Assignee"}):null,J("dependencies")?r.jsx(Un,{field:"dependencies",children:"Dependencies"}):null,J("created")?r.jsx(Un,{field:"created",children:"Created"}):null,J("updated")?r.jsx(Un,{field:"updated",children:"Updated"}):null]})}),r.jsx("tbody",{children:Gr.map((me,_e)=>r.jsxs(RU,{detailHref:jc(me),className:"cursor-pointer border-b border-border/50 transition hover:bg-muted/40 last:border-0",...Sa(_e),children:[J("title")?r.jsxs("td",{className:"py-4 pr-4",children:[r.jsx(YE,{title:me.title,detailHref:jc(me),onSave:ft=>Ca(me,ft),disabled:ne===ln(me)}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:me.projectTitle??r.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"})}),r.jsxs("p",{className:"mt-0.5 inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:me.id,children:[me.id.slice(0,8),r.jsx(Br,{value:me.id})]})]}):null,J("status")?r.jsx("td",{className:"py-4 pr-4",children:r.jsx("select",{value:me.status,disabled:ne===ln(me),onChange:ft=>Ys({item:me,toColumnId:ft.target.value}),className:we("appearance-none rounded-full border px-2.5 py-0.5 text-xs font-semibold tracking-wide outline-none","cursor-pointer bg-[length:12px] bg-[right_6px_center] bg-no-repeat pr-6",`bg-[url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E")]`,(of[me.status]??of.pending).className,ne===ln(me)&&"animate-pulse opacity-60"),children:j.map(ft=>{const vt=me.status===ft?void 0:Hl(me,ft),Mt=(vt==null?void 0:vt.disabled)??!1;return r.jsx("option",{value:ft,disabled:Mt,title:Mt?(vt==null?void 0:vt.disabledReason)??void 0:void 0,children:v[ft]},ft)})})}):null,r.jsx("td",{className:"py-4 pr-4",children:r.jsx(ga,{type:me.type,compact:!0})}),J("priority")?r.jsx("td",{className:"py-4 pr-4 capitalize text-muted-foreground",children:me.priority}):null,J("assignee")?r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:me.assignee??"Unassigned"}):null,J("dependencies")?r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:me.dependsOn.length}):null,J("created")?r.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:zn(me.created)}):null,J("updated")?r.jsx("td",{className:"py-4 text-muted-foreground",children:zn(me.updated)}):null]},ln(me)))})]})})})})():$==="list"?r.jsx("div",{className:"space-y-3",children:sl.map(({id:B,label:J,items:me})=>{var un;if(me.length===0&&!(In&&Ye==="status"))return null;const _e=!Je.has(B),ft=Ye==="status",vt=ft&&In?In.status!==B&&!((un=Hl(In,B))!=null&&un.disabled):!1,Mt=ft&&In?In.status!==B&&!vt:!1,hr=ft&&ae===B;return r.jsxs("div",{className:we("rounded-lg border border-border/60 bg-card/90 transition",hr&&vt&&"ring-2 ring-ring/30",Mt&&"border-dashed opacity-65"),onDragOver:ft?pn=>ds(pn,B):void 0,onDragLeave:ft?pn=>Lo(pn,B):void 0,onDrop:ft?pn=>Oo(pn,B):void 0,children:[r.jsxs("button",{type:"button",onClick:()=>ru(B),className:"flex w-full items-center gap-2 px-4 py-3 text-left",children:[r.jsx(pr,{className:`h-4 w-4 text-muted-foreground transition-transform ${_e?"":"-rotate-90"}`}),r.jsx("span",{className:"font-semibold text-foreground",children:J}),r.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:me.length})]}),_e&&me.length>0&&r.jsx("div",{className:"space-y-3 px-4 pb-4",children:me.map(pn=>{const mn=ln(pn),Io=De===mn,su=al.get(mn)??-1,Ea=ft;return r.jsx("div",{draggable:Ea,onDragStart:Ea?fs=>us(fs,mn):void 0,onDragEnd:Ea?Pr:void 0,...su>=0?Sa(su):{},className:we("transition",Ea&&"cursor-grab active:cursor-grabbing",Io&&"scale-[0.98] opacity-50"),children:r.jsx(M0,{assignment:pn,dragging:Io,transitioning:ne===mn,onPillSelect:fs=>void Ys({item:pn,toColumnId:fs.targetStatus,action:fs}),onRenameTitle:fs=>Ca(pn,fs)})},mn)})})]},B)})}):r.jsx(tp,{columns:Ze==="type"?ol:k,items:Jt,getItemId:ln,getColumnId:B=>Ze==="type"?B.type&&m.definitions.some(J=>J.id===B.type)?B.type:S:B.status,canDrop:({item:B,fromColumnId:J,toColumnId:me})=>{if(J===me)return{allowed:!0};const _e=Hl(B,me);return _e!=null&&_e.disabled?{allowed:!1,reason:_e.disabledReason||_e.description}:{allowed:!0,reason:_e?_e.warning||_e.description:`Move to ${me} (direct status change).`}},onMove:Ze==="type"?void 0:({item:B,toColumnId:J})=>Ys({item:B,toColumnId:J}),dragDisabled:Ze==="type",getExternalDragData:B=>B.projectSlug===null?{type:"standalone-assignment",id:B.id}:{type:"project-assignment",id:B.id},onCardContextMenu:(B,J)=>{J.preventDefault(),kt({item:B,anchor:{x:J.clientX,y:J.clientY}})},emptyMessage:B=>`No ${B.title.toLowerCase()} assignments.`,hiddenColumnIds:X.hidden,onHideColumn:B=>Me(J=>({hidden:J.hidden.includes(B)?J.hidden.filter(_e=>_e!==B):[...J.hidden,B]})),renderCard:(B,{dragging:J})=>{const me=al.get(ln(B))??-1;return r.jsx("div",{...me>=0?Sa(me):{},children:r.jsx(M0,{assignment:B,dragging:J,transitioning:ne===ln(B),onPillSelect:_e=>void Ys({item:B,toColumnId:_e.targetStatus,action:_e}),onRenameTitle:_e=>Ca(B,_e)})})}}),r.jsx(xa,{toast:le,onDismiss:fe}),r.jsx(NE,{open:Nt,onOpenChange:B=>{It(B),B||jt(!1)},initialName:en&&bt?`${bt.name} (copy)`:"",title:en?"Save as new view":"Save view",onSubmit:kp}),r.jsx(OE,{open:Le!==null,action:(Le==null?void 0:Le.action)??null,assignmentTitle:(Le==null?void 0:Le.item.title)??"Assignment",loading:ne===(Le?ln(Le.item):null),onOpenChange:B=>{B||at(null)},onConfirm:async B=>{if(!Le)return;const J=Le;await Na({item:J.item,toColumnId:J.toColumnId,action:J.action,reason:B})&&at(null)}}),r.jsx(iC,{anchor:(Be==null?void 0:Be.anchor)??null,items:Be?TU(Be.item,{onEdit:()=>{const B=Be.item,J=B.projectSlug===null?`/assignments/${B.id}`:`${B.projectWorkspace?`/w/${B.projectWorkspace}`:t}/projects/${B.projectSlug}/assignments/${B.slug}`;n(J)},onDelete:()=>_t(Be.item),onMove:()=>Oe(Be.item)}):[],onClose:()=>kt(null)}),r.jsx(ba,{open:St!==null,title:"Delete assignment?",description:St?`"${St.title}" will be permanently removed. This cannot be undone.`:"",confirmLabel:"Delete",destructive:!0,loading:pe!==null,onOpenChange:B=>{!B&&pe===null&&_t(null)},onConfirm:async()=>{if(!St||St.projectSlug===null){_t(null);return}const B=ln(St);te(B);try{const J=await fetch(`/api/projects/${encodeURIComponent(St.projectSlug)}/assignments/${encodeURIComponent(St.slug)}`,{method:"DELETE"});if(!J.ok){const me=await J.json().catch(()=>({}));throw new Error(me.error||"Failed to delete assignment")}_t(null),u()}catch(J){alert(J instanceof Error?J.message:"Failed to delete assignment")}finally{te(null)}}}),r.jsx(cy,{open:xe!==null,onOpenChange:B=>{B||Oe(null)},currentWorkspace:(xe==null?void 0:xe.projectWorkspace)??null,title:"Move assignment to workspace",description:"Standalone assignments belong to a project-workspace via the workspaceGroup frontmatter field.",onSubmit:async B=>{if(!xe)return;const J=await fetch(`/api/assignments/${encodeURIComponent(xe.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:B})});if(!J.ok){const me=await J.json().catch(()=>({}));throw new Error(me.error||"Failed to move assignment")}u()}})]})}function TU(e,t){const n=[{key:"edit",label:"Edit",icon:zi,onSelect:t.onEdit}];return e.projectSlug!==null?n.push({key:"delete",label:"Delete",icon:Tn,destructive:!0,onSelect:t.onDelete}):n.push({key:"move",label:"Move to workspace…",icon:jf,onSelect:t.onMove}),n}function RU({detailHref:e,children:t,className:n,...s}){const o=QE(e);return r.jsx("tr",{...s,ref:o.containerRef,className:n,onMouseDown:o.onMouseDown,onClick:o.onClick,children:t})}function M0({assignment:e,dragging:t,transitioning:n,onPillSelect:s,onRenameTitle:o}){var d;const i=jc(e),c=!!(s&&o),u=QE(i);return r.jsxs("div",{ref:c?u.containerRef:void 0,className:we("vp-card rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",c&&"cursor-pointer"),onMouseDown:c?u.onMouseDown:void 0,onClick:c?u.onClick:void 0,children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[c?r.jsx(YE,{title:e.title,detailHref:i,onSave:o,disabled:n}):r.jsx(Ee,{to:i,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),r.jsx("p",{className:"text-sm text-muted-foreground",children:e.projectTitle??r.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"})}),r.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:e.id??"",children:[(d=e.id)==null?void 0:d.slice(0,8),e.id&&r.jsx(Br,{value:e.id})]})]}),c?r.jsx(yU,{currentStatus:e.status,availableTransitions:e.availableTransitions,onSelect:s,disabled:n,className:"max-w-[150px]"}):r.jsx(bn,{status:e.status,className:"max-w-[150px]"})]}),e.blockedReason?r.jsx("p",{className:"mt-3 rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-sm text-warning-foreground",children:e.blockedReason}):null,r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[r.jsx(ga,{type:e.type}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:e.priority}),r.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:e.assignee??"Unassigned"}),r.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.dependsOn.length," dependencies"]})]}),r.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:[r.jsx("span",{children:n?"Updating":t?"Dragging":"Source-first"}),r.jsx("span",{children:zn(e.updated)})]})]})}function Hl(e,t){return e.availableTransitions.find(n=>n.targetStatus===t)}function ln(e){return e.id||e.slug||"unknown"}function Kr(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?/);if(!t)return{order:[],blocks:new Map,body:e};const n=t[1],s=e.slice(t[0].length),o=n.split(`
|
|
581
581
|
`),i=[],c=new Map;let u=null,d=[];const m=()=>{u&&(i.push(u),c.set(u,d))};for(const h of o){const g=h.match(/^([A-Za-z_][A-Za-z0-9_-]*):/);if(g&&!h.startsWith(" ")){m(),u=g[1],d=[h];continue}u&&d.push(h)}return m(),{order:i,blocks:c,body:s}}function Xi(e){return`---
|
|
582
582
|
${e.order.map(n=>e.blocks.get(n)).filter(n=>!!n).flat().join(`
|
|
583
583
|
`)}
|