syntaur 0.68.0 → 0.70.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.
Files changed (68) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dashboard/dist/assets/{_basePickBy-CE2CIvur.js → _basePickBy-DKk6tHtk.js} +1 -1
  3. package/dashboard/dist/assets/{_baseUniq-BznLQqID.js → _baseUniq-DM-f7DWz.js} +1 -1
  4. package/dashboard/dist/assets/{arc-B6JqtWve.js → arc-ZBlA3YdV.js} +1 -1
  5. package/dashboard/dist/assets/{architectureDiagram-2XIMDMQ5-P8UCT3rj.js → architectureDiagram-2XIMDMQ5-BUmvtGTF.js} +1 -1
  6. package/dashboard/dist/assets/{blockDiagram-WCTKOSBZ-C1ATZKSf.js → blockDiagram-WCTKOSBZ-B3qxWK6s.js} +1 -1
  7. package/dashboard/dist/assets/{c4Diagram-IC4MRINW-AvN1yayQ.js → c4Diagram-IC4MRINW-BEq_UJO-.js} +1 -1
  8. package/dashboard/dist/assets/channel-fypxffzQ.js +1 -0
  9. package/dashboard/dist/assets/{chunk-4BX2VUAB-CyYz6mlJ.js → chunk-4BX2VUAB-C-Y9ryMm.js} +1 -1
  10. package/dashboard/dist/assets/{chunk-55IACEB6-QyOF7ox_.js → chunk-55IACEB6-CGdtbsjw.js} +1 -1
  11. package/dashboard/dist/assets/{chunk-FMBD7UC4-DVTHM99U.js → chunk-FMBD7UC4-DllxJhUp.js} +1 -1
  12. package/dashboard/dist/assets/{chunk-JSJVCQXG-DQfxaQtT.js → chunk-JSJVCQXG-jjMM8O5F.js} +1 -1
  13. package/dashboard/dist/assets/{chunk-KX2RTZJC-4R1oobH6.js → chunk-KX2RTZJC-B_6BPltQ.js} +1 -1
  14. package/dashboard/dist/assets/{chunk-NQ4KR5QH-D8H_7yNS.js → chunk-NQ4KR5QH-D0hJiXHp.js} +1 -1
  15. package/dashboard/dist/assets/{chunk-QZHKN3VN-DLxDUSuo.js → chunk-QZHKN3VN-BCWo4hLS.js} +1 -1
  16. package/dashboard/dist/assets/{chunk-WL4C6EOR-CWuFDkVp.js → chunk-WL4C6EOR-DH_jEAwg.js} +1 -1
  17. package/dashboard/dist/assets/classDiagram-VBA2DB6C-1KnjQvtL.js +1 -0
  18. package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-1KnjQvtL.js +1 -0
  19. package/dashboard/dist/assets/clone-CKMabBhS.js +1 -0
  20. package/dashboard/dist/assets/{cose-bilkent-S5V4N54A-D23Dy_Za.js → cose-bilkent-S5V4N54A-5ld00TOH.js} +1 -1
  21. package/dashboard/dist/assets/{dagre-KLK3FWXG-CaKBk8eh.js → dagre-KLK3FWXG-Cnu6eQWy.js} +1 -1
  22. package/dashboard/dist/assets/{diagram-E7M64L7V-BAPQPki-.js → diagram-E7M64L7V-_CBBKNP-.js} +1 -1
  23. package/dashboard/dist/assets/{diagram-IFDJBPK2-Cla6qyvn.js → diagram-IFDJBPK2-DE6WjIb1.js} +1 -1
  24. package/dashboard/dist/assets/{diagram-P4PSJMXO-DnTZq_y6.js → diagram-P4PSJMXO-DpW7UzNK.js} +1 -1
  25. package/dashboard/dist/assets/{erDiagram-INFDFZHY-yc1_7ebn.js → erDiagram-INFDFZHY-BD2409fE.js} +1 -1
  26. package/dashboard/dist/assets/{flowDiagram-PKNHOUZH-CMt2tF6O.js → flowDiagram-PKNHOUZH-1p0khhFI.js} +1 -1
  27. package/dashboard/dist/assets/{ganttDiagram-A5KZAMGK-CXiK-5Gp.js → ganttDiagram-A5KZAMGK-B2zFyA4s.js} +1 -1
  28. package/dashboard/dist/assets/{gitGraphDiagram-K3NZZRJ6-B4PbW06T.js → gitGraphDiagram-K3NZZRJ6-bH-4YH7h.js} +1 -1
  29. package/dashboard/dist/assets/{graph-CjdFy-q-.js → graph-BT24B6iQ.js} +1 -1
  30. package/dashboard/dist/assets/{index-DlUgV5eO.css → index-BZwPAi8K.css} +1 -1
  31. package/dashboard/dist/assets/index-Cxqr3rQB.js +670 -0
  32. package/dashboard/dist/assets/{infoDiagram-LFFYTUFH-BeOWVt7p.js → infoDiagram-LFFYTUFH-CMzP4Hcg.js} +1 -1
  33. package/dashboard/dist/assets/{ishikawaDiagram-PHBUUO56-LE7swZOH.js → ishikawaDiagram-PHBUUO56-DMEmFC7M.js} +1 -1
  34. package/dashboard/dist/assets/{journeyDiagram-4ABVD52K-DG9-sksf.js → journeyDiagram-4ABVD52K-CAtzYQUm.js} +1 -1
  35. package/dashboard/dist/assets/{kanban-definition-K7BYSVSG-7CKAw6eI.js → kanban-definition-K7BYSVSG-d1JVbtvX.js} +1 -1
  36. package/dashboard/dist/assets/{layout-CHChKPuz.js → layout-BVuI38I_.js} +1 -1
  37. package/dashboard/dist/assets/{linear-BWSj4au4.js → linear-Bc8PGMbp.js} +1 -1
  38. package/dashboard/dist/assets/{mermaid.core-CAwQaPqG.js → mermaid.core-UtwFYLNj.js} +4 -4
  39. package/dashboard/dist/assets/{mindmap-definition-YRQLILUH-CtZWMkVN.js → mindmap-definition-YRQLILUH-DHc5RCDj.js} +1 -1
  40. package/dashboard/dist/assets/{pieDiagram-SKSYHLDU-CstCoaK7.js → pieDiagram-SKSYHLDU-9anIsdIA.js} +1 -1
  41. package/dashboard/dist/assets/{quadrantDiagram-337W2JSQ-DD8zRtaB.js → quadrantDiagram-337W2JSQ-FZ0D9HnU.js} +1 -1
  42. package/dashboard/dist/assets/{requirementDiagram-Z7DCOOCP-BWpKIK3b.js → requirementDiagram-Z7DCOOCP-BkjCvH_u.js} +1 -1
  43. package/dashboard/dist/assets/{sankeyDiagram-WA2Y5GQK-08gqQtFM.js → sankeyDiagram-WA2Y5GQK-DzqwYHDo.js} +1 -1
  44. package/dashboard/dist/assets/{sequenceDiagram-2WXFIKYE-DsfIDBUH.js → sequenceDiagram-2WXFIKYE-BW4g5Ao-.js} +1 -1
  45. package/dashboard/dist/assets/{stateDiagram-RAJIS63D-Dqzfk_yy.js → stateDiagram-RAJIS63D-D0tKU3Z0.js} +1 -1
  46. package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-DxWQhjNO.js +1 -0
  47. package/dashboard/dist/assets/{timeline-definition-YZTLITO2-DgH_p9jR.js → timeline-definition-YZTLITO2-Bu269QDX.js} +1 -1
  48. package/dashboard/dist/assets/{treemap-KZPCXAKY-7XKqMhq9.js → treemap-KZPCXAKY-BGu_rrva.js} +1 -1
  49. package/dashboard/dist/assets/{vennDiagram-LZ73GAT5-BFtNLBWM.js → vennDiagram-LZ73GAT5-Cx_n5FRZ.js} +1 -1
  50. package/dashboard/dist/assets/{xychartDiagram-JWTSCODW-CQPevMNl.js → xychartDiagram-JWTSCODW-BOJsKV_W.js} +1 -1
  51. package/dashboard/dist/index.html +2 -2
  52. package/dist/dashboard/server.js +83 -46
  53. package/dist/dashboard/server.js.map +1 -1
  54. package/dist/index.js +353 -326
  55. package/dist/index.js.map +1 -1
  56. package/dist/launch/index.js +328 -37
  57. package/dist/launch/index.js.map +1 -1
  58. package/package.json +1 -1
  59. package/platforms/claude-code/.claude-plugin/plugin.json +1 -1
  60. package/platforms/codex/.codex-plugin/plugin.json +1 -1
  61. package/platforms/hermes/plugins/syntaur/__pycache__/__init__.cpython-312.pyc +0 -0
  62. package/platforms/hermes/plugins/syntaur/__pycache__/boundary.cpython-312.pyc +0 -0
  63. package/dashboard/dist/assets/channel-IZujZyS6.js +0 -1
  64. package/dashboard/dist/assets/classDiagram-VBA2DB6C-ChnJofe3.js +0 -1
  65. package/dashboard/dist/assets/classDiagram-v2-RAHNMMFH-ChnJofe3.js +0 -1
  66. package/dashboard/dist/assets/clone-JjIbzsqJ.js +0 -1
  67. package/dashboard/dist/assets/index-COOcebN7.js +0 -659
  68. package/dashboard/dist/assets/stateDiagram-v2-FVOUBMTO-D542UPiR.js +0 -1
@@ -1,659 +0,0 @@
1
- var JI=Object.defineProperty;var ZI=(e,t,n)=>t in e?JI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ux=(e,t,n)=>ZI(e,typeof t!="symbol"?t+"":t,n);function eL(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const i=Object.getOwnPropertyDescriptor(r,o);i&&Object.defineProperty(e,o,i.get?i:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();function Cd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function vle(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}),n}var Hx={exports:{}},fu={},Vx={exports:{}},Ct={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var c1;function tL(){if(c1)return Ct;c1=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.iterator;function g(z){return z===null||typeof z!="object"?null:(z=h&&z[h]||z["@@iterator"],typeof z=="function"?z:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,v={};function b(z,Y,q){this.props=z,this.context=Y,this.refs=v,this.updater=q||y}b.prototype.isReactComponent={},b.prototype.setState=function(z,Y){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,Y,"setState")},b.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function j(){}j.prototype=b.prototype;function N(z,Y,q){this.props=z,this.context=Y,this.refs=v,this.updater=q||y}var S=N.prototype=new j;S.constructor=N,k(S,b.prototype),S.isPureReactComponent=!0;var C=Array.isArray,D=Object.prototype.hasOwnProperty,T={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function $(z,Y,q){var Q,ee={},Z=null,ie=null;if(Y!=null)for(Q in Y.ref!==void 0&&(ie=Y.ref),Y.key!==void 0&&(Z=""+Y.key),Y)D.call(Y,Q)&&!R.hasOwnProperty(Q)&&(ee[Q]=Y[Q]);var ne=arguments.length-2;if(ne===1)ee.children=q;else if(1<ne){for(var ue=Array(ne),ge=0;ge<ne;ge++)ue[ge]=arguments[ge+2];ee.children=ue}if(z&&z.defaultProps)for(Q in ne=z.defaultProps,ne)ee[Q]===void 0&&(ee[Q]=ne[Q]);return{$$typeof:e,type:z,key:Z,ref:ie,props:ee,_owner:T.current}}function P(z,Y){return{$$typeof:e,type:z.type,key:Y,ref:z.ref,props:z.props,_owner:z._owner}}function F(z){return typeof z=="object"&&z!==null&&z.$$typeof===e}function _(z){var Y={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(q){return Y[q]})}var V=/\/+/g;function U(z,Y){return typeof z=="object"&&z!==null&&z.key!=null?_(""+z.key):Y.toString(36)}function I(z,Y,q,Q,ee){var Z=typeof z;(Z==="undefined"||Z==="boolean")&&(z=null);var ie=!1;if(z===null)ie=!0;else switch(Z){case"string":case"number":ie=!0;break;case"object":switch(z.$$typeof){case e:case t:ie=!0}}if(ie)return ie=z,ee=ee(ie),z=Q===""?"."+U(ie,0):Q,C(ee)?(q="",z!=null&&(q=z.replace(V,"$&/")+"/"),I(ee,Y,q,"",function(ge){return ge})):ee!=null&&(F(ee)&&(ee=P(ee,q+(!ee.key||ie&&ie.key===ee.key?"":(""+ee.key).replace(V,"$&/")+"/")+z)),Y.push(ee)),1;if(ie=0,Q=Q===""?".":Q+":",C(z))for(var ne=0;ne<z.length;ne++){Z=z[ne];var ue=Q+U(Z,ne);ie+=I(Z,Y,q,ue,ee)}else if(ue=g(z),typeof ue=="function")for(z=ue.call(z),ne=0;!(Z=z.next()).done;)Z=Z.value,ue=Q+U(Z,ne++),ie+=I(Z,Y,q,ue,ee);else if(Z==="object")throw Y=String(z),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.");return ie}function M(z,Y,q){if(z==null)return z;var Q=[],ee=0;return I(z,Q,"","",function(Z){return Y.call(q,Z,ee++)}),Q}function B(z){if(z._status===-1){var Y=z._result;Y=Y(),Y.then(function(q){(z._status===0||z._status===-1)&&(z._status=1,z._result=q)},function(q){(z._status===0||z._status===-1)&&(z._status=2,z._result=q)}),z._status===-1&&(z._status=0,z._result=Y)}if(z._status===1)return z._result.default;throw z._result}var W={current:null},O={transition:null},H={ReactCurrentDispatcher:W,ReactCurrentBatchConfig:O,ReactCurrentOwner:T};function L(){throw Error("act(...) is not supported in production builds of React.")}return Ct.Children={map:M,forEach:function(z,Y,q){M(z,function(){Y.apply(this,arguments)},q)},count:function(z){var Y=0;return M(z,function(){Y++}),Y},toArray:function(z){return M(z,function(Y){return Y})||[]},only:function(z){if(!F(z))throw Error("React.Children.only expected to receive a single React element child.");return z}},Ct.Component=b,Ct.Fragment=n,Ct.Profiler=o,Ct.PureComponent=N,Ct.StrictMode=r,Ct.Suspense=u,Ct.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=H,Ct.act=L,Ct.cloneElement=function(z,Y,q){if(z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+z+".");var Q=k({},z.props),ee=z.key,Z=z.ref,ie=z._owner;if(Y!=null){if(Y.ref!==void 0&&(Z=Y.ref,ie=T.current),Y.key!==void 0&&(ee=""+Y.key),z.type&&z.type.defaultProps)var ne=z.type.defaultProps;for(ue in Y)D.call(Y,ue)&&!R.hasOwnProperty(ue)&&(Q[ue]=Y[ue]===void 0&&ne!==void 0?ne[ue]:Y[ue])}var ue=arguments.length-2;if(ue===1)Q.children=q;else if(1<ue){ne=Array(ue);for(var ge=0;ge<ue;ge++)ne[ge]=arguments[ge+2];Q.children=ne}return{$$typeof:e,type:z.type,key:ee,ref:Z,props:Q,_owner:ie}},Ct.createContext=function(z){return z={$$typeof:a,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},z.Provider={$$typeof:i,_context:z},z.Consumer=z},Ct.createElement=$,Ct.createFactory=function(z){var Y=$.bind(null,z);return Y.type=z,Y},Ct.createRef=function(){return{current:null}},Ct.forwardRef=function(z){return{$$typeof:l,render:z}},Ct.isValidElement=F,Ct.lazy=function(z){return{$$typeof:p,_payload:{_status:-1,_result:z},_init:B}},Ct.memo=function(z,Y){return{$$typeof:f,type:z,compare:Y===void 0?null:Y}},Ct.startTransition=function(z){var Y=O.transition;O.transition={};try{z()}finally{O.transition=Y}},Ct.unstable_act=L,Ct.useCallback=function(z,Y){return W.current.useCallback(z,Y)},Ct.useContext=function(z){return W.current.useContext(z)},Ct.useDebugValue=function(){},Ct.useDeferredValue=function(z){return W.current.useDeferredValue(z)},Ct.useEffect=function(z,Y){return W.current.useEffect(z,Y)},Ct.useId=function(){return W.current.useId()},Ct.useImperativeHandle=function(z,Y,q){return W.current.useImperativeHandle(z,Y,q)},Ct.useInsertionEffect=function(z,Y){return W.current.useInsertionEffect(z,Y)},Ct.useLayoutEffect=function(z,Y){return W.current.useLayoutEffect(z,Y)},Ct.useMemo=function(z,Y){return W.current.useMemo(z,Y)},Ct.useReducer=function(z,Y,q){return W.current.useReducer(z,Y,q)},Ct.useRef=function(z){return W.current.useRef(z)},Ct.useState=function(z){return W.current.useState(z)},Ct.useSyncExternalStore=function(z,Y,q){return W.current.useSyncExternalStore(z,Y,q)},Ct.useTransition=function(){return W.current.useTransition()},Ct.version="18.3.1",Ct}var u1;function Ed(){return u1||(u1=1,Vx.exports=tL()),Vx.exports}/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var d1;function nL(){if(d1)return fu;d1=1;var e=Ed(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function a(l,u,f){var p,h={},g=null,y=null;f!==void 0&&(g=""+f),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(y=u.ref);for(p in u)r.call(u,p)&&!i.hasOwnProperty(p)&&(h[p]=u[p]);if(l&&l.defaultProps)for(p in u=l.defaultProps,u)h[p]===void 0&&(h[p]=u[p]);return{$$typeof:t,type:l,key:g,ref:y,props:h,_owner:o.current}}return fu.Fragment=n,fu.jsx=a,fu.jsxs=a,fu}var f1;function rL(){return f1||(f1=1,Hx.exports=nL()),Hx.exports}var s=rL(),m=Ed();const Lt=Cd(m),zE=eL({__proto__:null,default:Lt},[m]);var ep={},Wx={exports:{}},xr={},qx={exports:{}},Kx={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */var p1;function sL(){return p1||(p1=1,(function(e){function t(O,H){var L=O.length;O.push(H);e:for(;0<L;){var z=L-1>>>1,Y=O[z];if(0<o(Y,H))O[z]=H,O[L]=Y,L=z;else break e}}function n(O){return O.length===0?null:O[0]}function r(O){if(O.length===0)return null;var H=O[0],L=O.pop();if(L!==H){O[0]=L;e:for(var z=0,Y=O.length,q=Y>>>1;z<q;){var Q=2*(z+1)-1,ee=O[Q],Z=Q+1,ie=O[Z];if(0>o(ee,L))Z<Y&&0>o(ie,ee)?(O[z]=ie,O[Z]=L,z=Z):(O[z]=ee,O[Q]=L,z=Q);else if(Z<Y&&0>o(ie,L))O[z]=ie,O[Z]=L,z=Z;else break e}}return H}function o(O,H){var L=O.sortIndex-H.sortIndex;return L!==0?L:O.id-H.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var u=[],f=[],p=1,h=null,g=3,y=!1,k=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(O){for(var H=n(f);H!==null;){if(H.callback===null)r(f);else if(H.startTime<=O)r(f),H.sortIndex=H.expirationTime,t(u,H);else break;H=n(f)}}function C(O){if(v=!1,S(O),!k)if(n(u)!==null)k=!0,B(D);else{var H=n(f);H!==null&&W(C,H.startTime-O)}}function D(O,H){k=!1,v&&(v=!1,j($),$=-1),y=!0;var L=g;try{for(S(H),h=n(u);h!==null&&(!(h.expirationTime>H)||O&&!_());){var z=h.callback;if(typeof z=="function"){h.callback=null,g=h.priorityLevel;var Y=z(h.expirationTime<=H);H=e.unstable_now(),typeof Y=="function"?h.callback=Y:h===n(u)&&r(u),S(H)}else r(u);h=n(u)}if(h!==null)var q=!0;else{var Q=n(f);Q!==null&&W(C,Q.startTime-H),q=!1}return q}finally{h=null,g=L,y=!1}}var T=!1,R=null,$=-1,P=5,F=-1;function _(){return!(e.unstable_now()-F<P)}function V(){if(R!==null){var O=e.unstable_now();F=O;var H=!0;try{H=R(!0,O)}finally{H?U():(T=!1,R=null)}}else T=!1}var U;if(typeof N=="function")U=function(){N(V)};else if(typeof MessageChannel<"u"){var I=new MessageChannel,M=I.port2;I.port1.onmessage=V,U=function(){M.postMessage(null)}}else U=function(){b(V,0)};function B(O){R=O,T||(T=!0,U())}function W(O,H){$=b(function(){O(e.unstable_now())},H)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(O){O.callback=null},e.unstable_continueExecution=function(){k||y||(k=!0,B(D))},e.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<O?Math.floor(1e3/O):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(O){switch(g){case 1:case 2:case 3:var H=3;break;default:H=g}var L=g;g=H;try{return O()}finally{g=L}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(O,H){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var L=g;g=O;try{return H()}finally{g=L}},e.unstable_scheduleCallback=function(O,H,L){var z=e.unstable_now();switch(typeof L=="object"&&L!==null?(L=L.delay,L=typeof L=="number"&&0<L?z+L:z):L=z,O){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=L+Y,O={id:p++,callback:H,priorityLevel:O,startTime:L,expirationTime:Y,sortIndex:-1},L>z?(O.sortIndex=L,t(f,O),n(u)===null&&O===n(f)&&(v?(j($),$=-1):v=!0,W(C,L-z))):(O.sortIndex=Y,t(u,O),k||y||(k=!0,B(D))),O},e.unstable_shouldYield=_,e.unstable_wrapCallback=function(O){var H=g;return function(){var L=g;g=H;try{return O.apply(this,arguments)}finally{g=L}}}})(Kx)),Kx}var h1;function oL(){return h1||(h1=1,qx.exports=sL()),qx.exports}/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var m1;function iL(){if(m1)return xr;m1=1;var e=Ed(),t=oL();function n(c){for(var d="https://reactjs.org/docs/error-decoder.html?invariant="+c,x=1;x<arguments.length;x++)d+="&args[]="+encodeURIComponent(arguments[x]);return"Minified React error #"+c+"; visit "+d+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function i(c,d){a(c,d),a(c+"Capture",d)}function a(c,d){for(o[c]=d,c=0;c<d.length;c++)r.add(d[c])}var l=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},h={};function g(c){return u.call(h,c)?!0:u.call(p,c)?!1:f.test(c)?h[c]=!0:(p[c]=!0,!1)}function y(c,d,x,w){if(x!==null&&x.type===0)return!1;switch(typeof d){case"function":case"symbol":return!0;case"boolean":return w?!1:x!==null?!x.acceptsBooleans:(c=c.toLowerCase().slice(0,5),c!=="data-"&&c!=="aria-");default:return!1}}function k(c,d,x,w){if(d===null||typeof d>"u"||y(c,d,x,w))return!0;if(w)return!1;if(x!==null)switch(x.type){case 3:return!d;case 4:return d===!1;case 5:return isNaN(d);case 6:return isNaN(d)||1>d}return!1}function v(c,d,x,w,E,A,G){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=w,this.attributeNamespace=E,this.mustUseProperty=x,this.propertyName=c,this.type=d,this.sanitizeURL=A,this.removeEmptyString=G}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(c){b[c]=new v(c,0,!1,c,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(c){var d=c[0];b[d]=new v(d,1,!1,c[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(c){b[c]=new v(c,2,!1,c.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(c){b[c]=new v(c,2,!1,c,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(c){b[c]=new v(c,3,!1,c.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(c){b[c]=new v(c,3,!0,c,null,!1,!1)}),["capture","download"].forEach(function(c){b[c]=new v(c,4,!1,c,null,!1,!1)}),["cols","rows","size","span"].forEach(function(c){b[c]=new v(c,6,!1,c,null,!1,!1)}),["rowSpan","start"].forEach(function(c){b[c]=new v(c,5,!1,c.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function N(c){return c[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(c){var d=c.replace(j,N);b[d]=new v(d,1,!1,c,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(c){var d=c.replace(j,N);b[d]=new v(d,1,!1,c,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(c){var d=c.replace(j,N);b[d]=new v(d,1,!1,c,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(c){b[c]=new v(c,1,!1,c.toLowerCase(),null,!1,!1)}),b.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(c){b[c]=new v(c,1,!1,c.toLowerCase(),null,!0,!0)});function S(c,d,x,w){var E=b.hasOwnProperty(d)?b[d]:null;(E!==null?E.type!==0:w||!(2<d.length)||d[0]!=="o"&&d[0]!=="O"||d[1]!=="n"&&d[1]!=="N")&&(k(d,x,E,w)&&(x=null),w||E===null?g(d)&&(x===null?c.removeAttribute(d):c.setAttribute(d,""+x)):E.mustUseProperty?c[E.propertyName]=x===null?E.type===3?!1:"":x:(d=E.attributeName,w=E.attributeNamespace,x===null?c.removeAttribute(d):(E=E.type,x=E===3||E===4&&x===!0?"":""+x,w?c.setAttributeNS(w,d,x):c.setAttribute(d,x))))}var C=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,D=Symbol.for("react.element"),T=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),$=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),F=Symbol.for("react.provider"),_=Symbol.for("react.context"),V=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),W=Symbol.for("react.offscreen"),O=Symbol.iterator;function H(c){return c===null||typeof c!="object"?null:(c=O&&c[O]||c["@@iterator"],typeof c=="function"?c:null)}var L=Object.assign,z;function Y(c){if(z===void 0)try{throw Error()}catch(x){var d=x.stack.trim().match(/\n( *(at )?)/);z=d&&d[1]||""}return`
34
- `+z+c}var q=!1;function Q(c,d){if(!c||q)return"";q=!0;var x=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(d)if(d=function(){throw Error()},Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(he){var w=he}Reflect.construct(c,[],d)}else{try{d.call()}catch(he){w=he}c.call(d.prototype)}else{try{throw Error()}catch(he){w=he}c()}}catch(he){if(he&&w&&typeof he.stack=="string"){for(var E=he.stack.split(`
35
- `),A=w.stack.split(`
36
- `),G=E.length-1,J=A.length-1;1<=G&&0<=J&&E[G]!==A[J];)J--;for(;1<=G&&0<=J;G--,J--)if(E[G]!==A[J]){if(G!==1||J!==1)do if(G--,J--,0>J||E[G]!==A[J]){var se=`
37
- `+E[G].replace(" at new "," at ");return c.displayName&&se.includes("<anonymous>")&&(se=se.replace("<anonymous>",c.displayName)),se}while(1<=G&&0<=J);break}}}finally{q=!1,Error.prepareStackTrace=x}return(c=c?c.displayName||c.name:"")?Y(c):""}function ee(c){switch(c.tag){case 5:return Y(c.type);case 16:return Y("Lazy");case 13:return Y("Suspense");case 19:return Y("SuspenseList");case 0:case 2:case 15:return c=Q(c.type,!1),c;case 11:return c=Q(c.type.render,!1),c;case 1:return c=Q(c.type,!0),c;default:return""}}function Z(c){if(c==null)return null;if(typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case R:return"Fragment";case T:return"Portal";case P:return"Profiler";case $:return"StrictMode";case U:return"Suspense";case I:return"SuspenseList"}if(typeof c=="object")switch(c.$$typeof){case _:return(c.displayName||"Context")+".Consumer";case F:return(c._context.displayName||"Context")+".Provider";case V:var d=c.render;return c=c.displayName,c||(c=d.displayName||d.name||"",c=c!==""?"ForwardRef("+c+")":"ForwardRef"),c;case M:return d=c.displayName||null,d!==null?d:Z(c.type)||"Memo";case B:d=c._payload,c=c._init;try{return Z(c(d))}catch{}}return null}function ie(c){var d=c.type;switch(c.tag){case 24:return"Cache";case 9:return(d.displayName||"Context")+".Consumer";case 10:return(d._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return c=d.render,c=c.displayName||c.name||"",d.displayName||(c!==""?"ForwardRef("+c+")":"ForwardRef");case 7:return"Fragment";case 5:return d;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Z(d);case 8:return d===$?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d}return null}function ne(c){switch(typeof c){case"boolean":case"number":case"string":case"undefined":return c;case"object":return c;default:return""}}function ue(c){var d=c.type;return(c=c.nodeName)&&c.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function ge(c){var d=ue(c)?"checked":"value",x=Object.getOwnPropertyDescriptor(c.constructor.prototype,d),w=""+c[d];if(!c.hasOwnProperty(d)&&typeof x<"u"&&typeof x.get=="function"&&typeof x.set=="function"){var E=x.get,A=x.set;return Object.defineProperty(c,d,{configurable:!0,get:function(){return E.call(this)},set:function(G){w=""+G,A.call(this,G)}}),Object.defineProperty(c,d,{enumerable:x.enumerable}),{getValue:function(){return w},setValue:function(G){w=""+G},stopTracking:function(){c._valueTracker=null,delete c[d]}}}}function Ne(c){c._valueTracker||(c._valueTracker=ge(c))}function Ce(c){if(!c)return!1;var d=c._valueTracker;if(!d)return!0;var x=d.getValue(),w="";return c&&(w=ue(c)?c.checked?"true":"false":c.value),c=w,c!==x?(d.setValue(c),!0):!1}function ke(c){if(c=c||(typeof document<"u"?document:void 0),typeof c>"u")return null;try{return c.activeElement||c.body}catch{return c.body}}function Ue(c,d){var x=d.checked;return L({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:x??c._wrapperState.initialChecked})}function oe(c,d){var x=d.defaultValue==null?"":d.defaultValue,w=d.checked!=null?d.checked:d.defaultChecked;x=ne(d.value!=null?d.value:x),c._wrapperState={initialChecked:w,initialValue:x,controlled:d.type==="checkbox"||d.type==="radio"?d.checked!=null:d.value!=null}}function ve(c,d){d=d.checked,d!=null&&S(c,"checked",d,!1)}function be(c,d){ve(c,d);var x=ne(d.value),w=d.type;if(x!=null)w==="number"?(x===0&&c.value===""||c.value!=x)&&(c.value=""+x):c.value!==""+x&&(c.value=""+x);else if(w==="submit"||w==="reset"){c.removeAttribute("value");return}d.hasOwnProperty("value")?He(c,d.type,x):d.hasOwnProperty("defaultValue")&&He(c,d.type,ne(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(c.defaultChecked=!!d.defaultChecked)}function Re(c,d,x){if(d.hasOwnProperty("value")||d.hasOwnProperty("defaultValue")){var w=d.type;if(!(w!=="submit"&&w!=="reset"||d.value!==void 0&&d.value!==null))return;d=""+c._wrapperState.initialValue,x||d===c.value||(c.value=d),c.defaultValue=d}x=c.name,x!==""&&(c.name=""),c.defaultChecked=!!c._wrapperState.initialChecked,x!==""&&(c.name=x)}function He(c,d,x){(d!=="number"||ke(c.ownerDocument)!==c)&&(x==null?c.defaultValue=""+c._wrapperState.initialValue:c.defaultValue!==""+x&&(c.defaultValue=""+x))}var rt=Array.isArray;function Fe(c,d,x,w){if(c=c.options,d){d={};for(var E=0;E<x.length;E++)d["$"+x[E]]=!0;for(x=0;x<c.length;x++)E=d.hasOwnProperty("$"+c[x].value),c[x].selected!==E&&(c[x].selected=E),E&&w&&(c[x].defaultSelected=!0)}else{for(x=""+ne(x),d=null,E=0;E<c.length;E++){if(c[E].value===x){c[E].selected=!0,w&&(c[E].defaultSelected=!0);return}d!==null||c[E].disabled||(d=c[E])}d!==null&&(d.selected=!0)}}function ot(c,d){if(d.dangerouslySetInnerHTML!=null)throw Error(n(91));return L({},d,{value:void 0,defaultValue:void 0,children:""+c._wrapperState.initialValue})}function Nt(c,d){var x=d.value;if(x==null){if(x=d.children,d=d.defaultValue,x!=null){if(d!=null)throw Error(n(92));if(rt(x)){if(1<x.length)throw Error(n(93));x=x[0]}d=x}d==null&&(d=""),x=d}c._wrapperState={initialValue:ne(x)}}function mt(c,d){var x=ne(d.value),w=ne(d.defaultValue);x!=null&&(x=""+x,x!==c.value&&(c.value=x),d.defaultValue==null&&c.defaultValue!==x&&(c.defaultValue=x)),w!=null&&(c.defaultValue=""+w)}function at(c){var d=c.textContent;d===c._wrapperState.initialValue&&d!==""&&d!==null&&(c.value=d)}function ce(c){switch(c){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function me(c,d){return c==null||c==="http://www.w3.org/1999/xhtml"?ce(d):c==="http://www.w3.org/2000/svg"&&d==="foreignObject"?"http://www.w3.org/1999/xhtml":c}var Ie,Ae=(function(c){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(d,x,w,E){MSApp.execUnsafeLocalFunction(function(){return c(d,x,w,E)})}:c})(function(c,d){if(c.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in c)c.innerHTML=d;else{for(Ie=Ie||document.createElement("div"),Ie.innerHTML="<svg>"+d.valueOf().toString()+"</svg>",d=Ie.firstChild;c.firstChild;)c.removeChild(c.firstChild);for(;d.firstChild;)c.appendChild(d.firstChild)}});function We(c,d){if(d){var x=c.firstChild;if(x&&x===c.lastChild&&x.nodeType===3){x.nodeValue=d;return}}c.textContent=d}var pt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Pe=["Webkit","ms","Moz","O"];Object.keys(pt).forEach(function(c){Pe.forEach(function(d){d=d+c.charAt(0).toUpperCase()+c.substring(1),pt[d]=pt[c]})});function Qe(c,d,x){return d==null||typeof d=="boolean"||d===""?"":x||typeof d!="number"||d===0||pt.hasOwnProperty(c)&&pt[c]?(""+d).trim():d+"px"}function Je(c,d){c=c.style;for(var x in d)if(d.hasOwnProperty(x)){var w=x.indexOf("--")===0,E=Qe(x,d[x],w);x==="float"&&(x="cssFloat"),w?c.setProperty(x,E):c[x]=E}}var ut=L({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function fe(c,d){if(d){if(ut[c]&&(d.children!=null||d.dangerouslySetInnerHTML!=null))throw Error(n(137,c));if(d.dangerouslySetInnerHTML!=null){if(d.children!=null)throw Error(n(60));if(typeof d.dangerouslySetInnerHTML!="object"||!("__html"in d.dangerouslySetInnerHTML))throw Error(n(61))}if(d.style!=null&&typeof d.style!="object")throw Error(n(62))}}function K(c,d){if(c.indexOf("-")===-1)return typeof d.is=="string";switch(c){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var re=null;function xe(c){return c=c.target||c.srcElement||window,c.correspondingUseElement&&(c=c.correspondingUseElement),c.nodeType===3?c.parentNode:c}var Ge=null,ze=null,lt=null;function ht(c){if(c=Qc(c)){if(typeof Ge!="function")throw Error(n(280));var d=c.stateNode;d&&(d=mf(d),Ge(c.stateNode,c.type,d))}}function vt(c){ze?lt?lt.push(c):lt=[c]:ze=c}function tt(){if(ze){var c=ze,d=lt;if(lt=ze=null,ht(c),d)for(c=0;c<d.length;c++)ht(d[c])}}function _t(c,d){return c(d)}function zt(){}var Bt=!1;function we(c,d,x){if(Bt)return c(d,x);Bt=!0;try{return _t(c,d,x)}finally{Bt=!1,(ze!==null||lt!==null)&&(zt(),tt())}}function Oe(c,d){var x=c.stateNode;if(x===null)return null;var w=mf(x);if(w===null)return null;x=w[d];e:switch(d){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(w=!w.disabled)||(c=c.type,w=!(c==="button"||c==="input"||c==="select"||c==="textarea")),c=!w;break e;default:c=!1}if(c)return null;if(x&&typeof x!="function")throw Error(n(231,d,typeof x));return x}var it=!1;if(l)try{var Et={};Object.defineProperty(Et,"passive",{get:function(){it=!0}}),window.addEventListener("test",Et,Et),window.removeEventListener("test",Et,Et)}catch{it=!1}function ln(c,d,x,w,E,A,G,J,se){var he=Array.prototype.slice.call(arguments,3);try{d.apply(x,he)}catch(Te){this.onError(Te)}}var Ut=!1,le=null,Se=!1,nt=null,Tn={onError:function(c){Ut=!0,le=c}};function Er(c,d,x,w,E,A,G,J,se){Ut=!1,le=null,ln.apply(Tn,arguments)}function so(c,d,x,w,E,A,G,J,se){if(Er.apply(this,arguments),Ut){if(Ut){var he=le;Ut=!1,le=null}else throw Error(n(198));Se||(Se=!0,nt=he)}}function wt(c){var d=c,x=c;if(c.alternate)for(;d.return;)d=d.return;else{c=d;do d=c,(d.flags&4098)!==0&&(x=d.return),c=d.return;while(c)}return d.tag===3?x:null}function _i(c){if(c.tag===13){var d=c.memoizedState;if(d===null&&(c=c.alternate,c!==null&&(d=c.memoizedState)),d!==null)return d.dehydrated}return null}function $o(c){if(wt(c)!==c)throw Error(n(188))}function $a(c){var d=c.alternate;if(!d){if(d=wt(c),d===null)throw Error(n(188));return d!==c?null:c}for(var x=c,w=d;;){var E=x.return;if(E===null)break;var A=E.alternate;if(A===null){if(w=E.return,w!==null){x=w;continue}break}if(E.child===A.child){for(A=E.child;A;){if(A===x)return $o(E),c;if(A===w)return $o(E),d;A=A.sibling}throw Error(n(188))}if(x.return!==w.return)x=E,w=A;else{for(var G=!1,J=E.child;J;){if(J===x){G=!0,x=E,w=A;break}if(J===w){G=!0,w=E,x=A;break}J=J.sibling}if(!G){for(J=A.child;J;){if(J===x){G=!0,x=A,w=E;break}if(J===w){G=!0,w=A,x=E;break}J=J.sibling}if(!G)throw Error(n(189))}}if(x.alternate!==w)throw Error(n(190))}if(x.tag!==3)throw Error(n(188));return x.stateNode.current===x?c:d}function nn(c){return c=$a(c),c!==null?Io(c):null}function Io(c){if(c.tag===5||c.tag===6)return c;for(c=c.child;c!==null;){var d=Io(c);if(d!==null)return d;c=c.sibling}return null}var Ia=t.unstable_scheduleCallback,La=t.unstable_cancelCallback,$c=t.unstable_shouldYield,Ma=t.unstable_requestPaint,Ht=t.unstable_now,Di=t.unstable_getCurrentPriorityLevel,oo=t.unstable_ImmediatePriority,Lo=t.unstable_UserBlockingPriority,Ds=t.unstable_NormalPriority,Mo=t.unstable_LowPriority,Oa=t.unstable_IdlePriority,Oo=null,ir=null;function dr(c){if(ir&&typeof ir.onCommitFiberRoot=="function")try{ir.onCommitFiberRoot(Oo,c,void 0,(c.current.flags&128)===128)}catch{}}var On=Math.clz32?Math.clz32:Lc,Fo=Math.log,Ic=Math.LN2;function Lc(c){return c>>>=0,c===0?32:31-(Fo(c)/Ic|0)|0}var zo=64,Wn=4194304;function io(c){switch(c&-c){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return c&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return c}}function qr(c,d){var x=c.pendingLanes;if(x===0)return 0;var w=0,E=c.suspendedLanes,A=c.pingedLanes,G=x&268435455;if(G!==0){var J=G&~E;J!==0?w=io(J):(A&=G,A!==0&&(w=io(A)))}else G=x&~E,G!==0?w=io(G):A!==0&&(w=io(A));if(w===0)return 0;if(d!==0&&d!==w&&(d&E)===0&&(E=w&-w,A=d&-d,E>=A||E===16&&(A&4194240)!==0))return d;if((w&4)!==0&&(w|=x&16),d=c.entangledLanes,d!==0)for(c=c.entanglements,d&=w;0<d;)x=31-On(d),E=1<<x,w|=c[x],d&=~E;return w}function Fa(c,d){switch(c){case 1:case 2:case 4:return d+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return d+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function $i(c,d){for(var x=c.suspendedLanes,w=c.pingedLanes,E=c.expirationTimes,A=c.pendingLanes;0<A;){var G=31-On(A),J=1<<G,se=E[G];se===-1?((J&x)===0||(J&w)!==0)&&(E[G]=Fa(J,d)):se<=d&&(c.expiredLanes|=J),A&=~J}}function Bo(c){return c=c.pendingLanes&-1073741825,c!==0?c:c&1073741824?1073741824:0}function Uo(){var c=zo;return zo<<=1,(zo&4194240)===0&&(zo=64),c}function $s(c){for(var d=[],x=0;31>x;x++)d.push(c);return d}function Fn(c,d,x){c.pendingLanes|=d,d!==536870912&&(c.suspendedLanes=0,c.pingedLanes=0),c=c.eventTimes,d=31-On(d),c[d]=x}function Rn(c,d){var x=c.pendingLanes&~d;c.pendingLanes=d,c.suspendedLanes=0,c.pingedLanes=0,c.expiredLanes&=d,c.mutableReadLanes&=d,c.entangledLanes&=d,d=c.entanglements;var w=c.eventTimes;for(c=c.expirationTimes;0<x;){var E=31-On(x),A=1<<E;d[E]=0,w[E]=-1,c[E]=-1,x&=~A}}function Is(c,d){var x=c.entangledLanes|=d;for(c=c.entanglements;x;){var w=31-On(x),E=1<<w;E&d|c[w]&d&&(c[w]|=d),x&=~E}}var Ot=0;function tf(c){return c&=-c,1<c?4<c?(c&268435455)!==0?16:536870912:4:1}var Mc,Ii,Oc,ao,Fc,za=!1,Ho=[],Ls=null,Ms=null,pn=null,Li=new Map,lo=new Map,Os=[],mg="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function nf(c,d){switch(c){case"focusin":case"focusout":Ls=null;break;case"dragenter":case"dragleave":Ms=null;break;case"mouseover":case"mouseout":pn=null;break;case"pointerover":case"pointerout":Li.delete(d.pointerId);break;case"gotpointercapture":case"lostpointercapture":lo.delete(d.pointerId)}}function Tr(c,d,x,w,E,A){return c===null||c.nativeEvent!==A?(c={blockedOn:d,domEventName:x,eventSystemFlags:w,nativeEvent:A,targetContainers:[E]},d!==null&&(d=Qc(d),d!==null&&Ii(d)),c):(c.eventSystemFlags|=w,d=c.targetContainers,E!==null&&d.indexOf(E)===-1&&d.push(E),c)}function X(c,d,x,w,E){switch(d){case"focusin":return Ls=Tr(Ls,c,d,x,w,E),!0;case"dragenter":return Ms=Tr(Ms,c,d,x,w,E),!0;case"mouseover":return pn=Tr(pn,c,d,x,w,E),!0;case"pointerover":var A=E.pointerId;return Li.set(A,Tr(Li.get(A)||null,c,d,x,w,E)),!0;case"gotpointercapture":return A=E.pointerId,lo.set(A,Tr(lo.get(A)||null,c,d,x,w,E)),!0}return!1}function te(c){var d=Oi(c.target);if(d!==null){var x=wt(d);if(x!==null){if(d=x.tag,d===13){if(d=_i(x),d!==null){c.blockedOn=d,Fc(c.priority,function(){Oc(x)});return}}else if(d===3&&x.stateNode.current.memoizedState.isDehydrated){c.blockedOn=x.tag===3?x.stateNode.containerInfo:null;return}}}c.blockedOn=null}function ye(c){if(c.blockedOn!==null)return!1;for(var d=c.targetContainers;0<d.length;){var x=Wo(c.domEventName,c.eventSystemFlags,d[0],c.nativeEvent);if(x===null){x=c.nativeEvent;var w=new x.constructor(x.type,x);re=w,x.target.dispatchEvent(w),re=null}else return d=Qc(x),d!==null&&Ii(d),c.blockedOn=x,!1;d.shift()}return!0}function Be(c,d,x){ye(c)&&x.delete(d)}function yt(){za=!1,Ls!==null&&ye(Ls)&&(Ls=null),Ms!==null&&ye(Ms)&&(Ms=null),pn!==null&&ye(pn)&&(pn=null),Li.forEach(Be),lo.forEach(Be)}function Tt(c,d){c.blockedOn===d&&(c.blockedOn=null,za||(za=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,yt)))}function Dt(c){function d(E){return Tt(E,c)}if(0<Ho.length){Tt(Ho[0],c);for(var x=1;x<Ho.length;x++){var w=Ho[x];w.blockedOn===c&&(w.blockedOn=null)}}for(Ls!==null&&Tt(Ls,c),Ms!==null&&Tt(Ms,c),pn!==null&&Tt(pn,c),Li.forEach(d),lo.forEach(d),x=0;x<Os.length;x++)w=Os[x],w.blockedOn===c&&(w.blockedOn=null);for(;0<Os.length&&(x=Os[0],x.blockedOn===null);)te(x),x.blockedOn===null&&Os.shift()}var An=C.ReactCurrentBatchConfig,zn=!0;function Pn(c,d,x,w){var E=Ot,A=An.transition;An.transition=null;try{Ot=1,Vo(c,d,x,w)}finally{Ot=E,An.transition=A}}function Rr(c,d,x,w){var E=Ot,A=An.transition;An.transition=null;try{Ot=4,Vo(c,d,x,w)}finally{Ot=E,An.transition=A}}function Vo(c,d,x,w){if(zn){var E=Wo(c,d,x,w);if(E===null)_g(c,d,w,Mi,x),nf(c,w);else if(X(E,c,d,x,w))w.stopPropagation();else if(nf(c,w),d&4&&-1<mg.indexOf(c)){for(;E!==null;){var A=Qc(E);if(A!==null&&Mc(A),A=Wo(c,d,x,w),A===null&&_g(c,d,w,Mi,x),A===E)break;E=A}E!==null&&w.stopPropagation()}else _g(c,d,w,null,x)}}var Mi=null;function Wo(c,d,x,w){if(Mi=null,c=xe(w),c=Oi(c),c!==null)if(d=wt(c),d===null)c=null;else if(x=d.tag,x===13){if(c=_i(d),c!==null)return c;c=null}else if(x===3){if(d.stateNode.current.memoizedState.isDehydrated)return d.tag===3?d.stateNode.containerInfo:null;c=null}else d!==c&&(c=null);return Mi=c,null}function is(c){switch(c){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Di()){case oo:return 1;case Lo:return 4;case Ds:case Mo:return 16;case Oa:return 536870912;default:return 16}default:return 16}}var qo=null,gg=null,rf=null;function X0(){if(rf)return rf;var c,d=gg,x=d.length,w,E="value"in qo?qo.value:qo.textContent,A=E.length;for(c=0;c<x&&d[c]===E[c];c++);var G=x-c;for(w=1;w<=G&&d[x-w]===E[A-w];w++);return rf=E.slice(c,1<w?1-w:void 0)}function sf(c){var d=c.keyCode;return"charCode"in c?(c=c.charCode,c===0&&d===13&&(c=13)):c=d,c===10&&(c=13),32<=c||c===13?c:0}function of(){return!0}function Q0(){return!1}function Ar(c){function d(x,w,E,A,G){this._reactName=x,this._targetInst=E,this.type=w,this.nativeEvent=A,this.target=G,this.currentTarget=null;for(var J in c)c.hasOwnProperty(J)&&(x=c[J],this[J]=x?x(A):A[J]);return this.isDefaultPrevented=(A.defaultPrevented!=null?A.defaultPrevented:A.returnValue===!1)?of:Q0,this.isPropagationStopped=Q0,this}return L(d.prototype,{preventDefault:function(){this.defaultPrevented=!0;var x=this.nativeEvent;x&&(x.preventDefault?x.preventDefault():typeof x.returnValue!="unknown"&&(x.returnValue=!1),this.isDefaultPrevented=of)},stopPropagation:function(){var x=this.nativeEvent;x&&(x.stopPropagation?x.stopPropagation():typeof x.cancelBubble!="unknown"&&(x.cancelBubble=!0),this.isPropagationStopped=of)},persist:function(){},isPersistent:of}),d}var Ba={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(c){return c.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},xg=Ar(Ba),zc=L({},Ba,{view:0,detail:0}),N$=Ar(zc),yg,bg,Bc,af=L({},zc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wg,button:0,buttons:0,relatedTarget:function(c){return c.relatedTarget===void 0?c.fromElement===c.srcElement?c.toElement:c.fromElement:c.relatedTarget},movementX:function(c){return"movementX"in c?c.movementX:(c!==Bc&&(Bc&&c.type==="mousemove"?(yg=c.screenX-Bc.screenX,bg=c.screenY-Bc.screenY):bg=yg=0,Bc=c),yg)},movementY:function(c){return"movementY"in c?c.movementY:bg}}),J0=Ar(af),C$=L({},af,{dataTransfer:0}),E$=Ar(C$),T$=L({},zc,{relatedTarget:0}),vg=Ar(T$),R$=L({},Ba,{animationName:0,elapsedTime:0,pseudoElement:0}),A$=Ar(R$),P$=L({},Ba,{clipboardData:function(c){return"clipboardData"in c?c.clipboardData:window.clipboardData}}),_$=Ar(P$),D$=L({},Ba,{data:0}),Z0=Ar(D$),$$={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},I$={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},L$={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function M$(c){var d=this.nativeEvent;return d.getModifierState?d.getModifierState(c):(c=L$[c])?!!d[c]:!1}function wg(){return M$}var O$=L({},zc,{key:function(c){if(c.key){var d=$$[c.key]||c.key;if(d!=="Unidentified")return d}return c.type==="keypress"?(c=sf(c),c===13?"Enter":String.fromCharCode(c)):c.type==="keydown"||c.type==="keyup"?I$[c.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wg,charCode:function(c){return c.type==="keypress"?sf(c):0},keyCode:function(c){return c.type==="keydown"||c.type==="keyup"?c.keyCode:0},which:function(c){return c.type==="keypress"?sf(c):c.type==="keydown"||c.type==="keyup"?c.keyCode:0}}),F$=Ar(O$),z$=L({},af,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ej=Ar(z$),B$=L({},zc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wg}),U$=Ar(B$),H$=L({},Ba,{propertyName:0,elapsedTime:0,pseudoElement:0}),V$=Ar(H$),W$=L({},af,{deltaX:function(c){return"deltaX"in c?c.deltaX:"wheelDeltaX"in c?-c.wheelDeltaX:0},deltaY:function(c){return"deltaY"in c?c.deltaY:"wheelDeltaY"in c?-c.wheelDeltaY:"wheelDelta"in c?-c.wheelDelta:0},deltaZ:0,deltaMode:0}),q$=Ar(W$),K$=[9,13,27,32],jg=l&&"CompositionEvent"in window,Uc=null;l&&"documentMode"in document&&(Uc=document.documentMode);var G$=l&&"TextEvent"in window&&!Uc,tj=l&&(!jg||Uc&&8<Uc&&11>=Uc),nj=" ",rj=!1;function sj(c,d){switch(c){case"keyup":return K$.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function oj(c){return c=c.detail,typeof c=="object"&&"data"in c?c.data:null}var Ua=!1;function Y$(c,d){switch(c){case"compositionend":return oj(d);case"keypress":return d.which!==32?null:(rj=!0,nj);case"textInput":return c=d.data,c===nj&&rj?null:c;default:return null}}function X$(c,d){if(Ua)return c==="compositionend"||!jg&&sj(c,d)?(c=X0(),rf=gg=qo=null,Ua=!1,c):null;switch(c){case"paste":return null;case"keypress":if(!(d.ctrlKey||d.altKey||d.metaKey)||d.ctrlKey&&d.altKey){if(d.char&&1<d.char.length)return d.char;if(d.which)return String.fromCharCode(d.which)}return null;case"compositionend":return tj&&d.locale!=="ko"?null:d.data;default:return null}}var Q$={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ij(c){var d=c&&c.nodeName&&c.nodeName.toLowerCase();return d==="input"?!!Q$[c.type]:d==="textarea"}function aj(c,d,x,w){vt(w),d=ff(d,"onChange"),0<d.length&&(x=new xg("onChange","change",null,x,w),c.push({event:x,listeners:d}))}var Hc=null,Vc=null;function J$(c){Nj(c,0)}function lf(c){var d=Ka(c);if(Ce(d))return c}function Z$(c,d){if(c==="change")return d}var lj=!1;if(l){var kg;if(l){var Sg="oninput"in document;if(!Sg){var cj=document.createElement("div");cj.setAttribute("oninput","return;"),Sg=typeof cj.oninput=="function"}kg=Sg}else kg=!1;lj=kg&&(!document.documentMode||9<document.documentMode)}function uj(){Hc&&(Hc.detachEvent("onpropertychange",dj),Vc=Hc=null)}function dj(c){if(c.propertyName==="value"&&lf(Vc)){var d=[];aj(d,Vc,c,xe(c)),we(J$,d)}}function eI(c,d,x){c==="focusin"?(uj(),Hc=d,Vc=x,Hc.attachEvent("onpropertychange",dj)):c==="focusout"&&uj()}function tI(c){if(c==="selectionchange"||c==="keyup"||c==="keydown")return lf(Vc)}function nI(c,d){if(c==="click")return lf(d)}function rI(c,d){if(c==="input"||c==="change")return lf(d)}function sI(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var as=typeof Object.is=="function"?Object.is:sI;function Wc(c,d){if(as(c,d))return!0;if(typeof c!="object"||c===null||typeof d!="object"||d===null)return!1;var x=Object.keys(c),w=Object.keys(d);if(x.length!==w.length)return!1;for(w=0;w<x.length;w++){var E=x[w];if(!u.call(d,E)||!as(c[E],d[E]))return!1}return!0}function fj(c){for(;c&&c.firstChild;)c=c.firstChild;return c}function pj(c,d){var x=fj(c);c=0;for(var w;x;){if(x.nodeType===3){if(w=c+x.textContent.length,c<=d&&w>=d)return{node:x,offset:d-c};c=w}e:{for(;x;){if(x.nextSibling){x=x.nextSibling;break e}x=x.parentNode}x=void 0}x=fj(x)}}function hj(c,d){return c&&d?c===d?!0:c&&c.nodeType===3?!1:d&&d.nodeType===3?hj(c,d.parentNode):"contains"in c?c.contains(d):c.compareDocumentPosition?!!(c.compareDocumentPosition(d)&16):!1:!1}function mj(){for(var c=window,d=ke();d instanceof c.HTMLIFrameElement;){try{var x=typeof d.contentWindow.location.href=="string"}catch{x=!1}if(x)c=d.contentWindow;else break;d=ke(c.document)}return d}function Ng(c){var d=c&&c.nodeName&&c.nodeName.toLowerCase();return d&&(d==="input"&&(c.type==="text"||c.type==="search"||c.type==="tel"||c.type==="url"||c.type==="password")||d==="textarea"||c.contentEditable==="true")}function oI(c){var d=mj(),x=c.focusedElem,w=c.selectionRange;if(d!==x&&x&&x.ownerDocument&&hj(x.ownerDocument.documentElement,x)){if(w!==null&&Ng(x)){if(d=w.start,c=w.end,c===void 0&&(c=d),"selectionStart"in x)x.selectionStart=d,x.selectionEnd=Math.min(c,x.value.length);else if(c=(d=x.ownerDocument||document)&&d.defaultView||window,c.getSelection){c=c.getSelection();var E=x.textContent.length,A=Math.min(w.start,E);w=w.end===void 0?A:Math.min(w.end,E),!c.extend&&A>w&&(E=w,w=A,A=E),E=pj(x,A);var G=pj(x,w);E&&G&&(c.rangeCount!==1||c.anchorNode!==E.node||c.anchorOffset!==E.offset||c.focusNode!==G.node||c.focusOffset!==G.offset)&&(d=d.createRange(),d.setStart(E.node,E.offset),c.removeAllRanges(),A>w?(c.addRange(d),c.extend(G.node,G.offset)):(d.setEnd(G.node,G.offset),c.addRange(d)))}}for(d=[],c=x;c=c.parentNode;)c.nodeType===1&&d.push({element:c,left:c.scrollLeft,top:c.scrollTop});for(typeof x.focus=="function"&&x.focus(),x=0;x<d.length;x++)c=d[x],c.element.scrollLeft=c.left,c.element.scrollTop=c.top}}var iI=l&&"documentMode"in document&&11>=document.documentMode,Ha=null,Cg=null,qc=null,Eg=!1;function gj(c,d,x){var w=x.window===x?x.document:x.nodeType===9?x:x.ownerDocument;Eg||Ha==null||Ha!==ke(w)||(w=Ha,"selectionStart"in w&&Ng(w)?w={start:w.selectionStart,end:w.selectionEnd}:(w=(w.ownerDocument&&w.ownerDocument.defaultView||window).getSelection(),w={anchorNode:w.anchorNode,anchorOffset:w.anchorOffset,focusNode:w.focusNode,focusOffset:w.focusOffset}),qc&&Wc(qc,w)||(qc=w,w=ff(Cg,"onSelect"),0<w.length&&(d=new xg("onSelect","select",null,d,x),c.push({event:d,listeners:w}),d.target=Ha)))}function cf(c,d){var x={};return x[c.toLowerCase()]=d.toLowerCase(),x["Webkit"+c]="webkit"+d,x["Moz"+c]="moz"+d,x}var Va={animationend:cf("Animation","AnimationEnd"),animationiteration:cf("Animation","AnimationIteration"),animationstart:cf("Animation","AnimationStart"),transitionend:cf("Transition","TransitionEnd")},Tg={},xj={};l&&(xj=document.createElement("div").style,"AnimationEvent"in window||(delete Va.animationend.animation,delete Va.animationiteration.animation,delete Va.animationstart.animation),"TransitionEvent"in window||delete Va.transitionend.transition);function uf(c){if(Tg[c])return Tg[c];if(!Va[c])return c;var d=Va[c],x;for(x in d)if(d.hasOwnProperty(x)&&x in xj)return Tg[c]=d[x];return c}var yj=uf("animationend"),bj=uf("animationiteration"),vj=uf("animationstart"),wj=uf("transitionend"),jj=new Map,kj="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Ko(c,d){jj.set(c,d),i(d,[c])}for(var Rg=0;Rg<kj.length;Rg++){var Ag=kj[Rg],aI=Ag.toLowerCase(),lI=Ag[0].toUpperCase()+Ag.slice(1);Ko(aI,"on"+lI)}Ko(yj,"onAnimationEnd"),Ko(bj,"onAnimationIteration"),Ko(vj,"onAnimationStart"),Ko("dblclick","onDoubleClick"),Ko("focusin","onFocus"),Ko("focusout","onBlur"),Ko(wj,"onTransitionEnd"),a("onMouseEnter",["mouseout","mouseover"]),a("onMouseLeave",["mouseout","mouseover"]),a("onPointerEnter",["pointerout","pointerover"]),a("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Kc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),cI=new Set("cancel close invalid load scroll toggle".split(" ").concat(Kc));function Sj(c,d,x){var w=c.type||"unknown-event";c.currentTarget=x,so(w,d,void 0,c),c.currentTarget=null}function Nj(c,d){d=(d&4)!==0;for(var x=0;x<c.length;x++){var w=c[x],E=w.event;w=w.listeners;e:{var A=void 0;if(d)for(var G=w.length-1;0<=G;G--){var J=w[G],se=J.instance,he=J.currentTarget;if(J=J.listener,se!==A&&E.isPropagationStopped())break e;Sj(E,J,he),A=se}else for(G=0;G<w.length;G++){if(J=w[G],se=J.instance,he=J.currentTarget,J=J.listener,se!==A&&E.isPropagationStopped())break e;Sj(E,J,he),A=se}}}if(Se)throw c=nt,Se=!1,nt=null,c}function Xt(c,d){var x=d[Og];x===void 0&&(x=d[Og]=new Set);var w=c+"__bubble";x.has(w)||(Cj(d,c,2,!1),x.add(w))}function Pg(c,d,x){var w=0;d&&(w|=4),Cj(x,c,w,d)}var df="_reactListening"+Math.random().toString(36).slice(2);function Gc(c){if(!c[df]){c[df]=!0,r.forEach(function(x){x!=="selectionchange"&&(cI.has(x)||Pg(x,!1,c),Pg(x,!0,c))});var d=c.nodeType===9?c:c.ownerDocument;d===null||d[df]||(d[df]=!0,Pg("selectionchange",!1,d))}}function Cj(c,d,x,w){switch(is(d)){case 1:var E=Pn;break;case 4:E=Rr;break;default:E=Vo}x=E.bind(null,d,x,c),E=void 0,!it||d!=="touchstart"&&d!=="touchmove"&&d!=="wheel"||(E=!0),w?E!==void 0?c.addEventListener(d,x,{capture:!0,passive:E}):c.addEventListener(d,x,!0):E!==void 0?c.addEventListener(d,x,{passive:E}):c.addEventListener(d,x,!1)}function _g(c,d,x,w,E){var A=w;if((d&1)===0&&(d&2)===0&&w!==null)e:for(;;){if(w===null)return;var G=w.tag;if(G===3||G===4){var J=w.stateNode.containerInfo;if(J===E||J.nodeType===8&&J.parentNode===E)break;if(G===4)for(G=w.return;G!==null;){var se=G.tag;if((se===3||se===4)&&(se=G.stateNode.containerInfo,se===E||se.nodeType===8&&se.parentNode===E))return;G=G.return}for(;J!==null;){if(G=Oi(J),G===null)return;if(se=G.tag,se===5||se===6){w=A=G;continue e}J=J.parentNode}}w=w.return}we(function(){var he=A,Te=xe(x),_e=[];e:{var Ee=jj.get(c);if(Ee!==void 0){var Ke=xg,Ze=c;switch(c){case"keypress":if(sf(x)===0)break e;case"keydown":case"keyup":Ke=F$;break;case"focusin":Ze="focus",Ke=vg;break;case"focusout":Ze="blur",Ke=vg;break;case"beforeblur":case"afterblur":Ke=vg;break;case"click":if(x.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ke=J0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ke=E$;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ke=U$;break;case yj:case bj:case vj:Ke=A$;break;case wj:Ke=V$;break;case"scroll":Ke=N$;break;case"wheel":Ke=q$;break;case"copy":case"cut":case"paste":Ke=_$;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ke=ej}var et=(d&4)!==0,hn=!et&&c==="scroll",de=et?Ee!==null?Ee+"Capture":null:Ee;et=[];for(var ae=he,pe;ae!==null;){pe=ae;var Me=pe.stateNode;if(pe.tag===5&&Me!==null&&(pe=Me,de!==null&&(Me=Oe(ae,de),Me!=null&&et.push(Yc(ae,Me,pe)))),hn)break;ae=ae.return}0<et.length&&(Ee=new Ke(Ee,Ze,null,x,Te),_e.push({event:Ee,listeners:et}))}}if((d&7)===0){e:{if(Ee=c==="mouseover"||c==="pointerover",Ke=c==="mouseout"||c==="pointerout",Ee&&x!==re&&(Ze=x.relatedTarget||x.fromElement)&&(Oi(Ze)||Ze[co]))break e;if((Ke||Ee)&&(Ee=Te.window===Te?Te:(Ee=Te.ownerDocument)?Ee.defaultView||Ee.parentWindow:window,Ke?(Ze=x.relatedTarget||x.toElement,Ke=he,Ze=Ze?Oi(Ze):null,Ze!==null&&(hn=wt(Ze),Ze!==hn||Ze.tag!==5&&Ze.tag!==6)&&(Ze=null)):(Ke=null,Ze=he),Ke!==Ze)){if(et=J0,Me="onMouseLeave",de="onMouseEnter",ae="mouse",(c==="pointerout"||c==="pointerover")&&(et=ej,Me="onPointerLeave",de="onPointerEnter",ae="pointer"),hn=Ke==null?Ee:Ka(Ke),pe=Ze==null?Ee:Ka(Ze),Ee=new et(Me,ae+"leave",Ke,x,Te),Ee.target=hn,Ee.relatedTarget=pe,Me=null,Oi(Te)===he&&(et=new et(de,ae+"enter",Ze,x,Te),et.target=pe,et.relatedTarget=hn,Me=et),hn=Me,Ke&&Ze)t:{for(et=Ke,de=Ze,ae=0,pe=et;pe;pe=Wa(pe))ae++;for(pe=0,Me=de;Me;Me=Wa(Me))pe++;for(;0<ae-pe;)et=Wa(et),ae--;for(;0<pe-ae;)de=Wa(de),pe--;for(;ae--;){if(et===de||de!==null&&et===de.alternate)break t;et=Wa(et),de=Wa(de)}et=null}else et=null;Ke!==null&&Ej(_e,Ee,Ke,et,!1),Ze!==null&&hn!==null&&Ej(_e,hn,Ze,et,!0)}}e:{if(Ee=he?Ka(he):window,Ke=Ee.nodeName&&Ee.nodeName.toLowerCase(),Ke==="select"||Ke==="input"&&Ee.type==="file")var st=Z$;else if(ij(Ee))if(lj)st=rI;else{st=tI;var dt=eI}else(Ke=Ee.nodeName)&&Ke.toLowerCase()==="input"&&(Ee.type==="checkbox"||Ee.type==="radio")&&(st=nI);if(st&&(st=st(c,he))){aj(_e,st,x,Te);break e}dt&&dt(c,Ee,he),c==="focusout"&&(dt=Ee._wrapperState)&&dt.controlled&&Ee.type==="number"&&He(Ee,"number",Ee.value)}switch(dt=he?Ka(he):window,c){case"focusin":(ij(dt)||dt.contentEditable==="true")&&(Ha=dt,Cg=he,qc=null);break;case"focusout":qc=Cg=Ha=null;break;case"mousedown":Eg=!0;break;case"contextmenu":case"mouseup":case"dragend":Eg=!1,gj(_e,x,Te);break;case"selectionchange":if(iI)break;case"keydown":case"keyup":gj(_e,x,Te)}var ft;if(jg)e:{switch(c){case"compositionstart":var gt="onCompositionStart";break e;case"compositionend":gt="onCompositionEnd";break e;case"compositionupdate":gt="onCompositionUpdate";break e}gt=void 0}else Ua?sj(c,x)&&(gt="onCompositionEnd"):c==="keydown"&&x.keyCode===229&&(gt="onCompositionStart");gt&&(tj&&x.locale!=="ko"&&(Ua||gt!=="onCompositionStart"?gt==="onCompositionEnd"&&Ua&&(ft=X0()):(qo=Te,gg="value"in qo?qo.value:qo.textContent,Ua=!0)),dt=ff(he,gt),0<dt.length&&(gt=new Z0(gt,c,null,x,Te),_e.push({event:gt,listeners:dt}),ft?gt.data=ft:(ft=oj(x),ft!==null&&(gt.data=ft)))),(ft=G$?Y$(c,x):X$(c,x))&&(he=ff(he,"onBeforeInput"),0<he.length&&(Te=new Z0("onBeforeInput","beforeinput",null,x,Te),_e.push({event:Te,listeners:he}),Te.data=ft))}Nj(_e,d)})}function Yc(c,d,x){return{instance:c,listener:d,currentTarget:x}}function ff(c,d){for(var x=d+"Capture",w=[];c!==null;){var E=c,A=E.stateNode;E.tag===5&&A!==null&&(E=A,A=Oe(c,x),A!=null&&w.unshift(Yc(c,A,E)),A=Oe(c,d),A!=null&&w.push(Yc(c,A,E))),c=c.return}return w}function Wa(c){if(c===null)return null;do c=c.return;while(c&&c.tag!==5);return c||null}function Ej(c,d,x,w,E){for(var A=d._reactName,G=[];x!==null&&x!==w;){var J=x,se=J.alternate,he=J.stateNode;if(se!==null&&se===w)break;J.tag===5&&he!==null&&(J=he,E?(se=Oe(x,A),se!=null&&G.unshift(Yc(x,se,J))):E||(se=Oe(x,A),se!=null&&G.push(Yc(x,se,J)))),x=x.return}G.length!==0&&c.push({event:d,listeners:G})}var uI=/\r\n?/g,dI=/\u0000|\uFFFD/g;function Tj(c){return(typeof c=="string"?c:""+c).replace(uI,`
38
- `).replace(dI,"")}function pf(c,d,x){if(d=Tj(d),Tj(c)!==d&&x)throw Error(n(425))}function hf(){}var Dg=null,$g=null;function Ig(c,d){return c==="textarea"||c==="noscript"||typeof d.children=="string"||typeof d.children=="number"||typeof d.dangerouslySetInnerHTML=="object"&&d.dangerouslySetInnerHTML!==null&&d.dangerouslySetInnerHTML.__html!=null}var Lg=typeof setTimeout=="function"?setTimeout:void 0,fI=typeof clearTimeout=="function"?clearTimeout:void 0,Rj=typeof Promise=="function"?Promise:void 0,pI=typeof queueMicrotask=="function"?queueMicrotask:typeof Rj<"u"?function(c){return Rj.resolve(null).then(c).catch(hI)}:Lg;function hI(c){setTimeout(function(){throw c})}function Mg(c,d){var x=d,w=0;do{var E=x.nextSibling;if(c.removeChild(x),E&&E.nodeType===8)if(x=E.data,x==="/$"){if(w===0){c.removeChild(E),Dt(d);return}w--}else x!=="$"&&x!=="$?"&&x!=="$!"||w++;x=E}while(x);Dt(d)}function Go(c){for(;c!=null;c=c.nextSibling){var d=c.nodeType;if(d===1||d===3)break;if(d===8){if(d=c.data,d==="$"||d==="$!"||d==="$?")break;if(d==="/$")return null}}return c}function Aj(c){c=c.previousSibling;for(var d=0;c;){if(c.nodeType===8){var x=c.data;if(x==="$"||x==="$!"||x==="$?"){if(d===0)return c;d--}else x==="/$"&&d++}c=c.previousSibling}return null}var qa=Math.random().toString(36).slice(2),Fs="__reactFiber$"+qa,Xc="__reactProps$"+qa,co="__reactContainer$"+qa,Og="__reactEvents$"+qa,mI="__reactListeners$"+qa,gI="__reactHandles$"+qa;function Oi(c){var d=c[Fs];if(d)return d;for(var x=c.parentNode;x;){if(d=x[co]||x[Fs]){if(x=d.alternate,d.child!==null||x!==null&&x.child!==null)for(c=Aj(c);c!==null;){if(x=c[Fs])return x;c=Aj(c)}return d}c=x,x=c.parentNode}return null}function Qc(c){return c=c[Fs]||c[co],!c||c.tag!==5&&c.tag!==6&&c.tag!==13&&c.tag!==3?null:c}function Ka(c){if(c.tag===5||c.tag===6)return c.stateNode;throw Error(n(33))}function mf(c){return c[Xc]||null}var Fg=[],Ga=-1;function Yo(c){return{current:c}}function Qt(c){0>Ga||(c.current=Fg[Ga],Fg[Ga]=null,Ga--)}function Kt(c,d){Ga++,Fg[Ga]=c.current,c.current=d}var Xo={},Jn=Yo(Xo),fr=Yo(!1),Fi=Xo;function Ya(c,d){var x=c.type.contextTypes;if(!x)return Xo;var w=c.stateNode;if(w&&w.__reactInternalMemoizedUnmaskedChildContext===d)return w.__reactInternalMemoizedMaskedChildContext;var E={},A;for(A in x)E[A]=d[A];return w&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=d,c.__reactInternalMemoizedMaskedChildContext=E),E}function pr(c){return c=c.childContextTypes,c!=null}function gf(){Qt(fr),Qt(Jn)}function Pj(c,d,x){if(Jn.current!==Xo)throw Error(n(168));Kt(Jn,d),Kt(fr,x)}function _j(c,d,x){var w=c.stateNode;if(d=d.childContextTypes,typeof w.getChildContext!="function")return x;w=w.getChildContext();for(var E in w)if(!(E in d))throw Error(n(108,ie(c)||"Unknown",E));return L({},x,w)}function xf(c){return c=(c=c.stateNode)&&c.__reactInternalMemoizedMergedChildContext||Xo,Fi=Jn.current,Kt(Jn,c),Kt(fr,fr.current),!0}function Dj(c,d,x){var w=c.stateNode;if(!w)throw Error(n(169));x?(c=_j(c,d,Fi),w.__reactInternalMemoizedMergedChildContext=c,Qt(fr),Qt(Jn),Kt(Jn,c)):Qt(fr),Kt(fr,x)}var uo=null,yf=!1,zg=!1;function $j(c){uo===null?uo=[c]:uo.push(c)}function xI(c){yf=!0,$j(c)}function Qo(){if(!zg&&uo!==null){zg=!0;var c=0,d=Ot;try{var x=uo;for(Ot=1;c<x.length;c++){var w=x[c];do w=w(!0);while(w!==null)}uo=null,yf=!1}catch(E){throw uo!==null&&(uo=uo.slice(c+1)),Ia(oo,Qo),E}finally{Ot=d,zg=!1}}return null}var Xa=[],Qa=0,bf=null,vf=0,Kr=[],Gr=0,zi=null,fo=1,po="";function Bi(c,d){Xa[Qa++]=vf,Xa[Qa++]=bf,bf=c,vf=d}function Ij(c,d,x){Kr[Gr++]=fo,Kr[Gr++]=po,Kr[Gr++]=zi,zi=c;var w=fo;c=po;var E=32-On(w)-1;w&=~(1<<E),x+=1;var A=32-On(d)+E;if(30<A){var G=E-E%5;A=(w&(1<<G)-1).toString(32),w>>=G,E-=G,fo=1<<32-On(d)+E|x<<E|w,po=A+c}else fo=1<<A|x<<E|w,po=c}function Bg(c){c.return!==null&&(Bi(c,1),Ij(c,1,0))}function Ug(c){for(;c===bf;)bf=Xa[--Qa],Xa[Qa]=null,vf=Xa[--Qa],Xa[Qa]=null;for(;c===zi;)zi=Kr[--Gr],Kr[Gr]=null,po=Kr[--Gr],Kr[Gr]=null,fo=Kr[--Gr],Kr[Gr]=null}var Pr=null,_r=null,rn=!1,ls=null;function Lj(c,d){var x=Jr(5,null,null,0);x.elementType="DELETED",x.stateNode=d,x.return=c,d=c.deletions,d===null?(c.deletions=[x],c.flags|=16):d.push(x)}function Mj(c,d){switch(c.tag){case 5:var x=c.type;return d=d.nodeType!==1||x.toLowerCase()!==d.nodeName.toLowerCase()?null:d,d!==null?(c.stateNode=d,Pr=c,_r=Go(d.firstChild),!0):!1;case 6:return d=c.pendingProps===""||d.nodeType!==3?null:d,d!==null?(c.stateNode=d,Pr=c,_r=null,!0):!1;case 13:return d=d.nodeType!==8?null:d,d!==null?(x=zi!==null?{id:fo,overflow:po}:null,c.memoizedState={dehydrated:d,treeContext:x,retryLane:1073741824},x=Jr(18,null,null,0),x.stateNode=d,x.return=c,c.child=x,Pr=c,_r=null,!0):!1;default:return!1}}function Hg(c){return(c.mode&1)!==0&&(c.flags&128)===0}function Vg(c){if(rn){var d=_r;if(d){var x=d;if(!Mj(c,d)){if(Hg(c))throw Error(n(418));d=Go(x.nextSibling);var w=Pr;d&&Mj(c,d)?Lj(w,x):(c.flags=c.flags&-4097|2,rn=!1,Pr=c)}}else{if(Hg(c))throw Error(n(418));c.flags=c.flags&-4097|2,rn=!1,Pr=c}}}function Oj(c){for(c=c.return;c!==null&&c.tag!==5&&c.tag!==3&&c.tag!==13;)c=c.return;Pr=c}function wf(c){if(c!==Pr)return!1;if(!rn)return Oj(c),rn=!0,!1;var d;if((d=c.tag!==3)&&!(d=c.tag!==5)&&(d=c.type,d=d!=="head"&&d!=="body"&&!Ig(c.type,c.memoizedProps)),d&&(d=_r)){if(Hg(c))throw Fj(),Error(n(418));for(;d;)Lj(c,d),d=Go(d.nextSibling)}if(Oj(c),c.tag===13){if(c=c.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(n(317));e:{for(c=c.nextSibling,d=0;c;){if(c.nodeType===8){var x=c.data;if(x==="/$"){if(d===0){_r=Go(c.nextSibling);break e}d--}else x!=="$"&&x!=="$!"&&x!=="$?"||d++}c=c.nextSibling}_r=null}}else _r=Pr?Go(c.stateNode.nextSibling):null;return!0}function Fj(){for(var c=_r;c;)c=Go(c.nextSibling)}function Ja(){_r=Pr=null,rn=!1}function Wg(c){ls===null?ls=[c]:ls.push(c)}var yI=C.ReactCurrentBatchConfig;function Jc(c,d,x){if(c=x.ref,c!==null&&typeof c!="function"&&typeof c!="object"){if(x._owner){if(x=x._owner,x){if(x.tag!==1)throw Error(n(309));var w=x.stateNode}if(!w)throw Error(n(147,c));var E=w,A=""+c;return d!==null&&d.ref!==null&&typeof d.ref=="function"&&d.ref._stringRef===A?d.ref:(d=function(G){var J=E.refs;G===null?delete J[A]:J[A]=G},d._stringRef=A,d)}if(typeof c!="string")throw Error(n(284));if(!x._owner)throw Error(n(290,c))}return c}function jf(c,d){throw c=Object.prototype.toString.call(d),Error(n(31,c==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":c))}function zj(c){var d=c._init;return d(c._payload)}function Bj(c){function d(de,ae){if(c){var pe=de.deletions;pe===null?(de.deletions=[ae],de.flags|=16):pe.push(ae)}}function x(de,ae){if(!c)return null;for(;ae!==null;)d(de,ae),ae=ae.sibling;return null}function w(de,ae){for(de=new Map;ae!==null;)ae.key!==null?de.set(ae.key,ae):de.set(ae.index,ae),ae=ae.sibling;return de}function E(de,ae){return de=oi(de,ae),de.index=0,de.sibling=null,de}function A(de,ae,pe){return de.index=pe,c?(pe=de.alternate,pe!==null?(pe=pe.index,pe<ae?(de.flags|=2,ae):pe):(de.flags|=2,ae)):(de.flags|=1048576,ae)}function G(de){return c&&de.alternate===null&&(de.flags|=2),de}function J(de,ae,pe,Me){return ae===null||ae.tag!==6?(ae=Lx(pe,de.mode,Me),ae.return=de,ae):(ae=E(ae,pe),ae.return=de,ae)}function se(de,ae,pe,Me){var st=pe.type;return st===R?Te(de,ae,pe.props.children,Me,pe.key):ae!==null&&(ae.elementType===st||typeof st=="object"&&st!==null&&st.$$typeof===B&&zj(st)===ae.type)?(Me=E(ae,pe.props),Me.ref=Jc(de,ae,pe),Me.return=de,Me):(Me=qf(pe.type,pe.key,pe.props,null,de.mode,Me),Me.ref=Jc(de,ae,pe),Me.return=de,Me)}function he(de,ae,pe,Me){return ae===null||ae.tag!==4||ae.stateNode.containerInfo!==pe.containerInfo||ae.stateNode.implementation!==pe.implementation?(ae=Mx(pe,de.mode,Me),ae.return=de,ae):(ae=E(ae,pe.children||[]),ae.return=de,ae)}function Te(de,ae,pe,Me,st){return ae===null||ae.tag!==7?(ae=Yi(pe,de.mode,Me,st),ae.return=de,ae):(ae=E(ae,pe),ae.return=de,ae)}function _e(de,ae,pe){if(typeof ae=="string"&&ae!==""||typeof ae=="number")return ae=Lx(""+ae,de.mode,pe),ae.return=de,ae;if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case D:return pe=qf(ae.type,ae.key,ae.props,null,de.mode,pe),pe.ref=Jc(de,null,ae),pe.return=de,pe;case T:return ae=Mx(ae,de.mode,pe),ae.return=de,ae;case B:var Me=ae._init;return _e(de,Me(ae._payload),pe)}if(rt(ae)||H(ae))return ae=Yi(ae,de.mode,pe,null),ae.return=de,ae;jf(de,ae)}return null}function Ee(de,ae,pe,Me){var st=ae!==null?ae.key:null;if(typeof pe=="string"&&pe!==""||typeof pe=="number")return st!==null?null:J(de,ae,""+pe,Me);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case D:return pe.key===st?se(de,ae,pe,Me):null;case T:return pe.key===st?he(de,ae,pe,Me):null;case B:return st=pe._init,Ee(de,ae,st(pe._payload),Me)}if(rt(pe)||H(pe))return st!==null?null:Te(de,ae,pe,Me,null);jf(de,pe)}return null}function Ke(de,ae,pe,Me,st){if(typeof Me=="string"&&Me!==""||typeof Me=="number")return de=de.get(pe)||null,J(ae,de,""+Me,st);if(typeof Me=="object"&&Me!==null){switch(Me.$$typeof){case D:return de=de.get(Me.key===null?pe:Me.key)||null,se(ae,de,Me,st);case T:return de=de.get(Me.key===null?pe:Me.key)||null,he(ae,de,Me,st);case B:var dt=Me._init;return Ke(de,ae,pe,dt(Me._payload),st)}if(rt(Me)||H(Me))return de=de.get(pe)||null,Te(ae,de,Me,st,null);jf(ae,Me)}return null}function Ze(de,ae,pe,Me){for(var st=null,dt=null,ft=ae,gt=ae=0,Hn=null;ft!==null&&gt<pe.length;gt++){ft.index>gt?(Hn=ft,ft=null):Hn=ft.sibling;var It=Ee(de,ft,pe[gt],Me);if(It===null){ft===null&&(ft=Hn);break}c&&ft&&It.alternate===null&&d(de,ft),ae=A(It,ae,gt),dt===null?st=It:dt.sibling=It,dt=It,ft=Hn}if(gt===pe.length)return x(de,ft),rn&&Bi(de,gt),st;if(ft===null){for(;gt<pe.length;gt++)ft=_e(de,pe[gt],Me),ft!==null&&(ae=A(ft,ae,gt),dt===null?st=ft:dt.sibling=ft,dt=ft);return rn&&Bi(de,gt),st}for(ft=w(de,ft);gt<pe.length;gt++)Hn=Ke(ft,de,gt,pe[gt],Me),Hn!==null&&(c&&Hn.alternate!==null&&ft.delete(Hn.key===null?gt:Hn.key),ae=A(Hn,ae,gt),dt===null?st=Hn:dt.sibling=Hn,dt=Hn);return c&&ft.forEach(function(ii){return d(de,ii)}),rn&&Bi(de,gt),st}function et(de,ae,pe,Me){var st=H(pe);if(typeof st!="function")throw Error(n(150));if(pe=st.call(pe),pe==null)throw Error(n(151));for(var dt=st=null,ft=ae,gt=ae=0,Hn=null,It=pe.next();ft!==null&&!It.done;gt++,It=pe.next()){ft.index>gt?(Hn=ft,ft=null):Hn=ft.sibling;var ii=Ee(de,ft,It.value,Me);if(ii===null){ft===null&&(ft=Hn);break}c&&ft&&ii.alternate===null&&d(de,ft),ae=A(ii,ae,gt),dt===null?st=ii:dt.sibling=ii,dt=ii,ft=Hn}if(It.done)return x(de,ft),rn&&Bi(de,gt),st;if(ft===null){for(;!It.done;gt++,It=pe.next())It=_e(de,It.value,Me),It!==null&&(ae=A(It,ae,gt),dt===null?st=It:dt.sibling=It,dt=It);return rn&&Bi(de,gt),st}for(ft=w(de,ft);!It.done;gt++,It=pe.next())It=Ke(ft,de,gt,It.value,Me),It!==null&&(c&&It.alternate!==null&&ft.delete(It.key===null?gt:It.key),ae=A(It,ae,gt),dt===null?st=It:dt.sibling=It,dt=It);return c&&ft.forEach(function(QI){return d(de,QI)}),rn&&Bi(de,gt),st}function hn(de,ae,pe,Me){if(typeof pe=="object"&&pe!==null&&pe.type===R&&pe.key===null&&(pe=pe.props.children),typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case D:e:{for(var st=pe.key,dt=ae;dt!==null;){if(dt.key===st){if(st=pe.type,st===R){if(dt.tag===7){x(de,dt.sibling),ae=E(dt,pe.props.children),ae.return=de,de=ae;break e}}else if(dt.elementType===st||typeof st=="object"&&st!==null&&st.$$typeof===B&&zj(st)===dt.type){x(de,dt.sibling),ae=E(dt,pe.props),ae.ref=Jc(de,dt,pe),ae.return=de,de=ae;break e}x(de,dt);break}else d(de,dt);dt=dt.sibling}pe.type===R?(ae=Yi(pe.props.children,de.mode,Me,pe.key),ae.return=de,de=ae):(Me=qf(pe.type,pe.key,pe.props,null,de.mode,Me),Me.ref=Jc(de,ae,pe),Me.return=de,de=Me)}return G(de);case T:e:{for(dt=pe.key;ae!==null;){if(ae.key===dt)if(ae.tag===4&&ae.stateNode.containerInfo===pe.containerInfo&&ae.stateNode.implementation===pe.implementation){x(de,ae.sibling),ae=E(ae,pe.children||[]),ae.return=de,de=ae;break e}else{x(de,ae);break}else d(de,ae);ae=ae.sibling}ae=Mx(pe,de.mode,Me),ae.return=de,de=ae}return G(de);case B:return dt=pe._init,hn(de,ae,dt(pe._payload),Me)}if(rt(pe))return Ze(de,ae,pe,Me);if(H(pe))return et(de,ae,pe,Me);jf(de,pe)}return typeof pe=="string"&&pe!==""||typeof pe=="number"?(pe=""+pe,ae!==null&&ae.tag===6?(x(de,ae.sibling),ae=E(ae,pe),ae.return=de,de=ae):(x(de,ae),ae=Lx(pe,de.mode,Me),ae.return=de,de=ae),G(de)):x(de,ae)}return hn}var Za=Bj(!0),Uj=Bj(!1),kf=Yo(null),Sf=null,el=null,qg=null;function Kg(){qg=el=Sf=null}function Gg(c){var d=kf.current;Qt(kf),c._currentValue=d}function Yg(c,d,x){for(;c!==null;){var w=c.alternate;if((c.childLanes&d)!==d?(c.childLanes|=d,w!==null&&(w.childLanes|=d)):w!==null&&(w.childLanes&d)!==d&&(w.childLanes|=d),c===x)break;c=c.return}}function tl(c,d){Sf=c,qg=el=null,c=c.dependencies,c!==null&&c.firstContext!==null&&((c.lanes&d)!==0&&(hr=!0),c.firstContext=null)}function Yr(c){var d=c._currentValue;if(qg!==c)if(c={context:c,memoizedValue:d,next:null},el===null){if(Sf===null)throw Error(n(308));el=c,Sf.dependencies={lanes:0,firstContext:c}}else el=el.next=c;return d}var Ui=null;function Xg(c){Ui===null?Ui=[c]:Ui.push(c)}function Hj(c,d,x,w){var E=d.interleaved;return E===null?(x.next=x,Xg(d)):(x.next=E.next,E.next=x),d.interleaved=x,ho(c,w)}function ho(c,d){c.lanes|=d;var x=c.alternate;for(x!==null&&(x.lanes|=d),x=c,c=c.return;c!==null;)c.childLanes|=d,x=c.alternate,x!==null&&(x.childLanes|=d),x=c,c=c.return;return x.tag===3?x.stateNode:null}var Jo=!1;function Qg(c){c.updateQueue={baseState:c.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Vj(c,d){c=c.updateQueue,d.updateQueue===c&&(d.updateQueue={baseState:c.baseState,firstBaseUpdate:c.firstBaseUpdate,lastBaseUpdate:c.lastBaseUpdate,shared:c.shared,effects:c.effects})}function mo(c,d){return{eventTime:c,lane:d,tag:0,payload:null,callback:null,next:null}}function Zo(c,d,x){var w=c.updateQueue;if(w===null)return null;if(w=w.shared,($t&2)!==0){var E=w.pending;return E===null?d.next=d:(d.next=E.next,E.next=d),w.pending=d,ho(c,x)}return E=w.interleaved,E===null?(d.next=d,Xg(w)):(d.next=E.next,E.next=d),w.interleaved=d,ho(c,x)}function Nf(c,d,x){if(d=d.updateQueue,d!==null&&(d=d.shared,(x&4194240)!==0)){var w=d.lanes;w&=c.pendingLanes,x|=w,d.lanes=x,Is(c,x)}}function Wj(c,d){var x=c.updateQueue,w=c.alternate;if(w!==null&&(w=w.updateQueue,x===w)){var E=null,A=null;if(x=x.firstBaseUpdate,x!==null){do{var G={eventTime:x.eventTime,lane:x.lane,tag:x.tag,payload:x.payload,callback:x.callback,next:null};A===null?E=A=G:A=A.next=G,x=x.next}while(x!==null);A===null?E=A=d:A=A.next=d}else E=A=d;x={baseState:w.baseState,firstBaseUpdate:E,lastBaseUpdate:A,shared:w.shared,effects:w.effects},c.updateQueue=x;return}c=x.lastBaseUpdate,c===null?x.firstBaseUpdate=d:c.next=d,x.lastBaseUpdate=d}function Cf(c,d,x,w){var E=c.updateQueue;Jo=!1;var A=E.firstBaseUpdate,G=E.lastBaseUpdate,J=E.shared.pending;if(J!==null){E.shared.pending=null;var se=J,he=se.next;se.next=null,G===null?A=he:G.next=he,G=se;var Te=c.alternate;Te!==null&&(Te=Te.updateQueue,J=Te.lastBaseUpdate,J!==G&&(J===null?Te.firstBaseUpdate=he:J.next=he,Te.lastBaseUpdate=se))}if(A!==null){var _e=E.baseState;G=0,Te=he=se=null,J=A;do{var Ee=J.lane,Ke=J.eventTime;if((w&Ee)===Ee){Te!==null&&(Te=Te.next={eventTime:Ke,lane:0,tag:J.tag,payload:J.payload,callback:J.callback,next:null});e:{var Ze=c,et=J;switch(Ee=d,Ke=x,et.tag){case 1:if(Ze=et.payload,typeof Ze=="function"){_e=Ze.call(Ke,_e,Ee);break e}_e=Ze;break e;case 3:Ze.flags=Ze.flags&-65537|128;case 0:if(Ze=et.payload,Ee=typeof Ze=="function"?Ze.call(Ke,_e,Ee):Ze,Ee==null)break e;_e=L({},_e,Ee);break e;case 2:Jo=!0}}J.callback!==null&&J.lane!==0&&(c.flags|=64,Ee=E.effects,Ee===null?E.effects=[J]:Ee.push(J))}else Ke={eventTime:Ke,lane:Ee,tag:J.tag,payload:J.payload,callback:J.callback,next:null},Te===null?(he=Te=Ke,se=_e):Te=Te.next=Ke,G|=Ee;if(J=J.next,J===null){if(J=E.shared.pending,J===null)break;Ee=J,J=Ee.next,Ee.next=null,E.lastBaseUpdate=Ee,E.shared.pending=null}}while(!0);if(Te===null&&(se=_e),E.baseState=se,E.firstBaseUpdate=he,E.lastBaseUpdate=Te,d=E.shared.interleaved,d!==null){E=d;do G|=E.lane,E=E.next;while(E!==d)}else A===null&&(E.shared.lanes=0);Wi|=G,c.lanes=G,c.memoizedState=_e}}function qj(c,d,x){if(c=d.effects,d.effects=null,c!==null)for(d=0;d<c.length;d++){var w=c[d],E=w.callback;if(E!==null){if(w.callback=null,w=x,typeof E!="function")throw Error(n(191,E));E.call(w)}}}var Zc={},zs=Yo(Zc),eu=Yo(Zc),tu=Yo(Zc);function Hi(c){if(c===Zc)throw Error(n(174));return c}function Jg(c,d){switch(Kt(tu,d),Kt(eu,c),Kt(zs,Zc),c=d.nodeType,c){case 9:case 11:d=(d=d.documentElement)?d.namespaceURI:me(null,"");break;default:c=c===8?d.parentNode:d,d=c.namespaceURI||null,c=c.tagName,d=me(d,c)}Qt(zs),Kt(zs,d)}function nl(){Qt(zs),Qt(eu),Qt(tu)}function Kj(c){Hi(tu.current);var d=Hi(zs.current),x=me(d,c.type);d!==x&&(Kt(eu,c),Kt(zs,x))}function Zg(c){eu.current===c&&(Qt(zs),Qt(eu))}var cn=Yo(0);function Ef(c){for(var d=c;d!==null;){if(d.tag===13){var x=d.memoizedState;if(x!==null&&(x=x.dehydrated,x===null||x.data==="$?"||x.data==="$!"))return d}else if(d.tag===19&&d.memoizedProps.revealOrder!==void 0){if((d.flags&128)!==0)return d}else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===c)break;for(;d.sibling===null;){if(d.return===null||d.return===c)return null;d=d.return}d.sibling.return=d.return,d=d.sibling}return null}var ex=[];function tx(){for(var c=0;c<ex.length;c++)ex[c]._workInProgressVersionPrimary=null;ex.length=0}var Tf=C.ReactCurrentDispatcher,nx=C.ReactCurrentBatchConfig,Vi=0,un=null,_n=null,Bn=null,Rf=!1,nu=!1,ru=0,bI=0;function Zn(){throw Error(n(321))}function rx(c,d){if(d===null)return!1;for(var x=0;x<d.length&&x<c.length;x++)if(!as(c[x],d[x]))return!1;return!0}function sx(c,d,x,w,E,A){if(Vi=A,un=d,d.memoizedState=null,d.updateQueue=null,d.lanes=0,Tf.current=c===null||c.memoizedState===null?kI:SI,c=x(w,E),nu){A=0;do{if(nu=!1,ru=0,25<=A)throw Error(n(301));A+=1,Bn=_n=null,d.updateQueue=null,Tf.current=NI,c=x(w,E)}while(nu)}if(Tf.current=_f,d=_n!==null&&_n.next!==null,Vi=0,Bn=_n=un=null,Rf=!1,d)throw Error(n(300));return c}function ox(){var c=ru!==0;return ru=0,c}function Bs(){var c={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Bn===null?un.memoizedState=Bn=c:Bn=Bn.next=c,Bn}function Xr(){if(_n===null){var c=un.alternate;c=c!==null?c.memoizedState:null}else c=_n.next;var d=Bn===null?un.memoizedState:Bn.next;if(d!==null)Bn=d,_n=c;else{if(c===null)throw Error(n(310));_n=c,c={memoizedState:_n.memoizedState,baseState:_n.baseState,baseQueue:_n.baseQueue,queue:_n.queue,next:null},Bn===null?un.memoizedState=Bn=c:Bn=Bn.next=c}return Bn}function su(c,d){return typeof d=="function"?d(c):d}function ix(c){var d=Xr(),x=d.queue;if(x===null)throw Error(n(311));x.lastRenderedReducer=c;var w=_n,E=w.baseQueue,A=x.pending;if(A!==null){if(E!==null){var G=E.next;E.next=A.next,A.next=G}w.baseQueue=E=A,x.pending=null}if(E!==null){A=E.next,w=w.baseState;var J=G=null,se=null,he=A;do{var Te=he.lane;if((Vi&Te)===Te)se!==null&&(se=se.next={lane:0,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null}),w=he.hasEagerState?he.eagerState:c(w,he.action);else{var _e={lane:Te,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null};se===null?(J=se=_e,G=w):se=se.next=_e,un.lanes|=Te,Wi|=Te}he=he.next}while(he!==null&&he!==A);se===null?G=w:se.next=J,as(w,d.memoizedState)||(hr=!0),d.memoizedState=w,d.baseState=G,d.baseQueue=se,x.lastRenderedState=w}if(c=x.interleaved,c!==null){E=c;do A=E.lane,un.lanes|=A,Wi|=A,E=E.next;while(E!==c)}else E===null&&(x.lanes=0);return[d.memoizedState,x.dispatch]}function ax(c){var d=Xr(),x=d.queue;if(x===null)throw Error(n(311));x.lastRenderedReducer=c;var w=x.dispatch,E=x.pending,A=d.memoizedState;if(E!==null){x.pending=null;var G=E=E.next;do A=c(A,G.action),G=G.next;while(G!==E);as(A,d.memoizedState)||(hr=!0),d.memoizedState=A,d.baseQueue===null&&(d.baseState=A),x.lastRenderedState=A}return[A,w]}function Gj(){}function Yj(c,d){var x=un,w=Xr(),E=d(),A=!as(w.memoizedState,E);if(A&&(w.memoizedState=E,hr=!0),w=w.queue,lx(Jj.bind(null,x,w,c),[c]),w.getSnapshot!==d||A||Bn!==null&&Bn.memoizedState.tag&1){if(x.flags|=2048,ou(9,Qj.bind(null,x,w,E,d),void 0,null),Un===null)throw Error(n(349));(Vi&30)!==0||Xj(x,d,E)}return E}function Xj(c,d,x){c.flags|=16384,c={getSnapshot:d,value:x},d=un.updateQueue,d===null?(d={lastEffect:null,stores:null},un.updateQueue=d,d.stores=[c]):(x=d.stores,x===null?d.stores=[c]:x.push(c))}function Qj(c,d,x,w){d.value=x,d.getSnapshot=w,Zj(d)&&ek(c)}function Jj(c,d,x){return x(function(){Zj(d)&&ek(c)})}function Zj(c){var d=c.getSnapshot;c=c.value;try{var x=d();return!as(c,x)}catch{return!0}}function ek(c){var d=ho(c,1);d!==null&&fs(d,c,1,-1)}function tk(c){var d=Bs();return typeof c=="function"&&(c=c()),d.memoizedState=d.baseState=c,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:su,lastRenderedState:c},d.queue=c,c=c.dispatch=jI.bind(null,un,c),[d.memoizedState,c]}function ou(c,d,x,w){return c={tag:c,create:d,destroy:x,deps:w,next:null},d=un.updateQueue,d===null?(d={lastEffect:null,stores:null},un.updateQueue=d,d.lastEffect=c.next=c):(x=d.lastEffect,x===null?d.lastEffect=c.next=c:(w=x.next,x.next=c,c.next=w,d.lastEffect=c)),c}function nk(){return Xr().memoizedState}function Af(c,d,x,w){var E=Bs();un.flags|=c,E.memoizedState=ou(1|d,x,void 0,w===void 0?null:w)}function Pf(c,d,x,w){var E=Xr();w=w===void 0?null:w;var A=void 0;if(_n!==null){var G=_n.memoizedState;if(A=G.destroy,w!==null&&rx(w,G.deps)){E.memoizedState=ou(d,x,A,w);return}}un.flags|=c,E.memoizedState=ou(1|d,x,A,w)}function rk(c,d){return Af(8390656,8,c,d)}function lx(c,d){return Pf(2048,8,c,d)}function sk(c,d){return Pf(4,2,c,d)}function ok(c,d){return Pf(4,4,c,d)}function ik(c,d){if(typeof d=="function")return c=c(),d(c),function(){d(null)};if(d!=null)return c=c(),d.current=c,function(){d.current=null}}function ak(c,d,x){return x=x!=null?x.concat([c]):null,Pf(4,4,ik.bind(null,d,c),x)}function cx(){}function lk(c,d){var x=Xr();d=d===void 0?null:d;var w=x.memoizedState;return w!==null&&d!==null&&rx(d,w[1])?w[0]:(x.memoizedState=[c,d],c)}function ck(c,d){var x=Xr();d=d===void 0?null:d;var w=x.memoizedState;return w!==null&&d!==null&&rx(d,w[1])?w[0]:(c=c(),x.memoizedState=[c,d],c)}function uk(c,d,x){return(Vi&21)===0?(c.baseState&&(c.baseState=!1,hr=!0),c.memoizedState=x):(as(x,d)||(x=Uo(),un.lanes|=x,Wi|=x,c.baseState=!0),d)}function vI(c,d){var x=Ot;Ot=x!==0&&4>x?x:4,c(!0);var w=nx.transition;nx.transition={};try{c(!1),d()}finally{Ot=x,nx.transition=w}}function dk(){return Xr().memoizedState}function wI(c,d,x){var w=ri(c);if(x={lane:w,action:x,hasEagerState:!1,eagerState:null,next:null},fk(c))pk(d,x);else if(x=Hj(c,d,x,w),x!==null){var E=lr();fs(x,c,w,E),hk(x,d,w)}}function jI(c,d,x){var w=ri(c),E={lane:w,action:x,hasEagerState:!1,eagerState:null,next:null};if(fk(c))pk(d,E);else{var A=c.alternate;if(c.lanes===0&&(A===null||A.lanes===0)&&(A=d.lastRenderedReducer,A!==null))try{var G=d.lastRenderedState,J=A(G,x);if(E.hasEagerState=!0,E.eagerState=J,as(J,G)){var se=d.interleaved;se===null?(E.next=E,Xg(d)):(E.next=se.next,se.next=E),d.interleaved=E;return}}catch{}finally{}x=Hj(c,d,E,w),x!==null&&(E=lr(),fs(x,c,w,E),hk(x,d,w))}}function fk(c){var d=c.alternate;return c===un||d!==null&&d===un}function pk(c,d){nu=Rf=!0;var x=c.pending;x===null?d.next=d:(d.next=x.next,x.next=d),c.pending=d}function hk(c,d,x){if((x&4194240)!==0){var w=d.lanes;w&=c.pendingLanes,x|=w,d.lanes=x,Is(c,x)}}var _f={readContext:Yr,useCallback:Zn,useContext:Zn,useEffect:Zn,useImperativeHandle:Zn,useInsertionEffect:Zn,useLayoutEffect:Zn,useMemo:Zn,useReducer:Zn,useRef:Zn,useState:Zn,useDebugValue:Zn,useDeferredValue:Zn,useTransition:Zn,useMutableSource:Zn,useSyncExternalStore:Zn,useId:Zn,unstable_isNewReconciler:!1},kI={readContext:Yr,useCallback:function(c,d){return Bs().memoizedState=[c,d===void 0?null:d],c},useContext:Yr,useEffect:rk,useImperativeHandle:function(c,d,x){return x=x!=null?x.concat([c]):null,Af(4194308,4,ik.bind(null,d,c),x)},useLayoutEffect:function(c,d){return Af(4194308,4,c,d)},useInsertionEffect:function(c,d){return Af(4,2,c,d)},useMemo:function(c,d){var x=Bs();return d=d===void 0?null:d,c=c(),x.memoizedState=[c,d],c},useReducer:function(c,d,x){var w=Bs();return d=x!==void 0?x(d):d,w.memoizedState=w.baseState=d,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:c,lastRenderedState:d},w.queue=c,c=c.dispatch=wI.bind(null,un,c),[w.memoizedState,c]},useRef:function(c){var d=Bs();return c={current:c},d.memoizedState=c},useState:tk,useDebugValue:cx,useDeferredValue:function(c){return Bs().memoizedState=c},useTransition:function(){var c=tk(!1),d=c[0];return c=vI.bind(null,c[1]),Bs().memoizedState=c,[d,c]},useMutableSource:function(){},useSyncExternalStore:function(c,d,x){var w=un,E=Bs();if(rn){if(x===void 0)throw Error(n(407));x=x()}else{if(x=d(),Un===null)throw Error(n(349));(Vi&30)!==0||Xj(w,d,x)}E.memoizedState=x;var A={value:x,getSnapshot:d};return E.queue=A,rk(Jj.bind(null,w,A,c),[c]),w.flags|=2048,ou(9,Qj.bind(null,w,A,x,d),void 0,null),x},useId:function(){var c=Bs(),d=Un.identifierPrefix;if(rn){var x=po,w=fo;x=(w&~(1<<32-On(w)-1)).toString(32)+x,d=":"+d+"R"+x,x=ru++,0<x&&(d+="H"+x.toString(32)),d+=":"}else x=bI++,d=":"+d+"r"+x.toString(32)+":";return c.memoizedState=d},unstable_isNewReconciler:!1},SI={readContext:Yr,useCallback:lk,useContext:Yr,useEffect:lx,useImperativeHandle:ak,useInsertionEffect:sk,useLayoutEffect:ok,useMemo:ck,useReducer:ix,useRef:nk,useState:function(){return ix(su)},useDebugValue:cx,useDeferredValue:function(c){var d=Xr();return uk(d,_n.memoizedState,c)},useTransition:function(){var c=ix(su)[0],d=Xr().memoizedState;return[c,d]},useMutableSource:Gj,useSyncExternalStore:Yj,useId:dk,unstable_isNewReconciler:!1},NI={readContext:Yr,useCallback:lk,useContext:Yr,useEffect:lx,useImperativeHandle:ak,useInsertionEffect:sk,useLayoutEffect:ok,useMemo:ck,useReducer:ax,useRef:nk,useState:function(){return ax(su)},useDebugValue:cx,useDeferredValue:function(c){var d=Xr();return _n===null?d.memoizedState=c:uk(d,_n.memoizedState,c)},useTransition:function(){var c=ax(su)[0],d=Xr().memoizedState;return[c,d]},useMutableSource:Gj,useSyncExternalStore:Yj,useId:dk,unstable_isNewReconciler:!1};function cs(c,d){if(c&&c.defaultProps){d=L({},d),c=c.defaultProps;for(var x in c)d[x]===void 0&&(d[x]=c[x]);return d}return d}function ux(c,d,x,w){d=c.memoizedState,x=x(w,d),x=x==null?d:L({},d,x),c.memoizedState=x,c.lanes===0&&(c.updateQueue.baseState=x)}var Df={isMounted:function(c){return(c=c._reactInternals)?wt(c)===c:!1},enqueueSetState:function(c,d,x){c=c._reactInternals;var w=lr(),E=ri(c),A=mo(w,E);A.payload=d,x!=null&&(A.callback=x),d=Zo(c,A,E),d!==null&&(fs(d,c,E,w),Nf(d,c,E))},enqueueReplaceState:function(c,d,x){c=c._reactInternals;var w=lr(),E=ri(c),A=mo(w,E);A.tag=1,A.payload=d,x!=null&&(A.callback=x),d=Zo(c,A,E),d!==null&&(fs(d,c,E,w),Nf(d,c,E))},enqueueForceUpdate:function(c,d){c=c._reactInternals;var x=lr(),w=ri(c),E=mo(x,w);E.tag=2,d!=null&&(E.callback=d),d=Zo(c,E,w),d!==null&&(fs(d,c,w,x),Nf(d,c,w))}};function mk(c,d,x,w,E,A,G){return c=c.stateNode,typeof c.shouldComponentUpdate=="function"?c.shouldComponentUpdate(w,A,G):d.prototype&&d.prototype.isPureReactComponent?!Wc(x,w)||!Wc(E,A):!0}function gk(c,d,x){var w=!1,E=Xo,A=d.contextType;return typeof A=="object"&&A!==null?A=Yr(A):(E=pr(d)?Fi:Jn.current,w=d.contextTypes,A=(w=w!=null)?Ya(c,E):Xo),d=new d(x,A),c.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Df,c.stateNode=d,d._reactInternals=c,w&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=E,c.__reactInternalMemoizedMaskedChildContext=A),d}function xk(c,d,x,w){c=d.state,typeof d.componentWillReceiveProps=="function"&&d.componentWillReceiveProps(x,w),typeof d.UNSAFE_componentWillReceiveProps=="function"&&d.UNSAFE_componentWillReceiveProps(x,w),d.state!==c&&Df.enqueueReplaceState(d,d.state,null)}function dx(c,d,x,w){var E=c.stateNode;E.props=x,E.state=c.memoizedState,E.refs={},Qg(c);var A=d.contextType;typeof A=="object"&&A!==null?E.context=Yr(A):(A=pr(d)?Fi:Jn.current,E.context=Ya(c,A)),E.state=c.memoizedState,A=d.getDerivedStateFromProps,typeof A=="function"&&(ux(c,d,A,x),E.state=c.memoizedState),typeof d.getDerivedStateFromProps=="function"||typeof E.getSnapshotBeforeUpdate=="function"||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(d=E.state,typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount(),d!==E.state&&Df.enqueueReplaceState(E,E.state,null),Cf(c,x,E,w),E.state=c.memoizedState),typeof E.componentDidMount=="function"&&(c.flags|=4194308)}function rl(c,d){try{var x="",w=d;do x+=ee(w),w=w.return;while(w);var E=x}catch(A){E=`
39
- Error generating stack: `+A.message+`
40
- `+A.stack}return{value:c,source:d,stack:E,digest:null}}function fx(c,d,x){return{value:c,source:null,stack:x??null,digest:d??null}}function px(c,d){try{console.error(d.value)}catch(x){setTimeout(function(){throw x})}}var CI=typeof WeakMap=="function"?WeakMap:Map;function yk(c,d,x){x=mo(-1,x),x.tag=3,x.payload={element:null};var w=d.value;return x.callback=function(){zf||(zf=!0,Tx=w),px(c,d)},x}function bk(c,d,x){x=mo(-1,x),x.tag=3;var w=c.type.getDerivedStateFromError;if(typeof w=="function"){var E=d.value;x.payload=function(){return w(E)},x.callback=function(){px(c,d)}}var A=c.stateNode;return A!==null&&typeof A.componentDidCatch=="function"&&(x.callback=function(){px(c,d),typeof w!="function"&&(ti===null?ti=new Set([this]):ti.add(this));var G=d.stack;this.componentDidCatch(d.value,{componentStack:G!==null?G:""})}),x}function vk(c,d,x){var w=c.pingCache;if(w===null){w=c.pingCache=new CI;var E=new Set;w.set(d,E)}else E=w.get(d),E===void 0&&(E=new Set,w.set(d,E));E.has(x)||(E.add(x),c=zI.bind(null,c,d,x),d.then(c,c))}function wk(c){do{var d;if((d=c.tag===13)&&(d=c.memoizedState,d=d!==null?d.dehydrated!==null:!0),d)return c;c=c.return}while(c!==null);return null}function jk(c,d,x,w,E){return(c.mode&1)===0?(c===d?c.flags|=65536:(c.flags|=128,x.flags|=131072,x.flags&=-52805,x.tag===1&&(x.alternate===null?x.tag=17:(d=mo(-1,1),d.tag=2,Zo(x,d,1))),x.lanes|=1),c):(c.flags|=65536,c.lanes=E,c)}var EI=C.ReactCurrentOwner,hr=!1;function ar(c,d,x,w){d.child=c===null?Uj(d,null,x,w):Za(d,c.child,x,w)}function kk(c,d,x,w,E){x=x.render;var A=d.ref;return tl(d,E),w=sx(c,d,x,w,A,E),x=ox(),c!==null&&!hr?(d.updateQueue=c.updateQueue,d.flags&=-2053,c.lanes&=~E,go(c,d,E)):(rn&&x&&Bg(d),d.flags|=1,ar(c,d,w,E),d.child)}function Sk(c,d,x,w,E){if(c===null){var A=x.type;return typeof A=="function"&&!Ix(A)&&A.defaultProps===void 0&&x.compare===null&&x.defaultProps===void 0?(d.tag=15,d.type=A,Nk(c,d,A,w,E)):(c=qf(x.type,null,w,d,d.mode,E),c.ref=d.ref,c.return=d,d.child=c)}if(A=c.child,(c.lanes&E)===0){var G=A.memoizedProps;if(x=x.compare,x=x!==null?x:Wc,x(G,w)&&c.ref===d.ref)return go(c,d,E)}return d.flags|=1,c=oi(A,w),c.ref=d.ref,c.return=d,d.child=c}function Nk(c,d,x,w,E){if(c!==null){var A=c.memoizedProps;if(Wc(A,w)&&c.ref===d.ref)if(hr=!1,d.pendingProps=w=A,(c.lanes&E)!==0)(c.flags&131072)!==0&&(hr=!0);else return d.lanes=c.lanes,go(c,d,E)}return hx(c,d,x,w,E)}function Ck(c,d,x){var w=d.pendingProps,E=w.children,A=c!==null?c.memoizedState:null;if(w.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null,transitions:null},Kt(ol,Dr),Dr|=x;else{if((x&1073741824)===0)return c=A!==null?A.baseLanes|x:x,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:c,cachePool:null,transitions:null},d.updateQueue=null,Kt(ol,Dr),Dr|=c,null;d.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=A!==null?A.baseLanes:x,Kt(ol,Dr),Dr|=w}else A!==null?(w=A.baseLanes|x,d.memoizedState=null):w=x,Kt(ol,Dr),Dr|=w;return ar(c,d,E,x),d.child}function Ek(c,d){var x=d.ref;(c===null&&x!==null||c!==null&&c.ref!==x)&&(d.flags|=512,d.flags|=2097152)}function hx(c,d,x,w,E){var A=pr(x)?Fi:Jn.current;return A=Ya(d,A),tl(d,E),x=sx(c,d,x,w,A,E),w=ox(),c!==null&&!hr?(d.updateQueue=c.updateQueue,d.flags&=-2053,c.lanes&=~E,go(c,d,E)):(rn&&w&&Bg(d),d.flags|=1,ar(c,d,x,E),d.child)}function Tk(c,d,x,w,E){if(pr(x)){var A=!0;xf(d)}else A=!1;if(tl(d,E),d.stateNode===null)If(c,d),gk(d,x,w),dx(d,x,w,E),w=!0;else if(c===null){var G=d.stateNode,J=d.memoizedProps;G.props=J;var se=G.context,he=x.contextType;typeof he=="object"&&he!==null?he=Yr(he):(he=pr(x)?Fi:Jn.current,he=Ya(d,he));var Te=x.getDerivedStateFromProps,_e=typeof Te=="function"||typeof G.getSnapshotBeforeUpdate=="function";_e||typeof G.UNSAFE_componentWillReceiveProps!="function"&&typeof G.componentWillReceiveProps!="function"||(J!==w||se!==he)&&xk(d,G,w,he),Jo=!1;var Ee=d.memoizedState;G.state=Ee,Cf(d,w,G,E),se=d.memoizedState,J!==w||Ee!==se||fr.current||Jo?(typeof Te=="function"&&(ux(d,x,Te,w),se=d.memoizedState),(J=Jo||mk(d,x,J,w,Ee,se,he))?(_e||typeof G.UNSAFE_componentWillMount!="function"&&typeof G.componentWillMount!="function"||(typeof G.componentWillMount=="function"&&G.componentWillMount(),typeof G.UNSAFE_componentWillMount=="function"&&G.UNSAFE_componentWillMount()),typeof G.componentDidMount=="function"&&(d.flags|=4194308)):(typeof G.componentDidMount=="function"&&(d.flags|=4194308),d.memoizedProps=w,d.memoizedState=se),G.props=w,G.state=se,G.context=he,w=J):(typeof G.componentDidMount=="function"&&(d.flags|=4194308),w=!1)}else{G=d.stateNode,Vj(c,d),J=d.memoizedProps,he=d.type===d.elementType?J:cs(d.type,J),G.props=he,_e=d.pendingProps,Ee=G.context,se=x.contextType,typeof se=="object"&&se!==null?se=Yr(se):(se=pr(x)?Fi:Jn.current,se=Ya(d,se));var Ke=x.getDerivedStateFromProps;(Te=typeof Ke=="function"||typeof G.getSnapshotBeforeUpdate=="function")||typeof G.UNSAFE_componentWillReceiveProps!="function"&&typeof G.componentWillReceiveProps!="function"||(J!==_e||Ee!==se)&&xk(d,G,w,se),Jo=!1,Ee=d.memoizedState,G.state=Ee,Cf(d,w,G,E);var Ze=d.memoizedState;J!==_e||Ee!==Ze||fr.current||Jo?(typeof Ke=="function"&&(ux(d,x,Ke,w),Ze=d.memoizedState),(he=Jo||mk(d,x,he,w,Ee,Ze,se)||!1)?(Te||typeof G.UNSAFE_componentWillUpdate!="function"&&typeof G.componentWillUpdate!="function"||(typeof G.componentWillUpdate=="function"&&G.componentWillUpdate(w,Ze,se),typeof G.UNSAFE_componentWillUpdate=="function"&&G.UNSAFE_componentWillUpdate(w,Ze,se)),typeof G.componentDidUpdate=="function"&&(d.flags|=4),typeof G.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof G.componentDidUpdate!="function"||J===c.memoizedProps&&Ee===c.memoizedState||(d.flags|=4),typeof G.getSnapshotBeforeUpdate!="function"||J===c.memoizedProps&&Ee===c.memoizedState||(d.flags|=1024),d.memoizedProps=w,d.memoizedState=Ze),G.props=w,G.state=Ze,G.context=se,w=he):(typeof G.componentDidUpdate!="function"||J===c.memoizedProps&&Ee===c.memoizedState||(d.flags|=4),typeof G.getSnapshotBeforeUpdate!="function"||J===c.memoizedProps&&Ee===c.memoizedState||(d.flags|=1024),w=!1)}return mx(c,d,x,w,A,E)}function mx(c,d,x,w,E,A){Ek(c,d);var G=(d.flags&128)!==0;if(!w&&!G)return E&&Dj(d,x,!1),go(c,d,A);w=d.stateNode,EI.current=d;var J=G&&typeof x.getDerivedStateFromError!="function"?null:w.render();return d.flags|=1,c!==null&&G?(d.child=Za(d,c.child,null,A),d.child=Za(d,null,J,A)):ar(c,d,J,A),d.memoizedState=w.state,E&&Dj(d,x,!0),d.child}function Rk(c){var d=c.stateNode;d.pendingContext?Pj(c,d.pendingContext,d.pendingContext!==d.context):d.context&&Pj(c,d.context,!1),Jg(c,d.containerInfo)}function Ak(c,d,x,w,E){return Ja(),Wg(E),d.flags|=256,ar(c,d,x,w),d.child}var gx={dehydrated:null,treeContext:null,retryLane:0};function xx(c){return{baseLanes:c,cachePool:null,transitions:null}}function Pk(c,d,x){var w=d.pendingProps,E=cn.current,A=!1,G=(d.flags&128)!==0,J;if((J=G)||(J=c!==null&&c.memoizedState===null?!1:(E&2)!==0),J?(A=!0,d.flags&=-129):(c===null||c.memoizedState!==null)&&(E|=1),Kt(cn,E&1),c===null)return Vg(d),c=d.memoizedState,c!==null&&(c=c.dehydrated,c!==null)?((d.mode&1)===0?d.lanes=1:c.data==="$!"?d.lanes=8:d.lanes=1073741824,null):(G=w.children,c=w.fallback,A?(w=d.mode,A=d.child,G={mode:"hidden",children:G},(w&1)===0&&A!==null?(A.childLanes=0,A.pendingProps=G):A=Kf(G,w,0,null),c=Yi(c,w,x,null),A.return=d,c.return=d,A.sibling=c,d.child=A,d.child.memoizedState=xx(x),d.memoizedState=gx,c):yx(d,G));if(E=c.memoizedState,E!==null&&(J=E.dehydrated,J!==null))return TI(c,d,G,w,J,E,x);if(A){A=w.fallback,G=d.mode,E=c.child,J=E.sibling;var se={mode:"hidden",children:w.children};return(G&1)===0&&d.child!==E?(w=d.child,w.childLanes=0,w.pendingProps=se,d.deletions=null):(w=oi(E,se),w.subtreeFlags=E.subtreeFlags&14680064),J!==null?A=oi(J,A):(A=Yi(A,G,x,null),A.flags|=2),A.return=d,w.return=d,w.sibling=A,d.child=w,w=A,A=d.child,G=c.child.memoizedState,G=G===null?xx(x):{baseLanes:G.baseLanes|x,cachePool:null,transitions:G.transitions},A.memoizedState=G,A.childLanes=c.childLanes&~x,d.memoizedState=gx,w}return A=c.child,c=A.sibling,w=oi(A,{mode:"visible",children:w.children}),(d.mode&1)===0&&(w.lanes=x),w.return=d,w.sibling=null,c!==null&&(x=d.deletions,x===null?(d.deletions=[c],d.flags|=16):x.push(c)),d.child=w,d.memoizedState=null,w}function yx(c,d){return d=Kf({mode:"visible",children:d},c.mode,0,null),d.return=c,c.child=d}function $f(c,d,x,w){return w!==null&&Wg(w),Za(d,c.child,null,x),c=yx(d,d.pendingProps.children),c.flags|=2,d.memoizedState=null,c}function TI(c,d,x,w,E,A,G){if(x)return d.flags&256?(d.flags&=-257,w=fx(Error(n(422))),$f(c,d,G,w)):d.memoizedState!==null?(d.child=c.child,d.flags|=128,null):(A=w.fallback,E=d.mode,w=Kf({mode:"visible",children:w.children},E,0,null),A=Yi(A,E,G,null),A.flags|=2,w.return=d,A.return=d,w.sibling=A,d.child=w,(d.mode&1)!==0&&Za(d,c.child,null,G),d.child.memoizedState=xx(G),d.memoizedState=gx,A);if((d.mode&1)===0)return $f(c,d,G,null);if(E.data==="$!"){if(w=E.nextSibling&&E.nextSibling.dataset,w)var J=w.dgst;return w=J,A=Error(n(419)),w=fx(A,w,void 0),$f(c,d,G,w)}if(J=(G&c.childLanes)!==0,hr||J){if(w=Un,w!==null){switch(G&-G){case 4:E=2;break;case 16:E=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:E=32;break;case 536870912:E=268435456;break;default:E=0}E=(E&(w.suspendedLanes|G))!==0?0:E,E!==0&&E!==A.retryLane&&(A.retryLane=E,ho(c,E),fs(w,c,E,-1))}return $x(),w=fx(Error(n(421))),$f(c,d,G,w)}return E.data==="$?"?(d.flags|=128,d.child=c.child,d=BI.bind(null,c),E._reactRetry=d,null):(c=A.treeContext,_r=Go(E.nextSibling),Pr=d,rn=!0,ls=null,c!==null&&(Kr[Gr++]=fo,Kr[Gr++]=po,Kr[Gr++]=zi,fo=c.id,po=c.overflow,zi=d),d=yx(d,w.children),d.flags|=4096,d)}function _k(c,d,x){c.lanes|=d;var w=c.alternate;w!==null&&(w.lanes|=d),Yg(c.return,d,x)}function bx(c,d,x,w,E){var A=c.memoizedState;A===null?c.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:w,tail:x,tailMode:E}:(A.isBackwards=d,A.rendering=null,A.renderingStartTime=0,A.last=w,A.tail=x,A.tailMode=E)}function Dk(c,d,x){var w=d.pendingProps,E=w.revealOrder,A=w.tail;if(ar(c,d,w.children,x),w=cn.current,(w&2)!==0)w=w&1|2,d.flags|=128;else{if(c!==null&&(c.flags&128)!==0)e:for(c=d.child;c!==null;){if(c.tag===13)c.memoizedState!==null&&_k(c,x,d);else if(c.tag===19)_k(c,x,d);else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===d)break e;for(;c.sibling===null;){if(c.return===null||c.return===d)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}w&=1}if(Kt(cn,w),(d.mode&1)===0)d.memoizedState=null;else switch(E){case"forwards":for(x=d.child,E=null;x!==null;)c=x.alternate,c!==null&&Ef(c)===null&&(E=x),x=x.sibling;x=E,x===null?(E=d.child,d.child=null):(E=x.sibling,x.sibling=null),bx(d,!1,E,x,A);break;case"backwards":for(x=null,E=d.child,d.child=null;E!==null;){if(c=E.alternate,c!==null&&Ef(c)===null){d.child=E;break}c=E.sibling,E.sibling=x,x=E,E=c}bx(d,!0,x,null,A);break;case"together":bx(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function If(c,d){(d.mode&1)===0&&c!==null&&(c.alternate=null,d.alternate=null,d.flags|=2)}function go(c,d,x){if(c!==null&&(d.dependencies=c.dependencies),Wi|=d.lanes,(x&d.childLanes)===0)return null;if(c!==null&&d.child!==c.child)throw Error(n(153));if(d.child!==null){for(c=d.child,x=oi(c,c.pendingProps),d.child=x,x.return=d;c.sibling!==null;)c=c.sibling,x=x.sibling=oi(c,c.pendingProps),x.return=d;x.sibling=null}return d.child}function RI(c,d,x){switch(d.tag){case 3:Rk(d),Ja();break;case 5:Kj(d);break;case 1:pr(d.type)&&xf(d);break;case 4:Jg(d,d.stateNode.containerInfo);break;case 10:var w=d.type._context,E=d.memoizedProps.value;Kt(kf,w._currentValue),w._currentValue=E;break;case 13:if(w=d.memoizedState,w!==null)return w.dehydrated!==null?(Kt(cn,cn.current&1),d.flags|=128,null):(x&d.child.childLanes)!==0?Pk(c,d,x):(Kt(cn,cn.current&1),c=go(c,d,x),c!==null?c.sibling:null);Kt(cn,cn.current&1);break;case 19:if(w=(x&d.childLanes)!==0,(c.flags&128)!==0){if(w)return Dk(c,d,x);d.flags|=128}if(E=d.memoizedState,E!==null&&(E.rendering=null,E.tail=null,E.lastEffect=null),Kt(cn,cn.current),w)break;return null;case 22:case 23:return d.lanes=0,Ck(c,d,x)}return go(c,d,x)}var $k,vx,Ik,Lk;$k=function(c,d){for(var x=d.child;x!==null;){if(x.tag===5||x.tag===6)c.appendChild(x.stateNode);else if(x.tag!==4&&x.child!==null){x.child.return=x,x=x.child;continue}if(x===d)break;for(;x.sibling===null;){if(x.return===null||x.return===d)return;x=x.return}x.sibling.return=x.return,x=x.sibling}},vx=function(){},Ik=function(c,d,x,w){var E=c.memoizedProps;if(E!==w){c=d.stateNode,Hi(zs.current);var A=null;switch(x){case"input":E=Ue(c,E),w=Ue(c,w),A=[];break;case"select":E=L({},E,{value:void 0}),w=L({},w,{value:void 0}),A=[];break;case"textarea":E=ot(c,E),w=ot(c,w),A=[];break;default:typeof E.onClick!="function"&&typeof w.onClick=="function"&&(c.onclick=hf)}fe(x,w);var G;x=null;for(he in E)if(!w.hasOwnProperty(he)&&E.hasOwnProperty(he)&&E[he]!=null)if(he==="style"){var J=E[he];for(G in J)J.hasOwnProperty(G)&&(x||(x={}),x[G]="")}else he!=="dangerouslySetInnerHTML"&&he!=="children"&&he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&he!=="autoFocus"&&(o.hasOwnProperty(he)?A||(A=[]):(A=A||[]).push(he,null));for(he in w){var se=w[he];if(J=E!=null?E[he]:void 0,w.hasOwnProperty(he)&&se!==J&&(se!=null||J!=null))if(he==="style")if(J){for(G in J)!J.hasOwnProperty(G)||se&&se.hasOwnProperty(G)||(x||(x={}),x[G]="");for(G in se)se.hasOwnProperty(G)&&J[G]!==se[G]&&(x||(x={}),x[G]=se[G])}else x||(A||(A=[]),A.push(he,x)),x=se;else he==="dangerouslySetInnerHTML"?(se=se?se.__html:void 0,J=J?J.__html:void 0,se!=null&&J!==se&&(A=A||[]).push(he,se)):he==="children"?typeof se!="string"&&typeof se!="number"||(A=A||[]).push(he,""+se):he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&(o.hasOwnProperty(he)?(se!=null&&he==="onScroll"&&Xt("scroll",c),A||J===se||(A=[])):(A=A||[]).push(he,se))}x&&(A=A||[]).push("style",x);var he=A;(d.updateQueue=he)&&(d.flags|=4)}},Lk=function(c,d,x,w){x!==w&&(d.flags|=4)};function iu(c,d){if(!rn)switch(c.tailMode){case"hidden":d=c.tail;for(var x=null;d!==null;)d.alternate!==null&&(x=d),d=d.sibling;x===null?c.tail=null:x.sibling=null;break;case"collapsed":x=c.tail;for(var w=null;x!==null;)x.alternate!==null&&(w=x),x=x.sibling;w===null?d||c.tail===null?c.tail=null:c.tail.sibling=null:w.sibling=null}}function er(c){var d=c.alternate!==null&&c.alternate.child===c.child,x=0,w=0;if(d)for(var E=c.child;E!==null;)x|=E.lanes|E.childLanes,w|=E.subtreeFlags&14680064,w|=E.flags&14680064,E.return=c,E=E.sibling;else for(E=c.child;E!==null;)x|=E.lanes|E.childLanes,w|=E.subtreeFlags,w|=E.flags,E.return=c,E=E.sibling;return c.subtreeFlags|=w,c.childLanes=x,d}function AI(c,d,x){var w=d.pendingProps;switch(Ug(d),d.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return er(d),null;case 1:return pr(d.type)&&gf(),er(d),null;case 3:return w=d.stateNode,nl(),Qt(fr),Qt(Jn),tx(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(c===null||c.child===null)&&(wf(d)?d.flags|=4:c===null||c.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,ls!==null&&(Px(ls),ls=null))),vx(c,d),er(d),null;case 5:Zg(d);var E=Hi(tu.current);if(x=d.type,c!==null&&d.stateNode!=null)Ik(c,d,x,w,E),c.ref!==d.ref&&(d.flags|=512,d.flags|=2097152);else{if(!w){if(d.stateNode===null)throw Error(n(166));return er(d),null}if(c=Hi(zs.current),wf(d)){w=d.stateNode,x=d.type;var A=d.memoizedProps;switch(w[Fs]=d,w[Xc]=A,c=(d.mode&1)!==0,x){case"dialog":Xt("cancel",w),Xt("close",w);break;case"iframe":case"object":case"embed":Xt("load",w);break;case"video":case"audio":for(E=0;E<Kc.length;E++)Xt(Kc[E],w);break;case"source":Xt("error",w);break;case"img":case"image":case"link":Xt("error",w),Xt("load",w);break;case"details":Xt("toggle",w);break;case"input":oe(w,A),Xt("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!A.multiple},Xt("invalid",w);break;case"textarea":Nt(w,A),Xt("invalid",w)}fe(x,A),E=null;for(var G in A)if(A.hasOwnProperty(G)){var J=A[G];G==="children"?typeof J=="string"?w.textContent!==J&&(A.suppressHydrationWarning!==!0&&pf(w.textContent,J,c),E=["children",J]):typeof J=="number"&&w.textContent!==""+J&&(A.suppressHydrationWarning!==!0&&pf(w.textContent,J,c),E=["children",""+J]):o.hasOwnProperty(G)&&J!=null&&G==="onScroll"&&Xt("scroll",w)}switch(x){case"input":Ne(w),Re(w,A,!0);break;case"textarea":Ne(w),at(w);break;case"select":case"option":break;default:typeof A.onClick=="function"&&(w.onclick=hf)}w=E,d.updateQueue=w,w!==null&&(d.flags|=4)}else{G=E.nodeType===9?E:E.ownerDocument,c==="http://www.w3.org/1999/xhtml"&&(c=ce(x)),c==="http://www.w3.org/1999/xhtml"?x==="script"?(c=G.createElement("div"),c.innerHTML="<script><\/script>",c=c.removeChild(c.firstChild)):typeof w.is=="string"?c=G.createElement(x,{is:w.is}):(c=G.createElement(x),x==="select"&&(G=c,w.multiple?G.multiple=!0:w.size&&(G.size=w.size))):c=G.createElementNS(c,x),c[Fs]=d,c[Xc]=w,$k(c,d,!1,!1),d.stateNode=c;e:{switch(G=K(x,w),x){case"dialog":Xt("cancel",c),Xt("close",c),E=w;break;case"iframe":case"object":case"embed":Xt("load",c),E=w;break;case"video":case"audio":for(E=0;E<Kc.length;E++)Xt(Kc[E],c);E=w;break;case"source":Xt("error",c),E=w;break;case"img":case"image":case"link":Xt("error",c),Xt("load",c),E=w;break;case"details":Xt("toggle",c),E=w;break;case"input":oe(c,w),E=Ue(c,w),Xt("invalid",c);break;case"option":E=w;break;case"select":c._wrapperState={wasMultiple:!!w.multiple},E=L({},w,{value:void 0}),Xt("invalid",c);break;case"textarea":Nt(c,w),E=ot(c,w),Xt("invalid",c);break;default:E=w}fe(x,E),J=E;for(A in J)if(J.hasOwnProperty(A)){var se=J[A];A==="style"?Je(c,se):A==="dangerouslySetInnerHTML"?(se=se?se.__html:void 0,se!=null&&Ae(c,se)):A==="children"?typeof se=="string"?(x!=="textarea"||se!=="")&&We(c,se):typeof se=="number"&&We(c,""+se):A!=="suppressContentEditableWarning"&&A!=="suppressHydrationWarning"&&A!=="autoFocus"&&(o.hasOwnProperty(A)?se!=null&&A==="onScroll"&&Xt("scroll",c):se!=null&&S(c,A,se,G))}switch(x){case"input":Ne(c),Re(c,w,!1);break;case"textarea":Ne(c),at(c);break;case"option":w.value!=null&&c.setAttribute("value",""+ne(w.value));break;case"select":c.multiple=!!w.multiple,A=w.value,A!=null?Fe(c,!!w.multiple,A,!1):w.defaultValue!=null&&Fe(c,!!w.multiple,w.defaultValue,!0);break;default:typeof E.onClick=="function"&&(c.onclick=hf)}switch(x){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}}w&&(d.flags|=4)}d.ref!==null&&(d.flags|=512,d.flags|=2097152)}return er(d),null;case 6:if(c&&d.stateNode!=null)Lk(c,d,c.memoizedProps,w);else{if(typeof w!="string"&&d.stateNode===null)throw Error(n(166));if(x=Hi(tu.current),Hi(zs.current),wf(d)){if(w=d.stateNode,x=d.memoizedProps,w[Fs]=d,(A=w.nodeValue!==x)&&(c=Pr,c!==null))switch(c.tag){case 3:pf(w.nodeValue,x,(c.mode&1)!==0);break;case 5:c.memoizedProps.suppressHydrationWarning!==!0&&pf(w.nodeValue,x,(c.mode&1)!==0)}A&&(d.flags|=4)}else w=(x.nodeType===9?x:x.ownerDocument).createTextNode(w),w[Fs]=d,d.stateNode=w}return er(d),null;case 13:if(Qt(cn),w=d.memoizedState,c===null||c.memoizedState!==null&&c.memoizedState.dehydrated!==null){if(rn&&_r!==null&&(d.mode&1)!==0&&(d.flags&128)===0)Fj(),Ja(),d.flags|=98560,A=!1;else if(A=wf(d),w!==null&&w.dehydrated!==null){if(c===null){if(!A)throw Error(n(318));if(A=d.memoizedState,A=A!==null?A.dehydrated:null,!A)throw Error(n(317));A[Fs]=d}else Ja(),(d.flags&128)===0&&(d.memoizedState=null),d.flags|=4;er(d),A=!1}else ls!==null&&(Px(ls),ls=null),A=!0;if(!A)return d.flags&65536?d:null}return(d.flags&128)!==0?(d.lanes=x,d):(w=w!==null,w!==(c!==null&&c.memoizedState!==null)&&w&&(d.child.flags|=8192,(d.mode&1)!==0&&(c===null||(cn.current&1)!==0?Dn===0&&(Dn=3):$x())),d.updateQueue!==null&&(d.flags|=4),er(d),null);case 4:return nl(),vx(c,d),c===null&&Gc(d.stateNode.containerInfo),er(d),null;case 10:return Gg(d.type._context),er(d),null;case 17:return pr(d.type)&&gf(),er(d),null;case 19:if(Qt(cn),A=d.memoizedState,A===null)return er(d),null;if(w=(d.flags&128)!==0,G=A.rendering,G===null)if(w)iu(A,!1);else{if(Dn!==0||c!==null&&(c.flags&128)!==0)for(c=d.child;c!==null;){if(G=Ef(c),G!==null){for(d.flags|=128,iu(A,!1),w=G.updateQueue,w!==null&&(d.updateQueue=w,d.flags|=4),d.subtreeFlags=0,w=x,x=d.child;x!==null;)A=x,c=w,A.flags&=14680066,G=A.alternate,G===null?(A.childLanes=0,A.lanes=c,A.child=null,A.subtreeFlags=0,A.memoizedProps=null,A.memoizedState=null,A.updateQueue=null,A.dependencies=null,A.stateNode=null):(A.childLanes=G.childLanes,A.lanes=G.lanes,A.child=G.child,A.subtreeFlags=0,A.deletions=null,A.memoizedProps=G.memoizedProps,A.memoizedState=G.memoizedState,A.updateQueue=G.updateQueue,A.type=G.type,c=G.dependencies,A.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext}),x=x.sibling;return Kt(cn,cn.current&1|2),d.child}c=c.sibling}A.tail!==null&&Ht()>il&&(d.flags|=128,w=!0,iu(A,!1),d.lanes=4194304)}else{if(!w)if(c=Ef(G),c!==null){if(d.flags|=128,w=!0,x=c.updateQueue,x!==null&&(d.updateQueue=x,d.flags|=4),iu(A,!0),A.tail===null&&A.tailMode==="hidden"&&!G.alternate&&!rn)return er(d),null}else 2*Ht()-A.renderingStartTime>il&&x!==1073741824&&(d.flags|=128,w=!0,iu(A,!1),d.lanes=4194304);A.isBackwards?(G.sibling=d.child,d.child=G):(x=A.last,x!==null?x.sibling=G:d.child=G,A.last=G)}return A.tail!==null?(d=A.tail,A.rendering=d,A.tail=d.sibling,A.renderingStartTime=Ht(),d.sibling=null,x=cn.current,Kt(cn,w?x&1|2:x&1),d):(er(d),null);case 22:case 23:return Dx(),w=d.memoizedState!==null,c!==null&&c.memoizedState!==null!==w&&(d.flags|=8192),w&&(d.mode&1)!==0?(Dr&1073741824)!==0&&(er(d),d.subtreeFlags&6&&(d.flags|=8192)):er(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function PI(c,d){switch(Ug(d),d.tag){case 1:return pr(d.type)&&gf(),c=d.flags,c&65536?(d.flags=c&-65537|128,d):null;case 3:return nl(),Qt(fr),Qt(Jn),tx(),c=d.flags,(c&65536)!==0&&(c&128)===0?(d.flags=c&-65537|128,d):null;case 5:return Zg(d),null;case 13:if(Qt(cn),c=d.memoizedState,c!==null&&c.dehydrated!==null){if(d.alternate===null)throw Error(n(340));Ja()}return c=d.flags,c&65536?(d.flags=c&-65537|128,d):null;case 19:return Qt(cn),null;case 4:return nl(),null;case 10:return Gg(d.type._context),null;case 22:case 23:return Dx(),null;case 24:return null;default:return null}}var Lf=!1,tr=!1,_I=typeof WeakSet=="function"?WeakSet:Set,Xe=null;function sl(c,d){var x=c.ref;if(x!==null)if(typeof x=="function")try{x(null)}catch(w){fn(c,d,w)}else x.current=null}function wx(c,d,x){try{x()}catch(w){fn(c,d,w)}}var Mk=!1;function DI(c,d){if(Dg=zn,c=mj(),Ng(c)){if("selectionStart"in c)var x={start:c.selectionStart,end:c.selectionEnd};else e:{x=(x=c.ownerDocument)&&x.defaultView||window;var w=x.getSelection&&x.getSelection();if(w&&w.rangeCount!==0){x=w.anchorNode;var E=w.anchorOffset,A=w.focusNode;w=w.focusOffset;try{x.nodeType,A.nodeType}catch{x=null;break e}var G=0,J=-1,se=-1,he=0,Te=0,_e=c,Ee=null;t:for(;;){for(var Ke;_e!==x||E!==0&&_e.nodeType!==3||(J=G+E),_e!==A||w!==0&&_e.nodeType!==3||(se=G+w),_e.nodeType===3&&(G+=_e.nodeValue.length),(Ke=_e.firstChild)!==null;)Ee=_e,_e=Ke;for(;;){if(_e===c)break t;if(Ee===x&&++he===E&&(J=G),Ee===A&&++Te===w&&(se=G),(Ke=_e.nextSibling)!==null)break;_e=Ee,Ee=_e.parentNode}_e=Ke}x=J===-1||se===-1?null:{start:J,end:se}}else x=null}x=x||{start:0,end:0}}else x=null;for($g={focusedElem:c,selectionRange:x},zn=!1,Xe=d;Xe!==null;)if(d=Xe,c=d.child,(d.subtreeFlags&1028)!==0&&c!==null)c.return=d,Xe=c;else for(;Xe!==null;){d=Xe;try{var Ze=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(Ze!==null){var et=Ze.memoizedProps,hn=Ze.memoizedState,de=d.stateNode,ae=de.getSnapshotBeforeUpdate(d.elementType===d.type?et:cs(d.type,et),hn);de.__reactInternalSnapshotBeforeUpdate=ae}break;case 3:var pe=d.stateNode.containerInfo;pe.nodeType===1?pe.textContent="":pe.nodeType===9&&pe.documentElement&&pe.removeChild(pe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Me){fn(d,d.return,Me)}if(c=d.sibling,c!==null){c.return=d.return,Xe=c;break}Xe=d.return}return Ze=Mk,Mk=!1,Ze}function au(c,d,x){var w=d.updateQueue;if(w=w!==null?w.lastEffect:null,w!==null){var E=w=w.next;do{if((E.tag&c)===c){var A=E.destroy;E.destroy=void 0,A!==void 0&&wx(d,x,A)}E=E.next}while(E!==w)}}function Mf(c,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var x=d=d.next;do{if((x.tag&c)===c){var w=x.create;x.destroy=w()}x=x.next}while(x!==d)}}function jx(c){var d=c.ref;if(d!==null){var x=c.stateNode;switch(c.tag){case 5:c=x;break;default:c=x}typeof d=="function"?d(c):d.current=c}}function Ok(c){var d=c.alternate;d!==null&&(c.alternate=null,Ok(d)),c.child=null,c.deletions=null,c.sibling=null,c.tag===5&&(d=c.stateNode,d!==null&&(delete d[Fs],delete d[Xc],delete d[Og],delete d[mI],delete d[gI])),c.stateNode=null,c.return=null,c.dependencies=null,c.memoizedProps=null,c.memoizedState=null,c.pendingProps=null,c.stateNode=null,c.updateQueue=null}function Fk(c){return c.tag===5||c.tag===3||c.tag===4}function zk(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||Fk(c.return))return null;c=c.return}for(c.sibling.return=c.return,c=c.sibling;c.tag!==5&&c.tag!==6&&c.tag!==18;){if(c.flags&2||c.child===null||c.tag===4)continue e;c.child.return=c,c=c.child}if(!(c.flags&2))return c.stateNode}}function kx(c,d,x){var w=c.tag;if(w===5||w===6)c=c.stateNode,d?x.nodeType===8?x.parentNode.insertBefore(c,d):x.insertBefore(c,d):(x.nodeType===8?(d=x.parentNode,d.insertBefore(c,x)):(d=x,d.appendChild(c)),x=x._reactRootContainer,x!=null||d.onclick!==null||(d.onclick=hf));else if(w!==4&&(c=c.child,c!==null))for(kx(c,d,x),c=c.sibling;c!==null;)kx(c,d,x),c=c.sibling}function Sx(c,d,x){var w=c.tag;if(w===5||w===6)c=c.stateNode,d?x.insertBefore(c,d):x.appendChild(c);else if(w!==4&&(c=c.child,c!==null))for(Sx(c,d,x),c=c.sibling;c!==null;)Sx(c,d,x),c=c.sibling}var qn=null,us=!1;function ei(c,d,x){for(x=x.child;x!==null;)Bk(c,d,x),x=x.sibling}function Bk(c,d,x){if(ir&&typeof ir.onCommitFiberUnmount=="function")try{ir.onCommitFiberUnmount(Oo,x)}catch{}switch(x.tag){case 5:tr||sl(x,d);case 6:var w=qn,E=us;qn=null,ei(c,d,x),qn=w,us=E,qn!==null&&(us?(c=qn,x=x.stateNode,c.nodeType===8?c.parentNode.removeChild(x):c.removeChild(x)):qn.removeChild(x.stateNode));break;case 18:qn!==null&&(us?(c=qn,x=x.stateNode,c.nodeType===8?Mg(c.parentNode,x):c.nodeType===1&&Mg(c,x),Dt(c)):Mg(qn,x.stateNode));break;case 4:w=qn,E=us,qn=x.stateNode.containerInfo,us=!0,ei(c,d,x),qn=w,us=E;break;case 0:case 11:case 14:case 15:if(!tr&&(w=x.updateQueue,w!==null&&(w=w.lastEffect,w!==null))){E=w=w.next;do{var A=E,G=A.destroy;A=A.tag,G!==void 0&&((A&2)!==0||(A&4)!==0)&&wx(x,d,G),E=E.next}while(E!==w)}ei(c,d,x);break;case 1:if(!tr&&(sl(x,d),w=x.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=x.memoizedProps,w.state=x.memoizedState,w.componentWillUnmount()}catch(J){fn(x,d,J)}ei(c,d,x);break;case 21:ei(c,d,x);break;case 22:x.mode&1?(tr=(w=tr)||x.memoizedState!==null,ei(c,d,x),tr=w):ei(c,d,x);break;default:ei(c,d,x)}}function Uk(c){var d=c.updateQueue;if(d!==null){c.updateQueue=null;var x=c.stateNode;x===null&&(x=c.stateNode=new _I),d.forEach(function(w){var E=UI.bind(null,c,w);x.has(w)||(x.add(w),w.then(E,E))})}}function ds(c,d){var x=d.deletions;if(x!==null)for(var w=0;w<x.length;w++){var E=x[w];try{var A=c,G=d,J=G;e:for(;J!==null;){switch(J.tag){case 5:qn=J.stateNode,us=!1;break e;case 3:qn=J.stateNode.containerInfo,us=!0;break e;case 4:qn=J.stateNode.containerInfo,us=!0;break e}J=J.return}if(qn===null)throw Error(n(160));Bk(A,G,E),qn=null,us=!1;var se=E.alternate;se!==null&&(se.return=null),E.return=null}catch(he){fn(E,d,he)}}if(d.subtreeFlags&12854)for(d=d.child;d!==null;)Hk(d,c),d=d.sibling}function Hk(c,d){var x=c.alternate,w=c.flags;switch(c.tag){case 0:case 11:case 14:case 15:if(ds(d,c),Us(c),w&4){try{au(3,c,c.return),Mf(3,c)}catch(et){fn(c,c.return,et)}try{au(5,c,c.return)}catch(et){fn(c,c.return,et)}}break;case 1:ds(d,c),Us(c),w&512&&x!==null&&sl(x,x.return);break;case 5:if(ds(d,c),Us(c),w&512&&x!==null&&sl(x,x.return),c.flags&32){var E=c.stateNode;try{We(E,"")}catch(et){fn(c,c.return,et)}}if(w&4&&(E=c.stateNode,E!=null)){var A=c.memoizedProps,G=x!==null?x.memoizedProps:A,J=c.type,se=c.updateQueue;if(c.updateQueue=null,se!==null)try{J==="input"&&A.type==="radio"&&A.name!=null&&ve(E,A),K(J,G);var he=K(J,A);for(G=0;G<se.length;G+=2){var Te=se[G],_e=se[G+1];Te==="style"?Je(E,_e):Te==="dangerouslySetInnerHTML"?Ae(E,_e):Te==="children"?We(E,_e):S(E,Te,_e,he)}switch(J){case"input":be(E,A);break;case"textarea":mt(E,A);break;case"select":var Ee=E._wrapperState.wasMultiple;E._wrapperState.wasMultiple=!!A.multiple;var Ke=A.value;Ke!=null?Fe(E,!!A.multiple,Ke,!1):Ee!==!!A.multiple&&(A.defaultValue!=null?Fe(E,!!A.multiple,A.defaultValue,!0):Fe(E,!!A.multiple,A.multiple?[]:"",!1))}E[Xc]=A}catch(et){fn(c,c.return,et)}}break;case 6:if(ds(d,c),Us(c),w&4){if(c.stateNode===null)throw Error(n(162));E=c.stateNode,A=c.memoizedProps;try{E.nodeValue=A}catch(et){fn(c,c.return,et)}}break;case 3:if(ds(d,c),Us(c),w&4&&x!==null&&x.memoizedState.isDehydrated)try{Dt(d.containerInfo)}catch(et){fn(c,c.return,et)}break;case 4:ds(d,c),Us(c);break;case 13:ds(d,c),Us(c),E=c.child,E.flags&8192&&(A=E.memoizedState!==null,E.stateNode.isHidden=A,!A||E.alternate!==null&&E.alternate.memoizedState!==null||(Ex=Ht())),w&4&&Uk(c);break;case 22:if(Te=x!==null&&x.memoizedState!==null,c.mode&1?(tr=(he=tr)||Te,ds(d,c),tr=he):ds(d,c),Us(c),w&8192){if(he=c.memoizedState!==null,(c.stateNode.isHidden=he)&&!Te&&(c.mode&1)!==0)for(Xe=c,Te=c.child;Te!==null;){for(_e=Xe=Te;Xe!==null;){switch(Ee=Xe,Ke=Ee.child,Ee.tag){case 0:case 11:case 14:case 15:au(4,Ee,Ee.return);break;case 1:sl(Ee,Ee.return);var Ze=Ee.stateNode;if(typeof Ze.componentWillUnmount=="function"){w=Ee,x=Ee.return;try{d=w,Ze.props=d.memoizedProps,Ze.state=d.memoizedState,Ze.componentWillUnmount()}catch(et){fn(w,x,et)}}break;case 5:sl(Ee,Ee.return);break;case 22:if(Ee.memoizedState!==null){qk(_e);continue}}Ke!==null?(Ke.return=Ee,Xe=Ke):qk(_e)}Te=Te.sibling}e:for(Te=null,_e=c;;){if(_e.tag===5){if(Te===null){Te=_e;try{E=_e.stateNode,he?(A=E.style,typeof A.setProperty=="function"?A.setProperty("display","none","important"):A.display="none"):(J=_e.stateNode,se=_e.memoizedProps.style,G=se!=null&&se.hasOwnProperty("display")?se.display:null,J.style.display=Qe("display",G))}catch(et){fn(c,c.return,et)}}}else if(_e.tag===6){if(Te===null)try{_e.stateNode.nodeValue=he?"":_e.memoizedProps}catch(et){fn(c,c.return,et)}}else if((_e.tag!==22&&_e.tag!==23||_e.memoizedState===null||_e===c)&&_e.child!==null){_e.child.return=_e,_e=_e.child;continue}if(_e===c)break e;for(;_e.sibling===null;){if(_e.return===null||_e.return===c)break e;Te===_e&&(Te=null),_e=_e.return}Te===_e&&(Te=null),_e.sibling.return=_e.return,_e=_e.sibling}}break;case 19:ds(d,c),Us(c),w&4&&Uk(c);break;case 21:break;default:ds(d,c),Us(c)}}function Us(c){var d=c.flags;if(d&2){try{e:{for(var x=c.return;x!==null;){if(Fk(x)){var w=x;break e}x=x.return}throw Error(n(160))}switch(w.tag){case 5:var E=w.stateNode;w.flags&32&&(We(E,""),w.flags&=-33);var A=zk(c);Sx(c,A,E);break;case 3:case 4:var G=w.stateNode.containerInfo,J=zk(c);kx(c,J,G);break;default:throw Error(n(161))}}catch(se){fn(c,c.return,se)}c.flags&=-3}d&4096&&(c.flags&=-4097)}function $I(c,d,x){Xe=c,Vk(c)}function Vk(c,d,x){for(var w=(c.mode&1)!==0;Xe!==null;){var E=Xe,A=E.child;if(E.tag===22&&w){var G=E.memoizedState!==null||Lf;if(!G){var J=E.alternate,se=J!==null&&J.memoizedState!==null||tr;J=Lf;var he=tr;if(Lf=G,(tr=se)&&!he)for(Xe=E;Xe!==null;)G=Xe,se=G.child,G.tag===22&&G.memoizedState!==null?Kk(E):se!==null?(se.return=G,Xe=se):Kk(E);for(;A!==null;)Xe=A,Vk(A),A=A.sibling;Xe=E,Lf=J,tr=he}Wk(c)}else(E.subtreeFlags&8772)!==0&&A!==null?(A.return=E,Xe=A):Wk(c)}}function Wk(c){for(;Xe!==null;){var d=Xe;if((d.flags&8772)!==0){var x=d.alternate;try{if((d.flags&8772)!==0)switch(d.tag){case 0:case 11:case 15:tr||Mf(5,d);break;case 1:var w=d.stateNode;if(d.flags&4&&!tr)if(x===null)w.componentDidMount();else{var E=d.elementType===d.type?x.memoizedProps:cs(d.type,x.memoizedProps);w.componentDidUpdate(E,x.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var A=d.updateQueue;A!==null&&qj(d,A,w);break;case 3:var G=d.updateQueue;if(G!==null){if(x=null,d.child!==null)switch(d.child.tag){case 5:x=d.child.stateNode;break;case 1:x=d.child.stateNode}qj(d,G,x)}break;case 5:var J=d.stateNode;if(x===null&&d.flags&4){x=J;var se=d.memoizedProps;switch(d.type){case"button":case"input":case"select":case"textarea":se.autoFocus&&x.focus();break;case"img":se.src&&(x.src=se.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(d.memoizedState===null){var he=d.alternate;if(he!==null){var Te=he.memoizedState;if(Te!==null){var _e=Te.dehydrated;_e!==null&&Dt(_e)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}tr||d.flags&512&&jx(d)}catch(Ee){fn(d,d.return,Ee)}}if(d===c){Xe=null;break}if(x=d.sibling,x!==null){x.return=d.return,Xe=x;break}Xe=d.return}}function qk(c){for(;Xe!==null;){var d=Xe;if(d===c){Xe=null;break}var x=d.sibling;if(x!==null){x.return=d.return,Xe=x;break}Xe=d.return}}function Kk(c){for(;Xe!==null;){var d=Xe;try{switch(d.tag){case 0:case 11:case 15:var x=d.return;try{Mf(4,d)}catch(se){fn(d,x,se)}break;case 1:var w=d.stateNode;if(typeof w.componentDidMount=="function"){var E=d.return;try{w.componentDidMount()}catch(se){fn(d,E,se)}}var A=d.return;try{jx(d)}catch(se){fn(d,A,se)}break;case 5:var G=d.return;try{jx(d)}catch(se){fn(d,G,se)}}}catch(se){fn(d,d.return,se)}if(d===c){Xe=null;break}var J=d.sibling;if(J!==null){J.return=d.return,Xe=J;break}Xe=d.return}}var II=Math.ceil,Of=C.ReactCurrentDispatcher,Nx=C.ReactCurrentOwner,Qr=C.ReactCurrentBatchConfig,$t=0,Un=null,gn=null,Kn=0,Dr=0,ol=Yo(0),Dn=0,lu=null,Wi=0,Ff=0,Cx=0,cu=null,mr=null,Ex=0,il=1/0,xo=null,zf=!1,Tx=null,ti=null,Bf=!1,ni=null,Uf=0,uu=0,Rx=null,Hf=-1,Vf=0;function lr(){return($t&6)!==0?Ht():Hf!==-1?Hf:Hf=Ht()}function ri(c){return(c.mode&1)===0?1:($t&2)!==0&&Kn!==0?Kn&-Kn:yI.transition!==null?(Vf===0&&(Vf=Uo()),Vf):(c=Ot,c!==0||(c=window.event,c=c===void 0?16:is(c.type)),c)}function fs(c,d,x,w){if(50<uu)throw uu=0,Rx=null,Error(n(185));Fn(c,x,w),(($t&2)===0||c!==Un)&&(c===Un&&(($t&2)===0&&(Ff|=x),Dn===4&&si(c,Kn)),gr(c,w),x===1&&$t===0&&(d.mode&1)===0&&(il=Ht()+500,yf&&Qo()))}function gr(c,d){var x=c.callbackNode;$i(c,d);var w=qr(c,c===Un?Kn:0);if(w===0)x!==null&&La(x),c.callbackNode=null,c.callbackPriority=0;else if(d=w&-w,c.callbackPriority!==d){if(x!=null&&La(x),d===1)c.tag===0?xI(Yk.bind(null,c)):$j(Yk.bind(null,c)),pI(function(){($t&6)===0&&Qo()}),x=null;else{switch(tf(w)){case 1:x=oo;break;case 4:x=Lo;break;case 16:x=Ds;break;case 536870912:x=Oa;break;default:x=Ds}x=r1(x,Gk.bind(null,c))}c.callbackPriority=d,c.callbackNode=x}}function Gk(c,d){if(Hf=-1,Vf=0,($t&6)!==0)throw Error(n(327));var x=c.callbackNode;if(al()&&c.callbackNode!==x)return null;var w=qr(c,c===Un?Kn:0);if(w===0)return null;if((w&30)!==0||(w&c.expiredLanes)!==0||d)d=Wf(c,w);else{d=w;var E=$t;$t|=2;var A=Qk();(Un!==c||Kn!==d)&&(xo=null,il=Ht()+500,Ki(c,d));do try{OI();break}catch(J){Xk(c,J)}while(!0);Kg(),Of.current=A,$t=E,gn!==null?d=0:(Un=null,Kn=0,d=Dn)}if(d!==0){if(d===2&&(E=Bo(c),E!==0&&(w=E,d=Ax(c,E))),d===1)throw x=lu,Ki(c,0),si(c,w),gr(c,Ht()),x;if(d===6)si(c,w);else{if(E=c.current.alternate,(w&30)===0&&!LI(E)&&(d=Wf(c,w),d===2&&(A=Bo(c),A!==0&&(w=A,d=Ax(c,A))),d===1))throw x=lu,Ki(c,0),si(c,w),gr(c,Ht()),x;switch(c.finishedWork=E,c.finishedLanes=w,d){case 0:case 1:throw Error(n(345));case 2:Gi(c,mr,xo);break;case 3:if(si(c,w),(w&130023424)===w&&(d=Ex+500-Ht(),10<d)){if(qr(c,0)!==0)break;if(E=c.suspendedLanes,(E&w)!==w){lr(),c.pingedLanes|=c.suspendedLanes&E;break}c.timeoutHandle=Lg(Gi.bind(null,c,mr,xo),d);break}Gi(c,mr,xo);break;case 4:if(si(c,w),(w&4194240)===w)break;for(d=c.eventTimes,E=-1;0<w;){var G=31-On(w);A=1<<G,G=d[G],G>E&&(E=G),w&=~A}if(w=E,w=Ht()-w,w=(120>w?120:480>w?480:1080>w?1080:1920>w?1920:3e3>w?3e3:4320>w?4320:1960*II(w/1960))-w,10<w){c.timeoutHandle=Lg(Gi.bind(null,c,mr,xo),w);break}Gi(c,mr,xo);break;case 5:Gi(c,mr,xo);break;default:throw Error(n(329))}}}return gr(c,Ht()),c.callbackNode===x?Gk.bind(null,c):null}function Ax(c,d){var x=cu;return c.current.memoizedState.isDehydrated&&(Ki(c,d).flags|=256),c=Wf(c,d),c!==2&&(d=mr,mr=x,d!==null&&Px(d)),c}function Px(c){mr===null?mr=c:mr.push.apply(mr,c)}function LI(c){for(var d=c;;){if(d.flags&16384){var x=d.updateQueue;if(x!==null&&(x=x.stores,x!==null))for(var w=0;w<x.length;w++){var E=x[w],A=E.getSnapshot;E=E.value;try{if(!as(A(),E))return!1}catch{return!1}}}if(x=d.child,d.subtreeFlags&16384&&x!==null)x.return=d,d=x;else{if(d===c)break;for(;d.sibling===null;){if(d.return===null||d.return===c)return!0;d=d.return}d.sibling.return=d.return,d=d.sibling}}return!0}function si(c,d){for(d&=~Cx,d&=~Ff,c.suspendedLanes|=d,c.pingedLanes&=~d,c=c.expirationTimes;0<d;){var x=31-On(d),w=1<<x;c[x]=-1,d&=~w}}function Yk(c){if(($t&6)!==0)throw Error(n(327));al();var d=qr(c,0);if((d&1)===0)return gr(c,Ht()),null;var x=Wf(c,d);if(c.tag!==0&&x===2){var w=Bo(c);w!==0&&(d=w,x=Ax(c,w))}if(x===1)throw x=lu,Ki(c,0),si(c,d),gr(c,Ht()),x;if(x===6)throw Error(n(345));return c.finishedWork=c.current.alternate,c.finishedLanes=d,Gi(c,mr,xo),gr(c,Ht()),null}function _x(c,d){var x=$t;$t|=1;try{return c(d)}finally{$t=x,$t===0&&(il=Ht()+500,yf&&Qo())}}function qi(c){ni!==null&&ni.tag===0&&($t&6)===0&&al();var d=$t;$t|=1;var x=Qr.transition,w=Ot;try{if(Qr.transition=null,Ot=1,c)return c()}finally{Ot=w,Qr.transition=x,$t=d,($t&6)===0&&Qo()}}function Dx(){Dr=ol.current,Qt(ol)}function Ki(c,d){c.finishedWork=null,c.finishedLanes=0;var x=c.timeoutHandle;if(x!==-1&&(c.timeoutHandle=-1,fI(x)),gn!==null)for(x=gn.return;x!==null;){var w=x;switch(Ug(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&gf();break;case 3:nl(),Qt(fr),Qt(Jn),tx();break;case 5:Zg(w);break;case 4:nl();break;case 13:Qt(cn);break;case 19:Qt(cn);break;case 10:Gg(w.type._context);break;case 22:case 23:Dx()}x=x.return}if(Un=c,gn=c=oi(c.current,null),Kn=Dr=d,Dn=0,lu=null,Cx=Ff=Wi=0,mr=cu=null,Ui!==null){for(d=0;d<Ui.length;d++)if(x=Ui[d],w=x.interleaved,w!==null){x.interleaved=null;var E=w.next,A=x.pending;if(A!==null){var G=A.next;A.next=E,w.next=G}x.pending=w}Ui=null}return c}function Xk(c,d){do{var x=gn;try{if(Kg(),Tf.current=_f,Rf){for(var w=un.memoizedState;w!==null;){var E=w.queue;E!==null&&(E.pending=null),w=w.next}Rf=!1}if(Vi=0,Bn=_n=un=null,nu=!1,ru=0,Nx.current=null,x===null||x.return===null){Dn=1,lu=d,gn=null;break}e:{var A=c,G=x.return,J=x,se=d;if(d=Kn,J.flags|=32768,se!==null&&typeof se=="object"&&typeof se.then=="function"){var he=se,Te=J,_e=Te.tag;if((Te.mode&1)===0&&(_e===0||_e===11||_e===15)){var Ee=Te.alternate;Ee?(Te.updateQueue=Ee.updateQueue,Te.memoizedState=Ee.memoizedState,Te.lanes=Ee.lanes):(Te.updateQueue=null,Te.memoizedState=null)}var Ke=wk(G);if(Ke!==null){Ke.flags&=-257,jk(Ke,G,J,A,d),Ke.mode&1&&vk(A,he,d),d=Ke,se=he;var Ze=d.updateQueue;if(Ze===null){var et=new Set;et.add(se),d.updateQueue=et}else Ze.add(se);break e}else{if((d&1)===0){vk(A,he,d),$x();break e}se=Error(n(426))}}else if(rn&&J.mode&1){var hn=wk(G);if(hn!==null){(hn.flags&65536)===0&&(hn.flags|=256),jk(hn,G,J,A,d),Wg(rl(se,J));break e}}A=se=rl(se,J),Dn!==4&&(Dn=2),cu===null?cu=[A]:cu.push(A),A=G;do{switch(A.tag){case 3:A.flags|=65536,d&=-d,A.lanes|=d;var de=yk(A,se,d);Wj(A,de);break e;case 1:J=se;var ae=A.type,pe=A.stateNode;if((A.flags&128)===0&&(typeof ae.getDerivedStateFromError=="function"||pe!==null&&typeof pe.componentDidCatch=="function"&&(ti===null||!ti.has(pe)))){A.flags|=65536,d&=-d,A.lanes|=d;var Me=bk(A,J,d);Wj(A,Me);break e}}A=A.return}while(A!==null)}Zk(x)}catch(st){d=st,gn===x&&x!==null&&(gn=x=x.return);continue}break}while(!0)}function Qk(){var c=Of.current;return Of.current=_f,c===null?_f:c}function $x(){(Dn===0||Dn===3||Dn===2)&&(Dn=4),Un===null||(Wi&268435455)===0&&(Ff&268435455)===0||si(Un,Kn)}function Wf(c,d){var x=$t;$t|=2;var w=Qk();(Un!==c||Kn!==d)&&(xo=null,Ki(c,d));do try{MI();break}catch(E){Xk(c,E)}while(!0);if(Kg(),$t=x,Of.current=w,gn!==null)throw Error(n(261));return Un=null,Kn=0,Dn}function MI(){for(;gn!==null;)Jk(gn)}function OI(){for(;gn!==null&&!$c();)Jk(gn)}function Jk(c){var d=n1(c.alternate,c,Dr);c.memoizedProps=c.pendingProps,d===null?Zk(c):gn=d,Nx.current=null}function Zk(c){var d=c;do{var x=d.alternate;if(c=d.return,(d.flags&32768)===0){if(x=AI(x,d,Dr),x!==null){gn=x;return}}else{if(x=PI(x,d),x!==null){x.flags&=32767,gn=x;return}if(c!==null)c.flags|=32768,c.subtreeFlags=0,c.deletions=null;else{Dn=6,gn=null;return}}if(d=d.sibling,d!==null){gn=d;return}gn=d=c}while(d!==null);Dn===0&&(Dn=5)}function Gi(c,d,x){var w=Ot,E=Qr.transition;try{Qr.transition=null,Ot=1,FI(c,d,x,w)}finally{Qr.transition=E,Ot=w}return null}function FI(c,d,x,w){do al();while(ni!==null);if(($t&6)!==0)throw Error(n(327));x=c.finishedWork;var E=c.finishedLanes;if(x===null)return null;if(c.finishedWork=null,c.finishedLanes=0,x===c.current)throw Error(n(177));c.callbackNode=null,c.callbackPriority=0;var A=x.lanes|x.childLanes;if(Rn(c,A),c===Un&&(gn=Un=null,Kn=0),(x.subtreeFlags&2064)===0&&(x.flags&2064)===0||Bf||(Bf=!0,r1(Ds,function(){return al(),null})),A=(x.flags&15990)!==0,(x.subtreeFlags&15990)!==0||A){A=Qr.transition,Qr.transition=null;var G=Ot;Ot=1;var J=$t;$t|=4,Nx.current=null,DI(c,x),Hk(x,c),oI($g),zn=!!Dg,$g=Dg=null,c.current=x,$I(x),Ma(),$t=J,Ot=G,Qr.transition=A}else c.current=x;if(Bf&&(Bf=!1,ni=c,Uf=E),A=c.pendingLanes,A===0&&(ti=null),dr(x.stateNode),gr(c,Ht()),d!==null)for(w=c.onRecoverableError,x=0;x<d.length;x++)E=d[x],w(E.value,{componentStack:E.stack,digest:E.digest});if(zf)throw zf=!1,c=Tx,Tx=null,c;return(Uf&1)!==0&&c.tag!==0&&al(),A=c.pendingLanes,(A&1)!==0?c===Rx?uu++:(uu=0,Rx=c):uu=0,Qo(),null}function al(){if(ni!==null){var c=tf(Uf),d=Qr.transition,x=Ot;try{if(Qr.transition=null,Ot=16>c?16:c,ni===null)var w=!1;else{if(c=ni,ni=null,Uf=0,($t&6)!==0)throw Error(n(331));var E=$t;for($t|=4,Xe=c.current;Xe!==null;){var A=Xe,G=A.child;if((Xe.flags&16)!==0){var J=A.deletions;if(J!==null){for(var se=0;se<J.length;se++){var he=J[se];for(Xe=he;Xe!==null;){var Te=Xe;switch(Te.tag){case 0:case 11:case 15:au(8,Te,A)}var _e=Te.child;if(_e!==null)_e.return=Te,Xe=_e;else for(;Xe!==null;){Te=Xe;var Ee=Te.sibling,Ke=Te.return;if(Ok(Te),Te===he){Xe=null;break}if(Ee!==null){Ee.return=Ke,Xe=Ee;break}Xe=Ke}}}var Ze=A.alternate;if(Ze!==null){var et=Ze.child;if(et!==null){Ze.child=null;do{var hn=et.sibling;et.sibling=null,et=hn}while(et!==null)}}Xe=A}}if((A.subtreeFlags&2064)!==0&&G!==null)G.return=A,Xe=G;else e:for(;Xe!==null;){if(A=Xe,(A.flags&2048)!==0)switch(A.tag){case 0:case 11:case 15:au(9,A,A.return)}var de=A.sibling;if(de!==null){de.return=A.return,Xe=de;break e}Xe=A.return}}var ae=c.current;for(Xe=ae;Xe!==null;){G=Xe;var pe=G.child;if((G.subtreeFlags&2064)!==0&&pe!==null)pe.return=G,Xe=pe;else e:for(G=ae;Xe!==null;){if(J=Xe,(J.flags&2048)!==0)try{switch(J.tag){case 0:case 11:case 15:Mf(9,J)}}catch(st){fn(J,J.return,st)}if(J===G){Xe=null;break e}var Me=J.sibling;if(Me!==null){Me.return=J.return,Xe=Me;break e}Xe=J.return}}if($t=E,Qo(),ir&&typeof ir.onPostCommitFiberRoot=="function")try{ir.onPostCommitFiberRoot(Oo,c)}catch{}w=!0}return w}finally{Ot=x,Qr.transition=d}}return!1}function e1(c,d,x){d=rl(x,d),d=yk(c,d,1),c=Zo(c,d,1),d=lr(),c!==null&&(Fn(c,1,d),gr(c,d))}function fn(c,d,x){if(c.tag===3)e1(c,c,x);else for(;d!==null;){if(d.tag===3){e1(d,c,x);break}else if(d.tag===1){var w=d.stateNode;if(typeof d.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(ti===null||!ti.has(w))){c=rl(x,c),c=bk(d,c,1),d=Zo(d,c,1),c=lr(),d!==null&&(Fn(d,1,c),gr(d,c));break}}d=d.return}}function zI(c,d,x){var w=c.pingCache;w!==null&&w.delete(d),d=lr(),c.pingedLanes|=c.suspendedLanes&x,Un===c&&(Kn&x)===x&&(Dn===4||Dn===3&&(Kn&130023424)===Kn&&500>Ht()-Ex?Ki(c,0):Cx|=x),gr(c,d)}function t1(c,d){d===0&&((c.mode&1)===0?d=1:(d=Wn,Wn<<=1,(Wn&130023424)===0&&(Wn=4194304)));var x=lr();c=ho(c,d),c!==null&&(Fn(c,d,x),gr(c,x))}function BI(c){var d=c.memoizedState,x=0;d!==null&&(x=d.retryLane),t1(c,x)}function UI(c,d){var x=0;switch(c.tag){case 13:var w=c.stateNode,E=c.memoizedState;E!==null&&(x=E.retryLane);break;case 19:w=c.stateNode;break;default:throw Error(n(314))}w!==null&&w.delete(d),t1(c,x)}var n1;n1=function(c,d,x){if(c!==null)if(c.memoizedProps!==d.pendingProps||fr.current)hr=!0;else{if((c.lanes&x)===0&&(d.flags&128)===0)return hr=!1,RI(c,d,x);hr=(c.flags&131072)!==0}else hr=!1,rn&&(d.flags&1048576)!==0&&Ij(d,vf,d.index);switch(d.lanes=0,d.tag){case 2:var w=d.type;If(c,d),c=d.pendingProps;var E=Ya(d,Jn.current);tl(d,x),E=sx(null,d,w,c,E,x);var A=ox();return d.flags|=1,typeof E=="object"&&E!==null&&typeof E.render=="function"&&E.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,pr(w)?(A=!0,xf(d)):A=!1,d.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,Qg(d),E.updater=Df,d.stateNode=E,E._reactInternals=d,dx(d,w,c,x),d=mx(null,d,w,!0,A,x)):(d.tag=0,rn&&A&&Bg(d),ar(null,d,E,x),d=d.child),d;case 16:w=d.elementType;e:{switch(If(c,d),c=d.pendingProps,E=w._init,w=E(w._payload),d.type=w,E=d.tag=VI(w),c=cs(w,c),E){case 0:d=hx(null,d,w,c,x);break e;case 1:d=Tk(null,d,w,c,x);break e;case 11:d=kk(null,d,w,c,x);break e;case 14:d=Sk(null,d,w,cs(w.type,c),x);break e}throw Error(n(306,w,""))}return d;case 0:return w=d.type,E=d.pendingProps,E=d.elementType===w?E:cs(w,E),hx(c,d,w,E,x);case 1:return w=d.type,E=d.pendingProps,E=d.elementType===w?E:cs(w,E),Tk(c,d,w,E,x);case 3:e:{if(Rk(d),c===null)throw Error(n(387));w=d.pendingProps,A=d.memoizedState,E=A.element,Vj(c,d),Cf(d,w,null,x);var G=d.memoizedState;if(w=G.element,A.isDehydrated)if(A={element:w,isDehydrated:!1,cache:G.cache,pendingSuspenseBoundaries:G.pendingSuspenseBoundaries,transitions:G.transitions},d.updateQueue.baseState=A,d.memoizedState=A,d.flags&256){E=rl(Error(n(423)),d),d=Ak(c,d,w,x,E);break e}else if(w!==E){E=rl(Error(n(424)),d),d=Ak(c,d,w,x,E);break e}else for(_r=Go(d.stateNode.containerInfo.firstChild),Pr=d,rn=!0,ls=null,x=Uj(d,null,w,x),d.child=x;x;)x.flags=x.flags&-3|4096,x=x.sibling;else{if(Ja(),w===E){d=go(c,d,x);break e}ar(c,d,w,x)}d=d.child}return d;case 5:return Kj(d),c===null&&Vg(d),w=d.type,E=d.pendingProps,A=c!==null?c.memoizedProps:null,G=E.children,Ig(w,E)?G=null:A!==null&&Ig(w,A)&&(d.flags|=32),Ek(c,d),ar(c,d,G,x),d.child;case 6:return c===null&&Vg(d),null;case 13:return Pk(c,d,x);case 4:return Jg(d,d.stateNode.containerInfo),w=d.pendingProps,c===null?d.child=Za(d,null,w,x):ar(c,d,w,x),d.child;case 11:return w=d.type,E=d.pendingProps,E=d.elementType===w?E:cs(w,E),kk(c,d,w,E,x);case 7:return ar(c,d,d.pendingProps,x),d.child;case 8:return ar(c,d,d.pendingProps.children,x),d.child;case 12:return ar(c,d,d.pendingProps.children,x),d.child;case 10:e:{if(w=d.type._context,E=d.pendingProps,A=d.memoizedProps,G=E.value,Kt(kf,w._currentValue),w._currentValue=G,A!==null)if(as(A.value,G)){if(A.children===E.children&&!fr.current){d=go(c,d,x);break e}}else for(A=d.child,A!==null&&(A.return=d);A!==null;){var J=A.dependencies;if(J!==null){G=A.child;for(var se=J.firstContext;se!==null;){if(se.context===w){if(A.tag===1){se=mo(-1,x&-x),se.tag=2;var he=A.updateQueue;if(he!==null){he=he.shared;var Te=he.pending;Te===null?se.next=se:(se.next=Te.next,Te.next=se),he.pending=se}}A.lanes|=x,se=A.alternate,se!==null&&(se.lanes|=x),Yg(A.return,x,d),J.lanes|=x;break}se=se.next}}else if(A.tag===10)G=A.type===d.type?null:A.child;else if(A.tag===18){if(G=A.return,G===null)throw Error(n(341));G.lanes|=x,J=G.alternate,J!==null&&(J.lanes|=x),Yg(G,x,d),G=A.sibling}else G=A.child;if(G!==null)G.return=A;else for(G=A;G!==null;){if(G===d){G=null;break}if(A=G.sibling,A!==null){A.return=G.return,G=A;break}G=G.return}A=G}ar(c,d,E.children,x),d=d.child}return d;case 9:return E=d.type,w=d.pendingProps.children,tl(d,x),E=Yr(E),w=w(E),d.flags|=1,ar(c,d,w,x),d.child;case 14:return w=d.type,E=cs(w,d.pendingProps),E=cs(w.type,E),Sk(c,d,w,E,x);case 15:return Nk(c,d,d.type,d.pendingProps,x);case 17:return w=d.type,E=d.pendingProps,E=d.elementType===w?E:cs(w,E),If(c,d),d.tag=1,pr(w)?(c=!0,xf(d)):c=!1,tl(d,x),gk(d,w,E),dx(d,w,E,x),mx(null,d,w,!0,c,x);case 19:return Dk(c,d,x);case 22:return Ck(c,d,x)}throw Error(n(156,d.tag))};function r1(c,d){return Ia(c,d)}function HI(c,d,x,w){this.tag=c,this.key=x,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Jr(c,d,x,w){return new HI(c,d,x,w)}function Ix(c){return c=c.prototype,!(!c||!c.isReactComponent)}function VI(c){if(typeof c=="function")return Ix(c)?1:0;if(c!=null){if(c=c.$$typeof,c===V)return 11;if(c===M)return 14}return 2}function oi(c,d){var x=c.alternate;return x===null?(x=Jr(c.tag,d,c.key,c.mode),x.elementType=c.elementType,x.type=c.type,x.stateNode=c.stateNode,x.alternate=c,c.alternate=x):(x.pendingProps=d,x.type=c.type,x.flags=0,x.subtreeFlags=0,x.deletions=null),x.flags=c.flags&14680064,x.childLanes=c.childLanes,x.lanes=c.lanes,x.child=c.child,x.memoizedProps=c.memoizedProps,x.memoizedState=c.memoizedState,x.updateQueue=c.updateQueue,d=c.dependencies,x.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},x.sibling=c.sibling,x.index=c.index,x.ref=c.ref,x}function qf(c,d,x,w,E,A){var G=2;if(w=c,typeof c=="function")Ix(c)&&(G=1);else if(typeof c=="string")G=5;else e:switch(c){case R:return Yi(x.children,E,A,d);case $:G=8,E|=8;break;case P:return c=Jr(12,x,d,E|2),c.elementType=P,c.lanes=A,c;case U:return c=Jr(13,x,d,E),c.elementType=U,c.lanes=A,c;case I:return c=Jr(19,x,d,E),c.elementType=I,c.lanes=A,c;case W:return Kf(x,E,A,d);default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case F:G=10;break e;case _:G=9;break e;case V:G=11;break e;case M:G=14;break e;case B:G=16,w=null;break e}throw Error(n(130,c==null?c:typeof c,""))}return d=Jr(G,x,d,E),d.elementType=c,d.type=w,d.lanes=A,d}function Yi(c,d,x,w){return c=Jr(7,c,w,d),c.lanes=x,c}function Kf(c,d,x,w){return c=Jr(22,c,w,d),c.elementType=W,c.lanes=x,c.stateNode={isHidden:!1},c}function Lx(c,d,x){return c=Jr(6,c,null,d),c.lanes=x,c}function Mx(c,d,x){return d=Jr(4,c.children!==null?c.children:[],c.key,d),d.lanes=x,d.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},d}function WI(c,d,x,w,E){this.tag=d,this.containerInfo=c,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=$s(0),this.expirationTimes=$s(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$s(0),this.identifierPrefix=w,this.onRecoverableError=E,this.mutableSourceEagerHydrationData=null}function Ox(c,d,x,w,E,A,G,J,se){return c=new WI(c,d,x,J,se),d===1?(d=1,A===!0&&(d|=8)):d=0,A=Jr(3,null,null,d),c.current=A,A.stateNode=c,A.memoizedState={element:w,isDehydrated:x,cache:null,transitions:null,pendingSuspenseBoundaries:null},Qg(A),c}function qI(c,d,x){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:T,key:w==null?null:""+w,children:c,containerInfo:d,implementation:x}}function s1(c){if(!c)return Xo;c=c._reactInternals;e:{if(wt(c)!==c||c.tag!==1)throw Error(n(170));var d=c;do{switch(d.tag){case 3:d=d.stateNode.context;break e;case 1:if(pr(d.type)){d=d.stateNode.__reactInternalMemoizedMergedChildContext;break e}}d=d.return}while(d!==null);throw Error(n(171))}if(c.tag===1){var x=c.type;if(pr(x))return _j(c,x,d)}return d}function o1(c,d,x,w,E,A,G,J,se){return c=Ox(x,w,!0,c,E,A,G,J,se),c.context=s1(null),x=c.current,w=lr(),E=ri(x),A=mo(w,E),A.callback=d??null,Zo(x,A,E),c.current.lanes=E,Fn(c,E,w),gr(c,w),c}function Gf(c,d,x,w){var E=d.current,A=lr(),G=ri(E);return x=s1(x),d.context===null?d.context=x:d.pendingContext=x,d=mo(A,G),d.payload={element:c},w=w===void 0?null:w,w!==null&&(d.callback=w),c=Zo(E,d,G),c!==null&&(fs(c,E,G,A),Nf(c,E,G)),G}function Yf(c){if(c=c.current,!c.child)return null;switch(c.child.tag){case 5:return c.child.stateNode;default:return c.child.stateNode}}function i1(c,d){if(c=c.memoizedState,c!==null&&c.dehydrated!==null){var x=c.retryLane;c.retryLane=x!==0&&x<d?x:d}}function Fx(c,d){i1(c,d),(c=c.alternate)&&i1(c,d)}function KI(){return null}var a1=typeof reportError=="function"?reportError:function(c){console.error(c)};function zx(c){this._internalRoot=c}Xf.prototype.render=zx.prototype.render=function(c){var d=this._internalRoot;if(d===null)throw Error(n(409));Gf(c,d,null,null)},Xf.prototype.unmount=zx.prototype.unmount=function(){var c=this._internalRoot;if(c!==null){this._internalRoot=null;var d=c.containerInfo;qi(function(){Gf(null,c,null,null)}),d[co]=null}};function Xf(c){this._internalRoot=c}Xf.prototype.unstable_scheduleHydration=function(c){if(c){var d=ao();c={blockedOn:null,target:c,priority:d};for(var x=0;x<Os.length&&d!==0&&d<Os[x].priority;x++);Os.splice(x,0,c),x===0&&te(c)}};function Bx(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)}function Qf(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11&&(c.nodeType!==8||c.nodeValue!==" react-mount-point-unstable "))}function l1(){}function GI(c,d,x,w,E){if(E){if(typeof w=="function"){var A=w;w=function(){var he=Yf(G);A.call(he)}}var G=o1(d,w,c,0,null,!1,!1,"",l1);return c._reactRootContainer=G,c[co]=G.current,Gc(c.nodeType===8?c.parentNode:c),qi(),G}for(;E=c.lastChild;)c.removeChild(E);if(typeof w=="function"){var J=w;w=function(){var he=Yf(se);J.call(he)}}var se=Ox(c,0,!1,null,null,!1,!1,"",l1);return c._reactRootContainer=se,c[co]=se.current,Gc(c.nodeType===8?c.parentNode:c),qi(function(){Gf(d,se,x,w)}),se}function Jf(c,d,x,w,E){var A=x._reactRootContainer;if(A){var G=A;if(typeof E=="function"){var J=E;E=function(){var se=Yf(G);J.call(se)}}Gf(d,G,c,E)}else G=GI(x,d,c,E,w);return Yf(G)}Mc=function(c){switch(c.tag){case 3:var d=c.stateNode;if(d.current.memoizedState.isDehydrated){var x=io(d.pendingLanes);x!==0&&(Is(d,x|1),gr(d,Ht()),($t&6)===0&&(il=Ht()+500,Qo()))}break;case 13:qi(function(){var w=ho(c,1);if(w!==null){var E=lr();fs(w,c,1,E)}}),Fx(c,1)}},Ii=function(c){if(c.tag===13){var d=ho(c,134217728);if(d!==null){var x=lr();fs(d,c,134217728,x)}Fx(c,134217728)}},Oc=function(c){if(c.tag===13){var d=ri(c),x=ho(c,d);if(x!==null){var w=lr();fs(x,c,d,w)}Fx(c,d)}},ao=function(){return Ot},Fc=function(c,d){var x=Ot;try{return Ot=c,d()}finally{Ot=x}},Ge=function(c,d,x){switch(d){case"input":if(be(c,x),d=x.name,x.type==="radio"&&d!=null){for(x=c;x.parentNode;)x=x.parentNode;for(x=x.querySelectorAll("input[name="+JSON.stringify(""+d)+'][type="radio"]'),d=0;d<x.length;d++){var w=x[d];if(w!==c&&w.form===c.form){var E=mf(w);if(!E)throw Error(n(90));Ce(w),be(w,E)}}}break;case"textarea":mt(c,x);break;case"select":d=x.value,d!=null&&Fe(c,!!x.multiple,d,!1)}},_t=_x,zt=qi;var YI={usingClientEntryPoint:!1,Events:[Qc,Ka,mf,vt,tt,_x]},du={findFiberByHostInstance:Oi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},XI={bundleType:du.bundleType,version:du.version,rendererPackageName:du.rendererPackageName,rendererConfig:du.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(c){return c=nn(c),c===null?null:c.stateNode},findFiberByHostInstance:du.findFiberByHostInstance||KI,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Zf=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Zf.isDisabled&&Zf.supportsFiber)try{Oo=Zf.inject(XI),ir=Zf}catch{}}return xr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=YI,xr.createPortal=function(c,d){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Bx(d))throw Error(n(200));return qI(c,d,null,x)},xr.createRoot=function(c,d){if(!Bx(c))throw Error(n(299));var x=!1,w="",E=a1;return d!=null&&(d.unstable_strictMode===!0&&(x=!0),d.identifierPrefix!==void 0&&(w=d.identifierPrefix),d.onRecoverableError!==void 0&&(E=d.onRecoverableError)),d=Ox(c,1,!1,null,null,x,!1,w,E),c[co]=d.current,Gc(c.nodeType===8?c.parentNode:c),new zx(d)},xr.findDOMNode=function(c){if(c==null)return null;if(c.nodeType===1)return c;var d=c._reactInternals;if(d===void 0)throw typeof c.render=="function"?Error(n(188)):(c=Object.keys(c).join(","),Error(n(268,c)));return c=nn(d),c=c===null?null:c.stateNode,c},xr.flushSync=function(c){return qi(c)},xr.hydrate=function(c,d,x){if(!Qf(d))throw Error(n(200));return Jf(null,c,d,!0,x)},xr.hydrateRoot=function(c,d,x){if(!Bx(c))throw Error(n(405));var w=x!=null&&x.hydratedSources||null,E=!1,A="",G=a1;if(x!=null&&(x.unstable_strictMode===!0&&(E=!0),x.identifierPrefix!==void 0&&(A=x.identifierPrefix),x.onRecoverableError!==void 0&&(G=x.onRecoverableError)),d=o1(d,null,c,1,x??null,E,!1,A,G),c[co]=d.current,Gc(c),w)for(c=0;c<w.length;c++)x=w[c],E=x._getVersion,E=E(x._source),d.mutableSourceEagerHydrationData==null?d.mutableSourceEagerHydrationData=[x,E]:d.mutableSourceEagerHydrationData.push(x,E);return new Xf(d)},xr.render=function(c,d,x){if(!Qf(d))throw Error(n(200));return Jf(null,c,d,!1,x)},xr.unmountComponentAtNode=function(c){if(!Qf(c))throw Error(n(40));return c._reactRootContainer?(qi(function(){Jf(null,null,c,!1,function(){c._reactRootContainer=null,c[co]=null})}),!0):!1},xr.unstable_batchedUpdates=_x,xr.unstable_renderSubtreeIntoContainer=function(c,d,x,w){if(!Qf(x))throw Error(n(200));if(c==null||c._reactInternals===void 0)throw Error(n(38));return Jf(c,d,x,!1,w)},xr.version="18.3.1-next-f1338f8080-20240426",xr}var g1;function BE(){if(g1)return Wx.exports;g1=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Wx.exports=iL(),Wx.exports}var x1;function aL(){if(x1)return ep;x1=1;var e=BE();return ep.createRoot=e.createRoot,ep.hydrateRoot=e.hydrateRoot,ep}var lL=aL();/**
41
- * react-router v7.13.1
42
- *
43
- * Copyright (c) Remix Software Inc.
44
- *
45
- * This source code is licensed under the MIT license found in the
46
- * LICENSE.md file in the root directory of this source tree.
47
- *
48
- * @license MIT
49
- */var y1="popstate";function b1(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function cL(e={}){function t(r,o){var f;let i=(f=o.state)==null?void 0:f.masked,{pathname:a,search:l,hash:u}=i||r.location;return gb("",{pathname:a,search:l,hash:u},o.state&&o.state.usr||null,o.state&&o.state.key||"default",i?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,o){return typeof o=="string"?o:Zu(o)}return dL(t,n,null,e)}function dn(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function bs(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function uL(){return Math.random().toString(36).substring(2,10)}function v1(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function gb(e,t,n=null,r,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?pc(t):t,state:n,key:t&&t.key||r||uL(),unstable_mask:o}}function Zu({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function pc(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function dL(e,t,n,r={}){let{window:o=document.defaultView,v5Compat:i=!1}=r,a=o.history,l="POP",u=null,f=p();f==null&&(f=0,a.replaceState({...a.state,idx:f},""));function p(){return(a.state||{idx:null}).idx}function h(){l="POP";let b=p(),j=b==null?null:b-f;f=b,u&&u({action:l,location:v.location,delta:j})}function g(b,j){l="PUSH";let N=b1(b)?b:gb(v.location,b,j);f=p()+1;let S=v1(N,f),C=v.createHref(N.unstable_mask||N);try{a.pushState(S,"",C)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;o.location.assign(C)}i&&u&&u({action:l,location:v.location,delta:1})}function y(b,j){l="REPLACE";let N=b1(b)?b:gb(v.location,b,j);f=p();let S=v1(N,f),C=v.createHref(N.unstable_mask||N);a.replaceState(S,"",C),i&&u&&u({action:l,location:v.location,delta:0})}function k(b){return fL(b)}let v={get action(){return l},get location(){return e(o,a)},listen(b){if(u)throw new Error("A history only accepts one active listener");return o.addEventListener(y1,h),u=b,()=>{o.removeEventListener(y1,h),u=null}},createHref(b){return t(o,b)},createURL:k,encodeLocation(b){let j=k(b);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:g,replace:y,go(b){return a.go(b)}};return v}function fL(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),dn(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Zu(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function UE(e,t,n="/"){return pL(e,t,n,!1)}function pL(e,t,n,r){let o=typeof t=="string"?pc(t):t,i=Eo(o.pathname||"/",n);if(i==null)return null;let a=HE(e);hL(a);let l=null;for(let u=0;l==null&&u<a.length;++u){let f=NL(i);l=kL(a[u],f,r)}return l}function HE(e,t=[],n=[],r="",o=!1){let i=(a,l,u=o,f)=>{let p={relativePath:f===void 0?a.path||"":f,caseSensitive:a.caseSensitive===!0,childrenIndex:l,route:a};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(r)&&u)return;dn(p.relativePath.startsWith(r),`Absolute route path "${p.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(r.length)}let h=Xs([r,p.relativePath]),g=n.concat(p);a.children&&a.children.length>0&&(dn(a.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),HE(a.children,t,g,h,u)),!(a.path==null&&!a.index)&&t.push({path:h,score:wL(h,a.index),routesMeta:g})};return e.forEach((a,l)=>{var u;if(a.path===""||!((u=a.path)!=null&&u.includes("?")))i(a,l);else for(let f of VE(a.path))i(a,l,!0,f)}),t}function VE(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,o=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return o?[i,""]:[i];let a=VE(r.join("/")),l=[];return l.push(...a.map(u=>u===""?i:[i,u].join("/"))),o&&l.push(...a),l.map(u=>e.startsWith("/")&&u===""?"/":u)}function hL(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:jL(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var mL=/^:[\w-]+$/,gL=3,xL=2,yL=1,bL=10,vL=-2,w1=e=>e==="*";function wL(e,t){let n=e.split("/"),r=n.length;return n.some(w1)&&(r+=vL),t&&(r+=xL),n.filter(o=>!w1(o)).reduce((o,i)=>o+(mL.test(i)?gL:i===""?yL:bL),r)}function jL(e,t){return e.length===t.length&&e.slice(0,-1).every((r,o)=>r===t[o])?e[e.length-1]-t[t.length-1]:0}function kL(e,t,n=!1){let{routesMeta:r}=e,o={},i="/",a=[];for(let l=0;l<r.length;++l){let u=r[l],f=l===r.length-1,p=i==="/"?t:t.slice(i.length)||"/",h=nh({path:u.relativePath,caseSensitive:u.caseSensitive,end:f},p),g=u.route;if(!h&&f&&n&&!r[r.length-1].route.index&&(h=nh({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},p)),!h)return null;Object.assign(o,h.params),a.push({params:o,pathname:Xs([i,h.pathname]),pathnameBase:RL(Xs([i,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(i=Xs([i,h.pathnameBase]))}return a}function nh(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=SL(e.path,e.caseSensitive,e.end),o=t.match(n);if(!o)return null;let i=o[0],a=i.replace(/(.)\/+$/,"$1"),l=o.slice(1);return{params:r.reduce((f,{paramName:p,isOptional:h},g)=>{if(p==="*"){let k=l[g]||"";a=i.slice(0,i.length-k.length).replace(/(.)\/+$/,"$1")}const y=l[g];return h&&!y?f[p]=void 0:f[p]=(y||"").replace(/%2F/g,"/"),f},{}),pathname:i,pathnameBase:a,pattern:e}}function SL(e,t=!1,n=!0){bs(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,l,u,f,p)=>{if(r.push({paramName:l,isOptional:u!=null}),u){let h=p.charAt(f+a.length);return h&&h!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),r]}function NL(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return bs(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Eo(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var CL=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function EL(e,t="/"){let{pathname:n,search:r="",hash:o=""}=typeof e=="string"?pc(e):e,i;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?i=j1(n.substring(1),"/"):i=j1(n,t)):i=t,{pathname:i,search:AL(r),hash:PL(o)}}function j1(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function Gx(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function TL(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function WE(e){let t=TL(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function $v(e,t,n,r=!1){let o;typeof e=="string"?o=pc(e):(o={...e},dn(!o.pathname||!o.pathname.includes("?"),Gx("?","pathname","search",o)),dn(!o.pathname||!o.pathname.includes("#"),Gx("#","pathname","hash",o)),dn(!o.search||!o.search.includes("#"),Gx("#","search","hash",o)));let i=e===""||o.pathname==="",a=i?"/":o.pathname,l;if(a==null)l=n;else{let h=t.length-1;if(!r&&a.startsWith("..")){let g=a.split("/");for(;g[0]==="..";)g.shift(),h-=1;o.pathname=g.join("/")}l=h>=0?t[h]:"/"}let u=EL(o,l),f=a&&a!=="/"&&a.endsWith("/"),p=(i||a===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(f||p)&&(u.pathname+="/"),u}var Xs=e=>e.join("/").replace(/\/\/+/g,"/"),RL=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),AL=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,PL=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,_L=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function DL(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function $L(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var qE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function KE(e,t){let n=e;if(typeof n!="string"||!CL.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,o=!1;if(qE)try{let i=new URL(window.location.href),a=n.startsWith("//")?new URL(i.protocol+n):new URL(n),l=Eo(a.pathname,t);a.origin===i.origin&&l!=null?n=l+a.search+a.hash:o=!0}catch{bs(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:o,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var GE=["POST","PUT","PATCH","DELETE"];new Set(GE);var IL=["GET",...GE];new Set(IL);var hc=m.createContext(null);hc.displayName="DataRouter";var Gh=m.createContext(null);Gh.displayName="DataRouterState";var LL=m.createContext(!1),YE=m.createContext({isTransitioning:!1});YE.displayName="ViewTransition";var ML=m.createContext(new Map);ML.displayName="Fetchers";var OL=m.createContext(null);OL.displayName="Await";var ts=m.createContext(null);ts.displayName="Navigation";var Td=m.createContext(null);Td.displayName="Location";var Es=m.createContext({outlet:null,matches:[],isDataRoute:!1});Es.displayName="Route";var Iv=m.createContext(null);Iv.displayName="RouteError";var XE="REACT_ROUTER_ERROR",FL="REDIRECT",zL="ROUTE_ERROR_RESPONSE";function BL(e){if(e.startsWith(`${XE}:${FL}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function UL(e){if(e.startsWith(`${XE}:${zL}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new _L(t.status,t.statusText,t.data)}catch{}}function HL(e,{relative:t}={}){dn(Rd(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=m.useContext(ts),{hash:o,pathname:i,search:a}=Ad(e,{relative:t}),l=i;return n!=="/"&&(l=i==="/"?n:Xs([n,i])),r.createHref({pathname:l,search:a,hash:o})}function Rd(){return m.useContext(Td)!=null}function rr(){return dn(Rd(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Td).location}var QE="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function JE(e){m.useContext(ts).static||m.useLayoutEffect(e)}function Wt(){let{isDataRoute:e}=m.useContext(Es);return e?sM():VL()}function VL(){dn(Rd(),"useNavigate() may be used only in the context of a <Router> component.");let e=m.useContext(hc),{basename:t,navigator:n}=m.useContext(ts),{matches:r}=m.useContext(Es),{pathname:o}=rr(),i=JSON.stringify(WE(r)),a=m.useRef(!1);return JE(()=>{a.current=!0}),m.useCallback((u,f={})=>{if(bs(a.current,QE),!a.current)return;if(typeof u=="number"){n.go(u);return}let p=$v(u,JSON.parse(i),o,f.relative==="path");e==null&&t!=="/"&&(p.pathname=p.pathname==="/"?t:Xs([t,p.pathname])),(f.replace?n.replace:n.push)(p,f.state,f)},[t,n,i,o,e])}var WL=m.createContext(null);function qL(e){let t=m.useContext(Es).outlet;return m.useMemo(()=>t&&m.createElement(WL.Provider,{value:e},t),[t,e])}function qt(){let{matches:e}=m.useContext(Es),t=e[e.length-1];return t?t.params:{}}function Ad(e,{relative:t}={}){let{matches:n}=m.useContext(Es),{pathname:r}=rr(),o=JSON.stringify(WE(n));return m.useMemo(()=>$v(e,JSON.parse(o),r,t==="path"),[e,o,r,t])}function KL(e,t){return ZE(e,t)}function ZE(e,t,n){var b;dn(Rd(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=m.useContext(ts),{matches:o}=m.useContext(Es),i=o[o.length-1],a=i?i.params:{},l=i?i.pathname:"/",u=i?i.pathnameBase:"/",f=i&&i.route;{let j=f&&f.path||"";t2(l,!f||j.endsWith("*")||j.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${j}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
50
-
51
- Please change the parent <Route path="${j}"> to <Route path="${j==="/"?"*":`${j}/*`}">.`)}let p=rr(),h;if(t){let j=typeof t=="string"?pc(t):t;dn(u==="/"||((b=j.pathname)==null?void 0:b.startsWith(u)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${j.pathname}" was given in the \`location\` prop.`),h=j}else h=p;let g=h.pathname||"/",y=g;if(u!=="/"){let j=u.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(j.length).join("/")}let k=UE(e,{pathname:y});bs(f||k!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),bs(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${h.pathname}${h.search}${h.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let v=JL(k&&k.map(j=>Object.assign({},j,{params:Object.assign({},a,j.params),pathname:Xs([u,r.encodeLocation?r.encodeLocation(j.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?u:Xs([u,r.encodeLocation?r.encodeLocation(j.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:j.pathnameBase])})),o,n);return t&&v?m.createElement(Td.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...h},navigationType:"POP"}},v):v}function GL(){let e=rM(),t=DL(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},a=null;return console.error("Error handled by React Router default ErrorBoundary:",e),a=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:i},"ErrorBoundary")," or"," ",m.createElement("code",{style:i},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},t),n?m.createElement("pre",{style:o},n):null,a)}var YL=m.createElement(GL,null),e2=class extends m.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=UL(e.digest);n&&(e=n)}let t=e!==void 0?m.createElement(Es.Provider,{value:this.props.routeContext},m.createElement(Iv.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?m.createElement(XL,{error:e},t):t}};e2.contextType=LL;var Yx=new WeakMap;function XL({children:e,error:t}){let{basename:n}=m.useContext(ts);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=BL(t.digest);if(r){let o=Yx.get(t);if(o)throw o;let i=KE(r.location,n);if(qE&&!Yx.get(t))if(i.isExternal||r.reloadDocument)window.location.href=i.absoluteURL||i.to;else{const a=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:r.replace}));throw Yx.set(t,a),a}return m.createElement("meta",{httpEquiv:"refresh",content:`0;url=${i.absoluteURL||i.to}`})}}return e}function QL({routeContext:e,match:t,children:n}){let r=m.useContext(hc);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),m.createElement(Es.Provider,{value:e},n)}function JL(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,i=r==null?void 0:r.errors;if(i!=null){let p=o.findIndex(h=>h.route.id&&(i==null?void 0:i[h.route.id])!==void 0);dn(p>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,p+1))}let a=!1,l=-1;if(n&&r){a=r.renderFallback;for(let p=0;p<o.length;p++){let h=o[p];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(l=p),h.route.id){let{loaderData:g,errors:y}=r,k=h.route.loader&&!g.hasOwnProperty(h.route.id)&&(!y||y[h.route.id]===void 0);if(h.route.lazy||k){n.isStatic&&(a=!0),l>=0?o=o.slice(0,l+1):o=[o[0]];break}}}}let u=n==null?void 0:n.onError,f=r&&u?(p,h)=>{var g,y;u(p,{location:r.location,params:((y=(g=r.matches)==null?void 0:g[0])==null?void 0:y.params)??{},unstable_pattern:$L(r.matches),errorInfo:h})}:void 0;return o.reduceRight((p,h,g)=>{let y,k=!1,v=null,b=null;r&&(y=i&&h.route.id?i[h.route.id]:void 0,v=h.route.errorElement||YL,a&&(l<0&&g===0?(t2("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,b=null):l===g&&(k=!0,b=h.route.hydrateFallbackElement||null)));let j=t.concat(o.slice(0,g+1)),N=()=>{let S;return y?S=v:k?S=b:h.route.Component?S=m.createElement(h.route.Component,null):h.route.element?S=h.route.element:S=p,m.createElement(QL,{match:h,routeContext:{outlet:p,matches:j,isDataRoute:r!=null},children:S})};return r&&(h.route.ErrorBoundary||h.route.errorElement||g===0)?m.createElement(e2,{location:r.location,revalidation:r.revalidation,component:v,error:y,children:N(),routeContext:{outlet:null,matches:j,isDataRoute:!0},onError:f}):N()},null)}function Lv(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ZL(e){let t=m.useContext(hc);return dn(t,Lv(e)),t}function eM(e){let t=m.useContext(Gh);return dn(t,Lv(e)),t}function tM(e){let t=m.useContext(Es);return dn(t,Lv(e)),t}function Mv(e){let t=tM(e),n=t.matches[t.matches.length-1];return dn(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function nM(){return Mv("useRouteId")}function rM(){var r;let e=m.useContext(Iv),t=eM("useRouteError"),n=Mv("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function sM(){let{router:e}=ZL("useNavigate"),t=Mv("useNavigate"),n=m.useRef(!1);return JE(()=>{n.current=!0}),m.useCallback(async(o,i={})=>{bs(n.current,QE),n.current&&(typeof o=="number"?await e.navigate(o):await e.navigate(o,{fromRouteId:t,...i}))},[e,t])}var k1={};function t2(e,t,n){!t&&!k1[e]&&(k1[e]=!0,bs(!1,n))}m.memo(oM);function oM({routes:e,future:t,state:n,isStatic:r,onError:o}){return ZE(e,void 0,{state:n,isStatic:r,onError:o})}function iM(e){return qL(e.context)}function Ye(e){dn(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function aM({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:o,static:i=!1,unstable_useTransitions:a}){dn(!Rd(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),u=m.useMemo(()=>({basename:l,navigator:o,static:i,unstable_useTransitions:a,future:{}}),[l,o,i,a]);typeof n=="string"&&(n=pc(n));let{pathname:f="/",search:p="",hash:h="",state:g=null,key:y="default",unstable_mask:k}=n,v=m.useMemo(()=>{let b=Eo(f,l);return b==null?null:{location:{pathname:b,search:p,hash:h,state:g,key:y,unstable_mask:k},navigationType:r}},[l,f,p,h,g,y,r,k]);return bs(v!=null,`<Router basename="${l}"> is not able to match the URL "${f}${p}${h}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:m.createElement(ts.Provider,{value:u},m.createElement(Td.Provider,{children:t,value:v}))}function lM({children:e,location:t}){return KL(xb(e),t)}function xb(e,t=[]){let n=[];return m.Children.forEach(e,(r,o)=>{if(!m.isValidElement(r))return;let i=[...t,o];if(r.type===m.Fragment){n.push.apply(n,xb(r.props.children,i));return}dn(r.type===Ye,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),dn(!r.props.index||!r.props.children,"An index route cannot have child routes.");let a={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(a.children=xb(r.props.children,i)),n.push(a)}),n}var Pp="get",_p="application/x-www-form-urlencoded";function Yh(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function cM(e){return Yh(e)&&e.tagName.toLowerCase()==="button"}function uM(e){return Yh(e)&&e.tagName.toLowerCase()==="form"}function dM(e){return Yh(e)&&e.tagName.toLowerCase()==="input"}function fM(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function pM(e,t){return e.button===0&&(!t||t==="_self")&&!fM(e)}function yb(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(o=>[n,o]):[[n,r]])},[]))}function hM(e,t){let n=yb(e);return t&&t.forEach((r,o)=>{n.has(o)||t.getAll(o).forEach(i=>{n.append(o,i)})}),n}var tp=null;function mM(){if(tp===null)try{new FormData(document.createElement("form"),0),tp=!1}catch{tp=!0}return tp}var gM=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Xx(e){return e!=null&&!gM.has(e)?(bs(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${_p}"`),null):e}function xM(e,t){let n,r,o,i,a;if(uM(e)){let l=e.getAttribute("action");r=l?Eo(l,t):null,n=e.getAttribute("method")||Pp,o=Xx(e.getAttribute("enctype"))||_p,i=new FormData(e)}else if(cM(e)||dM(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let u=e.getAttribute("formaction")||l.getAttribute("action");if(r=u?Eo(u,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Pp,o=Xx(e.getAttribute("formenctype"))||Xx(l.getAttribute("enctype"))||_p,i=new FormData(l,e),!mM()){let{name:f,type:p,value:h}=e;if(p==="image"){let g=f?`${f}.`:"";i.append(`${g}x`,"0"),i.append(`${g}y`,"0")}else f&&i.append(f,h)}}else{if(Yh(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Pp,r=null,o=_p,a=e}return i&&o==="text/plain"&&(a=i,i=void 0),{action:r,method:n.toLowerCase(),encType:o,formData:i,body:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Ov(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function yM(e,t,n,r){let o=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?o.pathname.endsWith("/")?o.pathname=`${o.pathname}_.${r}`:o.pathname=`${o.pathname}.${r}`:o.pathname==="/"?o.pathname=`_root.${r}`:t&&Eo(o.pathname,t)==="/"?o.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${r}`,o}async function bM(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function vM(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function wM(e,t,n){let r=await Promise.all(e.map(async o=>{let i=t.routes[o.route.id];if(i){let a=await bM(i,n);return a.links?a.links():[]}return[]}));return NM(r.flat(1).filter(vM).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function S1(e,t,n,r,o,i){let a=(u,f)=>n[f]?u.route.id!==n[f].route.id:!0,l=(u,f)=>{var p;return n[f].pathname!==u.pathname||((p=n[f].route.path)==null?void 0:p.endsWith("*"))&&n[f].params["*"]!==u.params["*"]};return i==="assets"?t.filter((u,f)=>a(u,f)||l(u,f)):i==="data"?t.filter((u,f)=>{var h;let p=r.routes[u.route.id];if(!p||!p.hasLoader)return!1;if(a(u,f)||l(u,f))return!0;if(u.route.shouldRevalidate){let g=u.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:((h=n[0])==null?void 0:h.params)||{},nextUrl:new URL(e,window.origin),nextParams:u.params,defaultShouldRevalidate:!0});if(typeof g=="boolean")return g}return!0}):[]}function jM(e,t,{includeHydrateFallback:n}={}){return kM(e.map(r=>{let o=t.routes[r.route.id];if(!o)return[];let i=[o.module];return o.clientActionModule&&(i=i.concat(o.clientActionModule)),o.clientLoaderModule&&(i=i.concat(o.clientLoaderModule)),n&&o.hydrateFallbackModule&&(i=i.concat(o.hydrateFallbackModule)),o.imports&&(i=i.concat(o.imports)),i}).flat(1))}function kM(e){return[...new Set(e)]}function SM(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function NM(e,t){let n=new Set;return new Set(t),e.reduce((r,o)=>{let i=JSON.stringify(SM(o));return n.has(i)||(n.add(i),r.push({key:i,link:o})),r},[])}function n2(){let e=m.useContext(hc);return Ov(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function CM(){let e=m.useContext(Gh);return Ov(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Fv=m.createContext(void 0);Fv.displayName="FrameworkContext";function r2(){let e=m.useContext(Fv);return Ov(e,"You must render this element inside a <HydratedRouter> element"),e}function EM(e,t){let n=m.useContext(Fv),[r,o]=m.useState(!1),[i,a]=m.useState(!1),{onFocus:l,onBlur:u,onMouseEnter:f,onMouseLeave:p,onTouchStart:h}=t,g=m.useRef(null);m.useEffect(()=>{if(e==="render"&&a(!0),e==="viewport"){let v=j=>{j.forEach(N=>{a(N.isIntersecting)})},b=new IntersectionObserver(v,{threshold:.5});return g.current&&b.observe(g.current),()=>{b.disconnect()}}},[e]),m.useEffect(()=>{if(r){let v=setTimeout(()=>{a(!0)},100);return()=>{clearTimeout(v)}}},[r]);let y=()=>{o(!0)},k=()=>{o(!1),a(!1)};return n?e!=="intent"?[i,g,{}]:[i,g,{onFocus:pu(l,y),onBlur:pu(u,k),onMouseEnter:pu(f,y),onMouseLeave:pu(p,k),onTouchStart:pu(h,y)}]:[!1,g,{}]}function pu(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function TM({page:e,...t}){let{router:n}=n2(),r=m.useMemo(()=>UE(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?m.createElement(AM,{page:e,matches:r,...t}):null}function RM(e){let{manifest:t,routeModules:n}=r2(),[r,o]=m.useState([]);return m.useEffect(()=>{let i=!1;return wM(e,t,n).then(a=>{i||o(a)}),()=>{i=!0}},[e,t,n]),r}function AM({page:e,matches:t,...n}){let r=rr(),{future:o,manifest:i,routeModules:a}=r2(),{basename:l}=n2(),{loaderData:u,matches:f}=CM(),p=m.useMemo(()=>S1(e,t,f,i,r,"data"),[e,t,f,i,r]),h=m.useMemo(()=>S1(e,t,f,i,r,"assets"),[e,t,f,i,r]),g=m.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let v=new Set,b=!1;if(t.forEach(N=>{var C;let S=i.routes[N.route.id];!S||!S.hasLoader||(!p.some(D=>D.route.id===N.route.id)&&N.route.id in u&&((C=a[N.route.id])!=null&&C.shouldRevalidate)||S.hasClientLoader?b=!0:v.add(N.route.id))}),v.size===0)return[];let j=yM(e,l,o.unstable_trailingSlashAwareDataRequests,"data");return b&&v.size>0&&j.searchParams.set("_routes",t.filter(N=>v.has(N.route.id)).map(N=>N.route.id).join(",")),[j.pathname+j.search]},[l,o.unstable_trailingSlashAwareDataRequests,u,r,i,p,t,e,a]),y=m.useMemo(()=>jM(h,i),[h,i]),k=RM(h);return m.createElement(m.Fragment,null,g.map(v=>m.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),y.map(v=>m.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),k.map(({key:v,link:b})=>m.createElement("link",{key:v,nonce:n.nonce,...b,crossOrigin:b.crossOrigin??n.crossOrigin})))}function PM(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var _M=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{_M&&(window.__reactRouterVersion="7.13.1")}catch{}function DM({basename:e,children:t,unstable_useTransitions:n,window:r}){let o=m.useRef();o.current==null&&(o.current=cL({window:r,v5Compat:!0}));let i=o.current,[a,l]=m.useState({action:i.action,location:i.location}),u=m.useCallback(f=>{n===!1?l(f):m.startTransition(()=>l(f))},[n]);return m.useLayoutEffect(()=>i.listen(u),[i,u]),m.createElement(aM,{basename:e,children:t,location:a.location,navigationType:a.action,navigator:i,unstable_useTransitions:n})}var s2=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,De=m.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:o,reloadDocument:i,replace:a,unstable_mask:l,state:u,target:f,to:p,preventScrollReset:h,viewTransition:g,unstable_defaultShouldRevalidate:y,...k},v){let{basename:b,navigator:j,unstable_useTransitions:N}=m.useContext(ts),S=typeof p=="string"&&s2.test(p),C=KE(p,b);p=C.to;let D=HL(p,{relative:o}),T=rr(),R=null;if(l){let M=$v(l,[],T.unstable_mask?T.unstable_mask.pathname:"/",!0);b!=="/"&&(M.pathname=M.pathname==="/"?b:Xs([b,M.pathname])),R=j.createHref(M)}let[$,P,F]=EM(r,k),_=MM(p,{replace:a,unstable_mask:l,state:u,target:f,preventScrollReset:h,relative:o,viewTransition:g,unstable_defaultShouldRevalidate:y,unstable_useTransitions:N});function V(M){t&&t(M),M.defaultPrevented||_(M)}let U=!(C.isExternal||i),I=m.createElement("a",{...k,...F,href:(U?R:void 0)||C.absoluteURL||D,onClick:U?V:t,ref:PM(v,P),target:f,"data-discover":!S&&n==="render"?"true":void 0});return $&&!S?m.createElement(m.Fragment,null,I,m.createElement(TM,{page:D})):I});De.displayName="Link";var $M=m.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:o=!1,style:i,to:a,viewTransition:l,children:u,...f},p){let h=Ad(a,{relative:f.relative}),g=rr(),y=m.useContext(Gh),{navigator:k,basename:v}=m.useContext(ts),b=y!=null&&UM(h)&&l===!0,j=k.encodeLocation?k.encodeLocation(h).pathname:h.pathname,N=g.pathname,S=y&&y.navigation&&y.navigation.location?y.navigation.location.pathname:null;n||(N=N.toLowerCase(),S=S?S.toLowerCase():null,j=j.toLowerCase()),S&&v&&(S=Eo(S,v)||S);const C=j!=="/"&&j.endsWith("/")?j.length-1:j.length;let D=N===j||!o&&N.startsWith(j)&&N.charAt(C)==="/",T=S!=null&&(S===j||!o&&S.startsWith(j)&&S.charAt(j.length)==="/"),R={isActive:D,isPending:T,isTransitioning:b},$=D?t:void 0,P;typeof r=="function"?P=r(R):P=[r,D?"active":null,T?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let F=typeof i=="function"?i(R):i;return m.createElement(De,{...f,"aria-current":$,className:P,ref:p,style:F,to:a,viewTransition:l},typeof u=="function"?u(R):u)});$M.displayName="NavLink";var IM=m.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:o,state:i,method:a=Pp,action:l,onSubmit:u,relative:f,preventScrollReset:p,viewTransition:h,unstable_defaultShouldRevalidate:g,...y},k)=>{let{unstable_useTransitions:v}=m.useContext(ts),b=zM(),j=BM(l,{relative:f}),N=a.toLowerCase()==="get"?"get":"post",S=typeof l=="string"&&s2.test(l),C=D=>{if(u&&u(D),D.defaultPrevented)return;D.preventDefault();let T=D.nativeEvent.submitter,R=(T==null?void 0:T.getAttribute("formmethod"))||a,$=()=>b(T||D.currentTarget,{fetcherKey:t,method:R,navigate:n,replace:o,state:i,relative:f,preventScrollReset:p,viewTransition:h,unstable_defaultShouldRevalidate:g});v&&n!==!1?m.startTransition(()=>$()):$()};return m.createElement("form",{ref:k,method:N,action:j,onSubmit:r?u:C,...y,"data-discover":!S&&e==="render"?"true":void 0})});IM.displayName="Form";function LM(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function o2(e){let t=m.useContext(hc);return dn(t,LM(e)),t}function MM(e,{target:t,replace:n,unstable_mask:r,state:o,preventScrollReset:i,relative:a,viewTransition:l,unstable_defaultShouldRevalidate:u,unstable_useTransitions:f}={}){let p=Wt(),h=rr(),g=Ad(e,{relative:a});return m.useCallback(y=>{if(pM(y,t)){y.preventDefault();let k=n!==void 0?n:Zu(h)===Zu(g),v=()=>p(e,{replace:k,unstable_mask:r,state:o,preventScrollReset:i,relative:a,viewTransition:l,unstable_defaultShouldRevalidate:u});f?m.startTransition(()=>v()):v()}},[h,p,g,n,r,o,t,e,i,a,l,u,f])}function Ts(e){bs(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=m.useRef(yb(e)),n=m.useRef(!1),r=rr(),o=m.useMemo(()=>hM(r.search,n.current?null:t.current),[r.search]),i=Wt(),a=m.useCallback((l,u)=>{const f=yb(typeof l=="function"?l(new URLSearchParams(o)):l);n.current=!0,i("?"+f,u)},[i,o]);return[o,a]}var OM=0,FM=()=>`__${String(++OM)}__`;function zM(){let{router:e}=o2("useSubmit"),{basename:t}=m.useContext(ts),n=nM(),r=e.fetch,o=e.navigate;return m.useCallback(async(i,a={})=>{let{action:l,method:u,encType:f,formData:p,body:h}=xM(i,t);if(a.navigate===!1){let g=a.fetcherKey||FM();await r(g,n,a.action||l,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:p,body:h,formMethod:a.method||u,formEncType:a.encType||f,flushSync:a.flushSync})}else await o(a.action||l,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:p,body:h,formMethod:a.method||u,formEncType:a.encType||f,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,o,t,n])}function BM(e,{relative:t}={}){let{basename:n}=m.useContext(ts),r=m.useContext(Es);dn(r,"useFormAction must be used inside a RouteContext");let[o]=r.matches.slice(-1),i={...Ad(e||".",{relative:t})},a=rr();if(e==null){i.search=a.search;let l=new URLSearchParams(i.search),u=l.getAll("index");if(u.some(p=>p==="")){l.delete("index"),u.filter(h=>h).forEach(h=>l.append("index",h));let p=l.toString();i.search=p?`?${p}`:""}}return(!e||e===".")&&o.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(i.pathname=i.pathname==="/"?n:Xs([n,i.pathname])),Zu(i)}function UM(e,{relative:t}={}){let n=m.useContext(YE);dn(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=o2("useViewTransitionState"),o=Ad(e,{relative:t});if(!n.isTransitioning)return!1;let i=Eo(n.currentLocation.pathname,r)||n.currentLocation.pathname,a=Eo(n.nextLocation.pathname,r)||n.nextLocation.pathname;return nh(o.pathname,a)!=null||nh(o.pathname,i)!=null}var jo=BE();const HM=Cd(jo);/**
52
- * @license lucide-react v0.460.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const VM=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),i2=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/**
57
- * @license lucide-react v0.460.0 - ISC
58
- *
59
- * This source code is licensed under the ISC license.
60
- * See the LICENSE file in the root directory of this source tree.
61
- */var WM={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
62
- * @license lucide-react v0.460.0 - ISC
63
- *
64
- * This source code is licensed under the ISC license.
65
- * See the LICENSE file in the root directory of this source tree.
66
- */const qM=m.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:a,...l},u)=>m.createElement("svg",{ref:u,...WM,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:i2("lucide",o),...l},[...a.map(([f,p])=>m.createElement(f,p)),...Array.isArray(i)?i:[i]]));/**
67
- * @license lucide-react v0.460.0 - ISC
68
- *
69
- * This source code is licensed under the ISC license.
70
- * See the LICENSE file in the root directory of this source tree.
71
- */const $e=(e,t)=>{const n=m.forwardRef(({className:r,...o},i)=>m.createElement(qM,{ref:i,iconNode:t,className:i2(`lucide-${VM(e)}`,r),...o}));return n.displayName=`${e}`,n};/**
72
- * @license lucide-react v0.460.0 - ISC
73
- *
74
- * This source code is licensed under the ISC license.
75
- * See the LICENSE file in the root directory of this source tree.
76
- */const Xh=$e("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
77
- * @license lucide-react v0.460.0 - ISC
78
- *
79
- * This source code is licensed under the ISC license.
80
- * See the LICENSE file in the root directory of this source tree.
81
- */const rh=$e("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
82
- * @license lucide-react v0.460.0 - ISC
83
- *
84
- * This source code is licensed under the ISC license.
85
- * See the LICENSE file in the root directory of this source tree.
86
- */const Qh=$e("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
87
- * @license lucide-react v0.460.0 - ISC
88
- *
89
- * This source code is licensed under the ISC license.
90
- * See the LICENSE file in the root directory of this source tree.
91
- */const sh=$e("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
92
- * @license lucide-react v0.460.0 - ISC
93
- *
94
- * This source code is licensed under the ISC license.
95
- * See the LICENSE file in the root directory of this source tree.
96
- */const Jh=$e("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/**
97
- * @license lucide-react v0.460.0 - ISC
98
- *
99
- * This source code is licensed under the ISC license.
100
- * See the LICENSE file in the root directory of this source tree.
101
- */const Zh=$e("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
102
- * @license lucide-react v0.460.0 - ISC
103
- *
104
- * This source code is licensed under the ISC license.
105
- * See the LICENSE file in the root directory of this source tree.
106
- */const oh=$e("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
107
- * @license lucide-react v0.460.0 - ISC
108
- *
109
- * This source code is licensed under the ISC license.
110
- * See the LICENSE file in the root directory of this source tree.
111
- */const KM=$e("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
112
- * @license lucide-react v0.460.0 - ISC
113
- *
114
- * This source code is licensed under the ISC license.
115
- * See the LICENSE file in the root directory of this source tree.
116
- */const GM=$e("BookOpenText",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]]);/**
117
- * @license lucide-react v0.460.0 - ISC
118
- *
119
- * This source code is licensed under the ISC license.
120
- * See the LICENSE file in the root directory of this source tree.
121
- */const a2=$e("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
122
- * @license lucide-react v0.460.0 - ISC
123
- *
124
- * This source code is licensed under the ISC license.
125
- * See the LICENSE file in the root directory of this source tree.
126
- */const zv=$e("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/**
127
- * @license lucide-react v0.460.0 - ISC
128
- *
129
- * This source code is licensed under the ISC license.
130
- * See the LICENSE file in the root directory of this source tree.
131
- */const YM=$e("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
132
- * @license lucide-react v0.460.0 - ISC
133
- *
134
- * This source code is licensed under the ISC license.
135
- * See the LICENSE file in the root directory of this source tree.
136
- */const l2=$e("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/**
137
- * @license lucide-react v0.460.0 - ISC
138
- *
139
- * This source code is licensed under the ISC license.
140
- * See the LICENSE file in the root directory of this source tree.
141
- */const Sr=$e("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
142
- * @license lucide-react v0.460.0 - ISC
143
- *
144
- * This source code is licensed under the ISC license.
145
- * See the LICENSE file in the root directory of this source tree.
146
- */const cr=$e("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
147
- * @license lucide-react v0.460.0 - ISC
148
- *
149
- * This source code is licensed under the ISC license.
150
- * See the LICENSE file in the root directory of this source tree.
151
- */const XM=$e("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
152
- * @license lucide-react v0.460.0 - ISC
153
- *
154
- * This source code is licensed under the ISC license.
155
- * See the LICENSE file in the root directory of this source tree.
156
- */const c2=$e("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
157
- * @license lucide-react v0.460.0 - ISC
158
- *
159
- * This source code is licensed under the ISC license.
160
- * See the LICENSE file in the root directory of this source tree.
161
- */const u2=$e("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
162
- * @license lucide-react v0.460.0 - ISC
163
- *
164
- * This source code is licensed under the ISC license.
165
- * See the LICENSE file in the root directory of this source tree.
166
- */const ih=$e("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
167
- * @license lucide-react v0.460.0 - ISC
168
- *
169
- * This source code is licensed under the ISC license.
170
- * See the LICENSE file in the root directory of this source tree.
171
- */const em=$e("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
172
- * @license lucide-react v0.460.0 - ISC
173
- *
174
- * This source code is licensed under the ISC license.
175
- * See the LICENSE file in the root directory of this source tree.
176
- */const bb=$e("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
177
- * @license lucide-react v0.460.0 - ISC
178
- *
179
- * This source code is licensed under the ISC license.
180
- * See the LICENSE file in the root directory of this source tree.
181
- */const d2=$e("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
182
- * @license lucide-react v0.460.0 - ISC
183
- *
184
- * This source code is licensed under the ISC license.
185
- * See the LICENSE file in the root directory of this source tree.
186
- */const QM=$e("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/**
187
- * @license lucide-react v0.460.0 - ISC
188
- *
189
- * This source code is licensed under the ISC license.
190
- * See the LICENSE file in the root directory of this source tree.
191
- */const JM=$e("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
192
- * @license lucide-react v0.460.0 - ISC
193
- *
194
- * This source code is licensed under the ISC license.
195
- * See the LICENSE file in the root directory of this source tree.
196
- */const ZM=$e("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);/**
197
- * @license lucide-react v0.460.0 - ISC
198
- *
199
- * This source code is licensed under the ISC license.
200
- * See the LICENSE file in the root directory of this source tree.
201
- */const eO=$e("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
202
- * @license lucide-react v0.460.0 - ISC
203
- *
204
- * This source code is licensed under the ISC license.
205
- * See the LICENSE file in the root directory of this source tree.
206
- */const tO=$e("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
207
- * @license lucide-react v0.460.0 - ISC
208
- *
209
- * This source code is licensed under the ISC license.
210
- * See the LICENSE file in the root directory of this source tree.
211
- */const nO=$e("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/**
212
- * @license lucide-react v0.460.0 - ISC
213
- *
214
- * This source code is licensed under the ISC license.
215
- * See the LICENSE file in the root directory of this source tree.
216
- */const tm=$e("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/**
217
- * @license lucide-react v0.460.0 - ISC
218
- *
219
- * This source code is licensed under the ISC license.
220
- * See the LICENSE file in the root directory of this source tree.
221
- */const rO=$e("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
222
- * @license lucide-react v0.460.0 - ISC
223
- *
224
- * This source code is licensed under the ISC license.
225
- * See the LICENSE file in the root directory of this source tree.
226
- */const f2=$e("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
227
- * @license lucide-react v0.460.0 - ISC
228
- *
229
- * This source code is licensed under the ISC license.
230
- * See the LICENSE file in the root directory of this source tree.
231
- */const ah=$e("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
232
- * @license lucide-react v0.460.0 - ISC
233
- *
234
- * This source code is licensed under the ISC license.
235
- * See the LICENSE file in the root directory of this source tree.
236
- */const sO=$e("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
237
- * @license lucide-react v0.460.0 - ISC
238
- *
239
- * This source code is licensed under the ISC license.
240
- * See the LICENSE file in the root directory of this source tree.
241
- */const oO=$e("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
242
- * @license lucide-react v0.460.0 - ISC
243
- *
244
- * This source code is licensed under the ISC license.
245
- * See the LICENSE file in the root directory of this source tree.
246
- */const mc=$e("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
247
- * @license lucide-react v0.460.0 - ISC
248
- *
249
- * This source code is licensed under the ISC license.
250
- * See the LICENSE file in the root directory of this source tree.
251
- */const N1=$e("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
252
- * @license lucide-react v0.460.0 - ISC
253
- *
254
- * This source code is licensed under the ISC license.
255
- * See the LICENSE file in the root directory of this source tree.
256
- */const iO=$e("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
257
- * @license lucide-react v0.460.0 - ISC
258
- *
259
- * This source code is licensed under the ISC license.
260
- * See the LICENSE file in the root directory of this source tree.
261
- */const aO=$e("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);/**
262
- * @license lucide-react v0.460.0 - ISC
263
- *
264
- * This source code is licensed under the ISC license.
265
- * See the LICENSE file in the root directory of this source tree.
266
- */const p2=$e("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
267
- * @license lucide-react v0.460.0 - ISC
268
- *
269
- * This source code is licensed under the ISC license.
270
- * See the LICENSE file in the root directory of this source tree.
271
- */const lO=$e("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/**
272
- * @license lucide-react v0.460.0 - ISC
273
- *
274
- * This source code is licensed under the ISC license.
275
- * See the LICENSE file in the root directory of this source tree.
276
- */const cO=$e("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
277
- * @license lucide-react v0.460.0 - ISC
278
- *
279
- * This source code is licensed under the ISC license.
280
- * See the LICENSE file in the root directory of this source tree.
281
- */const Bv=$e("FolderKanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]);/**
282
- * @license lucide-react v0.460.0 - ISC
283
- *
284
- * This source code is licensed under the ISC license.
285
- * See the LICENSE file in the root directory of this source tree.
286
- */const uO=$e("GitBranchPlus",[["path",{d:"M6 3v12",key:"qpgusn"}],["path",{d:"M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"1d02ji"}],["path",{d:"M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"chk6ph"}],["path",{d:"M15 6a9 9 0 0 0-9 9",key:"or332x"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/**
287
- * @license lucide-react v0.460.0 - ISC
288
- *
289
- * This source code is licensed under the ISC license.
290
- * See the LICENSE file in the root directory of this source tree.
291
- */const Uv=$e("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
292
- * @license lucide-react v0.460.0 - ISC
293
- *
294
- * This source code is licensed under the ISC license.
295
- * See the LICENSE file in the root directory of this source tree.
296
- */const dO=$e("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);/**
297
- * @license lucide-react v0.460.0 - ISC
298
- *
299
- * This source code is licensed under the ISC license.
300
- * See the LICENSE file in the root directory of this source tree.
301
- */const gc=$e("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
302
- * @license lucide-react v0.460.0 - ISC
303
- *
304
- * This source code is licensed under the ISC license.
305
- * See the LICENSE file in the root directory of this source tree.
306
- */const fO=$e("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/**
307
- * @license lucide-react v0.460.0 - ISC
308
- *
309
- * This source code is licensed under the ISC license.
310
- * See the LICENSE file in the root directory of this source tree.
311
- */const pO=$e("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/**
312
- * @license lucide-react v0.460.0 - ISC
313
- *
314
- * This source code is licensed under the ISC license.
315
- * See the LICENSE file in the root directory of this source tree.
316
- */const h2=$e("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
317
- * @license lucide-react v0.460.0 - ISC
318
- *
319
- * This source code is licensed under the ISC license.
320
- * See the LICENSE file in the root directory of this source tree.
321
- */const Hv=$e("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
322
- * @license lucide-react v0.460.0 - ISC
323
- *
324
- * This source code is licensed under the ISC license.
325
- * See the LICENSE file in the root directory of this source tree.
326
- */const vb=$e("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/**
327
- * @license lucide-react v0.460.0 - ISC
328
- *
329
- * This source code is licensed under the ISC license.
330
- * See the LICENSE file in the root directory of this source tree.
331
- */const hO=$e("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
332
- * @license lucide-react v0.460.0 - ISC
333
- *
334
- * This source code is licensed under the ISC license.
335
- * See the LICENSE file in the root directory of this source tree.
336
- */const m2=$e("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/**
337
- * @license lucide-react v0.460.0 - ISC
338
- *
339
- * This source code is licensed under the ISC license.
340
- * See the LICENSE file in the root directory of this source tree.
341
- */const mO=$e("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
342
- * @license lucide-react v0.460.0 - ISC
343
- *
344
- * This source code is licensed under the ISC license.
345
- * See the LICENSE file in the root directory of this source tree.
346
- */const gO=$e("LifeBuoy",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/**
347
- * @license lucide-react v0.460.0 - ISC
348
- *
349
- * This source code is licensed under the ISC license.
350
- * See the LICENSE file in the root directory of this source tree.
351
- */const xO=$e("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
352
- * @license lucide-react v0.460.0 - ISC
353
- *
354
- * This source code is licensed under the ISC license.
355
- * See the LICENSE file in the root directory of this source tree.
356
- */const yO=$e("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
357
- * @license lucide-react v0.460.0 - ISC
358
- *
359
- * This source code is licensed under the ISC license.
360
- * See the LICENSE file in the root directory of this source tree.
361
- */const bO=$e("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/**
362
- * @license lucide-react v0.460.0 - ISC
363
- *
364
- * This source code is licensed under the ISC license.
365
- * See the LICENSE file in the root directory of this source tree.
366
- */const Vv=$e("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
367
- * @license lucide-react v0.460.0 - ISC
368
- *
369
- * This source code is licensed under the ISC license.
370
- * See the LICENSE file in the root directory of this source tree.
371
- */const vO=$e("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/**
372
- * @license lucide-react v0.460.0 - ISC
373
- *
374
- * This source code is licensed under the ISC license.
375
- * See the LICENSE file in the root directory of this source tree.
376
- */const wO=$e("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
377
- * @license lucide-react v0.460.0 - ISC
378
- *
379
- * This source code is licensed under the ISC license.
380
- * See the LICENSE file in the root directory of this source tree.
381
- */const jO=$e("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
382
- * @license lucide-react v0.460.0 - ISC
383
- *
384
- * This source code is licensed under the ISC license.
385
- * See the LICENSE file in the root directory of this source tree.
386
- */const Wv=$e("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
387
- * @license lucide-react v0.460.0 - ISC
388
- *
389
- * This source code is licensed under the ISC license.
390
- * See the LICENSE file in the root directory of this source tree.
391
- */const kO=$e("MoonStar",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9",key:"4ay0iu"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}]]);/**
392
- * @license lucide-react v0.460.0 - ISC
393
- *
394
- * This source code is licensed under the ISC license.
395
- * See the LICENSE file in the root directory of this source tree.
396
- */const Qx=$e("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);/**
397
- * @license lucide-react v0.460.0 - ISC
398
- *
399
- * This source code is licensed under the ISC license.
400
- * See the LICENSE file in the root directory of this source tree.
401
- */const g2=$e("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/**
402
- * @license lucide-react v0.460.0 - ISC
403
- *
404
- * This source code is licensed under the ISC license.
405
- * See the LICENSE file in the root directory of this source tree.
406
- */const xc=$e("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
407
- * @license lucide-react v0.460.0 - ISC
408
- *
409
- * This source code is licensed under the ISC license.
410
- * See the LICENSE file in the root directory of this source tree.
411
- */const SO=$e("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
412
- * @license lucide-react v0.460.0 - ISC
413
- *
414
- * This source code is licensed under the ISC license.
415
- * See the LICENSE file in the root directory of this source tree.
416
- */const Mt=$e("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
417
- * @license lucide-react v0.460.0 - ISC
418
- *
419
- * This source code is licensed under the ISC license.
420
- * See the LICENSE file in the root directory of this source tree.
421
- */const x2=$e("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
422
- * @license lucide-react v0.460.0 - ISC
423
- *
424
- * This source code is licensed under the ISC license.
425
- * See the LICENSE file in the root directory of this source tree.
426
- */const NO=$e("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/**
427
- * @license lucide-react v0.460.0 - ISC
428
- *
429
- * This source code is licensed under the ISC license.
430
- * See the LICENSE file in the root directory of this source tree.
431
- */const CO=$e("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/**
432
- * @license lucide-react v0.460.0 - ISC
433
- *
434
- * This source code is licensed under the ISC license.
435
- * See the LICENSE file in the root directory of this source tree.
436
- */const vs=$e("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
437
- * @license lucide-react v0.460.0 - ISC
438
- *
439
- * This source code is licensed under the ISC license.
440
- * See the LICENSE file in the root directory of this source tree.
441
- */const EO=$e("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
442
- * @license lucide-react v0.460.0 - ISC
443
- *
444
- * This source code is licensed under the ISC license.
445
- * See the LICENSE file in the root directory of this source tree.
446
- */const nm=$e("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
447
- * @license lucide-react v0.460.0 - ISC
448
- *
449
- * This source code is licensed under the ISC license.
450
- * See the LICENSE file in the root directory of this source tree.
451
- */const TO=$e("SearchCheck",[["path",{d:"m8 11 2 2 4-4",key:"1sed1v"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
452
- * @license lucide-react v0.460.0 - ISC
453
- *
454
- * This source code is licensed under the ISC license.
455
- * See the LICENSE file in the root directory of this source tree.
456
- */const Ci=$e("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
457
- * @license lucide-react v0.460.0 - ISC
458
- *
459
- * This source code is licensed under the ISC license.
460
- * See the LICENSE file in the root directory of this source tree.
461
- */const RO=$e("SendToBack",[["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}],["path",{d:"M7 14v1a2 2 0 0 0 2 2h1",key:"pao6x6"}],["path",{d:"M14 7h1a2 2 0 0 1 2 2v1",key:"19tdru"}]]);/**
462
- * @license lucide-react v0.460.0 - ISC
463
- *
464
- * This source code is licensed under the ISC license.
465
- * See the LICENSE file in the root directory of this source tree.
466
- */const AO=$e("ServerOff",[["path",{d:"M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5",key:"bt2siv"}],["path",{d:"M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z",key:"1hjrv1"}],["path",{d:"M22 17v-1a2 2 0 0 0-2-2h-1",key:"1iynyr"}],["path",{d:"M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z",key:"161ggg"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
467
- * @license lucide-react v0.460.0 - ISC
468
- *
469
- * This source code is licensed under the ISC license.
470
- * See the LICENSE file in the root directory of this source tree.
471
- */const PO=$e("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/**
472
- * @license lucide-react v0.460.0 - ISC
473
- *
474
- * This source code is licensed under the ISC license.
475
- * See the LICENSE file in the root directory of this source tree.
476
- */const _O=$e("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
477
- * @license lucide-react v0.460.0 - ISC
478
- *
479
- * This source code is licensed under the ISC license.
480
- * See the LICENSE file in the root directory of this source tree.
481
- */const DO=$e("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/**
482
- * @license lucide-react v0.460.0 - ISC
483
- *
484
- * This source code is licensed under the ISC license.
485
- * See the LICENSE file in the root directory of this source tree.
486
- */const ys=$e("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
487
- * @license lucide-react v0.460.0 - ISC
488
- *
489
- * This source code is licensed under the ISC license.
490
- * See the LICENSE file in the root directory of this source tree.
491
- */const Jx=$e("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/**
492
- * @license lucide-react v0.460.0 - ISC
493
- *
494
- * This source code is licensed under the ISC license.
495
- * See the LICENSE file in the root directory of this source tree.
496
- */const C1=$e("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/**
497
- * @license lucide-react v0.460.0 - ISC
498
- *
499
- * This source code is licensed under the ISC license.
500
- * See the LICENSE file in the root directory of this source tree.
501
- */const qv=$e("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
502
- * @license lucide-react v0.460.0 - ISC
503
- *
504
- * This source code is licensed under the ISC license.
505
- * See the LICENSE file in the root directory of this source tree.
506
- */const $O=$e("SunMedium",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 3v1",key:"1asbbs"}],["path",{d:"M12 20v1",key:"1wcdkc"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M20 12h1",key:"1vloll"}],["path",{d:"m18.364 5.636-.707.707",key:"1hakh0"}],["path",{d:"m6.343 17.657-.707.707",key:"18m9nf"}],["path",{d:"m5.636 5.636.707.707",key:"1xv1c5"}],["path",{d:"m17.657 17.657.707.707",key:"vl76zb"}]]);/**
507
- * @license lucide-react v0.460.0 - ISC
508
- *
509
- * This source code is licensed under the ISC license.
510
- * See the LICENSE file in the root directory of this source tree.
511
- */const y2=$e("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
512
- * @license lucide-react v0.460.0 - ISC
513
- *
514
- * This source code is licensed under the ISC license.
515
- * See the LICENSE file in the root directory of this source tree.
516
- */const Il=$e("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
517
- * @license lucide-react v0.460.0 - ISC
518
- *
519
- * This source code is licensed under the ISC license.
520
- * See the LICENSE file in the root directory of this source tree.
521
- */const jn=$e("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
522
- * @license lucide-react v0.460.0 - ISC
523
- *
524
- * This source code is licensed under the ISC license.
525
- * See the LICENSE file in the root directory of this source tree.
526
- */const rm=$e("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
527
- * @license lucide-react v0.460.0 - ISC
528
- *
529
- * This source code is licensed under the ISC license.
530
- * See the LICENSE file in the root directory of this source tree.
531
- */const IO=$e("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
532
- * @license lucide-react v0.460.0 - ISC
533
- *
534
- * This source code is licensed under the ISC license.
535
- * See the LICENSE file in the root directory of this source tree.
536
- */const LO=$e("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
537
- * @license lucide-react v0.460.0 - ISC
538
- *
539
- * This source code is licensed under the ISC license.
540
- * See the LICENSE file in the root directory of this source tree.
541
- */const MO=$e("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/**
542
- * @license lucide-react v0.460.0 - ISC
543
- *
544
- * This source code is licensed under the ISC license.
545
- * See the LICENSE file in the root directory of this source tree.
546
- */const Pd=$e("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function b2(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=b2(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function OO(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=b2(e))&&(r&&(r+=" "),r+=t);return r}const Kv="-",FO=e=>{const t=BO(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:a=>{const l=a.split(Kv);return l[0]===""&&l.length!==1&&l.shift(),v2(l,t)||zO(a)},getConflictingClassGroupIds:(a,l)=>{const u=n[a]||[];return l&&r[a]?[...u,...r[a]]:u}}},v2=(e,t)=>{var a;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),o=r?v2(e.slice(1),r):void 0;if(o)return o;if(t.validators.length===0)return;const i=e.join(Kv);return(a=t.validators.find(({validator:l})=>l(i)))==null?void 0:a.classGroupId},E1=/^\[(.+)\]$/,zO=e=>{if(E1.test(e)){const t=E1.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},BO=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return HO(Object.entries(e.classGroups),n).forEach(([i,a])=>{wb(a,r,i,t)}),r},wb=(e,t,n,r)=>{e.forEach(o=>{if(typeof o=="string"){const i=o===""?t:T1(t,o);i.classGroupId=n;return}if(typeof o=="function"){if(UO(o)){wb(o(r),t,n,r);return}t.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([i,a])=>{wb(a,T1(t,i),n,r)})})},T1=(e,t)=>{let n=e;return t.split(Kv).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},UO=e=>e.isThemeGetter,HO=(e,t)=>t?e.map(([n,r])=>{const o=r.map(i=>typeof i=="string"?t+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([a,l])=>[t+a,l])):i);return[n,o]}):e,VO=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const o=(i,a)=>{n.set(i,a),t++,t>e&&(t=0,r=n,n=new Map)};return{get(i){let a=n.get(i);if(a!==void 0)return a;if((a=r.get(i))!==void 0)return o(i,a),a},set(i,a){n.has(i)?n.set(i,a):o(i,a)}}},w2="!",WO=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,o=t[0],i=t.length,a=l=>{const u=[];let f=0,p=0,h;for(let b=0;b<l.length;b++){let j=l[b];if(f===0){if(j===o&&(r||l.slice(b,b+i)===t)){u.push(l.slice(p,b)),p=b+i;continue}if(j==="/"){h=b;continue}}j==="["?f++:j==="]"&&f--}const g=u.length===0?l:l.substring(p),y=g.startsWith(w2),k=y?g.substring(1):g,v=h&&h>p?h-p:void 0;return{modifiers:u,hasImportantModifier:y,baseClassName:k,maybePostfixModifierPosition:v}};return n?l=>n({className:l,parseClassName:a}):a},qO=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},KO=e=>({cache:VO(e.cacheSize),parseClassName:WO(e),...FO(e)}),GO=/\s+/,YO=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o}=t,i=[],a=e.trim().split(GO);let l="";for(let u=a.length-1;u>=0;u-=1){const f=a[u],{modifiers:p,hasImportantModifier:h,baseClassName:g,maybePostfixModifierPosition:y}=n(f);let k=!!y,v=r(k?g.substring(0,y):g);if(!v){if(!k){l=f+(l.length>0?" "+l:l);continue}if(v=r(g),!v){l=f+(l.length>0?" "+l:l);continue}k=!1}const b=qO(p).join(":"),j=h?b+w2:b,N=j+v;if(i.includes(N))continue;i.push(N);const S=o(v,k);for(let C=0;C<S.length;++C){const D=S[C];i.push(j+D)}l=f+(l.length>0?" "+l:l)}return l};function XO(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=j2(t))&&(r&&(r+=" "),r+=n);return r}const j2=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=j2(e[r]))&&(n&&(n+=" "),n+=t);return n};function QO(e,...t){let n,r,o,i=a;function a(u){const f=t.reduce((p,h)=>h(p),e());return n=KO(f),r=n.cache.get,o=n.cache.set,i=l,l(u)}function l(u){const f=r(u);if(f)return f;const p=YO(u,n);return o(u,p),p}return function(){return i(XO.apply(null,arguments))}}const Jt=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},k2=/^\[(?:([a-z-]+):)?(.+)\]$/i,JO=/^\d+\/\d+$/,ZO=new Set(["px","full","screen"]),e4=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,t4=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,n4=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,r4=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,s4=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,yo=e=>Ll(e)||ZO.has(e)||JO.test(e),ai=e=>yc(e,"length",f4),Ll=e=>!!e&&!Number.isNaN(Number(e)),Zx=e=>yc(e,"number",Ll),hu=e=>!!e&&Number.isInteger(Number(e)),o4=e=>e.endsWith("%")&&Ll(e.slice(0,-1)),jt=e=>k2.test(e),li=e=>e4.test(e),i4=new Set(["length","size","percentage"]),a4=e=>yc(e,i4,S2),l4=e=>yc(e,"position",S2),c4=new Set(["image","url"]),u4=e=>yc(e,c4,h4),d4=e=>yc(e,"",p4),mu=()=>!0,yc=(e,t,n)=>{const r=k2.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},f4=e=>t4.test(e)&&!n4.test(e),S2=()=>!1,p4=e=>r4.test(e),h4=e=>s4.test(e),m4=()=>{const e=Jt("colors"),t=Jt("spacing"),n=Jt("blur"),r=Jt("brightness"),o=Jt("borderColor"),i=Jt("borderRadius"),a=Jt("borderSpacing"),l=Jt("borderWidth"),u=Jt("contrast"),f=Jt("grayscale"),p=Jt("hueRotate"),h=Jt("invert"),g=Jt("gap"),y=Jt("gradientColorStops"),k=Jt("gradientColorStopPositions"),v=Jt("inset"),b=Jt("margin"),j=Jt("opacity"),N=Jt("padding"),S=Jt("saturate"),C=Jt("scale"),D=Jt("sepia"),T=Jt("skew"),R=Jt("space"),$=Jt("translate"),P=()=>["auto","contain","none"],F=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto",jt,t],V=()=>[jt,t],U=()=>["",yo,ai],I=()=>["auto",Ll,jt],M=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],B=()=>["solid","dashed","dotted","double","none"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],O=()=>["start","end","center","between","around","evenly","stretch"],H=()=>["","0",jt],L=()=>["auto","avoid","all","avoid-page","page","left","right","column"],z=()=>[Ll,jt];return{cacheSize:500,separator:":",theme:{colors:[mu],spacing:[yo,ai],blur:["none","",li,jt],brightness:z(),borderColor:[e],borderRadius:["none","","full",li,jt],borderSpacing:V(),borderWidth:U(),contrast:z(),grayscale:H(),hueRotate:z(),invert:H(),gap:V(),gradientColorStops:[e],gradientColorStopPositions:[o4,ai],inset:_(),margin:_(),opacity:z(),padding:V(),saturate:z(),scale:z(),sepia:H(),skew:z(),space:V(),translate:V()},classGroups:{aspect:[{aspect:["auto","square","video",jt]}],container:["container"],columns:[{columns:[li]}],"break-after":[{"break-after":L()}],"break-before":[{"break-before":L()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...M(),jt]}],overflow:[{overflow:F()}],"overflow-x":[{"overflow-x":F()}],"overflow-y":[{"overflow-y":F()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",hu,jt]}],basis:[{basis:_()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",jt]}],grow:[{grow:H()}],shrink:[{shrink:H()}],order:[{order:["first","last","none",hu,jt]}],"grid-cols":[{"grid-cols":[mu]}],"col-start-end":[{col:["auto",{span:["full",hu,jt]},jt]}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":[mu]}],"row-start-end":[{row:["auto",{span:[hu,jt]},jt]}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",jt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",jt]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...O()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...O(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...O(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[N]}],px:[{px:[N]}],py:[{py:[N]}],ps:[{ps:[N]}],pe:[{pe:[N]}],pt:[{pt:[N]}],pr:[{pr:[N]}],pb:[{pb:[N]}],pl:[{pl:[N]}],m:[{m:[b]}],mx:[{mx:[b]}],my:[{my:[b]}],ms:[{ms:[b]}],me:[{me:[b]}],mt:[{mt:[b]}],mr:[{mr:[b]}],mb:[{mb:[b]}],ml:[{ml:[b]}],"space-x":[{"space-x":[R]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[R]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",jt,t]}],"min-w":[{"min-w":[jt,t,"min","max","fit"]}],"max-w":[{"max-w":[jt,t,"none","full","min","max","fit","prose",{screen:[li]},li]}],h:[{h:[jt,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[jt,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[jt,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[jt,t,"auto","min","max","fit"]}],"font-size":[{text:["base",li,ai]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Zx]}],"font-family":[{font:[mu]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",jt]}],"line-clamp":[{"line-clamp":["none",Ll,Zx]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",yo,jt]}],"list-image":[{"list-image":["none",jt]}],"list-style-type":[{list:["none","disc","decimal",jt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[j]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[j]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...B(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",yo,ai]}],"underline-offset":[{"underline-offset":["auto",yo,jt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:V()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",jt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",jt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[j]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...M(),l4]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",a4]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},u4]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[k]}],"gradient-via-pos":[{via:[k]}],"gradient-to-pos":[{to:[k]}],"gradient-from":[{from:[y]}],"gradient-via":[{via:[y]}],"gradient-to":[{to:[y]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[j]}],"border-style":[{border:[...B(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[j]}],"divide-style":[{divide:B()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...B()]}],"outline-offset":[{"outline-offset":[yo,jt]}],"outline-w":[{outline:[yo,ai]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:U()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[j]}],"ring-offset-w":[{"ring-offset":[yo,ai]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",li,d4]}],"shadow-color":[{shadow:[mu]}],opacity:[{opacity:[j]}],"mix-blend":[{"mix-blend":[...W(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":W()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",li,jt]}],grayscale:[{grayscale:[f]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[h]}],saturate:[{saturate:[S]}],sepia:[{sepia:[D]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[f]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[j]}],"backdrop-saturate":[{"backdrop-saturate":[S]}],"backdrop-sepia":[{"backdrop-sepia":[D]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[a]}],"border-spacing-x":[{"border-spacing-x":[a]}],"border-spacing-y":[{"border-spacing-y":[a]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",jt]}],duration:[{duration:z()}],ease:[{ease:["linear","in","out","in-out",jt]}],delay:[{delay:z()}],animate:[{animate:["none","spin","ping","pulse","bounce",jt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[C]}],"scale-x":[{"scale-x":[C]}],"scale-y":[{"scale-y":[C]}],rotate:[{rotate:[hu,jt]}],"translate-x":[{"translate-x":[$]}],"translate-y":[{"translate-y":[$]}],"skew-x":[{"skew-x":[T]}],"skew-y":[{"skew-y":[T]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",jt]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",jt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":V()}],"scroll-mx":[{"scroll-mx":V()}],"scroll-my":[{"scroll-my":V()}],"scroll-ms":[{"scroll-ms":V()}],"scroll-me":[{"scroll-me":V()}],"scroll-mt":[{"scroll-mt":V()}],"scroll-mr":[{"scroll-mr":V()}],"scroll-mb":[{"scroll-mb":V()}],"scroll-ml":[{"scroll-ml":V()}],"scroll-p":[{"scroll-p":V()}],"scroll-px":[{"scroll-px":V()}],"scroll-py":[{"scroll-py":V()}],"scroll-ps":[{"scroll-ps":V()}],"scroll-pe":[{"scroll-pe":V()}],"scroll-pt":[{"scroll-pt":V()}],"scroll-pr":[{"scroll-pr":V()}],"scroll-pb":[{"scroll-pb":V()}],"scroll-pl":[{"scroll-pl":V()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",jt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[yo,ai,Zx]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},g4=QO(m4);function je(...e){return g4(OO(e))}function Yn(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function Nr(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function N2(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Gv(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Yv(e){if(!e)return"—";const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const n=Math.floor((Date.now()-t.getTime())/1e3);if(n<60)return"just now";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const o=Math.floor(r/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Xl(e){return e.toLocaleString("en-US")}function Ql(e){if(!Number.isFinite(e))return"$0.00";const t=e!==0&&Math.abs(e)<1?4:2;return e.toLocaleString("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:t})}function x4(e){if(!e)return"—";const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return e;const[,n,r,o]=t,i=new Date(Number(n),Number(r)-1,Number(o));return Number.isNaN(i.getTime())?e:i.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function bn(e){return e.split(/[_\s-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function C2(e){return!e||e==="/"?"/":e.endsWith("/")?e.slice(0,-1):e}function E2(e){let t=C2(e);const n=t.match(/^\/w\/[^/]+(\/.*)?$/);return n&&(t=n[1]||"/"),t==="/"?"/":t.startsWith("/archive")?"/archive":t.startsWith("/projects")?/^\/projects\/[^/]+\/assignments\//.test(t)?"/assignments":"/projects":t.startsWith("/assignments")?"/assignments":t.startsWith("/servers")?"/servers":t.startsWith("/inventories")?"/inventories":t.startsWith("/schedules")?"/schedules":t.startsWith("/usage")?"/usage":t.startsWith("/agent-sessions")?"/agent-sessions":t.startsWith("/playbooks")?"/playbooks":t.startsWith("/memories")?"/memories":t.startsWith("/resources")?"/resources":t.startsWith("/todos")?"/todos":t.startsWith("/views")?"/views":t.startsWith("/help")?"/help":t.startsWith("/settings")?"/settings":t.startsWith("/workflow")?"/workflow":t.startsWith("/inbox")?"/inbox":null}function T2(e,t){return E2(e)===t}function R2(e){let n=C2(e).split("/").filter(Boolean);const r=[];let o="Overview",i=null,a="";if(n[0]==="w"&&n[1]&&(a=`/w/${n[1]}`,r.push({label:bn(n[1]),path:`${a}/projects`}),n=n.slice(2)),n.length===0)return{title:o,breadcrumbs:r,projectSlug:i};if(n[0]==="projects"){if(r.push({label:"Projects",path:`${a}/projects`}),o="Projects",n[1]&&(i=n[1],r.push({label:bn(n[1]),path:`${a}/projects/${n[1]}`}),o=bn(n[1])),n[2]==="edit")o="Edit Project";else if(n[2]==="create"&&n[3]==="assignment")o="Create Assignment";else if(n[2]==="assignments"&&n[3])r.push({label:bn(n[3]),path:`${a}/projects/${n[1]}/assignments/${n[3]}`}),o=bn(n[3]),n[4]==="edit"?o="Edit Assignment":n[4]==="plan"&&n[5]==="edit"?o="Edit Plan":n[4]==="scratchpad"&&n[5]==="edit"?o="Edit Scratchpad":n[4]==="handoff"&&n[5]==="edit"?o="Append Handoff":n[4]==="decision-record"&&n[5]==="edit"&&(o="Append Decision");else if((n[2]==="memories"||n[2]==="resources")&&n[3]){const l=n[2]==="memories"?"Memories":"Resources",u=n[2]==="memories"?"/memories":"/resources";r.push({label:l,path:u}),r.push({label:bn(n[3]),path:`${a}/projects/${n[1]}/${n[2]}/${n[3]}`}),o=bn(n[3]),n[4]==="edit"&&(o=n[2]==="memories"?"Edit Memory":"Edit Resource")}}else n[0]==="servers"?(o="Servers",r.push({label:"Servers",path:`${a}/servers`})):n[0]==="inventories"?(o="Inventories",r.push({label:"Inventories",path:`${a}/inventories`})):n[0]==="schedules"?(o="Schedules",r.push({label:"Schedules",path:`${a}/schedules`})):n[0]==="usage"?(o="Usage",r.push({label:"Usage",path:`${a}/usage`})):n[0]==="agent-sessions"?(o="Agent Sessions",r.push({label:"Agent Sessions",path:`${a}/agent-sessions`})):n[0]==="assignments"?(o="Assignments",r.push({label:"Assignments",path:`${a}/assignments`})):n[0]==="archive"?(o="Archive",r.push({label:"Archive",path:"/archive"})):n[0]==="playbooks"?(r.push({label:"Playbooks",path:"/playbooks"}),o="Playbooks",n[1]==="create"?o="Create Playbook":n[1]&&n[2]==="edit"?(r.push({label:bn(n[1]),path:`/playbooks/${n[1]}`}),o="Edit Playbook"):n[1]&&(r.push({label:bn(n[1]),path:`/playbooks/${n[1]}`}),o=bn(n[1]))):n[0]==="memories"?(r.push({label:"Memories",path:"/memories"}),o="Memories",n[1]==="new"&&(o="New Memory")):n[0]==="resources"?(r.push({label:"Resources",path:"/resources"}),o="Resources",n[1]==="new"&&(o="New Resource")):n[0]==="todos"?(o="Todos",r.push({label:"Todos",path:`${a}/todos`})):n[0]==="views"?(o="Saved Views",r.push({label:"Saved Views",path:`${a}/views`}),n[1]&&(o="View")):n[0]==="help"?(o="Help",r.push({label:"Help",path:"/help"})):n[0]==="settings"?(o="Settings",r.push({label:"Settings",path:"/settings"})):n[0]==="workflow"?(o="Workflow",r.push({label:"Workflow",path:"/workflow"})):n[0]==="create"&&n[1]==="project"&&(o="Create Project",r.push({label:"Create Project",path:`${a}/create/project`}));return{title:o,breadcrumbs:r,projectSlug:i}}function A2({item:e,onNavigate:t}){const n=rr(),r=e.icon,o=T2(n.pathname,e.to)&&!n.pathname.startsWith("/w/");return s.jsxs(De,{to:e.to,onClick:t,className:je("flex items-center gap-3 rounded-md px-3 py-2 text-sm font-medium transition",o?"bg-foreground text-background shadow-sm":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[s.jsx(r,{className:"h-4 w-4"}),s.jsx("span",{children:e.label}),e.badge&&e.badge>0?s.jsx("span",{className:je("ml-auto inline-flex min-w-[1.25rem] items-center justify-center rounded-full px-1.5 py-0.5 text-[11px] font-semibold",o?"bg-background/20 text-background":"bg-foreground text-background"),children:e.badge}):null]})}function R1({items:e,onNavigate:t}){return s.jsx("nav",{className:"space-y-1",children:e.map(n=>s.jsx(A2,{item:n,onNavigate:t},n.to))})}function y4({label:e,items:t,collapsed:n,onToggle:r,containsActive:o,onNavigate:i}){const a=n&&o;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:r,"aria-expanded":!n,className:je("flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs font-semibold uppercase tracking-wider transition",a?"text-foreground":"text-muted-foreground/70 hover:text-muted-foreground"),children:[s.jsx(cr,{className:je("h-3 w-3 transition-transform",n&&"-rotate-90")}),e]}),n?null:s.jsx("nav",{className:"space-y-1",children:t.map(l=>s.jsx(A2,{item:l,onNavigate:i},l.to))})]})}const P2=[{slug:"default",label:"Syntaur",description:"Brand purple, warm yellow, coral & teal accents.",swatches:{primary:"oklch(70% 0.18 290)",secondary:"oklch(80% 0.14 75)",coral:"oklch(72% 0.17 15)",teal:"oklch(72% 0.14 185)",amber:"oklch(82% 0.16 75)"}},{slug:"ocean",label:"Midnight",description:"Deep indigo-blue with cyan accents. Inspired by One Dark Pro.",swatches:{primary:"oklch(70% 0.16 240)",secondary:"oklch(78% 0.13 200)",coral:"oklch(72% 0.18 350)",teal:"oklch(78% 0.14 195)",amber:"oklch(84% 0.15 90)"}},{slug:"forest",label:"Verdant",description:"Saturated emerald and pine on a dark olive base.",swatches:{primary:"oklch(72% 0.17 145)",secondary:"oklch(80% 0.13 110)",coral:"oklch(72% 0.17 25)",teal:"oklch(75% 0.13 175)",amber:"oklch(82% 0.16 95)"}},{slug:"sunset",label:"Ember",description:"Warm sepia surfaces with copper and amber accents.",swatches:{primary:"oklch(72% 0.18 35)",secondary:"oklch(80% 0.16 60)",coral:"oklch(72% 0.19 15)",teal:"oklch(72% 0.12 180)",amber:"oklch(86% 0.17 70)"}}],b4=P2.map(e=>e.slug),lh="default";function _2(e){return typeof e=="string"&&b4.includes(e)}const D2={preset:lh,custom:!1};let Du=null,ll=null;function Xv(e){if(!e||typeof e!="object")return D2;const t=e;return{preset:_2(t.preset)?t.preset:lh,custom:t.custom===!0}}function v4(){return Du?Promise.resolve(Du):ll||(ll=fetch("/api/config/theme").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>{const t=Xv(e);return Du=t,ll=null,t}).catch(()=>(ll=null,D2)),ll)}async function w4(e){const t=await fetch("/api/config/theme",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({preset:e})});if(!t.ok){const r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));throw new Error(r.error??"Failed to save theme")}const n=Xv(await t.json());return Du=n,n}async function j4(){const e=await fetch("/api/config/theme",{method:"DELETE"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=Xv(await e.json());return Du=t,t}const jb="syntaur-theme",Dp="syntaur-preset",$2=m.createContext(null);function kb(){try{const e=window.localStorage.getItem(jb);return e==="light"||e==="dark"?e:null}catch{return null}}function I2(){try{const e=window.localStorage.getItem(Dp);return _2(e)?e:lh}catch{return lh}}function L2(){return typeof window>"u"||!window.matchMedia?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function M2(e){document.documentElement.classList.toggle("dark",e==="dark")}function O2(e){document.documentElement.dataset.theme=e}function k4(){typeof document>"u"||(M2(kb()??L2()),O2(I2()))}function S4({children:e}){const[t,n]=m.useState(()=>kb()),[r,o]=m.useState(()=>kb()??L2()),[i,a]=m.useState(()=>I2());m.useEffect(()=>{M2(r)},[r]),m.useEffect(()=>{O2(i)},[i]),m.useEffect(()=>{let p=!1;return v4().then(h=>{if(!p&&h.preset!==i){a(h.preset);try{window.localStorage.setItem(Dp,h.preset)}catch{}}}),()=>{p=!0}},[]),m.useEffect(()=>{if(!window.matchMedia)return;const p=window.matchMedia("(prefers-color-scheme: dark)"),h=()=>{t||o(p.matches?"dark":"light")};return h(),p.addEventListener("change",h),()=>{p.removeEventListener("change",h)}},[t]);async function l(p){a(p);try{window.localStorage.setItem(Dp,p)}catch{}await w4(p)}async function u(){const p=await j4();a(p.preset);try{window.localStorage.setItem(Dp,p.preset)}catch{}}const f={resolvedTheme:r,explicitTheme:t,setTheme:p=>{window.localStorage.setItem(jb,p),n(p),o(p)},toggleTheme:()=>{const p=r==="dark"?"light":"dark";window.localStorage.setItem(jb,p),n(p),o(p)},preset:i,setPreset:l,resetPreset:u};return s.jsx($2.Provider,{value:f,children:e})}function Qv(){const e=m.useContext($2);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}const N4=2e3,$u=new Set;let ps=null,ia=null,$p=!1,ch="closed";const Sb=new Set;function Ru(e){if(ch!==e){ch=e;for(const t of Sb)t(e)}}function A1(){return ch}function C4(e){return Sb.add(e),()=>{Sb.delete(e)}}function E4(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`}let T4=E4;function R4(){ia&&clearTimeout(ia),ia=setTimeout(()=>{ia=null,F2()},N4)}function F2(){if(ps&&(ps.readyState===WebSocket.OPEN||ps.readyState===WebSocket.CONNECTING))return;$p=!1,ch==="closed"&&Ru("connecting");const e=new WebSocket(T4());ps=e,e.onopen=()=>{ps===e&&Ru("open")},e.onmessage=t=>{if(ps===e)try{const n=JSON.parse(t.data);for(const r of $u)r(n)}catch{}},e.onclose=()=>{if(ps===e){if(ps=null,$p||$u.size===0){$p=!1,Ru("closed");return}Ru("reconnecting"),R4()}},e.onerror=()=>{e.close()}}function A4(e){return $u.add(e),F2(),()=>{$u.delete(e),$u.size===0&&(ia&&(clearTimeout(ia),ia=null),ps&&($p=!0,ps.close(),ps=null),Ru("closed"))}}function Ei(e){const t=m.useRef(e);t.current=e,m.useEffect(()=>A4(o=>t.current(o)),[])}const sm=["7d","30d","90d","all","custom"],z2="30d",P4=/^\d{4}-\d{2}-\d{2}$/,_d=["project","workspace","model","tool"],_4={"7d":7,"30d":30,"90d":90};function Iu(e){if(typeof e!="string"||!P4.test(e))return!1;const[t,n,r]=e.split("-").map(Number);if(n<1||n>12||r<1||r>31)return!1;const o=new Date(Date.UTC(t,n-1,r));return o.getUTCFullYear()===t&&o.getUTCMonth()===n-1&&o.getUTCDate()===r}function P1(e){const t=e.getUTCFullYear(),n=String(e.getUTCMonth()+1).padStart(2,"0"),r=String(e.getUTCDate()).padStart(2,"0");return`${t}-${n}-${r}`}function D4(e,t){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+t))}function $4(e,t=new Date){const n=e.window??z2;if(n==="all")return{};if(n==="custom"){const o={};return e.since&&(o.since=e.since),e.until&&(o.until=e.until),o}const r=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()));return{since:P1(D4(r,-(_4[n]-1))),until:P1(r)}}function I4(e){const t=[];if(!e||typeof e!="object"||Array.isArray(e))return{ok:!1,errors:["filters must be an object"]};const n=e;n.window!==void 0&&!sm.includes(n.window)&&t.push(`invalid window: ${String(n.window)}`);for(const r of["since","until"])n[r]!==void 0&&!Iu(n[r])&&t.push(`invalid ${r}: ${String(n[r])} (expected YYYY-MM-DD)`);for(const r of _d)n[r]!==void 0&&(typeof n[r]!="string"||n[r].length===0)&&t.push(`invalid ${r}: must be a non-empty string`);return Iu(n.since)&&Iu(n.until)&&n.since>n.until&&t.push("since must be on or before until"),{ok:t.length===0,errors:t}}function Dd(e){const t={};if(!e||typeof e!="object"||Array.isArray(e))return t;const n=e;typeof n.window=="string"&&sm.includes(n.window)&&(t.window=n.window),Iu(n.since)&&(t.since=n.since),Iu(n.until)&&(t.until=n.until);for(const r of _d)typeof n[r]=="string"&&n[r].length>0&&(t[r]=n[r]);return t.window!=="custom"&&(delete t.since,delete t.until),t}function Nb(e){const t=Dd(e),n=new URLSearchParams;t.window&&n.set("window",t.window),t.window==="custom"&&(t.since&&n.set("since",t.since),t.until&&n.set("until",t.until));for(const r of _d)t[r]&&n.set(r,t[r]);return n}function L4(e){const t={};for(const n of["window","since","until",..._d]){const r=e.get(n);r!==null&&(t[n]=r)}return Dd(t)}function B2(e,t=new Date){const n=Dd(e),{since:r,until:o}=$4(n,t),i=new URLSearchParams;r&&i.set("since",r),o&&i.set("until",o);for(const a of _d)n[a]&&i.set(a,n[a]);return i}const M4={"7d":"Last 7 days","30d":"Last 30 days","90d":"Last 90 days",all:"All time",custom:"Custom range"};function _1(e){const t=Dd(e),n=t.window??z2,r=[];return r.push(n==="custom"?`${t.since??"…"} → ${t.until??"…"}`:M4[n]),t.workspace&&r.push(`workspace: ${t.workspace}`),t.project&&r.push(`project: ${t.project}`),t.model&&r.push(`model: ${t.model}`),t.tool&&r.push(`tool: ${t.tool}`),r.join(" · ")}function tn(e,t,n=!0,r=!1){const[o,i]=m.useState(null),[a,l]=m.useState(!0),[u,f]=m.useState(null),[p,h]=m.useState(0),g=m.useRef(!1),y=n?e:null,k=m.useCallback(()=>{h(b=>b+1)},[]),v=m.useRef(y);return r&&v.current!==y&&(v.current=y,i(null),g.current=!1,f(null),l(!0)),m.useEffect(()=>{if(!y){l(!1),i(null),g.current=!1;return}let b=!1;return l(!g.current),f(null),fetch(y).then(async j=>{if(!j.ok){const N=await j.json().catch(()=>null);throw new Error((N==null?void 0:N.error)||`HTTP ${j.status}`)}return j.json()}).then(j=>{b||(i(j),g.current=!0,l(!1))}).catch(j=>{b||(f(j.message),l(!1))}),()=>{b=!0}},[y,p]),Ei(b=>{!t||!y||((b.type==="project-updated"||b.type==="assignment-updated")&&k(),b.type==="servers-updated"&&t==="servers"&&k(),b.type==="agent-sessions-updated"&&(t==="agent-sessions"||t==="overview")&&k(),b.type==="playbooks-updated"&&t==="playbooks"&&k(),b.type==="leases-updated"&&t==="inventories"&&k())}),{data:o,loading:a,error:u,refetch:k}}function to(e=!0){return tn("/api/projects","projects",e)}function Ea(){return tn("/api/workspaces","projects")}function mn(){const{workspace:e}=qt();return e?`/w/${e}`:""}function O4(e={}){const t=new URLSearchParams;typeof e.staleLimit=="number"&&Number.isFinite(e.staleLimit)&&t.set("staleLimit",String(e.staleLimit)),typeof e.staleOffset=="number"&&Number.isFinite(e.staleOffset)&&t.set("staleOffset",String(e.staleOffset));const n=t.toString(),r=n?`/api/overview?${n}`:"/api/overview";return tn(r,"overview")}function om(e=!0){return tn("/api/assignments","assignments",e)}function F4(e=!0){return tn("/api/archived","assignments",e)}function U2(){return tn("/api/help")}function H2(e){const t=e?`/api/projects/${e}`:null;return tn(t,"project",!0,!0)}function z4(e,t){const n=e&&t?`/api/projects/${e}/assignments/${t}`:null;return tn(n,"assignment",!0,!0)}function B4(e){const t=e?`/api/assignments/${e}`:null;return tn(t,"assignment",!0,!0)}function V2(e){return tn(e,void 0,!0,!0)}function Jv(e=!0){return tn("/api/servers","servers",e)}function W2(){return tn("/api/leases","inventories")}function im(){return tn("/api/agent-sessions","agent-sessions")}function U4(e,t){const n=e&&t?`/api/agent-sessions/${e}?assignment=${t}`:null;return tn(n,"agent-sessions",!0,!0)}function H4(e){const t=e?`/api/assignments/${e}/sessions`:null;return tn(t,"agent-sessions",!0,!0)}function V4(e,t){const n=e&&t?`/api/usage/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}`:null;return tn(n,void 0,!0,!0)}function W4(e){const t=e?`/api/usage/standalone/${encodeURIComponent(e)}`:null;return tn(t,void 0,!0,!0)}function Zv(e=!0){return tn("/api/playbooks","playbooks",e)}function q4(e){const t=B2(e).toString(),n=t?`/api/usage?${t}`:"/api/usage";return tn(n,void 0,!0,!0)}function q2(e=!0){return tn("/api/usage/facets",void 0,e)}function K4(e){const t=e?`/api/playbooks/${e}`:null;return tn(t,"playbooks",!0,!0)}function G4(){return tn("/api/memories","project")}function Y4(e,t){const n=e&&t?`/api/projects/${e}/memories/${t}`:null;return tn(n,"project",!0,!0)}function X4(){return tn("/api/resources","project")}function Q4(e,t){const n=e&&t?`/api/projects/${e}/resources/${t}`:null;return tn(n,"project",!0,!0)}const am=["new-workspace","new-project","new-todo","new-assignment"];function J4(e){return typeof e=="string"&&am.includes(e)}const Z4=["mod+k","mod+shift+k","?","escape","enter","shift+t","g","g o","g m","g a","g t","g s","g !","g ,","j","k","o","a","e","/","r","p","h","d","s","[","]"],e5=["mod","ctrl","alt","shift"];function wr(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";if(/\s/.test(t)&&!t.includes("+"))return t.split(/\s+/).map(wr).filter(l=>l.length>0).join(" ");const n=t.split("+").map(l=>l.trim()).filter(l=>l.length>0);if(n.length===0)return"";if(n.length===1)return n[0].toLowerCase();const r=n[n.length-1].toLowerCase(),o=n.slice(0,-1).map(l=>l.toLowerCase()),i=new Set,a=[];for(const l of e5)o.includes(l)&&!i.has(l)&&(a.push(l),i.add(l));for(const l of o)i.has(l)||(a.push(l),i.add(l));return[...a,r].join("+")}function t5(e){const t=wr(e);return t?Z4.includes(t):!1}const n5={"new-workspace":wr("Mod+Shift+Alt+w"),"new-project":wr("Mod+Shift+Alt+p"),"new-todo":wr("Mod+Shift+Alt+t"),"new-assignment":wr("Mod+Shift+Alt+a")};function r5(e){const t={...n5};for(const n of am){const r=e[n];typeof r=="string"&&r.length>0&&(t[n]=r)}return t}function sa(){if(typeof navigator>"u")return!1;const e=navigator.platform||"",t=navigator.userAgent||"";return/Mac|iPhone|iPad|iPod/.test(e)||/Mac OS X/.test(t)}function s5(e){const t=e.split("+").map(o=>o.trim()),n=t[t.length-1]??"",r=new Set(t.slice(0,-1).map(o=>o.toLowerCase()));return{key:n.toLowerCase(),mod:r.has("mod"),shift:r.has("shift"),alt:r.has("alt"),ctrl:r.has("ctrl")}}function np(e,t){const n=s5(t);if(e.key.toLowerCase()!==n.key)return!1;const o=sa()?e.metaKey:e.ctrlKey;return!(n.mod&&!o||!n.mod&&!n.ctrl&&o||n.ctrl&&!e.ctrlKey||n.shift&&!e.shiftKey||!n.shift&&!(n.key.length===1&&!/^[a-z0-9]$/.test(n.key))&&e.shiftKey||n.alt&&!e.altKey||!n.alt&&e.altKey)}function K2(e){const t=[],n=sa()?e.metaKey:e.ctrlKey;n&&t.push("mod"),e.ctrlKey&&!n&&t.push("ctrl"),e.altKey&&t.push("alt");const r=e.key;let o;r===" "||r==="Spacebar"?o="space":(r.length,o=r.toLowerCase());const i=o.length===1&&/^[a-z0-9]$/.test(o);e.shiftKey&&i&&t.push("shift");const a=[...t,o].join("+");return wr(a)}function Qs(e){return e.split("+").map(n=>{const r=n.toLowerCase();return r==="mod"?sa()?"⌘":"Ctrl":r==="shift"?sa()?"⇧":"Shift":r==="alt"?sa()?"⌥":"Alt":r==="ctrl"?sa()?"⌃":"Ctrl":r==="enter"?"↵":r==="escape"?"Esc":r==="arrowup"?"↑":r==="arrowdown"?"↓":n.length===1?n.toUpperCase():n}).join(sa()?"":"+")}function o5(e){const[t,n]=m.useState(null),[r,o]=m.useState(!0),[i,a]=m.useState(null),l=m.useCallback(async()=>{try{const u=await fetch(`/api/todos/${encodeURIComponent(e)}`);if(!u.ok)throw new Error(`HTTP ${u.status}`);n(await u.json()),a(null)}catch(u){a(u instanceof Error?u.message:"Failed to fetch todos")}finally{o(!1)}},[e]);return m.useEffect(()=>{l()},[l]),Ei(u=>{u.type==="todos-updated"&&!u.projectSlug&&l()}),{data:t,loading:r,error:i,refetch:l}}function G2(e=!0){const[t,n]=m.useState(null),[r,o]=m.useState(!0),[i,a]=m.useState(null),l=m.useCallback(async()=>{try{const u=await fetch("/api/todos");if(!u.ok)throw new Error(`HTTP ${u.status}`);n(await u.json()),a(null)}catch(u){a(u instanceof Error?u.message:"Failed to fetch todos")}finally{o(!1)}},[]);return m.useEffect(()=>{if(!e){o(!1);return}l()},[l,e]),Ei(u=>{e&&u.type==="todos-updated"&&!u.projectSlug&&l()}),{data:t,loading:r,error:i,refetch:l}}async function ew(e,t,n){await Ti(`/api/todos/${encodeURIComponent(e)}`,{description:t,tags:n})}async function Y2(e,t,n){await Ti(`/api/todos/${encodeURIComponent(e)}/${t}/complete`,{summary:"Completed."})}async function X2(e,t,n){await Ti(`/api/todos/${encodeURIComponent(e)}/${t}/block`,{reason:n})}async function Q2(e,t,n){await Ti(`/api/todos/${encodeURIComponent(e)}/${t}/start`,{session:n})}async function J2(e,t){await Ti(`/api/todos/${encodeURIComponent(e)}/${t}/reopen`,{})}async function Z2(e,t){await i5(`/api/todos/${encodeURIComponent(e)}/${t}`)}async function eT(e,t,n){const r=await fetch(`/api/todos/${encodeURIComponent(e)}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:n})});if(!r.ok)throw new Error(await r.text().catch(()=>"")||`HTTP ${r.status}`)}function tw(e,t,n){return`/api/todos/${encodeURIComponent(e)}/${t}/attachments/${encodeURIComponent(n)}`}async function tT(e,t,n){for(const r of n){const o=await fetch(`/api/todos/${encodeURIComponent(e)}/${t}/attachments`,{method:"POST",headers:{"Content-Type":"application/octet-stream","x-attachment-filename":encodeURIComponent(r.name||"file"),"x-attachment-mime":r.type||"application/octet-stream"},body:r});if(!o.ok)throw new Error(await o.text().catch(()=>"")||`HTTP ${o.status}`)}}async function nT(e,t,n){const r=await fetch(tw(e,t,n),{method:"DELETE"});if(!r.ok)throw new Error(await r.text().catch(()=>"")||`HTTP ${r.status}`)}async function Ti(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.text().catch(()=>"");let o=null;try{o=r?JSON.parse(r):null}catch{}const i=(o==null?void 0:o.error)||r||`HTTP ${n.status}`,a=new Error(i);throw a.status=n.status,a}return n.json().catch(()=>({}))}async function i5(e){const t=await fetch(e,{method:"DELETE"});if(!t.ok){const n=await t.text().catch(()=>"");let r=null;try{r=n?JSON.parse(n):null}catch{}const o=(r==null?void 0:r.error)||n||`HTTP ${t.status}`,i=new Error(o);throw i.status=t.status,i}}async function a5(e,t){return await Ti(`/api/todos/${encodeURIComponent(e)}/promote`,t)}async function l5(e){return await Ti("/api/todos/promote-bulk",e)}async function c5(e,t,n){await Ti(`/api/todos/${encodeURIComponent(e)}/${t}/move`,{to:n})}const lm=["assignment","project","todo","server","playbook"],fa={defaultScope:"all",aliases:{a:"assignment",p:"project",t:"todo",s:"server",pb:"playbook"},externalIds:!0},rT=["kind","status","tag","tags","assignee","type","project","externalid","jira","title","search"],Cb="all",sT=/^[a-z][a-z0-9]*$/;function nw(e){return typeof e=="string"&&lm.includes(e)}function u5(e){return e==="all"||nw(e)}function d5(e){if(!e||typeof e!="object")return p5();const t=e,n=u5(t.defaultScope)?t.defaultScope:fa.defaultScope,r=typeof t.externalIds=="boolean"?t.externalIds:fa.externalIds;let o;if(t.aliases&&typeof t.aliases=="object"){o={};for(const[i,a]of Object.entries(t.aliases))sT.test(i)&&i!==Cb&&!rT.includes(i)&&nw(a)&&(o[i]=a)}else o={...fa.aliases};return{defaultScope:n,aliases:o,externalIds:r}}function f5(e){if(!e||typeof e!="object")return{ok:!1,errors:["aliases must be an object"]};const t=[];for(const[n,r]of Object.entries(e))sT.test(n)||t.push(`alias key "${n}" must be lowercase and match [a-z][a-z0-9]*`),n===Cb&&t.push(`alias key "${Cb}" is reserved (the "search everything" escape)`),rT.includes(n)&&t.push(`alias key "${n}" collides with the reserved field name "${n}"`),nw(r)||t.push(`alias "${n}" must map to one of: ${lm.join(", ")}`);return t.length===0?{ok:!0}:{ok:!1,errors:t}}function p5(){return{defaultScope:fa.defaultScope,aliases:{...fa.aliases},externalIds:fa.externalIds}}const rw={search:fa,custom:!1};let El=null,cl=null,uh=0;const Eb=new Set;function oT(e){El=e;for(const t of Eb)t(e)}function sw(e){if(!e||typeof e!="object")return rw;const t=e;return{search:d5(t.search),custom:t.custom===!0}}function h5(){if(El)return Promise.resolve(El);if(cl)return cl;const e=++uh;return cl=fetch("/api/config/search").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{cl=null;const n=sw(t);return e!==uh?El??n:(El=n,n)}).catch(()=>(cl=null,rw)),cl}function ow(){const[e,t]=m.useState(()=>El??rw);return m.useEffect(()=>{let n=!1;return h5().then(r=>{n||t(r)}),Eb.add(t),()=>{n=!0,Eb.delete(t)}},[]),e}async function m5(e){var r;++uh;const t=await fetch("/api/config/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const o=await t.json().catch(()=>null);throw new Error(((r=o==null?void 0:o.errors)==null?void 0:r.join("; "))??(o==null?void 0:o.error)??`HTTP ${t.status}`)}const n=sw(await t.json());return oT(n),n}async function g5(){++uh;const e=await fetch("/api/config/search",{method:"DELETE"});if(!e.ok){const n=await e.json().catch(()=>null);throw new Error((n==null?void 0:n.error)??`HTTP ${e.status}`)}const t=sw(await e.json());return oT(t),t}const x5=new Set(["/projects","/assignments","/servers","/todos"]);function Ip(e,t){return x5.has(e)?`${t}${e}`:e}const y5=[{id:"page-overview",title:"Overview",basePath:"/",keywords:["home","dashboard"]},{id:"page-projects",title:"Projects",basePath:"/projects",keywords:[]},{id:"page-assignments",title:"Assignments",basePath:"/assignments",keywords:[]},{id:"page-todos",title:"Todos",basePath:"/todos",keywords:["tasks"]},{id:"page-servers",title:"Servers",basePath:"/servers",keywords:["sessions"]},{id:"page-playbooks",title:"Playbooks",basePath:"/playbooks",keywords:[]},{id:"page-memories",title:"Memories",basePath:"/memories",keywords:["knowledge","learnings"]},{id:"page-resources",title:"Resources",basePath:"/resources",keywords:["knowledge","reference"]},{id:"page-workflow",title:"Workflow",basePath:"/workflow",keywords:["statuses","transitions","derive","facts"]},{id:"page-settings",title:"Settings",basePath:"/settings",keywords:[]},{id:"page-help",title:"Help",basePath:"/help",keywords:["shortcuts"]}];function b5(e){if(!(e!=null&&e.length))return[];const t=[];for(const n of e)n.id&&(t.push(n.id),n.system&&t.push(`${n.system}:${n.id}`));return t}function v5(e){const t=[],n=e.externalIds!==!1,r=i=>n?b5(i):[],o=i=>n?i:void 0;for(const i of y5)t.push({type:"page",id:i.id,title:i.title,keywords:[...i.keywords],route:Ip(i.basePath,e.wsPrefix)});for(const i of e.projects??[]){const a=i.workspace?`/w/${i.workspace}`:"";t.push({type:"project",id:`project-${i.slug}`,title:i.title,subtitle:i.slug,keywords:[...i.tags??[],...r(i.externalIds)],route:`${a}/projects/${i.slug}`,tags:i.tags,project:i.slug,externalIds:o(i.externalIds)}),t.push({type:"todo",id:`project-todos-${i.slug}`,title:`${i.title} todos`,subtitle:`${i.slug} · project`,keywords:[...i.tags??[],"project","todos"],route:`${a}/projects/${i.slug}?tab=todos`})}for(const i of e.assignments??[]){const a=i.projectWorkspace?`/w/${i.projectWorkspace}`:"";t.push({type:"assignment",id:i.projectSlug===null?`assignment-standalone-${i.id}`:`assignment-${i.projectSlug}-${i.slug}`,title:i.title,subtitle:`${i.projectTitle} · ${i.status}`,keywords:[i.projectSlug??"standalone",i.assignee??"",...r(i.externalIds)].filter(l=>!!l),route:i.projectSlug===null?`/assignments/${i.id}`:`${a}/projects/${i.projectSlug}/assignments/${i.slug}`,status:i.status,tags:i.tags,assignee:i.assignee,assignmentType:i.type,project:i.projectSlug,externalIds:o(i.externalIds)})}for(const i of e.playbooks??[])t.push({type:"playbook",id:`playbook-${i.slug}`,title:i.name,subtitle:i.description,keywords:i.tags,route:`/playbooks/${i.slug}`,tags:i.tags});for(const i of e.servers??[])t.push({type:"server",id:`server-${i.name}`,title:i.name,subtitle:i.alive?"alive":"dead",route:`${Ip("/servers",e.wsPrefix)}#server-${encodeURIComponent(i.name)}`});for(const i of e.todos??[]){const a=i.workspace&&i.workspace!=="_ungrouped"?`/w/${i.workspace}`:e.wsPrefix,l=Ip("/todos",a);t.push({type:"todo",id:`todo-${i.id}`,title:i.description,subtitle:i.status,keywords:i.tags,route:`${l}?focus=${encodeURIComponent(i.id)}`,status:i.status,tags:i.tags})}return t}function w5(e){return!e.standalone&&!!e.projectWorkspace&&e.fileKind!=="memory"&&e.fileKind!=="resource"?`/w/${e.projectWorkspace}`:""}function j5(e){return e.map((t,n)=>({type:"content",id:`content-${t.path}-${n}`,title:`${t.assignmentSlug??t.itemSlug??""} › ${t.section??t.fileKind}`,subtitle:t.projectSlug??(t.standalone?"standalone":void 0),route:`${w5(t)}${t.route}`,project:t.projectSlug,snippet:t.snippet,snippetMatches:t.matches}))}function Ir(e){return e.toLowerCase().trim().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Lp(e){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)}async function k5(e,t,n){const r=t?"disable":"enable",o=await fetch(`/api/playbooks/${encodeURIComponent(e)}/${r}`,{method:"POST"});if(!o.ok){const i=await o.json().catch(()=>({}));throw new Error(i.error||`Failed to ${r} playbook`)}n()}async function ey(e,t){const n=await fetch(`/api/todos/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`Failed to create todo (HTTP ${n.status})`)}}async function D1(){const e=await fetch("/api/workspaces");if(!e.ok)throw new Error(`Failed to load workspaces (HTTP ${e.status})`);const t=await e.json();return{workspaces:Array.isArray(t.workspaces)?t.workspaces:[],hasUngrouped:t.hasUngrouped===!0}}async function $1(){const e=await fetch("/api/projects");if(!e.ok)throw new Error(`Failed to load projects (HTTP ${e.status})`);const t=await e.json();return Array.isArray(t)?t:[]}async function ty(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to load template (HTTP ${t.status})`);const n=await t.json();if(!n.content)throw new Error("Template returned no content");return n.content}function Xi(e,t,n){const r=e.match(/^(---\n)([\s\S]*?)(\n---)/);if(!r)return`---
547
- ${t}: ${JSON.stringify(n)}
548
- ---
549
- ${e}`;const o=r[1],i=r[2],a=r[3],l=e.slice(r[0].length),u=JSON.stringify(n),f=new RegExp(`^${t}:\\s*.*$`,"m");let p;return f.test(i)?p=i.replace(f,`${t}: ${u}`):p=`${i}
550
- ${t}: ${u}`,`${o}${p}${a}${l}`}const S5=/^[a-z0-9][a-z0-9-]*$/;function N5(e){const{playbooks:t,projectSlug:n,currentProjectTitle:r,currentProjectWorkspace:o,wsPrefix:i,refetchPlaybooks:a,navigate:l,toggleTheme:u}=e,f=[];if(f.push({id:"new-workspace",title:"New Workspace",subtitle:"Create a Syntaur workspace",group:"Create",keywords:["new","create","workspace"],bindableKind:"new-workspace",flow:{steps:[{kind:"text",id:"name",label:"Workspace name",placeholder:"lowercase, hyphenated (e.g. acme-app)",required:!0,pattern:{regex:S5,message:"Use lowercase letters, digits, and hyphens (e.g. acme-app). Must start with a letter or digit."}}],submit:async(p,h)=>{const g=(p.name??"").trim();if(!g)throw new Error("Name is required");const y=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g})});if(!y.ok){const k=await y.json().catch(()=>({}));throw new Error(k.error||`Failed to create workspace (HTTP ${y.status})`)}h.navigate(`/w/${g}/projects`)}}}),f.push({id:"new-project",title:"New Project",subtitle:"Create a project (pick workspace)",group:"Create",keywords:["new","create","project"],bindableKind:"new-project",flow:{steps:[{kind:"picker",id:"workspace",label:"Workspace",emptyMessage:'No workspaces yet — create one with "New Workspace"',loadOptions:async()=>{const{workspaces:p,hasUngrouped:h}=await D1(),g=[{value:"_ungrouped",label:"Ungrouped",hint:"no workspace"}];for(const y of p)g.push({value:y,label:y,hint:"workspace"});return g}},{kind:"text",id:"title",label:"Project title",placeholder:"e.g. Marketing site rebuild",required:!0}],submit:async(p,h)=>{const g=(p.workspace??"").trim(),y=(p.title??"").trim();if(!y)throw new Error("Title is required");const k=Ir(y);if(!k)throw new Error("Title must contain at least one alphanumeric character");let v=await ty("/api/templates/project");v=Xi(v,"slug",k),v=Xi(v,"title",y),g&&g!=="_ungrouped"&&(v=Xi(v,"workspace",g));const b=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:v})}),j=await b.json().catch(()=>({}));if(!b.ok)throw new Error(j.error||`Failed to create project (HTTP ${b.status})`);const N=g&&g!=="_ungrouped"?`/w/${g}/projects/${j.slug??k}`:`/projects/${j.slug??k}`;h.navigate(N)}}}),f.push({id:"new-todo",title:"New Todo",subtitle:"Pick scope (global / workspace / project)",group:"Create",keywords:["new","create","todo","task"],bindableKind:"new-todo",flow:{steps:[{kind:"picker",id:"scope",label:"Scope",loadOptions:async()=>{const[{workspaces:p},h]=await Promise.all([D1(),$1()]),g=[{value:"_ungrouped",label:"Global",hint:"no workspace"}];for(const y of p)g.push({value:y,label:y,hint:"workspace"});for(const y of h){const k=y.workspace??"_ungrouped";g.push({value:k,label:`${y.title}`,hint:`project · ${y.workspace??"ungrouped"}`})}return g}},{kind:"text",id:"description",label:"Description",placeholder:"Describe the todo…",required:!0}],submit:async p=>{const h=(p.scope??"_ungrouped").trim()||"_ungrouped",g=(p.description??"").trim();if(!g)throw new Error("Description is required");await ew(h,g)}}}),f.push({id:"new-assignment",title:"New Assignment",subtitle:"Pick standalone or a project",group:"Create",keywords:["new","create","assignment"],bindableKind:"new-assignment",flow:{steps:[{kind:"picker",id:"project",label:"Project",loadOptions:async()=>{const p=await $1(),h=[{value:"_standalone",label:"Standalone",hint:"one-off / not in a project"}];for(const g of p)h.push({value:g.slug,label:g.title,hint:g.workspace?`workspace · ${g.workspace}`:"ungrouped"});return h}},{kind:"text",id:"title",label:"Assignment title",placeholder:"What needs to get done?",required:!0}],submit:async(p,h)=>{var S;const g=(p.project??"_standalone").trim()||"_standalone",y=(p.title??"").trim();if(!y)throw new Error("Title is required");const k=Ir(y);if(!k)throw new Error("Title must contain at least one alphanumeric character");if(g==="_standalone"){let C=await ty("/api/templates/assignment?standalone=1");C=Xi(C,"slug",k),C=Xi(C,"title",y);const D=await fetch("/api/assignments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:C})}),T=await D.json().catch(()=>({}));if(!D.ok)throw new Error(T.error||`Failed to create assignment (HTTP ${D.status})`);const R=((S=T==null?void 0:T.assignment)==null?void 0:S.id)??(T==null?void 0:T.id);R?h.navigate(`/assignments/${R}`):h.navigate("/assignments");return}let v=await ty("/api/templates/assignment");v=Xi(v,"slug",k),v=Xi(v,"title",y);const b=await fetch(`/api/projects/${encodeURIComponent(g)}/assignments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:v})}),j=await b.json().catch(()=>({}));if(!b.ok)throw new Error(j.error||`Failed to create assignment (HTTP ${b.status})`);const N=j.slug??k;h.navigate(`/projects/${g}/assignments/${N}`)}}}),f.push({id:"create-project-route",title:"New Project (advanced editor)",subtitle:"Open the markdown editor",group:"Create",keywords:["new","create","project","advanced","editor"],run:()=>l(`${i}/create/project`)}),f.push({id:"create-standalone-assignment",title:"New Standalone Assignment (editor)",subtitle:"Open the markdown editor",group:"Create",keywords:["new","create","assignment","standalone","one-off","editor"],run:()=>l(`${i}/assignments/new`)}),n&&f.push({id:`create-assignment-in-${n}`,title:`New Assignment in ${r??n}`,subtitle:n,group:"Create",keywords:["new","create","assignment",n],run:()=>l(`${i}/projects/${n}/create/assignment`)}),f.push({id:"create-playbook",title:"New Playbook",group:"Create",keywords:["new","create","playbook"],run:()=>l("/playbooks/create")}),f.push({id:"create-todo-global",title:"New Todo (global, quick)",subtitle:"Ungrouped, single-step",group:"Create",keywords:["new","create","todo","global","ungrouped","quick"],requiresInput:{placeholder:"Describe the todo…",runWithInput:async p=>{const h=p.trim();h&&await ey("_ungrouped",h)}}}),i){const p=i.replace(/^\/w\//,"");f.push({id:`create-todo-workspace-${p}`,title:`New Todo in workspace ${p}`,subtitle:p,group:"Create",keywords:["new","create","todo","workspace",p],requiresInput:{placeholder:`Describe the todo for workspace ${p}…`,runWithInput:async h=>{const g=h.trim();g&&await ey(p,g)}}})}n&&o&&f.push({id:`create-todo-project-${n}`,title:`New Todo in project ${r??n}`,subtitle:`${n} · workspace ${o}`,group:"Create",keywords:["new","create","todo","project",n,o],requiresInput:{placeholder:`Describe the todo for project ${r??n}…`,runWithInput:async p=>{const h=p.trim();h&&await ey(o,h)}}});for(const p of t)f.push({id:`toggle-playbook-${p.slug}`,title:`Toggle Playbook: ${p.name}`,subtitle:p.enabled?"enabled":"disabled",group:"Toggle",keywords:["toggle","playbook",p.slug,...p.tags??[]],run:()=>k5(p.slug,p.enabled,a)});return f.push({id:"toggle-theme",title:"Toggle theme",subtitle:"Light / dark",group:"Theme",keywords:["theme","toggle","light","dark","appearance"],run:()=>u()}),f}const C5=["low","medium","high","critical"],cm={status:{kind:"enum"},priority:{kind:"ordinal",order:C5},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 E5(e,t){return e[t.toLowerCase()]??null}function Lr(e,t,n){return e.get?e.get(n):n[t]??n[t.toLowerCase()]}class br extends Error{constructor(t){super(t.map(n=>`${n.message} (at ${n.pos})`).join("; ")),this.errors=t,this.name="CompileError"}}function iT(e){const[t,n,r]=e.raw.split("-").map(a=>parseInt(a,10)),o=new Date(t,n-1,r);if(o.getFullYear()!==t||o.getMonth()!==n-1||o.getDate()!==r)throw new br([{pos:e.pos,message:`Invalid date "${e.raw}"`}]);const i=new Date(t,n-1,r+1).getTime();return[o.getTime(),i]}function Tb(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 Lu(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 ny(e,t){return typeof e=="string"&&e.toLowerCase()===t.toLowerCase()}function T5(e){return e==null||e===""}function Mp(e,t,n,r){switch(e.kind){case"enum":case"string":return e.noneSentinel&&n.raw.toLowerCase()==="none"?o=>T5(Lr(e,t,o)):o=>ny(Lr(e,t,o),n.raw);case"substring":return o=>{const i=Lr(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 br([{pos:n.pos,message:`Field "${t}" is boolean — use ${t}:true or ${t}:false`}]);const i=o==="true";return a=>{const l=Lr(e,t,a),u=typeof l=="boolean"?l:l==="true"?!0:l==="false"||l===null||l===void 0||l===""?!1:null;return u!==null&&u===i}}case"number":{const o=n.num??Lu(n.raw);if(o===null)throw new br([{pos:n.pos,message:`Field "${t}" is numeric — "${n.raw}" is not a number`}]);return i=>Lu(Lr(e,t,i))===o}case"ordinal":return o=>ny(Lr(e,t,o),n.raw);case"list":return o=>{const i=Lr(e,t,o);return Array.isArray(i)&&i.some(a=>ny(a,n.raw))};case"timestamp":{if(n.type==="date"){const[o,i]=iT(n);return a=>{const l=Tb(Lr(e,t,a));return l!==null&&l>=o&&l<i}}throw new br([{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 br([{pos:r,message:`Field "${t}" is a duration — use a comparison (e.g. ${t} > 3d)`}])}}function R5(e,t,n,r){const o=(i,a)=>{switch(n){case"<":return i<a;case">":return i>a;case"<=":return i<=a;case">=":return i>=a;case"=":return i===a;case"!=":return i!==a;default:return!1}};switch(e.kind){case"number":{const i=r.num??Lu(r.raw);if(i===null)throw new br([{pos:r.pos,message:`"${r.raw}" is not a number (field "${t}")`}]);return a=>{const l=Lu(Lr(e,t,a));return l!==null&&o(l,i)}}case"ordinal":{const i=e.order??[],a=i.findIndex(l=>l.toLowerCase()===r.raw.toLowerCase());if(a<0)throw new br([{pos:r.pos,message:`"${r.raw}" is not a valid ${t} (expected one of: ${i.join(", ")})`}]);return l=>{const u=Lr(e,t,l),f=typeof u=="string"?i.findIndex(p=>p.toLowerCase()===u.toLowerCase()):-1;return f>=0&&o(f,a)}}case"timestamp":{if(r.type==="duration"){const a=(r.sign===0?-1:r.sign??-1)*(r.num??0);return(l,u)=>{const f=Tb(Lr(e,t,l));return f!==null&&o(f,u.now+a)}}if(r.type==="date"){const[i,a]=iT(r);return l=>{const u=Tb(Lr(e,t,l));if(u===null)return!1;switch(n){case"<":return u<i;case"<=":return u<a;case">":return u>=a;case">=":return u>=i;case"=":return u>=i&&u<a;case"!=":return u<i||u>=a;default:return!1}}}throw new br([{pos:r.pos,message:`Compare timestamp field "${t}" to a duration (e.g. -36h) or a date (YYYY-MM-DD)`}])}case"duration":{if(r.type!=="duration")throw new br([{pos:r.pos,message:`Compare duration field "${t}" to a duration literal (e.g. 3d)`}]);const i=r.num??0;return a=>{const l=Lu(Lr(e,t,a));return l!==null&&o(l,i)}}case"enum":case"string":case"substring":case"list":{if(n==="=")return Mp(e,t,r,r.pos);if(n==="!="){const i=Mp(e,t,r,r.pos);return(a,l)=>!i(a,l)}throw new br([{pos:r.pos,message:`Field "${t}" does not support ordering comparisons (use ":" or "=").`}])}case"bool":{if(n==="="||n==="!="){const i=Mp(e,t,r,r.pos);return n==="="?i:(a,l)=>!i(a,l)}throw new br([{pos:r.pos,message:`Field "${t}" is boolean — use ${t}:true / ${t}:false`}])}}}function A5(e,t){const n=E5(t,e.field);if(!n)throw new br([{pos:e.pos,message:`Unknown field "${e.field}"`}]);if(e.op===":"){const r=e.values.map(o=>Mp(n,e.field,o,e.pos));return r.length===1?r[0]:(o,i)=>r.some(a=>a(o,i))}return R5(n,e.field,e.op,e.values[0])}function Mu(e,t){switch(e.kind){case"all":return()=>!0;case"atom":return A5(e,t);case"not":{const n=Mu(e.child,t);return(r,o)=>!n(r,o)}case"and":{const n=e.children.map(r=>Mu(r,t));return(r,o)=>n.every(i=>i(r,o))}case"or":{const n=e.children.map(r=>Mu(r,t));return(r,o)=>n.some(i=>i(r,o))}}}class oa extends Error{constructor(t,n){super(n),this.pos=t,this.name="LexError"}}const P5={h:36e5,d:864e5,w:7*864e5,m:30*864e5,mo:30*864e5,y:365*864e5},_5=/[A-Za-z_]/,D5=/[A-Za-z0-9_-]/,$5=/^\d{4}-\d{2}-\d{2}(?![\d-])/;function um(e){const t=[];let n=0;const r=(o,i)=>{let a=n;for(;a<e.length&&/\d/.test(e[a]);)a++;const l=e.slice(n,a);let u="";for(;a<e.length&&/[a-z]/i.test(e[a]);)u+=e[a],a++;if(n=a,u.length>0){const f=P5[u.toLowerCase()];if(f===void 0)throw new oa(o,`Unknown duration unit "${u}" (expected h, d, w, m, mo, or y)`);return{type:"DURATION",text:e.slice(o,a),pos:o,num:parseInt(l,10)*f,sign:i}}return i!==0?{type:"NUMBER",text:e.slice(o,a),pos:o,num:i*parseInt(l,10)}:{type:"NUMBER",text:l,pos:o,num:parseInt(l,10)}};for(;n<e.length;){const o=e[n],i=n;if(o===" "||o===" "||o===`
551
- `||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 oa(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 a=o;let l=n+1,u="";for(;l<e.length&&e[l]!==a;)e[l]==="\\"&&l+1<e.length?(u+=e[l+1],l+=2):(u+=e[l],l++);if(l>=e.length)throw new oa(i,"Unterminated string literal");t.push({type:"STRING",text:u,pos:i}),n=l+1;continue}if(o==="-"||o==="+"){if(/\d/.test(e[n+1]??"")){const a=o==="-"?-1:1;n++,t.push(r(i,a));continue}if(o==="-"){t.push({type:"MINUS",text:"-",pos:i}),n++;continue}throw new oa(i,'Unexpected "+"')}if(/\d/.test(o)){const a=e.slice(n).match($5);if(a){t.push({type:"DATE",text:a[0],pos:i}),n+=a[0].length;continue}t.push(r(i,0));continue}if(_5.test(o)){let a=n+1;for(;a<e.length&&D5.test(e[a]);)a++;const l=e.slice(n,a),u=l.toLowerCase();u==="and"?t.push({type:"AND",text:l,pos:i}):u==="or"?t.push({type:"OR",text:l,pos:i}):u==="not"?t.push({type:"NOT",text:l,pos:i}):t.push({type:"IDENT",text:l,pos:i}),n=a;continue}throw new oa(i,`Unexpected character "${o}"`)}return t.push({type:"EOF",text:"",pos:e.length}),t}class Ji extends Error{constructor(t,n){super(n),this.pos=t,this.name="ParseError"}}const I5=new Set(["IDENT","STRING","NUMBER","DATE","DURATION"]),L5=new Set(["IDENT","NOT","MINUS","LPAREN","STAR"]);class M5{constructor(t){Ux(this,"pos",0);this.tokens=t}peek(){return this.tokens[this.pos]}next(){return this.tokens[this.pos++]}expect(t,n){const r=this.peek();if(r.type!==t)throw new Ji(r.pos,`Expected ${n}, got "${r.text||r.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 Ji(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(L5.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 Ji(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 Ji(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 r=this.valueOrList();return{kind:"atom",field:t.text,op:":",values:r,pos:t.pos}}if(n.type==="OP"){this.next();const r=this.value();return{kind:"atom",field:t.text,op:n.text,values:[r],pos:t.pos}}throw new Ji(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(!I5.has(t.type))throw new Ji(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 dm(e){try{const t=um(e);return{ast:new M5(t).parseQuery(),errors:[]}}catch(t){if(t instanceof oa||t instanceof Ji)return{ast:null,errors:[{pos:t.pos,message:t.message}]};throw t}}function Jl(e,t=cm){const n=dm(e);if(!n.ast)return{query:null,errors:n.errors};try{return{query:{predicate:Mu(n.ast,t),ast:n.ast},errors:[]}}catch(r){if(r instanceof br)return{query:null,errors:r.errors};throw r}}function sn(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function I1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function fm(...e){return t=>{let n=!1;const r=e.map(o=>{const i=I1(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():I1(e[o],null)}}}}function nr(...e){return m.useCallback(fm(...e),e)}function O5(e,t){const n=m.createContext(t),r=i=>{const{children:a,...l}=i,u=m.useMemo(()=>l,Object.values(l));return s.jsx(n.Provider,{value:u,children:a})};r.displayName=e+"Provider";function o(i){const a=m.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,o]}function Ta(e,t=[]){let n=[];function r(i,a){const l=m.createContext(a),u=n.length;n=[...n,a];const f=h=>{var j;const{scope:g,children:y,...k}=h,v=((j=g==null?void 0:g[e])==null?void 0:j[u])||l,b=m.useMemo(()=>k,Object.values(k));return s.jsx(v.Provider,{value:b,children:y})};f.displayName=i+"Provider";function p(h,g){var v;const y=((v=g==null?void 0:g[e])==null?void 0:v[u])||l,k=m.useContext(y);if(k)return k;if(a!==void 0)return a;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[f,p]}const o=()=>{const i=n.map(a=>m.createContext(a));return function(l){const u=(l==null?void 0:l[e])||i;return m.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return o.scopeName=e,[r,F5(o,...t)]}function F5(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const a=r.reduce((l,{useScope:u,scopeName:f})=>{const h=u(i)[`__scope${f}`];return{...l,...h}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var wi=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},z5=zE[" useId ".trim().toString()]||(()=>{}),B5=0;function Ml(e){const[t,n]=m.useState(z5());return wi(()=>{n(r=>r??String(B5++))},[e]),e||(t?`radix-${t}`:"")}var U5=zE[" useInsertionEffect ".trim().toString()]||wi;function pm({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,a]=H5({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:o;{const p=m.useRef(e!==void 0);m.useEffect(()=>{const h=p.current;h!==l&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=l},[l,r])}const f=m.useCallback(p=>{var h;if(l){const g=V5(p)?p(e):p;g!==e&&((h=a.current)==null||h.call(a,g))}else i(p)},[l,e,i,a]);return[u,f]}function H5({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),i=m.useRef(t);return U5(()=>{i.current=t},[t]),m.useEffect(()=>{var a;o.current!==n&&((a=i.current)==null||a.call(i,n),o.current=n)},[n,o]),[n,r,i]}function V5(e){return typeof e=="function"}function W5(e){const t=q5(e),n=m.forwardRef((r,o)=>{const{children:i,...a}=r,l=m.Children.toArray(i),u=l.find(G5);if(u){const f=u.props.children,p=l.map(h=>h===u?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return s.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,p):null})}return s.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function q5(e){const t=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const a=X5(o),l=Y5(i,o.props);return o.type!==m.Fragment&&(l.ref=r?fm(r,a):a),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var K5=Symbol("radix.slottable");function G5(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===K5}function Y5(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function X5(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.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)}var Q5=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Sn=Q5.reduce((e,t)=>{const n=W5(`Primitive.${t}`),r=m.forwardRef((o,i)=>{const{asChild:a,...l}=o,u=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function J5(e,t){e&&jo.flushSync(()=>e.dispatchEvent(t))}function ba(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Z5(e,t=globalThis==null?void 0:globalThis.document){const n=ba(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var eF="DismissableLayer",Rb="dismissableLayer.update",tF="dismissableLayer.pointerDownOutside",nF="dismissableLayer.focusOutside",L1,aT=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),iw=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:a,onDismiss:l,...u}=e,f=m.useContext(aT),[p,h]=m.useState(null),g=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=m.useState({}),k=nr(t,R=>h(R)),v=Array.from(f.layers),[b]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),j=v.indexOf(b),N=p?v.indexOf(p):-1,S=f.layersWithOutsidePointerEventsDisabled.size>0,C=N>=j,D=oF(R=>{const $=R.target,P=[...f.branches].some(F=>F.contains($));!C||P||(o==null||o(R),a==null||a(R),R.defaultPrevented||l==null||l())},g),T=iF(R=>{const $=R.target;[...f.branches].some(F=>F.contains($))||(i==null||i(R),a==null||a(R),R.defaultPrevented||l==null||l())},g);return Z5(R=>{N===f.layers.size-1&&(r==null||r(R),!R.defaultPrevented&&l&&(R.preventDefault(),l()))},g),m.useEffect(()=>{if(p)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(L1=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),M1(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=L1)}},[p,g,n,f]),m.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),M1())},[p,f]),m.useEffect(()=>{const R=()=>y({});return document.addEventListener(Rb,R),()=>document.removeEventListener(Rb,R)},[]),s.jsx(Sn.div,{...u,ref:k,style:{pointerEvents:S?C?"auto":"none":void 0,...e.style},onFocusCapture:sn(e.onFocusCapture,T.onFocusCapture),onBlurCapture:sn(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:sn(e.onPointerDownCapture,D.onPointerDownCapture)})});iw.displayName=eF;var rF="DismissableLayerBranch",sF=m.forwardRef((e,t)=>{const n=m.useContext(aT),r=m.useRef(null),o=nr(t,r);return m.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(Sn.div,{...e,ref:o})});sF.displayName=rF;function oF(e,t=globalThis==null?void 0:globalThis.document){const n=ba(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let u=function(){lT(tF,n,f,{discrete:!0})};const f={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function iF(e,t=globalThis==null?void 0:globalThis.document){const n=ba(e),r=m.useRef(!1);return m.useEffect(()=>{const o=i=>{i.target&&!r.current&&lT(nF,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function M1(){const e=new CustomEvent(Rb);document.dispatchEvent(e)}function lT(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?J5(o,i):o.dispatchEvent(i)}var ry="focusScope.autoFocusOnMount",sy="focusScope.autoFocusOnUnmount",O1={bubbles:!1,cancelable:!0},aF="FocusScope",cT=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...a}=e,[l,u]=m.useState(null),f=ba(o),p=ba(i),h=m.useRef(null),g=nr(t,v=>u(v)),y=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(S){if(y.paused||!l)return;const C=S.target;l.contains(C)?h.current=C:mi(h.current,{select:!0})},b=function(S){if(y.paused||!l)return;const C=S.relatedTarget;C!==null&&(l.contains(C)||mi(h.current,{select:!0}))},j=function(S){if(document.activeElement===document.body)for(const D of S)D.removedNodes.length>0&&mi(l)};document.addEventListener("focusin",v),document.addEventListener("focusout",b);const N=new MutationObserver(j);return l&&N.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",b),N.disconnect()}}},[r,l,y.paused]),m.useEffect(()=>{if(l){z1.add(y);const v=document.activeElement;if(!l.contains(v)){const j=new CustomEvent(ry,O1);l.addEventListener(ry,f),l.dispatchEvent(j),j.defaultPrevented||(lF(pF(uT(l)),{select:!0}),document.activeElement===v&&mi(l))}return()=>{l.removeEventListener(ry,f),setTimeout(()=>{const j=new CustomEvent(sy,O1);l.addEventListener(sy,p),l.dispatchEvent(j),j.defaultPrevented||mi(v??document.body,{select:!0}),l.removeEventListener(sy,p),z1.remove(y)},0)}}},[l,f,p,y]);const k=m.useCallback(v=>{if(!n&&!r||y.paused)return;const b=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,j=document.activeElement;if(b&&j){const N=v.currentTarget,[S,C]=cF(N);S&&C?!v.shiftKey&&j===C?(v.preventDefault(),n&&mi(S,{select:!0})):v.shiftKey&&j===S&&(v.preventDefault(),n&&mi(C,{select:!0})):j===N&&v.preventDefault()}},[n,r,y.paused]);return s.jsx(Sn.div,{tabIndex:-1,...a,ref:g,onKeyDown:k})});cT.displayName=aF;function lF(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(mi(r,{select:t}),document.activeElement!==n)return}function cF(e){const t=uT(e),n=F1(t,e),r=F1(t.reverse(),e);return[n,r]}function uT(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function F1(e,t){for(const n of e)if(!uF(n,{upTo:t}))return n}function uF(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function dF(e){return e instanceof HTMLInputElement&&"select"in e}function mi(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&dF(e)&&t&&e.select()}}var z1=fF();function fF(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=B1(e,t),e.unshift(t)},remove(t){var n;e=B1(e,t),(n=e[0])==null||n.resume()}}}function B1(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function pF(e){return e.filter(t=>t.tagName!=="A")}var hF="Portal",aw=m.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[o,i]=m.useState(!1);wi(()=>i(!0),[]);const a=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return a?HM.createPortal(s.jsx(Sn.div,{...r,ref:t}),a):null});aw.displayName=hF;function mF(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Ra=e=>{const{present:t,children:n}=e,r=gF(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),i=nr(r.ref,xF(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:i}):null};Ra.displayName="Presence";function gF(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),i=m.useRef("none"),a=e?"mounted":"unmounted",[l,u]=mF(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const f=rp(r.current);i.current=l==="mounted"?f:"none"},[l]),wi(()=>{const f=r.current,p=o.current;if(p!==e){const g=i.current,y=rp(f);e?u("MOUNT"):y==="none"||(f==null?void 0:f.display)==="none"?u("UNMOUNT"):u(p&&g!==y?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),wi(()=>{if(t){let f;const p=t.ownerDocument.defaultView??window,h=y=>{const v=rp(r.current).includes(CSS.escape(y.animationName));if(y.target===t&&v&&(u("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",f=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},g=y=>{y.target===t&&(i.current=rp(r.current))};return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{p.clearTimeout(f),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:m.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function rp(e){return(e==null?void 0:e.animationName)||"none"}function xF(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.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)}var oy=0;function yF(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??U1()),document.body.insertAdjacentElement("beforeend",e[1]??U1()),oy++,()=>{oy===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),oy--}},[])}function U1(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var qs=function(){return qs=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},qs.apply(this,arguments)};function dT(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function bF(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var Op="right-scroll-bar-position",Fp="width-before-scroll-bar",vF="with-scroll-bars-hidden",wF="--removed-body-scroll-bar-size";function iy(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function jF(e,t){var n=m.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var kF=typeof window<"u"?m.useLayoutEffect:m.useEffect,H1=new WeakMap;function SF(e,t){var n=jF(null,function(r){return e.forEach(function(o){return iy(o,r)})});return kF(function(){var r=H1.get(n);if(r){var o=new Set(r),i=new Set(e),a=n.current;o.forEach(function(l){i.has(l)||iy(l,null)}),i.forEach(function(l){o.has(l)||iy(l,a)})}H1.set(n,e)},[e]),n}function NF(e){return e}function CF(e,t){t===void 0&&(t=NF);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var a=t(i,r);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(i){for(r=!0;n.length;){var a=n;n=[],a.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!0;var a=[];if(n.length){var l=n;n=[],l.forEach(i),a=n}var u=function(){var p=a;a=[],p.forEach(i)},f=function(){return Promise.resolve().then(u)};f(),n={push:function(p){a.push(p),f()},filter:function(p){return a=a.filter(p),n}}}};return o}function EF(e){e===void 0&&(e={});var t=CF(null);return t.options=qs({async:!0,ssr:!1},e),t}var fT=function(e){var t=e.sideCar,n=dT(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,qs({},n))};fT.isSideCarExport=!0;function TF(e,t){return e.useMedium(t),fT}var pT=EF(),ay=function(){},hm=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:ay,onWheelCapture:ay,onTouchMoveCapture:ay}),o=r[0],i=r[1],a=e.forwardProps,l=e.children,u=e.className,f=e.removeScrollBar,p=e.enabled,h=e.shards,g=e.sideCar,y=e.noRelative,k=e.noIsolation,v=e.inert,b=e.allowPinchZoom,j=e.as,N=j===void 0?"div":j,S=e.gapMode,C=dT(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=g,T=SF([n,t]),R=qs(qs({},C),o);return m.createElement(m.Fragment,null,p&&m.createElement(D,{sideCar:pT,removeScrollBar:f,shards:h,noRelative:y,noIsolation:k,inert:v,setCallbacks:i,allowPinchZoom:!!b,lockRef:n,gapMode:S}),a?m.cloneElement(m.Children.only(l),qs(qs({},R),{ref:T})):m.createElement(N,qs({},R,{className:u,ref:T}),l))});hm.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};hm.classNames={fullWidth:Fp,zeroRight:Op};var RF=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function AF(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=RF();return t&&e.setAttribute("nonce",t),e}function PF(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function _F(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var DF=function(){var e=0,t=null;return{add:function(n){e==0&&(t=AF())&&(PF(t,n),_F(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},$F=function(){var e=DF();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},hT=function(){var e=$F(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},IF={left:0,top:0,right:0,gap:0},ly=function(e){return parseInt(e||"",10)||0},LF=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[ly(n),ly(r),ly(o)]},MF=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return IF;var t=LF(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},OF=hT(),Ol="data-scroll-locked",FF=function(e,t,n,r){var o=e.left,i=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
552
- .`.concat(vF,` {
553
- overflow: hidden `).concat(r,`;
554
- padding-right: `).concat(l,"px ").concat(r,`;
555
- }
556
- body[`).concat(Ol,`] {
557
- overflow: hidden `).concat(r,`;
558
- overscroll-behavior: contain;
559
- `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
560
- padding-left: `.concat(o,`px;
561
- padding-top: `).concat(i,`px;
562
- padding-right: `).concat(a,`px;
563
- margin-left:0;
564
- margin-top:0;
565
- margin-right: `).concat(l,"px ").concat(r,`;
566
- `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
567
- }
568
-
569
- .`).concat(Op,` {
570
- right: `).concat(l,"px ").concat(r,`;
571
- }
572
-
573
- .`).concat(Fp,` {
574
- margin-right: `).concat(l,"px ").concat(r,`;
575
- }
576
-
577
- .`).concat(Op," .").concat(Op,` {
578
- right: 0 `).concat(r,`;
579
- }
580
-
581
- .`).concat(Fp," .").concat(Fp,` {
582
- margin-right: 0 `).concat(r,`;
583
- }
584
-
585
- body[`).concat(Ol,`] {
586
- `).concat(wF,": ").concat(l,`px;
587
- }
588
- `)},V1=function(){var e=parseInt(document.body.getAttribute(Ol)||"0",10);return isFinite(e)?e:0},zF=function(){m.useEffect(function(){return document.body.setAttribute(Ol,(V1()+1).toString()),function(){var e=V1()-1;e<=0?document.body.removeAttribute(Ol):document.body.setAttribute(Ol,e.toString())}},[])},BF=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;zF();var i=m.useMemo(function(){return MF(o)},[o]);return m.createElement(OF,{styles:FF(i,!t,o,n?"":"!important")})},Ab=!1;if(typeof window<"u")try{var sp=Object.defineProperty({},"passive",{get:function(){return Ab=!0,!0}});window.addEventListener("test",sp,sp),window.removeEventListener("test",sp,sp)}catch{Ab=!1}var ul=Ab?{passive:!1}:!1,UF=function(e){return e.tagName==="TEXTAREA"},mT=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!UF(e)&&n[t]==="visible")},HF=function(e){return mT(e,"overflowY")},VF=function(e){return mT(e,"overflowX")},W1=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=gT(e,r);if(o){var i=xT(e,r),a=i[1],l=i[2];if(a>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},WF=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},qF=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},gT=function(e,t){return e==="v"?HF(t):VF(t)},xT=function(e,t){return e==="v"?WF(t):qF(t)},KF=function(e,t){return e==="h"&&t==="rtl"?-1:1},GF=function(e,t,n,r,o){var i=KF(e,window.getComputedStyle(t).direction),a=i*r,l=n.target,u=t.contains(l),f=!1,p=a>0,h=0,g=0;do{if(!l)break;var y=xT(e,l),k=y[0],v=y[1],b=y[2],j=v-b-i*k;(k||j)&&gT(e,l)&&(h+=j,g+=k);var N=l.parentNode;l=N&&N.nodeType===Node.DOCUMENT_FRAGMENT_NODE?N.host:N}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(p&&Math.abs(h)<1||!p&&Math.abs(g)<1)&&(f=!0),f},op=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},q1=function(e){return[e.deltaX,e.deltaY]},K1=function(e){return e&&"current"in e?e.current:e},YF=function(e,t){return e[0]===t[0]&&e[1]===t[1]},XF=function(e){return`
589
- .block-interactivity-`.concat(e,` {pointer-events: none;}
590
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
591
- `)},QF=0,dl=[];function JF(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(QF++)[0],i=m.useState(hT)[0],a=m.useRef(e);m.useEffect(function(){a.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=bF([e.lockRef.current],(e.shards||[]).map(K1),!0).filter(Boolean);return v.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=m.useCallback(function(v,b){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!a.current.allowPinchZoom;var j=op(v),N=n.current,S="deltaX"in v?v.deltaX:N[0]-j[0],C="deltaY"in v?v.deltaY:N[1]-j[1],D,T=v.target,R=Math.abs(S)>Math.abs(C)?"h":"v";if("touches"in v&&R==="h"&&T.type==="range")return!1;var $=window.getSelection(),P=$&&$.anchorNode,F=P?P===T||P.contains(T):!1;if(F)return!1;var _=W1(R,T);if(!_)return!0;if(_?D=R:(D=R==="v"?"h":"v",_=W1(R,T)),!_)return!1;if(!r.current&&"changedTouches"in v&&(S||C)&&(r.current=D),!D)return!0;var V=r.current||D;return GF(V,b,v,V==="h"?S:C)},[]),u=m.useCallback(function(v){var b=v;if(!(!dl.length||dl[dl.length-1]!==i)){var j="deltaY"in b?q1(b):op(b),N=t.current.filter(function(D){return D.name===b.type&&(D.target===b.target||b.target===D.shadowParent)&&YF(D.delta,j)})[0];if(N&&N.should){b.cancelable&&b.preventDefault();return}if(!N){var S=(a.current.shards||[]).map(K1).filter(Boolean).filter(function(D){return D.contains(b.target)}),C=S.length>0?l(b,S[0]):!a.current.noIsolation;C&&b.cancelable&&b.preventDefault()}}},[]),f=m.useCallback(function(v,b,j,N){var S={name:v,delta:b,target:j,should:N,shadowParent:ZF(j)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(C){return C!==S})},1)},[]),p=m.useCallback(function(v){n.current=op(v),r.current=void 0},[]),h=m.useCallback(function(v){f(v.type,q1(v),v.target,l(v,e.lockRef.current))},[]),g=m.useCallback(function(v){f(v.type,op(v),v.target,l(v,e.lockRef.current))},[]);m.useEffect(function(){return dl.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,ul),document.addEventListener("touchmove",u,ul),document.addEventListener("touchstart",p,ul),function(){dl=dl.filter(function(v){return v!==i}),document.removeEventListener("wheel",u,ul),document.removeEventListener("touchmove",u,ul),document.removeEventListener("touchstart",p,ul)}},[]);var y=e.removeScrollBar,k=e.inert;return m.createElement(m.Fragment,null,k?m.createElement(i,{styles:XF(o)}):null,y?m.createElement(BF,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ZF(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const e6=TF(pT,JF);var yT=m.forwardRef(function(e,t){return m.createElement(hm,qs({},e,{ref:t,sideCar:e6}))});yT.classNames=hm.classNames;var t6=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},fl=new WeakMap,ip=new WeakMap,ap={},cy=0,bT=function(e){return e&&(e.host||bT(e.parentNode))},n6=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=bT(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},r6=function(e,t,n,r){var o=n6(t,Array.isArray(e)?e:[e]);ap[n]||(ap[n]=new WeakMap);var i=ap[n],a=[],l=new Set,u=new Set(o),f=function(h){!h||l.has(h)||(l.add(h),f(h.parentNode))};o.forEach(f);var p=function(h){!h||u.has(h)||Array.prototype.forEach.call(h.children,function(g){if(l.has(g))p(g);else try{var y=g.getAttribute(r),k=y!==null&&y!=="false",v=(fl.get(g)||0)+1,b=(i.get(g)||0)+1;fl.set(g,v),i.set(g,b),a.push(g),v===1&&k&&ip.set(g,!0),b===1&&g.setAttribute(n,"true"),k||g.setAttribute(r,"true")}catch(j){console.error("aria-hidden: cannot operate on ",g,j)}})};return p(t),l.clear(),cy++,function(){a.forEach(function(h){var g=fl.get(h)-1,y=i.get(h)-1;fl.set(h,g),i.set(h,y),g||(ip.has(h)||h.removeAttribute(r),ip.delete(h)),y||h.removeAttribute(n)}),cy--,cy||(fl=new WeakMap,fl=new WeakMap,ip=new WeakMap,ap={})}},s6=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=t6(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),r6(r,o,n,"aria-hidden")):function(){return null}};function o6(e){const t=i6(e),n=m.forwardRef((r,o)=>{const{children:i,...a}=r,l=m.Children.toArray(i),u=l.find(l6);if(u){const f=u.props.children,p=l.map(h=>h===u?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return s.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,p):null})}return s.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function i6(e){const t=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const a=u6(o),l=c6(i,o.props);return o.type!==m.Fragment&&(l.ref=r?fm(r,a):a),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var a6=Symbol("radix.slottable");function l6(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===a6}function c6(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function u6(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.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)}var mm="Dialog",[vT,wT]=Ta(mm),[d6,Rs]=vT(mm),jT=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:a=!0}=e,l=m.useRef(null),u=m.useRef(null),[f,p]=pm({prop:r,defaultProp:o??!1,onChange:i,caller:mm});return s.jsx(d6,{scope:t,triggerRef:l,contentRef:u,contentId:Ml(),titleId:Ml(),descriptionId:Ml(),open:f,onOpenChange:p,onOpenToggle:m.useCallback(()=>p(h=>!h),[p]),modal:a,children:n})};jT.displayName=mm;var kT="DialogTrigger",ST=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Rs(kT,n),i=nr(t,o.triggerRef);return s.jsx(Sn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":uw(o.open),...r,ref:i,onClick:sn(e.onClick,o.onOpenToggle)})});ST.displayName=kT;var lw="DialogPortal",[f6,NT]=vT(lw,{forceMount:void 0}),CT=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=Rs(lw,t);return s.jsx(f6,{scope:t,forceMount:n,children:m.Children.map(r,a=>s.jsx(Ra,{present:n||i.open,children:s.jsx(aw,{asChild:!0,container:o,children:a})}))})};CT.displayName=lw;var dh="DialogOverlay",ET=m.forwardRef((e,t)=>{const n=NT(dh,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Rs(dh,e.__scopeDialog);return i.modal?s.jsx(Ra,{present:r||i.open,children:s.jsx(h6,{...o,ref:t})}):null});ET.displayName=dh;var p6=o6("DialogOverlay.RemoveScroll"),h6=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Rs(dh,n);return s.jsx(yT,{as:p6,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(Sn.div,{"data-state":uw(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),va="DialogContent",TT=m.forwardRef((e,t)=>{const n=NT(va,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Rs(va,e.__scopeDialog);return s.jsx(Ra,{present:r||i.open,children:i.modal?s.jsx(m6,{...o,ref:t}):s.jsx(g6,{...o,ref:t})})});TT.displayName=va;var m6=m.forwardRef((e,t)=>{const n=Rs(va,e.__scopeDialog),r=m.useRef(null),o=nr(t,n.contentRef,r);return m.useEffect(()=>{const i=r.current;if(i)return s6(i)},[]),s.jsx(RT,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:sn(e.onCloseAutoFocus,i=>{var a;i.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:sn(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:sn(e.onFocusOutside,i=>i.preventDefault())})}),g6=m.forwardRef((e,t)=>{const n=Rs(va,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return s.jsx(RT,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var a,l;(a=e.onCloseAutoFocus)==null||a.call(e,i),i.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var u,f;(u=e.onInteractOutside)==null||u.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=i.target;((f=n.triggerRef.current)==null?void 0:f.contains(a))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),RT=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...a}=e,l=Rs(va,n),u=m.useRef(null),f=nr(t,u);return yF(),s.jsxs(s.Fragment,{children:[s.jsx(cT,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:s.jsx(iw,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":uw(l.open),...a,ref:f,onDismiss:()=>l.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(y6,{titleId:l.titleId}),s.jsx(v6,{contentRef:u,descriptionId:l.descriptionId})]})]})}),cw="DialogTitle",AT=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Rs(cw,n);return s.jsx(Sn.h2,{id:o.titleId,...r,ref:t})});AT.displayName=cw;var PT="DialogDescription",_T=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Rs(PT,n);return s.jsx(Sn.p,{id:o.descriptionId,...r,ref:t})});_T.displayName=PT;var DT="DialogClose",$T=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Rs(DT,n);return s.jsx(Sn.button,{type:"button",...r,ref:t,onClick:sn(e.onClick,()=>o.onOpenChange(!1))})});$T.displayName=DT;function uw(e){return e?"open":"closed"}var IT="DialogTitleWarning",[x6,LT]=O5(IT,{contentName:va,titleName:cw,docsSlug:"dialog"}),y6=({titleId:e})=>{const t=LT(IT),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
592
-
593
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
594
-
595
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},b6="DialogDescriptionWarning",v6=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${LT(b6).contentName}}.`;return m.useEffect(()=>{var i;const o=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},MT=jT,OT=ST,FT=CT,dw=ET,fw=TT,pw=AT,hw=_T,mw=$T;const Mn=MT,w6=OT,j6=FT,zT=mw,BT=m.forwardRef(({className:e,...t},n)=>s.jsx(dw,{ref:n,className:je("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",e),...t}));BT.displayName=dw.displayName;const Nn=m.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(j6,{children:[s.jsx(BT,{}),s.jsx(fw,{ref:r,className:je("chrome-card fixed left-1/2 top-1/2 z-50 grid w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 !p-6 outline-none",e),...n,children:t})]}));Nn.displayName=fw.displayName;function sr({className:e,...t}){return s.jsx("div",{className:je("flex flex-col space-y-2 text-left",e),...t})}function Wr({className:e,...t}){return s.jsx("div",{className:je("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}const Cn=m.forwardRef(({className:e,...t},n)=>s.jsx(pw,{ref:n,className:je("text-lg font-semibold tracking-tight text-foreground",e),...t}));Cn.displayName=pw.displayName;const ns=m.forwardRef(({className:e,...t},n)=>s.jsx(hw,{ref:n,className:je("text-sm leading-6 text-muted-foreground",e),...t}));ns.displayName=hw.displayName;const k6=-1,S6=-40;function uy(e,t){if(e.length===0)return 0;if(t.length===0)return-1/0;let n=0,r=0,o=-2,i=0;for(let a=0;a<e.length;a++){const l=e[a];let u=!1;for(;r<t.length;)if(t[r]===l){if(n+=100,r===o+1&&(n+=20),r===0)n+=30;else{const f=t[r-1];(f===" "||f==="-"||f==="_"||f==="/")&&(n+=15)}i>0&&(n+=Math.max(S6,i*k6)),o=r,i=0,r++,u=!0;break}else i++,r++;if(!u)return-1/0}return n}const G1={page:0,project:1,assignment:2,playbook:3,server:4,todo:5};function gw(e,t,n=50){const r=e.toLowerCase();if(!r)return t.slice(0,n).map(a=>({...a,score:0}));const i=t.map(a=>{var h;const l=uy(r,a.title.toLowerCase())*1,u=a.subtitle?uy(r,a.subtitle.toLowerCase())*.5:-1/0,f=(h=a.keywords)!=null&&h.length?uy(r,a.keywords.join(" ").toLowerCase())*.3:-1/0,p=Math.max(l,u,f);return{...a,score:p}}).filter(a=>a.score>-1/0);return i.sort((a,l)=>l.score!==a.score?l.score-a.score:a.title.length!==l.title.length?a.title.length-l.title.length:a.title!==l.title?a.title<l.title?-1:1:(G1[a.type]??99)-(G1[l.type]??99)),i.slice(0,n)}const N6={a:"assignment",p:"project",t:"todo",s:"server",pb:"playbook"},Y1=Symbol("absent");function lp(e){return e.replace(/\s+/g," ").trim()}const X1=new Set(["IDENT","STRING","NUMBER","DATE","DURATION"]);function C6(e){const t=e.externalIds;return Array.isArray(t)?t.map(n=>n&&typeof n=="object"?`${n.system}:${n.id}`:"").join(" "):""}function E6(e){const t=e.externalIds;return Array.isArray(t)?t.filter(n=>{const r=n==null?void 0:n.system;return typeof r=="string"&&r.toLowerCase()==="jira"}).map(n=>String(n.id)).join(" "):""}const ed={kind:{kind:"enum",get:e=>e.type},status:{kind:"enum"},tag:{kind:"list",get:e=>e.tags},tags:{kind:"list"},assignee:{kind:"string",noneSentinel:!0,get:e=>"assignee"in e?e.assignee:Y1},type:{kind:"enum",get:e=>e.assignmentType},project:{kind:"string",noneSentinel:!0,get:e=>"project"in e?e.project:Y1},externalid:{kind:"substring",get:C6},jira:{kind:"substring",get:E6},title:{kind:"substring"},search:{kind:"substring",get:e=>e.searchText??e.title}};function T6(e,t=N6,n){const r=(n==null?void 0:n.defaultScope)??"all",o=e.match(/^\s*all:\s*/i),i=o!==null,a=i?e.slice(o[0].length):e,l=A6(a,t),u={aqlExpr:l.aqlExpr,fuzzy:l.fuzzy};if(r!=="all"&&!i&&e.trim()!==""&&!R6(l.aqlExpr)){const f=`kind:${r}`;u.aqlExpr=l.aqlExpr?l.explicit?`${f} (${l.aqlExpr})`:`${f} ${l.aqlExpr}`:f}return u}function R6(e){if(!e)return!1;let t;try{t=um(e)}catch{return!1}for(let n=0;n<t.length-1;n++)if(t[n].type==="IDENT"&&t[n].text.toLowerCase()==="kind"&&t[n+1].type==="COLON")return!0;return!1}function A6(e,t){let n;try{n=um(e)}catch(h){if(h instanceof oa)return{aqlExpr:"",fuzzy:lp(e),explicit:!1};throw h}const r=n.length,o=(h,g)=>e.slice(n[h].pos,g<r?n[g].pos:e.length);let i=!1;for(let h=0;h<r;h++){const g=n[h];if(g.type==="OR"||g.type==="LPAREN"&&(h===0||n[h-1].type!=="COLON")){i=!0;break}}if(i){const h=lp(D6(e,n,r,t));return Jl(h,ed).query?{aqlExpr:h,fuzzy:"",explicit:!0}:{aqlExpr:"",fuzzy:lp(e),explicit:!0}}const a=[],l=[];let u=0,f=0;const p=h=>{if(h>f){const g=lp(o(f,h));g&&l.push(g)}};for(;u<r-1;){const h=P6(n,u,t);if(h){p(u),a.push(h.atom),u=h.end,f=u;continue}const g=_6(n,u,r);if(g!==null){const y=o(u,g).trim();if(Jl(y,ed).query){p(u),a.push(y),u=g,f=u;continue}u=g;continue}u++}return p(r-1),{aqlExpr:a.join(" "),fuzzy:l.join(" "),explicit:!1}}function P6(e,t,n){var l;let r=t,o="";e[r].type==="MINUS"?(o="-",r++):e[r].type==="NOT"&&(o="NOT ",r++);const i=e[r];if(!i||i.type!=="IDENT")return null;const a=n[i.text.toLowerCase()];return!a||((l=e[r+1])==null?void 0:l.type)!=="COLON"?null:{atom:`${o}kind:${a}`,end:r+2}}function _6(e,t,n){let r=t;(e[r].type==="MINUS"||e[r].type==="NOT")&&r++;const o=e[r];if(!o||o.type!=="IDENT"||!Object.prototype.hasOwnProperty.call(ed,o.text.toLowerCase()))return null;const i=e[r+1];if(!i)return null;if(i.type==="COLON"){const a=e[r+2];if(!a)return null;if(a.type==="LPAREN"){let l=0;for(let u=r+2;u<n;u++)if(e[u].type==="LPAREN")l++;else if(e[u].type==="RPAREN"){if(l--,l===0)return u+1}else if(e[u].type==="EOF")return null;return null}return X1.has(a.type)?r+3:null}if(i.type==="OP"){const a=e[r+2];return a&&X1.has(a.type)?r+3:null}return null}function D6(e,t,n,r){var a;let o="",i=0;for(let l=0;l<n;l++){const u=t[l];u.type==="IDENT"&&Object.prototype.hasOwnProperty.call(r,u.text.toLowerCase())&&((a=t[l+1])==null?void 0:a.type)==="COLON"&&(o+=e.slice(i,u.pos)+`kind:${r[u.text.toLowerCase()]} `,i=t[l+1].pos+1)}return o+=e.slice(i),o}const xw=["kanban","list","table"],UT=["title","status","priority","assignee","dependencies","created","updated"],$6=["asc","desc"],I6=["comfortable","compact"],L6=["none","status","type","priority","assignee","project"],M6=["last_24h","last_7d","last_30d","last_90d","older_7d","older_30d"];function Ve(e){const t=e===void 0?[]:Array.isArray(e)?e:[e],n=[];for(const r of t){if(typeof r!="string")continue;const o=r.trim();!o||o==="all"||n.includes(o)||n.push(o)}return n}function O6(e,t){const n=Ve(e),r=Ve(t);return n.length===r.length&&n.every(o=>r.includes(o))}const F6={defaultView:"kanban",sortField:"updated",sortDirection:"desc",density:"comfortable",grouping:"none",filters:{status:"all",type:"all",priority:"all",assignee:"all",project:"all",activity:"all"}},td={version:1,global:F6,projects:{}};function dy(e){return e==="table"?"table":"kanban"}function z6(e,t){return t?{...e,...t}:{...e}}function HT(e,t){const n=e.global;if(t===null)return n;const r=e.projects[t];return r?{defaultView:r.defaultView??n.defaultView,sortField:r.sortField??n.sortField,sortDirection:r.sortDirection??n.sortDirection,density:n.density,grouping:r.grouping??n.grouping,filters:z6(n.filters,r.filters)}:n}const B6=/^[A-Za-z_][A-Za-z0-9_-]*$/,U6=new Set(["and","or","not"]);function yw(e){return B6.test(e)&&!U6.has(e.toLowerCase())?e:VT(e)}function VT(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}const WT="__unassigned__",qT="__standalone__",H6={last_24h:"24h",last_7d:"7d",last_30d:"30d",last_90d:"90d",older_7d:"7d",older_30d:"30d"};function V6(e){return e.startsWith("older_")?"<":">="}const bw=["status","type","priority","assignee","project","tags"],W6=["created","updated"];function q6(e){var i;const t={};for(const a of bw){const l=Ve(e[a]);l.length&&(t[a]=l)}const n=(i=e.search)==null?void 0:i.trim();n&&(t.search=n);let r=e.activity&&e.activity!=="all"?e.activity:void 0;const o=e.dateRange;if(o){const a=K6(o);if(a)r||(r=a);else{const l=G6(o);l&&(t.dateRange=l)}}return r&&(t.activity=r),t}function K6(e){return e.field!=="updated"||!e.preset?null:e.preset==="older_7d"?"stale":e.preset==="last_7d"?"fresh":null}function G6(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 r={field:e.field};return t&&(r.from=t),n&&(r.to=n),r}function Ou(e){const t=q6(e),n=[];for(const r of bw){const o=t[r]??[];o.length&&n.push(Y6(r,o))}return t.search&&n.push(`search:${VT(t.search)}`),t.activity==="stale"?n.push("updated < -7d"):t.activity==="fresh"&&n.push("updated >= -7d"),t.dateRange&&n.push(...Q6(t.dateRange)),n.join(" AND ")}function Y6(e,t){const n=t.map(r=>X6(e,r));return n.length===1?`${e}:${n[0]}`:`${e}:(${n.join(", ")})`}function X6(e,t){return e==="assignee"&&t===WT||e==="project"&&t===qT?"none":yw(t)}function Q6(e){if(e.preset)return[`${e.field} ${V6(e.preset)} -${H6[e.preset]}`];const t=[];return e.from&&t.push(`${e.field} >= ${e.from}`),e.to&&t.push(`${e.field} <= ${e.to}`),t}function Fu(e){const t=dm(e);if(!t.ast)return null;const n=J6(t.ast);if(n===null)return null;const r={},o=new Set,i=new Map;for(const a of n){const l=Z6(a);if(!l)return null;switch(l.kind){case"value":{if(o.has(l.field))return null;o.add(l.field),r[l.field]=l.values;break}case"search":{if(o.has("search"))return null;o.add("search"),r.search=l.text;break}case"activity":{if(o.has("activity"))return null;o.add("activity"),r.activity=l.activity;break}case"datePreset":{const u=`date:${l.field}`;if(o.has(u)||i.has(l.field))return null;o.add(u),r.dateRange={field:l.field,preset:l.preset};break}case"dateBound":{const u=`date:${l.field}`;if(o.has(u))return null;const f=i.get(l.field)??{};if(l.bound==="from"){if(f.from!==void 0)return null;f.from=l.date}else{if(f.to!==void 0)return null;f.to=l.date}i.set(l.field,f);break}}}if(i.size>1)return null;for(const[a,l]of i){if(r.dateRange)return null;const u={field:a};l.from!==void 0&&(u.from=l.from),l.to!==void 0&&(u.to=l.to),r.dateRange=u}return r}function J6(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 Z6(e){const t=e.field.toLowerCase();if(e.op===":"){if(bw.includes(t)){const o=t,i=[];for(const a of e.values){const l=sz(o,a);if(l===null)return null;i.push(l)}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(!W6.includes(t))return null;const n=t;if(e.values.length!==1)return null;const r=e.values[0];return r.type==="duration"?ez(n,e.op,r):r.type==="date"?e.op===">="?{kind:"dateBound",field:n,bound:"from",date:r.raw}:e.op==="<="?{kind:"dateBound",field:n,bound:"to",date:r.raw}:null:null}function ez(e,t,n){if(n.sign!==-1)return null;const r=tz(n.raw);if(e==="updated"){if(t==="<"&&r==="7d")return{kind:"activity",activity:"stale"};if(t===">="&&r==="7d")return{kind:"activity",activity:"fresh"}}const o=rz(t,r);return o?{kind:"datePreset",field:e,preset:o}:null}function tz(e){return e.replace(/^[-+]/,"")}const nz={">=":{"24h":"last_24h","7d":"last_7d","30d":"last_30d","90d":"last_90d"},"<":{"7d":"older_7d","30d":"older_30d"}};function rz(e,t){return e!==">="&&e!=="<"?null:nz[e][t]??null}function sz(e,t){const n=t.raw;return e==="assignee"&&n.toLowerCase()==="none"?WT:e==="project"&&n.toLowerCase()==="none"?qT:n}const oz=new Set(["status","type","tag","assignee","externalid"]),fy=new Set(["IDENT","STRING","NUMBER","DATE","DURATION","STAR"]),Q1=8;function iz(e,t,n){var k,v,b,j,N;let r;try{r=um(e)}catch{return[]}const o=r.length,i=S=>{const C=S+1<o?r[S+1].pos:e.length;return r[S].pos+e.slice(r[S].pos,C).replace(/\s+$/,"").length};let a=-1;for(let S=0;S<o-1;S++)if(t>r[S].pos&&t<=i(S)){a=S;break}let l=a>=0?a-1:-1;if(a<0)for(let S=0;S<o-1&&i(S)<=t;S++)l=S;let u=null,f=null,p="";if(a>=0&&r[a].type==="COLON"&&((k=r[a-1])==null?void 0:k.type)==="IDENT"?(u=r[a-1].text.toLowerCase(),f=[t,t]):a>=0&&fy.has(r[a].type)&&((v=r[a-1])==null?void 0:v.type)==="COLON"&&((b=r[a-2])==null?void 0:b.type)==="IDENT"?(u=r[a-2].text.toLowerCase(),f=[r[a].pos,i(a)],p=r[a].text):a<0&&l>=0&&r[l].type==="COLON"&&((j=r[l-1])==null?void 0:j.type)==="IDENT"&&(u=r[l-1].text.toLowerCase(),f=[t,t]),u!==null){if(!oz.has(u))return[];const S=n.values[u]??[],C=p.toLowerCase(),D=[];for(const T of S)if(!(C&&!T.toLowerCase().startsWith(C))&&T.toLowerCase()!==C&&(D.push({label:T,insert:yw(T),replace:f,kind:"value"}),D.length>=Q1))break;return D}if(a>=0&&!fy.has(r[a].type))return[];if(a>=0&&r[a].type==="IDENT"&&((N=r[a+1])==null?void 0:N.type)==="COLON")return[];if(l>=0){const S=r[l].type;if(!(S==="AND"||S==="OR"||S==="NOT"||S==="MINUS"||S==="LPAREN"||S==="RPAREN"||fy.has(S)))return[]}const h=(a>=0?r[a].text:"").toLowerCase(),g=a>=0?[r[a].pos,i(a)]:[t,t],y=[];for(const[S,C]of Object.entries(n.aliases))h&&!S.toLowerCase().startsWith(h)||y.push({label:`${S}: (${C})`,insert:`${S}:`,replace:g,kind:"prefix"});for(const S of n.fields)h&&!S.toLowerCase().startsWith(h)||y.push({label:`${S}:`,insert:`${S}:`,replace:g,kind:"field"});return y.slice(0,Q1)}const az=200,lz=2;function cz(e,t){const[n,r]=m.useState(e),[o,i]=m.useState([]),[a,l]=m.useState(!1),[u,f]=m.useState(null),p=m.useRef(null);m.useEffect(()=>{const y=setTimeout(()=>r(e),az);return()=>clearTimeout(y)},[e]);const h=n.trim(),g=t&&h.length>=lz;return m.useEffect(()=>{if(!g){p.current=null,i([]),l(!1),f(null);return}const y=new AbortController;p.current=h,l(!0),f(null);const k=()=>p.current===h&&!y.signal.aborted;return fetch(`/api/search?q=${encodeURIComponent(h)}`,{signal:y.signal}).then(async v=>{if(!v.ok){const b=await v.json().catch(()=>null);throw new Error((b==null?void 0:b.error)||`HTTP ${v.status}`)}return v.json()}).then(v=>{k()&&(i(v.hits??[]),l(!1))}).catch(v=>{v.name!=="AbortError"&&k()&&(f(v.message),i([]),l(!1))}),()=>{y.abort()}},[g,h]),{hits:o,loading:a,error:u}}const zp={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 uz(e,t,n=()=>null){const r=[],o=new Set(t.statuses.map(l=>l.id));e.phaseLadder.length===0&&r.push("phaseLadder must have at least one rung");for(const l of e.phaseLadder){o.has(l.phase)||r.push(`phaseLadder rung "${l.phase}" is not a defined status id`);const u=l.when==="*"?null:n(l.when);u&&r.push(`phaseLadder rung "${l.phase}": invalid condition — ${u}`)}const i=new Set(["active","blocked","parked"]);for(const l of e.disposition)if(i.has(l.is)||r.push(`disposition "${l.is}" is not valid (expected active, blocked, or parked — terminal is never a rule)`),l.when!==null){const u=n(l.when);u&&r.push(`disposition rule "${l.is}": invalid condition — ${u}`)}const a=e.disposition.map((l,u)=>l.when===null?u:-1).filter(l=>l>=0);a.length===0?r.push("disposition rules must end with an `else:` arm (a rule with when: null)"):a.length>1?r.push("disposition rules must have exactly one `else:` arm (when: null)"):a[0]!==e.disposition.length-1&&r.push("the `else:` arm (when: null) must be the LAST disposition rule — rules after it are unreachable");for(const l of["parked","blocked"])o.has(e.headline[l])||r.push(`headline.${l} → "${e.headline[l]}" is not a defined status id (add the definition or run migrate-derive)`);return r}const KT={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:zp,deriveCustom:!1,knownCommands:[],factDeclarations:[],rawFacts:[]};let zu=null,Zi=null;function dz(){return zu?Promise.resolve(zu):Zi||(Zi=fetch("/api/config/statuses").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(zu=e,Zi=null,e)).catch(()=>(Zi=null,KT)),Zi)}function As(){const[e,t]=m.useState(()=>zu??KT);return m.useEffect(()=>{dz().then(t)},[]),e}function J1(){zu=null,Zi=null}function Co(e,t){const n=e.statuses.find(r=>r.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}const GT={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 Bp=null,pl=null;function fz(){return Bp?Promise.resolve(Bp):pl||(pl=fetch("/api/config/types").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>(Bp=e,pl=null,e)).catch(()=>(pl=null,GT)),pl)}function $d(){const[e,t]=m.useState(()=>Bp??GT);return m.useEffect(()=>{fz().then(t)},[]),e}function Fl(e,t){if(!t)return"—";const n=e.definitions.find(r=>r.id===t);return(n==null?void 0:n.label)??t.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function pz(e,t){return t?e.definitions.find(n=>n.id===t)??null:null}const hz={page:"Page",project:"Project",assignment:"Assignment",playbook:"Playbook",server:"Server",todo:"Todo",content:"Content"};function mz(e,t){const n=e.map(o=>({start:Math.max(0,Math.min(o.start,t)),end:Math.max(0,Math.min(o.end,t))})).filter(o=>o.end>o.start).sort((o,i)=>o.start-i.start||o.end-i.end),r=[];for(const o of n){const i=r[r.length-1];i&&o.start<=i.end?i.end=Math.max(i.end,o.end):r.push({...o})}return r}function gz(e,t){if(!t||t.length===0)return e;const n=mz(t,e.length);if(n.length===0)return e;const r=[];let o=0;return n.forEach((i,a)=>{i.start>o&&r.push(s.jsx(m.Fragment,{children:e.slice(o,i.start)},`t${a}`)),r.push(s.jsx("mark",{className:"rounded bg-yellow-200/70 px-0.5 text-foreground dark:bg-yellow-500/30",children:e.slice(i.start,i.end)},`m${a}`)),o=i.end}),o<e.length&&r.push(s.jsx(m.Fragment,{children:e.slice(o)},"tail")),r}function xz({entries:e}){const{paletteOpen:t,closePalette:n}=Ri(),r=Wt(),[o,i]=m.useState(""),[a,l]=m.useState(0),[u,f]=m.useState(0),[p,h]=m.useState(!0),[g,y]=m.useState(0),k=m.useRef(null),v=m.useRef(null),b=m.useId(),{search:j}=ow(),N=As(),S=$d(),{aqlExpr:C,fuzzy:D}=m.useMemo(()=>T6(o,j.aliases,{defaultScope:j.defaultScope}),[o,j.aliases,j.defaultScope]),T=m.useMemo(()=>{const O=new Set,H=new Set,L=new Set;for(const Y of e){for(const q of Y.tags??[])O.add(q);Y.assignee&&H.add(Y.assignee);for(const q of Y.externalIds??[])q.id&&(L.add(q.id),q.system&&L.add(`${q.system}:${q.id}`))}const z=Object.keys(ed);return{aliases:j.aliases,fields:j.externalIds?z:z.filter(Y=>Y!=="jira"&&Y!=="externalid"),values:{status:N.statuses.map(Y=>Y.id),type:S.definitions.map(Y=>Y.id),tag:[...O],assignee:[...H],externalid:j.externalIds?[...L]:[]}}},[e,j.aliases,j.externalIds,N.statuses,S.definitions]),R=m.useMemo(()=>iz(o,u,T),[o,u,T]),$=p&&R.length>0&&o.trim()!=="",P=m.useMemo(()=>{let O=e,H=D;if(C){const L=Jl(C,ed);if(L.query){const z=Date.now(),{predicate:Y}=L.query;O=e.filter(q=>Y(q,{now:z}))}else H=o}return gw(H,O,50)},[e,C,D,o]),{hits:F}=cz(o,t),_=m.useMemo(()=>j5(F),[F]),V=m.useMemo(()=>[...P,..._],[P,_]);m.useEffect(()=>{l(0)},[o,t]),m.useEffect(()=>{y(0)},[R]),m.useEffect(()=>{t||(i(""),f(0),h(!0))},[t]),m.useEffect(()=>{var H;const O=(H=k.current)==null?void 0:H.querySelector(`[data-palette-idx="${a}"]`);O==null||O.scrollIntoView({block:"nearest"})},[a]);function U(O){r(O.route),n()}function I(O,H){const L=H===a,z=O.type==="content";return s.jsxs("button",{type:"button","data-palette-idx":H,onClick:()=>U(O),onMouseEnter:()=>l(H),className:`flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors ${L?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:hz[O.type]??O.type}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate",children:O.title}),z&&O.snippet?s.jsx("span",{className:"truncate text-xs text-muted-foreground",children:gz(O.snippet,O.snippetMatches)}):null]}),O.subtitle?s.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:O.subtitle}):null]},O.id)}function M(O){const H=o.slice(0,O.replace[0])+O.insert+o.slice(O.replace[1]),L=O.replace[0]+O.insert.length;i(H),f(L),requestAnimationFrame(()=>{const z=v.current;z&&(z.focus(),z.setSelectionRange(L,L))})}function B(O){if($){if(O.key==="Tab"||O.key==="ArrowRight"&&u>=o.length){O.preventDefault();const H=R[g];H&&M(H);return}if(O.key==="ArrowDown"){O.preventDefault(),y(H=>Math.min(R.length-1,H+1));return}if(O.key==="ArrowUp"){O.preventDefault(),y(H=>Math.max(0,H-1));return}if(O.key==="Enter"){O.preventDefault();const H=V[a];H&&U(H);return}return}if(O.key==="ArrowDown")O.preventDefault(),l(H=>Math.min(V.length-1,H+1));else if(O.key==="ArrowUp")O.preventDefault(),l(H=>Math.max(0,H-1));else if(O.key==="Enter"){O.preventDefault();const H=V[a];H&&U(H)}}const W=$&&R[g]?`${b}-option-${g}`:void 0;return s.jsx(Mn,{open:t,onOpenChange:O=>O?null:n(),children:s.jsxs(Nn,{className:"max-w-xl p-0 gap-0",onEscapeKeyDown:O=>{$&&(O.preventDefault(),h(!1))},children:[s.jsx(Cn,{className:"sr-only",children:"Command palette"}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:v,autoFocus:!0,type:"text",role:"combobox","aria-expanded":$,"aria-controls":$?b:void 0,"aria-activedescendant":W,"aria-autocomplete":"list",value:o,onChange:O=>{i(O.target.value),f(O.target.selectionStart??O.target.value.length),h(!0)},onSelect:O=>f(O.currentTarget.selectionStart??0),onKeyDown:B,placeholder:"Search… try a: p: jira:PROJ-123 tag:backend",className:"w-full rounded-t-xl border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary"}),$?s.jsx("div",{role:"listbox",id:b,"aria-label":"Query suggestions",className:"absolute left-0 right-0 top-full z-50 max-h-64 overflow-y-auto border-b border-border/70 bg-background shadow-lg",children:R.map((O,H)=>{const L=H===g;return s.jsxs("button",{id:`${b}-option-${H}`,role:"option","aria-selected":L,type:"button",onMouseDown:z=>{z.preventDefault(),M(O)},onMouseEnter:()=>y(H),className:`flex w-full items-center justify-between gap-3 px-4 py-1.5 text-left text-sm ${L?"bg-accent text-accent-foreground":"text-foreground"}`,children:[s.jsx("code",{className:"truncate",children:O.label}),s.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground",children:O.kind})]},`${O.kind}-${O.insert}-${H}`)})}):null]}),C?s.jsxs("div",{className:"border-b border-border/70 px-4 py-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"Filtering"})," ",s.jsx("code",{className:"text-foreground",children:C}),D?s.jsxs("span",{children:[" · ranking “",D,"”"]}):null]}):o.trim()===""?s.jsxs("div",{className:"border-b border-border/70 px-4 py-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"Prefixes"})," ",Object.keys(j.aliases).map(O=>s.jsxs("code",{className:"mr-1",children:[O,":"]},O))," · ",s.jsx("code",{children:"status:"})," ",s.jsx("code",{children:"tag:"})," ",s.jsx("code",{children:"assignee:"})," ",s.jsx("code",{children:"type:"})," ",j.externalIds?s.jsx("code",{children:"jira:"}):null]}):null,s.jsx("div",{ref:k,className:"max-h-[60vh] overflow-y-auto p-1",children:V.length===0?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:"No matches"}):s.jsxs(s.Fragment,{children:[P.map((O,H)=>I(O,H)),_.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"Content"}),_.map((O,H)=>I(O,P.length+H))]}):null]})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:$?"⇥/→ accept · ↑↓ suggestions · Esc close":"↑↓ navigate · ↵ open · Esc close"}),s.jsxs("span",{children:[V.length," result",V.length===1?"":"s"]})]})]})})}function yz({label:e,onBack:t,disabled:n,stepCounter:r}){return s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-3 py-2",children:[s.jsxs("button",{type:"button",onClick:t,disabled:n,className:"inline-flex h-7 items-center gap-1 rounded border border-border/70 bg-background/60 px-2 text-[11px] text-muted-foreground transition-colors hover:bg-accent/40 hover:text-foreground disabled:opacity-50","aria-label":"Back",children:[s.jsx(XM,{className:"h-3.5 w-3.5","aria-hidden":"true"}),s.jsx("span",{children:"Back"})]}),s.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),r?s.jsxs("span",{className:"ml-auto text-[10px] text-muted-foreground/80",children:["step ",r.current," of ",r.total]}):null]})}function bz({step:e,initialValue:t,disabled:n,onSubmit:r}){const[o,i]=m.useState(t??""),[a,l]=m.useState(!1),u=m.useRef(null);m.useEffect(()=>{var k;(k=u.current)==null||k.focus()},[]);const f=o.trim(),p=e.required!==!1,h=e.pattern&&f.length>0&&!e.pattern.regex.test(f),g=!n&&(!p||f.length>0)&&!h;function y(k){if(k.key==="Enter"){if(k.preventDefault(),!g){l(!0);return}r(f)}}return s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:u,type:"text",value:o,onChange:k=>{i(k.target.value),l(!1)},onKeyDown:y,placeholder:e.placeholder,disabled:n,className:"w-full border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),a&&e.pattern&&h?s.jsx("div",{className:"border-b border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:e.pattern.message}):null]})}function vz({step:e,disabled:t,onSubmit:n}){const[r,o]=m.useState({phase:"loading"}),[i,a]=m.useState(""),[l,u]=m.useState(0),[f,p]=m.useState(0),h=m.useRef(null),g=m.useRef(null);m.useEffect(()=>{var v;(v=h.current)==null||v.focus()},[]),m.useEffect(()=>{let v=!1;return o({phase:"loading"}),Promise.resolve().then(()=>e.loadOptions()).then(b=>{v||o({phase:"loaded",options:b})}).catch(b=>{if(v)return;const j=b instanceof Error?b.message:"Failed to load options";o({phase:"error",message:j})}),()=>{v=!0}},[e,f]);const y=m.useMemo(()=>{if(r.phase!=="loaded")return[];const v=r.options.map(b=>({type:"option",title:b.label,subtitle:b.hint,keywords:[b.value],option:b}));return gw(i,v,100)},[r,i]);m.useEffect(()=>{u(0)},[y.length]),m.useEffect(()=>{var b;const v=(b=g.current)==null?void 0:b.querySelector(`[data-picker-idx="${l}"]`);v==null||v.scrollIntoView({block:"nearest"})},[l]);function k(v){if(r.phase==="loaded"){if(v.key==="ArrowDown")v.preventDefault(),u(b=>Math.min(y.length-1,b+1));else if(v.key==="ArrowUp")v.preventDefault(),u(b=>Math.max(0,b-1));else if(v.key==="Enter"){v.preventDefault();const b=y[l];b&&n(b.option.value)}}}return s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:h,type:"text",value:i,onChange:v=>a(v.target.value),onKeyDown:k,placeholder:`Filter ${e.label.toLowerCase()}…`,disabled:t||r.phase==="loading",className:"w-full border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),s.jsx("div",{ref:g,className:"max-h-[60vh] min-h-[120px] overflow-y-auto p-1",children:r.phase==="loading"?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:"Loading…"}):r.phase==="error"?s.jsxs("div",{className:"px-4 py-4 text-sm",children:[s.jsxs("div",{className:"mb-2 text-destructive",children:["Failed to load: ",r.message]}),s.jsx("button",{type:"button",onClick:()=>p(v=>v+1),className:"rounded border border-border/70 bg-background/60 px-2 py-1 text-xs text-foreground hover:bg-accent/40",children:"Retry"})]}):y.length===0?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:r.options.length===0?e.emptyMessage??"No options available":"No matches"}):y.map((v,b)=>{const j=b===l;return s.jsxs("button",{type:"button","data-picker-idx":b,onClick:()=>n(v.option.value),onMouseEnter:()=>u(b),disabled:t,className:`flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors disabled:opacity-60 ${j?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:v.option.label}),v.option.hint?s.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:v.option.hint}):null]},v.option.value)})})]})}function wz({entries:e}){var Q,ee;const t=Wt(),{actionsPaletteOpen:n,closeActionsPalette:r,customBindings:o,bindAction:i,findConflict:a,pendingActionKind:l,consumePendingActionKind:u}=Ri(),[f,p]=m.useState(""),[h,g]=m.useState(0),[y,k]=m.useState(null),[v,b]=m.useState(""),[j,N]=m.useState(null),[S,C]=m.useState(null),[D,T]=m.useState(!1),[R,$]=m.useState(null),P=m.useRef(null),F=m.useMemo(()=>e.map(Z=>({type:Z.group.toLowerCase(),title:Z.title,subtitle:Z.subtitle,keywords:Z.keywords,action:Z})),[e]),_=m.useMemo(()=>gw(f,F,50),[f,F]);m.useEffect(()=>{g(0)},[f,n]),m.useEffect(()=>{n||(p(""),k(null),b(""),N(null),C(null),T(!1),$(null))},[n]),m.useEffect(()=>{if(!n||!l)return;const Z=u();if(!Z)return;const ie=e.find(ne=>ne.bindableKind===Z);ie&&V(ie)},[n,l]),m.useEffect(()=>{var ie;const Z=(ie=P.current)==null?void 0:ie.querySelector(`[data-palette-idx="${h}"]`);Z==null||Z.scrollIntoView({block:"nearest"})},[h]);async function V(Z){if(!D){if(Z.flow&&Z.flow.steps.length>0){N({action:Z,stepIndex:0,values:{}}),$(null);return}if(Z.requiresInput){k(Z),b(""),$(null);return}if(Z.run){T(!0),$(null);try{await Z.run(),r()}catch(ie){$(ie instanceof Error?ie.message:"Action failed")}finally{T(!1)}}}}async function U(Z){if(!j)return;const ie=j.action.flow.steps[j.stepIndex],ne={...j.values,[ie.id]:Z};if(j.stepIndex+1<j.action.flow.steps.length){N({action:j.action,stepIndex:j.stepIndex+1,values:ne});return}T(!0),$(null);try{await j.action.flow.submit(ne,{navigate:t}),r()}catch(ue){$(ue instanceof Error?ue.message:"Action failed")}finally{T(!1)}}function I(){if(j&&!D){if(j.stepIndex===0){N(null),$(null);return}N({action:j.action,stepIndex:j.stepIndex-1,values:j.values}),$(null)}}async function M(){if(D||!(y!=null&&y.requiresInput))return;const Z=v.trim();if(Z){T(!0),$(null);try{await y.requiresInput.runWithInput(Z),r()}catch(ie){$(ie instanceof Error?ie.message:"Action failed")}finally{T(!1)}}}function B(Z){if(Z.key==="ArrowDown")Z.preventDefault(),g(ie=>Math.min(_.length-1,ie+1));else if(Z.key==="ArrowUp")Z.preventDefault(),g(ie=>Math.max(0,ie-1));else if(Z.key==="Enter"&&(Z.metaKey||Z.ctrlKey)){Z.preventDefault();const ie=_[h];ie!=null&&ie.action.bindableKind&&C({action:ie.action,combo:null,conflict:null,saving:!1,error:null})}else if(Z.key==="Enter"){Z.preventDefault();const ie=_[h];ie&&V(ie.action)}}function W(Z){Z.key==="Enter"?(Z.preventDefault(),M()):Z.key==="Escape"&&(Z.preventDefault(),k(null),b(""))}function O(Z){if(!S||Z.key==="Escape"||Z.key==="Enter"&&!S.combo)return;if(Z.key==="Enter"&&S.combo){Z.preventDefault(),Z.stopPropagation(),H();return}Z.preventDefault(),Z.stopPropagation();const ie=K2(Z.nativeEvent);if(!ie)return;const ne=a(ie,S.action.bindableKind);C({...S,combo:ie,conflict:ne,error:null})}async function H(){var Z;if(!(!S||!S.combo||!S.action.bindableKind)){if((Z=S.conflict)!=null&&Z.description){C({...S,error:`Reserved: ${S.conflict.description}`});return}C({...S,saving:!0,error:null});try{await i(S.action.bindableKind,S.combo),C(null)}catch(ie){C({...S,saving:!1,error:ie instanceof Error?ie.message:"Failed to save binding"})}}}const L=y!==null,z=j!==null,Y=S!==null,q=j?j.action.flow.steps[j.stepIndex]:null;return s.jsx(Mn,{open:n,onOpenChange:Z=>Z?null:r(),children:s.jsxs(Nn,{className:"max-w-xl p-0 gap-0",onEscapeKeyDown:Z=>{if(!D){if(Y){Z.preventDefault(),C(null);return}if(z){Z.preventDefault(),I();return}L&&(Z.preventDefault(),k(null),b(""),$(null))}},children:[s.jsx(Cn,{className:"sr-only",children:"Actions palette"}),Y&&S?s.jsxs("div",{onKeyDown:O,tabIndex:-1,autoFocus:!0,children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-4 py-3",children:[s.jsx(vb,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),s.jsxs("span",{className:"text-sm text-foreground",children:["Bind hotkey for ",S.action.title]})]}),s.jsx("div",{className:"px-4 py-6 text-center",children:S.combo?s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"text-2xl font-semibold tracking-wide text-foreground",children:Qs(S.combo)}),(Q=S.conflict)!=null&&Q.description?s.jsxs("div",{className:"text-sm text-destructive",children:["Reserved: ",S.conflict.description," (cannot bind)"]}):(ee=S.conflict)!=null&&ee.kind?s.jsxs("div",{className:"text-sm text-amber-500 dark:text-amber-400",children:['Already bound to "',S.conflict.kind,'". Press Enter to overwrite.']}):s.jsx("div",{className:"text-sm text-muted-foreground",children:"Press Enter to save, or another key to retry."}),S.error?s.jsx("div",{className:"text-sm text-destructive",children:S.error}):null]}):s.jsx("div",{className:"text-sm text-muted-foreground",children:"Press the key combination you want to bind…"})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"any key records · Enter saves · Esc cancels"}),s.jsx("span",{children:S.saving?"Saving…":""})]}),s.jsx("button",{type:"button",className:"sr-only",onClick:()=>void H(),"data-bind-confirm":!0}),s.jsx("input",{type:"hidden",onKeyDown:Z=>{Z.key==="Enter"&&H()}})]}):z&&q&&j?s.jsxs(s.Fragment,{children:[s.jsx(yz,{label:`${j.action.title} · ${q.label}`,onBack:I,disabled:D,stepCounter:{current:j.stepIndex+1,total:j.action.flow.steps.length}}),q.kind==="text"?s.jsx(bz,{step:q,initialValue:j.values[q.id],disabled:D,onSubmit:U}):s.jsx(vz,{step:q,disabled:D,onSubmit:U}),R?s.jsx("div",{className:"border-t border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:R}):null,s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"↵ next · ← back · Esc back"}),s.jsx("span",{children:D?"Running…":""})]})]}):L?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/70 px-4 py-3",children:[s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:y.group}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:y.title})]}),s.jsx("input",{autoFocus:!0,type:"text",value:v,onChange:Z=>b(Z.target.value),onKeyDown:W,placeholder:y.requiresInput.placeholder,disabled:D,className:"w-full border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),R?s.jsx("div",{className:"border-b border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:R}):null,s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsxs("span",{children:["↵"," submit ","·"," Esc back"]}),s.jsx("span",{children:D?"Running…":""})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("input",{autoFocus:!0,type:"text",value:f,onChange:Z=>p(Z.target.value),onKeyDown:B,placeholder:"Run an action: new project, new todo, toggle…",disabled:D,className:"w-full rounded-t-xl border-0 border-b border-border/70 bg-transparent px-4 py-3 text-sm text-foreground outline-none focus:border-primary disabled:opacity-60"}),R?s.jsx("div",{className:"border-b border-border/70 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:R}):null,s.jsx("div",{ref:P,className:"max-h-[60vh] overflow-y-auto p-1",children:_.length===0?s.jsx("div",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:f?"No matches":"Start typing to search actions"}):_.map((Z,ie)=>{const ne=ie===h,ue=Z.action.bindableKind,ge=ue?o[ue]:void 0;return s.jsxs("button",{type:"button","data-palette-idx":ie,onClick:()=>V(Z.action),onMouseEnter:()=>g(ie),disabled:D,className:`group flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-sm transition-colors disabled:opacity-60 ${ne?"bg-accent text-accent-foreground":"hover:bg-accent/50 text-foreground"}`,children:[s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:Z.action.group}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:Z.action.title}),Z.action.subtitle?s.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:Z.action.subtitle}):null,ge?s.jsx("span",{className:"shrink-0 rounded border border-border/70 bg-background/60 px-1.5 py-0.5 text-[10px] font-medium tracking-wide text-foreground",children:Qs(ge)}):null,ue?s.jsx("span",{role:"button",tabIndex:-1,"aria-label":"Bind hotkey",onClick:Ne=>{Ne.preventDefault(),Ne.stopPropagation(),C({action:Z.action,combo:null,conflict:null,saving:!1,error:null})},className:`shrink-0 inline-flex h-6 w-6 items-center justify-center rounded border border-border/70 bg-background/60 text-muted-foreground transition-opacity hover:text-foreground ${ne?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:s.jsx(vb,{className:"h-3.5 w-3.5","aria-hidden":"true"})}):null]},Z.action.id)})}),s.jsxs("div",{className:"flex items-center justify-between border-t border-border/70 px-3 py-2 text-[11px] text-muted-foreground",children:[s.jsxs("span",{children:["↑↓"," navigate ","·"," ","↵"," run ","·"," ⌘↵ bind ","·"," Esc close"]}),s.jsx("span",{children:D?"Running…":`${_.length} action${_.length===1?"":"s"}`})]})]})]})})}const jz=[{combo:"mod+k",description:"Open command palette",scope:"global"},{combo:"mod+shift+k",description:"Open actions palette",scope:"global"},{combo:"?",description:"Show keyboard shortcuts",scope:"global"},{combo:"escape",description:"Close dialog or cancel",scope:"global"},{combo:"enter",description:"Activate selected item",scope:"global"},{combo:"shift+t",description:"Toggle light/dark theme",scope:"global"},{combo:"g",description:"Start navigation chord",scope:"global"},{combo:"g o",description:"Go to Overview",scope:"global"},{combo:"g m",description:"Go to Projects",scope:"global"},{combo:"g a",description:"Go to Assignments",scope:"global"},{combo:"g t",description:"Go to Todos",scope:"global"},{combo:"g s",description:"Go to Servers",scope:"global"},{combo:"g !",description:"Go to Attention",scope:"global"},{combo:"g ,",description:"Go to Settings",scope:"global"},{combo:"j",description:"Move selection down",scope:"list"},{combo:"k",description:"Move selection up",scope:"list"},{combo:"o",description:"Open selected item",scope:"list"},{combo:"a",description:"New assignment in project",scope:"project"},{combo:"e",description:"Edit project / assignment",scope:"project|assignment"},{combo:"/",description:"Focus search",scope:"assignments-board"},{combo:"r",description:"Refresh board",scope:"assignments-board"},{combo:"p",description:"Edit plan",scope:"assignment"},{combo:"h",description:"Append handoff",scope:"assignment"},{combo:"d",description:"Append decision record",scope:"assignment"},{combo:"s",description:"Edit scratchpad",scope:"assignment"},{combo:"[",description:"Previous assignment",scope:"assignment"},{combo:"]",description:"Next assignment",scope:"assignment"}];function kz(e){const t=wr(e);return t?jz.find(n=>n.combo===t)??null:null}const gu={"new-workspace":"New Workspace","new-project":"New Project","new-todo":"New Todo","new-assignment":"New Assignment"},Sz={global:"Global","list:overview":"Overview","list:projects":"Projects list","list:assignments":"Assignments list","list:todos":"Todos list",assignment:"Assignment detail",project:"Project detail"},Nz=["global","list:overview","list:projects","list:assignments","list:todos","project","assignment"];function Z1(e){if(e.includes(" ")){const[t,n]=e.split(" ");return`${Qs(t)} then ${Qs(n)}`}return Qs(e)}function Cz(){const{cheatsheetOpen:e,closeCheatsheet:t,listBindings:n,customBindings:r,actionEntries:o}=Ri(),i=m.useMemo(()=>{const u=new Set;for(const f of Object.values(r))typeof f=="string"&&f&&u.add(wr(f));return u},[r]),a=m.useMemo(()=>{if(!e)return new Map;const u=n(),f=new Map;for(const p of u){if(i.has(wr(p.keys)))continue;const h=f.get(p.scope)??[];h.push({keys:p.keys,description:p.description}),f.set(p.scope,h)}return f},[e,n,i]),l=m.useMemo(()=>{const u=[];for(const[f,p]of Object.entries(r)){if(!p)continue;const h=o.find(g=>g.bindableKind===f);u.push({kind:f,combo:p,title:h?h.title:f})}return u},[r,o]);return s.jsx(Mn,{open:e,onOpenChange:u=>u?null:t(),children:s.jsxs(Nn,{className:"max-w-2xl",children:[s.jsx(Cn,{children:"Keyboard shortcuts"}),s.jsxs(ns,{children:["Press Esc to close. ",Qs("Mod+k")," opens the command palette. Press g twice to restart the chord timer."]}),s.jsxs("div",{className:"mt-2 max-h-[60vh] space-y-4 overflow-y-auto pr-1",children:[Nz.map(u=>{const f=a.get(u);return!f||f.length===0?null:s.jsxs("section",{children:[s.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:Sz[u]}),s.jsx("ul",{className:"space-y-1",children:f.map((p,h)=>s.jsxs("li",{className:"flex items-center justify-between gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-1.5 text-sm",children:[s.jsx("span",{className:"text-foreground",children:p.description}),s.jsx("kbd",{className:"shrink-0 rounded border border-border/70 bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:Z1(p.keys)})]},`${u}-${p.keys}-${h}`))})]},u)}),l.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Custom bindings"}),s.jsx("ul",{className:"space-y-1",children:l.map(u=>s.jsxs("li",{className:"flex items-center justify-between gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-1.5 text-sm",children:[s.jsx("span",{className:"text-foreground",children:u.title}),s.jsx("kbd",{className:"shrink-0 rounded border border-border/70 bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:Z1(u.combo)})]},`custom-${u.kind}`))})]}):null]})]})})}const vw={bindings:{},custom:!1};let Bu=null,hl=null;const Pb=new Set;function YT(e){Bu=e;for(const t of Pb)t(e)}function ww(e){if(!e||typeof e!="object")return vw;const t=e,n={};if(t.bindings&&typeof t.bindings=="object"&&!Array.isArray(t.bindings))for(const[r,o]of Object.entries(t.bindings)){if(!J4(r)||typeof o!="string"||o.trim()==="")continue;const i=wr(o);i&&(n[r]=i)}return{bindings:n,custom:t.custom===!0}}function Ez(){return Bu?Promise.resolve(Bu):hl||(hl=fetch("/api/config/hotkeys").then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}).then(e=>{const t=ww(e);return Bu=t,hl=null,t}).catch(()=>(hl=null,vw)),hl)}function Tz(){const[e,t]=m.useState(()=>Bu??vw);return m.useEffect(()=>{let n=!1;return Ez().then(r=>{n||t(r)}),Pb.add(t),()=>{n=!0,Pb.delete(t)}},[]),e}async function eS(e){const t={};for(const o of am){const i=e[o];if(typeof i!="string")continue;const a=wr(i);a&&(t[o]=a)}const n=await fetch("/api/config/hotkeys",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({bindings:t})});if(!n.ok){const o=await n.json().catch(()=>({error:`HTTP ${n.status}`}));throw new Error(o.error??"Failed to save hotkey bindings")}const r=ww(await n.json());return YT(r),r}async function Rz(){const e=await fetch("/api/config/hotkeys",{method:"DELETE"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=ww(await e.json());return YT(t),t}const tS=1500;function Az(e){const t=e.match(/^\/w\/([^/]+)(?:\/|$)/);return t?`/w/${t[1]}`:""}const XT=m.createContext(null);function Pz({children:e}){const{toggleTheme:t}=Qv(),n=rr(),r=Wt(),o=Az(n.pathname),[i,a]=m.useState(!1),l=to(i),u=om(i),f=Zv(i),p=Jv(i),h=G2(i),{search:g}=ow(),y=m.useMemo(()=>{var ot,Nt,mt,at;const ve=l.data??[],be=((ot=u.data)==null?void 0:ot.assignments)??[],Re=((Nt=f.data)==null?void 0:Nt.playbooks)??[],He=((mt=p.data)==null?void 0:mt.sessions)??[],Fe=(((at=h.data)==null?void 0:at.workspaces)??[]).flatMap(ce=>ce.items.map(me=>({...me,workspace:ce.workspace})));return v5({projects:ve,assignments:be,playbooks:Re,servers:He,todos:Fe,wsPrefix:o,externalIds:g.externalIds})},[l.data,u.data,f.data,p.data,h.data,o,g.externalIds]),v=m.useMemo(()=>R2(n.pathname),[n.pathname]).projectSlug,b=m.useMemo(()=>{var ve;return v?((ve=l.data)==null?void 0:ve.find(be=>be.slug===v))??null:null},[l.data,v]),j=(b==null?void 0:b.title)??null,N=(b==null?void 0:b.workspace)??null,S=m.useMemo(()=>{var ve;return N5({playbooks:((ve=f.data)==null?void 0:ve.playbooks)??[],projectSlug:v,currentProjectTitle:j,currentProjectWorkspace:N,wsPrefix:o,refetchPlaybooks:f.refetch,navigate:r,toggleTheme:t})},[f.data,f.refetch,v,j,N,o,r,t]),C=m.useRef(new Map),D=m.useRef(["global"]),T=m.useRef({phase:"idle"}),R=m.useRef(null),$=m.useRef(1),[P,F]=m.useState(!1),[_,V]=m.useState(!1),[U,I]=m.useState(!1),[M,B]=m.useState(null);m.useEffect(()=>{(P||U)&&a(!0)},[P,U]);const{bindings:W}=Tz(),O=m.useMemo(()=>r5(W),[W]),H=m.useCallback(ve=>{const be=$.current++;return C.current.set(be,{...ve,id:be}),be},[]),L=m.useCallback(ve=>{C.current.delete(ve)},[]),z=m.useCallback(ve=>{D.current.push(ve)},[]),Y=m.useCallback(ve=>{const be=D.current;for(let Re=be.length-1;Re>=0;Re--)if(be[Re]===ve){be.splice(Re,1);return}},[]),q=m.useCallback(()=>F(!0),[]),Q=m.useCallback(()=>F(!1),[]),ee=m.useCallback(()=>V(!0),[]),Z=m.useCallback(()=>V(!1),[]),ie=m.useCallback(()=>I(!0),[]),ne=m.useCallback(()=>{I(!1),B(null)},[]),ue=m.useCallback(()=>Array.from(C.current.values()),[]),ge=m.useCallback(()=>{let ve=null;return B(be=>(ve=be,null)),ve},[]),Ne=m.useCallback(ve=>{B(ve),I(!0)},[]),Ce=m.useCallback((ve,be)=>{const Re=wr(ve);if(!Re)return null;if(t5(Re)){const He=kz(Re);return{description:(He==null?void 0:He.description)??"Reserved built-in shortcut"}}for(const[He,rt]of Object.entries(O))if(!(be&&He===be)&&rt===Re)return{kind:He};return null},[O]),ke=m.useCallback(async(ve,be)=>{const Re=wr(be);if(!Re)throw new Error("Empty combo");const He=Ce(Re,ve);if(He){const Fe=He.description?`Reserved: ${He.description}`:`Already bound to "${He.kind}"`;throw new Error(Fe)}const rt={...W,[ve]:Re};return await eS(rt),Re},[W,Ce]),Ue=m.useCallback(async ve=>{if(!W[ve])return;const be={...W};delete be[ve],await eS(be)},[W]);m.useEffect(()=>{T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null)},[n.pathname]),m.useEffect(()=>{function ve(Fe){if(!(Fe instanceof HTMLElement))return!1;const ot=Fe.tagName;return!!(ot==="INPUT"||ot==="TEXTAREA"||ot==="SELECT"||Fe.isContentEditable||Fe.closest('[role="combobox"], [role="textbox"]'))}function be(){return!!(document.querySelector('[role="dialog"][data-state="open"]')||document.querySelector('[role="alertdialog"][data-state="open"]'))}function Re(){const Fe=D.current;return Fe[Fe.length-1]??"global"}function He(Fe){return Fe.scope==="global"?!0:Fe.scope===Re()}function rt(Fe){const ot=np(Fe,"Mod+k"),Nt=np(Fe,"Mod+Shift+k"),mt=Fe.key==="Escape",at=ot||Nt||mt;if(be()&&!at||ve(Fe.target)&&!at)return;const ce=T.current;if(ce.phase==="awaiting-second")if(Date.now()-ce.startedAt>tS)T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null);else{const Ae=Array.from(C.current.values());for(const We of Ae){if(!He(We))continue;const pt=We.keys.split(" ");if(!(pt.length!==2||pt[0]!=="g")&&np(Fe,pt[1])&&!(We.when&&!We.when())){Fe.preventDefault(),T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null),We.handler(Fe);return}}T.current={phase:"idle"},R.current!==null&&(window.clearTimeout(R.current),R.current=null)}const me=Array.from(C.current.values());for(const Ie of me){if(!He(Ie))continue;const Ae=Ie.keys.split(" ");if(Ae.length===1&&np(Fe,Ae[0])&&!(Ie.when&&!Ie.when())){Fe.preventDefault(),Ie.handler(Fe);return}}Fe.key==="g"&&!Fe.metaKey&&!Fe.ctrlKey&&!Fe.altKey&&!Fe.shiftKey&&Array.from(C.current.values()).some(Ae=>He(Ae)&&Ae.keys.startsWith("g "))&&(Fe.preventDefault(),T.current={phase:"awaiting-second",startedAt:Date.now()},R.current!==null&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{T.current={phase:"idle"},R.current=null},tS))}return window.addEventListener("keydown",rt),()=>{window.removeEventListener("keydown",rt),R.current!==null&&(window.clearTimeout(R.current),R.current=null)}},[]),m.useEffect(()=>{const ve=H({keys:"Shift+t",handler:()=>t(),scope:"global",description:"Toggle light/dark theme"});return()=>L(ve)},[H,L,t]),m.useEffect(()=>{const ve=H({keys:"?",scope:"global",description:"Show keyboard shortcuts",handler:()=>ee()});return()=>L(ve)},[H,L,ee]),m.useEffect(()=>{const ve=H({keys:"Mod+k",scope:"global",description:"Open command palette",handler:()=>{if(P){Q();return}document.querySelector('[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]')||q()}});return()=>L(ve)},[H,L,q,Q,P]),m.useEffect(()=>{const ve=H({keys:"Mod+Shift+k",scope:"global",description:"Open actions palette",handler:()=>{if(U){ne();return}document.querySelector('[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]')||ie()}});return()=>L(ve)},[H,L,ie,ne,U]),m.useEffect(()=>{const be=[{suffix:"o",basePath:"/",desc:"Go to Overview"},{suffix:"m",basePath:"/projects",desc:"Go to Projects"},{suffix:"a",basePath:"/assignments",desc:"Go to Assignments"},{suffix:"t",basePath:"/todos",desc:"Go to Todos"},{suffix:"s",basePath:"/servers",desc:"Go to Servers"},{suffix:",",basePath:"/settings",desc:"Go to Settings"}].map(Re=>H({keys:`g ${Re.suffix}`,scope:"global",description:Re.desc,handler:()=>r(Ip(Re.basePath,o))}));return()=>be.forEach(L)},[H,L,r,o]),m.useEffect(()=>{const ve=[];for(const[be,Re]of Object.entries(O)){if(!Re)continue;const He=S.find(Fe=>Fe.bindableKind===be),rt=He?`Custom: ${He.title}`:`Custom: ${be}`;ve.push(H({keys:Re,scope:"global",description:rt,handler:()=>{B(be),I(!0)}}))}return()=>ve.forEach(L)},[H,L,O,S]);const oe=m.useMemo(()=>({register:H,unregister:L,pushScope:z,popScope:Y,openPalette:q,closePalette:Q,paletteOpen:P,openCheatsheet:ee,closeCheatsheet:Z,cheatsheetOpen:_,openActionsPalette:ie,closeActionsPalette:ne,actionsPaletteOpen:U,listBindings:ue,wsPrefix:o,paletteEntries:y,actionEntries:S,userBindings:W,customBindings:O,bindAction:ke,unbindAction:Ue,findConflict:Ce,openActionsPaletteWithAction:Ne,pendingActionKind:M,consumePendingActionKind:ge}),[H,L,z,Y,q,Q,P,ee,Z,_,ie,ne,U,ue,o,y,S,W,O,ke,Ue,Ce,Ne,M,ge]);return s.jsxs(XT.Provider,{value:oe,children:[e,s.jsx(xz,{entries:y}),s.jsx(wz,{entries:S}),s.jsx(Cz,{})]})}function Ri(){const e=m.useContext(XT);if(!e)throw new Error("useHotkeyContext must be used within HotkeyProvider");return e}function en({keys:e,handler:t,scope:n="global",description:r,when:o,enabled:i=!0}){const{register:a,unregister:l}=Ri(),u=m.useRef(t),f=m.useRef(o);m.useEffect(()=>{u.current=t,f.current=o},[t,o]),m.useEffect(()=>{if(!i)return;const p=a({keys:e,handler:h=>u.current(h),scope:n,description:r,when:f.current?()=>f.current():void 0});return()=>l(p)},[a,l,e,n,r,i])}function Ai(e){const{pushScope:t,popScope:n}=Ri();m.useEffect(()=>(t(e),()=>n(e)),[t,n,e])}function Id(e,t){const[n,r]=m.useState(e.length===0?-1:0),o=rr();m.useEffect(()=>{r(e.length===0?-1:0)},[o.pathname]),m.useEffect(()=>{r(a=>e.length===0?-1:Math.min(Math.max(0,a),e.length-1))},[e.length]),m.useEffect(()=>{if(document.querySelectorAll("[data-hotkey-row-index]").forEach(l=>{const u=Number(l.getAttribute("data-hotkey-row-index"));l.setAttribute("data-hotkey-selected",u===n?"true":"false")}),n>=0){const l=document.querySelector(`[data-hotkey-row-index="${n}"]`);l==null||l.scrollIntoView({block:"nearest"})}},[n,e.length]),en({keys:"j",scope:t.scope,description:"Select next row",handler:()=>r(a=>e.length===0?-1:Math.min(e.length-1,a<0?0:a+1))}),en({keys:"k",scope:t.scope,description:"Select previous row",handler:()=>r(a=>e.length===0?-1:Math.max(0,a<0?0:a-1))}),en({keys:"Enter",scope:t.scope,description:"Open selected row",handler:()=>{n>=0&&n<e.length&&t.onOpen(e[n],n)}}),en({keys:"o",scope:t.scope,description:"Open selected row",enabled:t.bindO??!0,handler:()=>{n>=0&&n<e.length&&t.onOpen(e[n],n)}});const i=m.useCallback(a=>({"data-hotkey-row-index":a,"data-hotkey-selected":a===n?"true":"false"}),[n]);return{selectedIndex:n,hotkeyRowProps:i}}function _z(){return m.useSyncExternalStore(C4,A1,A1)}function Dz(e){switch(e){case"reconnecting":return{show:!0,label:"Reconnecting…",tone:"amber"};case"closed":return{show:!0,label:"Offline",tone:"amber"};case"connecting":return{show:!0,label:"Connecting…",tone:"muted"};case"open":return{show:!1,label:"Live",tone:"muted"}}}function $z(){const e=_z(),t=Dz(e);return s.jsx("div",{role:"status","aria-live":"polite",className:"flex items-center",children:t.show?s.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium ${t.tone==="amber"?"border-warning-foreground/30 bg-warning text-warning-foreground":"border-border/70 bg-background/80 text-muted-foreground"}`,children:[s.jsx("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${t.tone==="amber"?"bg-warning-foreground animate-pulse":"bg-muted-foreground/60"}`}),t.label]}):s.jsx("span",{className:"sr-only"})})}function Iz({title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:r}){const o=mn(),{resolvedTheme:i,toggleTheme:a}=Qv(),{openPalette:l}=Ri();return s.jsx("header",{className:"sticky top-0 z-30 border-b border-border/70 bg-background/70 backdrop-blur",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-4 py-2.5 lg:px-6",children:[s.jsx("button",{type:"button",onClick:r,className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-border/70 bg-card/80 text-foreground lg:hidden","aria-label":"Open navigation",children:s.jsx(jO,{className:"h-4 w-4"})}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[t.length>1?s.jsxs("nav",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-[0.1em] text-muted-foreground",children:[t.slice(0,-1).map((u,f)=>s.jsxs("span",{className:"flex items-center gap-1.5",children:[f>0?s.jsx("span",{children:"/"}):null,s.jsx(De,{to:u.path,className:"hover:text-foreground",children:u.label})]},u.path)),s.jsx("span",{children:"/"})]}):null,s.jsx("h1",{className:"min-w-0 truncate text-base font-semibold text-foreground",children:e})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($z,{}),s.jsxs("button",{type:"button",onClick:l,className:"shell-action","aria-label":"Open command palette",children:[s.jsx(Ci,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline font-mono text-xs",children:Qs("Mod+k")})]}),s.jsx(De,{className:"shell-action hidden sm:inline-flex",to:"/help",children:"Help"}),s.jsxs(De,{className:"shell-action",to:`${o}/create/project`,"aria-label":"New Project",children:[s.jsx(Mt,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:"New Project"})]}),n?s.jsxs(De,{className:"shell-action",to:`${o}/projects/${n}/create/assignment`,"aria-label":"New Assignment",children:[s.jsx(Mt,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:"New Assignment"})]}):null,s.jsxs("button",{type:"button",onClick:a,className:"shell-action","aria-label":"Toggle theme",children:[i==="dark"?s.jsx($O,{className:"h-4 w-4"}):s.jsx(kO,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:i==="dark"?"Light":"Dark"})]})]})]})})}const Lz=4e3;function Qn(){const[e,t]=m.useState(null),n=m.useRef(null),r=m.useCallback(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null),t(null)},[]),o=m.useCallback((i,a="error")=>{n.current!==null&&clearTimeout(n.current),t({id:Date.now()+Math.random(),message:i,kind:a}),n.current=setTimeout(()=>{t(null),n.current=null},Lz)},[]);return m.useEffect(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),{toast:e,showToast:o,dismissToast:r}}function Xn({toast:e,onDismiss:t}){if(!e)return null;const n=e.kind==="error";return s.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex max-w-sm",role:"status","aria-live":"polite",children:s.jsx("button",{type:"button",onClick:t,className:je("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)})}const nS={review:0,blocked:0,question:0,"plan-approval":0};function QT(){const[e,t]=m.useState([]),[n,r]=m.useState(nS),[o,i]=m.useState(0),[a,l]=m.useState(!0),[u,f]=m.useState(null),[p,h]=m.useState(0),g=m.useCallback(()=>{h(y=>y+1)},[]);return m.useEffect(()=>{let y=!1;return l(!0),f(null),fetch("/api/inbox").then(async k=>{if(!k.ok){const v=await k.json().catch(()=>null);throw new Error((v==null?void 0:v.error)||`HTTP ${k.status}`)}return k.json()}).then(k=>{y||(t(Array.isArray(k.items)?k.items:[]),r(k.counts??nS),i(typeof k.total=="number"?k.total:0),l(!1))}).catch(k=>{y||(f(k.message),l(!1))}),()=>{y=!0}},[p]),Ei(y=>{(y.type==="assignment-updated"||y.type==="project-updated")&&g()}),{items:e,counts:n,total:o,loading:a,error:u,refetch:g}}const JT="syntaur.sidebar.collapsed.v1";function ZT(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function Mz(e){if(!e)return{};try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}catch{return{}}}function Oz(e,t){return{...e,[t]:!(e[t]??!1)}}function Fz(){const e=ZT();if(!e)return{};try{return Mz(e.getItem(JT))}catch{return{}}}let Up=Fz();const _b=new Set,zz={};function Bz(e){const t=ZT();if(t)try{t.setItem(JT,JSON.stringify(e))}catch{}}function Uz(e){return _b.add(e),()=>{_b.delete(e)}}function Hz(){return Up}function Vz(){return zz}function Wz(e){Up=Oz(Up,e),Bz(Up);for(const t of _b)t()}function qz(){const e=m.useSyncExternalStore(Uz,Hz,Vz);return{isCollapsed:(n,r=!1)=>e[n]??r,toggle:Wz}}const fh="_ungrouped",Kz=256;function Gz(e){if(!Array.isArray(e))return[];const t=new Set,n=[];for(const r of e){if(typeof r!="string")continue;const o=r.trim();o.length!==0&&(o.length>Kz||/[\r\n]/.test(o)||t.has(o)||(t.add(o),n.push(o)))}return n}function Yz(e,t){if(t.length===0)return[...e];const n=new Set(t);return e.filter(r=>!n.has(r))}function Xz(e,t){return t.includes(e)}const jw={hidden:[],custom:!1};let ko=null,ea=null,nd=0;const Db=new Set;function eR(e){ko=e;for(const t of Db)t(e)}function kw(e){if(!e||typeof e!="object")return jw;const t=e;return{hidden:Gz(t.hidden),custom:t.custom===!0}}function Qz(){if(ko)return Promise.resolve({value:ko,ok:!0});if(ea)return ea;const e=++nd;return ea=fetch("/api/config/workspace-visibility").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{ea=null;const n=kw(t);return e!==nd?{value:ko??n,ok:!0}:(ko=n,{value:n,ok:!0})}).catch(()=>(ea=null,{value:jw,ok:!1})),ea}function tR(){const[e,t]=m.useState(()=>ko??jw),[n,r]=m.useState(()=>ko===null),[o,i]=m.useState(!1),[a,l]=m.useState(0);m.useEffect(()=>{let f=!1;return r(ko===null),Qz().then(p=>{f||(t(p.value),r(!1),i(!p.ok))}),Db.add(t),()=>{f=!0,Db.delete(t)}},[a]);function u(){Jz(),l(f=>f+1)}return{...e,loading:n,error:o,reload:u}}function Jz(){ko=null,ea=null,++nd}async function Zz(e){++nd;const t=await fetch("/api/config/workspace-visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hidden:e})});if(!t.ok){const r=await t.json().catch(()=>null);throw new Error((r==null?void 0:r.error)??`HTTP ${t.status}`)}const n=kw(await t.json());return eR(n),n}async function eB(){++nd;const e=await fetch("/api/config/workspace-visibility",{method:"DELETE"});if(!e.ok){const n=await e.json().catch(()=>null);throw new Error((n==null?void 0:n.error)??`HTTP ${e.status}`)}const t=kw(await e.json());return eR(t),t}var tB=Symbol("radix.slottable");function nB(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=tB,t}var nR="AlertDialog",[rB]=Ta(nR,[wT]),Po=wT(),rR=e=>{const{__scopeAlertDialog:t,...n}=e,r=Po(t);return s.jsx(MT,{...r,...n,modal:!0})};rR.displayName=nR;var sB="AlertDialogTrigger",oB=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=Po(n);return s.jsx(OT,{...o,...r,ref:t})});oB.displayName=sB;var iB="AlertDialogPortal",sR=e=>{const{__scopeAlertDialog:t,...n}=e,r=Po(t);return s.jsx(FT,{...r,...n})};sR.displayName=iB;var aB="AlertDialogOverlay",oR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=Po(n);return s.jsx(dw,{...o,...r,ref:t})});oR.displayName=aB;var zl="AlertDialogContent",[lB,cB]=rB(zl),uB=nB("AlertDialogContent"),iR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...o}=e,i=Po(n),a=m.useRef(null),l=nr(t,a),u=m.useRef(null);return s.jsx(x6,{contentName:zl,titleName:aR,docsSlug:"alert-dialog",children:s.jsx(lB,{scope:n,cancelRef:u,children:s.jsxs(fw,{role:"alertdialog",...i,...o,ref:l,onOpenAutoFocus:sn(o.onOpenAutoFocus,f=>{var p;f.preventDefault(),(p=u.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[s.jsx(uB,{children:r}),s.jsx(fB,{contentRef:a})]})})})});iR.displayName=zl;var aR="AlertDialogTitle",lR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=Po(n);return s.jsx(pw,{...o,...r,ref:t})});lR.displayName=aR;var cR="AlertDialogDescription",uR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=Po(n);return s.jsx(hw,{...o,...r,ref:t})});uR.displayName=cR;var dB="AlertDialogAction",dR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,o=Po(n);return s.jsx(mw,{...o,...r,ref:t})});dR.displayName=dB;var fR="AlertDialogCancel",pR=m.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:o}=cB(fR,n),i=Po(n),a=nr(t,o);return s.jsx(mw,{...i,...r,ref:a})});pR.displayName=fR;var fB=({contentRef:e})=>{const t=`\`${zl}\` requires a description for the component to be accessible for screen reader users.
596
-
597
- You can add a description to the \`${zl}\` by passing a \`${cR}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
598
-
599
- Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${zl}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
600
-
601
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return m.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},pB=rR,hB=sR,hR=oR,mR=iR,gR=dR,xR=pR,yR=lR,bR=uR;const Tl=pB,mB=hB,vR=m.forwardRef(({className:e,...t},n)=>s.jsx(hR,{ref:n,className:je("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",e),...t}));vR.displayName=hR.displayName;const aa=m.forwardRef(({className:e,...t},n)=>s.jsxs(mB,{children:[s.jsx(vR,{}),s.jsx(mR,{ref:n,className:je("chrome-card fixed left-1/2 top-1/2 z-50 grid w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 !p-6 outline-none",e),...t})]}));aa.displayName=mR.displayName;function Rl({className:e,...t}){return s.jsx("div",{className:je("flex flex-col space-y-2 text-left",e),...t})}function Al({className:e,...t}){return s.jsx("div",{className:je("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}const la=m.forwardRef(({className:e,...t},n)=>s.jsx(yR,{ref:n,className:je("text-lg font-semibold tracking-tight text-foreground",e),...t}));la.displayName=yR.displayName;const ca=m.forwardRef(({className:e,...t},n)=>s.jsx(bR,{ref:n,className:je("text-sm leading-6 text-muted-foreground",e),...t}));ca.displayName=bR.displayName;const yi=m.forwardRef(({className:e,...t},n)=>s.jsx(gR,{ref:n,className:je(e),...t}));yi.displayName=gR.displayName;const rd=m.forwardRef(({className:e,...t},n)=>s.jsx(xR,{ref:n,className:je(e),...t}));rd.displayName=xR.displayName;const gB=[{to:"/",label:"Overview",icon:f2},{to:"/inbox",label:"Needs me",icon:h2}],xB=[{id:"library",label:"Library",items:[{to:"/playbooks",label:"Playbooks",icon:a2},{to:"/memories",label:"Memories",icon:YM},{to:"/resources",label:"Resources",icon:mO}]},{id:"board",label:"Board",items:[{to:"/todos",label:"Todos",icon:ys},{to:"/views",label:"Saved Views",icon:m2},{to:"/archive",label:"Archive",icon:Qh}]},{id:"operations",label:"Operations",items:[{to:"/inventories",label:"Inventories",icon:zv},{to:"/schedules",label:"Schedules",icon:l2},{to:"/usage",label:"Usage",icon:tm}]}],yB=[{suffix:"/projects",label:"Projects",icon:Bv},{suffix:"/assignments",label:"Assignments",icon:yO},{suffix:"/servers",label:"Servers",icon:Wv},{suffix:"/agent-sessions",label:"Agent Sessions",icon:Xh}],bB=[{to:"/help",label:"Help",icon:gO},{to:"/workflow",label:"Workflow",icon:MO},{to:"/settings",label:"Settings",icon:_O}];function vB({title:e,breadcrumbs:t,projectSlug:n,workspace:r,children:o}){const[i,a]=m.useState(!1);return en({keys:"Escape",scope:"global",description:"Close mobile navigation",enabled:i,handler:()=>a(!1)}),s.jsx("div",{className:"min-h-screen bg-background",children:s.jsxs("div",{className:"relative grid min-h-screen lg:grid-cols-[240px_minmax(0,1fr)]",children:[s.jsx("aside",{className:"hidden max-h-screen sticky top-0 overflow-y-auto border-r border-border/70 bg-sidebar px-4 py-4 lg:flex lg:flex-col",children:s.jsx(rS,{activeWorkspace:r})}),i?s.jsx("div",{className:"fixed inset-0 z-40 bg-overlay/40 lg:hidden",children:s.jsxs("div",{className:"h-full max-w-xs border-r border-border/70 bg-sidebar p-4 shadow-2xl",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx(De,{to:"/",className:"text-lg font-semibold text-foreground",onClick:()=>a(!1),children:"Syntaur"}),s.jsx("button",{type:"button",onClick:()=>a(!1),className:"inline-flex h-9 w-9 items-center justify-center rounded-md border border-border/70 bg-background/80","aria-label":"Close navigation",children:s.jsx(Pd,{className:"h-4 w-4"})})]}),s.jsx(rS,{activeWorkspace:r,onNavigate:()=>a(!1)})]})}):null,s.jsxs("div",{className:"min-w-0",children:[s.jsx(Iz,{title:e,breadcrumbs:t,projectSlug:n,onOpenMobileNav:()=>a(!0)}),s.jsx("main",{className:"mx-auto w-full max-w-[1480px] px-4 py-4 lg:px-6 lg:py-5",children:o})]})]})})}function rS({activeWorkspace:e,onNavigate:t}){const{total:n}=QT(),r=gB.map(M=>M.to==="/inbox"?{...M,badge:n}:M),{data:o}=Ea(),i=(o==null?void 0:o.workspaces)??[],a=(o==null?void 0:o.hasUngrouped)??!1,{hidden:l}=tR(),u=rr(),{isCollapsed:f,toggle:p}=qz(),h=u.pathname.startsWith("/w/")?null:E2(u.pathname),[g,y]=m.useState(!1),[k,v]=m.useState(""),[b,j]=m.useState(null),[N,S]=m.useState(null),[C,D]=m.useState(null),[T,R]=m.useState(!1),$=Wt(),{toast:P,showToast:F,dismissToast:_}=Qn(),V=Yz([...i,...a?[fh]:[]],l);async function U(M){if(N){R(!0);try{const B=`/api/workspaces/${encodeURIComponent(N)}${M?"?cascade=true":""}`,W=await fetch(B,{method:"DELETE"});if(W.status===409){const O=await W.json().catch(()=>({}));D((O==null?void 0:O.blockedBy)??{projects:[],standalones:[]});return}if(!W.ok){const O=await W.json().catch(()=>({}));throw new Error(O.error||"Failed to delete workspace")}S(null),D(null)}catch(B){console.error(B),alert(B instanceof Error?B.message:"Failed to delete workspace")}finally{R(!1)}}}async function I(M,B){try{if(M.type==="project"){const W=await fetch(`/api/projects/${encodeURIComponent(M.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:B})});if(!W.ok){const O=await W.json().catch(()=>({}));throw new Error(O.error||"Failed to move project")}return}if(M.type==="standalone-assignment"){const W=await fetch(`/api/assignments/${encodeURIComponent(M.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:B})});if(!W.ok){const O=await W.json().catch(()=>({}));throw new Error(O.error||"Failed to move assignment")}return}if(M.type==="project-assignment"){alert("Assignments inherit workspace from their project — drag the project (or move it) to change workspaces.");return}}catch(W){console.error(W),alert(W instanceof Error?W.message:"Failed to move item")}}return s.jsxs("div",{className:"flex h-full flex-col gap-3",children:[s.jsx(Xn,{toast:P,onDismiss:_}),s.jsx("div",{className:"space-y-3",children:s.jsxs(De,{to:"/",className:"inline-flex items-center gap-3",onClick:t,children:[s.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-lg bg-card text-foreground shadow-sm ring-1 ring-border/60",children:s.jsxs("svg",{viewBox:"0 0 43 51","aria-label":"Syntaur",role:"img",className:"h-4 w-auto",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M13 2C13 0.89543 13.8954 0 15 0H41C42.1046 0 43 0.895431 43 2V12C43 13.1046 42.1046 14 41 14H13V2Z"}),s.jsx("path",{d:"M0 15C0 13.8954 0.895431 13 2 13H14V25C14 26.1046 13.1046 27 12 27H2C0.89543 27 0 26.1046 0 25V15Z"}),s.jsx("path",{d:"M30 49C30 50.1046 29.1046 51 28 51L2 51C0.89543 51 0 50.1046 0 49L0 39C0 37.8954 0.895431 37 2 37L30 37L30 49Z"}),s.jsx("path",{d:"M42.9646 36C42.9646 37.1046 42.0692 38 40.9646 38H28.9646V26C28.9646 24.8954 29.86 24 30.9646 24H40.9646C42.0692 24 42.9646 24.8954 42.9646 26V36Z"})]})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Syntaur"}),s.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Local-first project control"})]})]})}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(R1,{items:r,onNavigate:t}),xB.map(M=>s.jsx(y4,{label:M.label,items:M.items,collapsed:f(M.id),onToggle:()=>p(M.id),containsActive:M.items.some(B=>B.to===h),onNavigate:t},M.id))]}),s.jsx("div",{className:"border-t border-border/40"}),s.jsxs("div",{className:"flex-1 space-y-1 overflow-y-auto",children:[V.length===0&&!g&&s.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground/60",children:"No workspaces yet"}),V.map(M=>{const B=M==="_ungrouped",W=B?"Ungrouped":bn(M),O=B?"/w/_ungrouped":`/w/${M}`,H=f(`ws:${M}`),L=e===M||e===null&&B&&u.pathname.startsWith("/w/_ungrouped"),z=b===M;return s.jsxs("div",{className:`rounded-md transition ${z?"bg-accent/40 ring-1 ring-ring/40":""}`,onDragOver:Y=>{Y.dataTransfer.types.includes("application/json")&&(Y.preventDefault(),Y.dataTransfer.dropEffect="move",j(M))},onDragLeave:Y=>{Y.currentTarget.contains(Y.relatedTarget)||j(q=>q===M?null:q)},onDrop:async Y=>{try{const q=Y.dataTransfer.getData("application/json");if(!q)return;Y.preventDefault();let Q;try{Q=JSON.parse(q)}catch{return}if(!(Q!=null&&Q.type)||!(Q!=null&&Q.id))return;await I(Q,B?null:M)}finally{j(null)}},children:[s.jsxs("div",{className:"group flex items-center",children:[s.jsxs("button",{type:"button",onClick:()=>p(`ws:${M}`),className:`flex flex-1 items-center gap-2 rounded-md px-3 py-1.5 text-xs font-semibold uppercase tracking-wider transition ${L?"text-foreground":"text-muted-foreground/70 hover:text-muted-foreground"}`,children:[s.jsx(cr,{className:`h-3 w-3 transition-transform ${H?"-rotate-90":""}`}),W]}),B?null:s.jsx("button",{type:"button",onClick:Y=>{Y.stopPropagation(),S(M),D(null)},title:`Delete workspace "${M}"`,"aria-label":`Delete workspace "${M}"`,className:"mr-1 flex h-6 w-6 items-center justify-center rounded text-muted-foreground/60 opacity-0 transition hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100",children:s.jsx(jn,{className:"h-3 w-3"})})]}),!H&&s.jsx("nav",{className:"ml-2 space-y-0.5",children:yB.map(Y=>{const q=`${O}${Y.suffix}`,Q=T2(u.pathname,Y.suffix)&&u.pathname.startsWith(O),ee=Y.icon;return s.jsxs(De,{to:q,onClick:t,className:`flex items-center gap-3 rounded-md px-3 py-1.5 text-sm font-medium transition ${Q?"bg-foreground text-background shadow-sm":"text-muted-foreground hover:bg-background/80 hover:text-foreground"}`,children:[s.jsx(ee,{className:"h-4 w-4"}),s.jsx("span",{children:Y.label})]},q)})})]},M)}),g?s.jsx("form",{className:"px-3 py-1.5",onSubmit:async M=>{M.preventDefault();const B=k.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(B){y(!1),v("");try{const W=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B})});if(!W.ok){const O=await W.json().catch(()=>null);F((O==null?void 0:O.error)||`HTTP ${W.status}`,"error");return}t==null||t(),$(`/w/${B}/projects`)}catch(W){F(W instanceof Error?W.message:"Failed to create workspace","error")}}},children:s.jsx("input",{autoFocus:!0,type:"text",value:k,onChange:M=>v(M.target.value),onKeyDown:M=>{M.key==="Escape"&&(y(!1),v(""))},onBlur:()=>{k.trim()||(y(!1),v(""))},placeholder:"workspace-name",className:"w-full rounded-md border border-border/60 bg-background/80 px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/50 focus:border-foreground/40 focus:outline-none"})}):s.jsxs("button",{type:"button",onClick:()=>y(!0),className:"flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-xs font-medium text-muted-foreground/60 transition hover:text-muted-foreground",children:[s.jsx(Mt,{className:"h-3 w-3"}),"New Workspace"]})]}),s.jsx("div",{className:"border-t border-border/40"}),s.jsx(R1,{items:bB,onNavigate:t}),s.jsx(Tl,{open:N!==null,onOpenChange:M=>{T||M||(S(null),D(null))},children:s.jsxs(aa,{children:[s.jsxs(Rl,{children:[s.jsx(la,{children:C?"Workspace has references":"Delete workspace?"}),s.jsx(ca,{children:C?s.jsxs(s.Fragment,{children:["The workspace ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:N})," is still referenced by:"]}):s.jsxs(s.Fragment,{children:["Remove the workspace ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:N})," from the registry. This does not affect projects or standalones unless you choose to cascade."]})})]}),C?s.jsxs("div",{className:"space-y-2 text-sm",children:[C.projects.length>0?s.jsxs("div",{children:[s.jsxs("p",{className:"font-medium text-foreground",children:["Projects (",C.projects.length,")"]}),s.jsx("ul",{className:"mt-1 list-disc pl-5 text-muted-foreground",children:C.projects.map(M=>s.jsx("li",{children:s.jsx(De,{to:`/projects/${M}`,className:"hover:underline",children:M})},M))})]}):null,C.standalones.length>0?s.jsxs("div",{children:[s.jsxs("p",{className:"font-medium text-foreground",children:["Standalones (",C.standalones.length,")"]}),s.jsx("ul",{className:"mt-1 list-disc pl-5 text-muted-foreground",children:C.standalones.map(M=>s.jsx("li",{children:s.jsx(De,{to:`/assignments/${M}`,className:"hover:underline",children:M})},M))})]}):null,s.jsxs("p",{className:"text-xs text-muted-foreground",children:['Choose "Clear references and delete" to set ',s.jsx("code",{children:"workspace:"})," / ",s.jsx("code",{children:"workspaceGroup:"})," to ",s.jsx("code",{children:"null"})," on each, then remove the workspace."]})]}):null,s.jsxs(Al,{children:[s.jsx(rd,{disabled:T,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),C?s.jsx(yi,{disabled:T,onClick:M=>{M.preventDefault(),U(!0)},className:"shell-action mt-0 border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50",children:T?"Working…":"Clear references and delete"}):s.jsx(yi,{disabled:T,onClick:M=>{M.preventDefault(),U(!1)},className:"shell-action mt-0 border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:cursor-not-allowed disabled:opacity-50",children:T?"Working…":"Delete"})]})]})})]})}function wB(){const e=rr(),{workspace:t}=qt(),{title:n,breadcrumbs:r,projectSlug:o}=R2(e.pathname);return s.jsx(vB,{title:n,breadcrumbs:r,projectSlug:o,workspace:t??null,children:s.jsx(iM,{})})}function jB(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const gm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function bc(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Sw(e){return"nodeType"in e}function ur(e){var t,n;return e?bc(e)?e:Sw(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Nw(e){const{Document:t}=ur(e);return e instanceof t}function Ld(e){return bc(e)?!1:e instanceof ur(e).HTMLElement}function wR(e){return e instanceof ur(e).SVGElement}function vc(e){return e?bc(e)?e.document:Sw(e)?Nw(e)?e:Ld(e)||wR(e)?e.ownerDocument:document:document:document}const ws=gm?m.useLayoutEffect:m.useEffect;function xm(e){const t=m.useRef(e);return ws(()=>{t.current=e}),m.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function kB(){const e=m.useRef(null),t=m.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=m.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function sd(e,t){t===void 0&&(t=[e]);const n=m.useRef(e);return ws(()=>{n.current!==e&&(n.current=e)},t),n}function Md(e,t){const n=m.useRef();return m.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function ph(e){const t=xm(e),n=m.useRef(null),r=m.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function hh(e){const t=m.useRef();return m.useEffect(()=>{t.current=e},[e]),t.current}let py={};function Od(e,t){return m.useMemo(()=>{if(t)return t;const n=py[e]==null?0:py[e]+1;return py[e]=n,e+"-"+n},[e,t])}function jR(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,a)=>{const l=Object.entries(a);for(const[u,f]of l){const p=i[u];p!=null&&(i[u]=p+e*f)}return i},{...t})}}const Bl=jR(1),od=jR(-1);function SB(e){return"clientX"in e&&"clientY"in e}function ym(e){if(!e)return!1;const{KeyboardEvent:t}=ur(e.target);return t&&e instanceof t}function NB(e){if(!e)return!1;const{TouchEvent:t}=ur(e.target);return t&&e instanceof t}function mh(e){if(NB(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return SB(e)?{x:e.clientX,y:e.clientY}:null}const js=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[js.Translate.toString(e),js.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),sS="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function CB(e){return e.matches(sS)?e:e.querySelector(sS)}const EB={display:"none"};function TB(e){let{id:t,value:n}=e;return Lt.createElement("div",{id:t,style:EB},n)}function RB(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Lt.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function AB(){const[e,t]=m.useState("");return{announce:m.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const kR=m.createContext(null);function PB(e){const t=m.useContext(kR);m.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function _B(){const[e]=m.useState(()=>new Set),t=m.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[m.useCallback(r=>{let{type:o,event:i}=r;e.forEach(a=>{var l;return(l=a[o])==null?void 0:l.call(a,i)})},[e]),t]}const DB={draggable:`
602
- To pick up a draggable item, press the space bar.
603
- While dragging, use the arrow keys to move the item.
604
- Press space again to drop the item in its new position, or press escape to cancel.
605
- `},$B={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 IB(e){let{announcements:t=$B,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=DB}=e;const{announce:i,announcement:a}=AB(),l=Od("DndLiveRegion"),[u,f]=m.useState(!1);if(m.useEffect(()=>{f(!0)},[]),PB(m.useMemo(()=>({onDragStart(h){let{active:g}=h;i(t.onDragStart({active:g}))},onDragMove(h){let{active:g,over:y}=h;t.onDragMove&&i(t.onDragMove({active:g,over:y}))},onDragOver(h){let{active:g,over:y}=h;i(t.onDragOver({active:g,over:y}))},onDragEnd(h){let{active:g,over:y}=h;i(t.onDragEnd({active:g,over:y}))},onDragCancel(h){let{active:g,over:y}=h;i(t.onDragCancel({active:g,over:y}))}}),[i,t])),!u)return null;const p=Lt.createElement(Lt.Fragment,null,Lt.createElement(TB,{id:r,value:o.draggable}),Lt.createElement(RB,{id:l,announcement:a}));return n?jo.createPortal(p,n):p}var $n;(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"})($n||($n={}));function gh(){}function ji(e,t){return m.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function bm(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const ks=Object.freeze({x:0,y:0});function SR(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function LB(e,t){const n=mh(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function NR(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function MB(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function oS(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function CR(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function iS(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 vm=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=iS(t,t.left,t.top),i=[];for(const a of r){const{id:l}=a,u=n.get(l);if(u){const f=SR(iS(u),o);i.push({id:l,data:{droppableContainer:a,value:f}})}}return i.sort(NR)},OB=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=oS(t),i=[];for(const a of r){const{id:l}=a,u=n.get(l);if(u){const f=oS(u),p=o.reduce((g,y,k)=>g+SR(f[k],y),0),h=Number((p/4).toFixed(4));i.push({id:l,data:{droppableContainer:a,value:h}})}}return i.sort(NR)};function FB(e,t){const n=Math.max(t.top,e.top),r=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),a=o-r,l=i-n;if(r<o&&n<i){const u=t.width*t.height,f=e.width*e.height,p=a*l,h=p/(u+f-p);return Number(h.toFixed(4))}return 0}const zB=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:a}=i,l=n.get(a);if(l){const u=FB(l,t);u>0&&o.push({id:a,data:{droppableContainer:i,value:u}})}}return o.sort(MB)};function BB(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function ER(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ks}function UB(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((a,l)=>({...a,top:a.top+e*l.y,bottom:a.bottom+e*l.y,left:a.left+e*l.x,right:a.right+e*l.x}),{...n})}}const HB=UB(1);function TR(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 VB(e,t,n){const r=TR(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:l}=r,u=e.left-a-(1-o)*parseFloat(n),f=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),p=o?e.width/o:e.width,h=i?e.height/i:e.height;return{width:p,height:h,top:f,right:u+p,bottom:f+h,left:u}}const WB={ignoreTransform:!1};function wc(e,t){t===void 0&&(t=WB);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:p}=ur(e).getComputedStyle(e);f&&(n=VB(n,f,p))}const{top:r,left:o,width:i,height:a,bottom:l,right:u}=n;return{top:r,left:o,width:i,height:a,bottom:l,right:u}}function aS(e){return wc(e,{ignoreTransform:!0})}function qB(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function KB(e,t){return t===void 0&&(t=ur(e).getComputedStyle(e)),t.position==="fixed"}function GB(e,t){t===void 0&&(t=ur(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 wm(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(Nw(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Ld(o)||wR(o)||n.includes(o))return n;const i=ur(e).getComputedStyle(o);return o!==e&&GB(o,i)&&n.push(o),KB(o,i)?n:r(o.parentNode)}return e?r(e):n}function RR(e){const[t]=wm(e,1);return t??null}function hy(e){return!gm||!e?null:bc(e)?e:Sw(e)?Nw(e)||e===vc(e).scrollingElement?window:Ld(e)?e:null:null}function AR(e){return bc(e)?e.scrollX:e.scrollLeft}function PR(e){return bc(e)?e.scrollY:e.scrollTop}function $b(e){return{x:AR(e),y:PR(e)}}var Vn;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Vn||(Vn={}));function _R(e){return!gm||!e?!1:e===document.scrollingElement}function DR(e){const t={x:0,y:0},n=_R(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,a=e.scrollTop>=r.y,l=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:a,isRight:l,maxScroll:r,minScroll:t}}const YB={x:.2,y:.2};function XB(e,t,n,r,o){let{top:i,left:a,right:l,bottom:u}=n;r===void 0&&(r=10),o===void 0&&(o=YB);const{isTop:f,isBottom:p,isLeft:h,isRight:g}=DR(e),y={x:0,y:0},k={x:0,y:0},v={height:t.height*o.y,width:t.width*o.x};return!f&&i<=t.top+v.height?(y.y=Vn.Backward,k.y=r*Math.abs((t.top+v.height-i)/v.height)):!p&&u>=t.bottom-v.height&&(y.y=Vn.Forward,k.y=r*Math.abs((t.bottom-v.height-u)/v.height)),!g&&l>=t.right-v.width?(y.x=Vn.Forward,k.x=r*Math.abs((t.right-v.width-l)/v.width)):!h&&a<=t.left+v.width&&(y.x=Vn.Backward,k.x=r*Math.abs((t.left+v.width-a)/v.width)),{direction:y,speed:k}}function QB(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:a}=window;return{top:0,left:0,right:i,bottom:a,width:i,height:a}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function $R(e){return e.reduce((t,n)=>Bl(t,$b(n)),ks)}function JB(e){return e.reduce((t,n)=>t+AR(n),0)}function ZB(e){return e.reduce((t,n)=>t+PR(n),0)}function IR(e,t){if(t===void 0&&(t=wc),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);RR(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const e8=[["x",["left","right"],JB],["y",["top","bottom"],ZB]];class Cw{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 r=wm(n),o=$R(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,a,l]of e8)for(const u of a)Object.defineProperty(this,u,{get:()=>{const f=l(r),p=o[i]-f;return this.rect[u]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Uu{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function t8(e){const{EventTarget:t}=ur(e);return e instanceof t?e:vc(e)}function my(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var Zr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Zr||(Zr={}));function lS(e){e.preventDefault()}function n8(e){e.stopPropagation()}var At;(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"})(At||(At={}));const LR={start:[At.Space,At.Enter],cancel:[At.Esc],end:[At.Space,At.Enter,At.Tab]},r8=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case At.Right:return{...n,x:n.x+25};case At.Left:return{...n,x:n.x-25};case At.Down:return{...n,y:n.y+25};case At.Up:return{...n,y:n.y-25}}};class jc{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 Uu(vc(n)),this.windowListeners=new Uu(ur(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Zr.Resize,this.handleCancel),this.windowListeners.add(Zr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Zr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&IR(r),n(ks)}handleKeyDown(t){if(ym(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=LR,coordinateGetter:a=r8,scrollBehavior:l="smooth"}=o,{code:u}=t;if(i.end.includes(u)){this.handleEnd(t);return}if(i.cancel.includes(u)){this.handleCancel(t);return}const{collisionRect:f}=r.current,p=f?{x:f.left,y:f.top}:ks;this.referenceCoordinates||(this.referenceCoordinates=p);const h=a(t,{active:n,context:r.current,currentCoordinates:p});if(h){const g=od(h,p),y={x:0,y:0},{scrollableAncestors:k}=r.current;for(const v of k){const b=t.code,{isTop:j,isRight:N,isLeft:S,isBottom:C,maxScroll:D,minScroll:T}=DR(v),R=QB(v),$={x:Math.min(b===At.Right?R.right-R.width/2:R.right,Math.max(b===At.Right?R.left:R.left+R.width/2,h.x)),y:Math.min(b===At.Down?R.bottom-R.height/2:R.bottom,Math.max(b===At.Down?R.top:R.top+R.height/2,h.y))},P=b===At.Right&&!N||b===At.Left&&!S,F=b===At.Down&&!C||b===At.Up&&!j;if(P&&$.x!==h.x){const _=v.scrollLeft+g.x,V=b===At.Right&&_<=D.x||b===At.Left&&_>=T.x;if(V&&!g.y){v.scrollTo({left:_,behavior:l});return}V?y.x=v.scrollLeft-_:y.x=b===At.Right?v.scrollLeft-D.x:v.scrollLeft-T.x,y.x&&v.scrollBy({left:-y.x,behavior:l});break}else if(F&&$.y!==h.y){const _=v.scrollTop+g.y,V=b===At.Down&&_<=D.y||b===At.Up&&_>=T.y;if(V&&!g.x){v.scrollTo({top:_,behavior:l});return}V?y.y=v.scrollTop-_:y.y=b===At.Down?v.scrollTop-D.y:v.scrollTop-T.y,y.y&&v.scrollBy({top:-y.y,behavior:l});break}}this.handleMove(t,Bl(od(h,this.referenceCoordinates),y))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(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()}}jc.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=LR,onActivation:o}=t,{active:i}=n;const{code:a}=e.nativeEvent;if(r.start.includes(a)){const l=i.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function cS(e){return!!(e&&"distance"in e)}function uS(e){return!!(e&&"delay"in e)}class Ew{constructor(t,n,r){var o;r===void 0&&(r=t8(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:a}=i;this.props=t,this.events=n,this.document=vc(a),this.documentListeners=new Uu(this.document),this.listeners=new Uu(r),this.windowListeners=new Uu(ur(a)),this.initialCoordinates=(o=mh(i))!=null?o:ks,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:r}}}=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(Zr.Resize,this.handleCancel),this.windowListeners.add(Zr.DragStart,lS),this.windowListeners.add(Zr.VisibilityChange,this.handleCancel),this.windowListeners.add(Zr.ContextMenu,lS),this.documentListeners.add(Zr.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(uS(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(cS(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:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Zr.Click,n8,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Zr.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:a,options:{activationConstraint:l}}=i;if(!o)return;const u=(n=mh(t))!=null?n:ks,f=od(o,u);if(!r&&l){if(cS(l)){if(l.tolerance!=null&&my(f,l.tolerance))return this.handleCancel();if(my(f,l.distance))return this.handleStart()}if(uS(l)&&my(f,l.tolerance))return this.handleCancel();this.handlePending(l,f);return}t.cancelable&&t.preventDefault(),a(u)}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===At.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const s8={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class kc extends Ew{constructor(t){const{event:n}=t,r=vc(n.target);super(t,s8,r)}}kc.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const o8={move:{name:"mousemove"},end:{name:"mouseup"}};var Ib;(function(e){e[e.RightClick=2]="RightClick"})(Ib||(Ib={}));class i8 extends Ew{constructor(t){super(t,o8,vc(t.event.target))}}i8.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Ib.RightClick?!1:(r==null||r({event:n}),!0)}}];const gy={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class a8 extends Ew{constructor(t){super(t,gy)}static setup(){return window.addEventListener(gy.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(gy.move.name,t)};function t(){}}}a8.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r==null||r({event:n}),!0)}}];var Hu;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Hu||(Hu={}));var xh;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(xh||(xh={}));function l8(e){let{acceleration:t,activator:n=Hu.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:a=5,order:l=xh.TreeOrder,pointerCoordinates:u,scrollableAncestors:f,scrollableAncestorRects:p,delta:h,threshold:g}=e;const y=u8({delta:h,disabled:!i}),[k,v]=kB(),b=m.useRef({x:0,y:0}),j=m.useRef({x:0,y:0}),N=m.useMemo(()=>{switch(n){case Hu.Pointer:return u?{top:u.y,bottom:u.y,left:u.x,right:u.x}:null;case Hu.DraggableRect:return o}},[n,o,u]),S=m.useRef(null),C=m.useCallback(()=>{const T=S.current;if(!T)return;const R=b.current.x*j.current.x,$=b.current.y*j.current.y;T.scrollBy(R,$)},[]),D=m.useMemo(()=>l===xh.TreeOrder?[...f].reverse():f,[l,f]);m.useEffect(()=>{if(!i||!f.length||!N){v();return}for(const T of D){if((r==null?void 0:r(T))===!1)continue;const R=f.indexOf(T),$=p[R];if(!$)continue;const{direction:P,speed:F}=XB(T,$,N,t,g);for(const _ of["x","y"])y[_][P[_]]||(F[_]=0,P[_]=0);if(F.x>0||F.y>0){v(),S.current=T,k(C,a),b.current=F,j.current=P;return}}b.current={x:0,y:0},j.current={x:0,y:0},v()},[t,C,r,v,i,a,JSON.stringify(N),JSON.stringify(y),k,f,D,p,JSON.stringify(g)])}const c8={x:{[Vn.Backward]:!1,[Vn.Forward]:!1},y:{[Vn.Backward]:!1,[Vn.Forward]:!1}};function u8(e){let{delta:t,disabled:n}=e;const r=hh(t);return Md(o=>{if(n||!r||!o)return c8;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Vn.Backward]:o.x[Vn.Backward]||i.x===-1,[Vn.Forward]:o.x[Vn.Forward]||i.x===1},y:{[Vn.Backward]:o.y[Vn.Backward]||i.y===-1,[Vn.Forward]:o.y[Vn.Forward]||i.y===1}}},[n,t,r])}function d8(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Md(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function f8(e,t){return m.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(a=>({eventName:a.eventName,handler:t(a.handler,r)}));return[...n,...i]},[]),[e,t])}var id;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(id||(id={}));var Lb;(function(e){e.Optimized="optimized"})(Lb||(Lb={}));const dS=new Map;function p8(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,a]=m.useState(null),{frequency:l,measure:u,strategy:f}=o,p=m.useRef(e),h=b(),g=sd(h),y=m.useCallback(function(j){j===void 0&&(j=[]),!g.current&&a(N=>N===null?j:N.concat(j.filter(S=>!N.includes(S))))},[g]),k=m.useRef(null),v=Md(j=>{if(h&&!n)return dS;if(!j||j===dS||p.current!==e||i!=null){const N=new Map;for(let S of e){if(!S)continue;if(i&&i.length>0&&!i.includes(S.id)&&S.rect.current){N.set(S.id,S.rect.current);continue}const C=S.node.current,D=C?new Cw(u(C),C):null;S.rect.current=D,D&&N.set(S.id,D)}return N}return j},[e,i,n,h,u]);return m.useEffect(()=>{p.current=e},[e]),m.useEffect(()=>{h||y()},[n,h]),m.useEffect(()=>{i&&i.length>0&&a(null)},[JSON.stringify(i)]),m.useEffect(()=>{h||typeof l!="number"||k.current!==null||(k.current=setTimeout(()=>{y(),k.current=null},l))},[l,h,y,...r]),{droppableRects:v,measureDroppableContainers:y,measuringScheduled:i!=null};function b(){switch(f){case id.Always:return!1;case id.BeforeDragging:return n;default:return!n}}}function Tw(e,t){return Md(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function h8(e,t){return Tw(e,t)}function m8(e){let{callback:t,disabled:n}=e;const r=xm(t),o=m.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return m.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function jm(e){let{callback:t,disabled:n}=e;const r=xm(t),o=m.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return m.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function g8(e){return new Cw(wc(e),e)}function fS(e,t,n){t===void 0&&(t=g8);const[r,o]=m.useState(null);function i(){o(u=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=u??n)!=null?f:null}const p=t(e);return JSON.stringify(u)===JSON.stringify(p)?u:p})}const a=m8({callback(u){if(e)for(const f of u){const{type:p,target:h}=f;if(p==="childList"&&h instanceof HTMLElement&&h.contains(e)){i();break}}}}),l=jm({callback:i});return ws(()=>{i(),e?(l==null||l.observe(e),a==null||a.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),a==null||a.disconnect())},[e]),r}function x8(e){const t=Tw(e);return ER(e,t)}const pS=[];function y8(e){const t=m.useRef(e),n=Md(r=>e?r&&r!==pS&&e&&t.current&&e.parentNode===t.current.parentNode?r:wm(e):pS,[e]);return m.useEffect(()=>{t.current=e},[e]),n}function b8(e){const[t,n]=m.useState(null),r=m.useRef(e),o=m.useCallback(i=>{const a=hy(i.target);a&&n(l=>l?(l.set(a,$b(a)),new Map(l)):null)},[]);return m.useEffect(()=>{const i=r.current;if(e!==i){a(i);const l=e.map(u=>{const f=hy(u);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,$b(f)]):null}).filter(u=>u!=null);n(l.length?new Map(l):null),r.current=e}return()=>{a(e),a(i)};function a(l){l.forEach(u=>{const f=hy(u);f==null||f.removeEventListener("scroll",o)})}},[o,e]),m.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,a)=>Bl(i,a),ks):$R(e):ks,[e,t])}function hS(e,t){t===void 0&&(t=[]);const n=m.useRef(null);return m.useEffect(()=>{n.current=null},t),m.useEffect(()=>{const r=e!==ks;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?od(e,n.current):ks}function v8(e){m.useEffect(()=>{if(!gm)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function w8(e,t){return m.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=a=>{i(a,t)},n},{}),[e,t])}function MR(e){return m.useMemo(()=>e?qB(e):null,[e])}const mS=[];function j8(e,t){t===void 0&&(t=wc);const[n]=e,r=MR(n?ur(n):null),[o,i]=m.useState(mS);function a(){i(()=>e.length?e.map(u=>_R(u)?r:new Cw(t(u),u)):mS)}const l=jm({callback:a});return ws(()=>{l==null||l.disconnect(),a(),e.forEach(u=>l==null?void 0:l.observe(u))},[e]),o}function OR(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Ld(t)?t:e}function k8(e){let{measure:t}=e;const[n,r]=m.useState(null),o=m.useCallback(f=>{for(const{target:p}of f)if(Ld(p)){r(h=>{const g=t(p);return h?{...h,width:g.width,height:g.height}:g});break}},[t]),i=jm({callback:o}),a=m.useCallback(f=>{const p=OR(f);i==null||i.disconnect(),p&&(i==null||i.observe(p)),r(p?t(p):null)},[t,i]),[l,u]=ph(a);return m.useMemo(()=>({nodeRef:l,rect:n,setRef:u}),[n,l,u])}const S8=[{sensor:kc,options:{}},{sensor:jc,options:{}}],N8={current:{}},Hp={draggable:{measure:aS},droppable:{measure:aS,strategy:id.WhileDragging,frequency:Lb.Optimized},dragOverlay:{measure:wc}};class Vu 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,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const C8={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Vu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:gh},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Hp,measureDroppableContainers:gh,windowRect:null,measuringScheduled:!1},FR={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:gh,draggableNodes:new Map,over:null,measureDroppableContainers:gh},Fd=m.createContext(FR),zR=m.createContext(C8);function E8(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Vu}}}function T8(e,t){switch(t.type){case $n.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case $n.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 $n.DragEnd:case $n.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $n.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Vu(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case $n.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const a=new Vu(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case $n.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Vu(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function R8(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=m.useContext(Fd),i=hh(r),a=hh(n==null?void 0:n.id);return m.useEffect(()=>{if(!t&&!r&&i&&a!=null){if(!ym(i)||document.activeElement===i.target)return;const l=o.get(a);if(!l)return;const{activatorNode:u,node:f}=l;if(!u.current&&!f.current)return;requestAnimationFrame(()=>{for(const p of[u.current,f.current]){if(!p)continue;const h=CB(p);if(h){h.focus();break}}})}},[r,t,o,a,i]),null}function BR(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function A8(e){return m.useMemo(()=>({draggable:{...Hp.draggable,...e==null?void 0:e.draggable},droppable:{...Hp.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Hp.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 P8(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=m.useRef(!1),{x:a,y:l}=typeof o=="boolean"?{x:o,y:o}:o;ws(()=>{if(!a&&!l||!t){i.current=!1;return}if(i.current||!r)return;const f=t==null?void 0:t.node.current;if(!f||f.isConnected===!1)return;const p=n(f),h=ER(p,r);if(a||(h.x=0),l||(h.y=0),i.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const g=RR(f);g&&g.scrollBy({top:h.y,left:h.x})}},[t,a,l,r,n])}const km=m.createContext({...ks,scaleX:1,scaleY:1});var gi;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(gi||(gi={}));const Sm=m.memo(function(t){var n,r,o,i;let{id:a,accessibility:l,autoScroll:u=!0,children:f,sensors:p=S8,collisionDetection:h=zB,measuring:g,modifiers:y,...k}=t;const v=m.useReducer(T8,void 0,E8),[b,j]=v,[N,S]=_B(),[C,D]=m.useState(gi.Uninitialized),T=C===gi.Initialized,{draggable:{active:R,nodes:$,translate:P},droppable:{containers:F}}=b,_=R!=null?$.get(R):null,V=m.useRef({initial:null,translated:null}),U=m.useMemo(()=>{var lt;return R!=null?{id:R,data:(lt=_==null?void 0:_.data)!=null?lt:N8,rect:V}:null},[R,_]),I=m.useRef(null),[M,B]=m.useState(null),[W,O]=m.useState(null),H=sd(k,Object.values(k)),L=Od("DndDescribedBy",a),z=m.useMemo(()=>F.getEnabled(),[F]),Y=A8(g),{droppableRects:q,measureDroppableContainers:Q,measuringScheduled:ee}=p8(z,{dragging:T,dependencies:[P.x,P.y],config:Y.droppable}),Z=d8($,R),ie=m.useMemo(()=>W?mh(W):null,[W]),ne=ze(),ue=h8(Z,Y.draggable.measure);P8({activeNode:R!=null?$.get(R):null,config:ne.layoutShiftCompensation,initialRect:ue,measure:Y.draggable.measure});const ge=fS(Z,Y.draggable.measure,ue),Ne=fS(Z?Z.parentElement:null),Ce=m.useRef({activatorEvent:null,active:null,activeNode:Z,collisionRect:null,collisions:null,droppableRects:q,draggableNodes:$,draggingNode:null,draggingNodeRect:null,droppableContainers:F,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ke=F.getNodeFor((n=Ce.current.over)==null?void 0:n.id),Ue=k8({measure:Y.dragOverlay.measure}),oe=(r=Ue.nodeRef.current)!=null?r:Z,ve=T?(o=Ue.rect)!=null?o:ge:null,be=!!(Ue.nodeRef.current&&Ue.rect),Re=x8(be?null:ge),He=MR(oe?ur(oe):null),rt=y8(T?ke??Z:null),Fe=j8(rt),ot=BR(y,{transform:{x:P.x-Re.x,y:P.y-Re.y,scaleX:1,scaleY:1},activatorEvent:W,active:U,activeNodeRect:ge,containerNodeRect:Ne,draggingNodeRect:ve,over:Ce.current.over,overlayNodeRect:Ue.rect,scrollableAncestors:rt,scrollableAncestorRects:Fe,windowRect:He}),Nt=ie?Bl(ie,P):null,mt=b8(rt),at=hS(mt),ce=hS(mt,[ge]),me=Bl(ot,at),Ie=ve?HB(ve,ot):null,Ae=U&&Ie?h({active:U,collisionRect:Ie,droppableRects:q,droppableContainers:z,pointerCoordinates:Nt}):null,We=CR(Ae,"id"),[pt,Pe]=m.useState(null),Qe=be?ot:Bl(ot,ce),Je=BB(Qe,(i=pt==null?void 0:pt.rect)!=null?i:null,ge),ut=m.useRef(null),fe=m.useCallback((lt,ht)=>{let{sensor:vt,options:tt}=ht;if(I.current==null)return;const _t=$.get(I.current);if(!_t)return;const zt=lt.nativeEvent,Bt=new vt({active:I.current,activeNode:_t,event:zt,options:tt,context:Ce,onAbort(Oe){if(!$.get(Oe))return;const{onDragAbort:Et}=H.current,ln={id:Oe};Et==null||Et(ln),N({type:"onDragAbort",event:ln})},onPending(Oe,it,Et,ln){if(!$.get(Oe))return;const{onDragPending:le}=H.current,Se={id:Oe,constraint:it,initialCoordinates:Et,offset:ln};le==null||le(Se),N({type:"onDragPending",event:Se})},onStart(Oe){const it=I.current;if(it==null)return;const Et=$.get(it);if(!Et)return;const{onDragStart:ln}=H.current,Ut={activatorEvent:zt,active:{id:it,data:Et.data,rect:V}};jo.unstable_batchedUpdates(()=>{ln==null||ln(Ut),D(gi.Initializing),j({type:$n.DragStart,initialCoordinates:Oe,active:it}),N({type:"onDragStart",event:Ut}),B(ut.current),O(zt)})},onMove(Oe){j({type:$n.DragMove,coordinates:Oe})},onEnd:we($n.DragEnd),onCancel:we($n.DragCancel)});ut.current=Bt;function we(Oe){return async function(){const{active:Et,collisions:ln,over:Ut,scrollAdjustedTranslate:le}=Ce.current;let Se=null;if(Et&&le){const{cancelDrop:nt}=H.current;Se={activatorEvent:zt,active:Et,collisions:ln,delta:le,over:Ut},Oe===$n.DragEnd&&typeof nt=="function"&&await Promise.resolve(nt(Se))&&(Oe=$n.DragCancel)}I.current=null,jo.unstable_batchedUpdates(()=>{j({type:Oe}),D(gi.Uninitialized),Pe(null),B(null),O(null),ut.current=null;const nt=Oe===$n.DragEnd?"onDragEnd":"onDragCancel";if(Se){const Tn=H.current[nt];Tn==null||Tn(Se),N({type:nt,event:Se})}})}}},[$]),K=m.useCallback((lt,ht)=>(vt,tt)=>{const _t=vt.nativeEvent,zt=$.get(tt);if(I.current!==null||!zt||_t.dndKit||_t.defaultPrevented)return;const Bt={active:zt};lt(vt,ht.options,Bt)===!0&&(_t.dndKit={capturedBy:ht.sensor},I.current=tt,fe(vt,ht))},[$,fe]),re=f8(p,K);v8(p),ws(()=>{ge&&C===gi.Initializing&&D(gi.Initialized)},[ge,C]),m.useEffect(()=>{const{onDragMove:lt}=H.current,{active:ht,activatorEvent:vt,collisions:tt,over:_t}=Ce.current;if(!ht||!vt)return;const zt={active:ht,activatorEvent:vt,collisions:tt,delta:{x:me.x,y:me.y},over:_t};jo.unstable_batchedUpdates(()=>{lt==null||lt(zt),N({type:"onDragMove",event:zt})})},[me.x,me.y]),m.useEffect(()=>{const{active:lt,activatorEvent:ht,collisions:vt,droppableContainers:tt,scrollAdjustedTranslate:_t}=Ce.current;if(!lt||I.current==null||!ht||!_t)return;const{onDragOver:zt}=H.current,Bt=tt.get(We),we=Bt&&Bt.rect.current?{id:Bt.id,rect:Bt.rect.current,data:Bt.data,disabled:Bt.disabled}:null,Oe={active:lt,activatorEvent:ht,collisions:vt,delta:{x:_t.x,y:_t.y},over:we};jo.unstable_batchedUpdates(()=>{Pe(we),zt==null||zt(Oe),N({type:"onDragOver",event:Oe})})},[We]),ws(()=>{Ce.current={activatorEvent:W,active:U,activeNode:Z,collisionRect:Ie,collisions:Ae,droppableRects:q,draggableNodes:$,draggingNode:oe,draggingNodeRect:ve,droppableContainers:F,over:pt,scrollableAncestors:rt,scrollAdjustedTranslate:me},V.current={initial:ve,translated:Ie}},[U,Z,Ae,Ie,$,oe,ve,q,F,pt,rt,me]),l8({...ne,delta:P,draggingRect:Ie,pointerCoordinates:Nt,scrollableAncestors:rt,scrollableAncestorRects:Fe});const xe=m.useMemo(()=>({active:U,activeNode:Z,activeNodeRect:ge,activatorEvent:W,collisions:Ae,containerNodeRect:Ne,dragOverlay:Ue,draggableNodes:$,droppableContainers:F,droppableRects:q,over:pt,measureDroppableContainers:Q,scrollableAncestors:rt,scrollableAncestorRects:Fe,measuringConfiguration:Y,measuringScheduled:ee,windowRect:He}),[U,Z,ge,W,Ae,Ne,Ue,$,F,q,pt,Q,rt,Fe,Y,ee,He]),Ge=m.useMemo(()=>({activatorEvent:W,activators:re,active:U,activeNodeRect:ge,ariaDescribedById:{draggable:L},dispatch:j,draggableNodes:$,over:pt,measureDroppableContainers:Q}),[W,re,U,ge,j,L,$,pt,Q]);return Lt.createElement(kR.Provider,{value:S},Lt.createElement(Fd.Provider,{value:Ge},Lt.createElement(zR.Provider,{value:xe},Lt.createElement(km.Provider,{value:Je},f)),Lt.createElement(R8,{disabled:(l==null?void 0:l.restoreFocus)===!1})),Lt.createElement(IB,{...l,hiddenTextDescribedById:L}));function ze(){const lt=(M==null?void 0:M.autoScrollEnabled)===!1,ht=typeof u=="object"?u.enabled===!1:u===!1,vt=T&&!lt&&!ht;return typeof u=="object"?{...u,enabled:vt}:{enabled:vt}}}),_8=m.createContext(null),gS="button",D8="Draggable";function $8(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=Od(D8),{activators:a,activatorEvent:l,active:u,activeNodeRect:f,ariaDescribedById:p,draggableNodes:h,over:g}=m.useContext(Fd),{role:y=gS,roleDescription:k="draggable",tabIndex:v=0}=o??{},b=(u==null?void 0:u.id)===t,j=m.useContext(b?km:_8),[N,S]=ph(),[C,D]=ph(),T=w8(a,t),R=sd(n);ws(()=>(h.set(t,{id:t,key:i,node:N,activatorNode:C,data:R}),()=>{const P=h.get(t);P&&P.key===i&&h.delete(t)}),[h,t]);const $=m.useMemo(()=>({role:y,tabIndex:v,"aria-disabled":r,"aria-pressed":b&&y===gS?!0:void 0,"aria-roledescription":k,"aria-describedby":p.draggable}),[r,y,v,b,k,p.draggable]);return{active:u,activatorEvent:l,activeNodeRect:f,attributes:$,isDragging:b,listeners:r?void 0:T,node:N,over:g,setNodeRef:S,setActivatorNodeRef:D,transform:j}}function UR(){return m.useContext(zR)}const I8="Droppable",L8={timeout:25};function M8(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=Od(I8),{active:a,dispatch:l,over:u,measureDroppableContainers:f}=m.useContext(Fd),p=m.useRef({disabled:n}),h=m.useRef(!1),g=m.useRef(null),y=m.useRef(null),{disabled:k,updateMeasurementsFor:v,timeout:b}={...L8,...o},j=sd(v??r),N=m.useCallback(()=>{if(!h.current){h.current=!0;return}y.current!=null&&clearTimeout(y.current),y.current=setTimeout(()=>{f(Array.isArray(j.current)?j.current:[j.current]),y.current=null},b)},[b]),S=jm({callback:N,disabled:k||!a}),C=m.useCallback(($,P)=>{S&&(P&&(S.unobserve(P),h.current=!1),$&&S.observe($))},[S]),[D,T]=ph(C),R=sd(t);return m.useEffect(()=>{!S||!D.current||(S.disconnect(),h.current=!1,S.observe(D.current))},[D,S]),m.useEffect(()=>(l({type:$n.RegisterDroppable,element:{id:r,key:i,disabled:n,node:D,rect:g,data:R}}),()=>l({type:$n.UnregisterDroppable,key:i,id:r})),[r]),m.useEffect(()=>{n!==p.current.disabled&&(l({type:$n.SetDroppableDisabled,id:r,key:i,disabled:n}),p.current.disabled=n)},[r,i,n,l]),{active:a,rect:g,isOver:(u==null?void 0:u.id)===r,node:D,over:u,setNodeRef:T}}function O8(e){let{animation:t,children:n}=e;const[r,o]=m.useState(null),[i,a]=m.useState(null),l=hh(n);return!n&&!r&&l&&o(l),ws(()=>{if(!i)return;const u=r==null?void 0:r.key,f=r==null?void 0:r.props.id;if(u==null||f==null){o(null);return}Promise.resolve(t(f,i)).then(()=>{o(null)})},[t,r,i]),Lt.createElement(Lt.Fragment,null,n,r?m.cloneElement(r,{ref:a}):null)}const F8={x:0,y:0,scaleX:1,scaleY:1};function z8(e){let{children:t}=e;return Lt.createElement(Fd.Provider,{value:FR},Lt.createElement(km.Provider,{value:F8},t))}const B8={position:"fixed",touchAction:"none"},U8=e=>ym(e)?"transform 250ms ease":void 0,H8=m.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:a,rect:l,style:u,transform:f,transition:p=U8}=e;if(!l)return null;const h=o?f:{...f,scaleX:1,scaleY:1},g={...B8,width:l.width,height:l.height,top:l.top,left:l.left,transform:js.Transform.toString(h),transformOrigin:o&&r?LB(r,l):void 0,transition:typeof p=="function"?p(r):p,...u};return Lt.createElement(n,{className:a,style:g,ref:t},i)}),V8=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:a}=e;if(i!=null&&i.active)for(const[l,u]of Object.entries(i.active))u!==void 0&&(o[l]=n.node.style.getPropertyValue(l),n.node.style.setProperty(l,u));if(i!=null&&i.dragOverlay)for(const[l,u]of Object.entries(i.dragOverlay))u!==void 0&&r.node.style.setProperty(l,u);return a!=null&&a.active&&n.node.classList.add(a.active),a!=null&&a.dragOverlay&&r.node.classList.add(a.dragOverlay),function(){for(const[u,f]of Object.entries(o))n.node.style.setProperty(u,f);a!=null&&a.active&&n.node.classList.remove(a.active)}},W8=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:js.Transform.toString(t)},{transform:js.Transform.toString(n)}]},q8={duration:250,easing:"ease",keyframes:W8,sideEffects:V8({styles:{active:{opacity:"0"}}})};function K8(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return xm((i,a)=>{if(t===null)return;const l=n.get(i);if(!l)return;const u=l.node.current;if(!u)return;const f=OR(a);if(!f)return;const{transform:p}=ur(a).getComputedStyle(a),h=TR(p);if(!h)return;const g=typeof t=="function"?t:G8(t);return IR(u,o.draggable.measure),g({active:{id:i,data:l.data,node:u,rect:o.draggable.measure(u)},draggableNodes:n,dragOverlay:{node:a,rect:o.dragOverlay.measure(f)},droppableContainers:r,measuringConfiguration:o,transform:h})})}function G8(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...q8,...e};return i=>{let{active:a,dragOverlay:l,transform:u,...f}=i;if(!t)return;const p={x:l.rect.left-a.rect.left,y:l.rect.top-a.rect.top},h={scaleX:u.scaleX!==1?a.rect.width*u.scaleX/l.rect.width:1,scaleY:u.scaleY!==1?a.rect.height*u.scaleY/l.rect.height:1},g={x:u.x-p.x,y:u.y-p.y,...h},y=o({...f,active:a,dragOverlay:l,transform:{initial:u,final:g}}),[k]=y,v=y[y.length-1];if(JSON.stringify(k)===JSON.stringify(v))return;const b=r==null?void 0:r({active:a,dragOverlay:l,...f}),j=l.node.animate(y,{duration:t,easing:n,fill:"forwards"});return new Promise(N=>{j.onfinish=()=>{b==null||b(),N()}})}}let xS=0;function Y8(e){return m.useMemo(()=>{if(e!=null)return xS++,xS},[e])}const X8=Lt.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:a,wrapperElement:l="div",className:u,zIndex:f=999}=e;const{activatorEvent:p,active:h,activeNodeRect:g,containerNodeRect:y,draggableNodes:k,droppableContainers:v,dragOverlay:b,over:j,measuringConfiguration:N,scrollableAncestors:S,scrollableAncestorRects:C,windowRect:D}=UR(),T=m.useContext(km),R=Y8(h==null?void 0:h.id),$=BR(a,{activatorEvent:p,active:h,activeNodeRect:g,containerNodeRect:y,draggingNodeRect:b.rect,over:j,overlayNodeRect:b.rect,scrollableAncestors:S,scrollableAncestorRects:C,transform:T,windowRect:D}),P=Tw(g),F=K8({config:r,draggableNodes:k,droppableContainers:v,measuringConfiguration:N}),_=P?b.setRef:void 0;return Lt.createElement(z8,null,Lt.createElement(O8,{animation:F},h&&R?Lt.createElement(H8,{key:R,id:h.id,ref:_,as:l,activatorEvent:p,adjustScale:t,className:u,transition:i,rect:P,style:{zIndex:f,...o},transform:$},n):null))});function Sc(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Q8(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function cp(e){return e!==null&&e>=0}function J8(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 Z8(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Rw=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=Sc(t,r,n),a=t[o],l=i[o];return!l||!a?null:{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}},up={scaleX:1,scaleY:1},Aw=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:a}=e;const l=(t=i[n])!=null?t:r;if(!l)return null;if(o===n){const f=i[a];return f?{x:0,y:n<a?f.top+f.height-(l.top+l.height):f.top-l.top,...up}:null}const u=e7(i,o,n);return o>n&&o<=a?{x:0,y:-l.height-u,...up}:o<n&&o>=a?{x:0,y:l.height+u,...up}:{x:0,y:0,...up}};function e7(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const HR="Sortable",VR=Lt.createContext({activeIndex:-1,containerId:HR,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Rw,disabled:{draggable:!1,droppable:!1}});function Nm(e){let{children:t,id:n,items:r,strategy:o=Rw,disabled:i=!1}=e;const{active:a,dragOverlay:l,droppableRects:u,over:f,measureDroppableContainers:p}=UR(),h=Od(HR,n),g=l.rect!==null,y=m.useMemo(()=>r.map(T=>typeof T=="object"&&"id"in T?T.id:T),[r]),k=a!=null,v=a?y.indexOf(a.id):-1,b=f?y.indexOf(f.id):-1,j=m.useRef(y),N=!J8(y,j.current),S=b!==-1&&v===-1||N,C=Z8(i);ws(()=>{N&&k&&p(y)},[N,y,k,p]),m.useEffect(()=>{j.current=y},[y]);const D=m.useMemo(()=>({activeIndex:v,containerId:h,disabled:C,disableTransforms:S,items:y,overIndex:b,useDragOverlay:g,sortedRects:Q8(y,u),strategy:o}),[v,h,C.draggable,C.droppable,S,y,b,u,g,o]);return Lt.createElement(VR.Provider,{value:D},t)}const t7=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Sc(n,r,o).indexOf(t)},n7=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:a,previousItems:l,previousContainerId:u,transition:f}=e;return!f||!r||l!==i&&o===a?!1:n?!0:a!==o&&t===u},r7={duration:200,easing:"ease"},WR="transform",s7=js.Transition.toString({property:WR,duration:0,easing:"linear"}),o7={roleDescription:"sortable"};function i7(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,a]=m.useState(null),l=m.useRef(n);return ws(()=>{if(!t&&n!==l.current&&r.current){const u=o.current;if(u){const f=wc(r.current,{ignoreTransform:!0}),p={x:u.left-f.left,y:u.top-f.top,scaleX:u.width/f.width,scaleY:u.height/f.height};(p.x||p.y)&&a(p)}}n!==l.current&&(l.current=n)},[t,n,r,o]),m.useEffect(()=>{i&&a(null)},[i]),i}function Cm(e){let{animateLayoutChanges:t=n7,attributes:n,disabled:r,data:o,getNewIndex:i=t7,id:a,strategy:l,resizeObserverConfig:u,transition:f=r7}=e;const{items:p,containerId:h,activeIndex:g,disabled:y,disableTransforms:k,sortedRects:v,overIndex:b,useDragOverlay:j,strategy:N}=m.useContext(VR),S=a7(r,y),C=p.indexOf(a),D=m.useMemo(()=>({sortable:{containerId:h,index:C,items:p},...o}),[h,o,C,p]),T=m.useMemo(()=>p.slice(p.indexOf(a)),[p,a]),{rect:R,node:$,isOver:P,setNodeRef:F}=M8({id:a,data:D,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...u}}),{active:_,activatorEvent:V,activeNodeRect:U,attributes:I,setNodeRef:M,listeners:B,isDragging:W,over:O,setActivatorNodeRef:H,transform:L}=$8({id:a,data:D,attributes:{...o7,...n},disabled:S.draggable}),z=jB(F,M),Y=!!_,q=Y&&!k&&cp(g)&&cp(b),Q=!j&&W,ee=Q&&q?L:null,ie=q?ee??(l??N)({rects:v,activeNodeRect:U,activeIndex:g,overIndex:b,index:C}):null,ne=cp(g)&&cp(b)?i({id:a,items:p,activeIndex:g,overIndex:b}):C,ue=_==null?void 0:_.id,ge=m.useRef({activeId:ue,items:p,newIndex:ne,containerId:h}),Ne=p!==ge.current.items,Ce=t({active:_,containerId:h,isDragging:W,isSorting:Y,id:a,index:C,items:p,newIndex:ge.current.newIndex,previousItems:ge.current.items,previousContainerId:ge.current.containerId,transition:f,wasDragging:ge.current.activeId!=null}),ke=i7({disabled:!Ce,index:C,node:$,rect:R});return m.useEffect(()=>{Y&&ge.current.newIndex!==ne&&(ge.current.newIndex=ne),h!==ge.current.containerId&&(ge.current.containerId=h),p!==ge.current.items&&(ge.current.items=p)},[Y,ne,h,p]),m.useEffect(()=>{if(ue===ge.current.activeId)return;if(ue!=null&&ge.current.activeId==null){ge.current.activeId=ue;return}const oe=setTimeout(()=>{ge.current.activeId=ue},50);return()=>clearTimeout(oe)},[ue]),{active:_,activeIndex:g,attributes:I,data:D,rect:R,index:C,newIndex:ne,items:p,isOver:P,isSorting:Y,isDragging:W,listeners:B,node:$,overIndex:b,over:O,setNodeRef:z,setActivatorNodeRef:H,setDroppableNodeRef:F,setDraggableNodeRef:M,transform:ke??ie,transition:Ue()};function Ue(){if(ke||Ne&&ge.current.newIndex===C)return s7;if(!(Q&&!ym(V)||!f)&&(Y||Ce))return js.Transition.toString({...f,property:WR})}}function a7(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:t.droppable}}function yh(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 l7=[At.Down,At.Right,At.Up,At.Left],qR=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:a,scrollableAncestors:l}}=t;if(l7.includes(e.code)){if(e.preventDefault(),!n||!r)return;const u=[];i.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const g=o.get(h.id);if(g)switch(e.code){case At.Down:r.top<g.top&&u.push(h);break;case At.Up:r.top>g.top&&u.push(h);break;case At.Left:r.left>g.left&&u.push(h);break;case At.Right:r.left<g.left&&u.push(h);break}});const f=OB({collisionRect:r,droppableRects:o,droppableContainers:u});let p=CR(f,"id");if(p===(a==null?void 0:a.id)&&f.length>1&&(p=f[1].id),p!=null){const h=i.get(n.id),g=i.get(p),y=g?o.get(g.id):null,k=g==null?void 0:g.node.current;if(k&&y&&h&&g){const b=wm(k).some((T,R)=>l[R]!==T),j=KR(h,g),N=c7(h,g),S=b||!j?{x:0,y:0}:{x:N?r.width-y.width:0,y:N?r.height-y.height:0},C={x:y.left,y:y.top};return S.x&&S.y?C:od(C,S)}}}};function KR(e,t){return!yh(e)||!yh(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function c7(e,t){return!yh(e)||!yh(t)||!KR(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function bt({label:e="Loading dashboard data…"}){return s.jsx("div",{className:"flex min-h-[240px] items-center justify-center",children:s.jsx("div",{className:"chrome-card !px-4 !py-3",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:e})})})}function Rt({title:e="Something went wrong",error:t,action:n,onRetry:r,retryLabel:o="Retry"}){const i=n??(r?s.jsxs("button",{type:"button",onClick:r,className:"shell-action",children:[s.jsx(EO,{className:"h-4 w-4"}),s.jsx("span",{children:o})]}):null);return s.jsx("div",{className:"rounded-lg border border-error-foreground/30 bg-error px-4 py-5",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"text-lg font-semibold text-error-foreground",children:e}),s.jsx("p",{className:"text-sm leading-6 text-error-foreground/90",children:t}),i?s.jsx("div",{className:"pt-2",children:i}):null]})})}function Vp({command:e,description:t,example:n}){return s.jsxs("div",{className:"rounded-lg border border-border/70 bg-code px-3 py-3 text-code-foreground shadow-sm",children:[s.jsx("code",{className:"block overflow-x-auto font-mono text-sm",children:e}),t?s.jsx("p",{className:"mt-2 text-sm text-code-foreground/80",children:t}):null,n?s.jsx("p",{className:"mt-2 font-mono text-xs text-code-foreground/60",children:n}):null]})}function qe({title:e,description:t,children:n,className:r,actions:o}){return s.jsxs("section",{className:je("surface-panel space-y-3",r),children:[e||o?s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[e?s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:e}):null,t?s.jsx("p",{className:"text-sm text-muted-foreground",children:t}):null]}),o]}):null,n]})}function u7({help:e,compact:t=!1}){const n=t?(e==null?void 0:e.firstProjectChecklist.slice(0,3))??[]:(e==null?void 0:e.firstProjectChecklist)??[];return s.jsx(qe,{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:s.jsx(De,{className:"text-sm font-semibold text-primary hover:underline",to:"/help",children:"Open full help"}),children:s.jsx("div",{className:"space-y-3",children:n.map((r,o)=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.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}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:r.title}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:r.detail}),r.command?s.jsx(Vp,{command:r.command.command,example:r.command.example}):null]})]})},r.title))})})}const xy={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."},pa={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 d7(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>String(t[r]??`{${r}}`))}function f7({hero:e,itemsById:t}){const n=mn();if(e.kind==="clean")return s.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-border/60 bg-background/60 p-6 shadow-sm",children:[s.jsx("p",{className:"eyebrow",children:pa.emptyStateCleanTitle}),s.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:xy.clean}),s.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."}),s.jsx("div",{className:"mt-4",children:s.jsx(De,{to:`${n}/projects`,className:"shell-action shell-action--cta",children:pa.emptyStateCleanCTA})})]});const r=e.itemId?t[e.itemId]:void 0,o=(r==null?void 0:r.assignmentTitle)??"",i=xy[e.copyKey]??xy[e.kind],a=d7(i,{total:e.total,title:o}),l=r?p7(r,n):`${n}/assignments`;return s.jsxs("section",{"aria-labelledby":"overview-hero-title",className:"rounded-xl border border-primary/20 bg-primary/5 p-6 shadow-sm",children:[s.jsx("p",{className:"eyebrow",children:"Top priority"}),s.jsx("h2",{id:"overview-hero-title",className:"mt-2 text-2xl font-semibold tracking-tight text-foreground",children:a}),r?s.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["In ",s.jsx("span",{className:"font-medium text-foreground",children:r.projectTitle??"Standalone"})," ","· status ",s.jsx("span",{className:"font-medium text-foreground",children:r.status})]}):null,s.jsx("div",{className:"mt-4",children:s.jsxs(De,{to:l,className:"shell-action shell-action--cta",children:["Open ",o||"assignment"]})})]})}function p7(e,t){return e.projectSlug?`${t}${e.href}`:e.href}const yy=["title","status","priority","assignee","dependencies","created","updated"],ad=24,GR=60;function h7(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return Number.isInteger(t.w)&&t.w>=1&&t.w<=ad&&Number.isInteger(t.h)&&t.h>=1&&t.h<=GR}const m7={status:"all",priority:"all",assignee:"all",project:"all",activity:"all"},yS="2026-05-21T00:00:00Z";function by(e,t,n){return{id:e,name:t,workspace:null,entityType:"assignment",config:{viewMode:"list",filters:{...m7,...n},sortField:"updated",sortDirection:"desc",listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}},createdAt:yS,updatedAt:yS}}const bi={version:1,views:[by("default-recently-updated","Recently updated",{}),by("default-high-priority","High priority",{priority:"high"}),by("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 YR(e,t){const n=Ve(e.filters.project),r=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,a=e.filters.query,l=typeof a=="string"&&a.trim().length>0&&Fu(a)===null;return r&&(!o||o==="all")&&!i&&!l}function XR(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?YR(e.config,t.slug):!1}}const QR=`syntaur.savedViews.cache.v${bi.version}`;let Ul=g7(),ta=null,Pw=null;const Mb=new Set,bh=new Set;let JR=0;function ZR(){return++JR}function Ob(e){return e===JR}function g7(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(QR);if(!e)return null;const t=JSON.parse(e);return t.version!==bi.version?null:t}catch{return null}}function x7(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(QR,JSON.stringify(e))}catch{}}function eA(e){Ul=e,Pw=null,x7(e);for(const t of Mb)t(e);for(const t of bh)t(null)}function y7(e){Pw=e;for(const t of bh)t(e)}function tA(e){if(!e||typeof e!="object")return bi;const t=e;return t.version!==bi.version||!Array.isArray(t.views)||!t.dashboard?bi:t}function bS(){if(ta)return ta;const e=ZR();return ta=fetch("/api/saved-views").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=tA(t);return Ob(e)&&eA(n),ta=null,Ul??n}).catch(t=>{const n=t instanceof Error?t:new Error(String(t));return Ob(e)&&y7(n),ta=null,Ul??bi}),ta}function _w(){const[e,t]=m.useState(()=>Ul??bi),[n,r]=m.useState(()=>Ul===null),[o,i]=m.useState(!1),[a,l]=m.useState(()=>Pw);return m.useEffect(()=>{let f=!1;Ul===null&&r(!0),bS().then(g=>{f||(t(g),r(!1),i(!0))});const p=g=>{f||(t(g),r(!1),i(!0),l(null))},h=g=>{f||(l(g),r(!1),i(!0))};return Mb.add(p),bh.add(h),()=>{f=!0,Mb.delete(p),bh.delete(h)}},[]),{file:e,loading:n,ready:o,error:a,refetch:()=>{ta=null,r(!0),l(null),i(!1),bS()}}}function zd(){const{file:e,loading:t}=_w();return{views:e.views,loading:t}}function nA(){const{file:e,loading:t}=_w();return{layout:e.dashboard,loading:t}}function ki(e){const{file:t,loading:n,ready:r,error:o,refetch:i}=_w();return e?{view:t.views.find(l=>l.id===e)??null,loading:n,ready:r,error:o,refetch:i}:{view:null,loading:!1,ready:!0,error:null,refetch:i}}async function Em(e,t,n){const r=ZR(),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 a=await o.json().catch(()=>({error:`HTTP ${o.status}`}));throw new Error(a.error??`HTTP ${o.status}`)}const i=tA(await o.json());return Ob(r)&&eA(i),i}function Zl(e){return Em("POST","/api/saved-views",e)}function vh(e,t){return Em("PATCH",`/api/saved-views/${encodeURIComponent(e)}`,t)}function b7(e){return Em("DELETE",`/api/saved-views/${encodeURIComponent(e)}`)}function Fb(e){return Em("PUT","/api/dashboard",{slots:e})}const v7=["top","right","bottom","left"],Si=Math.min,Mr=Math.max,wh=Math.round,dp=Math.floor,Js=e=>({x:e,y:e}),w7={left:"right",right:"left",bottom:"top",top:"bottom"};function zb(e,t,n){return Mr(e,Si(t,n))}function To(e,t){return typeof e=="function"?e(t):e}function Ro(e){return e.split("-")[0]}function Nc(e){return e.split("-")[1]}function Dw(e){return e==="x"?"y":"x"}function $w(e){return e==="y"?"height":"width"}function Gs(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Iw(e){return Dw(Gs(e))}function j7(e,t,n){n===void 0&&(n=!1);const r=Nc(e),o=Iw(e),i=$w(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=jh(a)),[a,jh(a)]}function k7(e){const t=jh(e);return[Bb(e),t,Bb(t)]}function Bb(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const vS=["left","right"],wS=["right","left"],S7=["top","bottom"],N7=["bottom","top"];function C7(e,t,n){switch(e){case"top":case"bottom":return n?t?wS:vS:t?vS:wS;case"left":case"right":return t?S7:N7;default:return[]}}function E7(e,t,n,r){const o=Nc(e);let i=C7(Ro(e),n==="start",r);return o&&(i=i.map(a=>a+"-"+o),t&&(i=i.concat(i.map(Bb)))),i}function jh(e){const t=Ro(e);return w7[t]+e.slice(t.length)}function T7(e){return{top:0,right:0,bottom:0,left:0,...e}}function rA(e){return typeof e!="number"?T7(e):{top:e,right:e,bottom:e,left:e}}function kh(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function jS(e,t,n){let{reference:r,floating:o}=e;const i=Gs(t),a=Iw(t),l=$w(a),u=Ro(t),f=i==="y",p=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,g=r[l]/2-o[l]/2;let y;switch(u){case"top":y={x:p,y:r.y-o.height};break;case"bottom":y={x:p,y:r.y+r.height};break;case"right":y={x:r.x+r.width,y:h};break;case"left":y={x:r.x-o.width,y:h};break;default:y={x:r.x,y:r.y}}switch(Nc(t)){case"start":y[a]-=g*(n&&f?-1:1);break;case"end":y[a]+=g*(n&&f?-1:1);break}return y}async function R7(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:a,elements:l,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:p="viewport",elementContext:h="floating",altBoundary:g=!1,padding:y=0}=To(t,e),k=rA(y),b=l[g?h==="floating"?"reference":"floating":h],j=kh(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:f,rootBoundary:p,strategy:u})),N=h==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),C=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},D=kh(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:N,offsetParent:S,strategy:u}):N);return{top:(j.top-D.top+k.top)/C.y,bottom:(D.bottom-j.bottom+k.bottom)/C.y,left:(j.left-D.left+k.left)/C.x,right:(D.right-j.right+k.right)/C.x}}const A7=50,P7=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:R7},u=await(a.isRTL==null?void 0:a.isRTL(t));let f=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:p,y:h}=jS(f,r,u),g=r,y=0;const k={};for(let v=0;v<i.length;v++){const b=i[v];if(!b)continue;const{name:j,fn:N}=b,{x:S,y:C,data:D,reset:T}=await N({x:p,y:h,initialPlacement:r,placement:g,strategy:o,middlewareData:k,rects:f,platform:l,elements:{reference:e,floating:t}});p=S??p,h=C??h,k[j]={...k[j],...D},T&&y<A7&&(y++,typeof T=="object"&&(T.placement&&(g=T.placement),T.rects&&(f=T.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:p,y:h}=jS(f,g,u)),v=-1)}return{x:p,y:h,placement:g,strategy:o,middlewareData:k}},_7=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:a,elements:l,middlewareData:u}=t,{element:f,padding:p=0}=To(e,t)||{};if(f==null)return{};const h=rA(p),g={x:n,y:r},y=Iw(o),k=$w(y),v=await a.getDimensions(f),b=y==="y",j=b?"top":"left",N=b?"bottom":"right",S=b?"clientHeight":"clientWidth",C=i.reference[k]+i.reference[y]-g[y]-i.floating[k],D=g[y]-i.reference[y],T=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let R=T?T[S]:0;(!R||!await(a.isElement==null?void 0:a.isElement(T)))&&(R=l.floating[S]||i.floating[k]);const $=C/2-D/2,P=R/2-v[k]/2-1,F=Si(h[j],P),_=Si(h[N],P),V=F,U=R-v[k]-_,I=R/2-v[k]/2+$,M=zb(V,I,U),B=!u.arrow&&Nc(o)!=null&&I!==M&&i.reference[k]/2-(I<V?F:_)-v[k]/2<0,W=B?I<V?I-V:I-U:0;return{[y]:g[y]+W,data:{[y]:M,centerOffset:I-M-W,...B&&{alignmentOffset:W}},reset:B}}}),D7=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:a,initialPlacement:l,platform:u,elements:f}=t,{mainAxis:p=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:v=!0,...b}=To(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const j=Ro(o),N=Gs(l),S=Ro(l)===l,C=await(u.isRTL==null?void 0:u.isRTL(f.floating)),D=g||(S||!v?[jh(l)]:k7(l)),T=k!=="none";!g&&T&&D.push(...E7(l,v,k,C));const R=[l,...D],$=await u.detectOverflow(t,b),P=[];let F=((r=i.flip)==null?void 0:r.overflows)||[];if(p&&P.push($[j]),h){const I=j7(o,a,C);P.push($[I[0]],$[I[1]])}if(F=[...F,{placement:o,overflows:P}],!P.every(I=>I<=0)){var _,V;const I=(((_=i.flip)==null?void 0:_.index)||0)+1,M=R[I];if(M&&(!(h==="alignment"?N!==Gs(M):!1)||F.every(O=>Gs(O.placement)===N?O.overflows[0]>0:!0)))return{data:{index:I,overflows:F},reset:{placement:M}};let B=(V=F.filter(W=>W.overflows[0]<=0).sort((W,O)=>W.overflows[1]-O.overflows[1])[0])==null?void 0:V.placement;if(!B)switch(y){case"bestFit":{var U;const W=(U=F.filter(O=>{if(T){const H=Gs(O.placement);return H===N||H==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(H=>H>0).reduce((H,L)=>H+L,0)]).sort((O,H)=>O[1]-H[1])[0])==null?void 0:U[0];W&&(B=W);break}case"initialPlacement":B=l;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function kS(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function SS(e){return v7.some(t=>e[t]>=0)}const $7=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=To(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...i,elementContext:"reference"}),l=kS(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:SS(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...i,altBoundary:!0}),l=kS(a,n.floating);return{data:{escapedOffsets:l,escaped:SS(l)}}}default:return{}}}}},sA=new Set(["left","top"]);async function I7(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Ro(n),l=Nc(n),u=Gs(n)==="y",f=sA.has(a)?-1:1,p=i&&u?-1:1,h=To(t,e);let{mainAxis:g,crossAxis:y,alignmentAxis:k}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof k=="number"&&(y=l==="end"?k*-1:k),u?{x:y*p,y:g*f}:{x:g*f,y:y*p}}const L7=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:a,middlewareData:l}=t,u=await I7(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:a}}}}},M7=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:j=>{let{x:N,y:S}=j;return{x:N,y:S}}},...f}=To(e,t),p={x:n,y:r},h=await i.detectOverflow(t,f),g=Gs(Ro(o)),y=Dw(g);let k=p[y],v=p[g];if(a){const j=y==="y"?"top":"left",N=y==="y"?"bottom":"right",S=k+h[j],C=k-h[N];k=zb(S,k,C)}if(l){const j=g==="y"?"top":"left",N=g==="y"?"bottom":"right",S=v+h[j],C=v-h[N];v=zb(S,v,C)}const b=u.fn({...t,[y]:k,[g]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[y]:a,[g]:l}}}}}},O7=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:a}=t,{offset:l=0,mainAxis:u=!0,crossAxis:f=!0}=To(e,t),p={x:n,y:r},h=Gs(o),g=Dw(h);let y=p[g],k=p[h];const v=To(l,t),b=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(u){const S=g==="y"?"height":"width",C=i.reference[g]-i.floating[S]+b.mainAxis,D=i.reference[g]+i.reference[S]-b.mainAxis;y<C?y=C:y>D&&(y=D)}if(f){var j,N;const S=g==="y"?"width":"height",C=sA.has(Ro(o)),D=i.reference[h]-i.floating[S]+(C&&((j=a.offset)==null?void 0:j[h])||0)+(C?0:b.crossAxis),T=i.reference[h]+i.reference[S]+(C?0:((N=a.offset)==null?void 0:N[h])||0)-(C?b.crossAxis:0);k<D?k=D:k>T&&(k=T)}return{[g]:y,[h]:k}}}},F7=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:a,elements:l}=t,{apply:u=()=>{},...f}=To(e,t),p=await a.detectOverflow(t,f),h=Ro(o),g=Nc(o),y=Gs(o)==="y",{width:k,height:v}=i.floating;let b,j;h==="top"||h==="bottom"?(b=h,j=g===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(j=h,b=g==="end"?"top":"bottom");const N=v-p.top-p.bottom,S=k-p.left-p.right,C=Si(v-p[b],N),D=Si(k-p[j],S),T=!t.middlewareData.shift;let R=C,$=D;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&($=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(R=N),T&&!g){const F=Mr(p.left,0),_=Mr(p.right,0),V=Mr(p.top,0),U=Mr(p.bottom,0);y?$=k-2*(F!==0||_!==0?F+_:Mr(p.left,p.right)):R=v-2*(V!==0||U!==0?V+U:Mr(p.top,p.bottom))}await u({...t,availableWidth:$,availableHeight:R});const P=await a.getDimensions(l.floating);return k!==P.width||v!==P.height?{reset:{rects:!0}}:{}}}};function Tm(){return typeof window<"u"}function Cc(e){return oA(e)?(e.nodeName||"").toLowerCase():"#document"}function Ur(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function no(e){var t;return(t=(oA(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function oA(e){return Tm()?e instanceof Node||e instanceof Ur(e).Node:!1}function Ss(e){return Tm()?e instanceof Element||e instanceof Ur(e).Element:!1}function _o(e){return Tm()?e instanceof HTMLElement||e instanceof Ur(e).HTMLElement:!1}function NS(e){return!Tm()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ur(e).ShadowRoot}function Bd(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Ns(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function z7(e){return/^(table|td|th)$/.test(Cc(e))}function Rm(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const B7=/transform|translate|scale|rotate|perspective|filter/,U7=/paint|layout|strict|content/,Qi=e=>!!e&&e!=="none";let vy;function Lw(e){const t=Ss(e)?Ns(e):e;return Qi(t.transform)||Qi(t.translate)||Qi(t.scale)||Qi(t.rotate)||Qi(t.perspective)||!Mw()&&(Qi(t.backdropFilter)||Qi(t.filter))||B7.test(t.willChange||"")||U7.test(t.contain||"")}function H7(e){let t=Ni(e);for(;_o(t)&&!ec(t);){if(Lw(t))return t;if(Rm(t))return null;t=Ni(t)}return null}function Mw(){return vy==null&&(vy=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),vy}function ec(e){return/^(html|body|#document)$/.test(Cc(e))}function Ns(e){return Ur(e).getComputedStyle(e)}function Am(e){return Ss(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ni(e){if(Cc(e)==="html")return e;const t=e.assignedSlot||e.parentNode||NS(e)&&e.host||no(e);return NS(t)?t.host:t}function iA(e){const t=Ni(e);return ec(t)?e.ownerDocument?e.ownerDocument.body:e.body:_o(t)&&Bd(t)?t:iA(t)}function ld(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=iA(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),a=Ur(o);if(i){const l=Ub(a);return t.concat(a,a.visualViewport||[],Bd(o)?o:[],l&&n?ld(l):[])}else return t.concat(o,ld(o,[],n))}function Ub(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function aA(e){const t=Ns(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=_o(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:r,l=wh(n)!==i||wh(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function Ow(e){return Ss(e)?e:e.contextElement}function Hl(e){const t=Ow(e);if(!_o(t))return Js(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=aA(t);let a=(i?wh(n.width):n.width)/r,l=(i?wh(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const V7=Js(0);function lA(e){const t=Ur(e);return!Mw()||!t.visualViewport?V7:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function W7(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ur(e)?!1:t}function wa(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Ow(e);let a=Js(1);t&&(r?Ss(r)&&(a=Hl(r)):a=Hl(e));const l=W7(i,n,r)?lA(i):Js(0);let u=(o.left+l.x)/a.x,f=(o.top+l.y)/a.y,p=o.width/a.x,h=o.height/a.y;if(i){const g=Ur(i),y=r&&Ss(r)?Ur(r):r;let k=g,v=Ub(k);for(;v&&r&&y!==k;){const b=Hl(v),j=v.getBoundingClientRect(),N=Ns(v),S=j.left+(v.clientLeft+parseFloat(N.paddingLeft))*b.x,C=j.top+(v.clientTop+parseFloat(N.paddingTop))*b.y;u*=b.x,f*=b.y,p*=b.x,h*=b.y,u+=S,f+=C,k=Ur(v),v=Ub(k)}}return kh({width:p,height:h,x:u,y:f})}function Pm(e,t){const n=Am(e).scrollLeft;return t?t.left+n:wa(no(e)).left+n}function cA(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Pm(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function q7(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",a=no(r),l=t?Rm(t.floating):!1;if(r===a||l&&i)return n;let u={scrollLeft:0,scrollTop:0},f=Js(1);const p=Js(0),h=_o(r);if((h||!h&&!i)&&((Cc(r)!=="body"||Bd(a))&&(u=Am(r)),h)){const y=wa(r);f=Hl(r),p.x=y.x+r.clientLeft,p.y=y.y+r.clientTop}const g=a&&!h&&!i?cA(a,u):Js(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-u.scrollLeft*f.x+p.x+g.x,y:n.y*f.y-u.scrollTop*f.y+p.y+g.y}}function K7(e){return Array.from(e.getClientRects())}function G7(e){const t=no(e),n=Am(e),r=e.ownerDocument.body,o=Mr(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Mr(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Pm(e);const l=-n.scrollTop;return Ns(r).direction==="rtl"&&(a+=Mr(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:a,y:l}}const CS=25;function Y7(e,t){const n=Ur(e),r=no(e),o=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,u=0;if(o){i=o.width,a=o.height;const p=Mw();(!p||p&&t==="fixed")&&(l=o.offsetLeft,u=o.offsetTop)}const f=Pm(r);if(f<=0){const p=r.ownerDocument,h=p.body,g=getComputedStyle(h),y=p.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,k=Math.abs(r.clientWidth-h.clientWidth-y);k<=CS&&(i-=k)}else f<=CS&&(i+=f);return{width:i,height:a,x:l,y:u}}function X7(e,t){const n=wa(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=_o(e)?Hl(e):Js(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,u=o*i.x,f=r*i.y;return{width:a,height:l,x:u,y:f}}function ES(e,t,n){let r;if(t==="viewport")r=Y7(e,n);else if(t==="document")r=G7(no(e));else if(Ss(t))r=X7(t,n);else{const o=lA(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return kh(r)}function uA(e,t){const n=Ni(e);return n===t||!Ss(n)||ec(n)?!1:Ns(n).position==="fixed"||uA(n,t)}function Q7(e,t){const n=t.get(e);if(n)return n;let r=ld(e,[],!1).filter(l=>Ss(l)&&Cc(l)!=="body"),o=null;const i=Ns(e).position==="fixed";let a=i?Ni(e):e;for(;Ss(a)&&!ec(a);){const l=Ns(a),u=Lw(a);!u&&l.position==="fixed"&&(o=null),(i?!u&&!o:!u&&l.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Bd(a)&&!u&&uA(e,a))?r=r.filter(p=>p!==a):o=l,a=Ni(a)}return t.set(e,r),r}function J7(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?Rm(t)?[]:Q7(t,this._c):[].concat(n),r],l=ES(t,a[0],o);let u=l.top,f=l.right,p=l.bottom,h=l.left;for(let g=1;g<a.length;g++){const y=ES(t,a[g],o);u=Mr(y.top,u),f=Si(y.right,f),p=Si(y.bottom,p),h=Mr(y.left,h)}return{width:f-h,height:p-u,x:h,y:u}}function Z7(e){const{width:t,height:n}=aA(e);return{width:t,height:n}}function eU(e,t,n){const r=_o(t),o=no(t),i=n==="fixed",a=wa(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const u=Js(0);function f(){u.x=Pm(o)}if(r||!r&&!i)if((Cc(t)!=="body"||Bd(o))&&(l=Am(t)),r){const y=wa(t,!0,i,t);u.x=y.x+t.clientLeft,u.y=y.y+t.clientTop}else o&&f();i&&!r&&o&&f();const p=o&&!r&&!i?cA(o,l):Js(0),h=a.left+l.scrollLeft-u.x-p.x,g=a.top+l.scrollTop-u.y-p.y;return{x:h,y:g,width:a.width,height:a.height}}function wy(e){return Ns(e).position==="static"}function TS(e,t){if(!_o(e)||Ns(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return no(e)===n&&(n=n.ownerDocument.body),n}function dA(e,t){const n=Ur(e);if(Rm(e))return n;if(!_o(e)){let o=Ni(e);for(;o&&!ec(o);){if(Ss(o)&&!wy(o))return o;o=Ni(o)}return n}let r=TS(e,t);for(;r&&z7(r)&&wy(r);)r=TS(r,t);return r&&ec(r)&&wy(r)&&!Lw(r)?n:r||H7(e)||n}const tU=async function(e){const t=this.getOffsetParent||dA,n=this.getDimensions,r=await n(e.floating);return{reference:eU(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function nU(e){return Ns(e).direction==="rtl"}const rU={convertOffsetParentRelativeRectToViewportRelativeRect:q7,getDocumentElement:no,getClippingRect:J7,getOffsetParent:dA,getElementRects:tU,getClientRects:K7,getDimensions:Z7,getScale:Hl,isElement:Ss,isRTL:nU};function fA(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function sU(e,t){let n=null,r;const o=no(e);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),i();const f=e.getBoundingClientRect(),{left:p,top:h,width:g,height:y}=f;if(l||t(),!g||!y)return;const k=dp(h),v=dp(o.clientWidth-(p+g)),b=dp(o.clientHeight-(h+y)),j=dp(p),S={rootMargin:-k+"px "+-v+"px "+-b+"px "+-j+"px",threshold:Mr(0,Si(1,u))||1};let C=!0;function D(T){const R=T[0].intersectionRatio;if(R!==u){if(!C)return a();R?a(!1,R):r=setTimeout(()=>{a(!1,1e-7)},1e3)}R===1&&!fA(f,e.getBoundingClientRect())&&a(),C=!1}try{n=new IntersectionObserver(D,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(D,S)}n.observe(e)}return a(!0),i}function oU(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=Ow(e),p=o||i?[...f?ld(f):[],...t?ld(t):[]]:[];p.forEach(j=>{o&&j.addEventListener("scroll",n,{passive:!0}),i&&j.addEventListener("resize",n)});const h=f&&l?sU(f,n):null;let g=-1,y=null;a&&(y=new ResizeObserver(j=>{let[N]=j;N&&N.target===f&&y&&t&&(y.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var S;(S=y)==null||S.observe(t)})),n()}),f&&!u&&y.observe(f),t&&y.observe(t));let k,v=u?wa(e):null;u&&b();function b(){const j=wa(e);v&&!fA(v,j)&&n(),v=j,k=requestAnimationFrame(b)}return n(),()=>{var j;p.forEach(N=>{o&&N.removeEventListener("scroll",n),i&&N.removeEventListener("resize",n)}),h==null||h(),(j=y)==null||j.disconnect(),y=null,u&&cancelAnimationFrame(k)}}const iU=L7,aU=M7,lU=D7,cU=F7,uU=$7,RS=_7,dU=O7,fU=(e,t,n)=>{const r=new Map,o={platform:rU,...n},i={...o.platform,_c:r};return P7(e,t,{...o,platform:i})};var pU=typeof document<"u",hU=function(){},Wp=pU?m.useLayoutEffect:hU;function Sh(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,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Sh(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Sh(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function pA(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function AS(e,t){const n=pA(e);return Math.round(t*n)/n}function jy(e){const t=m.useRef(e);return Wp(()=>{t.current=e}),t}function mU(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:u,open:f}=e,[p,h]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,y]=m.useState(r);Sh(g,r)||y(r);const[k,v]=m.useState(null),[b,j]=m.useState(null),N=m.useCallback(O=>{O!==T.current&&(T.current=O,v(O))},[]),S=m.useCallback(O=>{O!==R.current&&(R.current=O,j(O))},[]),C=i||k,D=a||b,T=m.useRef(null),R=m.useRef(null),$=m.useRef(p),P=u!=null,F=jy(u),_=jy(o),V=jy(f),U=m.useCallback(()=>{if(!T.current||!R.current)return;const O={placement:t,strategy:n,middleware:g};_.current&&(O.platform=_.current),fU(T.current,R.current,O).then(H=>{const L={...H,isPositioned:V.current!==!1};I.current&&!Sh($.current,L)&&($.current=L,jo.flushSync(()=>{h(L)}))})},[g,t,n,_,V]);Wp(()=>{f===!1&&$.current.isPositioned&&($.current.isPositioned=!1,h(O=>({...O,isPositioned:!1})))},[f]);const I=m.useRef(!1);Wp(()=>(I.current=!0,()=>{I.current=!1}),[]),Wp(()=>{if(C&&(T.current=C),D&&(R.current=D),C&&D){if(F.current)return F.current(C,D,U);U()}},[C,D,U,F,P]);const M=m.useMemo(()=>({reference:T,floating:R,setReference:N,setFloating:S}),[N,S]),B=m.useMemo(()=>({reference:C,floating:D}),[C,D]),W=m.useMemo(()=>{const O={position:n,left:0,top:0};if(!B.floating)return O;const H=AS(B.floating,p.x),L=AS(B.floating,p.y);return l?{...O,transform:"translate("+H+"px, "+L+"px)",...pA(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:H,top:L}},[n,l,B.floating,p.x,p.y]);return m.useMemo(()=>({...p,update:U,refs:M,elements:B,floatingStyles:W}),[p,U,M,B,W])}const gU=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?RS({element:r.current,padding:o}).fn(n):{}:r?RS({element:r,padding:o}).fn(n):{}}}},xU=(e,t)=>{const n=iU(e);return{name:n.name,fn:n.fn,options:[e,t]}},yU=(e,t)=>{const n=aU(e);return{name:n.name,fn:n.fn,options:[e,t]}},bU=(e,t)=>({fn:dU(e).fn,options:[e,t]}),vU=(e,t)=>{const n=lU(e);return{name:n.name,fn:n.fn,options:[e,t]}},wU=(e,t)=>{const n=cU(e);return{name:n.name,fn:n.fn,options:[e,t]}},jU=(e,t)=>{const n=uU(e);return{name:n.name,fn:n.fn,options:[e,t]}},kU=(e,t)=>{const n=gU(e);return{name:n.name,fn:n.fn,options:[e,t]}};var SU="Arrow",hA=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return s.jsx(Sn.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});hA.displayName=SU;var NU=hA;function CU(e){const[t,n]=m.useState(void 0);return wi(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let a,l;if("borderBoxSize"in i){const u=i.borderBoxSize,f=Array.isArray(u)?u[0]:u;a=f.inlineSize,l=f.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Fw="Popper",[mA,gA]=Ta(Fw),[EU,xA]=mA(Fw),yA=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return s.jsx(EU,{scope:t,anchor:r,onAnchorChange:o,children:n})};yA.displayName=Fw;var bA="PopperAnchor",vA=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=xA(bA,n),a=m.useRef(null),l=nr(t,a),u=m.useRef(null);return m.useEffect(()=>{const f=u.current;u.current=(r==null?void 0:r.current)||a.current,f!==u.current&&i.onAnchorChange(u.current)}),r?null:s.jsx(Sn.div,{...o,ref:l})});vA.displayName=bA;var zw="PopperContent",[TU,RU]=mA(zw),wA=m.forwardRef((e,t)=>{var ie,ne,ue,ge,Ne,Ce;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:f=[],collisionPadding:p=0,sticky:h="partial",hideWhenDetached:g=!1,updatePositionStrategy:y="optimized",onPlaced:k,...v}=e,b=xA(zw,n),[j,N]=m.useState(null),S=nr(t,ke=>N(ke)),[C,D]=m.useState(null),T=CU(C),R=(T==null?void 0:T.width)??0,$=(T==null?void 0:T.height)??0,P=r+(i!=="center"?"-"+i:""),F=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},_=Array.isArray(f)?f:[f],V=_.length>0,U={padding:F,boundary:_.filter(PU),altBoundary:V},{refs:I,floatingStyles:M,placement:B,isPositioned:W,middlewareData:O}=mU({strategy:"fixed",placement:P,whileElementsMounted:(...ke)=>oU(...ke,{animationFrame:y==="always"}),elements:{reference:b.anchor},middleware:[xU({mainAxis:o+$,alignmentAxis:a}),u&&yU({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?bU():void 0,...U}),u&&vU({...U}),wU({...U,apply:({elements:ke,rects:Ue,availableWidth:oe,availableHeight:ve})=>{const{width:be,height:Re}=Ue.reference,He=ke.floating.style;He.setProperty("--radix-popper-available-width",`${oe}px`),He.setProperty("--radix-popper-available-height",`${ve}px`),He.setProperty("--radix-popper-anchor-width",`${be}px`),He.setProperty("--radix-popper-anchor-height",`${Re}px`)}}),C&&kU({element:C,padding:l}),_U({arrowWidth:R,arrowHeight:$}),g&&jU({strategy:"referenceHidden",...U})]}),[H,L]=SA(B),z=ba(k);wi(()=>{W&&(z==null||z())},[W,z]);const Y=(ie=O.arrow)==null?void 0:ie.x,q=(ne=O.arrow)==null?void 0:ne.y,Q=((ue=O.arrow)==null?void 0:ue.centerOffset)!==0,[ee,Z]=m.useState();return wi(()=>{j&&Z(window.getComputedStyle(j).zIndex)},[j]),s.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...M,transform:W?M.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[(ge=O.transformOrigin)==null?void 0:ge.x,(Ne=O.transformOrigin)==null?void 0:Ne.y].join(" "),...((Ce=O.hide)==null?void 0:Ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(TU,{scope:n,placedSide:H,onArrowChange:D,arrowX:Y,arrowY:q,shouldHideArrow:Q,children:s.jsx(Sn.div,{"data-side":H,"data-align":L,...v,ref:S,style:{...v.style,animation:W?void 0:"none"}})})})});wA.displayName=zw;var jA="PopperArrow",AU={top:"bottom",right:"left",bottom:"top",left:"right"},kA=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=RU(jA,r),a=AU[i.placedSide];return s.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]: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:s.jsx(NU,{...o,ref:n,style:{...o.style,display:"block"}})})});kA.displayName=jA;function PU(e){return e!==null}var _U=e=>({name:"transformOrigin",options:e,fn(t){var b,j,N;const{placement:n,rects:r,middlewareData:o}=t,a=((b=o.arrow)==null?void 0:b.centerOffset)!==0,l=a?0:e.arrowWidth,u=a?0:e.arrowHeight,[f,p]=SA(n),h={start:"0%",center:"50%",end:"100%"}[p],g=(((j=o.arrow)==null?void 0:j.x)??0)+l/2,y=(((N=o.arrow)==null?void 0:N.y)??0)+u/2;let k="",v="";return f==="bottom"?(k=a?h:`${g}px`,v=`${-u}px`):f==="top"?(k=a?h:`${g}px`,v=`${r.floating.height+u}px`):f==="right"?(k=`${-u}px`,v=a?h:`${y}px`):f==="left"&&(k=`${r.floating.width+u}px`,v=a?h:`${y}px`),{data:{x:k,y:v}}}});function SA(e){const[t,n="center"]=e.split("-");return[t,n]}var DU=yA,$U=vA,IU=wA,LU=kA,MU=Symbol("radix.slottable");function OU(e){const t=({children:n})=>s.jsx(s.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=MU,t}var FU=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"}),zU="VisuallyHidden",NA=m.forwardRef((e,t)=>s.jsx(Sn.span,{...e,ref:t,style:{...FU,...e.style}}));NA.displayName=zU;var BU=NA,[_m]=Ta("Tooltip",[gA]),Dm=gA(),CA="TooltipProvider",UU=700,Hb="tooltip.open",[HU,Bw]=_m(CA),EA=e=>{const{__scopeTooltip:t,delayDuration:n=UU,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,a=m.useRef(!0),l=m.useRef(!1),u=m.useRef(0);return m.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),s.jsx(HU,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(u.current),a.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:m.useCallback(f=>{l.current=f},[]),disableHoverableContent:o,children:i})};EA.displayName=CA;var cd="Tooltip",[VU,Ud]=_m(cd),TA=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=e,u=Bw(cd,e.__scopeTooltip),f=Dm(t),[p,h]=m.useState(null),g=Ml(),y=m.useRef(0),k=a??u.disableHoverableContent,v=l??u.delayDuration,b=m.useRef(!1),[j,N]=pm({prop:r,defaultProp:o??!1,onChange:R=>{R?(u.onOpen(),document.dispatchEvent(new CustomEvent(Hb))):u.onClose(),i==null||i(R)},caller:cd}),S=m.useMemo(()=>j?b.current?"delayed-open":"instant-open":"closed",[j]),C=m.useCallback(()=>{window.clearTimeout(y.current),y.current=0,b.current=!1,N(!0)},[N]),D=m.useCallback(()=>{window.clearTimeout(y.current),y.current=0,N(!1)},[N]),T=m.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{b.current=!0,N(!0),y.current=0},v)},[v,N]);return m.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]),s.jsx(DU,{...f,children:s.jsx(VU,{scope:t,contentId:g,open:j,stateAttribute:S,trigger:p,onTriggerChange:h,onTriggerEnter:m.useCallback(()=>{u.isOpenDelayedRef.current?T():C()},[u.isOpenDelayedRef,T,C]),onTriggerLeave:m.useCallback(()=>{k?D():(window.clearTimeout(y.current),y.current=0)},[D,k]),onOpen:C,onClose:D,disableHoverableContent:k,children:n})})};TA.displayName=cd;var Vb="TooltipTrigger",RA=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Ud(Vb,n),i=Bw(Vb,n),a=Dm(n),l=m.useRef(null),u=nr(t,l,o.onTriggerChange),f=m.useRef(!1),p=m.useRef(!1),h=m.useCallback(()=>f.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),s.jsx($U,{asChild:!0,...a,children:s.jsx(Sn.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:sn(e.onPointerMove,g=>{g.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:sn(e.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:sn(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:sn(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:sn(e.onBlur,o.onClose),onClick:sn(e.onClick,o.onClose)})})});RA.displayName=Vb;var Uw="TooltipPortal",[WU,qU]=_m(Uw,{forceMount:void 0}),AA=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Ud(Uw,t);return s.jsx(WU,{scope:t,forceMount:n,children:s.jsx(Ra,{present:n||i.open,children:s.jsx(aw,{asChild:!0,container:o,children:r})})})};AA.displayName=Uw;var tc="TooltipContent",PA=m.forwardRef((e,t)=>{const n=qU(tc,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=Ud(tc,e.__scopeTooltip);return s.jsx(Ra,{present:r||a.open,children:a.disableHoverableContent?s.jsx(_A,{side:o,...i,ref:t}):s.jsx(KU,{side:o,...i,ref:t})})}),KU=m.forwardRef((e,t)=>{const n=Ud(tc,e.__scopeTooltip),r=Bw(tc,e.__scopeTooltip),o=m.useRef(null),i=nr(t,o),[a,l]=m.useState(null),{trigger:u,onClose:f}=n,p=o.current,{onPointerInTransitChange:h}=r,g=m.useCallback(()=>{l(null),h(!1)},[h]),y=m.useCallback((k,v)=>{const b=k.currentTarget,j={x:k.clientX,y:k.clientY},N=JU(j,b.getBoundingClientRect()),S=ZU(j,N),C=eH(v.getBoundingClientRect()),D=nH([...S,...C]);l(D),h(!0)},[h]);return m.useEffect(()=>()=>g(),[g]),m.useEffect(()=>{if(u&&p){const k=b=>y(b,p),v=b=>y(b,u);return u.addEventListener("pointerleave",k),p.addEventListener("pointerleave",v),()=>{u.removeEventListener("pointerleave",k),p.removeEventListener("pointerleave",v)}}},[u,p,y,g]),m.useEffect(()=>{if(a){const k=v=>{const b=v.target,j={x:v.clientX,y:v.clientY},N=(u==null?void 0:u.contains(b))||(p==null?void 0:p.contains(b)),S=!tH(j,a);N?g():S&&(g(),f())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[u,p,a,f,g]),s.jsx(_A,{...e,ref:i})}),[GU,YU]=_m(cd,{isInside:!1}),XU=OU("TooltipContent"),_A=m.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=e,u=Ud(tc,n),f=Dm(n),{onClose:p}=u;return m.useEffect(()=>(document.addEventListener(Hb,p),()=>document.removeEventListener(Hb,p)),[p]),m.useEffect(()=>{if(u.trigger){const h=g=>{const y=g.target;y!=null&&y.contains(u.trigger)&&p()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,p]),s.jsx(iw,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:h=>h.preventDefault(),onDismiss:p,children:s.jsxs(IU,{"data-state":u.stateAttribute,...f,...l,ref:t,style:{...l.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:[s.jsx(XU,{children:r}),s.jsx(GU,{scope:n,isInside:!0,children:s.jsx(BU,{id:u.contentId,role:"tooltip",children:o||r})})]})})});PA.displayName=tc;var DA="TooltipArrow",QU=m.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Dm(n);return YU(DA,n).isInside?null:s.jsx(LU,{...o,...r,ref:t})});QU.displayName=DA;function JU(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function ZU(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function eH(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function tH(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const l=t[i],u=t[a],f=l.x,p=l.y,h=u.x,g=u.y;p>r!=g>r&&n<(h-f)*(r-p)/(g-p)+f&&(o=!o)}return o}function nH(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),rH(t)}function rH(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.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 sH=EA,oH=TA,iH=RA,aH=AA,$A=PA;const ha=sH,Or=oH,Fr=iH,vr=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(aH,{children:s.jsx($A,{ref:r,sideOffset:t,className:je("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})}));vr.displayName=$A.displayName;function Hw({items:e,align:t="end"}){const[n,r]=m.useState(!1),[o,i]=m.useState(null),a=m.useRef(null);if(m.useEffect(()=>{if(!n){i(null);return}function u(p){a.current&&!a.current.contains(p.target)&&r(!1)}function f(p){p.key==="Escape"&&r(!1)}return document.addEventListener("mousedown",u),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",f)}},[n]),e.length===0)return null;function l(u,f){const p=u.icon,h=je("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition",f&&"pl-8",u.disabled?"opacity-50 cursor-not-allowed":u.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),g=f?u.active?s.jsx(Sr,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):s.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}):p?s.jsx(p,{className:"h-4 w-4 shrink-0"}):null,y=s.jsxs(s.Fragment,{children:[g,s.jsx("span",{className:"block min-w-0 truncate",children:u.label})]});if(u.disabled){const k=s.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:s.jsx("button",{type:"button",disabled:!0,className:h,children:y})});return u.disabledReason?s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:k}),s.jsx(vr,{side:"left",children:u.disabledReason})]},u.key):s.jsx("div",{children:k},u.key)}return u.href?s.jsx(De,{to:u.href,className:h,onClick:()=>r(!1),children:y},u.key):s.jsx("button",{type:"button",className:h,onClick:()=>{var k;(k=u.onSelect)==null||k.call(u),r(!1)},children:y},u.key)}return s.jsxs("div",{className:"relative",ref:a,children:[s.jsx("button",{type:"button",onClick:()=>r(u=>!u),className:"shell-action",title:"More actions","aria-label":"More actions","aria-haspopup":"true","aria-expanded":n,children:s.jsx(oO,{className:"h-4 w-4"})}),n&&s.jsx("div",{className:je("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:s.jsx(ha,{delayDuration:200,children:e.map(u=>{if(u.submenu&&u.submenu.length>0){const f=u.icon,p=o===u.key;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",className:je("flex w-full items-center gap-2 px-3 py-1.5 text-sm text-left transition hover:bg-foreground/5"),"aria-expanded":p,onClick:()=>i(p?null:u.key),children:[f?s.jsx(f,{className:"h-4 w-4 shrink-0"}):null,s.jsx("span",{className:"block min-w-0 flex-1 truncate",children:u.label}),p?s.jsx(cr,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):s.jsx(c2,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]}),p?u.submenu.map(h=>l(h,!0)):null]},u.key)}return l(u,!1)})})})]})}function PS(e){const t=Date.parse(e);return Number.isNaN(t)?!1:Date.now()-t>10080*60*1e3}const lH={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 cH(e){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r,0,0,0,0).getTime()}function uH(e){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r,23,59,59,999).getTime()}function dH(e,t,n=Date.now()){if(!t)return!0;const r=t.field==="created"?e.created??e.updated:e.updated,o=Date.parse(r);if(Number.isNaN(o))return!1;if(t.preset){const l=lH[t.preset];return l===void 0?!0:t.preset.startsWith("older_")?n-o>l:o>=n-l&&o<=n}const i=t.from&&t.from.length>0?t.from:void 0,a=t.to&&t.to.length>0?t.to:void 0;return!i&&!a?!0:!(i&&o<cH(i)||a&&o>uH(a))}function fH(e,t,n={}){const{workspace:r,search:o,includeArchived:i}=n;if(e.archived===!0&&!i)return!1;const a=Ve(t.status),l=Ve(t.priority),u=Ve(t.type),f=Ve(t.assignee),p=Ve(t.project),h=Ve(t.tags),{activity:g}=t;if(r){if(r==="_ungrouped"){if(e.projectWorkspace!=null)return!1}else if(e.projectWorkspace!==r)return!1}if(a.length&&!a.includes(e.status)||l.length&&!l.includes(e.priority)||u.length&&!u.includes(e.type??"")||g==="stale"&&!PS(e.updated)||g==="fresh"&&PS(e.updated))return!1;if(f.length){const y=e.assignee??"__unassigned__";if(!f.includes(y))return!1}if(p.length&&!p.some(k=>k==="__standalone__"?e.projectSlug==null:e.projectSlug===k))return!1;if(h.length){const y=e.tags??[];if(!h.some(k=>y.includes(k)))return!1}if(!dH(e,t.dateRange))return!1;if(o){const y=o.trim().toLowerCase();if(y&&!`${e.title??""} ${e.slug??""} ${e.projectTitle??"standalone"} ${e.projectSlug??""}`.toLowerCase().includes(y))return!1}return!0}function ud(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}const _S={critical:0,high:1,medium:2,low:3};function fp(e){return Date.parse(e??"")||0}function Hd(e,t,n){return[...e].sort((o,i)=>{let a=0;switch(t){case"title":a=o.title.localeCompare(i.title);break;case"status":a=o.status.localeCompare(i.status);break;case"priority":a=(_S[o.priority]??99)-(_S[i.priority]??99);break;case"assignee":a=(o.assignee??"").localeCompare(i.assignee??"");break;case"dependencies":a=o.dependsOn.length-i.dependsOn.length;break;case"created":a=fp(o.created)-fp(i.created);break;case"updated":a=fp(o.updated)-fp(i.updated);break}return n==="asc"?a:-a})}function pH(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 IA(e,t,n={}){const{workspace:r,includeArchived:o=!1,now:i=Date.now()}=n,a={now:i};return e.filter(l=>{if(l.archived===!0&&!o)return!1;if(r){if(r==="_ungrouped"){if(l.projectWorkspace!=null)return!1}else if(l.projectWorkspace!==r)return!1}if(!t)return!0;const u=pH(l);return t.predicate(u,a)})}const $m={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 Im(e){const t=e.name,n={fact:t,approved:`${t}Approved`,changesRequested:`${t}ChangesRequested`,by:`${t}By`,approvedBy:`${t}ApprovedBy`},r=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:r}}function hH(e){const t=[];for(const n of e??[]){if(!n||typeof n.name!="string")continue;const r=n.name.trim();if(!/^[a-z][a-zA-Z0-9]*$/.test(r))continue;const o=(n.type??"").trim();if(o==="bool"||o==="number")t.push({name:r,type:o});else if(o==="attestation"){const i=(n.binds??"none").toString().trim()||"none";(i==="plan"||i==="commit"||i==="none")&&t.push({name:r,type:"attestation",binds:i})}}return t}function Wb(e){const t=[],n=new Map;for(const r of Object.keys($m))n.set(r,"built-in");for(const r of Object.keys(cm))n.set(r,"built-in");for(const r of e??[]){const o=((r==null?void 0:r.name)??"").trim();if(!/^[a-z][a-zA-Z0-9]*$/.test(o)){t.push(`fact "${(r==null?void 0:r.name)??""}": invalid name — must match /^[a-z][a-zA-Z0-9]*$/`);continue}const i=(r.type??"").trim();if(i!=="bool"&&i!=="number"&&i!=="attestation"){t.push(`fact "${o}": invalid type "${r.type??""}" — expected bool, number, or attestation`);continue}if(i==="attestation"){const f=(r.binds??"none").toString().trim()||"none";if(f!=="plan"&&f!=="commit"&&f!=="none"){t.push(`fact "${o}": invalid binds "${r.binds}" — expected plan, commit, or none`);continue}}const l=Im(i==="attestation"?{name:o,type:i}:{name:o,type:i}).registryKeys,u=l.find(f=>n.has(f));if(u!==void 0){const f=n.get(u);f==="built-in"?t.push(`fact "${o}": exported field "${u}" collides with a built-in field`):f===o?t.push(`fact "${o}": duplicate declaration (a fact named "${o}" is already declared)`):t.push(`fact "${o}": exported field "${u}" collides with fact "${f}"`);continue}for(const f of l)n.set(f,o)}return t}function mH(e){const t=new Set([...Object.keys($m),...Object.keys(cm)]),n=[];for(const r of e){const o=Im(r).registryKeys;if(!o.some(i=>t.has(i))){for(const i of o)t.add(i);n.push(r)}}return n}function LA(e,t){const n=Im(t);t.type==="attestation"?(e[n.exports.fact.toLowerCase()]={kind:"bool",get:r=>r[n.exports.fact]},e[n.exports.approved.toLowerCase()]={kind:"bool",get:r=>r[n.exports.approved]},e[n.exports.changesRequested.toLowerCase()]={kind:"bool",get:r=>r[n.exports.changesRequested]},e[n.exports.by.toLowerCase()]={kind:"list",get:r=>r[n.exports.by]},e[n.exports.approvedBy.toLowerCase()]={kind:"list",get:r=>r[n.exports.approvedBy]}):e[n.exports.fact.toLowerCase()]={kind:t.type,get:r=>r[n.exports.fact]}}function Vw(e){const t={...$m};for(const n of e)LA(t,n);return t}function MA(e){const t={...cm};for(const n of e)LA(t,n);return t}function OA(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 r of e){const o=Im(r);r.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 St({title:e,description:t,actions:n}){return s.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 px-4 py-6 text-center",children:s.jsxs("div",{className:"mx-auto max-w-xl space-y-2",children:[s.jsx("h3",{className:"text-base font-semibold text-foreground",children:e}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:t}),n?s.jsx("div",{className:"flex flex-wrap justify-center gap-3 pt-2",children:n}):null]})})}const nc='a, button, input, select, textarea, [contenteditable="true"], [role="button"], [data-no-drag]';function Lm({columns:e,items:t,getItemId:n,getColumnId:r,renderCard:o,canDrop:i,onMove:a,getExternalDragData:l,onCardContextMenu:u,emptyMessage:f="No cards in this column.",hiddenColumnIds:p,onHideColumn:h,compact:g=!1,dragDisabled:y=!1,boundedColumns:k=!1}){const v=k&&!g,b=m.useMemo(()=>new Set(p??[]),[p]),j=m.useMemo(()=>e.filter(B=>!b.has(B.id)),[e,b]),N=m.useMemo(()=>e.filter(B=>b.has(B.id)),[e,b]),[S,C]=m.useState(null),[D,T]=m.useState(null),R=m.useRef(null),$=m.useMemo(()=>new Map(t.map(B=>[n(B),B])),[n,t]),P=m.useMemo(()=>j.map(B=>({column:B,items:t.filter(W=>r(W)===B.id)})),[j,r,t]),F=S?$.get(S)??null:null;function _(B){if(!F)return{allowed:!1};const W=r(F);return(i==null?void 0:i({item:F,fromColumnId:W,toColumnId:B}))??{allowed:!0}}function V(){C(null),T(null)}function U(B,W,O){if(y)return;const H=(l==null?void 0:l(W))??null;!a&&!H||(B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",O),H&&B.dataTransfer.setData("application/json",JSON.stringify(H)),a&&C(O))}function I(B,W,O){y||!a||!F||!_(W).allowed||(B.preventDefault(),B.dataTransfer.dropEffect="move",T(L=>(L==null?void 0:L.columnId)===W&&L.index===O?L:{columnId:W,index:O}))}async function M(B,W,O){var q;if(B.preventDefault(),y||!a||!F){V();return}const H=r(F),z=(((q=P.find(Q=>Q.column.id===H))==null?void 0:q.items)??[]).findIndex(Q=>n(Q)===n(F));if(!_(W).allowed||z<0){V();return}if(H===W&&(O===z||O===z+1)){V();return}try{await a({item:F,fromColumnId:H,toColumnId:W,fromIndex:z,toIndex:O})}finally{V()}}return s.jsxs("div",{className:"relative overflow-x-auto pb-2",style:{scrollbarColor:"oklch(var(--border)) transparent",scrollbarWidth:"thin"},children:[N.length>0&&h?s.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Hidden:"}),N.map(B=>s.jsxs("button",{type:"button",onClick:()=>h(B.id),className:"rounded-full border border-dashed border-border/60 px-2 py-0.5 hover:border-border hover:text-foreground",title:`Restore "${B.title}" column`,children:[B.title," ×"]},B.id))]}):null,s.jsx("div",{className:je("grid min-w-max grid-flow-col items-start gap-4",g?"auto-cols-[minmax(240px,280px)]":"auto-cols-[minmax(300px,360px)]"),children:P.map(({column:B,items:W})=>{const O=_(B.id),H=(D==null?void 0:D.columnId)===B.id;return s.jsxs("section",{className:je("flex flex-col rounded-lg border border-border/60 bg-card/85 shadow-sm",g?"min-h-[200px] p-2":"min-h-[320px] p-3",v?"max-h-[70vh]":"",F&&!O.allowed?"border-dashed opacity-65":"",F&&O.allowed?"border-primary/30 bg-accent/30":"",H?"ring-2 ring-ring/30":""),title:F&&!O.allowed?O.reason:void 0,children:[s.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:je("font-semibold uppercase tracking-[0.16em] text-muted-foreground",g?"text-xs":"text-sm"),children:B.title}),B.description&&!g?s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:B.description}):null]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs font-semibold text-foreground",children:W.length}),h?s.jsx("button",{type:"button",onClick:()=>h(B.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 "${B.title}" column`,"aria-label":`Hide column ${B.title}`,children:"×"}):null]})]}),s.jsxs("div",{className:je("flex flex-1 flex-col gap-3",v?"min-h-0 overflow-y-auto pr-1":""),onDragOver:L=>I(L,B.id,W.length),onDrop:L=>M(L,B.id,W.length),children:[W.length===0?y?s.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 f=="function"?f(B):f}):s.jsx(gH,{active:(D==null?void 0:D.columnId)===B.id&&D.index===0,disabled:!!F&&!O.allowed,children:typeof f=="function"?f(B):f}):null,W.map((L,z)=>{const Y=n(L),q=S===Y;return s.jsxs(m.Fragment,{children:[s.jsx("div",{className:je("h-2 rounded-full transition",(D==null?void 0:D.columnId)===B.id&&D.index===z?"bg-primary/70":"bg-transparent"),onDragOver:Q=>I(Q,B.id,z),onDrop:Q=>M(Q,B.id,z)}),s.jsx("div",{draggable:!y&&!!(a||l),onMouseDown:Q=>{R.current=Q.target},onDragStart:Q=>{const ee=R.current;if(ee!=null&&ee.closest(nc)){Q.preventDefault();return}U(Q,L,Y)},onDragEnd:V,onContextMenu:Q=>{if(!u)return;const ee=Q.target;ee!=null&&ee.closest(nc)||u(L,Q)},className:je("transition",!y&&(a||l)?"cursor-grab active:cursor-grabbing":"",q?"scale-[0.98] opacity-50":""),children:o(L,{dragging:q})})]},Y)}),W.length>0&&!y?s.jsx("div",{className:je("mt-1 rounded-md border border-dashed px-3 py-2 text-center text-xs text-muted-foreground transition",(D==null?void 0:D.columnId)===B.id&&D.index===W.length?"border-primary/50 bg-primary/10 text-foreground":"border-border/60",F&&!O.allowed?"opacity-40":""),children:"Drop here to place at the end"}):null]})]},B.id)})})]})}function gH({active:e,disabled:t,children:n}){return s.jsx("div",{className:je("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 So="border-status-pending-foreground/30 bg-status-pending text-status-pending-foreground",Vl="border-status-in-progress-foreground/30 bg-status-in-progress text-status-in-progress-foreground",FA="border-status-blocked-foreground/30 bg-status-blocked text-status-blocked-foreground",qb="border-status-review-foreground/30 bg-status-review text-status-review-foreground",zA="border-status-completed-foreground/30 bg-status-completed text-status-completed-foreground",BA="border-status-failed-foreground/30 bg-status-failed text-status-failed-foreground",UA="border-status-archived-foreground/30 bg-status-archived text-status-archived-foreground",qp=So,xH={draft:So,pending:So,ready_for_planning:So,ready_to_implement:Vl,in_progress:Vl,blocked:FA,review:qb,code_review:qb,completed:zA,failed:BA,active:Vl,stopped:So,archived:UA};function yH(e){return xH[e]??qp}const bH={slate:qp,gray:qp,grey:qp};function HA(e){return e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function vH(e){let t=e.trim().replace(/^#/,"");return t.length===3&&(t=t.split("").map(n=>n+n).join("")),t.length!==6||/[^0-9a-fA-F]/.test(t)?null:{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function wH(e,t){const n=t==null?void 0:t.trim();if(n)if(n.startsWith("#")){const r=vH(n);if(r){const{r:o,g:i,b:a}=r;return{className:"",style:{backgroundColor:`rgba(${o}, ${i}, ${a}, 0.15)`,borderColor:`rgba(${o}, ${i}, ${a}, 0.4)`,color:n}}}}else{const r=bH[n.toLowerCase()];if(r)return{className:r}}return{className:yH(e)}}function dd(e,t){const n=e.find(i=>i.id===t),{className:r,style:o}=wH(t,n==null?void 0:n.color);return{label:(n==null?void 0:n.label)??HA(t),className:r,style:o,iconName:n==null?void 0:n.icon}}function Kb(e){return e?!!e.terminal||e.id==="completed"||e.id==="failed":!1}function VA(e){const t=new Map(e.statuses.map(a=>[a.id,a])),n=e.order.length>0?e.order:e.statuses.map(a=>a.id),r=new Set,o=[],i=(a,l)=>{r.has(a)||(r.add(a),o.push({id:a,label:(l==null?void 0:l.label)??HA(a),terminal:Kb(l??{id:a})}))};for(const a of n)i(a,t.get(a));for(const a of e.statuses)i(a.id,a);return o}const WA={draft:{label:"Draft",description:"Just-created stub; not yet shaped.",className:So,icon:xc},pending:{label:"Pending",description:"Waiting to start or waiting on dependencies.",className:So,icon:ZM},ready_for_planning:{label:"Ready for Planning",description:"Objective and acceptance criteria written; awaiting a plan.",className:So,icon:f2},ready_to_implement:{label:"Ready to Implement",description:"Plan written and approved; ready to start coding.",className:Vl,icon:SO},in_progress:{label:"In Progress",description:"Actively being worked on.",className:Vl,icon:Vv},blocked:{label:"Blocked",description:"Blocked by an explicit obstacle that needs intervention.",className:FA,icon:ih},review:{label:"Review",description:"Ready for inspection or approval.",className:qb,icon:TO},completed:{label:"Completed",description:"Finished successfully.",className:zA,icon:em},failed:{label:"Failed",description:"Could not be completed as planned.",className:BA,icon:ih},active:{label:"Active",description:"The project has active or review work in flight.",className:Vl,icon:bb},stopped:{label:"Stopped",description:"Session ended without completing.",className:So,icon:QM},archived:{label:"Archived",description:"Hidden from normal views; restorable from the Archive page.",className:UA,icon:bb}},qA="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)]";function Gb(e){var t;return((t=WA[e])==null?void 0:t.icon)??bb}function kn({status:e,className:t,showIcon:n=!0,progress:r}){var y;const o=As(),i=dd(o.statuses,e),a=Gb(e),l=i.label,u=((y=o.statuses.find(k=>k.id===e))==null?void 0:y.description)??Vd(e),f=r&&r.total>0,p=f?Math.min(1,Math.max(0,r.checked/r.total)):0,h=f?`${l} — ${u} (${r.checked}/${r.total} criteria)`:`${l} — ${u}`,g=n?f?s.jsxs("span",{className:"relative inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"absolute inset-0 h-full w-full -rotate-90",children:[s.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"1.5"}),s.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-p)})]}),s.jsx(a,{className:"h-2.5 w-2.5"})]}):s.jsx(a,{className:"h-3.5 w-3.5 shrink-0"}):null;return s.jsxs("span",{title:h,className:je(qA,i.className,t),style:i.style,children:[g,s.jsx("span",{className:"min-w-0 truncate",children:l})]})}function Vd(e){var t;return((t=WA[e])==null?void 0:t.description)??`Status: ${e}`}function Aa({type:e,className:t,compact:n=!1}){const r=$d();if(!e)return null;const o=pz(r,e),i=(o==null?void 0:o.label)??e.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase()),a=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 s.jsx("span",{title:(o==null?void 0:o.description)??`Type: ${i}`,style:a,className:je("inline-flex items-center whitespace-nowrap rounded-full border text-xs capitalize",n?"px-2 py-0.5":"px-2.5 py-1",!a&&"border-border/60 text-muted-foreground",t),children:i})}async function Wd(e){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{return await navigator.clipboard.writeText(e),!0}catch{}return jH(e)}function jH(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 Hr({value:e,label:t,disabled:n=!1,disabledReason:r,onError:o}){const[i,a]=m.useState(!1);async function l(){n||(await Wd(e)?(a(!0),setTimeout(()=>a(!1),1500)):o==null||o(new Error("Copy to clipboard failed in this context.")))}return n?s.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:r??"Copy unavailable","aria-label":t??"Copy",children:s.jsx(ah,{className:"h-3 w-3","aria-hidden":"true"})}):s.jsx("button",{type:"button",onClick:l,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?s.jsx(Sr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):s.jsx(ah,{className:"h-3 w-3","aria-hidden":"true"})})}function kH(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function SH({items:e,statusOrder:t,sortField:n,sortDirection:r,listSectionVisibility:o,compact:i=!1}){const a=As(),[l,u]=m.useState(()=>new Set(o.collapsed));m.useEffect(()=>{u(new Set(o.collapsed))},[o]);const f=p=>{u(h=>{const g=new Set(h);return g.has(p)?g.delete(p):g.add(p),g})};return s.jsx("div",{className:je("space-y-2",i?"space-y-1.5":"space-y-3"),children:t.map(p=>{const h=Hd(e.filter(k=>k.status===p),n,r);if(h.length===0)return null;const g=!l.has(p),y=Co(a,p);return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/90",children:[s.jsxs("button",{type:"button",onClick:()=>f(p),className:je("flex w-full items-center gap-2 text-left",i?"px-3 py-2 text-xs":"px-4 py-3 text-sm"),children:[s.jsx(cr,{className:je("text-muted-foreground transition-transform",i?"h-3.5 w-3.5":"h-4 w-4",g?"":"-rotate-90")}),s.jsx("span",{className:"font-semibold text-foreground",children:y}),s.jsx("span",{className:je("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:h.length})]}),g&&s.jsx("ul",{className:je("divide-y divide-border/40 border-t border-border/40",i?"text-xs":"text-sm"),children:h.map(k=>{const v=kH(k);return s.jsx("li",{children:s.jsxs(De,{to:v,className:je("flex items-center gap-3 hover:bg-muted/40",i?"px-3 py-1.5":"px-4 py-2.5"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:k.title}),k.projectTitle?s.jsx("span",{className:"hidden truncate text-muted-foreground sm:inline",children:k.projectTitle}):null,s.jsx("span",{className:"shrink-0 text-muted-foreground",children:Yn(k.updated)})]})},`${k.projectSlug??"standalone"}:${k.id}`)})})]},p)})})}function NH(e){return e.projectSlug===null?`/assignments/${e.id}`:`${e.projectWorkspace?`/w/${e.projectWorkspace}`:""}/projects/${e.projectSlug}/assignments/${e.slug}`}function CH({items:e,sortField:t,sortDirection:n,tableColumnVisibility:r,compact:o=!1}){const i=new Set(r.hidden);i.delete("title");const a=p=>!i.has(p),l=Hd(e,t,n),u=o?"py-2 pr-3":"py-3 pr-4",f=o?"text-xs":"text-sm";return s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:je("w-full text-left",f),children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[a("title")?s.jsx("th",{className:je("font-medium",u),children:"Assignment"}):null,a("status")?s.jsx("th",{className:je("font-medium",u),children:"Status"}):null,a("priority")?s.jsx("th",{className:je("font-medium",u),children:"Priority"}):null,a("assignee")?s.jsx("th",{className:je("font-medium",u),children:"Assignee"}):null,a("dependencies")?s.jsx("th",{className:je("font-medium",u),children:"Dependencies"}):null,a("created")?s.jsx("th",{className:je("font-medium",u),children:"Created"}):null,a("updated")?s.jsx("th",{className:je("font-medium",u),children:"Updated"}):null]})}),s.jsx("tbody",{children:l.map(p=>{const h=NH(p),g=`${p.projectSlug??"standalone"}:${p.id}`;return s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[a("title")?s.jsxs("td",{className:u,children:[s.jsx(De,{to:h,className:"font-semibold text-foreground hover:text-primary",children:p.title}),p.projectTitle?s.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:p.projectTitle}):null]}):null,a("status")?s.jsx("td",{className:u,children:s.jsx(kn,{status:p.status,className:"max-w-[150px]"})}):null,a("priority")?s.jsx("td",{className:je("capitalize text-muted-foreground",u),children:p.priority}):null,a("assignee")?s.jsx("td",{className:je("text-muted-foreground",u),children:p.assignee??"Unassigned"}):null,a("dependencies")?s.jsx("td",{className:je("text-muted-foreground",u),children:p.dependsOn.length}):null,a("created")?s.jsx("td",{className:je("text-muted-foreground",u),children:Yn(p.created)}):null,a("updated")?s.jsx("td",{className:je("text-muted-foreground",u),children:Yn(p.updated)}):null]},g)})})]})})}function KA({view:e,compact:t,emptyDescription:n}){const{data:r,loading:o,error:i}=om(),a=As(),l=m.useMemo(()=>a.order.map(p=>({id:p,title:Co(a,p),description:Vd(p)})),[a]),u=m.useMemo(()=>MA(a.factDeclarations),[a.factDeclarations]),f=m.useMemo(()=>{if(!r)return[];const p=e.config.filters.query??Ou(e.config.filters);let h=null;p.trim()!==""&&(h=Jl(p,u).query);const g=IA(r.assignments,h,{workspace:e.workspace});return Hd(g,e.config.sortField,e.config.sortDirection)},[r,e,u]);if(o&&!r)return s.jsx(bt,{label:"Loading assignments…"});if(i)return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load assignments"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i})]});if(f.length===0)return s.jsx(St,{title:"No assignments match this view.",description:n??"Adjust the view's filters to surface different work."});switch(e.config.viewMode){case"kanban":return s.jsx(Lm,{compact:t,dragDisabled:!0,columns:l,items:f,getItemId:p=>p.slug||p.id,getColumnId:p=>p.status,hiddenColumnIds:e.config.kanbanColumnVisibility.hidden,renderCard:p=>t?s.jsx(EH,{item:p}):s.jsx(TH,{item:p})});case"list":return s.jsx(SH,{items:f,statusOrder:a.order,sortField:e.config.sortField,sortDirection:e.config.sortDirection,listSectionVisibility:e.config.listSectionVisibility,compact:t});case"table":return s.jsx(CH,{items:f,sortField:e.config.sortField,sortDirection:e.config.sortDirection,tableColumnVisibility:e.config.tableColumnVisibility,compact:t})}}function EH({item:e}){const t=ud(e);return s.jsxs("div",{className:je("rounded-md border border-border/60 bg-background/85 p-2 shadow-sm"),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(De,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),s.jsx(kn,{status:e.status,className:"max-w-[150px]"})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),s.jsx("span",{className:"shrink-0",children:Yn(e.updated)})]}),e.id?s.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),s.jsx(Hr,{value:e.id})]}):null]})}function TH({item:e}){const t=ud(e);return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(De,{to:t,className:"block truncate text-sm font-semibold text-foreground hover:text-primary",children:e.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:e.projectTitle??"Standalone"})]}),s.jsx(kn,{status:e.status,className:"max-w-[150px]"})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[s.jsx(Aa,{type:e.type,compact:!0}),s.jsx("span",{className:"text-xs capitalize text-muted-foreground",children:e.priority})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:e.assignee??"Unassigned"}),s.jsx("span",{className:"shrink-0",children:Yn(e.updated)})]})]})}function RH({viewId:e,onPickAnother:t}){const{view:n,loading:r,error:o,refetch:i}=ki(e);return r?s.jsx(bt,{label:"Loading view…"}):o?s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load view"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o.message}),s.jsx("button",{type:"button",onClick:()=>i(),className:"shell-action mt-3",children:"Retry"})]}):n?s.jsx(KA,{view:n,compact:!0,emptyDescription:"Adjust the view's filters to surface different work, or pick another widget for this slot."}):s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"View no longer exists"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"The saved view this slot was bound to has been deleted."}),s.jsx("button",{type:"button",onClick:t,className:"shell-action mt-3",children:"Pick another widget"})]})}function GA({sessions:e}){return s.jsxs("aside",{"aria-labelledby":"overview-sessions-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[s.jsx("header",{className:"border-b border-border/40 px-4 py-3",children:s.jsx("h3",{id:"overview-sessions-title",className:"text-sm font-semibold text-foreground",children:"Recent Sessions"})}),e.length===0?s.jsxs("div",{className:"px-4 py-6 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:pa.recentSessionsEmptyTitle}),s.jsx("p",{className:"mt-1 text-muted-foreground",children:pa.recentSessionsEmptyHint})]}):s.jsx("ul",{className:"divide-y divide-border/40",children:e.map(t=>s.jsx("li",{children:s.jsx(AH,{session:t})},t.sessionId))})]})}function AH({session:e}){const t=mn(),[n,r]=m.useState(!1),o=PH(e,t),i=_H(e),a=!e.path;return s.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(De,{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}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:[i," · ",Yv(e.started)]}),n&&e.path?s.jsxs("div",{className:"mt-1 space-y-0.5",children:[s.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}),s.jsx("p",{className:"text-[10px] text-muted-foreground",children:pa.recentSessionsCopyFallbackHint})]}):null]}),s.jsx(Hr,{value:e.path,label:pa.recentSessionsCopyPathLabel,disabled:a,disabledReason:pa.recentSessionsCopyPathDisabled,onError:()=>r(!0)})]})}function PH(e,t){return e.projectSlug&&e.assignmentSlug?`${t}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`:(!e.projectSlug&&e.assignmentSlug,"/agent-sessions")}function _H(e){return e.assignmentSlug&&e.projectSlug?`${e.projectSlug}/${e.assignmentSlug}`:e.assignmentSlug?`standalone/${e.assignmentSlug}`:"standalone"}const DH={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 na(e){if(!e)return 0;const t=Date.parse(e);return Number.isNaN(t)?0:t}function $H(e,t,n=Date.now()){const r=na(e);if(t.preset){const a=DH[t.preset];return a?t.preset.startsWith("older_")?r<n-a:r>=n-a:!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)&&r<o||i!==null&&Number.isFinite(i)&&r>i)}function IH(e,t,n=Date.now()){const{dateRange:r,project:o,agent:i,sessionStatus:a}=t,l=new Set(o??[]),u=new Set(i??[]),f=new Set(a??[]);return e.filter(p=>{if(r&&!$H(p.started,r,n))return!1;if(l.size>0){const h=p.projectSlug??"__standalone__";if(!l.has(h))return!1}if(u.size>0&&!Array.from(u).some(g=>g.toLowerCase()===p.agent.toLowerCase()))return!1;if(f.size>0){let h=!1;for(const g of f){switch(g){case"active":p.status==="active"&&(h=!0);break;case"ended":(p.status==="completed"||p.status==="stopped")&&(h=!0);break;case"tracked":h=!0;break}if(h)break}if(!h)return!1}return!0})}function LH(e,t,n){return[...e].sort((o,i)=>{let a=0;switch(t){case"started":a=na(o.started)-na(i.started);break;case"lastActivity":a=na(o.updatedAt)-na(i.updatedAt);break;case"projectName":{const l=o.projectSlug??"",u=i.projectSlug??"";a=l.localeCompare(u);break}case"agentName":a=o.agent.localeCompare(i.agent);break;default:a=na(o.started)-na(i.started);break}return n==="asc"?a:-a})}function MH(e,t){return t==null||Number.isNaN(t)||t<=0?e:e.slice(0,t)}function OH({view:e,emptyDescription:t}){const{data:n,loading:r,error:o}=im(),i=m.useMemo(()=>{if(!n)return[];const a=n.sessions??[],{config:l}=e,u=l.filters,f={dateRange:u.dateRange?{...u.dateRange,field:"started"}:void 0,project:Ve(u.project),agent:Ve(u.agent),sessionStatus:Ve(u.sessionStatus),limit:l.limit};let p=IH(a,f);return p=LH(p,l.sortField,l.sortDirection),p=MH(p,l.limit),p},[n,e]);return r&&!n?s.jsx(bt,{label:"Loading sessions…"}):o?s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load sessions"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o})]}):i.length===0?s.jsx(St,{title:"No sessions match this view.",description:t??"Adjust the view's filters to surface different sessions."}):s.jsx(GA,{sessions:i})}function FH({activeViewId:e,onSelectView:t,onCreateNew:n}){const{views:r,loading:o}=zd(),[i,a]=m.useState(!1),l=m.useRef(null),u=m.useMemo(()=>r.filter(h=>h.entityType==="session"),[r]);m.useEffect(()=>{if(!i)return;function h(y){l.current&&!l.current.contains(y.target)&&a(!1)}function g(y){y.key==="Escape"&&a(!1)}return document.addEventListener("mousedown",h),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",g)}},[i]);const f=e?r.find(h=>h.id===e)??null:null,p=o?"Session views…":f?f.name:"Session views";return s.jsxs("div",{className:"relative",ref:l,children:[s.jsxs("button",{type:"button",disabled:o,onClick:()=>a(h=>!h),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:[s.jsx("span",{className:"max-w-[160px] truncate",children:p}),s.jsx(cr,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),i&&s.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:[s.jsxs("button",{type:"button",onClick:()=>{a(!1),t(null)},className:je("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:[s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:e?null:s.jsx(Sr,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),s.jsx("span",{children:"All sessions"})]}),u.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"my-1 border-t border-border/40"}),u.map(h=>{const g=h.id===e;return s.jsxs("button",{type:"button",onClick:()=>{a(!1),t(h.id)},className:je("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",g&&"font-semibold text-foreground"),children:[s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:g?s.jsx(Sr,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null}),s.jsx("span",{className:"truncate",children:h.name})]},h.id)})]}),s.jsx("div",{className:"my-1 border-t border-border/40"}),s.jsxs("button",{type:"button",onClick:()=>{a(!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:[s.jsx(Mt,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{children:"Create new view…"})]})]})]})}const zH={__unassigned__:"Unassigned",__standalone__:"No project"};function wn({options:e,value:t,onChange:n,allLabel:r="Any",className:o,disabled:i,ariaLabel:a}){const[l,u]=m.useState(!1),f=m.useRef(null),p=m.useRef(null),h=m.useRef([]),g=m.useMemo(()=>{const N=new Set(e.map(C=>C.value)),S=t.filter(C=>!N.has(C)).map(C=>({value:C,label:zH[C]??C}));return[...e,...S]},[e,t]),y=m.useMemo(()=>new Set(t),[t]);m.useEffect(()=>{if(!l)return;function N(S){f.current&&!f.current.contains(S.target)&&u(!1)}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[l]),m.useEffect(()=>{var N;l&&((N=h.current[0])==null||N.focus())},[l]);const k=m.useMemo(()=>{if(t.length===0)return r;if(t.length===1){const N=g.find(S=>S.value===t[0]);return N?N.label:t[0]}return`${t.length} selected`},[t,g,r]);function v(N){n(y.has(N)?t.filter(S=>S!==N):[...t,N])}function b(N){var C;const S=Math.max(0,Math.min(N,g.length-1));(C=h.current[S])==null||C.focus()}function j(N){var T;const S=h.current,C=document.activeElement,D=S.findIndex(R=>R===C);N.key==="ArrowDown"?(N.preventDefault(),b(D<0?0:D+1)):N.key==="ArrowUp"?(N.preventDefault(),b(D<0?g.length-1:D-1)):N.key==="Home"?(N.preventDefault(),b(0)):N.key==="End"?(N.preventDefault(),b(g.length-1)):N.key==="Escape"&&(N.preventDefault(),u(!1),(T=p.current)==null||T.focus())}return s.jsxs("div",{className:"relative",ref:f,children:[s.jsxs("button",{type:"button",ref:p,disabled:i,"aria-haspopup":"menu","aria-expanded":l,"aria-label":a,onClick:()=>u(N=>!N),onKeyDown:N=>{!l&&(N.key==="ArrowDown"||N.key==="ArrowUp")&&(N.preventDefault(),u(!0))},className:je("editor-input inline-flex items-center justify-between gap-1.5 text-left",t.length>0&&"border-foreground/40 text-foreground",o),children:[s.jsx("span",{className:"truncate",children:k}),s.jsx(cr,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),l?s.jsxs("div",{role:"menu","aria-label":a,onKeyDown:j,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:[s.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 pb-1",children:[s.jsx("button",{type:"button",role:"menuitem",className:"text-xs text-muted-foreground hover:text-foreground disabled:opacity-40",disabled:t.length===g.length,onClick:()=>n(g.map(N=>N.value)),children:"Select all"}),s.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"})]}),g.length===0?s.jsx("p",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"No options"}):g.map((N,S)=>{const C=y.has(N.value);return s.jsxs("button",{ref:D=>{h.current[S]=D},type:"button",role:"menuitemcheckbox","aria-checked":C,tabIndex:-1,onClick:()=>v(N.value),className:je("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition hover:bg-foreground/5",C?"text-foreground":"text-muted-foreground"),children:[s.jsx("span",{className:je("flex h-4 w-4 shrink-0 items-center justify-center rounded border",C?"border-foreground bg-foreground text-background":"border-border/70"),"aria-hidden":"true",children:C?s.jsx(Sr,{className:"h-3 w-3"}):null}),s.jsx("span",{className:"truncate",children:N.label})]},N.value)})]}):null]})}const DS={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"},BH=["updated","created"];function Mm({value:e,onChange:t,className:n,ariaLabel:r="Date range filter"}){const[o,i]=m.useState(!1),a=m.useRef(null),l=(e==null?void 0:e.field)??"updated",u=!!(e&&!e.preset&&(e.from||e.to)),[f,p]=m.useState(u);m.useEffect(()=>p(u),[u]),m.useEffect(()=>{if(!o)return;function j(S){a.current&&!a.current.contains(S.target)&&i(!1)}function N(S){S.key==="Escape"&&i(!1)}return document.addEventListener("mousedown",j),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",N)}},[o]);const h=!!(e&&(e.preset||e.from||e.to)),g=m.useMemo(()=>!h||!e?"Any date":e.preset?`${l}: ${DS[e.preset]??e.preset}`:`${l}: ${e.from||"…"} → ${e.to||"…"}`,[h,e,l]);function y(j){t(e?{...e,field:j}:{field:j,preset:"",from:"",to:""})}function k(j){p(!1),t({field:l,preset:j,from:"",to:""})}function v(){p(!1),t(null)}function b(j,N){const S={field:l,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""};t({...S,[j]:N})}return s.jsxs("div",{className:"relative",ref:a,children:[s.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":o,"aria-label":r,onClick:()=>i(j=>!j),className:je("editor-input inline-flex items-center justify-between gap-1.5 text-left",h&&"border-foreground/40 text-foreground",n),children:[s.jsx("span",{className:"truncate",children:g}),s.jsx(cr,{className:"h-3.5 w-3.5 shrink-0 opacity-60","aria-hidden":"true"})]}),o?s.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:[s.jsx("div",{className:"mb-2 inline-flex rounded-md border border-border/60 bg-background/80 p-0.5",children:BH.map(j=>s.jsx("button",{type:"button","aria-pressed":l===j,onClick:()=>y(j),className:je("rounded-sm px-2.5 py-1 text-xs font-medium capitalize transition",l===j?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:j},j))}),s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(ky,{label:"Any date",selected:!h,onClick:v}),M6.map(j=>s.jsx(ky,{label:DS[j],selected:(e==null?void 0:e.preset)===j,onClick:()=>k(j)},j)),s.jsx(ky,{label:"Custom range…",selected:f,onClick:()=>{p(!0),t({field:l,preset:"",from:(e==null?void 0:e.from)??"",to:(e==null?void 0:e.to)??""})}})]}),f?s.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-border/60 pt-2",children:[s.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["From",s.jsx("input",{type:"date",value:(e==null?void 0:e.from)??"",max:(e==null?void 0:e.to)||void 0,onChange:j=>b("from",j.target.value),className:"editor-input w-40"})]}),s.jsxs("label",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:["To",s.jsx("input",{type:"date",value:(e==null?void 0:e.to)??"",min:(e==null?void 0:e.from)||void 0,onChange:j=>b("to",j.target.value),className:"editor-input w-40"})]})]}):null]}):null]})}function ky({label:e,selected:t,onClick:n}){return s.jsxs("button",{type:"button",onClick:n,className:je("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:[s.jsx("span",{children:e}),t?s.jsx(Sr,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}):null]})}const UH=new Set(["status","type","priority","assignee","project","tags","activity","dateRange","search","query","sessionStatus","agent"]);function HH(e,t){const n={};for(const[r,o]of Object.entries(e))UH.has(r)||(n[r]=o);return{...n,...t}}function Nh(e,t,n){return{...e,viewMode:t.viewMode,filters:HH(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 VH(e,t){var g,y;const n={},r=Ve(e.status);r.length&&(n.status=r);const o=Ve(e.type);o.length&&(n.type=o);const i=Ve(e.priority);i.length&&(n.priority=i);const a=Ve(e.assignee);a.length&&(n.assignee=a);const l=Ve(e.tags);if(l.length&&(n.tags=l),t&&t!=="all")n.project=[t];else{const k=Ve(e.project);k.length&&(n.project=k)}e.activity&&e.activity!=="all"&&(n.activity=e.activity);const u=Ve(e.sessionStatus);u.length&&(n.sessionStatus=u);const f=Ve(e.agent);f.length&&(n.agent=f),e.dateRange&&(n.dateRange=e.dateRange);const p=(g=e.search)==null?void 0:g.trim();p&&(n.search=p);const h=(y=e.query)==null?void 0:y.trim();return h&&(n.query=h),n}function rc(e){const t={viewMode:e.state.viewMode,filters:VH(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 ml={viewMode:"kanban",sortField:"updated",sortDirection:"desc"},pp={sortField:"started",sortDirection:"desc"};function YA(e,t){const{config:n}=rc({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:[]}}}),r={...n};return e.limit!==void 0&&e.limit>0&&(r.limit=e.limit),{workspace:t,config:r}}function Ww(e,t){const{config:n}=rc({name:"",context:{workspace:t,projectSlug:null},state:{viewMode:"list",filters:e.filters,sortField:e.sortField,sortDirection:e.sortDirection,listSectionVisibility:{collapsed:[]},kanbanColumnVisibility:{hidden:[]},tableColumnVisibility:{hidden:[]}}}),r={...n};return e.limit!==void 0&&e.limit>0&&(r.limit=e.limit),{workspace:t,config:r}}function ma(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 r={field:e.field};return t&&(r.from=t),n&&(r.to=n),r}function Om(e){return e?{field:e.field,preset:e.preset??"",from:e.from??"",to:e.to??""}:null}function XA(e,t){var r,o,i,a,l,u,f,p,h,g,y,k,v,b,j;const{config:n}=e;if((r=t.setViewMode)==null||r.call(t,n.viewMode),(o=t.setStatusFilter)==null||o.call(t,Ve(n.filters.status)),(i=t.setTypeFilter)==null||i.call(t,Ve(n.filters.type)),(a=t.setPriorityFilter)==null||a.call(t,Ve(n.filters.priority)),(l=t.setAssigneeFilter)==null||l.call(t,Ve(n.filters.assignee)),(u=t.setProjectFilter)==null||u.call(t,Ve(n.filters.project)),(f=t.setTagsFilter)==null||f.call(t,Ve(n.filters.tags)),(p=t.setDateRange)==null||p.call(t,Om(n.filters.dateRange)),(h=t.setSearch)==null||h.call(t,n.filters.search??""),(g=t.setQuery)==null||g.call(t,n.filters.query??Ou(n.filters)),t.setActivityFilter){const N=n.filters.activity??"all";t.setActivityFilter(N==="fresh"||N==="stale"?N:"all")}(y=t.setSortField)==null||y.call(t,n.sortField),(k=t.setSortDirection)==null||k.call(t,n.sortDirection),(v=t.setListSectionVisibility)==null||v.call(t,{collapsed:[...n.listSectionVisibility.collapsed]}),(b=t.setKanbanColumnVisibility)==null||b.call(t,{hidden:[...n.kanbanColumnVisibility.hidden]}),(j=t.setTableColumnVisibility)==null||j.call(t,{hidden:[...n.tableColumnVisibility.hidden]})}function Kp(e){return e?`/w/${e}/views`:"/views"}function QA(e){return`${Kp(e.workspace)}/${encodeURIComponent(e.id)}`}function JA(e){const t=e.workspace?`/w/${e.workspace}`:"",n=Ve(e.config.filters.project);return n.length===1&&n[0]!=="__standalone__"&&YR(e.config,n[0])?`${t}/projects/${n[0]}?tab=assignments&loadView=${encodeURIComponent(e.id)}`:`${t}/assignments?loadView=${encodeURIComponent(e.id)}`}const WH=["critical","high","medium","low"],qH={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 KH(e){if(e.preset)return`${e.field} ${qH[e.preset]??e.preset}`;const t=e.from??"…",n=e.to??"…";return`${e.field} ${t}→${n}`}function ZA(e){var o,i;const t=(o=e.query)==null?void 0:o.trim();if(t&&Fu(t)===null)return`query: ${t}`;const n=[];for(const a of["status","priority","type","assignee","project","tags"]){const l=Ve(e[a]);l.length&&n.push(`${a}=${l.join(", ")}`)}e.activity&&e.activity!=="all"&&n.push(`activity=${e.activity}`),e.dateRange&&n.push(KH(e.dateRange));const r=(i=e.search)==null?void 0:i.trim();return r&&n.push(`search="${r}"`),n.join(" · ")||"no filters"}const $S=80,GH=["started","lastActivity","projectName","agentName"],YH={started:"Start time",lastActivity:"Last updated",projectName:"Project",agentName:"Agent"},XH=[{value:"active",label:"Active"},{value:"ended",label:"Ended"},{value:"tracked",label:"Tracked"},{value:"untracked",label:"Untracked"}];function eP({open:e,onOpenChange:t,initialView:n,onSubmit:r}){const o=!!n,{data:i}=to(),{data:a}=im(),[l,u]=m.useState(""),[f,p]=m.useState([]),[h,g]=m.useState([]),[y,k]=m.useState([]),[v,b]=m.useState(null),[j,N]=m.useState(pp.sortField),[S,C]=m.useState(pp.sortDirection),[D,T]=m.useState(""),[R,$]=m.useState(!1),[P,F]=m.useState(null);function _(){p([]),g([]),k([]),b(null),N(pp.sortField),C(pp.sortDirection),T("")}m.useEffect(()=>{if(e)if(F(null),$(!1),n){const O=n.config.filters;u(n.name),p(Ve(O.project)),g(Ve(O.agent)),k(Ve(O.sessionStatus)),b(Om(O.dateRange)),N(n.config.sortField),C(n.config.sortDirection),T(n.config.limit!==void 0?String(n.config.limit):"")}else u(""),_()},[e,n]);const V=m.useMemo(()=>[{value:"__standalone__",label:"No project"},...(i??[]).map(H=>({value:H.slug,label:H.title}))],[i]),U=m.useMemo(()=>{const O=new Set;for(const H of(a==null?void 0:a.sessions)??[])H.agent&&O.add(H.agent);return Array.from(O).sort().map(H=>({value:H,label:H}))},[a]),I=l.trim(),M=I.length>0&&I.length<=$S,B=D.trim()===""?void 0:parseInt(D.trim(),10),W=D.trim()===""||Number.isFinite(B)&&B!==void 0&&B>0&&B<=500;return s.jsx(Mn,{open:e,onOpenChange:t,children:s.jsx(Nn,{className:"max-w-lg",children:s.jsxs("form",{className:"space-y-4",onSubmit:async O=>{if(O.preventDefault(),!M||!W||R)return;$(!0),F(null);const H=ma(v),L=H?{...H,field:"started"}:void 0,z={filters:{project:f,agent:h,sessionStatus:y,dateRange:L},sortField:j,sortDirection:S,limit:B};try{await r(I,z)}catch(Y){F(Y instanceof Error?Y.message:String(Y)),$(!1)}},children:[s.jsx(sr,{children:s.jsx(Cn,{children:o?"Edit session view":"Create session view"})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:"create-session-view-name",children:"Name"}),s.jsx("input",{id:"create-session-view-name",type:"text",value:l,autoFocus:!0,required:!0,maxLength:$S,onChange:O=>u(O.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"})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[s.jsx(gl,{label:"Date range (session start)",children:s.jsx(Mm,{className:"w-full",value:v,onChange:b})}),s.jsx(gl,{label:"Project",children:s.jsx(wn,{ariaLabel:"Project filter",className:"w-full",allLabel:"All projects",options:V,value:f,onChange:p})}),s.jsx(gl,{label:"Agent",children:s.jsx(wn,{ariaLabel:"Agent filter",className:"w-full",allLabel:"All agents",options:U,value:h,onChange:g})}),s.jsx(gl,{label:"Session status",children:s.jsx(wn,{ariaLabel:"Session status filter",className:"w-full",allLabel:"All statuses",options:XH,value:y,onChange:k})}),s.jsx(gl,{label:"Sort by",className:"sm:col-span-2",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("select",{value:j,onChange:O=>N(O.target.value),className:"editor-input w-full",children:GH.map(O=>s.jsx("option",{value:O,children:YH[O]??O},O))}),s.jsx("button",{type:"button",onClick:()=>C(O=>O==="asc"?"desc":"asc"),className:"shell-action shrink-0",title:S==="asc"?"Ascending":"Descending",children:S==="asc"?"Asc":"Desc"})]})}),s.jsxs(gl,{label:"Max results",className:"sm:col-span-2",children:[s.jsx("input",{type:"number",min:1,max:500,value:D,onChange:O=>T(O.target.value),placeholder:"No limit",className:"editor-input w-full"}),W?null:s.jsx("p",{className:"mt-1 text-xs text-error-foreground",children:"Limit must be between 1 and 500"})]})]}),P?s.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:P}):null,s.jsxs(Wr,{className:"sm:justify-between",children:[s.jsx("button",{type:"button",onClick:_,className:"shell-action",disabled:R,children:"Clear all"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:R,children:"Cancel"}),s.jsx("button",{type:"submit",disabled:!M||!W||R,className:"shell-action shell-action--cta disabled:opacity-50",children:R?"Saving…":o?"Save changes":"Create view"})]})]})]})})})}function gl({label:e,className:t,children:n}){return s.jsxs("label",{className:`space-y-1 ${t??""}`,children:[s.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:e}),n]})}function Sy({title:e,message:t,onPickAnother:n}){return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:e}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t}),n?s.jsx("button",{type:"button",onClick:n,className:"shell-action mt-3",children:"Pick another widget"}):null]})}function QH({viewId:e,slotId:t,onPickAnother:n}){const{data:r,loading:o,error:i}=im(),{view:a,loading:l,ready:u}=ki(e??null),{layout:f}=nA(),{showToast:p}=Qn(),[h,g]=m.useState(!1),y=m.useCallback(async b=>{if(!t)return;const j=f.slots.map(N=>N.id===t?{...N,widget:b?{kind:"agent-sessions",viewId:b}:{kind:"agent-sessions"}}:N);try{await Fb(j)}catch(N){p(N instanceof Error?N.message:"Failed to update widget")}},[f,t,p]);async function k(b,j){const{workspace:N,config:S}=Ww(j,null);try{const D=(await Zl({name:b,workspace:N,config:S,entityType:"session"})).views.find(T=>T.name===b&&T.entityType==="session");D&&await y(D.id),g(!1),p(`Created session view "${b}"`)}catch(C){throw p(C instanceof Error?C.message:"Failed to create session view"),C}}let v;return e?l&&!u?v=s.jsx(bt,{label:"Loading view…"}):a?a.entityType!=="session"?v=s.jsx(Sy,{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}):v=s.jsx(OH,{view:a,emptyDescription:"Adjust the view's filters to surface different sessions, or pick another widget for this slot."}):v=s.jsx(Sy,{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&&!r?v=s.jsx(bt,{label:"Loading sessions…"}):i?v=s.jsx(Sy,{title:"Couldn't load sessions",message:i}):v=s.jsx(GA,{sessions:(r==null?void 0:r.sessions)??[]}),s.jsxs("div",{className:"space-y-2",children:[t?s.jsx("div",{className:"flex items-center justify-between gap-2",children:s.jsx(FH,{activeViewId:e??null,onSelectView:b=>void y(b),onCreateNew:()=>g(!0)})}):null,v,s.jsx(eP,{open:h,onOpenChange:g,workspace:null,onSubmit:k})]})}const JH=5;function ZH(){const{data:e,loading:t,error:n}=W2();if(t&&!e)return s.jsx(bt,{label:"Loading inventories…"});if(n)return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-3 text-sm text-muted-foreground",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load inventories"}),s.jsx("p",{className:"mt-1 text-xs",children:n})]});const o=((e==null?void 0:e.inventories)??[]).slice(0,JH);return s.jsxs("aside",{"aria-labelledby":"overview-inventories-title",className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[s.jsxs("header",{className:"flex items-center justify-between border-b border-border/40 px-4 py-3",children:[s.jsx("h3",{id:"overview-inventories-title",className:"text-sm font-semibold text-foreground",children:"Inventories"}),s.jsx(De,{to:"/inventories",className:"text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),o.length===0?s.jsxs("div",{className:"px-4 py-6 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"No inventories yet."}),s.jsx("p",{className:"mt-1 text-muted-foreground",children:"Create one to track leased resources across agents."})]}):s.jsx("ul",{className:"divide-y divide-border/40",children:o.map(i=>{const a=i.inventory,l=i.active_leases.length,u=i.members.length,f=a.display_name??a.slug;return s.jsx("li",{children:s.jsxs(De,{to:`/inventories/${encodeURIComponent(a.slug)}`,className:"flex items-center gap-3 px-4 py-2.5 text-sm hover:bg-muted/40",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:f}),s.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[l,"/",u," leased"]})]})},a.slug)})})]})}function e9(e){let t=0,n=0;for(const r of e.daily)t+=r.total_tokens,n+=r.total_cost;return{tokens:t,cost:n}}function IS({filters:e,metric:t}){const n=e??{},{data:r,loading:o,error:i}=q4(n),a=t==="cost"?"Spend":"Token Usage",l=`/usage?${Nb(n).toString()}`;let u;if(o&&!r)u=s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"});else if(i&&!r)u=s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load usage"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i})]});else if(!r||r.daily.length===0)u=s.jsx("p",{className:"text-sm text-muted-foreground",children:"No usage for these filters."});else{const{tokens:f,cost:p}=e9(r),h=t==="cost"?{label:"Total spend",value:Ql(p)}:{label:"Total tokens",value:Xl(f)},g=t==="cost"?{label:"Tokens",value:Xl(f)}:{label:"Spend",value:Ql(p)};u=s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(LS,{label:h.label,value:h.value,emphasize:!0}),s.jsx(LS,{label:g.label,value:g.value})]})}return s.jsxs("aside",{className:"rounded-xl border border-border/60 bg-background/60 shadow-sm",children:[s.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-border/40 px-4 py-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground",children:a}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",title:_1(n),children:_1(n)})]}),s.jsx(De,{to:l,className:"shrink-0 text-xs text-muted-foreground hover:text-foreground",children:"View all →"})]}),s.jsx("div",{className:"px-4 py-4",children:u})]})}function LS({label:e,value:t,emphasize:n}){return s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e}),s.jsx("p",{className:n?"text-2xl font-semibold tabular-nums text-foreground":"text-lg font-semibold tabular-nums text-foreground",children:t})]})}const t9={"7d":"7 days","30d":"30 days","90d":"90 days",all:"All time",custom:"Custom"};function n9(e){return e.kind==="token-usage"||e.kind==="spend"?e.filters??{}:{}}const xl="bg-background border border-border rounded px-2 py-1 text-sm text-foreground";function MS({config:e,open:t,onSave:n,onCancel:r}){const o=e.kind==="spend"?"Configure Spend":"Configure Token Usage",{data:i}=to(),{data:a}=Ea(),{data:l}=q2(t),[u,f]=m.useState("30d"),[p,h]=m.useState(""),[g,y]=m.useState(""),[k,v]=m.useState(""),[b,j]=m.useState(""),[N,S]=m.useState(""),[C,D]=m.useState(""),[T,R]=m.useState(!1),[$,P]=m.useState(null);m.useEffect(()=>{if(!t)return;const M=n9(e);f(M.window??"30d"),h(M.since??""),y(M.until??""),v(M.project??""),j(M.workspace??""),S(M.model??""),D(M.tool??""),R(!1),P(null)},[t,e]);function F(){return Dd({window:u,since:u==="custom"?p:void 0,until:u==="custom"?g:void 0,project:k||void 0,workspace:b||void 0,model:N||void 0,tool:C||void 0})}async function _(M){if(M.preventDefault(),T)return;const B=F(),W=I4(B);if(!W.ok){P(W.errors.join("; "));return}R(!0),P(null);const O=e.kind==="token-usage"?{kind:"token-usage",filters:B}:e.kind==="spend"?{kind:"spend",filters:B}:e;try{await n(O)}catch(H){P(H instanceof Error?H.message:String(H)),R(!1)}}const V=(i==null?void 0:i.map(M=>M.slug))??[],U=(a==null?void 0:a.workspaces)??[],I=(a==null?void 0:a.hasUngrouped)??!1;return s.jsx(Mn,{open:t,onOpenChange:M=>{M||r()},children:s.jsx(Nn,{className:"max-w-md",children:s.jsxs("form",{onSubmit:_,children:[s.jsx(sr,{children:s.jsx(Cn,{children:o})}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Window"}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:sm.map(M=>s.jsx("button",{type:"button",onClick:()=>f(M),className:"rounded px-2.5 py-1 text-sm border "+(M===u?"border-primary bg-primary/10 text-foreground":"border-border text-muted-foreground hover:text-foreground"),children:t9[M]},M))})]}),u==="custom"?s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Since"}),s.jsx("input",{type:"date",value:p,onChange:M=>h(M.target.value),className:xl})]}),s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Until"}),s.jsx("input",{type:"date",value:g,onChange:M=>y(M.target.value),className:xl})]})]}):null,s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Workspace"}),s.jsxs("select",{value:b,onChange:M=>{j(M.target.value),M.target.value&&v("")},className:xl,children:[s.jsx("option",{value:"",children:"All workspaces"}),I?s.jsx("option",{value:"_ungrouped",children:"(ungrouped)"}):null,U.map(M=>s.jsx("option",{value:M,children:M},M))]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Project"}),s.jsxs("select",{value:k,onChange:M=>{v(M.target.value),M.target.value&&j("")},className:xl,children:[s.jsx("option",{value:"",children:"All projects"}),V.map(M=>s.jsx("option",{value:M,children:M},M))]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Model"}),s.jsxs("select",{value:N,onChange:M=>S(M.target.value),className:xl,children:[s.jsx("option",{value:"",children:"All models"}),((l==null?void 0:l.models)??[]).map(M=>s.jsx("option",{value:M,children:M},M))]})]}),s.jsxs("label",{className:"flex flex-1 flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Tool"}),s.jsxs("select",{value:C,onChange:M=>D(M.target.value),className:xl,children:[s.jsx("option",{value:"",children:"All tools"}),((l==null?void 0:l.tools)??[]).map(M=>s.jsx("option",{value:M,children:M},M))]})]})]}),$?s.jsx("p",{className:"text-xs text-destructive",role:"alert",children:$}):null]}),s.jsxs(Wr,{className:"sm:justify-between",children:[s.jsx("button",{type:"button",onClick:r,disabled:T,className:"shell-action",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:T,className:"shell-action shell-action--cta",children:T?"Saving…":"Save"})]})]})})})}const qw={"saved-view":{title:"Saved view",icon:m2,render:(e,t)=>e.kind!=="saved-view"?null:m.createElement(RH,{viewId:e.viewId,onPickAnother:t.onPickAnother})},"agent-sessions":{title:"Agent sessions",icon:Xh,render:(e,t)=>e.kind!=="agent-sessions"?null:m.createElement(QH,{viewId:e.viewId,slotId:t.slotId,onPickAnother:t.onPickAnother})},inventories:{title:"Inventories",icon:zv,render:()=>m.createElement(ZH)},"token-usage":{title:"Token Usage",icon:pO,render:e=>e.kind!=="token-usage"?null:m.createElement(IS,{filters:e.filters,metric:"tokens"}),ConfigEditor:MS},spend:{title:"Spend",icon:tm,render:e=>e.kind!=="spend"?null:m.createElement(IS,{filters:e.filters,metric:"cost"}),ConfigEditor:MS}},tP=50,Yb=16,r9=2,ua=6,Ch=11,Xb={w:6,h:2};function Gp(e,t,n){return Math.min(Math.max(e,t),n)}const s9=[{minWidth:1280,columns:24},{minWidth:1024,columns:16},{minWidth:768,columns:12},{minWidth:640,columns:6},{minWidth:0,columns:1}];function o9(e){if(!Number.isFinite(e)||e<0)return 1;for(const t of s9)if(e>=t.minWidth)return t.columns;return 1}function Yp(e,t){return t<=0?1:Gp(Math.round(e/ad*t),1,t)}function Qb(e){if(h7(e))return e;switch(e){case"small":return{w:8,h:ua};case"wide":return{w:16,h:ua};case"tall":return{w:8,h:Ch};case"large":return{w:16,h:Ch};default:return{w:8,h:ua}}}function i9(e,t){return t>0?Math.round(e/t):0}function a9(e,t=tP){return Math.round(e/t)}const l9=[{label:"Third",w:8,h:ua},{label:"Half",w:12,h:ua},{label:"Two-thirds",w:16,h:ua},{label:"Full",w:24,h:ua},{label:"Half tall",w:12,h:Ch},{label:"Full tall",w:24,h:Ch}];function c9({slot:e,activeColumns:t,colWidthPx:n,onReplace:r,onRemove:o,onRemoveSlot:i,onResize:a,onConfigChange:l}){const[u,f]=m.useState(!1),[p,h]=m.useState(null),g=m.useRef(null),{attributes:y,listeners:k,setNodeRef:v,setActivatorNodeRef:b,transform:j,transition:N,isDragging:S}=Cm({id:e.id}),C=Qb(e.size),D=p?p.renderW:Yp(C.w,t),T=p?p.h:C.h,R={transform:js.Translate.toString(j),transition:N,zIndex:S?50:void 0,position:S?"relative":void 0,gridColumn:`span ${D}`,gridRow:`span ${T}`};function $(B){g.current=null;try{B.currentTarget.releasePointerCapture(B.pointerId)}catch{}h(null)}function P(B){return{onPointerDown:W=>{if(g.current)return;W.preventDefault(),W.stopPropagation(),W.currentTarget.setPointerCapture(W.pointerId);const O=Yp(C.w,t);g.current={pointerId:W.pointerId,startX:W.clientX,startY:W.clientY,startRenderW:O,startH:C.h,axis:B,lastRenderW:O,lastH:C.h},h({renderW:O,h:C.h})},onPointerMove:W=>{const O=g.current;if(!O||W.pointerId!==O.pointerId)return;let H=O.startRenderW,L=O.startH;(O.axis==="w"||O.axis==="both")&&(H=Gp(O.startRenderW+i9(W.clientX-O.startX,n),1,t)),(O.axis==="h"||O.axis==="both")&&(L=Gp(O.startH+a9(W.clientY-O.startY),r9,GR)),O.lastRenderW=H,O.lastH=L,h({renderW:H,h:L})},onPointerUp:W=>{const O=g.current;if(!O||W.pointerId!==O.pointerId)return;const H=Qb(e.size),z={w:O.axis==="h"?H.w:Gp(Math.round(O.lastRenderW/t*ad),1,ad),h:O.lastH};$(W),(z.w!==H.w||z.h!==H.h)&&a(z)},onPointerCancel:W=>{const O=g.current;O&&W.pointerId===O.pointerId&&$(W)},onLostPointerCapture:W=>{const O=g.current;O&&W.pointerId===O.pointerId&&$(W)}}}const F="absolute z-10 touch-none rounded-sm bg-transparent transition hover:bg-primary/30",_=s.jsxs(s.Fragment,{children:[t>1?s.jsx("div",{"aria-hidden":"true",className:je(F,"right-0 top-0 h-full w-1.5 cursor-ew-resize"),...P("w")}):null,s.jsx("div",{"aria-hidden":"true",className:je(F,"bottom-0 left-0 h-1.5 w-full cursor-ns-resize"),...P("h")}),t>1?s.jsx("div",{"aria-hidden":"true",className:je(F,"bottom-0 right-0 h-3 w-3 cursor-nwse-resize"),...P("both")}):null]}),V=s.jsx("button",{ref:b,...y,...k,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:s.jsx(gc,{className:"h-4 w-4","aria-hidden":"true"})});if(e.widget===null)return s.jsxs("div",{ref:v,style:{...R,gridColumn:`span ${Yp(Xb.w,t)}`,gridRow:`span ${Xb.h}`},className:je("relative flex items-center justify-center rounded-lg border border-dashed border-border bg-card/40 p-3 shadow-sm transition-colors hover:border-primary/40 hover:bg-card/60",S&&"opacity-0"),children:[s.jsx("div",{className:"absolute left-2 top-2",children:V}),s.jsx("button",{type:"button","aria-label":"Remove slot",onClick:i,onPointerDown:B=>B.stopPropagation(),className:"absolute right-2 top-2 z-10 text-muted-foreground/50 transition hover:text-destructive",children:s.jsx(jn,{className:"h-4 w-4"})}),s.jsxs("button",{type:"button",onClick:r,className:"shell-action inline-flex items-center gap-2",children:[s.jsx(Mt,{className:"h-4 w-4"}),"Add widget"]})]});const U=qw[e.widget.kind];if(!U)return s.jsxs("div",{ref:v,style:R,className:je("relative overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",S&&"opacity-0"),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[V,s.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 I=U.icon,M=U.ConfigEditor;return s.jsxs("div",{ref:v,style:R,className:je("relative overflow-auto rounded-lg border border-border/60 bg-card/85 p-3 shadow-sm",S&&"opacity-0"),children:[s.jsxs("header",{className:"mb-2 flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[V,s.jsx(I,{className:"h-3.5 w-3.5","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:s.jsx(d9,{slot:e,fallback:U.title})})]}),s.jsx(Hw,{items:[{key:"replace",label:"Replace…",icon:NO,onSelect:r},...U.ConfigEditor?[{key:"configure",label:"Configure…",icon:PO,onSelect:()=>f(!0)}]:[],{key:"size",label:"Size",icon:wO,submenu:l9.map(B=>({key:`size-${B.label}`,label:B.label,active:C.w===B.w&&C.h===B.h,onSelect:()=>a({w:B.w,h:B.h})}))},{key:"remove",label:"Remove",icon:jn,destructive:!0,onSelect:o}]})]}),s.jsx("div",{children:U.render(e.widget,{slotId:e.id,onPickAnother:r})}),M?s.jsx(M,{config:e.widget,open:u,onSave:async B=>{await l(B),f(!1)},onCancel:()=>f(!1)}):null,_]})}function u9({slot:e,activeColumns:t,colWidthPx:n}){const r=e.widget?qw[e.widget.kind]:null,o=r==null?void 0:r.icon,i=e.widget===null?"Empty widget slot":(r==null?void 0:r.title)??`Unknown widget kind: ${e.widget.kind}`,a=e.widget===null?Xb:Qb(e.size),l=Yp(a.w,t),u=n>0?l*n+(l-1)*Yb:void 0;return s.jsx("div",{"aria-hidden":"true",className:"min-w-[200px] rounded-lg border border-border/70 bg-card/95 p-3 shadow-xl ring-1 ring-foreground/10",style:{width:u?`${Math.max(u,200)}px`:void 0},children:s.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-[0.12em] text-muted-foreground",children:[s.jsx(gc,{className:"h-4 w-4","aria-hidden":"true"}),o?s.jsx(o,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null,s.jsx("span",{className:"min-w-0 flex-1 truncate",children:i})]})})}function d9({slot:e,fallback:t}){var o,i;const n=((o=e.widget)==null?void 0:o.kind)==="saved-view"?e.widget.viewId:null,{view:r}=ki(n);return((i=e.widget)==null?void 0:i.kind)==="saved-view"&&r?s.jsx(s.Fragment,{children:r.name}):s.jsx(s.Fragment,{children:t})}const f9=["agent-sessions","inventories","token-usage","spend"];function p9({open:e,onOpenChange:t,onSelect:n}){const{views:r,loading:o}=zd();function i(a){n(a),t(!1)}return s.jsx(Mn,{open:e,onOpenChange:t,children:s.jsxs(Nn,{className:"max-w-xl",children:[s.jsxs(sr,{children:[s.jsx(Cn,{children:"Add a widget"}),s.jsx(ns,{children:"Choose a built-in widget, an assignment view, or a session view."})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Built-in widgets"}),s.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:f9.map(a=>{const l=qw[a],u=l.icon;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>i({kind:a}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[s.jsx(u,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),s.jsx("span",{className:"font-medium text-foreground",children:l.title})]})},a)})})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-[0.12em] text-muted-foreground",children:"Saved views"}),o?s.jsx("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm text-muted-foreground",children:"Loading saved views…"}):r.length===0?s.jsxs("div",{className:"rounded-md border border-border/60 px-3 py-4 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"No saved views yet"}),s.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Save a view from the assignments page first."," ",s.jsx(De,{to:"/views",className:"text-foreground underline hover:opacity-80",children:"Manage views →"})]})]}):s.jsxs("div",{className:"space-y-3",children:[r.some(a=>a.entityType!=="session")&&s.jsxs("div",{children:[s.jsx("h4",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Assignments"}),s.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:r.filter(a=>a.entityType!=="session").map(a=>s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>i({kind:"saved-view",viewId:a.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:a.name}),a.workspace!==null?s.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: ${a.workspace}`,children:a.workspace}):null,s.jsx("span",{className:"shrink-0 rounded-full border border-border/60 px-2 py-0.5 text-[10px] capitalize text-muted-foreground",children:a.config.viewMode})]})},a.id))})]}),r.some(a=>a.entityType==="session")&&s.jsxs("div",{children:[s.jsx("h4",{className:"mb-1 px-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Sessions"}),s.jsx("ul",{className:"divide-y divide-border/40 rounded-md border border-border/60",children:r.filter(a=>a.entityType==="session").map(a=>s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>i({kind:"agent-sessions",viewId:a.id}),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm hover:bg-muted/40",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:a.name}),a.workspace!==null?s.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: ${a.workspace}`,children:a.workspace}):null]})},a.id))})]})]}),!o&&r.some(a=>a.workspace!==null)?s.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 h9=(e,{currentCoordinates:t,context:n})=>{var h;const r=e.code==="ArrowRight"||e.code==="ArrowDown"?1:e.code==="ArrowLeft"||e.code==="ArrowUp"?-1:0;if(r===0)return;e.preventDefault();const o=n.over??n.active,i=(h=o==null?void 0:o.data.current)==null?void 0:h.sortable,a=i==null?void 0:i.items;if(!o||!a)return t;const l=a.indexOf(o.id);if(l===-1)return t;const u=a[l+r],f=u===void 0?null:n.droppableRects.get(u),p=n.collisionRect;return!f||!p?t:{x:f.left+(f.width-p.width)/2,y:f.top+(f.height-p.height)/2}};function m9(e){const t=new Set(e.map(o=>o.id));let n=-1;for(const o of t){const i=/^slot-(\d+)$/.exec(o);if(i){const a=parseInt(i[1],10);a>n&&(n=a)}}let r=n+1;for(;t.has(`slot-${r}`);)r++;return`slot-${r}`}function g9(e,t){const n={id:m9(e),widget:null};return[...e,n]}function x9(e,t){return e.filter(n=>n.id!==t)}function y9(){const{data:e,error:t,refetch:n}=O4(),{data:r}=U2(),{layout:o}=nA(),[i,a]=m.useState(!1),[l,u]=m.useState(null),[f,p]=m.useState(null),[h,g]=m.useState(o.slots),[y,k]=m.useState(null),v=m.useRef(null),[b,j]=m.useState(ad),[N,S]=m.useState(0);m.useEffect(()=>{const W=v.current;if(!W)return;const O=new ResizeObserver(H=>{for(const L of H){const z=L.contentRect.width,Y=o9(z),q=Y>0?(z-(Y-1)*Yb)/Y:0;j(Y),S(q)}});return O.observe(W),()=>O.disconnect()},[]),m.useEffect(()=>{g(o.slots)},[o.slots]);const C=bm(ji(kc,{activationConstraint:{distance:8}}),ji(jc,{coordinateGetter:h9}));Ai("list:overview"),en({keys:"r",description:"Refresh",scope:"list:overview",handler:()=>{n()}});const D=m.useCallback(W=>{u(W),a(!0)},[]),T=m.useCallback(async(W,O)=>{p(null),g(W);try{await Fb(W)}catch(H){g(O),p(H instanceof Error?H.message:String(H))}},[]),R=m.useCallback(W=>{if(l===null)return;const O=h.map((H,L)=>L===l?{...H,widget:W}:H);u(null),T(O,h)},[h,l,T]),$=m.useCallback(W=>{const O=h.map((H,L)=>L===W?{...H,widget:null,size:void 0}:H);T(O,h)},[h,T]),P=m.useCallback(W=>{const O=x9(h,W);T(O,h)},[h,T]),F=m.useCallback(()=>{const W=g9(h);T(W,h)},[h,T]),_=m.useCallback((W,O)=>{const H=h.map((L,z)=>z===W?{...L,size:O}:L);T(H,h)},[h,T]),V=m.useCallback(W=>{const{active:O,over:H}=W;if(k(null),!H||O.id===H.id)return;const L=h.findIndex(q=>q.id===O.id),z=h.findIndex(q=>q.id===H.id);if(L===-1||z===-1)return;const Y=Sc(h,L,z);T(Y,h)},[h,T]),U=m.useCallback(W=>{k(String(W.active.id))},[]),I=h.find(W=>W.id===y)??null,M=m.useCallback(async(W,O)=>{const H=h,L=h.map((z,Y)=>Y===W?{...z,widget:O}:z);p(null),g(L);try{await Fb(L)}catch(z){g(H);const Y=z instanceof Error?z.message:String(z);throw p(Y),z instanceof Error?z:new Error(Y)}},[h]),B={};if(e)for(const W of Object.keys(e.segments))for(const O of e.segments[W].items)B[O.id]=O;return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("header",{className:"space-y-2",children:[s.jsx("p",{className:"eyebrow",children:"Workspace Overview"}),s.jsx("h1",{className:"text-4xl font-semibold tracking-display text-foreground md:text-5xl",children:"What needs you today"})]}),e?s.jsx(f7,{hero:e.hero,itemsById:B}):t?s.jsx(Rt,{error:t,onRetry:n}):s.jsx(bt,{label:"Loading overview…"}),e!=null&&e.firstRun?s.jsx(u7,{help:r}):null,f?s.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: ",f]}):null,s.jsxs(Sm,{sensors:C,collisionDetection:vm,onDragStart:U,onDragCancel:()=>k(null),onDragEnd:V,children:[s.jsx(Nm,{items:h.map(W=>W.id),strategy:Rw,children:s.jsx("div",{ref:v,style:{display:"grid",gridTemplateColumns:`repeat(${b}, minmax(0, 1fr))`,gridAutoRows:`${tP}px`,gridAutoFlow:"dense",gap:`${Yb}px`},children:h.map((W,O)=>s.jsx(c9,{slot:W,index:O,activeColumns:b,colWidthPx:N,onReplace:()=>D(O),onRemove:()=>$(O),onRemoveSlot:()=>P(W.id),onResize:H=>_(O,H),onConfigChange:H=>M(O,H)},W.id))})}),s.jsx(X8,{dropAnimation:null,children:I?s.jsx(u9,{slot:I,activeColumns:b,colWidthPx:N}):null})]}),s.jsxs("button",{type:"button",onClick:F,className:"shell-action inline-flex items-center gap-2",children:[s.jsx(Mt,{className:"h-4 w-4"}),"Add slot"]}),e!=null&&e.serverStats?s.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(Wv,{className:"h-3 w-3","aria-hidden":"true"}),s.jsxs("span",{children:["● ",e.serverStats.totalPorts," ports ·"," ",e.serverStats.deadSessions>0?`${e.serverStats.deadSessions} dead`:"all healthy"]})]}):null,s.jsx(p9,{open:i,onOpenChange:W=>{a(W),W||u(null)},onSelect:R})]})}const b9=["review","blocked","question","plan-approval"],v9={review:"Review",blocked:"Blocked",question:"Questions","plan-approval":"Plan approval"};function w9(e){const t=[];for(const n of b9){const r=e.filter(o=>o.category===n).sort((o,i)=>i.ageMs-o.ageMs);r.length!==0&&t.push({category:n,label:v9[n],count:r.length,items:r})}return t}function j9(e){if(!Number.isFinite(e)||e<0)return"just now";const t=Math.floor(e/1e3);if(t<60)return"just now";const n=Math.floor(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60);return r<24?`${r}h`:`${Math.floor(r/24)}d`}function nP(e,t){const n=encodeURIComponent(t);return e.project===null?{method:"POST",url:`/api/assignments/${encodeURIComponent(e.assignmentId)}/transitions/${n}`}:{method:"POST",url:`/api/projects/${encodeURIComponent(e.project)}/assignments/${encodeURIComponent(e.assignmentSlug)}/transitions/${n}`}}function k9(e){return e.project===null?{method:"POST",url:`/api/assignments/${encodeURIComponent(e.assignmentId)}/comments`}:{method:"POST",url:`/api/projects/${encodeURIComponent(e.project)}/assignments/${encodeURIComponent(e.assignmentSlug)}/comments`}}function S9(e,t){const n=encodeURIComponent(t);return e.project===null?{method:"PATCH",url:`/api/assignments/${encodeURIComponent(e.assignmentId)}/comments/${n}/resolved`}:{method:"PATCH",url:`/api/projects/${encodeURIComponent(e.project)}/assignments/${encodeURIComponent(e.assignmentSlug)}/comments/${n}/resolved`}}function Kw(e,t){const n=t?`?tab=${t}`:"";return e.project===null?`/assignments/${encodeURIComponent(e.assignmentId)}${n}`:`/projects/${encodeURIComponent(e.project)}/assignments/${encodeURIComponent(e.assignmentSlug)}${n}`}function N9(){const{items:e,total:t,loading:n,error:r,refetch:o}=QT(),{toast:i,showToast:a,dismissToast:l}=Qn();if(n&&e.length===0)return s.jsx(bt,{label:"Loading your inbox…"});if(r&&e.length===0)return s.jsx(Rt,{title:"Inbox unavailable",error:r,action:s.jsx("button",{type:"button",className:"shell-action",onClick:o,children:"Retry"})});const u=w9(e);return u.length===0?s.jsxs("div",{className:"space-y-4",children:[s.jsx(Xn,{toast:i,onDismiss:l}),s.jsx(OS,{total:0}),s.jsx(St,{title:"Nothing needs you right now",description:"No reviews, blocks, open questions, or plans awaiting approval across your projects. New items appear here the moment something needs a human decision."})]}):s.jsxs("div",{className:"space-y-5",children:[s.jsx(Xn,{toast:i,onDismiss:l}),s.jsx(OS,{total:t}),u.map(f=>s.jsx(qe,{title:f.label,actions:s.jsx("span",{className:"rounded-full bg-foreground px-2.5 py-0.5 text-xs font-semibold text-background",children:f.count}),children:s.jsx("ul",{className:"space-y-3",children:f.items.map(p=>s.jsx(C9,{item:p,onMutated:o,onError:h=>a(h,"error"),onSuccess:h=>a(h,"success")},`${p.category}:${p.assignmentId}:${p.since}`))})},f.category))]})}function OS({total:e}){return s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("span",{className:"inline-flex h-9 w-9 items-center justify-center rounded-lg bg-card text-foreground shadow-sm ring-1 ring-border/60",children:s.jsx(h2,{className:"h-4 w-4"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Needs me"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:e===0?"Everything is handled.":`${e} ${e===1?"item":"items"} awaiting your decision.`})]})]})}async function Eh(e,t,n,r){try{const o=await fetch(e.url,{method:e.method,headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!o.ok){const i=await o.json().catch(()=>null);throw new Error((i==null?void 0:i.error)||`HTTP ${o.status}`)}return n.onSuccess(r),n.onMutated(),!0}catch(o){return n.onError(o instanceof Error?o.message:String(o)),!1}}function C9({item:e,onMutated:t,onError:n,onSuccess:r}){return s.jsxs("li",{className:"flex flex-col gap-2 rounded-lg border border-border/70 bg-background/40 p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[s.jsx(De,{to:Kw(e),className:"text-sm font-semibold text-foreground hover:underline",children:e.title}),s.jsx("span",{className:"text-xs text-muted-foreground",children:e.project?e.project:"standalone"}),s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",title:e.since,children:j9(e.ageMs)})]}),e.summary?s.jsx("p",{className:"text-sm text-muted-foreground",children:e.summary}):null,s.jsx(E9,{item:e,onMutated:t,onError:n,onSuccess:r}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"min-w-0 flex-1 truncate rounded bg-muted/60 px-2 py-1 font-mono text-[11px] text-muted-foreground",children:e.action.command}),s.jsx(Hr,{value:e.action.command,label:"Copy",onError:o=>n(o.message)})]})]})}function E9(e){switch(e.item.category){case"review":return s.jsx(T9,{...e});case"blocked":return s.jsx(R9,{...e});case"question":return s.jsx(A9,{...e});case"plan-approval":return s.jsx(P9,{...e});default:return null}}const ga="shell-action inline-flex items-center gap-1.5";function T9({item:e,onMutated:t,onError:n,onSuccess:r}){const[o,i]=m.useState(null),{acceptCommand:a,reopenCommand:l}=e;async function u(f,p){i(f),await Eh(nP(e,f),void 0,{onMutated:t,onError:n,onSuccess:r},`${p} — ${e.title}`),i(null)}return s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a?s.jsxs("button",{type:"button",className:ga,disabled:o!==null,onClick:()=>u(a,"Accepted"),children:[s.jsx(Sr,{className:"h-3.5 w-3.5"}),o===a?"Accepting…":"Accept"]}):null,l?s.jsxs("button",{type:"button",className:ga,disabled:o!==null,onClick:()=>u(l,"Reopened"),children:[s.jsx(vs,{className:"h-3.5 w-3.5"}),o===l?"Reopening…":"Reopen"]}):null]})}function R9({item:e,onMutated:t,onError:n,onSuccess:r}){const[o,i]=m.useState(""),[a,l]=m.useState(!1);async function u(){l(!0);const f=await Eh(nP(e,"unblock"),o.trim()?{reason:o.trim()}:void 0,{onMutated:t,onError:n,onSuccess:r},`Unblocked — ${e.title}`);l(!1),f&&i("")}return s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("input",{type:"text",value:o,onChange:f=>i(f.target.value),placeholder:"Reason (optional)",className:"min-w-[12rem] flex-1 rounded border border-border bg-background px-2 py-1 text-sm"}),s.jsxs("button",{type:"button",className:ga,disabled:a,onClick:u,children:[s.jsx(vO,{className:"h-3.5 w-3.5"}),a?"Unblocking…":"Unblock"]})]})}function A9({item:e,onMutated:t,onError:n,onSuccess:r}){const[o,i]=m.useState(""),[a,l]=m.useState(!1),u=e.commentId;async function f(){if(!o.trim())return;l(!0);const h=await Eh(k9(e),{body:o.trim(),type:"note",author:"human",...u?{replyTo:u}:{}},{onMutated:t,onError:n,onSuccess:r},`Replied — ${e.title}`);l(!1),h&&i("")}async function p(){if(!u){n("Could not determine which question to resolve — open the assignment to resolve it.");return}l(!0),await Eh({...S9(e,u)},{resolved:!0},{onMutated:t,onError:n,onSuccess:r},`Resolved — ${e.title}`),l(!1)}return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(De,{to:Kw(e,"comments"),className:ga,children:[s.jsx(Zh,{className:"h-3.5 w-3.5"}),"Open to answer"]}),s.jsxs("button",{type:"button",className:ga,disabled:a||!u,title:u?void 0:"Open the assignment to resolve this question.",onClick:p,children:[s.jsx(em,{className:"h-3.5 w-3.5"}),"Resolve"]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("input",{type:"text",value:o,onChange:h=>i(h.target.value),placeholder:"Reply inline…",className:"min-w-[12rem] flex-1 rounded border border-border bg-background px-2 py-1 text-sm"}),s.jsxs("button",{type:"button",className:ga,disabled:a||!o.trim(),onClick:f,children:[s.jsx(d2,{className:"h-3.5 w-3.5"}),a?"Posting…":"Reply"]})]})]})}function P9({item:e}){return s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.jsxs(De,{to:Kw(e,"plan"),className:ga,children:[s.jsx(Zh,{className:"h-3.5 w-3.5"}),"Review plan"]})})}function _9({term:e,description:t}){return s.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 D9(){const{data:e,loading:t,error:n}=U2(),{openCheatsheet:r}=Ri();return t?s.jsx(bt,{label:"Loading help…"}):n||!e?s.jsx(Rt,{error:n||"Help content is unavailable."}):s.jsxs("div",{className:"space-y-5",children:[s.jsx(qe,{title:"Keyboard Shortcuts",description:"Navigate the dashboard without reaching for the mouse.",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("button",{type:"button",onClick:r,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"}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["or press ",s.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-1.5 py-0.5 font-mono text-[11px]",children:"?"})," ","anywhere. ",Qs("Mod+k")," opens the command palette."]})]})}),s.jsx(qe,{title:"What Syntaur Is",description:e.whatIsSyntaur.summary,children:s.jsx("div",{className:"grid gap-3 md:grid-cols-3",children:e.whatIsSyntaur.bullets.map(o=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3 text-sm leading-6 text-muted-foreground",children:o},o))})}),s.jsx(qe,{title:"Getting Started",children:s.jsx("div",{className:"space-y-3",children:e.workflow.map((o,i)=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.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}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?s.jsx(Vp,{command:o.command.command,description:o.command.description,example:o.command.example}):null,o.href?s.jsx(De,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open the related surface"}):null]})]})},o.title))})}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[s.jsxs(qe,{title:"Core Concepts",children:[s.jsx("div",{className:"flex flex-wrap gap-2",children:e.coreConcepts.map(o=>s.jsx(_9,{term:o.term,description:o.description},o.term))}),s.jsx("div",{className:"grid gap-3 pt-2",children:e.coreConcepts.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.term}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description})]},o.term))})]}),s.jsx(qe,{title:"Status Guide",children:s.jsx("div",{className:"space-y-3",children:e.statusGuide.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(kn,{status:o.status}),s.jsx("p",{className:"font-semibold text-foreground",children:o.meaning})]}),s.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:o.useWhen})]},o.status))})})]}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[s.jsx(qe,{title:"Ownership And File Rules",children:s.jsx("div",{className:"space-y-3",children:e.ownershipRules.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.label}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description}),s.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:o.files.map(i=>s.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))})}),s.jsx(qe,{title:"How To Navigate The Dashboard",children:s.jsx("div",{className:"space-y-3",children:e.navigation.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.label}),s.jsx(De,{className:"text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open"})]}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.description})]},o.label))})})]}),s.jsx(qe,{title:"CLI Quick Reference",children:s.jsx("div",{className:"grid gap-3 xl:grid-cols-2",children:e.commands.map(o=>s.jsx(Vp,{command:o.command,description:o.description,example:o.example},o.command))})}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[s.jsx(qe,{title:"FAQ",children:s.jsx("div",{className:"space-y-3",children:e.faq.map(o=>s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.question}),s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.answer})]},o.question))})}),s.jsx(qe,{title:"First Project Checklist",children:s.jsx("div",{className:"space-y-3",children:e.firstProjectChecklist.map((o,i)=>s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.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}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:o.title}),s.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:o.detail}),o.command?s.jsx(Vp,{command:o.command.command,example:o.command.example}):null,o.href?s.jsx(De,{className:"inline-flex text-sm font-semibold text-primary hover:underline",to:o.href,children:"Open the related surface"}):null]})]})},o.title))})})]})]})}function Gw({children:e}){return s.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 Fm=m.forwardRef(({value:e,onChange:t,placeholder:n="Search"},r)=>s.jsxs("label",{className:"relative flex min-w-[220px] flex-1 items-center",children:[s.jsx(Ci,{className:"pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground"}),s.jsx("input",{ref:r,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"})]}));Fm.displayName="SearchInput";function zm({value:e,options:t,onChange:n}){return s.jsx("div",{className:"inline-flex rounded-md border border-border/60 bg-background/80 p-1",children:t.map(r=>s.jsx("button",{type:"button","aria-pressed":e===r.value,onClick:()=>n(r.value),className:je("rounded-sm px-2.5 py-1.5 text-sm font-medium transition",e===r.value?"bg-foreground text-background":"text-muted-foreground hover:text-foreground"),children:r.label},r.value))})}const $9={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"},FS=["bg-primary","bg-secondary","bg-accent-coral","bg-accent-teal","bg-accent-amber"];function Th({progress:e,className:t,showLegend:n=!1}){const r=As(),i=m.useMemo(()=>{let a=0;const l=Object.keys(e).filter(f=>f!=="total");return(r.order.length>0?[...r.order,...l.filter(f=>!r.order.includes(f))]:l).map(f=>({key:f,className:$9[f]??FS[a++%FS.length]}))},[r.order,e]).filter(a=>(e[a.key]??0)>0);return s.jsxs("div",{className:je("space-y-2",t),children:[s.jsx("div",{className:"flex h-1.5 w-full overflow-hidden rounded-lg border border-border/70 bg-muted/60",children:e.total===0?s.jsx("div",{className:"h-full w-full bg-muted"}):i.map(a=>s.jsx("div",{className:a.className,style:{width:`${(e[a.key]??0)/e.total*100}%`},title:`${bn(a.key)}: ${e[a.key]??0}`},a.key))}),n?i.length>0?s.jsx("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:i.map(a=>s.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-background/80 px-2 py-1",children:[s.jsx("span",{className:je("h-2 w-2 rounded-full",a.className)}),s.jsx("span",{children:bn(a.key)}),s.jsx("span",{className:"font-medium text-foreground",children:e[a.key]??0})]},a.key))}):s.jsx("p",{className:"text-xs text-muted-foreground/70",children:"No assignments yet"}):null]})}const I9=["pending","active","blocked","failed","completed"],Yw=I9,L9=["draft","pending","ready_for_planning","ready_to_implement","in_progress","blocked","review","completed","failed"];function rP(e){return e&&e.length>0?e:[...L9]}function M9(e,t,n){if(t<0||t>=e.length)return e;const r=[...e],[o]=r.splice(t,1),i=t<n?n-1:n;return r.splice(Math.max(0,Math.min(i,r.length)),0,o),r}const O9=220,hp=8;function sP({anchor:e,items:t,onClose:n}){const r=m.useRef(null),[o,i]=m.useState(null);return m.useLayoutEffect(()=>{if(!e){i(null);return}const a=r.current,l=(a==null?void 0:a.offsetWidth)??O9,u=(a==null?void 0:a.offsetHeight)??0,f=Math.max(hp,window.innerWidth-l-hp),p=Math.max(hp,window.innerHeight-u-hp);i({left:Math.min(e.x,f),top:Math.min(e.y,p)})},[e]),m.useEffect(()=>{if(!e)return;function a(f){r.current&&!r.current.contains(f.target)&&n()}function l(f){f.key==="Escape"&&n()}function u(){n()}return document.addEventListener("mousedown",a),document.addEventListener("keydown",l),document.addEventListener("contextmenu",a),window.addEventListener("scroll",u,!0),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",l),document.removeEventListener("contextmenu",a),window.removeEventListener("scroll",u,!0)}},[e,n]),!e||t.length===0?null:s.jsx("div",{ref:r,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:s.jsx(ha,{delayDuration:200,children:t.map(a=>{const l=a.icon,u=je("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition",a.disabled?"cursor-not-allowed opacity-50":a.destructive?"text-destructive hover:bg-destructive/10":"hover:bg-foreground/5"),f=s.jsxs(s.Fragment,{children:[l?s.jsx(l,{className:"h-4 w-4 shrink-0"}):null,s.jsx("span",{className:"block min-w-0 truncate",children:a.label})]});if(a.disabled){const p=s.jsx("span",{tabIndex:0,className:"inline-block w-full outline-none focus-visible:ring-1 focus-visible:ring-ring",children:s.jsx("button",{type:"button",disabled:!0,className:u,children:f})});return a.disabledReason?s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:p}),s.jsx(vr,{side:"left",children:a.disabledReason})]},a.key):s.jsx("div",{children:p},a.key)}return a.href?s.jsx(De,{to:a.href,className:u,onClick:()=>n(),children:f},a.key):s.jsx("button",{type:"button",className:u,onClick:()=>{var p;(p=a.onSelect)==null||p.call(a),n()},children:f},a.key)})})})}const F9="__ungrouped__";function Xw({open:e,onOpenChange:t,currentWorkspace:n,onSubmit:r,title:o="Move to workspace",description:i="Pick the workspace this item should belong to."}){const{data:a,loading:l}=Ea(),[u,f]=m.useState(n),[p,h]=m.useState(!1),[g,y]=m.useState(null);m.useEffect(()=>{e&&(f(n),y(null))},[e,n]);const k=m.useMemo(()=>[...((a==null?void 0:a.workspaces)??[]).map(N=>({key:N,label:N,value:N})),{key:F9,label:"Ungrouped",value:null}],[a]),v=!p&&u!==n;async function b(){if(v){h(!0),y(null);try{await r(u),t(!1)}catch(j){y(j instanceof Error?j.message:"Failed to move item")}finally{h(!1)}}}return s.jsx(Mn,{open:e,onOpenChange:j=>p?void 0:t(j),children:s.jsxs(Nn,{children:[s.jsxs(sr,{children:[s.jsx(Cn,{children:o}),s.jsx(ns,{children:i})]}),s.jsx("div",{className:"my-2 max-h-[320px] overflow-y-auto rounded-md border border-border/60",children:l&&k.length===0?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-sm text-muted-foreground",children:[s.jsx(Vv,{className:"h-4 w-4 animate-spin"})," Loading workspaces…"]}):k.map(j=>{const N=j.value===n,S=j.value===u;return s.jsxs("button",{type:"button",disabled:N||p,onClick:()=>f(j.value),className:je("flex w-full items-center justify-between px-3 py-2 text-left text-sm transition",N?"cursor-not-allowed bg-foreground/5 text-muted-foreground":S?"bg-accent/40 text-foreground":"hover:bg-foreground/5"),children:[s.jsxs("span",{className:je("block min-w-0 truncate",j.value===null?"italic text-muted-foreground":""),children:[j.label,N?s.jsx("span",{className:"ml-2 text-xs",children:"(current)"}):null]}),S?s.jsx(Sr,{className:"h-4 w-4 text-foreground"}):null]},j.key)})}),g?s.jsx("p",{className:"text-sm text-destructive",role:"alert",children:g}):null,s.jsxs(Wr,{children:[s.jsx("button",{type:"button",onClick:()=>t(!1),disabled:p,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:b,disabled:!v,className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:p?"Moving…":"Move"})]})]})})}function zS(){const{workspace:e}=qt(),t=mn(),n=Wt(),{data:r,loading:o,error:i,refetch:a}=to(),{toast:l,showToast:u,dismissToast:f}=Qn(),p=m.useRef(null);Ai("list:projects");const[h,g]=m.useState(""),[y,k]=m.useState("all"),[v,b]=m.useState("all"),[j,N]=m.useState("updated"),[S,C]=Ts(),D=S.get("view"),T=D==="table"||D==="kanban"?D:"cards",R=z=>{C(Y=>{const q=new URLSearchParams(Y);return z==="cards"?q.delete("view"):q.set("view",z),q})},[$,P]=m.useState({}),[F,_]=m.useState(null),[V,U]=m.useState(null),I=m.useMemo(()=>r?r.filter(z=>{if(e){if(e==="_ungrouped"){if(z.workspace!==null)return!1}else if(z.workspace!==e)return!1}return y!=="all"&&z.status!==y||v!=="all"&&!z.tags.includes(v)?!1:h.trim()?`${z.title} ${z.tags.join(" ")} ${z.slug}`.toLowerCase().includes(h.toLowerCase()):!0}).sort((z,Y)=>B9(z,Y,j)):[],[r,h,y,v,j,e]),M=I.map(z=>`${z.slug}:${z.status}`).join("|");m.useEffect(()=>{P(U9(I))},[M,j]);const B=m.useMemo(()=>{const z=new Map(I.map(Y=>[Y.slug,Y]));return Yw.flatMap(Y=>($[Y]??I.filter(Q=>Q.status===Y).map(Q=>Q.slug)).map(Q=>z.get(Q)).filter(Q=>!!Q))},[I,$]),{visibleItems:W,visibleIndexByKey:O}=m.useMemo(()=>{const z=T==="kanban"?B:I,Y=new Map;return z.forEach((q,Q)=>Y.set(q.slug,Q)),{visibleItems:z,visibleIndexByKey:Y}},[T,I,B]),{hotkeyRowProps:H}=Id(W,{scope:"list:projects",onOpen:z=>n(`${t}/projects/${z.slug}`)});if(en({keys:"/",scope:"list:projects",description:"Focus filter",handler:()=>{var z;return(z=p.current)==null?void 0:z.focus()}}),en({keys:"r",scope:"list:projects",description:"Refresh",handler:()=>a()}),o)return s.jsx(bt,{label:"Loading projects…"});if(i||!r)return s.jsx(Rt,{error:i||"Project list is unavailable.",onRetry:a});const L=Array.from(new Set(r.flatMap(z=>z.tags))).sort();return s.jsxs("div",{className:"space-y-5",children:[s.jsx(Xn,{toast:l,onDismiss:f}),s.jsxs(Gw,{children:[s.jsx(Fm,{ref:p,value:h,onChange:g,placeholder:"Search by project title or tag"}),s.jsxs("select",{value:y,onChange:z=>k(z.target.value),className:"editor-input max-w-[180px]",children:[s.jsx("option",{value:"all",children:"All statuses"}),s.jsx("option",{value:"pending",children:"Pending"}),s.jsx("option",{value:"active",children:"Active"}),s.jsx("option",{value:"blocked",children:"Blocked"}),s.jsx("option",{value:"failed",children:"Failed"}),s.jsx("option",{value:"completed",children:"Completed"})]}),s.jsxs("select",{value:v,onChange:z=>b(z.target.value),className:"editor-input max-w-[180px]",children:[s.jsx("option",{value:"all",children:"All tags"}),L.map(z=>s.jsx("option",{value:z,children:z},z))]}),s.jsxs("select",{value:j,onChange:z=>N(z.target.value),className:"editor-input max-w-[180px]",children:[s.jsx("option",{value:"updated",children:"Sort: Updated"}),s.jsx("option",{value:"created",children:"Sort: Created"}),s.jsx("option",{value:"title",children:"Sort: Title"}),s.jsx("option",{value:"attention",children:"Sort: Attention"})]}),s.jsx(zm,{value:T,onChange:z=>R(z),options:[{value:"cards",label:"Cards"},{value:"table",label:"Table"},{value:"kanban",label:"Kanban"}]})]}),I.length===0?r.length===0?s.jsxs("div",{className:"rounded-frame border border-border/60 bg-card px-6 py-16 text-center",children:[s.jsx("p",{className:"eyebrow mx-auto justify-center",children:"Start here"}),s.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"}),s.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."}),s.jsxs("div",{className:"mt-6 flex flex-wrap justify-center gap-3",children:[s.jsx(De,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create your first project"}),s.jsx(De,{className:"shell-action",to:"/help",children:"Read the spec"})]})]}):s.jsx(St,{title:"No projects match these filters",description:"Adjust the current search and filters or create a new project.",actions:s.jsx(De,{className:"shell-action shell-action--solid",to:`${t}/create/project`,children:"Create Project"})}):T==="cards"?s.jsx("div",{className:"grid gap-3 lg:grid-cols-2 2xl:grid-cols-3",children:I.map((z,Y)=>s.jsxs(De,{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",...H(Y),children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:z.title}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Yn(z.updated)]})]}),s.jsx(kn,{status:z.status})]}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsx(Th,{progress:z.progress,showLegend:!0}),s.jsx("div",{className:"flex flex-wrap gap-2",children:z.tags.map(q=>s.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:q},q))}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("p",{className:"text-muted-foreground",children:"Needs attention"}),s.jsx("p",{className:"mt-1 font-semibold text-foreground",children:z.needsAttention.blockedCount+z.needsAttention.failedCount})]}),s.jsxs("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:[s.jsx("p",{className:"text-muted-foreground",children:"Assignments"}),s.jsx("p",{className:"mt-1 font-semibold text-foreground",children:z.progress.total})]})]})]})]},z.slug))}):T==="table"?s.jsx(qe,{title:`${I.length} project${I.length===1?"":"s"}`,children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[s.jsx("th",{className:"pb-3 font-medium",children:"Project"}),s.jsx("th",{className:"pb-3 font-medium",children:"Status"}),s.jsx("th",{className:"pb-3 font-medium",children:"Progress"}),s.jsx("th",{className:"pb-3 font-medium",children:"Attention"}),s.jsx("th",{className:"pb-3 font-medium",children:"Updated"})]})}),s.jsx("tbody",{children:I.map((z,Y)=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",...H(Y),children:[s.jsxs("td",{className:"py-4 pr-4",children:[s.jsx(De,{to:`${t}/projects/${z.slug}`,className:"font-semibold text-foreground hover:text-primary",children:z.title}),s.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:z.tags.map(q=>s.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:q},q))})]}),s.jsx("td",{className:"py-4 pr-4",children:s.jsx(kn,{status:z.status})}),s.jsx("td",{className:"py-4 pr-4",children:s.jsx("div",{className:"min-w-[220px]",children:s.jsx(Th,{progress:z.progress})})}),s.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:z.needsAttention.blockedCount+z.needsAttention.failedCount}),s.jsx("td",{className:"py-4 text-muted-foreground",children:Yn(z.updated)})]},z.slug))})]})})}):s.jsx(Lm,{columns:BS,items:B,getItemId:z=>z.slug,getColumnId:z=>z.status,canDrop:({fromColumnId:z,toColumnId:Y})=>({allowed:!0,reason:z===Y?void 0:"This will set a manual status override on the project."}),onMove:async({item:z,fromColumnId:Y,toColumnId:q,fromIndex:Q,toIndex:ee})=>{var Z;if(Y===q){const ie=$[Y]??I.filter(ne=>ne.status===Y).map(ne=>ne.slug);P(ne=>({...ne,[Y]:M9(ie,Q,ee)}));return}try{const ie=await fetch(`/api/projects/${z.slug}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:q})});if(!ie.ok){const ue=await ie.json().catch(()=>null);u((ue==null?void 0:ue.error)||`HTTP ${ie.status}`,"error");return}a();const ne=((Z=BS.find(ue=>ue.id===q))==null?void 0:Z.title)??q;u(`Moved "${z.title}" to ${ne}`,"success")}catch(ie){u(ie instanceof Error?ie.message:"Failed to move project","error")}},getExternalDragData:z=>({type:"project",id:z.slug}),onCardContextMenu:(z,Y)=>{Y.preventDefault(),_({project:z,anchor:{x:Y.clientX,y:Y.clientY}})},emptyMessage:z=>`No ${z.title.toLowerCase()} projects.`,renderCard:(z,{dragging:Y})=>{const q=O.get(z.slug)??-1;return s.jsx("div",{...q>=0?H(q):{},children:s.jsx(H9,{project:z,dragging:Y})})}}),s.jsx(sP,{anchor:(F==null?void 0:F.anchor)??null,items:F?[{key:"edit",label:"Edit",icon:xc,onSelect:()=>n(`${t}/projects/${F.project.slug}`)},{key:"move",label:"Move to workspace…",icon:Jh,onSelect:()=>U(F.project)}]:[],onClose:()=>_(null)}),s.jsx(Xw,{open:V!==null,onOpenChange:z=>{z||U(null)},currentWorkspace:(V==null?void 0:V.workspace)??null,title:"Move project to workspace",onSubmit:async z=>{if(!V)return;const Y=await fetch(`/api/projects/${encodeURIComponent(V.slug)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:z})});if(!Y.ok){const q=await Y.json().catch(()=>({}));throw new Error(q.error||"Failed to move project")}a()}}),s.jsx("div",{className:"rounded-lg border border-border/60 bg-card/80 p-3 text-sm text-muted-foreground",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Hv,{className:"mt-0.5 h-4 w-4"}),s.jsxs("p",{children:["Project status is derived from assignment state by default.",T==="kanban"?" Drag projects between columns or use":" Use"," the status override on the project detail page to set a manual status."]})]})})]})}const z9={pending:"Pending",active:"Active",blocked:"Blocked",failed:"Failed",completed:"Completed"},BS=Yw.map(e=>({id:e,title:z9[e],description:Vd(e)}));function B9(e,t,n){switch(n){case"created":return t.created.localeCompare(e.created);case"title":return e.title.localeCompare(t.title);case"attention":return US(t)-US(e);case"updated":default:return t.updated.localeCompare(e.updated)}}function US(e){return e.needsAttention.failedCount*10+e.needsAttention.blockedCount*5+e.needsAttention.openQuestions}function U9(e){return Object.fromEntries(Yw.map(t=>[t,e.filter(n=>n.status===t).map(n=>n.slug)]))}function H9({project:e,dragging:t}){const n=mn();return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(De,{to:`${n}/projects/${e.slug}`,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Yn(e.updated)]})]}),s.jsx(kn,{status:e.status})]}),s.jsx("div",{className:"mt-4",children:s.jsx(Th,{progress:e.progress})}),s.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.tags.map(r=>s.jsx("span",{className:"rounded-full border border-border/60 bg-background/80 px-2.5 py-1 text-xs text-foreground",children:r},r)),s.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.progress.total," assignments"]}),s.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"]})]}),s.jsx("div",{className:"mt-4 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:t?"Reordering within status":"Derived project lane"})]})}function Rh({title:e,description:t,actions:n,className:r}){return s.jsxs("div",{className:je("flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",r),children:[s.jsxs("div",{className:"space-y-1",children:[e?s.jsx("h1",{className:"text-xl font-semibold tracking-tight text-foreground sm:text-2xl",children:e}):null,t?s.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:t}):null]}),n?s.jsx("div",{className:"flex flex-wrap items-center gap-3",children:n}):null]})}function V9(){return s.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:[s.jsx(Qh,{className:"h-3 w-3"}),"Archived"]})}function HS(e){return e.projectSlug?`/projects/${e.projectSlug}/assignments/${e.slug}`:`/assignments/${e.id}`}function W9(){const{data:e,loading:t,error:n,refetch:r}=F4(),[o,i]=m.useState(null),[a,l]=m.useState(null),[u,f]=m.useState({}),{toast:p,showToast:h,dismissToast:g}=Qn();async function y(S,C,D){i(C),l(null);try{const T=await fetch(S,{method:"POST",headers:{"Content-Type":"application/json"}});if(!T.ok){const R=await T.json().catch(()=>null);throw new Error((R==null?void 0:R.error)||`HTTP ${T.status}`)}r(),h(D,"success")}catch(T){l(T instanceof Error?T.message:"Restore failed")}finally{i(null)}}function k(S){return y(`/api/projects/${S.slug}/unarchive`,`project:${S.slug}`,"Project restored")}function v(S){const C=S.projectSlug?`/api/projects/${S.projectSlug}/assignments/${S.slug}/unarchive`:`/api/assignments/${S.id}/unarchive`;return y(C,`assignment:${S.id}`,"Assignment restored")}if(t)return s.jsx(bt,{label:"Loading archived content…"});if(n)return s.jsx(Rt,{error:n});const b=(e==null?void 0:e.projects)??[],j=(e==null?void 0:e.assignments)??[],N=b.length===0&&j.length===0;return s.jsxs("div",{className:"space-y-6",children:[s.jsx(Xn,{toast:p,onDismiss:g}),s.jsx(Rh,{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."}),a?s.jsx("div",{className:"rounded border border-status-failed-foreground/30 bg-status-failed px-3 py-2 text-sm text-status-failed-foreground",children:a}):null,N?s.jsx(St,{title:"Nothing archived",description:"Archived projects and assignments will appear here, ready to restore."}):s.jsxs(s.Fragment,{children:[b.length>0&&s.jsx(qe,{title:"Archived Projects",description:"Restoring a project unhides every cascade-hidden assignment; individually-archived children stay archived.",children:s.jsx("ul",{className:"divide-y divide-border",children:b.map(S=>{const C=u[S.slug]??!1;return s.jsxs("li",{className:"py-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>f(D=>({...D,[S.slug]:!C})),className:"inline-flex items-center gap-1.5 text-left text-sm font-medium text-foreground hover:text-foreground/80","aria-expanded":C,children:[C?s.jsx(cr,{className:"h-4 w-4"}):s.jsx(c2,{className:"h-4 w-4"}),s.jsx(Bv,{className:"h-4 w-4 text-muted-foreground"}),S.title,s.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",S.assignments.length," assignment",S.assignments.length===1?"":"s",")"]})]}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Archived ",S.archivedAt?Nr(S.archivedAt):"with no timestamp",S.archivedReason?` · ${S.archivedReason}`:""]}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[s.jsx(De,{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"}),s.jsxs("button",{type:"button",onClick:()=>k(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:[s.jsx(rh,{className:"h-3 w-3"}),"Restore"]})]})]}),C&&S.assignments.length>0&&s.jsx("ul",{className:"mt-2 space-y-1 pl-9",children:S.assignments.map(D=>s.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-sm",children:[s.jsx(De,{to:HS(D),className:"text-foreground hover:text-foreground/80",children:D.title}),s.jsx(kn,{status:D.status,showIcon:!1}),s.jsx("span",{className:"text-xs text-muted-foreground",children:D.archived?"Archived individually — stays archived after restore":"Hidden via project — returns on restore"})]},D.id))})]},S.slug)})})}),j.length>0&&s.jsx(qe,{title:"Archived Assignments",description:"Individually-archived assignments whose project is still active.",children:s.jsx("ul",{className:"divide-y divide-border",children:j.map(S=>s.jsxs("li",{className:"flex flex-wrap items-center gap-3 py-3",children:[s.jsx(De,{to:HS(S),className:"text-sm font-medium text-foreground hover:text-foreground/80",children:S.title}),s.jsx(kn,{status:S.status,showIcon:!1}),s.jsx(V9,{}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.projectTitle??"Standalone"," · Archived"," ",S.archivedAt?Nr(S.archivedAt):"with no timestamp",S.archivedReason?` · ${S.archivedReason}`:""]}),s.jsxs("button",{type:"button",onClick:()=>v(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:[s.jsx(rh,{className:"h-3 w-3"}),"Restore"]})]},S.id))})})]})]})}const VS="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",WS="block min-w-0 truncate";function Qw({externalIds:e,className:t}){return e.length===0?null:s.jsx("span",{className:je("flex flex-wrap items-center gap-1.5",t),children:e.map((n,r)=>{const o=`${n.system}:${n.id}`,i=`${n.system}:${n.id}:${r}`;return n.url!=null&&n.url.length>0?s.jsxs("a",{href:n.url??void 0,target:"_blank",rel:"noopener noreferrer",className:je(VS,"transition-colors hover:text-foreground hover:border-foreground/40"),title:`Open ${o} in ${n.system}`,children:[s.jsx("span",{className:WS,children:o}),s.jsx(mc,{className:"h-2.5 w-2.5 shrink-0"})]},i):s.jsx("span",{className:VS,title:o,children:s.jsx("span",{className:WS,children:o})},i)})})}const q9={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 Gn({label:e,value:t,description:n,icon:r,tone:o="default",to:i}){const a=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.1em] text-muted-foreground",children:e}),s.jsx("p",{className:"text-2xl font-semibold text-foreground",children:t})]}),r?s.jsx("span",{className:"rounded-md border border-border/60 bg-background/80 p-1.5 text-muted-foreground",children:s.jsx(r,{className:"h-5 w-5"})}):null]}),n?s.jsx("p",{className:"mt-2 text-sm leading-5 text-muted-foreground",children:n}):null]}),f=je(q9[(t===0||t==="0")&&(o==="warn"||o==="danger")?"default":o],i?"block transition hover:-translate-y-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40":"");return i?s.jsx(De,{to:i,className:f,children:a}):s.jsx("article",{className:f,children:a})}function qS(e){const t=K9(e),n=m.forwardRef((r,o)=>{const{children:i,...a}=r,l=m.Children.toArray(i),u=l.find(Y9);if(u){const f=u.props.children,p=l.map(h=>h===u?m.Children.count(f)>1?m.Children.only(null):m.isValidElement(f)?f.props.children:null:h);return s.jsx(t,{...a,ref:o,children:m.isValidElement(f)?m.cloneElement(f,void 0,p):null})}return s.jsx(t,{...a,ref:o,children:i})});return n.displayName=`${e}.Slot`,n}function K9(e){const t=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const a=Q9(o),l=X9(i,o.props);return o.type!==m.Fragment&&(l.ref=r?fm(r,a):a),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var G9=Symbol("radix.slottable");function Y9(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===G9}function X9(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Q9(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.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 J9(e){const t=e+"CollectionProvider",[n,r]=Ta(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=v=>{const{scope:b,children:j}=v,N=Lt.useRef(null),S=Lt.useRef(new Map).current;return s.jsx(o,{scope:b,itemMap:S,collectionRef:N,children:j})};a.displayName=t;const l=e+"CollectionSlot",u=qS(l),f=Lt.forwardRef((v,b)=>{const{scope:j,children:N}=v,S=i(l,j),C=nr(b,S.collectionRef);return s.jsx(u,{ref:C,children:N})});f.displayName=l;const p=e+"CollectionItemSlot",h="data-radix-collection-item",g=qS(p),y=Lt.forwardRef((v,b)=>{const{scope:j,children:N,...S}=v,C=Lt.useRef(null),D=nr(b,C),T=i(p,j);return Lt.useEffect(()=>(T.itemMap.set(C,{ref:C,...S}),()=>void T.itemMap.delete(C))),s.jsx(g,{[h]:"",ref:D,children:N})});y.displayName=p;function k(v){const b=i(e+"CollectionConsumer",v);return Lt.useCallback(()=>{const N=b.collectionRef.current;if(!N)return[];const S=Array.from(N.querySelectorAll(`[${h}]`));return Array.from(b.itemMap.values()).sort((T,R)=>S.indexOf(T.ref.current)-S.indexOf(R.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:f,ItemSlot:y},k,r]}var Z9=m.createContext(void 0);function oP(e){const t=m.useContext(Z9);return e||t||"ltr"}var Ny="rovingFocusGroup.onEntryFocus",eV={bubbles:!1,cancelable:!0},qd="RovingFocusGroup",[Jb,iP,tV]=J9(qd),[nV,aP]=Ta(qd,[tV]),[rV,sV]=nV(qd),lP=m.forwardRef((e,t)=>s.jsx(Jb.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Jb.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(oV,{...e,ref:t})})}));lP.displayName=qd;var oV=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:f,preventScrollOnEntryFocus:p=!1,...h}=e,g=m.useRef(null),y=nr(t,g),k=oP(i),[v,b]=pm({prop:a,defaultProp:l??null,onChange:u,caller:qd}),[j,N]=m.useState(!1),S=ba(f),C=iP(n),D=m.useRef(!1),[T,R]=m.useState(0);return m.useEffect(()=>{const $=g.current;if($)return $.addEventListener(Ny,S),()=>$.removeEventListener(Ny,S)},[S]),s.jsx(rV,{scope:n,orientation:r,dir:k,loop:o,currentTabStopId:v,onItemFocus:m.useCallback($=>b($),[b]),onItemShiftTab:m.useCallback(()=>N(!0),[]),onFocusableItemAdd:m.useCallback(()=>R($=>$+1),[]),onFocusableItemRemove:m.useCallback(()=>R($=>$-1),[]),children:s.jsx(Sn.div,{tabIndex:j||T===0?-1:0,"data-orientation":r,...h,ref:y,style:{outline:"none",...e.style},onMouseDown:sn(e.onMouseDown,()=>{D.current=!0}),onFocus:sn(e.onFocus,$=>{const P=!D.current;if($.target===$.currentTarget&&P&&!j){const F=new CustomEvent(Ny,eV);if($.currentTarget.dispatchEvent(F),!F.defaultPrevented){const _=C().filter(B=>B.focusable),V=_.find(B=>B.active),U=_.find(B=>B.id===v),M=[V,U,..._].filter(Boolean).map(B=>B.ref.current);dP(M,p)}}D.current=!1}),onBlur:sn(e.onBlur,()=>N(!1))})})}),cP="RovingFocusGroupItem",uP=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:a,...l}=e,u=Ml(),f=i||u,p=sV(cP,n),h=p.currentTabStopId===f,g=iP(n),{onFocusableItemAdd:y,onFocusableItemRemove:k,currentTabStopId:v}=p;return m.useEffect(()=>{if(r)return y(),()=>k()},[r,y,k]),s.jsx(Jb.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:s.jsx(Sn.span,{tabIndex:h?0:-1,"data-orientation":p.orientation,...l,ref:t,onMouseDown:sn(e.onMouseDown,b=>{r?p.onItemFocus(f):b.preventDefault()}),onFocus:sn(e.onFocus,()=>p.onItemFocus(f)),onKeyDown:sn(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){p.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const j=lV(b,p.orientation,p.dir);if(j!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let S=g().filter(C=>C.focusable).map(C=>C.ref.current);if(j==="last")S.reverse();else if(j==="prev"||j==="next"){j==="prev"&&S.reverse();const C=S.indexOf(b.currentTarget);S=p.loop?cV(S,C+1):S.slice(C+1)}setTimeout(()=>dP(S))}}),children:typeof a=="function"?a({isCurrentTabStop:h,hasTabStop:v!=null}):a})})});uP.displayName=cP;var iV={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function aV(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function lV(e,t,n){const r=aV(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return iV[r]}function dP(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function cV(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var uV=lP,dV=uP,Bm="Tabs",[fV]=Ta(Bm,[aP]),fP=aP(),[pV,Jw]=fV(Bm),pP=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:u="automatic",...f}=e,p=oP(l),[h,g]=pm({prop:r,onChange:o,defaultProp:i??"",caller:Bm});return s.jsx(pV,{scope:n,baseId:Ml(),value:h,onValueChange:g,orientation:a,dir:p,activationMode:u,children:s.jsx(Sn.div,{dir:p,"data-orientation":a,...f,ref:t})})});pP.displayName=Bm;var hP="TabsList",mP=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Jw(hP,n),a=fP(n);return s.jsx(uV,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(Sn.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});mP.displayName=hP;var gP="TabsTrigger",xP=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,a=Jw(gP,n),l=fP(n),u=vP(a.baseId,r),f=wP(a.baseId,r),p=r===a.value;return s.jsx(dV,{asChild:!0,...l,focusable:!o,active:p,children:s.jsx(Sn.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":f,"data-state":p?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...i,ref:t,onMouseDown:sn(e.onMouseDown,h=>{!o&&h.button===0&&h.ctrlKey===!1?a.onValueChange(r):h.preventDefault()}),onKeyDown:sn(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&a.onValueChange(r)}),onFocus:sn(e.onFocus,()=>{const h=a.activationMode!=="manual";!p&&!o&&h&&a.onValueChange(r)})})})});xP.displayName=gP;var yP="TabsContent",bP=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...a}=e,l=Jw(yP,n),u=vP(l.baseId,r),f=wP(l.baseId,r),p=r===l.value,h=m.useRef(p);return m.useEffect(()=>{const g=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(g)},[]),s.jsx(Ra,{present:o||p,children:({present:g})=>s.jsx(Sn.div,{"data-state":p?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:f,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:h.current?"0s":void 0},children:g&&i})})});bP.displayName=yP;function vP(e,t){return`${e}-trigger-${t}`}function wP(e,t){return`${e}-content-${t}`}var jP=pP,kP=mP,Zb=xP,ev=bP;function Um({value:e,onValueChange:t,items:n,className:r}){const o=m.useRef(null),[i,a]=m.useState(!1),l=m.useCallback(()=>{const u=o.current;u&&a(u.scrollLeft+u.clientWidth<u.scrollWidth-1)},[]);return m.useEffect(()=>{const u=o.current;if(!u)return;l(),u.addEventListener("scroll",l,{passive:!0});const f=new ResizeObserver(l);return f.observe(u),()=>{u.removeEventListener("scroll",l),f.disconnect()}},[l,n.length]),s.jsxs(jP,{value:e,onValueChange:t,className:r,children:[s.jsxs("div",{className:"relative",children:[s.jsx(kP,{ref:o,className:"flex gap-2 overflow-x-auto rounded-md border border-border/70 bg-card/80 p-1",children:n.map(u=>s.jsxs(Zb,{value:u.value,className:je("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:[s.jsx("span",{children:u.label}),typeof u.count=="number"?s.jsx("span",{className:"rounded-full bg-background/20 px-2 py-0.5 text-xs data-[state=active]:bg-background/20",children:u.count}):null,u.problemCount&&u.problemCount>0?s.jsx("span",{className:"rounded-full bg-destructive/15 px-2 py-0.5 text-xs text-destructive","aria-label":`${u.problemCount} ${u.problemCount===1?"error":"errors"}`,title:`${u.problemCount} ${u.problemCount===1?"error":"errors"}`,children:u.problemCount}):null]},u.value))}),i?s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 w-8 rounded-r-md bg-gradient-to-l from-card to-transparent"}):null]}),n.map(u=>s.jsx(ev,{value:u.value,className:"pt-3",children:u.content},u.value))]})}const hV="modulepreload",mV=function(e){return"/"+e},KS={},gV=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let a=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),u=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));o=a(n.map(f=>{if(f=mV(f),f in KS)return;KS[f]=!0;const p=f.endsWith(".css"),h=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":hV,p||(g.as="script"),g.crossOrigin="",g.href=f,u&&g.setAttribute("nonce",u),document.head.appendChild(g),p)return new Promise((y,k)=>{g.addEventListener("load",y),g.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return o.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})};function xV({definition:e,className:t,nodeRoutes:n={}}){const r=m.useRef(null),[o,i]=m.useState(null),[a,l]=m.useState(!0),u=Wt(),f=document.documentElement.classList.contains("dark")?"dark":"default";return m.useEffect(()=>{let p=!1;async function h(){if(r.current)try{const g=(await gV(async()=>{const{default:v}=await import("./mermaid.core-CAwQaPqG.js").then(b=>b.bs);return{default:v}},[])).default;if(g.initialize({startOnLoad:!1,theme:"base",themeVariables:yV(f==="dark")}),p)return;const y=`mermaid-${Date.now()}`,{svg:k}=await g.render(y,e);if(p||!r.current)return;r.current.innerHTML=k,bV(r.current,n,u),l(!1)}catch(g){p||(i(g instanceof Error?g.message:"Failed to render graph"),l(!1))}}return l(!0),i(null),h(),()=>{p=!0}},[e,u,n,f]),o?s.jsxs("div",{className:je("rounded-lg border border-border bg-card p-4",t),children:[s.jsxs("p",{className:"text-sm text-error-foreground",children:["Failed to render dependency graph: ",o]}),s.jsx("pre",{className:"mt-2 text-xs text-muted-foreground overflow-auto",children:e})]}):s.jsxs("div",{className:je("rounded-lg border border-border bg-card p-4",t),children:[a&&s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading graph..."}),s.jsx("div",{ref:r,className:"overflow-auto"})]})}function yV(e){const t=document.documentElement,n=h=>{const g=getComputedStyle(t).getPropertyValue(h).trim();return g?`oklch(${g})`:""},r=n("--card"),o=n("--card-foreground"),i=n("--border"),a=n("--primary"),l=n("--primary-foreground"),u=n("--muted"),f=n("--muted-foreground"),p=n("--secondary");return{background:r,primaryColor:r,primaryTextColor:o,primaryBorderColor:i,secondaryColor:u,secondaryTextColor:o,secondaryBorderColor:i,tertiaryColor:u,tertiaryTextColor:f,tertiaryBorderColor:i,lineColor:e?f:i,textColor:o,mainBkg:r,nodeBkg:r,nodeTextColor:o,nodeBorder:i,clusterBkg:u,clusterBorder:i,edgeLabelBackground:r,titleColor:o,activeTaskBkgColor:a,activeTaskBorderColor:a,altBackground:u,labelColor:o,errorBkgColor:p,errorTextColor:l}}function bV(e,t,n){var r;for(const o of e.querySelectorAll(".node")){const i=((r=o.textContent)==null?void 0:r.replace(/\s+/g," ").trim())??"",a=t[i];if(!a)continue;o.style.cursor="pointer",o.setAttribute("role","link"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`Open ${i}`);const l=()=>n(a);o.addEventListener("click",l),o.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),l())})}}function vV(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const wV=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,jV=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kV={};function GS(e,t){return(kV.jsx?jV:wV).test(e)}const SV=/[ \t\n\f\r]/g;function NV(e){return typeof e=="object"?e.type==="text"?YS(e.value):!1:YS(e)}function YS(e){return e.replace(SV,"")===""}class Kd{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Kd.prototype.normal={};Kd.prototype.property={};Kd.prototype.space=void 0;function SP(e,t){const n={},r={};for(const o of e)Object.assign(n,o.property),Object.assign(r,o.normal);return new Kd(n,r,t)}function tv(e){return e.toLowerCase()}class Cr{constructor(t,n){this.attribute=n,this.property=t}}Cr.prototype.attribute="";Cr.prototype.booleanish=!1;Cr.prototype.boolean=!1;Cr.prototype.commaOrSpaceSeparated=!1;Cr.prototype.commaSeparated=!1;Cr.prototype.defined=!1;Cr.prototype.mustUseProperty=!1;Cr.prototype.number=!1;Cr.prototype.overloadedBoolean=!1;Cr.prototype.property="";Cr.prototype.spaceSeparated=!1;Cr.prototype.space=void 0;let CV=0;const kt=Pa(),yn=Pa(),nv=Pa(),Le=Pa(),Gt=Pa(),Wl=Pa(),$r=Pa();function Pa(){return 2**++CV}const rv=Object.freeze(Object.defineProperty({__proto__:null,boolean:kt,booleanish:yn,commaOrSpaceSeparated:$r,commaSeparated:Wl,number:Le,overloadedBoolean:nv,spaceSeparated:Gt},Symbol.toStringTag,{value:"Module"})),Cy=Object.keys(rv);class Zw extends Cr{constructor(t,n,r,o){let i=-1;if(super(t,n),XS(this,"space",o),typeof r=="number")for(;++i<Cy.length;){const a=Cy[i];XS(this,Cy[i],(r&rv[a])===rv[a])}}}Zw.prototype.defined=!0;function XS(e,t,n){n&&(e[t]=n)}function Ec(e){const t={},n={};for(const[r,o]of Object.entries(e.properties)){const i=new Zw(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[tv(r)]=r,n[tv(i.attribute)]=r}return new Kd(t,n,e.space)}const NP=Ec({properties:{ariaActiveDescendant:null,ariaAtomic:yn,ariaAutoComplete:null,ariaBusy:yn,ariaChecked:yn,ariaColCount:Le,ariaColIndex:Le,ariaColSpan:Le,ariaControls:Gt,ariaCurrent:null,ariaDescribedBy:Gt,ariaDetails:null,ariaDisabled:yn,ariaDropEffect:Gt,ariaErrorMessage:null,ariaExpanded:yn,ariaFlowTo:Gt,ariaGrabbed:yn,ariaHasPopup:null,ariaHidden:yn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Gt,ariaLevel:Le,ariaLive:null,ariaModal:yn,ariaMultiLine:yn,ariaMultiSelectable:yn,ariaOrientation:null,ariaOwns:Gt,ariaPlaceholder:null,ariaPosInSet:Le,ariaPressed:yn,ariaReadOnly:yn,ariaRelevant:null,ariaRequired:yn,ariaRoleDescription:Gt,ariaRowCount:Le,ariaRowIndex:Le,ariaRowSpan:Le,ariaSelected:yn,ariaSetSize:Le,ariaSort:null,ariaValueMax:Le,ariaValueMin:Le,ariaValueNow:Le,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function CP(e,t){return t in e?e[t]:t}function EP(e,t){return CP(e,t.toLowerCase())}const EV=Ec({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Wl,acceptCharset:Gt,accessKey:Gt,action:null,allow:null,allowFullScreen:kt,allowPaymentRequest:kt,allowUserMedia:kt,alt:null,as:null,async:kt,autoCapitalize:null,autoComplete:Gt,autoFocus:kt,autoPlay:kt,blocking:Gt,capture:null,charSet:null,checked:kt,cite:null,className:Gt,cols:Le,colSpan:null,content:null,contentEditable:yn,controls:kt,controlsList:Gt,coords:Le|Wl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:kt,defer:kt,dir:null,dirName:null,disabled:kt,download:nv,draggable:yn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:kt,formTarget:null,headers:Gt,height:Le,hidden:nv,high:Le,href:null,hrefLang:null,htmlFor:Gt,httpEquiv:Gt,id:null,imageSizes:null,imageSrcSet:null,inert:kt,inputMode:null,integrity:null,is:null,isMap:kt,itemId:null,itemProp:Gt,itemRef:Gt,itemScope:kt,itemType:Gt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:kt,low:Le,manifest:null,max:null,maxLength:Le,media:null,method:null,min:null,minLength:Le,multiple:kt,muted:kt,name:null,nonce:null,noModule:kt,noValidate:kt,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:kt,optimum:Le,pattern:null,ping:Gt,placeholder:null,playsInline:kt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:kt,referrerPolicy:null,rel:Gt,required:kt,reversed:kt,rows:Le,rowSpan:Le,sandbox:Gt,scope:null,scoped:kt,seamless:kt,selected:kt,shadowRootClonable:kt,shadowRootDelegatesFocus:kt,shadowRootMode:null,shape:null,size:Le,sizes:null,slot:null,span:Le,spellCheck:yn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Le,step:null,style:null,tabIndex:Le,target:null,title:null,translate:null,type:null,typeMustMatch:kt,useMap:null,value:yn,width:Le,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Gt,axis:null,background:null,bgColor:null,border:Le,borderColor:null,bottomMargin:Le,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:kt,declare:kt,event:null,face:null,frame:null,frameBorder:null,hSpace:Le,leftMargin:Le,link:null,longDesc:null,lowSrc:null,marginHeight:Le,marginWidth:Le,noResize:kt,noHref:kt,noShade:kt,noWrap:kt,object:null,profile:null,prompt:null,rev:null,rightMargin:Le,rules:null,scheme:null,scrolling:yn,standby:null,summary:null,text:null,topMargin:Le,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Le,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:kt,disableRemotePlayback:kt,prefix:null,property:null,results:Le,security:null,unselectable:null},space:"html",transform:EP}),TV=Ec({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:$r,accentHeight:Le,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Le,amplitude:Le,arabicForm:null,ascent:Le,attributeName:null,attributeType:null,azimuth:Le,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Le,by:null,calcMode:null,capHeight:Le,className:Gt,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:Le,diffuseConstant:Le,direction:null,display:null,dur:null,divisor:Le,dominantBaseline:null,download:kt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Le,enableBackground:null,end:null,event:null,exponent:Le,externalResourcesRequired:null,fill:null,fillOpacity:Le,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:Wl,g2:Wl,glyphName:Wl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Le,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Le,horizOriginX:Le,horizOriginY:Le,id:null,ideographic:Le,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Le,k:Le,k1:Le,k2:Le,k3:Le,k4:Le,kernelMatrix:$r,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Le,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:Le,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:Le,overlineThickness:Le,paintOrder:null,panose1:null,path:null,pathLength:Le,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Gt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Le,pointsAtY:Le,pointsAtZ:Le,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:$r,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:$r,rev:$r,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:$r,requiredFeatures:$r,requiredFonts:$r,requiredFormats:$r,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:Le,specularExponent:Le,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Le,strikethroughThickness:Le,string:null,stroke:null,strokeDashArray:$r,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Le,strokeOpacity:Le,strokeWidth:null,style:null,surfaceScale:Le,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:$r,tabIndex:Le,tableValues:null,target:null,targetX:Le,targetY:Le,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:$r,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Le,underlineThickness:Le,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Le,values:null,vAlphabetic:Le,vMathematical:Le,vectorEffect:null,vHanging:Le,vIdeographic:Le,version:null,vertAdvY:Le,vertOriginX:Le,vertOriginY:Le,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Le,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:CP}),TP=Ec({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()}}),RP=Ec({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:EP}),AP=Ec({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),RV={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"},AV=/[A-Z]/g,QS=/-[a-z]/g,PV=/^data[-\w.:]+$/i;function _V(e,t){const n=tv(t);let r=t,o=Cr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&PV.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(QS,$V);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!QS.test(i)){let a=i.replace(AV,DV);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}o=Zw}return new o(r,t)}function DV(e){return"-"+e.toLowerCase()}function $V(e){return e.charAt(1).toUpperCase()}const IV=SP([NP,EV,TP,RP,AP],"html"),e0=SP([NP,TV,TP,RP,AP],"svg");function LV(e){return e.join(" ").trim()}var yl={},Ey,JS;function MV(){if(JS)return Ey;JS=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
606
- `,f="/",p="*",h="",g="comment",y="declaration";function k(b,j){if(typeof b!="string")throw new TypeError("First argument must be a string");if(!b)return[];j=j||{};var N=1,S=1;function C(I){var M=I.match(t);M&&(N+=M.length);var B=I.lastIndexOf(u);S=~B?I.length-B:S+I.length}function D(){var I={line:N,column:S};return function(M){return M.position=new T(I),P(),M}}function T(I){this.start=I,this.end={line:N,column:S},this.source=j.source}T.prototype.content=b;function R(I){var M=new Error(j.source+":"+N+":"+S+": "+I);if(M.reason=I,M.filename=j.source,M.line=N,M.column=S,M.source=b,!j.silent)throw M}function $(I){var M=I.exec(b);if(M){var B=M[0];return C(B),b=b.slice(B.length),M}}function P(){$(n)}function F(I){var M;for(I=I||[];M=_();)M!==!1&&I.push(M);return I}function _(){var I=D();if(!(f!=b.charAt(0)||p!=b.charAt(1))){for(var M=2;h!=b.charAt(M)&&(p!=b.charAt(M)||f!=b.charAt(M+1));)++M;if(M+=2,h===b.charAt(M-1))return R("End of comment missing");var B=b.slice(2,M-2);return S+=2,C(B),b=b.slice(M),S+=2,I({type:g,comment:B})}}function V(){var I=D(),M=$(r);if(M){if(_(),!$(o))return R("property missing ':'");var B=$(i),W=I({type:y,property:v(M[0].replace(e,h)),value:B?v(B[0].replace(e,h)):h});return $(a),W}}function U(){var I=[];F(I);for(var M;M=V();)M!==!1&&(I.push(M),F(I));return I}return P(),U()}function v(b){return b?b.replace(l,h):h}return Ey=k,Ey}var ZS;function OV(){if(ZS)return yl;ZS=1;var e=yl&&yl.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(yl,"__esModule",{value:!0}),yl.default=n;const t=e(MV());function n(r,o){let i=null;if(!r||typeof r!="string")return i;const a=(0,t.default)(r),l=typeof o=="function";return a.forEach(u=>{if(u.type!=="declaration")return;const{property:f,value:p}=u;l?o(f,p,u):p&&(i=i||{},i[f]=p)}),i}return yl}var xu={},eN;function FV(){if(eN)return xu;eN=1,Object.defineProperty(xu,"__esModule",{value:!0}),xu.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,i=function(f){return!f||n.test(f)||e.test(f)},a=function(f,p){return p.toUpperCase()},l=function(f,p){return"".concat(p,"-")},u=function(f,p){return p===void 0&&(p={}),i(f)?f:(f=f.toLowerCase(),p.reactCompat?f=f.replace(o,l):f=f.replace(r,l),f.replace(t,a))};return xu.camelCase=u,xu}var yu,tN;function zV(){if(tN)return yu;tN=1;var e=yu&&yu.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},t=e(OV()),n=FV();function r(o,i){var a={};return!o||typeof o!="string"||(0,t.default)(o,function(l,u){l&&u&&(a[(0,n.camelCase)(l,i)]=u)}),a}return r.default=r,yu=r,yu}var BV=zV();const UV=Cd(BV),PP=_P("end"),t0=_P("start");function _P(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function HV(e){const t=t0(e),n=PP(e);if(t&&n)return{start:t,end:n}}function Wu(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?nN(e.position):"start"in e||"end"in e?nN(e):"line"in e||"column"in e?sv(e):""}function sv(e){return rN(e&&e.line)+":"+rN(e&&e.column)}function nN(e){return sv(e&&e.start)+"-"+sv(e&&e.end)}function rN(e){return e&&typeof e=="number"?e:1}class or extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let o="",i={},a=!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&&(a=!0,o=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?i.ruleId=r:(i.source=r.slice(0,u),i.ruleId=r.slice(u+1))}if(!i.place&&i.ancestors&&i.ancestors){const u=i.ancestors[i.ancestors.length-1];u&&(i.place=u.position)}const l=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=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=l?l.line:void 0,this.name=Wu(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=a&&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}}or.prototype.file="";or.prototype.name="";or.prototype.reason="";or.prototype.message="";or.prototype.stack="";or.prototype.column=void 0;or.prototype.line=void 0;or.prototype.ancestors=void 0;or.prototype.cause=void 0;or.prototype.fatal=void 0;or.prototype.place=void 0;or.prototype.ruleId=void 0;or.prototype.source=void 0;const n0={}.hasOwnProperty,VV=new Map,WV=/[A-Z]/g,qV=new Set(["table","tbody","thead","tfoot","tr"]),KV=new Set(["td","th"]),DP="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function GV(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=nW(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");r=tW(n,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,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"?e0:IV,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=$P(o,e,void 0);return i&&typeof i!="string"?i:o.create(e,o.Fragment,{children:i||void 0},void 0)}function $P(e,t,n){if(t.type==="element")return YV(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return XV(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return JV(e,t,n);if(t.type==="mdxjsEsm")return QV(e,t);if(t.type==="root")return ZV(e,t,n);if(t.type==="text")return eW(e,t)}function YV(e,t,n){const r=e.schema;let o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=e0,e.schema=o),e.ancestors.push(t);const i=LP(e,t.tagName,!1),a=rW(e,t);let l=s0(e,t);return qV.has(t.tagName)&&(l=l.filter(function(u){return typeof u=="string"?!NV(u):!0})),IP(e,a,i,t),r0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function XV(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}fd(e,t.position)}function QV(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);fd(e,t.position)}function JV(e,t,n){const r=e.schema;let o=r;t.name==="svg"&&r.space==="html"&&(o=e0,e.schema=o),e.ancestors.push(t);const i=t.name===null?e.Fragment:LP(e,t.name,!0),a=sW(e,t),l=s0(e,t);return IP(e,a,i,t),r0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function ZV(e,t,n){const r={};return r0(r,s0(e,t)),e.create(t,e.Fragment,r,n)}function eW(e,t){return t.value}function IP(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function r0(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function tW(e,t,n){return r;function r(o,i,a,l){const f=Array.isArray(a.children)?n:t;return l?f(i,a,l):f(i,a)}}function nW(e,t){return n;function n(r,o,i,a){const l=Array.isArray(i.children),u=t0(r);return t(o,i,a,l,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function rW(e,t){const n={};let r,o;for(o in t.properties)if(o!=="children"&&n0.call(t.properties,o)){const i=oW(e,o,t.properties[o]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&KV.has(t.tagName)?r=l:n[a]=l}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function sW(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const a=i.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else fd(e,t.position);else{const o=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,i=e.evaluater.evaluateExpression(l.expression)}else fd(e,t.position);else i=r.value===null?!0:r.value;n[o]=i}return n}function s0(e,t){const n=[];let r=-1;const o=e.passKeys?new Map:VV;for(;++r<t.children.length;){const i=t.children[r];let a;if(e.passKeys){const u=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(u){const f=o.get(u)||0;a=u+"-"+f,o.set(u,f+1)}}const l=$P(e,i,a);l!==void 0&&n.push(l)}return n}function oW(e,t,n){const r=_V(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?vV(n):LV(n)),r.property==="style"){let o=typeof n=="object"?n:iW(e,String(n));return e.stylePropertyNameCase==="css"&&(o=aW(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?RV[r.property]||r.property:r.attribute,n]}}function iW(e,t){try{return UV(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,o=new or("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=DP+"#cannot-parse-style-attribute",o}}function LP(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const o=t.split(".");let i=-1,a;for(;++i<o.length;){const l=GS(o[i])?{type:"Identifier",name:o[i]}:{type:"Literal",value:o[i]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(i&&l.type==="Literal"),optional:!1}:l}r=a}else r=GS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const o=r.value;return n0.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);fd(e)}function fd(e,t){const n=new or("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=DP+"#cannot-handle-mdx-estrees-without-createevaluater",n}function aW(e){const t={};let n;for(n in e)n0.call(e,n)&&(t[lW(n)]=e[n]);return t}function lW(e){let t=e.replace(WV,cW);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function cW(e){return"-"+e.toLowerCase()}const Ty={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"]},uW={};function dW(e,t){const n=uW,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return MP(e,r,o)}function MP(e,t,n){if(fW(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 sN(e.children,t,n)}return Array.isArray(e)?sN(e,t,n):""}function sN(e,t,n){const r=[];let o=-1;for(;++o<e.length;)r[o]=MP(e[o],t,n);return r.join("")}function fW(e){return!!(e&&typeof e=="object")}const oN=document.createElement("i");function o0(e){const t="&"+e+";";oN.innerHTML=t;const n=oN.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function eo(e,t,n,r){const o=e.length;let i=0,a;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);i<r.length;)a=r.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function es(e,t){return e.length>0?(eo(e,e.length,0,t),e):t}const iN={}.hasOwnProperty;function pW(e){const t={};let n=-1;for(;++n<e.length;)hW(t,e[n]);return t}function hW(e,t){let n;for(n in t){const o=(iN.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){iN.call(o,a)||(o[a]=[]);const l=i[a];mW(o[a],Array.isArray(l)?l:l?[l]:[])}}}function mW(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);eo(e,0,0,r)}function OP(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 ql(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ks=Pi(/[A-Za-z]/),Br=Pi(/[\dA-Za-z]/),gW=Pi(/[#-'*+\--9=?A-Z^-~]/);function ov(e){return e!==null&&(e<32||e===127)}const iv=Pi(/\d/),xW=Pi(/[\dA-Fa-f]/),yW=Pi(/[!-/:-@[-`{-~]/);function xt(e){return e!==null&&e<-2}function kr(e){return e!==null&&(e<0||e===32)}function Ft(e){return e===-2||e===-1||e===32}const bW=Pi(new RegExp("\\p{P}|\\p{S}","u")),vW=Pi(/\s/);function Pi(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Tc(e){const t=[];let n=-1,r=0,o=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&Br(e.charCodeAt(n+1))&&Br(e.charCodeAt(n+2)))o=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(a=String.fromCharCode(i));else if(i>55295&&i<57344){const l=e.charCodeAt(n+1);i<56320&&l>56319&&l<57344?(a=String.fromCharCode(i,l),o=1):a="�"}else a=String.fromCharCode(i);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+o+1,a=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function Yt(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(u){return Ft(u)?(e.enter(n),l(u)):t(u)}function l(u){return Ft(u)&&i++<o?(e.consume(u),l):(e.exit(n),t(u))}}const wW={tokenize:jW};function jW(e){const t=e.attempt(this.parser.constructs.contentInitial,r,o);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Yt(e,t,"linePrefix")}function o(l){return e.enter("paragraph"),i(l)}function i(l){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return xt(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const kW={tokenize:SW},aN={tokenize:NW};function SW(e){const t=this,n=[];let r=0,o,i,a;return l;function l(S){if(r<n.length){const C=n[r];return t.containerState=C[1],e.attempt(C[0].continuation,u,f)(S)}return f(S)}function u(S){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&N();const C=t.events.length;let D=C,T;for(;D--;)if(t.events[D][0]==="exit"&&t.events[D][1].type==="chunkFlow"){T=t.events[D][1].end;break}j(r);let R=C;for(;R<t.events.length;)t.events[R][1].end={...T},R++;return eo(t.events,D+1,0,t.events.slice(C)),t.events.length=R,f(S)}return l(S)}function f(S){if(r===n.length){if(!o)return g(S);if(o.currentConstruct&&o.currentConstruct.concrete)return k(S);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(aN,p,h)(S)}function p(S){return o&&N(),j(r),g(S)}function h(S){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,k(S)}function g(S){return t.containerState={},e.attempt(aN,y,k)(S)}function y(S){return r++,n.push([t.currentConstruct,t.containerState]),g(S)}function k(S){if(S===null){o&&N(),j(0),e.consume(S);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:i}),v(S)}function v(S){if(S===null){b(e.exit("chunkFlow"),!0),j(0),e.consume(S);return}return xt(S)?(e.consume(S),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(S),v)}function b(S,C){const D=t.sliceStream(S);if(C&&D.push(null),S.previous=i,i&&(i.next=S),i=S,o.defineSkip(S.start),o.write(D),t.parser.lazy[S.start.line]){let T=o.events.length;for(;T--;)if(o.events[T][1].start.offset<a&&(!o.events[T][1].end||o.events[T][1].end.offset>a))return;const R=t.events.length;let $=R,P,F;for(;$--;)if(t.events[$][0]==="exit"&&t.events[$][1].type==="chunkFlow"){if(P){F=t.events[$][1].end;break}P=!0}for(j(r),T=R;T<t.events.length;)t.events[T][1].end={...F},T++;eo(t.events,$+1,0,t.events.slice(R)),t.events.length=T}}function j(S){let C=n.length;for(;C-- >S;){const D=n[C];t.containerState=D[1],D[0].exit.call(t,e)}n.length=S}function N(){o.write([null]),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function NW(e,t,n){return Yt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function lN(e){if(e===null||kr(e)||vW(e))return 1;if(bW(e))return 2}function i0(e,t,n){const r=[];let o=-1;for(;++o<e.length;){const i=e[o].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const av={name:"attention",resolveAll:CW,tokenize:EW};function CW(e,t){let n=-1,r,o,i,a,l,u,f,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const h={...e[r][1].end},g={...e[n][1].start};cN(h,-u),cN(g,u),a={type:u>1?"strongSequence":"emphasisSequence",start:h,end:{...e[r][1].end}},l={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},i={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},o={type:u>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},f=[],e[r][1].end.offset-e[r][1].start.offset&&(f=es(f,[["enter",e[r][1],t],["exit",e[r][1],t]])),f=es(f,[["enter",o,t],["enter",a,t],["exit",a,t],["enter",i,t]]),f=es(f,i0(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),f=es(f,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,f=es(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,eo(e,r-1,n-r+3,f),n=r+f.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function EW(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,o=lN(r);let i;return a;function a(u){return i=u,e.enter("attentionSequence"),l(u)}function l(u){if(u===i)return e.consume(u),l;const f=e.exit("attentionSequence"),p=lN(u),h=!p||p===2&&o||n.includes(u),g=!o||o===2&&p||n.includes(r);return f._open=!!(i===42?h:h&&(o||!g)),f._close=!!(i===42?g:g&&(p||!h)),t(u)}}function cN(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const TW={name:"autolink",tokenize:RW};function RW(e,t,n){let r=0;return o;function o(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(y){return Ks(y)?(e.consume(y),a):y===64?n(y):f(y)}function a(y){return y===43||y===45||y===46||Br(y)?(r=1,l(y)):f(y)}function l(y){return y===58?(e.consume(y),r=0,u):(y===43||y===45||y===46||Br(y))&&r++<32?(e.consume(y),l):(r=0,f(y))}function u(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):y===null||y===32||y===60||ov(y)?n(y):(e.consume(y),u)}function f(y){return y===64?(e.consume(y),p):gW(y)?(e.consume(y),f):n(y)}function p(y){return Br(y)?h(y):n(y)}function h(y){return y===46?(e.consume(y),r=0,p):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):g(y)}function g(y){if((y===45||Br(y))&&r++<63){const k=y===45?g:h;return e.consume(y),k}return n(y)}}const Hm={partial:!0,tokenize:AW};function AW(e,t,n){return r;function r(i){return Ft(i)?Yt(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||xt(i)?t(i):n(i)}}const FP={continuation:{tokenize:_W},exit:DW,name:"blockQuote",tokenize:PW};function PW(e,t,n){const r=this;return o;function o(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),i}return n(a)}function i(a){return Ft(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function _W(e,t,n){const r=this;return o;function o(a){return Ft(a)?Yt(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(FP,t,n)(a)}}function DW(e){e.exit("blockQuote")}const zP={name:"characterEscape",tokenize:$W};function $W(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return yW(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const BP={name:"characterReference",tokenize:IW};function IW(e,t,n){const r=this;let o=0,i,a;return l;function l(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),u}function u(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),i=31,a=Br,p(h))}function f(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=xW,p):(e.enter("characterReferenceValue"),i=7,a=iv,p(h))}function p(h){if(h===59&&o){const g=e.exit("characterReferenceValue");return a===Br&&!o0(r.sliceSerialize(g))?n(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(h)&&o++<i?(e.consume(h),p):n(h)}}const uN={partial:!0,tokenize:MW},dN={concrete:!0,name:"codeFenced",tokenize:LW};function LW(e,t,n){const r=this,o={partial:!0,tokenize:D};let i=0,a=0,l;return u;function u(T){return f(T)}function f(T){const R=r.events[r.events.length-1];return i=R&&R[1].type==="linePrefix"?R[2].sliceSerialize(R[1],!0).length:0,l=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(T)}function p(T){return T===l?(a++,e.consume(T),p):a<3?n(T):(e.exit("codeFencedFenceSequence"),Ft(T)?Yt(e,h,"whitespace")(T):h(T))}function h(T){return T===null||xt(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(uN,v,C)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(T))}function g(T){return T===null||xt(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(T)):Ft(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Yt(e,y,"whitespace")(T)):T===96&&T===l?n(T):(e.consume(T),g)}function y(T){return T===null||xt(T)?h(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),k(T))}function k(T){return T===null||xt(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(T)):T===96&&T===l?n(T):(e.consume(T),k)}function v(T){return e.attempt(o,C,b)(T)}function b(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),j}function j(T){return i>0&&Ft(T)?Yt(e,N,"linePrefix",i+1)(T):N(T)}function N(T){return T===null||xt(T)?e.check(uN,v,C)(T):(e.enter("codeFlowValue"),S(T))}function S(T){return T===null||xt(T)?(e.exit("codeFlowValue"),N(T)):(e.consume(T),S)}function C(T){return e.exit("codeFenced"),t(T)}function D(T,R,$){let P=0;return F;function F(M){return T.enter("lineEnding"),T.consume(M),T.exit("lineEnding"),_}function _(M){return T.enter("codeFencedFence"),Ft(M)?Yt(T,V,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):V(M)}function V(M){return M===l?(T.enter("codeFencedFenceSequence"),U(M)):$(M)}function U(M){return M===l?(P++,T.consume(M),U):P>=a?(T.exit("codeFencedFenceSequence"),Ft(M)?Yt(T,I,"whitespace")(M):I(M)):$(M)}function I(M){return M===null||xt(M)?(T.exit("codeFencedFence"),R(M)):$(M)}}}function MW(e,t,n){const r=this;return o;function o(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Ry={name:"codeIndented",tokenize:FW},OW={partial:!0,tokenize:zW};function FW(e,t,n){const r=this;return o;function o(f){return e.enter("codeIndented"),Yt(e,i,"linePrefix",5)(f)}function i(f){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?a(f):n(f)}function a(f){return f===null?u(f):xt(f)?e.attempt(OW,a,u)(f):(e.enter("codeFlowValue"),l(f))}function l(f){return f===null||xt(f)?(e.exit("codeFlowValue"),a(f)):(e.consume(f),l)}function u(f){return e.exit("codeIndented"),t(f)}}function zW(e,t,n){const r=this;return o;function o(a){return r.parser.lazy[r.now().line]?n(a):xt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):Yt(e,i,"linePrefix",5)(a)}function i(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):xt(a)?o(a):n(a)}}const BW={name:"codeText",previous:HW,resolve:UW,tokenize:VW};function UW(e){let t=e.length-4,n=3,r,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function HW(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function VW(e,t,n){let r=0,o,i;return a;function a(h){return e.enter("codeText"),e.enter("codeTextSequence"),l(h)}function l(h){return h===96?(e.consume(h),r++,l):(e.exit("codeTextSequence"),u(h))}function u(h){return h===null?n(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),u):h===96?(i=e.enter("codeTextSequence"),o=0,p(h)):xt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),u):(e.enter("codeTextData"),f(h))}function f(h){return h===null||h===32||h===96||xt(h)?(e.exit("codeTextData"),u(h)):(e.consume(h),f)}function p(h){return h===96?(e.consume(h),o++,p):o===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(i.type="codeTextData",f(h))}}class WW{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 r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const o=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&bu(this.left,r),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),bu(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),bu(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);bu(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);bu(this.left,n.reverse())}}}function bu(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 UP(e){const t={};let n=-1,r,o,i,a,l,u,f;const p=new WW(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,i=0,i<u.length&&u[i][1].type==="lineEndingBlank"&&(i+=2),i<u.length&&u[i][1].type==="content"))for(;++i<u.length&&u[i][1].type!=="content";)u[i][1].type==="chunkText"&&(u[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,qW(p,n)),n=t[n],f=!0);else if(r[1]._container){for(i=n,o=void 0;i--;)if(a=p.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(o&&(p.get(o)[1].type="lineEndingBlank"),a[1].type="lineEnding",o=i);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;o&&(r[1].end={...p.get(o)[1].start},l=p.slice(o,n),l.unshift(r),p.splice(o,n-o+1,l))}}return eo(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!f}function qW(e,t){const n=e.get(t)[1],r=e.get(t)[2];let o=t-1;const i=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,u=[],f={};let p,h,g=-1,y=n,k=0,v=0;const b=[v];for(;y;){for(;e.get(++o)[1]!==y;);i.push(o),y._tokenizer||(p=r.sliceStream(y),y.next||p.push(null),h&&a.defineSkip(y.start),y._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(p),y._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),h=y,y=y.next}for(y=n;++g<l.length;)l[g][0]==="exit"&&l[g-1][0]==="enter"&&l[g][1].type===l[g-1][1].type&&l[g][1].start.line!==l[g][1].end.line&&(v=g+1,b.push(v),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(a.events=[],y?(y._tokenizer=void 0,y.previous=void 0):b.pop(),g=b.length;g--;){const j=l.slice(b[g],b[g+1]),N=i.pop();u.push([N,N+j.length-1]),e.splice(N,2,j)}for(u.reverse(),g=-1;++g<u.length;)f[k+u[g][0]]=k+u[g][1],k+=u[g][1]-u[g][0]-1;return f}const KW={resolve:YW,tokenize:XW},GW={partial:!0,tokenize:QW};function YW(e){return UP(e),e}function XW(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(l)}function o(l){return l===null?i(l):xt(l)?e.check(GW,a,i)(l):(e.consume(l),o)}function i(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function QW(e,t,n){const r=this;return o;function o(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Yt(e,i,"linePrefix")}function i(a){if(a===null||xt(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function HP(e,t,n,r,o,i,a,l,u){const f=u||Number.POSITIVE_INFINITY;let p=0;return h;function h(j){return j===60?(e.enter(r),e.enter(o),e.enter(i),e.consume(j),e.exit(i),g):j===null||j===32||j===41||ov(j)?n(j):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),v(j))}function g(j){return j===62?(e.enter(i),e.consume(j),e.exit(i),e.exit(o),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),y(j))}function y(j){return j===62?(e.exit("chunkString"),e.exit(l),g(j)):j===null||j===60||xt(j)?n(j):(e.consume(j),j===92?k:y)}function k(j){return j===60||j===62||j===92?(e.consume(j),y):y(j)}function v(j){return!p&&(j===null||j===41||kr(j))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(j)):p<f&&j===40?(e.consume(j),p++,v):j===41?(e.consume(j),p--,v):j===null||j===32||j===40||ov(j)?n(j):(e.consume(j),j===92?b:v)}function b(j){return j===40||j===41||j===92?(e.consume(j),v):v(j)}}function VP(e,t,n,r,o,i){const a=this;let l=0,u;return f;function f(y){return e.enter(r),e.enter(o),e.consume(y),e.exit(o),e.enter(i),p}function p(y){return l>999||y===null||y===91||y===93&&!u||y===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(y):y===93?(e.exit(i),e.enter(o),e.consume(y),e.exit(o),e.exit(r),t):xt(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===null||y===91||y===93||xt(y)||l++>999?(e.exit("chunkString"),p(y)):(e.consume(y),u||(u=!Ft(y)),y===92?g:h)}function g(y){return y===91||y===92||y===93?(e.consume(y),l++,h):h(y)}}function WP(e,t,n,r,o,i){let a;return l;function l(g){return g===34||g===39||g===40?(e.enter(r),e.enter(o),e.consume(g),e.exit(o),a=g===40?41:g,u):n(g)}function u(g){return g===a?(e.enter(o),e.consume(g),e.exit(o),e.exit(r),t):(e.enter(i),f(g))}function f(g){return g===a?(e.exit(i),u(a)):g===null?n(g):xt(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Yt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===a||g===null||xt(g)?(e.exit("chunkString"),f(g)):(e.consume(g),g===92?h:p)}function h(g){return g===a||g===92?(e.consume(g),p):p(g)}}function qu(e,t){let n;return r;function r(o){return xt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r):Ft(o)?Yt(e,r,n?"linePrefix":"lineSuffix")(o):t(o)}}const JW={name:"definition",tokenize:eq},ZW={partial:!0,tokenize:tq};function eq(e,t,n){const r=this;let o;return i;function i(y){return e.enter("definition"),a(y)}function a(y){return VP.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function l(y){return o=ql(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),u):n(y)}function u(y){return kr(y)?qu(e,f)(y):f(y)}function f(y){return HP(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(ZW,h,h)(y)}function h(y){return Ft(y)?Yt(e,g,"whitespace")(y):g(y)}function g(y){return y===null||xt(y)?(e.exit("definition"),r.parser.defined.push(o),t(y)):n(y)}}function tq(e,t,n){return r;function r(l){return kr(l)?qu(e,o)(l):n(l)}function o(l){return WP(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return Ft(l)?Yt(e,a,"whitespace")(l):a(l)}function a(l){return l===null||xt(l)?t(l):n(l)}}const nq={name:"hardBreakEscape",tokenize:rq};function rq(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return xt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const sq={name:"headingAtx",resolve:oq,tokenize:iq};function oq(e,t){let n=e.length-2,r=3,o,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},eo(e,r,n-r+1,[["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t]])),e}function iq(e,t,n){let r=0;return o;function o(p){return e.enter("atxHeading"),i(p)}function i(p){return e.enter("atxHeadingSequence"),a(p)}function a(p){return p===35&&r++<6?(e.consume(p),a):p===null||kr(p)?(e.exit("atxHeadingSequence"),l(p)):n(p)}function l(p){return p===35?(e.enter("atxHeadingSequence"),u(p)):p===null||xt(p)?(e.exit("atxHeading"),t(p)):Ft(p)?Yt(e,l,"whitespace")(p):(e.enter("atxHeadingText"),f(p))}function u(p){return p===35?(e.consume(p),u):(e.exit("atxHeadingSequence"),l(p))}function f(p){return p===null||p===35||kr(p)?(e.exit("atxHeadingText"),l(p)):(e.consume(p),f)}}const aq=["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"],fN=["pre","script","style","textarea"],lq={concrete:!0,name:"htmlFlow",resolveTo:dq,tokenize:fq},cq={partial:!0,tokenize:hq},uq={partial:!0,tokenize:pq};function dq(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 fq(e,t,n){const r=this;let o,i,a,l,u;return f;function f(q){return p(q)}function p(q){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(q),h}function h(q){return q===33?(e.consume(q),g):q===47?(e.consume(q),i=!0,v):q===63?(e.consume(q),o=3,r.interrupt?t:L):Ks(q)?(e.consume(q),a=String.fromCharCode(q),b):n(q)}function g(q){return q===45?(e.consume(q),o=2,y):q===91?(e.consume(q),o=5,l=0,k):Ks(q)?(e.consume(q),o=4,r.interrupt?t:L):n(q)}function y(q){return q===45?(e.consume(q),r.interrupt?t:L):n(q)}function k(q){const Q="CDATA[";return q===Q.charCodeAt(l++)?(e.consume(q),l===Q.length?r.interrupt?t:V:k):n(q)}function v(q){return Ks(q)?(e.consume(q),a=String.fromCharCode(q),b):n(q)}function b(q){if(q===null||q===47||q===62||kr(q)){const Q=q===47,ee=a.toLowerCase();return!Q&&!i&&fN.includes(ee)?(o=1,r.interrupt?t(q):V(q)):aq.includes(a.toLowerCase())?(o=6,Q?(e.consume(q),j):r.interrupt?t(q):V(q)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(q):i?N(q):S(q))}return q===45||Br(q)?(e.consume(q),a+=String.fromCharCode(q),b):n(q)}function j(q){return q===62?(e.consume(q),r.interrupt?t:V):n(q)}function N(q){return Ft(q)?(e.consume(q),N):F(q)}function S(q){return q===47?(e.consume(q),F):q===58||q===95||Ks(q)?(e.consume(q),C):Ft(q)?(e.consume(q),S):F(q)}function C(q){return q===45||q===46||q===58||q===95||Br(q)?(e.consume(q),C):D(q)}function D(q){return q===61?(e.consume(q),T):Ft(q)?(e.consume(q),D):S(q)}function T(q){return q===null||q===60||q===61||q===62||q===96?n(q):q===34||q===39?(e.consume(q),u=q,R):Ft(q)?(e.consume(q),T):$(q)}function R(q){return q===u?(e.consume(q),u=null,P):q===null||xt(q)?n(q):(e.consume(q),R)}function $(q){return q===null||q===34||q===39||q===47||q===60||q===61||q===62||q===96||kr(q)?D(q):(e.consume(q),$)}function P(q){return q===47||q===62||Ft(q)?S(q):n(q)}function F(q){return q===62?(e.consume(q),_):n(q)}function _(q){return q===null||xt(q)?V(q):Ft(q)?(e.consume(q),_):n(q)}function V(q){return q===45&&o===2?(e.consume(q),B):q===60&&o===1?(e.consume(q),W):q===62&&o===4?(e.consume(q),z):q===63&&o===3?(e.consume(q),L):q===93&&o===5?(e.consume(q),H):xt(q)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(cq,Y,U)(q)):q===null||xt(q)?(e.exit("htmlFlowData"),U(q)):(e.consume(q),V)}function U(q){return e.check(uq,I,Y)(q)}function I(q){return e.enter("lineEnding"),e.consume(q),e.exit("lineEnding"),M}function M(q){return q===null||xt(q)?U(q):(e.enter("htmlFlowData"),V(q))}function B(q){return q===45?(e.consume(q),L):V(q)}function W(q){return q===47?(e.consume(q),a="",O):V(q)}function O(q){if(q===62){const Q=a.toLowerCase();return fN.includes(Q)?(e.consume(q),z):V(q)}return Ks(q)&&a.length<8?(e.consume(q),a+=String.fromCharCode(q),O):V(q)}function H(q){return q===93?(e.consume(q),L):V(q)}function L(q){return q===62?(e.consume(q),z):q===45&&o===2?(e.consume(q),L):V(q)}function z(q){return q===null||xt(q)?(e.exit("htmlFlowData"),Y(q)):(e.consume(q),z)}function Y(q){return e.exit("htmlFlow"),t(q)}}function pq(e,t,n){const r=this;return o;function o(a){return xt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function hq(e,t,n){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Hm,t,n)}}const mq={name:"htmlText",tokenize:gq};function gq(e,t,n){const r=this;let o,i,a;return l;function l(L){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(L),u}function u(L){return L===33?(e.consume(L),f):L===47?(e.consume(L),D):L===63?(e.consume(L),S):Ks(L)?(e.consume(L),$):n(L)}function f(L){return L===45?(e.consume(L),p):L===91?(e.consume(L),i=0,k):Ks(L)?(e.consume(L),N):n(L)}function p(L){return L===45?(e.consume(L),y):n(L)}function h(L){return L===null?n(L):L===45?(e.consume(L),g):xt(L)?(a=h,W(L)):(e.consume(L),h)}function g(L){return L===45?(e.consume(L),y):h(L)}function y(L){return L===62?B(L):L===45?g(L):h(L)}function k(L){const z="CDATA[";return L===z.charCodeAt(i++)?(e.consume(L),i===z.length?v:k):n(L)}function v(L){return L===null?n(L):L===93?(e.consume(L),b):xt(L)?(a=v,W(L)):(e.consume(L),v)}function b(L){return L===93?(e.consume(L),j):v(L)}function j(L){return L===62?B(L):L===93?(e.consume(L),j):v(L)}function N(L){return L===null||L===62?B(L):xt(L)?(a=N,W(L)):(e.consume(L),N)}function S(L){return L===null?n(L):L===63?(e.consume(L),C):xt(L)?(a=S,W(L)):(e.consume(L),S)}function C(L){return L===62?B(L):S(L)}function D(L){return Ks(L)?(e.consume(L),T):n(L)}function T(L){return L===45||Br(L)?(e.consume(L),T):R(L)}function R(L){return xt(L)?(a=R,W(L)):Ft(L)?(e.consume(L),R):B(L)}function $(L){return L===45||Br(L)?(e.consume(L),$):L===47||L===62||kr(L)?P(L):n(L)}function P(L){return L===47?(e.consume(L),B):L===58||L===95||Ks(L)?(e.consume(L),F):xt(L)?(a=P,W(L)):Ft(L)?(e.consume(L),P):B(L)}function F(L){return L===45||L===46||L===58||L===95||Br(L)?(e.consume(L),F):_(L)}function _(L){return L===61?(e.consume(L),V):xt(L)?(a=_,W(L)):Ft(L)?(e.consume(L),_):P(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,U):xt(L)?(a=V,W(L)):Ft(L)?(e.consume(L),V):(e.consume(L),I)}function U(L){return L===o?(e.consume(L),o=void 0,M):L===null?n(L):xt(L)?(a=U,W(L)):(e.consume(L),U)}function I(L){return L===null||L===34||L===39||L===60||L===61||L===96?n(L):L===47||L===62||kr(L)?P(L):(e.consume(L),I)}function M(L){return L===47||L===62||kr(L)?P(L):n(L)}function B(L){return L===62?(e.consume(L),e.exit("htmlTextData"),e.exit("htmlText"),t):n(L)}function W(L){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),O}function O(L){return Ft(L)?Yt(e,H,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):H(L)}function H(L){return e.enter("htmlTextData"),a(L)}}const a0={name:"labelEnd",resolveAll:vq,resolveTo:wq,tokenize:jq},xq={tokenize:kq},yq={tokenize:Sq},bq={tokenize:Nq};function vq(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==n.length&&eo(e,0,e.length,n),e}function wq(e,t){let n=e.length,r=0,o,i,a,l;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(a){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(i=n,o.type!=="labelLink")){r=2;break}}else o.type==="labelEnd"&&(a=n);const u={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},p={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",u,t],["enter",f,t]],l=es(l,e.slice(i+1,i+r+3)),l=es(l,[["enter",p,t]]),l=es(l,i0(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=es(l,[["exit",p,t],e[a-2],e[a-1],["exit",f,t]]),l=es(l,e.slice(a+1)),l=es(l,[["exit",u,t]]),eo(e,i,e.length,l),e}function jq(e,t,n){const r=this;let o=r.events.length,i,a;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){i=r.events[o][1];break}return l;function l(g){return i?i._inactive?h(g):(a=r.parser.defined.includes(ql(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),u):n(g)}function u(g){return g===40?e.attempt(xq,p,a?p:h)(g):g===91?e.attempt(yq,p,a?f:h)(g):a?p(g):h(g)}function f(g){return e.attempt(bq,p,h)(g)}function p(g){return t(g)}function h(g){return i._balanced=!0,n(g)}}function kq(e,t,n){return r;function r(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),o}function o(h){return kr(h)?qu(e,i)(h):i(h)}function i(h){return h===41?p(h):HP(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function a(h){return kr(h)?qu(e,u)(h):p(h)}function l(h){return n(h)}function u(h){return h===34||h===39||h===40?WP(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):p(h)}function f(h){return kr(h)?qu(e,p)(h):p(h)}function p(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):n(h)}}function Sq(e,t,n){const r=this;return o;function o(l){return VP.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(ql(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function Nq(e,t,n){return r;function r(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 Cq={name:"labelStartImage",resolveAll:a0.resolveAll,tokenize:Eq};function Eq(e,t,n){const r=this;return o;function o(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),i}function i(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const Tq={name:"labelStartLink",resolveAll:a0.resolveAll,tokenize:Rq};function Rq(e,t,n){const r=this;return o;function o(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Ay={name:"lineEnding",tokenize:Aq};function Aq(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Yt(e,t,"linePrefix")}}const Xp={name:"thematicBreak",tokenize:Pq};function Pq(e,t,n){let r=0,o;return i;function i(f){return e.enter("thematicBreak"),a(f)}function a(f){return o=f,l(f)}function l(f){return f===o?(e.enter("thematicBreakSequence"),u(f)):r>=3&&(f===null||xt(f))?(e.exit("thematicBreak"),t(f)):n(f)}function u(f){return f===o?(e.consume(f),r++,u):(e.exit("thematicBreakSequence"),Ft(f)?Yt(e,l,"whitespace")(f):l(f))}}const yr={continuation:{tokenize:Iq},exit:Mq,name:"list",tokenize:$q},_q={partial:!0,tokenize:Oq},Dq={partial:!0,tokenize:Lq};function $q(e,t,n){const r=this,o=r.events[r.events.length-1];let i=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,a=0;return l;function l(y){const k=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:iv(y)){if(r.containerState.type||(r.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Xp,n,f)(y):f(y);if(!r.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(y)}return n(y)}function u(y){return iv(y)&&++a<10?(e.consume(y),u):(!r.interrupt||a<2)&&(r.containerState.marker?y===r.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),f(y)):n(y)}function f(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,e.check(Hm,r.interrupt?n:p,e.attempt(_q,g,h))}function p(y){return r.containerState.initialBlankLine=!0,i++,g(y)}function h(y){return Ft(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),g):n(y)}function g(y){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function Iq(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Hm,o,i);function o(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Yt(e,t,"listItemIndent",r.containerState.size+1)(l)}function i(l){return r.containerState.furtherBlankLines||!Ft(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Dq,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Yt(e,e.attempt(yr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Lq(e,t,n){const r=this;return Yt(e,o,"listItemIndent",r.containerState.size+1);function o(i){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(i):n(i)}}function Mq(e){e.exit(this.containerState.type)}function Oq(e,t,n){const r=this;return Yt(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(i){const a=r.events[r.events.length-1];return!Ft(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const pN={name:"setextUnderline",resolveTo:Fq,tokenize:zq};function Fq(e,t){let n=e.length,r,o,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=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 a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",i?(e.splice(o,0,["enter",a,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function zq(e,t,n){const r=this;let o;return i;function i(f){let p=r.events.length,h;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){h=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),o=f,a(f)):n(f)}function a(f){return e.enter("setextHeadingLineSequence"),l(f)}function l(f){return f===o?(e.consume(f),l):(e.exit("setextHeadingLineSequence"),Ft(f)?Yt(e,u,"lineSuffix")(f):u(f))}function u(f){return f===null||xt(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const Bq={tokenize:Uq};function Uq(e){const t=this,n=e.attempt(Hm,r,e.attempt(this.parser.constructs.flowInitial,o,Yt(e,e.attempt(this.parser.constructs.flow,o,e.attempt(KW,o)),"linePrefix")));return n;function r(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 Hq={resolveAll:KP()},Vq=qP("string"),Wq=qP("text");function qP(e){return{resolveAll:KP(e==="text"?qq:void 0),tokenize:t};function t(n){const r=this,o=this.parser.constructs[e],i=n.attempt(o,a,l);return a;function a(p){return f(p)?i(p):l(p)}function l(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),u}function u(p){return f(p)?(n.exit("data"),i(p)):(n.consume(p),u)}function f(p){if(p===null)return!0;const h=o[p];let g=-1;if(h)for(;++g<h.length;){const y=h[g];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function KP(e){return t;function t(n,r){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,r):n}}function qq(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 r=e[n-1][1],o=t.sliceStream(r);let i=o.length,a=-1,l=0,u;for(;i--;){const f=o[i];if(typeof f=="string"){for(a=f.length;f.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(f===-2)u=!0,l++;else if(f!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const f={type:n===e.length||u||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...f.start},r.start.offset===r.end.offset?Object.assign(r,f):(e.splice(n,0,["enter",f,t],["exit",f,t]),n+=2)}n++}return e}const Kq={42:yr,43:yr,45:yr,48:yr,49:yr,50:yr,51:yr,52:yr,53:yr,54:yr,55:yr,56:yr,57:yr,62:FP},Gq={91:JW},Yq={[-2]:Ry,[-1]:Ry,32:Ry},Xq={35:sq,42:Xp,45:[pN,Xp],60:lq,61:pN,95:Xp,96:dN,126:dN},Qq={38:BP,92:zP},Jq={[-5]:Ay,[-4]:Ay,[-3]:Ay,33:Cq,38:BP,42:av,60:[TW,mq],91:Tq,92:[nq,zP],93:a0,95:av,96:BW},Zq={null:[av,Hq]},eK={null:[42,95]},tK={null:[]},nK=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:eK,contentInitial:Gq,disable:tK,document:Kq,flow:Xq,flowInitial:Yq,insideSpan:Zq,string:Qq,text:Jq},Symbol.toStringTag,{value:"Module"}));function rK(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},i=[];let a=[],l=[];const u={attempt:R(D),check:R(T),consume:N,enter:S,exit:C,interrupt:R(T,{interrupt:!0})},f={code:null,containerState:{},defineSkip:v,events:[],now:k,parser:e,previous:null,sliceSerialize:g,sliceStream:y,write:h};let p=t.tokenize.call(f,u);return t.resolveAll&&i.push(t),f;function h(_){return a=es(a,_),b(),a[a.length-1]!==null?[]:($(t,0),f.events=i0(i,f.events,f),f.events)}function g(_,V){return oK(y(_),V)}function y(_){return sK(a,_)}function k(){const{_bufferIndex:_,_index:V,line:U,column:I,offset:M}=r;return{_bufferIndex:_,_index:V,line:U,column:I,offset:M}}function v(_){o[_.line]=_.column,F()}function b(){let _;for(;r._index<a.length;){const V=a[r._index];if(typeof V=="string")for(_=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===_&&r._bufferIndex<V.length;)j(V.charCodeAt(r._bufferIndex));else j(V)}}function j(_){p=p(_)}function N(_){xt(_)?(r.line++,r.column=1,r.offset+=_===-3?2:1,F()):_!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),f.previous=_}function S(_,V){const U=V||{};return U.type=_,U.start=k(),f.events.push(["enter",U,f]),l.push(U),U}function C(_){const V=l.pop();return V.end=k(),f.events.push(["exit",V,f]),V}function D(_,V){$(_,V.from)}function T(_,V){V.restore()}function R(_,V){return U;function U(I,M,B){let W,O,H,L;return Array.isArray(I)?Y(I):"tokenize"in I?Y([I]):z(I);function z(Z){return ie;function ie(ne){const ue=ne!==null&&Z[ne],ge=ne!==null&&Z.null,Ne=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(ge)?ge:ge?[ge]:[]];return Y(Ne)(ne)}}function Y(Z){return W=Z,O=0,Z.length===0?B:q(Z[O])}function q(Z){return ie;function ie(ne){return L=P(),H=Z,Z.partial||(f.currentConstruct=Z),Z.name&&f.parser.constructs.disable.null.includes(Z.name)?ee():Z.tokenize.call(V?Object.assign(Object.create(f),V):f,u,Q,ee)(ne)}}function Q(Z){return _(H,L),M}function ee(Z){return L.restore(),++O<W.length?q(W[O]):B}}}function $(_,V){_.resolveAll&&!i.includes(_)&&i.push(_),_.resolve&&eo(f.events,V,f.events.length-V,_.resolve(f.events.slice(V),f)),_.resolveTo&&(f.events=_.resolveTo(f.events,f))}function P(){const _=k(),V=f.previous,U=f.currentConstruct,I=f.events.length,M=Array.from(l);return{from:I,restore:B};function B(){r=_,f.previous=V,f.currentConstruct=U,f.events.length=I,l=M,F()}}function F(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function sK(e,t){const n=t.start._index,r=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex;let a;if(n===o)a=[e[n].slice(r,i)];else{if(a=e.slice(n,o),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}i>0&&a.push(e[o].slice(0,i))}return a}function oK(e,t){let n=-1;const r=[];let o;for(;++n<e.length;){const i=e[n];let a;if(typeof i=="string")a=i;else switch(i){case-5:{a="\r";break}case-4:{a=`
607
- `;break}case-3:{a=`\r
608
- `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&o)continue;a=" ";break}default:a=String.fromCharCode(i)}o=i===-2,r.push(a)}return r.join("")}function iK(e){const r={constructs:pW([nK,...(e||{}).extensions||[]]),content:o(wW),defined:[],document:o(kW),flow:o(Bq),lazy:{},string:o(Vq),text:o(Wq)};return r;function o(i){return a;function a(l){return rK(r,i,l)}}}function aK(e){for(;!UP(e););return e}const hN=/[\0\t\n\r]/g;function lK(){let e=1,t="",n=!0,r;return o;function o(i,a,l){const u=[];let f,p,h,g,y;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),h=0,t="",n&&(i.charCodeAt(0)===65279&&h++,n=void 0);h<i.length;){if(hN.lastIndex=h,f=hN.exec(i),g=f&&f.index!==void 0?f.index:i.length,y=i.charCodeAt(g),!f){t=i.slice(h);break}if(y===10&&h===g&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),h<g&&(u.push(i.slice(h,g)),e+=g-h),y){case 0:{u.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,u.push(-2);e++<p;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}h=g+1}return l&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const cK=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function uK(e){return e.replace(cK,dK)}function dK(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const o=n.charCodeAt(1),i=o===120||o===88;return OP(n.slice(i?2:1),i?16:10)}return o0(n)||e}const GP={}.hasOwnProperty;function fK(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),pK(n)(aK(iK(n).document().write(lK()(e,t,!0))))}function pK(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(He),autolinkProtocol:P,autolinkEmail:P,atxHeading:i(oe),blockQuote:i(ge),characterEscape:P,characterReference:P,codeFenced:i(Ne),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(Ne,a),codeText:i(Ce,a),codeTextData:P,data:P,codeFlowValue:P,definition:i(ke),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(Ue),hardBreakEscape:i(ve),hardBreakTrailing:i(ve),htmlFlow:i(be,a),htmlFlowData:P,htmlText:i(be,a),htmlTextData:P,image:i(Re),label:a,link:i(He),listItem:i(Fe),listItemValue:g,listOrdered:i(rt,h),listUnordered:i(rt),paragraph:i(ot),reference:q,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(oe),strong:i(Nt),thematicBreak:i(at)},exit:{atxHeading:u(),atxHeadingSequence:D,autolink:u(),autolinkEmail:ue,autolinkProtocol:ne,blockQuote:u(),characterEscapeValue:F,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:Z,characterReference:ie,codeFenced:u(b),codeFencedFence:v,codeFencedFenceInfo:y,codeFencedFenceMeta:k,codeFlowValue:F,codeIndented:u(j),codeText:u(M),codeTextData:F,data:F,definition:u(),definitionDestinationString:C,definitionLabelString:N,definitionTitleString:S,emphasis:u(),hardBreakEscape:u(V),hardBreakTrailing:u(V),htmlFlow:u(U),htmlFlowData:F,htmlText:u(I),htmlTextData:F,image:u(W),label:H,labelText:O,lineEnding:_,link:u(B),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:Q,resourceDestinationString:L,resourceTitleString:z,resource:Y,setextHeading:u($),setextHeadingLineSequence:R,setextHeadingText:T,strong:u(),thematicBreak:u()}};YP(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ce){let me={type:"root",children:[]};const Ie={stack:[me],tokenStack:[],config:t,enter:l,exit:f,buffer:a,resume:p,data:n},Ae=[];let We=-1;for(;++We<ce.length;)if(ce[We][1].type==="listOrdered"||ce[We][1].type==="listUnordered")if(ce[We][0]==="enter")Ae.push(We);else{const pt=Ae.pop();We=o(ce,pt,We)}for(We=-1;++We<ce.length;){const pt=t[ce[We][0]];GP.call(pt,ce[We][1].type)&&pt[ce[We][1].type].call(Object.assign({sliceSerialize:ce[We][2].sliceSerialize},Ie),ce[We][1])}if(Ie.tokenStack.length>0){const pt=Ie.tokenStack[Ie.tokenStack.length-1];(pt[1]||mN).call(Ie,void 0,pt[0])}for(me.position={start:ci(ce.length>0?ce[0][1].start:{line:1,column:1,offset:0}),end:ci(ce.length>0?ce[ce.length-2][1].end:{line:1,column:1,offset:0})},We=-1;++We<t.transforms.length;)me=t.transforms[We](me)||me;return me}function o(ce,me,Ie){let Ae=me-1,We=-1,pt=!1,Pe,Qe,Je,ut;for(;++Ae<=Ie;){const fe=ce[Ae];switch(fe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{fe[0]==="enter"?We++:We--,ut=void 0;break}case"lineEndingBlank":{fe[0]==="enter"&&(Pe&&!ut&&!We&&!Je&&(Je=Ae),ut=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ut=void 0}if(!We&&fe[0]==="enter"&&fe[1].type==="listItemPrefix"||We===-1&&fe[0]==="exit"&&(fe[1].type==="listUnordered"||fe[1].type==="listOrdered")){if(Pe){let K=Ae;for(Qe=void 0;K--;){const re=ce[K];if(re[1].type==="lineEnding"||re[1].type==="lineEndingBlank"){if(re[0]==="exit")continue;Qe&&(ce[Qe][1].type="lineEndingBlank",pt=!0),re[1].type="lineEnding",Qe=K}else if(!(re[1].type==="linePrefix"||re[1].type==="blockQuotePrefix"||re[1].type==="blockQuotePrefixWhitespace"||re[1].type==="blockQuoteMarker"||re[1].type==="listItemIndent"))break}Je&&(!Qe||Je<Qe)&&(Pe._spread=!0),Pe.end=Object.assign({},Qe?ce[Qe][1].start:fe[1].end),ce.splice(Qe||Ae,0,["exit",Pe,fe[2]]),Ae++,Ie++}if(fe[1].type==="listItemPrefix"){const K={type:"listItem",_spread:!1,start:Object.assign({},fe[1].start),end:void 0};Pe=K,ce.splice(Ae,0,["enter",K,fe[2]]),Ae++,Ie++,Je=void 0,ut=!0}}}return ce[me][1]._spread=pt,Ie}function i(ce,me){return Ie;function Ie(Ae){l.call(this,ce(Ae),Ae),me&&me.call(this,Ae)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ce,me,Ie){this.stack[this.stack.length-1].children.push(ce),this.stack.push(ce),this.tokenStack.push([me,Ie||void 0]),ce.position={start:ci(me.start),end:void 0}}function u(ce){return me;function me(Ie){ce&&ce.call(this,Ie),f.call(this,Ie)}}function f(ce,me){const Ie=this.stack.pop(),Ae=this.tokenStack.pop();if(Ae)Ae[0].type!==ce.type&&(me?me.call(this,ce,Ae[0]):(Ae[1]||mN).call(this,ce,Ae[0]));else throw new Error("Cannot close `"+ce.type+"` ("+Wu({start:ce.start,end:ce.end})+"): it’s not open");Ie.position.end=ci(ce.end)}function p(){return dW(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function g(ce){if(this.data.expectingFirstListItemValue){const me=this.stack[this.stack.length-2];me.start=Number.parseInt(this.sliceSerialize(ce),10),this.data.expectingFirstListItemValue=void 0}}function y(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.lang=ce}function k(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.meta=ce}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.value=ce.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function j(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.value=ce.replace(/(\r?\n|\r)$/g,"")}function N(ce){const me=this.resume(),Ie=this.stack[this.stack.length-1];Ie.label=me,Ie.identifier=ql(this.sliceSerialize(ce)).toLowerCase()}function S(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.title=ce}function C(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.url=ce}function D(ce){const me=this.stack[this.stack.length-1];if(!me.depth){const Ie=this.sliceSerialize(ce).length;me.depth=Ie}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function R(ce){const me=this.stack[this.stack.length-1];me.depth=this.sliceSerialize(ce).codePointAt(0)===61?1:2}function $(){this.data.setextHeadingSlurpLineEnding=void 0}function P(ce){const Ie=this.stack[this.stack.length-1].children;let Ae=Ie[Ie.length-1];(!Ae||Ae.type!=="text")&&(Ae=mt(),Ae.position={start:ci(ce.start),end:void 0},Ie.push(Ae)),this.stack.push(Ae)}function F(ce){const me=this.stack.pop();me.value+=this.sliceSerialize(ce),me.position.end=ci(ce.end)}function _(ce){const me=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ie=me.children[me.children.length-1];Ie.position.end=ci(ce.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(me.type)&&(P.call(this,ce),F.call(this,ce))}function V(){this.data.atHardBreak=!0}function U(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.value=ce}function I(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.value=ce}function M(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.value=ce}function B(){const ce=this.stack[this.stack.length-1];if(this.data.inReference){const me=this.data.referenceType||"shortcut";ce.type+="Reference",ce.referenceType=me,delete ce.url,delete ce.title}else delete ce.identifier,delete ce.label;this.data.referenceType=void 0}function W(){const ce=this.stack[this.stack.length-1];if(this.data.inReference){const me=this.data.referenceType||"shortcut";ce.type+="Reference",ce.referenceType=me,delete ce.url,delete ce.title}else delete ce.identifier,delete ce.label;this.data.referenceType=void 0}function O(ce){const me=this.sliceSerialize(ce),Ie=this.stack[this.stack.length-2];Ie.label=uK(me),Ie.identifier=ql(me).toLowerCase()}function H(){const ce=this.stack[this.stack.length-1],me=this.resume(),Ie=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ie.type==="link"){const Ae=ce.children;Ie.children=Ae}else Ie.alt=me}function L(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.url=ce}function z(){const ce=this.resume(),me=this.stack[this.stack.length-1];me.title=ce}function Y(){this.data.inReference=void 0}function q(){this.data.referenceType="collapsed"}function Q(ce){const me=this.resume(),Ie=this.stack[this.stack.length-1];Ie.label=me,Ie.identifier=ql(this.sliceSerialize(ce)).toLowerCase(),this.data.referenceType="full"}function ee(ce){this.data.characterReferenceType=ce.type}function Z(ce){const me=this.sliceSerialize(ce),Ie=this.data.characterReferenceType;let Ae;Ie?(Ae=OP(me,Ie==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ae=o0(me);const We=this.stack[this.stack.length-1];We.value+=Ae}function ie(ce){const me=this.stack.pop();me.position.end=ci(ce.end)}function ne(ce){F.call(this,ce);const me=this.stack[this.stack.length-1];me.url=this.sliceSerialize(ce)}function ue(ce){F.call(this,ce);const me=this.stack[this.stack.length-1];me.url="mailto:"+this.sliceSerialize(ce)}function ge(){return{type:"blockquote",children:[]}}function Ne(){return{type:"code",lang:null,meta:null,value:""}}function Ce(){return{type:"inlineCode",value:""}}function ke(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ue(){return{type:"emphasis",children:[]}}function oe(){return{type:"heading",depth:0,children:[]}}function ve(){return{type:"break"}}function be(){return{type:"html",value:""}}function Re(){return{type:"image",title:null,url:"",alt:null}}function He(){return{type:"link",title:null,url:"",children:[]}}function rt(ce){return{type:"list",ordered:ce.type==="listOrdered",start:null,spread:ce._spread,children:[]}}function Fe(ce){return{type:"listItem",spread:ce._spread,checked:null,children:[]}}function ot(){return{type:"paragraph",children:[]}}function Nt(){return{type:"strong",children:[]}}function mt(){return{type:"text",value:""}}function at(){return{type:"thematicBreak"}}}function ci(e){return{line:e.line,column:e.column,offset:e.offset}}function YP(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?YP(e,r):hK(e,r)}}function hK(e,t){let n;for(n in t)if(GP.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function mN(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Wu({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Wu({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Wu({start:t.start,end:t.end})+") is still open")}function mK(e){const t=this;t.parser=n;function n(r){return fK(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function gK(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 xK(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
609
- `}]}function yK(e,t){const n=t.value?t.value+`
610
- `:"",r={},o=t.lang?t.lang.split(/\s+/):[];o.length>0&&(r.className=["language-"+o[0]]);let i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function bK(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function vK(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function wK(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),o=Tc(r.toLowerCase()),i=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=i+1,l+=1,e.footnoteCounts.set(r,l);const u={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+o,id:n+"fnref-"+o+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,u);const f={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,f),e.applyData(t,f)}function jK(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function kK(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function XP(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const o=e.all(t),i=o[0];i&&i.type==="text"?i.value="["+i.value:o.unshift({type:"text",value:"["});const a=o[o.length-1];return a&&a.type==="text"?a.value+=r:o.push({type:"text",value:r}),o}function SK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return XP(e,t);const o={src:Tc(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(o.title=r.title);const i={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,i),e.applyData(t,i)}function NK(e,t){const n={src:Tc(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function CK(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function EK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return XP(e,t);const o={href:Tc(r.url||"")};r.title!==null&&r.title!==void 0&&(o.title=r.title);const i={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function TK(e,t){const n={href:Tc(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function RK(e,t,n){const r=e.all(t),o=n?AK(n):QP(t),i={},a=[];if(typeof t.checked=="boolean"){const p=r[0];let h;p&&p.type==="element"&&p.tagName==="p"?h=p:(h={type:"element",tagName:"p",properties:{},children:[]},r.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const p=r[l];(o||l!==0||p.type!=="element"||p.tagName!=="p")&&a.push({type:"text",value:`
611
- `}),p.type==="element"&&p.tagName==="p"&&!o?a.push(...p.children):a.push(p)}const u=r[r.length-1];u&&(o||u.type!=="element"||u.tagName!=="p")&&a.push({type:"text",value:`
612
- `});const f={type:"element",tagName:"li",properties:i,children:a};return e.patch(t,f),e.applyData(t,f)}function AK(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=QP(n[r])}return t}function QP(e){const t=e.spread;return t??e.children.length>1}function PK(e,t){const n={},r=e.all(t);let o=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++o<r.length;){const a=r[o];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function _K(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function DK(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function $K(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function IK(e,t){const n=e.all(t),r=n.shift(),o=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),o.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=t0(t.children[1]),u=PP(t.children[t.children.length-1]);l&&u&&(a.position={start:l,end:u}),o.push(a)}const i={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,i),e.applyData(t,i)}function LK(e,t,n){const r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let u=-1;const f=[];for(;++u<l;){const h=t.children[u],g={},y=a?a[u]:void 0;y&&(g.align=y);let k={type:"element",tagName:i,properties:g,children:[]};h&&(k.children=e.all(h),e.patch(h,k),k=e.applyData(h,k)),f.push(k)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(t,p),e.applyData(t,p)}function MK(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const gN=9,xN=32;function OK(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),o=0;const i=[];for(;r;)i.push(yN(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return i.push(yN(t.slice(o),o>0,!1)),i.join("")}function yN(e,t,n){let r=0,o=e.length;if(t){let i=e.codePointAt(r);for(;i===gN||i===xN;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(o-1);for(;i===gN||i===xN;)o--,i=e.codePointAt(o-1)}return o>r?e.slice(r,o):""}function FK(e,t){const n={type:"text",value:OK(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function zK(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const BK={blockquote:gK,break:xK,code:yK,delete:bK,emphasis:vK,footnoteReference:wK,heading:jK,html:kK,imageReference:SK,image:NK,inlineCode:CK,linkReference:EK,link:TK,listItem:RK,list:PK,paragraph:_K,root:DK,strong:$K,table:IK,tableCell:MK,tableRow:LK,text:FK,thematicBreak:zK,toml:mp,yaml:mp,definition:mp,footnoteDefinition:mp};function mp(){}const JP=-1,Vm=0,Ku=1,Ah=2,l0=3,c0=4,u0=5,d0=6,ZP=7,e_=8,bN=typeof self=="object"?self:globalThis,UK=(e,t)=>{const n=(o,i)=>(e.set(i,o),o),r=o=>{if(e.has(o))return e.get(o);const[i,a]=t[o];switch(i){case Vm:case JP:return n(a,o);case Ku:{const l=n([],o);for(const u of a)l.push(r(u));return l}case Ah:{const l=n({},o);for(const[u,f]of a)l[r(u)]=r(f);return l}case l0:return n(new Date(a),o);case c0:{const{source:l,flags:u}=a;return n(new RegExp(l,u),o)}case u0:{const l=n(new Map,o);for(const[u,f]of a)l.set(r(u),r(f));return l}case d0:{const l=n(new Set,o);for(const u of a)l.add(r(u));return l}case ZP:{const{name:l,message:u}=a;return n(new bN[l](u),o)}case e_:return n(BigInt(a),o);case"BigInt":return n(Object(BigInt(a)),o);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:l}=new Uint8Array(a);return n(new DataView(l),a)}}return n(new bN[i](a),o)};return r},vN=e=>UK(new Map,e)(0),bl="",{toString:HK}={},{keys:VK}=Object,vu=e=>{const t=typeof e;if(t!=="object"||!e)return[Vm,t];const n=HK.call(e).slice(8,-1);switch(n){case"Array":return[Ku,bl];case"Object":return[Ah,bl];case"Date":return[l0,bl];case"RegExp":return[c0,bl];case"Map":return[u0,bl];case"Set":return[d0,bl];case"DataView":return[Ku,n]}return n.includes("Array")?[Ku,n]:n.includes("Error")?[ZP,n]:[Ah,n]},gp=([e,t])=>e===Vm&&(t==="function"||t==="symbol"),WK=(e,t,n,r)=>{const o=(a,l)=>{const u=r.push(a)-1;return n.set(l,u),u},i=a=>{if(n.has(a))return n.get(a);let[l,u]=vu(a);switch(l){case Vm:{let p=a;switch(u){case"bigint":l=e_,p=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);p=null;break;case"undefined":return o([JP],a)}return o([l,p],a)}case Ku:{if(u){let g=a;return u==="DataView"?g=new Uint8Array(a.buffer):u==="ArrayBuffer"&&(g=new Uint8Array(a)),o([u,[...g]],a)}const p=[],h=o([l,p],a);for(const g of a)p.push(i(g));return h}case Ah:{if(u)switch(u){case"BigInt":return o([u,a.toString()],a);case"Boolean":case"Number":case"String":return o([u,a.valueOf()],a)}if(t&&"toJSON"in a)return i(a.toJSON());const p=[],h=o([l,p],a);for(const g of VK(a))(e||!gp(vu(a[g])))&&p.push([i(g),i(a[g])]);return h}case l0:return o([l,a.toISOString()],a);case c0:{const{source:p,flags:h}=a;return o([l,{source:p,flags:h}],a)}case u0:{const p=[],h=o([l,p],a);for(const[g,y]of a)(e||!(gp(vu(g))||gp(vu(y))))&&p.push([i(g),i(y)]);return h}case d0:{const p=[],h=o([l,p],a);for(const g of a)(e||!gp(vu(g)))&&p.push(i(g));return h}}const{message:f}=a;return o([l,{name:u,message:f}],a)};return i},wN=(e,{json:t,lossy:n}={})=>{const r=[];return WK(!(t||n),!!t,new Map,r)(e),r},Ph=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?vN(wN(e,t)):structuredClone(e):(e,t)=>vN(wN(e,t));function qK(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function KK(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function GK(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||qK,r=e.options.footnoteBackLabel||KK,o=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let u=-1;for(;++u<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[u]);if(!f)continue;const p=e.all(f),h=String(f.identifier).toUpperCase(),g=Tc(h.toLowerCase());let y=0;const k=[],v=e.footnoteCounts.get(h);for(;v!==void 0&&++y<=v;){k.length>0&&k.push({type:"text",value:" "});let N=typeof n=="string"?n:n(u,y);typeof N=="string"&&(N={type:"text",value:N}),k.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,y),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const b=p[p.length-1];if(b&&b.type==="element"&&b.tagName==="p"){const N=b.children[b.children.length-1];N&&N.type==="text"?N.value+=" ":b.children.push({type:"text",value:" "}),b.children.push(...k)}else p.push(...k);const j={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(p,!0)};e.patch(f,j),l.push(j)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...Ph(a),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
613
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
614
- `}]}}const t_=(function(e){if(e==null)return JK;if(typeof e=="function")return Wm(e);if(typeof e=="object")return Array.isArray(e)?YK(e):XK(e);if(typeof e=="string")return QK(e);throw new Error("Expected function, string, or object as test")});function YK(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=t_(e[n]);return Wm(r);function r(...o){let i=-1;for(;++i<t.length;)if(t[i].apply(this,o))return!0;return!1}}function XK(e){const t=e;return Wm(n);function n(r){const o=r;let i;for(i in e)if(o[i]!==t[i])return!1;return!0}}function QK(e){return Wm(t);function t(n){return n&&n.type===e}}function Wm(e){return t;function t(n,r,o){return!!(ZK(n)&&e.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function JK(){return!0}function ZK(e){return e!==null&&typeof e=="object"&&"type"in e}const n_=[],eG=!0,jN=!1,tG="skip";function nG(e,t,n,r){let o;typeof t=="function"&&typeof n!="function"?(r=n,n=t):o=t;const i=t_(o),a=r?-1:1;l(e,void 0,[])();function l(u,f,p){const h=u&&typeof u=="object"?u:{};if(typeof h.type=="string"){const y=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(u.type+(y?"<"+y+">":""))+")"})}return g;function g(){let y=n_,k,v,b;if((!t||i(u,f,p[p.length-1]||void 0))&&(y=rG(n(u,p)),y[0]===jN))return y;if("children"in u&&u.children){const j=u;if(j.children&&y[0]!==tG)for(v=(r?j.children.length:-1)+a,b=p.concat(j);v>-1&&v<j.children.length;){const N=j.children[v];if(k=l(N,v,b)(),k[0]===jN)return k;v=typeof k[1]=="number"?k[1]:v+a}}return y}}}function rG(e){return Array.isArray(e)?e:typeof e=="number"?[eG,e]:e==null?n_:[e]}function r_(e,t,n,r){let o,i,a;typeof t=="function"&&typeof n!="function"?(i=void 0,a=t,o=n):(i=t,a=n,o=r),nG(e,i,l,o);function l(u,f){const p=f[f.length-1],h=p?p.children.indexOf(u):void 0;return a(u,h,p)}}const lv={}.hasOwnProperty,sG={};function oG(e,t){const n=t||sG,r=new Map,o=new Map,i=new Map,a={...BK,...n.handlers},l={all:f,applyData:aG,definitionById:r,footnoteById:o,footnoteCounts:i,footnoteOrder:[],handlers:a,one:u,options:n,patch:iG,wrap:cG};return r_(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const h=p.type==="definition"?r:o,g=String(p.identifier).toUpperCase();h.has(g)||h.set(g,p)}}),l;function u(p,h){const g=p.type,y=l.handlers[g];if(lv.call(l.handlers,g)&&y)return y(l,p,h);if(l.options.passThrough&&l.options.passThrough.includes(g)){if("children"in p){const{children:v,...b}=p,j=Ph(b);return j.children=l.all(p),j}return Ph(p)}return(l.options.unknownHandler||lG)(l,p,h)}function f(p){const h=[];if("children"in p){const g=p.children;let y=-1;for(;++y<g.length;){const k=l.one(g[y],p);if(k){if(y&&g[y-1].type==="break"&&(!Array.isArray(k)&&k.type==="text"&&(k.value=kN(k.value)),!Array.isArray(k)&&k.type==="element")){const v=k.children[0];v&&v.type==="text"&&(v.value=kN(v.value))}Array.isArray(k)?h.push(...k):h.push(k)}}}return h}}function iG(e,t){e.position&&(t.position=HV(e))}function aG(e,t){let n=t;if(e&&e.data){const r=e.data.hName,o=e.data.hChildren,i=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&i&&Object.assign(n.properties,Ph(i)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function lG(e,t){const n=t.data||{},r="value"in t&&!(lv.call(n,"hProperties")||lv.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function cG(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
615
- `});++r<e.length;)r&&n.push({type:"text",value:`
616
- `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
617
- `}),n}function kN(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function SN(e,t){const n=oG(e,t),r=n.one(e,void 0),o=GK(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return o&&i.children.push({type:"text",value:`
618
- `},o),i}function uG(e,t){return e&&"run"in e?async function(n,r){const o=SN(n,{file:r,...t});await e.run(o,r)}:function(n,r){return SN(n,{file:r,...e||t})}}function NN(e){if(e)throw e}var Py,CN;function dG(){if(CN)return Py;CN=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},i=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var p=e.call(f,"constructor"),h=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!p&&!h)return!1;var g;for(g in f);return typeof g>"u"||e.call(f,g)},a=function(f,p){n&&p.name==="__proto__"?n(f,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):f[p.name]=p.newValue},l=function(f,p){if(p==="__proto__")if(e.call(f,p)){if(r)return r(f,p).value}else return;return f[p]};return Py=function u(){var f,p,h,g,y,k,v=arguments[0],b=1,j=arguments.length,N=!1;for(typeof v=="boolean"&&(N=v,v=arguments[1]||{},b=2),(v==null||typeof v!="object"&&typeof v!="function")&&(v={});b<j;++b)if(f=arguments[b],f!=null)for(p in f)h=l(v,p),g=l(f,p),v!==g&&(N&&g&&(i(g)||(y=o(g)))?(y?(y=!1,k=h&&o(h)?h:[]):k=h&&i(h)?h:{},a(v,{name:p,newValue:u(N,k,g)})):typeof g<"u"&&a(v,{name:p,newValue:g}));return v},Py}var fG=dG();const _y=Cd(fG);function cv(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function pG(){const e=[],t={run:n,use:r};return t;function n(...o){let i=-1;const a=o.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...o);function l(u,...f){const p=e[++i];let h=-1;if(u){a(u);return}for(;++h<o.length;)(f[h]===null||f[h]===void 0)&&(f[h]=o[h]);o=f,p?hG(p,l)(...f):a(null,...f)}}function r(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),t}}function hG(e,t){let n;return r;function r(...a){const l=e.length>a.length;let u;l&&a.push(o);try{u=e.apply(this,a)}catch(f){const p=f;if(l&&n)throw p;return o(p)}l||(u&&u.then&&typeof u.then=="function"?u.then(i,o):u instanceof Error?o(u):i(u))}function o(a,...l){n||(n=!0,t(a,...l))}function i(a){o(null,a)}}const Vs={basename:mG,dirname:gG,extname:xG,join:yG,sep:"/"};function mG(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Gd(e);let n=0,r=-1,o=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else r<0&&(i=!0,r=o+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;o--;)if(e.codePointAt(o)===47){if(i){n=o+1;break}}else a<0&&(i=!0,a=o+1),l>-1&&(e.codePointAt(o)===t.codePointAt(l--)?l<0&&(r=o):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function gG(e){if(Gd(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function xG(e){Gd(e);let t=e.length,n=-1,r=0,o=-1,i=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?o<0?o=t:i!==1&&(i=1):o>-1&&(i=-1)}return o<0||n<0||i===0||i===1&&o===n-1&&o===r+1?"":e.slice(o,n)}function yG(...e){let t=-1,n;for(;++t<e.length;)Gd(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":bG(n)}function bG(e){Gd(e);const t=e.codePointAt(0)===47;let n=vG(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function vG(e,t){let n="",r=0,o=-1,i=0,a=-1,l,u;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(o===a-1||i===1))if(o!==a-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),o=a,i=0;continue}}else if(n.length>0){n="",r=0,o=a,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(o+1,a):n=e.slice(o+1,a),r=a-o-1;o=a,i=0}else l===46&&i>-1?i++:i=-1}return n}function Gd(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const wG={cwd:jG};function jG(){return"/"}function uv(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function kG(e){if(typeof e=="string")e=new URL(e);else if(!uv(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return SG(e)}function SG(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(t)}const Dy=["history","path","basename","stem","extname","dirname"];class s_{constructor(t){let n;t?uv(t)?n={path:t}:typeof t=="string"||NG(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":wG.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Dy.length;){const i=Dy[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let o;for(o in n)Dy.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Vs.basename(this.path):void 0}set basename(t){Iy(t,"basename"),$y(t,"basename"),this.path=Vs.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Vs.dirname(this.path):void 0}set dirname(t){EN(this.basename,"dirname"),this.path=Vs.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Vs.extname(this.path):void 0}set extname(t){if($y(t,"extname"),EN(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Vs.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){uv(t)&&(t=kG(t)),Iy(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Vs.basename(this.path,this.extname):void 0}set stem(t){Iy(t,"stem"),$y(t,"stem"),this.path=Vs.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const o=this.message(t,n,r);throw o.fatal=!0,o}info(t,n,r){const o=this.message(t,n,r);return o.fatal=void 0,o}message(t,n,r){const o=new or(t,n,r);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function $y(e,t){if(e&&e.includes(Vs.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Vs.sep+"`")}function Iy(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function EN(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function NG(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const CG=(function(e){const r=this.constructor.prototype,o=r[e],i=function(){return o.apply(i,arguments)};return Object.setPrototypeOf(i,r),i}),EG={}.hasOwnProperty;class f0 extends CG{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=pG()}copy(){const t=new f0;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(_y(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Oy("data",this.frozen),this.namespace[t]=n,this):EG.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Oy("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const o=n.call(t,...r);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=xp(t),r=this.parser||this.Parser;return Ly("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Ly("process",this.parser||this.Parser),My("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(i,a){const l=xp(t),u=r.parse(l);r.run(u,l,function(p,h,g){if(p||!h||!g)return f(p);const y=h,k=r.stringify(y,g);AG(k)?g.value=k:g.result=k,f(p,g)});function f(p,h){p||!h?a(p):i?i(h):n(void 0,h)}}}processSync(t){let n=!1,r;return this.freeze(),Ly("processSync",this.parser||this.Parser),My("processSync",this.compiler||this.Compiler),this.process(t,o),RN("processSync","process",n),r;function o(i,a){n=!0,NN(i),r=a}}run(t,n,r){TN(t),this.freeze();const o=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(a,l){const u=xp(n);o.run(t,u,f);function f(p,h,g){const y=h||t;p?l(p):a?a(y):r(void 0,y,g)}}}runSync(t,n){let r=!1,o;return this.run(t,n,i),RN("runSync","run",r),o;function i(a,l){NN(a),o=l,r=!0}}stringify(t,n){this.freeze();const r=xp(n),o=this.compiler||this.Compiler;return My("stringify",o),TN(t),o(t,r)}use(t,...n){const r=this.attachers,o=this.namespace;if(Oy("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(f){if(typeof f=="function")u(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[p,...h]=f;u(p,h)}else a(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function a(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(f.plugins),f.settings&&(o.settings=_y(!0,o.settings,f.settings))}function l(f){let p=-1;if(f!=null)if(Array.isArray(f))for(;++p<f.length;){const h=f[p];i(h)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function u(f,p){let h=-1,g=-1;for(;++h<r.length;)if(r[h][0]===f){g=h;break}if(g===-1)r.push([f,...p]);else if(p.length>0){let[y,...k]=p;const v=r[g][1];cv(v)&&cv(y)&&(y=_y(!0,v,y)),r[g]=[f,y,...k]}}}}const TG=new f0().freeze();function Ly(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function My(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Oy(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function TN(e){if(!cv(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function RN(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function xp(e){return RG(e)?e:new s_(e)}function RG(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function AG(e){return typeof e=="string"||PG(e)}function PG(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const _G="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",AN=[],PN={allowDangerousHtml:!0},DG=/^(https?|ircs?|mailto|xmpp)$/i,$G=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function IG(e){const t=LG(e),n=MG(e);return OG(t.runSync(t.parse(n),n),e)}function LG(e){const t=e.rehypePlugins||AN,n=e.remarkPlugins||AN,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...PN}:PN;return TG().use(mK).use(n).use(uG,r).use(t)}function MG(e){const t=e.children||"",n=new s_;return typeof t=="string"&&(n.value=t),n}function OG(e,t){const n=t.allowedElements,r=t.allowElement,o=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,u=t.urlTransform||FG;for(const p of $G)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+_G+p.id,void 0);return t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:e.type==="root"?e.children:[e]}),r_(e,f),GV(e,{Fragment:s.Fragment,components:o,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function f(p,h,g){if(p.type==="raw"&&g&&typeof h=="number")return a?g.children.splice(h,1):g.children[h]={type:"text",value:p.value},h;if(p.type==="element"){let y;for(y in Ty)if(Object.hasOwn(Ty,y)&&Object.hasOwn(p.properties,y)){const k=p.properties[y],v=Ty[y];(v===null||v.includes(p.tagName))&&(p.properties[y]=u(String(k||""),y,p))}}if(p.type==="element"){let y=n?!n.includes(p.tagName):i?i.includes(p.tagName):!1;if(!y&&r&&typeof h=="number"&&(y=!r(p,h,g)),y&&g&&typeof h=="number")return l&&p.children?g.children.splice(h,1,...p.children):g.children.splice(h,1),h}}}function FG(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),o=e.indexOf("/");return t===-1||o!==-1&&t>o||n!==-1&&t>n||r!==-1&&t>r||DG.test(e.slice(0,t))?e:""}function vl(e){return e.trim().toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function wo(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(wo).join(""):m.isValidElement(e)?wo(e.props.children):m.Children.toArray(e).map(wo).join("")}const zG={h1:({children:e,...t})=>s.jsx("h1",{id:vl(wo(e)),...t,children:e}),h2:({children:e,...t})=>s.jsx("h2",{id:vl(wo(e)),...t,children:e}),h3:({children:e,...t})=>s.jsx("h3",{id:vl(wo(e)),...t,children:e}),h4:({children:e,...t})=>s.jsx("h4",{id:vl(wo(e)),...t,children:e}),h5:({children:e,...t})=>s.jsx("h5",{id:vl(wo(e)),...t,children:e}),h6:({children:e,...t})=>s.jsx("h6",{id:vl(wo(e)),...t,children:e})};function vn({content:e,className:t,emptyState:n="No markdown content yet."}){const r=e.replace(/<!--[\s\S]*?-->/g,"");return r.trim()?s.jsx("div",{className:je("prose-syntaur max-w-none",t),children:s.jsx(IG,{components:zG,children:r})}):s.jsx("div",{className:"rounded-md border border-dashed border-border/80 bg-muted/30 px-3 py-4 text-sm text-muted-foreground",children:n})}function rs(e){return`/api/projects/${encodeURIComponent(e)}/todos`}function BG(e){const[t,n]=m.useState(null),[r,o]=m.useState(!0),[i,a]=m.useState(null),l=m.useCallback(async()=>{if(e)try{const u=await fetch(rs(e));if(!u.ok)throw new Error(`HTTP ${u.status}`);n(await u.json()),a(null)}catch(u){a(u instanceof Error?u.message:"Failed to fetch todos")}finally{o(!1)}},[e]);return m.useEffect(()=>{l()},[l]),Ei(u=>{u.type==="todos-updated"&&u.projectSlug===e&&l()}),{data:t,loading:r,error:i,refetch:l}}async function UG(e,t,n){await _a(rs(e),{description:t,tags:n})}async function HG(e,t,n){await _a(`${rs(e)}/${t}/complete`,{summary:"Completed."})}async function VG(e,t,n){await _a(`${rs(e)}/${t}/block`,{reason:n})}async function WG(e,t,n){await _a(`${rs(e)}/${t}/start`,{session:n})}async function qG(e,t){await _a(`${rs(e)}/${t}/reopen`,{})}async function KG(e,t){await QG(`${rs(e)}/${t}`)}async function GG(e,t,n){const r=await fetch(`${rs(e)}/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:n})});if(!r.ok)throw new Error(await r.text().catch(()=>"")||`HTTP ${r.status}`)}function o_(e,t,n){return`${rs(e)}/${t}/attachments/${encodeURIComponent(n)}`}async function YG(e,t,n){for(const r of n){const o=await fetch(`${rs(e)}/${t}/attachments`,{method:"POST",headers:{"Content-Type":"application/octet-stream","x-attachment-filename":encodeURIComponent(r.name||"file"),"x-attachment-mime":r.type||"application/octet-stream"},body:r});if(!o.ok)throw new Error(await o.text().catch(()=>"")||`HTTP ${o.status}`)}}async function XG(e,t,n){const r=await fetch(o_(e,t,n),{method:"DELETE"});if(!r.ok)throw new Error(await r.text().catch(()=>"")||`HTTP ${r.status}`)}async function _a(e,t){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){const r=await n.text().catch(()=>"");let o=null;try{o=r?JSON.parse(r):null}catch{}const i=(o==null?void 0:o.error)||r||`HTTP ${n.status}`,a=new Error(i);throw a.status=n.status,a}return n.json().catch(()=>({}))}async function QG(e){const t=await fetch(e,{method:"DELETE"});if(!t.ok){const n=await t.text().catch(()=>"");let r=null;try{r=n?JSON.parse(n):null}catch{}const o=(r==null?void 0:r.error)||n||`HTTP ${t.status}`,i=new Error(o);throw i.status=t.status,i}}async function JG(e,t){return await _a(`${rs(e)}/promote`,t)}async function ZG(e,t,n){await _a(`${rs(e)}/${t}/move`,{to:n})}function ss({open:e,title:t,description:n,confirmLabel:r,cancelLabel:o="Cancel",loading:i=!1,destructive:a=!1,onConfirm:l,onOpenChange:u}){return s.jsx(Tl,{open:e,onOpenChange:f=>i?void 0:u(f),children:s.jsxs(aa,{children:[s.jsxs(Rl,{children:[s.jsx(la,{children:t}),s.jsx(ca,{children:n})]}),s.jsxs(Al,{children:[s.jsx(rd,{disabled:i,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:o}),s.jsx(yi,{disabled:i,className:`shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50 ${a?"border-destructive/80 bg-destructive text-destructive-foreground hover:bg-destructive/90":"shell-action--cta"}`,onClick:f=>{f.preventDefault(),l()},children:i?"Working...":r})]})]})})}const _N=[{value:"open",icon:"○",label:"Open",color:"text-muted-foreground"},{value:"in_progress",icon:"◉",label:"In Progress",color:"text-status-in-progress-foreground"},{value:"completed",icon:"✓",label:"Completed",color:"text-status-completed-foreground"},{value:"blocked",icon:"✕",label:"Blocked",color:"text-status-blocked-foreground"}];function i_({status:e,onChange:t}){const[n,r]=m.useState(!1),o=m.useRef(null);m.useEffect(()=>{if(!n)return;function a(l){o.current&&!o.current.contains(l.target)&&r(!1)}return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[n]);const i=_N.find(a=>a.value===e);return s.jsxs("div",{className:"relative",ref:o,onClick:a=>a.stopPropagation(),children:[s.jsx("button",{onClick:()=>r(!n),className:`text-lg leading-none ${i.color} hover:opacity-70 transition`,title:i.label,children:i.icon}),n&&s.jsx("div",{className:"absolute left-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border/70 bg-background shadow-lg py-1",children:_N.filter(a=>a.value!==e).map(a=>s.jsxs("button",{onClick:()=>{t(a.value),r(!1)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-sm hover:bg-foreground/5 transition ${a.color}`,children:[s.jsx("span",{className:"text-base leading-none",children:a.icon}),s.jsx("span",{children:a.label})]},a.value))})]})}function a_({item:e,copiedId:t,selected:n,editing:r,onBeginEdit:o,onEndEdit:i,onPatchDescription:a,onAddAttachments:l,onDeleteAttachment:u,attachmentUrl:f,onToggleSelected:p,onMoveOne:h,onStatusChange:g,onCopyId:y,onDelete:k,hotkeyRowProps:v,onDragOrigin:b,onDragStart:j,onDragEnd:N,isDragging:S}){return s.jsxs("div",{draggable:!0,"data-todo-id":e.id,...v??{},onMouseDown:b,onDragStart:C=>j(C,e.id),onDragEnd:N,className:`surface-panel flex items-start gap-3 px-3 py-2 cursor-grab active:cursor-grabbing hover:bg-foreground/[0.03] transition ${S?"opacity-50 shadow-lg":""}`,children:[s.jsx("input",{type:"checkbox","data-no-drag":!0,"aria-label":`Select todo ${e.id}`,title:"Select",checked:n,onChange:C=>p(e.id,C),onClick:C=>C.stopPropagation(),className:"mt-1 h-4 w-4 shrink-0 cursor-pointer accent-foreground"}),s.jsx("span",{className:"mt-0.5 self-stretch w-px bg-border/60","aria-hidden":"true"}),s.jsx("div",{className:"mt-0.5 shrink-0",children:s.jsx(i_,{status:e.status,onChange:C=>g(e.id,C)})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-baseline flex-wrap gap-x-2",children:[s.jsx(l_,{description:e.description,status:e.status,editing:r,onBeginEdit:()=>o(e.id),onEndEdit:i,onSave:C=>a(e.id,C)}),e.tags.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:e.tags.map(C=>`#${C}`).join(" ")}),e.session&&s.jsxs("span",{className:"text-xs text-info-foreground/70 font-mono",children:["session:",e.session.slice(0,8)]}),s.jsx(sY,{item:e})]}),s.jsx(c_,{item:e,attachmentUrl:f,onAdd:C=>l(e.id,C),onDelete:C=>u(e.id,C)})]}),t===e.id?s.jsxs("span",{className:"text-xs text-status-completed-foreground flex items-center gap-1",children:[s.jsx(Sr,{className:"h-3 w-3"})," Copied to clipboard"]}):s.jsxs(s.Fragment,{children:[s.jsxs("button",{"data-no-drag":!0,className:"text-xs text-muted-foreground/60 font-mono hover:text-foreground transition",onClick:C=>y(C,e.id),children:["t:",e.id]}),s.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-foreground transition",title:"Copy ID",onClick:C=>y(C,e.id),children:s.jsx(ah,{className:"h-3 w-3"})}),s.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-foreground transition",title:"Move to...",onClick:C=>h(e.id,C),children:s.jsx(Jh,{className:"h-3 w-3"})}),s.jsx("button",{"data-no-drag":!0,className:"text-muted-foreground/40 hover:text-destructive transition",title:"Delete todo",onClick:C=>k(C,e.id,e.description),children:s.jsx(jn,{className:"h-3 w-3"})})]})]})}function l_({description:e,status:t,editing:n,onBeginEdit:r,onEndEdit:o,onSave:i}){return n?s.jsx(eY,{initialValue:e,onSave:i,onExit:o}):s.jsx("button",{type:"button","data-no-drag":!0,onClick:a=>{a.stopPropagation(),r()},title:"Click to edit",className:je("text-left text-sm rounded-sm transition hover:text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",t==="completed"?"line-through text-muted-foreground":"text-foreground"),children:e})}function eY({initialValue:e,onSave:t,onExit:n}){const r=m.useRef(e),[o,i]=m.useState(e),[a,l]=m.useState(!1),[u,f]=m.useState(!1),p=m.useRef(null),h=m.useRef(!1);m.useEffect(()=>{const v=p.current;v&&(v.focus(),v.select())},[]);const g=m.useCallback(()=>{var v;f(!0),window.setTimeout(()=>f(!1),260),(v=p.current)==null||v.focus()},[]),y=m.useCallback(async()=>{var b;if(h.current)return;const v=o.trim();if(v.length===0){g();return}if(v===r.current){n();return}h.current=!0,l(!0);try{await t(v),n()}catch{l(!1),h.current=!1,(b=p.current)==null||b.focus()}},[o,n,t,g]);function k(v){v.key==="Enter"?(v.preventDefault(),y()):v.key==="Escape"&&(v.preventDefault(),h.current=!0,n())}return s.jsx("input",{ref:p,type:"text","data-no-drag":!0,disabled:a,value:o,onClick:v=>v.stopPropagation(),onChange:v=>i(v.target.value),onKeyDown:k,onBlur:()=>void y(),className:je("w-full rounded-sm border border-border bg-background px-1.5 py-0.5 text-sm text-foreground outline-none transition focus:border-ring focus:ring-1 focus:ring-ring",u&&"syntaur-input-shake",a&&"opacity-70")})}function tY(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function nY(e){const t=e.clipboardData,n=[];if(t.files&&t.files.length&&n.push(...Array.from(t.files)),!n.length&&t.items){for(const r of Array.from(t.items))if(r.kind==="file"){const o=r.getAsFile();o&&n.push(o)}}return n}function c_({item:e,attachmentUrl:t,onAdd:n,onDelete:r}){const o=e.attachments??[],[i,a]=m.useState(!1),[l,u]=m.useState(!1),f=m.useRef(null),p=m.useRef(null);m.useEffect(()=>{var g;i&&((g=p.current)==null||g.focus())},[i]);const h=m.useCallback(async g=>{if(g.length){u(!0);try{await n(g),a(!1)}finally{u(!1)}}},[n]);return s.jsxs("div",{className:"mt-1","data-no-drag":!0,onClick:g=>g.stopPropagation(),children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.map(g=>s.jsx(rY,{att:g,url:t(e.id,g.id),onDelete:()=>void r(g.id)},g.id)),s.jsxs("button",{type:"button","data-no-drag":!0,title:"Attach files",onClick:()=>a(g=>!g),className:"inline-flex items-center gap-1 rounded-md border border-border/60 px-1.5 py-0.5 text-xs text-muted-foreground hover:text-foreground hover:border-border transition",children:[s.jsx(g2,{className:"h-3 w-3"}),o.length===0?"Attach":""]})]}),i&&s.jsxs("div",{ref:p,"data-no-drag":!0,tabIndex:0,role:"button","aria-label":"Add attachments: drop, paste, or click",onPaste:g=>{const y=nY(g);y.length&&(g.preventDefault(),h(y))},onDragOver:g=>{Array.from(g.dataTransfer.types).includes("Files")&&g.preventDefault()},onDrop:g=>{const y=Array.from(g.dataTransfer.files);y.length&&(g.preventDefault(),h(y))},onClick:()=>{var g;return(g=f.current)==null?void 0:g.click()},className:"mt-1 cursor-pointer rounded-md border border-dashed border-border/70 px-3 py-2 text-xs text-muted-foreground hover:border-border focus:outline-none focus:ring-2 focus:ring-ring/40",children:[l?"Uploading…":"Drop, paste (⌘V / Ctrl+V), or click to add files",s.jsx("input",{ref:f,type:"file",multiple:!0,className:"hidden",onChange:g=>{const y=Array.from(g.target.files??[]);g.target.value="",h(y)}})]})]})}function rY({att:e,url:t,onDelete:n}){return s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-border/60 bg-background px-1.5 py-0.5 text-xs",children:[tY(e.mime)?s.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",title:e.filename,children:s.jsx("img",{src:t,alt:e.filename,className:"h-6 w-6 rounded object-cover"})}):s.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-foreground hover:text-primary",children:[s.jsx(g2,{className:"h-3 w-3"}),s.jsx("span",{className:"block max-w-[160px] truncate",children:e.filename})]}),s.jsx("button",{type:"button",title:"Remove attachment",onClick:n,className:"text-muted-foreground/60 hover:text-destructive transition",children:s.jsx(Pd,{className:"h-3 w-3"})})]})}function sY({item:e}){return!(e.branch||e.planDir||e.worktreePath||e.createdAt||e.updatedAt)?null:s.jsxs("span",{className:"inline-flex items-center gap-1 align-middle",children:[e.branch?s.jsx(ha,{delayDuration:120,children:s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-info-foreground/30 bg-info/30 px-1.5 py-0.5 text-[10px] font-mono text-info-foreground",children:[s.jsx(Uv,{className:"h-2.5 w-2.5"}),s.jsx("span",{className:"block min-w-0 max-w-[120px] truncate",children:e.branch})]})}),s.jsx(vr,{children:e.branch})]})}):null,e.planDir?s.jsx(ha,{delayDuration:120,children:s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:s.jsx("button",{type:"button","data-no-drag":!0,onClick:n=>{n.stopPropagation(),Wd(e.planDir)},className:"inline-flex items-center rounded-full border border-status-completed-foreground/40 bg-status-completed/30 p-1 text-status-completed-foreground hover:bg-status-completed/50","aria-label":"Copy plan directory path",children:s.jsx(p2,{className:"h-2.5 w-2.5"})})}),s.jsxs(vr,{children:["Plan: ",e.planDir]})]})}):null,e.worktreePath||e.createdAt||e.updatedAt?s.jsx(ha,{delayDuration:120,children:s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:s.jsx("span",{className:"text-[10px] text-muted-foreground/60 cursor-default",children:"·"})}),s.jsx(vr,{children:s.jsxs("div",{className:"space-y-0.5 text-xs font-mono",children:[e.worktreePath?s.jsxs("div",{children:["worktree: ",e.worktreePath]}):null,e.createdAt?s.jsxs("div",{children:["created: ",e.createdAt]}):null,e.updatedAt?s.jsxs("div",{children:["updated: ",e.updatedAt]}):null]})})]})}):null]})}const u_="__one_off__";function p0({open:e,selectedIds:t,scope:n,onOpenChange:r,onDone:o,defaultProject:i,defaultTitle:a,allowOneOff:l=!0}){const[u,f]=m.useState("new"),[p,h]=m.useState(!1),[g,y]=m.useState(null),[k,v]=m.useState(null),[b,j]=m.useState(null),[N,S]=m.useState(""),[C,D]=m.useState(""),[T,R]=m.useState(""),[$,P]=m.useState(""),[F,_]=m.useState(""),[V,U]=m.useState(""),[I,M]=m.useState(null),[B,W]=m.useState(!1),O=t.length>1;m.useEffect(()=>{if(!e){f("new"),y(null),S(""),D(""),R(""),P(""),_(""),U(""),M(null);return}S(i??""),D(a??"");let Q=!1;return(async()=>{try{const ee=await fetch("/api/projects");if(!ee.ok)throw new Error(`HTTP ${ee.status}`);const Z=await ee.json();Q||v(Z.filter(ie=>!ie.archived))}catch(ee){Q||j(ee instanceof Error?ee.message:String(ee))}})(),()=>{Q=!0}},[e,i,a]),m.useEffect(()=>{if(!F){M(null);return}let Q=!1;return W(!0),(async()=>{try{const ee=await fetch(`/api/projects/${encodeURIComponent(F)}/assignments`);if(!ee.ok)throw new Error(`HTTP ${ee.status}`);const Z=await ee.json();Q||M(Z)}catch{Q||M([])}finally{Q||W(!1)}})(),()=>{Q=!0}},[F]);const H=m.useMemo(()=>k??[],[k]);async function L(Q){if(Q.preventDefault(),!N){y('Pick a target project (or "One-off").');return}if(O&&!C.trim()){y("Title is required when promoting multiple todos.");return}const ee=N===u_?{oneOff:!0}:{project:N};if(n.kind==="aggregate"){const ie={groups:n.groups,mode:"new-assignment",target:ee,title:C.trim()||void 0,type:T.trim()||void 0,priority:$||void 0};await q(ie);return}const Z={todoIds:t,mode:"new-assignment",target:ee,title:C.trim()||void 0,type:T.trim()||void 0,priority:$||void 0};await Y(Z)}async function z(Q){if(Q.preventDefault(),n.kind==="aggregate"){y("Existing-assignment mode does not support cross-workspace selections yet.");return}if(!F||!V){y("Pick both project and assignment.");return}const ee={todoIds:t,mode:"to-assignment",target:{assignment:`${F}/${V}`}};await Y(ee)}async function Y(Q){h(!0),y(null);try{let ee;if(n.kind==="workspace")ee=await a5(n.workspace,Q);else if(n.kind==="project")ee=await JG(n.projectId,Q);else throw new Error("Aggregate scope requires runBulkMutation.");o(ee),r(!1)}catch(ee){y(ee instanceof Error?ee.message:String(ee))}finally{h(!1)}}async function q(Q){h(!0),y(null);try{const ee=await l5(Q);o(ee),r(!1)}catch(ee){y(ee instanceof Error?ee.message:String(ee))}finally{h(!1)}}return s.jsx(Mn,{open:e,onOpenChange:Q=>p?void 0:r(Q),children:s.jsxs(Nn,{className:"max-w-xl",children:[s.jsxs(sr,{children:[s.jsxs(Cn,{children:["Promote ",t.length," todo",t.length===1?"":"s"]}),s.jsxs(ns,{children:["Convert the selected todo",t.length===1?"":"s"," to a new or existing assignment. Source todo",t.length===1?"":"s"," will be marked ",s.jsx("strong",{children:"in progress"})," and linked to the new assignment (auto-completed when the assignment closes)."]})]}),s.jsxs(jP,{value:u,onValueChange:Q=>f(Q),children:[s.jsxs(kP,{className:"flex gap-2 rounded-md border border-border/70 bg-card/80 p-1 mb-4",children:[s.jsx(Zb,{value:"new",className:je("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:"New assignment"}),s.jsx(Zb,{value:"existing",className:je("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:"Existing assignment"})]}),s.jsx(ev,{value:"new",children:s.jsxs("form",{onSubmit:L,className:"space-y-4",children:[s.jsx(wl,{label:"Target project",children:s.jsx(DN,{value:N,onChange:S,projects:H,error:b,disabled:p,allowOneOff:l})}),s.jsx(wl,{label:O?"Title (required)":"Title (defaults to first todo)",children:s.jsx("input",{type:"text",value:C,onChange:Q=>D(Q.target.value),disabled:p,className:"editor-input bg-background/95 font-sans"})}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(wl,{label:"Type",children:s.jsx("input",{type:"text",value:T,onChange:Q=>R(Q.target.value),placeholder:"feature",disabled:p,className:"editor-input bg-background/95 font-sans"})}),s.jsx(wl,{label:"Priority",children:s.jsxs("select",{value:$,onChange:Q=>P(Q.target.value),disabled:p,className:"editor-input bg-background/95 font-sans",children:[s.jsx("option",{value:"",children:"—"}),s.jsx("option",{value:"low",children:"low"}),s.jsx("option",{value:"medium",children:"medium"}),s.jsx("option",{value:"high",children:"high"}),s.jsx("option",{value:"critical",children:"critical"})]})})]}),g?s.jsx($N,{message:g}):null,s.jsx(IN,{onCancel:()=>r(!1),submitting:p,submitLabel:"Promote"})]})}),s.jsx(ev,{value:"existing",children:s.jsxs("form",{onSubmit:z,className:"space-y-4",children:[s.jsx(wl,{label:"Project",children:s.jsx(DN,{value:F,onChange:Q=>{_(Q),U("")},projects:H,error:b,disabled:p})}),s.jsx(wl,{label:B?"Assignment (loading...)":"Assignment",children:s.jsxs("select",{value:V,onChange:Q=>U(Q.target.value),disabled:p||!F||B,className:"editor-input bg-background/95 font-sans",children:[s.jsx("option",{value:"",children:F?"Select assignment...":"Pick a project first"}),(I??[]).map(Q=>s.jsxs("option",{value:Q.slug,children:[Q.title," (",Q.status,")"]},Q.slug))]})}),g?s.jsx($N,{message:g}):null,s.jsx(IN,{onCancel:()=>r(!1),submitting:p,submitLabel:"Promote"})]})})]})]})})}function wl({label:e,children:t}){return s.jsxs("label",{className:"block space-y-1.5",children:[s.jsx("span",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),t]})}function DN({value:e,onChange:t,projects:n,error:r,disabled:o,allowOneOff:i}){return r?s.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load projects: ",r]}):s.jsxs("select",{value:e,onChange:a=>t(a.target.value),disabled:o,className:"editor-input bg-background/95 font-sans",children:[s.jsx("option",{value:"",children:"Select project..."}),i?s.jsx("option",{value:u_,children:"One-off (no project)"}):null,n.map(a=>s.jsxs("option",{value:a.slug,children:[a.title," (",a.slug,")"]},a.slug))]})}function $N({message:e}){return s.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:e})}function IN({onCancel:e,submitting:t,submitLabel:n}){return s.jsxs(Wr,{children:[s.jsx("button",{type:"button",onClick:e,disabled:t,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:t,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:t?"Submitting...":n})]})}function d_({open:e,selectedIds:t,scope:n,onOpenChange:r,onDone:o}){const[i,a]=m.useState("project"),[l,u]=m.useState(""),[f,p]=m.useState(""),[h,g]=m.useState(!1),[y,k]=m.useState(null),[v,b]=m.useState(null),[j,N]=m.useState(null);m.useEffect(()=>{if(!e){a("project"),u(""),p(""),k(null),b(null);return}let R=!1;return(async()=>{try{const $=await fetch("/api/projects");if(!$.ok)throw new Error(`HTTP ${$.status}`);const P=await $.json();R||N(P.filter(F=>!F.archived))}catch($){R||b($ instanceof Error?$.message:String($))}})(),()=>{R=!0}},[e]);const S=m.useMemo(()=>j?n.kind==="project"?j.filter(R=>R.slug!==n.projectId):j:[],[j,n]);function C(){if(i==="global")return{global:!0};if(i==="workspace"){const R=l.trim();return R?{workspace:R}:"Workspace name is required."}return f?{project:f}:"Pick a target project."}async function D(R,$){try{return n.kind==="workspace"?await c5(n.workspace,R,$):await ZG(n.projectId,R,$),{ok:!0}}catch(P){return{ok:!1,error:P instanceof Error?P.message:String(P)}}}async function T(R){R.preventDefault(),b(null);const $=C();if(typeof $=="string"){b($);return}g(!0),k(null);const P=[],F=[];for(const _ of t){const V=await D(_,$);V.ok?P.push(_):F.push({id:_,error:V.error})}g(!1),o(),F.length===0?r(!1):k({succeeded:P,failed:F})}return s.jsx(Mn,{open:e,onOpenChange:R=>h?void 0:r(R),children:s.jsx(Nn,{className:"max-w-xl",children:s.jsxs("form",{onSubmit:T,className:"space-y-4",children:[s.jsxs(sr,{children:[s.jsxs(Cn,{children:["Move ",t.length," todo",t.length===1?"":"s"]}),s.jsxs(ns,{children:["Move the selected todo",t.length===1?"":"s"," to a different scope. id, tags, branch, timestamps, and plan dir are preserved."]})]}),s.jsxs("fieldset",{className:"space-y-2",disabled:h,children:[s.jsx("legend",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground mb-1",children:"Target scope"}),s.jsx(Fy,{kind:"project",checked:i==="project",onChange:()=>a("project"),label:"Project"}),s.jsx(Fy,{kind:"workspace",checked:i==="workspace",onChange:()=>a("workspace"),label:"Workspace"}),s.jsx(Fy,{kind:"global",checked:i==="global",onChange:()=>a("global"),label:"Global"})]}),i==="project"?s.jsx(LN,{label:"Target project",children:s.jsxs("select",{value:f,onChange:R=>p(R.target.value),disabled:h,className:"editor-textarea w-full bg-background/95 font-sans",children:[s.jsx("option",{value:"",children:"Select project..."}),S.map(R=>s.jsxs("option",{value:R.slug,children:[R.title," (",R.slug,")"]},R.slug))]})}):null,i==="workspace"?s.jsx(LN,{label:"Target workspace name",children:s.jsx("input",{type:"text",value:l,onChange:R=>u(R.target.value),disabled:h,placeholder:"e.g. syntaur",className:"editor-textarea w-full bg-background/95 font-sans"})}):null,v?s.jsx(oY,{message:v}):null,y?s.jsxs("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-sm text-warning-foreground space-y-1",children:[s.jsxs("div",{className:"font-medium",children:["Moved ",y.succeeded.length," of ",t.length,"; ",y.failed.length," failed."]}),s.jsx("ul",{className:"text-xs space-y-0.5",children:y.failed.map(R=>s.jsxs("li",{children:["[t:",R.id,"] ",R.error]},R.id))})]}):null,s.jsxs(Wr,{children:[s.jsx("button",{type:"button",onClick:()=>r(!1),disabled:h,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:y?"Close":"Cancel"}),y===null?s.jsx("button",{type:"submit",disabled:h,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:h?"Moving...":"Move"}):null]})]})})})}function LN({label:e,children:t}){return s.jsxs("label",{className:"block space-y-1.5",children:[s.jsx("span",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),t]})}function Fy({kind:e,checked:t,onChange:n,label:r}){return s.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[s.jsx("input",{type:"radio",name:"move-target-kind",value:e,checked:t,onChange:n}),s.jsx("span",{children:r})]})}function oY({message:e}){return s.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:e})}function h0({label:e,count:t,expanded:n,onToggle:r,isDropTarget:o=!1,onDragOver:i,onDragLeave:a,onDrop:l,children:u}){return s.jsxs("div",{className:je("rounded-lg border border-border/60 bg-card/40 transition",o&&"ring-2 ring-ring/30"),onDragOver:i,onDragLeave:a,onDrop:l,children:[s.jsxs("button",{type:"button",onClick:r,"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2.5 text-left",children:[s.jsx(cr,{className:je("h-4 w-4 text-muted-foreground transition-transform",!n&&"-rotate-90")}),s.jsx("span",{className:"font-semibold text-foreground",children:e}),s.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:t})]}),n&&s.jsx("div",{className:"space-y-1 px-2 pb-2",children:u})]})}const f_=[{id:"open-blocked",label:"Open / Blocked",statuses:["open","blocked"],dropStatus:"open",defaultCollapsed:!1},{id:"in-progress",label:"In Progress",statuses:["in_progress"],dropStatus:"in_progress",defaultCollapsed:!1},{id:"done",label:"Done",statuses:["completed"],dropStatus:"completed",defaultCollapsed:!0}];function qm(e){switch(e){case"in_progress":return"in-progress";case"completed":return"done";case"open":case"blocked":default:return"open-blocked"}}function m0(e){const t={"open-blocked":[],"in-progress":[],done:[]};for(const n of e)t[qm(n.status)].push(n);return f_.map(n=>({config:n,items:t[n.id]}))}const p_="syntaur.todos.sections.collapsed.v1",MN=Object.fromEntries(f_.map(e=>[e.id,e.defaultCollapsed]));function zy(){if(typeof window>"u"||!window.localStorage)return{};try{const e=window.localStorage.getItem(p_);if(!e)return{};const t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function iY(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(p_,JSON.stringify(e))}catch{}}function g0(e){const[t,n]=m.useState(()=>zy()[e]??{});m.useEffect(()=>{n(zy()[e]??{})},[e]);const r=m.useCallback(i=>t[i]??MN[i],[t]),o=m.useCallback(i=>{const a=zy(),l=a[e]??{},u=l[i]??MN[i],f={...l,[i]:!u};a[e]=f,iY(a),n(f)},[e]);return{isCollapsed:r,toggle:o}}function aY({projectId:e}){var ut;const{data:t,loading:n,error:r,refetch:o}=BG(e),{toast:i,showToast:a,dismissToast:l}=Qn(),[u,f]=m.useState(""),[p,h]=m.useState(""),[g,y]=m.useState(""),[k,v]=m.useState(""),[b,j]=m.useState(null),[N,S]=m.useState(!1),[C,D]=m.useState(null),[T,R]=m.useState(null),[$,P]=m.useState(new Set),[F,_]=m.useState(!1),[V,U]=m.useState(!1),[I,M]=m.useState(null),B=m.useRef(null);Ai("list:todos");const W=g0("project:"+e),[O,H]=m.useState(null),[L,z]=m.useState(null),Y=m.useRef(null);async function q(fe,K){fe.stopPropagation(),await Wd(K)&&(D(K),setTimeout(()=>D(re=>re===K?null:re),1500))}const Q=m.useMemo(()=>{if(!(t!=null&&t.items))return[];const fe=new Set;for(const K of t.items)for(const re of K.tags)fe.add(re);return Array.from(fe).sort()},[t]),ee=m.useMemo(()=>{if(!(t!=null&&t.items))return[];let fe=t.items;if(u.trim()){const K=u.toLowerCase();fe=fe.filter(re=>re.description.toLowerCase().includes(K)||re.tags.some(xe=>xe.toLowerCase().includes(K))||re.id.includes(K))}return p&&(fe=fe.filter(K=>K.status===p)),g&&(fe=fe.filter(K=>K.tags.includes(g))),fe},[t,u,p,g]);m.useEffect(()=>{P(new Set)},[u,p,g,e]);const Z=m.useMemo(()=>ee.filter(fe=>$.has(fe.id)).length,[ee,$]),ie=ee.length>0&&Z===ee.length,ne=Z>0&&!ie;function ue(fe){P(K=>{const re=new Set(K);return re.has(fe)?re.delete(fe):re.add(fe),re})}function ge(){P(fe=>{const K=new Set(fe);if(ie)for(const re of ee)K.delete(re.id);else for(const re of ee)K.add(re.id);return K})}function Ne(){P(new Set)}const Ce=I?[I]:Array.from($);function ke(){P(new Set),M(null),o()}function Ue(){P(new Set),o()}function oe(fe){a(fe instanceof Error?fe.message:"Action failed","error")}async function ve(){if(k.trim())try{await UG(e,k.trim()),v(""),o()}catch(fe){oe(fe)}}function be(fe,K,re){fe.stopPropagation(),j({id:K,description:re})}async function Re(fe,K){try{switch(K){case"open":await qG(e,fe);break;case"in_progress":await WG(e,fe);break;case"completed":await HG(e,fe);break;case"blocked":await VG(e,fe);break}o()}catch(re){oe(re)}}async function He(fe,K){try{await GG(e,fe,K),o()}catch(re){throw oe(re),re}}async function rt(fe,K){try{await YG(e,fe,K),o()}catch(re){oe(re)}}async function Fe(fe,K){try{await XG(e,fe,K),o()}catch(re){oe(re)}}const ot=m0(ee),Nt=ot.filter(fe=>!W.isCollapsed(fe.config.id)).flatMap(fe=>fe.items),{hotkeyRowProps:mt}=Id(Nt,{scope:"list:todos",bindO:!1,onOpen:fe=>R(fe.id)});en({keys:"/",scope:"list:todos",description:"Focus filter",handler:()=>{var fe;return(fe=B.current)==null?void 0:fe.focus()}}),en({keys:"r",scope:"list:todos",description:"Refresh",handler:()=>o()});const[at,ce]=Ts(),me=at.get("focus");m.useEffect(()=>{if(!me||!(t!=null&&t.items))return;const fe=t.items.find(re=>re.id===me);if(!fe)return;const K=qm(fe.status);W.isCollapsed(K)&&W.toggle(K)},[me,t==null?void 0:t.items]),m.useEffect(()=>{if(!me)return;const fe=document.querySelector(`[data-todo-id="${window.CSS.escape(me)}"]`);if(!fe)return;fe.scrollIntoView({block:"nearest"}),fe.classList.add("ring-2","ring-primary/60");const K=window.setTimeout(()=>{fe.classList.remove("ring-2","ring-primary/60"),ce(re=>{const xe=new URLSearchParams(re);return xe.delete("focus"),xe},{replace:!0})},1500);return()=>window.clearTimeout(K)},[me,Nt.length,ce]);const Ie=O?(t==null?void 0:t.items.find(fe=>fe.id===O))??null:null;function Ae(fe,K){const re=Y.current;if(re!=null&&re.closest(nc)){fe.preventDefault();return}fe.dataTransfer.effectAllowed="move",fe.dataTransfer.setData("text/plain",K),H(K)}function We(){H(null),z(null)}function pt(fe,K){!Ie||K.statuses.includes(Ie.status)||(fe.preventDefault(),fe.dataTransfer.dropEffect="move",z(K.id))}function Pe(fe,K){L===K.id&&!fe.currentTarget.contains(fe.relatedTarget)&&z(null)}function Qe(fe,K){fe.preventDefault();const re=Ie;We(),!(!re||K.statuses.includes(re.status))&&Re(re.id,K.dropStatus)}if(n)return s.jsx(bt,{label:"Loading todos..."});if(r)return s.jsx(Rt,{error:r});const Je=(t==null?void 0:t.counts)||{open:0,in_progress:0,blocked:0,total:0};return s.jsxs("div",{className:"space-y-4",children:[s.jsx(Xn,{toast:i,onDismiss:l}),s.jsx(ss,{open:b!==null,title:"Delete todo?",description:`Delete "${(b==null?void 0:b.description)??""}"? This can't be undone.`,confirmLabel:"Delete",destructive:!0,loading:N,onOpenChange:fe=>{!fe&&!N&&j(null)},onConfirm:async()=>{if(b){S(!0);try{await KG(e,b.id),o(),j(null)}catch(fe){oe(fe)}finally{S(!1)}}}}),s.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",children:[s.jsx(Gn,{label:"Open",value:Je.open,icon:ys}),s.jsx(Gn,{label:"In Progress",value:Je.in_progress,icon:ys,tone:"info"}),s.jsx(Gn,{label:"Blocked",value:Je.blocked,icon:rm,tone:"warn"}),s.jsx(Gn,{label:"Total",value:Je.total,icon:ys})]}),s.jsx("div",{className:"surface-panel p-3",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text","aria-label":"New todo description",placeholder:"Add a todo...",value:k,onChange:fe=>v(fe.target.value),onKeyDown:fe=>{fe.key==="Enter"&&k.trim()&&ve()},className:"h-9 flex-1 rounded-md border border-border/70 bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground/80 focus:border-foreground/30 focus:outline-none"}),s.jsxs("button",{onClick:ve,disabled:!k.trim(),className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-40",children:[s.jsx(Mt,{className:"h-4 w-4"}),"Add"]})]})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative flex-1 max-w-sm",children:[s.jsx(Ci,{"aria-hidden":"true",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:B,type:"text","aria-label":"Search todos",placeholder:"Search...",value:u,onChange:fe=>f(fe.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/80 focus:border-foreground/30 focus:outline-none"})]}),s.jsxs("select",{"aria-label":"Filter by status",value:p,onChange:fe=>h(fe.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"",children:"All statuses"}),s.jsx("option",{value:"open",children:"Open"}),s.jsx("option",{value:"in_progress",children:"In Progress"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"blocked",children:"Blocked"})]}),Q.length>0&&s.jsxs("select",{"aria-label":"Filter by tag",value:g,onChange:fe=>y(fe.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"",children:"All tags"}),Q.map(fe=>s.jsxs("option",{value:fe,children:["#",fe]},fe))]})]}),$.size>0?s.jsxs("div",{className:"surface-panel flex items-center justify-between gap-3 px-3 py-2",children:[s.jsxs("span",{className:"text-sm font-medium",children:[$.size," selected"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>_(!0),className:"shell-action shell-action--cta",children:"Promote selected"}),s.jsx("button",{type:"button",onClick:()=>{M(null),U(!0)},className:"shell-action",children:"Move to…"}),s.jsx("button",{type:"button",onClick:Ne,className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]})]}):null,ee.length>0&&s.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox","aria-label":"Select all visible todos",checked:ie,ref:fe=>{fe&&(fe.indeterminate=ne)},onChange:ge,className:"h-4 w-4 cursor-pointer accent-foreground"}),s.jsxs("span",{children:["Select all in current filter (",ee.length,")"]})]}),ee.length===0?(((ut=t==null?void 0:t.items)==null?void 0:ut.length)??0)===0?s.jsx(St,{title:"No todos yet",description:"Add your first todo using the field above to start tracking work for this project."}):s.jsx(St,{title:"No todos match your filters",description:"No todos match the current search, status, or tag filters. Try clearing or adjusting them."}):s.jsx("div",{className:"space-y-3",children:(()=>{let fe=-1;return ot.map(({config:K,items:re})=>{const xe=!W.isCollapsed(K.id);return s.jsx(h0,{label:K.label,count:re.length,expanded:xe,onToggle:()=>W.toggle(K.id),isDropTarget:L===K.id,onDragOver:Ge=>pt(Ge,K),onDragLeave:Ge=>Pe(Ge,K),onDrop:Ge=>Qe(Ge,K),children:xe&&re.map(Ge=>(fe+=1,s.jsx(a_,{item:Ge,copiedId:C,selected:$.has(Ge.id),editing:T===Ge.id,onBeginEdit:ze=>R(ze),onEndEdit:()=>R(null),onPatchDescription:He,onAddAttachments:rt,onDeleteAttachment:Fe,attachmentUrl:(ze,lt)=>o_(e,ze,lt),onToggleSelected:ze=>ue(ze),onMoveOne:(ze,lt)=>{lt.stopPropagation(),M(ze),U(!0)},onStatusChange:Re,onCopyId:q,onDelete:be,hotkeyRowProps:mt(fe),onDragOrigin:ze=>{Y.current=ze.target},onDragStart:Ae,onDragEnd:We,isDragging:O===Ge.id},Ge.id)))},K.id)})})()}),s.jsx(p0,{open:F,selectedIds:Array.from($),scope:{kind:"project",projectId:e},onOpenChange:_,onDone:Ue}),s.jsx(d_,{open:V,selectedIds:Ce,scope:{kind:"project",projectId:e},onOpenChange:fe=>{U(fe),fe||M(null)},onDone:ke})]})}const lY={title:"Assignment",status:"Status",priority:"Priority",assignee:"Assignee",dependencies:"Dependencies",created:"Created",updated:"Updated"},ON=new Set(["title"]);function h_({visibility:e,onChange:t}){const[n,r]=m.useState(!1);function o(a){if(ON.has(a))return;const u=e.hidden.includes(a)?e.hidden.filter(f=>f!==a):[...e.hidden,a];t({hidden:u})}const i=e.hidden.length;return s.jsxs(Mn,{open:n,onOpenChange:r,children:[s.jsx(w6,{asChild:!0,children:s.jsxs("button",{type:"button",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:"Show or hide table columns",children:[s.jsx(rO,{className:"h-3.5 w-3.5","aria-hidden":"true"}),s.jsxs("span",{children:["Columns",i>0?` (${yy.length-i}/${yy.length})`:""]})]})}),s.jsxs(Nn,{className:"max-w-sm",children:[s.jsx(sr,{children:s.jsx(Cn,{children:"Columns"})}),s.jsx("div",{className:"space-y-2",children:yy.map(a=>{const l=e.hidden.includes(a),u=ON.has(a);return s.jsxs("label",{className:`flex items-center gap-2 rounded-md px-2 py-1.5 text-sm ${u?"opacity-60":"cursor-pointer hover:bg-background/80"}`,children:[s.jsx("input",{type:"checkbox",checked:!l,onChange:()=>o(a),disabled:u,className:"h-4 w-4 rounded border-border accent-foreground"}),s.jsx("span",{children:lY[a]}),u?s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"always shown"}):null]},a)})})]})]})}const Kl={...td,custom:!1},m_=`view-prefs.cache.v${td.version}`;let pd=cY(),jl=null;const hd=new Set;let g_=0;function x0(){return++g_}function y0(e){return e===g_}function cY(){if(typeof window>"u"||!window.localStorage)return null;try{const e=window.localStorage.getItem(m_);if(!e)return null;const t=JSON.parse(e);return t.version!==td.version?null:t}catch{return null}}function uY(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(m_,JSON.stringify(e))}catch{}}function b0(e){pd=e,uY(e);for(const t of hd)t(e)}function v0(e){if(!e||typeof e!="object")return Kl;const t=e;return t.version!==td.version||!t.global||!t.projects?Kl:{version:td.version,global:t.global,projects:t.projects,custom:t.custom===!0}}function w0(){if(jl)return jl;const e=x0();return jl=fetch("/api/view-prefs").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{const n=v0(t);return y0(e)&&b0(n),jl=null,pd??n}).catch(()=>(jl=null,pd??Kl)),jl}function x_(e){const[t,n]=m.useState(()=>pd??Kl);return m.useEffect(()=>{let r=!1;return w0().then(o=>{r||n(o)}),hd.add(n),()=>{r=!0,hd.delete(n)}},[]),HT(t,e??null)}function dY(){const[e,t]=m.useState(()=>pd??Kl);return m.useEffect(()=>{let n=!1;return w0().then(r=>{n||t(r)}),hd.add(t),()=>{n=!0,hd.delete(t)}},[]),e}async function y_(e){const t=x0(),n=await fetch("/api/view-prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const o=await n.json().catch(()=>({error:`HTTP ${n.status}`}));throw new Error(o.error??"Failed to save view-prefs")}const r=v0(await n.json());return y0(t)&&b0(r),r}function b_(e){return y_({global:e})}function v_(e,t){return y_({projects:{[e]:t}})}async function fY(){const e=x0(),t=await fetch("/api/view-prefs",{method:"DELETE"});if(!t.ok)throw new Error(`HTTP ${t.status}`);const n=v0(await t.json());return y0(e)&&b0(n),n}const FN=80;function w_({open:e,onOpenChange:t,initialName:n="",onSubmit:r,title:o="Save view"}){const[i,a]=m.useState(n),[l,u]=m.useState(!1),[f,p]=m.useState(null);m.useEffect(()=>{e&&(a(n),p(null),u(!1))},[e,n]);const h=i.trim(),g=h.length>0&&h.length<=FN;return s.jsx(Mn,{open:e,onOpenChange:t,children:s.jsx(Nn,{className:"max-w-md",children:s.jsxs("form",{className:"space-y-4",onSubmit:async y=>{if(y.preventDefault(),!(!g||l)){u(!0),p(null);try{await r(h)}catch(k){p(k instanceof Error?k.message:String(k)),u(!1)}}},children:[s.jsx(sr,{children:s.jsx(Cn,{children:o})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"text",value:i,autoFocus:!0,required:!0,maxLength:FN,onChange:y=>a(y.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"}),f?s.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:f}):null]}),s.jsxs(Wr,{children:[s.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:l,children:"Cancel"}),s.jsx("button",{type:"submit",disabled:!g||l,className:"shell-action shell-action--cta disabled:opacity-50",children:l?"Saving…":"Save"})]})]})})})}function j_({scope:e,loadedViewId:t,onApply:n,onOpenSaveDialog:r}){const{views:o,loading:i}=zd(),[a,l]=m.useState(!1),u=m.useRef(null);m.useEffect(()=>{if(!a)return;function g(k){u.current&&!u.current.contains(k.target)&&l(!1)}function y(k){k.key==="Escape"&&l(!1)}return document.addEventListener("mousedown",g),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",y)}},[a]);const f=m.useMemo(()=>o.filter(g=>XR(g,e)),[o,e]),p=t?o.find(g=>g.id===t)??null:null,h=i?"Saved views…":p?p.name:"Saved views";return s.jsxs("div",{className:"relative",ref:u,children:[s.jsxs("button",{type:"button",disabled:i,onClick:()=>l(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":a,title:h,children:[s.jsx("span",{className:"max-w-[160px] truncate",children:h}),s.jsx(cr,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),a&&s.jsx("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:f.length===0?s.jsxs("div",{className:"px-3 py-3 text-sm text-muted-foreground",children:[s.jsx("p",{className:"mb-2",children:"No saved views yet — Save the current view to start."}),s.jsx("button",{type:"button",onClick:()=>{l(!1),r()},className:"shell-action w-full justify-center",children:"Save current view"})]}):f.map(g=>{const y=g.id===t;return s.jsxs("button",{type:"button",onClick:()=>{l(!1),n(g)},className:je("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:[s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:y?s.jsx(Sr,{className:"h-3.5 w-3.5","aria-hidden":"true"}):null}),s.jsx("span",{className:"truncate",children:g.name})]},g.id)})})]})}const pY=new Set(["overview","assignments","todos","dependencies","knowledge"]),zN="__unknown_type__";function BN(){const{slug:e,workspace:t}=qt(),n=mn(),r=Wt();Ai("project"),en({keys:"a",scope:"project",description:"Create assignment",handler:()=>r(`${n}/projects/${e}/create/assignment`)}),en({keys:"e",scope:"project",description:"Edit project",handler:()=>r(`${n}/projects/${e}/edit`)});const{data:o,loading:i,error:a,refetch:l}=H2(e),u=As(),f=$d(),{data:p}=Ea(),[h,g]=Ts(),y=h.get("tab"),k=y&&pY.has(y)?y:"overview";function v(le){g(Se=>{const nt=new URLSearchParams(Se);return le==="overview"?nt.delete("tab"):nt.set("tab",le),nt},{replace:!0})}const b=e?`p:${e}`:null,j=x_(b),[N,S]=m.useState(()=>dy(j.defaultView)),[C,D]=m.useState(()=>Ve(j.filters.status)),[T,R]=m.useState(()=>Ve(j.filters.assignee)),[$,P]=m.useState(()=>Ve(j.filters.priority)),[F,_]=m.useState(()=>Ve(j.filters.type)),[V,U]=m.useState(()=>Ve(j.filters.tags)),[I,M]=m.useState(null),[B,W]=m.useState(()=>j.grouping),[O,H]=m.useState(()=>j.sortField),[L,z]=m.useState(()=>j.sortDirection),[Y,q]=m.useState(()=>({collapsed:[]})),[Q,ee]=m.useState(()=>({hidden:[]})),[Z,ie]=m.useState(()=>({hidden:[]})),[ne,ue]=m.useState(null),[ge,Ne]=m.useState(!1),[Ce,ke]=m.useState(!1),{toast:Ue,showToast:oe,dismissToast:ve}=Qn(),be={kind:"project",slug:e??"",workspace:t??null},Re=h.get("loadView"),{view:He,loading:rt,error:Fe}=ki(Re),{view:ot,loading:Nt,error:mt}=ki(ne),at=m.useRef(null);m.useEffect(()=>{ne&&!Nt&&!mt&&!ot&&ue(null)},[ot,mt,ne,Nt]),m.useEffect(()=>{ue(null),at.current=null,M(null)},[e,t]),m.useEffect(()=>{S(dy(j.defaultView)),D(Ve(j.filters.status)),R(Ve(j.filters.assignee)),P(Ve(j.filters.priority)),_(Ve(j.filters.type)),U(Ve(j.filters.tags)),W(j.grouping),H(j.sortField),z(j.sortDirection)},[e,j.defaultView,j.filters.status,j.filters.assignee,j.filters.priority,j.filters.type,j.filters.tags,j.grouping,j.sortField,j.sortDirection]);const ce=m.useCallback(le=>{b&&v_(b,le).catch(Se=>{console.warn("Failed to persist project view prefs:",Se)})},[b]),me=m.useCallback(le=>{S(le),ce({defaultView:le})},[ce]),Ie=m.useCallback(le=>{D(le),ce({filters:{status:le}})},[ce]),Ae=m.useCallback(le=>{R(le),ce({filters:{assignee:le}})},[ce]),We=m.useCallback(le=>{P(le),ce({filters:{priority:le}})},[ce]),pt=m.useCallback(le=>{_(le),ce({filters:{type:le}})},[ce]),Pe=m.useCallback(le=>{U(le),ce({filters:{tags:le}})},[ce]),Qe=m.useCallback(le=>{W(le),ce({grouping:le})},[ce]),Je=m.useCallback(le=>{H(le),ce({sortField:le})},[ce]),ut=m.useCallback(le=>{z(le),ce({sortDirection:le})},[ce]),fe=m.useCallback(()=>({viewMode:N,filters:{status:C,priority:$,type:F,assignee:T,tags:V,project:"all",activity:"all",dateRange:ma(I)},sortField:O,sortDirection:L,listSectionVisibility:Y,kanbanColumnVisibility:Q,tableColumnVisibility:Z}),[N,C,$,F,T,V,I,O,L,Y,Q,Z]),K=m.useCallback(le=>{XA(le,{setViewMode:Se=>S(dy(Se)),setStatusFilter:Ie,setPriorityFilter:We,setTypeFilter:pt,setAssigneeFilter:Ae,setTagsFilter:Pe,setDateRange:M,setSortField:Je,setSortDirection:ut,setListSectionVisibility:q,setKanbanColumnVisibility:ee,setTableColumnVisibility:ie}),ue(le.id)},[Ie,We,pt,Ae,Pe,Je,ut]),re=m.useCallback(le=>{K(le),at.current=le.id,g(Se=>{const nt=new URLSearchParams(Se);return nt.set("loadView",le.id),nt},{replace:!0})},[K,g]),xe=m.useCallback(async le=>{try{const Se=rc({name:le,context:{workspace:t??null,projectSlug:e??null},state:fe()}),nt=await Zl(Se),Tn=nt.views[nt.views.length-1];ue((Tn==null?void 0:Tn.id)??null),Tn&&(at.current=Tn.id,g(Er=>{const so=new URLSearchParams(Er);return so.set("loadView",Tn.id),so},{replace:!0})),Ne(!1),ke(!1),oe(`Saved view "${le}"`,"success")}catch(Se){throw oe(Se instanceof Error?Se.message:"Failed to save view","error"),Se}},[fe,g,oe,e,t]),Ge=m.useCallback(async()=>{if(!(!ne||!ot))try{const le=Ve(ot.config.filters.project)[0]??null,Se=rc({name:ot.name,context:{workspace:t??null,projectSlug:le},state:fe()}),nt=Nh(ot.config,Se.config,Se.config);await vh(ne,{config:nt}),oe("View updated","success")}catch(le){oe(le instanceof Error?le.message:"Failed to update view","error")}},[fe,ot,ne,oe,t]);m.useEffect(()=>{if(!Re){at.current=null;return}if(at.current!==Re&&(ne&&ne!==Re&&ue(null),!rt)){if(Fe){oe("Couldn't load saved view — try again","error");return}if(He){if(at.current=Re,!XR(He,{kind:"project",slug:e??"",workspace:t??null})){r(JA(He),{replace:!0});return}K(He),g(le=>{const Se=new URLSearchParams(le);return Se.delete("loadView"),Se},{replace:!0});return}at.current=Re,oe("Saved view no longer exists","error"),g(le=>{const Se=new URLSearchParams(le);return Se.delete("loadView"),Se},{replace:!0})}},[Re,He,rt,Fe,ne,K,g,oe,r,e,t]);function ze(le){O===le?ut(L==="asc"?"desc":"asc"):(Je(le),ut("asc"))}const lt=m.useMemo(()=>o?Object.fromEntries(o.assignments.flatMap(le=>{const Se=`${n}/projects/${o.slug}/assignments/${le.slug}`;return[[le.slug,Se],[le.title,Se]]})):{},[o]),[ht,vt]=m.useState(!1);async function tt(le){vt(!0);try{const Se=await fetch(`/api/projects/${e}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:le})});if(!Se.ok){const nt=await Se.json().catch(()=>null);oe((nt==null?void 0:nt.error)||`HTTP ${Se.status}`,"error");return}l(),oe(le?"Status override set":"Status override cleared","success")}catch(Se){oe(Se instanceof Error?Se.message:"Failed to update status","error")}finally{vt(!1)}}async function _t(le){vt(!0);try{const Se=await fetch(`/api/projects/${e}/${le?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!Se.ok){const nt=await Se.json().catch(()=>null);oe((nt==null?void 0:nt.error)||`HTTP ${Se.status}`,"error");return}l(),oe(le?"Project archived":"Project restored","success")}catch(Se){oe(Se instanceof Error?Se.message:"Failed to update archive state","error")}finally{vt(!1)}}async function zt(le){vt(!0);try{const Se=await fetch(`/api/projects/${e}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspace:le})});if(!Se.ok){const nt=await Se.json().catch(()=>null);oe((nt==null?void 0:nt.error)||`HTTP ${Se.status}`,"error");return}l(),oe(le?`Moved to "${le}"`:"Moved to ungrouped","success")}catch(Se){oe(Se instanceof Error?Se.message:"Failed to move workspace","error")}finally{vt(!1)}}if(i)return s.jsx(bt,{label:"Loading project workspace…"});if(a||!o)return s.jsx(Rt,{error:a||"Project not found."});const Bt=(()=>{const le=new Set;for(const nt of o.assignments)nt.assignee&&le.add(nt.assignee);const Se=[{value:"__unassigned__",label:"Unassigned"}];for(const nt of Array.from(le).sort())Se.push({value:nt,label:nt});return Se})(),we=Array.from(new Set(o.assignments.flatMap(le=>le.tags??[]))).sort().map(le=>({value:le,label:le})),Oe=o.assignments.filter(le=>fH(le,{status:C,priority:$,type:F,assignee:T,tags:V,dateRange:ma(I)})),it=Hd(Oe,O,L),Et=new Set(f.definitions.map(le=>le.id)),ln=B==="type"?[...f.definitions.map(le=>({id:le.id,title:Fl(f,le.id),description:le.description})),...Oe.some(le=>!le.type||!Et.has(le.type))?[{id:zN,title:"Other",description:"Assignments with no recognized type."}]:[]]:rP(u.order).map(le=>({id:le,title:Co(u,le),description:Vd(le)}));function Ut({field:le,children:Se}){const nt=O===le;return s.jsx("th",{className:"pb-3 font-medium",children:s.jsxs("button",{type:"button",onClick:()=>ze(le),className:"inline-flex items-center gap-1 hover:text-foreground",children:[Se,nt?L==="asc"?s.jsx(u2,{className:"h-3 w-3"}):s.jsx(cr,{className:"h-3 w-3"}):null]})})}return s.jsxs("div",{className:"space-y-5","data-density":j.density,children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(kn,{status:o.status}),o.statusOverride&&s.jsx("button",{type:"button",className:"shell-action border-warning-foreground/40 text-warning-foreground disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>tt(null),disabled:ht,title:"Clear manual status override and return to derived status",children:"Clear Override"}),s.jsxs("select",{className:"shell-action appearance-none bg-transparent text-sm disabled:cursor-not-allowed disabled:opacity-50",value:"",disabled:ht,onChange:le=>{le.target.value&&tt(le.target.value)},title:"Override project status",children:[s.jsx("option",{value:"",children:"Set Status…"}),u.statuses.map(le=>s.jsx("option",{value:le.id,children:le.label},le.id)),s.jsx("option",{value:"active",children:"Active"})]}),s.jsx("button",{type:"button",className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>_t(!o.archived),disabled:ht,title:o.archived?"Restore this project and its cascade-hidden assignments":"Archive this project (hides it and its assignments from normal views)",children:o.archived?"Restore":"Archive"}),p&&p.workspaces.length>0&&s.jsxs("select",{className:"shell-action appearance-none bg-transparent text-sm disabled:cursor-not-allowed disabled:opacity-50",value:"",disabled:ht,onChange:le=>{le.target.value==="_ungrouped"?zt(null):le.target.value&&zt(le.target.value)},title:"Move project to a different workspace",children:[s.jsx("option",{value:"",children:"Move to Workspace…"}),p.workspaces.filter(le=>le!==o.workspace).map(le=>s.jsx("option",{value:le,children:le},le)),o.workspace&&s.jsx("option",{value:"_ungrouped",children:"Ungrouped"})]}),s.jsxs(De,{className:"shell-action",to:`${n}/projects/${o.slug}/edit`,children:[s.jsx(Jx,{className:"h-4 w-4"}),s.jsx("span",{children:"Edit Project"})]}),s.jsx(Qw,{externalIds:o.externalIds}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Created ",Yn(o.created),". Last source update ",Nr(o.updated),"."]})]}),s.jsxs("div",{className:"grid gap-3 grid-cols-2 sm:grid-cols-3 xl:grid-cols-5",children:[s.jsx(Gn,{label:"Assignments",value:o.progress.total}),s.jsx(Gn,{label:"In Progress",value:o.progress.in_progress??0,tone:"info"}),s.jsx(Gn,{label:"Review",value:o.progress.review??0,tone:"info"}),s.jsx(Gn,{label:"Blocked",value:o.progress.blocked??0,tone:"warn"}),s.jsx(Gn,{label:"Completed",value:o.progress.completed??0,tone:"success"})]}),s.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_300px]",children:[s.jsx("div",{className:"space-y-4",children:s.jsx(Um,{value:k,onValueChange:v,items:[{value:"overview",label:"Overview",content:s.jsx("div",{className:"space-y-5",children:s.jsx(qe,{title:"Project Overview",children:o.body&&o.body.trim()?s.jsx(vn,{content:o.body}):s.jsx(St,{title:"No overview yet",description:"Add a short summary so collaborators and agents know what this project is about.",actions:s.jsxs(De,{className:"shell-action shell-action--cta",to:`${n}/projects/${o.slug}/edit`,children:[s.jsx(Jx,{className:"h-4 w-4"}),s.jsx("span",{children:"Add overview"})]})})})})},{value:"assignments",label:"Assignments",count:o.assignments.filter(le=>!le.archived).length,content:s.jsx("div",{className:"space-y-5",children:s.jsx(qe,{title:"Assignment Queue",description:"Board and table views over the source assignment files.",actions:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(wn,{ariaLabel:"Status filter",className:"max-w-[170px]",allLabel:"All statuses",options:u.statuses.map(le=>({value:le.id,label:le.label})),value:C,onChange:Ie}),s.jsx(wn,{ariaLabel:"Assignee filter",className:"max-w-[170px]",allLabel:"All assignees",options:Bt,value:T,onChange:Ae}),s.jsx(wn,{ariaLabel:"Priority filter",className:"max-w-[170px]",allLabel:"All priorities",options:[{value:"critical",label:"Critical"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}],value:$,onChange:We}),s.jsx(wn,{ariaLabel:"Type filter",className:"max-w-[170px]",allLabel:"All types",options:f.definitions.map(le=>({value:le.id,label:Fl(f,le.id)})),value:F,onChange:pt}),s.jsx(wn,{ariaLabel:"Tags filter",className:"max-w-[170px]",allLabel:"Any tags",options:we,value:V,onChange:Pe}),s.jsx(Mm,{className:"max-w-[190px]",value:I,onChange:M}),N==="kanban"&&s.jsxs("select",{value:B==="type"?"type":"status",onChange:le=>Qe(le.target.value),className:"editor-input max-w-[170px]",title:"Group kanban by",children:[s.jsx("option",{value:"status",children:"Group: Status"}),s.jsx("option",{value:"type",children:"Group: Type"})]}),s.jsx(zm,{value:N,onChange:le=>me(le),options:[{value:"kanban",label:"Kanban"},{value:"table",label:"Table"}]}),s.jsx(j_,{scope:be,loadedViewId:ne,onApply:re,onOpenSaveDialog:()=>{ke(!1),Ne(!0)}}),s.jsx("button",{type:"button",onClick:()=>{ot?Ge():(ke(!1),Ne(!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:ot?`Update ${ot.name}`:"Save current view",children:ot?`Update '${ot.name}'`:"Save view"}),ot?s.jsx("button",{type:"button",onClick:()=>{ke(!0),Ne(!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]}),children:Oe.length===0?s.jsx(St,{title:"No assignments match these filters",description:"Clear the current filters or create a new assignment for this project.",actions:s.jsx(De,{className:"shell-action shell-action--cta",to:`${n}/projects/${o.slug}/create/assignment`,children:"Create Assignment"})}):N==="kanban"?s.jsx(Lm,{columns:ln,items:it,getItemId:le=>le.slug,getColumnId:le=>B==="type"?le.type&&Et.has(le.type)?le.type:zN:le.status,dragDisabled:!0,boundedColumns:!0,renderCard:le=>s.jsx(hY,{projectSlug:o.slug,assignment:le}),emptyMessage:le=>`No ${le.title.toLowerCase()} assignments.`,hiddenColumnIds:Q.hidden,onHideColumn:le=>ee(Se=>({hidden:Se.hidden.includes(le)?Se.hidden.filter(Tn=>Tn!==le):[...Se.hidden,le]}))}):(()=>{const le=new Set(Z.hidden),Se=nt=>nt==="title"||!le.has(nt);return s.jsxs("div",{className:"overflow-x-auto",children:[s.jsx("div",{className:"mb-3 flex items-center justify-end",children:s.jsx(h_,{visibility:Z,onChange:ie})}),s.jsxs("table",{className:"w-full min-w-[720px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[Se("title")?s.jsx(Ut,{field:"title",children:"Assignment"}):null,Se("status")?s.jsx(Ut,{field:"status",children:"Status"}):null,s.jsx("th",{className:"pb-3 font-medium",children:"Type"}),Se("priority")?s.jsx(Ut,{field:"priority",children:"Priority"}):null,Se("assignee")?s.jsx(Ut,{field:"assignee",children:"Assignee"}):null,Se("dependencies")?s.jsx(Ut,{field:"dependencies",children:"Dependencies"}):null,Se("created")?s.jsx(Ut,{field:"created",children:"Created"}):null,Se("updated")?s.jsx(Ut,{field:"updated",children:"Updated"}):null]})}),s.jsx("tbody",{children:it.map(nt=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[Se("title")?s.jsx("td",{className:"py-4",children:s.jsx(De,{to:`${n}/projects/${o.slug}/assignments/${nt.slug}`,className:"font-semibold text-foreground hover:text-primary",children:nt.title})}):null,Se("status")?s.jsx("td",{className:"py-4",children:s.jsx(kn,{status:nt.status,className:"max-w-[150px]"})}):null,s.jsx("td",{className:"py-4",children:s.jsx(Aa,{type:nt.type,compact:!0})}),Se("priority")?s.jsx("td",{className:"py-4 capitalize text-muted-foreground",children:nt.priority}):null,Se("assignee")?s.jsx("td",{className:"py-4 text-muted-foreground",children:nt.assignee??"—"}):null,Se("dependencies")?s.jsx("td",{className:"py-4 text-muted-foreground",children:nt.dependsOn.length}):null,Se("created")?s.jsx("td",{className:"py-4 text-muted-foreground",children:Yn(nt.created)}):null,Se("updated")?s.jsx("td",{className:"py-4 text-muted-foreground",children:Yn(nt.updated)}):null]},nt.slug))})]})]})})()})})},{value:"todos",label:"Todos",content:s.jsx(aY,{projectId:o.slug})},{value:"dependencies",label:"Dependencies",content:o.dependencyGraph?s.jsx(qe,{title:"Dependency Graph",description:"Rendered from the derived graph when available, with a source-based fallback.",children:s.jsx(xV,{definition:o.dependencyGraph,nodeRoutes:lt})}):s.jsx(St,{title:"No dependency graph yet",description:"Dependencies appear here once assignments declare dependsOn relationships."})},{value:"knowledge",label:"Knowledge",content:s.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[s.jsx(qe,{title:"Resources",description:"Shared project references.",actions:s.jsxs(De,{className:"shell-action",to:`/resources/new?project=${o.slug}`,children:[s.jsx(Mt,{className:"h-4 w-4"}),s.jsx("span",{children:"New Resource"})]}),children:o.resources.length===0?s.jsx(St,{title:"No resources yet",description:"Resources live at the project level and stay available to every assignment."}):s.jsx("div",{className:"space-y-3",children:o.resources.map(le=>s.jsxs(De,{to:`/projects/${o.slug}/resources/${le.slug}`,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:le.name}),s.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[le.category," · ",le.source]})]},le.slug))})}),s.jsx(qe,{title:"Memories",description:"Learnings and patterns captured during the project.",actions:s.jsxs(De,{className:"shell-action",to:`/memories/new?project=${o.slug}`,children:[s.jsx(Mt,{className:"h-4 w-4"}),s.jsx("span",{children:"New Memory"})]}),children:o.memories.length===0?s.jsx(St,{title:"No memories yet",description:"Memories capture patterns discovered during execution so later assignments can reuse them."}):s.jsx("div",{className:"space-y-3",children:o.memories.map(le=>s.jsxs(De,{to:`/projects/${o.slug}/memories/${le.slug}`,className:"block rounded-md border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:le.name}),s.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[le.scope," · ",le.source]})]},le.slug))})})]})}]})}),s.jsxs("div",{className:"space-y-5",children:[s.jsx(qe,{title:"Progress Summary",children:s.jsx(Th,{progress:o.progress,showLegend:!0})}),s.jsx(qe,{title:"Attention",children:(()=>{const le=[{label:"Blocked",count:o.needsAttention.blockedCount,alert:!0},{label:"Failed",count:o.needsAttention.failedCount,alert:!0},{label:"Unanswered questions",count:o.needsAttention.openQuestions,alert:!1}].filter(Se=>Se.count>0);return le.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"Nothing needs attention."}):s.jsx("dl",{className:"space-y-3 text-sm",children:le.map(Se=>s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("dt",{className:"text-muted-foreground",children:Se.label}),s.jsx("dd",{className:`font-semibold ${Se.alert?"text-warning-foreground":"text-foreground"}`,children:Se.count})]},Se.label))})})()}),s.jsx(qe,{title:"Quick Links",children:s.jsxs("div",{className:"space-y-2 text-sm",children:[s.jsxs(De,{className:"flex items-center gap-2 text-primary hover:underline",to:`${n}/projects/${o.slug}/edit`,children:[s.jsx(Jx,{className:"h-4 w-4"}),"Edit project source"]}),s.jsxs(De,{className:"flex items-center gap-2 text-primary hover:underline",to:`${n}/projects/${o.slug}/create/assignment`,children:[s.jsx(Mt,{className:"h-4 w-4"}),"Create assignment"]}),s.jsxs(De,{className:"flex items-center gap-2 text-primary hover:underline",to:"/help",children:[s.jsx(GM,{className:"h-4 w-4"}),"Review project rules"]}),s.jsxs("button",{type:"button",onClick:()=>v("dependencies"),className:"flex items-center gap-2 text-primary hover:underline",children:[s.jsx(Uv,{className:"h-4 w-4"}),"Jump to dependencies"]})]})}),o.archived?s.jsxs(qe,{title:"Archive Metadata",children:[s.jsxs("p",{className:"text-sm leading-6 text-muted-foreground",children:["Archived ",o.archivedAt?Nr(o.archivedAt):"with no timestamp recorded","."]}),o.archivedReason?s.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:o.archivedReason}):null]}):null]})]}),s.jsx(Xn,{toast:Ue,onDismiss:ve}),s.jsx(w_,{open:ge,onOpenChange:le=>{Ne(le),le||ke(!1)},initialName:Ce&&ot?`${ot.name} (copy)`:"",title:Ce?"Save as new view":"Save view",onSubmit:xe})]})}function hY({projectSlug:e,assignment:t}){const n=mn();return s.jsxs(De,{to:`${n}/projects/${e}/assignments/${t.slug}`,className:"vp-card block rounded-lg border border-border/60 bg-background/80 p-3 transition hover:border-primary/40",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h3",{className:"font-semibold text-foreground",children:t.title}),s.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:t.id,children:[t.id.slice(0,8),s.jsx("span",{onClick:r=>{r.preventDefault(),r.stopPropagation()},children:s.jsx(Hr,{value:t.id})})]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Updated ",Yn(t.updated)]})]}),s.jsx(kn,{status:t.status,className:"max-w-[150px]"})]}),s.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[s.jsx(Aa,{type:t.type}),s.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:t.priority}),s.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:t.assignee??"Unassigned"}),s.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[t.dependsOn.length," dependencies"]})]})]})}function k_(e,t=!0){const[n,r]=m.useState([]),[o,i]=m.useState(!0),[a,l]=m.useState(null),[u,f]=m.useState(0),p=t?e:null,h=m.useCallback(()=>{f(y=>y+1)},[]),g=m.useRef(p);return g.current!==p&&(g.current=p,r([]),l(null)),m.useEffect(()=>{if(!p){i(!1),r([]);return}let y=!1;return i(!0),l(null),fetch(p).then(async k=>{if(!k.ok){const v=await k.json().catch(()=>null);throw new Error((v==null?void 0:v.error)||`HTTP ${k.status}`)}return k.json()}).then(k=>{y||(r(Array.isArray(k.events)?k.events:[]),i(!1))}).catch(k=>{y||(l(k.message),i(!1))}),()=>{y=!0}},[p,u]),Ei(y=>{p&&(y.type==="assignment-updated"||y.type==="project-updated")&&h()}),{events:n,loading:o,error:a,refetch:h}}function S_({sessionId:e,disabled:t=!1,disabledReason:n,onError:r,onNotice:o}){const[i,a]=m.useState(!1),[l,u]=m.useState(!1);async function f(){var h;if(t||l)return;u(!0);const p=(async()=>{const g=await fetch(`/api/launch/command?session=${encodeURIComponent(e)}&mode=resume`);if(!g.ok){const k=await g.json().catch(()=>null);throw new Error((k==null?void 0:k.error)??`HTTP ${g.status}`)}const y=await g.json().catch(()=>null);if(!y||typeof y.command!="string")throw new Error("Malformed response from launch command endpoint");return{command:y.command,fallbackWarning:typeof y.fallbackWarning=="string"&&y.fallbackWarning?y.fallbackWarning:void 0}})();try{const g=typeof((h=navigator.clipboard)==null?void 0:h.write)=="function"&&typeof ClipboardItem<"u";let y;if(g)await navigator.clipboard.write([new ClipboardItem({"text/plain":p.then(k=>new Blob([k.command],{type:"text/plain"}))})]),y=(await p).fallbackWarning;else{const k=await p;if(!navigator.clipboard||typeof navigator.clipboard.writeText!="function")throw new Error("Clipboard API is unavailable in this context.");await navigator.clipboard.writeText(k.command),y=k.fallbackWarning}a(!0),setTimeout(()=>a(!1),1500),y&&(o==null||o(y))}catch(g){let y=g instanceof Error?g:new Error(String(g));try{await p}catch(k){y=k instanceof Error?k:new Error(String(k))}r==null||r(y)}finally{u(!1)}}return t?s.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"cursor-not-allowed text-muted-foreground/50",title:n??"Copy launch command unavailable","aria-label":"Copy launch command",children:s.jsx(C1,{className:"h-3 w-3","aria-hidden":"true"})}):s.jsx("button",{type:"button",onClick:f,disabled:l,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 disabled:cursor-wait",title:i?"Copied!":"Copy launch command (cd + resume)","aria-label":"Copy launch command",children:i?s.jsx(Sr,{className:"h-3 w-3 text-status-completed-foreground","aria-hidden":"true"}):s.jsx(C1,{className:"h-3 w-3","aria-hidden":"true"})})}function wu(e,t,n,r,o){let i=`syntaur://open?${e.kind}=${encodeURIComponent(e.id)}`;return e.kind==="session"&&t&&(i+=`&mode=${encodeURIComponent(t)}`),n&&(i+=`&terminal=${encodeURIComponent(n)}`),r&&e.kind==="assignment"&&(i+=`&agent=${encodeURIComponent(r)}`),o!==void 0&&e.kind==="assignment"&&(i+=`&prompt=${encodeURIComponent(o)}`),i}function mY(e){return e.kind==="session"?{method:"POST",url:`/api/agent-sessions/${encodeURIComponent(e.id)}/worktree/recreate`}:e.projectSlug&&e.assignmentSlug?{method:"POST",url:`/api/projects/${encodeURIComponent(e.projectSlug)}/assignments/${encodeURIComponent(e.assignmentSlug)}/worktree/recreate`}:{method:"POST",url:`/api/assignments/${encodeURIComponent(e.id)}/worktree/recreate`}}function gY(e){if(!e.trim())return"Branch name is required.";if(/\s/.test(e))return"Branch name cannot contain whitespace.";if(/[\x00-\x1F\x7F~^:?*[\\]/.test(e))return"Branch name cannot contain any of: ~ ^ : ? * [ \\ or control characters.";if(e.startsWith("-"))return'Branch name cannot start with "-".';if(e.startsWith("/")||e.endsWith("/"))return'Branch name cannot start or end with "/".';if(e.endsWith("."))return'Branch name cannot end with ".".';if(e.includes(".."))return'Branch name cannot contain "..".';if(e.includes("@{"))return'Branch name cannot contain "@{".';if(e==="@")return'Branch name cannot be "@".';for(const t of e.split("/")){if(!t)return'Branch name cannot contain empty path segments (e.g. "a//b").';if(t.startsWith("."))return'Branch name segments cannot start with ".".';if(t.endsWith(".lock"))return'Branch name segments cannot end with ".lock".'}return null}async function N_(e,t,n,r){const o=await fetch(`/api/projects/${e}/assignments/${t}/transitions/${n.command}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r?{reason:r}:{})}),i=await o.json().catch(()=>null);if(!o.ok)throw new Error((i==null?void 0:i.error)||`HTTP ${o.status}`);return i.assignment}async function C_(e,t,n){const r=await fetch(`/api/projects/${e}/assignments/${t}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:n})}),o=await r.json().catch(()=>null);if(!r.ok)throw new Error((o==null?void 0:o.error)||`HTTP ${r.status}`);return o.assignment}async function xY(e,t){const n=await fetch(`/api/projects/${e}/assignments/${t}`,{method:"DELETE"}),r=await n.json().catch(()=>null);if(!n.ok)throw new Error((r==null?void 0:r.error)||`HTTP ${n.status}`)}function E_(e){return e.requiresReason||e.command==="block"}async function yY(e,t,n){const r=await fetch(`/api/assignments/${e}/transitions/${t.command}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n?{reason:n}:{})}),o=await r.json().catch(()=>null);if(!r.ok)throw new Error((o==null?void 0:o.error)||`HTTP ${r.status}`);return o.assignment}async function bY(e,t){const n=await fetch(`/api/assignments/${e}/status-override`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})}),r=await n.json().catch(()=>null);if(!n.ok)throw new Error((r==null?void 0:r.error)||`HTTP ${n.status}`);return r.assignment}async function vY(e){const t=await fetch(`/api/projects/${e.projectSlug}/assignments/${e.assignmentSlug}/title`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title})}),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.assignment}async function wY(e){const t=await fetch(`/api/assignments/${e.id}/title`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title})}),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.assignment}class j0 extends Error{constructor(t,n){super(t),this.stderr=n,this.name="CreateWorktreeError"}}async function k0(e){const t=await e.json().catch(()=>null);return new j0((t==null?void 0:t.error)||`HTTP ${e.status}`,t==null?void 0:t.stderr)}async function jY(e){const t=await fetch(`/api/projects/${e}/repository-candidates`),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.candidates}async function kY(e){const t=await fetch(`/api/assignments/${e}/repository-candidates`),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)||`HTTP ${t.status}`);return n.candidates}async function SY(e,t,n){const r=await fetch(`/api/projects/${e}/assignments/${t}/worktree`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw await k0(r);return(await r.json()).assignment}async function NY(e,t){const n=await fetch(`/api/assignments/${e}/worktree`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw await k0(n);return(await n.json()).assignment}async function CY(e){const{url:t}=mY(e),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!n.ok)throw await k0(n);return await n.json()}async function Km(e){const t=await e.json().catch(()=>null);if(!e.ok)throw new Error((t==null?void 0:t.error)||`HTTP ${e.status}`);return t}async function EY(e,t,n){const r=await fetch(`/api/projects/${e}/assignments/${t}/repository-branches?repo=${encodeURIComponent(n)}`);return Km(r)}async function TY(e,t){const n=await fetch(`/api/assignments/${e}/repository-branches?repo=${encodeURIComponent(t)}`);return Km(n)}async function RY(e,t){const n=await fetch(`/api/projects/${e}/assignments/${t}/source-assignments`);return(await Km(n)).sourceAssignments}async function AY(e){const t=await fetch(`/api/assignments/${e}/source-assignments`);return(await Km(t)).sourceAssignments}function T_(){const[e,t]=m.useState(!1),[n,r]=m.useState(null),[o,i]=m.useState(null),[a,l]=m.useState(null),[u,f]=m.useState(null),[p,h]=m.useState(null),[g,y]=m.useState(!1),[k,v]=m.useState(null),[b,j]=m.useState(null);async function N(T,R,$,P){if(!e){t(!0);try{const F=await fetch("/api/launch/preflight",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:{kind:T.kind,id:T.id}})});if(!F.ok){window.location.href=wu(T,R,void 0,$,P);return}const _=await F.json();if(_.ok){window.location.href=wu(T,R,void 0,$,P);return}if(_.reason==="workspace-path-invalid"){_.recreate?(f(_.recreate),h({target:T,mode:R,agentId:$,prompt:P})):l(_.message);return}r(_),i({target:T,mode:R,agentId:$,prompt:P})}catch(F){console.warn("preflight failed, firing without override:",F),window.location.href=wu(T,R,void 0,$,P)}finally{t(!1)}}}function S(){!n||!o||(window.location.href=wu(o.target,o.mode,n.suggestedFallback,o.agentId,o.prompt),r(null),i(null))}async function C(){if(!(!u||!p||g)){y(!0),v(null);try{const T=await CY({kind:u.kind,id:u.id,projectSlug:u.projectSlug,assignmentSlug:u.assignmentSlug}),{target:R,mode:$,agentId:P,prompt:F}=p;f(null),h(null),window.location.href=wu(R,$,void 0,P,F),!T.exact&&!T.alreadyExisted&&j(`Recreated from ${T.baseUsed} — the original branch couldn't be restored exactly, but the directory is back and your agent is opening.`)}catch(T){v(T instanceof j0&&T.stderr?`${T.message}
619
- ${T.stderr}`:T instanceof Error?T.message:String(T))}finally{y(!1)}}}const D=s.jsxs(s.Fragment,{children:[s.jsx(Tl,{open:n!==null,onOpenChange:T=>!T&&(r(null),i(null)),children:s.jsxs(aa,{children:[s.jsxs(Rl,{children:[s.jsxs(la,{children:[n==null?void 0:n.terminal," is not installed"]}),s.jsxs(ca,{children:[(n==null?void 0:n.terminal)==="cmux"?s.jsxs(s.Fragment,{children:["To use cmux, install ",s.jsx("strong",{children:"cmux.app"})," into"," ",s.jsx("code",{children:"/Applications"}),"."," "]}):null,"Open in ",s.jsx("strong",{children:n==null?void 0:n.suggestedFallback})," instead? You can change the default in"," ",s.jsx(De,{to:"/settings",className:"underline hover:text-foreground",onClick:()=>{r(null),i(null)},children:"Settings"}),"."]})]}),s.jsxs(Al,{children:[s.jsx(rd,{className:"shell-action mt-0",children:"Cancel"}),s.jsxs(yi,{className:"shell-action mt-0 shell-action--cta",onClick:T=>{T.preventDefault(),S()},children:["Open in ",n==null?void 0:n.suggestedFallback]})]})]})}),s.jsx(Tl,{open:a!==null,onOpenChange:T=>!T&&l(null),children:s.jsxs(aa,{children:[s.jsxs(Rl,{children:[s.jsx(la,{children:"Can't open in agent"}),s.jsxs(ca,{children:[a," Set a valid worktree or repository, then try again."]})]}),s.jsx(Al,{children:s.jsx(yi,{className:"shell-action mt-0 shell-action--cta",onClick:()=>l(null),children:"OK"})})]})}),s.jsx(Tl,{open:u!==null,onOpenChange:T=>{!T&&!g&&(f(null),h(null),v(null))},children:s.jsxs(aa,{children:[s.jsxs(Rl,{children:[s.jsx(la,{children:"Worktree was deleted"}),s.jsxs(ca,{children:["The worktree at ",s.jsx("code",{children:u==null?void 0:u.deletedPath})," no longer exists. Recreate it",u!=null&&u.branch?s.jsxs(s.Fragment,{children:[" ","on branch ",s.jsx("code",{children:u.branch})]}):null," ","so this can open?"]})]}),k&&s.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded bg-muted p-2 text-xs text-destructive",children:k}),s.jsxs(Al,{children:[s.jsx(rd,{className:"shell-action mt-0",disabled:g,children:"No"}),s.jsx(yi,{className:"shell-action mt-0 shell-action--cta",disabled:g,onClick:T=>{T.preventDefault(),C()},children:g?"Recreating…":"Yes, recreate"})]})]})}),s.jsx(Tl,{open:b!==null,onOpenChange:T=>!T&&j(null),children:s.jsxs(aa,{children:[s.jsxs(Rl,{children:[s.jsx(la,{children:"Worktree recreated"}),s.jsx(ca,{children:b})]}),s.jsx(Al,{children:s.jsx(yi,{className:"shell-action mt-0 shell-action--cta",onClick:()=>j(null),children:"OK"})})]})})]});return{open:N,pending:e,dialogs:D}}function R_({session:e,onMarkStopped:t}){const n=T_(),r={kind:"session",id:e.sessionId},o="size-3.5",i=je("shell-action","inline-flex items-center justify-center px-2 py-1 text-xs","disabled:cursor-not-allowed disabled:opacity-50"),a="inline-flex outline-none focus-visible:ring-1 focus-visible:ring-ring rounded-sm",l=!e.resumeSupported&&!e.forkSupported;return s.jsxs(s.Fragment,{children:[s.jsx(ha,{delayDuration:200,children:s.jsxs("div",{className:"inline-flex items-center gap-1",children:[l&&s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:s.jsx("span",{tabIndex:0,className:a,children:s.jsxs("button",{type:"button",disabled:!0,"aria-disabled":!0,className:i,children:[s.jsx(Il,{className:o}),s.jsx("span",{children:"Reopen"})]})})}),s.jsx(vr,{side:"top",children:"Reopen unavailable — this agent has no resume/fork command configured"})]}),e.resumeSupported&&(e.isLive?s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:s.jsx("span",{tabIndex:0,className:a,children:s.jsxs("button",{type:"button",disabled:!0,"aria-disabled":!0,className:i,children:[s.jsx(Il,{className:o}),s.jsx("span",{children:"Resume"})]})})}),s.jsx(vr,{side:"top",children:"Session appears active — fork instead to avoid transcript corruption"})]}):s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:s.jsxs("button",{type:"button",className:i,disabled:n.pending,onClick:()=>void n.open(r,"resume"),children:[s.jsx(Il,{className:o}),s.jsx("span",{children:"Resume"})]})}),s.jsx(vr,{side:"top",children:"Continue this session in its agent (same session id, same transcript)"})]})),e.forkSupported&&s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:s.jsxs("button",{type:"button",className:i,disabled:n.pending,onClick:()=>void n.open(r,"fork"),children:[s.jsx(dO,{className:o}),s.jsx("span",{children:"Fork"})]})}),s.jsx(vr,{side:"top",children:"Branch a new session from this point — safe even when the original is still running"})]}),e.status==="active"&&s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:s.jsxs("button",{type:"button",className:i,disabled:n.pending,onClick:()=>t(e.sessionId),children:[s.jsx(qv,{className:o}),s.jsx("span",{children:"Mark stopped"})]})}),s.jsx(vr,{side:"top",children:e.resumeSupported?"Tell the dashboard this session has ended so Resume re-enables":"Tell the dashboard this session has ended"})]})]})}),n.dialogs]})}async function PY(e){const t=await fetch(`/api/agent-sessions/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"stopped"})});if(!t.ok)throw new Error(await t.text().catch(()=>"")||`HTTP ${t.status}`)}function A_({sessions:e,loading:t,error:n,onError:r,onNotice:o}){return t&&!e?null:n&&!e?s.jsx(qe,{title:"Agent Sessions",children:s.jsx(St,{title:"Couldn't load sessions",description:n})}):!e||e.length===0?s.jsx(qe,{title:"Agent Sessions",children:s.jsx(St,{title:"No agent sessions yet",description:"Sessions appear here when an agent registers one via /grab-assignment or syntaur track-session."})}):s.jsx(qe,{title:"Agent Sessions",children:s.jsx("div",{className:"space-y-2",children:e.map(i=>s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Xh,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"font-medium text-foreground",children:i.agent}),s.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground",title:i.sessionId,children:[i.sessionId.slice(0,8),s.jsx(Hr,{value:i.sessionId,onError:r}),s.jsx(S_,{sessionId:i.sessionId,disabled:!i.resumeSupported,disabledReason:"Resume not supported for this agent",onError:r,onNotice:o})]})]}),s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(kn,{status:i.status}),s.jsx("span",{className:"text-xs text-muted-foreground",children:Nr(i.started)})]}),s.jsx(R_,{session:i,onMarkStopped:a=>PY(a).catch(l=>r==null?void 0:r(l instanceof Error?l:new Error(String(l))))})]},i.sessionId))})})}const By="Cost / Usage";function P_({summary:e,error:t}){return t&&!e?s.jsx(qe,{title:By,children:s.jsx(St,{title:"Couldn't load usage",description:t})}):e?e.lastEventDay===null?s.jsx(qe,{title:By,children:s.jsx(St,{title:"No usage recorded yet",description:"Cost and token totals appear here once the usage collector records activity for this assignment."})}):s.jsx(qe,{title:By,children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(UN,{label:"Total cost",value:Ql(e.totalCost)}),s.jsx(UN,{label:"Total tokens",value:Xl(e.totalTokens)})]}),e.byModel.length>1?s.jsxs("div",{className:"space-y-1.5 border-t border-border pt-3",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"By model"}),s.jsx("div",{className:"space-y-1",children:e.byModel.map(n=>s.jsxs("div",{className:"flex items-center justify-between gap-2 text-sm",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(tm,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"truncate font-mono text-xs text-foreground",title:n.model,children:n.model})]}),s.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:[Xl(n.totalTokens)," · ",Ql(n.totalCost)]})]},n.model))})]}):null,s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last usage recorded ",x4(e.lastEventDay)]})]})}):null}function UN({label:e,value:t}){return s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:e}),s.jsx("p",{className:"text-lg font-semibold tabular-nums text-foreground",children:t})]})}function __({open:e,action:t,assignmentTitle:n,loading:r=!1,onConfirm:o,onOpenChange:i}){const[a,l]=m.useState("");m.useEffect(()=>{e||l("")},[e,t==null?void 0:t.command]);const u=m.useMemo(()=>t&&t.command==="block"?"Blocked Reason":"Reason",[t]);if(!t)return null;const f=`${t.label} "${n}"`,p=r?"Applying...":t.label,h=a.trim()||void 0;return s.jsx(Mn,{open:e,onOpenChange:g=>r?void 0:i(g),children:s.jsx(Nn,{className:"max-w-xl",children:s.jsxs("form",{className:"space-y-5",onSubmit:g=>{g.preventDefault(),o(h)},children:[s.jsxs(sr,{children:[s.jsx(Cn,{children:f}),s.jsx(ns,{children:t.description})]}),t.warning?s.jsx("div",{className:"rounded-lg border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:t.warning}):null,s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"block text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:u}),s.jsx("textarea",{value:a,onChange:g=>l(g.target.value),autoFocus:!0,rows:4,disabled:r,placeholder:"Optional context for why this assignment is blocked.",className:"editor-textarea min-h-[120px] bg-background/95 font-sans"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave this blank to continue without a written reason."})]}),s.jsxs(Wr,{children:[s.jsx("button",{type:"button",onClick:()=>i(!1),disabled:r,className:"shell-action disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"submit",disabled:r,className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:p})]})]})})})}const _Y=/^[a-z0-9][a-z0-9_-]*$/,D_=["first","last","none"];class $_ extends Error{constructor(n,r){super(n);Ux(this,"fieldErrors");this.name="AgentsConfigError",this.fieldErrors=r}}const S0={agents:[],custom:!1};let Pl=null,kl=null,_h=0;const dv=new Set;function I_(e){Pl=e;for(const t of dv)t(e)}function DY(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;if(typeof t.id!="string"||t.id.length===0||typeof t.label!="string"||typeof t.command!="string")return null;const n={id:t.id,label:t.label,command:t.command};return Array.isArray(t.args)&&t.args.every(r=>typeof r=="string")&&(n.args=t.args),typeof t.promptArgPosition=="string"&&D_.includes(t.promptArgPosition)&&(n.promptArgPosition=t.promptArgPosition),typeof t.resolveFromShellAliases=="boolean"&&(n.resolveFromShellAliases=t.resolveFromShellAliases),typeof t.default=="boolean"&&(n.default=t.default),typeof t.model=="string"&&(n.model=t.model),typeof t.playbook=="string"&&(n.playbook=t.playbook),typeof t.launchPrompt=="string"&&(n.launchPrompt=t.launchPrompt),n}function N0(e){if(!e||typeof e!="object")return S0;const t=e,n=Array.isArray(t.agents)?t.agents:[],r=[];for(const o of n){const i=DY(o);i&&r.push(i)}return{agents:r,custom:t.custom===!0}}function $Y(){if(Pl)return Promise.resolve(Pl);if(kl)return kl;const e=++_h;return kl=fetch("/api/config/agents").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{kl=null;const n=N0(t);return e!==_h?Pl??n:(Pl=n,n)}).catch(()=>(kl=null,S0)),kl}function L_(){const[e,t]=m.useState(()=>Pl??S0);return m.useEffect(()=>{let n=!1;return $Y().then(r=>{n||t(r)}),dv.add(t),()=>{n=!0,dv.delete(t)}},[]),e}async function M_(e){const t=await e.json().catch(()=>null),n=(t==null?void 0:t.error)??`HTTP ${e.status}`;return new $_(n,t==null?void 0:t.fieldErrors)}async function IY(e){++_h;const t=await fetch("/api/config/agents",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({agents:e})});if(!t.ok)throw await M_(t);const n=N0(await t.json());return I_(n),n}async function LY(){++_h;const e=await fetch("/api/config/agents",{method:"DELETE"});if(!e.ok)throw await M_(e);const t=N0(await e.json());return I_(t),t}const HN=/[A-Za-z0-9_-]/,MY=/^[a-z0-9]+(-[a-z0-9]+)*$/,VN=/(^|\s)@([A-Za-z0-9_-]+)/g,fv="assignment";function O_(e,t){const n=Math.max(0,Math.min(t,e.length));let r=n;for(;r>0&&HN.test(e[r-1]);)r--;const o=r-1;if(o<0||e[o]!=="@"||o>0&&!/\s/.test(e[o-1]))return null;let i=n;for(;i<e.length&&HN.test(e[i]);)i++;return{start:o,end:i,partial:e.slice(o+1,n)}}function F_(e,t){const n=[fv,...t.filter(a=>a!==fv)],r=e.toLowerCase();if(r==="")return n;const o=[],i=[];for(const a of n){const l=a.toLowerCase();l.startsWith(r)?o.push(a):l.includes(r)&&i.push(a)}return[...o,...i]}function z_(e,t,n){const r=`@${n}`;return{text:e.slice(0,t.start)+r+e.slice(t.end),caret:t.start+r.length}}function B_(e,t){const n=t instanceof Set?t:new Set(t),r=[];VN.lastIndex=0;let o;for(;(o=VN.exec(e))!==null;){const i=o[2];i!==fv&&(MY.test(i)?n.has(i)||r.push(`Playbook "${i}" is not installed — "@${i}" will be left as literal text.`):r.push(`"@${i}" is not a valid playbook token — it will be left as literal text.`))}return r}const WN=2e3;function OY({open:e,assignmentId:t,agentId:n,onConfirm:r,onOpenChange:o}){const[i,a]=m.useState(""),[l,u]=m.useState([]),[f,p]=m.useState(!1),[h,g]=m.useState(null),[y,k]=m.useState(0),[v,b]=m.useState(0),[j,N]=m.useState(!1),S=m.useRef(null);m.useEffect(()=>{if(!e)return;let I=!1;p(!0),g(null),N(!1);const M=new URLSearchParams({assignment:t});return n&&M.set("agent",n),fetch(`/api/launch/prompt?${M.toString()}`).then(async B=>{if(!B.ok){const W=await B.json().catch(()=>null);throw new Error((W==null?void 0:W.error)??`HTTP ${B.status}`)}return await B.json()}).then(B=>{I||(a(B.template??""),u(B.knownPlaybookSlugs??[]),k((B.template??"").length))}).catch(B=>{I||g(B instanceof Error?B.message:String(B))}).finally(()=>{I||p(!1)}),()=>{I=!0}},[e,t,n]);const C=O_(i,y),D=C?F_(C.partial,l):[],T=e&&!f&&!j&&D.length>0,R=B_(i,l),$=i.length>WN;function P(I){a(I.target.value),k(I.target.selectionStart??I.target.value.length),b(0),N(!1)}function F(I){k(I.currentTarget.selectionStart??i.length),b(0)}function _(I){if(!C||!I)return;const M=z_(i,C,I);a(M.text),k(M.caret),b(0),N(!0),requestAnimationFrame(()=>{const B=S.current;B&&(B.focus(),B.setSelectionRange(M.caret,M.caret))})}function V(I){T&&(I.key==="ArrowDown"?(I.preventDefault(),b(M=>Math.min(M+1,D.length-1))):I.key==="ArrowUp"?(I.preventDefault(),b(M=>Math.max(M-1,0))):(I.key==="Enter"||I.key==="Tab")&&(I.preventDefault(),_(D[v])))}function U(){$||f||(r(i),o(!1))}return s.jsx(Mn,{open:e,onOpenChange:o,children:s.jsxs(Nn,{onEscapeKeyDown:I=>{T&&(I.preventDefault(),N(!0))},children:[s.jsxs(sr,{children:[s.jsx(Cn,{children:"Edit launch prompt"}),s.jsxs(ns,{children:["The first message the agent starts with. ",s.jsx("code",{children:"@assignment"})," and"," ",s.jsx("code",{children:"@<playbook>"})," tokens resolve at launch. This edit applies to this launch only."]})]}),h?s.jsxs("p",{className:"text-sm text-error-foreground",children:["Couldn't load the prompt: ",h]}):s.jsxs("div",{className:"relative",children:[s.jsx("textarea",{ref:S,value:i,disabled:f,rows:4,spellCheck:!1,placeholder:f?"Loading…":"@assignment Run @<playbook> end-to-end.",onChange:P,onKeyDown:V,onKeyUp:F,onClick:F,className:je("w-full rounded-md border border-border/60 bg-background/90 p-3 font-mono text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-ring/30 min-h-[80px] resize-y",$&&"border-error-foreground")}),T&&s.jsx("ul",{role:"listbox",className:"absolute left-0 right-0 top-full z-30 mt-1 max-h-48 overflow-auto rounded-md border border-border/70 bg-background py-1 shadow-lg",children:D.map((I,M)=>s.jsx("li",{children:s.jsxs("button",{type:"button",role:"option","aria-selected":M===v,onMouseDown:B=>{B.preventDefault(),_(I)},className:je("flex w-full items-center gap-2 px-2.5 py-1.5 text-left font-mono text-sm transition-colors hover:bg-accent",M===v&&"bg-accent"),children:[s.jsx("span",{className:"text-muted-foreground",children:"@"}),s.jsx("span",{className:"truncate",children:I})]})},I))})]}),R.length>0&&!h&&s.jsx("ul",{className:"space-y-0.5 text-[11px] text-error-foreground",children:R.map(I=>s.jsx("li",{children:I},I))}),$&&s.jsxs("p",{className:"text-[11px] text-error-foreground",children:["Too long — keep it under ",WN," characters (",i.length,")."]}),s.jsxs(Wr,{children:[s.jsx("button",{type:"button",className:"shell-action mt-0",onClick:()=>o(!1),children:"Cancel"}),s.jsx("button",{type:"button",className:"shell-action mt-0 shell-action--cta",disabled:f||$||h!==null,onClick:U,children:"Launch"})]})]})})}function U_({target:e,worktreePath:t=null,repository:n=null,size:r="default",title:o}){const i=e.kind==="assignment"&&!t&&!n,a=T_(),[l,u]=m.useState(null),p=L_().agents,[h,g]=m.useState(null);m.useEffect(()=>{p.length!==0&&g(R=>R&&p.some(P=>P.id===R)?R:(p.find(P=>P.default)??p[0]).id)},[p]);const y=e.kind==="assignment"&&p.length>1,k=p.find(R=>R.id===h)??null,v=m.useRef(null),[b,j]=m.useState(!1);m.useEffect(()=>{if(!b)return;function R(P){v.current&&!v.current.contains(P.target)&&j(!1)}function $(P){P.key==="Escape"&&j(!1)}return document.addEventListener("mousedown",R),document.addEventListener("keydown",$),()=>{document.removeEventListener("mousedown",R),document.removeEventListener("keydown",$)}},[b]);function N(R){var $,P;if(e.kind==="assignment"){const F=p.find(V=>V.id===R)??p.find(V=>V.default)??p[0];!!(($=F==null?void 0:F.launchPrompt)!=null&&$.trim())||!!((P=F==null?void 0:F.playbook)!=null&&P.trim())?a.open(e,void 0,R):u({agentId:R})}else a.open(e,void 0,R)}const S=e.kind==="assignment"?"Open this assignment in your configured terminal + agent":"Resume this session in its agent",C="Set a workspace path first — see the Workspace Before Code playbook",D=je("shell-action",r==="compact"&&"inline-flex items-center justify-center px-2 py-1 text-xs","disabled:cursor-not-allowed disabled:opacity-50");if(i)return s.jsxs("button",{type:"button",disabled:!0,title:C,className:D,"aria-disabled":!0,children:[s.jsx(Il,{className:"size-3.5"}),s.jsx("span",{children:"Open in agent"})]});const T=e.kind==="session"?"Open":"Open in agent";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative inline-flex",ref:v,children:[s.jsxs("div",{className:"inline-flex items-stretch",children:[s.jsxs("button",{type:"button",onClick:()=>N(h??void 0),disabled:a.pending,title:(o??S)+(y&&k?` (${k.label})`:""),className:je(D,y&&"rounded-r-none"),children:[s.jsx(Il,{className:"size-3.5"}),s.jsx("span",{children:T})]}),y&&s.jsx("button",{type:"button",onClick:()=>j(R=>!R),disabled:a.pending,"aria-haspopup":"menu","aria-expanded":b,"aria-label":"Choose which agent to launch",title:"Choose which agent to launch",className:je(D,"-ml-px rounded-l-none",r==="compact"?"px-1":"px-1.5"),children:s.jsx(cr,{className:je("size-3.5 opacity-70 transition-transform",b&&"rotate-180")})})]}),b&&y&&s.jsxs("div",{role:"menu","aria-label":"Open with agent",className:"absolute right-0 top-full z-30 mt-1 min-w-[180px] overflow-hidden rounded-md border border-border/70 bg-background py-1 shadow-lg",children:[s.jsx("div",{className:"px-2.5 pb-1 pt-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground/70",children:"Open with agent"}),p.map(R=>s.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":R.id===h,onClick:()=>{g(R.id),j(!1),N(R.id)},className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-sm text-foreground transition-colors hover:bg-accent",children:[s.jsx(Sr,{className:je("size-3.5 shrink-0",R.id===h?"opacity-100":"opacity-0")}),s.jsx("span",{className:"truncate",children:R.label}),R.default&&s.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground/60",children:"default"})]},R.id))]})]}),a.dialogs,e.kind==="assignment"&&l&&s.jsx(OY,{open:!0,assignmentId:e.id,agentId:l.agentId,onConfirm:R=>{a.open(e,void 0,l.agentId,R)},onOpenChange:R=>{R||u(null)}})]})}const Uy="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 disabled:cursor-not-allowed disabled:opacity-50";function H_({projectSlug:e,assignmentSlug:t,assignmentId:n,defaultBranch:r,defaultParentBranch:o="main",onCreated:i}){const a=e&&t?{kind:"project-nested",projectSlug:e,assignmentSlug:t}:{kind:"standalone",assignmentId:n},[l,u]=m.useState(!1),[f,p]=m.useState("new-branch"),[h,g]=m.useState(null),[y,k]=m.useState(null),[v,b]=m.useState(""),[j,N]=m.useState(!1),[S,C]=m.useState(""),[D,T]=m.useState([]),[R,$]=m.useState(!1),[P,F]=m.useState(null),[_,V]=m.useState(""),[U,I]=m.useState(null),[M,B]=m.useState(null),[W,O]=m.useState(""),[H,L]=m.useState(r),[z,Y]=m.useState(!1),[q,Q]=m.useState(null);m.useEffect(()=>{if(!l)return;let oe=!1;return p("new-branch"),g(null),k(null),b(""),N(!1),C(""),T([]),$(!1),F(null),V(""),I(null),B(null),O(""),L(r),Q(null),(a.kind==="project-nested"?jY(a.projectSlug):kY(a.assignmentId)).then(Re=>{if(!oe)if(g(Re),Re.length===0)N(!0);else{const He=Re.find(Fe=>Fe.source==="project"),rt=Re.find(Fe=>Fe.source==="sibling");b((He==null?void 0:He.path)??(rt==null?void 0:rt.path)??Re[0].path)}}).catch(Re=>{oe||(k(Re.message),g([]),N(!0))}),(a.kind==="project-nested"?RY(a.projectSlug,a.assignmentSlug):AY(a.assignmentId)).then(Re=>{oe||I(Re)}).catch(Re=>{oe||(B(Re.message),I([]))}),()=>{oe=!0}},[l,r,o,e,t,n]);const ee=f==="branch-off"?(U??[]).find(oe=>oe.id===W)??null:null,Z=f==="branch-off"?(ee==null?void 0:ee.repository)??"":j?S.trim():v;m.useEffect(()=>{if(!l||f!=="new-branch")return;if(!Z){T([]),F(null),$(!1),V("");return}let oe=!1;return $(!0),F(null),V(""),(a.kind==="project-nested"?EY(a.projectSlug,a.assignmentSlug,Z):TY(a.assignmentId,Z)).then(be=>{if(oe)return;T(be.branches);const Re=(be.defaultBranch&&be.branches.includes(be.defaultBranch)?be.defaultBranch:be.branches.includes(o)?o:be.branches[0])??"";V(Re),$(!1)}).catch(be=>{oe||(T([]),F(be.message),$(!1))}),()=>{oe=!0}},[l,f,Z,o,e,t,n]);const ie=gY(H.trim()),ne=m.useMemo(()=>!Z||!H.trim()?"":`${Z.replace(/\/+$/,"")}/.worktrees/${H.trim()}`,[Z,H]),ue=h!==null&&h.length===0,ge=U!==null&&U.length===0,Ne=oe=>{oe!==f&&(p(oe),O(""),Q(null),oe==="branch-off"&&(V(""),T([]),F(null),$(!1)))},Ce=oe=>{O(oe);const ve=(U??[]).find(be=>be.id===oe);V((ve==null?void 0:ve.branch)??"")},ke=z||ie!==null||!Z||!_.trim()||(f==="new-branch"?h===null||R:U===null||!W),Ue=async()=>{Y(!0),Q(null);try{const oe={repository:Z,branch:H.trim(),parentBranch:_.trim()};a.kind==="project-nested"?await SY(a.projectSlug,a.assignmentSlug,oe):await NY(a.assignmentId,oe),u(!1),i()}catch(oe){oe instanceof j0?Q({message:oe.message,stderr:oe.stderr}):oe instanceof Error?Q({message:oe.message}):Q({message:String(oe)})}finally{Y(!1)}};return s.jsxs(Mn,{open:l,onOpenChange:oe=>z?void 0:u(oe),children:[s.jsxs("button",{type:"button",className:"shell-action inline-flex items-center gap-1.5",onClick:()=>u(!0),children:[s.jsx(uO,{className:"h-3.5 w-3.5","aria-hidden":"true"}),s.jsx("span",{children:"Create worktree"})]}),s.jsxs(Nn,{children:[s.jsxs(sr,{children:[s.jsx(Cn,{children:"Create worktree"}),s.jsxs(ns,{children:["Creates a git worktree at ",s.jsx("code",{children:"<repo>/.worktrees/<branch>"})," and records the workspace fields on this assignment's frontmatter."]})]}),s.jsxs("div",{className:"grid gap-4 text-sm",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-1 rounded-md border border-border/70 p-1",children:[s.jsx("button",{type:"button",disabled:z,onClick:()=>Ne("new-branch"),className:`rounded px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed ${f==="new-branch"?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"}`,children:"New branch from repo"}),s.jsx("button",{type:"button",disabled:z,onClick:()=>Ne("branch-off"),className:`rounded px-2 py-1.5 text-xs font-medium transition-colors disabled:cursor-not-allowed ${f==="branch-off"?"bg-foreground text-background":"text-muted-foreground hover:bg-muted"}`,children:"Branch off another assignment"})]}),f==="new-branch"?s.jsxs(s.Fragment,{children:[ue?s.jsxs("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-xs text-warning-foreground",children:["No repositories configured for this project. Enter a repo path below, or add a"," ",s.jsx("code",{children:"repositories:"})," list to ",s.jsx("code",{children:"project.md"}),"."]}):null,y?s.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:["Could not load repository candidates: ",y]}):null,s.jsxs("label",{className:"grid gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Repository"}),s.jsx("select",{className:Uy,value:v,onChange:oe=>b(oe.target.value),disabled:z||h===null||j,children:(h??[]).map(oe=>s.jsxs("option",{value:oe.path,children:[oe.path,oe.source==="project"?" (project)":oe.sourceAssignmentSlug?` (sibling — ${oe.sourceAssignmentSlug})`:" (sibling)"]},`${oe.source}:${oe.path}`))}),ue?null:s.jsx("button",{type:"button",className:"justify-self-start text-[11px] text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:z,onClick:()=>N(oe=>!oe),children:j?"Use a listed repository":"Enter a custom repository path (advanced)"}),j?s.jsx("input",{className:"mt-1 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",type:"text",placeholder:"/absolute/path/to/repo",value:S,onChange:oe=>C(oe.target.value),disabled:z}):null]}),s.jsxs("label",{className:"grid gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Parent branch"}),s.jsx("select",{className:Uy,value:_,onChange:oe=>V(oe.target.value),disabled:z||R||D.length===0,children:R?s.jsx("option",{value:"",children:"Loading branches…"}):D.length===0?s.jsx("option",{value:"",children:P?"Could not load branches":Z?"No branches found":"— pick a repository —"}):D.map(oe=>s.jsx("option",{value:oe,children:oe},oe))}),P?s.jsxs("span",{className:"text-[11px] text-error-foreground",children:["Could not load branches: ",P]}):null]})]}):s.jsxs(s.Fragment,{children:[M?s.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:["Could not load assignments: ",M]}):null,ge?s.jsx("div",{className:"rounded-md border border-warning-foreground/30 bg-warning px-3 py-2 text-xs text-warning-foreground",children:"No other assignments with a configured workspace to branch off. Create a worktree for one first, or use “New branch from repo”."}):s.jsxs("label",{className:"grid gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Source assignment"}),s.jsxs("select",{className:Uy,value:W,onChange:oe=>Ce(oe.target.value),disabled:z||U===null,children:[s.jsx("option",{value:"",children:"— select an assignment —"}),(U??[]).map(oe=>s.jsxs("option",{value:oe.id,children:[oe.title," (",oe.branch,")"]},oe.id))]})]}),ee?s.jsxs("div",{className:"grid gap-2 rounded-md border border-border/70 bg-muted/40 px-3 py-2 text-xs",children:[s.jsxs("div",{className:"grid gap-0.5",children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Repository (from source)"}),s.jsx("code",{className:"break-all",children:ee.repository})]}),s.jsxs("div",{className:"grid gap-0.5",children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Parent branch (from source)"}),s.jsx("code",{children:ee.branch})]})]}):null]}),s.jsxs("label",{className:"grid gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"New branch name"}),s.jsx("input",{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",type:"text",value:H,onChange:oe=>L(oe.target.value),disabled:z}),ie?s.jsx("span",{className:"text-[11px] text-error-foreground",children:ie}):null]}),s.jsxs("div",{className:"grid gap-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Worktree path"}),s.jsx("code",{className:"rounded-md border border-border bg-muted px-2 py-1 text-xs break-all",children:ne||s.jsx("span",{className:"opacity-60",children:"— pick a repo & branch —"})})]}),q?s.jsxs("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-2 text-xs text-error-foreground",children:[s.jsx("div",{className:"font-medium",children:q.message}),q.stderr?s.jsx("pre",{className:"mt-2 whitespace-pre-wrap text-[11px] opacity-90",children:q.stderr}):null]}):null]}),s.jsxs(Wr,{children:[s.jsx(zT,{disabled:z,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",disabled:ke,onClick:()=>void Ue(),className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:z?"Working…":"Create worktree"})]})]})]})}function FY(e){const t=e.split(`
620
- `),n=t.findIndex(a=>/^##\s+Acceptance Criteria\s*$/i.test(a.trim()));if(n===-1)return{acceptanceCriteria:[],summaryBody:e};let r=t.length;for(let a=n+1;a<t.length;a+=1)if(/^#{1,2}\s+\S/.test(t[a].trim())){r=a;break}const o=t.slice(n+1,r).map(a=>a.match(/^\s*[-*]\s+\[( |x|X)\]\s+(.*)$/)).filter(a=>!!a).map(a=>({checked:a[1].toLowerCase()==="x",text:a[2].trim()})),i=[...t.slice(0,n),...t.slice(r)].join(`
621
- `).replace(/\n{3,}/g,`
622
-
623
- `).trim();return{acceptanceCriteria:o,summaryBody:i}}function zY(e){const t=e.split(`
624
- `),n=t.findIndex(a=>/^##\s+Todos\s*$/i.test(a.trim()));if(n===-1)return{hasSection:!1,todosMarkdown:"",remaining:e};let r=t.length;for(let a=n+1;a<t.length;a+=1)if(/^#{1,2}\s+\S/.test(t[a].trim())){r=a;break}const o=t.slice(n+1,r).join(`
625
- `).replace(/<!--[\s\S]*?-->/g,"").replace(/\n{3,}/g,`
626
-
627
- `).trim(),i=[...t.slice(0,n),...t.slice(r)].join(`
628
- `).replace(/\n{3,}/g,`
629
-
630
- `).trim();return{hasSection:!0,todosMarkdown:o,remaining:i}}function BY({projectSlug:e,dependencies:t,blockedReason:n}){const[r,o]=m.useState(!1);if(t.length===0)return null;const i=t.filter(l=>l.status!=="completed"&&l.status!=="review"),a=i.length===0;return a&&!r?s.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:[s.jsx(em,{className:"h-4 w-4 shrink-0 text-success-foreground"}),s.jsxs("span",{className:"text-sm font-medium text-success-foreground",children:["All ",t.length," ",t.length===1?"dependency":"dependencies"," resolved"]}),s.jsx(cr,{className:"ml-auto h-4 w-4 text-success-foreground"})]}):s.jsxs("div",{className:"space-y-3",children:[i.length>0&&s.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-warning-foreground/30 bg-warning px-4 py-3",children:[s.jsx(ih,{className:"mt-0.5 h-4 w-4 shrink-0 text-warning-foreground"}),s.jsxs("div",{className:"text-sm text-warning-foreground",children:[s.jsxs("strong",{children:[i.length," ",i.length===1?"dependency is":"dependencies are"," not yet completed."]}),n&&s.jsxs("p",{className:"mt-1 text-warning-foreground/80",children:["Blocked reason: ",n]})]})]}),s.jsx(qe,{title:"Dependencies",description:`${t.length-i.length} of ${t.length} resolved`,actions:a?s.jsx("button",{type:"button",onClick:()=>o(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:"Collapse"}):void 0,children:s.jsx("div",{className:"divide-y divide-border/40",children:t.map(l=>s.jsxs(De,{to:`/projects/${e}/assignments/${l.slug}`,className:"flex items-center gap-3 px-1 py-2.5 transition hover:bg-muted/40 first:pt-0 last:pb-0",children:[s.jsx(kn,{status:l.status}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:l.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:l.slug})]}),l.assignee&&s.jsx("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:l.assignee}),s.jsx(oh,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},l.slug))})})]})}function UY({links:e}){const t=mn();if(e.length===0)return null;const n=e.filter(o=>!o.isReverse),r=e.filter(o=>o.isReverse);return s.jsx(qe,{title:"Linked Assignments",description:`${e.length} ${e.length===1?"link":"links"}`,children:s.jsxs("div",{className:"divide-y divide-border/40",children:[n.map(o=>s.jsxs(De,{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:[s.jsx(Zh,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),s.jsx(kn,{status:o.status}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.slug})]}),s.jsx(oh,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`fwd-${o.slug}`)),r.map(o=>s.jsxs(De,{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:[s.jsx(sh,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),s.jsx(kn,{status:o.status}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:o.title}),s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.slug})]}),s.jsx(oh,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},`rev-${o.slug}`))]})})}function HY(e){const t=new Map;for(const r of e)t.set(r.id,{entry:r,replies:[]});const n=[];for(const r of e){const o=t.get(r.id);r.replyTo&&t.has(r.replyTo)?t.get(r.replyTo).replies.push(o):n.push(o)}return n}function VY(e,t){return e===null?`/api/assignments/${encodeURIComponent(t)}/comments`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments`}function V_({projectSlug:e,assignmentSlug:t,entries:n}){const[r,o]=m.useState(n);m.useEffect(()=>{o(n)},[n]);const i=m.useMemo(()=>HY(r),[r]),[a,l]=m.useState(""),[u,f]=m.useState("note"),[p,h]=m.useState(!1),[g,y]=m.useState(null);async function k(b){var S;if(b.preventDefault(),!a.trim())return;h(!0),y(null);const j=`tmp-${Date.now()}`,N={id:j,timestamp:new Date().toISOString(),author:"human",type:u,body:a,resolved:u==="question"?!1:void 0};o(C=>[...C,N]);try{const C=await fetch(VY(e,t),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:a,type:u})});if(!C.ok){const R=await C.text();throw new Error(R||`HTTP ${C.status}`)}const D=await C.json().catch(()=>null),T=(S=D==null?void 0:D.comment)==null?void 0:S.id;o(R=>R.map($=>$.id===j?{...$,id:T??$.id}:$)),l(""),window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(C){y(C instanceof Error?C.message:String(C)),o(D=>D.filter(T=>T.id!==j))}finally{h(!1)}}async function v(b,j){o(N=>N.map(S=>S.id===b?{...S,resolved:j}:S));try{const N=e===null?`/api/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(b)}/resolved`:`/api/projects/${encodeURIComponent(e)}/assignments/${encodeURIComponent(t)}/comments/${encodeURIComponent(b)}/resolved`,S=await fetch(N,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({resolved:j})});if(!S.ok)throw new Error(`HTTP ${S.status}`);window.dispatchEvent(new CustomEvent("syntaur-refresh"))}catch(N){y(N instanceof Error?N.message:String(N)),o(S=>S.map(C=>C.id===b?{...C,resolved:!j}:C))}}return s.jsx(qe,{title:"Comments",description:"Threaded questions, notes, and feedback. Questions can be resolved once answered.",children:s.jsxs("div",{className:"space-y-4",children:[i.map(b=>s.jsx(W_,{node:b,onToggleResolved:v,depth:0},b.entry.id)),s.jsxs("form",{onSubmit:k,className:"mt-6 space-y-2 border-t border-border pt-4",children:[s.jsx("label",{className:"block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Add comment"}),s.jsx("textarea",{value:a,onChange:b=>l(b.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…"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:u,onChange:b=>f(b.target.value),className:"rounded border border-border bg-background px-2 py-1 text-xs",children:[s.jsx("option",{value:"note",children:"note"}),s.jsx("option",{value:"question",children:"question"}),s.jsx("option",{value:"feedback",children:"feedback"})]}),s.jsx("button",{type:"submit",disabled:p||!a.trim(),className:"shell-action",children:p?"Posting…":"Post comment"}),g?s.jsx("span",{className:"text-xs text-error-foreground",children:g}):null]})]})]})})}function W_({node:e,depth:t,onToggleResolved:n}){const{entry:r,replies:o}=e,i=r.type==="question";return s.jsxs("div",{className:je("space-y-2",t>0&&"ml-4 border-l border-border pl-4"),children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:r.id}),s.jsx("span",{children:"·"}),s.jsx("span",{children:r.timestamp}),s.jsx("span",{children:"·"}),s.jsx("span",{className:"font-medium text-foreground",children:r.author}),s.jsx("span",{children:"·"}),s.jsx("span",{className:je("rounded px-1.5 py-0.5 font-mono text-[10px] uppercase",i&&"bg-warning text-warning-foreground",r.type==="feedback"&&"bg-info text-info-foreground",r.type==="note"&&"bg-muted text-muted-foreground"),children:r.type}),i?s.jsxs("button",{type:"button",onClick:()=>n(r.id,!r.resolved),className:je("inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium",r.resolved?"bg-success text-success-foreground hover:bg-success/80":"bg-muted text-muted-foreground hover:bg-muted/80"),title:r.resolved?"Mark unresolved":"Mark resolved",children:[r.resolved?s.jsx(em,{className:"h-3 w-3"}):s.jsx(JM,{className:"h-3 w-3"}),r.resolved?"resolved":"open"]}):null,r.replyTo?s.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[s.jsx(CO,{className:"h-3 w-3"}),r.replyTo]}):null]}),s.jsx(vn,{content:r.body}),o.length>0?s.jsx("div",{className:"space-y-2",children:o.map(a=>s.jsx(W_,{node:a,depth:t+1,onToggleResolved:n},a.entry.id))}):null]})}const WY={"status-change":"Status changed","assignee-change":"Assignee changed","priority-change":"Priority changed",archived:"Archived",restored:"Restored","plan-approval":"Plan approved","fact-set":"Fact set","fact-clear":"Fact cleared",attestation:"Attestation","comment-added":"Comment added","comment-resolved":"Comment resolved"};function qY(e){return WY[e]??bn(e)}function Sl(e,t){if(!e)return null;const n=e[t];return n==null?null:typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?String(n):null}function KY({event:e}){const{details:t}=e;if(!t)return null;const n=Sl(t,"from"),r=Sl(t,"to");if(n!==null||r!==null)return s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5 text-xs",children:[n!==null?s.jsx("code",{className:"rounded bg-muted/60 px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:n}):null,s.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),r!==null?s.jsx("code",{className:"rounded bg-muted/60 px-1.5 py-0.5 font-mono text-[11px] text-foreground",children:r}):s.jsx("span",{className:"text-muted-foreground",children:"(none)"})]});const o=Sl(t,"name"),i=Sl(t,"value");if(o!==null)return s.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.jsx("span",{className:"font-medium text-foreground",children:o}),i!==null?s.jsxs(s.Fragment,{children:[": ",i]}):null]});const a=Sl(t,"reason");if(a!==null)return s.jsx("span",{className:"text-xs text-muted-foreground",children:a});const l=Sl(t,"author");if(l!==null)return s.jsxs("span",{className:"text-xs text-muted-foreground",children:["by ",s.jsx("span",{className:"font-medium text-foreground",children:l})]});const u=Object.keys(t);return u.length===0?null:s.jsx("span",{className:"text-xs text-muted-foreground",children:u.join(", ")})}function q_({events:e,loading:t,error:n}){return t&&e.length===0?s.jsx(bt,{label:"Loading activity…"}):n&&e.length===0?s.jsx(St,{title:"Activity unavailable",description:"The event log could not be loaded. The rest of this page is unaffected."}):e.length===0?s.jsx(St,{title:"No activity yet",description:"Status changes, approvals, comments, and other tracked mutations appear here as a chronological audit trail."}):s.jsx(qe,{title:"Activity",description:"Reverse-chronological audit trail of tracked changes to this assignment — who changed what, when.",children:s.jsx("ol",{className:"space-y-3",children:e.map(r=>s.jsxs("li",{className:"flex flex-col gap-1 border-l-2 border-border pl-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-[11px] font-medium text-foreground",children:qY(r.type)}),s.jsx("span",{className:"text-xs text-muted-foreground",children:r.actor}),s.jsx("span",{className:"ml-auto text-xs text-muted-foreground",title:Gv(r.at),children:Yv(r.at)})]}),s.jsx(KY,{event:r})]},r.event_id))})})}function K_(e){const t=rr();m.useEffect(()=>{const n=t.hash.slice(1);if(!n)return;let r=0,o;const i=()=>{const a=document.getElementById(n);return a?(a.scrollIntoView({block:"start"}),!0):!1};return r=requestAnimationFrame(()=>{i()||(o=setTimeout(i,80))}),()=>{cancelAnimationFrame(r),o&&clearTimeout(o)}},[t.hash,t.pathname,e])}const GY=["review","complete","shape","plan-ready","implement","unblock","start","block","fail","reopen"];function qN(){var xe,Ge,ze,lt,ht,vt,tt,_t,zt,Bt;const{slug:e,aslug:t}=qt(),n=Wt(),r=mn(),[o,i]=Ts(),[a,l]=m.useState(null),{toast:u,showToast:f,dismissToast:p}=Qn(),[h,g]=m.useState(null),[y,k]=m.useState(null),[v,b]=m.useState(null),[j,N]=m.useState(null),[S,C]=m.useState({}),[D,T]=m.useState(!1),[R,$]=m.useState(!1),[P,F]=m.useState(0),_=o.get("tab")??"summary";K_(_);const V=As(),{data:U,loading:I,error:M,refetch:B}=z4(e,t),{data:W}=H2(e),{data:O}=Jv(),{data:H,loading:L,error:z}=U4(e,t),{data:Y,loading:q,error:Q}=V4(e,t),ee=e&&t?`/api/projects/${e}/assignments/${t}/events`:null,{events:Z,loading:ie,error:ne,refetch:ue}=k_(ee),ge=m.useMemo(()=>{if(!U||!W)return[];const we=new Map(W.assignments.map(Oe=>[Oe.slug,Oe]));return U.dependsOn.map(Oe=>{const it=we.get(Oe);return{slug:Oe,title:(it==null?void 0:it.title)??Oe,status:(it==null?void 0:it.status)??"pending",priority:(it==null?void 0:it.priority)??"medium",assignee:(it==null?void 0:it.assignee)??null}})},[U,W]),Ne=ge.filter(we=>we.status!=="completed"&&we.status!=="review");Ai("assignment");const Ce=m.useMemo(()=>((W==null?void 0:W.assignments)??[]).map(we=>we.slug),[W]),ke=t?Ce.indexOf(t):-1,Ue=ke>0?Ce[ke-1]:null,oe=ke>=0&&ke<Ce.length-1?Ce[ke+1]:null,ve=`${r}/projects/${e}/assignments/${t}`;en({keys:"e",scope:"assignment",description:"Edit assignment",handler:()=>n(`${ve}/edit`)}),en({keys:"p",scope:"assignment",description:"Edit plan",handler:()=>n(`${ve}/plan/edit`)}),en({keys:"h",scope:"assignment",description:"Append handoff",handler:()=>n(`${ve}/handoff/edit`)}),en({keys:"d",scope:"assignment",description:"Append decision record",handler:()=>n(`${ve}/decision-record/edit`)}),en({keys:"s",scope:"assignment",description:"Edit scratchpad",handler:()=>n(`${ve}/scratchpad/edit`)}),en({keys:"[",scope:"assignment",description:"Previous assignment in project",enabled:!!Ue,handler:()=>Ue&&n(`${r}/projects/${e}/assignments/${Ue}`)}),en({keys:"]",scope:"assignment",description:"Next assignment in project",enabled:!!oe,handler:()=>oe&&n(`${r}/projects/${e}/assignments/${oe}`)});const be=m.useMemo(()=>U?FY(U.body):{acceptanceCriteria:[],summaryBody:""},[U]);m.useEffect(()=>{C({})},[U]);const Re=m.useMemo(()=>zY(be.summaryBody),[be.summaryBody]),He=be.acceptanceCriteria,rt=He.filter(we=>we.checked).length,Fe=He.length>0&&rt===He.length,ot=m.useRef(Fe),Nt=m.useRef(!1);if(m.useEffect(()=>{if(U){if(!Nt.current){ot.current=Fe,Nt.current=!0;return}Fe&&!ot.current&&F(we=>we+1),ot.current=Fe}},[Fe,U]),I)return s.jsx(bt,{label:"Loading assignment workspace…"});if(M||!U||!e||!t)return s.jsx(Rt,{error:M||"Assignment not found.",onRetry:B});const mt=e,at=t,ce=He.length>0?{checked:rt,total:He.length}:void 0,me=U.availableTransitions??[],Ie=me.filter(we=>!we.disabled&&we.targetStatus!==U.status),Ae=GY.map(we=>Ie.find(Oe=>Oe.command===we)).find(Boolean)??Ie[0]??null,We=[];if(O!=null&&O.sessions)for(const we of O.sessions)for(const Oe of we.windows)for(const it of Oe.panes)((xe=it.assignment)==null?void 0:xe.project)===e&&((Ge=it.assignment)==null?void 0:Ge.slug)===t&&We.push({sessionName:we.name,command:it.command,urls:it.urls});async function pt(we){l(null);try{await C_(mt,at,we),B(),ue()}catch(Oe){l(Oe.message)}}async function Pe(we){l(null);try{const Oe=await fetch(`/api/projects/${mt}/assignments/${at}/${we?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!Oe.ok){const it=await Oe.json().catch(()=>null);throw new Error((it==null?void 0:it.error)||`HTTP ${Oe.status}`)}B(),ue(),f(we?"Assignment archived":"Assignment restored","success")}catch(Oe){l(Oe.message)}}async function Qe(){$(!0);try{await xY(mt,at),n(`${r}/projects/${mt}`)}catch(we){l(we.message),$(!1),T(!1)}}async function Je(we,Oe){l(null),g(we.command);try{return await N_(mt,at,we,Oe),B(),ue(),!0}catch(it){return l(it.message),!1}finally{g(null)}}function ut(we){if(E_(we)){k(we);return}Je(we)}async function fe(we,Oe){b(null),N(we),C(it=>({...it,[we]:Oe}));try{const it=await fetch(`/api/projects/${mt}/assignments/${at}/acceptance-criteria/${we}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({checked:Oe})}),Et=await it.json();if(!it.ok)throw new Error(Et.error||`HTTP ${it.status}`);B()}catch(it){C(ln=>{const Ut={...ln};return delete Ut[we],Ut});const Et=it.message;b(Et),f(Et||"Failed to update acceptance criterion","error")}finally{N(null)}}const K=[...Ie.filter(we=>we!==Ae).map(we=>({key:`transition-${we.command}`,label:we.label,onSelect:()=>ut(we),disabled:h===we.command})),...me.filter(we=>we.disabled||we.targetStatus===U.status).map(we=>({key:`transition-${we.command}`,label:we.label,disabled:!0,disabledReason:we.targetStatus===U.status?`Already ${U.status.replace(/_/g," ")}`:we.disabledReason??we.warning??we.description})),...V.statuses.map(we=>({key:`override-${we.id}`,label:`Override → ${we.label}`,onSelect:()=>pt(we.id),disabled:we.id===U.status,disabledReason:we.id===U.status?"Already in this status":void 0})),{key:"edit-assignment",label:"Edit assignment source",icon:aO,href:`${r}/projects/${e}/assignments/${t}/edit`},{key:"edit-plan",label:"Edit plan",icon:RO,href:`${r}/projects/${e}/assignments/${t}/plan/edit`},{key:"edit-scratchpad",label:"Edit scratchpad",icon:Qx,href:`${r}/projects/${e}/assignments/${t}/scratchpad/edit`},{key:"append-handoff",label:"Append handoff",icon:oh,href:`${r}/projects/${e}/assignments/${t}/handoff/edit`},{key:"append-decision",label:"Append decision",icon:fO,href:`${r}/projects/${e}/assignments/${t}/decision-record/edit`},{key:U.archived?"unarchive":"archive",label:U.archived?"Restore assignment":"Archive assignment",icon:U.archived?rh:Qh,onSelect:()=>Pe(!U.archived)},{key:"delete",label:"Delete assignment",icon:jn,destructive:!0,onSelect:()=>T(!0)}],re=(Ae==null?void 0:Ae.command)==="review";return s.jsxs("div",{className:"space-y-5",children:[s.jsx(Xn,{toast:u,onDismiss:p}),s.jsxs("div",{className:"sticky top-12 z-20 rounded-lg border border-border/60 bg-card/90 p-3 shadow-sm backdrop-blur",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(kn,{status:U.status,progress:ce}),U.phase&&U.phase!==U.status&&s.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: ",U.phase]}),U.disposition&&U.disposition!=="active"&&s.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:U.disposition}),s.jsx(Aa,{type:U.type}),s.jsx("h1",{className:"text-lg font-semibold text-foreground",children:U.title}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Updated ",Yv(U.updated)]}),Ne.length>0&&s.jsxs("span",{className:"text-xs text-warning-foreground",children:["⚠ ",Ne.length," unmet dep",Ne.length===1?"":"s"]}),s.jsx(Qw,{externalIds:U.externalIds}),s.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[s.jsx(U_,{target:{kind:"assignment",id:U.id},worktreePath:((ze=U.workspace)==null?void 0:ze.worktreePath)??null,repository:((lt=U.workspace)==null?void 0:lt.repository)??null}),!((ht=U.workspace)!=null&&ht.worktreePath)&&e&&t&&s.jsx(H_,{projectSlug:e,assignmentSlug:t,defaultBranch:`syntaur/${e}/${t}`,onCreated:()=>B()}),Ae&&s.jsx("button",{type:"button",title:Ae.warning||Ae.description,disabled:h===Ae.command,onClick:()=>ut(Ae),className:je("shell-action disabled:cursor-not-allowed disabled:opacity-50",Ae.warning&&"border-warning-foreground/40",re&&P>0&&"send-to-review-glow"),children:s.jsx("span",{children:h===Ae.command?"Working…":Ae.label})},re?`review-${P}`:Ae.command),s.jsx(Hw,{items:K,align:"end"})]})]}),a?s.jsx("p",{className:"mt-4 rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:a}):null,U.blockedReason?s.jsxs("div",{className:"mt-4 rounded-md border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:[s.jsx("strong",{children:"Blocked reason:"})," ",U.blockedReason]}):null,U.override&&U.derived&&U.derived.derivedStatus!==U.status?s.jsxs("div",{className:"mt-4 rounded-md border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:[s.jsxs("strong",{children:["Pinned to ",U.status]})," by ",U.override.source,U.override.reason?s.jsxs(s.Fragment,{children:[" — “",U.override.reason,"”"]}):null," · ","would otherwise be ",s.jsx("strong",{children:U.derived.derivedStatus})]}):null,(vt=U.derived)!=null&&vt.nextAction?s.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:[s.jsx("span",{className:"font-medium text-foreground",children:"Next:"})," ",U.derived.nextAction]}):null]}),U.derived&&(Object.keys(U.derived.customFacts??{}).length>0||(U.derived.attestations??[]).length>0)?s.jsx(qe,{title:"Facts",description:"Custom asserted facts and review attestations, materialized server-side.",children:s.jsxs("div",{className:"space-y-3",children:[Object.keys(U.derived.customFacts??{}).length>0&&s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:Object.entries(U.derived.customFacts??{}).map(([we,Oe])=>s.jsxs("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-[11px] text-muted-foreground",children:[we,": ",s.jsx("span",{className:"font-medium text-foreground",children:String(Oe)})]},we))}),(U.derived.attestations??[]).map(we=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-[11px] font-medium text-foreground",children:we.fact}),s.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["(",we.binds,")"]}),we.records.length===0?s.jsx("span",{className:"text-[11px] text-muted-foreground",children:"— no attestations yet"}):we.records.map(Oe=>s.jsxs("span",{title:`${Oe.verdict}${Oe.note?` — ${Oe.note}`:""}${Oe.stale?" (stale — revision moved)":""} · ${Oe.at}`,className:je("rounded-full border px-2 py-0.5 text-[11px]",Oe.stale?"border-border/40 text-muted-foreground line-through":Oe.verdict==="approved"?"border-success-foreground/40 text-success-foreground":"border-warning-foreground/40 text-warning-foreground"),children:[Oe.actor,": ",Oe.verdict==="approved"?"approved":"changes",Oe.stale?" (stale)":""]},Oe.actor))]},we.fact))]})}):null,ge.length>0&&s.jsx(BY,{projectSlug:e,dependencies:ge,blockedReason:U.blockedReason}),U.enrichedLinks&&U.enrichedLinks.length>0&&s.jsx(UY,{links:U.enrichedLinks}),U.referencedBy&&U.referencedBy.length>0&&s.jsx(qe,{title:"Referenced by",description:"Other assignments whose Todos, progress, comments, or handoffs link to this one.",children:s.jsx("ul",{className:"space-y-2",children:U.referencedBy.map(we=>{const Oe=we.sourceProjectSlug===null?`/assignments/${we.sourceId}`:`${r}/projects/${we.sourceProjectSlug}/assignments/${we.sourceSlug}`;return s.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[s.jsx(De,{to:Oe,className:"text-foreground hover:text-primary",children:we.sourceTitle}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",we.mentions," mention",we.mentions===1?"":"s",")"]}),we.sourceProjectSlug===null?s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"}):null]},we.sourceId)})})}),s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]",children:[s.jsx("div",{className:"space-y-4",children:s.jsx(Um,{value:_,onValueChange:we=>i({tab:we}),items:[{value:"summary",label:"Summary",content:s.jsxs("div",{className:"space-y-5",children:[be.acceptanceCriteria.length>0?s.jsx(qe,{title:"Acceptance Criteria",description:"These checkboxes update the source assignment markdown.",children:s.jsxs("div",{className:"space-y-3",children:[v?s.jsx("p",{className:"rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:v}):null,be.acceptanceCriteria.map((we,Oe)=>{const it=j!==null,Et=Oe in S?S[Oe]:we.checked;return s.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-border/60 bg-background/80 px-3 py-3",children:[s.jsx("input",{type:"checkbox",checked:Et,disabled:it,onChange:ln=>fe(Oe,ln.target.checked),className:"mt-1 h-4 w-4 rounded border-border text-primary"}),s.jsx("span",{className:"criterion-label text-sm leading-6","data-checked":Et,children:we.text})]},`${Oe}-${we.text}`)})]})}):null,Re.hasSection?s.jsx(qe,{title:"Todos",description:"Checklist of work items from assignment.md. Links point to plan files.",children:s.jsx(vn,{content:Re.todosMarkdown,emptyState:"No todos yet."})}):null,s.jsx(qe,{title:"Assignment Summary",children:s.jsx(vn,{content:Re.remaining,emptyState:be.acceptanceCriteria.length>0||Re.hasSection?"No additional summary markdown beyond the acceptance criteria and todos.":"This assignment does not have summary markdown yet."})})]})},{value:"plan",label:"Plan",count:U.plan?1:0,content:U.plan?s.jsx("div",{className:"space-y-5",children:s.jsxs(qe,{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:s.jsxs(De,{className:"shell-action",to:`${r}/projects/${e}/assignments/${t}/plan/edit`,children:[s.jsx(Qx,{className:"h-4 w-4"}),s.jsx("span",{children:"Edit Plan"})]}),children:[s.jsx("div",{className:"mb-4",children:s.jsx(kn,{status:U.plan.status})}),s.jsx(vn,{content:U.plan.body,emptyState:"No plan content yet."})]})}):s.jsx(St,{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:U.scratchpad?1:0,content:U.scratchpad?s.jsx(qe,{title:"Scratchpad",actions:s.jsxs(De,{className:"shell-action",to:`${r}/projects/${e}/assignments/${t}/scratchpad/edit`,children:[s.jsx(Qx,{className:"h-4 w-4"}),s.jsx("span",{children:"Edit Scratchpad"})]}),children:s.jsx(vn,{content:U.scratchpad.body,emptyState:"Scratchpad is empty."})}):s.jsx(St,{title:"No scratchpad yet",description:"Scratchpad notes appear here when you use the Edit Scratchpad action."})},{value:"handoff",label:"Handoff",count:((tt=U.handoff)==null?void 0:tt.handoffCount)??0,content:s.jsx("div",{className:"space-y-5",children:U.handoff?s.jsx(qe,{children:s.jsx(vn,{content:U.handoff.body,emptyState:"No handoff history yet."})}):s.jsx(St,{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:((_t=U.progress)==null?void 0:_t.entryCount)??0,content:s.jsx("div",{className:"space-y-5",children:U.progress&&U.progress.entries.length>0?s.jsx(qe,{title:"Progress",description:"Reverse-chronological log of work done on this assignment. Agents append entries via progress.md.",children:s.jsx("ol",{className:"space-y-4",children:U.progress.entries.map((we,Oe)=>s.jsxs("li",{className:"border-l-2 border-border pl-3",children:[s.jsx("div",{className:"text-xs font-mono text-muted-foreground",children:we.timestamp}),s.jsx(vn,{content:we.body})]},`${we.timestamp}-${Oe}`))})}):s.jsx(St,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((zt=U.comments)==null?void 0:zt.entryCount)??0,content:s.jsx("div",{className:"space-y-5",children:U.comments&&U.comments.entries.length>0?s.jsx(V_,{projectSlug:e,assignmentSlug:t,entries:U.comments.entries}):s.jsx(St,{title:"No comments yet",description:"Comments appear here when agents or humans post via `syntaur comment` or the dashboard."})})},{value:"decisions",label:"Decisions",count:((Bt=U.decisionRecord)==null?void 0:Bt.decisionCount)??0,content:s.jsx("div",{className:"space-y-5",children:U.decisionRecord?s.jsx(qe,{children:s.jsx(vn,{content:U.decisionRecord.body,emptyState:"No decision history yet."})}):s.jsx(St,{title:"No decision record yet",description:"Decision records appear here when you append one via the Append Decision action."})})},{value:"activity",label:"Activity",count:Z.length,content:s.jsx(q_,{events:Z,loading:ie,error:ne})}]})}),s.jsxs("div",{className:"min-w-0 space-y-5",children:[s.jsx(qe,{title:"Details",children:s.jsxs("dl",{className:"space-y-3 text-sm",children:[s.jsx(ui,{label:"ID",value:U.id,copyable:!0}),s.jsx(ui,{label:"Priority",value:U.priority}),U.assignee&&s.jsx(ui,{label:"Assignee",value:U.assignee}),s.jsx(ui,{label:"Updated",value:`${Gv(U.updated)} · Created ${N2(U.created)}`}),U.workspace.repository&&s.jsx(ui,{label:"Repository",value:U.workspace.repository,copyable:!0}),U.workspace.worktreePath&&s.jsx(ui,{label:"Worktree",value:U.workspace.worktreePath,copyable:!0}),U.workspace.branch&&s.jsx(ui,{label:"Branch",value:U.workspace.branch,copyable:!0}),U.workspace.parentBranch&&s.jsx(ui,{label:"Parent branch",value:U.workspace.parentBranch,copyable:!0}),U.externalIds.map((we,Oe)=>s.jsx(YY,{entry:we},`${we.system}:${we.id}:${Oe}`))]})}),We.length>0&&s.jsx(qe,{title:"Servers",children:s.jsx("div",{className:"space-y-2",children:We.map((we,Oe)=>s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-sm",children:[s.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:we.command,children:we.command}),s.jsx("span",{className:"min-w-0 max-w-full truncate text-xs text-muted-foreground",title:we.sessionName,children:we.sessionName}),we.urls.map(it=>s.jsxs("a",{href:it,target:"_blank",rel:"noopener noreferrer",title:it,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:[s.jsx("span",{className:"min-w-0 truncate",children:it.replace("http://localhost:",":")}),s.jsx(mc,{className:"h-2.5 w-2.5 shrink-0"})]},it))]},Oe))})}),s.jsx(A_,{sessions:H==null?void 0:H.sessions,loading:L,error:z,onError:we=>f(we.message,"error"),onNotice:we=>f(we,"success")}),s.jsx(P_,{summary:Y==null?void 0:Y.summary,loading:q,error:Q})]})]}),s.jsx(__,{open:y!==null,action:y,assignmentTitle:U.title,loading:h===(y==null?void 0:y.command),onOpenChange:we=>{we||k(null)},onConfirm:async we=>{if(!y)return;await Je(y,we)&&k(null)}}),s.jsx(ss,{open:D,title:"Delete assignment?",description:`This will permanently delete "${U.title}" and all its files (plan, scratchpad, handoff, decision record). This cannot be undone.`,confirmLabel:"Delete Assignment",destructive:!0,loading:R,onOpenChange:we=>{we||T(!1)},onConfirm:Qe})]})}function ui({label:e,value:t,copyable:n}){return s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("dt",{className:"text-muted-foreground",children:e}),s.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[s.jsx("span",{className:"block min-w-0 truncate",title:t,children:t}),n&&t!=="—"&&s.jsx(Hr,{value:t})]})]})}function YY({entry:e}){const t=e.url!=null&&e.url.length>0;return s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("dt",{className:"text-muted-foreground",children:e.system}),s.jsx("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:t?s.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:[s.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id}),s.jsx(mc,{className:"h-2.5 w-2.5 shrink-0"})]}):s.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id})})]})}function XY(){var _,V,U,I,M,B,W,O;const{id:e}=qt(),[t,n]=Ts(),r=t.get("tab")??"summary";K_(r);const{data:o,loading:i,error:a,refetch:l}=B4(e),{data:u,loading:f,error:p}=H4(e),{data:h,loading:g,error:y}=W4(o==null?void 0:o.slug),k=e?`/api/standalone/assignments/${e}/events`:null,{events:v,loading:b,error:j,refetch:N}=k_(k),[S,C]=m.useState(!1),[D,T]=m.useState(null),{toast:R,showToast:$,dismissToast:P}=Qn();async function F(H){if(e){T(null);try{const L=await fetch(`/api/assignments/${e}/${H?"archive":"unarchive"}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!L.ok){const z=await L.json().catch(()=>null);throw new Error((z==null?void 0:z.error)||`HTTP ${L.status}`)}l(),N(),$(H?"Assignment archived":"Assignment restored","success")}catch(L){T(L instanceof Error?L.message:"Archive failed")}}}return i?s.jsx(bt,{}):a?s.jsx(Rt,{error:a}):o?s.jsxs("div",{className:"space-y-6",children:[s.jsx(Xn,{toast:R,onDismiss:P}),s.jsxs("header",{className:"space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx(kn,{status:o.status}),s.jsx(Aa,{type:o.type}),s.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:o.id}),s.jsx(Qw,{externalIds:o.externalIds}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[s.jsx(U_,{target:{kind:"assignment",id:o.id},worktreePath:((_=o.workspace)==null?void 0:_.worktreePath)??null,repository:((V=o.workspace)==null?void 0:V.repository)??null,size:"compact"}),!((U=o.workspace)!=null&&U.worktreePath)&&s.jsx(H_,{assignmentId:o.id,defaultBranch:`syntaur/${o.slug}`,onCreated:()=>l()}),s.jsxs("button",{type:"button",onClick:()=>C(!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:[s.jsx(Jh,{className:"h-3 w-3"}),"Move to workspace…"]}),s.jsx(De,{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"}),s.jsxs("button",{type:"button",onClick:()=>F(!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?s.jsx(rh,{className:"h-3 w-3"}):s.jsx(Qh,{className:"h-3 w-3"}),o.archived?"Restore":"Archive"]})]})]}),s.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:o.title}),o.blockedReason?s.jsxs("p",{className:"text-sm text-warning-foreground",children:["Blocked: ",o.blockedReason]}):null,D?s.jsx("p",{className:"text-sm text-status-failed-foreground",children:D}):null]}),o.referencedBy&&o.referencedBy.length>0?s.jsx(qe,{title:"Referenced by",description:"Other assignments whose bodies link to this one.",children:s.jsx("ul",{className:"space-y-2",children:o.referencedBy.map(H=>s.jsxs("li",{className:"flex items-center gap-2 text-sm",children:[s.jsx(De,{to:H.sourceProjectSlug===null?`/assignments/${H.sourceId}`:`/projects/${H.sourceProjectSlug}/assignments/${H.sourceSlug}`,className:"text-foreground hover:text-primary",children:H.sourceTitle}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",H.mentions," mention",H.mentions===1?"":"s",")"]})]},H.sourceId))})}):null,s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]",children:[s.jsx("div",{className:"space-y-4",children:s.jsx(Um,{value:r,onValueChange:H=>n({tab:H}),items:[{value:"summary",label:"Summary",content:s.jsx("div",{className:"space-y-5",children:s.jsx(qe,{title:"Assignment",children:s.jsx(vn,{content:o.body,emptyState:"This assignment does not have summary markdown yet."})})})},{value:"progress",label:"Progress",count:((I=o.progress)==null?void 0:I.entryCount)??0,content:s.jsx("div",{className:"space-y-5",children:o.progress&&o.progress.entries.length>0?s.jsx(qe,{title:"Progress",description:"Reverse-chronological log of work done on this assignment.",children:s.jsx("ol",{className:"space-y-4",children:o.progress.entries.map((H,L)=>s.jsxs("li",{className:"border-l-2 border-border pl-3",children:[s.jsx("div",{className:"text-xs font-mono text-muted-foreground",children:H.timestamp}),s.jsx(vn,{content:H.body})]},`${H.timestamp}-${L}`))})}):s.jsx(St,{title:"No progress entries yet",description:"Progress entries appear here as the agent appends them to progress.md."})})},{value:"comments",label:"Comments",count:((M=o.comments)==null?void 0:M.entryCount)??0,content:s.jsx("div",{className:"space-y-5",children:s.jsx(V_,{projectSlug:null,assignmentSlug:o.id,entries:((B=o.comments)==null?void 0:B.entries)??[]})})},{value:"plan",label:"Plan",content:s.jsx("div",{className:"space-y-5",children:o.plan?s.jsxs(qe,{children:[s.jsx(vn,{content:o.plan.body,emptyState:"Plan file exists but is empty."}),s.jsx("div",{className:"mt-3 flex justify-end",children:s.jsx(De,{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"})})]}):s.jsx(St,{title:"No plan file yet",description:"Create one via the CLI or `/plan-assignment`."})})},{value:"scratchpad",label:"Scratchpad",content:s.jsx("div",{className:"space-y-5",children:o.scratchpad?s.jsxs(qe,{children:[s.jsx(vn,{content:o.scratchpad.body,emptyState:"Scratchpad is empty."}),s.jsx("div",{className:"mt-3 flex justify-end",children:s.jsx(De,{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"})})]}):s.jsx(St,{title:"No scratchpad yet",description:"Scratchpad is scaffolded at assignment creation time."})})},{value:"handoff",label:"Handoff",count:((W=o.handoff)==null?void 0:W.handoffCount)??0,content:s.jsx("div",{className:"space-y-5",children:o.handoff?s.jsxs(qe,{children:[s.jsx(vn,{content:o.handoff.body,emptyState:"No handoff history yet."}),s.jsx("div",{className:"mt-3 flex justify-end",children:s.jsx(De,{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"})})]}):s.jsx(St,{title:"No handoff log yet",description:"Handoffs appear here when an agent appends one."})})},{value:"decisions",label:"Decisions",count:((O=o.decisionRecord)==null?void 0:O.decisionCount)??0,content:s.jsx("div",{className:"space-y-5",children:o.decisionRecord?s.jsxs(qe,{children:[s.jsx(vn,{content:o.decisionRecord.body,emptyState:"No decision history yet."}),s.jsx("div",{className:"mt-3 flex justify-end",children:s.jsx(De,{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"})})]}):s.jsx(St,{title:"No decision record yet",description:"Decision records appear here once appended."})})},{value:"activity",label:"Activity",count:v.length,content:s.jsx(q_,{events:v,loading:b,error:j})}]})}),s.jsxs("div",{className:"min-w-0 space-y-5",children:[s.jsx(qe,{title:"Details",children:s.jsxs("dl",{className:"space-y-3 text-sm",children:[s.jsx(di,{label:"ID",value:o.id,copyable:!0}),s.jsx(di,{label:"Priority",value:o.priority}),o.assignee&&s.jsx(di,{label:"Assignee",value:o.assignee}),s.jsx(di,{label:"Updated",value:`${Gv(o.updated)} · Created ${N2(o.created)}`}),o.workspace.repository&&s.jsx(di,{label:"Repository",value:o.workspace.repository,copyable:!0}),o.workspace.worktreePath&&s.jsx(di,{label:"Worktree",value:o.workspace.worktreePath,copyable:!0}),o.workspace.branch&&s.jsx(di,{label:"Branch",value:o.workspace.branch,copyable:!0}),o.workspace.parentBranch&&s.jsx(di,{label:"Parent branch",value:o.workspace.parentBranch,copyable:!0}),o.externalIds.map((H,L)=>s.jsx(QY,{entry:H},`${H.system}:${H.id}:${L}`))]})}),s.jsx(A_,{sessions:u==null?void 0:u.sessions,loading:f,error:p,onError:H=>$(H.message,"error"),onNotice:H=>$(H,"success")}),s.jsx(P_,{summary:h==null?void 0:h.summary,loading:g,error:y})]})]}),s.jsx(Xw,{open:S,onOpenChange:C,currentWorkspace:o.projectWorkspace,title:"Move assignment to workspace",description:"Standalone assignments belong to a project-workspace via the workspaceGroup frontmatter field.",onSubmit:async H=>{const L=await fetch(`/api/assignments/${encodeURIComponent(o.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:H})});if(!L.ok){const z=await L.json().catch(()=>({}));throw new Error(z.error||"Failed to move assignment")}l()}})]}):s.jsx(Rt,{error:"Assignment not found"})}function di({label:e,value:t,copyable:n}){return s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("dt",{className:"text-muted-foreground",children:e}),s.jsxs("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:[s.jsx("span",{className:"truncate",title:t,children:t}),n&&t!=="—"&&s.jsx(Hr,{value:t})]})]})}function QY({entry:e}){const t=e.url!=null&&e.url.length>0;return s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("dt",{className:"text-muted-foreground",children:e.system}),s.jsx("dd",{className:"flex items-center gap-1.5 max-w-[60%] text-right text-foreground break-all",children:t?s.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:[s.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id}),s.jsx(mc,{className:"h-2.5 w-2.5 shrink-0"})]}):s.jsx("span",{className:"truncate min-w-0",title:e.id,children:e.id})})]})}function JY({currentStatus:e,availableTransitions:t,onSelect:n,overrideTargets:r,onOverride:o,disabled:i=!1,className:a}){const[l,u]=m.useState(!1),[f,p]=m.useState(null),[h,g]=m.useState(0),y=m.useRef(null),k=m.useRef(null),v=m.useId(),b=As(),j=dd(b.statuses,e),N=Gb(e),S=r??[],C=t.length+S.length,D=m.useCallback(_=>{u(!1),_&&requestAnimationFrame(()=>{var V;(V=y.current)==null||V.focus()})},[]),T=m.useCallback(()=>{var V;const _=(V=y.current)==null?void 0:V.getBoundingClientRect();_&&p({top:_.top,left:_.left,width:_.width,bottom:_.bottom})},[]);m.useLayoutEffect(()=>{l&&T()},[l,T]),m.useEffect(()=>{if(!l)return;const _=()=>T();return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[l,T]),m.useEffect(()=>{if(!l)return;const _=V=>{var I,M;const U=V.target;U&&((I=k.current)!=null&&I.contains(U)||(M=y.current)!=null&&M.contains(U)||D(!1))};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[l,D]),m.useEffect(()=>{l&&g(0)},[l,C]);function R(_){return!_.disabled&&_.id!==e}function $(_){if(_<t.length){const U=t[_];U&&(n(U),D(!0));return}const V=S[_-t.length];V&&R(V)&&(o==null||o(V.id),D(!0))}function P(_){(_.key==="Enter"||_.key===" "||_.key==="ArrowDown")&&(_.preventDefault(),u(!0))}function F(_){if(C===0){_.key==="Escape"&&(_.preventDefault(),D(!0));return}_.key==="ArrowDown"?(_.preventDefault(),g(V=>(V+1)%C)):_.key==="ArrowUp"?(_.preventDefault(),g(V=>(V-1+C)%C)):_.key==="Home"?(_.preventDefault(),g(0)):_.key==="End"?(_.preventDefault(),g(C-1)):_.key==="Enter"?(_.preventDefault(),$(h)):_.key==="Escape"&&(_.preventDefault(),D(!0))}return s.jsxs(s.Fragment,{children:[s.jsxs("button",{ref:y,type:"button","data-no-drag":!0,disabled:i,"aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?v:void 0,onClick:()=>{i||u(_=>!_)},onKeyDown:P,title:`Status: ${j.label}. Click to change.`,style:j.style,className:je(qA,j.className,a,"cursor-pointer transition hover:brightness-95 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",i&&"cursor-not-allowed opacity-60"),children:[s.jsx(N,{className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 truncate",children:j.label})]}),l&&f&&typeof document<"u"?jo.createPortal(s.jsx("div",{ref:k,id:v,role:"menu",tabIndex:-1,autoFocus:!0,onKeyDown:F,style:{position:"fixed",top:f.bottom+6,left:f.left,minWidth:Math.max(f.width,180),zIndex:60},className:"rounded-md border border-border/70 bg-popover py-1 text-sm text-popover-foreground shadow-lg",children:C===0?s.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No status changes available from this status."}):s.jsxs(s.Fragment,{children:[t.map((_,V)=>{const U=Gb(_.targetStatus),I=V===h;return s.jsxs("button",{type:"button",role:"menuitem","data-no-drag":!0,onMouseEnter:()=>g(V),onClick:()=>$(V),title:_.warning||_.description,className:je("flex w-full flex-col items-stretch gap-0.5 px-3 py-1.5 text-left text-sm transition",I?"bg-foreground/5":"hover:bg-foreground/5"),children:[s.jsxs("span",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(U,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.jsx("span",{className:"truncate",children:_.label})]}),s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:Co(b,_.targetStatus)})]}),_.warning?s.jsx("span",{className:"text-[11px] leading-snug text-warning-foreground",children:_.warning}):null]},`${_.command}:${_.targetStatus}`)}),S.length>0&&t.length>0?s.jsx("div",{className:"my-1 border-t border-border/60",role:"separator"}):null,S.map((_,V)=>{const U=t.length+V,I=U===h,M=!R(_),B=dd(b.statuses,_.id);return s.jsx("button",{type:"button",role:"menuitem","data-no-drag":!0,disabled:M,onMouseEnter:()=>g(U),onClick:()=>$(U),title:M?_.disabledReason??(_.id===e?"Already in this status":void 0):`Set status to ${_.label}`,className:je("flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left text-sm transition",M?"cursor-not-allowed text-muted-foreground/60":I?"bg-foreground/5":"hover:bg-foreground/5"),children:s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{"aria-hidden":"true",className:je("h-2.5 w-2.5 flex-shrink-0 rounded-full border border-border/40",B.style?void 0:B.className),style:B.style?{backgroundColor:B.style.color}:void 0}),s.jsxs("span",{className:"truncate",children:["Override → ",_.label]})]})},`override-${_.id}`)})]})}),document.body):null]})}function G_({title:e,detailHref:t,onSave:n,disabled:r=!1}){const[o,i]=m.useState(!1);return o?s.jsx(ZY,{initialTitle:e,disabled:r,onSave:n,onExit:()=>i(!1)}):s.jsxs("div",{className:"group flex items-baseline gap-1.5",children:[s.jsx("button",{type:"button","data-no-drag":!0,disabled:r,onClick:()=>{r||i(!0)},className:je("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",r&&"cursor-not-allowed opacity-60"),title:"Click to rename",children:e}),s.jsx(De,{to:t,"data-no-drag":!0,"aria-label":"Open detail page",title:"Open detail page",onClick:a=>a.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:s.jsx(mc,{className:"h-3.5 w-3.5"})})]})}function ZY({initialTitle:e,disabled:t,onSave:n,onExit:r}){const o=m.useRef(e),[i,a]=m.useState(e),[l,u]=m.useState(!1),[f,p]=m.useState(!1),h=m.useRef(null),g=m.useRef(!1);m.useEffect(()=>{const b=h.current;b&&(b.focus(),b.select())},[]);const y=m.useCallback(()=>{var b;p(!0),window.setTimeout(()=>p(!1),260),(b=h.current)==null||b.focus()},[]),k=m.useCallback(async()=>{if(g.current)return;const b=i.trim();if(b.length===0){y();return}if(b===o.current){r();return}g.current=!0,u(!0);try{await n(b)}catch{}finally{u(!1),r()}},[i,r,n,y]);function v(b){b.key==="Enter"?(b.preventDefault(),k()):b.key==="Escape"&&(b.preventDefault(),g.current=!0,r())}return s.jsx("input",{ref:h,type:"text","data-no-drag":!0,disabled:t||l,value:i,onChange:b=>a(b.target.value),onKeyDown:v,onBlur:()=>void k(),className:je("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",f&&"syntaur-input-shake",l&&"opacity-70")})}function Y_(e){const t=Wt(),n=m.useRef(null),r=m.useRef(!1),o=m.useCallback(()=>{const a=n.current,l=!!(a!=null&&a.querySelector('[aria-expanded="true"]')),u=!!document.querySelector('[role="menu"]'),f=document.activeElement,p=!!(f&&(a!=null&&a.contains(f))&&(f.tagName==="INPUT"||f.tagName==="TEXTAREA"));r.current=l||u||p},[]),i=m.useCallback(a=>{if(r.current)return;const l=a.target;!l||l.closest(nc)||t(e)},[t,e]);return{containerRef:n,onMouseDown:o,onClick:i}}const KN=/[A-Za-z0-9_-]/;function GN(e,t){const n=Math.max(0,Math.min(t,e.length)),r=eX(e,n);if(r)return r;let o=n;for(;o>0&&KN.test(e[o-1]);)o--;let i=n;for(;i<e.length&&KN.test(e[i]);)i++;const a=e.slice(o,n),l=e.slice(0,o),u=l.match(/([A-Za-z_][A-Za-z0-9_-]*)\s*(:|>=|<=|!=|=|>|<)\s*$/);if(u)return{kind:"value",field:u[1].toLowerCase(),partial:a,tokenStart:o,tokenEnd:i};const f=l.match(/([A-Za-z_][A-Za-z0-9_-]*)\s*:\s*\([^)]*,\s*$/);return f?{kind:"value",field:f[1].toLowerCase(),partial:a,tokenStart:o,tokenEnd:i}:{kind:"field",partial:a,tokenStart:o,tokenEnd:i}}function eX(e,t){let n=-1;for(let u=t-1;u>=0;u--)if(e[u]==='"'&&(u===0||e[u-1]!=="\\")){n=u;break}if(n<0)return null;for(let u=n+1;u<t;u++)if(e[u]==='"'&&e[u-1]!=="\\")return null;let r=t;for(;r<e.length&&!(e[r]==='"'&&e[r-1]!=="\\");)r++;const o=e.slice(n+1,t),a=e.slice(0,n).match(/([A-Za-z_][A-Za-z0-9_-]*)\s*(:|>=|<=|!=|=|>|<)\s*$/);return{kind:"value",field:a?a[1].toLowerCase():"",partial:o,tokenStart:n,tokenEnd:r<e.length?r+1:r}}function tX(e,t){const n=OA(t),r=e.toLowerCase();if(r==="")return n;const o=[],i=[];for(const a of n){const l=a.toLowerCase();l.startsWith(r)?o.push(a):l.includes(r)&&i.push(a)}return[...o,...i]}function nX(e,t,n,r){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 l=r[o];(l==null?void 0:l.kind)==="bool"&&(i=["true","false"]);break}}if(!i.length)return[];const a=t.toLowerCase();return a===""?i:i.filter(l=>l.toLowerCase().startsWith(a))}function rX(e,t,n){let r;return t.kind==="field"?r=`${n}:`:r=yw(n),{text:e.slice(0,t.tokenStart)+r+e.slice(t.tokenEnd),caret:t.tokenStart+r.length}}const sX=180;function oX(e,t){const[n,r]=m.useState(e);return m.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}function iX({value:e,onChange:t,onCompiled:n,registry:r,declarations:o,valueSources:i,placeholder:a="AQL query (e.g. status:active AND priority:high)",className:l}){const u=m.useRef(null),f=m.useRef(null),p=oX(e,sX),[h,g]=m.useState([]),[y,k]=m.useState([]),[v,b]=m.useState("field"),[j,N]=m.useState(-1),[S,C]=m.useState(!1),D=m.useRef(e.length);m.useEffect(()=>{if(p.trim()===""){g([]),n==null||n(null);return}const I=Jl(p,r);I.errors.length>0?(g(I.errors),n==null||n(null)):(g([]),n==null||n(I.query))},[p,r,n]);const T=m.useCallback((I,M)=>{const B=GN(I,M);if(!B){k([]),C(!1);return}if(B.kind==="field"){const W=tX(B.partial,o);k(W),b("field"),C(W.length>0)}else{const W=nX(B.field,B.partial,i,r);k(W),b("value"),C(W.length>0)}N(-1)},[o,i,r]),R=m.useCallback(I=>{const M=I.target.value,B=I.target.selectionStart??M.length;D.current=B,t(M),T(M,B)},[t,T]),$=m.useCallback(I=>{const M=u.current,B=(M==null?void 0:M.selectionStart)??D.current,W=GN(e,B);if(!W)return;const{text:O,caret:H}=rX(e,W,I);t(O),C(!1),k([]),requestAnimationFrame(()=>{u.current&&(u.current.focus(),u.current.setSelectionRange(H,H),D.current=H)})},[e,t]),P=m.useCallback(I=>{if(!(!S||y.length===0))switch(I.key){case"ArrowDown":I.preventDefault(),N(M=>Math.min(M+1,y.length-1));break;case"ArrowUp":I.preventDefault(),N(M=>Math.max(M-1,-1));break;case"Enter":case"Tab":j>=0&&(I.preventDefault(),$(y[j]));break;case"Escape":C(!1),k([]);break}},[S,y,j,$]),F=m.useRef(null),_=m.useCallback(()=>{F.current=setTimeout(()=>C(!1),120)},[]);m.useEffect(()=>()=>{F.current!==null&&clearTimeout(F.current)},[]);const V=m.useCallback(()=>{var M;const I=((M=u.current)==null?void 0:M.selectionStart)??e.length;T(e,I)},[e,T]);m.useEffect(()=>{var I,M;S&&((M=(I=f.current)==null?void 0:I.querySelector('[aria-selected="true"]'))==null||M.scrollIntoView({block:"nearest"}))},[j,S]);const U=h.length>0&&p.trim()!=="";return s.jsxs("div",{className:`relative flex flex-col gap-1 ${l??""}`,children:[s.jsx("input",{ref:u,type:"text",value:e,onChange:R,onKeyDown:P,onBlur:_,onFocus:V,placeholder:a,"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",U?"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&&y.length>0&&s.jsx("ul",{ref:f,role:"listbox","aria-label":v==="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:y.map((I,M)=>s.jsx("li",{role:"option","aria-selected":M===j,onMouseDown:B=>{B.preventDefault(),$(I)},className:["cursor-pointer px-3 py-1.5 font-mono text-sm",M===j?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"].join(" "),children:I},I))}),U&&s.jsx("ul",{className:"space-y-0.5",role:"status","aria-live":"polite",children:h.map((I,M)=>s.jsxs("li",{className:"font-mono text-xs text-destructive",children:["at ",I.pos,": ",I.message]},M))})]})}const YN=xw;function yp(e){return e==="1"?"stale":e==="0"?"fresh":"all"}function aX(e,t){return e.toString()===t.toString()}function XN(){const{workspace:e}=qt(),t=mn(),n=Wt(),r=m.useRef(null);Ai("list:assignments");const{data:o,loading:i,error:a,refetch:l}=om(),u=As(),f=$d(),[p,h]=Ts(),g=e?`w:${e}`:null,y=x_(g),k=m.useRef(void 0),v=m.useMemo(()=>rP(u.order),[u]),b=m.useMemo(()=>{const X={};for(const te of v)X[te]=Co(u,te);return X},[v,u]),j=m.useMemo(()=>v.map(X=>({id:X,title:b[X]??X,description:Vd(X)})),[v,b]),N=m.useMemo(()=>f.definitions.map(X=>({id:X.id,title:Fl(f,X.id),description:X.description})),[f]),S="__unknown_type__",C=m.useMemo(()=>new Set(["all",...v]),[v]),D=p.get("view"),T=p.get("status"),R=p.get("stale"),$=D&&YN.includes(D)?D:"kanban";function P(X){if(!X)return[];const te=[];for(const ye of X.split(",")){const Be=ye.trim();!Be||Be==="all"||!C.has(Be)||te.includes(Be)||te.push(Be)}return te}const F=m.useCallback(X=>{h(te=>{const ye=new URLSearchParams(te);return X==="kanban"?ye.delete("view"):ye.set("view",X),ye})},[h]),[_,V]=m.useState(""),[U,I]=m.useState(()=>P(T)),[M,B]=m.useState(()=>Ve(y.filters.priority)),[W,O]=m.useState(()=>Ve(y.filters.type)),[H,L]=m.useState(()=>Ve(y.filters.assignee)),[z,Y]=m.useState(()=>Ve(y.filters.project)),[q,Q]=m.useState(()=>Ve(y.filters.tags)),[ee,Z]=m.useState(null),[ie,ne]=m.useState(()=>yp(R)),[ue,ge]=m.useState(()=>Ou({status:P(T),priority:Ve(y.filters.priority),type:Ve(y.filters.type),assignee:Ve(y.filters.assignee),project:Ve(y.filters.project),tags:Ve(y.filters.tags),activity:yp(R)})),[Ne,Ce]=m.useState(()=>y.sortField),[ke,Ue]=m.useState(()=>y.sortDirection),[oe,ve]=m.useState(()=>({hidden:[]})),[be,Re]=m.useState(()=>({hidden:[]})),[He,rt]=m.useState(()=>y.grouping),Fe=He==="type"?"type":"status",[ot,Nt]=m.useState(()=>new Set),[mt,at]=m.useState([]),{toast:ce,showToast:me,dismissToast:Ie}=Qn(),[Ae,We]=m.useState(null),[pt,Pe]=m.useState(null),[Qe,Je]=m.useState(null),[ut,fe]=m.useState(null),[K,re]=m.useState(null),[xe,Ge]=m.useState(null),[ze,lt]=m.useState(null),[ht,vt]=m.useState(null),[tt,_t]=m.useState(null),[zt,Bt]=m.useState(!1),[we,Oe]=m.useState(!1),it=e?{kind:"workspace",workspace:e}:{kind:"global"},Et=p.get("loadView"),{view:ln,loading:Ut,error:le}=ki(Et),{view:Se,loading:nt,error:Tn}=ki(tt),Er=m.useRef(null);m.useEffect(()=>{at((o==null?void 0:o.assignments)??[])},[o]),m.useEffect(()=>{tt&&!nt&&!Tn&&!Se&&_t(null)},[Se,Tn,tt,nt]),m.useEffect(()=>{_t(null),Er.current=null,Z(null),V("")},[e]);const so=m.useRef({status:T,stale:R});m.useEffect(()=>{const X=P(T),te=yp(R);O6(X,U)||I(X),te!==ie&&ne(te);const ye=so.current,Be=ye.status!==T||ye.stale!==R;so.current={status:T,stale:R},Be&&nn({status:X,activity:te})},[ie,R,U,T]),m.useEffect(()=>{k.current===g&&h(X=>{const te=new URLSearchParams(X);return U.length===0?te.delete("status"):te.set("status",U.join(",")),ie==="all"?te.delete("stale"):ie==="stale"?te.set("stale","1"):te.set("stale","0"),aX(X,te)?X:te})},[ie,g,h,U]),m.useEffect(()=>{B(Ve(y.filters.priority)),O(Ve(y.filters.type)),L(Ve(y.filters.assignee)),Y(Ve(y.filters.project)),Q(Ve(y.filters.tags)),Ce(y.sortField),Ue(y.sortDirection),rt(y.grouping)},[y.filters.priority,y.filters.type,y.filters.assignee,y.filters.project,y.filters.tags,y.sortField,y.sortDirection,y.grouping]),m.useEffect(()=>{if(k.current===g)return;let X=!1;return w0().then(te=>{if(X||k.current===g)return;const ye=HT(te,g),Be=ye.defaultView,yt=Ve(ye.filters.status),Tt=ye.filters.activity??"all",Dt=new URLSearchParams(window.location.search);let An=!1;const zn=new URLSearchParams(Dt);Dt.get("view")===null&&Be!=="kanban"&&YN.includes(Be)&&(zn.set("view",Be),An=!0),Dt.get("status")===null&&yt.length>0&&(zn.set("status",yt.join(",")),I(yt),An=!0),Dt.get("stale")===null&&Tt!=="all"&&(zn.set("stale",Tt==="stale"?"1":"0"),ne(Tt),An=!0),An&&h(zn,{replace:!0});const Pn=P(zn.get("status")),Rr=zn.get("stale")===null?Tt:yp(zn.get("stale"));ge(Ou({status:Pn,priority:Ve(ye.filters.priority),type:Ve(ye.filters.type),assignee:Ve(ye.filters.assignee),project:Ve(ye.filters.project),tags:Ve(ye.filters.tags),activity:Rr==="fresh"||Rr==="stale"?Rr:"all"})),queueMicrotask(()=>{k.current=g})}),()=>{X=!0}},[g]);const wt=m.useCallback(X=>{(g===null?b_(X):v_(g,X)).catch(ye=>{console.warn("Failed to persist view prefs:",ye)})},[g]),_i=m.useCallback(X=>{F(X),wt({defaultView:X})},[F,wt]),$o=m.useRef(null);$o.current={status:U,priority:M,type:W,assignee:H,project:z,tags:q,activity:ie,dateRange:ee,search:_};const $a=m.useCallback((X={})=>{const te=$o.current;return{status:te.status,priority:te.priority,type:te.type,assignee:te.assignee,project:te.project,tags:te.tags,activity:te.activity,dateRange:ma(te.dateRange),search:te.search,...X}},[]),nn=m.useCallback((X={})=>{ge(Ou($a(X)))},[$a]),Io=m.useCallback(X=>{I(X),wt({filters:{status:X}}),nn({status:X})},[wt,nn]),Ia=m.useCallback(X=>{B(X),wt({filters:{priority:X}}),nn({priority:X})},[wt,nn]),La=m.useCallback(X=>{O(X),wt({filters:{type:X}}),nn({type:X})},[wt,nn]),$c=m.useCallback(X=>{L(X),wt({filters:{assignee:X}}),nn({assignee:X})},[wt,nn]),Ma=m.useCallback(X=>{Y(X),wt({filters:{project:X}}),nn({project:X})},[wt,nn]),Ht=m.useCallback(X=>{Q(X),wt({filters:{tags:X}}),nn({tags:X})},[wt,nn]),Di=m.useCallback(X=>{ne(X),wt({filters:{activity:X}}),nn({activity:X})},[wt,nn]),oo=m.useCallback(X=>{V(X),nn({search:X})},[nn]),Lo=m.useCallback(X=>{Z(X),nn({dateRange:ma(X)})},[nn]),Ds=m.useCallback(X=>{Ce(X),wt({sortField:X})},[wt]),Mo=m.useCallback(X=>{Ue(X),wt({sortDirection:X})},[wt]),Oa=m.useCallback(X=>{rt(X),wt({grouping:X})},[wt]),Oo=m.useCallback(()=>{oo(""),Io([]),Ht([]),Lo(null),Di("all")},[oo,Io,Ht,Lo,Di]),ir=m.useCallback(X=>{ge(X);const te=Fu(X);te&&(I(Ve(te.status)),B(Ve(te.priority)),O(Ve(te.type)),L(Ve(te.assignee)),Y(Ve(te.project)),Q(Ve(te.tags)),V(te.search??""),ne(te.activity&&te.activity!=="all"?te.activity:"all"),Z(Om(te.dateRange)))},[]),dr=m.useMemo(()=>Fu(ue)!==null,[ue]),On=m.useCallback(()=>{const te=Fu(ue)!==null?{status:U,priority:M,type:W,assignee:H,project:z,tags:q,activity:ie,dateRange:ma(ee),search:_}:{};return{viewMode:$,filters:{...te,query:ue},sortField:Ne,sortDirection:ke,listSectionVisibility:{collapsed:[...ot]},kanbanColumnVisibility:oe,tableColumnVisibility:be}},[$,ue,U,M,W,H,z,q,ie,ee,_,Ne,ke,ot,oe,be]),Fo=m.useCallback(X=>{XA(X,{setViewMode:F,setQuery:ge,setStatusFilter:te=>{I(te),wt({filters:{status:te}})},setPriorityFilter:te=>{B(te),wt({filters:{priority:te}})},setTypeFilter:te=>{O(te),wt({filters:{type:te}})},setAssigneeFilter:te=>{L(te),wt({filters:{assignee:te}})},setProjectFilter:te=>{Y(te),wt({filters:{project:te}})},setTagsFilter:te=>{Q(te),wt({filters:{tags:te}})},setActivityFilter:te=>{ne(te),wt({filters:{activity:te}})},setDateRange:Z,setSearch:V,setSortField:Ds,setSortDirection:Mo,setListSectionVisibility:te=>Nt(new Set(te.collapsed)),setKanbanColumnVisibility:ve,setTableColumnVisibility:Re}),_t(X.id)},[F,wt,Ds,Mo]),Ic=m.useCallback(X=>{Fo(X),Er.current=X.id,h(te=>{const ye=new URLSearchParams(te);return ye.set("loadView",X.id),ye},{replace:!0})},[Fo,h]),Lc=m.useCallback(async X=>{try{const te=rc({name:X,context:{workspace:e??null,projectSlug:null},state:On()}),ye=await Zl(te),Be=ye.views[ye.views.length-1];_t((Be==null?void 0:Be.id)??null),Be&&(Er.current=Be.id,h(yt=>{const Tt=new URLSearchParams(yt);return Tt.set("loadView",Be.id),Tt},{replace:!0})),Bt(!1),Oe(!1),me(`Saved view "${X}"`,"success")}catch(te){throw me(te instanceof Error?te.message:"Failed to save view","error"),te}},[On,h,me,e]),zo=m.useCallback(async()=>{if(!(!tt||!Se))try{const X=rc({name:Se.name,context:{workspace:e??null,projectSlug:null},state:On()}),te=Nh(Se.config,X.config,X.config);await vh(tt,{config:te}),me("View updated","success")}catch(X){me(X instanceof Error?X.message:"Failed to update view","error")}},[On,Se,tt,me,e]);m.useEffect(()=>{if(!Et){Er.current=null;return}if(Er.current!==Et&&(tt&&tt!==Et&&_t(null),!Ut)){if(le){me("Couldn't load saved view — try again","error");return}if(ln){Er.current=Et,Fo(ln),h(X=>{const te=new URLSearchParams(X);return te.delete("loadView"),te},{replace:!0});return}Er.current=Et,me("Saved view no longer exists","error"),h(X=>{const te=new URLSearchParams(X);return te.delete("loadView"),te},{replace:!0})}},[Et,ln,Ut,le,tt,Fo,h,me]);const Wn=m.useMemo(()=>mt.filter(X=>e?e==="_ungrouped"?X.projectWorkspace===null:X.projectWorkspace===e:!0),[mt,e]),io=m.useMemo(()=>Array.from(new Set(Wn.map(X=>X.status))).sort(),[Wn]),qr=m.useMemo(()=>Array.from(new Set(Wn.map(X=>X.priority))).sort(),[Wn]),Fa=m.useMemo(()=>Array.from(new Set(Wn.map(X=>X.assignee??"__unassigned__"))).sort(),[Wn]),$i=m.useMemo(()=>Array.from(new Map(Wn.filter(X=>X.projectSlug!==null).map(X=>[X.projectSlug,X.projectTitle]))).sort(([,X],[,te])=>X.localeCompare(te)),[Wn]),Bo=m.useMemo(()=>Array.from(new Set(Wn.flatMap(X=>X.tags??[]))).sort(),[Wn]),Uo=m.useMemo(()=>MA(u.factDeclarations),[u.factDeclarations]),$s=m.useMemo(()=>ue.trim()===""?null:Jl(ue,Uo).query,[ue,Uo]),Fn=m.useMemo(()=>IA(mt,$s,{workspace:e}),[mt,$s,e]),Rn=m.useMemo(()=>Hd(Fn,Ne,ke),[Fn,Ne,ke]),Is=m.useMemo(()=>{if(He==="none")return[{id:"__all__",label:"All assignments",items:Rn}];if(He==="type"){const X=f.definitions.map(Be=>({id:Be.id,label:Fl(f,Be.id),items:Rn.filter(yt=>yt.type===Be.id)})),te=new Set(f.definitions.map(Be=>Be.id)),ye=Rn.filter(Be=>!Be.type||!te.has(Be.type));return ye.length>0&&X.push({id:S,label:"Other",items:ye}),X}if(He==="priority")return["critical","high","medium","low"].map(te=>({id:te,label:te.charAt(0).toUpperCase()+te.slice(1),items:Rn.filter(ye=>ye.priority===te)}));if(He==="assignee")return Array.from(new Set(Rn.map(te=>te.assignee??"__unassigned__"))).sort().map(te=>({id:te,label:te==="__unassigned__"?"Unassigned":te,items:Rn.filter(ye=>(ye.assignee??"__unassigned__")===te)}));if(He==="project"){const X=new Map;for(const te of Rn){const ye=te.projectSlug??"__standalone__",Be=te.projectTitle??"Standalone";X.has(ye)||X.set(ye,Be)}return Array.from(X.entries()).sort(([,te],[,ye])=>te.localeCompare(ye)).map(([te,ye])=>({id:te,label:ye,items:Rn.filter(Be=>(Be.projectSlug??"__standalone__")===te)}))}return v.map(X=>({id:X,label:b[X]??X,items:Rn.filter(te=>te.status===X)}))},[He,Rn,f,v,b]),Ot=m.useMemo(()=>{const X=new Set(f.definitions.map(ye=>ye.id));return Fn.some(ye=>!ye.type||!X.has(ye.type))?[...N,{id:S,title:"Other",description:"Assignments with no recognized type."}]:N},[N,f,Fn]),{visibleItems:tf,visibleIndexByKey:Mc}=m.useMemo(()=>{let X;if($==="table")X=Rn;else if($==="kanban"){const ye=new Set(f.definitions.map(Be=>Be.id));Fe==="type"?X=[...f.definitions.flatMap(Be=>Fn.filter(yt=>yt.type===Be.id)),...Fn.filter(Be=>!Be.type||!ye.has(Be.type))]:X=v.flatMap(Be=>Fn.filter(yt=>yt.status===Be))}else X=Is.flatMap(ye=>ye.items);const te=new Map;return X.forEach((ye,Be)=>te.set(xn(ye),Be)),{visibleItems:X,visibleIndexByKey:te}},[$,Rn,Is,Fe,f,Fn,v]),{hotkeyRowProps:Ii}=Id(tf,{scope:"list:assignments",onOpen:X=>{if(X.projectSlug===null){n(`/assignments/${X.id}`);return}const te=X.projectWorkspace?`/w/${X.projectWorkspace}`:t;n(`${te}/projects/${X.projectSlug}/assignments/${X.slug}`)}});if(en({keys:"/",scope:"list:assignments",description:"Focus filter",handler:()=>{var X;return(X=r.current)==null?void 0:X.focus()}}),en({keys:"r",scope:"list:assignments",description:"Refresh",handler:()=>l()}),i)return s.jsx(bt,{label:"Loading assignments board…"});if(a||!o)return s.jsx(Rt,{error:a||"Assignments board is unavailable.",onRetry:l});async function Oc({item:X,toColumnId:te,action:ye,reason:Be}){if(!ye){const Tt=u.statuses.find(Dt=>Dt.id===te);if(Kb(Tt??{id:te}))return me(`Reach “${Co(u,te)}” through its complete/fail transition.`,"error"),!1}We(xn(X));const yt=mt;at(Tt=>Tt.map(Dt=>xn(Dt)===xn(X)?{...Dt,status:te,blockedReason:te==="blocked"?Be??Dt.blockedReason:null}:Dt));try{const Tt=X.projectSlug===null?ye?await yY(X.id,ye,Be):await bY(X.id,te):ye?await N_(X.projectSlug,X.slug,ye,Be):await C_(X.projectSlug,X.slug,te);return at(Dt=>Dt.map(An=>xn(An)===xn(X)?{...An,status:Tt.status,blockedReason:Tt.blockedReason,availableTransitions:Tt.availableTransitions,updated:Tt.updated}:An)),l(),me(`Moved to ${Co(u,Tt.status)}`,"success"),!0}catch(Tt){return at(yt),me(Tt.message,"error"),!1}finally{We(null)}}async function ao({item:X,toColumnId:te,action:ye}){if(X.status===te)return;const Be=ye??ju(X,te);if(Be!=null&&Be.disabled){me(Be.disabledReason||`Cannot move this assignment to ${te}.`,"error");return}if(Be&&E_(Be)){fe({item:X,toColumnId:te,action:Be});return}await Oc({item:X,toColumnId:te,action:Be})}function Fc(X){return VA(u).map(te=>te.id===X.status?{id:te.id,label:te.label,disabled:!0,disabledReason:"Already in this status"}:te.terminal&&!X.availableTransitions.find(Be=>Be.targetStatus===te.id&&!Be.disabled)?{id:te.id,label:te.label,disabled:!0,disabledReason:`Reach ${te.label} via its transition when available`}:{id:te.id,label:te.label})}function za(X,te){ao({item:X,toColumnId:te})}async function Ho(X,te){if(te===X.title)return;const ye=xn(X),Be=mt;at(yt=>yt.map(Tt=>xn(Tt)===ye?{...Tt,title:te}:Tt)),We(ye);try{const yt=X.projectSlug===null?await wY({id:X.id,title:te}):await vY({projectSlug:X.projectSlug,assignmentSlug:X.slug,title:te});at(Tt=>Tt.map(Dt=>xn(Dt)===ye?{...Dt,title:yt.title,updated:yt.updated}:Dt)),l()}catch(yt){throw at(Be),me(yt.message,"error"),yt}finally{We(null)}}function Ls(X){Nt(te=>{const ye=new Set(te);return ye.has(X)?ye.delete(X):ye.add(X),ye})}function Ms(X){Ne===X?Mo(ke==="asc"?"desc":"asc"):(Ds(X),Mo("asc"))}const pn=pt?mt.find(X=>xn(X)===pt)??null:null;function Li(X,te){X.dataTransfer.effectAllowed="move",X.dataTransfer.setData("text/plain",te),Pe(te)}function lo(){Pe(null),Je(null)}function Os(X,te){if(!pn)return;const ye=ju(pn,te);pn.status===te||ye!=null&&ye.disabled||(X.preventDefault(),X.dataTransfer.dropEffect="move",Je(te))}function mg(X,te){Qe===te&&!X.currentTarget.contains(X.relatedTarget)&&Je(null)}function nf(X,te){if(X.preventDefault(),!pn||pn.status===te){lo();return}lo(),ao({item:pn,toColumnId:te})}function Tr({field:X,children:te}){const ye=Ne===X;return s.jsx("th",{className:"pb-3 font-medium",children:s.jsxs("button",{type:"button",onClick:()=>Ms(X),className:"inline-flex items-center gap-1 hover:text-foreground",children:[te,ye?ke==="asc"?s.jsx(u2,{className:"h-3 w-3"}):s.jsx(cr,{className:"h-3 w-3"}):null]})})}return s.jsxs("div",{className:"space-y-5","data-density":y.density,children:[s.jsx("div",{className:"flex items-center justify-end",children:s.jsxs(De,{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:[s.jsx(Mt,{className:"h-4 w-4"}),"New Assignment"]})}),s.jsxs(Gw,{children:[s.jsx(iX,{className:"w-full md:min-w-[320px] md:flex-1",value:ue,onChange:ir,registry:Uo,declarations:u.factDeclarations,valueSources:{statuses:u.order,priorities:qr,types:f.definitions.map(X=>X.id),assignees:Fa.filter(X=>X!=="__unassigned__"),projects:$i.map(([X])=>X),tags:Bo}}),dr?null:s.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"}),s.jsx(Fm,{ref:r,value:_,onChange:dr?oo:()=>{},placeholder:"Search assignments or projects"}),s.jsx(wn,{ariaLabel:"Status filter",className:"max-w-[180px]",allLabel:"All statuses",disabled:!dr,options:io.map(X=>({value:X,label:b[X]??X})),value:U,onChange:Io}),s.jsx(wn,{ariaLabel:"Priority filter",className:"max-w-[180px]",allLabel:"All priorities",disabled:!dr,options:qr.map(X=>({value:X,label:X[0].toUpperCase()+X.slice(1)})),value:M,onChange:Ia}),s.jsx(wn,{ariaLabel:"Type filter",className:"max-w-[180px]",allLabel:"All types",disabled:!dr,options:f.definitions.map(X=>({value:X.id,label:Fl(f,X.id)})),value:W,onChange:La}),s.jsx(wn,{ariaLabel:"Assignee filter",className:"max-w-[180px]",allLabel:"All assignees",disabled:!dr,options:[{value:"__unassigned__",label:"Unassigned"},...Fa.filter(X=>X!=="__unassigned__").map(X=>({value:X,label:X}))],value:H,onChange:$c}),s.jsx(wn,{ariaLabel:"Project filter",className:"max-w-[180px]",allLabel:"All projects",disabled:!dr,options:[{value:"__standalone__",label:"Standalone"},...$i.map(([X,te])=>({value:X,label:te}))],value:z,onChange:Ma}),s.jsx(wn,{ariaLabel:"Tags filter",className:"max-w-[180px]",allLabel:"Any tags",disabled:!dr,options:Bo.map(X=>({value:X,label:X})),value:q,onChange:Ht}),s.jsx(Mm,{className:"max-w-[200px]",value:ee,onChange:dr?Lo:()=>{}}),s.jsxs("select",{value:ie,disabled:!dr,onChange:X=>Di(X.target.value),className:"editor-input max-w-[180px]","aria-label":"Filter by activity",title:"Filter by activity",children:[s.jsx("option",{value:"all",children:"All activity"}),s.jsx("option",{value:"stale",children:"Stale only"}),s.jsx("option",{value:"fresh",children:"Fresh only"})]}),s.jsx("select",{value:$==="kanban"?Fe:He,onChange:X=>Oa(X.target.value),className:"editor-input max-w-[180px]",title:"Group by",children:L6.map(X=>{const te=$==="kanban"&&X!=="status"&&X!=="type",ye=X==="none"?"No grouping":`Group: ${X.charAt(0).toUpperCase()+X.slice(1)}`;return s.jsx("option",{value:X,disabled:te,children:te?`${ye} (list only)`:ye},X)})}),s.jsx(zm,{value:$,onChange:X=>_i(X),options:[{value:"table",label:"Table"},{value:"list",label:"List"},{value:"kanban",label:"Kanban"}]}),$==="table"?s.jsx(h_,{visibility:be,onChange:Re}):null,s.jsx(j_,{scope:it,loadedViewId:tt,onApply:Ic,onOpenSaveDialog:()=>{Oe(!1),Bt(!0)}}),s.jsx("button",{type:"button",onClick:()=>{Se?zo():(Oe(!1),Bt(!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:Se?`Update ${Se.name}`:"Save current view",children:Se?`Update '${Se.name}'`:"Save view"}),Se?s.jsx("button",{type:"button",onClick:()=>{Oe(!0),Bt(!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?s.jsx(St,{title:"No assignments yet",description:"Assignments appear here once projects contain concrete work items.",actions:s.jsxs(De,{className:"shell-action shell-action--cta",to:`${t}/projects`,children:[s.jsx(Bv,{className:"h-4 w-4"}),s.jsx("span",{children:"Browse Projects"})]})}):Fn.length===0?s.jsx(St,{title:"No assignments match these filters",description:"Adjust the search term or filters to show assignments across all projects again.",actions:s.jsxs("button",{type:"button",onClick:Oo,className:"shell-action shell-action--cta",children:[s.jsx(lO,{className:"h-4 w-4"}),s.jsx("span",{children:"Clear all filters"})]})}):$==="table"?(()=>{const X=new Set(be.hidden),te=ye=>ye==="title"||!X.has(ye);return s.jsx(qe,{title:`${Rn.length} assignment${Rn.length===1?"":"s"}`,children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[te("title")?s.jsx(Tr,{field:"title",children:"Assignment"}):null,te("status")?s.jsx(Tr,{field:"status",children:"Status"}):null,s.jsx("th",{className:"py-2 pr-4 text-xs font-medium uppercase tracking-wider",children:"Type"}),te("priority")?s.jsx(Tr,{field:"priority",children:"Priority"}):null,te("assignee")?s.jsx(Tr,{field:"assignee",children:"Assignee"}):null,te("dependencies")?s.jsx(Tr,{field:"dependencies",children:"Dependencies"}):null,te("created")?s.jsx(Tr,{field:"created",children:"Created"}):null,te("updated")?s.jsx(Tr,{field:"updated",children:"Updated"}):null]})}),s.jsx("tbody",{children:Rn.map((ye,Be)=>s.jsxs(cX,{detailHref:ud(ye),className:"cursor-pointer border-b border-border/50 transition hover:bg-muted/40 last:border-0",...Ii(Be),children:[te("title")?s.jsxs("td",{className:"py-4 pr-4",children:[s.jsx(G_,{title:ye.title,detailHref:ud(ye),onSave:yt=>Ho(ye,yt),disabled:Ae===xn(ye)}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:ye.projectTitle??s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"})}),s.jsxs("p",{className:"mt-0.5 inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:ye.id,children:[ye.id.slice(0,8),s.jsx(Hr,{value:ye.id})]})]}):null,te("status")?s.jsx("td",{className:"py-4 pr-4",children:s.jsx("select",{value:ye.status,disabled:Ae===xn(ye),onChange:yt=>ao({item:ye,toColumnId:yt.target.value}),className:je("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")]`,dd(u.statuses,ye.status).className,Ae===xn(ye)&&"animate-pulse opacity-60"),style:dd(u.statuses,ye.status).style,children:v.map(yt=>{const Tt=ye.status===yt,Dt=Tt?void 0:ju(ye,yt),An=u.statuses.find(Vo=>Vo.id===yt),zn=!Tt&&Kb(An??{id:yt})&&!Dt,Pn=((Dt==null?void 0:Dt.disabled)??!1)||zn,Rr=zn?`Reach ${b[yt]??yt} via its transition when available`:(Dt==null?void 0:Dt.disabledReason)??void 0;return s.jsx("option",{value:yt,disabled:Pn,title:Pn?Rr:void 0,children:b[yt]},yt)})})}):null,s.jsx("td",{className:"py-4 pr-4",children:s.jsx(Aa,{type:ye.type,compact:!0})}),te("priority")?s.jsx("td",{className:"py-4 pr-4 capitalize text-muted-foreground",children:ye.priority}):null,te("assignee")?s.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:ye.assignee??"Unassigned"}):null,te("dependencies")?s.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:ye.dependsOn.length}):null,te("created")?s.jsx("td",{className:"py-4 pr-4 text-muted-foreground",children:Yn(ye.created)}):null,te("updated")?s.jsx("td",{className:"py-4 text-muted-foreground",children:Yn(ye.updated)}):null]},xn(ye)))})]})})})})():$==="list"?s.jsx("div",{className:"space-y-3",children:Is.map(({id:X,label:te,items:ye})=>{var zn;if(ye.length===0&&!(pn&&He==="status"))return null;const Be=!ot.has(X),yt=He==="status",Tt=yt&&pn?pn.status!==X&&!((zn=ju(pn,X))!=null&&zn.disabled):!1,Dt=yt&&pn?pn.status!==X&&!Tt:!1,An=yt&&Qe===X;return s.jsxs("div",{className:je("rounded-lg border border-border/60 bg-card/90 transition",An&&Tt&&"ring-2 ring-ring/30",Dt&&"border-dashed opacity-65"),onDragOver:yt?Pn=>Os(Pn,X):void 0,onDragLeave:yt?Pn=>mg(Pn,X):void 0,onDrop:yt?Pn=>nf(Pn,X):void 0,children:[s.jsxs("button",{type:"button",onClick:()=>Ls(X),className:"flex w-full items-center gap-2 px-4 py-3 text-left",children:[s.jsx(cr,{className:`h-4 w-4 text-muted-foreground transition-transform ${Be?"":"-rotate-90"}`}),s.jsx("span",{className:"font-semibold text-foreground",children:te}),s.jsx("span",{className:"rounded-full border border-border/60 px-2 py-0.5 text-xs text-muted-foreground",children:ye.length})]}),Be&&ye.length>0&&s.jsx("div",{className:"space-y-3 px-4 pb-4",children:ye.map(Pn=>{const Rr=xn(Pn),Vo=pt===Rr,Mi=Mc.get(Rr)??-1,Wo=yt;return s.jsx("div",{draggable:Wo,onDragStart:Wo?is=>Li(is,Rr):void 0,onDragEnd:Wo?lo:void 0,...Mi>=0?Ii(Mi):{},className:je("transition",Wo&&"cursor-grab active:cursor-grabbing",Vo&&"scale-[0.98] opacity-50"),children:s.jsx(QN,{assignment:Pn,dragging:Vo,transitioning:Ae===Rr,onPillSelect:is=>void ao({item:Pn,toColumnId:is.targetStatus,action:is}),overrideTargets:Fc(Pn),onOverride:is=>za(Pn,is),onRenameTitle:is=>Ho(Pn,is)})},Rr)})})]},X)})}):s.jsx(Lm,{columns:Fe==="type"?Ot:j,items:Fn,getItemId:xn,getColumnId:X=>Fe==="type"?X.type&&f.definitions.some(te=>te.id===X.type)?X.type:S:X.status,canDrop:({item:X,fromColumnId:te,toColumnId:ye})=>{if(te===ye)return{allowed:!0};const Be=ju(X,ye);return Be!=null&&Be.disabled?{allowed:!1,reason:Be.disabledReason||Be.description}:{allowed:!0,reason:Be?Be.warning||Be.description:`Move to ${ye} (direct status change).`}},onMove:Fe==="type"?void 0:({item:X,toColumnId:te})=>ao({item:X,toColumnId:te}),dragDisabled:Fe==="type",getExternalDragData:X=>X.projectSlug===null?{type:"standalone-assignment",id:X.id}:{type:"project-assignment",id:X.id},onCardContextMenu:(X,te)=>{te.preventDefault(),re({item:X,anchor:{x:te.clientX,y:te.clientY}})},emptyMessage:X=>`No ${X.title.toLowerCase()} assignments.`,hiddenColumnIds:oe.hidden,onHideColumn:X=>ve(te=>({hidden:te.hidden.includes(X)?te.hidden.filter(Be=>Be!==X):[...te.hidden,X]})),renderCard:(X,{dragging:te})=>{const ye=Mc.get(xn(X))??-1;return s.jsx("div",{...ye>=0?Ii(ye):{},children:s.jsx(QN,{assignment:X,dragging:te,transitioning:Ae===xn(X),onPillSelect:Be=>void ao({item:X,toColumnId:Be.targetStatus,action:Be}),overrideTargets:Fc(X),onOverride:Be=>za(X,Be),onRenameTitle:Be=>Ho(X,Be)})})}}),s.jsx(Xn,{toast:ce,onDismiss:Ie}),s.jsx(w_,{open:zt,onOpenChange:X=>{Bt(X),X||Oe(!1)},initialName:we&&Se?`${Se.name} (copy)`:"",title:we?"Save as new view":"Save view",onSubmit:Lc}),s.jsx(__,{open:ut!==null,action:(ut==null?void 0:ut.action)??null,assignmentTitle:(ut==null?void 0:ut.item.title)??"Assignment",loading:Ae===(ut?xn(ut.item):null),onOpenChange:X=>{X||fe(null)},onConfirm:async X=>{if(!ut)return;const te=ut;await Oc({item:te.item,toColumnId:te.toColumnId,action:te.action,reason:X})&&fe(null)}}),s.jsx(sP,{anchor:(K==null?void 0:K.anchor)??null,items:K?lX(K.item,{onEdit:()=>{const X=K.item,te=X.projectSlug===null?`/assignments/${X.id}`:`${X.projectWorkspace?`/w/${X.projectWorkspace}`:t}/projects/${X.projectSlug}/assignments/${X.slug}`;n(te)},onDelete:()=>Ge(K.item),onMove:()=>vt(K.item)}):[],onClose:()=>re(null)}),s.jsx(ss,{open:xe!==null,title:"Delete assignment?",description:xe?`"${xe.title}" will be permanently removed. This cannot be undone.`:"",confirmLabel:"Delete",destructive:!0,loading:ze!==null,onOpenChange:X=>{!X&&ze===null&&Ge(null)},onConfirm:async()=>{if(!xe||xe.projectSlug===null){Ge(null);return}const X=xn(xe);lt(X);try{const te=await fetch(`/api/projects/${encodeURIComponent(xe.projectSlug)}/assignments/${encodeURIComponent(xe.slug)}`,{method:"DELETE"});if(!te.ok){const ye=await te.json().catch(()=>({}));throw new Error(ye.error||"Failed to delete assignment")}Ge(null),l(),me("Assignment deleted","success")}catch(te){me(te instanceof Error?te.message:"Failed to delete assignment","error")}finally{lt(null)}}}),s.jsx(Xw,{open:ht!==null,onOpenChange:X=>{X||vt(null)},currentWorkspace:(ht==null?void 0:ht.projectWorkspace)??null,title:"Move assignment to workspace",description:"Standalone assignments belong to a project-workspace via the workspaceGroup frontmatter field.",onSubmit:async X=>{if(!ht)return;const te=await fetch(`/api/assignments/${encodeURIComponent(ht.id)}/move-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceGroup:X})});if(!te.ok){const ye=await te.json().catch(()=>({}));throw new Error(ye.error||"Failed to move assignment")}l()}})]})}function lX(e,t){const n=[{key:"edit",label:"Edit",icon:xc,onSelect:t.onEdit}];return e.projectSlug!==null?n.push({key:"delete",label:"Delete",icon:jn,destructive:!0,onSelect:t.onDelete}):n.push({key:"move",label:"Move to workspace…",icon:Jh,onSelect:t.onMove}),n}function cX({detailHref:e,children:t,className:n,...r}){const o=Y_(e);return s.jsx("tr",{...r,ref:o.containerRef,className:n,onMouseDown:o.onMouseDown,onClick:o.onClick,children:t})}function QN({assignment:e,dragging:t,transitioning:n,onPillSelect:r,overrideTargets:o,onOverride:i,onRenameTitle:a}){var p;const l=ud(e),u=!!(r&&a),f=Y_(l);return s.jsxs("div",{ref:u?f.containerRef:void 0,className:je("vp-card rounded-lg border border-border/60 bg-background/85 p-3 shadow-sm",u&&"cursor-pointer"),onMouseDown:u?f.onMouseDown:void 0,onClick:u?f.onClick:void 0,children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[u?s.jsx(G_,{title:e.title,detailHref:l,onSave:a,disabled:n}):s.jsx(De,{to:l,className:"text-base font-semibold text-foreground hover:text-primary",children:e.title}),s.jsx("p",{className:"text-sm text-muted-foreground",children:e.projectTitle??s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] uppercase text-muted-foreground",children:"Standalone"})}),s.jsxs("p",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-muted-foreground/70",title:e.id??"",children:[(p=e.id)==null?void 0:p.slice(0,8),e.id&&s.jsx(Hr,{value:e.id})]})]}),u?s.jsx(JY,{currentStatus:e.status,availableTransitions:e.availableTransitions,onSelect:r,overrideTargets:o,onOverride:i,disabled:n,className:"max-w-[150px]"}):s.jsx(kn,{status:e.status,className:"max-w-[150px]"})]}),e.blockedReason?s.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,s.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[s.jsx(Aa,{type:e.type}),s.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs capitalize text-muted-foreground",children:e.priority}),s.jsx("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:e.assignee??"Unassigned"}),e.dependsOn.length>0?s.jsxs("span",{className:"rounded-full border border-border/60 px-2.5 py-1 text-xs text-muted-foreground",children:[e.dependsOn.length," ",e.dependsOn.length===1?"dependency":"dependencies"]}):null]}),s.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs uppercase tracking-[0.08em] text-muted-foreground",children:[s.jsx("span",{children:n?"Updating":t?"Dragging":"Source-first"}),s.jsx("span",{children:Yn(e.updated)})]})]})}function ju(e,t){return e.availableTransitions.find(n=>n.targetStatus===t)}function xn(e){return e.id||e.slug||"unknown"}function os(e){const t=e.match(/^---\n([\s\S]*?)\n---\n?/);if(!t)return{order:[],blocks:new Map,body:e};const n=t[1],r=e.slice(t[0].length),o=n.split(`
631
- `),i=[],a=new Map;let l=null,u=[];const f=()=>{l&&(i.push(l),a.set(l,u))};for(const p of o){const h=p.match(/^([A-Za-z_][A-Za-z0-9_-]*):/);if(h&&!p.startsWith(" ")){f(),l=h[1],u=[p];continue}l&&u.push(p)}return f(),{order:i,blocks:a,body:r}}function Rc(e){return`---
632
- ${e.order.map(n=>e.blocks.get(n)).filter(n=>!!n).flat().join(`
633
- `)}
634
- ---
635
-
636
- ${e.body.replace(/^\n+/,"")}`}const uX=/[:#{}[\],&*?|>!%@`]/;function pv(e){return e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1).replace(/\\(["\\])/g,"$1"):e.length>=2&&e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1).replace(/''/g,"'"):e}function X_(e){return uX.test(e)||/^\s|\s$/.test(e)||/^["']|["']$/.test(e)?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:e}function In(e,t){const n=e.blocks.get(t);if(!(n!=null&&n[0]))return"";const r=n[0].match(/^[^:]+:\s*(.*)$/);if(!r)return"";const o=r[1].trim();return o==="null"?"":pv(o)}function dX(e,t){return In(e,t)==="true"}function fX(e){const t=[];let n="",r=null;for(let o=0;o<e.length;o+=1){const i=e[o];if(r){n+=i,i==="\\"&&r==='"'&&o+1<e.length?(n+=e[o+1],o+=1):i===r&&(r=null);continue}if(i==='"'||i==="'"){r=i,n+=i;continue}if(i===","){t.push(n),n="";continue}n+=i}return t.push(n),t}function Gu(e,t){const n=e.blocks.get(t);if(!(n!=null&&n.length))return[];if(n[0].trim().endsWith("[]"))return[];const o=n[0].match(/^[^:]+:\s*\[(.*)\]\s*$/);return o?fX(o[1]).map(i=>pv(i.trim())).filter(i=>i.length>0):n.slice(1).map(i=>i.trim()).filter(i=>i.startsWith("- ")).map(i=>pv(i.slice(2).trim()))}function pX(e){return typeof e=="boolean"?e?"true":"false":e===null||e===""?"null":X_(e)}function Ln(e,t,n){e.blocks.has(t)||e.order.push(t),e.blocks.set(t,[`${t}: ${pX(n)}`])}function Yu(e,t,n){if(e.blocks.has(t)||e.order.push(t),n.length===0){e.blocks.set(t,[`${t}: []`]);return}e.blocks.set(t,[`${t}:`,...n.map(r=>` - ${X_(r)}`)])}function Xu(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function Gm(e){const t=os(e);return{title:In(t,"title"),slug:In(t,"slug"),workspace:In(t,"workspace"),archived:dX(t,"archived"),archivedAt:In(t,"archivedAt"),archivedReason:In(t,"archivedReason"),tags:Gu(t,"tags").join(", "),body:t.body}}function hX(e,t){const n=os(e),r={...Gm(e),...t};return Ln(n,"title",r.title),Ln(n,"slug",r.slug),Ln(n,"workspace",r.workspace||null),Ln(n,"archived",r.archived),Ln(n,"archivedAt",r.archivedAt||null),Ln(n,"archivedReason",r.archivedReason||null),Yu(n,"tags",Xu(r.tags)),n.body=r.body,Rc(n)}function Ym(e){const t=os(e);return{title:In(t,"title"),slug:In(t,"slug"),status:In(t,"status"),priority:In(t,"priority")||"medium",assignee:In(t,"assignee"),dependsOn:Gu(t,"dependsOn").join(", "),links:Gu(t,"links").join(", "),blockedReason:In(t,"blockedReason"),tags:Gu(t,"tags").join(", "),body:t.body}}function mX(e,t){const n=os(e),r={...Ym(e),...t};return Ln(n,"title",r.title),Ln(n,"slug",r.slug),Ln(n,"status",r.status),Ln(n,"priority",r.priority),Ln(n,"assignee",r.assignee||null),Yu(n,"dependsOn",Xu(r.dependsOn)),Yu(n,"links",Xu(r.links)),Ln(n,"blockedReason",r.blockedReason||null),Yu(n,"tags",Xu(r.tags)),n.body=r.body,Rc(n)}function Xm(e){const t=os(e);return{assignment:In(t,"assignment"),status:In(t,"status"),body:t.body}}function gX(e,t){const n=os(e),r={...Xm(e),...t};return Ln(n,"assignment",r.assignment),Ln(n,"status",r.status),n.body=r.body,Rc(n)}function Qm(e){const t=os(e);return{assignment:In(t,"assignment"),body:t.body}}function xX(e,t){const n=os(e),r={...Qm(e),...t};return Ln(n,"assignment",r.assignment),n.body=r.body,Rc(n)}function Jm(e){const t=os(e);return{name:In(t,"name"),slug:In(t,"slug"),description:In(t,"description"),whenToUse:In(t,"when_to_use"),tags:Gu(t,"tags").join(", "),body:t.body}}function yX(e,t){const n=os(e),r={...Jm(e),...t};return Ln(n,"name",r.name),Ln(n,"slug",r.slug),Ln(n,"description",r.description||null),Ln(n,"when_to_use",r.whenToUse||null),Yu(n,"tags",Xu(r.tags)),n.body=r.body,Rc(n)}function C0(e){return{body:os(e).body}}function Q_(e){return C0(e)}function J_(e,t){const n=os(e);return t.body!==void 0&&(n.body=t.body),Rc(n)}function bX(e,t){return J_(e,t)}function Zt(e,t,n){switch(e){case"project":return hX(t,n);case"assignment":return mX(t,n);case"plan":return gX(t,n);case"scratchpad":return xX(t,n);case"playbook":return yX(t,n);case"memory":return J_(t,n);case"resource":return bX(t,n);default:return t}}function vX(e){return(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="s"}function wX(e){return!e.saving&&e.validationErrorCount===0}function Ac({initialContent:e,documentType:t,mode:n="edit",onSave:r,saving:o,error:i,title:a,description:l,onCancel:u,helpTitle:f,helpBody:p,allowSlugEdit:h=!1}){const[g,y]=m.useState(e),[k,v]=m.useState(!1),[b,j]=m.useState("edit");m.useEffect(()=>{y(e)},[e]);const N=NX(t,g),S=g!==e,C=SX(t,g),D=S?"Unsaved changes":n==="create"?"Draft":"Saved",T=t!=="memory"&&t!=="resource",R=m.useRef({content:g,saving:o,validationErrorCount:N.length,onSave:r});return R.current={content:g,saving:o,validationErrorCount:N.length,onSave:r},m.useEffect(()=>{const $=P=>{if(!vX(P))return;P.preventDefault();const{content:F,saving:_,validationErrorCount:V,onSave:U}=R.current;wX({saving:_,validationErrorCount:V})&&U(F)};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[]),m.useEffect(()=>{if(!S)return;const $=P=>{P.preventDefault(),P.returnValue=""};return window.addEventListener("beforeunload",$),()=>window.removeEventListener("beforeunload",$)},[S]),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"rounded-lg border border-border/70 bg-card/90 p-3 shadow-sm",children:[s.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h1",{className:"text-lg font-semibold text-foreground",children:a}),s.jsx("span",{className:"rounded-full border border-border/70 bg-background/80 px-2.5 py-1 text-xs font-medium text-muted-foreground",children:D})]}),l?s.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:l}):null]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:u,className:"shell-action",children:[s.jsx(sh,{className:"h-4 w-4"}),s.jsx("span",{children:"Back"})]}),T?s.jsxs("button",{type:"button",onClick:()=>v($=>!$),className:"shell-action",children:[s.jsx(iO,{className:"h-4 w-4"}),s.jsx("span",{children:k?"Structured":"Raw Markdown"})]}):null,s.jsxs("button",{type:"button",onClick:()=>r(g),disabled:o||N.length>0,className:"inline-flex items-center gap-2 rounded-md bg-foreground px-4 py-2 text-sm font-semibold text-background transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx(nm,{className:"h-4 w-4"}),s.jsx("span",{children:o?"Saving…":"Save"})]})]})]}),i?s.jsx("p",{className:"mt-4 rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:i}):null,N.length>0?s.jsx("div",{className:"mt-4 rounded-md border border-warning-foreground/30 bg-warning px-4 py-3 text-sm text-warning-foreground",children:s.jsx("ul",{className:"space-y-1",children:N.map($=>s.jsx("li",{children:$},$))})}):null]}),s.jsxs("div",{className:"flex items-center gap-2 md:hidden",children:[s.jsx("button",{type:"button",onClick:()=>j("edit"),className:`shell-action ${b==="edit"?"shell-action--cta":""}`,children:"Edit"}),s.jsxs("button",{type:"button",onClick:()=>j("preview"),className:`shell-action ${b==="preview"?"shell-action--cta":""}`,children:[s.jsx(N1,{className:"h-4 w-4"}),"Preview"]})]}),s.jsxs("div",{className:"grid gap-3 xl:grid-cols-[minmax(0,1.2fr)_minmax(320px,0.8fr)]",children:[s.jsx("div",{className:b==="preview"?"hidden md:block":"",children:s.jsx("div",{className:"surface-panel space-y-3",children:k?s.jsx("textarea",{value:g,onChange:$=>y($.target.value),className:"min-h-[720px] w-full rounded-md border border-border/70 bg-background/90 p-4 font-mono text-sm text-foreground outline-none transition focus:border-primary focus:ring-2 focus:ring-ring/30",spellCheck:!1}):s.jsx(jX,{documentType:t,content:g,onChange:y,allowSlugEdit:h})})}),s.jsx("div",{className:b==="edit"?"hidden md:block":"",children:s.jsxs("div",{className:"surface-panel sticky top-16 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(N1,{className:"h-4 w-4 text-muted-foreground"}),s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Preview"})]}),s.jsx(vn,{content:C,emptyState:"Write markdown body content to preview it here."})]})})]})]})}function jX({documentType:e,content:t,onChange:n,allowSlugEdit:r}){const o=As();if(e==="project"){const a=Gm(t);return s.jsxs("div",{className:"space-y-3",children:[s.jsxs(ku,{children:[s.jsx(Vt,{label:"Project title",children:s.jsx("input",{value:a.title,onChange:l=>{const u=l.target.value,f={title:u};r&&(a.slug===Ir(a.title)||!a.slug.trim())&&(f.slug=Ir(u)),n(Zt(e,t,f))},className:"editor-input"})}),s.jsx(Vt,{label:"Slug",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{value:a.slug,disabled:!r,onChange:l=>n(Zt(e,t,{slug:Ir(l.target.value)})),className:`editor-input ${r?"":"editor-input-disabled"}`}),s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:r?"The slug becomes the folder name and URL. It is auto-generated from the title until you change it, and it cannot be renamed after creation.":"The slug is the folder name and URL-safe identifier. It is locked after creation so links and file paths stay stable."})]})}),s.jsx(Vt,{label:"Tags",children:s.jsx("input",{value:a.tags,onChange:l=>n(Zt(e,t,{tags:l.target.value})),placeholder:"Comma-separated tags",className:"editor-input"})}),s.jsx(kX,{value:a.workspace,onChange:l=>n(Zt(e,t,{workspace:l}))})]}),s.jsx(Vt,{label:"Project body",children:s.jsx("textarea",{value:a.body,onChange:l=>n(Zt(e,t,{body:l.target.value})),className:"editor-textarea",spellCheck:!1})})]})}if(e==="assignment"){const a=Ym(t),l=VA(o),u=!l.some(f=>f.id===a.status);return s.jsxs("div",{className:"space-y-3",children:[s.jsxs(ku,{children:[s.jsx(Vt,{label:"Assignment title",children:s.jsx("input",{value:a.title,onChange:f=>{const p=f.target.value,h={title:p};r&&(a.slug===Ir(a.title)||!a.slug.trim())&&(h.slug=Ir(p)),n(Zt(e,t,h))},className:"editor-input"})}),s.jsx(Vt,{label:"Slug",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{value:a.slug,disabled:!r,onChange:f=>n(Zt(e,t,{slug:Ir(f.target.value)})),className:`editor-input ${r?"":"editor-input-disabled"}`}),s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:r?"The slug becomes the assignment folder name and URL. It is auto-generated from the title until you change it, and it cannot be renamed after creation.":"The slug is locked after creation because assignment paths and dependency references use it as a stable identifier."})]})}),s.jsx(Vt,{label:"Status",children:s.jsxs("select",{value:a.status,onChange:f=>n(Zt(e,t,{status:f.target.value})),className:"editor-input",children:[u?s.jsx("option",{value:a.status,children:Co(o,a.status)}):null,l.map(f=>s.jsx("option",{value:f.id,children:f.label},f.id))]})}),s.jsx(Vt,{label:"Priority",children:s.jsxs("select",{value:a.priority,onChange:f=>n(Zt(e,t,{priority:f.target.value})),className:"editor-input",children:[s.jsx("option",{value:"low",children:"Low"}),s.jsx("option",{value:"medium",children:"Medium"}),s.jsx("option",{value:"high",children:"High"}),s.jsx("option",{value:"critical",children:"Critical"})]})}),s.jsx(Vt,{label:"Assignee",children:s.jsx("input",{value:a.assignee,onChange:f=>n(Zt(e,t,{assignee:f.target.value})),placeholder:"Agent name",className:"editor-input"})}),s.jsx(Vt,{label:"Depends on",className:"md:col-span-2",children:s.jsx("input",{value:a.dependsOn,onChange:f=>n(Zt(e,t,{dependsOn:f.target.value})),placeholder:"Comma-separated assignment slugs",className:"editor-input"})}),s.jsx(Vt,{label:"Links",className:"md:col-span-2",children:s.jsx("input",{value:a.links,onChange:f=>n(Zt(e,t,{links:f.target.value})),placeholder:"Comma-separated: projectSlug/assignmentSlug",className:"editor-input"})}),s.jsx(Vt,{label:"Blocked reason",className:"md:col-span-2",children:s.jsx("input",{value:a.blockedReason,onChange:f=>n(Zt(e,t,{blockedReason:f.target.value})),placeholder:"Read-only unless the assignment is actually blocked",className:"editor-input"})}),s.jsx(Vt,{label:"Tags",className:"md:col-span-2",children:s.jsx("input",{value:a.tags,onChange:f=>n(Zt(e,t,{tags:f.target.value})),placeholder:"Comma-separated tags",className:"editor-input"})})]}),s.jsx(Vt,{label:"Assignment body",children:s.jsx("textarea",{value:a.body,onChange:f=>n(Zt(e,t,{body:f.target.value})),className:"editor-textarea",spellCheck:!1})})]})}if(e==="plan"){const a=Xm(t);return s.jsxs("div",{className:"space-y-3",children:[s.jsxs(ku,{children:[s.jsx(Vt,{label:"Assignment",children:s.jsx("input",{value:a.assignment,disabled:!0,className:"editor-input editor-input-disabled"})}),s.jsx(Vt,{label:"Plan status",children:s.jsxs("select",{value:a.status,onChange:l=>n(Zt(e,t,{status:l.target.value})),className:"editor-input",children:[s.jsx("option",{value:"draft",children:"Draft"}),s.jsx("option",{value:"approved",children:"Approved"}),s.jsx("option",{value:"in_progress",children:"In Progress"}),s.jsx("option",{value:"completed",children:"Completed"})]})})]}),s.jsx(Vt,{label:"Plan body",children:s.jsx("textarea",{value:a.body,onChange:l=>n(Zt(e,t,{body:l.target.value})),className:"editor-textarea",spellCheck:!1})})]})}if(e==="scratchpad"){const a=Qm(t);return s.jsxs("div",{className:"space-y-3",children:[s.jsx(ku,{children:s.jsx(Vt,{label:"Assignment",children:s.jsx("input",{value:a.assignment,disabled:!0,className:"editor-input editor-input-disabled"})})}),s.jsx(Vt,{label:"Scratchpad body",children:s.jsx("textarea",{value:a.body,onChange:l=>n(Zt(e,t,{body:l.target.value})),className:"editor-textarea",spellCheck:!1})})]})}if(e==="memory"||e==="resource"){const a=e==="memory"?C0(t):Q_(t),l=e==="memory"?"Memory body":"Resource body";return s.jsxs("div",{className:"space-y-3",children:[s.jsx(Vt,{label:l,children:s.jsx("textarea",{value:a.body,onChange:u=>n(Zt(e,t,{body:u.target.value})),className:"editor-textarea",spellCheck:!1})}),s.jsx("p",{className:"text-xs text-muted-foreground/80",children:"Frontmatter (name, scope/category, source, related assignments, tags) is preserved server-side on save."})]})}const i=Jm(t);return s.jsxs("div",{className:"space-y-3",children:[s.jsxs(ku,{children:[s.jsx(Vt,{label:"Playbook name",children:s.jsx("input",{value:i.name,onChange:a=>{const l=a.target.value,u={name:l};r&&(i.slug===Ir(i.name)||!i.slug.trim())&&(u.slug=Ir(l)),n(Zt(e,t,u))},className:"editor-input"})}),s.jsx(Vt,{label:"Slug",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{value:i.slug,disabled:!r,onChange:a=>n(Zt(e,t,{slug:Ir(a.target.value)})),className:`editor-input ${r?"":"editor-input-disabled"}`}),s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:r?"The slug becomes the filename. It is auto-generated from the name until you change it.":"The slug is locked after creation because it is the filename."})]})}),s.jsx(Vt,{label:"Description",className:"md:col-span-2",children:s.jsx("input",{value:i.description,onChange:a=>n(Zt(e,t,{description:a.target.value})),placeholder:"One-line description of what this playbook does",className:"editor-input"})}),s.jsx(Vt,{label:"Tags",className:"md:col-span-2",children:s.jsx("input",{value:i.tags,onChange:a=>n(Zt(e,t,{tags:a.target.value})),placeholder:"Comma-separated tags",className:"editor-input"})}),s.jsx(Vt,{label:"When to use",className:"md:col-span-2",children:s.jsx("input",{value:i.whenToUse,onChange:a=>n(Zt(e,t,{whenToUse:a.target.value})),placeholder:"Describe when agents should apply this playbook",className:"editor-input"})})]}),s.jsx(Vt,{label:"Playbook rules",children:s.jsx("textarea",{value:i.body,onChange:a=>n(Zt(e,t,{body:a.target.value})),className:"editor-textarea",spellCheck:!1})})]})}function ku({children:e}){return s.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:e})}function Vt({label:e,children:t,className:n}){return s.jsxs("label",{className:`block space-y-2 ${n??""}`,children:[s.jsx("span",{className:"text-sm font-medium text-foreground",children:e}),t]})}function kX({value:e,onChange:t}){const{data:n}=Ea(),r=(n==null?void 0:n.workspaces)??[];return s.jsx(Vt,{label:"Workspace",children:s.jsxs("select",{value:e,onChange:o=>t(o.target.value),className:"editor-input",children:[s.jsx("option",{value:"",children:"Ungrouped"}),r.map(o=>s.jsx("option",{value:o,children:o},o))]})})}function SX(e,t){switch(e){case"project":return Gm(t).body;case"assignment":return Ym(t).body;case"plan":return Xm(t).body;case"scratchpad":return Qm(t).body;case"playbook":return Jm(t).body;case"memory":return C0(t).body;case"resource":return Q_(t).body}}function NX(e,t){switch(e){case"project":{const n=Gm(t);return[n.title.trim()?null:"Project title is required.",n.slug.trim()?null:"Project slug is required.",n.slug.trim()&&!Lp(n.slug)?"Project slug must be lowercase letters, numbers, and hyphens only.":null].filter(r=>!!r)}case"assignment":{const n=Ym(t);return[n.title.trim()?null:"Assignment title is required.",n.slug.trim()?null:"Assignment slug is required.",n.slug.trim()&&!Lp(n.slug)?"Assignment slug must be lowercase letters, numbers, and hyphens only.":null].filter(r=>!!r)}case"plan":return Xm(t).assignment.trim()?[]:["Plan assignment is required."];case"scratchpad":return Qm(t).assignment.trim()?[]:["Scratchpad assignment is required."];case"playbook":{const n=Jm(t);return[n.name.trim()?null:"Playbook name is required.",n.slug.trim()?null:"Playbook slug is required.",n.slug.trim()&&!Lp(n.slug)?"Playbook slug must be lowercase letters, numbers, and hyphens only.":null].filter(r=>!!r)}case"memory":case"resource":return[]}}function JN(){const e=Wt(),{workspace:t}=qt(),n=mn(),[r,o]=m.useState(null),[i,a]=m.useState(!0),[l,u]=m.useState(!1),[f,p]=m.useState(null);m.useEffect(()=>{fetch("/api/templates/project").then(g=>g.json()).then(g=>{let y=g.content;t&&t!=="_ungrouped"&&(y=y.replace(/^(tags: \[\])$/m,`$1
637
- workspace: ${t}`)),o(y),a(!1)}).catch(g=>{p(g.message),a(!1)})},[t]);async function h(g){u(!0),p(null);try{const y=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:g})}),k=await y.json();if(!y.ok){p(k.error||`HTTP ${y.status}`),u(!1);return}e(`${n}/projects/${k.slug}`)}catch(y){p(y.message),u(!1);return}u(!1)}return i?s.jsx(bt,{label:"Loading project template…"}):f&&!r?s.jsx(Rt,{error:f}):s.jsx(Ac,{initialContent:r||"",documentType:"project",mode:"create",onSave:h,saving:l,error:f,title:"Create Project",description:"Projects hold the high-level objective, shared context, and human-authored overview. Put execution details in assignments instead of overloading project.md.",onCancel:()=>e(`${n}/projects`),helpTitle:"Project editing rules",helpBody:"Use this form for project intent, slug, tags, and overview content. If you ever need less common metadata, raw markdown mode still exposes the full file.",allowSlugEdit:!0})}function ZN(){const{slug:e}=qt(),t=mn(),n=Wt(),[r,o]=m.useState(null),[i,a]=m.useState(!0),[l,u]=m.useState(!1),[f,p]=m.useState(null);m.useEffect(()=>{fetch("/api/templates/assignment").then(g=>g.json()).then(g=>{o(g.content),a(!1)}).catch(g=>{p(g.message),a(!1)})},[]);async function h(g){if(!e){p("Project slug is required.");return}u(!0),p(null);try{const y=await fetch(`/api/projects/${e}/assignments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:g})}),k=await y.json();if(!y.ok){p(k.error||`HTTP ${y.status}`),u(!1);return}n(`${t}/projects/${e}/assignments/${k.slug}`)}catch(y){p(y.message),u(!1);return}u(!1)}return i?s.jsx(bt,{label:"Loading assignment template…"}):f&&!r?s.jsx(Rt,{error:f}):s.jsx(Ac,{initialContent:r||"",documentType:"assignment",mode:"create",onSave:h,saving:l,error:f,title:"Create Assignment",description:"Assignments are the execution unit. Declare dependencies here, keep status pending until work starts, and use blocked later only for runtime obstacles.",onCancel:()=>n(e?`${t}/projects/${e}`:`${t}/projects`),helpTitle:"Assignment editing rules",helpBody:"Use structured fields for priority, assignee, dependencies, and tags. Status can be changed through lifecycle actions, kanban drag, or the status override.",allowSlugEdit:!0})}function eC(){const{workspace:e}=qt(),t=mn(),n=Wt(),[r,o]=m.useState(null),[i,a]=m.useState(!0),[l,u]=m.useState(!1),[f,p]=m.useState(null);m.useEffect(()=>{const g=new URLSearchParams({standalone:"1"});e&&g.set("workspace",e),fetch(`/api/templates/assignment?${g.toString()}`).then(y=>y.json()).then(y=>{o(y.content),a(!1)}).catch(y=>{p(y.message),a(!1)})},[e]);async function h(g){var y;u(!0),p(null);try{const k=await fetch("/api/assignments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:g})}),v=await k.json();if(!k.ok){p(v.error||`HTTP ${k.status}`),u(!1);return}const b=(y=v==null?void 0:v.assignment)==null?void 0:y.id;if(!b){p("Server did not return the new assignment id."),u(!1);return}n(`/assignments/${b}`)}catch(k){p(k.message),u(!1);return}u(!1)}return i?s.jsx(bt,{label:"Loading assignment template…"}):f&&!r?s.jsx(Rt,{error:f}):s.jsx(Ac,{initialContent:r||"",documentType:"assignment",mode:"create",onSave:h,saving:l,error:f,title:"Create Standalone Assignment",description:e?`Standalone assignments live outside any project. This one will be tagged with workspaceGroup: ${e} so it appears in this workspace's views.`:"Standalone assignments live outside any project. Add a workspaceGroup to make them appear in workspace-filtered views.",onCancel:()=>n(`${t}/assignments`),helpTitle:"Standalone assignment editing rules",helpBody:"No project field is needed (it must remain null). Use workspaceGroup to group with other workspace work. Status, priority, and tags work the same as project-nested assignments.",allowSlugEdit:!0})}function Pc({loadUrl:e,saveUrl:t,redirectTo:n,title:r,description:o,documentType:i,helpTitle:a,helpBody:l}){const u=Wt(),{data:f,loading:p,error:h}=V2(e),[g,y]=m.useState(!1),[k,v]=m.useState(null);async function b(j){y(!0),v(null);try{const N=await fetch(t,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:j})}),S=await N.json();if(!N.ok){v(S.error||`HTTP ${N.status}`),y(!1);return}u(n)}catch(N){v(N.message),y(!1);return}y(!1)}return p?s.jsx(bt,{label:`Loading ${r.toLowerCase()}…`}):h||!f?s.jsx(Rt,{error:h||`${r} is unavailable.`}):s.jsx(Ac,{initialContent:f.content,documentType:i,onSave:b,saving:g,error:k,title:r,description:o,onCancel:()=>u(n),helpTitle:a,helpBody:l})}function tC(){const{slug:e}=qt(),t=mn(),n=e??"";return s.jsx(Pc,{loadUrl:`/api/projects/${n}/edit`,saveUrl:`/api/projects/${n}`,redirectTo:`${t}/projects/${n}`,title:"Edit Project",description:"Project edits change the human-authored source document. The structured form stays focused on title, slug, tags, and overview content.",documentType:"project",helpTitle:"Editable vs derived project fields",helpBody:"Project status remains derived from assignment state. If you need less common frontmatter fields, switch to raw markdown mode instead of expanding the structured form."})}function Hy(){const{slug:e,aslug:t,id:n}=qt(),r=mn(),o=!!n,i=o?`/api/assignments/${n}/edit`:`/api/projects/${e}/assignments/${t}/edit`,a=o?`/api/assignments/${n}`:`/api/projects/${e}/assignments/${t}`,l=o?`/assignments/${n}`:`${r}/projects/${e}/assignments/${t}`;return s.jsx(Pc,{loadUrl:i,saveUrl:a,redirectTo:l,title:"Edit Assignment",description:"Edit assignment fields including status, priority, assignee, dependencies, and body.",documentType:"assignment",helpTitle:"Assignment editing",helpBody:"All fields are editable. Status can also be changed through lifecycle actions or kanban drag."})}function Vy(){const{slug:e,aslug:t,id:n}=qt(),r=mn(),o=!!n,i=o?`/api/assignments/${n}/plan/edit`:`/api/projects/${e}/assignments/${t}/plan/edit`,a=o?`/api/assignments/${n}/plan`:`/api/projects/${e}/assignments/${t}/plan`,l=o?`/assignments/${n}?tab=plan`:`${r}/projects/${e}/assignments/${t}?tab=plan`;return s.jsx(Pc,{loadUrl:i,saveUrl:a,redirectTo:l,title:"Edit Plan",description:"Plans are separate from assignment status, so keep implementation steps here instead of overloading the assignment body.",documentType:"plan",helpTitle:"Plan status is separate",helpBody:"Plan status tracks the plan document itself. It does not replace the assignment lifecycle state."})}function Wy(){const{slug:e,aslug:t,id:n}=qt(),r=mn(),o=!!n,i=o?`/api/assignments/${n}/scratchpad/edit`:`/api/projects/${e}/assignments/${t}/scratchpad/edit`,a=o?`/api/assignments/${n}/scratchpad`:`/api/projects/${e}/assignments/${t}/scratchpad`,l=o?`/assignments/${n}?tab=scratchpad`:`${r}/projects/${e}/assignments/${t}?tab=scratchpad`;return s.jsx(Pc,{loadUrl:i,saveUrl:a,redirectTo:l,title:"Edit Scratchpad",description:"Scratchpad is the assignment’s working memory surface for notes, experiments, and temporary context.",documentType:"scratchpad",helpTitle:"Scratchpad usage",helpBody:"Scratchpad is for transient notes. Keep canonical objective and lifecycle data in assignment.md and any active plan files (plan.md, plan-v2.md, ...)."})}function Z_({loadUrl:e,saveUrl:t,redirectTo:n,title:r,description:o,helpTitle:i,helpBody:a}){const l=Wt(),{data:u,loading:f,error:p}=V2(e),[h,g]=m.useState(""),[y,k]=m.useState(""),[v,b]=m.useState(!1),[j,N]=m.useState(null);async function S(){b(!0),N(null);try{const C=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:h,body:y})}),D=await C.json();if(!C.ok){N(D.error||`HTTP ${C.status}`),b(!1);return}l(n)}catch(C){N(C.message),b(!1);return}b(!1)}return f?s.jsx(bt,{label:`Loading ${r.toLowerCase()}…`}):p||!u?s.jsx(Rt,{error:p||`${r} is unavailable.`}):s.jsxs("div",{className:"space-y-4",children:[s.jsx(qe,{title:r,description:o,children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("label",{className:"block space-y-2",children:[s.jsx("span",{className:"text-sm font-medium text-foreground",children:"Entry title"}),s.jsx("input",{value:h,onChange:C=>g(C.target.value),placeholder:"Optional title",className:"editor-input"})]}),s.jsxs("label",{className:"block space-y-2",children:[s.jsx("span",{className:"text-sm font-medium text-foreground",children:"Entry body"}),s.jsx("textarea",{value:y,onChange:C=>k(C.target.value),className:"editor-textarea",spellCheck:!1})]}),j?s.jsx("p",{className:"rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:j}):null,s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx("button",{type:"button",onClick:()=>l(n),className:"shell-action",children:"Cancel"}),s.jsx("button",{type:"button",onClick:S,disabled:v||!y.trim(),className:"shell-action shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:v?"Appending…":"Append Entry"})]})]})}),s.jsx(qe,{title:"Current Document",children:s.jsx(vn,{content:u.content.replace(/^---[\s\S]*?---\n?/,""),emptyState:"No existing content."})})]})}function qy(){const{slug:e,aslug:t,id:n}=qt(),r=mn(),o=!!n,i=o?`/api/assignments/${n}/handoff/edit`:`/api/projects/${e}/assignments/${t}/handoff/edit`,a=o?`/api/assignments/${n}/handoff/entries`:`/api/projects/${e}/assignments/${t}/handoff/entries`,l=o?`/assignments/${n}?tab=handoff`:`${r}/projects/${e}/assignments/${t}?tab=handoff`;return s.jsx(Z_,{loadUrl:i,saveUrl:a,redirectTo:l,title:"Append Handoff Entry",description:"Add a new handoff without rewriting previous history.",helpTitle:"Append-only handoff history",helpBody:"Handoff log entries preserve the baton-passing trail between sessions and agents. Add a new entry instead of editing older ones."})}function Ky(){const{slug:e,aslug:t,id:n}=qt(),r=mn(),o=!!n,i=o?`/api/assignments/${n}/decision-record/edit`:`/api/projects/${e}/assignments/${t}/decision-record/edit`,a=o?`/api/assignments/${n}/decision-record/entries`:`/api/projects/${e}/assignments/${t}/decision-record/entries`,l=o?`/assignments/${n}?tab=decisions`:`${r}/projects/${e}/assignments/${t}?tab=decisions`;return s.jsx(Z_,{loadUrl:i,saveUrl:a,redirectTo:l,title:"Append Decision Entry",description:"Record a new decision and rationale without editing prior entries.",helpTitle:"Append-only decision history",helpBody:"Decision records should accumulate over time so the implementation rationale remains auditable and reviewable."})}function nC(){const{workspace:e}=qt(),{data:t}=to(),{data:n,loading:r,error:o,refetch:i}=Jv(),{toast:a,showToast:l,dismissToast:u}=Qn(),[f,p]=m.useState(!1),[h,g]=m.useState(""),[y,k]=m.useState(!1),[v,b]=m.useState(null),[j,N]=m.useState(!1),S=rr();m.useEffect(()=>{const P=S.hash.match(/^#server-(.+)/);if(!P)return;const F=decodeURIComponent(P[1]),_=document.querySelector(`[data-server-name="${window.CSS.escape(F)}"]`);if(!_)return;_.scrollIntoView({block:"nearest"}),_.classList.add("ring-2","ring-primary/60");const V=window.setTimeout(()=>_.classList.remove("ring-2","ring-primary/60"),1500);return()=>window.clearTimeout(V)},[S.hash,n]);const C=(()=>{if(!e||!n)return(n==null?void 0:n.sessions)??[];if(!t)return[];const P=new Set(t.filter(F=>e==="_ungrouped"?F.workspace===null:F.workspace===e).map(F=>F.slug));return n.sessions.filter(F=>F.windows.some(_=>_.panes.some(V=>V.assignment&&V.assignment.project!==null&&P.has(V.assignment.project))))})();async function D(P){if(P.preventDefault(),!!h.trim())try{const F=await fetch("/api/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:h.trim()})});if(!F.ok){const _=await F.json().catch(()=>null);l((_==null?void 0:_.error)||`HTTP ${F.status}`,"error");return}g(""),p(!1),i(),l(`Tracking "${h.trim()}"`,"success")}catch(F){l(F instanceof Error?F.message:"Failed to register session","error")}}async function T(){k(!0);try{const P=await fetch("/api/servers/refresh",{method:"POST"});if(!P.ok){const F=await P.json().catch(()=>null);l((F==null?void 0:F.error)||`HTTP ${P.status}`,"error");return}i()}catch(P){l(P instanceof Error?P.message:"Failed to refresh sessions","error")}finally{k(!1)}}async function R(P){N(!0);try{const F=await fetch(`/api/servers/${encodeURIComponent(P)}`,{method:"DELETE"});if(!F.ok){const _=await F.json().catch(()=>null);l((_==null?void 0:_.error)||`HTTP ${F.status}`,"error");return}b(null),i(),l(`Stopped tracking "${P}"`,"success")}catch(F){l(F instanceof Error?F.message:"Failed to remove session","error")}finally{N(!1)}}async function $(P){try{const F=await fetch(`/api/servers/${encodeURIComponent(P)}/refresh`,{method:"POST"});if(!F.ok){const _=await F.json().catch(()=>null);l((_==null?void 0:_.error)||`HTTP ${F.status}`,"error");return}i()}catch(F){l(F instanceof Error?F.message:"Failed to refresh session","error")}}return r?s.jsx(bt,{label:"Loading servers…"}):o?s.jsx(Rt,{error:o}):n?n.tmuxAvailable?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f?s.jsxs("form",{onSubmit:D,className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:h,onChange:P=>g(P.target.value),placeholder:"tmux session name",className:"editor-input text-sm",autoFocus:!0}),s.jsx("button",{type:"submit",className:"shell-action",children:"Add"}),s.jsx("button",{type:"button",className:"shell-action",onClick:()=>p(!1),children:"Cancel"})]}):s.jsxs("button",{className:"shell-action",onClick:()=>p(!0),children:[s.jsx(Mt,{className:"h-3.5 w-3.5"}),"Track Session"]}),s.jsxs("button",{className:"shell-action",onClick:T,disabled:y,children:[s.jsx(x2,{className:`h-3.5 w-3.5 ${y?"animate-spin":""}`}),"Refresh All"]})]}),C.length===0?s.jsx(St,{title:"No sessions tracked",description:"Register a tmux session to start tracking your dev servers."}):s.jsx("div",{className:"mt-4 space-y-4",children:C.map(P=>s.jsx(CX,{session:P,onRefresh:()=>$(P.name),onRemove:()=>b(P.name),onRefetch:i},P.name))}),s.jsx(ss,{open:v!==null,title:"Stop tracking session?",description:`Remove "${v??""}" from tracked servers. This does not stop the tmux session itself.`,confirmLabel:"Stop Tracking",destructive:!0,loading:j,onOpenChange:P=>{!P&&!j&&b(null)},onConfirm:async()=>{v&&await R(v)}}),s.jsx(Xn,{toast:a,onDismiss:u})]}):s.jsx(s.Fragment,{children:s.jsxs("div",{className:"surface-panel mt-4 flex flex-col items-center gap-3 py-12 text-center",children:[s.jsx(Il,{className:"h-10 w-10 text-muted-foreground/40"}),s.jsx("p",{className:"text-sm font-medium text-foreground",children:"tmux is not installed"}),s.jsxs("p",{className:"max-w-md text-sm text-muted-foreground",children:["Server tracking requires tmux. Install it with ",s.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:"brew install tmux"})," to get started."]})]})}):null}function CX({session:e,onRefresh:t,onRemove:n,onRefetch:r}){return s.jsxs("div",{className:"surface-panel","data-server-name":e.name,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Wv,{className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"text-sm font-semibold text-foreground",children:e.name}),s.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${e.alive?"border border-success-foreground/30 bg-success text-success-foreground":"border border-error-foreground/30 bg-error text-error-foreground"}`,children:e.alive?"alive":"dead"}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last refreshed: ",Nr(e.lastRefreshed)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{className:"shell-action",onClick:t,title:"Refresh","aria-label":"Refresh",children:s.jsx(x2,{className:"h-3.5 w-3.5"})}),s.jsx("button",{className:"shell-action",onClick:n,title:"Remove","aria-label":"Remove",children:s.jsx(jn,{className:"h-3.5 w-3.5"})})]})]}),e.alive&&e.windows.length>0&&s.jsx("div",{className:"mt-3 space-y-3",children:e.windows.map(o=>s.jsxs("div",{children:[s.jsxs("p",{className:"mb-1.5 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:["Window ",o.index,": ",o.name]}),s.jsx("div",{className:"space-y-1.5",children:o.panes.map(i=>s.jsx(EX,{pane:i,sessionName:e.name,windowIndex:o.index,onRefetch:r},`${o.index}:${i.index}`))})]},o.index))}),!e.alive&&s.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(AO,{className:"h-4 w-4"}),s.jsx("span",{children:e.kind==="process"?"Process no longer running":"Session no longer exists"})]})]})}function EX({pane:e,sessionName:t,windowIndex:n,onRefetch:r}){const o=mn(),i=e.cwd.replace(/^\/Users\/[^/]+/,"~");return s.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-2 text-sm",children:[s.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground/60",children:[":",e.index]}),s.jsx("span",{className:"shrink-0 rounded bg-muted/60 px-1.5 py-0.5 font-mono text-xs",children:e.command}),s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx("span",{className:"block min-w-0 truncate",title:e.cwd,children:i}),s.jsx(Hr,{value:e.cwd})]}),e.branch&&s.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[s.jsx(Uv,{className:"h-3 w-3"}),e.branch,e.worktree&&s.jsx("span",{className:"rounded bg-status-in-progress px-1 py-0.5 text-[10px] font-medium text-status-in-progress-foreground",children:"worktree"})]}),e.ports.length>0&&s.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:e.urls.map(a=>s.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"inline-flex 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:[a.replace("http://localhost:",":"),s.jsx(mc,{className:"h-2.5 w-2.5"})]},a))}),s.jsx("div",{className:"ml-auto shrink-0",children:e.assignment?s.jsxs(De,{to:e.assignment.project===null?`/assignments/${e.assignment.slug}`:`${o}/projects/${e.assignment.project}/assignments/${e.assignment.slug}`,className:"inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/10 px-1.5 py-0.5 text-xs font-medium text-primary hover:bg-primary/20",children:[s.jsx(xO,{className:"h-2.5 w-2.5"}),e.assignment.title,e.assignment.project===null?s.jsx("span",{className:"ml-1 rounded bg-muted px-1 py-0.5 text-[9px] uppercase tracking-wide text-muted-foreground",children:"Standalone"}):null]}):s.jsx("span",{className:"text-xs text-muted-foreground/40",children:"unlinked"})})]})}function e3(e){return e<60?`${e}s`:e<3600?`${Math.round(e/60)}m`:e<86400?`${Math.round(e/3600)}h`:`${Math.round(e/86400)}d`}function TX(e,t){const n=Date.parse(e),r=Math.floor((n-t)/1e3);return Number.isNaN(r)?"–":r<=0?"expired":e3(r)}function RX(e){switch(e){case"idle":return"border-success-foreground/30 bg-success text-success-foreground";case"leased":return"border-warning-foreground/30 bg-warning text-warning-foreground";case"retired":return"border-muted-foreground/30 bg-muted text-muted-foreground"}}function AX(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function rC(){const{data:e,loading:t,error:n,refetch:r}=W2(),[o,i]=m.useState(()=>Date.now()),[a,l]=m.useState(null),[u,f]=m.useState(!1),{toast:p,showToast:h,dismissToast:g}=Qn();if(m.useEffect(()=>{const k=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(k)},[]),t)return s.jsx(bt,{label:"Loading inventories…"});if(n)return s.jsx(Rt,{title:"Could not load inventories",error:n,action:s.jsx("button",{type:"button",onClick:r,className:"rounded border px-3 py-1 text-sm",children:"Retry"})});if(!e||e.inventories.length===0)return s.jsx(St,{title:"No inventories yet",description:"Create one with `syntaur lease create-inventory <slug> --kind <kind>`, then add members with `syntaur lease member add <slug> <id>`."});async function y(){if(a){f(!0);try{const k=await fetch(`/api/leases/${encodeURIComponent(a.slug)}/force-release/${encodeURIComponent(a.lease.lease_id)}`,{method:"POST"});if(!k.ok){const v=await k.json().catch(()=>null);throw new Error((v==null?void 0:v.error)??`HTTP ${k.status}`)}r(),l(null)}catch(k){h(k instanceof Error?`Force release failed: ${k.message}`:"Force release failed","error")}finally{f(!1)}}}return s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"flex items-start justify-between",children:s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-semibold",children:"Inventories"}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Claimable shared resources (dev envs, test DBs, named locks, …). Global in v1 — the same set appears on every workspace."})]})}),s.jsx("div",{className:"grid gap-4",children:e.inventories.map(k=>s.jsx(PX,{detail:k,now:o,onForceRelease:v=>l({slug:k.inventory.slug,lease:v})},k.inventory.slug))}),s.jsx(ss,{open:a!==null,title:"Force release this lease?",description:a?`This will revoke lease ${a.lease.lease_id} and (if it's still the current holder) free member ${a.lease.member_id}. Any agent still using this lease will see a stale-lease error on its next CLI call.`:"",confirmLabel:"Force release",destructive:!0,loading:u,onConfirm:y,onOpenChange:k=>{k||l(null)}}),s.jsx(Xn,{toast:p,onDismiss:g})]})}function PX({detail:e,now:t,onForceRelease:n}){const{inventory:r,members:o,active_leases:i}=e,a=o.filter(u=>u.status==="idle").length,l=o.filter(u=>u.status==="leased").length;return s.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",children:[s.jsx(zv,{className:"mr-2 inline h-4 w-4 text-muted-foreground"}),r.display_name??r.slug]}),s.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[s.jsx("code",{className:"font-mono",children:r.slug})," · kind=",r.kind," · default TTL=",e3(r.default_ttl_s)]})]}),s.jsx("div",{className:"text-right text-xs text-muted-foreground",children:s.jsxs("div",{children:[a," idle · ",l," leased · ",o.length," total"]})})]}),s.jsx("div",{className:"mt-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:o.map(u=>s.jsx(_X,{member:u},u.member_id))}),i.length>0&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Active leases"}),s.jsx("div",{className:"mt-2 space-y-2",children:i.map(u=>s.jsx(DX,{lease:u,now:t,onForceRelease:()=>n(u)},u.lease_id))})]})]})}function _X({member:e}){const t=AX(e.metadata_json);return s.jsxs("div",{className:"rounded-md border bg-muted/40 px-3 py-2 text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"font-mono",children:e.member_id}),s.jsx("span",{className:`rounded border px-1.5 py-0.5 text-xs ${RX(e.status)}`,children:e.status})]}),t&&s.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:Object.entries(t).map(([n,r])=>s.jsxs("div",{className:"truncate",children:[s.jsx("span",{className:"font-mono",children:n}),"=",s.jsx("span",{className:"font-mono",children:String(r)})]},n))})]})}function DX({lease:e,now:t,onForceRelease:n}){return s.jsxs("div",{className:"flex items-center justify-between rounded border bg-muted/20 px-3 py-2 text-sm",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[e.lease_id.slice(0,8),"…"]}),s.jsx("span",{className:"font-mono",children:e.member_id}),e.requested_for&&s.jsxs("span",{className:"text-xs text-muted-foreground",children:["for ",e.requested_for]})]})}),s.jsxs("div",{className:"ml-3 flex items-center gap-3",children:[s.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[s.jsx(eO,{className:"h-3 w-3"}),TX(e.expires_at,t)]}),s.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1 rounded border border-destructive/40 px-2 py-1 text-xs text-destructive hover:bg-destructive/10",children:[s.jsx(DO,{className:"h-3 w-3"}),"Force release"]})]})]})}function $X(e){switch(e.kind){case"at":return`at ${e.at}`;case"in":return`in ${Math.round((e.durationMs??0)/1e3)}s`;case"cron":return`cron ${e.expr}${e.tz?` (${e.tz})`:""}`;case"after-reset":return`after ${e.provider} reset`;case"when-status":return`when ${e.assignmentId??"this"} → ${e.status}`;case"when-plan-lands":return`when ${e.assignmentId??"this"} plan lands`;default:return e.kind}}async function IX(){const e=await fetch("/api/schedules");if(!e.ok)throw new Error(`HTTP ${e.status}`);return(await e.json()).schedules}async function LX(e){const t=await fetch("/api/schedules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json().catch(()=>null);if(!t.ok)throw new Error((n==null?void 0:n.error)??`HTTP ${t.status}`);return n.schedule}async function MX(e){const t=await fetch(`/api/schedules/${encodeURIComponent(e)}/cancel`,{method:"POST"});if(!t.ok){const n=await t.json().catch(()=>null);throw new Error((n==null?void 0:n.error)??`HTTP ${t.status}`)}}function OX(){const[e,t]=m.useState(null),[n,r]=m.useState(!0),[o,i]=m.useState(null),a=m.useCallback(async()=>{try{t(await IX()),i(null)}catch(l){i(l instanceof Error?l.message:"Failed to fetch schedules")}finally{r(!1)}},[]);return m.useEffect(()=>{a()},[a]),Ei(l=>{l.type==="schedules-updated"&&a()}),{data:e,loading:n,error:o,refetch:a}}const FX=[{value:"cron",label:"Cron expression"},{value:"at",label:"At a timestamp"},{value:"in",label:"After a delay"},{value:"after-reset",label:"After quota reset"},{value:"when-status",label:"When assignment reaches status"},{value:"when-plan-lands",label:"When plan lands"}];function zX({open:e,onOpenChange:t,onCreated:n}){const[r,o]=m.useState(""),[i,a]=m.useState("claude"),[l,u]=m.useState("cron"),[f,p]=m.useState(!0),[h,g]=m.useState(""),[y,k]=m.useState(""),[v,b]=m.useState("0 3 * * *"),[j,N]=m.useState(""),[S,C]=m.useState(""),[D,T]=m.useState("5"),[R,$]=m.useState("claude"),[P,F]=m.useState(""),[_,V]=m.useState("rolling-5h"),[U,I]=m.useState("ready_to_implement"),[M,B]=m.useState(""),[W,O]=m.useState(!1),[H,L]=m.useState(null);function z(){switch(l){case"cron":return{kind:l,expr:v,...j?{tz:j}:{}};case"at":return{kind:l,at:S};case"in":return{kind:l,durationMs:Math.round(Number(D)*36e5),anchorIso:new Date().toISOString()};case"after-reset":return{kind:l,provider:R,anchor:{windowStartIso:P||new Date().toISOString(),windowKind:_}};case"when-status":return{kind:l,status:U,...M?{assignmentId:M}:{}};case"when-plan-lands":return{kind:l,...M?{assignmentId:M}:{}}}}async function Y(){O(!0),L(null);try{const ee={assignmentId:r.trim(),agentId:i.trim(),trigger:z(),unattended:f,terminalPreference:h.trim()||null,promptTemplate:y.trim()||null};if(!ee.assignmentId)throw new Error("Assignment id is required");await LX(ee),n(),t(!1)}catch(ee){L(ee instanceof Error?ee.message:"Create failed")}finally{O(!1)}}const q="w-full rounded border bg-background px-2 py-1 text-sm",Q="block text-xs font-medium text-muted-foreground";return s.jsx(Mn,{open:e,onOpenChange:t,children:s.jsxs(Nn,{className:"max-h-[90vh] overflow-y-auto",children:[s.jsxs(sr,{className:"flex-row items-center justify-between space-y-0",children:[s.jsx(Cn,{children:"New schedule"}),s.jsx(zT,{className:"text-muted-foreground transition hover:text-foreground","aria-label":"Close",children:s.jsx(Pd,{className:"h-4 w-4"})})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Assignment id / slug"}),s.jsx("input",{autoFocus:!0,className:q,value:r,onChange:ee=>o(ee.target.value),placeholder:"scheduled-agents"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Agent"}),s.jsx("input",{className:q,value:i,onChange:ee=>a(ee.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Terminal (optional)"}),s.jsx("input",{className:q,value:h,onChange:ee=>g(ee.target.value),placeholder:"default"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Trigger"}),s.jsx("select",{className:q,value:l,onChange:ee=>u(ee.target.value),children:FX.map(ee=>s.jsx("option",{value:ee.value,children:ee.label},ee.value))})]}),l==="cron"&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Cron expr"}),s.jsx("input",{className:q,value:v,onChange:ee=>b(ee.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Timezone (optional)"}),s.jsx("input",{className:q,value:j,onChange:ee=>N(ee.target.value),placeholder:"local"})]})]}),l==="at"&&s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"ISO timestamp"}),s.jsx("input",{className:q,value:S,onChange:ee=>C(ee.target.value),placeholder:"2026-06-16T03:00:00Z"})]}),l==="in"&&s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Delay (hours)"}),s.jsx("input",{className:q,type:"number",value:D,onChange:ee=>T(ee.target.value)})]}),l==="after-reset"&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Provider"}),s.jsxs("select",{className:q,value:R,onChange:ee=>$(ee.target.value),children:[s.jsx("option",{value:"claude",children:"claude"}),s.jsx("option",{value:"codex",children:"codex"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Window kind"}),s.jsxs("select",{className:q,value:_,onChange:ee=>V(ee.target.value),children:[s.jsx("option",{value:"rolling-5h",children:"rolling-5h"}),s.jsx("option",{value:"weekly",children:"weekly"})]})]}),s.jsxs("div",{className:"col-span-2",children:[s.jsx("label",{className:Q,children:"Window start (optional ISO)"}),s.jsx("input",{className:q,value:P,onChange:ee=>F(ee.target.value),placeholder:"now"})]})]}),l==="when-status"&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Status"}),s.jsx("input",{className:q,value:U,onChange:ee=>I(ee.target.value)})]}),s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Watch assignment (optional)"}),s.jsx("input",{className:q,value:M,onChange:ee=>B(ee.target.value),placeholder:"this assignment"})]})]}),l==="when-plan-lands"&&s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Watch assignment (optional)"}),s.jsx("input",{className:q,value:M,onChange:ee=>B(ee.target.value),placeholder:"this assignment"})]}),s.jsxs("div",{children:[s.jsx("label",{className:Q,children:"Prompt template (optional)"}),s.jsx("input",{className:q,value:y,onChange:ee=>k(ee.target.value),placeholder:"plan @assignment"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:f,onChange:ee=>p(ee.target.checked)}),"Unattended (hard limits + kill switch apply)"]}),H&&s.jsx("p",{className:"text-sm text-destructive",children:H})]}),s.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>t(!1),className:"rounded border px-3 py-1 text-sm",children:"Cancel"}),s.jsx("button",{type:"button",onClick:Y,disabled:W,className:"rounded bg-primary px-3 py-1 text-sm text-primary-foreground disabled:opacity-50",children:W?"Creating…":"Create"})]})]})})}const BX=new Set(["completed","failed","launch_failed","cancelled","killed"]);function UX(e){return e==="running"?"border-success-foreground/30 bg-success text-success-foreground":e==="eligible"?"border-info-foreground/30 bg-info text-info-foreground":e==="held"?"border-warning-foreground/30 bg-warning text-warning-foreground":e==="launch_failed"||e==="failed"||e==="killed"?"border-error-foreground/30 bg-error text-error-foreground":"border-muted-foreground/30 bg-muted text-muted-foreground"}function HX(){const{data:e,loading:t,error:n,refetch:r}=OX(),[o,i]=m.useState(!1),{toast:a,showToast:l,dismissToast:u}=Qn();if(t)return s.jsx(bt,{label:"Loading schedules…"});if(n)return s.jsx(Rt,{title:"Could not load schedules",error:n,action:s.jsx("button",{type:"button",onClick:r,className:"rounded border px-3 py-1 text-sm",children:"Retry"})});async function f(p){try{await MX(p.id),r()}catch(h){l(h instanceof Error?`Cancel failed: ${h.message}`:"Cancel failed","error")}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-semibold",children:"Schedules"}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Run work on an assignment unattended — on a clock, after a quota reset, or when an assignment reaches a status. The scheduler tick is the sole authority; this page calls the same CLI verbs."})]}),s.jsxs("button",{type:"button",onClick:()=>i(!0),className:"shell-action shell-action--cta",children:[s.jsx(Mt,{className:"h-4 w-4"}),"New schedule"]})]}),!e||e.length===0?s.jsx(St,{title:"No schedules yet",description:"Create one above, or with `syntaur schedule create --assignment <id> --cron '0 3 * * *'`."}):s.jsx("div",{className:"grid gap-2",children:e.map(p=>s.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(l2,{className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"font-mono text-sm",children:p.assignmentId}),s.jsx("span",{className:`rounded border px-1.5 py-0.5 text-xs ${UX(p.attempt.state)}`,children:p.attempt.state}),!p.unattended&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"interactive"})]}),s.jsxs("div",{className:"mt-0.5 text-xs text-muted-foreground",children:[$X(p.trigger)," · agent ",s.jsx("code",{className:"font-mono",children:p.agentId}),p.attempt.lastError&&s.jsxs("span",{className:"text-destructive",children:[" · ",p.attempt.lastError]})]})]}),!BX.has(p.attempt.state)&&s.jsxs("button",{type:"button",onClick:()=>f(p),className:"flex items-center gap-1 rounded border border-destructive/40 px-2 py-1 text-xs text-destructive hover:bg-destructive/10",children:[s.jsx(KM,{className:"h-3 w-3"}),"Cancel"]})]},p.id))}),s.jsx(Xn,{toast:a,onDismiss:u}),s.jsx(zX,{open:o,onOpenChange:i,onCreated:r})]})}const VX={"7d":"7 days","30d":"30 days","90d":"90 days",all:"All time",custom:"Custom"},fi="rounded-md border border-border/60 bg-background px-2 py-1 text-sm text-foreground focus:border-primary focus:outline-none focus:ring-2 focus:ring-ring/30";function sC(){const[e,t]=Ts(),n=L4(e),r=n.window??"30d",o=e.get("groupBy")==="assignment"?"assignment":"project",{data:i}=to(),{data:a}=Ea(),{data:l}=q2(),[u,f]=m.useState(null),[p,h]=m.useState(!0),[g,y]=m.useState(null),[k,v]=m.useState(0);m.useEffect(()=>{if(!e.get("window")){const N=Nb({window:"30d",...n});o==="assignment"&&N.set("groupBy","assignment"),t(N,{replace:!0})}},[]);const b=B2({window:r,...n}).toString();m.useEffect(()=>{const N=new AbortController;h(!0),y(null);const S=b?`/api/usage?${b}&groupBy=${o}`:`/api/usage?groupBy=${o}`;return fetch(S,{signal:N.signal}).then(async C=>{if(!C.ok){const D=await C.json().catch(()=>({}));throw new Error(D.error??`HTTP ${C.status}`)}return C.json()}).then(C=>{f(C),h(!1)}).catch(C=>{C instanceof Error&&C.name==="AbortError"||(y(C instanceof Error?C.message:String(C)),h(!1))}),()=>N.abort()},[b,o,k]);function j(N,S=o){const C=Nb(N);S==="assignment"&&C.set("groupBy","assignment"),t(C)}return s.jsxs("div",{className:"p-6 max-w-7xl mx-auto",children:[s.jsxs("header",{className:"flex items-center gap-3 mb-6",children:[s.jsx(tm,{className:"w-6 h-6 text-primary"}),s.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:"Token usage"})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 items-end mb-6 p-4 rounded-lg bg-card border border-border/60",children:[s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Window"}),s.jsx("select",{value:r,onChange:N=>j({...n,window:N.target.value}),className:fi,children:sm.map(N=>s.jsx("option",{value:N,children:VX[N]},N))})]}),r==="custom"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Since"}),s.jsx("input",{type:"date",value:n.since??"",onChange:N=>j({...n,window:"custom",since:N.target.value||void 0}),className:fi})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Until"}),s.jsx("input",{type:"date",value:n.until??"",onChange:N=>j({...n,window:"custom",until:N.target.value||void 0}),className:fi})]})]}):null,s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Workspace"}),s.jsxs("select",{value:n.workspace??"",onChange:N=>j({...n,workspace:N.target.value||void 0,project:void 0}),className:fi,children:[s.jsx("option",{value:"",children:"All"}),a!=null&&a.hasUngrouped?s.jsx("option",{value:"_ungrouped",children:"(ungrouped)"}):null,((a==null?void 0:a.workspaces)??[]).map(N=>s.jsx("option",{value:N,children:N},N))]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Project"}),s.jsxs("select",{value:n.project??"",onChange:N=>j({...n,project:N.target.value||void 0,workspace:void 0}),className:fi,children:[s.jsx("option",{value:"",children:"All"}),(i??[]).map(N=>s.jsx("option",{value:N.slug,children:N.slug},N.slug))]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Model"}),s.jsxs("select",{value:n.model??"",onChange:N=>j({...n,model:N.target.value||void 0}),className:fi,children:[s.jsx("option",{value:"",children:"All"}),((l==null?void 0:l.models)??[]).map(N=>s.jsx("option",{value:N,children:N},N))]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Tool"}),s.jsxs("select",{value:n.tool??"",onChange:N=>j({...n,tool:N.target.value||void 0}),className:fi,children:[s.jsx("option",{value:"",children:"All"}),((l==null?void 0:l.tools)??[]).map(N=>s.jsx("option",{value:N,children:N},N))]})]}),s.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Group by"}),s.jsxs("select",{value:o,onChange:N=>j(n,N.target.value),className:fi,children:[s.jsx("option",{value:"project",children:"Project"}),s.jsx("option",{value:"assignment",children:"Assignment"})]})]})]}),p&&s.jsx(bt,{label:"Loading usage…"}),g&&s.jsx(Rt,{error:g,action:s.jsx("button",{type:"button",className:"shell-action",onClick:()=>v(N=>N+1),children:"Retry"})}),u&&!p&&!g&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"mb-8",children:[s.jsx("h2",{className:"text-lg font-medium mb-2",children:"Summary"}),u.summary.length===0?s.jsxs("p",{className:"text-muted-foreground text-sm",children:["No usage data for these filters. Run"," ",s.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-primary",children:"syntaur usage"})," ","to ingest the latest ccusage data."]}):s.jsxs("table",{className:"w-full text-sm border border-border/60 rounded overflow-hidden",children:[s.jsx("thead",{className:"bg-muted/50 text-muted-foreground",children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left px-3 py-2",children:"Project"}),o==="assignment"&&s.jsx("th",{className:"text-left px-3 py-2",children:"Assignment"}),s.jsx("th",{className:"text-right px-3 py-2",children:"Tokens"}),s.jsx("th",{className:"text-right px-3 py-2",children:"Cost"}),s.jsx("th",{className:"text-left px-3 py-2",children:"Last event"})]})}),s.jsx("tbody",{children:u.summary.map((N,S)=>s.jsxs("tr",{className:"border-t border-border/60",children:[s.jsx("td",{className:"px-3 py-2",children:N.projectSlug||"(unattributed)"}),o==="assignment"&&s.jsx("td",{className:"px-3 py-2",children:N.assignmentSlug||"(unattributed)"}),s.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:Xl(N.totalTokens)}),s.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:Ql(N.totalCost)}),s.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:N.lastEventDay})]},S))})]})]}),s.jsxs("section",{children:[s.jsx("h2",{className:"text-lg font-medium mb-2",children:"Daily breakdown"}),u.daily.length===0?s.jsx("p",{className:"text-muted-foreground text-sm",children:"No daily rows."}):s.jsxs("table",{className:"w-full text-sm border border-border/60 rounded overflow-hidden",children:[s.jsx("thead",{className:"bg-muted/50 text-muted-foreground",children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left px-3 py-2",children:"Day"}),s.jsx("th",{className:"text-left px-3 py-2",children:"Tool"}),s.jsx("th",{className:"text-left px-3 py-2",children:"Model"}),s.jsx("th",{className:"text-left px-3 py-2",children:"Project"}),s.jsx("th",{className:"text-left px-3 py-2",children:"Assignment"}),s.jsx("th",{className:"text-right px-3 py-2",children:"Tokens"}),s.jsx("th",{className:"text-right px-3 py-2",children:"Cost"})]})}),s.jsx("tbody",{children:u.daily.map((N,S)=>s.jsxs("tr",{className:"border-t border-border/60",children:[s.jsx("td",{className:"px-3 py-2 tabular-nums",children:N.day}),s.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:N.tool}),s.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:N.model}),s.jsx("td",{className:"px-3 py-2",children:N.project_slug||"–"}),s.jsx("td",{className:"px-3 py-2",children:N.assignment_slug||"–"}),s.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:Xl(N.total_tokens)}),s.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:Ql(N.total_cost)})]},S))})]})]})]})]})}function oC(){const{workspace:e}=qt(),{data:t}=to(),{data:n,loading:r,error:o}=im(),[i,a]=m.useState(""),[l,u]=m.useState(""),[f,p]=m.useState(""),[h,g]=m.useState("started_desc"),[y,k]=m.useState(0),[v,b]=m.useState(new Set),[j,N]=m.useState(!1),[S,C]=m.useState(null),[D,T]=m.useState(null),R=(n==null?void 0:n.sessions.some(I=>I.status==="active"))??!1;m.useEffect(()=>{if(!R)return;const I=window.setInterval(()=>k(M=>M+1),3e4);return()=>window.clearInterval(I)},[R]),m.useEffect(()=>{b(I=>{if(I.size===0)return I;const M=new Set((n==null?void 0:n.sessions.map(W=>W.sessionId))??[]),B=new Set([...I].filter(W=>M.has(W)));return B.size===I.size?I:B})},[n]);const $=m.useMemo(()=>{if(!n)return[];if(e&&!t)return[];const I=i.trim().toLowerCase();return[...n.sessions.filter(B=>{var H;if(e&&t){const L=((H=t.find(z=>z.slug===B.projectSlug))==null?void 0:H.workspace)??null;if(e==="_ungrouped"){if(L!==null)return!1}else if(L!==e)return!1}const W=qX(B.started);return l&&(!W||W<l)||f&&(!W||W>f)?!1:I?[B.projectSlug??"",B.assignmentSlug??"",B.agent,B.sessionId,B.path,B.description??"",B.transcriptPath??""].join(" ").toLowerCase().includes(I):!0})].sort((B,W)=>KX(B,W,h))},[n,i,h,l,f,y,e,t]);function P(I){b(M=>{const B=new Set(M);return B.has(I)?B.delete(I):B.add(I),B})}function F(){v.size===$.length&&$.length>0?b(new Set):b(new Set($.map(I=>I.sessionId)))}async function _(I){C(null),N(!0);try{const M=await fetch("/api/agent-sessions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionIds:I})}),B=await M.json().catch(()=>null);if(!M.ok)throw new Error((B==null?void 0:B.error)||`HTTP ${M.status}`);b(W=>new Set([...W].filter(O=>!I.includes(O)))),T(null)}catch(M){C(M.message)}finally{N(!1)}}async function V(I){try{const M=await fetch(`/api/agent-sessions/${encodeURIComponent(I)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"stopped"})});if(!M.ok){const B=await M.json().catch(()=>null);C((B==null?void 0:B.error)||`Failed to mark session stopped: HTTP ${M.status}`)}}catch(M){C(M.message)}}if(r)return s.jsx(bt,{label:"Loading agent sessions..."});if(o)return s.jsx(Rt,{error:o});if(!n)return null;const U=n.sessions.length>0;return s.jsxs(s.Fragment,{children:[s.jsxs(Gw,{children:[s.jsx(Fm,{value:i,onChange:a,placeholder:"Search project, assignment, agent, session ID, path, or description"}),s.jsxs("label",{className:"flex min-w-[150px] flex-col gap-1 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Started From",s.jsx("input",{type:"date",value:l,onChange:I=>u(I.target.value),className:"editor-input min-w-[150px]"})]}),s.jsxs("label",{className:"flex min-w-[150px] flex-col gap-1 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Started To",s.jsx("input",{type:"date",value:f,onChange:I=>p(I.target.value),className:"editor-input min-w-[150px]"})]}),s.jsxs("select",{value:h,onChange:I=>g(I.target.value),className:"editor-input max-w-[200px]",children:[s.jsx("option",{value:"started_desc",children:"Newest first"}),s.jsx("option",{value:"started_asc",children:"Oldest first"}),s.jsx("option",{value:"assignment_asc",children:"Assignment A-Z"}),s.jsx("option",{value:"agent_asc",children:"Agent A-Z"})]})]}),S?s.jsx("div",{className:"mt-4 rounded-md border border-error-foreground/30 bg-error px-4 py-3 text-sm text-error-foreground",children:S}):null,v.size>0&&s.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded border border-border/40 bg-muted/30 px-4 py-2 text-sm",children:[s.jsxs("span",{className:"text-muted-foreground",children:[v.size," session",v.size!==1?"s":""," selected"]}),s.jsxs("button",{className:"shell-action text-destructive",onClick:()=>T({sessionIds:[...v],title:`Delete ${v.size} selected session${v.size===1?"":"s"}?`,description:"This removes the selected agent session records from the dashboard. This cannot be undone.",confirmLabel:v.size===1?"Delete Session":"Delete Sessions"}),disabled:j,children:[s.jsx(jn,{className:"mr-1 inline h-3.5 w-3.5"}),"Delete Selected"]}),s.jsx("button",{className:"shell-action",onClick:()=>b(new Set),children:"Clear Selection"})]}),U?$.length===0?s.jsx(St,{title:"No agent sessions match these filters",description:"Adjust the status, search term, date range, or sorting controls to show sessions again."}):s.jsx("div",{className:"surface-panel mt-4 overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[960px] table-fixed text-sm lg:min-w-[1280px]",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/40 text-left text-xs uppercase tracking-wider text-muted-foreground",children:[s.jsx("th",{className:"w-[32px] pb-2 pr-3",children:s.jsx("button",{onClick:F,className:"text-muted-foreground hover:text-foreground",children:v.size===$.length&&$.length>0?s.jsx(ys,{className:"h-4 w-4"}):s.jsx(qv,{className:"h-4 w-4"})})}),s.jsx("th",{className:"w-[140px] pb-2 pr-3",children:"Project"}),s.jsx("th",{className:"w-[160px] pb-2 pr-3",children:"Assignment"}),s.jsx("th",{className:"w-[200px] pb-2 pr-3",children:"Description"}),s.jsx("th",{className:"w-[110px] pb-2 pr-3",children:"Agent"}),s.jsx("th",{className:"hidden w-[130px] pb-2 pr-3 lg:table-cell",children:"Session ID"}),s.jsx("th",{className:"w-[140px] pb-2 pr-3",children:"Started"}),s.jsx("th",{className:"hidden w-[200px] pb-2 pr-3 lg:table-cell",children:"Path"}),s.jsx("th",{className:"hidden w-[200px] pb-2 pr-3 lg:table-cell",children:"Transcript"}),s.jsx("th",{className:"w-[40px] pb-2"})]})}),s.jsx("tbody",{children:$.map(I=>s.jsx(WX,{session:I,selected:v.has(I.sessionId),onToggle:()=>P(I.sessionId),onDelete:()=>T({sessionIds:[I.sessionId],title:`Delete session ${I.sessionId.slice(0,8)}...?`,description:`Remove this ${I.agent} session record${I.assignmentSlug?` for ${I.assignmentSlug}`:""}. This cannot be undone.`,confirmLabel:"Delete Session"}),onMarkStopped:V,onCopyError:C},I.sessionId))})]})}):s.jsx(St,{title:"No agent sessions",description:"No agent sessions have been registered yet. Use /grab-assignment or syntaur track-session to register one."}),s.jsx(ss,{open:D!==null,title:(D==null?void 0:D.title)??"Delete session?",description:(D==null?void 0:D.description)??"",confirmLabel:(D==null?void 0:D.confirmLabel)??"Delete",destructive:!0,loading:j,onOpenChange:I=>{I||T(null)},onConfirm:async()=>{D&&await _(D.sessionIds)}})]})}function WX({session:e,selected:t,onToggle:n,onDelete:r,onMarkStopped:o,onCopyError:i}){const a=mn(),l=e.sessionId.length>12?e.sessionId.slice(0,8)+"...":e.sessionId,u=e.path?e.path.replace(/^\/Users\/[^/]+/,"~"):"—",f=e.transcriptPath?e.transcriptPath.replace(/^\/Users\/[^/]+/,"~"):"—";return s.jsxs("tr",{className:"border-b border-border/20 last:border-0",children:[s.jsx("td",{className:"py-2 pr-3",children:s.jsx("button",{onClick:n,className:"text-muted-foreground hover:text-foreground",children:t?s.jsx(ys,{className:"h-4 w-4"}):s.jsx(qv,{className:"h-4 w-4"})})}),s.jsx("td",{className:"py-2 pr-3",children:e.projectSlug?s.jsx(De,{to:`${a}/projects/${e.projectSlug}`,className:"block truncate text-primary hover:underline",title:bn(e.projectSlug),children:bn(e.projectSlug)}):e.assignmentSlug?s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] font-mono uppercase tracking-wide text-muted-foreground",children:"Standalone"}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx("td",{className:"py-2 pr-3",children:e.projectSlug&&e.assignmentSlug?s.jsx(De,{to:`${a}/projects/${e.projectSlug}/assignments/${e.assignmentSlug}`,className:"block truncate text-primary hover:underline",title:bn(e.assignmentSlug),children:bn(e.assignmentSlug)}):e.assignmentSlug?s.jsx(De,{to:`/assignments/${e.assignmentSlug}`,className:"block truncate font-mono text-primary hover:underline",title:e.assignmentSlug,children:e.assignmentSlug}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx("td",{className:"py-2 pr-3",children:e.description?s.jsx("div",{className:"truncate text-xs text-muted-foreground",title:e.description,children:e.description}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx("td",{className:"py-2 pr-3",children:s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Xh,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"block min-w-0 truncate",children:e.agent})]})}),s.jsx("td",{className:"hidden py-2 pr-3 lg:table-cell",children:s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"block min-w-0 truncate font-mono text-xs text-muted-foreground",title:e.sessionId,children:l}),s.jsx(Hr,{value:e.sessionId}),s.jsx(S_,{sessionId:e.sessionId,disabled:!e.resumeSupported,disabledReason:"Resume not supported for this agent",onError:p=>i(p.message),onNotice:p=>i(p)})]})}),s.jsx("td",{className:"py-2 pr-3 text-xs text-muted-foreground",children:s.jsx("span",{className:"truncate block",children:Nr(e.started)})}),s.jsx("td",{className:"hidden py-2 pr-3 lg:table-cell",children:s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"block min-w-0 truncate text-xs text-muted-foreground",title:e.path,children:u}),e.path&&s.jsx(Hr,{value:e.path})]})}),s.jsx("td",{className:"hidden py-2 pr-3 lg:table-cell",children:e.transcriptPath?s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"block min-w-0 truncate font-mono text-xs text-muted-foreground",title:e.transcriptPath,children:f}),s.jsx(Hr,{value:e.transcriptPath})]}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx("td",{className:"py-2",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(R_,{session:e,onMarkStopped:o}),s.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-destructive",title:"Delete session",children:s.jsx(jn,{className:"h-3.5 w-3.5"})})]})})]})}function qX(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return null;const n=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0");return`${n}-${r}-${o}`}function bp(e){const t=Date.parse(e.started),n=e.ended?Date.parse(e.ended):Date.now();return Number.isNaN(t)||Number.isNaN(n)?0:Math.max(0,Math.floor((n-t)/6e4))}function KX(e,t,n){switch(n){case"started_asc":return e.started.localeCompare(t.started);case"started_desc":return t.started.localeCompare(e.started);case"duration_asc":return bp(e)-bp(t);case"duration_desc":return bp(t)-bp(e);case"assignment_asc":return(e.assignmentSlug??"").localeCompare(t.assignmentSlug??"")||(e.projectSlug??"").localeCompare(t.projectSlug??"");case"agent_asc":return e.agent.localeCompare(t.agent)||(e.assignmentSlug??"").localeCompare(t.assignmentSlug??"");default:return 0}}function GX(){const{data:e,loading:t,error:n,refetch:r}=Zv(),[o,i]=m.useState(""),[a,l]=m.useState(null),[u,f]=m.useState(null),[p,h]=m.useState(null),g=m.useMemo(()=>{if(!(e!=null&&e.playbooks))return[];if(!o.trim())return e.playbooks;const v=o.toLowerCase();return e.playbooks.filter(b=>b.name.toLowerCase().includes(v)||b.description.toLowerCase().includes(v)||b.slug.toLowerCase().includes(v)||b.tags.some(j=>j.toLowerCase().includes(v)))},[e,o]);async function y(v,b,j){if(v.preventDefault(),v.stopPropagation(),!a){l(b);try{const N=j?"disable":"enable",S=await fetch(`/api/playbooks/${encodeURIComponent(b)}/${N}`,{method:"POST"});if(!S.ok){const C=await S.json().catch(()=>({}));throw new Error(C.error||`Failed to ${N} playbook`)}r()}catch(N){console.error(N),alert(N instanceof Error?N.message:"Failed to update playbook")}finally{l(null)}}}async function k(){if(u){h(u.slug);try{const v=await fetch(`/api/playbooks/${encodeURIComponent(u.slug)}`,{method:"DELETE"});if(!v.ok){const b=await v.json().catch(()=>({}));throw new Error(b.error||"Failed to delete playbook")}f(null),r()}catch(v){console.error(v),alert(v instanceof Error?v.message:"Failed to delete playbook")}finally{h(null)}}}return t?s.jsx(bt,{label:"Loading playbooks..."}):n?s.jsx(Rt,{error:n}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsxs("div",{className:"relative flex-1 max-w-sm",children:[s.jsx(Ci,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{type:"text",placeholder:"Search playbooks...",value:o,onChange:v=>i(v.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),s.jsxs(De,{to:"/playbooks/create",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:[s.jsx(Mt,{className:"h-4 w-4"}),"Create Playbook"]})]}),s.jsxs(De,{to:"/playbooks/manifest",className:"surface-panel group flex items-center gap-3 p-3 transition hover:border-foreground/20",children:[s.jsx(p2,{className:"h-5 w-5 shrink-0 text-muted-foreground"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground group-hover:underline",children:"Playbook Manifest"}),s.jsx("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-[10px] text-muted-foreground",children:"auto-generated"})]}),s.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Index of all playbooks with descriptions. Include ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-[11px]",children:"~/.syntaur/playbooks/manifest.md"})," in your CLAUDE.md for agent context."]})]})]}),g.length===0?s.jsx(St,{title:"No playbooks found",description:(e==null?void 0:e.playbooks.length)===0?"Playbooks define rules and workflows for how agents should operate. Create your first one to get started.":"No playbooks match your search.",actions:(e==null?void 0:e.playbooks.length)===0?s.jsxs(De,{to:"/playbooks/create",className:"inline-flex items-center gap-2 rounded-md bg-foreground px-3 py-2 text-sm font-medium text-background transition hover:bg-foreground/90",children:[s.jsx(Mt,{className:"h-4 w-4"}),"Create Playbook"]}):void 0}):s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:g.map(v=>{const b=a===v.slug,j=[{key:"delete",label:"Delete",icon:jn,destructive:!0,onSelect:()=>f({slug:v.slug,name:v.name})}];return s.jsxs("div",{className:`surface-panel relative flex flex-col gap-2 p-4 transition hover:border-foreground/20 ${v.enabled?"":"opacity-75"}`,children:[s.jsx("div",{className:"absolute right-3 top-3 z-10",children:s.jsx(Hw,{items:j})}),s.jsxs(De,{to:`/playbooks/${v.slug}`,className:"group flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(a2,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground group-hover:underline",children:v.name}),v.description?s.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground line-clamp-2",children:v.description}):null]})]}),s.jsx("div",{className:"flex items-center gap-2 pt-1 pr-20",children:s.jsxs("div",{className:"flex flex-wrap gap-1",children:[v.tags.slice(0,3).map(N=>s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-[10px] text-muted-foreground",children:[s.jsx(y2,{className:"h-2.5 w-2.5"}),N]},N)),v.tags.length>3?s.jsxs("span",{className:"text-[10px] text-muted-foreground/60",children:["+",v.tags.length-3]}):null]})})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":v.enabled,"aria-label":v.enabled?"Disable playbook":"Enable playbook",onClick:N=>y(N,v.slug,v.enabled),disabled:b,className:`absolute bottom-3 right-3 z-10 inline-flex h-5 w-9 items-center rounded-full border opacity-100 transition disabled:opacity-50 ${v.enabled?"border-status-completed-foreground/60 bg-status-completed-foreground/80":"border-foreground/40 bg-foreground/15"}`,children:s.jsx("span",{className:`block h-4 w-4 rounded-full shadow-sm transition-transform ${v.enabled?"translate-x-[18px] bg-background":"translate-x-[2px] bg-foreground/70"}`})})]},v.slug)})}),s.jsx(ss,{open:u!==null,title:"Delete playbook?",description:u?`"${u.name}" will be removed from disk and the playbook manifest will be regenerated. This cannot be undone.`:"",confirmLabel:"Delete",destructive:!0,loading:p!==null,onConfirm:k,onOpenChange:v=>{v||f(null)}})]})}function YX(){const{slug:e}=qt(),t=Wt(),{data:n,loading:r,error:o,refetch:i}=K4(e),[a,l]=m.useState(!1),[u,f]=m.useState(!1),[p,h]=m.useState(!1),[g,y]=m.useState(!1),[k,v]=m.useState(""),[b,j]=m.useState(!1),[N,S]=m.useState(null),C=e==="manifest";m.useEffect(()=>{g&&(v(e??""),S(null))},[g,e]);const D=Ir(k),T=D.length>0&&Lp(D)&&D!=="manifest",R=D!==e;async function $(){if(!(!e||!T||!R)){j(!0),S(null);try{const _=await fetch(`/api/playbooks/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({newSlug:D})});if(!_.ok){const V=await _.json().catch(()=>({}));throw new Error(V.error||"Failed to rename playbook")}y(!1),t(`/playbooks/${D}`)}catch(_){S(_ instanceof Error?_.message:"Failed to rename playbook")}finally{j(!1)}}}async function P(){if(e){f(!0);try{(await fetch(`/api/playbooks/${e}`,{method:"DELETE"})).ok&&t("/playbooks")}finally{f(!1)}}}async function F(){if(!(!e||!n)){h(!0);try{const _=n.enabled?"disable":"enable",V=await fetch(`/api/playbooks/${encodeURIComponent(e)}/${_}`,{method:"POST"});if(!V.ok){const U=await V.json().catch(()=>({}));throw new Error(U.error||`Failed to ${_} playbook`)}i()}catch(_){console.error(_),alert(_ instanceof Error?_.message:"Failed to update playbook")}finally{h(!1)}}}return r?s.jsx(bt,{label:"Loading playbook..."}):o?s.jsx(Rt,{error:o}):n?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:C?"Playbook Manifest":n.name}),C?s.jsx("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-xs text-muted-foreground",children:"auto-generated"}):null]}),!C&&n.description?s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:n.description}):null,C?s.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["This file is rebuilt automatically when playbooks are added or removed. Include"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"~/.syntaur/playbooks/manifest.md"})," ","in your CLAUDE.md for agent context."]}):null,!C&&n.whenToUse?s.jsxs("p",{className:"mt-2 text-sm text-muted-foreground italic",children:["When to use: ",n.whenToUse]}):null,s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[s.jsxs("span",{children:["Created ",Nr(n.created)]}),s.jsxs("span",{children:["Updated ",Nr(n.updated)]})]}),n.tags.length>0?s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:n.tags.map(_=>s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-xs text-muted-foreground",children:[s.jsx(y2,{className:"h-3 w-3"}),_]},_))}):null]}),C?null:s.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:n.enabled?"Enabled":"Disabled"}),s.jsx("button",{type:"button",role:"switch","aria-checked":n.enabled,"aria-label":n.enabled?"Disable playbook":"Enable playbook",onClick:F,disabled:p,className:`inline-flex h-5 w-9 items-center rounded-full border transition disabled:opacity-50 ${n.enabled?"border-status-completed-foreground/60 bg-status-completed-foreground/80":"border-foreground/40 bg-foreground/15"}`,children:s.jsx("span",{className:`block h-4 w-4 rounded-full shadow-sm transition-transform ${n.enabled?"translate-x-[18px] bg-background":"translate-x-[2px] bg-foreground/70"}`})})]}),s.jsxs(De,{to:`/playbooks/${e}/edit`,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:[s.jsx(xc,{className:"h-3 w-3"}),"Edit"]}),s.jsxs("button",{type:"button",onClick:()=>y(!0),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:[s.jsx(IO,{className:"h-3 w-3"}),"Rename"]}),a?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:P,disabled:u,className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90 disabled:opacity-50",children:u?"Deleting...":"Confirm"}),s.jsx("button",{type:"button",onClick:()=>l(!1),className:"inline-flex h-8 items-center rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:"Cancel"})]}):s.jsxs("button",{type:"button",onClick:()=>l(!0),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-destructive transition hover:bg-destructive/10",children:[s.jsx(jn,{className:"h-3 w-3"}),"Delete"]})]})]}),s.jsx("div",{className:"surface-panel p-4",children:s.jsx(vn,{content:n.body})}),s.jsx(Mn,{open:g,onOpenChange:_=>b?void 0:y(_),children:s.jsxs(Nn,{children:[s.jsxs(sr,{children:[s.jsx(Cn,{children:"Rename playbook"}),s.jsx(ns,{children:"The slug changes both the file name and the canonical slug stored in frontmatter. The URL will update on save."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"rename-slug-input",className:"block text-xs font-medium text-muted-foreground",children:"New slug"}),s.jsx("input",{id:"rename-slug-input",type:"text",autoFocus:!0,value:k,onChange:_=>v(_.target.value),disabled:b,className:"h-9 w-full rounded-md border border-border/70 bg-background px-3 text-sm text-foreground focus:border-foreground/40 focus:outline-none",placeholder:"my-new-slug"}),k&&D!==k?s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Will be normalized to ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:D||"—"})]}):null,k&&!T?s.jsx("p",{className:"text-xs text-destructive",children:'Slugs must be lowercase, hyphen-separated, with no special characters, and cannot be "manifest".'}):null]}),N?s.jsx("p",{className:"text-sm text-destructive",role:"alert",children:N}):null,s.jsxs(Wr,{children:[s.jsx("button",{type:"button",onClick:()=>y(!1),disabled:b,className:"shell-action mt-0 disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),s.jsx("button",{type:"button",onClick:$,disabled:b||!T||!R,className:"shell-action mt-0 shell-action--cta disabled:cursor-not-allowed disabled:opacity-50",children:b?"Renaming…":"Rename"})]})]})})]}):null}function XX(){const e=Wt(),[t,n]=m.useState(null),[r,o]=m.useState(!0),[i,a]=m.useState(!1),[l,u]=m.useState(null);m.useEffect(()=>{fetch("/api/playbooks/template/new").then(p=>p.json()).then(p=>{n(p.content),o(!1)}).catch(p=>{u(p.message),o(!1)})},[]);async function f(p){a(!0),u(null);try{const h=await fetch("/api/playbooks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:p})}),g=await h.json();if(!h.ok){u(g.error||`HTTP ${h.status}`),a(!1);return}e(`/playbooks/${g.slug}`)}catch(h){u(h.message),a(!1);return}a(!1)}return r?s.jsx(bt,{label:"Loading playbook template..."}):l&&!t?s.jsx(Rt,{error:l}):s.jsx(Ac,{initialContent:t||"",documentType:"playbook",mode:"create",onSave:f,saving:i,error:l,title:"Create Playbook",description:"Playbooks define rules and workflows for how agents should operate. Keep them short, imperative, and focused on a single concern.",onCancel:()=>e("/playbooks"),allowSlugEdit:!0})}function QX(){const{slug:e}=qt(),t=Wt(),[n,r]=m.useState(null),[o,i]=m.useState(!0),[a,l]=m.useState(!1),[u,f]=m.useState(null);m.useEffect(()=>{e&&fetch(`/api/playbooks/${e}/edit`).then(h=>h.json()).then(h=>{r(h.content),i(!1)}).catch(h=>{f(h.message),i(!1)})},[e]);async function p(h){if(e){l(!0),f(null);try{const g=await fetch(`/api/playbooks/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:h})}),y=await g.json();if(!g.ok){f(y.error||`HTTP ${g.status}`),l(!1);return}t(`/playbooks/${e}`)}catch(g){f(g.message),l(!1);return}l(!1)}}return o?s.jsx(bt,{label:"Loading playbook..."}):u&&!n?s.jsx(Rt,{error:u}):s.jsx(Ac,{initialContent:n||"",documentType:"playbook",mode:"edit",onSave:p,saving:a,error:u,title:"Edit Playbook",onCancel:()=>t(`/playbooks/${e}`)})}function JX(){const{data:e,loading:t,error:n}=G4(),[r,o]=m.useState(""),[i,a]=m.useState("all"),[l,u]=m.useState("all"),[f,p]=m.useState("all"),h=(e==null?void 0:e.memories)??[],g=m.useMemo(()=>Array.from(new Set(h.map(b=>b.projectSlug))).sort(),[h]),y=m.useMemo(()=>Array.from(new Set(h.map(b=>b.scope).filter(Boolean))).sort(),[h]),k=m.useMemo(()=>Array.from(new Set(h.map(b=>b.source).filter(Boolean))).sort(),[h]),v=m.useMemo(()=>h.filter(b=>{if(i!=="all"&&b.projectSlug!==i||l!=="all"&&b.scope!==l||f!=="all"&&b.source!==f)return!1;if(r.trim()){const j=r.toLowerCase();if(!b.name.toLowerCase().includes(j)&&!b.slug.toLowerCase().includes(j)&&!b.projectTitle.toLowerCase().includes(j))return!1}return!0}),[h,r,i,l,f]);return t?s.jsx(bt,{label:"Loading memories…"}):n?s.jsx(Rt,{error:n}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Ci,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{type:"text",placeholder:"Search memories…",value:r,onChange:b=>o(b.target.value),className:"h-9 w-64 rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),s.jsxs("select",{value:i,onChange:b=>a(b.target.value),className:"editor-input max-w-[170px]",children:[s.jsx("option",{value:"all",children:"All projects"}),g.map(b=>s.jsx("option",{value:b,children:b},b))]}),s.jsxs("select",{value:l,onChange:b=>u(b.target.value),className:"editor-input max-w-[140px]",children:[s.jsx("option",{value:"all",children:"All scopes"}),y.map(b=>s.jsx("option",{value:b,children:b},b))]}),s.jsxs("select",{value:f,onChange:b=>p(b.target.value),className:"editor-input max-w-[140px]",children:[s.jsx("option",{value:"all",children:"All sources"}),k.map(b=>s.jsx("option",{value:b,children:b},b))]})]}),s.jsxs(De,{to:"/memories/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:[s.jsx(Mt,{className:"h-4 w-4"}),"New Memory"]})]}),v.length===0?s.jsx(St,{title:h.length===0?"No memories yet":"No memories match these filters",description:h.length===0?"Memories capture patterns and learnings discovered while working in a project. Agents create them via /create-memory or you can add one manually.":"Clear the current filters or create a new memory.",actions:h.length===0?s.jsxs(De,{to:"/memories/new",className:"inline-flex items-center gap-2 rounded-md bg-foreground px-3 py-2 text-sm font-medium text-background transition hover:bg-foreground/90",children:[s.jsx(Mt,{className:"h-4 w-4"}),"New Memory"]}):void 0}):s.jsx("div",{className:"surface-panel overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[820px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Name"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Project"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Scope"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Source"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"# Related"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Updated"})]})}),s.jsx("tbody",{children:v.map(b=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[s.jsx("td",{className:"px-3 py-3",children:s.jsx(De,{to:`/projects/${b.projectSlug}/memories/${b.slug}`,className:"font-semibold text-foreground hover:text-primary",children:b.name||b.slug})}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:s.jsx(De,{to:`/projects/${b.projectSlug}`,className:"hover:text-foreground hover:underline",children:b.projectTitle})}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:b.scope||"—"}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:b.source||"—"}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:b.relatedAssignments.length}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:Yn(b.updated)})]},`${b.projectSlug}/${b.slug}`))})]})})]})}function ZX(){const{slug:e,itemSlug:t}=qt(),n=Wt(),{data:r,loading:o,error:i}=Y4(e,t),[a,l]=m.useState(!1),[u,f]=m.useState(!1);async function p(){if(!(!e||!t)){f(!0);try{(await fetch(`/api/projects/${e}/memories/${t}`,{method:"DELETE"})).ok&&n("/memories")}finally{f(!1)}}}return o?s.jsx(bt,{label:"Loading memory…"}):i?s.jsx(Rt,{error:i}):r?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:r.name||r.slug}),s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(De,{to:`/projects/${r.projectSlug}`,className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 hover:text-foreground",children:r.projectTitle}),r.scope?s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:["Scope: ",r.scope]}):null,r.source?s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:["Source: ",r.source]}):null,r.sourceAssignment?s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:["From: ",r.sourceAssignment]}):null,s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:[r.relatedAssignments.length," related"]})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[s.jsxs("span",{children:["Created ",Nr(r.created)]}),s.jsxs("span",{children:["Updated ",Nr(r.updated)]})]}),r.tags&&r.tags.length>0?s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:r.tags.map(h=>s.jsx("span",{className:"inline-flex items-center rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 text-xs text-muted-foreground",children:h},h))}):null]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs(De,{to:`/projects/${e}/memories/${t}/edit`,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:[s.jsx(xc,{className:"h-3 w-3"}),"Edit"]}),a?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:p,disabled:u,className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90 disabled:opacity-50",children:u?"Deleting…":"Confirm"}),s.jsx("button",{type:"button",onClick:()=>l(!1),className:"inline-flex h-8 items-center rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:"Cancel"})]}):s.jsxs("button",{type:"button",onClick:()=>l(!0),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-destructive transition hover:bg-destructive/10",children:[s.jsx(jn,{className:"h-3 w-3"}),"Delete"]})]})]}),s.jsx("div",{className:"surface-panel p-4",children:s.jsx(vn,{content:r.body})})]}):null}function eQ(){const e=Wt(),[t]=Ts(),n=t.get("project"),{data:r,loading:o,error:i}=to(),[a,l]=m.useState(n??""),[u,f]=m.useState(""),[p,h]=m.useState(""),[g,y]=m.useState(!1),[k,v]=m.useState(null);m.useEffect(()=>{!a&&r&&r.length>0&&l(n??r[0].slug)},[r,n,a]);async function b(j){if(j.preventDefault(),!(!a||!u.trim())){y(!0),v(null);try{const N=await fetch(`/api/projects/${a}/memories`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:u.trim(),body:p||void 0})}),S=await N.json();if(!N.ok){v(S.error||`HTTP ${N.status}`),y(!1);return}e(`/projects/${S.projectSlug}/memories/${S.slug}`)}catch(N){v(N.message),y(!1)}}}return o?s.jsx(bt,{label:"Loading projects…"}):i?s.jsx(Rt,{error:i}):!r||r.length===0?s.jsx(Rt,{error:"You need at least one project before you can create a memory. Create a project from the sidebar."}):s.jsxs("form",{onSubmit:b,className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"New Memory"}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Memories capture patterns and learnings discovered during work in a project. They are available to every assignment in that project."})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"project",className:"block text-sm font-medium text-foreground",children:"Project"}),s.jsx("select",{id:"project",value:a,onChange:j=>l(j.target.value),className:"editor-input",required:!0,children:r.map(j=>s.jsx("option",{value:j.slug,children:j.title},j.slug))})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-foreground",children:"Name"}),s.jsx("input",{id:"name",type:"text",value:u,onChange:j=>f(j.target.value),placeholder:"e.g. PostgreSQL connection pooling",className:"editor-input",required:!0,autoFocus:!0}),s.jsx("p",{className:"text-xs text-muted-foreground/80",children:"The slug is auto-derived from the name. Letters, digits, and hyphens."})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"body",className:"block text-sm font-medium text-foreground",children:"Body"}),s.jsx("textarea",{id:"body",value:p,onChange:j=>h(j.target.value),rows:14,placeholder:"Write the memory body in markdown. Leave blank to start from a template.",className:"editor-input font-mono text-sm"})]}),k?s.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:k}):null,s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"submit",disabled:g||!u.trim()||!a,className:"inline-flex h-9 items-center rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-50",children:g?"Creating…":"Create Memory"}),s.jsx("button",{type:"button",onClick:()=>e("/memories"),className:"inline-flex h-9 items-center rounded-md border border-border/70 bg-background px-3 text-sm font-medium text-foreground transition hover:bg-muted",children:"Cancel"})]})]})}function tQ(){const{slug:e,itemSlug:t}=qt();return s.jsx(Pc,{loadUrl:`/api/projects/${e}/memories/${t}/edit`,saveUrl:`/api/projects/${e}/memories/${t}`,redirectTo:`/projects/${e}/memories/${t}`,title:"Edit Memory",description:"Edit the body. The frontmatter (name, scope, source, related assignments) is preserved unchanged on save.",documentType:"memory",helpTitle:"Memory editing",helpBody:"Memory edits are body-only. Frontmatter changes from the editor are ignored server-side; the file's existing frontmatter is preserved and `updated` is bumped automatically."})}function nQ(){const{data:e,loading:t,error:n}=X4(),[r,o]=m.useState(""),[i,a]=m.useState("all"),[l,u]=m.useState("all"),[f,p]=m.useState("all"),h=(e==null?void 0:e.resources)??[],g=m.useMemo(()=>Array.from(new Set(h.map(b=>b.projectSlug))).sort(),[h]),y=m.useMemo(()=>Array.from(new Set(h.map(b=>b.category).filter(Boolean))).sort(),[h]),k=m.useMemo(()=>Array.from(new Set(h.map(b=>b.source).filter(Boolean))).sort(),[h]),v=m.useMemo(()=>h.filter(b=>{if(i!=="all"&&b.projectSlug!==i||l!=="all"&&b.category!==l||f!=="all"&&b.source!==f)return!1;if(r.trim()){const j=r.toLowerCase();if(!b.name.toLowerCase().includes(j)&&!b.slug.toLowerCase().includes(j)&&!b.projectTitle.toLowerCase().includes(j))return!1}return!0}),[h,r,i,l,f]);return t?s.jsx(bt,{label:"Loading resources…"}):n?s.jsx(Rt,{error:n}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Ci,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{type:"text",placeholder:"Search resources…",value:r,onChange:b=>o(b.target.value),className:"h-9 w-64 rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),s.jsxs("select",{value:i,onChange:b=>a(b.target.value),className:"editor-input max-w-[170px]",children:[s.jsx("option",{value:"all",children:"All projects"}),g.map(b=>s.jsx("option",{value:b,children:b},b))]}),s.jsxs("select",{value:l,onChange:b=>u(b.target.value),className:"editor-input max-w-[160px]",children:[s.jsx("option",{value:"all",children:"All categories"}),y.map(b=>s.jsx("option",{value:b,children:b},b))]}),s.jsxs("select",{value:f,onChange:b=>p(b.target.value),className:"editor-input max-w-[140px]",children:[s.jsx("option",{value:"all",children:"All sources"}),k.map(b=>s.jsx("option",{value:b,children:b},b))]})]}),s.jsxs(De,{to:"/resources/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:[s.jsx(Mt,{className:"h-4 w-4"}),"New Resource"]})]}),v.length===0?s.jsx(St,{title:h.length===0?"No resources yet":"No resources match these filters",description:h.length===0?"Resources are reference materials shared across a project — specs, requirements, links, or any reference content.":"Clear the current filters or create a new resource.",actions:h.length===0?s.jsxs(De,{to:"/resources/new",className:"inline-flex items-center gap-2 rounded-md bg-foreground px-3 py-2 text-sm font-medium text-background transition hover:bg-foreground/90",children:[s.jsx(Mt,{className:"h-4 w-4"}),"New Resource"]}):void 0}):s.jsx("div",{className:"surface-panel overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[820px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border/60 text-muted-foreground",children:[s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Name"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Project"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Category"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Source"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"# Related"}),s.jsx("th",{className:"px-3 pb-3 pt-3 font-medium",children:"Updated"})]})}),s.jsx("tbody",{children:v.map(b=>s.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[s.jsx("td",{className:"px-3 py-3",children:s.jsx(De,{to:`/projects/${b.projectSlug}/resources/${b.slug}`,className:"font-semibold text-foreground hover:text-primary",children:b.name||b.slug})}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:s.jsx(De,{to:`/projects/${b.projectSlug}`,className:"hover:text-foreground hover:underline",children:b.projectTitle})}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:b.category||"—"}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:b.source||"—"}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:b.relatedAssignments.length}),s.jsx("td",{className:"px-3 py-3 text-muted-foreground",children:Yn(b.updated)})]},`${b.projectSlug}/${b.slug}`))})]})})]})}function rQ(){const{slug:e,itemSlug:t}=qt(),n=Wt(),{data:r,loading:o,error:i}=Q4(e,t),[a,l]=m.useState(!1),[u,f]=m.useState(!1);async function p(){if(!(!e||!t)){f(!0);try{(await fetch(`/api/projects/${e}/resources/${t}`,{method:"DELETE"})).ok&&n("/resources")}finally{f(!1)}}}return o?s.jsx(bt,{label:"Loading resource…"}):i?s.jsx(Rt,{error:i}):r?s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:r.name||r.slug}),s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(De,{to:`/projects/${r.projectSlug}`,className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5 hover:text-foreground",children:r.projectTitle}),r.category?s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:["Category: ",r.category]}):null,r.source?s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:["Source: ",r.source]}):null,s.jsxs("span",{className:"rounded-full border border-border/60 bg-muted/50 px-2 py-0.5",children:[r.relatedAssignments.length," related"]})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[s.jsxs("span",{children:["Created ",Nr(r.created)]}),s.jsxs("span",{children:["Updated ",Nr(r.updated)]})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs(De,{to:`/projects/${e}/resources/${t}/edit`,className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:[s.jsx(xc,{className:"h-3 w-3"}),"Edit"]}),a?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:p,disabled:u,className:"inline-flex h-8 items-center gap-1.5 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition hover:bg-destructive/90 disabled:opacity-50",children:u?"Deleting…":"Confirm"}),s.jsx("button",{type:"button",onClick:()=>l(!1),className:"inline-flex h-8 items-center rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-foreground transition hover:bg-muted",children:"Cancel"})]}):s.jsxs("button",{type:"button",onClick:()=>l(!0),className:"inline-flex h-8 items-center gap-1.5 rounded-md border border-border/70 bg-background px-3 text-xs font-medium text-destructive transition hover:bg-destructive/10",children:[s.jsx(jn,{className:"h-3 w-3"}),"Delete"]})]})]}),s.jsx("div",{className:"surface-panel p-4",children:s.jsx(vn,{content:r.body})})]}):null}function sQ(){const e=Wt(),[t]=Ts(),n=t.get("project"),{data:r,loading:o,error:i}=to(),[a,l]=m.useState(n??""),[u,f]=m.useState(""),[p,h]=m.useState(""),[g,y]=m.useState(!1),[k,v]=m.useState(null);m.useEffect(()=>{!a&&r&&r.length>0&&l(n??r[0].slug)},[r,n,a]);async function b(j){if(j.preventDefault(),!(!a||!u.trim())){y(!0),v(null);try{const N=await fetch(`/api/projects/${a}/resources`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:u.trim(),body:p||void 0})}),S=await N.json();if(!N.ok){v(S.error||`HTTP ${N.status}`),y(!1);return}e(`/projects/${S.projectSlug}/resources/${S.slug}`)}catch(N){v(N.message),y(!1)}}}return o?s.jsx(bt,{label:"Loading projects…"}):i?s.jsx(Rt,{error:i}):!r||r.length===0?s.jsx(Rt,{error:"You need at least one project before you can create a resource. Create a project from the sidebar."}):s.jsxs("form",{onSubmit:b,className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"New Resource"}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Resources are reference material — specs, requirements, links — shared across every assignment in a project."})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"project",className:"block text-sm font-medium text-foreground",children:"Project"}),s.jsx("select",{id:"project",value:a,onChange:j=>l(j.target.value),className:"editor-input",required:!0,children:r.map(j=>s.jsx("option",{value:j.slug,children:j.title},j.slug))})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-foreground",children:"Name"}),s.jsx("input",{id:"name",type:"text",value:u,onChange:j=>f(j.target.value),placeholder:"e.g. Auth Requirements",className:"editor-input",required:!0,autoFocus:!0}),s.jsx("p",{className:"text-xs text-muted-foreground/80",children:"The slug is auto-derived from the name. Letters, digits, and hyphens."})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{htmlFor:"body",className:"block text-sm font-medium text-foreground",children:"Body"}),s.jsx("textarea",{id:"body",value:p,onChange:j=>h(j.target.value),rows:14,placeholder:"Write the resource body in markdown. Leave blank to start from a template.",className:"editor-input font-mono text-sm"})]}),k?s.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:k}):null,s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"submit",disabled:g||!u.trim()||!a,className:"inline-flex h-9 items-center rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-50",children:g?"Creating…":"Create Resource"}),s.jsx("button",{type:"button",onClick:()=>e("/resources"),className:"inline-flex h-9 items-center rounded-md border border-border/70 bg-background px-3 text-sm font-medium text-foreground transition hover:bg-muted",children:"Cancel"})]})]})}function oQ(){const{slug:e,itemSlug:t}=qt();return s.jsx(Pc,{loadUrl:`/api/projects/${e}/resources/${t}/edit`,saveUrl:`/api/projects/${e}/resources/${t}`,redirectTo:`/projects/${e}/resources/${t}`,title:"Edit Resource",description:"Edit the body. The frontmatter (name, category, source, related assignments) is preserved unchanged on save.",documentType:"resource",helpTitle:"Resource editing",helpBody:"Resource edits are body-only. Frontmatter changes from the editor are ignored server-side; the file's existing frontmatter is preserved and `updated` is bumped automatically."})}const hv=["projects","playbooks","todos","servers","config"];function iQ(e){const t=new Set;for(const n of e.split(",").map(r=>r.trim()))hv.includes(n)&&t.add(n);return t}function iC(e){return e?Nr(e):"never"}function aQ(){const[e,t]=m.useState(!0),[n,r]=m.useState(null),[o,i]=m.useState(""),[a,l]=m.useState(new Set(hv)),[u,f]=m.useState(!1),[p,h]=m.useState(!1),[g,y]=m.useState(null),[k,v]=m.useState(null),[b,j]=m.useState(!1),N=m.useCallback(async()=>{try{const $=await fetch("/api/backup");if(!$.ok)throw new Error(`HTTP ${$.status}`);const P=await $.json();r(P),i(P.repo??""),l(iQ(P.categories)),f(!1)}catch($){v({type:"error",message:`Failed to load backup config: ${$ instanceof Error?$.message:String($)}`})}finally{t(!1)}},[]);m.useEffect(()=>{N()},[N]);function S($){l(P=>{const F=new Set(P);return F.has($)?F.delete($):F.add($),F}),f(!0)}async function C(){h(!0),v(null);try{const $=Array.from(a),P=await fetch("/api/backup/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({repo:o.trim()||null,categories:$})}),F=await P.json();if(!P.ok)throw new Error(F.error||`HTTP ${P.status}`);r(F),f(!1),v({type:"success",message:"Backup configuration saved."})}catch($){v({type:"error",message:`Save failed: ${$ instanceof Error?$.message:String($)}`})}finally{h(!1)}}async function D(){y("push"),v(null);try{const $=await fetch("/api/backup/push",{method:"POST"}),P=await $.json();if(!$.ok||P.success===!1)throw new Error(P.error||P.message||`HTTP ${$.status}`);v({type:"success",message:P.message||"Backup complete."}),await N()}catch($){v({type:"error",message:`Backup failed: ${$ instanceof Error?$.message:String($)}`})}finally{y(null)}}async function T(){y("pull"),v(null);try{const $=await fetch("/api/backup/pull",{method:"POST"}),P=await $.json();if(!$.ok||P.success===!1)throw new Error(P.error||P.message||`HTTP ${$.status}`);v({type:"success",message:P.message||"Restore complete."}),await N()}catch($){v({type:"error",message:`Restore failed: ${$ instanceof Error?$.message:String($)}`})}finally{y(null)}}if(e)return s.jsx(qe,{title:"GitHub Backup",description:"Back up Syntaur files to a GitHub repository",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})});const R=!!o.trim()&&a.size>0&&!g&&!u;return s.jsxs(qe,{title:"GitHub Backup",description:"Back up Syntaur files to a GitHub repository and restore from it",children:[s.jsxs("div",{className:"space-y-4",children:[k&&s.jsx("div",{className:`rounded-lg border px-4 py-2 text-sm ${k.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:k.message}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Repository URL"}),s.jsx("input",{type:"text",value:o,onChange:$=>{i($.target.value),f(!0)},placeholder:"git@github.com:you/syntaur-backup.git",className:"editor-input w-full text-sm"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["SSH or HTTPS URL. Requires ",s.jsx("code",{className:"rounded bg-muted px-1",children:"git"})," installed and credentials configured locally."]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Categories to back up"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:hv.map($=>{const P=a.has($);return s.jsxs("button",{type:"button",onClick:()=>S($),className:`shell-action text-xs ${P?"bg-primary/10 text-primary hover:bg-primary/20":"bg-muted/30 text-muted-foreground hover:bg-muted/60"}`,children:[s.jsx("span",{className:`mr-1 inline-block h-2 w-2 rounded-full ${P?"bg-primary":"bg-muted-foreground/40"}`}),$]},$)})})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-2 text-xs text-muted-foreground sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-foreground",children:"Last backup: "}),iC((n==null?void 0:n.lastBackup)??null)]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-foreground",children:"Last restore: "}),iC((n==null?void 0:n.lastRestore)??null)]}),(n==null?void 0:n.locked)&&s.jsx("div",{className:"sm:col-span-2 text-warning-foreground",children:"⚠ A backup operation is in progress or the lock file is stale."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-2",children:[s.jsxs("button",{className:"shell-action bg-primary/10 text-primary hover:bg-primary/20",onClick:C,disabled:p||!u,children:[s.jsx(nm,{className:"h-3.5 w-3.5"}),p?"Saving...":"Save Config"]}),s.jsxs("button",{className:"shell-action",onClick:D,disabled:!R,title:R?"Back up now":u?"Save config first":"Set repo and pick categories",children:[s.jsx(LO,{className:"h-3.5 w-3.5"}),g==="push"?"Backing up...":"Back Up Now"]}),s.jsxs("button",{className:"shell-action",onClick:()=>j(!0),disabled:!R,title:R?"Restore from backup":u?"Save config first":"Set repo and pick categories",children:[s.jsx(sO,{className:"h-3.5 w-3.5"}),g==="pull"?"Restoring...":"Restore"]}),u&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"})]}),s.jsxs("p",{className:"flex items-start gap-2 rounded-md border border-border/40 bg-muted/20 p-3 text-xs text-muted-foreground",children:[s.jsx(tO,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsxs("span",{children:["Restore never overwrites ",s.jsx("code",{className:"rounded bg-muted px-1",children:"config.md"})," (would clobber backup settings). The agent sessions database is not backed up — only markdown files."]})]})]}),s.jsx(ss,{open:b,title:"Restore from GitHub?",description:"Restore will overwrite local files for the selected categories with the contents of the GitHub repo. This cannot be undone. Continue?",confirmLabel:"Restore",destructive:!0,loading:g==="pull",onOpenChange:$=>{!$&&g!=="pull"&&j(!1)},onConfirm:async()=>{await T(),j(!1)}})]})}function lQ(){const{customBindings:e,userBindings:t,actionEntries:n,findConflict:r,bindAction:o,unbindAction:i}=Ri(),[a,l]=m.useState(null),[u,f]=m.useState(null),[p,h]=m.useState(!1),g=Object.values(t).some(S=>typeof S=="string"&&S.length>0);function y(S,C){f({type:S,message:C}),setTimeout(()=>f(null),2500)}function k(S){l({kind:S,combo:null,conflict:null,saving:!1,error:null})}function v(S){if(!a||S.key==="Escape")return;if(S.key==="Enter"&&a.combo){S.preventDefault(),b();return}if(S.key==="Enter")return;S.preventDefault(),S.stopPropagation();const C=K2(S.nativeEvent);if(!C)return;const D=r(C,a.kind);l({...a,combo:C,conflict:D,error:null})}async function b(){var S;if(a!=null&&a.combo){if((S=a.conflict)!=null&&S.description){l({...a,error:`Reserved: ${a.conflict.description}`});return}l({...a,saving:!0,error:null});try{await o(a.kind,a.combo),l(null),y("success",`Bound ${gu[a.kind]}`)}catch(C){l({...a,saving:!1,error:C instanceof Error?C.message:"Failed to save"})}}}async function j(S){try{await i(S),y("success",`Cleared ${gu[S]} binding`)}catch(C){y("error",C instanceof Error?C.message:"Failed to clear binding")}}async function N(){if(!p){h(!0);try{await Rz(),y("success","All hotkey bindings cleared")}catch(S){y("error",S instanceof Error?S.message:"Failed to reset bindings")}finally{h(!1)}}}return s.jsxs(qe,{title:"Hotkey Bindings",description:"Each canonical create action ships with a default hotkey that fires the action without opening the palette. Override any of them below — Clear restores the default.",actions:g?s.jsxs("button",{className:"shell-action text-xs",onClick:()=>void N(),disabled:p,children:[s.jsx(vs,{className:"h-3 w-3"}),"Restore defaults"]}):void 0,children:[u?s.jsx("div",{className:`mb-3 rounded-md border px-3 py-1.5 text-xs ${u.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:u.message}):null,s.jsx("ul",{className:"space-y-2",children:am.map(S=>{var $,P;const C=n.find(F=>F.bindableKind===S),D=e[S],T=typeof t[S]=="string"&&!!t[S],R=(a==null?void 0:a.kind)===S;return s.jsxs("li",{className:"flex flex-wrap items-center gap-3 rounded-md border border-border/40 bg-background/60 px-3 py-2",children:[s.jsx(vb,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm text-foreground",children:(C==null?void 0:C.title)??gu[S]}),C!=null&&C.subtitle?s.jsx("div",{className:"text-xs text-muted-foreground",children:C.subtitle}):null]}),D?s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[s.jsx("kbd",{className:"rounded border border-border/70 bg-muted px-2 py-0.5 font-mono text-xs text-foreground",children:Qs(D)}),s.jsx("span",{className:`text-[10px] uppercase tracking-wide ${T?"text-primary":"text-muted-foreground"}`,children:T?"custom":"default"})]}):s.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"unbound"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",className:"shell-action text-xs",onClick:()=>k(S),children:D?"Rebind":"Bind"}),T?s.jsxs("button",{type:"button",className:"shell-action text-xs",onClick:()=>void j(S),"aria-label":`Restore default ${gu[S]} binding`,children:[s.jsx(Pd,{className:"h-3 w-3"}),"Restore default"]}):null]}),R?s.jsx("div",{className:"mt-2 w-full rounded-md border border-primary/40 bg-primary/5 px-3 py-3 text-center outline-none",tabIndex:0,autoFocus:!0,onKeyDown:v,onBlur:()=>{(a==null?void 0:a.kind)===S&&!a.saving&&l(null)},children:a!=null&&a.combo?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-base font-semibold tracking-wide text-foreground",children:Qs(a.combo)}),($=a.conflict)!=null&&$.description?s.jsxs("div",{className:"text-xs text-destructive",children:["Reserved: ",a.conflict.description]}):(P=a.conflict)!=null&&P.kind?s.jsxs("div",{className:"text-xs text-amber-500 dark:text-amber-400",children:['Already bound to "',gu[a.conflict.kind],'". Press Enter to overwrite.']}):s.jsx("div",{className:"text-xs text-muted-foreground",children:"Press Enter to save, Esc to cancel, any other key to retry."}),a.error?s.jsx("div",{className:"text-xs text-destructive",children:a.error}):null]}):s.jsx("div",{className:"text-xs text-muted-foreground",children:"Press the key combination you want to bind…"})}):null]},S)})})]})}const cQ={kanban:"Kanban",list:"List",table:"Table"},uQ={comfortable:"Comfortable",compact:"Compact"},dQ={title:"Title",status:"Status",priority:"Priority",assignee:"Assignee",dependencies:"Dependencies",created:"Created",updated:"Updated"},fQ={asc:"Ascending",desc:"Descending"};function pQ(){const e=dY(),t=e.global,[n,r]=m.useState(!1),[o,i]=m.useState(null);function a(f,p){i({type:f,message:p}),setTimeout(()=>i(null),2e3)}async function l(f,p){if(t[f]!==p){r(!0);try{await b_({[f]:p}),a("success","Saved")}catch(h){a("error",h instanceof Error?h.message:"Failed to save")}finally{r(!1)}}}async function u(){if(e.custom){r(!0);try{await fY(),a("success","Reset to defaults")}catch(f){a("error",f instanceof Error?f.message:"Failed to reset")}finally{r(!1)}}}return s.jsxs(qe,{title:"View defaults",description:"Defaults for the assignments board, list, and table views. Per-project overrides are saved automatically as you use them.",actions:e.custom?s.jsxs("button",{type:"button",className:"shell-action text-xs",onClick:u,disabled:n,children:[s.jsx(vs,{className:"h-3 w-3"}),"Reset"]}):void 0,children:[o&&s.jsx("div",{className:`mb-3 rounded-md border px-3 py-1.5 text-xs ${o.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:o.message}),s.jsxs("dl",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Default view"}),s.jsx("dd",{className:"mt-1.5 inline-flex rounded-md border border-border/60 p-0.5",children:xw.map(f=>s.jsx("button",{type:"button",onClick:()=>l("defaultView",f),disabled:n,"aria-pressed":t.defaultView===f,className:`px-3 py-1 text-xs ${t.defaultView===f?"rounded bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`,children:cQ[f]},f))})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Density"}),s.jsx("dd",{className:"mt-1.5 inline-flex rounded-md border border-border/60 p-0.5",children:I6.map(f=>s.jsx("button",{type:"button",onClick:()=>l("density",f),disabled:n,"aria-pressed":t.density===f,className:`px-3 py-1 text-xs ${t.density===f?"rounded bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`,children:uQ[f]},f))})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Sort by"}),s.jsx("dd",{className:"mt-1.5",children:s.jsx("select",{value:t.sortField,onChange:f=>l("sortField",f.target.value),disabled:n,className:"editor-input max-w-[220px]",children:UT.map(f=>s.jsx("option",{value:f,children:dQ[f]??f},f))})})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Direction"}),s.jsx("dd",{className:"mt-1.5 inline-flex rounded-md border border-border/60 p-0.5",children:$6.map(f=>s.jsx("button",{type:"button",onClick:()=>l("sortDirection",f),disabled:n,"aria-pressed":t.sortDirection===f,className:`px-3 py-1 text-xs ${t.sortDirection===f?"rounded bg-foreground text-background":"text-muted-foreground hover:text-foreground"}`,children:fQ[f]},f))})]})]})]})}function hQ({value:e,onChange:t,knownSlugs:n,rows:r=2,placeholder:o,className:i,wrapperClassName:a,singleLine:l,"aria-label":u}){const[f,p]=m.useState(0),[h,g]=m.useState(0),[y,k]=m.useState(!1),v=m.useRef(null),b=O_(e,f),j=b?F_(b.partial,n):[],N=!y&&j.length>0,S=Math.min(h,Math.max(0,j.length-1)),C=P=>l?P.replace(/[\r\n]+/g," "):P;function D(P){t(C(P.target.value)),p(P.target.selectionStart??P.target.value.length),g(0),k(!1)}function T(P){p(P.currentTarget.selectionStart??e.length)}function R(P){if(!b||!P)return;const F=z_(e,b,P);t(C(F.text)),p(F.caret),g(0),k(!0),requestAnimationFrame(()=>{const _=v.current;_&&(_.focus(),_.setSelectionRange(F.caret,F.caret))})}function $(P){N&&(P.key==="ArrowDown"?(P.preventDefault(),g(F=>Math.min(F+1,j.length-1))):P.key==="ArrowUp"?(P.preventDefault(),g(F=>Math.max(F-1,0))):P.key==="Enter"||P.key==="Tab"?(P.preventDefault(),R(j[S])):P.key==="Escape"&&(P.preventDefault(),k(!0)))}return s.jsxs("div",{className:je("relative",a),children:[s.jsx("textarea",{ref:v,value:e,rows:r,placeholder:o,"aria-label":u,onChange:D,onKeyDown:$,onKeyUp:T,onClick:T,className:i}),N&&s.jsx("ul",{role:"listbox",className:"absolute left-0 right-0 top-full z-30 mt-1 max-h-48 overflow-auto rounded-md border border-border/70 bg-background py-1 shadow-lg",children:j.map((P,F)=>s.jsx("li",{children:s.jsxs("button",{type:"button",role:"option","aria-selected":F===S,onMouseDown:_=>{_.preventDefault(),R(P)},className:je("flex w-full items-center gap-2 px-2.5 py-1.5 text-left font-mono text-sm transition-colors hover:bg-accent",F===S&&"bg-accent"),children:[s.jsx("span",{className:"text-muted-foreground",children:"@"}),s.jsx("span",{className:"truncate",children:P})]})},P))})]})}const mQ={first:"first",last:"last",none:"none"};function t3(){return`row_${Math.random().toString(36).slice(2,10)}_${Date.now().toString(36)}`}function Su(e){return e.map(t=>({rowKey:t3(),id:t.id,originalId:t.id,isNew:!1,idEditable:!1,autoSlugFromLabel:!1,label:t.label,command:t.command,argsText:t.args?t.args.join(" "):"",promptArgPosition:t.promptArgPosition??"first",resolveFromShellAliases:t.resolveFromShellAliases??!1,default:t.default??!1,model:t.model??"",playbook:t.playbook??"",launchPrompt:t.launchPrompt??"",fieldErrors:{}}))}function gQ(e){return e.map(t=>{const n={id:t.id,label:t.label,command:t.command},r=t.argsText.split(/[,\s]+/).filter(Boolean);return r.length>0&&(n.args=r),t.promptArgPosition!=="first"&&(n.promptArgPosition=t.promptArgPosition),t.resolveFromShellAliases&&(n.resolveFromShellAliases=!0),t.default&&(n.default=!0),t.model.trim()&&(n.model=t.model.trim()),t.playbook.trim()&&(n.playbook=t.playbook.trim()),t.launchPrompt.trim()&&(n.launchPrompt=t.launchPrompt),n})}function xQ(e){if(e.length===0)return e;let t=-1;for(let n=0;n<e.length;n++)if(e[n].default){t=n;break}return e.map((n,r)=>({...n,default:t===-1?r===0:r===t}))}function yQ(e,t){return!t||t.length===0?e:e.map((n,r)=>{const o={};for(const i of t){if(i.index!==void 0){i.index===r&&(o[i.field]=i.message);continue}if(i.id!==void 0){i.id===n.id&&(o[i.field]=i.message);continue}o[i.field]=i.message}return{...n,fieldErrors:o}})}function bQ(e){return e.map(t=>Object.keys(t.fieldErrors).length===0?t:{...t,fieldErrors:{}})}function vQ(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const r=e[n],o=t[n];if(r.id!==o.id||r.label!==o.label||r.command!==o.command||r.argsText!==o.argsText||r.promptArgPosition!==o.promptArgPosition||r.resolveFromShellAliases!==o.resolveFromShellAliases||r.default!==o.default||r.model!==o.model||r.playbook!==o.playbook||r.launchPrompt!==o.launchPrompt)return!1}return!0}function wQ({row:e,index:t,canRemove:n,playbooks:r,onPatch:o,onSetDefault:i,onRemove:a}){const{attributes:l,listeners:u,setNodeRef:f,setActivatorNodeRef:p,transform:h,transition:g,isDragging:y}=Cm({id:e.rowKey}),k={transform:js.Transform.toString(h),transition:g,zIndex:y?50:void 0,position:y?"relative":void 0};function v(C){const D={label:C};if(e.autoSlugFromLabel){const T=Ir(C);T&&_Y.test(T)?D.id=T:D.id=`agent-${t+1}`}o(D)}function b(C){o({id:C,autoSlugFromLabel:!1})}const j=C=>e.fieldErrors[C]?"border-error-foreground/60":"",N=m.useMemo(()=>r.map(C=>C.slug),[r]),S=m.useMemo(()=>B_(e.launchPrompt,N),[e.launchPrompt,N]);return s.jsxs("div",{ref:f,style:k,className:`surface-panel space-y-2 px-3 py-2 ${y?"opacity-60 shadow-lg":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{ref:p,...l,...u,type:"button","aria-label":"Drag to reorder",className:"cursor-grab active:cursor-grabbing text-muted-foreground/40 hover:text-muted-foreground transition touch-none",children:s.jsx(gc,{className:"h-4 w-4"})}),s.jsxs("label",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx("input",{type:"radio",name:"agents-default",checked:e.default,onChange:i,className:"h-3 w-3 cursor-pointer accent-foreground"}),"Default"]}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wide text-muted-foreground/70",children:"id"}),e.idEditable?s.jsx("input",{type:"text",value:e.id,onChange:C=>b(C.target.value),className:`editor-input w-32 font-mono text-xs ${j("id")}`,"aria-label":"Agent id"}):s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.id}),s.jsx("button",{type:"button",onClick:a,disabled:!n,"aria-label":"Remove agent",className:"rounded p-1 text-muted-foreground/60 transition hover:bg-foreground/[0.04] hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30",children:s.jsx(jn,{className:"h-3.5 w-3.5"})})]})]}),e.fieldErrors.id&&s.jsx("p",{className:"ml-7 text-[11px] text-error-foreground",children:e.fieldErrors.id}),s.jsxs("div",{className:"ml-7 grid grid-cols-1 gap-2 sm:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground/80",children:"Label"}),s.jsx("input",{type:"text",value:e.label,onChange:C=>v(C.target.value),className:`editor-input mt-0.5 w-full ${j("label")}`}),e.fieldErrors.label&&s.jsx("p",{className:"mt-0.5 text-[11px] text-error-foreground",children:e.fieldErrors.label})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground/80",children:"Command"}),s.jsx("input",{type:"text",value:e.command,placeholder:"claude or /usr/local/bin/claude",onChange:C=>o({command:C.target.value}),className:`editor-input mt-0.5 w-full font-mono ${j("command")}`}),e.fieldErrors.command&&s.jsx("p",{className:"mt-0.5 text-[11px] text-error-foreground",children:e.fieldErrors.command})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground/80",children:"Args (comma- or space-separated)"}),s.jsx("input",{type:"text",value:e.argsText,placeholder:"--dangerously-skip-permissions",onChange:C=>o({argsText:C.target.value}),className:`editor-input mt-0.5 w-full font-mono ${j("args")}`}),e.fieldErrors.args&&s.jsx("p",{className:"mt-0.5 text-[11px] text-error-foreground",children:e.fieldErrors.args})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground/80",children:"Prompt arg position"}),s.jsx("select",{value:e.promptArgPosition,onChange:C=>o({promptArgPosition:C.target.value}),className:`editor-input mt-0.5 w-full ${j("promptArgPosition")}`,children:D_.map(C=>s.jsx("option",{value:C,children:mQ[C]},C))}),e.fieldErrors.promptArgPosition&&s.jsx("p",{className:"mt-0.5 text-[11px] text-error-foreground",children:e.fieldErrors.promptArgPosition})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground/80",children:"Model"}),s.jsx("input",{type:"text",value:e.model,placeholder:"opus (optional)",onChange:C=>o({model:C.target.value}),className:`editor-input mt-0.5 w-full font-mono ${j("model")}`}),e.fieldErrors.model&&s.jsx("p",{className:"mt-0.5 text-[11px] text-error-foreground",children:e.fieldErrors.model})]}),s.jsxs("div",{className:"col-span-full",children:[s.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground/80",children:"Launch prompt"}),s.jsx(hQ,{value:e.launchPrompt,onChange:C=>o({launchPrompt:C}),knownSlugs:N,singleLine:!0,rows:5,placeholder:"@assignment Run @<playbook> end-to-end. (optional)",wrapperClassName:"mt-0.5",className:`editor-input w-full resize-y font-mono leading-relaxed min-h-[6rem] ${j("launchPrompt")}`,"aria-label":"Launch prompt"}),e.fieldErrors.launchPrompt&&s.jsx("p",{className:"mt-0.5 text-[11px] text-error-foreground",children:e.fieldErrors.launchPrompt}),S.length>0&&!e.fieldErrors.launchPrompt&&s.jsx("ul",{className:"mt-0.5 space-y-0.5 text-[11px] text-error-foreground",children:S.map(C=>s.jsx("li",{children:C},C))})]}),s.jsxs("label",{className:"col-span-full inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:e.resolveFromShellAliases,onChange:C=>o({resolveFromShellAliases:C.target.checked}),className:"h-3.5 w-3.5 cursor-pointer accent-foreground"}),"Resolve from shell aliases (look up ",s.jsx("code",{className:"font-mono",children:"command"})," in your interactive shell before launching)"]})]})]})}function jQ(){const e=L_(),t=Zv(),n=m.useMemo(()=>{var F;return(((F=t.data)==null?void 0:F.playbooks)??[]).filter(_=>_.enabled).map(_=>({slug:_.slug,name:_.name}))},[t.data]),[r,o]=m.useState(()=>Su(e.agents)),[i,a]=m.useState(()=>Su(e.agents)),[l,u]=m.useState(!1),[f,p]=m.useState(null),[h,g]=m.useState(!1),[y,k]=m.useState(null);m.useEffect(()=>{const F=Su(e.agents);o(F),a(F),p(null)},[e.agents]);const v=m.useMemo(()=>!vQ(r,i),[r,i]),b=bm(ji(kc,{activationConstraint:{distance:8}}),ji(jc));function j(F,_){k({type:F,message:_}),setTimeout(()=>k(null),2500)}function N(F,_){o(V=>V.map(U=>U.rowKey===F?{...U,..._,fieldErrors:kQ(U.fieldErrors,_)}:U))}function S(F){o(_=>_.map(V=>({...V,default:V.rowKey===F})))}function C(){o(F=>{const _=new Set(F.map(W=>W.id)),V="new-agent";let U=V,I=1;for(;_.has(U);)I+=1,U=`${V}-${I}`;const M=I===1?"New Agent":`New Agent ${I}`,B={rowKey:t3(),id:U,originalId:null,isNew:!0,idEditable:!0,autoSlugFromLabel:!0,label:M,command:"",argsText:"",promptArgPosition:"first",resolveFromShellAliases:!0,default:!1,model:"",playbook:"",launchPrompt:"",fieldErrors:{}};return[...F,B]})}function D(F){o(_=>_.filter(V=>V.rowKey!==F))}async function T(){u(!0),p(null);try{const F=xQ(r),_=gQ(F),V=await IY(_),U=Su(V.agents);o(U),a(U),j("success","Agents saved")}catch(F){if(F instanceof $_)p(F.message),o(_=>yQ(bQ(_),F.fieldErrors)),j("error",F.message);else{const _=F instanceof Error?F.message:"Failed to save";p(_),j("error",_)}}finally{u(!1)}}function R(){o(i),p(null)}async function $(){if(e.custom){u(!0),p(null);try{const F=await LY(),_=Su(F.agents);o(_),a(_),j("success","Reset to defaults")}catch(F){const _=F instanceof Error?F.message:"Failed to reset";p(_),j("error",_)}finally{u(!1)}}}function P(F){const{active:_,over:V}=F;!V||_.id===V.id||o(U=>{const I=U.findIndex(B=>B.rowKey===_.id),M=U.findIndex(B=>B.rowKey===V.id);return I===-1||M===-1?U:Sc(U,I,M)})}return s.jsxs(qe,{title:"Agents",description:"Configure which agents the dashboard and 'Open in agent' actions can launch. The default agent is used when no other one is specified.",actions:e.custom?s.jsxs("button",{type:"button",className:"shell-action text-xs",onClick:()=>g(!0),disabled:l,children:[s.jsx(vs,{className:"h-3 w-3"}),"Reset"]}):void 0,children:[!e.custom&&s.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-border/60 bg-foreground/[0.02] px-3 py-2 text-xs text-muted-foreground",children:[s.jsx(Hv,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsxs("span",{children:["Using built-in defaults — first save will write your own list to"," ",s.jsx("code",{className:"font-mono",children:"~/.syntaur/config.md"}),"."]})]}),y&&s.jsx("div",{className:`rounded-md border px-3 py-1.5 text-xs ${y.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:y.message}),f&&(!y||y.type!=="error")&&s.jsx("div",{className:"rounded-md border border-error-foreground/30 bg-error px-3 py-1.5 text-xs text-error-foreground",children:f}),s.jsx(Sm,{sensors:b,collisionDetection:vm,onDragEnd:P,children:s.jsx(Nm,{items:r.map(F=>F.rowKey),strategy:Aw,children:s.jsx("div",{className:"space-y-2",children:r.map((F,_)=>s.jsx(wQ,{row:F,index:_,canRemove:r.length>1,playbooks:n,onPatch:V=>N(F.rowKey,V),onSetDefault:()=>S(F.rowKey),onRemove:()=>D(F.rowKey)},F.rowKey))})})}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("button",{type:"button",onClick:C,disabled:l,className:"shell-action text-xs",children:[s.jsx(Mt,{className:"h-3 w-3"}),"Add agent"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:R,disabled:!v||l,className:"shell-action text-xs",children:"Discard"}),s.jsxs("button",{type:"button",onClick:T,disabled:!v||l,className:"shell-action text-xs",children:[s.jsx(nm,{className:"h-3 w-3"}),"Save"]})]})]}),s.jsx(ss,{open:h,title:"Reset agents to defaults?",description:"Reset agents to built-in defaults? Any custom agents will be deleted from your config.",confirmLabel:"Reset",destructive:!0,loading:l,onOpenChange:F=>{!F&&!l&&g(!1)},onConfirm:async()=>{await $(),g(!1)}})]})}function kQ(e,t){if(Object.keys(e).length===0)return e;const n={...e};return"id"in t&&delete n.id,"label"in t&&delete n.label,"command"in t&&delete n.command,"argsText"in t&&delete n.args,"promptArgPosition"in t&&delete n.promptArgPosition,"resolveFromShellAliases"in t&&delete n.resolveFromShellAliases,"default"in t&&delete n.default,"model"in t&&delete n.model,"playbook"in t&&delete n.playbook,"launchPrompt"in t&&delete n.launchPrompt,n}const n3=["terminal-app","iterm","ghostty","alacritty","warp","kitty","cmux"],Dh={terminal:"terminal-app",custom:!1};let _l=null,Nl=null,$h=0;const mv=new Set;function r3(e){_l=e;for(const t of mv)t(e)}function E0(e){if(!e||typeof e!="object")return Dh;const t=e;return{terminal:typeof t.terminal=="string"&&n3.includes(t.terminal)?t.terminal:Dh.terminal,custom:t.custom===!0}}function SQ(){if(_l)return Promise.resolve(_l);if(Nl)return Nl;const e=++$h;return Nl=fetch("/api/config/terminal").then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{Nl=null;const n=E0(t);return e!==$h?_l??n:(_l=n,n)}).catch(()=>(Nl=null,Dh)),Nl}function NQ(){const[e,t]=m.useState(()=>_l??Dh);return m.useEffect(()=>{let n=!1;return SQ().then(r=>{n||t(r)}),mv.add(t),()=>{n=!0,mv.delete(t)}},[]),e}async function CQ(e){++$h;const t=await fetch("/api/config/terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({terminal:e})});if(!t.ok){const r=await t.json().catch(()=>null);throw new Error((r==null?void 0:r.error)??`HTTP ${t.status}`)}const n=E0(await t.json());return r3(n),n}async function EQ(){++$h;const e=await fetch("/api/config/terminal",{method:"DELETE"});if(!e.ok){const n=await e.json().catch(()=>null);throw new Error((n==null?void 0:n.error)??`HTTP ${e.status}`)}const t=E0(await e.json());return r3(t),t}const vp={"terminal-app":"Terminal (macOS built-in)",iterm:"iTerm2",ghostty:"Ghostty",alacritty:"Alacritty",warp:"Warp",kitty:"kitty",cmux:"cmux"};function TQ(){const{terminal:e,custom:t}=NQ(),[n,r]=m.useState(!1),[o,i]=m.useState(null);function a(f){i(f),setTimeout(()=>i(null),2500)}async function l(f){if(!(f===e&&t)){r(!0);try{await CQ(f),a({type:"success",message:`Terminal set to ${vp[f]}.`})}catch(p){a({type:"error",message:p instanceof Error?p.message:"Save failed."})}finally{r(!1)}}}async function u(){r(!0);try{const f=await EQ();a({type:"success",message:`Reset to OS default (${vp[f.terminal]}).`})}catch(f){a({type:"error",message:f instanceof Error?f.message:"Reset failed."})}finally{r(!1)}}return s.jsxs(qe,{title:"Terminal",description:`Which terminal "Open in agent" launches. Defaults to the OS choice (currently ${vp[e]}) when unset.`,actions:t?s.jsxs("button",{className:"shell-action text-xs",onClick:u,disabled:n,type:"button",children:[s.jsx(vs,{className:"h-3 w-3"}),"Reset to OS default"]}):void 0,children:[o&&s.jsx("div",{className:`mb-3 rounded-md border px-3 py-1.5 text-xs ${o.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:o.message}),s.jsxs("label",{className:"block text-sm",children:[s.jsx("span",{className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:"Launch in"}),s.jsx("select",{value:e,onChange:f=>l(f.target.value),disabled:n,className:"w-full max-w-sm rounded-md border border-border/60 bg-background px-3 py-1.5 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60",children:n3.map(f=>s.jsx("option",{value:f,children:vp[f]},f))})]})]})}const aC={all:"Everything",assignment:"Assignments",project:"Projects",todo:"Todos",server:"Servers",playbook:"Playbooks"},RQ=["all",...lm];function Gy(e){return Object.entries(e).map(([t,n])=>({prefix:t,kind:n}))}function AQ(e){const t=[],n={},r=new Set;for(const{prefix:i,kind:a}of e){const l=i.trim();if(l===""){t.push("An alias prefix is empty.");continue}if(r.has(l)){t.push(`Duplicate prefix "${l}".`);continue}r.add(l),n[l]=a}const o=f5(n);return o.ok||t.push(...o.errors),{map:n,errors:t}}function PQ(){const{search:e,custom:t}=ow(),[n,r]=m.useState(e.defaultScope),[o,i]=m.useState(e.externalIds),[a,l]=m.useState(()=>Gy(e.aliases)),[u,f]=m.useState(!1),[p,h]=m.useState(!1),[g,y]=m.useState(null),k=JSON.stringify(e);m.useEffect(()=>{u||(r(e.defaultScope),i(e.externalIds),l(Gy(e.aliases)))},[k]);const{map:v,errors:b}=AQ(a);function j(P){y(P),setTimeout(()=>y(null),2500)}function N(){l(P=>[...P,{prefix:"",kind:"assignment"}]),f(!0)}function S(P){l(F=>F.filter((_,V)=>V!==P)),f(!0)}function C(P,F){l(_=>_.map((V,U)=>U===P?{...V,...F}:V)),f(!0)}function D(P){r(P.defaultScope),i(P.externalIds),l(Gy(P.aliases)),f(!1)}async function T(){if(!(b.length>0)){h(!0);try{const P=await m5({defaultScope:n,aliases:v,externalIds:o});D(P.search),j({type:"success",message:"Search settings saved."})}catch(P){j({type:"error",message:P instanceof Error?P.message:"Save failed."})}finally{h(!1)}}}async function R(){h(!0);try{const P=await g5();D(P.search),j({type:"success",message:"Reset to defaults."})}catch(P){j({type:"error",message:P instanceof Error?P.message:"Reset failed."})}finally{h(!1)}}const $=u&&b.length===0&&!p;return s.jsxs(qe,{title:"Search",description:"Customize the Cmd+K command palette: default scope, type-alias prefixes, and external-ID indexing.",actions:t?s.jsxs("button",{className:"shell-action text-xs",onClick:R,disabled:p,type:"button",children:[s.jsx(vs,{className:"h-3 w-3"}),"Reset to defaults"]}):void 0,children:[g&&s.jsx("div",{className:`mb-3 rounded-md border px-3 py-1.5 text-xs ${g.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:g.message}),s.jsxs("div",{className:"space-y-5",children:[s.jsxs("label",{className:"block text-sm",children:[s.jsx("span",{className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:"Default scope"}),s.jsx("select",{value:n,onChange:P=>{r(P.target.value),f(!0)},disabled:p,className:"w-full max-w-sm rounded-md border border-border/60 bg-background px-3 py-1.5 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60",children:RQ.map(P=>s.jsx("option",{value:P,children:aC[P]},P))}),s.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:["Searches with no type prefix are limited to this. An ",s.jsx("code",{children:"all:"})," prefix (or empty box) always searches everything."]})]}),s.jsxs("div",{className:"text-sm",children:[s.jsx("span",{className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:"Type-alias prefixes"}),s.jsx("div",{className:"space-y-2",children:a.map((P,F)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:P.prefix,onChange:_=>C(F,{prefix:_.target.value}),placeholder:"prefix",disabled:p,spellCheck:!1,className:"w-24 rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60"}),s.jsx("span",{className:"text-muted-foreground",children:"→"}),s.jsx("select",{value:P.kind,onChange:_=>C(F,{kind:_.target.value}),disabled:p,className:"rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60",children:lm.map(_=>s.jsx("option",{value:_,children:aC[_]},_))}),s.jsx("button",{type:"button",onClick:()=>S(F),disabled:p,"aria-label":`Remove alias ${P.prefix}`,className:"rounded-md p-1 text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-60",children:s.jsx(Pd,{className:"h-3.5 w-3.5"})})]},F))}),s.jsxs("button",{type:"button",onClick:N,disabled:p,className:"mt-2 inline-flex items-center gap-1 text-xs text-primary hover:underline disabled:opacity-60",children:[s.jsx(Mt,{className:"h-3 w-3"}),"Add alias"]})]}),s.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[s.jsx("input",{type:"checkbox",checked:o,onChange:P=>{i(P.target.checked),f(!0)},disabled:p,className:"mt-0.5"}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium",children:"Index external IDs"}),s.jsxs("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:["Fold external IDs (e.g. Jira keys) into search and enable"," ",s.jsx("code",{children:"jira:"}),"/",s.jsx("code",{children:"externalid:"})," and bare-ID matching."]})]})]}),u&&b.length>0&&s.jsx("ul",{className:"space-y-1 text-xs text-error-foreground",children:b.map((P,F)=>s.jsx("li",{children:P},F))}),s.jsx("div",{children:s.jsx("button",{type:"button",onClick:T,disabled:!$,className:"rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:p?"Saving…":"Save search settings"})})]})]})}function Nu(e){return e===fh?"Ungrouped":e}function _Q(){const{data:e,loading:t,error:n,refetch:r}=Ea(),{hidden:o,custom:i,loading:a,error:l,reload:u}=tR(),[f,p]=m.useState(!1),[h,g]=m.useState(null);function y(j){g(j),setTimeout(()=>g(null),2500)}const k=e?[...e.workspaces,...e.hasUngrouped?[fh]:[]]:[];async function v(j,N){const S=N?o.filter(C=>C!==j):[...o,j];p(!0);try{await Zz(S),y({type:"success",message:N?`Showing "${Nu(j)}" in the left nav.`:`Hiding "${Nu(j)}" from the left nav.`})}catch(C){y({type:"error",message:C instanceof Error?C.message:"Save failed."})}finally{p(!1)}}async function b(){p(!0);try{await eB(),y({type:"success",message:"All workspaces shown in the left nav."})}catch(j){y({type:"error",message:j instanceof Error?j.message:"Reset failed."})}finally{p(!1)}}return s.jsxs(qe,{title:"Workspace visibility",description:"Choose which workspaces appear in the left nav. Hidden workspaces stay fully reachable by direct URL — this only controls the sidebar.",actions:i?s.jsxs("button",{className:"shell-action text-xs",onClick:b,disabled:f,type:"button",children:[s.jsx(vs,{className:"h-3 w-3"}),"Show all"]}):void 0,children:[h&&s.jsx("div",{className:`mb-3 rounded-md border px-3 py-1.5 text-xs ${h.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:h.message}),t||a?s.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading workspaces…"}):n||l?s.jsxs("div",{className:"flex items-center gap-3 text-sm text-error-foreground",children:[s.jsx("span",{children:n?"Failed to load workspaces.":"Failed to load the visibility preference."}),s.jsxs("button",{type:"button",className:"shell-action text-xs",onClick:()=>{n&&r(),l&&u()},children:[s.jsx(vs,{className:"h-3 w-3"}),"Retry"]})]}):k.length===0?s.jsx("div",{className:"text-sm text-muted-foreground",children:"No workspaces yet."}):s.jsx("ul",{className:"flex flex-col divide-y divide-border/40",children:k.map(j=>{const N=!Xz(j,o);return s.jsxs("li",{className:"flex items-center justify-between gap-3 py-2",children:[s.jsxs("span",{className:"truncate text-sm",title:Nu(j),children:[Nu(j),j===fh&&s.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:"(standalone, ungrouped)"})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":N,"aria-label":`Show "${Nu(j)}" in the left nav`,onClick:()=>v(j,!N),disabled:f,className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-60 ${N?"bg-primary":"bg-muted"}`,children:s.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 rounded-full bg-background shadow-sm ring-0 transition-transform ${N?"translate-x-4":"translate-x-0"}`})})]},j)})})]})}function DQ(){const{preset:e,setPreset:t,resetPreset:n}=Qv(),[r,o]=m.useState(!1),[i,a]=m.useState(null);async function l(f){if(!(f===e||r)){o(!0),a(null);try{await t(f),a({type:"success",message:"Theme updated"}),setTimeout(()=>a(null),2e3)}catch(p){a({type:"error",message:p instanceof Error?p.message:"Failed to save theme"})}finally{o(!1)}}}async function u(){o(!0),a(null);try{await n(),a({type:"success",message:"Theme reset to default"}),setTimeout(()=>a(null),2e3)}catch(f){a({type:"error",message:f instanceof Error?f.message:"Failed to reset theme"})}finally{o(!1)}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs(qe,{title:"Theme",description:"Pick a color theme for the dashboard. The default is the Syntaur brand.",actions:e!=="default"?s.jsxs("button",{className:"shell-action text-xs",onClick:u,disabled:r,children:[s.jsx(vs,{className:"h-3 w-3"}),"Reset"]}):void 0,children:[i&&s.jsx("div",{className:`mb-3 rounded-md border px-3 py-1.5 text-xs ${i.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:i.message}),s.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4",children:P2.map(f=>{const p=f.slug===e;return s.jsxs("button",{type:"button",onClick:()=>l(f.slug),disabled:r,"aria-pressed":p,className:`group relative flex flex-col gap-2 rounded-lg border bg-card/95 p-3 text-left transition disabled:opacity-60 ${p?"border-primary ring-2 ring-primary/40":"border-border/60 hover:border-primary/40"}`,children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"h-5 w-5 rounded-full ring-1 ring-border/60",style:{background:f.swatches.primary}}),s.jsx("span",{className:"h-5 w-5 rounded-full ring-1 ring-border/60",style:{background:f.swatches.secondary}}),s.jsx("span",{className:"h-5 w-5 rounded-full ring-1 ring-border/60",style:{background:f.swatches.coral}}),s.jsx("span",{className:"h-5 w-5 rounded-full ring-1 ring-border/60",style:{background:f.swatches.teal}}),s.jsx("span",{className:"h-5 w-5 rounded-full ring-1 ring-border/60",style:{background:f.swatches.amber}}),p&&s.jsx("span",{className:"ml-auto inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-primary-foreground",children:s.jsx(Sr,{className:"h-3 w-3"})})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-foreground",children:f.label}),s.jsx("div",{className:"text-xs text-muted-foreground",children:f.description})]})]},f.slug)})})]}),s.jsx(lQ,{}),s.jsx(TQ,{}),s.jsx(PQ,{}),s.jsx(_Q,{}),s.jsx(jQ,{}),s.jsx(pQ,{}),s.jsx(aQ,{})]})}function $Q({open:e,affected:t,remaining:n,ruleReferences:r,headlineReferences:o,onResolve:i,onCancel:a}){var D,T;const[l,u]=m.useState(n.length>0?"remap":"delete"),[f,p]=m.useState(((D=n[0])==null?void 0:D.id)??""),[h,g]=m.useState(((T=n[0])==null?void 0:T.id)??""),[y,k]=m.useState(!1),v=t.count>0;m.useEffect(()=>{var R,$;e&&(u(n.length>0?"remap":"delete"),p(((R=n[0])==null?void 0:R.id)??""),g((($=n[0])==null?void 0:$.id)??""),k(!1))},[e,n]);const b=!o||h!==""&&h!==t.id,j=l==="remap"&&n.length>0&&f!==""&&f!==t.id||l==="delete"&&(!v||y)&&b;function N(){j&&(l==="remap"?i({id:t.id,mode:"remap",target:f},f):i({id:t.id,mode:"delete"},o?h:""))}const S=t.assignments.slice(0,10),C=t.count-S.length;return s.jsx(Mn,{open:e,onOpenChange:R=>R?void 0:a(),children:s.jsxs(Nn,{className:"max-w-xl",children:[s.jsxs(sr,{children:[s.jsxs(Cn,{children:['Delete status "',t.label,'"',v?` — ${t.count} assignment${t.count===1?"":"s"} reference it`:""]}),s.jsx(ns,{children:v?"Choose how to resolve the affected assignments before this status is removed from the workflow.":"No assignments use this status, but workflow rules reference it. Choose how to resolve them."})]}),v&&s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsxs("ul",{className:"space-y-1 text-sm",children:[S.map(R=>s.jsx("li",{children:s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:R.display})},`${R.projectSlug??"standalone"}/${R.assignmentSlug}`)),C>0&&s.jsxs("li",{className:"text-xs italic text-muted-foreground",children:["+",C," more not shown"]})]})}),r.length>0&&s.jsxs("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/5 p-3",children:[s.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"Workflow rules referencing this status:"}),s.jsx("ul",{className:"space-y-0.5 font-mono text-xs text-muted-foreground",children:r.map((R,$)=>s.jsxs("li",{children:[s.jsx("span",{className:"text-foreground",children:R.section}),s.jsx("span",{className:"mx-1",children:"·"}),R.detail]},$))}),s.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:l==="remap"?"These will be remapped to the target status.":"Ladder rungs and transitions referencing this status will be removed"+(o?"; headline rules must be remapped below.":".")})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"radio",name:"status-delete-mode",checked:l==="remap",onChange:()=>u("remap"),disabled:n.length===0,className:"mt-1"}),s.jsxs("span",{className:"flex-1",children:[s.jsx("span",{className:"block text-sm font-medium",children:v?"Remap to another status":"Remap rules to another status"}),s.jsxs("select",{value:f,onChange:R=>p(R.target.value),onClick:()=>u("remap"),disabled:l!=="remap"||n.length===0,className:"mt-2 block w-full rounded-md border border-border/60 bg-background px-2 py-1 text-sm",children:[n.length===0&&s.jsx("option",{value:"",children:"(no other statuses)"}),n.map(R=>s.jsxs("option",{value:R.id,children:[R.label," (",R.id,")"]},R.id))]}),n.length===0&&s.jsx("span",{className:"block text-xs text-muted-foreground mt-1",children:"No other saved statuses to remap to. Add another status first, or use Delete."})]})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"radio",name:"status-delete-mode",checked:l==="delete",onChange:()=>u("delete"),className:"mt-1"}),s.jsxs("span",{className:"flex-1",children:[s.jsx("span",{className:"block text-sm font-medium text-error-foreground",children:v?"Delete these assignments":"Drop the referencing rules"}),s.jsx("span",{className:"block text-xs text-muted-foreground mt-1",children:v?`Permanently removes ${t.count} assignment${t.count===1?"":"s"} from disk. This cannot be undone.`:"Ladder rungs and transitions referencing this status are removed."}),l==="delete"&&o&&s.jsxs("span",{className:"mt-2 block",children:[s.jsx("span",{className:"block text-xs font-medium",children:"Remap headline rules to"}),s.jsxs("select",{value:h,onChange:R=>g(R.target.value),disabled:n.length===0,className:"mt-1 block w-full rounded-md border border-border/60 bg-background px-2 py-1 text-sm",children:[n.length===0&&s.jsx("option",{value:"",children:"(no other statuses)"}),n.map(R=>s.jsxs("option",{value:R.id,children:[R.label," (",R.id,")"]},R.id))]}),s.jsx("span",{className:"mt-1 block text-xs text-muted-foreground",children:"The headline projection cannot reference a deleted status, so it must point somewhere."})]}),l==="delete"&&v&&s.jsxs("label",{className:"mt-2 flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:R=>k(R.target.checked)}),s.jsxs("span",{className:"text-xs",children:["I understand this will permanently delete ",t.count," assignment",t.count===1?"":"s","."]})]})]})]})]}),s.jsxs(Wr,{children:[s.jsx("button",{type:"button",onClick:a,className:"shell-action",children:"Cancel"}),s.jsx("button",{type:"button",onClick:N,disabled:!j,className:`shell-action ${l==="delete"?"bg-error text-error-foreground hover:opacity-90":"shell-action--cta"} disabled:cursor-not-allowed disabled:opacity-50`,children:l==="remap"?v?`Remap ${t.count} → ${f||"..."}`:`Remap rules → ${f||"..."}`:v?`Delete ${t.count}`:"Drop rules"})]})]})})}function IQ({open:e,references:t,onConfirm:n,onCancel:r}){return s.jsx(Mn,{open:e,onOpenChange:o=>o?void 0:r(),children:s.jsxs(Nn,{className:"max-w-xl",children:[s.jsxs(sr,{children:[s.jsx(Cn,{children:"Delete fact — referenced by derive rules"}),s.jsx(ns,{children:"Removing this fact will break the following derive conditions. The doctor check will flag them as invalid until they are fixed."})]}),s.jsx("div",{className:"rounded-md border border-border/60 bg-background/80 p-3",children:s.jsx("ul",{className:"space-y-2 text-sm",children:t.map((o,i)=>s.jsxs("li",{className:"font-mono text-xs text-muted-foreground",children:[s.jsx("span",{className:"text-foreground",children:o.location}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:o.when})]},i))})}),s.jsxs(Wr,{children:[s.jsx("button",{type:"button",onClick:r,className:"shell-action",children:"Cancel"}),s.jsx("button",{type:"button",onClick:n,className:"shell-action bg-error text-error-foreground hover:opacity-90",children:"Confirm delete — rules will become invalid"})]})]})})}function LQ({value:e,onChange:t,ariaLabel:n}){const r=n??"Pick a color",o=n?`${n} (hex)`:"Color hex value";return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"color",value:e||"#64748b",onChange:i=>t(i.target.value),className:"h-7 w-7 shrink-0 cursor-pointer rounded-md border border-border/60 bg-transparent p-0.5",title:"Pick a color","aria-label":r}),s.jsx("input",{type:"text",value:e,onChange:i=>t(i.target.value),placeholder:"#64748b",className:"editor-input w-[5.5rem] font-mono text-xs","aria-label":o})]})}function MQ({row:e,isSaved:t,onUpdate:n,onRemove:r}){const{attributes:o,listeners:i,setNodeRef:a,setActivatorNodeRef:l,transform:u,transition:f,isDragging:p}=Cm({id:e.rowKey}),h={transform:js.Transform.toString(u),transition:f,zIndex:p?50:void 0,position:p?"relative":void 0};return s.jsxs("div",{ref:a,style:h,className:`surface-panel flex flex-wrap items-center gap-3 px-3 py-2 ${p?"opacity-60 shadow-lg":""}`,children:[s.jsx("button",{ref:l,...o,...i,type:"button","aria-label":"Drag to reorder",className:"cursor-grab active:cursor-grabbing text-muted-foreground/40 hover:text-muted-foreground transition touch-none",children:s.jsx(gc,{className:"h-4 w-4"})}),s.jsx("div",{className:"min-w-[8rem] flex-1",children:t?s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:s.jsx("input",{type:"text",value:e.id,readOnly:!0,"aria-label":"Status ID",className:"editor-input w-full text-sm cursor-not-allowed opacity-60"})}),s.jsx(vr,{className:"max-w-xs text-xs font-normal normal-case tracking-normal",children:"To rename a saved status, delete the row and create a new one (this triggers the orphan-resolution flow if assignments still reference it)."})]}):s.jsx("input",{type:"text",value:e.id,onChange:g=>n("id",g.target.value),"aria-label":"Status ID",className:"editor-input w-full text-sm"})}),s.jsx("div",{className:"min-w-[8rem] flex-1",children:s.jsx("input",{type:"text",value:e.label,onChange:g=>n("label",g.target.value),"aria-label":"Status label",className:"editor-input w-full text-sm"})}),s.jsx("div",{className:"min-w-[10rem] flex-1",children:s.jsx("input",{type:"text",value:e.description,onChange:g=>n("description",g.target.value),"aria-label":"Status description",placeholder:"description (optional)",className:"editor-input w-full text-sm"})}),s.jsx(LQ,{value:e.color,onChange:g=>n("color",g),ariaLabel:`Color for ${e.label||e.id}`}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:s.jsx("span",{className:"cursor-help text-xs text-muted-foreground underline decoration-dotted underline-offset-4",children:"Done"})}),s.jsx(vr,{className:"max-w-xs text-xs font-normal normal-case tracking-normal",children:'When enabled, assignments in this status count as finished — they fill the "done" portion of progress bars and satisfy dependency requirements.'})]}),s.jsx("button",{type:"button",role:"switch","aria-checked":e.terminal,"aria-label":`Done state for ${e.label||e.id}`,onClick:()=>n("terminal",!e.terminal),className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background ${e.terminal?"bg-primary":"bg-muted"}`,children:s.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 rounded-full bg-background shadow-sm ring-0 transition-transform ${e.terminal?"translate-x-4":"translate-x-0"}`})})]}),s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground",onClick:r,title:"Remove status","aria-label":`Remove status ${e.id}`,children:s.jsx(jn,{className:"h-3.5 w-3.5"})})]})}function OQ({statuses:e,savedStatusIds:t,onUpdate:n,onAdd:r,onRemove:o,onReorder:i}){const a=bm(ji(kc,{activationConstraint:{distance:8}}),ji(jc,{coordinateGetter:qR}));function l(u){const{active:f,over:p}=u;if(!p||f.id===p.id)return;const h=e.findIndex(y=>y.rowKey===f.id),g=e.findIndex(y=>y.rowKey===p.id);h===-1||g===-1||i(Sc(e,h,g))}return s.jsx(qe,{title:"Status Definitions",description:"Define the statuses assignments can have. Drag rows to set the display order used by Kanban columns, progress bars, and dropdowns.",actions:s.jsxs("button",{className:"shell-action text-xs",onClick:r,children:[s.jsx(Mt,{className:"h-3 w-3"}),"Add Status"]}),children:s.jsx(Sm,{sensors:a,collisionDetection:vm,onDragEnd:l,children:s.jsx(Nm,{items:e.map(u=>u.rowKey),strategy:Aw,children:s.jsx("div",{className:"space-y-2",children:e.map((u,f)=>s.jsx(MQ,{row:u,isSaved:t.has(u.id),onUpdate:(p,h)=>n(f,p,h),onRemove:()=>o(f)},u.rowKey))})})})})}function FQ(e){const t=Array.from(e.pendingResolutions.values()),r={statuses:e.statuses.map(o=>({id:o.id,label:o.label,...o.description?{description:o.description}:{},...o.color?{color:o.color}:{},...o.terminal?{terminal:!0}:{}})),order:e.order,resolutions:t};return e.transitions!==void 0&&(r.transitions=e.transitions),e.derive!==void 0&&(r.derive=e.derive),e.facts!==void 0&&(r.facts=e.facts),e.factRemovalAcks&&e.factRemovalAcks.length>0&&(r.factRemovalAcks=e.factRemovalAcks),{body:r,resolutions:t}}function zQ(e,t,n){const r=[];t.phaseLadder.forEach((o,i)=>{o.phase===e&&r.push({section:"phaseLadder",detail:`phaseLadder rung ${i} ("${o.phase}")`})}),t.headline.parked===e&&r.push({section:"headline",detail:"headline.parked"}),t.headline.blocked===e&&r.push({section:"headline",detail:"headline.blocked"});for(const o of n)(o.from===e||o.to===e)&&r.push({section:"transitions",detail:`transition ${o.from} --${o.command}--> ${o.to}`});return r}function BQ(e,t){return t.headline.parked===e||t.headline.blocked===e}function UQ(e,t,n){return{phaseLadder:e.phaseLadder.map(r=>r.phase===t?{...r,phase:n}:r),disposition:e.disposition,headline:{parked:e.headline.parked===t?n:e.headline.parked,blocked:e.headline.blocked===t?n:e.headline.blocked}}}function HQ(e,t,n){return e.map(r=>({...r,from:r.from===t?n:r.from,to:r.to===t?n:r.to}))}function VQ(e,t,n){return{phaseLadder:e.phaseLadder.filter(r=>r.phase!==t),disposition:e.disposition,headline:{parked:e.headline.parked===t?n:e.headline.parked,blocked:e.headline.blocked===t?n:e.headline.blocked}}}function WQ(e,t){return e.filter(n=>n.from!==t&&n.to!==t)}function qQ(e,t){const n=new Map;t.forEach((o,i)=>{n.has(o)||n.set(o,i)});const r=t.length;return e.map((o,i)=>({s:o,originalIndex:i,r:n.get(o.id)??r})).sort((o,i)=>o.r-i.r||o.originalIndex-i.originalIndex).map(o=>o.s)}function lC(e,t){const n=new Map;for(const[r,o]of e.entries())t.has(o.id)||o.mode==="remap"&&!t.has(o.target)||n.set(r,o);return n}function s3(){return`row_${Math.random().toString(36).slice(2,10)}_${Date.now().toString(36)}`}function KQ(e){const t=e.statuses.map(n=>({rowKey:s3(),id:n.id,label:n.label,description:n.description??"",color:n.color??"",terminal:n.terminal??!1}));return qQ(t,e.order)}function GQ(e){return Wb(e)}function cC(e){const t=new Map;for(const n of e)t.set(n,(t.get(n)??0)+1);return t}function YQ(e){const t=new Map;for(let n=0;n<e.length;n++){const r=cC(Wb(e.slice(0,n))),o=cC(Wb(e.slice(0,n+1)));for(const[i,a]of o.entries()){const l=r.get(i)??0;if(a>l){t.set(n,i);break}}}return t}const XQ=[{value:"bool",label:"bool"},{value:"number",label:"number"},{value:"attestation",label:"attestation"}],QQ=[{value:"plan",label:"plan"},{value:"commit",label:"commit"},{value:"none",label:"none"}];function JQ(){return{name:"",type:"bool",binds:null}}function ZQ({rows:e,onChange:t,saving:n}){const r=YQ(e),o=m.useCallback(()=>{t([...e,JQ()])},[e,t]),i=m.useCallback((l,u,f)=>{t(e.map((p,h)=>h===l?{...p,[u]:f}:p))},[e,t]),a=m.useCallback(l=>{t(e.filter((u,f)=>f!==l))},[e,t]);return s.jsxs(qe,{title:"Facts",description:"Declare custom facts and attestation fields for derive rules and the fact vocabulary.",children:[s.jsxs("p",{className:"mb-3 text-xs text-muted-foreground",children:["Names must match ",s.jsx("code",{className:"font-mono",children:"^[a-z][a-zA-Z0-9]*"})," — start with a lowercase letter, then letters or numbers only (no spaces, hyphens, or underscores)."]}),s.jsxs("div",{className:"space-y-2",children:[e.length===0&&s.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No custom facts declared."}),e.map((l,u)=>{const f=r.get(u),p=l.type==="attestation";return s.jsxs("div",{className:`rounded-md border p-2 ${f?"border-error-foreground/40 bg-error/5":"border-border/60 bg-background/80"}`,children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"flex-1 grid grid-cols-1 sm:grid-cols-3 gap-2",children:[s.jsx("input",{type:"text",value:l.name,onChange:h=>i(u,"name",h.target.value),placeholder:"factName",disabled:n,className:"w-full rounded-md border border-border/60 bg-background px-2 py-1 text-sm font-mono focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60"}),s.jsx("select",{value:l.type,onChange:h=>{const g=h.target.value;t(e.map((y,k)=>k===u?{...y,type:g,binds:g==="attestation"?y.binds:null}:y))},disabled:n,className:"w-full rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60",children:XQ.map(h=>s.jsx("option",{value:h.value,children:h.label},h.value))}),p?s.jsx("select",{value:l.binds??"none",onChange:h=>i(u,"binds",h.target.value),disabled:n,className:"w-full rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60",children:QQ.map(h=>s.jsx("option",{value:h.value,children:h.label},h.value))}):s.jsx("span",{className:"text-sm text-muted-foreground py-1",children:"—"})]}),f&&s.jsxs(Or,{children:[s.jsx(Fr,{asChild:!0,children:s.jsx("span",{className:"mt-1 inline-flex text-error-foreground","aria-label":"Invalid fact",children:s.jsx(ih,{className:"h-3.5 w-3.5 flex-shrink-0"})})}),s.jsx(vr,{className:"max-w-xs text-xs font-normal normal-case tracking-normal",children:f})]}),s.jsx("button",{type:"button",onClick:()=>a(u),disabled:n,className:"mt-0.5 shell-action text-xs text-muted-foreground hover:text-error disabled:opacity-50",title:"Delete",children:s.jsx(jn,{className:"h-3.5 w-3.5"})})]}),f&&s.jsx("p",{className:"mt-1 text-xs text-error-foreground",children:f})]},u)})]}),s.jsxs("button",{type:"button",onClick:o,disabled:n,className:"mt-2 shell-action text-xs inline-flex items-center gap-1 disabled:opacity-50",children:[s.jsx(Mt,{className:"h-3.5 w-3.5"}),"Add fact"]})]})}function o3(e,t=$m){var r,o;if(e==="*")return null;const n=dm(e);if(!n.ast)return((r=n.errors[0])==null?void 0:r.message)??"unparseable condition";try{return Mu(n.ast,t),null}catch(i){if(i instanceof br)return((o=i.errors[0])==null?void 0:o.message)??"invalid condition";throw i}}function Yy(e){if(e.values.length!==1)return null;const t=e.values[0];return{field:e.field,op:e.op,value:t.raw,valueType:t.type}}function eJ(e){if(e.kind==="atom"){const t=Yy(e);return t?{outerJoin:"AND",groups:[{join:"AND",comparisons:[t]}]}:null}if(e.kind==="and"||e.kind==="or"){const t=e.kind==="and"?"AND":"OR",n=e.kind==="and"?"or":"and",r=e.kind==="and"?"OR":"AND",o=[];for(const i of e.children)if(i.kind==="atom"){const a=Yy(i);if(!a)return null;o.push({join:r,comparisons:[a]})}else if(i.kind===n){const a=[];for(const l of i.children){if(l.kind!=="atom")return null;const u=Yy(l);if(!u)return null;a.push(u)}o.push({join:r,comparisons:a})}else return null;return{outerJoin:t,groups:o}}return null}function uC(e){const t=e.trim();if(t===""||t==="*")return null;const n=dm(t);return n.ast?eJ(n.ast):null}const tJ=/^[A-Za-z_][A-Za-z0-9_-]*$/;function nJ(e){return e===""||!tJ.test(e)||/^(and|or|not)$/i.test(e)}function rJ(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function sJ(e){return e.valueType==="number"||e.valueType==="date"||e.valueType==="duration"?e.value:nJ(e.value)?rJ(e.value):e.value}function oJ(e){const t=sJ(e);return e.op===":"?`${e.field}:${t}`:`${e.field} ${e.op} ${t}`}function iJ(e){return e.groups.map(n=>{const r=n.comparisons.map(oJ).join(` ${n.join} `);return n.comparisons.length>1?`(${r})`:r}).join(` ${e.outerJoin} `)}function aJ(e,t){return e.trim()==="*"?null:e.trim()===""?"condition is empty":o3(e,t)}function lJ(e){return mH(hH(e))}function cJ(e){const t=Vw(e),n=[];for(const r of OA(e)){const o=t[r.toLowerCase()];o&&n.push({name:r,kind:o.kind})}return n}function i3(e){switch(e){case"bool":return"word";case"number":case"ordinal":case"duration":case"timestamp":return"number";default:return"string"}}function gv(e){switch(e){case"bool":return[":"];case"number":case"ordinal":case"duration":case"timestamp":return[":","=","!=","<","<=",">",">="];default:return[":","!="]}}function Cu(e){const t=e[0];return{outerJoin:"AND",groups:[{join:"AND",comparisons:[t?{field:t.name,op:gv(t.kind)[0],value:t.kind==="bool"?"true":"",valueType:i3(t.kind)}:{field:"",op:":",value:""}]}]}}function a3({value:e,onChange:t,fieldOptions:n,registry:r,disabled:o}){const i=m.useMemo(()=>uC(e),[e]),a=e.trim()===""||i!==null,[l,u]=m.useState(a?"builder":"raw"),[f,p]=m.useState(()=>i??Cu(n)),h=m.useRef(e);m.useEffect(()=>{if(e===h.current)return;const T=uC(e);T&&p(T),!(e.trim()===""||T)&&l==="builder"&&u("raw"),h.current=e},[e]);const g=aJ(e,r);function y(T){h.current=T,t(T)}function k(T){p(T),y(iJ(T))}function v(T){k({outerJoin:T,groups:f.groups.map(R=>({...R,join:T==="AND"?"OR":"AND"}))})}function b(T,R,$){const P=f.groups.map((F,_)=>_===T?{...F,comparisons:F.comparisons.map((V,U)=>U===R?{...V,...$}:V)}:F);k({...f,groups:P})}function j(T){const R=Cu(n).groups[0].comparisons[0],$=f.groups.map((P,F)=>F===T?{...P,comparisons:[...P.comparisons,{...R}]}:P);k({...f,groups:$})}function N(T,R){let $=f.groups.map((P,F)=>F===T?{...P,comparisons:P.comparisons.filter((_,V)=>V!==R)}:P);$=$.filter(P=>P.comparisons.length>0),$.length===0&&($=Cu(n).groups),k({...f,groups:$})}function S(){const T=f.outerJoin==="AND"?"OR":"AND";k({...f,groups:[...f.groups,{join:T,comparisons:[Cu(n).groups[0].comparisons[0]]}]})}function C(){if(l==="builder"){u("raw");return}a&&(p(i??Cu(n)),u("builder"))}const D="rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60";return s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:"Condition"}),s.jsxs("button",{type:"button",onClick:C,disabled:o||l==="raw"&&!a,title:l==="raw"&&!a?"Condition too complex for the builder — edit as raw AQL":l==="builder"?"Switch to raw AQL":"Switch to builder",className:"shell-action text-xs inline-flex items-center gap-1 disabled:opacity-50",children:[l==="builder"?s.jsx(nO,{className:"h-3 w-3"}):s.jsx(bO,{className:"h-3 w-3"}),l==="builder"?"Raw AQL":"Builder"]})]}),l==="raw"?s.jsx("input",{type:"text",list:"aql-field-names",value:e,onChange:T=>y(T.target.value),disabled:o,placeholder:"e.g. planApproved:true AND implementationStarted:true",className:`${D} w-full font-mono`}):s.jsxs("div",{className:"space-y-2",children:[f.groups.map((T,R)=>s.jsxs("div",{children:[R>0&&s.jsxs("div",{className:"my-1 flex items-center gap-2",children:[s.jsx("span",{className:"h-px flex-1 bg-border/60"}),s.jsx("button",{type:"button",onClick:()=>v(f.outerJoin==="AND"?"OR":"AND"),disabled:o,className:"shell-action text-[10px] uppercase tracking-wide",children:f.outerJoin}),s.jsx("span",{className:"h-px flex-1 bg-border/60"})]}),s.jsxs("div",{className:"rounded-md border border-border/50 bg-background/60 p-2 space-y-1.5",children:[T.comparisons.map(($,P)=>{const F=n.find(U=>U.name===$.field),_=(F==null?void 0:F.kind)??"string",V=gv(_);return s.jsxs("div",{className:"flex items-center gap-1.5",children:[P>0&&s.jsx("span",{className:"w-9 shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground",children:T.join}),s.jsxs("select",{value:$.field,onChange:U=>{const I=n.find(W=>W.name===U.target.value),M=(I==null?void 0:I.kind)??"string",B=gv(M);b(R,P,{field:U.target.value,op:B.includes($.op)?$.op:B[0],value:M==="bool"?"true":$.value,valueType:i3(M)})},disabled:o,className:`${D} font-mono`,children:[n.length===0&&s.jsx("option",{value:"",children:"(no fields)"}),!n.some(U=>U.name===$.field)&&$.field!==""&&s.jsx("option",{value:$.field,children:$.field}),n.map(U=>s.jsx("option",{value:U.name,children:U.name},U.name))]}),s.jsx("select",{value:$.op,onChange:U=>b(R,P,{op:U.target.value}),disabled:o,className:`${D} font-mono`,children:V.map(U=>s.jsx("option",{value:U,children:U},U))}),_==="bool"?s.jsxs("select",{value:$.value||"true",onChange:U=>b(R,P,{value:U.target.value}),disabled:o,className:`${D} font-mono`,children:[s.jsx("option",{value:"true",children:"true"}),s.jsx("option",{value:"false",children:"false"})]}):s.jsx("input",{type:"text",value:$.value,onChange:U=>b(R,P,{value:U.target.value}),disabled:o,placeholder:"value",className:`${D} w-24 font-mono`}),s.jsx("button",{type:"button",onClick:()=>N(R,P),disabled:o,className:"ml-auto inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Remove condition",children:s.jsx(jn,{className:"h-3.5 w-3.5"})})]},P)}),s.jsxs("button",{type:"button",onClick:()=>j(R),disabled:o,className:"shell-action text-xs inline-flex items-center gap-1",children:[s.jsx(Mt,{className:"h-3 w-3"}),T.join," condition"]})]})]},R)),s.jsxs("button",{type:"button",onClick:S,disabled:o,className:"shell-action text-xs inline-flex items-center gap-1",children:[s.jsx(Mt,{className:"h-3 w-3"}),f.outerJoin," group"]})]}),s.jsx("datalist",{id:"aql-field-names",children:n.map(T=>s.jsx("option",{value:T.name},T.name))}),s.jsx("p",{className:"font-mono text-[11px] text-muted-foreground truncate",title:e,children:e.trim()===""?s.jsx("span",{className:"italic",children:"empty condition"}):e}),g&&s.jsx("p",{className:"text-xs text-error-foreground",children:g})]})}let dC=0;function Ih(){return dC+=1,`dr_${dC}_${Math.random().toString(36).slice(2,8)}`}function Xy(e){const t=[...e.disposition].sort((n,r)=>n.when===null&&r.when!==null?1:n.when!==null&&r.when===null?-1:0);return{phaseLadder:e.phaseLadder.map(n=>({rowKey:Ih(),phase:n.phase,when:n.when,next:n.next??""})),disposition:t.map(n=>({rowKey:Ih(),when:n.when,is:n.is})),headline:{parked:e.headline.parked,blocked:e.headline.blocked}}}function xv(e){const t=e.phaseLadder.map(r=>r.next.trim()?{phase:r.phase,when:r.when,next:r.next.trim()}:{phase:r.phase,when:r.when}),n=e.disposition.map(r=>({when:r.when,is:r.is}));return{phaseLadder:t,disposition:n,headline:{terminal:"passthrough",active:"phase",parked:e.headline.parked,blocked:e.headline.blocked}}}function uJ(e){return e.findIndex(t=>t.when.trim()==="*")}function l3(e,t,n){return uz(e,{statuses:t},r=>o3(r,n))}const fC=["active","blocked","parked"];function dJ({value:e,deriveCustom:t,statuses:n,acceptedFacts:r,onChange:o,onReset:i,disabled:a}){const l=m.useMemo(()=>Vw(r),[r]),u=m.useMemo(()=>cJ(r),[r]),f=bm(ji(kc,{activationConstraint:{distance:8}}),ji(jc,{coordinateGetter:qR})),p=m.useMemo(()=>{try{return l3(xv(e),n,l)}catch{return["derive rules are malformed"]}},[e,n,l]),h=uJ(e.phaseLadder),g=h>=0?e.phaseLadder[h]:null,y=e.phaseLadder.filter((P,F)=>F!==h);function k(P,F){o({...e,phaseLadder:[...P?[P]:[],...F]})}function v(P,F){const _=e.phaseLadder.map(V=>V.rowKey===P?{...V,...F}:V);o({...e,phaseLadder:_})}function b(){var F;const P={rowKey:Ih(),phase:((F=n[0])==null?void 0:F.id)??"",when:"",next:""};k(g,[...y,P])}function j(P){o({...e,phaseLadder:e.phaseLadder.filter(F=>F.rowKey!==P)})}function N(P){const{active:F,over:_}=P;if(!_||F.id===_.id)return;const V=y.findIndex(I=>I.rowKey===F.id),U=y.findIndex(I=>I.rowKey===_.id);V===-1||U===-1||k(g,Sc(y,V,U))}function S(P,F){o({...e,disposition:e.disposition.map(_=>_.rowKey===P?{..._,...F}:_)})}function C(){const P={rowKey:Ih(),when:"",is:"active"},F=e.disposition.findIndex(V=>V.when===null),_=[...e.disposition];F>=0?_.splice(F,0,P):_.push(P),o({...e,disposition:_})}function D(P){o({...e,disposition:e.disposition.filter(F=>F.rowKey!==P)})}function T(P,F){o({...e,headline:{...e.headline,[P]:F}})}const R="rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60";function $(P,F,_){return s.jsxs("select",{value:P,onChange:V=>F(V.target.value),disabled:a,"aria-label":_,className:`${R} font-mono`,children:[!n.some(V=>V.id===P)&&P!==""&&s.jsx("option",{value:P,children:P}),n.map(V=>s.jsxs("option",{value:V.id,children:[V.label," (",V.id,")"]},V.id))]})}return s.jsxs(qe,{title:"Derive Rules",description:"The phase ladder, disposition rules, and headline projection that map facts to a status. Highest matching rung wins — drag to reorder priority.",actions:t?s.jsxs("button",{type:"button",className:"shell-action text-xs inline-flex items-center gap-1",onClick:i,disabled:a,children:[s.jsx(vs,{className:"h-3 w-3"}),"Reset to default rules"]}):void 0,children:[!t&&s.jsx("div",{className:"mb-3 rounded-md border border-border/60 bg-muted/30 px-3 py-1.5 text-xs text-muted-foreground",children:"Using built-in derive rules. Editing anything below switches to a custom configuration."}),p.length>0&&s.jsxs("div",{className:"mb-3 rounded-md border border-error-foreground/30 bg-error/10 px-3 py-2 text-xs text-error-foreground",children:[s.jsx("p",{className:"font-medium",children:"These derive rules won't save until fixed:"}),s.jsx("ul",{className:"mt-1 list-disc pl-4 space-y-0.5",children:p.map((P,F)=>s.jsx("li",{children:P},F))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Phase ladder"}),g&&s.jsxs("div",{className:"surface-panel flex flex-wrap items-start gap-3 px-3 py-2 opacity-90",children:[s.jsx("span",{className:"mt-1 text-muted-foreground/40",children:s.jsx(gc,{className:"h-4 w-4 opacity-30"})}),s.jsxs("div",{className:"min-w-[10rem] flex-1 space-y-1",children:[s.jsx("label",{className:"text-xs text-muted-foreground",children:"Phase (catch-all, lowest priority)"}),$(g.phase,P=>v(g.rowKey,{phase:P}),"Catch-all phase"),s.jsx("span",{className:"ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"matches everything"})]}),s.jsxs("div",{className:"min-w-[12rem] flex-1",children:[s.jsx("label",{className:"text-xs text-muted-foreground",children:"Next action"}),s.jsx("input",{type:"text",value:g.next,onChange:P=>v(g.rowKey,{next:P.target.value}),disabled:a,className:`${R} w-full`})]})]}),s.jsx(Sm,{sensors:f,collisionDetection:vm,onDragEnd:N,children:s.jsx(Nm,{items:y.map(P=>P.rowKey),strategy:Aw,children:s.jsx("div",{className:"space-y-2",children:y.map(P=>s.jsx(fJ,{rung:P,disabled:a,statusSelect:$,fieldOptions:u,registry:l,onUpdate:F=>v(P.rowKey,F),onRemove:()=>j(P.rowKey)},P.rowKey))})})}),s.jsxs("button",{type:"button",onClick:b,disabled:a,className:"shell-action text-xs inline-flex items-center gap-1",children:[s.jsx(Mt,{className:"h-3 w-3"}),"Add rung"]})]}),s.jsxs("div",{className:"mt-5 space-y-2",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Disposition (first match wins)"}),s.jsx("div",{className:"space-y-2",children:e.disposition.map(P=>P.when===null?s.jsxs("div",{className:"surface-panel flex items-center gap-3 px-3 py-2",children:[s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"otherwise"}),s.jsx("span",{className:"text-sm text-muted-foreground",children:"is"}),s.jsx("select",{value:P.is,onChange:F=>S(P.rowKey,{is:F.target.value}),disabled:a,className:`${R} font-mono`,children:fC.map(F=>s.jsx("option",{value:F,children:F},F))})]},P.rowKey):s.jsxs("div",{className:"surface-panel flex flex-wrap items-start gap-3 px-3 py-2",children:[s.jsx("div",{className:"min-w-[14rem] flex-1",children:s.jsx(a3,{value:P.when,onChange:F=>S(P.rowKey,{when:F}),fieldOptions:u,registry:l,disabled:a})}),s.jsxs("div",{className:"flex items-center gap-2 pt-5",children:[s.jsx("span",{className:"text-sm text-muted-foreground",children:"is"}),s.jsx("select",{value:P.is,onChange:F=>S(P.rowKey,{is:F.target.value}),disabled:a,className:`${R} font-mono`,children:fC.map(F=>s.jsx("option",{value:F,children:F},F))}),s.jsx("button",{type:"button",onClick:()=>D(P.rowKey),disabled:a,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Remove disposition rule",children:s.jsx(jn,{className:"h-3.5 w-3.5"})})]})]},P.rowKey))}),s.jsxs("button",{type:"button",onClick:C,disabled:a,className:"shell-action text-xs inline-flex items-center gap-1",children:[s.jsx(Mt,{className:"h-3 w-3"}),"Add disposition rule"]})]}),s.jsxs("div",{className:"mt-5 space-y-2",children:[s.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Headline projection"}),s.jsxs("div",{className:"surface-panel grid grid-cols-1 gap-3 px-3 py-2 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-muted-foreground",children:"When parked, show"}),$(e.headline.parked,P=>T("parked",P),"Parked headline status")]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-muted-foreground",children:"When blocked, show"}),$(e.headline.blocked,P=>T("blocked",P),"Blocked headline status")]}),s.jsxs("div",{className:"text-xs text-muted-foreground",children:["Terminal statuses: ",s.jsx("span",{className:"font-mono",children:"passthrough"})]}),s.jsxs("div",{className:"text-xs text-muted-foreground",children:["Active: ",s.jsx("span",{className:"font-mono",children:"phase"})]})]})]})]})}function fJ({rung:e,disabled:t,statusSelect:n,fieldOptions:r,registry:o,onUpdate:i,onRemove:a}){const{attributes:l,listeners:u,setNodeRef:f,setActivatorNodeRef:p,transform:h,transition:g,isDragging:y}=Cm({id:e.rowKey}),k={transform:js.Transform.toString(h),transition:g,zIndex:y?50:void 0,position:y?"relative":void 0};return s.jsxs("div",{ref:f,style:k,className:`surface-panel flex flex-wrap items-start gap-3 px-3 py-2 ${y?"opacity-60 shadow-lg":""}`,children:[s.jsx("button",{ref:p,...l,...u,type:"button","aria-label":"Drag to reorder rung",className:"mt-1 cursor-grab active:cursor-grabbing text-muted-foreground/40 hover:text-muted-foreground transition touch-none",children:s.jsx(gc,{className:"h-4 w-4"})}),s.jsxs("div",{className:"min-w-[10rem] space-y-1",children:[s.jsx("label",{className:"text-xs text-muted-foreground",children:"Phase"}),n(e.phase,v=>i({phase:v}),"Rung phase")]}),s.jsx("div",{className:"min-w-[14rem] flex-1",children:s.jsx(a3,{value:e.when,onChange:v=>i({when:v}),fieldOptions:r,registry:o,disabled:t})}),s.jsxs("div",{className:"min-w-[12rem] flex-1 space-y-1",children:[s.jsx("label",{className:"text-xs text-muted-foreground",children:"Next action"}),s.jsx("input",{type:"text",value:e.next,onChange:v=>i({next:v.target.value}),disabled:t,className:"w-full rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60"})]}),s.jsx("button",{type:"button",onClick:a,disabled:t,className:"mt-5 inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Remove rung",children:s.jsx(jn,{className:"h-3.5 w-3.5"})})]})}const pJ=new Map([["pending:start","in_progress"],["pending:block","blocked"],["draft:shape","ready_for_planning"],["draft:start","in_progress"],["ready_for_planning:plan-ready","ready_to_implement"],["ready_for_planning:start","in_progress"],["ready_to_implement:implement","in_progress"],["in_progress:block","blocked"],["in_progress:review","review"],["in_progress:complete","completed"],["in_progress:fail","failed"],["blocked:unblock","in_progress"],["review:start","in_progress"],["review:complete","completed"],["review:fail","failed"],["completed:reopen","in_progress"],["failed:reopen","in_progress"]]);let pC=0;function c3(){return pC+=1,`tr_${pC}_${Math.random().toString(36).slice(2,8)}`}function hJ(e){return{rowKey:c3(),from:e.from,command:e.command,to:e.to,label:e.label??"",description:e.description??"",requiresReason:e.requiresReason??!1}}function yv(e){return e.map(hJ)}function mJ(e){const t={from:e.from,command:e.command,to:e.to};return e.label.trim()&&(t.label=e.label.trim()),e.description.trim()&&(t.description=e.description.trim()),e.requiresReason&&(t.requiresReason=!0),t}function gJ(e){return e.map(mJ)}function u3(){const e=[];for(const[t,n]of pJ){const r=t.indexOf(":");e.push({from:t.slice(0,r),command:t.slice(r+1),to:n})}return e}function xJ(e,t){return e.filter(n=>t.has(n.from)&&t.has(n.to))}function d3(e,t){const n=[];for(const r of e)t.has(r.from)||n.push(`transition ${r.from} --${r.command}--> ${r.to}: "${r.from}" is not a defined status`),t.has(r.to)||n.push(`transition ${r.from} --${r.command}--> ${r.to}: "${r.to}" is not a defined status`);return n}function yJ(e,t){var i;const n=(i=t[0])==null?void 0:i.id,r=new Set;for(const a of e)a.to&&r.add(a.to);const o=new Set;for(const a of t)a.id!==n&&(r.has(a.id)||o.add(a.id));return o}function hC(e,t){const n=new Set(t.map(l=>l.id)),r=yJ(e,t),o=[],i=new Set;for(const l of t)i.has(l.id)||(i.add(l.id),o.push({id:l.id,label:l.label,color:l.color,terminal:l.terminal??!1,orphan:r.has(l.id),missing:!1}));for(const l of e)for(const u of[l.from,l.to])u&&!i.has(u)&&(i.add(u),o.push({id:u,label:u,terminal:!1,orphan:!1,missing:!0}));const a=e.map(l=>({rowKey:l.rowKey,from:l.from,to:l.to,command:l.command,label:l.label,requiresReason:l.requiresReason,undefinedRef:!n.has(l.from)||!n.has(l.to)}));return{nodes:o,edges:a}}function En(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=En(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var bJ={value:()=>{}};function Zm(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Qp(n)}function Qp(e){this._=e}function vJ(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Qp.prototype=Zm.prototype={constructor:Qp,on:function(e,t){var n=this._,r=vJ(e+"",n),o,i=-1,a=r.length;if(arguments.length<2){for(;++i<a;)if((o=(e=r[i]).type)&&(o=wJ(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(o=(e=r[i]).type)n[o]=mC(n[o],e.name,t);else if(t==null)for(o in n)n[o]=mC(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Qp(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,i;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};function wJ(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function mC(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=bJ,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var bv="http://www.w3.org/1999/xhtml";const gC={svg:"http://www.w3.org/2000/svg",xhtml:bv,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function eg(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),gC.hasOwnProperty(t)?{space:gC[t],local:e}:e}function jJ(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===bv&&t.documentElement.namespaceURI===bv?t.createElement(e):t.createElementNS(n,e)}}function kJ(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function f3(e){var t=eg(e);return(t.local?kJ:jJ)(t)}function SJ(){}function T0(e){return e==null?SJ:function(){return this.querySelector(e)}}function NJ(e){typeof e!="function"&&(e=T0(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],a=i.length,l=r[o]=new Array(a),u,f,p=0;p<a;++p)(u=i[p])&&(f=e.call(u,u.__data__,p,i))&&("__data__"in u&&(f.__data__=u.__data__),l[p]=f);return new Vr(r,this._parents)}function CJ(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function EJ(){return[]}function p3(e){return e==null?EJ:function(){return this.querySelectorAll(e)}}function TJ(e){return function(){return CJ(e.apply(this,arguments))}}function RJ(e){typeof e=="function"?e=TJ(e):e=p3(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var a=t[i],l=a.length,u,f=0;f<l;++f)(u=a[f])&&(r.push(e.call(u,u.__data__,f,a)),o.push(u));return new Vr(r,o)}function h3(e){return function(){return this.matches(e)}}function m3(e){return function(t){return t.matches(e)}}var AJ=Array.prototype.find;function PJ(e){return function(){return AJ.call(this.children,e)}}function _J(){return this.firstElementChild}function DJ(e){return this.select(e==null?_J:PJ(typeof e=="function"?e:m3(e)))}var $J=Array.prototype.filter;function IJ(){return Array.from(this.children)}function LJ(e){return function(){return $J.call(this.children,e)}}function MJ(e){return this.selectAll(e==null?IJ:LJ(typeof e=="function"?e:m3(e)))}function OJ(e){typeof e!="function"&&(e=h3(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],a=i.length,l=r[o]=[],u,f=0;f<a;++f)(u=i[f])&&e.call(u,u.__data__,f,i)&&l.push(u);return new Vr(r,this._parents)}function g3(e){return new Array(e.length)}function FJ(){return new Vr(this._enter||this._groups.map(g3),this._parents)}function Lh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Lh.prototype={constructor:Lh,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function zJ(e){return function(){return e}}function BJ(e,t,n,r,o,i){for(var a=0,l,u=t.length,f=i.length;a<f;++a)(l=t[a])?(l.__data__=i[a],r[a]=l):n[a]=new Lh(e,i[a]);for(;a<u;++a)(l=t[a])&&(o[a]=l)}function UJ(e,t,n,r,o,i,a){var l,u,f=new Map,p=t.length,h=i.length,g=new Array(p),y;for(l=0;l<p;++l)(u=t[l])&&(g[l]=y=a.call(u,u.__data__,l,t)+"",f.has(y)?o[l]=u:f.set(y,u));for(l=0;l<h;++l)y=a.call(e,i[l],l,i)+"",(u=f.get(y))?(r[l]=u,u.__data__=i[l],f.delete(y)):n[l]=new Lh(e,i[l]);for(l=0;l<p;++l)(u=t[l])&&f.get(g[l])===u&&(o[l]=u)}function HJ(e){return e.__data__}function VJ(e,t){if(!arguments.length)return Array.from(this,HJ);var n=t?UJ:BJ,r=this._parents,o=this._groups;typeof e!="function"&&(e=zJ(e));for(var i=o.length,a=new Array(i),l=new Array(i),u=new Array(i),f=0;f<i;++f){var p=r[f],h=o[f],g=h.length,y=WJ(e.call(p,p&&p.__data__,f,r)),k=y.length,v=l[f]=new Array(k),b=a[f]=new Array(k),j=u[f]=new Array(g);n(p,h,v,b,j,y,t);for(var N=0,S=0,C,D;N<k;++N)if(C=v[N]){for(N>=S&&(S=N+1);!(D=b[S])&&++S<k;);C._next=D||null}}return a=new Vr(a,r),a._enter=l,a._exit=u,a}function WJ(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function qJ(){return new Vr(this._exit||this._groups.map(g3),this._parents)}function KJ(e,t,n){var r=this.enter(),o=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function GJ(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,a=Math.min(o,i),l=new Array(o),u=0;u<a;++u)for(var f=n[u],p=r[u],h=f.length,g=l[u]=new Array(h),y,k=0;k<h;++k)(y=f[k]||p[k])&&(g[k]=y);for(;u<o;++u)l[u]=n[u];return new Vr(l,this._parents)}function YJ(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,i=r[o],a;--o>=0;)(a=r[o])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function XJ(e){e||(e=QJ);function t(h,g){return h&&g?e(h.__data__,g.__data__):!h-!g}for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var a=n[i],l=a.length,u=o[i]=new Array(l),f,p=0;p<l;++p)(f=a[p])&&(u[p]=f);u.sort(t)}return new Vr(o,this._parents).order()}function QJ(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function JJ(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ZJ(){return Array.from(this)}function eZ(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var a=r[o];if(a)return a}return null}function tZ(){let e=0;for(const t of this)++e;return e}function nZ(){return!this.node()}function rZ(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],i=0,a=o.length,l;i<a;++i)(l=o[i])&&e.call(l,l.__data__,i,o);return this}function sZ(e){return function(){this.removeAttribute(e)}}function oZ(e){return function(){this.removeAttributeNS(e.space,e.local)}}function iZ(e,t){return function(){this.setAttribute(e,t)}}function aZ(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function lZ(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function cZ(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function uZ(e,t){var n=eg(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?oZ:sZ:typeof t=="function"?n.local?cZ:lZ:n.local?aZ:iZ)(n,t))}function x3(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function dZ(e){return function(){this.style.removeProperty(e)}}function fZ(e,t,n){return function(){this.style.setProperty(e,t,n)}}function pZ(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function hZ(e,t,n){return arguments.length>1?this.each((t==null?dZ:typeof t=="function"?pZ:fZ)(e,t,n??"")):sc(this.node(),e)}function sc(e,t){return e.style.getPropertyValue(t)||x3(e).getComputedStyle(e,null).getPropertyValue(t)}function mZ(e){return function(){delete this[e]}}function gZ(e,t){return function(){this[e]=t}}function xZ(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yZ(e,t){return arguments.length>1?this.each((t==null?mZ:typeof t=="function"?xZ:gZ)(e,t)):this.node()[e]}function y3(e){return e.trim().split(/^|\s+/)}function R0(e){return e.classList||new b3(e)}function b3(e){this._node=e,this._names=y3(e.getAttribute("class")||"")}b3.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function v3(e,t){for(var n=R0(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function w3(e,t){for(var n=R0(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function bZ(e){return function(){v3(this,e)}}function vZ(e){return function(){w3(this,e)}}function wZ(e,t){return function(){(t.apply(this,arguments)?v3:w3)(this,e)}}function jZ(e,t){var n=y3(e+"");if(arguments.length<2){for(var r=R0(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?wZ:t?bZ:vZ)(n,t))}function kZ(){this.textContent=""}function SZ(e){return function(){this.textContent=e}}function NZ(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function CZ(e){return arguments.length?this.each(e==null?kZ:(typeof e=="function"?NZ:SZ)(e)):this.node().textContent}function EZ(){this.innerHTML=""}function TZ(e){return function(){this.innerHTML=e}}function RZ(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function AZ(e){return arguments.length?this.each(e==null?EZ:(typeof e=="function"?RZ:TZ)(e)):this.node().innerHTML}function PZ(){this.nextSibling&&this.parentNode.appendChild(this)}function _Z(){return this.each(PZ)}function DZ(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function $Z(){return this.each(DZ)}function IZ(e){var t=typeof e=="function"?e:f3(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function LZ(){return null}function MZ(e,t){var n=typeof e=="function"?e:f3(e),r=t==null?LZ:typeof t=="function"?t:T0(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function OZ(){var e=this.parentNode;e&&e.removeChild(this)}function FZ(){return this.each(OZ)}function zZ(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function BZ(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function UZ(e){return this.select(e?BZ:zZ)}function HZ(e){return arguments.length?this.property("__data__",e):this.node().__data__}function VZ(e){return function(t){e.call(this,t,this.__data__)}}function WZ(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function qZ(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n<o;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function KZ(e,t,n){return function(){var r=this.__on,o,i=VZ(t);if(r){for(var a=0,l=r.length;a<l;++a)if((o=r[a]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function GZ(e,t,n){var r=WZ(e+""),o,i=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var u=0,f=l.length,p;u<f;++u)for(o=0,p=l[u];o<i;++o)if((a=r[o]).type===p.type&&a.name===p.name)return p.value}return}for(l=t?KZ:qZ,o=0;o<i;++o)this.each(l(r[o],t,n));return this}function j3(e,t,n){var r=x3(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function YZ(e,t){return function(){return j3(this,e,t)}}function XZ(e,t){return function(){return j3(this,e,t.apply(this,arguments))}}function QZ(e,t){return this.each((typeof t=="function"?XZ:YZ)(e,t))}function*JZ(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length,a;o<i;++o)(a=r[o])&&(yield a)}var k3=[null];function Vr(e,t){this._groups=e,this._parents=t}function Yd(){return new Vr([[document.documentElement]],k3)}function ZZ(){return this}Vr.prototype=Yd.prototype={constructor:Vr,select:NJ,selectAll:RJ,selectChild:DJ,selectChildren:MJ,filter:OJ,data:VJ,enter:FJ,exit:qJ,join:KJ,merge:GJ,selection:ZZ,order:YJ,sort:XJ,call:JJ,nodes:ZJ,node:eZ,size:tZ,empty:nZ,each:rZ,attr:uZ,style:hZ,property:yZ,classed:jZ,text:CZ,html:AZ,raise:_Z,lower:$Z,append:IZ,insert:MZ,remove:FZ,clone:UZ,datum:HZ,on:GZ,dispatch:QZ,[Symbol.iterator]:JZ};function zr(e){return typeof e=="string"?new Vr([[document.querySelector(e)]],[document.documentElement]):new Vr([[e]],k3)}function eee(e){let t;for(;t=e.sourceEvent;)e=t;return e}function hs(e,t){if(e=eee(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const tee={passive:!1},md={capture:!0,passive:!1};function Qy(e){e.stopImmediatePropagation()}function Gl(e){e.preventDefault(),e.stopImmediatePropagation()}function S3(e){var t=e.document.documentElement,n=zr(e).on("dragstart.drag",Gl,md);"onselectstart"in t?n.on("selectstart.drag",Gl,md):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function N3(e,t){var n=e.document.documentElement,r=zr(e).on("dragstart.drag",null);t&&(r.on("click.drag",Gl,md),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const wp=e=>()=>e;function vv(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:a,y:l,dx:u,dy:f,dispatch:p}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:p}})}vv.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function nee(e){return!e.ctrlKey&&!e.button}function ree(){return this.parentNode}function see(e,t){return t??{x:e.x,y:e.y}}function oee(){return navigator.maxTouchPoints||"ontouchstart"in this}function C3(){var e=nee,t=ree,n=see,r=oee,o={},i=Zm("start","drag","end"),a=0,l,u,f,p,h=0;function g(C){C.on("mousedown.drag",y).filter(r).on("touchstart.drag",b).on("touchmove.drag",j,tee).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(C,D){if(!(p||!e.call(this,C,D))){var T=S(this,t.call(this,C,D),C,D,"mouse");T&&(zr(C.view).on("mousemove.drag",k,md).on("mouseup.drag",v,md),S3(C.view),Qy(C),f=!1,l=C.clientX,u=C.clientY,T("start",C))}}function k(C){if(Gl(C),!f){var D=C.clientX-l,T=C.clientY-u;f=D*D+T*T>h}o.mouse("drag",C)}function v(C){zr(C.view).on("mousemove.drag mouseup.drag",null),N3(C.view,f),Gl(C),o.mouse("end",C)}function b(C,D){if(e.call(this,C,D)){var T=C.changedTouches,R=t.call(this,C,D),$=T.length,P,F;for(P=0;P<$;++P)(F=S(this,R,C,D,T[P].identifier,T[P]))&&(Qy(C),F("start",C,T[P]))}}function j(C){var D=C.changedTouches,T=D.length,R,$;for(R=0;R<T;++R)($=o[D[R].identifier])&&(Gl(C),$("drag",C,D[R]))}function N(C){var D=C.changedTouches,T=D.length,R,$;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),R=0;R<T;++R)($=o[D[R].identifier])&&(Qy(C),$("end",C,D[R]))}function S(C,D,T,R,$,P){var F=i.copy(),_=hs(P||T,D),V,U,I;if((I=n.call(C,new vv("beforestart",{sourceEvent:T,target:g,identifier:$,active:a,x:_[0],y:_[1],dx:0,dy:0,dispatch:F}),R))!=null)return V=I.x-_[0]||0,U=I.y-_[1]||0,function M(B,W,O){var H=_,L;switch(B){case"start":o[$]=M,L=a++;break;case"end":delete o[$],--a;case"drag":_=hs(O||W,D),L=a;break}F.call(B,C,new vv(B,{sourceEvent:W,subject:I,target:g,identifier:$,active:L,x:_[0]+V,y:_[1]+U,dx:_[0]-H[0],dy:_[1]-H[1],dispatch:F}),R)}}return g.filter=function(C){return arguments.length?(e=typeof C=="function"?C:wp(!!C),g):e},g.container=function(C){return arguments.length?(t=typeof C=="function"?C:wp(C),g):t},g.subject=function(C){return arguments.length?(n=typeof C=="function"?C:wp(C),g):n},g.touchable=function(C){return arguments.length?(r=typeof C=="function"?C:wp(!!C),g):r},g.on=function(){var C=i.on.apply(i,arguments);return C===i?g:C},g.clickDistance=function(C){return arguments.length?(h=(C=+C)*C,g):Math.sqrt(h)},g}function A0(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function E3(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Xd(){}var gd=.7,Mh=1/gd,Yl="\\s*([+-]?\\d+)\\s*",xd="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Zs="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",iee=/^#([0-9a-f]{3,8})$/,aee=new RegExp(`^rgb\\(${Yl},${Yl},${Yl}\\)$`),lee=new RegExp(`^rgb\\(${Zs},${Zs},${Zs}\\)$`),cee=new RegExp(`^rgba\\(${Yl},${Yl},${Yl},${xd}\\)$`),uee=new RegExp(`^rgba\\(${Zs},${Zs},${Zs},${xd}\\)$`),dee=new RegExp(`^hsl\\(${xd},${Zs},${Zs}\\)$`),fee=new RegExp(`^hsla\\(${xd},${Zs},${Zs},${xd}\\)$`),xC={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};A0(Xd,ja,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:yC,formatHex:yC,formatHex8:pee,formatHsl:hee,formatRgb:bC,toString:bC});function yC(){return this.rgb().formatHex()}function pee(){return this.rgb().formatHex8()}function hee(){return T3(this).formatHsl()}function bC(){return this.rgb().formatRgb()}function ja(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=iee.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?vC(t):n===3?new jr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?jp(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?jp(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=aee.exec(e))?new jr(t[1],t[2],t[3],1):(t=lee.exec(e))?new jr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=cee.exec(e))?jp(t[1],t[2],t[3],t[4]):(t=uee.exec(e))?jp(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=dee.exec(e))?kC(t[1],t[2]/100,t[3]/100,1):(t=fee.exec(e))?kC(t[1],t[2]/100,t[3]/100,t[4]):xC.hasOwnProperty(e)?vC(xC[e]):e==="transparent"?new jr(NaN,NaN,NaN,0):null}function vC(e){return new jr(e>>16&255,e>>8&255,e&255,1)}function jp(e,t,n,r){return r<=0&&(e=t=n=NaN),new jr(e,t,n,r)}function mee(e){return e instanceof Xd||(e=ja(e)),e?(e=e.rgb(),new jr(e.r,e.g,e.b,e.opacity)):new jr}function wv(e,t,n,r){return arguments.length===1?mee(e):new jr(e,t,n,r??1)}function jr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}A0(jr,wv,E3(Xd,{brighter(e){return e=e==null?Mh:Math.pow(Mh,e),new jr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?gd:Math.pow(gd,e),new jr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new jr(xa(this.r),xa(this.g),xa(this.b),Oh(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:wC,formatHex:wC,formatHex8:gee,formatRgb:jC,toString:jC}));function wC(){return`#${da(this.r)}${da(this.g)}${da(this.b)}`}function gee(){return`#${da(this.r)}${da(this.g)}${da(this.b)}${da((isNaN(this.opacity)?1:this.opacity)*255)}`}function jC(){const e=Oh(this.opacity);return`${e===1?"rgb(":"rgba("}${xa(this.r)}, ${xa(this.g)}, ${xa(this.b)}${e===1?")":`, ${e})`}`}function Oh(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function xa(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function da(e){return e=xa(e),(e<16?"0":"")+e.toString(16)}function kC(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ms(e,t,n,r)}function T3(e){if(e instanceof ms)return new ms(e.h,e.s,e.l,e.opacity);if(e instanceof Xd||(e=ja(e)),!e)return new ms;if(e instanceof ms)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),a=NaN,l=i-o,u=(i+o)/2;return l?(t===i?a=(n-r)/l+(n<r)*6:n===i?a=(r-t)/l+2:a=(t-n)/l+4,l/=u<.5?i+o:2-i-o,a*=60):l=u>0&&u<1?0:a,new ms(a,l,u,e.opacity)}function xee(e,t,n,r){return arguments.length===1?T3(e):new ms(e,t,n,r??1)}function ms(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}A0(ms,xee,E3(Xd,{brighter(e){return e=e==null?Mh:Math.pow(Mh,e),new ms(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?gd:Math.pow(gd,e),new ms(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new jr(Jy(e>=240?e-240:e+120,o,r),Jy(e,o,r),Jy(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new ms(SC(this.h),kp(this.s),kp(this.l),Oh(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Oh(this.opacity);return`${e===1?"hsl(":"hsla("}${SC(this.h)}, ${kp(this.s)*100}%, ${kp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function SC(e){return e=(e||0)%360,e<0?e+360:e}function kp(e){return Math.max(0,Math.min(1,e||0))}function Jy(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const tg=e=>()=>e;function R3(e,t){return function(n){return e+n*t}}function yee(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function wle(e,t){var n=t-e;return n?R3(e,n>180||n<-180?n-360*Math.round(n/360):n):tg(isNaN(e)?t:e)}function bee(e){return(e=+e)==1?A3:function(t,n){return n-t?yee(t,n,e):tg(isNaN(t)?n:t)}}function A3(e,t){var n=t-e;return n?R3(e,n):tg(isNaN(e)?t:e)}const Fh=(function e(t){var n=bee(t);function r(o,i){var a=n((o=wv(o)).r,(i=wv(i)).r),l=n(o.g,i.g),u=n(o.b,i.b),f=A3(o.opacity,i.opacity);return function(p){return o.r=a(p),o.g=l(p),o.b=u(p),o.opacity=f(p),o+""}}return r.gamma=e,r})(1);function vee(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=e[o]*(1-i)+t[o]*i;return r}}function wee(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function jee(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),i=new Array(n),a;for(a=0;a<r;++a)o[a]=Qu(e[a],t[a]);for(;a<n;++a)i[a]=t[a];return function(l){for(a=0;a<r;++a)i[a]=o[a](l);return i}}function kee(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Ws(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function See(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=Qu(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var jv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Zy=new RegExp(jv.source,"g");function Nee(e){return function(){return e}}function Cee(e){return function(t){return e(t)+""}}function P3(e,t){var n=jv.lastIndex=Zy.lastIndex=0,r,o,i,a=-1,l=[],u=[];for(e=e+"",t=t+"";(r=jv.exec(e))&&(o=Zy.exec(t));)(i=o.index)>n&&(i=t.slice(n,i),l[a]?l[a]+=i:l[++a]=i),(r=r[0])===(o=o[0])?l[a]?l[a]+=o:l[++a]=o:(l[++a]=null,u.push({i:a,x:Ws(r,o)})),n=Zy.lastIndex;return n<t.length&&(i=t.slice(n),l[a]?l[a]+=i:l[++a]=i),l.length<2?u[0]?Cee(u[0].x):Nee(t):(t=u.length,function(f){for(var p=0,h;p<t;++p)l[(h=u[p]).i]=h.x(f);return l.join("")})}function Qu(e,t){var n=typeof t,r;return t==null||n==="boolean"?tg(t):(n==="number"?Ws:n==="string"?(r=ja(t))?(t=r,Fh):P3:t instanceof ja?Fh:t instanceof Date?kee:wee(t)?vee:Array.isArray(t)?jee:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?See:Ws)(e,t)}var NC=180/Math.PI,kv={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function _3(e,t,n,r,o,i){var a,l,u;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(u=e*n+t*r)&&(n-=e*u,r-=t*u),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,u/=l),e*r<t*n&&(e=-e,t=-t,u=-u,a=-a),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*NC,skewX:Math.atan(u)*NC,scaleX:a,scaleY:l}}var Sp;function Eee(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?kv:_3(t.a,t.b,t.c,t.d,t.e,t.f)}function Tee(e){return e==null||(Sp||(Sp=document.createElementNS("http://www.w3.org/2000/svg","g")),Sp.setAttribute("transform",e),!(e=Sp.transform.baseVal.consolidate()))?kv:(e=e.matrix,_3(e.a,e.b,e.c,e.d,e.e,e.f))}function D3(e,t,n,r){function o(f){return f.length?f.pop()+" ":""}function i(f,p,h,g,y,k){if(f!==h||p!==g){var v=y.push("translate(",null,t,null,n);k.push({i:v-4,x:Ws(f,h)},{i:v-2,x:Ws(p,g)})}else(h||g)&&y.push("translate("+h+t+g+n)}function a(f,p,h,g){f!==p?(f-p>180?p+=360:p-f>180&&(f+=360),g.push({i:h.push(o(h)+"rotate(",null,r)-2,x:Ws(f,p)})):p&&h.push(o(h)+"rotate("+p+r)}function l(f,p,h,g){f!==p?g.push({i:h.push(o(h)+"skewX(",null,r)-2,x:Ws(f,p)}):p&&h.push(o(h)+"skewX("+p+r)}function u(f,p,h,g,y,k){if(f!==h||p!==g){var v=y.push(o(y)+"scale(",null,",",null,")");k.push({i:v-4,x:Ws(f,h)},{i:v-2,x:Ws(p,g)})}else(h!==1||g!==1)&&y.push(o(y)+"scale("+h+","+g+")")}return function(f,p){var h=[],g=[];return f=e(f),p=e(p),i(f.translateX,f.translateY,p.translateX,p.translateY,h,g),a(f.rotate,p.rotate,h,g),l(f.skewX,p.skewX,h,g),u(f.scaleX,f.scaleY,p.scaleX,p.scaleY,h,g),f=p=null,function(y){for(var k=-1,v=g.length,b;++k<v;)h[(b=g[k]).i]=b.x(y);return h.join("")}}}var Ree=D3(Eee,"px, ","px)","deg)"),Aee=D3(Tee,", ",")",")"),Pee=1e-12;function CC(e){return((e=Math.exp(e))+1/e)/2}function _ee(e){return((e=Math.exp(e))-1/e)/2}function Dee(e){return((e=Math.exp(2*e))-1)/(e+1)}const Jp=(function e(t,n,r){function o(i,a){var l=i[0],u=i[1],f=i[2],p=a[0],h=a[1],g=a[2],y=p-l,k=h-u,v=y*y+k*k,b,j;if(v<Pee)j=Math.log(g/f)/t,b=function(R){return[l+R*y,u+R*k,f*Math.exp(t*R*j)]};else{var N=Math.sqrt(v),S=(g*g-f*f+r*v)/(2*f*n*N),C=(g*g-f*f-r*v)/(2*g*n*N),D=Math.log(Math.sqrt(S*S+1)-S),T=Math.log(Math.sqrt(C*C+1)-C);j=(T-D)/t,b=function(R){var $=R*j,P=CC(D),F=f/(n*N)*(P*Dee(t*$+D)-_ee(D));return[l+F*y,u+F*k,f*P/CC(t*$+D)]}}return b.duration=j*1e3*t/Math.SQRT2,b}return o.rho=function(i){var a=Math.max(.001,+i),l=a*a,u=l*l;return e(a,l,u)},o})(Math.SQRT2,2,4);var oc=0,Au=0,Eu=0,$3=1e3,zh,Pu,Bh=0,ka=0,ng=0,yd=typeof performance=="object"&&performance.now?performance:Date,I3=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function P0(){return ka||(I3($ee),ka=yd.now()+ng)}function $ee(){ka=0}function Uh(){this._call=this._time=this._next=null}Uh.prototype=L3.prototype={constructor:Uh,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?P0():+n)+(t==null?0:+t),!this._next&&Pu!==this&&(Pu?Pu._next=this:zh=this,Pu=this),this._call=e,this._time=n,Sv()},stop:function(){this._call&&(this._call=null,this._time=1/0,Sv())}};function L3(e,t,n){var r=new Uh;return r.restart(e,t,n),r}function Iee(){P0(),++oc;for(var e=zh,t;e;)(t=ka-e._time)>=0&&e._call.call(void 0,t),e=e._next;--oc}function EC(){ka=(Bh=yd.now())+ng,oc=Au=0;try{Iee()}finally{oc=0,Mee(),ka=0}}function Lee(){var e=yd.now(),t=e-Bh;t>$3&&(ng-=t,Bh=e)}function Mee(){for(var e,t=zh,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:zh=n);Pu=e,Sv(r)}function Sv(e){if(!oc){Au&&(Au=clearTimeout(Au));var t=e-ka;t>24?(e<1/0&&(Au=setTimeout(EC,e-yd.now()-ng)),Eu&&(Eu=clearInterval(Eu))):(Eu||(Bh=yd.now(),Eu=setInterval(Lee,$3)),oc=1,I3(EC))}}function TC(e,t,n){var r=new Uh;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Oee=Zm("start","end","cancel","interrupt"),Fee=[],M3=0,RC=1,Nv=2,Zp=3,AC=4,Cv=5,eh=6;function rg(e,t,n,r,o,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;zee(e,n,{name:t,index:r,group:o,on:Oee,tween:Fee,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:M3})}function _0(e,t){var n=Ps(e,t);if(n.state>M3)throw new Error("too late; already scheduled");return n}function ro(e,t){var n=Ps(e,t);if(n.state>Zp)throw new Error("too late; already running");return n}function Ps(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function zee(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=L3(i,0,n.time);function i(f){n.state=RC,n.timer.restart(a,n.delay,n.time),n.delay<=f&&a(f-n.delay)}function a(f){var p,h,g,y;if(n.state!==RC)return u();for(p in r)if(y=r[p],y.name===n.name){if(y.state===Zp)return TC(a);y.state===AC?(y.state=eh,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete r[p]):+p<t&&(y.state=eh,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete r[p])}if(TC(function(){n.state===Zp&&(n.state=AC,n.timer.restart(l,n.delay,n.time),l(f))}),n.state=Nv,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Nv){for(n.state=Zp,o=new Array(g=n.tween.length),p=0,h=-1;p<g;++p)(y=n.tween[p].value.call(e,e.__data__,n.index,n.group))&&(o[++h]=y);o.length=h+1}}function l(f){for(var p=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(u),n.state=Cv,1),h=-1,g=o.length;++h<g;)o[h].call(e,p);n.state===Cv&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=eh,n.timer.stop(),delete r[t];for(var f in r)return;delete e.__transition}}function th(e,t){var n=e.__transition,r,o,i=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){i=!1;continue}o=r.state>Nv&&r.state<Cv,r.state=eh,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}i&&delete e.__transition}}function Bee(e){return this.each(function(){th(this,e)})}function Uee(e,t){var n,r;return function(){var o=ro(this,e),i=o.tween;if(i!==n){r=n=i;for(var a=0,l=r.length;a<l;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}o.tween=r}}function Hee(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=ro(this,e),a=i.tween;if(a!==r){o=(r=a).slice();for(var l={name:t,value:n},u=0,f=o.length;u<f;++u)if(o[u].name===t){o[u]=l;break}u===f&&o.push(l)}i.tween=o}}function Vee(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Ps(this.node(),n).tween,o=0,i=r.length,a;o<i;++o)if((a=r[o]).name===e)return a.value;return null}return this.each((t==null?Uee:Hee)(n,e,t))}function D0(e,t,n){var r=e._id;return e.each(function(){var o=ro(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Ps(o,r).value[t]}}function O3(e,t){var n;return(typeof t=="number"?Ws:t instanceof ja?Fh:(n=ja(t))?(t=n,Fh):P3)(e,t)}function Wee(e){return function(){this.removeAttribute(e)}}function qee(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Kee(e,t,n){var r,o=n+"",i;return function(){var a=this.getAttribute(e);return a===o?null:a===r?i:i=t(r=a,n)}}function Gee(e,t,n){var r,o=n+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===o?null:a===r?i:i=t(r=a,n)}}function Yee(e,t,n){var r,o,i;return function(){var a,l=n(this),u;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),u=l+"",a===u?null:a===r&&u===o?i:(o=u,i=t(r=a,l)))}}function Xee(e,t,n){var r,o,i;return function(){var a,l=n(this),u;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),u=l+"",a===u?null:a===r&&u===o?i:(o=u,i=t(r=a,l)))}}function Qee(e,t){var n=eg(e),r=n==="transform"?Aee:O3;return this.attrTween(e,typeof t=="function"?(n.local?Xee:Yee)(n,r,D0(this,"attr."+e,t)):t==null?(n.local?qee:Wee)(n):(n.local?Gee:Kee)(n,r,t))}function Jee(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Zee(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ete(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Zee(e,i)),n}return o._value=t,o}function tte(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Jee(e,i)),n}return o._value=t,o}function nte(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=eg(e);return this.tween(n,(r.local?ete:tte)(r,t))}function rte(e,t){return function(){_0(this,e).delay=+t.apply(this,arguments)}}function ste(e,t){return t=+t,function(){_0(this,e).delay=t}}function ote(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?rte:ste)(t,e)):Ps(this.node(),t).delay}function ite(e,t){return function(){ro(this,e).duration=+t.apply(this,arguments)}}function ate(e,t){return t=+t,function(){ro(this,e).duration=t}}function lte(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ite:ate)(t,e)):Ps(this.node(),t).duration}function cte(e,t){if(typeof t!="function")throw new Error;return function(){ro(this,e).ease=t}}function ute(e){var t=this._id;return arguments.length?this.each(cte(t,e)):Ps(this.node(),t).ease}function dte(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ro(this,e).ease=n}}function fte(e){if(typeof e!="function")throw new Error;return this.each(dte(this._id,e))}function pte(e){typeof e!="function"&&(e=h3(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],a=i.length,l=r[o]=[],u,f=0;f<a;++f)(u=i[f])&&e.call(u,u.__data__,f,i)&&l.push(u);return new Ao(r,this._parents,this._name,this._id)}function hte(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),a=new Array(r),l=0;l<i;++l)for(var u=t[l],f=n[l],p=u.length,h=a[l]=new Array(p),g,y=0;y<p;++y)(g=u[y]||f[y])&&(h[y]=g);for(;l<r;++l)a[l]=t[l];return new Ao(a,this._parents,this._name,this._id)}function mte(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function gte(e,t,n){var r,o,i=mte(t)?_0:ro;return function(){var a=i(this,e),l=a.on;l!==r&&(o=(r=l).copy()).on(t,n),a.on=o}}function xte(e,t){var n=this._id;return arguments.length<2?Ps(this.node(),n).on.on(e):this.each(gte(n,e,t))}function yte(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function bte(){return this.on("end.remove",yte(this._id))}function vte(e){var t=this._name,n=this._id;typeof e!="function"&&(e=T0(e));for(var r=this._groups,o=r.length,i=new Array(o),a=0;a<o;++a)for(var l=r[a],u=l.length,f=i[a]=new Array(u),p,h,g=0;g<u;++g)(p=l[g])&&(h=e.call(p,p.__data__,g,l))&&("__data__"in p&&(h.__data__=p.__data__),f[g]=h,rg(f[g],t,n,g,f,Ps(p,n)));return new Ao(i,this._parents,t,n)}function wte(e){var t=this._name,n=this._id;typeof e!="function"&&(e=p3(e));for(var r=this._groups,o=r.length,i=[],a=[],l=0;l<o;++l)for(var u=r[l],f=u.length,p,h=0;h<f;++h)if(p=u[h]){for(var g=e.call(p,p.__data__,h,u),y,k=Ps(p,n),v=0,b=g.length;v<b;++v)(y=g[v])&&rg(y,t,n,v,g,k);i.push(g),a.push(p)}return new Ao(i,a,t,n)}var jte=Yd.prototype.constructor;function kte(){return new jte(this._groups,this._parents)}function Ste(e,t){var n,r,o;return function(){var i=sc(this,e),a=(this.style.removeProperty(e),sc(this,e));return i===a?null:i===n&&a===r?o:o=t(n=i,r=a)}}function F3(e){return function(){this.style.removeProperty(e)}}function Nte(e,t,n){var r,o=n+"",i;return function(){var a=sc(this,e);return a===o?null:a===r?i:i=t(r=a,n)}}function Cte(e,t,n){var r,o,i;return function(){var a=sc(this,e),l=n(this),u=l+"";return l==null&&(u=l=(this.style.removeProperty(e),sc(this,e))),a===u?null:a===r&&u===o?i:(o=u,i=t(r=a,l))}}function Ete(e,t){var n,r,o,i="style."+t,a="end."+i,l;return function(){var u=ro(this,e),f=u.on,p=u.value[i]==null?l||(l=F3(t)):void 0;(f!==n||o!==p)&&(r=(n=f).copy()).on(a,o=p),u.on=r}}function Tte(e,t,n){var r=(e+="")=="transform"?Ree:O3;return t==null?this.styleTween(e,Ste(e,r)).on("end.style."+e,F3(e)):typeof t=="function"?this.styleTween(e,Cte(e,r,D0(this,"style."+e,t))).each(Ete(this._id,e)):this.styleTween(e,Nte(e,r,t),n).on("end.style."+e,null)}function Rte(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Ate(e,t,n){var r,o;function i(){var a=t.apply(this,arguments);return a!==o&&(r=(o=a)&&Rte(e,a,n)),r}return i._value=t,i}function Pte(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,Ate(e,t,n??""))}function _te(e){return function(){this.textContent=e}}function Dte(e){return function(){var t=e(this);this.textContent=t??""}}function $te(e){return this.tween("text",typeof e=="function"?Dte(D0(this,"text",e)):_te(e==null?"":e+""))}function Ite(e){return function(t){this.textContent=e.call(this,t)}}function Lte(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Ite(o)),t}return r._value=e,r}function Mte(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Lte(e))}function Ote(){for(var e=this._name,t=this._id,n=z3(),r=this._groups,o=r.length,i=0;i<o;++i)for(var a=r[i],l=a.length,u,f=0;f<l;++f)if(u=a[f]){var p=Ps(u,t);rg(u,e,n,f,a,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new Ao(r,this._parents,e,n)}function Fte(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(i,a){var l={value:a},u={value:function(){--o===0&&i()}};n.each(function(){var f=ro(this,r),p=f.on;p!==e&&(t=(e=p).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(u)),f.on=t}),o===0&&i()})}var zte=0;function Ao(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function z3(){return++zte}var bo=Yd.prototype;Ao.prototype={constructor:Ao,select:vte,selectAll:wte,selectChild:bo.selectChild,selectChildren:bo.selectChildren,filter:pte,merge:hte,selection:kte,transition:Ote,call:bo.call,nodes:bo.nodes,node:bo.node,size:bo.size,empty:bo.empty,each:bo.each,on:xte,attr:Qee,attrTween:nte,style:Tte,styleTween:Pte,text:$te,textTween:Mte,remove:bte,tween:Vee,delay:ote,duration:lte,ease:ute,easeVarying:fte,end:Fte,[Symbol.iterator]:bo[Symbol.iterator]};function Bte(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ute={time:null,delay:0,duration:250,ease:Bte};function Hte(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Vte(e){var t,n;e instanceof Ao?(t=e._id,e=e._name):(t=z3(),(n=Ute).time=P0(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var a=r[i],l=a.length,u,f=0;f<l;++f)(u=a[f])&&rg(u,e,t,f,a,n||Hte(u,t));return new Ao(r,this._parents,e,t)}Yd.prototype.interrupt=Bee;Yd.prototype.transition=Vte;const Np=e=>()=>e;function Wte(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function No(e,t,n){this.k=e,this.x=t,this.y=n}No.prototype={constructor:No,scale:function(e){return e===1?this:new No(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new No(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var sg=new No(1,0,0);B3.prototype=No.prototype;function B3(e){for(;!e.__zoom;)if(!(e=e.parentNode))return sg;return e.__zoom}function eb(e){e.stopImmediatePropagation()}function Tu(e){e.preventDefault(),e.stopImmediatePropagation()}function qte(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Kte(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function PC(){return this.__zoom||sg}function Gte(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Yte(){return navigator.maxTouchPoints||"ontouchstart"in this}function Xte(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function U3(){var e=qte,t=Kte,n=Xte,r=Gte,o=Yte,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,u=Jp,f=Zm("start","zoom","end"),p,h,g,y=500,k=150,v=0,b=10;function j(I){I.property("__zoom",PC).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",F).filter(o).on("touchstart.zoom",_).on("touchmove.zoom",V).on("touchend.zoom touchcancel.zoom",U).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}j.transform=function(I,M,B,W){var O=I.selection?I.selection():I;O.property("__zoom",PC),I!==O?D(I,M,B,W):O.interrupt().each(function(){T(this,arguments).event(W).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},j.scaleBy=function(I,M,B,W){j.scaleTo(I,function(){var O=this.__zoom.k,H=typeof M=="function"?M.apply(this,arguments):M;return O*H},B,W)},j.scaleTo=function(I,M,B,W){j.transform(I,function(){var O=t.apply(this,arguments),H=this.__zoom,L=B==null?C(O):typeof B=="function"?B.apply(this,arguments):B,z=H.invert(L),Y=typeof M=="function"?M.apply(this,arguments):M;return n(S(N(H,Y),L,z),O,a)},B,W)},j.translateBy=function(I,M,B,W){j.transform(I,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof B=="function"?B.apply(this,arguments):B),t.apply(this,arguments),a)},null,W)},j.translateTo=function(I,M,B,W,O){j.transform(I,function(){var H=t.apply(this,arguments),L=this.__zoom,z=W==null?C(H):typeof W=="function"?W.apply(this,arguments):W;return n(sg.translate(z[0],z[1]).scale(L.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof B=="function"?-B.apply(this,arguments):-B),H,a)},W,O)};function N(I,M){return M=Math.max(i[0],Math.min(i[1],M)),M===I.k?I:new No(M,I.x,I.y)}function S(I,M,B){var W=M[0]-B[0]*I.k,O=M[1]-B[1]*I.k;return W===I.x&&O===I.y?I:new No(I.k,W,O)}function C(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function D(I,M,B,W){I.on("start.zoom",function(){T(this,arguments).event(W).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(W).end()}).tween("zoom",function(){var O=this,H=arguments,L=T(O,H).event(W),z=t.apply(O,H),Y=B==null?C(z):typeof B=="function"?B.apply(O,H):B,q=Math.max(z[1][0]-z[0][0],z[1][1]-z[0][1]),Q=O.__zoom,ee=typeof M=="function"?M.apply(O,H):M,Z=u(Q.invert(Y).concat(q/Q.k),ee.invert(Y).concat(q/ee.k));return function(ie){if(ie===1)ie=ee;else{var ne=Z(ie),ue=q/ne[2];ie=new No(ue,Y[0]-ne[0]*ue,Y[1]-ne[1]*ue)}L.zoom(null,ie)}})}function T(I,M,B){return!B&&I.__zooming||new R(I,M)}function R(I,M){this.that=I,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,M),this.taps=0}R.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,M){return this.mouse&&I!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var M=zr(this.that).datum();f.call(I,this.that,new Wte(I,{sourceEvent:this.sourceEvent,target:j,transform:this.that.__zoom,dispatch:f}),M)}};function $(I,...M){if(!e.apply(this,arguments))return;var B=T(this,M).event(I),W=this.__zoom,O=Math.max(i[0],Math.min(i[1],W.k*Math.pow(2,r.apply(this,arguments)))),H=hs(I);if(B.wheel)(B.mouse[0][0]!==H[0]||B.mouse[0][1]!==H[1])&&(B.mouse[1]=W.invert(B.mouse[0]=H)),clearTimeout(B.wheel);else{if(W.k===O)return;B.mouse=[H,W.invert(H)],th(this),B.start()}Tu(I),B.wheel=setTimeout(L,k),B.zoom("mouse",n(S(N(W,O),B.mouse[0],B.mouse[1]),B.extent,a));function L(){B.wheel=null,B.end()}}function P(I,...M){if(g||!e.apply(this,arguments))return;var B=I.currentTarget,W=T(this,M,!0).event(I),O=zr(I.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",q,!0),H=hs(I,B),L=I.clientX,z=I.clientY;S3(I.view),eb(I),W.mouse=[H,this.__zoom.invert(H)],th(this),W.start();function Y(Q){if(Tu(Q),!W.moved){var ee=Q.clientX-L,Z=Q.clientY-z;W.moved=ee*ee+Z*Z>v}W.event(Q).zoom("mouse",n(S(W.that.__zoom,W.mouse[0]=hs(Q,B),W.mouse[1]),W.extent,a))}function q(Q){O.on("mousemove.zoom mouseup.zoom",null),N3(Q.view,W.moved),Tu(Q),W.event(Q).end()}}function F(I,...M){if(e.apply(this,arguments)){var B=this.__zoom,W=hs(I.changedTouches?I.changedTouches[0]:I,this),O=B.invert(W),H=B.k*(I.shiftKey?.5:2),L=n(S(N(B,H),W,O),t.apply(this,M),a);Tu(I),l>0?zr(this).transition().duration(l).call(D,L,W,I):zr(this).call(j.transform,L,W,I)}}function _(I,...M){if(e.apply(this,arguments)){var B=I.touches,W=B.length,O=T(this,M,I.changedTouches.length===W).event(I),H,L,z,Y;for(eb(I),L=0;L<W;++L)z=B[L],Y=hs(z,this),Y=[Y,this.__zoom.invert(Y),z.identifier],O.touch0?!O.touch1&&O.touch0[2]!==Y[2]&&(O.touch1=Y,O.taps=0):(O.touch0=Y,H=!0,O.taps=1+!!p);p&&(p=clearTimeout(p)),H&&(O.taps<2&&(h=Y[0],p=setTimeout(function(){p=null},y)),th(this),O.start())}}function V(I,...M){if(this.__zooming){var B=T(this,M).event(I),W=I.changedTouches,O=W.length,H,L,z,Y;for(Tu(I),H=0;H<O;++H)L=W[H],z=hs(L,this),B.touch0&&B.touch0[2]===L.identifier?B.touch0[0]=z:B.touch1&&B.touch1[2]===L.identifier&&(B.touch1[0]=z);if(L=B.that.__zoom,B.touch1){var q=B.touch0[0],Q=B.touch0[1],ee=B.touch1[0],Z=B.touch1[1],ie=(ie=ee[0]-q[0])*ie+(ie=ee[1]-q[1])*ie,ne=(ne=Z[0]-Q[0])*ne+(ne=Z[1]-Q[1])*ne;L=N(L,Math.sqrt(ie/ne)),z=[(q[0]+ee[0])/2,(q[1]+ee[1])/2],Y=[(Q[0]+Z[0])/2,(Q[1]+Z[1])/2]}else if(B.touch0)z=B.touch0[0],Y=B.touch0[1];else return;B.zoom("touch",n(S(L,z,Y),B.extent,a))}}function U(I,...M){if(this.__zooming){var B=T(this,M).event(I),W=I.changedTouches,O=W.length,H,L;for(eb(I),g&&clearTimeout(g),g=setTimeout(function(){g=null},y),H=0;H<O;++H)L=W[H],B.touch0&&B.touch0[2]===L.identifier?delete B.touch0:B.touch1&&B.touch1[2]===L.identifier&&delete B.touch1;if(B.touch1&&!B.touch0&&(B.touch0=B.touch1,delete B.touch1),B.touch0)B.touch0[1]=this.__zoom.invert(B.touch0[0]);else if(B.end(),B.taps===2&&(L=hs(L,this),Math.hypot(h[0]-L[0],h[1]-L[1])<b)){var z=zr(this).on("dblclick.zoom");z&&z.apply(this,arguments)}}}return j.wheelDelta=function(I){return arguments.length?(r=typeof I=="function"?I:Np(+I),j):r},j.filter=function(I){return arguments.length?(e=typeof I=="function"?I:Np(!!I),j):e},j.touchable=function(I){return arguments.length?(o=typeof I=="function"?I:Np(!!I),j):o},j.extent=function(I){return arguments.length?(t=typeof I=="function"?I:Np([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),j):t},j.scaleExtent=function(I){return arguments.length?(i[0]=+I[0],i[1]=+I[1],j):[i[0],i[1]]},j.translateExtent=function(I){return arguments.length?(a[0][0]=+I[0][0],a[1][0]=+I[1][0],a[0][1]=+I[0][1],a[1][1]=+I[1][1],j):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},j.constrain=function(I){return arguments.length?(n=I,j):n},j.duration=function(I){return arguments.length?(l=+I,j):l},j.interpolate=function(I){return arguments.length?(u=I,j):u},j.on=function(){var I=f.on.apply(f,arguments);return I===f?j:I},j.clickDistance=function(I){return arguments.length?(v=(I=+I)*I,j):Math.sqrt(v)},j.tapDistance=function(I){return arguments.length?(b=+I,j):b},j}const Cs={error001:(e="react")=>`Seems like you have not used zustand provider as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},bd=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],H3=["Enter"," ","Escape"],V3={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var ic;(function(e){e.Strict="strict",e.Loose="loose"})(ic||(ic={}));var ya;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ya||(ya={}));var vd;(function(e){e.Partial="partial",e.Full="full"})(vd||(vd={}));const W3={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var xi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(xi||(xi={}));var wd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(wd||(wd={}));var ct;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ct||(ct={}));const _C={[ct.Left]:ct.Right,[ct.Right]:ct.Left,[ct.Top]:ct.Bottom,[ct.Bottom]:ct.Top};function q3(e){return e===null?null:e?"valid":"invalid"}const K3=e=>"id"in e&&"source"in e&&"target"in e,Qte=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),$0=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Qd=(e,t=[0,0])=>{const{width:n,height:r}=Do(e),o=e.origin??t,i=n*o[0],a=r*o[1];return{x:e.position.x-i,y:e.position.y-a}},Jte=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const i=typeof o=="string";let a=!t.nodeLookup&&!i?o:void 0;t.nodeLookup&&(a=i?t.nodeLookup.get(o):$0(o)?o:t.nodeLookup.get(o.id));const l=a?Hh(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return og(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ig(n)},Jd=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=og(n,Hh(o)),r=!0)}),r?ig(n):{x:0,y:0,width:0,height:0}},I0=(e,t,[n,r,o]=[0,0,1],i=!1,a=!1)=>{const l={..._c(t,[n,r,o]),width:t.width/o,height:t.height/o},u=[];for(const f of e.values()){const{measured:p,selectable:h=!0,hidden:g=!1}=f;if(a&&!h||g)continue;const y=p.width??f.width??f.initialWidth??null,k=p.height??f.height??f.initialHeight??null,v=jd(l,lc(f)),b=(y??0)*(k??0),j=i&&v>0;(!f.internals.handleBounds||j||v>=b||f.dragging)&&u.push(f)}return u},Zte=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function ene(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function tne({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},a){if(e.size===0)return!0;const l=ene(e,a),u=Jd(l),f=M0(u,t,n,(a==null?void 0:a.minZoom)??o,(a==null?void 0:a.maxZoom)??i,(a==null?void 0:a.padding)??.1);return await r.setViewport(f,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),!0}function G3({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:u,y:f}=l?l.internals.positionAbsolute:{x:0,y:0},p=a.origin??r;let h=a.extent||o;if(a.extent==="parent"&&!a.expandParent)if(!l)i==null||i("005",Cs.error005());else{const y=l.measured.width,k=l.measured.height;y&&k&&(h=[[u,f],[u+y,f+k]])}else l&&Na(a.extent)&&(h=[[a.extent[0][0]+u,a.extent[0][1]+f],[a.extent[1][0]+u,a.extent[1][1]+f]]);const g=Na(h)?Sa(t,h,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",Cs.error015())),{position:{x:g.x-u+(a.measured.width??0)*p[0],y:g.y-f+(a.measured.height??0)*p[1]},positionAbsolute:g}}async function nne({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(g=>g.id)),a=[];for(const g of n){if(g.deletable===!1)continue;const y=i.has(g.id),k=!y&&g.parentId&&a.find(v=>v.id===g.parentId);(y||k)&&a.push(g)}const l=new Set(t.map(g=>g.id)),u=r.filter(g=>g.deletable!==!1),p=Zte(a,u);for(const g of u)l.has(g.id)&&!p.find(k=>k.id===g.id)&&p.push(g);if(!o)return{edges:p,nodes:a};const h=await o({nodes:a,edges:p});return typeof h=="boolean"?h?{edges:p,nodes:a}:{edges:[],nodes:[]}:h}const ac=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Sa=(e={x:0,y:0},t,n)=>({x:ac(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:ac(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Y3(e,t,n){const{width:r,height:o}=Do(n),{x:i,y:a}=n.internals.positionAbsolute;return Sa(e,[[i,a],[i+r,a+o]],t)}const DC=(e,t,n)=>e<t?ac(Math.abs(e-t),1,t)/t:e>n?-ac(Math.abs(e-n),1,t)/t:0,L0=(e,t,n=15,r=40)=>{const o=DC(e.x,r,t.width-r)*n,i=DC(e.y,r,t.height-r)*n;return[o,i]},og=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Ev=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),ig=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),lc=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=$0(e)?e.internals.positionAbsolute:Qd(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Hh=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=$0(e)?e.internals.positionAbsolute:Qd(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},X3=(e,t)=>ig(og(Ev(e),Ev(t))),jd=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},$C=e=>gs(e.width)&&gs(e.height)&&gs(e.x)&&gs(e.y),gs=e=>!isNaN(e)&&isFinite(e),Q3=(e,t)=>(n,r)=>{},Zd=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),_c=({x:e,y:t},[n,r,o],i=!1,a=[1,1])=>{const l={x:(e-n)/o,y:(t-r)/o};return i?Zd(l,a):l},cc=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Cl(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function rne(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Cl(e,n),o=Cl(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Cl(e.top??e.y??0,n),o=Cl(e.bottom??e.y??0,n),i=Cl(e.left??e.x??0,t),a=Cl(e.right??e.x??0,t);return{top:r,right:a,bottom:o,left:i,x:i+a,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function sne(e,t,n,r,o,i){const{x:a,y:l}=cc(e,[t,n,r]),{x:u,y:f}=cc({x:e.x+e.width,y:e.y+e.height},[t,n,r]),p=o-u,h=i-f;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(p),bottom:Math.floor(h)}}const M0=(e,t,n,r,o,i)=>{const a=rne(i,t,n),l=(t-a.x)/e.width,u=(n-a.y)/e.height,f=Math.min(l,u),p=ac(f,r,o),h=e.x+e.width/2,g=e.y+e.height/2,y=t/2-h*p,k=n/2-g*p,v=sne(e,y,k,p,t,n),b={left:Math.min(v.left-a.left,0),top:Math.min(v.top-a.top,0),right:Math.min(v.right-a.right,0),bottom:Math.min(v.bottom-a.bottom,0)};return{x:y-b.left+b.right,y:k-b.top+b.bottom,zoom:p}},kd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Na(e){return e!=null&&e!=="parent"}function Do(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function J3(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Z3(e,t={width:0,height:0},n,r,o){const i={...e},a=r.get(n);if(a){const l=a.origin||o;i.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function IC(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function one(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function ine(e){return{...V3,...e||{}}}function Ju(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:a}=xs(e),l=_c({x:i-((o==null?void 0:o.left)??0),y:a-((o==null?void 0:o.top)??0)},r),{x:u,y:f}=n?Zd(l,t):l;return{xSnapped:u,ySnapped:f,...l}}const O0=e=>({width:e.offsetWidth,height:e.offsetHeight}),eD=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},ane=["INPUT","SELECT","TEXTAREA"];function tD(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:ane.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const nD=e=>"clientX"in e,xs=(e,t)=>{var i,a;const n=nD(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},LC=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:o,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...O0(a)}})};function rD({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:a,targetControlY:l}){const u=e*.125+o*.375+a*.375+n*.125,f=t*.125+i*.375+l*.375+r*.125,p=Math.abs(u-e),h=Math.abs(f-t);return[u,f,p,h]}function Cp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function MC({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case ct.Left:return[t-Cp(t-r,i),n];case ct.Right:return[t+Cp(r-t,i),n];case ct.Top:return[t,n-Cp(n-o,i)];case ct.Bottom:return[t,n+Cp(o-n,i)]}}function sD({sourceX:e,sourceY:t,sourcePosition:n=ct.Bottom,targetX:r,targetY:o,targetPosition:i=ct.Top,curvature:a=.25}){const[l,u]=MC({pos:n,x1:e,y1:t,x2:r,y2:o,c:a}),[f,p]=MC({pos:i,x1:r,y1:o,x2:e,y2:t,c:a}),[h,g,y,k]=rD({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:l,sourceControlY:u,targetControlX:f,targetControlY:p});return[`M${e},${t} C${l},${u} ${f},${p} ${r},${o}`,h,g,y,k]}function oD({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,a=Math.abs(r-t)/2,l=r<t?r+a:r-a;return[i,l,o,a]}function lne({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const a=o&&n?r+1e3:r,l=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return a+l}function cne({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=og(Hh(e),Hh(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return jd(a,ig(i))>0}const une=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,dne=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),fne=(e,t,n={})=>{var i;if(!e.source||!e.target)return(i=n.onError)==null||i.call(n,"006",Cs.error006()),t;const r=n.getEdgeId||une;let o;return K3(e)?o={...e}:o={...e,id:r(e)},dne(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function iD({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,a,l]=oD({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,a,l]}const OC={[ct.Left]:{x:-1,y:0},[ct.Right]:{x:1,y:0},[ct.Top]:{x:0,y:-1},[ct.Bottom]:{x:0,y:1}},pne=({source:e,sourcePosition:t=ct.Bottom,target:n})=>t===ct.Left||t===ct.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},FC=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function hne({source:e,sourcePosition:t=ct.Bottom,target:n,targetPosition:r=ct.Top,center:o,offset:i,stepPosition:a}){const l=OC[t],u=OC[r],f={x:e.x+l.x*i,y:e.y+l.y*i},p={x:n.x+u.x*i,y:n.y+u.y*i},h=pne({source:f,sourcePosition:t,target:p}),g=h.x!==0?"x":"y",y=h[g];let k=[],v,b;const j={x:0,y:0},N={x:0,y:0},[,,S,C]=oD({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[g]*u[g]===-1){g==="x"?(v=o.x??f.x+(p.x-f.x)*a,b=o.y??(f.y+p.y)/2):(v=o.x??(f.x+p.x)/2,b=o.y??f.y+(p.y-f.y)*a);const $=[{x:v,y:f.y},{x:v,y:p.y}],P=[{x:f.x,y:b},{x:p.x,y:b}];l[g]===y?k=g==="x"?$:P:k=g==="x"?P:$}else{const $=[{x:f.x,y:p.y}],P=[{x:p.x,y:f.y}];if(g==="x"?k=l.x===y?P:$:k=l.y===y?$:P,t===r){const I=Math.abs(e[g]-n[g]);if(I<=i){const M=Math.min(i-1,i-I);l[g]===y?j[g]=(f[g]>e[g]?-1:1)*M:N[g]=(p[g]>n[g]?-1:1)*M}}if(t!==r){const I=g==="x"?"y":"x",M=l[g]===u[I],B=f[I]>p[I],W=f[I]<p[I];(l[g]===1&&(!M&&B||M&&W)||l[g]!==1&&(!M&&W||M&&B))&&(k=g==="x"?$:P)}const F={x:f.x+j.x,y:f.y+j.y},_={x:p.x+N.x,y:p.y+N.y},V=Math.max(Math.abs(F.x-k[0].x),Math.abs(_.x-k[0].x)),U=Math.max(Math.abs(F.y-k[0].y),Math.abs(_.y-k[0].y));V>=U?(v=(F.x+_.x)/2,b=k[0].y):(v=k[0].x,b=(F.y+_.y)/2)}const D={x:f.x+j.x,y:f.y+j.y},T={x:p.x+N.x,y:p.y+N.y};return[[e,...D.x!==k[0].x||D.y!==k[0].y?[D]:[],...k,...T.x!==k[k.length-1].x||T.y!==k[k.length-1].y?[T]:[],n],v,b,S,C]}function mne(e,t,n,r){const o=Math.min(FC(e,t)/2,FC(t,n)/2,r),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){const f=e.x<n.x?-1:1,p=e.y<n.y?1:-1;return`L ${i+o*f},${a}Q ${i},${a} ${i},${a+o*p}`}const l=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${i},${a+o*u}Q ${i},${a} ${i+o*l},${a}`}function Tv({sourceX:e,sourceY:t,sourcePosition:n=ct.Bottom,targetX:r,targetY:o,targetPosition:i=ct.Top,borderRadius:a=5,centerX:l,centerY:u,offset:f=20,stepPosition:p=.5}){const[h,g,y,k,v]=hne({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:l,y:u},offset:f,stepPosition:p});let b=`M${h[0].x} ${h[0].y}`;for(let j=1;j<h.length-1;j++)b+=mne(h[j-1],h[j],h[j+1],a);return b+=`L${h[h.length-1].x} ${h[h.length-1].y}`,[b,g,y,k,v]}function zC(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function gne(e){var h;const{sourceNode:t,targetNode:n}=e;if(!zC(t)||!zC(n))return null;const r=t.internals.handleBounds||BC(t.handles),o=n.internals.handleBounds||BC(n.handles),i=UC((r==null?void 0:r.source)??[],e.sourceHandle),a=UC(e.connectionMode===ic.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!a)return(h=e.onError)==null||h.call(e,"008",Cs.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||ct.Bottom,u=(a==null?void 0:a.position)||ct.Top,f=Ca(t,i,l),p=Ca(n,a,u);return{sourceX:f.x,sourceY:f.y,targetX:p.x,targetY:p.y,sourcePosition:l,targetPosition:u}}function BC(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function Ca(e,t,n=ct.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??Do(e);if(r)return{x:o+a/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case ct.Top:return{x:o+a/2,y:i};case ct.Right:return{x:o+a,y:i+l/2};case ct.Bottom:return{x:o+a/2,y:i+l};case ct.Left:return{x:o,y:i+l/2}}}function UC(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Rv(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function xne(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||o].forEach(u=>{if(u&&typeof u=="object"){const f=Rv(u,t);i.has(f)||(a.push({id:f,color:u.color||n,...u}),i.add(f))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const aD=1e3,yne=10,F0={nodeOrigin:[0,0],nodeExtent:bd,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},bne={...F0,checkEquality:!0};function z0(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function vne(e,t,n){const r=z0(F0,n);for(const o of e.values())if(o.parentId)U0(o,e,t,r);else{const i=Qd(o,r.nodeOrigin),a=Na(o.extent)?o.extent:r.nodeExtent,l=Sa(i,a,Do(o));o.internals.positionAbsolute=l}}function wne(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function B0(e){return e==="manual"}function Av(e,t,n,r={}){var p,h;const o=z0(bne,r),i={i:0},a=new Map(t),l=o!=null&&o.elevateNodesOnSelect&&!B0(o.zIndexMode)?aD:0;let u=e.length>0,f=!1;t.clear(),n.clear();for(const g of e){let y=a.get(g.id);if(o.checkEquality&&g===(y==null?void 0:y.internals.userNode))t.set(g.id,y);else{const k=Qd(g,o.nodeOrigin),v=Na(g.extent)?g.extent:o.nodeExtent,b=Sa(k,v,Do(g));y={...o.defaults,...g,measured:{width:(p=g.measured)==null?void 0:p.width,height:(h=g.measured)==null?void 0:h.height},internals:{positionAbsolute:b,handleBounds:wne(g,y),z:lD(g,l,o.zIndexMode),userNode:g}},t.set(g.id,y)}(y.measured===void 0||y.measured.width===void 0||y.measured.height===void 0)&&!y.hidden&&(u=!1),g.parentId&&U0(y,t,n,r,i),f||(f=g.selected??!1)}return{nodesInitialized:u,hasSelectedNodes:f}}function jne(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function U0(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:l,zIndexMode:u}=z0(F0,r),f=e.parentId,p=t.get(f);if(!p){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}jne(e,n),o&&!p.parentId&&p.internals.rootParentIndex===void 0&&u==="auto"&&(p.internals.rootParentIndex=++o.i,p.internals.z=p.internals.z+o.i*yne),o&&p.internals.rootParentIndex!==void 0&&(o.i=p.internals.rootParentIndex);const h=i&&!B0(u)?aD:0,{x:g,y,z:k}=kne(e,p,a,l,h,u),{positionAbsolute:v}=e.internals,b=g!==v.x||y!==v.y;(b||k!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:g,y}:v,z:k}})}function lD(e,t,n){const r=gs(e.zIndex)?e.zIndex:0;return B0(n)?r:r+(e.selected?t:0)}function kne(e,t,n,r,o,i){const{x:a,y:l}=t.internals.positionAbsolute,u=Do(e),f=Qd(e,n),p=Na(e.extent)?Sa(f,e.extent,u):f;let h=Sa({x:a+p.x,y:l+p.y},r,u);e.extent==="parent"&&(h=Y3(h,u,t));const g=lD(e,o,i),y=t.internals.z??0;return{x:h.x,y:h.y,z:y>=g?y+1:g}}function H0(e,t,n,r=[0,0]){var a;const o=[],i=new Map;for(const l of e){const u=t.get(l.parentId);if(!u)continue;const f=((a=i.get(l.parentId))==null?void 0:a.expandedRect)??lc(u),p=X3(f,l.rect);i.set(l.parentId,{expandedRect:p,parent:u})}return i.size>0&&i.forEach(({expandedRect:l,parent:u},f)=>{var S;const p=u.internals.positionAbsolute,h=Do(u),g=u.origin??r,y=l.x<p.x?Math.round(Math.abs(p.x-l.x)):0,k=l.y<p.y?Math.round(Math.abs(p.y-l.y)):0,v=Math.max(h.width,Math.round(l.width)),b=Math.max(h.height,Math.round(l.height)),j=(v-h.width)*g[0],N=(b-h.height)*g[1];(y>0||k>0||j||N)&&(o.push({id:f,type:"position",position:{x:u.position.x-y+j,y:u.position.y-k+N}}),(S=n.get(f))==null||S.forEach(C=>{e.some(D=>D.id===C.id)||o.push({id:C.id,type:"position",position:{x:C.position.x+y,y:C.position.y+k}})})),(h.width<l.width||h.height<l.height||y||k)&&o.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:v+(y?g[0]*y-j:0),height:b+(k?g[1]*k-N:0)}})}),o}function Sne(e,t,n,r,o,i,a){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let u=!1;if(!l)return{changes:[],updatedInternals:u};const f=[],p=window.getComputedStyle(l),{m22:h}=new window.DOMMatrixReadOnly(p.transform),g=[];for(const y of e.values()){const k=t.get(y.id);if(!k)continue;if(k.hidden){t.set(k.id,{...k,internals:{...k.internals,handleBounds:void 0}}),u=!0;continue}const v=O0(y.nodeElement),b=k.measured.width!==v.width||k.measured.height!==v.height;if(!!(v.width&&v.height&&(b||!k.internals.handleBounds||y.force))){const N=y.nodeElement.getBoundingClientRect(),S=Na(k.extent)?k.extent:i;let{positionAbsolute:C}=k.internals;k.parentId&&k.extent==="parent"?C=Y3(C,v,t.get(k.parentId)):S&&(C=Sa(C,S,v));const D={...k,measured:v,internals:{...k.internals,positionAbsolute:C,handleBounds:{source:LC("source",y.nodeElement,N,h,k.id),target:LC("target",y.nodeElement,N,h,k.id)}}};t.set(k.id,D),k.parentId&&U0(D,t,n,{nodeOrigin:o,zIndexMode:a}),u=!0,b&&(f.push({id:k.id,type:"dimensions",dimensions:v}),k.expandParent&&k.parentId&&g.push({id:k.id,parentId:k.parentId,rect:lc(D,o)}))}}if(g.length>0){const y=H0(g,t,n,o);f.push(...y)}return{changes:f,updatedInternals:u}}async function Nne({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return!1;const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}function HC(e,t,n,r,o,i){let a=o;const l=r.get(a)||new Map;r.set(a,l.set(n,t)),a=`${o}-${e}`;const u=r.get(a)||new Map;if(r.set(a,u.set(n,t)),i){a=`${o}-${e}-${i}`;const f=r.get(a)||new Map;r.set(a,f.set(n,t))}}function cD(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:a=null,targetHandle:l=null}=r,u={edgeId:r.id,source:o,target:i,sourceHandle:a,targetHandle:l},f=`${o}-${a}--${i}-${l}`,p=`${i}-${l}--${o}-${a}`;HC("source",u,p,e,o,a),HC("target",u,f,e,i,l),t.set(r.id,r)}}function uD(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:uD(n,t):!1}function VC(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function Cne(e,t,n,r){const o=new Map;for(const[i,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!uD(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(i);l&&o.set(i,{id:i,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return o}function tb({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,u;const o=[];for(const[f,p]of t){const h=(a=n.get(f))==null?void 0:a.internals.userNode;h&&o.push({...h,position:p.position,dragging:r})}if(!e)return[o[0],o];const i=(l=n.get(e))==null?void 0:l.internals.userNode;return[i?{...i,position:((u=t.get(e))==null?void 0:u.position)||i.position,dragging:r}:o[0],o]}function Ene({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},a=Zd(i,t);return{x:a.x-i.x,y:a.y-i.y}}function Tne({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},a=0,l=new Map,u=!1,f={x:0,y:0},p=null,h=!1,g=null,y=!1,k=!1,v=null;function b({noDragClassName:N,handleSelector:S,domNode:C,isSelectable:D,nodeId:T,nodeClickDistance:R=0}){g=zr(C);function $({x:V,y:U}){const{nodeLookup:I,nodeExtent:M,snapGrid:B,snapToGrid:W,nodeOrigin:O,onNodeDrag:H,onSelectionDrag:L,onError:z,updateNodePositions:Y}=t();i={x:V,y:U};let q=!1;const Q=l.size>1,ee=Q&&M?Ev(Jd(l)):null,Z=Q&&W?Ene({dragItems:l,snapGrid:B,x:V,y:U}):null;for(const[ie,ne]of l){if(!I.has(ie))continue;let ue={x:V-ne.distance.x,y:U-ne.distance.y};W&&(ue=Z?{x:Math.round(ue.x+Z.x),y:Math.round(ue.y+Z.y)}:Zd(ue,B));let ge=null;if(Q&&M&&!ne.extent&&ee){const{positionAbsolute:ke}=ne.internals,Ue=ke.x-ee.x+M[0][0],oe=ke.x+ne.measured.width-ee.x2+M[1][0],ve=ke.y-ee.y+M[0][1],be=ke.y+ne.measured.height-ee.y2+M[1][1];ge=[[Ue,ve],[oe,be]]}const{position:Ne,positionAbsolute:Ce}=G3({nodeId:ie,nextPosition:ue,nodeLookup:I,nodeExtent:ge||M,nodeOrigin:O,onError:z});q=q||ne.position.x!==Ne.x||ne.position.y!==Ne.y,ne.position=Ne,ne.internals.positionAbsolute=Ce}if(k=k||q,!!q&&(Y(l,!0),v&&(r||H||!T&&L))){const[ie,ne]=tb({nodeId:T,dragItems:l,nodeLookup:I});r==null||r(v,l,ie,ne),H==null||H(v,ie,ne),T||L==null||L(v,ne)}}async function P(){if(!p)return;const{transform:V,panBy:U,autoPanSpeed:I,autoPanOnNodeDrag:M}=t();if(!M){u=!1,cancelAnimationFrame(a);return}const[B,W]=L0(f,p,I);(B!==0||W!==0)&&(i.x=(i.x??0)-B/V[2],i.y=(i.y??0)-W/V[2],await U({x:B,y:W})&&$(i)),a=requestAnimationFrame(P)}function F(V){var Q;const{nodeLookup:U,multiSelectionActive:I,nodesDraggable:M,transform:B,snapGrid:W,snapToGrid:O,selectNodesOnDrag:H,onNodeDragStart:L,onSelectionDragStart:z,unselectNodesAndEdges:Y}=t();h=!0,(!H||!D)&&!I&&T&&((Q=U.get(T))!=null&&Q.selected||Y()),D&&H&&T&&(e==null||e(T));const q=Ju(V.sourceEvent,{transform:B,snapGrid:W,snapToGrid:O,containerBounds:p});if(i=q,l=Cne(U,M,q,T),l.size>0&&(n||L||!T&&z)){const[ee,Z]=tb({nodeId:T,dragItems:l,nodeLookup:U});n==null||n(V.sourceEvent,l,ee,Z),L==null||L(V.sourceEvent,ee,Z),T||z==null||z(V.sourceEvent,Z)}}const _=C3().clickDistance(R).on("start",V=>{const{domNode:U,nodeDragThreshold:I,transform:M,snapGrid:B,snapToGrid:W}=t();p=(U==null?void 0:U.getBoundingClientRect())||null,y=!1,k=!1,v=V.sourceEvent,I===0&&F(V),i=Ju(V.sourceEvent,{transform:M,snapGrid:B,snapToGrid:W,containerBounds:p}),f=xs(V.sourceEvent,p)}).on("drag",V=>{const{autoPanOnNodeDrag:U,transform:I,snapGrid:M,snapToGrid:B,nodeDragThreshold:W,nodeLookup:O}=t(),H=Ju(V.sourceEvent,{transform:I,snapGrid:M,snapToGrid:B,containerBounds:p});if(v=V.sourceEvent,(V.sourceEvent.type==="touchmove"&&V.sourceEvent.touches.length>1||T&&!O.has(T))&&(y=!0),!y){if(!u&&U&&h&&(u=!0,P()),!h){const L=xs(V.sourceEvent,p),z=L.x-f.x,Y=L.y-f.y;Math.sqrt(z*z+Y*Y)>W&&F(V)}(i.x!==H.xSnapped||i.y!==H.ySnapped)&&l&&h&&(f=xs(V.sourceEvent,p),$(H))}}).on("end",V=>{if(!h||y){y&&l.size>0&&t().updateNodePositions(l,!1);return}if(u=!1,h=!1,cancelAnimationFrame(a),l.size>0){const{nodeLookup:U,updateNodePositions:I,onNodeDragStop:M,onSelectionDragStop:B}=t();if(k&&(I(l,!1),k=!1),o||M||!T&&B){const[W,O]=tb({nodeId:T,dragItems:l,nodeLookup:U,dragging:!1});o==null||o(V.sourceEvent,l,W,O),M==null||M(V.sourceEvent,W,O),T||B==null||B(V.sourceEvent,O)}}}).filter(V=>{const U=V.target;return!V.button&&(!N||!VC(U,`.${N}`,C))&&(!S||VC(U,S,C))});g.call(_)}function j(){g==null||g.on(".drag",null)}return{update:b,destroy:j}}function Rne(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())jd(o,lc(i))>0&&r.push(i);return r}const Ane=250;function Pne(e,t,n,r){var l,u;let o=[],i=1/0;const a=Rne(e,n,t+Ane);for(const f of a){const p=[...((l=f.internals.handleBounds)==null?void 0:l.source)??[],...((u=f.internals.handleBounds)==null?void 0:u.target)??[]];for(const h of p){if(r.nodeId===h.nodeId&&r.type===h.type&&r.id===h.id)continue;const{x:g,y}=Ca(f,h,h.position,!0),k=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(y-e.y,2));k>t||(k<i?(o=[{...h,x:g,y}],i=k):k===i&&o.push({...h,x:g,y}))}}if(!o.length)return null;if(o.length>1){const f=r.type==="source"?"target":"source";return o.find(p=>p.type===f)??o[0]}return o[0]}function dD(e,t,n,r,o,i=!1){var f,p,h;const a=r.get(e);if(!a)return null;const l=o==="strict"?(f=a.internals.handleBounds)==null?void 0:f[t]:[...((p=a.internals.handleBounds)==null?void 0:p.source)??[],...((h=a.internals.handleBounds)==null?void 0:h.target)??[]],u=(n?l==null?void 0:l.find(g=>g.id===n):l==null?void 0:l[0])??null;return u&&i?{...u,...Ca(a,u,u.position,!0)}:u}function fD(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function _ne(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const pD=()=>!0;function Dne(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:a,domNode:l,nodeLookup:u,lib:f,autoPanOnConnect:p,flowId:h,panBy:g,cancelConnection:y,onConnectStart:k,onConnect:v,onConnectEnd:b,isValidConnection:j=pD,onReconnectEnd:N,updateConnection:S,getTransform:C,getFromHandle:D,autoPanSpeed:T,dragThreshold:R=1,handleDomNode:$}){const P=eD(e.target);let F=0,_;const{x:V,y:U}=xs(e),I=fD(i,$),M=l==null?void 0:l.getBoundingClientRect();let B=!1;if(!M||!I)return;const W=dD(o,I,r,u,t);if(!W)return;let O=xs(e,M),H=!1,L=null,z=!1,Y=null;function q(){if(!p||!M)return;const[Ne,Ce]=L0(O,M,T);g({x:Ne,y:Ce}),F=requestAnimationFrame(q)}const Q={...W,nodeId:o,type:I,position:W.position},ee=u.get(o);let ie={inProgress:!0,isValid:null,from:Ca(ee,Q,ct.Left,!0),fromHandle:Q,fromPosition:Q.position,fromNode:ee,to:O,toHandle:null,toPosition:_C[Q.position],toNode:null,pointer:O};function ne(){B=!0,S(ie),k==null||k(e,{nodeId:o,handleId:r,handleType:I})}R===0&&ne();function ue(Ne){if(!B){const{x:be,y:Re}=xs(Ne),He=be-V,rt=Re-U;if(!(He*He+rt*rt>R*R))return;ne()}if(!D()||!Q){ge(Ne);return}const Ce=C();O=xs(Ne,M),_=Pne(_c(O,Ce,!1,[1,1]),n,u,Q),H||(q(),H=!0);const ke=hD(Ne,{handle:_,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:a?"target":"source",isValidConnection:j,doc:P,lib:f,flowId:h,nodeLookup:u});Y=ke.handleDomNode,L=ke.connection,z=_ne(!!_,ke.isValid);const Ue=u.get(o),oe=Ue?Ca(Ue,Q,ct.Left,!0):ie.from,ve={...ie,from:oe,isValid:z,to:ke.toHandle&&z?cc({x:ke.toHandle.x,y:ke.toHandle.y},Ce):O,toHandle:ke.toHandle,toPosition:z&&ke.toHandle?ke.toHandle.position:_C[Q.position],toNode:ke.toHandle?u.get(ke.toHandle.nodeId):null,pointer:O};S(ve),ie=ve}function ge(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(B){(_||Y)&&L&&z&&(v==null||v(L));const{inProgress:Ce,...ke}=ie,Ue={...ke,toPosition:ie.toHandle?ie.toPosition:null};b==null||b(Ne,Ue),i&&(N==null||N(Ne,Ue))}y(),cancelAnimationFrame(F),H=!1,z=!1,L=null,Y=null,P.removeEventListener("mousemove",ue),P.removeEventListener("mouseup",ge),P.removeEventListener("touchmove",ue),P.removeEventListener("touchend",ge)}}P.addEventListener("mousemove",ue),P.addEventListener("mouseup",ge),P.addEventListener("touchmove",ue),P.addEventListener("touchend",ge)}function hD(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:a,lib:l,flowId:u,isValidConnection:f=pD,nodeLookup:p}){const h=i==="target",g=t?a.querySelector(`.${l}-flow__handle[data-id="${u}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:y,y:k}=xs(e),v=a.elementFromPoint(y,k),b=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:g,j={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const N=fD(void 0,b),S=b.getAttribute("data-nodeid"),C=b.getAttribute("data-handleid"),D=b.classList.contains("connectable"),T=b.classList.contains("connectableend");if(!S||!N)return j;const R={source:h?S:r,sourceHandle:h?C:o,target:h?r:S,targetHandle:h?o:C};j.connection=R;const P=D&&T&&(n===ic.Strict?h&&N==="source"||!h&&N==="target":S!==r||C!==o);j.isValid=P&&f(R),j.toHandle=dD(S,N,C,p,n,!0)}return j}const Pv={onPointerDown:Dne,isValid:hD};function $ne({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=zr(e);function i({translateExtent:l,width:u,height:f,zoomStep:p=1,pannable:h=!0,zoomable:g=!0,inversePan:y=!1}){const k=S=>{if(S.sourceEvent.type!=="wheel"||!t)return;const C=n(),D=S.sourceEvent.ctrlKey&&kd()?10:1,T=-S.sourceEvent.deltaY*(S.sourceEvent.deltaMode===1?.05:S.sourceEvent.deltaMode?1:.002)*p,R=C[2]*Math.pow(2,T*D);t.scaleTo(R)};let v=[0,0];const b=S=>{(S.sourceEvent.type==="mousedown"||S.sourceEvent.type==="touchstart")&&(v=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY])},j=S=>{const C=n();if(S.sourceEvent.type!=="mousemove"&&S.sourceEvent.type!=="touchmove"||!t)return;const D=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY],T=[D[0]-v[0],D[1]-v[1]];v=D;const R=r()*Math.max(C[2],Math.log(C[2]))*(y?-1:1),$={x:C[0]-T[0]*R,y:C[1]-T[1]*R},P=[[0,0],[u,f]];t.setViewportConstrained({x:$.x,y:$.y,zoom:C[2]},P,l)},N=U3().on("start",b).on("zoom",h?j:null).on("zoom.wheel",g?k:null);o.call(N,{})}function a(){o.on("zoom",null)}return{update:i,destroy:a,pointer:hs}}const ag=e=>({x:e.x,y:e.y,zoom:e.k}),nb=({x:e,y:t,zoom:n})=>sg.translate(e,t).scale(n),Dl=(e,t)=>e.target.closest(`.${t}`),mD=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ine=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,rb=(e,t=0,n=Ine,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},gD=e=>{const t=e.ctrlKey&&kd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Lne({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:u,onPanZoomEnd:f}){return p=>{if(Dl(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const h=n.property("__zoom").k||1;if(p.ctrlKey&&a){const b=hs(p),j=gD(p),N=h*Math.pow(2,j);r.scaleTo(n,N,b,p);return}const g=p.deltaMode===1?20:1;let y=o===ya.Vertical?0:p.deltaX*g,k=o===ya.Horizontal?0:p.deltaY*g;!kd()&&p.shiftKey&&o!==ya.Vertical&&(y=p.deltaY*g,k=0),r.translateBy(n,-(y/h)*i,-(k/h)*i,{internal:!0});const v=ag(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(u==null||u(p,v),e.panScrollTimeout=setTimeout(()=>{f==null||f(p,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(p,v))}}function Mne({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",a=!t&&i&&!r.ctrlKey,l=Dl(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,o)}}function One({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,a,l;if((i=r.sourceEvent)!=null&&i.internal)return;const o=ag(r.transform);e.mouseButton=((a=r.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function Fne({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var a,l;e.usedRightMouseButton=!!(n&&mD(t,e.mouseButton??0)),(a=i.sourceEvent)!=null&&a.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((l=i.sourceEvent)!=null&&l.internal)&&(o==null||o(i.sourceEvent,ag(i.transform)))}}function zne({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,i&&mD(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const u=ag(a.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(a.sourceEvent,u)},n?150:0)}}}function Bne({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:l,noPanClassName:u,lib:f,connectionInProgress:p}){return h=>{var b;const g=e||t,y=n&&h.ctrlKey,k=h.type==="wheel";if(h.button===1&&h.type==="mousedown"&&(Dl(h,`${f}-flow__node`)||Dl(h,`${f}-flow__edge`)))return!0;if(!r&&!g&&!o&&!i&&!n||a||p&&!k||Dl(h,l)&&k||Dl(h,u)&&(!k||o&&k&&!e)||!n&&h.ctrlKey&&k)return!1;if(!n&&h.type==="touchstart"&&((b=h.touches)==null?void 0:b.length)>1)return h.preventDefault(),!1;if(!g&&!o&&!y&&k||!r&&(h.type==="mousedown"||h.type==="touchstart")||Array.isArray(r)&&!r.includes(h.button)&&h.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(h.button)||!h.button||h.button<=1;return(!h.ctrlKey||k)&&v}}function Une({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:u}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),h=U3().scaleExtent([t,n]).translateExtent(r),g=zr(e).call(h);N({x:o.x,y:o.y,zoom:ac(o.zoom,t,n)},[[0,0],[p.width,p.height]],r);const y=g.on("wheel.zoom"),k=g.on("dblclick.zoom");h.wheelDelta(gD);async function v(_,V){return g?new Promise(U=>{h==null||h.interpolate((V==null?void 0:V.interpolate)==="linear"?Qu:Jp).transform(rb(g,V==null?void 0:V.duration,V==null?void 0:V.ease,()=>U(!0)),_)}):!1}function b({noWheelClassName:_,noPanClassName:V,onPaneContextMenu:U,userSelectionActive:I,panOnScroll:M,panOnDrag:B,panOnScrollMode:W,panOnScrollSpeed:O,preventScrolling:H,zoomOnPinch:L,zoomOnScroll:z,zoomOnDoubleClick:Y,zoomActivationKeyPressed:q,lib:Q,onTransformChange:ee,connectionInProgress:Z,paneClickDistance:ie,selectionOnDrag:ne}){I&&!f.isZoomingOrPanning&&j();const ue=M&&!q&&!I;h.clickDistance(ne?1/0:!gs(ie)||ie<0?0:ie);const ge=ue?Lne({zoomPanValues:f,noWheelClassName:_,d3Selection:g,d3Zoom:h,panOnScrollMode:W,panOnScrollSpeed:O,zoomOnPinch:L,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:l}):Mne({noWheelClassName:_,preventScrolling:H,d3ZoomHandler:y});g.on("wheel.zoom",ge,{passive:!1});const Ne=One({zoomPanValues:f,onDraggingChange:u,onPanZoomStart:a});h.on("start",Ne);const Ce=Fne({zoomPanValues:f,panOnDrag:B,onPaneContextMenu:!!U,onPanZoom:i,onTransformChange:ee});h.on("zoom",Ce);const ke=zne({zoomPanValues:f,panOnDrag:B,panOnScroll:M,onPaneContextMenu:U,onPanZoomEnd:l,onDraggingChange:u});h.on("end",ke);const Ue=Bne({zoomActivationKeyPressed:q,panOnDrag:B,zoomOnScroll:z,panOnScroll:M,zoomOnDoubleClick:Y,zoomOnPinch:L,userSelectionActive:I,noPanClassName:V,noWheelClassName:_,lib:Q,connectionInProgress:Z});h.filter(Ue),Y?g.on("dblclick.zoom",k):g.on("dblclick.zoom",null)}function j(){h.on("zoom",null)}async function N(_,V,U){const I=nb(_),M=h==null?void 0:h.constrain()(I,V,U);return M&&await v(M),M}async function S(_,V){const U=nb(_);return await v(U,V),U}function C(_){if(g){const V=nb(_),U=g.property("__zoom");(U.k!==_.zoom||U.x!==_.x||U.y!==_.y)&&(h==null||h.transform(g,V,null,{sync:!0}))}}function D(){const _=g?B3(g.node()):{x:0,y:0,k:1};return{x:_.x,y:_.y,zoom:_.k}}async function T(_,V){return g?new Promise(U=>{h==null||h.interpolate((V==null?void 0:V.interpolate)==="linear"?Qu:Jp).scaleTo(rb(g,V==null?void 0:V.duration,V==null?void 0:V.ease,()=>U(!0)),_)}):!1}async function R(_,V){return g?new Promise(U=>{h==null||h.interpolate((V==null?void 0:V.interpolate)==="linear"?Qu:Jp).scaleBy(rb(g,V==null?void 0:V.duration,V==null?void 0:V.ease,()=>U(!0)),_)}):!1}function $(_){h==null||h.scaleExtent(_)}function P(_){h==null||h.translateExtent(_)}function F(_){const V=!gs(_)||_<0?0:_;h==null||h.clickDistance(V)}return{update:b,destroy:j,setViewport:S,setViewportConstrained:N,getViewport:D,scaleTo:T,scaleBy:R,setScaleExtent:$,setTranslateExtent:P,syncViewport:C,setClickDistance:F}}var uc;(function(e){e.Line="line",e.Handle="handle"})(uc||(uc={}));function Hne({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const a=e-t,l=n-r,u=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&o&&(u[0]=u[0]*-1),l&&i&&(u[1]=u[1]*-1),u}function WC(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function pi(e,t){return Math.max(0,t-e)}function hi(e,t){return Math.max(0,e-t)}function Ep(e,t,n){return Math.max(0,t-e,e-n)}function qC(e,t){return e?!t:t}function Vne(e,t,n,r,o,i,a,l){let{affectsX:u,affectsY:f}=t;const{isHorizontal:p,isVertical:h}=t,g=p&&h,{xSnapped:y,ySnapped:k}=n,{minWidth:v,maxWidth:b,minHeight:j,maxHeight:N}=r,{x:S,y:C,width:D,height:T,aspectRatio:R}=e;let $=Math.floor(p?y-e.pointerX:0),P=Math.floor(h?k-e.pointerY:0);const F=D+(u?-$:$),_=T+(f?-P:P),V=-i[0]*D,U=-i[1]*T;let I=Ep(F,v,b),M=Ep(_,j,N);if(a){let O=0,H=0;u&&$<0?O=pi(S+$+V,a[0][0]):!u&&$>0&&(O=hi(S+F+V,a[1][0])),f&&P<0?H=pi(C+P+U,a[0][1]):!f&&P>0&&(H=hi(C+_+U,a[1][1])),I=Math.max(I,O),M=Math.max(M,H)}if(l){let O=0,H=0;u&&$>0?O=hi(S+$,l[0][0]):!u&&$<0&&(O=pi(S+F,l[1][0])),f&&P>0?H=hi(C+P,l[0][1]):!f&&P<0&&(H=pi(C+_,l[1][1])),I=Math.max(I,O),M=Math.max(M,H)}if(o){if(p){const O=Ep(F/R,j,N)*R;if(I=Math.max(I,O),a){let H=0;!u&&!f||u&&!f&&g?H=hi(C+U+F/R,a[1][1])*R:H=pi(C+U+(u?$:-$)/R,a[0][1])*R,I=Math.max(I,H)}if(l){let H=0;!u&&!f||u&&!f&&g?H=pi(C+F/R,l[1][1])*R:H=hi(C+(u?$:-$)/R,l[0][1])*R,I=Math.max(I,H)}}if(h){const O=Ep(_*R,v,b)/R;if(M=Math.max(M,O),a){let H=0;!u&&!f||f&&!u&&g?H=hi(S+_*R+V,a[1][0])/R:H=pi(S+(f?P:-P)*R+V,a[0][0])/R,M=Math.max(M,H)}if(l){let H=0;!u&&!f||f&&!u&&g?H=pi(S+_*R,l[1][0])/R:H=hi(S+(f?P:-P)*R,l[0][0])/R,M=Math.max(M,H)}}}P=P+(P<0?M:-M),$=$+($<0?I:-I),o&&(g?F>_*R?P=(qC(u,f)?-$:$)/R:$=(qC(u,f)?-P:P)*R:p?(P=$/R,f=u):($=P*R,u=f));const B=u?S+$:S,W=f?C+P:C;return{width:D+(u?-$:$),height:T+(f?-P:P),x:i[0]*$*(u?-1:1)+B,y:i[1]*P*(f?-1:1)+W}}const xD={width:0,height:0,x:0,y:0},Wne={...xD,pointerX:0,pointerY:0,aspectRatio:1};function qne(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,l=n[0]*i,u=n[1]*a;return[[r-l,o-u],[r+i-l,o+a-u]]}function Kne({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=zr(e);let a={controlDirection:WC("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:f,boundaries:p,keepAspectRatio:h,resizeDirection:g,onResizeStart:y,onResize:k,onResizeEnd:v,shouldResize:b}){let j={...xD},N={...Wne};a={boundaries:p,resizeDirection:g,keepAspectRatio:h,controlDirection:WC(f)};let S,C=null,D=[],T,R,$,P=!1;const F=C3().on("start",_=>{const{nodeLookup:V,transform:U,snapGrid:I,snapToGrid:M,nodeOrigin:B,paneDomNode:W}=n();if(S=V.get(t),!S)return;C=(W==null?void 0:W.getBoundingClientRect())??null;const{xSnapped:O,ySnapped:H}=Ju(_.sourceEvent,{transform:U,snapGrid:I,snapToGrid:M,containerBounds:C});j={width:S.measured.width??0,height:S.measured.height??0,x:S.position.x??0,y:S.position.y??0},N={...j,pointerX:O,pointerY:H,aspectRatio:j.width/j.height},T=void 0,R=Na(S.extent)?S.extent:void 0,S.parentId&&(S.extent==="parent"||S.expandParent)&&(T=V.get(S.parentId)),T&&S.extent==="parent"&&(R=[[0,0],[T.measured.width,T.measured.height]]),D=[],$=void 0;for(const[L,z]of V)if(z.parentId===t&&(D.push({id:L,position:{...z.position},extent:z.extent}),z.extent==="parent"||z.expandParent)){const Y=qne(z,S,z.origin??B);$?$=[[Math.min(Y[0][0],$[0][0]),Math.min(Y[0][1],$[0][1])],[Math.max(Y[1][0],$[1][0]),Math.max(Y[1][1],$[1][1])]]:$=Y}y==null||y(_,{...j})}).on("drag",_=>{const{transform:V,snapGrid:U,snapToGrid:I,nodeOrigin:M}=n(),B=Ju(_.sourceEvent,{transform:V,snapGrid:U,snapToGrid:I,containerBounds:C}),W=[];if(!S)return;const{x:O,y:H,width:L,height:z}=j,Y={},q=S.origin??M,{width:Q,height:ee,x:Z,y:ie}=Vne(N,a.controlDirection,B,a.boundaries,a.keepAspectRatio,q,R,$),ne=Q!==L,ue=ee!==z,ge=Z!==O&&ne,Ne=ie!==H&&ue;if(!ge&&!Ne&&!ne&&!ue)return;if((ge||Ne||q[0]===1||q[1]===1)&&(Y.x=ge?Z:j.x,Y.y=Ne?ie:j.y,j.x=Y.x,j.y=Y.y,D.length>0)){const oe=Z-O,ve=ie-H;for(const be of D)be.position={x:be.position.x-oe+q[0]*(Q-L),y:be.position.y-ve+q[1]*(ee-z)},W.push(be)}if((ne||ue)&&(Y.width=ne&&(!a.resizeDirection||a.resizeDirection==="horizontal")?Q:j.width,Y.height=ue&&(!a.resizeDirection||a.resizeDirection==="vertical")?ee:j.height,j.width=Y.width,j.height=Y.height),T&&S.expandParent){const oe=q[0]*(Y.width??0);Y.x&&Y.x<oe&&(j.x=oe,N.x=N.x-(Y.x-oe));const ve=q[1]*(Y.height??0);Y.y&&Y.y<ve&&(j.y=ve,N.y=N.y-(Y.y-ve))}const Ce=Hne({width:j.width,prevWidth:L,height:j.height,prevHeight:z,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),ke={...j,direction:Ce};(b==null?void 0:b(_,ke))!==!1&&(P=!0,k==null||k(_,ke),r(Y,W))}).on("end",_=>{P&&(v==null||v(_,{...j}),o==null||o({...j}),P=!1)});i.call(F)}function u(){i.on(".drag",null)}return{update:l,destroy:u}}var sb={exports:{}},ob={},ib={exports:{}},ab={};/**
638
- * @license React
639
- * use-sync-external-store-shim.production.js
640
- *
641
- * Copyright (c) Meta Platforms, Inc. and affiliates.
642
- *
643
- * This source code is licensed under the MIT license found in the
644
- * LICENSE file in the root directory of this source tree.
645
- */var KC;function Gne(){if(KC)return ab;KC=1;var e=Ed();function t(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function l(h,g){var y=g(),k=r({inst:{value:y,getSnapshot:g}}),v=k[0].inst,b=k[1];return i(function(){v.value=y,v.getSnapshot=g,u(v)&&b({inst:v})},[h,y,g]),o(function(){return u(v)&&b({inst:v}),h(function(){u(v)&&b({inst:v})})},[h]),a(y),y}function u(h){var g=h.getSnapshot;h=h.value;try{var y=g();return!n(h,y)}catch{return!0}}function f(h,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:l;return ab.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,ab}var GC;function Yne(){return GC||(GC=1,ib.exports=Gne()),ib.exports}/**
646
- * @license React
647
- * use-sync-external-store-shim/with-selector.production.js
648
- *
649
- * Copyright (c) Meta Platforms, Inc. and affiliates.
650
- *
651
- * This source code is licensed under the MIT license found in the
652
- * LICENSE file in the root directory of this source tree.
653
- */var YC;function Xne(){if(YC)return ob;YC=1;var e=Ed(),t=Yne();function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,i=e.useRef,a=e.useEffect,l=e.useMemo,u=e.useDebugValue;return ob.useSyncExternalStoreWithSelector=function(f,p,h,g,y){var k=i(null);if(k.current===null){var v={hasValue:!1,value:null};k.current=v}else v=k.current;k=l(function(){function j(T){if(!N){if(N=!0,S=T,T=g(T),y!==void 0&&v.hasValue){var R=v.value;if(y(R,T))return C=R}return C=T}if(R=C,r(S,T))return R;var $=g(T);return y!==void 0&&y(R,$)?(S=T,R):(S=T,C=$)}var N=!1,S,C,D=h===void 0?null:h;return[function(){return j(p())},D===null?void 0:function(){return j(D())}]},[p,h,g,y]);var b=o(f,k[0],k[1]);return a(function(){v.hasValue=!0,v.value=b},[b]),u(b),b},ob}var XC;function Qne(){return XC||(XC=1,sb.exports=Xne()),sb.exports}var Jne=Qne();const Zne=Cd(Jne),ere={},QC=e=>{let t;const n=new Set,r=(p,h)=>{const g=typeof p=="function"?p(t):p;if(!Object.is(g,t)){const y=t;t=h??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(k=>k(t,y))}},o=()=>t,u={setState:r,getState:o,getInitialState:()=>f,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(ere?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},f=t=e(r,o,u);return u},tre=e=>e?QC(e):QC,{useDebugValue:nre}=Lt,{useSyncExternalStoreWithSelector:rre}=Zne,sre=e=>e;function yD(e,t=sre,n){const r=rre(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return nre(r),r}const JC=(e,t)=>{const n=tre(e),r=(o,i=t)=>yD(n,o,i);return Object.assign(r,n),r},ore=(e,t)=>e?JC(e,t):JC;function on(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const lg=m.createContext(null),ire=lg.Provider,bD=Cs.error001("react");function Pt(e,t){const n=m.useContext(lg);if(n===null)throw new Error(bD);return yD(n,e,t)}function an(){const e=m.useContext(lg);if(e===null)throw new Error(bD);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const ZC={display:"none"},are={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},vD="react-flow__node-desc",wD="react-flow__edge-desc",lre="react-flow__aria-live",cre=e=>e.ariaLiveMessage,ure=e=>e.ariaLabelConfig;function dre({rfId:e}){const t=Pt(cre);return s.jsx("div",{id:`${lre}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:are,children:t})}function fre({rfId:e,disableKeyboardA11y:t}){const n=Pt(ure);return s.jsxs(s.Fragment,{children:[s.jsx("div",{id:`${vD}-${e}`,style:ZC,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),s.jsx("div",{id:`${wD}-${e}`,style:ZC,children:n["edge.a11yDescription.default"]}),!t&&s.jsx(dre,{rfId:e})]})}const ef=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const a=`${e}`.split("-");return s.jsx("div",{className:En(["react-flow__panel",n,...a]),style:r,ref:i,...o,children:t})});ef.displayName="Panel";function pre({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:s.jsx(ef,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:s.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const hre=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Tp=e=>e.id;function mre(e,t){return on(e.selectedNodes.map(Tp),t.selectedNodes.map(Tp))&&on(e.selectedEdges.map(Tp),t.selectedEdges.map(Tp))}function gre({onSelectionChange:e}){const t=an(),{selectedNodes:n,selectedEdges:r}=Pt(hre,mre);return m.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const xre=e=>!!e.onSelectionChangeHandlers;function yre({onSelectionChange:e}){const t=Pt(xre);return e||t?s.jsx(gre,{onSelectionChange:e}):null}const jD=[0,0],bre={x:0,y:0,zoom:1},vre=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],eE=[...vre,"rfId"],wre=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),tE={translateExtent:bd,nodeOrigin:jD,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function jre(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:u}=Pt(wre,on),f=an();m.useEffect(()=>(u(e.defaultNodes,e.defaultEdges),()=>{p.current=tE,l()}),[]);const p=m.useRef(tE);return m.useEffect(()=>{for(const h of eE){const g=e[h],y=p.current[h];g!==y&&(typeof e[h]>"u"||(h==="nodes"?t(g):h==="edges"?n(g):h==="minZoom"?r(g):h==="maxZoom"?o(g):h==="translateExtent"?i(g):h==="nodeExtent"?a(g):h==="ariaLabelConfig"?f.setState({ariaLabelConfig:ine(g)}):h==="fitView"?f.setState({fitViewQueued:g}):h==="fitViewOptions"?f.setState({fitViewOptions:g}):f.setState({[h]:g})))}p.current=e},eE.map(h=>e[h])),null}function nE(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function kre(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const o=nE(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[e]),t!==null?t:(r=nE())!=null&&r.matches?"dark":"light"}const rE=typeof document<"u"?document:null;function Sd(e=null,t={target:rE,actInsideInputWithModifier:!0}){const[n,r]=m.useState(!1),o=m.useRef(!1),i=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(h=>typeof h=="string").map(h=>h.replace("+",`
654
- `).replace(`
655
-
656
- `,`
657
- +`).split(`
658
- `)),p=f.reduce((h,g)=>h.concat(...g),[]);return[f,p]}return[[],[]]},[e]);return m.useEffect(()=>{const u=(t==null?void 0:t.target)??rE,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const p=y=>{var b,j;if(o.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!o.current||o.current&&!f)&&tD(y))return!1;const v=oE(y.code,l);if(i.current.add(y[v]),sE(a,i.current,!1)){const N=((j=(b=y.composedPath)==null?void 0:b.call(y))==null?void 0:j[0])||y.target,S=(N==null?void 0:N.nodeName)==="BUTTON"||(N==null?void 0:N.nodeName)==="A";t.preventDefault!==!1&&(o.current||!S)&&y.preventDefault(),r(!0)}},h=y=>{const k=oE(y.code,l);sE(a,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(y[k]),y.key==="Meta"&&i.current.clear(),o.current=!1},g=()=>{i.current.clear(),r(!1)};return u==null||u.addEventListener("keydown",p),u==null||u.addEventListener("keyup",h),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{u==null||u.removeEventListener("keydown",p),u==null||u.removeEventListener("keyup",h),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,r]),n}function sE(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function oE(e,t){return t.includes(e)?"code":"key"}const Sre=()=>{const e=an();return m.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,i],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??i},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:i,maxZoom:a,panZoom:l}=e.getState(),u=M0(t,r,o,i,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(u,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:i,domNode:a}=e.getState();if(!a)return t;const{x:l,y:u}=a.getBoundingClientRect(),f={x:t.x-l,y:t.y-u},p=n.snapGrid??o,h=n.snapToGrid??i;return _c(f,r,h,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),a=cc(t,n);return{x:a.x+o,y:a.y+i}}}),[])};function kD(e,t){const n=[],r=new Map,o=[];for(const i of e)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const a=r.get(i.id);a?a.push(i):r.set(i.id,[i])}for(const i of t){const a=r.get(i.id);if(!a){n.push(i);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...i};for(const u of a)Nre(u,l);n.push(l)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function Nre(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function SD(e,t){return kD(e,t)}function ND(e,t){return kD(e,t)}function ra(e,t){return{id:e,type:"select",selected:t}}function $l(e,t=new Set,n=!1){const r=[];for(const[o,i]of e){const a=t.has(o);!(i.selected===void 0&&!a)&&i.selected!==a&&(n&&(i.selected=a),r.push(ra(i.id,a)))}return r}function iE({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,a]of e.entries()){const l=t.get(a.id),u=((o=l==null?void 0:l.internals)==null?void 0:o.userNode)??l;u!==void 0&&u!==a&&n.push({id:a.id,item:a,type:"replace"}),u===void 0&&n.push({item:a,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function aE(e){return{id:e.id,type:"remove"}}const Cre=Q3();function Ere(e,t,n={}){return fne(e,t,{...n,onError:n.onError??Cre})}const lE=e=>Qte(e),Tre=e=>K3(e);function CD(e){return m.forwardRef(e)}const Rre=typeof window<"u"?m.useLayoutEffect:m.useEffect;function cE(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>Are(()=>n(o=>o+BigInt(1))));return Rre(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function Are(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const ED=m.createContext(null);function Pre({children:e}){const t=an(),n=m.useCallback(l=>{const{nodes:u=[],setNodes:f,hasDefaultNodes:p,onNodesChange:h,nodeLookup:g,fitViewQueued:y,onNodesChangeMiddlewareMap:k}=t.getState();let v=u;for(const j of l)v=typeof j=="function"?j(v):j;let b=iE({items:v,lookup:g});for(const j of k.values())b=j(b);p&&f(v),b.length>0?h==null||h(b):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:j,nodes:N,setNodes:S}=t.getState();j&&S(N)})},[]),r=cE(n),o=m.useCallback(l=>{const{edges:u=[],setEdges:f,hasDefaultEdges:p,onEdgesChange:h,edgeLookup:g}=t.getState();let y=u;for(const k of l)y=typeof k=="function"?k(y):k;p?f(y):h&&h(iE({items:y,lookup:g}))},[]),i=cE(o),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return s.jsx(ED.Provider,{value:a,children:e})}function _re(){const e=m.useContext(ED);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Dre=e=>!!e.panZoom;function cg(){const e=Sre(),t=an(),n=_re(),r=Pt(Dre),o=m.useMemo(()=>{const i=h=>t.getState().nodeLookup.get(h),a=h=>{n.nodeQueue.push(h)},l=h=>{n.edgeQueue.push(h)},u=h=>{var j,N;const{nodeLookup:g,nodeOrigin:y}=t.getState(),k=lE(h)?h:g.get(h.id),v=k.parentId?Z3(k.position,k.measured,k.parentId,g,y):k.position,b={...k,position:v,width:((j=k.measured)==null?void 0:j.width)??k.width,height:((N=k.measured)==null?void 0:N.height)??k.height};return lc(b)},f=(h,g,y={replace:!1})=>{a(k=>k.map(v=>{if(v.id===h){const b=typeof g=="function"?g(v):g;return y.replace&&lE(b)?b:{...v,...b}}return v}))},p=(h,g,y={replace:!1})=>{l(k=>k.map(v=>{if(v.id===h){const b=typeof g=="function"?g(v):g;return y.replace&&Tre(b)?b:{...v,...b}}return v}))};return{getNodes:()=>t.getState().nodes.map(h=>({...h})),getNode:h=>{var g;return(g=i(h))==null?void 0:g.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:h=[]}=t.getState();return h.map(g=>({...g}))},getEdge:h=>t.getState().edgeLookup.get(h),setNodes:a,setEdges:l,addNodes:h=>{const g=Array.isArray(h)?h:[h];n.nodeQueue.push(y=>[...y,...g])},addEdges:h=>{const g=Array.isArray(h)?h:[h];n.edgeQueue.push(y=>[...y,...g])},toObject:()=>{const{nodes:h=[],edges:g=[],transform:y}=t.getState(),[k,v,b]=y;return{nodes:h.map(j=>({...j})),edges:g.map(j=>({...j})),viewport:{x:k,y:v,zoom:b}}},deleteElements:async({nodes:h=[],edges:g=[]})=>{const{nodes:y,edges:k,onNodesDelete:v,onEdgesDelete:b,triggerNodeChanges:j,triggerEdgeChanges:N,onDelete:S,onBeforeDelete:C}=t.getState(),{nodes:D,edges:T}=await nne({nodesToRemove:h,edgesToRemove:g,nodes:y,edges:k,onBeforeDelete:C}),R=T.length>0,$=D.length>0;if(R){const P=T.map(aE);b==null||b(T),N(P)}if($){const P=D.map(aE);v==null||v(D),j(P)}return($||R)&&(S==null||S({nodes:D,edges:T})),{deletedNodes:D,deletedEdges:T}},getIntersectingNodes:(h,g=!0,y)=>{const k=$C(h),v=k?h:u(h),b=y!==void 0;return v?(y||t.getState().nodes).filter(j=>{const N=t.getState().nodeLookup.get(j.id);if(N&&!k&&(j.id===h.id||!N.internals.positionAbsolute))return!1;const S=lc(b?j:N),C=jd(S,v);return g&&C>0||C>=S.width*S.height||C>=v.width*v.height}):[]},isNodeIntersecting:(h,g,y=!0)=>{const v=$C(h)?h:u(h);if(!v)return!1;const b=jd(v,g);return y&&b>0||b>=g.width*g.height||b>=v.width*v.height},updateNode:f,updateNodeData:(h,g,y={replace:!1})=>{f(h,k=>{const v=typeof g=="function"?g(k):g;return y.replace?{...k,data:v}:{...k,data:{...k.data,...v}}},y)},updateEdge:p,updateEdgeData:(h,g,y={replace:!1})=>{p(h,k=>{const v=typeof g=="function"?g(k):g;return y.replace?{...k,data:v}:{...k,data:{...k.data,...v}}},y)},getNodesBounds:h=>{const{nodeLookup:g,nodeOrigin:y}=t.getState();return Jte(h,{nodeLookup:g,nodeOrigin:y})},getHandleConnections:({type:h,id:g,nodeId:y})=>{var k;return Array.from(((k=t.getState().connectionLookup.get(`${y}-${h}${g?`-${g}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:h,handleId:g,nodeId:y})=>{var k;return Array.from(((k=t.getState().connectionLookup.get(`${y}${h?g?`-${h}-${g}`:`-${h}`:""}`))==null?void 0:k.values())??[])},fitView:async h=>{const g=t.getState().fitViewResolver??one();return t.setState({fitViewQueued:!0,fitViewOptions:h,fitViewResolver:g}),n.nodeQueue.push(y=>[...y]),g.promise}}},[]);return m.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const uE=e=>e.selected,$re=typeof window<"u"?window:void 0;function Ire({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=an(),{deleteElements:r}=cg(),o=Sd(e,{actInsideInputWithModifier:!1}),i=Sd(t,{target:$re});m.useEffect(()=>{if(o){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(uE),edges:a.filter(uE)}),n.setState({nodesSelectionActive:!1})}},[o]),m.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Lre(e){const t=an();m.useEffect(()=>{const n=()=>{var o,i,a,l;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=O0(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Cs.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const ug={position:"absolute",width:"100%",height:"100%",top:0,left:0},Mre=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Ore({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=ya.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:u,translateExtent:f,minZoom:p,maxZoom:h,zoomActivationKeyCode:g,preventScrolling:y=!0,children:k,noWheelClassName:v,noPanClassName:b,onViewportChange:j,isControlledViewport:N,paneClickDistance:S,selectionOnDrag:C}){const D=an(),T=m.useRef(null),{userSelectionActive:R,lib:$,connectionInProgress:P}=Pt(Mre,on),F=Sd(g),_=m.useRef();Lre(T);const V=m.useCallback(U=>{j==null||j({x:U[0],y:U[1],zoom:U[2]}),N||D.setState({transform:U})},[j,N]);return m.useEffect(()=>{if(T.current){_.current=Une({domNode:T.current,minZoom:p,maxZoom:h,translateExtent:f,viewport:u,onDraggingChange:B=>D.setState(W=>W.paneDragging===B?W:{paneDragging:B}),onPanZoomStart:(B,W)=>{const{onViewportChangeStart:O,onMoveStart:H}=D.getState();H==null||H(B,W),O==null||O(W)},onPanZoom:(B,W)=>{const{onViewportChange:O,onMove:H}=D.getState();H==null||H(B,W),O==null||O(W)},onPanZoomEnd:(B,W)=>{const{onViewportChangeEnd:O,onMoveEnd:H}=D.getState();H==null||H(B,W),O==null||O(W)}});const{x:U,y:I,zoom:M}=_.current.getViewport();return D.setState({panZoom:_.current,transform:[U,I,M],domNode:T.current.closest(".react-flow")}),()=>{var B;(B=_.current)==null||B.destroy()}}},[]),m.useEffect(()=>{var U;(U=_.current)==null||U.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:F,preventScrolling:y,noPanClassName:b,userSelectionActive:R,noWheelClassName:v,lib:$,onTransformChange:V,connectionInProgress:P,selectionOnDrag:C,paneClickDistance:S})},[e,t,n,r,o,i,a,l,F,y,b,R,v,$,V,P,C,S]),s.jsx("div",{className:"react-flow__renderer",ref:T,style:ug,children:k})}const Fre=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function zre(){const{userSelectionActive:e,userSelectionRect:t}=Pt(Fre,on);return e&&t?s.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const lb=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Bre=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Ure({isSelecting:e,selectionKeyPressed:t,selectionMode:n=vd.Full,panOnDrag:r,autoPanOnSelection:o,paneClickDistance:i,selectionOnDrag:a,onSelectionStart:l,onSelectionEnd:u,onPaneClick:f,onPaneContextMenu:p,onPaneScroll:h,onPaneMouseEnter:g,onPaneMouseMove:y,onPaneMouseLeave:k,children:v}){const b=m.useRef(0),j=an(),{userSelectionActive:N,elementsSelectable:S,dragging:C,connectionInProgress:D,panBy:T,autoPanSpeed:R}=Pt(Bre,on),$=S&&(e||N),P=m.useRef(null),F=m.useRef(),_=m.useRef(new Set),V=m.useRef(new Set),U=m.useRef(!1),I=m.useRef({x:0,y:0}),M=m.useRef(!1),B=ne=>{if(U.current||D){U.current=!1;return}f==null||f(ne),j.getState().resetSelectedElements(),j.setState({nodesSelectionActive:!1})},W=ne=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){ne.preventDefault();return}p==null||p(ne)},O=h?ne=>h(ne):void 0,H=ne=>{U.current&&(ne.stopPropagation(),U.current=!1)},L=ne=>{var be,Re;const{domNode:ue,transform:ge}=j.getState();if(F.current=ue==null?void 0:ue.getBoundingClientRect(),!F.current)return;const Ne=ne.target===P.current;if(!Ne&&!!ne.target.closest(".nokey")||!e||!(a&&Ne||t)||ne.button!==0||!ne.isPrimary)return;(Re=(be=ne.target)==null?void 0:be.setPointerCapture)==null||Re.call(be,ne.pointerId),U.current=!1;const{x:Ue,y:oe}=xs(ne.nativeEvent,F.current),ve=_c({x:Ue,y:oe},ge);j.setState({userSelectionRect:{width:0,height:0,startX:ve.x,startY:ve.y,x:Ue,y:oe}}),Ne||(ne.stopPropagation(),ne.preventDefault())};function z(ne,ue){const{userSelectionRect:ge}=j.getState();if(!ge)return;const{transform:Ne,nodeLookup:Ce,edgeLookup:ke,connectionLookup:Ue,triggerNodeChanges:oe,triggerEdgeChanges:ve,defaultEdgeOptions:be}=j.getState(),Re={x:ge.startX,y:ge.startY},{x:He,y:rt}=cc(Re,Ne),Fe={startX:Re.x,startY:Re.y,x:ne<He?ne:He,y:ue<rt?ue:rt,width:Math.abs(ne-He),height:Math.abs(ue-rt)},ot=_.current,Nt=V.current;_.current=new Set(I0(Ce,Fe,Ne,n===vd.Partial,!0).map(at=>at.id)),V.current=new Set;const mt=(be==null?void 0:be.selectable)??!0;for(const at of _.current){const ce=Ue.get(at);if(ce)for(const{edgeId:me}of ce.values()){const Ie=ke.get(me);Ie&&(Ie.selectable??mt)&&V.current.add(me)}}if(!IC(ot,_.current)){const at=$l(Ce,_.current,!0);oe(at)}if(!IC(Nt,V.current)){const at=$l(ke,V.current);ve(at)}j.setState({userSelectionRect:Fe,userSelectionActive:!0,nodesSelectionActive:!1})}function Y(){if(!o||!F.current)return;const[ne,ue]=L0(I.current,F.current,R);T({x:ne,y:ue}).then(ge=>{if(!U.current||!ge){b.current=requestAnimationFrame(Y);return}const{x:Ne,y:Ce}=I.current;z(Ne,Ce),b.current=requestAnimationFrame(Y)})}const q=()=>{cancelAnimationFrame(b.current),b.current=0,M.current=!1};m.useEffect(()=>()=>q(),[]);const Q=ne=>{const{userSelectionRect:ue,transform:ge,resetSelectedElements:Ne}=j.getState();if(!F.current||!ue)return;const{x:Ce,y:ke}=xs(ne.nativeEvent,F.current);I.current={x:Ce,y:ke};const Ue=cc({x:ue.startX,y:ue.startY},ge);if(!U.current){const oe=t?0:i;if(Math.hypot(Ce-Ue.x,ke-Ue.y)<=oe)return;Ne(),l==null||l(ne)}U.current=!0,M.current||(Y(),M.current=!0),z(Ce,ke)},ee=ne=>{var ue,ge;ne.button===0&&((ge=(ue=ne.target)==null?void 0:ue.releasePointerCapture)==null||ge.call(ue,ne.pointerId),!N&&ne.target===P.current&&j.getState().userSelectionRect&&(B==null||B(ne)),j.setState({userSelectionActive:!1,userSelectionRect:null}),U.current&&(u==null||u(ne),j.setState({nodesSelectionActive:_.current.size>0})),q())},Z=ne=>{var ue,ge;(ge=(ue=ne.target)==null?void 0:ue.releasePointerCapture)==null||ge.call(ue,ne.pointerId),q()},ie=r===!0||Array.isArray(r)&&r.includes(0);return s.jsxs("div",{className:En(["react-flow__pane",{draggable:ie,dragging:C,selection:e}]),onClick:$?void 0:lb(B,P),onContextMenu:lb(W,P),onWheel:lb(O,P),onPointerEnter:$?void 0:g,onPointerMove:$?Q:y,onPointerUp:$?ee:void 0,onPointerCancel:$?Z:void 0,onPointerDownCapture:$?L:void 0,onClickCapture:$?H:void 0,onPointerLeave:k,ref:P,style:ug,children:[v,s.jsx(zre,{})]})}function _v({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:l,onError:u}=t.getState(),f=l.get(e);if(!f){u==null||u("012",Cs.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&a)&&(i({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var p;return(p=r==null?void 0:r.current)==null?void 0:p.blur()})):o([e])}function TD({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:a}){const l=an(),[u,f]=m.useState(!1),p=m.useRef();return m.useEffect(()=>{p.current=Tne({getStoreItems:()=>l.getState(),onNodeMouseDown:h=>{_v({id:h,store:l,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!p.current))return p.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:a}),()=>{var h;(h=p.current)==null||h.destroy()}},[n,r,t,i,e,o,a]),u}const Hre=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function RD(){const e=an();return m.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:a,onError:l,updateNodePositions:u,nodeLookup:f,nodeOrigin:p}=e.getState(),h=new Map,g=Hre(a),y=o?i[0]:5,k=o?i[1]:5,v=n.direction.x*y*n.factor,b=n.direction.y*k*n.factor;for(const[,j]of f){if(!g(j))continue;let N={x:j.internals.positionAbsolute.x+v,y:j.internals.positionAbsolute.y+b};o&&(N=Zd(N,i));const{position:S,positionAbsolute:C}=G3({nodeId:j.id,nextPosition:N,nodeLookup:f,nodeExtent:r,nodeOrigin:p,onError:l});j.position=S,j.internals.positionAbsolute=C,h.set(j.id,j)}u(h)},[])}const V0=m.createContext(null),Vre=V0.Provider;V0.Consumer;const AD=()=>m.useContext(V0),Wre=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),qre=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:a}=r,{fromHandle:l,toHandle:u,isValid:f}=a,p=(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:p,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===ic.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!o,valid:p&&f}};function Kre({type:e="source",position:t=ct.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:a,onConnect:l,children:u,className:f,onMouseDown:p,onTouchStart:h,...g},y){var M,B;const k=a||null,v=e==="target",b=an(),j=AD(),{connectOnClick:N,noPanClassName:S,rfId:C}=Pt(Wre,on),{connectingFrom:D,connectingTo:T,clickConnecting:R,isPossibleEndHandle:$,connectionInProcess:P,clickConnectionInProcess:F,valid:_}=Pt(qre(j,k,e),on);j||(B=(M=b.getState()).onError)==null||B.call(M,"010",Cs.error010());const V=W=>{const{defaultEdgeOptions:O,onConnect:H,hasDefaultEdges:L}=b.getState(),z={...O,...W};if(L){const{edges:Y,setEdges:q,onError:Q}=b.getState();q(Ere(z,Y,{onError:Q}))}H==null||H(z),l==null||l(z)},U=W=>{if(!j)return;const O=nD(W.nativeEvent);if(o&&(O&&W.button===0||!O)){const H=b.getState();Pv.onPointerDown(W.nativeEvent,{handleDomNode:W.currentTarget,autoPanOnConnect:H.autoPanOnConnect,connectionMode:H.connectionMode,connectionRadius:H.connectionRadius,domNode:H.domNode,nodeLookup:H.nodeLookup,lib:H.lib,isTarget:v,handleId:k,nodeId:j,flowId:H.rfId,panBy:H.panBy,cancelConnection:H.cancelConnection,onConnectStart:H.onConnectStart,onConnectEnd:(...L)=>{var z,Y;return(Y=(z=b.getState()).onConnectEnd)==null?void 0:Y.call(z,...L)},updateConnection:H.updateConnection,onConnect:V,isValidConnection:n||((...L)=>{var z,Y;return((Y=(z=b.getState()).isValidConnection)==null?void 0:Y.call(z,...L))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:H.autoPanSpeed,dragThreshold:H.connectionDragThreshold})}O?p==null||p(W):h==null||h(W)},I=W=>{const{onClickConnectStart:O,onClickConnectEnd:H,connectionClickStartHandle:L,connectionMode:z,isValidConnection:Y,lib:q,rfId:Q,nodeLookup:ee,connection:Z}=b.getState();if(!j||!L&&!o)return;if(!L){O==null||O(W.nativeEvent,{nodeId:j,handleId:k,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:j,type:e,id:k}});return}const ie=eD(W.target),ne=n||Y,{connection:ue,isValid:ge}=Pv.isValid(W.nativeEvent,{handle:{nodeId:j,id:k,type:e},connectionMode:z,fromNodeId:L.nodeId,fromHandleId:L.id||null,fromType:L.type,isValidConnection:ne,flowId:Q,doc:ie,lib:q,nodeLookup:ee});ge&&ue&&V(ue);const Ne=structuredClone(Z);delete Ne.inProgress,Ne.toPosition=Ne.toHandle?Ne.toHandle.position:null,H==null||H(W,Ne),b.setState({connectionClickStartHandle:null})};return s.jsx("div",{"data-handleid":k,"data-nodeid":j,"data-handlepos":t,"data-id":`${C}-${j}-${k}-${e}`,className:En(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,f,{source:!v,target:v,connectable:r,connectablestart:o,connectableend:i,clickconnecting:R,connectingfrom:D,connectingto:T,valid:_,connectionindicator:r&&(!P||$)&&(P||F?i:o)}]),onMouseDown:U,onTouchStart:U,onClick:N?I:void 0,ref:y,...g,children:u})}const dc=m.memo(CD(Kre));function Gre({data:e,isConnectable:t,sourcePosition:n=ct.Bottom}){return s.jsxs(s.Fragment,{children:[e==null?void 0:e.label,s.jsx(dc,{type:"source",position:n,isConnectable:t})]})}function Yre({data:e,isConnectable:t,targetPosition:n=ct.Top,sourcePosition:r=ct.Bottom}){return s.jsxs(s.Fragment,{children:[s.jsx(dc,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,s.jsx(dc,{type:"source",position:r,isConnectable:t})]})}function Xre(){return null}function Qre({data:e,isConnectable:t,targetPosition:n=ct.Top}){return s.jsxs(s.Fragment,{children:[s.jsx(dc,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Vh={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},dE={input:Gre,default:Yre,output:Qre,group:Xre};function Jre(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const Zre=e=>{const{width:t,height:n,x:r,y:o}=Jd(e.nodeLookup,{filter:i=>!!i.selected});return{width:gs(t)?t:null,height:gs(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function ese({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=an(),{width:o,height:i,transformString:a,userSelectionActive:l}=Pt(Zre,on),u=RD(),f=m.useRef(null);m.useEffect(()=>{var y;n||(y=f.current)==null||y.focus({preventScroll:!0})},[n]);const p=!l&&o!==null&&i!==null;if(TD({nodeRef:f,disabled:!p}),!p)return null;const h=e?y=>{const k=r.getState().nodes.filter(v=>v.selected);e(y,k)}:void 0,g=y=>{Object.prototype.hasOwnProperty.call(Vh,y.key)&&(y.preventDefault(),u({direction:Vh[y.key],factor:y.shiftKey?4:1}))};return s.jsx("div",{className:En(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:s.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:n?void 0:-1,onKeyDown:n?void 0:g,style:{width:o,height:i}})})}const fE=typeof window<"u"?window:void 0,tse=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function PD({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:u,selectionKeyCode:f,selectionOnDrag:p,selectionMode:h,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:k,panActivationKeyCode:v,zoomActivationKeyCode:b,elementsSelectable:j,zoomOnScroll:N,zoomOnPinch:S,panOnScroll:C,panOnScrollSpeed:D,panOnScrollMode:T,zoomOnDoubleClick:R,panOnDrag:$,autoPanOnSelection:P,defaultViewport:F,translateExtent:_,minZoom:V,maxZoom:U,preventScrolling:I,onSelectionContextMenu:M,noWheelClassName:B,noPanClassName:W,disableKeyboardA11y:O,onViewportChange:H,isControlledViewport:L}){const{nodesSelectionActive:z,userSelectionActive:Y}=Pt(tse,on),q=Sd(f,{target:fE}),Q=Sd(v,{target:fE}),ee=Q||$,Z=Q||C,ie=p&&ee!==!0,ne=q||Y||ie;return Ire({deleteKeyCode:u,multiSelectionKeyCode:k}),s.jsx(Ore,{onPaneContextMenu:i,elementsSelectable:j,zoomOnScroll:N,zoomOnPinch:S,panOnScroll:Z,panOnScrollSpeed:D,panOnScrollMode:T,zoomOnDoubleClick:R,panOnDrag:!q&&ee,defaultViewport:F,translateExtent:_,minZoom:V,maxZoom:U,zoomActivationKeyCode:b,preventScrolling:I,noWheelClassName:B,noPanClassName:W,onViewportChange:H,isControlledViewport:L,paneClickDistance:l,selectionOnDrag:ie,children:s.jsxs(Ure,{onSelectionStart:g,onSelectionEnd:y,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:ee,autoPanOnSelection:P,isSelecting:!!ne,selectionMode:h,selectionKeyPressed:q,paneClickDistance:l,selectionOnDrag:ie,children:[e,z&&s.jsx(ese,{onSelectionContextMenu:M,noPanClassName:W,disableKeyboardA11y:O})]})})}PD.displayName="FlowRenderer";const nse=m.memo(PD),rse=e=>t=>e?I0(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function sse(e){return Pt(m.useCallback(rse(e),[e]),on)}const ose=e=>e.updateNodeInternals;function ise(){const e=Pt(ose),[t]=m.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:o.target,force:!0})}),e(r)}));return m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function ase({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=an(),i=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),u=m.useRef(e.targetPosition),f=m.useRef(t),p=n&&!!e.internals.handleBounds;return m.useEffect(()=>{i.current&&!e.hidden&&(!p||a.current!==i.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(i.current),a.current=i.current)},[p,e.hidden]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(i.current){const h=f.current!==t,g=l.current!==e.sourcePosition,y=u.current!==e.targetPosition;(h||g||y)&&(f.current=t,l.current=e.sourcePosition,u.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function lse({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:a,nodesDraggable:l,elementsSelectable:u,nodesConnectable:f,nodesFocusable:p,resizeObserver:h,noDragClassName:g,noPanClassName:y,disableKeyboardA11y:k,rfId:v,nodeTypes:b,nodeClickDistance:j,onError:N}){const{node:S,internals:C,isParent:D}=Pt(ne=>{const ue=ne.nodeLookup.get(e),ge=ne.parentLookup.has(e);return{node:ue,internals:ue.internals,isParent:ge}},on);let T=S.type||"default",R=(b==null?void 0:b[T])||dE[T];R===void 0&&(N==null||N("003",Cs.error003(T)),T="default",R=(b==null?void 0:b.default)||dE.default);const $=!!(S.draggable||l&&typeof S.draggable>"u"),P=!!(S.selectable||u&&typeof S.selectable>"u"),F=!!(S.connectable||f&&typeof S.connectable>"u"),_=!!(S.focusable||p&&typeof S.focusable>"u"),V=an(),U=J3(S),I=ase({node:S,nodeType:T,hasDimensions:U,resizeObserver:h}),M=TD({nodeRef:I,disabled:S.hidden||!$,noDragClassName:g,handleSelector:S.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:j}),B=RD();if(S.hidden)return null;const W=Do(S),O=Jre(S),H=P||$||t||n||r||o,L=n?ne=>n(ne,{...C.userNode}):void 0,z=r?ne=>r(ne,{...C.userNode}):void 0,Y=o?ne=>o(ne,{...C.userNode}):void 0,q=i?ne=>i(ne,{...C.userNode}):void 0,Q=a?ne=>a(ne,{...C.userNode}):void 0,ee=ne=>{const{selectNodesOnDrag:ue,nodeDragThreshold:ge}=V.getState();P&&(!ue||!$||ge>0)&&_v({id:e,store:V,nodeRef:I}),t&&t(ne,{...C.userNode})},Z=ne=>{if(!(tD(ne.nativeEvent)||k)){if(H3.includes(ne.key)&&P){const ue=ne.key==="Escape";_v({id:e,store:V,unselect:ue,nodeRef:I})}else if($&&S.selected&&Object.prototype.hasOwnProperty.call(Vh,ne.key)){ne.preventDefault();const{ariaLabelConfig:ue}=V.getState();V.setState({ariaLiveMessage:ue["node.a11yDescription.ariaLiveMessage"]({direction:ne.key.replace("Arrow","").toLowerCase(),x:~~C.positionAbsolute.x,y:~~C.positionAbsolute.y})}),B({direction:Vh[ne.key],factor:ne.shiftKey?4:1})}}},ie=()=>{var Ue;if(k||!((Ue=I.current)!=null&&Ue.matches(":focus-visible")))return;const{transform:ne,width:ue,height:ge,autoPanOnNodeFocus:Ne,setCenter:Ce}=V.getState();if(!Ne)return;I0(new Map([[e,S]]),{x:0,y:0,width:ue,height:ge},ne,!0).length>0||Ce(S.position.x+W.width/2,S.position.y+W.height/2,{zoom:ne[2]})};return s.jsx("div",{className:En(["react-flow__node",`react-flow__node-${T}`,{[y]:$},S.className,{selected:S.selected,selectable:P,parent:D,draggable:$,dragging:M}]),ref:I,style:{zIndex:C.z,transform:`translate(${C.positionAbsolute.x}px,${C.positionAbsolute.y}px)`,pointerEvents:H?"all":"none",visibility:U?"visible":"hidden",...S.style,...O},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:L,onMouseMove:z,onMouseLeave:Y,onContextMenu:q,onClick:ee,onDoubleClick:Q,onKeyDown:_?Z:void 0,tabIndex:_?0:void 0,onFocus:_?ie:void 0,role:S.ariaRole??(_?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${vD}-${v}`,"aria-label":S.ariaLabel,...S.domAttributes,children:s.jsx(Vre,{value:e,children:s.jsx(R,{id:e,data:S.data,type:T,positionAbsoluteX:C.positionAbsolute.x,positionAbsoluteY:C.positionAbsolute.y,selected:S.selected??!1,selectable:P,draggable:$,deletable:S.deletable??!0,isConnectable:F,sourcePosition:S.sourcePosition,targetPosition:S.targetPosition,dragging:M,dragHandle:S.dragHandle,zIndex:C.z,parentId:S.parentId,...W})})})}var cse=m.memo(lse);const use=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function _D(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,onError:i}=Pt(use,on),a=sse(e.onlyRenderVisibleElements),l=ise();return s.jsx("div",{className:"react-flow__nodes",style:ug,children:a.map(u=>s.jsx(cse,{id:u,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:i},u))})}_D.displayName="NodeRenderer";const dse=m.memo(_D);function fse(e){return Pt(m.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),a=n.nodeLookup.get(o.target);i&&a&&cne({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),on)}const pse=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return s.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},hse=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return s.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},pE={[wd.Arrow]:pse,[wd.ArrowClosed]:hse};function mse(e){const t=an();return m.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(pE,e)?pE[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",Cs.error009(e)),null)},[e])}const gse=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const u=mse(t);return u?s.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:s.jsx(u,{color:n,strokeWidth:a})}):null},DD=({defaultColor:e,rfId:t})=>{const n=Pt(i=>i.edges),r=Pt(i=>i.defaultEdgeOptions),o=m.useMemo(()=>xne(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?s.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:s.jsx("defs",{children:o.map(i=>s.jsx(gse,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};DD.displayName="MarkerDefinitions";var xse=m.memo(DD);function $D({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:u,className:f,...p}){const[h,g]=m.useState({x:1,y:0,width:0,height:0}),y=En(["react-flow__edge-textwrapper",f]),k=m.useRef(null);return m.useEffect(()=>{if(k.current){const v=k.current.getBBox();g({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?s.jsxs("g",{transform:`translate(${e-h.width/2} ${t-h.height/2})`,className:y,visibility:h.width?"visible":"hidden",...p,children:[o&&s.jsx("rect",{width:h.width+2*a[0],x:-a[0],y:-a[1],height:h.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),s.jsx("text",{className:"react-flow__edge-text",y:h.height/2,dy:"0.3em",ref:k,style:r,children:n}),u]}):null}$D.displayName="EdgeText";const yse=m.memo($D);function dg({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:u,interactionWidth:f=20,...p}){return s.jsxs(s.Fragment,{children:[s.jsx("path",{...p,d:e,fill:"none",className:En(["react-flow__edge-path",p.className])}),f?s.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,r&&gs(t)&&gs(n)?s.jsx(yse,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:u}):null]})}function hE({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===ct.Left||e===ct.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function ID({sourceX:e,sourceY:t,sourcePosition:n=ct.Bottom,targetX:r,targetY:o,targetPosition:i=ct.Top}){const[a,l]=hE({pos:n,x1:e,y1:t,x2:r,y2:o}),[u,f]=hE({pos:i,x1:r,y1:o,x2:e,y2:t}),[p,h,g,y]=rD({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:l,targetControlX:u,targetControlY:f});return[`M${e},${t} C${a},${l} ${u},${f} ${r},${o}`,p,h,g,y]}function LD(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:a,targetPosition:l,label:u,labelStyle:f,labelShowBg:p,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:y,style:k,markerEnd:v,markerStart:b,interactionWidth:j})=>{const[N,S,C]=ID({sourceX:n,sourceY:r,sourcePosition:a,targetX:o,targetY:i,targetPosition:l}),D=e.isInternal?void 0:t;return s.jsx(dg,{id:D,path:N,labelX:S,labelY:C,label:u,labelStyle:f,labelShowBg:p,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:y,style:k,markerEnd:v,markerStart:b,interactionWidth:j})})}const bse=LD({isInternal:!1}),MD=LD({isInternal:!0});bse.displayName="SimpleBezierEdge";MD.displayName="SimpleBezierEdgeInternal";function OD(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:a,labelStyle:l,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,sourcePosition:y=ct.Bottom,targetPosition:k=ct.Top,markerEnd:v,markerStart:b,pathOptions:j,interactionWidth:N})=>{const[S,C,D]=Tv({sourceX:n,sourceY:r,sourcePosition:y,targetX:o,targetY:i,targetPosition:k,borderRadius:j==null?void 0:j.borderRadius,offset:j==null?void 0:j.offset,stepPosition:j==null?void 0:j.stepPosition}),T=e.isInternal?void 0:t;return s.jsx(dg,{id:T,path:S,labelX:C,labelY:D,label:a,labelStyle:l,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:v,markerStart:b,interactionWidth:N})})}const FD=OD({isInternal:!1}),zD=OD({isInternal:!0});FD.displayName="SmoothStepEdge";zD.displayName="SmoothStepEdgeInternal";function BD(e){return m.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return s.jsx(FD,{...n,id:r,pathOptions:m.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const vse=BD({isInternal:!1}),UD=BD({isInternal:!0});vse.displayName="StepEdge";UD.displayName="StepEdgeInternal";function HD(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:a,labelStyle:l,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:k,interactionWidth:v})=>{const[b,j,N]=iD({sourceX:n,sourceY:r,targetX:o,targetY:i}),S=e.isInternal?void 0:t;return s.jsx(dg,{id:S,path:b,labelX:j,labelY:N,label:a,labelStyle:l,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:y,markerStart:k,interactionWidth:v})})}const wse=HD({isInternal:!1}),VD=HD({isInternal:!0});wse.displayName="StraightEdge";VD.displayName="StraightEdgeInternal";function WD(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:a=ct.Bottom,targetPosition:l=ct.Top,label:u,labelStyle:f,labelShowBg:p,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:y,style:k,markerEnd:v,markerStart:b,pathOptions:j,interactionWidth:N})=>{const[S,C,D]=sD({sourceX:n,sourceY:r,sourcePosition:a,targetX:o,targetY:i,targetPosition:l,curvature:j==null?void 0:j.curvature}),T=e.isInternal?void 0:t;return s.jsx(dg,{id:T,path:S,labelX:C,labelY:D,label:u,labelStyle:f,labelShowBg:p,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:y,style:k,markerEnd:v,markerStart:b,interactionWidth:N})})}const jse=WD({isInternal:!1}),qD=WD({isInternal:!0});jse.displayName="BezierEdge";qD.displayName="BezierEdgeInternal";const mE={default:qD,straight:VD,step:UD,smoothstep:zD,simplebezier:MD},gE={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},kse=(e,t,n)=>n===ct.Left?e-t:n===ct.Right?e+t:e,Sse=(e,t,n)=>n===ct.Top?e-t:n===ct.Bottom?e+t:e,xE="react-flow__edgeupdater";function yE({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:a,type:l}){return s.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:a,className:En([xE,`${xE}-${l}`]),cx:kse(t,r,e),cy:Sse(n,r,e),r,stroke:"transparent",fill:"transparent"})}function Nse({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:a,sourcePosition:l,targetPosition:u,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,setReconnecting:g,setUpdateHover:y}){const k=an(),v=(C,D)=>{if(C.button!==0)return;const{autoPanOnConnect:T,domNode:R,connectionMode:$,connectionRadius:P,lib:F,onConnectStart:_,cancelConnection:V,nodeLookup:U,rfId:I,panBy:M,updateConnection:B}=k.getState(),W=D.type==="target",O=(z,Y)=>{g(!1),h==null||h(z,n,D.type,Y)},H=z=>f==null?void 0:f(n,z),L=(z,Y)=>{g(!0),p==null||p(C,n,D.type),_==null||_(z,Y)};Pv.onPointerDown(C.nativeEvent,{autoPanOnConnect:T,connectionMode:$,connectionRadius:P,domNode:R,handleId:D.id,nodeId:D.nodeId,nodeLookup:U,isTarget:W,edgeUpdaterType:D.type,lib:F,flowId:I,cancelConnection:V,panBy:M,isValidConnection:(...z)=>{var Y,q;return((q=(Y=k.getState()).isValidConnection)==null?void 0:q.call(Y,...z))??!0},onConnect:H,onConnectStart:L,onConnectEnd:(...z)=>{var Y,q;return(q=(Y=k.getState()).onConnectEnd)==null?void 0:q.call(Y,...z)},onReconnectEnd:O,updateConnection:B,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:C.currentTarget})},b=C=>v(C,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),j=C=>v(C,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),N=()=>y(!0),S=()=>y(!1);return s.jsxs(s.Fragment,{children:[(e===!0||e==="source")&&s.jsx(yE,{position:l,centerX:r,centerY:o,radius:t,onMouseDown:b,onMouseEnter:N,onMouseOut:S,type:"source"}),(e===!0||e==="target")&&s.jsx(yE,{position:u,centerX:i,centerY:a,radius:t,onMouseDown:j,onMouseEnter:N,onMouseOut:S,type:"target"})]})}function Cse({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:a,onMouseEnter:l,onMouseMove:u,onMouseLeave:f,reconnectRadius:p,onReconnect:h,onReconnectStart:g,onReconnectEnd:y,rfId:k,edgeTypes:v,noPanClassName:b,onError:j,disableKeyboardA11y:N}){let S=Pt(Ce=>Ce.edgeLookup.get(e));const C=Pt(Ce=>Ce.defaultEdgeOptions);S=C?{...C,...S}:S;let D=S.type||"default",T=(v==null?void 0:v[D])||mE[D];T===void 0&&(j==null||j("011",Cs.error011(D)),D="default",T=(v==null?void 0:v.default)||mE.default);const R=!!(S.focusable||t&&typeof S.focusable>"u"),$=typeof h<"u"&&(S.reconnectable||n&&typeof S.reconnectable>"u"),P=!!(S.selectable||r&&typeof S.selectable>"u"),F=m.useRef(null),[_,V]=m.useState(!1),[U,I]=m.useState(!1),M=an(),{zIndex:B,sourceX:W,sourceY:O,targetX:H,targetY:L,sourcePosition:z,targetPosition:Y}=Pt(m.useCallback(Ce=>{const ke=Ce.nodeLookup.get(S.source),Ue=Ce.nodeLookup.get(S.target);if(!ke||!Ue)return{zIndex:S.zIndex,...gE};const oe=gne({id:e,sourceNode:ke,targetNode:Ue,sourceHandle:S.sourceHandle||null,targetHandle:S.targetHandle||null,connectionMode:Ce.connectionMode,onError:j});return{zIndex:lne({selected:S.selected,zIndex:S.zIndex,sourceNode:ke,targetNode:Ue,elevateOnSelect:Ce.elevateEdgesOnSelect,zIndexMode:Ce.zIndexMode}),...oe||gE}},[S.source,S.target,S.sourceHandle,S.targetHandle,S.selected,S.zIndex]),on),q=m.useMemo(()=>S.markerStart?`url('#${Rv(S.markerStart,k)}')`:void 0,[S.markerStart,k]),Q=m.useMemo(()=>S.markerEnd?`url('#${Rv(S.markerEnd,k)}')`:void 0,[S.markerEnd,k]);if(S.hidden||W===null||O===null||H===null||L===null)return null;const ee=Ce=>{var ve;const{addSelectedEdges:ke,unselectNodesAndEdges:Ue,multiSelectionActive:oe}=M.getState();P&&(M.setState({nodesSelectionActive:!1}),S.selected&&oe?(Ue({nodes:[],edges:[S]}),(ve=F.current)==null||ve.blur()):ke([e])),o&&o(Ce,S)},Z=i?Ce=>{i(Ce,{...S})}:void 0,ie=a?Ce=>{a(Ce,{...S})}:void 0,ne=l?Ce=>{l(Ce,{...S})}:void 0,ue=u?Ce=>{u(Ce,{...S})}:void 0,ge=f?Ce=>{f(Ce,{...S})}:void 0,Ne=Ce=>{var ke;if(!N&&H3.includes(Ce.key)&&P){const{unselectNodesAndEdges:Ue,addSelectedEdges:oe}=M.getState();Ce.key==="Escape"?((ke=F.current)==null||ke.blur(),Ue({edges:[S]})):oe([e])}};return s.jsx("svg",{style:{zIndex:B},children:s.jsxs("g",{className:En(["react-flow__edge",`react-flow__edge-${D}`,S.className,b,{selected:S.selected,animated:S.animated,inactive:!P&&!o,updating:_,selectable:P}]),onClick:ee,onDoubleClick:Z,onContextMenu:ie,onMouseEnter:ne,onMouseMove:ue,onMouseLeave:ge,onKeyDown:R?Ne:void 0,tabIndex:R?0:void 0,role:S.ariaRole??(R?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":S.ariaLabel===null?void 0:S.ariaLabel||`Edge from ${S.source} to ${S.target}`,"aria-describedby":R?`${wD}-${k}`:void 0,ref:F,...S.domAttributes,children:[!U&&s.jsx(T,{id:e,source:S.source,target:S.target,type:S.type,selected:S.selected,animated:S.animated,selectable:P,deletable:S.deletable??!0,label:S.label,labelStyle:S.labelStyle,labelShowBg:S.labelShowBg,labelBgStyle:S.labelBgStyle,labelBgPadding:S.labelBgPadding,labelBgBorderRadius:S.labelBgBorderRadius,sourceX:W,sourceY:O,targetX:H,targetY:L,sourcePosition:z,targetPosition:Y,data:S.data,style:S.style,sourceHandleId:S.sourceHandle,targetHandleId:S.targetHandle,markerStart:q,markerEnd:Q,pathOptions:"pathOptions"in S?S.pathOptions:void 0,interactionWidth:S.interactionWidth}),$&&s.jsx(Nse,{edge:S,isReconnectable:$,reconnectRadius:p,onReconnect:h,onReconnectStart:g,onReconnectEnd:y,sourceX:W,sourceY:O,targetX:H,targetY:L,sourcePosition:z,targetPosition:Y,setUpdateHover:V,setReconnecting:I})]})})}var Ese=m.memo(Cse);const Tse=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function KD({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:u,onEdgeMouseLeave:f,onEdgeClick:p,reconnectRadius:h,onEdgeDoubleClick:g,onReconnectStart:y,onReconnectEnd:k,disableKeyboardA11y:v}){const{edgesFocusable:b,edgesReconnectable:j,elementsSelectable:N,onError:S}=Pt(Tse,on),C=fse(t);return s.jsxs("div",{className:"react-flow__edges",children:[s.jsx(xse,{defaultColor:e,rfId:n}),C.map(D=>s.jsx(Ese,{id:D,edgesFocusable:b,edgesReconnectable:j,elementsSelectable:N,noPanClassName:o,onReconnect:i,onContextMenu:a,onMouseEnter:l,onMouseMove:u,onMouseLeave:f,onClick:p,reconnectRadius:h,onDoubleClick:g,onReconnectStart:y,onReconnectEnd:k,rfId:n,onError:S,edgeTypes:r,disableKeyboardA11y:v},D))]})}KD.displayName="EdgeRenderer";const Rse=m.memo(KD),Ase=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Pse({children:e}){const t=Pt(Ase);return s.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function _se(e){const t=cg(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Dse=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function $se(e){const t=Pt(Dse),n=an();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Ise(e){return e.connection.inProgress?{...e.connection,to:_c(e.connection.to,e.transform)}:{...e.connection}}function Lse(e){return Ise}function Mse(e){const t=Lse();return Pt(t,on)}const Ose=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Fse({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:a,isValid:l,inProgress:u}=Pt(Ose,on);return!(i&&o&&u)?null:s.jsx("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:s.jsx("g",{className:En(["react-flow__connection",q3(l)]),children:s.jsx(GD,{style:t,type:n,CustomComponent:r,isValid:l})})})}const GD=({style:e,type:t=xi.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:a,fromHandle:l,fromPosition:u,to:f,toNode:p,toHandle:h,toPosition:g,pointer:y}=Mse();if(!o)return;if(n)return s.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:i.x,fromY:i.y,toX:f.x,toY:f.y,fromPosition:u,toPosition:g,connectionStatus:q3(r),toNode:p,toHandle:h,pointer:y});let k="";const v={sourceX:i.x,sourceY:i.y,sourcePosition:u,targetX:f.x,targetY:f.y,targetPosition:g};switch(t){case xi.Bezier:[k]=sD(v);break;case xi.SimpleBezier:[k]=ID(v);break;case xi.Step:[k]=Tv({...v,borderRadius:0});break;case xi.SmoothStep:[k]=Tv(v);break;default:[k]=iD(v)}return s.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:e})};GD.displayName="ConnectionLine";const zse={};function bE(e=zse){m.useRef(e),an(),m.useEffect(()=>{},[e])}function Bse(){an(),m.useRef(!1),m.useEffect(()=>{},[])}function YD({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:u,onNodeMouseLeave:f,onNodeContextMenu:p,onSelectionContextMenu:h,onSelectionStart:g,onSelectionEnd:y,connectionLineType:k,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:j,selectionKeyCode:N,selectionOnDrag:S,selectionMode:C,multiSelectionKeyCode:D,panActivationKeyCode:T,zoomActivationKeyCode:R,deleteKeyCode:$,onlyRenderVisibleElements:P,elementsSelectable:F,defaultViewport:_,translateExtent:V,minZoom:U,maxZoom:I,preventScrolling:M,defaultMarkerColor:B,zoomOnScroll:W,zoomOnPinch:O,panOnScroll:H,panOnScrollSpeed:L,panOnScrollMode:z,zoomOnDoubleClick:Y,panOnDrag:q,autoPanOnSelection:Q,onPaneClick:ee,onPaneMouseEnter:Z,onPaneMouseMove:ie,onPaneMouseLeave:ne,onPaneScroll:ue,onPaneContextMenu:ge,paneClickDistance:Ne,nodeClickDistance:Ce,onEdgeContextMenu:ke,onEdgeMouseEnter:Ue,onEdgeMouseMove:oe,onEdgeMouseLeave:ve,reconnectRadius:be,onReconnect:Re,onReconnectStart:He,onReconnectEnd:rt,noDragClassName:Fe,noWheelClassName:ot,noPanClassName:Nt,disableKeyboardA11y:mt,nodeExtent:at,rfId:ce,viewport:me,onViewportChange:Ie}){return bE(e),bE(t),Bse(),_se(n),$se(me),s.jsx(nse,{onPaneClick:ee,onPaneMouseEnter:Z,onPaneMouseMove:ie,onPaneMouseLeave:ne,onPaneContextMenu:ge,onPaneScroll:ue,paneClickDistance:Ne,deleteKeyCode:$,selectionKeyCode:N,selectionOnDrag:S,selectionMode:C,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:D,panActivationKeyCode:T,zoomActivationKeyCode:R,elementsSelectable:F,zoomOnScroll:W,zoomOnPinch:O,zoomOnDoubleClick:Y,panOnScroll:H,panOnScrollSpeed:L,panOnScrollMode:z,panOnDrag:q,autoPanOnSelection:Q,defaultViewport:_,translateExtent:V,minZoom:U,maxZoom:I,onSelectionContextMenu:h,preventScrolling:M,noDragClassName:Fe,noWheelClassName:ot,noPanClassName:Nt,disableKeyboardA11y:mt,onViewportChange:Ie,isControlledViewport:!!me,children:s.jsxs(Pse,{children:[s.jsx(Rse,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:a,onReconnect:Re,onReconnectStart:He,onReconnectEnd:rt,onlyRenderVisibleElements:P,onEdgeContextMenu:ke,onEdgeMouseEnter:Ue,onEdgeMouseMove:oe,onEdgeMouseLeave:ve,reconnectRadius:be,defaultMarkerColor:B,noPanClassName:Nt,disableKeyboardA11y:mt,rfId:ce}),s.jsx(Fse,{style:v,type:k,component:b,containerStyle:j}),s.jsx("div",{className:"react-flow__edgelabel-renderer"}),s.jsx(dse,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:u,onNodeMouseLeave:f,onNodeContextMenu:p,nodeClickDistance:Ce,onlyRenderVisibleElements:P,noPanClassName:Nt,noDragClassName:Fe,disableKeyboardA11y:mt,nodeExtent:at,rfId:ce}),s.jsx("div",{className:"react-flow__viewport-portal"})]})})}YD.displayName="GraphView";const Use=m.memo(YD),Hse=Q3(),vE=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:a,fitViewOptions:l,minZoom:u=.5,maxZoom:f=2,nodeOrigin:p,nodeExtent:h,zIndexMode:g="basic"}={})=>{const y=new Map,k=new Map,v=new Map,b=new Map,j=r??t??[],N=n??e??[],S=p??[0,0],C=h??bd;cD(v,b,j);const{nodesInitialized:D}=Av(N,y,k,{nodeOrigin:S,nodeExtent:C,zIndexMode:g});let T=[0,0,1];if(a&&o&&i){const R=Jd(y,{filter:_=>!!((_.width||_.initialWidth)&&(_.height||_.initialHeight))}),{x:$,y:P,zoom:F}=M0(R,o,i,u,f,(l==null?void 0:l.padding)??.1);T=[$,P,F]}return{rfId:"1",width:o??0,height:i??0,transform:T,nodes:N,nodesInitialized:D,nodeLookup:y,parentLookup:k,edges:j,edgeLookup:b,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:u,maxZoom:f,translateExtent:bd,nodeExtent:C,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ic.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:S,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:l,fitViewResolver:null,connection:{...W3},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Hse,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:V3,zIndexMode:g,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Vse=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:a,fitViewOptions:l,minZoom:u,maxZoom:f,nodeOrigin:p,nodeExtent:h,zIndexMode:g})=>ore((y,k)=>{async function v(){const{nodeLookup:b,panZoom:j,fitViewOptions:N,fitViewResolver:S,width:C,height:D,minZoom:T,maxZoom:R}=k();j&&(await tne({nodes:b,width:C,height:D,panZoom:j,minZoom:T,maxZoom:R},N),S==null||S.resolve(!0),y({fitViewResolver:null}))}return{...vE({nodes:e,edges:t,width:o,height:i,fitView:a,fitViewOptions:l,minZoom:u,maxZoom:f,nodeOrigin:p,nodeExtent:h,defaultNodes:n,defaultEdges:r,zIndexMode:g}),setNodes:b=>{const{nodeLookup:j,parentLookup:N,nodeOrigin:S,elevateNodesOnSelect:C,fitViewQueued:D,zIndexMode:T,nodesSelectionActive:R}=k(),{nodesInitialized:$,hasSelectedNodes:P}=Av(b,j,N,{nodeOrigin:S,nodeExtent:h,elevateNodesOnSelect:C,checkEquality:!0,zIndexMode:T}),F=R&&P;D&&$?(v(),y({nodes:b,nodesInitialized:$,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:F})):y({nodes:b,nodesInitialized:$,nodesSelectionActive:F})},setEdges:b=>{const{connectionLookup:j,edgeLookup:N}=k();cD(j,N,b),y({edges:b})},setDefaultNodesAndEdges:(b,j)=>{if(b){const{setNodes:N}=k();N(b),y({hasDefaultNodes:!0})}if(j){const{setEdges:N}=k();N(j),y({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:j,nodeLookup:N,parentLookup:S,domNode:C,nodeOrigin:D,nodeExtent:T,debug:R,fitViewQueued:$,zIndexMode:P}=k(),{changes:F,updatedInternals:_}=Sne(b,N,S,C,D,T,P);_&&(vne(N,S,{nodeOrigin:D,nodeExtent:T,zIndexMode:P}),$?(v(),y({fitViewQueued:!1,fitViewOptions:void 0})):y({}),(F==null?void 0:F.length)>0&&(R&&console.log("React Flow: trigger node changes",F),j==null||j(F)))},updateNodePositions:(b,j=!1)=>{const N=[];let S=[];const{nodeLookup:C,triggerNodeChanges:D,connection:T,updateConnection:R,onNodesChangeMiddlewareMap:$}=k();for(const[P,F]of b){const _=C.get(P),V=!!(_!=null&&_.expandParent&&(_!=null&&_.parentId)&&(F!=null&&F.position)),U={id:P,type:"position",position:V?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:j};if(_&&T.inProgress&&T.fromNode.id===_.id){const I=Ca(_,T.fromHandle,ct.Left,!0);R({...T,from:I})}V&&_.parentId&&N.push({id:P,parentId:_.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),S.push(U)}if(N.length>0){const{parentLookup:P,nodeOrigin:F}=k(),_=H0(N,C,P,F);S.push(..._)}for(const P of $.values())S=P(S);D(S)},triggerNodeChanges:b=>{const{onNodesChange:j,setNodes:N,nodes:S,hasDefaultNodes:C,debug:D}=k();if(b!=null&&b.length){if(C){const T=SD(b,S);N(T)}D&&console.log("React Flow: trigger node changes",b),j==null||j(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:j,setEdges:N,edges:S,hasDefaultEdges:C,debug:D}=k();if(b!=null&&b.length){if(C){const T=ND(b,S);N(T)}D&&console.log("React Flow: trigger edge changes",b),j==null||j(b)}},addSelectedNodes:b=>{const{multiSelectionActive:j,edgeLookup:N,nodeLookup:S,triggerNodeChanges:C,triggerEdgeChanges:D}=k();if(j){const T=b.map(R=>ra(R,!0));C(T);return}C($l(S,new Set([...b]),!0)),D($l(N))},addSelectedEdges:b=>{const{multiSelectionActive:j,edgeLookup:N,nodeLookup:S,triggerNodeChanges:C,triggerEdgeChanges:D}=k();if(j){const T=b.map(R=>ra(R,!0));D(T);return}D($l(N,new Set([...b]))),C($l(S,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:j}={})=>{const{edges:N,nodes:S,nodeLookup:C,triggerNodeChanges:D,triggerEdgeChanges:T}=k(),R=b||S,$=j||N,P=[];for(const _ of R){if(!_.selected)continue;const V=C.get(_.id);V&&(V.selected=!1),P.push(ra(_.id,!1))}const F=[];for(const _ of $)_.selected&&F.push(ra(_.id,!1));D(P),T(F)},setMinZoom:b=>{const{panZoom:j,maxZoom:N}=k();j==null||j.setScaleExtent([b,N]),y({minZoom:b})},setMaxZoom:b=>{const{panZoom:j,minZoom:N}=k();j==null||j.setScaleExtent([N,b]),y({maxZoom:b})},setTranslateExtent:b=>{var j;(j=k().panZoom)==null||j.setTranslateExtent(b),y({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:j,triggerNodeChanges:N,triggerEdgeChanges:S,elementsSelectable:C}=k();if(!C)return;const D=j.reduce((R,$)=>$.selected?[...R,ra($.id,!1)]:R,[]),T=b.reduce((R,$)=>$.selected?[...R,ra($.id,!1)]:R,[]);N(D),S(T)},setNodeExtent:b=>{const{nodes:j,nodeLookup:N,parentLookup:S,nodeOrigin:C,elevateNodesOnSelect:D,nodeExtent:T,zIndexMode:R}=k();b[0][0]===T[0][0]&&b[0][1]===T[0][1]&&b[1][0]===T[1][0]&&b[1][1]===T[1][1]||(Av(j,N,S,{nodeOrigin:C,nodeExtent:b,elevateNodesOnSelect:D,checkEquality:!1,zIndexMode:R}),y({nodeExtent:b}))},panBy:b=>{const{transform:j,width:N,height:S,panZoom:C,translateExtent:D}=k();return Nne({delta:b,panZoom:C,transform:j,translateExtent:D,width:N,height:S})},setCenter:async(b,j,N)=>{const{width:S,height:C,maxZoom:D,panZoom:T}=k();if(!T)return!1;const R=typeof(N==null?void 0:N.zoom)<"u"?N.zoom:D;return await T.setViewport({x:S/2-b*R,y:C/2-j*R,zoom:R},{duration:N==null?void 0:N.duration,ease:N==null?void 0:N.ease,interpolate:N==null?void 0:N.interpolate}),!0},cancelConnection:()=>{y({connection:{...W3}})},updateConnection:b=>{y({connection:b})},reset:()=>y({...vE()})}},Object.is);function Wse({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:u,fitView:f,nodeOrigin:p,nodeExtent:h,zIndexMode:g,children:y}){const[k]=m.useState(()=>Vse({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:f,minZoom:a,maxZoom:l,fitViewOptions:u,nodeOrigin:p,nodeExtent:h,zIndexMode:g}));return s.jsx(ire,{value:k,children:s.jsx(Pre,{children:y})})}function qse({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:a,fitView:l,fitViewOptions:u,minZoom:f,maxZoom:p,nodeOrigin:h,nodeExtent:g,zIndexMode:y}){return m.useContext(lg)?s.jsx(s.Fragment,{children:e}):s.jsx(Wse,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:a,fitView:l,initialFitViewOptions:u,initialMinZoom:f,initialMaxZoom:p,nodeOrigin:h,nodeExtent:g,zIndexMode:y,children:e})}const Kse={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Gse({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:a,onNodeClick:l,onEdgeClick:u,onInit:f,onMove:p,onMoveStart:h,onMoveEnd:g,onConnect:y,onConnectStart:k,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:j,onNodeMouseEnter:N,onNodeMouseMove:S,onNodeMouseLeave:C,onNodeContextMenu:D,onNodeDoubleClick:T,onNodeDragStart:R,onNodeDrag:$,onNodeDragStop:P,onNodesDelete:F,onEdgesDelete:_,onDelete:V,onSelectionChange:U,onSelectionDragStart:I,onSelectionDrag:M,onSelectionDragStop:B,onSelectionContextMenu:W,onSelectionStart:O,onSelectionEnd:H,onBeforeDelete:L,connectionMode:z,connectionLineType:Y=xi.Bezier,connectionLineStyle:q,connectionLineComponent:Q,connectionLineContainerStyle:ee,deleteKeyCode:Z="Backspace",selectionKeyCode:ie="Shift",selectionOnDrag:ne=!1,selectionMode:ue=vd.Full,panActivationKeyCode:ge="Space",multiSelectionKeyCode:Ne=kd()?"Meta":"Control",zoomActivationKeyCode:Ce=kd()?"Meta":"Control",snapToGrid:ke,snapGrid:Ue,onlyRenderVisibleElements:oe=!1,selectNodesOnDrag:ve,nodesDraggable:be,autoPanOnNodeFocus:Re,nodesConnectable:He,nodesFocusable:rt,nodeOrigin:Fe=jD,edgesFocusable:ot,edgesReconnectable:Nt,elementsSelectable:mt=!0,defaultViewport:at=bre,minZoom:ce=.5,maxZoom:me=2,translateExtent:Ie=bd,preventScrolling:Ae=!0,nodeExtent:We,defaultMarkerColor:pt="#b1b1b7",zoomOnScroll:Pe=!0,zoomOnPinch:Qe=!0,panOnScroll:Je=!1,panOnScrollSpeed:ut=.5,panOnScrollMode:fe=ya.Free,zoomOnDoubleClick:K=!0,panOnDrag:re=!0,onPaneClick:xe,onPaneMouseEnter:Ge,onPaneMouseMove:ze,onPaneMouseLeave:lt,onPaneScroll:ht,onPaneContextMenu:vt,paneClickDistance:tt=1,nodeClickDistance:_t=0,children:zt,onReconnect:Bt,onReconnectStart:we,onReconnectEnd:Oe,onEdgeContextMenu:it,onEdgeDoubleClick:Et,onEdgeMouseEnter:ln,onEdgeMouseMove:Ut,onEdgeMouseLeave:le,reconnectRadius:Se=10,onNodesChange:nt,onEdgesChange:Tn,noDragClassName:Er="nodrag",noWheelClassName:so="nowheel",noPanClassName:wt="nopan",fitView:_i,fitViewOptions:$o,connectOnClick:$a,attributionPosition:nn,proOptions:Io,defaultEdgeOptions:Ia,elevateNodesOnSelect:La=!0,elevateEdgesOnSelect:$c=!1,disableKeyboardA11y:Ma=!1,autoPanOnConnect:Ht,autoPanOnNodeDrag:Di,autoPanOnSelection:oo=!0,autoPanSpeed:Lo,connectionRadius:Ds,isValidConnection:Mo,onError:Oa,style:Oo,id:ir,nodeDragThreshold:dr,connectionDragThreshold:On,viewport:Fo,onViewportChange:Ic,width:Lc,height:zo,colorMode:Wn="light",debug:io,onScroll:qr,ariaLabelConfig:Fa,zIndexMode:$i="basic",...Bo},Uo){const $s=ir||"1",Fn=kre(Wn),Rn=m.useCallback(Is=>{Is.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),qr==null||qr(Is)},[qr]);return s.jsx("div",{"data-testid":"rf__wrapper",...Bo,onScroll:Rn,style:{...Oo,...Kse},ref:Uo,className:En(["react-flow",o,Fn]),id:ir,role:"application",children:s.jsxs(qse,{nodes:e,edges:t,width:Lc,height:zo,fitView:_i,fitViewOptions:$o,minZoom:ce,maxZoom:me,nodeOrigin:Fe,nodeExtent:We,zIndexMode:$i,children:[s.jsx(jre,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:y,onConnectStart:k,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:j,nodesDraggable:be,autoPanOnNodeFocus:Re,nodesConnectable:He,nodesFocusable:rt,edgesFocusable:ot,edgesReconnectable:Nt,elementsSelectable:mt,elevateNodesOnSelect:La,elevateEdgesOnSelect:$c,minZoom:ce,maxZoom:me,nodeExtent:We,onNodesChange:nt,onEdgesChange:Tn,snapToGrid:ke,snapGrid:Ue,connectionMode:z,translateExtent:Ie,connectOnClick:$a,defaultEdgeOptions:Ia,fitView:_i,fitViewOptions:$o,onNodesDelete:F,onEdgesDelete:_,onDelete:V,onNodeDragStart:R,onNodeDrag:$,onNodeDragStop:P,onSelectionDrag:M,onSelectionDragStart:I,onSelectionDragStop:B,onMove:p,onMoveStart:h,onMoveEnd:g,noPanClassName:wt,nodeOrigin:Fe,rfId:$s,autoPanOnConnect:Ht,autoPanOnNodeDrag:Di,autoPanSpeed:Lo,onError:Oa,connectionRadius:Ds,isValidConnection:Mo,selectNodesOnDrag:ve,nodeDragThreshold:dr,connectionDragThreshold:On,onBeforeDelete:L,debug:io,ariaLabelConfig:Fa,zIndexMode:$i}),s.jsx(Use,{onInit:f,onNodeClick:l,onEdgeClick:u,onNodeMouseEnter:N,onNodeMouseMove:S,onNodeMouseLeave:C,onNodeContextMenu:D,onNodeDoubleClick:T,nodeTypes:i,edgeTypes:a,connectionLineType:Y,connectionLineStyle:q,connectionLineComponent:Q,connectionLineContainerStyle:ee,selectionKeyCode:ie,selectionOnDrag:ne,selectionMode:ue,deleteKeyCode:Z,multiSelectionKeyCode:Ne,panActivationKeyCode:ge,zoomActivationKeyCode:Ce,onlyRenderVisibleElements:oe,defaultViewport:at,translateExtent:Ie,minZoom:ce,maxZoom:me,preventScrolling:Ae,zoomOnScroll:Pe,zoomOnPinch:Qe,zoomOnDoubleClick:K,panOnScroll:Je,panOnScrollSpeed:ut,panOnScrollMode:fe,panOnDrag:re,autoPanOnSelection:oo,onPaneClick:xe,onPaneMouseEnter:Ge,onPaneMouseMove:ze,onPaneMouseLeave:lt,onPaneScroll:ht,onPaneContextMenu:vt,paneClickDistance:tt,nodeClickDistance:_t,onSelectionContextMenu:W,onSelectionStart:O,onSelectionEnd:H,onReconnect:Bt,onReconnectStart:we,onReconnectEnd:Oe,onEdgeContextMenu:it,onEdgeDoubleClick:Et,onEdgeMouseEnter:ln,onEdgeMouseMove:Ut,onEdgeMouseLeave:le,reconnectRadius:Se,defaultMarkerColor:pt,noDragClassName:Er,noWheelClassName:so,noPanClassName:wt,rfId:$s,disableKeyboardA11y:Ma,nodeExtent:We,viewport:Fo,onViewportChange:Ic}),s.jsx(yre,{onSelectionChange:U}),zt,s.jsx(pre,{proOptions:Io,position:nn}),s.jsx(fre,{rfId:$s,disableKeyboardA11y:Ma})]})})}var Yse=CD(Gse);function Xse(e){const[t,n]=m.useState(e),r=m.useCallback(o=>n(i=>SD(o,i)),[]);return[t,n,r]}function Qse(e){const[t,n]=m.useState(e),r=m.useCallback(o=>n(i=>ND(o,i)),[]);return[t,n,r]}function Jse({dimensions:e,lineWidth:t,variant:n,className:r}){return s.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:En(["react-flow__background-pattern",n,r])})}function Zse({radius:e,className:t}){return s.jsx("circle",{cx:e,cy:e,r:e,className:En(["react-flow__background-pattern","dots",t])})}var vi;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(vi||(vi={}));const eoe={[vi.Dots]:1,[vi.Lines]:1,[vi.Cross]:6},toe=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function XD({id:e,variant:t=vi.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:a,bgColor:l,style:u,className:f,patternClassName:p}){const h=m.useRef(null),{transform:g,patternId:y}=Pt(toe,on),k=r||eoe[t],v=t===vi.Dots,b=t===vi.Cross,j=Array.isArray(n)?n:[n,n],N=[j[0]*g[2]||1,j[1]*g[2]||1],S=k*g[2],C=Array.isArray(i)?i:[i,i],D=b?[S,S]:N,T=[C[0]*g[2]||1+D[0]/2,C[1]*g[2]||1+D[1]/2],R=`${y}${e||""}`;return s.jsxs("svg",{className:En(["react-flow__background",f]),style:{...u,...ug,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:h,"data-testid":"rf__background",children:[s.jsx("pattern",{id:R,x:g[0]%N[0],y:g[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`,children:v?s.jsx(Zse,{radius:S/2,className:p}):s.jsx(Jse,{dimensions:D,lineWidth:o,variant:t,className:p})}),s.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${R})`})]})}XD.displayName="Background";const noe=m.memo(XD);function roe(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:s.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function soe(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:s.jsx("path",{d:"M0 0h32v4.2H0z"})})}function ooe(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:s.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function ioe(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function aoe(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Rp({children:e,className:t,...n}){return s.jsx("button",{type:"button",className:En(["react-flow__controls-button",t]),...n,children:e})}const loe=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function QD({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:a,onFitView:l,onInteractiveChange:u,className:f,children:p,position:h="bottom-left",orientation:g="vertical","aria-label":y}){const k=an(),{isInteractive:v,minZoomReached:b,maxZoomReached:j,ariaLabelConfig:N}=Pt(loe,on),{zoomIn:S,zoomOut:C,fitView:D}=cg(),T=()=>{S(),i==null||i()},R=()=>{C(),a==null||a()},$=()=>{D(o),l==null||l()},P=()=>{k.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),u==null||u(!v)},F=g==="horizontal"?"horizontal":"vertical";return s.jsxs(ef,{className:En(["react-flow__controls",F,f]),position:h,style:e,"data-testid":"rf__controls","aria-label":y??N["controls.ariaLabel"],children:[t&&s.jsxs(s.Fragment,{children:[s.jsx(Rp,{onClick:T,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:j,children:s.jsx(roe,{})}),s.jsx(Rp,{onClick:R,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:b,children:s.jsx(soe,{})})]}),n&&s.jsx(Rp,{className:"react-flow__controls-fitview",onClick:$,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:s.jsx(ooe,{})}),r&&s.jsx(Rp,{className:"react-flow__controls-interactive",onClick:P,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:v?s.jsx(aoe,{}):s.jsx(ioe,{})}),p]})}QD.displayName="Controls";const coe=m.memo(QD);function uoe({id:e,x:t,y:n,width:r,height:o,style:i,color:a,strokeColor:l,strokeWidth:u,className:f,borderRadius:p,shapeRendering:h,selected:g,onClick:y}){const{background:k,backgroundColor:v}=i||{},b=a||k||v;return s.jsx("rect",{className:En(["react-flow__minimap-node",{selected:g},f]),x:t,y:n,rx:p,ry:p,width:r,height:o,style:{fill:b,stroke:l,strokeWidth:u},shapeRendering:h,onClick:y?j=>y(j,e):void 0})}const doe=m.memo(uoe),foe=e=>e.nodes.map(t=>t.id),cb=e=>e instanceof Function?e:()=>e;function poe({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=doe,onClick:a}){const l=Pt(foe,on),u=cb(t),f=cb(e),p=cb(n),h=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return s.jsx(s.Fragment,{children:l.map(g=>s.jsx(moe,{id:g,nodeColorFunc:u,nodeStrokeColorFunc:f,nodeClassNameFunc:p,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:a,shapeRendering:h},g))})}function hoe({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:l,onClick:u}){const{node:f,x:p,y:h,width:g,height:y}=Pt(k=>{const v=k.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const b=v.internals.userNode,{x:j,y:N}=v.internals.positionAbsolute,{width:S,height:C}=Do(b);return{node:b,x:j,y:N,width:S,height:C}},on);return!f||f.hidden||!J3(f)?null:s.jsx(l,{x:p,y:h,width:g,height:y,style:f.style,selected:!!f.selected,className:r(f),color:t(f),borderRadius:o,strokeColor:n(f),strokeWidth:i,shapeRendering:a,onClick:u,id:f.id})}const moe=m.memo(hoe);var goe=m.memo(poe);const xoe=200,yoe=150,boe=e=>!e.hidden,voe=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?X3(Jd(e.nodeLookup,{filter:boe}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},woe="react-flow__minimap-desc";function JD({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:u,maskColor:f,maskStrokeColor:p,maskStrokeWidth:h,position:g="bottom-right",onClick:y,onNodeClick:k,pannable:v=!1,zoomable:b=!1,ariaLabel:j,inversePan:N,zoomStep:S=1,offsetScale:C=5}){const D=an(),T=m.useRef(null),{boundingRect:R,viewBB:$,rfId:P,panZoom:F,translateExtent:_,flowWidth:V,flowHeight:U,ariaLabelConfig:I}=Pt(voe,on),M=(e==null?void 0:e.width)??xoe,B=(e==null?void 0:e.height)??yoe,W=R.width/M,O=R.height/B,H=Math.max(W,O),L=H*M,z=H*B,Y=C*H,q=R.x-(L-R.width)/2-Y,Q=R.y-(z-R.height)/2-Y,ee=L+Y*2,Z=z+Y*2,ie=`${woe}-${P}`,ne=m.useRef(0),ue=m.useRef();ne.current=H,m.useEffect(()=>{if(T.current&&F)return ue.current=$ne({domNode:T.current,panZoom:F,getTransform:()=>D.getState().transform,getViewScale:()=>ne.current}),()=>{var ke;(ke=ue.current)==null||ke.destroy()}},[F]),m.useEffect(()=>{var ke;(ke=ue.current)==null||ke.update({translateExtent:_,width:V,height:U,inversePan:N,pannable:v,zoomStep:S,zoomable:b})},[v,b,N,S,_,V,U]);const ge=y?ke=>{var ve;const[Ue,oe]=((ve=ue.current)==null?void 0:ve.pointer(ke))||[0,0];y(ke,{x:Ue,y:oe})}:void 0,Ne=k?m.useCallback((ke,Ue)=>{const oe=D.getState().nodeLookup.get(Ue).internals.userNode;k(ke,oe)},[]):void 0,Ce=j??I["minimap.ariaLabel"];return s.jsx(ef,{position:g,style:{...e,"--xy-minimap-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof h=="number"?h*H:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:En(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:s.jsxs("svg",{width:M,height:B,viewBox:`${q} ${Q} ${ee} ${Z}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ie,ref:T,onClick:ge,children:[Ce&&s.jsx("title",{id:ie,children:Ce}),s.jsx(goe,{onClick:Ne,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:a,nodeComponent:l}),s.jsx("path",{className:"react-flow__minimap-mask",d:`M${q-Y},${Q-Y}h${ee+Y*2}v${Z+Y*2}h${-ee-Y*2}z
659
- M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}JD.displayName="MiniMap";m.memo(JD);const joe=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,koe={[uc.Line]:"right",[uc.Handle]:"bottom-right"};function Soe({nodeId:e,position:t,variant:n=uc.Handle,className:r,style:o=void 0,children:i,color:a,minWidth:l=10,minHeight:u=10,maxWidth:f=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:h=!1,resizeDirection:g,autoScale:y=!0,shouldResize:k,onResizeStart:v,onResize:b,onResizeEnd:j}){const N=AD(),S=typeof e=="string"?e:N,C=an(),D=m.useRef(null),T=n===uc.Handle,R=Pt(m.useCallback(joe(T&&y),[T,y]),on),$=m.useRef(null),P=t??koe[n];m.useEffect(()=>{if(!(!D.current||!S))return $.current||($.current=Kne({domNode:D.current,nodeId:S,getStoreItems:()=>{const{nodeLookup:_,transform:V,snapGrid:U,snapToGrid:I,nodeOrigin:M,domNode:B}=C.getState();return{nodeLookup:_,transform:V,snapGrid:U,snapToGrid:I,nodeOrigin:M,paneDomNode:B}},onChange:(_,V)=>{const{triggerNodeChanges:U,nodeLookup:I,parentLookup:M,nodeOrigin:B}=C.getState(),W=[],O={x:_.x,y:_.y},H=I.get(S);if(H&&H.expandParent&&H.parentId){const L=H.origin??B,z=_.width??H.measured.width??0,Y=_.height??H.measured.height??0,q={id:H.id,parentId:H.parentId,rect:{width:z,height:Y,...Z3({x:_.x??H.position.x,y:_.y??H.position.y},{width:z,height:Y},H.parentId,I,L)}},Q=H0([q],I,M,B);W.push(...Q),O.x=_.x?Math.max(L[0]*z,_.x):void 0,O.y=_.y?Math.max(L[1]*Y,_.y):void 0}if(O.x!==void 0&&O.y!==void 0){const L={id:S,type:"position",position:{...O}};W.push(L)}if(_.width!==void 0&&_.height!==void 0){const z={id:S,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:_.width,height:_.height}};W.push(z)}for(const L of V){const z={...L,type:"position"};W.push(z)}U(W)},onEnd:({width:_,height:V})=>{const U={id:S,type:"dimensions",resizing:!1,dimensions:{width:_,height:V}};C.getState().triggerNodeChanges([U])}})),$.current.update({controlPosition:P,boundaries:{minWidth:l,minHeight:u,maxWidth:f,maxHeight:p},keepAspectRatio:h,resizeDirection:g,onResizeStart:v,onResize:b,onResizeEnd:j,shouldResize:k}),()=>{var _;(_=$.current)==null||_.destroy()}},[P,l,u,f,p,h,v,b,j,k]);const F=P.split("-");return s.jsx("div",{className:En(["react-flow__resize-control","nodrag",...F,n,r]),ref:D,style:{...o,scale:R,...a&&{[T?"backgroundColor":"borderColor"]:a}},children:i})}m.memo(Soe);var ZD=Object.defineProperty,Noe=(e,t,n)=>t in e?ZD(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Coe=(e,t)=>{for(var n in t)ZD(e,n,{get:t[n],enumerable:!0})},Eoe=(e,t,n)=>Noe(e,t+"",n),e$={};Coe(e$,{Graph:()=>_s,alg:()=>W0,json:()=>n$,version:()=>Aoe});var Toe=Object.defineProperty,t$=(e,t)=>{for(var n in t)Toe(e,n,{get:t[n],enumerable:!0})},_s=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){let t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&t.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,this.edge(o))});let n={},r=o=>{let i=this.parent(o);return!i||t.hasNode(i)?(n[o]=i??void 0,i??void 0):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,r(o))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let o,i,a,l,u=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,a=e.name,arguments.length===2&&(l=t,u=!0)):(o=e,i=t,a=r,arguments.length>2&&(l=n,u=!0)),o=""+o,i=""+i,a!==void 0&&(a=""+a);let f=_u(this._isDirected,o,i,a);if(f in this._edgeLabels)return u&&(this._edgeLabels[f]=l),this;if(a!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[f]=u?l:this._defaultEdgeLabelFn(o,i,a);let p=Roe(this._isDirected,o,i,a);return o=p.v,i=p.w,Object.freeze(p),this._edgeObjs[f]=p,wE(this._preds[i],o),wE(this._sucs[o],i),this._in[i][f]=p,this._out[o][f]=p,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?ub(this._isDirected,e):_u(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?ub(this._isDirected,e):_u(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?ub(this._isDirected,e):_u(this._isDirected,e,t,n),o=this._edgeObjs[r];if(o){let i=o.v,a=o.w;delete this._edgeLabels[r],delete this._edgeObjs[r],jE(this._preds[a],i),jE(this._sucs[i],a),delete this._in[a][r],delete this._out[i][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(o=>o.v===t&&o.w===n||o.v===n&&o.w===t):r}};function wE(e,t){e[t]?e[t]++:e[t]=1}function jE(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function _u(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let a=o;o=i,i=a}return o+""+i+""+(r===void 0?"\0":r)}function Roe(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let l=o;o=i,i=l}let a={v:o,w:i};return r&&(a.name=r),a}function ub(e,t){return _u(e,t.v,t.w,t.name)}var Aoe="4.0.1",n$={};t$(n$,{read:()=>$oe,write:()=>Poe});function Poe(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:_oe(e),edges:Doe(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function _oe(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),o={v:t};return n!==void 0&&(o.value=n),r!==void 0&&(o.parent=r),o})}function Doe(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function $oe(e){let t=new _s(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var W0={};t$(W0,{CycleException:()=>qh,bellmanFord:()=>r$,components:()=>Moe,dijkstra:()=>Wh,dijkstraAll:()=>zoe,findCycles:()=>Boe,floydWarshall:()=>Hoe,isAcyclic:()=>Woe,postorder:()=>Koe,preorder:()=>Goe,prim:()=>Yoe,shortestPaths:()=>Xoe,tarjan:()=>o$,topsort:()=>i$});var Ioe=()=>1;function r$(e,t,n,r){return Loe(e,String(t),n||Ioe,r||function(o){return e.outEdges(o)})}function Loe(e,t,n,r){let o={},i,a=0,l=e.nodes(),u=function(h){let g=n(h);o[h.v].distance+g<o[h.w].distance&&(o[h.w]={distance:o[h.v].distance+g,predecessor:h.v},i=!0)},f=function(){l.forEach(function(h){r(h).forEach(function(g){let y=g.v===h?g.v:g.w,k=y===g.v?g.w:g.v;u({v:y,w:k})})})};l.forEach(function(h){let g=h===t?0:Number.POSITIVE_INFINITY;o[h]={distance:g,predecessor:""}});let p=l.length;for(let h=1;h<p&&(i=!1,a++,f(),!!i);h++);if(a===p-1&&(i=!1,f(),i))throw new Error("The graph contains a negative weight cycle");return o}function Moe(e){let t={},n=[],r;function o(i){i in t||(t[i]=!0,r.push(i),e.successors(i).forEach(o),e.predecessors(i).forEach(o))}return e.nodes().forEach(function(i){r=[],o(i),r.length&&n.push(r)}),n}var s$=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let o=this._arr,i=o.length;return n[r]=i,o.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,o=n[e],i=n[t];n[e]=i,n[t]=o,r[i.key]=e,r[o.key]=t}},Ooe=()=>1;function Wh(e,t,n,r){let o=function(i){return e.outEdges(i)};return Foe(e,String(t),n||Ooe,r||o)}function Foe(e,t,n,r){let o={},i=new s$,a,l,u=function(f){let p=f.v!==a?f.v:f.w,h=o[p],g=n(f),y=l.distance+g;if(g<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+f+" Weight: "+g);y<h.distance&&(h.distance=y,h.predecessor=a,i.decrease(p,y))};for(e.nodes().forEach(function(f){let p=f===t?0:Number.POSITIVE_INFINITY;o[f]={distance:p,predecessor:""},i.add(f,p)});i.size()>0&&(a=i.removeMin(),l=o[a],l.distance!==Number.POSITIVE_INFINITY);)r(a).forEach(u);return o}function zoe(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=Wh(e,o,t,n),r},{})}function o$(e){let t=0,n=[],r={},o=[];function i(a){let l=r[a]={onStack:!0,lowlink:t,index:t++};if(n.push(a),e.successors(a).forEach(function(u){u in r?r[u].onStack&&(l.lowlink=Math.min(l.lowlink,r[u].index)):(i(u),l.lowlink=Math.min(l.lowlink,r[u].lowlink))}),l.lowlink===l.index){let u=[],f;do f=n.pop(),r[f].onStack=!1,u.push(f);while(a!==f);o.push(u)}}return e.nodes().forEach(function(a){a in r||i(a)}),o}function Boe(e){return o$(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Uoe=()=>1;function Hoe(e,t,n){return Voe(e,t||Uoe,n||function(r){return e.outEdges(r)})}function Voe(e,t,n){let r={},o=e.nodes();return o.forEach(function(i){r[i]={},r[i][i]={distance:0,predecessor:""},o.forEach(function(a){i!==a&&(r[i][a]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(i).forEach(function(a){let l=a.v===i?a.w:a.v,u=t(a);r[i][l]={distance:u,predecessor:i}})}),o.forEach(function(i){let a=r[i];o.forEach(function(l){let u=r[l];o.forEach(function(f){let p=u[i],h=a[f],g=u[f],y=p.distance+h.distance;y<g.distance&&(g.distance=y,g.predecessor=h.predecessor)})})}),r}var qh=class extends Error{constructor(...e){super(...e)}};function i$(e){let t={},n={},r=[];function o(i){if(i in n)throw new qh;i in t||(n[i]=!0,t[i]=!0,e.predecessors(i).forEach(o),delete n[i],r.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new qh;return r}function Woe(e){try{i$(e)}catch(t){if(t instanceof qh)return!1;throw t}return!0}function qoe(e,t,n,r,o){Array.isArray(t)||(t=[t]);let i=(l=>{var u;return(u=e.isDirected()?e.successors(l):e.neighbors(l))!=null?u:[]}),a={};return t.forEach(function(l){if(!e.hasNode(l))throw new Error("Graph does not have node: "+l);o=a$(e,l,n==="post",a,i,r,o)}),o}function a$(e,t,n,r,o,i,a){return t in r||(r[t]=!0,n||(a=i(a,t)),o(t).forEach(function(l){a=a$(e,l,n,r,o,i,a)}),n&&(a=i(a,t))),a}function l$(e,t,n){return qoe(e,t,n,function(r,o){return r.push(o),r},[])}function Koe(e,t){return l$(e,t,"post")}function Goe(e,t){return l$(e,t,"pre")}function Yoe(e,t){let n=new _s,r={},o=new s$,i;function a(u){let f=u.v===i?u.w:u.v,p=o.priority(f);if(p!==void 0){let h=t(u);h<p&&(r[f]=i,o.decrease(f,h))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(u){o.add(u,Number.POSITIVE_INFINITY),n.setNode(u)}),o.decrease(e.nodes()[0],0);let l=!1;for(;o.size()>0;){if(i=o.removeMin(),i in r)n.setEdge(i,r[i]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}e.nodeEdges(i).forEach(a)}return n}function Xoe(e,t,n,r){return Qoe(e,t,n,r??(o=>{let i=e.outEdges(o);return i??[]}))}function Qoe(e,t,n,r){if(n===void 0)return Wh(e,t,n,r);let o=!1,i=e.nodes();for(let a=0;a<i.length;a++){let l=r(i[a]);for(let u=0;u<l.length;u++){let f=l[u],p=f.v===i[a]?f.v:f.w,h=p===f.v?f.w:f.v;n({v:p,w:h})<0&&(o=!0)}if(o)return r$(e,t,n,r)}return Wh(e,t,n,r)}function Dc(e,t,n,r){let o=r;for(;e.hasNode(o);)o=q0(r);return n.dummy=t,e.setNode(o,n),o}function Joe(e){let t=new _s().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})}),t}function c$(e){let t=new _s({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function kE(e,t){let n=e.x,r=e.y,o=t.x-n,i=t.y-r,a=e.width/2,l=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let u,f;return Math.abs(i)*a>Math.abs(o)*l?(i<0&&(l=-l),u=l*o/i,f=l):(o<0&&(a=-a),u=a,f=a*i/o),{x:n+u,y:r+f}}function fg(e){let t=Nd(d$(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),o=r.rank;o!==void 0&&(t[o]||(t[o]=[]),t[o][r.order]=n)}),t}function Zoe(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),n=Ys(Math.min,t);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=n)})}function eie(e){let t=e.nodes().map(a=>e.node(a).rank).filter(a=>a!==void 0),n=Ys(Math.min,t),r=[];e.nodes().forEach(a=>{let l=e.node(a).rank-n;r[l]||(r[l]=[]),r[l].push(a)});let o=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((a,l)=>{a===void 0&&l%i!==0?--o:a!==void 0&&o&&a.forEach(u=>e.node(u).rank+=o)})}function SE(e,t,n,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),Dc(e,"border",o,t)}function tie(e,t=u$){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var u$=65535;function Ys(e,t){if(t.length>u$){let n=tie(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function d$(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return Ys(Math.max,t)}function nie(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function rie(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function sie(e,t){return t()}var oie=0;function q0(e){let t=++oie;return e+(""+t)}function Nd(e,t,n=1){t==null&&(t=e,e=0);let r=i=>i<t;n<0&&(r=i=>t<i);let o=[];for(let i=e;r(i);i+=n)o.push(i);return o}function Kh(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function pg(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[o,i])=>(r[o]=n(i,o),r),{})}function iie(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var hg="\0",aie=class{constructor(){Eoe(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return NE(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&NE(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,lie)),n=n._prev;return"["+e.join(", ")+"]"}};function NE(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function lie(e,t){if(e!=="_next"&&e!=="_prev")return t}var cie=aie,uie=()=>1;function die(e,t){if(e.nodeCount()<=1)return[];let n=pie(e,t||uie);return fie(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function fie(e,t,n){var r;let o=[],i=t[t.length-1],a=t[0],l;for(;e.nodeCount();){for(;l=a.dequeue();)db(e,t,n,l);for(;l=i.dequeue();)db(e,t,n,l);if(e.nodeCount()){for(let u=t.length-2;u>0;--u)if(l=(r=t[u])==null?void 0:r.dequeue(),l){o=o.concat(db(e,t,n,l,!0)||[]);break}}}return o}function db(e,t,n,r,o){let i=[],a=o?i:void 0;return(e.inEdges(r.v)||[]).forEach(l=>{let u=e.edge(l),f=e.node(l.v);o&&i.push({v:l.v,w:l.w}),f.out-=u,Dv(t,n,f)}),(e.outEdges(r.v)||[]).forEach(l=>{let u=e.edge(l),f=l.w,p=e.node(f);p.in-=u,Dv(t,n,p)}),e.removeNode(r.v),a}function pie(e,t){let n=new _s,r=0,o=0;e.nodes().forEach(l=>{n.setNode(l,{v:l,in:0,out:0})}),e.edges().forEach(l=>{let u=n.edge(l.v,l.w)||0,f=t(l),p=u+f;n.setEdge(l.v,l.w,p);let h=n.node(l.v),g=n.node(l.w);o=Math.max(o,h.out+=f),r=Math.max(r,g.in+=f)});let i=hie(o+r+3).map(()=>new cie),a=r+1;return n.nodes().forEach(l=>{Dv(i,a,n.node(l))}),{graph:n,buckets:i,zeroIdx:a}}function Dv(e,t,n){var r,o,i;n.out?n.in?(i=e[n.out-n.in+t])==null||i.enqueue(n):(o=e[e.length-1])==null||o.enqueue(n):(r=e[0])==null||r.enqueue(n)}function hie(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function mie(e){(e.graph().acyclicer==="greedy"?die(e,t(e)):gie(e)).forEach(n=>{let r=e.edge(n);e.removeEdge(n),r.forwardName=n.name,r.reversed=!0,e.setEdge(n.w,n.v,r,q0("rev"))});function t(n){return r=>n.edge(r).weight}}function gie(e){let t=[],n={},r={};function o(i){Object.hasOwn(r,i)||(r[i]=!0,n[i]=!0,e.outEdges(i).forEach(a=>{Object.hasOwn(n,a.w)?t.push(a):o(a.w)}),delete n[i])}return e.nodes().forEach(o),t}function xie(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function yie(e){e.graph().dummyChains=[],e.edges().forEach(t=>bie(e,t))}function bie(e,t){let n=t.v,r=e.node(n).rank,o=t.w,i=e.node(o).rank,a=t.name,l=e.edge(t),u=l.labelRank;if(i===r+1)return;e.removeEdge(t);let f,p,h;for(h=0,++r;r<i;++h,++r)l.points=[],p={width:0,height:0,edgeLabel:l,edgeObj:t,rank:r},f=Dc(e,"edge",p,"_d"),r===u&&(p.width=l.width,p.height=l.height,p.dummy="edge-label",p.labelpos=l.labelpos),e.setEdge(n,f,{weight:l.weight},a),h===0&&e.graph().dummyChains.push(f),n=f;e.setEdge(n,o,{weight:l.weight},a)}function vie(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,o;for(e.setEdge(n.edgeObj,r);n.dummy;)o=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=o,n=e.node(t)})}function K0(e){let t={};function n(r){let o=e.node(r);if(Object.hasOwn(t,r))return o.rank;t[r]=!0;let i=e.outEdges(r),a=i?i.map(u=>u==null?Number.POSITIVE_INFINITY:n(u.w)-e.edge(u).minlen):[],l=Ys(Math.min,a);return l===Number.POSITIVE_INFINITY&&(l=0),o.rank=l}e.sources().forEach(n)}function fc(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var f$=wie;function wie(e){let t=new _s({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],o=e.nodeCount();t.setNode(r,{});let i,a;for(;jie(t,e)<o&&(i=kie(t,e),!!i);)a=t.hasNode(i.v)?fc(e,i):-fc(e,i),Sie(t,e,a);return t}function jie(e,t){function n(r){let o=t.nodeEdges(r);o&&o.forEach(i=>{let a=i.v,l=r===a?i.w:a;!e.hasNode(l)&&!fc(t,i)&&(e.setNode(l,{}),e.setEdge(r,l,{}),n(l))})}return e.nodes().forEach(n),e.nodeCount()}function kie(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=fc(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function Sie(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:Nie,postorder:Cie}=W0,Eie=Da;Da.initLowLimValues=Y0;Da.initCutValues=G0;Da.calcCutValue=p$;Da.leaveEdge=m$;Da.enterEdge=g$;Da.exchangeEdges=x$;function Da(e){e=Joe(e),K0(e);let t=f$(e);Y0(t),G0(t,e);let n,r;for(;n=m$(t);)r=g$(t,e,n),x$(t,e,n,r)}function G0(e,t){let n=Cie(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>Tie(e,t,r))}function Tie(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=p$(e,t,n)}function p$(e,t,n){let r=e.node(n).parent,o=!0,i=t.edge(n,r),a=0;i||(o=!1,i=t.edge(r,n)),a=i.weight;let l=t.nodeEdges(n);return l&&l.forEach(u=>{let f=u.v===n,p=f?u.w:u.v;if(p!==r){let h=f===o,g=t.edge(u).weight;if(a+=h?g:-g,Aie(e,n,p)){let y=e.edge(n,p).cutvalue;a+=h?-y:y}}}),a}function Y0(e,t){arguments.length<2&&(t=e.nodes()[0]),h$(e,{},1,t)}function h$(e,t,n,r,o){let i=n,a=e.node(r);t[r]=!0;let l=e.neighbors(r);return l&&l.forEach(u=>{Object.hasOwn(t,u)||(n=h$(e,t,n,u,r))}),a.low=i,a.lim=n++,o?a.parent=o:delete a.parent,n}function m$(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function g$(e,t,n){let r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);let i=e.node(r),a=e.node(o),l=i,u=!1;return i.lim>a.lim&&(l=a,u=!0),t.edges().filter(f=>u===CE(e,e.node(f.v),l)&&u!==CE(e,e.node(f.w),l)).reduce((f,p)=>fc(t,p)<fc(t,f)?p:f)}function x$(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),Y0(e),G0(e,t),Rie(e,t)}function Rie(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=Nie(e,[n]);r=r.slice(1),r.forEach(o=>{let i=e.node(o).parent,a=t.edge(o,i),l=!1;a||(a=t.edge(i,o),l=!0),t.node(o).rank=t.node(i).rank+(l?a.minlen:-a.minlen)})}function Aie(e,t,n){return e.hasEdge(t,n)}function CE(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Pie=_ie;function _ie(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":EE(e);break;case"tight-tree":$ie(e);break;case"longest-path":Die(e);break;case"none":break;default:EE(e)}}var Die=K0;function $ie(e){K0(e),f$(e)}function EE(e){Eie(e)}var Iie=Lie;function Lie(e){let t=Oie(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),o=r.edgeObj,i=Mie(e,t,o.v,o.w),a=i.path,l=i.lca,u=0,f=a[u],p=!0;for(;n!==o.w;){if(r=e.node(n),p){for(;(f=a[u])!==l&&e.node(f).maxRank<r.rank;)u++;f===l&&(p=!1)}if(!p){for(;u<a.length-1&&e.node(a[u+1]).minRank<=r.rank;)u++;f=a[u]}f!==void 0&&e.setParent(n,f),n=e.successors(n)[0]}})}function Mie(e,t,n,r){let o=[],i=[],a=Math.min(t[n].low,t[r].low),l=Math.max(t[n].lim,t[r].lim),u;u=n;do u=e.parent(u),o.push(u);while(u&&(t[u].low>a||l>t[u].lim));let f=u,p=r;for(;(p=e.parent(p))!==f;)i.push(p);return{path:o.concat(i.reverse()),lca:f}}function Oie(e){let t={},n=0;function r(o){let i=n;e.children(o).forEach(r),t[o]={low:i,lim:n++}}return e.children(hg).forEach(r),t}function Fie(e){let t=Dc(e,"root",{},"_root"),n=zie(e),r=Object.values(n),o=Ys(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=i);let a=Bie(e)+1;e.children(hg).forEach(l=>y$(e,t,i,a,o,n,l)),e.graph().nodeRankFactor=i}function y$(e,t,n,r,o,i,a){var l;let u=e.children(a);if(!u.length){a!==t&&e.setEdge(t,a,{weight:0,minlen:n});return}let f=SE(e,"_bt"),p=SE(e,"_bb"),h=e.node(a);e.setParent(f,a),h.borderTop=f,e.setParent(p,a),h.borderBottom=p,u.forEach(g=>{var y;y$(e,t,n,r,o,i,g);let k=e.node(g),v=k.borderTop?k.borderTop:g,b=k.borderBottom?k.borderBottom:g,j=k.borderTop?r:2*r,N=v!==b?1:o-((y=i[a])!=null?y:0)+1;e.setEdge(f,v,{weight:j,minlen:N,nestingEdge:!0}),e.setEdge(b,p,{weight:j,minlen:N,nestingEdge:!0})}),e.parent(a)||e.setEdge(t,f,{weight:0,minlen:o+((l=i[a])!=null?l:0)})}function zie(e){let t={};function n(r,o){let i=e.children(r);i&&i.length&&i.forEach(a=>n(a,o+1)),t[r]=o}return e.children(hg).forEach(r=>n(r,1)),t}function Bie(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Uie(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Hie=Vie;function Vie(e){function t(n){let r=e.children(n),o=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,a=o.maxRank+1;i<a;++i)TE(e,"borderLeft","_bl",n,o,i),TE(e,"borderRight","_br",n,o,i)}}e.children(hg).forEach(t)}function TE(e,t,n,r,o,i){let a={width:0,height:0,rank:i,borderType:t},l=o[t][i-1],u=Dc(e,"border",a,n);o[t][i]=u,e.setParent(u,r),l&&e.setEdge(l,u,{weight:1})}function Wie(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&b$(e)}function qie(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&Kie(e),(n==="lr"||n==="rl")&&(Gie(e),b$(e))}function b$(e){e.nodes().forEach(t=>RE(e.node(t))),e.edges().forEach(t=>RE(e.edge(t)))}function RE(e){let t=e.width;e.width=e.height,e.height=t}function Kie(e){e.nodes().forEach(t=>fb(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(fb),Object.hasOwn(r,"y")&&fb(r)})}function fb(e){e.y=-e.y}function Gie(e){e.nodes().forEach(t=>pb(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(pb),Object.hasOwn(r,"x")&&pb(r)})}function pb(e){let t=e.x;e.x=e.y,e.y=t}function Yie(e){let t={},n=e.nodes().filter(l=>!e.children(l).length),r=n.map(l=>e.node(l).rank),o=Ys(Math.max,r),i=Nd(o+1).map(()=>[]);function a(l){if(t[l])return;t[l]=!0;let u=e.node(l);i[u.rank].push(l);let f=e.successors(l);f&&f.forEach(a)}return n.sort((l,u)=>e.node(l).rank-e.node(u).rank).forEach(a),i}function Xie(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Qie(e,t[r-1],t[r]);return n}function Qie(e,t,n){let r=iie(n,n.map((f,p)=>p)),o=t.flatMap(f=>{let p=e.outEdges(f);return p?p.map(h=>({pos:r[h.w],weight:e.edge(h).weight})).sort((h,g)=>h.pos-g.pos):[]}),i=1;for(;i<n.length;)i<<=1;let a=2*i-1;i-=1;let l=new Array(a).fill(0),u=0;return o.forEach(f=>{let p=f.pos+i;l[p]+=f.weight;let h=0;for(;p>0;)p%2&&(h+=l[p+1]),p=p-1>>1,l[p]+=f.weight;u+=f.weight*h}),u}function Jie(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let o=r.reduce((i,a)=>{let l=e.edge(a),u=e.node(a.v);return{sum:i.sum+l.weight*u.order,weight:i.weight+l.weight}},{sum:0,weight:0});return{v:n,barycenter:o.sum/o.weight,weight:o.weight}}})}function Zie(e,t){let n={};e.forEach((o,i)=>{let a={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(a.barycenter=o.barycenter,a.weight=o.weight),n[o.v]=a}),t.edges().forEach(o=>{let i=n[o.v],a=n[o.w];i!==void 0&&a!==void 0&&(a.indegree++,i.out.push(a))});let r=Object.values(n).filter(o=>!o.indegree);return eae(r)}function eae(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&tae(o,i)}}function r(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(n(o)),o.out.forEach(r(o))}return t.filter(o=>!o.merged).map(o=>Kh(o,["vs","i","barycenter","weight"]))}function tae(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function nae(e,t){let n=nie(e,p=>Object.hasOwn(p,"barycenter")),r=n.lhs,o=n.rhs.sort((p,h)=>h.i-p.i),i=[],a=0,l=0,u=0;r.sort(rae(!!t)),u=AE(i,o,u),r.forEach(p=>{u+=p.vs.length,i.push(p.vs),a+=p.barycenter*p.weight,l+=p.weight,u=AE(i,o,u)});let f={vs:i.flat(1)};return l&&(f.barycenter=a/l,f.weight=l),f}function AE(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function rae(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function v$(e,t,n,r){let o=e.children(t),i=e.node(t),a=i?i.borderLeft:void 0,l=i?i.borderRight:void 0,u={};a&&(o=o.filter(g=>g!==a&&g!==l));let f=Jie(e,o);f.forEach(g=>{if(e.children(g.v).length){let y=v$(e,g.v,n,r);u[g.v]=y,Object.hasOwn(y,"barycenter")&&oae(g,y)}});let p=Zie(f,n);sae(p,u);let h=nae(p,r);if(a&&l){h.vs=[a,h.vs,l].flat(1);let g=e.predecessors(a);if(g&&g.length){let y=e.node(g[0]),k=e.predecessors(l),v=e.node(k[0]);Object.hasOwn(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+y.order+v.order)/(h.weight+2),h.weight+=2}}return h}function sae(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function oae(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function iae(e,t,n,r){r||(r=e.nodes());let o=aae(e),i=new _s({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(a=>e.node(a));return r.forEach(a=>{let l=e.node(a),u=e.parent(a);if(l.rank===t||l.minRank<=t&&t<=l.maxRank){i.setNode(a),i.setParent(a,u||o);let f=e[n](a);f&&f.forEach(p=>{let h=p.v===a?p.w:p.v,g=i.edge(h,a),y=g!==void 0?g.weight:0;i.setEdge(h,a,{weight:e.edge(p).weight+y})}),Object.hasOwn(l,"minRank")&&i.setNode(a,{borderLeft:l.borderLeft[t],borderRight:l.borderRight[t]})}}),i}function aae(e){let t;for(;e.hasNode(t=q0("_root")););return t}function lae(e,t,n){let r={},o;n.forEach(i=>{let a=e.parent(i),l,u;for(;a;){if(l=e.parent(a),l?(u=r[l],r[l]=a):(u=o,o=a),u&&u!==a){t.setEdge(u,a);return}a=l}})}function w$(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,w$);return}let n=d$(e),r=PE(e,Nd(1,n+1),"inEdges"),o=PE(e,Nd(n-1,-1,-1),"outEdges"),i=Yie(e);if(_E(e,i),t.disableOptimalOrderHeuristic)return;let a=Number.POSITIVE_INFINITY,l,u=t.constraints||[];for(let f=0,p=0;p<4;++f,++p){cae(f%2?r:o,f%4>=2,u),i=fg(e);let h=Xie(e,i);h<a?(p=0,l=Object.assign({},i),a=h):h===a&&(l=structuredClone(i))}_E(e,l)}function PE(e,t,n){let r=new Map,o=(i,a)=>{r.has(i)||r.set(i,[]),r.get(i).push(a)};for(let i of e.nodes()){let a=e.node(i);if(typeof a.rank=="number"&&o(a.rank,i),typeof a.minRank=="number"&&typeof a.maxRank=="number")for(let l=a.minRank;l<=a.maxRank;l++)l!==a.rank&&o(l,i)}return t.map(function(i){return iae(e,i,n,r.get(i)||[])})}function cae(e,t,n){let r=new _s;e.forEach(function(o){n.forEach(l=>r.setEdge(l.left,l.right));let i=o.graph().root,a=v$(o,i,r,t);a.vs.forEach((l,u)=>o.node(l).order=u),lae(o,r,a.vs)})}function _E(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function uae(e,t){let n={};function r(o,i){let a=0,l=0,u=o.length,f=i[i.length-1];return i.forEach((p,h)=>{let g=fae(e,p),y=g?e.node(g).order:u;(g||p===f)&&(i.slice(l,h+1).forEach(k=>{let v=e.predecessors(k);v&&v.forEach(b=>{let j=e.node(b),N=j.order;(N<a||y<N)&&!(j.dummy&&e.node(k).dummy)&&j$(n,b,k)})}),l=h+1,a=y)}),i}return t.length&&t.reduce(r),n}function dae(e,t){let n={};function r(i,a,l,u,f){Nd(a,l).forEach(p=>{let h=i[p];if(h!==void 0&&e.node(h).dummy){let g=e.predecessors(h);g&&g.forEach(y=>{if(y===void 0)return;let k=e.node(y);k.dummy&&(k.order<u||k.order>f)&&j$(n,y,h)})}})}function o(i,a){let l=-1,u=-1,f=0;return a.forEach((p,h)=>{if(e.node(p).dummy==="border"){let g=e.predecessors(p);if(g&&g.length){let y=g[0];if(y===void 0)return;u=e.node(y).order,r(a,f,h,l,u),f=h,l=u}}r(a,f,a.length,u,i.length)}),a}return t.length&&t.reduce(o),n}function fae(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function j$(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];r||(e[t]=r={}),r[n]=!0}function pae(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function hae(e,t,n,r){let o={},i={},a={};return t.forEach(l=>{l.forEach((u,f)=>{o[u]=u,i[u]=u,a[u]=f})}),t.forEach(l=>{let u=-1;l.forEach(f=>{let p=r(f);if(p&&p.length){let h=p.sort((y,k)=>{let v=a[y],b=a[k];return(v!==void 0?v:0)-(b!==void 0?b:0)}),g=(h.length-1)/2;for(let y=Math.floor(g),k=Math.ceil(g);y<=k;++y){let v=h[y];if(v===void 0)continue;let b=a[v];if(b!==void 0&&i[f]===f&&u<b&&!pae(n,f,v)){let j=o[v];j!==void 0&&(i[v]=f,i[f]=o[f]=j,u=b)}}}})}),{root:o,align:i}}function mae(e,t,n,r,o=!1){let i={},a=gae(e,t,n,o),l=o?"borderLeft":"borderRight";function u(y,k){let v=a.nodes().slice(),b={},j=v.pop();for(;j;){if(b[j])y(j);else{b[j]=!0,v.push(j);for(let N of k(j))v.push(N)}j=v.pop()}}function f(y){let k=a.inEdges(y);k?i[y]=k.reduce((v,b)=>{var j;let N=(j=i[b.v])!=null?j:0,S=a.edge(b);return Math.max(v,N+(S!==void 0?S:0))},0):i[y]=0}function p(y){let k=a.outEdges(y),v=Number.POSITIVE_INFINITY;k&&(v=k.reduce((j,N)=>{let S=i[N.w],C=a.edge(N);return Math.min(j,(S!==void 0?S:0)-(C!==void 0?C:0))},Number.POSITIVE_INFINITY));let b=e.node(y);v!==Number.POSITIVE_INFINITY&&b.borderType!==l&&(i[y]=Math.max(i[y]!==void 0?i[y]:0,v))}function h(y){return a.predecessors(y)||[]}function g(y){return a.successors(y)||[]}return u(f,h),u(p,g),Object.keys(r).forEach(y=>{var k;let v=n[y];v!==void 0&&(i[y]=(k=i[v])!=null?k:0)}),i}function gae(e,t,n,r){let o=new _s,i=e.graph(),a=wae(i.nodesep,i.edgesep,r);return t.forEach(l=>{let u;l.forEach(f=>{let p=n[f];if(p!==void 0){if(o.setNode(p),u!==void 0){let h=n[u];if(h!==void 0){let g=o.edge(h,p);o.setEdge(h,p,Math.max(a(e,f,u),g||0))}}u=f}})}),o}function xae(e,t){return Object.values(t).reduce((n,r)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([l,u])=>{let f=jae(e,l)/2;o=Math.max(u+f,o),i=Math.min(u-f,i)});let a=o-i;return a<n[0]&&(n=[a,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function yae(e,t){let n=Object.values(t),r=Ys(Math.min,n),o=Ys(Math.max,n);["u","d"].forEach(i=>{["l","r"].forEach(a=>{let l=i+a,u=e[l];if(!u||u===t)return;let f=Object.values(u),p=r-Ys(Math.min,f);a!=="l"&&(p=o-Ys(Math.max,f)),p&&(e[l]=pg(u,h=>h+p))})})}function bae(e,t=void 0){let n=e.ul;return n?pg(n,(r,o)=>{var i,a;if(t){let u=t.toLowerCase(),f=e[u];if(f&&f[o]!==void 0)return f[o]}let l=Object.values(e).map(u=>{let f=u[o];return f!==void 0?f:0}).sort((u,f)=>u-f);return(((i=l[1])!=null?i:0)+((a=l[2])!=null?a:0))/2}):{}}function vae(e){let t=fg(e),n=Object.assign(uae(e,t),dae(e,t)),r={},o;["u","d"].forEach(a=>{o=a==="u"?t:Object.values(t).reverse(),["l","r"].forEach(l=>{l==="r"&&(o=o.map(p=>Object.values(p).reverse()));let u=hae(e,o,n,p=>(a==="u"?e.predecessors(p):e.successors(p))||[]),f=mae(e,o,u.root,u.align,l==="r");l==="r"&&(f=pg(f,p=>-p)),r[a+l]=f})});let i=xae(e,r);return yae(r,i),bae(r,e.graph().align)}function wae(e,t,n){return(r,o,i)=>{let a=r.node(o),l=r.node(i),u=0,f;if(u+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":f=-a.width/2;break;case"r":f=a.width/2;break}if(f&&(u+=n?f:-f),f=void 0,u+=(a.dummy?t:e)/2,u+=(l.dummy?t:e)/2,u+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":f=l.width/2;break;case"r":f=-l.width/2;break}return f&&(u+=n?f:-f),u}}function jae(e,t){return e.node(t).width}function kae(e){e=c$(e),Sae(e),Object.entries(vae(e)).forEach(([t,n])=>e.node(t).x=n)}function Sae(e){let t=fg(e),n=e.graph(),r=n.ranksep,o=n.rankalign,i=0;t.forEach(a=>{let l=a.reduce((u,f)=>{var p;let h=(p=e.node(f).height)!=null?p:0;return u>h?u:h},0);a.forEach(u=>{let f=e.node(u);o==="top"?f.y=i+f.height/2:o==="bottom"?f.y=i+l-f.height/2:f.y=i+l/2}),i+=l+r})}function Nae(e,t={}){let n=t.debugTiming?rie:sie;return n("layout",()=>{let r=n(" buildLayoutGraph",()=>Iae(e));return n(" runLayout",()=>Cae(r,n,t)),n(" updateInputGraph",()=>Eae(e,r)),r})}function Cae(e,t,n){t(" makeSpaceForEdgeLabels",()=>Lae(e)),t(" removeSelfEdges",()=>Wae(e)),t(" acyclic",()=>mie(e)),t(" nestingGraph.run",()=>Fie(e)),t(" rank",()=>Pie(c$(e))),t(" injectEdgeLabelProxies",()=>Mae(e)),t(" removeEmptyRanks",()=>eie(e)),t(" nestingGraph.cleanup",()=>Uie(e)),t(" normalizeRanks",()=>Zoe(e)),t(" assignRankMinMax",()=>Oae(e)),t(" removeEdgeLabelProxies",()=>Fae(e)),t(" normalize.run",()=>yie(e)),t(" parentDummyChains",()=>Iie(e)),t(" addBorderSegments",()=>Hie(e)),t(" order",()=>w$(e,n)),t(" insertSelfEdges",()=>qae(e)),t(" adjustCoordinateSystem",()=>Wie(e)),t(" position",()=>kae(e)),t(" positionSelfEdges",()=>Kae(e)),t(" removeBorderNodes",()=>Vae(e)),t(" normalize.undo",()=>vie(e)),t(" fixupEdgeLabelCoords",()=>Uae(e)),t(" undoCoordinateSystem",()=>qie(e)),t(" translateGraph",()=>zae(e)),t(" assignNodeIntersects",()=>Bae(e)),t(" reversePoints",()=>Hae(e)),t(" acyclic.undo",()=>xie(e))}function Eae(e,t){e.nodes().forEach(n=>{let r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,r.order=o.order,r.rank=o.rank,t.children(n).length&&(r.width=o.width,r.height=o.height))}),e.edges().forEach(n=>{let r=e.edge(n),o=t.edge(n);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Tae=["nodesep","edgesep","ranksep","marginx","marginy"],Rae={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},Aae=["acyclicer","ranker","rankdir","align","rankalign"],Pae=["width","height","rank"],DE={width:0,height:0},_ae=["minlen","weight","width","height","labeloffset"],Dae={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},$ae=["labelpos"];function Iae(e){let t=new _s({multigraph:!0,compound:!0}),n=mb(e.graph());return t.setGraph(Object.assign({},Rae,hb(n,Tae),Kh(n,Aae))),e.nodes().forEach(r=>{let o=mb(e.node(r)),i=hb(o,Pae);Object.keys(DE).forEach(l=>{i[l]===void 0&&(i[l]=DE[l])}),t.setNode(r,i);let a=e.parent(r);a!==void 0&&t.setParent(r,a)}),e.edges().forEach(r=>{let o=mb(e.edge(r));t.setEdge(r,Object.assign({},Dae,hb(o,_ae),Kh(o,$ae)))}),t}function Lae(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Mae(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),o={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};Dc(e,"edge-proxy",o,"_ep")}})}function Oae(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Fae(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function zae(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,i=e.graph(),a=i.marginx||0,l=i.marginy||0;function u(f){let p=f.x,h=f.y,g=f.width,y=f.height;t=Math.min(t,p-g/2),n=Math.max(n,p+g/2),r=Math.min(r,h-y/2),o=Math.max(o,h+y/2)}e.nodes().forEach(f=>u(e.node(f))),e.edges().forEach(f=>{let p=e.edge(f);Object.hasOwn(p,"x")&&u(p)}),t-=a,r-=l,e.nodes().forEach(f=>{let p=e.node(f);p.x-=t,p.y-=r}),e.edges().forEach(f=>{let p=e.edge(f);p.points.forEach(h=>{h.x-=t,h.y-=r}),Object.hasOwn(p,"x")&&(p.x-=t),Object.hasOwn(p,"y")&&(p.y-=r)}),i.width=n-t+a,i.height=o-r+l}function Bae(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),o=e.node(t.w),i,a;n.points?(i=n.points[0],a=n.points[n.points.length-1]):(n.points=[],i=o,a=r),n.points.unshift(kE(r,i)),n.points.push(kE(o,a))})}function Uae(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Hae(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Vae(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),i=e.node(n.borderLeft[n.borderLeft.length-1]),a=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(a.x-i.x),n.height=Math.abs(o.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function Wae(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function qae(e){fg(e).forEach(t=>{let n=0;t.forEach((r,o)=>{let i=e.node(r);i.order=o+n,(i.selfEdges||[]).forEach(a=>{Dc(e,"selfedge",{width:a.label.width,height:a.label.height,rank:i.rank,order:o+ ++n,e:a.e,label:a.label},"_se")}),delete i.selfEdges})})}function Kae(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="selfedge"){let r=n,o=e.node(r.e.v),i=o.x+o.width/2,a=o.y,l=n.x-i,u=o.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:i+2*l/3,y:a-u},{x:i+5*l/6,y:a-u},{x:i+l,y:a},{x:i+5*l/6,y:a+u},{x:i+2*l/3,y:a+u}],r.label.x=n.x,r.label.y=n.y}})}function hb(e,t){return pg(Kh(e,t),Number)}function mb(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}/*! For license information please see dagre.esm.js.LEGAL.txt */function Gae(e,t,n={}){const r=new Map;if(e.length===0)return r;const o=n.nodeWidth??150,i=n.nodeHeight??64,a=new e$.Graph;a.setGraph({rankdir:n.direction??"LR",nodesep:40,ranksep:90}),a.setDefaultEdgeLabel(()=>({}));const l=new Set;for(const u of e)l.add(u.id),a.setNode(u.id,{width:o,height:i});for(const u of t)l.has(u.from)&&l.has(u.to)&&a.setEdge(u.from,u.to);Nae(a);for(const u of l){const f=a.node(u);f&&r.set(u,{x:f.x-o/2,y:f.y-i/2})}return r}function Yae({data:e,selected:t}){const{label:n,statusId:r,color:o,terminal:i,orphan:a,missing:l}=e;return s.jsxs("div",{className:je("min-w-[120px] rounded-md border px-3 py-2 text-xs shadow-sm transition-colors",l?"border-dashed border-error-foreground/60 bg-error/10 text-error-foreground":a?"border-warning-foreground/70 bg-warning/10":"border-border/70 bg-card",t&&"ring-2 ring-primary/50"),children:[s.jsx(dc,{type:"target",position:ct.Left,className:"!h-2 !w-2 !bg-muted-foreground"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[!l&&s.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full border border-border/50",style:o?{backgroundColor:o}:void 0}),s.jsx("span",{className:"font-medium text-foreground",children:n}),l&&s.jsx(d2,{className:"h-3 w-3 shrink-0","aria-label":"Undefined status"}),a&&!l&&s.jsx(rm,{className:"h-3 w-3 shrink-0 text-warning-foreground","aria-label":"Orphan status"})]}),s.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-[10px] text-muted-foreground",children:[s.jsx("span",{children:r}),i&&s.jsxs("span",{className:"inline-flex items-center gap-0.5 text-muted-foreground",title:"Terminal status",children:[s.jsx(cO,{className:"h-2.5 w-2.5"})," terminal"]})]}),l&&s.jsx("div",{className:"mt-1 text-[10px] font-medium",children:"undefined status"}),a&&!l&&s.jsx("div",{className:"mt-1 text-[10px] text-warning-foreground",children:"no incoming edge"}),s.jsx(dc,{type:"source",position:ct.Right,className:"!h-2 !w-2 !bg-muted-foreground"})]})}const Xae={status:Yae},Qae="oklch(var(--muted-foreground))",Jae="oklch(var(--primary))",Zae="oklch(var(--error-foreground))";function ele({onRelayout:e}){const{fitView:t}=cg();return s.jsx(ef,{position:"top-right",children:s.jsxs("button",{type:"button",onClick:()=>{e(),requestAnimationFrame(()=>t({padding:.2}))},className:"shell-action inline-flex items-center gap-1 text-xs",title:"Reset node positions to the automatic layout",children:[s.jsx(hO,{className:"h-3 w-3"}),"Re-layout"]})})}function $E({nodes:e,edges:t,selectedRowKey:n,editable:r,onSelectEdge:o,onCreateEdge:i,onDeleteEdge:a}){const[l,u,f]=Xse([]),[p,h]=Qse([]),g=m.useRef(new Map),[y,k]=m.useState(0),v=m.useMemo(()=>JSON.stringify(e.map(R=>[R.id,R.label,R.color??"",R.terminal,R.orphan,R.missing])),[e]);m.useEffect(()=>{const R=Gae(e,t,{direction:"LR"}),$=new Set(e.map(P=>P.id));for(const P of g.current.keys())$.has(P)||g.current.delete(P);u(e.map(P=>{let F=g.current.get(P.id);return F||(F=R.get(P.id)??{x:0,y:0},g.current.set(P.id,F)),{id:P.id,type:"status",position:F,data:{label:P.label,statusId:P.id,color:P.color,terminal:P.terminal,orphan:P.orphan,missing:P.missing},draggable:!0,deletable:!1}}))},[v,y,u]);const b=m.useCallback(()=>{g.current.clear(),k(R=>R+1)},[]),j=m.useMemo(()=>t.map(R=>`${R.rowKey}:${R.from}>${R.to}:${R.command}:${R.requiresReason?1:0}:${R.undefinedRef?1:0}`).join("|"),[t]);m.useEffect(()=>{h(t.map(R=>{const $=R.rowKey===n,P=R.undefinedRef?Zae:$?Jae:Qae;return{id:R.rowKey,source:R.from,target:R.to,label:R.requiresReason?`${R.command} (reason)`:R.command,selected:$,deletable:r,markerEnd:{type:wd.ArrowClosed,color:P},style:{stroke:P,strokeWidth:$?2.5:1.5},labelStyle:{fill:"oklch(var(--foreground))",fontSize:11,fontFamily:"ui-monospace, monospace"},labelBgStyle:{fill:"oklch(var(--card))"},labelBgPadding:[4,2],labelBgBorderRadius:4}}))},[j,n,r,h]);const N=m.useCallback(R=>{for(const $ of R)$.type==="position"&&$.position&&g.current.set($.id,$.position);f(R)},[f]),S=m.useCallback(R=>{r&&R.source&&R.target&&i(R.source,R.target)},[r,i]),C=m.useCallback(R=>{if(r)for(const $ of R)a($.id)},[r,a]),D=m.useCallback((R,$)=>o($.id),[o]),T=m.useCallback(({edges:R})=>{R.length===1&&o(R[0].id)},[o]);return s.jsx("div",{className:"h-[460px] w-full overflow-hidden rounded-md border border-border/60 bg-background",children:s.jsxs(Yse,{nodes:l,edges:p,nodeTypes:Xae,onNodesChange:N,onConnect:S,onEdgesDelete:C,onEdgeClick:D,onSelectionChange:T,nodesConnectable:r,deleteKeyCode:r?["Backspace","Delete"]:null,elementsSelectable:!0,fitView:!0,fitViewOptions:{padding:.2},proOptions:{hideAttribution:!1},children:[s.jsx(noe,{gap:16}),s.jsx(coe,{showInteractive:!1}),s.jsx(ele,{onRelayout:b})]})})}const Ap="rounded-md border border-border/60 bg-background px-2 py-1 text-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/30 disabled:opacity-60";function tle({transition:e,statuses:t,knownCommands:n,onChange:r,onDelete:o,disabled:i}){const a=m.useRef(null);if(m.useEffect(()=>{var y;e&&!i&&((y=a.current)==null||y.focus())},[e==null?void 0:e.rowKey]),!e)return s.jsx("div",{className:"surface-panel flex h-full min-h-[120px] items-center justify-center px-4 py-6 text-center text-xs text-muted-foreground",children:"Select a transition edge to edit it, or use “Add transition”."});const l=e,u=new Set(t.map(y=>y.id)),f=!u.has(l.from),p=!u.has(l.to);function h(y){r({...l,...y})}function g(y,k,v,b){const j=u.has(y);return s.jsxs("select",{ref:b,value:y,onChange:N=>k(N.target.value),disabled:i,"aria-label":v,className:`${Ap} w-full font-mono`,children:[!j&&y!==""&&s.jsxs("option",{value:y,children:[y," (undefined)"]}),y===""&&s.jsx("option",{value:"",children:"Select a status…"}),t.map(N=>s.jsxs("option",{value:N.id,children:[N.label," (",N.id,")"]},N.id))]})}return s.jsxs("div",{className:"surface-panel space-y-3 px-4 py-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"Edit transition"}),s.jsxs("button",{type:"button",onClick:()=>o(l.rowKey),disabled:i,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-error-foreground hover:bg-error/10","aria-label":"Delete transition",children:[s.jsx(jn,{className:"h-3.5 w-3.5"}),"Delete"]})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"From status"}),g(l.from,y=>h({from:y}),"From status",a),f&&s.jsxs("span",{className:"block text-[11px] text-error-foreground",children:["“",l.from,"” is not a defined status"]})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Command"}),s.jsx("input",{type:"text",list:"transition-inspector-commands",value:l.command,onChange:y=>h({command:y.target.value}),disabled:i,placeholder:"command",className:`${Ap} w-full font-mono`})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"To status"}),g(l.to,y=>h({to:y}),"To status"),p&&s.jsxs("span",{className:"block text-[11px] text-error-foreground",children:["“",l.to,"” is not a defined status"]})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Label (optional)"}),s.jsx("input",{type:"text",value:l.label,onChange:y=>h({label:y.target.value}),disabled:i,placeholder:"label",className:`${Ap} w-full`})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Description (optional)"}),s.jsx("textarea",{value:l.description,onChange:y=>h({description:y.target.value}),disabled:i,placeholder:"description",rows:2,className:`${Ap} w-full resize-y`})]}),s.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("button",{type:"button",role:"switch","aria-checked":l.requiresReason,"aria-label":"Requires reason",onClick:()=>h({requiresReason:!l.requiresReason}),disabled:i,className:`relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${l.requiresReason?"bg-primary":"bg-muted"}`,children:s.jsx("span",{className:`pointer-events-none inline-block h-4 w-4 rounded-full bg-background shadow-sm transition-transform ${l.requiresReason?"translate-x-4":"translate-x-0"}`})}),"Requires a reason"]}),s.jsx("datalist",{id:"transition-inspector-commands",children:n.map(y=>s.jsx("option",{value:y},y))})]})}function IE(){return s.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2.5 w-4 rounded",style:{backgroundColor:"oklch(var(--error-foreground))"}}),"references an undefined status"]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full border-2 border-dashed border-error-foreground/70"}),"ghost (undefined) status"]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-sm border border-warning-foreground/70 bg-warning/10"}),"orphan status (no incoming edge)"]})]})}function nle({value:e,customizing:t,statuses:n,knownCommands:r,onChange:o,onCustomize:i,disabled:a}){var S;const l=m.useMemo(()=>new Set(n.map(C=>C.id)),[n]),[u,f]=m.useState(null),p=m.useMemo(()=>yv(u3()),[]),h=m.useMemo(()=>hC(p,n),[p,n]);if(!t&&e.length===0)return s.jsxs(qe,{title:"Transitions",description:"Which commands move an assignment between statuses, as a state-machine graph. Showing the built-in defaults.",actions:s.jsx("button",{type:"button",onClick:i,disabled:a,className:"shell-action text-xs",children:"Customize defaults"}),children:[s.jsx(IE,{}),s.jsx($E,{nodes:h.nodes,edges:h.edges,selectedRowKey:null,editable:!1,onSelectEdge:()=>{},onCreateEdge:()=>{},onDeleteEdge:()=>{}})]});const g=d3(e,l),y=hC(e,n),k=e.find(C=>C.rowKey===u)??null;function v(C){o(e.map(D=>D.rowKey===C.rowKey?C:D))}function b(C){o(e.filter(D=>D.rowKey!==C)),u===C&&f(null)}function j(C,D){const T={rowKey:c3(),from:C,command:r[0]??"",to:D,label:"",description:"",requiresReason:!1};o([...e,T]),f(T.rowKey)}const N=((S=n[0])==null?void 0:S.id)??"";return s.jsxs(qe,{title:"Transitions",description:"Statuses are nodes; commands are labeled directed edges. Drag node-to-node to add a transition, or use “Add transition”, then edit it in the panel.",actions:s.jsxs("button",{type:"button",onClick:()=>j(N,N),disabled:a||n.length===0,className:"shell-action text-xs inline-flex items-center gap-1 disabled:opacity-50",children:[s.jsx(Mt,{className:"h-3 w-3"}),"Add transition"]}),children:[g.length>0&&s.jsxs("div",{className:"mb-3 rounded-md border border-error-foreground/30 bg-error/10 px-3 py-2 text-xs text-error-foreground",children:[s.jsx("p",{className:"font-medium",children:"These transitions won't save until fixed:"}),s.jsx("ul",{className:"mt-1 list-disc space-y-0.5 pl-4",children:g.map((C,D)=>s.jsx("li",{children:C},D))})]}),s.jsx(IE,{}),s.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx($E,{nodes:y.nodes,edges:y.edges,selectedRowKey:u,editable:!a,onSelectEdge:f,onCreateEdge:j,onDeleteEdge:b})}),s.jsx("div",{className:"w-full shrink-0 lg:w-80",children:s.jsx(tle,{transition:k,statuses:n,knownCommands:r,onChange:v,onDelete:b,disabled:a})})]})]})}function rle(e){const t=[];e.transitions>0&&t.push({tab:"Transitions",count:e.transitions}),e.derive>0&&t.push({tab:"Derive Rules",count:e.derive}),e.facts>0&&t.push({tab:"Facts",count:e.facts});const n=e.transitions+e.derive+e.facts,r=n===0?"Unsaved changes":`Fix errors in ${t.map(o=>o.tab).join(", ")} to save`;return{total:n,offending:t,message:r}}function sle(){var pt;const[e,t]=m.useState(!0),[n,r]=m.useState(null),[o,i]=m.useState(!1),[a,l]=m.useState([]),[u,f]=m.useState(!1),[p,h]=m.useState(null),[g,y]=m.useState(!1),[k,v]=m.useState(new Set),[b,j]=m.useState(new Map),[N,S]=m.useState({open:!1}),[C,D]=m.useState([]),[T,R]=m.useState([]),[$,P]=m.useState({open:!1}),[F,_]=m.useState(()=>Xy(zp)),[V,U]=m.useState(!1),[I,M]=m.useState(!1),[B,W]=m.useState(!1),[O,H]=m.useState([]),[L,z]=m.useState(!1),[Y,q]=m.useState([]),[Q,ee]=m.useState("statuses"),Z=m.useCallback(Pe=>{const Qe=KQ(Pe);l(Qe),i(Pe.custom),v(new Set(Qe.map(Je=>Je.id))),j(new Map),D(Pe.rawFacts??[]),R([]),_(Xy(Pe.derive??zp)),U(Pe.deriveCustom??!1),M(!1),W(!1),H(yv(Pe.transitions??[])),z(Pe.transitionsCustom??!1),q(Pe.knownCommands??[]),y(!1)},[]),ie=m.useCallback(async()=>{try{const Pe=await fetch("/api/config/statuses");if(!Pe.ok)throw new Error(`HTTP ${Pe.status}`);const Qe=await Pe.json();Z(Qe),r(null)}catch(Pe){r(Pe instanceof Error?Pe.message:"Failed to load config")}finally{t(!1)}},[Z]);m.useEffect(()=>{ie()},[ie]);function ne(){setTimeout(()=>h(null),3e3)}const ue=m.useMemo(()=>a.map(Pe=>({id:Pe.id,label:Pe.label,color:Pe.color,terminal:Pe.terminal})),[a]),ge=m.useMemo(()=>new Set(a.map(Pe=>Pe.id)),[a]),Ne=m.useMemo(()=>lJ(C),[C]),Ce=m.useMemo(()=>Vw(Ne),[Ne]),ke=m.useMemo(()=>GQ(C),[C]),Ue=m.useMemo(()=>{try{return l3(xv(F),a,Ce)}catch{return["derive rules are malformed"]}},[F,a,Ce]),oe=m.useMemo(()=>L?d3(O,ge):[],[O,L,ge]),ve=ke.length+Ue.length+oe.length,be=m.useCallback(Pe=>{D(Pe),y(!0)},[]),Re=m.useCallback(Pe=>{_(Pe),M(!0),W(!1),U(!0),y(!0)},[]),He=m.useCallback(()=>{_(Xy(zp)),W(!0),M(!0),U(!1),y(!0)},[]),rt=m.useCallback(Pe=>{H(Pe),y(!0)},[]),Fe=m.useCallback(()=>{H(Pe=>Pe.length>0?Pe:yv(xJ(u3(),ge))),z(!0),y(!0)},[ge]);async function ot(Pe=T){f(!0),h(null);try{const{body:Qe}=FQ({statuses:a,order:a.map(K=>K.id),pendingResolutions:b,facts:C,factRemovalAcks:Pe,derive:B?null:I?xv(F):void 0,transitions:L?gJ(O):void 0}),Je=await fetch("/api/config/statuses",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Qe)});if(!Je.ok){const K=await Je.json().catch(()=>null);if(Je.status===409&&(K==null?void 0:K.error)==="unresolved-fact-references"&&K.references){P({open:!0,references:K.references}),f(!1);return}if((K==null?void 0:K.error)==="invalid-derive")throw new Error(`Invalid derive rules: ${(K.problems??[]).join("; ")}`);if((K==null?void 0:K.error)==="invalid-transitions")throw new Error(`Invalid transitions: ${(K.problems??[]).join("; ")}`);if((K==null?void 0:K.error)==="invalid-facts")throw new Error(`Invalid facts: ${(K.problems??[]).join("; ")}`);if(Je.status===409&&(K==null?void 0:K.error)==="unresolved-orphans"){const re=Array.isArray(K.unresolved)?K.unresolved.map(xe=>xe.id).join(", "):"";throw new Error(`Cannot save — these statuses have assignments that need a resolution: ${re}. Click the trash icon on each row to choose remap or delete.`)}if(Je.status===409&&(K==null?void 0:K.error)==="concurrent-edit"){const re=K.applied?` (${K.applied.remapped} remapped, ${K.applied.deleted} deleted before the conflict)`:"";h({type:"error",message:`Concurrent edit detected${re}: ${K.cause??"an assignment moved to a still-dropped status during save"}. Refreshing — please re-resolve.`}),await ie();return}if(Je.status===500&&(K==null?void 0:K.error)==="config-write-failed"&&(K!=null&&K.applied)){const{remapped:re,deleted:xe}=K.applied,Ge=K.message?`: ${K.message}`:"";h({type:"error",message:`Resolutions applied (${re} remapped, ${xe} deleted) but the status config write failed${Ge}. Click Save again to retry.`}),await ie();return}throw(K==null?void 0:K.error)==="invalid-remap-target"?new Error(`Invalid remap target (${K.reason}): ${K.id} → ${K.target}.`):(K==null?void 0:K.error)==="duplicate-resolution-ids"?new Error(`Duplicate resolution ids: ${(K.ids??[]).join(", ")}`):(K==null?void 0:K.error)==="stale-resolution"?new Error(`Stale resolution for id "${K.id??"?"}".`):(K==null?void 0:K.error)==="malformed-resolutions"?new Error(`Malformed resolutions: ${K.message??"unknown"}`):(K==null?void 0:K.error)==="remap-write-failed"||(K==null?void 0:K.error)==="delete-failed"||(K==null?void 0:K.error)==="scan-failed"?new Error(`${K.error}: ${K.cause??"unknown"}`):new Error((K==null?void 0:K.error)??`Save failed (HTTP ${Je.status})`)}const ut=await Je.json();Z(ut),J1();const fe=ut.applied?` (${ut.applied.remapped} remapped, ${ut.applied.deleted} deleted)`:"";h({type:"success",message:`Status config saved${fe}`}),ne()}catch(Qe){h({type:"error",message:Qe instanceof Error?Qe.message:"Save failed"})}finally{f(!1)}}async function Nt(){f(!0),h(null);try{const Pe=await fetch("/api/config/statuses",{method:"DELETE"});if(!Pe.ok)throw new Error("Reset failed");const Qe=await Pe.json();Z(Qe),J1(),h({type:"success",message:"Reset to defaults"}),ne()}catch(Pe){h({type:"error",message:Pe instanceof Error?Pe.message:"Reset failed"})}finally{f(!1)}}function mt(Pe,Qe,Je){l(ut=>{const fe=[...ut];return fe[Pe]={...fe[Pe],[Qe]:Je},fe}),y(!0)}function at(){const Pe=`status_${a.length+1}`;l(Qe=>[...Qe,{rowKey:s3(),id:Pe,label:"New Status",description:"",color:"",terminal:!1}]),y(!0)}function ce(Pe){l(Qe=>{const Je=Qe.filter(fe=>fe.id!==Pe),ut=new Set(Je.map(fe=>fe.id));return j(fe=>lC(fe,ut)),Je}),y(!0)}async function me(Pe){const Qe=a[Pe].id,Je=zQ(Qe,F,O),ut=BQ(Qe,F);if(!k.has(Qe)){if(Je.length===0){ce(Qe);return}S({open:!0,affected:{id:Qe,count:0,truncated:!1,assignments:[]},pendingId:Qe,ruleReferences:Je,headlineReferences:ut});return}try{const fe=await fetch(`/api/config/statuses/affected/${encodeURIComponent(Qe)}`);if(!fe.ok)throw new Error(`HTTP ${fe.status}`);const K=await fe.json();if(K.count===0&&Je.length===0){ce(Qe);return}S({open:!0,affected:K,pendingId:Qe,ruleReferences:Je,headlineReferences:ut})}catch(fe){h({type:"error",message:`Could not check affected assignments for "${Qe}": ${fe instanceof Error?fe.message:String(fe)}`})}}function Ie(Pe,Qe){if(!N.open)return;const{pendingId:Je,affected:ut,ruleReferences:fe}=N;if(Je!==Pe.id){S({open:!1});return}if(!a.some(K=>K.id===Je)){h({type:"error",message:`Row for "${Je}" was already removed — modal action ignored.`}),S({open:!1});return}Pe.mode==="remap"?(_(K=>UQ(K,Je,Qe)),H(K=>HQ(K,Je,Qe))):(_(K=>VQ(K,Je,Qe)),H(K=>WQ(K,Je))),fe.some(K=>K.section!=="transitions")&&(M(!0),U(!0)),l(K=>{const re=K.filter(Ge=>Ge.id!==Je),xe=new Set(re.map(Ge=>Ge.id));return j(Ge=>{const ze=lC(Ge,xe),lt=new Map(ze);return ut.count>0&&lt.set(Je,Pe),lt}),re}),y(!0),S({open:!1})}function Ae(){if(!$.open)return;const Pe=$.references.map(Je=>Je.factName),Qe=Array.from(new Set([...T,...Pe]));R(Qe),P({open:!1}),ot(Qe)}function We(){S({open:!1})}return e?s.jsx(bt,{label:"Loading workflow..."}):n?s.jsx(Rt,{error:n}):s.jsx(ha,{children:s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:`flex items-center justify-between rounded-lg border px-4 py-3 text-sm ${o?"border-primary/30 bg-primary/5 text-primary":"border-border/60 bg-muted/30 text-muted-foreground"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Hv,{className:"h-4 w-4"}),o?"Using custom status configuration from ~/.syntaur/config.md":"Using default status configuration"]}),s.jsxs("button",{className:"shell-action text-xs",onClick:Nt,disabled:u||!o&&!g,children:[s.jsx(vs,{className:"h-3 w-3"}),"Reset to Defaults"]})]}),p&&s.jsx("div",{className:`rounded-lg border px-4 py-2 text-sm ${p.type==="success"?"border-success-foreground/30 bg-success text-success-foreground":"border-error-foreground/30 bg-error text-error-foreground"}`,children:p.message}),s.jsx(Um,{value:Q,onValueChange:ee,items:[{value:"statuses",label:"Statuses",content:s.jsx(OQ,{statuses:a,savedStatusIds:k,onUpdate:mt,onAdd:at,onRemove:me,onReorder:Pe=>{l(Pe),y(!0)}})},{value:"transitions",label:"Transitions",problemCount:oe.length,content:s.jsx(nle,{value:O,customizing:L,statuses:ue,knownCommands:Y,onChange:rt,onCustomize:Fe,disabled:u})},{value:"derive",label:"Derive Rules",problemCount:Ue.length,content:s.jsx(dJ,{value:F,deriveCustom:V,statuses:ue,acceptedFacts:Ne,onChange:Re,onReset:He,disabled:u})},{value:"facts",label:"Facts",problemCount:ke.length,content:s.jsx(ZQ,{rows:C,onChange:be,saving:u})}]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("button",{className:"shell-action bg-primary/10 text-primary hover:bg-primary/20 disabled:opacity-50",onClick:()=>void ot(),disabled:u||!g||ve>0,children:[s.jsx(nm,{className:"h-3.5 w-3.5"}),u?"Saving...":"Save Configuration"]}),g&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"shell-action text-xs",onClick:()=>{t(!0),ie()},disabled:u,children:"Discard Changes"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:rle({transitions:oe.length,derive:Ue.length,facts:ke.length}).message})]})]}),N.open&&s.jsx($Q,{open:N.open,affected:{...N.affected,label:((pt=a.find(Pe=>Pe.id===N.affected.id))==null?void 0:pt.label)??N.affected.id},remaining:a.filter(Pe=>Pe.id!==N.affected.id&&k.has(Pe.id)).map(Pe=>({id:Pe.id,label:Pe.label})),ruleReferences:N.ruleReferences,headlineReferences:N.headlineReferences,onResolve:Ie,onCancel:We}),s.jsx(IQ,{open:$.open,references:$.open?$.references:[],onConfirm:Ae,onCancel:()=>{P({open:!1}),f(!1)}})]})})}const vo=e=>`${e.workspace}::${e.id}`;function LE(e){if(e.includes("/")){const[t,n]=e.split("/");return`/projects/${t}/assignments/${n}`}return`/assignments/${e}`}function ole(){var fe;const{data:e,loading:t,error:n,refetch:r}=G2(),{toast:o,showToast:i,dismissToast:a}=Qn(),l=Wt(),[u,f]=m.useState(""),p=m.useRef(null);Ai("list:todos");const[h,g]=m.useState(""),[y,k]=m.useState(""),[v,b]=m.useState(""),[j,N]=m.useState("_global"),[S,C]=m.useState(null),[D,T]=m.useState(null),[R,$]=m.useState(new Set),[P,F]=m.useState(!1),_=m.useRef(null),[V,U]=m.useState(null),I=g0("all"),[M,B]=m.useState(null),[W,O]=m.useState(null),H=m.useRef(null);m.useEffect(()=>{let K=!1;return(async()=>{try{const re=await fetch("/api/projects");if(!re.ok)return;const xe=await re.json();K||U(xe.filter(Ge=>!Ge.archived))}catch{}})(),()=>{K=!0}},[]);async function L(K,re){K.stopPropagation(),await Wd(re)&&(C(re),setTimeout(()=>C(xe=>xe===re?null:xe),1500))}const z=m.useMemo(()=>{if(!(e!=null&&e.workspaces))return[];const K=[];for(const re of e.workspaces)for(const xe of re.items)K.push({...xe,workspace:re.workspace});return K},[e]),Y=m.useMemo(()=>{const K=new Set;for(const re of z)for(const xe of re.tags)K.add(xe);return Array.from(K).sort()},[z]),q=m.useMemo(()=>{let K=z;if(u.trim()){const re=u.toLowerCase();K=K.filter(xe=>xe.description.toLowerCase().includes(re)||xe.tags.some(Ge=>Ge.toLowerCase().includes(re))||xe.id.includes(re))}return h&&(K=K.filter(re=>re.status===h)),y&&(K=K.filter(re=>re.tags.includes(y))),K},[z,u,h,y]);m.useEffect(()=>{$(new Set),_.current=null},[u,h,y]);const Q=m.useMemo(()=>q.filter(K=>R.has(vo(K))),[q,R]),ee=q.length>0&&Q.length===q.length,Z=Q.length>0&&!ee,ie=m.useMemo(()=>{if(Q.length===0)return null;const K=new Set(Q.map(re=>re.workspace));return K.size===1?[...K][0]:null},[Q]),ne=m.useMemo(()=>{if(!ie||!V)return;const K=V.filter(re=>re.workspace===ie);return K.length===1?K[0].slug:void 0},[ie,V]),ue=((fe=Q[0])==null?void 0:fe.description)??"",ge=m.useMemo(()=>{if(ie)return null;const K=new Map;for(const re of Q)K.has(re.workspace)||K.set(re.workspace,[]),K.get(re.workspace).push(re.id);return Array.from(K,([re,xe])=>({workspace:re,todoIds:xe}))},[Q,ie]),Ne=ie?{kind:"workspace",workspace:ie}:{kind:"aggregate",groups:ge??[]};function Ce(K,re,xe){const Ge=vo(K),ze=!!(xe&&"shiftKey"in xe&&xe.shiftKey),lt=_.current?at.findIndex(ht=>vo(ht)===_.current):-1;if(ze&&lt!==-1){const ht=Math.min(lt,re),vt=Math.max(lt,re);$(tt=>{const _t=new Set(tt);for(let zt=ht;zt<=vt;zt++){const Bt=at[zt];Bt&&_t.add(vo(Bt))}return _t})}else $(ht=>{const vt=new Set(ht);return vt.has(Ge)?vt.delete(Ge):vt.add(Ge),vt});_.current=Ge}function ke(){$(K=>{const re=new Set(K);if(ee)for(const xe of q)re.delete(vo(xe));else for(const xe of q)re.add(vo(xe));return re})}function Ue(){$(new Set),_.current=null}function oe(K){Ue(),r(),K!=null&&K.assignmentRef&&l(LE(K.assignmentRef))}const ve=m.useMemo(()=>{if(!(e!=null&&e.workspaces))return{open:0,in_progress:0,completed:0,blocked:0,total:0};const K={open:0,in_progress:0,completed:0,blocked:0,total:0};for(const re of e.workspaces)K.open+=re.counts.open,K.in_progress+=re.counts.in_progress,K.completed+=re.counts.completed,K.blocked+=re.counts.blocked,K.total+=re.counts.total;return K},[e]);function be(K){i(K instanceof Error?K.message:"Action failed","error")}async function Re(){if(v.trim())try{await ew(j,v.trim()),b(""),r(),i("Todo added","success")}catch(K){be(K)}}async function He(K,re,xe){try{switch(xe){case"open":await J2(K,re);break;case"in_progress":await Q2(K,re);break;case"completed":await Y2(K,re);break;case"blocked":await X2(K,re);break}r(),i("Todo updated","success")}catch(Ge){be(Ge)}}async function rt(K,re){try{await Z2(K,re),r(),i("Todo deleted","success")}catch(xe){be(xe)}}async function Fe(K,re,xe){try{await eT(K,re,xe),r(),i("Todo updated","success")}catch(Ge){throw be(Ge),Ge}}async function ot(K,re,xe){try{await tT(K,re,xe),r(),i(xe.length===1?"Attachment added":`${xe.length} attachments added`,"success")}catch(Ge){be(Ge)}}async function Nt(K,re,xe){try{await nT(K,re,xe),r(),i("Attachment removed","success")}catch(Ge){be(Ge)}}const mt=m0(q),at=mt.filter(K=>!I.isCollapsed(K.config.id)).flatMap(K=>K.items),{hotkeyRowProps:ce}=Id(at,{scope:"list:todos",bindO:!1,onOpen:K=>T(vo(K))});en({keys:"/",scope:"list:todos",description:"Focus filter",handler:()=>{var K;return(K=p.current)==null?void 0:K.focus()}}),en({keys:"r",scope:"list:todos",description:"Refresh",handler:()=>r()});const[me,Ie]=Ts(),Ae=me.get("focus");m.useEffect(()=>{if(!Ae)return;const K=z.find(xe=>xe.id===Ae);if(!K)return;const re=qm(K.status);I.isCollapsed(re)&&I.toggle(re)},[Ae,z]),m.useEffect(()=>{if(!Ae)return;const K=document.querySelector(`[data-todo-id="${CSS.escape(Ae)}"]`);if(!K)return;K.scrollIntoView({block:"nearest"}),K.classList.add("ring-2","ring-primary/60");const re=window.setTimeout(()=>{K.classList.remove("ring-2","ring-primary/60"),Ie(xe=>{const Ge=new URLSearchParams(xe);return Ge.delete("focus"),Ge})},1500);return()=>window.clearTimeout(re)},[Ae,at.length,Ie]);const We=M?q.find(K=>vo(K)===M)??null:null;function pt(K,re){const xe=H.current;if(xe!=null&&xe.closest(nc)){K.preventDefault();return}K.dataTransfer.effectAllowed="move",K.dataTransfer.setData("text/plain",re),B(re)}function Pe(){B(null),O(null)}function Qe(K,re){!We||re.statuses.includes(We.status)||(K.preventDefault(),K.dataTransfer.dropEffect="move",O(re.id))}function Je(K,re){W===re.id&&!K.currentTarget.contains(K.relatedTarget)&&O(null)}function ut(K,re){K.preventDefault();const xe=We;Pe(),!(!xe||re.statuses.includes(xe.status))&&He(xe.workspace,xe.id,re.dropStatus)}return t?s.jsx(bt,{label:"Loading todos..."}):n?s.jsx(Rt,{error:n}):s.jsxs("div",{className:"space-y-4",children:[s.jsx(Xn,{toast:o,onDismiss:a}),s.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",children:[s.jsx(Gn,{label:"Open",value:ve.open,icon:ys}),s.jsx(Gn,{label:"In Progress",value:ve.in_progress,icon:Vv,tone:"info"}),s.jsx(Gn,{label:"Blocked",value:ve.blocked,icon:rm,tone:"warn"}),s.jsx(Gn,{label:"Completed",value:ve.completed,icon:ys,tone:"default"})]}),s.jsx("div",{className:"surface-panel p-3",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:j,onChange:K=>N(K.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"_global",children:"Global"}),e==null?void 0:e.workspaces.filter(K=>K.workspace!=="_global").map(K=>s.jsx("option",{value:K.workspace,children:K.workspace},K.workspace))]}),s.jsx("input",{type:"text",placeholder:"Add a todo...",value:v,onChange:K=>b(K.target.value),onKeyDown:K=>K.key==="Enter"&&Re(),className:"h-9 flex-1 rounded-md border border-border/70 bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"}),s.jsxs("button",{onClick:Re,disabled:!v.trim(),className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-40",children:[s.jsx(Mt,{className:"h-4 w-4"}),"Add"]})]})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative flex-1 max-w-sm",children:[s.jsx(Ci,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:p,type:"text",placeholder:"Search todos...",value:u,onChange:K=>f(K.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),s.jsxs("select",{value:h,onChange:K=>g(K.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"",children:"All statuses"}),s.jsx("option",{value:"open",children:"Open"}),s.jsx("option",{value:"in_progress",children:"In Progress"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"blocked",children:"Blocked"})]}),Y.length>0&&s.jsxs("select",{value:y,onChange:K=>k(K.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"",children:"All tags"}),Y.map(K=>s.jsxs("option",{value:K,children:["#",K]},K))]})]}),Q.length>0?s.jsxs("div",{className:"surface-panel flex items-center justify-between gap-3 px-3 py-2",children:[s.jsxs("span",{className:"text-sm font-medium",children:[Q.length," selected",ie?s.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(from ",s.jsx("strong",{children:ie}),")"]}):s.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["across ",new Set(Q.map(K=>K.workspace)).size," workspaces"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>F(!0),className:"shell-action shell-action--cta",children:"Promote to assignment"}),s.jsx("button",{type:"button",onClick:Ue,className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]})]}):null,q.length>0&&s.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox","aria-label":"Select all visible todos",checked:ee,ref:K=>{K&&(K.indeterminate=Z)},onChange:ke,className:"h-4 w-4 cursor-pointer accent-foreground"}),s.jsxs("span",{children:["Select all in current filter (",q.length,")"]}),s.jsx("span",{className:"text-muted-foreground/60",children:"— shift-click for range select"})]}),s.jsx("div",{className:"space-y-3",children:(()=>{let K=-1;return mt.map(({config:re,items:xe})=>{const Ge=!I.isCollapsed(re.id);return s.jsx(h0,{label:re.label,count:xe.length,expanded:Ge,onToggle:()=>I.toggle(re.id),isDropTarget:W===re.id,onDragOver:ze=>Qe(ze,re),onDragLeave:ze=>Je(ze,re),onDrop:ze=>ut(ze,re),children:Ge&&xe.map(ze=>{K+=1;const lt=K,ht=vo(ze),vt=R.has(ht);return s.jsxs("div",{draggable:!0,"data-todo-id":ze.id,...ce(lt),onMouseDown:tt=>{H.current=tt.target},onDragStart:tt=>pt(tt,ht),onDragEnd:Pe,className:`surface-panel flex items-start gap-3 px-3 py-2 group cursor-grab active:cursor-grabbing hover:bg-foreground/[0.03] transition ${vt?"ring-1 ring-foreground/20":""} ${M===ht?"opacity-50 shadow-lg":""}`,children:[s.jsx("input",{type:"checkbox","data-no-drag":!0,"aria-label":`Select todo ${ze.id}`,title:"Select",checked:vt,onChange:()=>{},onClick:tt=>{tt.stopPropagation(),Ce(ze,lt,tt)},className:"mt-1 h-4 w-4 shrink-0 cursor-pointer accent-foreground"}),s.jsx("span",{className:"mt-0.5 self-stretch w-px bg-border/60","aria-hidden":"true"}),s.jsx("div",{className:"mt-0.5 shrink-0",children:s.jsx(i_,{status:ze.status,onChange:tt=>He(ze.workspace,ze.id,tt)})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-baseline flex-wrap gap-x-2",children:[s.jsx(l_,{description:ze.description,status:ze.status,editing:D===ht,onBeginEdit:()=>T(ht),onEndEdit:()=>T(null),onSave:tt=>Fe(ze.workspace,ze.id,tt)}),ze.tags.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:ze.tags.map(tt=>`#${tt}`).join(" ")}),ze.linkedAssignmentRef?s.jsxs(De,{to:LE(ze.linkedAssignmentRef),"data-no-drag":!0,className:"inline-flex items-center gap-0.5 rounded-full border border-status-completed-foreground/40 bg-status-completed/30 px-1.5 py-0.5 text-[10px] font-mono text-status-completed-foreground hover:bg-status-completed/50",onClick:tt=>tt.stopPropagation(),children:[s.jsx(Zh,{className:"h-2.5 w-2.5"}),ze.linkedAssignmentRef.includes("/")?ze.linkedAssignmentRef:`oneoff:${ze.linkedAssignmentRef.slice(0,8)}`]}):null]}),s.jsx(c_,{item:ze,attachmentUrl:(tt,_t)=>tw(ze.workspace,tt,_t),onAdd:tt=>ot(ze.workspace,ze.id,tt),onDelete:tt=>Nt(ze.workspace,ze.id,tt)})]}),s.jsx("span",{className:"text-xs text-muted-foreground/60 font-mono",children:ze.workspace!=="_global"&&s.jsx(De,{to:`/w/${ze.workspace}/todos`,className:"hover:text-foreground transition mr-2",onClick:tt=>tt.stopPropagation(),children:ze.workspace})}),S===ze.id?s.jsxs("span",{className:"text-xs text-status-completed-foreground flex items-center gap-1",children:[s.jsx(Sr,{className:"h-3 w-3"})," Copied to clipboard"]}):s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"text-xs text-muted-foreground/60 font-mono hover:text-foreground transition",onClick:tt=>L(tt,ze.id),children:["t:",ze.id]}),s.jsx("button",{className:"text-muted-foreground/40 hover:text-foreground transition",title:"Copy ID",onClick:tt=>L(tt,ze.id),children:s.jsx(ah,{className:"h-3 w-3"})})]}),s.jsx("button",{onClick:tt=>{tt.stopPropagation(),rt(ze.workspace,ze.id)},className:"text-xs text-muted-foreground/40 hover:text-destructive transition opacity-0 group-hover:opacity-100",children:"delete"})]},`${ze.workspace}-${ze.id}`)})},re.id)})})()}),s.jsx(p0,{open:P,selectedIds:Q.map(K=>K.id),scope:Ne,onOpenChange:F,onDone:oe,defaultProject:ne,defaultTitle:ue,allowOneOff:!0})]})}const ile={open:{icon:"○",cls:"text-muted-foreground",label:"Open"},in_progress:{icon:"◉",cls:"text-status-in-progress-foreground",label:"In progress"},blocked:{icon:"✕",cls:"text-status-blocked-foreground",label:"Blocked"},completed:{icon:"✓",cls:"text-status-completed-foreground",label:"Completed"},mixed:{icon:"◐",cls:"text-muted-foreground",label:"Mixed"}};function ale({bundle:e}){const t=ile[e.derivedStatus.status],{counts:n}=e.derivedStatus;return s.jsxs("div",{className:"border rounded-md p-3 mb-2 bg-card",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:`text-lg leading-none ${t.cls}`,title:t.label,children:t.icon}),s.jsxs("span",{className:"font-mono text-sm text-muted-foreground",children:["b:",e.id]}),e.slug&&s.jsx("span",{className:"font-medium",children:e.slug}),s.jsxs("span",{className:"ml-auto text-sm text-muted-foreground",children:[n.completed,"/",n.total," done"]})]}),s.jsxs("div",{className:"mt-2 grid gap-1 text-sm",children:[e.branch&&s.jsxs("div",{className:"text-muted-foreground",children:[s.jsx("span",{className:"font-medium",children:"Branch:"})," ",s.jsx("code",{className:"font-mono",children:e.branch})]}),e.worktreePath&&s.jsxs("div",{className:"text-muted-foreground truncate",children:[s.jsx("span",{className:"font-medium",children:"Worktree:"})," ",s.jsx("code",{className:"font-mono",children:e.worktreePath})]}),e.planDir&&s.jsxs("div",{className:"text-muted-foreground truncate",children:[s.jsx("span",{className:"font-medium",children:"Plan:"})," ",s.jsx("code",{className:"font-mono",children:e.planDir})]})]}),s.jsx("ul",{className:"mt-2 ml-6 text-sm list-disc",children:e.members.map(r=>s.jsxs("li",{className:r.status==="completed"?"line-through text-muted-foreground":"",children:[s.jsxs("span",{className:"font-mono text-xs text-muted-foreground mr-2",children:["t:",r.id]}),r.description]},r.id))})]})}function lle({bundles:e,title:t="Bundles"}){return e.length===0?null:s.jsxs("section",{className:"mb-6",children:[s.jsxs("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:[t," (",e.length,")"]}),e.map(n=>s.jsx(ale,{bundle:n},n.id))]})}function cle(e){const[t,n]=m.useState(null),[r,o]=m.useState(!0),[i,a]=m.useState(null),l=m.useCallback(async()=>{try{const u=await fetch(`/api/bundles/${encodeURIComponent(e)}`);if(!u.ok)throw new Error(`HTTP ${u.status}`);n(await u.json()),a(null)}catch(u){a(u instanceof Error?u.message:"Failed to fetch bundles")}finally{o(!1)}},[e]);return m.useEffect(()=>{l()},[l]),Ei(u=>{u.type==="todos-updated"&&!u.projectSlug&&l()}),{data:t,loading:r,error:i,refetch:l}}function ule(){const{workspace:e}=qt(),t=e||"_global",{data:n,loading:r,error:o,refetch:i}=o5(t),{toast:a,showToast:l,dismissToast:u}=Qn(),{data:f}=cle(t),[p,h]=m.useState(""),[g,y]=m.useState(""),[k,v]=m.useState(""),[b,j]=m.useState(""),[N,S]=m.useState(null),[C,D]=m.useState(!1),[T,R]=m.useState(null),[$,P]=m.useState(null),[F,_]=m.useState(new Set),[V,U]=m.useState(!1),[I,M]=m.useState(!1),[B,W]=m.useState(null),O=m.useRef(null);Ai("list:todos");const H=g0("workspace:"+t),[L,z]=m.useState(null),[Y,q]=m.useState(null),Q=m.useRef(null);async function ee(K,re){K.stopPropagation(),await Wd(re)&&(R(re),setTimeout(()=>R(xe=>xe===re?null:xe),1500))}const Z=m.useMemo(()=>{if(!(n!=null&&n.items))return[];const K=new Set;for(const re of n.items)for(const xe of re.tags)K.add(xe);return Array.from(K).sort()},[n]),ie=m.useMemo(()=>{if(!(n!=null&&n.items))return[];let K=n.items;if(p.trim()){const re=p.toLowerCase();K=K.filter(xe=>xe.description.toLowerCase().includes(re)||xe.tags.some(Ge=>Ge.toLowerCase().includes(re))||xe.id.includes(re))}return g&&(K=K.filter(re=>re.status===g)),k&&(K=K.filter(re=>re.tags.includes(k))),K},[n,p,g,k]);m.useEffect(()=>{_(new Set)},[p,g,k,t]);const ne=m.useMemo(()=>ie.filter(K=>F.has(K.id)).length,[ie,F]),ue=ie.length>0&&ne===ie.length,ge=ne>0&&!ue;function Ne(K){_(re=>{const xe=new Set(re);return xe.has(K)?xe.delete(K):xe.add(K),xe})}function Ce(){_(K=>{const re=new Set(K);if(ue)for(const xe of ie)re.delete(xe.id);else for(const xe of ie)re.add(xe.id);return re})}function ke(){_(new Set)}const Ue=B?[B]:Array.from(F);function oe(){_(new Set),W(null),i()}function ve(){_(new Set),i()}function be(K){l(K instanceof Error?K.message:"Action failed","error")}async function Re(){if(b.trim())try{await ew(t,b.trim()),j(""),i()}catch(K){be(K)}}function He(K,re,xe){K.stopPropagation(),S({id:re,description:xe})}async function rt(K,re){try{switch(re){case"open":await J2(t,K);break;case"in_progress":await Q2(t,K);break;case"completed":await Y2(t,K);break;case"blocked":await X2(t,K);break}i()}catch(xe){be(xe)}}async function Fe(K,re){try{await eT(t,K,re),i()}catch(xe){throw be(xe),xe}}async function ot(K,re){try{await tT(t,K,re),i()}catch(xe){be(xe)}}async function Nt(K,re){try{await nT(t,K,re),i()}catch(xe){be(xe)}}const mt=m0(ie),at=mt.filter(K=>!H.isCollapsed(K.config.id)).flatMap(K=>K.items),{hotkeyRowProps:ce}=Id(at,{scope:"list:todos",bindO:!1,onOpen:K=>P(K.id)});en({keys:"/",scope:"list:todos",description:"Focus filter",handler:()=>{var K;return(K=O.current)==null?void 0:K.focus()}}),en({keys:"r",scope:"list:todos",description:"Refresh",handler:()=>i()});const[me,Ie]=Ts(),Ae=me.get("focus");m.useEffect(()=>{if(!Ae||!(n!=null&&n.items))return;const K=n.items.find(xe=>xe.id===Ae);if(!K)return;const re=qm(K.status);H.isCollapsed(re)&&H.toggle(re)},[Ae,n==null?void 0:n.items]),m.useEffect(()=>{if(!Ae)return;const K=document.querySelector(`[data-todo-id="${window.CSS.escape(Ae)}"]`);if(!K)return;K.scrollIntoView({block:"nearest"}),K.classList.add("ring-2","ring-primary/60");const re=window.setTimeout(()=>{K.classList.remove("ring-2","ring-primary/60"),Ie(xe=>{const Ge=new URLSearchParams(xe);return Ge.delete("focus"),Ge})},1500);return()=>window.clearTimeout(re)},[Ae,at.length,Ie]);const We=L?(n==null?void 0:n.items.find(K=>K.id===L))??null:null;function pt(K,re){const xe=Q.current;if(xe!=null&&xe.closest(nc)){K.preventDefault();return}K.dataTransfer.effectAllowed="move",K.dataTransfer.setData("text/plain",re),z(re)}function Pe(){z(null),q(null)}function Qe(K,re){!We||re.statuses.includes(We.status)||(K.preventDefault(),K.dataTransfer.dropEffect="move",q(re.id))}function Je(K,re){Y===re.id&&!K.currentTarget.contains(K.relatedTarget)&&q(null)}function ut(K,re){K.preventDefault();const xe=We;Pe(),!(!xe||re.statuses.includes(xe.status))&&rt(xe.id,re.dropStatus)}if(r)return s.jsx(bt,{label:"Loading todos..."});if(o)return s.jsx(Rt,{error:o});const fe=(n==null?void 0:n.counts)||{open:0,in_progress:0,blocked:0,total:0};return s.jsxs("div",{className:"space-y-4",children:[s.jsx(Xn,{toast:a,onDismiss:u}),s.jsx(ss,{open:N!==null,title:"Delete todo?",description:`Delete "${(N==null?void 0:N.description)??""}"? This can't be undone.`,confirmLabel:"Delete",destructive:!0,loading:C,onOpenChange:K=>{!K&&!C&&S(null)},onConfirm:async()=>{if(N){D(!0);try{await Z2(t,N.id),i(),S(null)}catch(K){be(K)}finally{D(!1)}}}}),s.jsxs("div",{className:"grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",children:[s.jsx(Gn,{label:"Open",value:fe.open,icon:ys}),s.jsx(Gn,{label:"In Progress",value:fe.in_progress,icon:ys,tone:"info"}),s.jsx(Gn,{label:"Blocked",value:fe.blocked,icon:rm,tone:"warn"}),s.jsx(Gn,{label:"Total",value:fe.total,icon:ys})]}),f&&s.jsx(lle,{bundles:f.bundles}),s.jsx("div",{className:"surface-panel p-3",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Add a todo...",value:b,onChange:K=>j(K.target.value),onKeyDown:K=>K.key==="Enter"&&Re(),className:"h-9 flex-1 rounded-md border border-border/70 bg-background px-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"}),s.jsxs("button",{onClick:Re,disabled:!b.trim(),className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-foreground px-3 text-sm font-medium text-background transition hover:bg-foreground/90 disabled:opacity-40",children:[s.jsx(Mt,{className:"h-4 w-4"}),"Add"]})]})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative flex-1 max-w-sm",children:[s.jsx(Ci,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:O,type:"text",placeholder:"Search...",value:p,onChange:K=>h(K.target.value),className:"h-9 w-full rounded-md border border-border/70 bg-background pl-9 pr-3 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/30 focus:outline-none"})]}),s.jsxs("select",{value:g,onChange:K=>y(K.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"",children:"All statuses"}),s.jsx("option",{value:"open",children:"Open"}),s.jsx("option",{value:"in_progress",children:"In Progress"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"blocked",children:"Blocked"})]}),Z.length>0&&s.jsxs("select",{value:k,onChange:K=>v(K.target.value),className:"h-9 rounded-md border border-border/70 bg-background px-2 text-sm text-foreground focus:border-foreground/30 focus:outline-none",children:[s.jsx("option",{value:"",children:"All tags"}),Z.map(K=>s.jsxs("option",{value:K,children:["#",K]},K))]})]}),F.size>0?s.jsxs("div",{className:"surface-panel flex items-center justify-between gap-3 px-3 py-2",children:[s.jsxs("span",{className:"text-sm font-medium",children:[F.size," selected"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>U(!0),className:"shell-action shell-action--cta",children:"Promote selected"}),s.jsx("button",{type:"button",onClick:()=>{W(null),M(!0)},className:"shell-action",children:"Move to…"}),s.jsx("button",{type:"button",onClick:ke,className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]})]}):null,ie.length>0&&s.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox","aria-label":"Select all visible todos",checked:ue,ref:K=>{K&&(K.indeterminate=ge)},onChange:Ce,className:"h-4 w-4 cursor-pointer accent-foreground"}),s.jsxs("span",{children:["Select all in current filter (",ie.length,")"]})]}),s.jsx("div",{className:"space-y-3",children:(()=>{let K=-1;return mt.map(({config:re,items:xe})=>{const Ge=!H.isCollapsed(re.id);return s.jsx(h0,{label:re.label,count:xe.length,expanded:Ge,onToggle:()=>H.toggle(re.id),isDropTarget:Y===re.id,onDragOver:ze=>Qe(ze,re),onDragLeave:ze=>Je(ze,re),onDrop:ze=>ut(ze,re),children:Ge&&xe.map(ze=>(K+=1,s.jsx(a_,{item:ze,copiedId:T,selected:F.has(ze.id),editing:$===ze.id,onBeginEdit:lt=>P(lt),onEndEdit:()=>P(null),onPatchDescription:Fe,onAddAttachments:ot,onDeleteAttachment:Nt,attachmentUrl:(lt,ht)=>tw(t,lt,ht),onToggleSelected:lt=>Ne(lt),onMoveOne:(lt,ht)=>{ht.stopPropagation(),W(lt),M(!0)},onStatusChange:rt,onCopyId:ee,onDelete:He,hotkeyRowProps:ce(K),onDragOrigin:lt=>{Q.current=lt.target},onDragStart:pt,onDragEnd:Pe,isDragging:L===ze.id},ze.id)))},re.id)})})()}),s.jsx(p0,{open:V,selectedIds:Array.from(F),scope:{kind:"workspace",workspace:t},onOpenChange:U,onDone:ve}),s.jsx(d_,{open:I,selectedIds:Ue,scope:{kind:"workspace",workspace:t},onOpenChange:K=>{M(K),K||W(null)},onDone:oe})]})}function k$(){const{views:e}=zd();async function t(i,a,l){const u=e.find(h=>h.id===i.id)??i,f=YA(l,u.workspace).config,p=Nh(u.config,f,u.config);await vh(i.id,{name:a,config:p})}async function n(i,a,l){const u=e.find(h=>h.id===i.id)??i,f=Ww(l,u.workspace).config,p=Nh(u.config,f,u.config);await vh(i.id,{name:a,config:p})}async function r(i){await Zl({name:`${i.name} (copy)`,workspace:i.workspace,config:i.config,entityType:i.entityType})}async function o(i){await b7(i.id)}return{submitEdit:t,submitEditSession:n,duplicate:r,remove:o}}const ME=80,dle={kanban:"Kanban",list:"List",table:"Table"},fle={title:"Title",status:"Status",priority:"Priority",assignee:"Assignee",dependencies:"Dependencies",created:"Created",updated:"Updated"};function S$({open:e,onOpenChange:t,workspace:n,initialView:r,onSubmit:o}){const i=!!r,a=As(),l=$d(),{data:u}=to(),{data:f}=om(),[p,h]=m.useState(""),[g,y]=m.useState(ml.viewMode),[k,v]=m.useState([]),[b,j]=m.useState([]),[N,S]=m.useState([]),[C,D]=m.useState([]),[T,R]=m.useState([]),[$,P]=m.useState([]),[F,_]=m.useState("all"),[V,U]=m.useState(null),[I,M]=m.useState(""),[B,W]=m.useState(ml.sortField),[O,H]=m.useState(ml.sortDirection),[L,z]=m.useState(!1),[Y,q]=m.useState(null);function Q(){y(ml.viewMode),v([]),j([]),S([]),D([]),R([]),P([]),_("all"),U(null),M(""),W(ml.sortField),H(ml.sortDirection)}m.useEffect(()=>{if(e)if(q(null),z(!1),r){const oe=r.config.filters;h(r.name),y(r.config.viewMode),v(Ve(oe.status)),j(Ve(oe.priority)),S(Ve(oe.type)),D(Ve(oe.project)),R(Ve(oe.assignee)),P(Ve(oe.tags)),_(oe.activity??"all"),U(Om(oe.dateRange)),M(oe.search??""),W(r.config.sortField),H(r.config.sortDirection)}else h(""),Q()},[e,r]);const ee=oe=>ve=>oe?oe==="_ungrouped"?ve.projectWorkspace===null:ve.projectWorkspace===oe:!0,Z=m.useMemo(()=>{const oe=be=>n?n==="_ungrouped"?be.workspace===null:be.workspace===n:!0,ve=(u??[]).filter(oe);return[{value:"__standalone__",label:"No project"},...ve.map(be=>({value:be.slug,label:be.title}))]},[u,n]),ie=m.useMemo(()=>{const oe=new Set,ve=ee(n);for(const Re of(f==null?void 0:f.assignments)??[])ve(Re)&&Re.assignee&&oe.add(Re.assignee);const be=[{value:"__unassigned__",label:"Unassigned"}];for(const Re of Array.from(oe).sort())be.push({value:Re,label:Re});return be},[f,n]),ne=m.useMemo(()=>{const oe=new Set,ve=ee(n);for(const be of(f==null?void 0:f.assignments)??[])if(ve(be))for(const Re of be.tags??[])oe.add(Re);return Array.from(oe).sort().map(be=>({value:be,label:be}))},[f,n]),ue=m.useMemo(()=>a.order.map(oe=>({value:oe,label:Co(a,oe)})),[a]),ge=m.useMemo(()=>WH.map(oe=>({value:oe,label:oe[0].toUpperCase()+oe.slice(1)})),[]),Ne=m.useMemo(()=>l.definitions.map(oe=>({value:oe.id,label:Fl(l,oe.id)})),[l]),Ce=xw.map(oe=>({value:oe,label:dle[oe]})),ke=p.trim(),Ue=ke.length>0&&ke.length<=ME;return s.jsx(Mn,{open:e,onOpenChange:t,children:s.jsx(Nn,{className:"max-w-lg",children:s.jsxs("form",{className:"space-y-4",onSubmit:async oe=>{if(oe.preventDefault(),!Ue||L)return;z(!0),q(null);const ve={viewMode:g,filters:{status:k,priority:b,type:N,project:C,assignee:T,tags:$,activity:F,dateRange:ma(V),search:I},sortField:B,sortDirection:O};try{await o(ke,ve)}catch(be){q(be instanceof Error?be.message:String(be)),z(!1)}},children:[s.jsx(sr,{children:s.jsx(Cn,{children:i?"Edit view":"Create view"})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"block text-xs font-medium text-muted-foreground",htmlFor:"create-view-name",children:"Name"}),s.jsx("input",{id:"create-view-name",type:"text",value:p,autoFocus:!0,required:!0,maxLength:ME,onChange:oe=>h(oe.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"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:"View mode"}),s.jsx(zm,{value:g,onChange:oe=>y(oe),options:Ce})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[s.jsx(Hs,{label:"Status",children:s.jsx(wn,{ariaLabel:"Status filter",className:"w-full",allLabel:"All statuses",options:ue,value:k,onChange:v})}),s.jsx(Hs,{label:"Priority",children:s.jsx(wn,{ariaLabel:"Priority filter",className:"w-full",allLabel:"All priorities",options:ge,value:b,onChange:j})}),s.jsx(Hs,{label:"Type",children:s.jsx(wn,{ariaLabel:"Type filter",className:"w-full",allLabel:"All types",options:Ne,value:N,onChange:S})}),s.jsx(Hs,{label:"Project",children:s.jsx(wn,{ariaLabel:"Project filter",className:"w-full",allLabel:"All projects",options:Z,value:C,onChange:D})}),s.jsx(Hs,{label:"Assignee",children:s.jsx(wn,{ariaLabel:"Assignee filter",className:"w-full",allLabel:"All assignees",options:ie,value:T,onChange:R})}),s.jsx(Hs,{label:"Tags",children:s.jsx(wn,{ariaLabel:"Tags filter",className:"w-full",allLabel:"Any tags",options:ne,value:$,onChange:P})}),s.jsx(Hs,{label:"Activity",children:s.jsxs("select",{value:F,onChange:oe=>_(oe.target.value),className:"editor-input w-full",children:[s.jsx("option",{value:"all",children:"All activity"}),s.jsx("option",{value:"stale",children:"Stale only"}),s.jsx("option",{value:"fresh",children:"Fresh only"})]})}),s.jsx(Hs,{label:"Date range",children:s.jsx(Mm,{className:"w-full",value:V,onChange:U})}),s.jsx(Hs,{label:"Search",className:"sm:col-span-2",children:s.jsx("input",{type:"text",value:I,onChange:oe=>M(oe.target.value),placeholder:"Title / slug / project contains…",className:"editor-input w-full"})}),s.jsx(Hs,{label:"Sort by",className:"sm:col-span-2",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx("select",{value:B,onChange:oe=>W(oe.target.value),className:"editor-input w-full",children:UT.map(oe=>s.jsx("option",{value:oe,children:fle[oe]??oe},oe))}),s.jsx("button",{type:"button",onClick:()=>H(oe=>oe==="asc"?"desc":"asc"),className:"shell-action shrink-0",title:O==="asc"?"Ascending":"Descending",children:O==="asc"?"Asc":"Desc"})]})})]}),Y?s.jsx("p",{className:"text-xs text-error-foreground",role:"alert",children:Y}):null,s.jsxs(Wr,{className:"sm:justify-between",children:[s.jsx("button",{type:"button",onClick:Q,className:"shell-action",disabled:L,children:"Clear all"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>t(!1),className:"shell-action",disabled:L,children:"Cancel"}),s.jsx("button",{type:"submit",disabled:!Ue||L,className:"shell-action shell-action--cta disabled:opacity-50",children:L?"Saving…":i?"Save changes":"Create view"})]})]})]})})})}function Hs({label:e,className:t,children:n}){return s.jsxs("label",{className:`space-y-1 ${t??""}`,children:[s.jsx("span",{className:"block text-xs font-medium text-muted-foreground",children:e}),n]})}const ple={kanban:"Kanban",list:"List",table:"Table"},hle={assignment:"Assignment",session:"Session"},mle={assignment:"bg-muted text-muted-foreground",session:"bg-primary/10 text-primary"};function OE(){const{workspace:e}=qt(),{views:t,loading:n}=zd(),{submitEdit:r,submitEditSession:o,duplicate:i,remove:a}=k$(),{toast:l,showToast:u,dismissToast:f}=Qn(),[p,h]=m.useState(null),[g,y]=m.useState(!1),[k,v]=m.useState(!1),[b,j]=m.useState(!1),[N,S]=m.useState(null);async function C(U,I){const{workspace:M,config:B}=YA(I,e??null);try{await Zl({name:U,workspace:M,config:B}),v(!1),u(`Created view "${U}"`)}catch(W){throw u(W instanceof Error?W.message:"Failed to create saved view"),W}}async function D(U,I){const{workspace:M,config:B}=Ww(I,e??null);try{await Zl({name:U,workspace:M,config:B,entityType:"session"}),j(!1),u(`Created session view "${U}"`)}catch(W){throw u(W instanceof Error?W.message:"Failed to create session view"),W}}async function T(U,I,M){try{await r(U,I,M),S(null),u(`Updated view "${I}"`)}catch(B){throw u(B instanceof Error?B.message:"Failed to update saved view"),B}}async function R(U,I,M){try{await o(U,I,M),S(null),u(`Updated session view "${I}"`)}catch(B){throw u(B instanceof Error?B.message:"Failed to update session view"),B}}async function $(U){try{await i(U),u(`Duplicated "${U.name}"`)}catch(I){u(I instanceof Error?I.message:"Failed to duplicate saved view")}}async function P(){if(p){y(!0);try{await a(p),h(null)}catch(U){u(U instanceof Error?U.message:"Failed to delete saved view")}finally{y(!1)}}}const F=s.jsxs("button",{type:"button",onClick:()=>v(!0),className:"shell-action inline-flex items-center gap-1.5 shell-action--cta",children:[s.jsx(Mt,{className:"h-4 w-4"}),"Create view"]}),_=s.jsxs("button",{type:"button",onClick:()=>j(!0),className:"shell-action inline-flex items-center gap-1.5",children:[s.jsx(Mt,{className:"h-4 w-4"}),"Create session view"]}),V=(N==null?void 0:N.entityType)==="session";return s.jsxs("div",{className:"space-y-4",children:[s.jsx(Rh,{title:"Saved Views",description:"Create a view here, or open, edit, and reuse views captured from any board.",actions:s.jsxs("div",{className:"flex items-center gap-2",children:[_,F]})}),n?s.jsx(bt,{label:"Loading saved views…"}):t.length===0?s.jsx(St,{title:"No saved views yet",description:"Create your first view here, or capture one from any assignments board.",actions:s.jsxs("div",{className:"flex items-center gap-2",children:[_,F]})}):s.jsx(qe,{children:s.jsx("ul",{className:"divide-y divide-border/60",children:t.map(U=>s.jsx(gle,{view:U,onRequestDelete:()=>h(U),onRequestEdit:()=>S(U),onRequestDuplicate:()=>void $(U)},U.id))})}),s.jsx(S$,{open:k||!V&&N!==null,onOpenChange:U=>{U||(v(!1),V||S(null))},workspace:N&&!V?N.workspace:e??null,initialView:N&&!V?N:null,onSubmit:N&&!V?(U,I)=>T(N,U,I):C}),s.jsx(eP,{open:b||V&&N!==null,onOpenChange:U=>{U||(j(!1),V&&S(null))},workspace:N&&V?N.workspace:e??null,initialView:N&&V?N:null,onSubmit:N&&V?(U,I)=>R(N,U,I):D}),s.jsx(ss,{open:p!==null,title:"Delete saved view?",description:p?`Delete '${p.name}'? Any Overview widgets referencing this view will become empty.`:"",confirmLabel:"Delete",loading:g,destructive:!0,onConfirm:P,onOpenChange:U=>{!U&&!g&&h(null)}}),s.jsx(Xn,{toast:l,onDismiss:f})]})}function gle({view:e,onRequestDelete:t,onRequestEdit:n,onRequestDuplicate:r}){const o=Wt(),i=()=>o(QA(e)),a=ZA(e.config.filters),l=e.workspace?bn(e.workspace):null,u=e.entityType??"assignment",f=u==="session",p=f?`limit: ${e.config.limit??"none"} · sort: ${e.config.sortField} ${e.config.sortDirection}`:null;return s.jsxs("li",{className:"flex flex-wrap items-center gap-3 py-3",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:i,className:"truncate text-left text-sm font-semibold text-foreground hover:text-primary",title:"Open view",children:e.name}),s.jsx("span",{className:`inline-flex shrink-0 items-center rounded-full border border-border/70 px-2 py-0.5 text-xs font-medium ${mle[u]??"bg-muted text-muted-foreground"}`,children:hle[u]??u}),!f&&s.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border/70 bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:ple[e.config.viewMode]}),l?s.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border/70 bg-muted/60 px-2 py-0.5 text-xs text-muted-foreground",children:l}):null]}),s.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:[a,p?` · ${p}`:""]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx("button",{type:"button",onClick:i,className:"shell-action",children:"Open"}),s.jsx("button",{type:"button",onClick:n,className:"shell-action",children:"Edit"}),s.jsx("button",{type:"button",onClick:r,className:"shell-action",children:"Duplicate"}),s.jsx("button",{type:"button",onClick:t,className:"shell-action border-destructive/40 text-destructive hover:bg-destructive/10",children:"Delete"})]})]})}const xle={kanban:"Kanban",list:"List",table:"Table"};function FE(){const{id:e,workspace:t}=qt(),n=Wt(),{view:r,ready:o,error:i,refetch:a}=ki(e),{submitEdit:l,duplicate:u,remove:f}=k$(),{toast:p,showToast:h,dismissToast:g}=Qn(),[y,k]=m.useState(!1),[v,b]=m.useState(!1),[j,N]=m.useState(!1);if(m.useEffect(()=>{!o||!r||(t??null)!==(r.workspace??null)&&n(QA(r),{replace:!0})},[o,r,t,n]),!o)return s.jsx(bt,{label:"Loading view…"});if(i)return s.jsxs("div",{className:"rounded-lg border border-border/60 bg-card/85 px-4 py-6 text-sm",children:[s.jsx("p",{className:"font-medium text-foreground",children:"Couldn't load view"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i.message}),s.jsx("button",{type:"button",onClick:()=>a(),className:"shell-action mt-3",children:"Retry"})]});if(!r)return s.jsxs("div",{className:"space-y-3",children:[s.jsx(Rh,{title:"View not found",description:"This saved view no longer exists."}),s.jsxs(De,{to:Kp(t??null),className:"shell-action inline-flex items-center gap-1.5",children:[s.jsx(sh,{className:"h-4 w-4"})," Back to Saved Views"]})]});const S=r.workspace?bn(r.workspace):null;async function C(R,$){const P=r;try{await l(P,R,$),k(!1),h(`Updated view "${R}"`)}catch(F){throw h(F instanceof Error?F.message:"Failed to update saved view"),F}}async function D(){const R=r;try{await u(R),h(`Duplicated "${R.name}"`)}catch($){h($ instanceof Error?$.message:"Failed to duplicate saved view")}}async function T(){const R=r;N(!0);try{await f(R),b(!1),n(Kp(R.workspace))}catch($){h($ instanceof Error?$.message:"Failed to delete saved view")}finally{N(!1)}}return s.jsxs("div",{className:"space-y-4",children:[s.jsxs(De,{to:Kp(r.workspace),className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(sh,{className:"h-4 w-4"})," Saved Views"]}),s.jsx(Rh,{title:r.name,description:ZA(r.config.filters),actions:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border/70 bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:xle[r.config.viewMode]}),S?s.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border/70 bg-muted/60 px-2 py-0.5 text-xs text-muted-foreground",children:S}):null,s.jsx("button",{type:"button",onClick:()=>k(!0),className:"shell-action",children:"Edit"}),s.jsx("button",{type:"button",onClick:()=>void D(),className:"shell-action",children:"Duplicate"}),s.jsx("button",{type:"button",onClick:()=>n(JA(r)),className:"shell-action",children:"Open on board"}),s.jsx("button",{type:"button",onClick:()=>b(!0),className:"shell-action border-destructive/40 text-destructive hover:bg-destructive/10",children:"Delete"})]})}),s.jsx(KA,{view:r}),y?s.jsx(S$,{open:y,onOpenChange:k,workspace:r.workspace,initialView:r,onSubmit:C}):null,s.jsx(ss,{open:v,title:"Delete saved view?",description:`Delete '${r.name}'? Any Overview widgets referencing this view will become empty.`,confirmLabel:"Delete",loading:j,destructive:!0,onConfirm:T,onOpenChange:R=>{!R&&!j&&b(!1)}}),s.jsx(Xn,{toast:p,onDismiss:g})]})}function yle(){return s.jsx(DM,{children:s.jsx(Pz,{children:s.jsx(lM,{children:s.jsxs(Ye,{element:s.jsx(wB,{}),children:[s.jsx(Ye,{path:"/",element:s.jsx(y9,{})}),s.jsx(Ye,{path:"/inbox",element:s.jsx(N9,{})}),s.jsx(Ye,{path:"/projects",element:s.jsx(zS,{})}),s.jsx(Ye,{path:"/archive",element:s.jsx(W9,{})}),s.jsx(Ye,{path:"/assignments",element:s.jsx(XN,{})}),s.jsx(Ye,{path:"/assignments/new",element:s.jsx(eC,{})}),s.jsx(Ye,{path:"/assignments/:id",element:s.jsx(XY,{})}),s.jsx(Ye,{path:"/assignments/:id/edit",element:s.jsx(Hy,{})}),s.jsx(Ye,{path:"/assignments/:id/plan/edit",element:s.jsx(Vy,{})}),s.jsx(Ye,{path:"/assignments/:id/scratchpad/edit",element:s.jsx(Wy,{})}),s.jsx(Ye,{path:"/assignments/:id/handoff/edit",element:s.jsx(qy,{})}),s.jsx(Ye,{path:"/assignments/:id/decision-record/edit",element:s.jsx(Ky,{})}),s.jsx(Ye,{path:"/servers",element:s.jsx(nC,{})}),s.jsx(Ye,{path:"/inventories",element:s.jsx(rC,{})}),s.jsx(Ye,{path:"/schedules",element:s.jsx(HX,{})}),s.jsx(Ye,{path:"/usage",element:s.jsx(sC,{})}),s.jsx(Ye,{path:"/agent-sessions",element:s.jsx(oC,{})}),s.jsx(Ye,{path:"/playbooks",element:s.jsx(GX,{})}),s.jsx(Ye,{path:"/playbooks/create",element:s.jsx(XX,{})}),s.jsx(Ye,{path:"/playbooks/:slug",element:s.jsx(YX,{})}),s.jsx(Ye,{path:"/playbooks/:slug/edit",element:s.jsx(QX,{})}),s.jsx(Ye,{path:"/memories",element:s.jsx(JX,{})}),s.jsx(Ye,{path:"/memories/new",element:s.jsx(eQ,{})}),s.jsx(Ye,{path:"/projects/:slug/memories/:itemSlug",element:s.jsx(ZX,{})}),s.jsx(Ye,{path:"/projects/:slug/memories/:itemSlug/edit",element:s.jsx(tQ,{})}),s.jsx(Ye,{path:"/resources",element:s.jsx(nQ,{})}),s.jsx(Ye,{path:"/resources/new",element:s.jsx(sQ,{})}),s.jsx(Ye,{path:"/projects/:slug/resources/:itemSlug",element:s.jsx(rQ,{})}),s.jsx(Ye,{path:"/projects/:slug/resources/:itemSlug/edit",element:s.jsx(oQ,{})}),s.jsx(Ye,{path:"/todos",element:s.jsx(ole,{})}),s.jsx(Ye,{path:"/views",element:s.jsx(OE,{})}),s.jsx(Ye,{path:"/views/:id",element:s.jsx(FE,{})}),s.jsx(Ye,{path:"/help",element:s.jsx(D9,{})}),s.jsx(Ye,{path:"/settings",element:s.jsx(DQ,{})}),s.jsx(Ye,{path:"/workflow",element:s.jsx(sle,{})}),s.jsx(Ye,{path:"/create/project",element:s.jsx(JN,{})}),s.jsx(Ye,{path:"/projects/:slug",element:s.jsx(BN,{})}),s.jsx(Ye,{path:"/projects/:slug/edit",element:s.jsx(tC,{})}),s.jsx(Ye,{path:"/projects/:slug/create/assignment",element:s.jsx(ZN,{})}),s.jsx(Ye,{path:"/projects/:slug/assignments/:aslug",element:s.jsx(qN,{})}),s.jsx(Ye,{path:"/projects/:slug/assignments/:aslug/edit",element:s.jsx(Hy,{})}),s.jsx(Ye,{path:"/projects/:slug/assignments/:aslug/plan/edit",element:s.jsx(Vy,{})}),s.jsx(Ye,{path:"/projects/:slug/assignments/:aslug/scratchpad/edit",element:s.jsx(Wy,{})}),s.jsx(Ye,{path:"/projects/:slug/assignments/:aslug/handoff/edit",element:s.jsx(qy,{})}),s.jsx(Ye,{path:"/projects/:slug/assignments/:aslug/decision-record/edit",element:s.jsx(Ky,{})}),s.jsx(Ye,{path:"/w/:workspace/projects",element:s.jsx(zS,{})}),s.jsx(Ye,{path:"/w/:workspace/assignments",element:s.jsx(XN,{})}),s.jsx(Ye,{path:"/w/:workspace/assignments/new",element:s.jsx(eC,{})}),s.jsx(Ye,{path:"/w/:workspace/servers",element:s.jsx(nC,{})}),s.jsx(Ye,{path:"/w/:workspace/inventories",element:s.jsx(rC,{})}),s.jsx(Ye,{path:"/w/:workspace/usage",element:s.jsx(sC,{})}),s.jsx(Ye,{path:"/w/:workspace/agent-sessions",element:s.jsx(oC,{})}),s.jsx(Ye,{path:"/w/:workspace/todos",element:s.jsx(ule,{})}),s.jsx(Ye,{path:"/w/:workspace/views",element:s.jsx(OE,{})}),s.jsx(Ye,{path:"/w/:workspace/views/:id",element:s.jsx(FE,{})}),s.jsx(Ye,{path:"/w/:workspace/create/project",element:s.jsx(JN,{})}),s.jsx(Ye,{path:"/w/:workspace/projects/:slug",element:s.jsx(BN,{})}),s.jsx(Ye,{path:"/w/:workspace/projects/:slug/edit",element:s.jsx(tC,{})}),s.jsx(Ye,{path:"/w/:workspace/projects/:slug/create/assignment",element:s.jsx(ZN,{})}),s.jsx(Ye,{path:"/w/:workspace/projects/:slug/assignments/:aslug",element:s.jsx(qN,{})}),s.jsx(Ye,{path:"/w/:workspace/projects/:slug/assignments/:aslug/edit",element:s.jsx(Hy,{})}),s.jsx(Ye,{path:"/w/:workspace/projects/:slug/assignments/:aslug/plan/edit",element:s.jsx(Vy,{})}),s.jsx(Ye,{path:"/w/:workspace/projects/:slug/assignments/:aslug/scratchpad/edit",element:s.jsx(Wy,{})}),s.jsx(Ye,{path:"/w/:workspace/projects/:slug/assignments/:aslug/handoff/edit",element:s.jsx(qy,{})}),s.jsx(Ye,{path:"/w/:workspace/projects/:slug/assignments/:aslug/decision-record/edit",element:s.jsx(Ky,{})})]})})})})}k4();lL.createRoot(document.getElementById("root")).render(s.jsx(m.StrictMode,{children:s.jsx(S4,{children:s.jsx(yle,{})})}));export{Xd as C,jr as R,gV as _,Qu as a,vle as b,A0 as d,E3 as e,Cd as g,wle as h,Ws as i,A3 as n,mee as r,zr as s};